semiotic 3.8.0 → 3.8.2

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 (331) hide show
  1. package/CLAUDE.md +14 -9
  2. package/README.md +56 -55
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +240 -30
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +3 -2
  7. package/ai/system-prompt.md +7 -3
  8. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
  9. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  10. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  11. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  12. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  13. package/dist/chunk-chunk-27HVVXS6.module.min.js +1 -0
  14. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  15. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  16. package/dist/chunk-chunk-2UN3ANRN.module.min.js +2 -0
  17. package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
  18. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  19. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  20. package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
  21. package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
  22. package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
  23. package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
  24. package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
  25. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  26. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  27. package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
  28. package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
  29. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  30. package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
  31. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  32. package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
  33. package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
  34. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  35. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  36. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  37. package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
  38. package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
  39. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  40. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  41. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  42. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  43. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  44. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  45. package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
  46. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  47. package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
  48. package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
  49. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
  50. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  51. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  52. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  53. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  54. package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
  55. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  56. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  57. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  58. package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
  59. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  60. package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
  61. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
  62. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  63. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  64. package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
  65. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  66. package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
  67. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  68. package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
  69. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  70. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  71. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  72. package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
  73. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  74. package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
  75. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
  76. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  77. package/dist/components/AccessibleNavTree.d.ts +7 -1
  78. package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
  79. package/dist/components/ai/useNavigationSync.d.ts +17 -2
  80. package/dist/components/chartContainerMobile.d.ts +9 -0
  81. package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
  82. package/dist/components/charts/geo/DistanceCartogram.d.ts +14 -2
  83. package/dist/components/charts/geo/FlowMap.d.ts +10 -6
  84. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +14 -2
  85. package/dist/components/charts/index.d.ts +6 -0
  86. package/dist/components/charts/network/ChordDiagram.d.ts +9 -1
  87. package/dist/components/charts/network/ForceDirectedGraph.d.ts +11 -0
  88. package/dist/components/charts/network/SankeyDiagram.d.ts +9 -1
  89. package/dist/components/charts/ordinal/BarChart.d.ts +21 -0
  90. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +11 -0
  91. package/dist/components/charts/ordinal/StackedBarChart.d.ts +11 -0
  92. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +7 -0
  93. package/dist/components/charts/physics/EventDropChart.d.ts +7 -0
  94. package/dist/components/charts/physics/GaltonBoardChart.d.ts +8 -0
  95. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  96. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +4 -25
  97. package/dist/components/charts/physics/PhysicsPileChart.d.ts +7 -0
  98. package/dist/components/charts/physics/physicsChartShared.d.ts +17 -1
  99. package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
  100. package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
  101. package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
  102. package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
  103. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  104. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  105. package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
  106. package/dist/components/charts/shared/chartSpecCore.d.ts +3 -3
  107. package/dist/components/charts/shared/datumTypes.d.ts +2 -0
  108. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +2 -0
  109. package/dist/components/charts/shared/formatUtils.d.ts +3 -3
  110. package/dist/components/charts/shared/hatchFill.d.ts +87 -0
  111. package/dist/components/charts/shared/hooks.d.ts +7 -6
  112. package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
  113. package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
  114. package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
  115. package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
  116. package/dist/components/charts/shared/sparseArray.d.ts +1 -1
  117. package/dist/components/charts/shared/streamPropsHelpers.d.ts +6 -4
  118. package/dist/components/charts/shared/styleRules.d.ts +205 -0
  119. package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
  120. package/dist/components/charts/shared/types.d.ts +9 -6
  121. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
  122. package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
  123. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  124. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
  125. package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
  126. package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
  127. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +24 -1
  128. package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
  129. package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
  130. package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
  131. package/dist/components/charts/shared/validateChartData.d.ts +7 -5
  132. package/dist/components/charts/shared/validationMap.d.ts +11 -2
  133. package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
  134. package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
  135. package/dist/components/charts/value/targetPresentation.d.ts +22 -0
  136. package/dist/components/charts/value/types.d.ts +5 -6
  137. package/dist/components/charts/xy/AreaChart.d.ts +8 -0
  138. package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
  139. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
  140. package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
  141. package/dist/components/charts/xy/Heatmap.d.ts +2 -2
  142. package/dist/components/charts/xy/LineChart.d.ts +11 -0
  143. package/dist/components/charts/xy/QuadrantChart.d.ts +7 -0
  144. package/dist/components/charts/xy/Scatterplot.d.ts +10 -0
  145. package/dist/components/charts/xy/StackedAreaChart.d.ts +7 -0
  146. package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
  147. package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
  148. package/dist/components/controls/SentenceFilter.d.ts +97 -0
  149. package/dist/components/data/fromVegaLite.d.ts +19 -9
  150. package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
  151. package/dist/components/semiotic-ai.d.ts +3 -1
  152. package/dist/components/semiotic-controls.d.ts +2 -0
  153. package/dist/components/semiotic-geo.d.ts +4 -0
  154. package/dist/components/semiotic-network.d.ts +4 -0
  155. package/dist/components/semiotic-ordinal.d.ts +6 -0
  156. package/dist/components/semiotic-physics.d.ts +4 -0
  157. package/dist/components/semiotic-rough.d.ts +4 -0
  158. package/dist/components/semiotic-utils-core.d.ts +4 -0
  159. package/dist/components/semiotic-xy.d.ts +4 -0
  160. package/dist/components/semiotic.d.ts +9 -1
  161. package/dist/components/server/optionalImageTypes.d.ts +37 -0
  162. package/dist/components/server/serverChartConfigShared.d.ts +9 -5
  163. package/dist/components/server/serverChartConfigs.d.ts +4 -4
  164. package/dist/components/server/staticAnnotations.d.ts +6 -3
  165. package/dist/components/server/staticLegend.d.ts +1 -1
  166. package/dist/components/server/staticNetwork.d.ts +4 -4
  167. package/dist/components/server/staticSVGChrome.d.ts +5 -4
  168. package/dist/components/store/ObservationStore.d.ts +21 -1
  169. package/dist/components/stream/AccessibleDataTable.d.ts +4 -10
  170. package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
  171. package/dist/components/stream/CanvasHitTester.d.ts +4 -4
  172. package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
  173. package/dist/components/stream/FrameRuntime.d.ts +57 -0
  174. package/dist/components/stream/GeoParticlePool.d.ts +1 -1
  175. package/dist/components/stream/GeoPipelineStore.d.ts +43 -12
  176. package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
  177. package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
  178. package/dist/components/stream/NetworkPipelineStore.d.ts +24 -21
  179. package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
  180. package/dist/components/stream/NetworkSVGOverlay.d.ts +6 -0
  181. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  182. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  183. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
  184. package/dist/components/stream/OrdinalPipelineStore.d.ts +13 -13
  185. package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
  186. package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
  187. package/dist/components/stream/ParticlePool.d.ts +1 -1
  188. package/dist/components/stream/PipelineStore.d.ts +12 -16
  189. package/dist/components/stream/SVGOverlay.d.ts +6 -0
  190. package/dist/components/stream/SceneGraph.d.ts +3 -3
  191. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  192. package/dist/components/stream/accessorUtils.d.ts +2 -2
  193. package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
  194. package/dist/components/stream/frameGraphics.d.ts +4 -0
  195. package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
  196. package/dist/components/stream/geoPipelineHelpers.d.ts +3 -3
  197. package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
  198. package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
  199. package/dist/components/stream/geoTypes.d.ts +48 -15
  200. package/dist/components/stream/hitTestUtils.d.ts +2 -2
  201. package/dist/components/stream/hoverUtils.d.ts +4 -2
  202. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +1 -0
  203. package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
  204. package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
  205. package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
  206. package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
  207. package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
  208. package/dist/components/stream/networkFrameObservations.d.ts +15 -0
  209. package/dist/components/stream/networkFramePaint.d.ts +11 -2
  210. package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
  211. package/dist/components/stream/networkPipelineConfig.d.ts +2 -2
  212. package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
  213. package/dist/components/stream/networkTypes.d.ts +37 -56
  214. package/dist/components/stream/ordinalCanvasRenderers.d.ts +2 -2
  215. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +20 -1
  216. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
  217. package/dist/components/stream/ordinalTypes.d.ts +30 -3
  218. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +2 -0
  219. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +6 -0
  220. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +21 -6
  221. package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
  222. package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
  223. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +19 -1
  224. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +3 -1
  225. package/dist/components/stream/pipelineConfig.d.ts +4 -2
  226. package/dist/components/stream/pipelineDecay.d.ts +2 -2
  227. package/dist/components/stream/pipelinePulse.d.ts +2 -2
  228. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +23 -2
  229. package/dist/components/stream/pipelineTransitions.d.ts +1 -1
  230. package/dist/components/stream/pipelineUpdateContract.d.ts +7 -0
  231. package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
  232. package/dist/components/stream/renderBackend.d.ts +27 -0
  233. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
  234. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
  235. package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
  236. package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
  237. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +31 -4
  238. package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
  239. package/dist/components/stream/streamThemeTypes.d.ts +14 -0
  240. package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
  241. package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
  242. package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
  243. package/dist/components/stream/titleLayout.d.ts +31 -0
  244. package/dist/components/stream/types.d.ts +30 -65
  245. package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
  246. package/dist/components/stream/useFrame.d.ts +23 -0
  247. package/dist/components/stream/useLegendCategoryEmission.d.ts +3 -3
  248. package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
  249. package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
  250. package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
  251. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -5
  252. package/dist/controls.min.js +1 -1
  253. package/dist/controls.module.min.js +1 -1
  254. package/dist/forceLayoutWorker.js +1 -1
  255. package/dist/geo.min.js +1 -1
  256. package/dist/geo.module.min.js +1 -1
  257. package/dist/network.min.js +1 -1
  258. package/dist/network.module.min.js +1 -1
  259. package/dist/ordinal.min.js +1 -1
  260. package/dist/ordinal.module.min.js +1 -1
  261. package/dist/physics-matter.min.js +1 -1
  262. package/dist/physics-matter.module.min.js +1 -1
  263. package/dist/physics-rapier.min.js +1 -1
  264. package/dist/physics-rapier.module.min.js +1 -1
  265. package/dist/physics.min.js +1 -1
  266. package/dist/physics.module.min.js +1 -1
  267. package/dist/physicsWorker.js +1 -1
  268. package/dist/realtime.min.js +1 -1
  269. package/dist/realtime.module.min.js +1 -1
  270. package/dist/rough.min.js +1 -0
  271. package/dist/rough.module.min.js +1 -0
  272. package/dist/semiotic-ai-core.min.js +1 -1
  273. package/dist/semiotic-ai-core.module.min.js +1 -1
  274. package/dist/semiotic-ai.d.ts +3 -1
  275. package/dist/semiotic-ai.min.js +1 -1
  276. package/dist/semiotic-ai.module.min.js +1 -1
  277. package/dist/semiotic-controls.d.ts +2 -0
  278. package/dist/semiotic-data.min.js +1 -1
  279. package/dist/semiotic-data.module.min.js +1 -1
  280. package/dist/semiotic-experimental.min.js +1 -1
  281. package/dist/semiotic-experimental.module.min.js +1 -1
  282. package/dist/semiotic-geo.d.ts +4 -0
  283. package/dist/semiotic-network.d.ts +4 -0
  284. package/dist/semiotic-ordinal.d.ts +6 -0
  285. package/dist/semiotic-physics.d.ts +4 -0
  286. package/dist/semiotic-realtime-core.min.js +1 -1
  287. package/dist/semiotic-realtime-core.module.min.js +1 -1
  288. package/dist/semiotic-realtime-react.min.js +1 -1
  289. package/dist/semiotic-realtime-react.module.min.js +1 -1
  290. package/dist/semiotic-recipes-core.min.js +1 -1
  291. package/dist/semiotic-recipes-core.module.min.js +1 -1
  292. package/dist/semiotic-recipes-react.min.js +1 -1
  293. package/dist/semiotic-recipes-react.module.min.js +1 -1
  294. package/dist/semiotic-recipes.min.js +1 -1
  295. package/dist/semiotic-recipes.module.min.js +1 -1
  296. package/dist/semiotic-rough.d.ts +4 -0
  297. package/dist/semiotic-server-edge.min.js +1 -1
  298. package/dist/semiotic-server-edge.module.min.js +1 -1
  299. package/dist/semiotic-server-node.min.js +1 -1
  300. package/dist/semiotic-server-node.module.min.js +1 -1
  301. package/dist/semiotic-themes-core.min.js +1 -1
  302. package/dist/semiotic-themes-core.module.min.js +1 -1
  303. package/dist/semiotic-themes-react.min.js +1 -1
  304. package/dist/semiotic-themes-react.module.min.js +1 -1
  305. package/dist/semiotic-themes.min.js +1 -1
  306. package/dist/semiotic-themes.module.min.js +1 -1
  307. package/dist/semiotic-utils-core.d.ts +4 -0
  308. package/dist/semiotic-utils-core.min.js +1 -1
  309. package/dist/semiotic-utils-core.module.min.js +1 -1
  310. package/dist/semiotic-utils-react.min.js +1 -1
  311. package/dist/semiotic-utils-react.module.min.js +1 -1
  312. package/dist/semiotic-utils.min.js +1 -1
  313. package/dist/semiotic-utils.module.min.js +1 -1
  314. package/dist/semiotic-value.min.js +1 -1
  315. package/dist/semiotic-value.module.min.js +1 -1
  316. package/dist/semiotic-xy.d.ts +4 -0
  317. package/dist/semiotic.d.ts +9 -1
  318. package/dist/semiotic.min.js +1 -1
  319. package/dist/semiotic.module.min.js +1 -1
  320. package/dist/server.min.js +1 -1
  321. package/dist/server.module.min.js +1 -1
  322. package/dist/test-utils/capturedFrameProps.d.ts +67 -0
  323. package/dist/test-utils/frameMock.d.ts +12 -9
  324. package/dist/xy.min.js +1 -1
  325. package/dist/xy.module.min.js +1 -1
  326. package/package.json +29 -10
  327. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  328. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  329. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  330. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  331. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{getMax as e,getMin as t,getMinMax as o}from"./semiotic-ai-chunk-OG7BQUUW.module.min.js";import{useMemo as r,useCallback as n,useState as i,useEffect as a,forwardRef as s,useRef as l}from"react";var c=Object.freeze([]);function u(e){if(!e)return c;let t=!1;for(let o=0;e.length>o;o++){const r=e[o];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const o=[];for(const t of e)null!=t&&"object"==typeof t&&o.push(t);return o}import*as d from"react";import{useRef as h,useState as p,useEffect as m,useMemo as f,useCallback as g,useImperativeHandle as y,useId as b,forwardRef as v,memo as x}from"react";import{useRef as w,useEffect as k,useMemo as S}from"react";import{select as A}from"d3-selection";import{brush as C,brushX as M,brushY as P}from"d3-brush";import*as I from"react";function _({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:o}={}){const r=I.useId().replace(/:/g,""),n=I.useRef(o);return n.current=o,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:I.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),n.current?.(t))},[])}}}import{jsx as L,jsxs as R}from"react/jsx-runtime";function T(e,t,o,r){const[n,i]=[Math.min(...t),Math.max(...t)],a=(i-n)/20;let[s,l]=e;if(r)0>o?s=Math.max(n,s-a):l=Math.min(i,l+a);else{const e=l-s;s=Math.max(n,Math.min(i-e,s+o*a)),l=s+e}return[s,l]}function N(e,t){let o=0,r=t.length-1;for(;r>o;){const n=o+r+1>>1;t[n]>e?r=n-1:o=n}return t[o]}function $(e,t){let o=0,r=t.length-1;for(;r>o;){const n=o+r>>1;e>t[n]?o=n+1:r=n}return t[o]}function B({width:e,height:t,totalWidth:o,totalHeight:r,margin:n,dimension:i,scales:a,onBrush:s,binSize:l,snap:c,binBoundaries:u,snapDuring:d,streaming:h}){const p=w(null),m=w(null),f=w(s);f.current=s;const g=w(a);g.current=a;const y=S(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),b=w(y);b.current=y;const v=w(!1),x=w(null),I=_({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=g.current,o=m.current;if(!t||!o||!p.current)return;const r=A(p.current).select(".brush-g");if("clear"===e.type)return v.current=!0,r.call(o.move,null),v.current=!1,x.current=null,void f.current(null);const n=t.x.domain(),a=t.y.domain(),s=x.current;let l=s?.x??[n[0]+.4*(n[1]-n[0]),n[0]+.6*(n[1]-n[0])],c=s?.y??[a[0]+.4*(a[1]-a[0]),a[0]+.6*(a[1]-a[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==i&&(l=T(l,n,d,e.resize)),u||"x"===i||(c=T(c,a,d,e.resize)),u&&"y"===i||!u&&"x"===i)return;const h={x:l,y:c};v.current=!0,r.call(o.move,"x"===i?[t.x(l[0]),t.x(l[1])]:"y"===i?[t.y(c[1]),t.y(c[0])]:[[t.x(l[0]),t.y(c[1])],[t.x(l[1]),t.y(c[0])]]),v.current=!1,x.current=h,f.current(h)}});return k(()=>{if(!p.current)return;const o=A(p.current).select(".brush-g"),r="x"===i?M():"y"===i?P():C();return r.extent([[0,0],[e,t]]),r.on("brush end",n=>{if(v.current)return;const a=g.current;if(!a)return;if(!n.selection)return x.current=null,void f.current(null);let s,u;if("x"===i){const[e,o]=n.selection;s=[a.x.invert(e),a.x.invert(o)],u=[a.y.invert(t),a.y.invert(0)]}else if("y"===i){const[t,o]=n.selection;s=[a.x.invert(0),a.x.invert(e)],u=[a.y.invert(o),a.y.invert(t)]}else{const[[e,t],[o,r]]=n.selection;s=[a.x.invert(e),a.x.invert(o)],u=[a.y.invert(r),a.y.invert(t)]}if("bin"===c&&"y"!==i&&("end"===n.type||"brush"===n.type&&d)){const e=b.current;e&&e.length>0?s=function(e,t){return 0===t.length?e:[N(e[0],t),$(e[1],t)]}(s,e):l&&l>0&&(s=[Math.floor(s[0]/l)*l,Math.ceil(s[1]/l)*l]);const t=a.x(s[0]),c=a.x(s[1]);if(v.current=!0,"x"===i)o.call(r.move,[t,c]);else if("xy"===i){const e=n.selection;o.call(r.move,[[t,e[0][1]],[c,e[1][1]]])}v.current=!1}const h={x:s,y:u};x.current=h,f.current(h)}),o.call(r),m.current=r,o.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),m.current=null}},[e,t,i,c,l,d]),k(()=>{if(!(h&&a&&m.current&&x.current))return;if(!p.current)return;if("y"===i)return;const e=x.current,t=a.x.domain()[0],o=A(p.current).select(".brush-g");if(t>=e.x[1])return v.current=!0,o.call(m.current.move,null),v.current=!1,x.current=null,void f.current(null);let r=e.x[0],n=!1;if(t>e.x[0]){if(r=t,"bin"===c){const e=b.current;e&&e.length>0?r=$(t,e):l&&l>0&&(r=Math.ceil(t/l)*l)}if(r>=e.x[1])return v.current=!0,o.call(m.current.move,null),v.current=!1,x.current=null,void f.current(null);n=!0}const s=a.x(r),u=a.x(e.x[1]);if(v.current=!0,"x"===i)o.call(m.current.move,[s,u]);else{const t=a.y(e.y[1]),r=a.y(e.y[0]);o.call(m.current.move,[[s,t],[u,r]])}if(v.current=!1,n){const t={x:[r,e.x[1]],y:e.y};x.current=t,f.current(t)}},[a,h,i,c,l]),R("svg",{ref:p,width:o,height:r,...I.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[L("title",{children:I.svgProps["aria-label"]}),L("desc",{id:I.descriptionId,children:I.description}),L("g",{className:"brush-g",transform:`translate(${n.left},${n.top})`})]})}var D=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=u(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}setReplacementData(e){if(e=u(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let o=0;e.length>o;o++){const r=e[o];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import{createContext as F,useCallback as E,useContext as z,useMemo as j,useRef as O,useSyncExternalStore as H}from"react";import{jsx as W}from"react/jsx-runtime";function q(e){let t=null;const o=()=>(t||(t=F(null)),t),r=G(e);return[function({children:t,initialState:r}){const n=O(r),i=j(()=>G(e,n.current),[]),a=o();return W(a.Provider,{value:i,children:t})},(e,t)=>{const n=o(),i=z(n)??r,a=O(e);a.current=e;const s=O({hasValue:!1,value:void 0}),l=E(()=>{const e=a.current(i.getState()),o=s.current;return o.hasValue&&t&&t(o.value,e)?o.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=E(()=>a.current(i.getState()),[i]);return H(i.subscribe,l,c)}]}function G(e,t){const o=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of o)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return o.add(e),()=>{o.delete(e)}}}}function Y(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function V(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:X}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var X=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],U={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},K={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Q={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:X,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Z(e,t){if("light"===t)return U;if("dark"===t)return K;if("high-contrast"===t)return Q;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?K:U;return V({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return V({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[J,ee]=q(e=>({theme:U,setTheme(t){e(e=>({theme:Z(e.theme,t)}))}})),te=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const o of e){const e=this.push(o);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e(this.buffer[(t+o)%this._capacity],o)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e[o]=this.buffer[(t+o)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let o=0,r=[];t.length>e&&(o=t.length-e,r=t.slice(0,o)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=o;t.length>e;e++)this.push(t[e]);return r}update(e,t){const o=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++){const i=(r+n)%this._capacity,a=this.buffer[i];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},o.push(e),this.buffer[i]=t(a)}}return o}remove(e){const t=[],o=[];if(this.forEach(r=>{e(r)?o.push(r):t.push(r)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return o}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},oe=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isFinite(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 re(e,t){return e===t}function ne(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function ie(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function ae(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var se=/^\d{4}-\d{1,2}$/;function le(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const o=se.test(t)?t+"-01":t;if(o===t&&10>t.length)return NaN;const r=Date.parse(o);return Number.isFinite(r)?r:NaN}function ce(e){return e instanceof Date?e.getTime():"string"==typeof e?le(e):+e}function ue(e){return new Set(Array.isArray(e)?e:[e])}import{scaleOrdinal as de}from"d3-scale";function he(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function pe(e,t,o){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(o)}`}function me(e){const t=e.map(he),o=t.length-1;return e=>{if(0>=e){const[e,o,r]=t[0];return pe(e,o,r)}if(e>=1){const[e,r,n]=t[o];return pe(e,r,n)}const r=e*o,n=Math.floor(r),i=r-n,[a,s,l]=t[n],[c,u,d]=t[n+1];return pe(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var fe=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ge=me(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ye=me(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),be=me(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ve=me(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),xe=me(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),we=me(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ke=me(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Se=me(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Ae=me(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Ce=me(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Me=me(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Pe=me(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Ie={blues:ge,reds:ye,greens:be,viridis:ke,oranges:ve,purples:xe,greys:we,plasma:Se,inferno:Ae,magma:Ce,cividis:Me,turbo:Pe};function _e(e){return e&&Ie[e]||ge}var Le=me(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Re=me(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Te=me(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Ne=me(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),$e=me(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Be=me(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),De=me(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Fe={category10:fe,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Ie},Ee=fe,ze=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],je=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Oe=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function He(e,t,o){if("function"==typeof t){const r=t(e);return o&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Oe.has(t)}(r)?o(r):r}const r=e?.[t]+"";return o?o(r):Ee[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(r))%Ee.length]}function We(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const o=e[t];return"string"==typeof o&&o.length>0?o:void 0}function qe(e,t,o="category10"){if(o&&"object"==typeof o&&!Array.isArray(o)){const e=o;return t=>We(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),n=r.every(e=>!isNaN(Number(e)));if(Array.isArray(o))return de().domain(r).range(o).unknown("#999");const i=Fe[o]||Fe.category10;if(n&&"function"==typeof i){let e=-1/0;for(const t of r){const o=Number(t);o>e&&(e=o)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Ee;return de().domain(r).range(e).unknown("#999")}}function Ge(e,t,o=[3,20],r){let n;if(n="function"==typeof t?t(e):e?.[t],!r)return n;const[i,a]=r,[s,l]=o;if(a===i)return(s+l)/2;let c=(n-i)/(a-i);return 0>c?c=0:c>1&&(c=1),s+c*(l-s)}function Ye(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Ve(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Xe(e,t,o){return e+(t-e)*o}function Ue(){return"undefined"!=typeof performance?performance.now():Date.now()}var Ke={fresh:1,aging:1.5,stale:3};function Qe(e,t,o={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(o.fresh??1)>e?"fresh":t*(o.aging??1.5)>e?"aging":t*(o.stale??3)>e?"stale":"expired":"fresh"}function Ze(e,t,o){if(1>=o)return 1;const r=o-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const o=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>o?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,o/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-o/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??o/2,threshold:e.stepThreshold??.5*o,minOpacity:e.minOpacity??.1})}function Je(e){const t=new Map;for(let o=0;e.length>o;o++)t.set(e[o],o);return t}function et(e,t,o){const r=e.duration??500,n=o-t;return r>n?1-n/r:0}function tt(e,t,o,r){let n=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,n=!0),e._pulseColor!==o&&(e._pulseColor=o,n=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,n=!0),n):(0!==e._pulseIntensity&&(e._pulseIntensity=0,n=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,n=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,n=!0),n)}function ot(e,t,o=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,n=t.peek();return null!=n&&r>o-n}function rt(e,t,o){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const o=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${o}:${r}`;if(null!=o&&null!=r)return`p:${o}:${r}`}return"p:"+o;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+o;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??o}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+o:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function nt(e,t,o,r,n,i){const a=[];for(const n of e){const e=o(n),i=r(n);Number.isFinite(e)&&Number.isFinite(i)&&a.push({px:t.x(e),py:t.y(i),rawY:i,d:n})}a.sort((e,t)=>e.px-t.px);const s=Array(a.length),l=Array(a.length),c=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];s[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:s,rawValues:l,style:n,datum:c,group:i}}function it(e,t,o,r,n,i,a,s){const l=[];for(const i of e){const e=o(i),a=r(i);if(!Number.isFinite(e)||!Number.isFinite(a))continue;const c=t.x(e),u=s?s(i):n;l.push({px:c,topY:t.y(a),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:a}}function at(e,t,o,r){const n=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const n of t)e+=o(n,r)||0;n.set(r,-e/2)}else if("wiggle"===r){e.length>0&&n.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],a=e[r];let s=0,l=0,c=0;for(const e of t){const t=o(e,a)||0;s+=(2*c+t)*(t-(o(e,i)||0)),l+=t,c+=t}const u=n.get(i)??0;n.set(a,u-(l>0?s/(2*l):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=o(r,i)||0;r+=(n.get(i)??0)+e/2}const i=r/e.length;for(const t of e)n.set(t,(n.get(t)??0)-i)}}else for(const t of e)n.set(t,0);return n}function st(e,t,o,r,n,i,a){const s=o(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;const c={type:"point",x:t.x(s),y:t.y(l),r:n,style:i,datum:e};return void 0!==a&&(c.pointId=a),c}function lt(e,t,o,r,n,i,a,s){const l=o(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:t.x(l),y:t.y(c),size:n,symbolType:i,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function ct(e,t,o,r,n,i,a){return{type:"rect",x:e,y:t,w:o,h:r,style:n,datum:i,group:a}}function ut(e,t,o,r,n,i,a){const s={type:"heatcell",x:e,y:t,w:o,h:r,fill:n,datum:i};return a?.showValues&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function dt(e,t,o,r){return"function"==typeof t.style?t.style(r||{},o):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(o,r)}function ht(e,t,o,r){if(!e.scales)return null;const n=[],i=[];for(const o of t){const t=e.getX(o);if(!Number.isFinite(t))continue;const a=r.getTop(o),s=r.getBottom(o);if(!Number.isFinite(a)||!Number.isFinite(s))continue;const l=e.scales.x(t),c=e.scales.y(a),u=e.scales.y(s);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(n.push([l,c]),i.push([l,u]))}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:dt(e,r,o,t[0]),datum:t,group:o,interactive:r.interactive}}function pt(e){const t=[],o=[];if(!e)return{perSeries:t,aggregate:o};for(const r of e)r.perSeries?t.push(r):o.push(r);return{perSeries:t,aggregate:o}}function mt(e,t,o){const r=[];for(const n of o){const o=ht(e,t,"__ribbon_aggregate",n);o&&r.push(o)}return r}function ft(e,t,o,r){const n=[];for(const i of r){const r=ht(e,t,o,i);r&&n.push(r)}return n}function gt(e,t){if(!e)return{};if(!t||0===t.length)return e;const o=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),n=r.getBottom(e);Number.isFinite(n)&&Number.isFinite(t)&&o.push({y0:n,y1:t})}return 0===o.length?e:{...e,band:o[0],bands:o}}function yt(e,t,o,r){if(!e.config.pointStyle)return;const n=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const a=r.r??3,s=e.getPointId?e.getPointId(i)+"":void 0,l=st(i,e.scales,e.getX,n,a,r,s);l&&o.push(l)}}}var bt={topOpacity:.8,bottomOpacity:.05};function vt(e){if(e)return!0===e?bt:"colorStops"in e?e:{topOpacity:e.topOpacity??bt.topOpacity,bottomOpacity:e.bottomOpacity??bt.bottomOpacity}}import{symbol as xt,symbolCircle as wt,symbolCross as kt,symbolDiamond as St,symbolSquare as At,symbolStar as Ct,symbolTriangle as Mt,symbolWye as Pt}from"d3-shape";var It={circle:wt,square:At,triangle:Mt,diamond:St,star:Ct,cross:kt,wye:Pt},_t=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Lt(e,t,o){if(o)return o;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*Rt(e),o=.92*t;return`M0,${-t}L${o},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-o},${(.78*t).toFixed(3)}Z`}(t):xt(It[r]??wt,Math.max(1,t))()??""}function Rt(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var Tt=new Map;function Nt(e,t,o,r,n){const i=new Map;for(const a of e){const e=t(a),s=o(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const l=Math.floor(e/r)*r;let c=i.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},i.set(l,c)),c.total+=s,n){const e=n(a);c.categories.set(e,(c.categories.get(e)||0)+s)}}return i}function $t(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:o,overlays:r,warned:n}=e;Bt(r)&&0===o.length&&Dt(n,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),o.length>0&&o.every(e=>null==e.datum)&&Dt(n,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Bt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Bt))}function Dt(e,t,o){e.has(t)||(e.add(t),console.warn(o))}function Ft(e,t,o,r){const n=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${n.message}`,error:n,recovery:o?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:o,affectedRevision:r}}function Et(e,t){const o="function"==typeof e?e:o=>o[e||t];return e=>{const t=o(e);return null==t?NaN:+t}}function zt(e){const t=[],o=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=Et(o&&e.valueAccessor||e.yAccessor,o?"value":"y");if(e.boundsAccessor){const o=ne(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const n=o(e);return Number.isFinite(n)&&0!==n?t+n:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const n=o(e);return Number.isFinite(n)&&0!==n?t-n:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const o=Array.isArray(e.band)?e.band:[e.band];for(const e of o)t.push({kind:"band",getTop:Et(e.y1Accessor,"y1"),getBottom:Et(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as jt,scaleLog as Ot,scaleSymlog as Ht,scaleTime as Wt}from"d3-scale";function qt(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Gt(e,t,o){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return Ot().domain(e).range(o).clamp(!0)}return"symlog"===e?Ht().domain(t).range(o):"time"===e?Wt().domain([new Date(t[0]),new Date(t[1])]).range(o):jt().domain(t).range(o)}function Yt(e,t,o){t>e.capacity&&(e.resize(t),o&&t>o.capacity&&o.resize(t))}function Vt(e,t){const o=new te(e.capacity);return e.forEach(()=>o.push(t)),o}function Xt(e,t,o,r){const n=e.push(t);return o&&o.push(r),n}function Ut(e,t,o){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{o(e)&&r.add(t)}),0===r.size)return;const n=t.toArray();t.clear();for(let e=0;n.length>e;e++)r.has(e)||t.push(n[e])}var Kt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Qt(e,t){const o={...e};for(const e of t)o[Kt[e]]++;return o}function Zt(e,t,o){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Qt(o,r)}}var Jt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Zt({kind:"initialize"},[],this.revisions)}get last(){return this.latest}record(e,t){const o=Zt(e,t,this.revisions);return this.revisions=o.revisions,this.latest=o,o}},eo=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],to=["scene-style","data-paint","accessibility","evidence"],oo=new Set(["lineStyle","pointStyle","areaStyle","barStyle","swarmStyle","waterfallStyle","candlestickStyle","boundsStyle","colorScheme","themeCategorical","themeSemantic","barColors"]),ro=class{constructor(){this.tracker=new Jt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},eo)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},to):this.recordNoop("restyle")}recordConfig(e,t,o){return this.tracker.record({kind:"config",keys:e},t?function(e,t){const o=new Set(["layout","scene-geometry","data-paint","overlay","accessibility","evidence"]);return t&&o.add("domain"),e.some(e=>oo.has(e))&&o.add("scene-style"),o}(e,o):[])}};import{quadtree as no}from"d3-quadtree";var io=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let o=0,r=0;for(const e of t)"point"===e.type&&(o++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=o)return void(this.tree=null);const n=Array(o);let i=0;for(const e of t)"point"===e.type&&(n[i++]=e);this.tree=no().x(e=>e.x).y(e=>e.y).addAll(n)}},ao=class e{constructor(e){if(this.xExtent=new oe,this.yExtent=new oe,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new ro,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new io,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,o)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,r,n,i=("undefined"!=typeof performance?performance.now():Date.now())){const a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4;let l=!1;const c=n??(()=>{const e=new Map;for(let t=0;o.length>t;t++)e.set(o[t],t);return e})();for(const o of t){if("line"===o.type)continue;if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[o.datum];let n=0,s=!1;for(const o of t){const t=c.get(o);if(null==t)continue;s=!0;const a=r.get(t);if(null==a)continue;const l=et(e,a,i);l>n&&(n=l)}s&&(l=tt(o,n,a)||l);continue}const t=c.get(o.datum);if(null==t)continue;const n=r.get(t);l=tt(o,null==n?0:et(e,n,i),a,s)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),o),this._stylePaintPending=!1,this.config=e,this.buffer=new te(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=ne(e.timeAccessor||e.xAccessor,"time"),this.getY=ne(e.valueAccessor||e.yAccessor,"value")):(this.getX=ne(e.xAccessor,"x"),this.getY=ne(e.yAccessor,"y")),this.getGroup=ae(e.groupAccessor),this.getCategory=ae(e.categoryAccessor),this.getSize=e.sizeAccessor?ne(e.sizeAccessor,"size"):void 0,this.getColor=ae(e.colorAccessor),this.getSymbol=ae(e.symbolAccessor),this.getY0=e.y0Accessor?ne(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=zt(e),this.getPointId=ae(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,o=null!=e.closeAccessor;this.getOpen=t?ne(e.openAccessor,"open"):void 0,this.getHigh=ne(e.highAccessor,"high"),this.getLow=ne(e.lowAccessor,"low"),this.getClose=o?ne(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!o}e.pulse&&(this.timestampBuffer=new te(e.windowSize))}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Vt(this.buffer,Ue())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),r=t.getBottom(e);Number.isFinite(o)&&this.yExtent.push(o),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),r=t.getBottom(e);Number.isFinite(o)&&this.yExtent.evict(o),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=Ue();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=o?ne(this.config.timeAccessor||this.config.xAccessor,"time"):ne(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],o=this.config.xAccessor,r="function"==typeof o?o(t):t[o||"x"],n=r instanceof Date,i="string"==typeof r&&Number.isFinite(le(r));if(this.xIsDate=n||i,i){const e="string"==typeof o?o:void 0;this.getX=e?t=>ce(t[e]):e=>ce(o(e))}}Yt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)Xt(this.buffer,o,this.timestampBuffer,t),this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o)}else for(const o of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Xt(this.buffer,o,this.timestampBuffer,t);this.xExtent.push(this.getX(o)),this.pushDatumYExtent(o),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:o}=this,r=this.scales,n=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(o,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),a=this.yExtent.extent;let s=qt(this.xExtent.extent,t.xExtent),l=qt(a,t.yExtent);const c=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!c&&o.size>0){const e=function(e){const{config:t,groups:o,getX:r,getY:n}=e,i="exact"===t.axisExtent;if(t.normalize){const o=[0,i?1:1+t.extentPadding];return{yDomain:o,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:o}}}const a=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===a)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const s=new Map,l=new Set;let c=0;const u=new Map,d=new Map;for(const e of o){const t=new Map;let o=0;for(const i of e.data){const e=r(i),a=n(i);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),l.add(e),o+=a;const s=(u.get(e)||0)+a;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,o)}const h=t.stackOrder??"key",p=(e,t)=>t>e?-1:e>t?1:0;let m,f;if("input"===h)m=o.map(e=>e.key);else if("insideOut"===h){const e=[...o].map(e=>e.key).sort((e,t)=>{const o=(d.get(t)??0)-(d.get(e)??0);return 0!==o?o:p(e,t)}),t=[],r=[];let n=0,i=0;for(const o of e)i>n?(t.push(o),n+=d.get(o)??0):(r.push(o),i+=d.get(o)??0);m=[...r.reverse(),...t]}else m="asc"===h?o.map(e=>e.key).sort((e,t)=>{const o=(d.get(e)??0)-(d.get(t)??0);return 0!==o?o:p(e,t)}):"desc"===h?o.map(e=>e.key).sort((e,t)=>{const o=(d.get(t)??0)-(d.get(e)??0);return 0!==o?o:p(e,t)}):o.map(e=>e.key).sort(p);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),o=at(e,m,(e,t)=>s.get(e)?.get(t)||0,t.baseline);let r=1/0,n=-1/0;for(const t of e){const e=o.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>n&&(n=e+i)}Number.isFinite(r)&&Number.isFinite(n)||(r=0,n=0);const a=n-r,c=i?0:a>0?a*t.extentPadding:1;f=[r-c,n+c]}else if("diverging"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),[o,r]=function(e,t,o){let r=0,n=0;for(const i of e){let e=0,a=0;for(const r of t){const t=o(r,i)||0;0>t?a+=t:e+=t}r>a&&(r=a),e>n&&(n=e)}return[r,n]}(e,m,(e,t)=>s.get(e)?.get(t)||0),n=r-o,a=i?0:n>0?n*t.extentPadding:1;f=[o-a,r+a]}else f=[0,c+(i?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:a,yDomain:f}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:o.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!c&&o.size>0?l=function(e,t,o,r,n,i,a){const[,s]=function(e,t,o,r,n){const i=Nt(e,t,o,r,n);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(e,t,o,r,n);return[0,a?s:s+s*i]}(o,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!c&&o.size>0?l=function(e,t,o,r){const[n,i]=function(e,t){let o=0,r=0,n=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(n+=e,o>n&&(o=n),n>r&&(r=n))}return[o,r]}(e,t),a=i-n,s=r?0:a>0?a*o:1;return[Math.min(0,n-Math.abs(s)),Math.max(0,i+Math.abs(s))]}(o,this.getY,t.extentPadding,d):c||l[0]===1/0||(l=function(e,t,o){if(!o.length)return e;let[r,n]=e;for(const e of t)for(const t of o){const o=t.getTop(e),i=t.getBottom(e);Number.isFinite(o)&&(r>o&&(r=o),o>n&&(n=o)),Number.isFinite(i)&&(r>i&&(r=i),i>n&&(n=i))}return[r,n]}(l,i,this.resolvedRibbons),l=function(e,t){const o=e[1]-e[0],r=t.exactMode?0:o>0?o*t.extentPadding:1,n=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||n[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(n[0]=t.dataYDomain[0]/(1+t.extentPadding)),n}(l,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));l=function(e,t,o){if(!t||o)return e;const r=t[0],n=t[1];return null==r&&null==n?e:[null!=r?r:e[0],null!=n?n:e[1]]}(l,t.yExtent,!!c),({xDomain:s,yDomain:l}=function(e,t,o){let r=e,n=t;if(r[0]===1/0||r[1]===-1/0)if("time"===o){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:r,yDomain:n}}(s,l,t.xScaleType)),this.scales=function(e){const{config:t,layout:o,xDomain:r,yDomain:n}=e,i="streaming"===t.runtimeMode,a=Math.max(0,Math.min(t.scalePadding||0,Math.min(o.width,o.height)/2-1));if(i){if("x"==("up"===(s=t.arrowOfTime)||"down"===s?"y":"x")){const e="right"===t.arrowOfTime?[a,o.width-a]:[o.width-a,a];return{x:jt().domain(r).range(e),y:Gt(t.yScaleType,n,[o.height-a,a])}}const e="down"===t.arrowOfTime?[a,o.height-a]:[o.height-a,a];return{x:Gt(t.yScaleType,n,[a,o.width-a]),y:jt().domain(r).range(e)}}var s;return{x:Gt(t.xScaleType,r,[a,o.width-a]),y:Gt(t.yScaleType,n,[o.height-a,a])}}({config:t,layout:e,xDomain:s,yDomain:l}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=n):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=h,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,o=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=o;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=o;for(const r of e.bottomPath)r[0]*=t,r[1]*=o;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*o,width:e.clipRect.width*t,height:e.clipRect.height*o});break;case"point":case"glyph":e.x*=t,e.y*=o;break;case"rect":case"heatcell":e.x*=t,e.y*=o,e.w*=t,e.h*=o;break;case"candlestick":e.x*=t,e.openY*=o,e.closeY*=o,e.highY*=o,e.lowY*=o}const r=this.scales.x.domain(),n=this.scales.y.domain(),i=this.scales.x.range(),a=this.scales.y.range(),s=Gt,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=a[1]>a[0];this.scales={x:s(this.config.xScaleType,r,i[0]>i[1]?[e.width-l,l]:[l,e.width-l]),y:s(this.config.yScaleType,n,c?[l,e.height-l]:[e.height-l,l])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:o,scales:r}=this;if(!r)return[];if(o.customLayout){const n={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:o.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:o.themeSemantic??{},categorical:o.themeCategorical??ze},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const n=this.resolveLineStyle(e,t);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:o.themeSemantic?.primary??"#4e79a7"},config:o.layoutConfig??{},selection:o.layoutSelection??null};let i;try{i=o.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,r=Ft("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{o.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const a=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of a)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(a,o.layoutSelection??null)}return $t({label:"customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const n={scales:r,config:o,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(o.chartType){case"line":return function(e,t){const o=e.groupData(t),r=[],n=e.config.annotations?.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:n,aggregate:i}=pt(e.ribbons);if(i.length>0&&r.push(...mt(e,t,i)),n.length>0)for(const t of o)r.push(...ft(e,t.data,t.key,n))}for(const t of o){const o=e.resolveLineStyle(t.key,t.data[0]),i=nt(t.data,e.scales,e.getX,e.getY,o,t.key);n&&n.length>0&&(i.colorThresholds=n),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return yt(e,o,r),r}(n,t);case"area":return function(e,t){const o=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:n,aggregate:i}=pt(e.ribbons);if(i.length>0&&r.push(...mt(e,t,i)),n.length>0)for(const t of o)r.push(...ft(e,t.data,t.key,n))}const n=e.scales.y.domain()[0],i=e.getY0?t=>{const o=e.getY0(t);return null==o?n:o}:void 0;for(const t of o){const o=e.resolveAreaStyle(t.key,t.data[0]),a=it(t.data,e.scales,e.getX,e.getY,n,o,t.key,i),s=vt(e.config.gradientFill);s&&(a.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(a.curve=e.config.curve),e.config.lineGradient&&(a.strokeGradient=e.config.lineGradient),r.push(a)}return yt(e,o,r),r}(n,t);case"mixed":return function(e,t){const o=e.groupData(t),r=[],n=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:n,aggregate:i}=pt(e.ribbons);if(i.length>0&&r.push(...mt(e,t,i)),n.length>0)for(const t of o)r.push(...ft(e,t.data,t.key,n))}const i=e.scales.y.domain()[0],a=e.getY0?t=>{const o=e.getY0(t);return null==o?i:o}:void 0;for(const t of o)if(n.has(t.key)){const o=e.resolveAreaStyle(t.key,t.data[0]),n=it(t.data,e.scales,e.getX,e.getY,i,o,t.key,a),s=vt(e.config.gradientFill);s&&(n.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}else{const o=e.resolveLineStyle(t.key,t.data[0]),n=nt(t.data,e.scales,e.getX,e.getY,o,t.key);e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}return yt(e,o,r),r}(n,t);case"stackedarea":return function(e,t){const o=e.groupData(t),r=e.config.stackOrder??"key",n=()=>o.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)n();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of o){let o=0;for(const t of r.data){const r=e.getX(t),n=e.getY(t);Number.isFinite(r)&&Number.isFinite(n)&&(o+=n)}t.set(r.key,o)}const n=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)o.sort((e,o)=>{const r=(t.get(e.key)??0)-(t.get(o.key)??0);return 0!==r?r:n(e.key,o.key)});else if("desc"===r)o.sort((e,o)=>{const r=(t.get(o.key)??0)-(t.get(e.key)??0);return 0!==r?r:n(e.key,o.key)});else{const e=[...o].sort((e,o)=>{const r=(t.get(o.key)??0)-(t.get(e.key)??0);return 0!==r?r:n(e.key,o.key)}),r=[],i=[];let a=0,s=0;for(const o of e)s>a?(r.push(o),a+=t.get(o.key)??0):(i.push(o),s+=t.get(o.key)??0);o.length=0,o.push(...i.reverse(),...r)}}else n();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,a=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=function(e,t,o,r,n,i,a,s="zero"){const l=new Set;for(const t of e)for(const e of t.data){const t=o(e);Number.isFinite(t)&&l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const n of t.data){const t=o(n),i=r(n);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of c){let o=0;for(const r of e)o+=u.get(r.key)?.get(t)||0;d.set(t,o||1)}}const h=at(c,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,s),p="diverging"===s&&!i,m=[],f=new Map,g=new Map,y=new Map,b=new Map;for(const e of c)g.set(e,h.get(e)??0),y.set(e,0),b.set(e,0);for(const o of e){const e=u.get(o.key),r=new Map;let s=[],l=[];const h=()=>{if(s.length>=2){const e={type:"area",topPath:s,bottomPath:l,style:n(o.key,o.data[0]),datum:o.data,group:o.key};a&&(e.curve=a),m.push(e)}s=[],l=[]};for(const o of c){const n=e.has(o);let a,c,u=n?e.get(o):0;if(i&&n&&(u/=d.get(o)),!n||!Number.isFinite(u)||0===u){h();continue}p?u>0?(a=y.get(o),c=a+u,y.set(o,c)):(a=b.get(o),c=a+u,b.set(o,c)):(a=g.get(o),c=a+u,g.set(o,c));const m=t.x(o);l.push([m,t.y(a)]),s.push([m,t.y(c)]),r.set(o,c)}h(),f.set(o.key,r)}return{nodes:m,stackedTops:f}}(o,e.scales,e.getX,e.getY,(t,o)=>e.resolveAreaStyle(t,o),e.config.normalize,i,a),c=s;if(e.config.pointStyle){const t=new WeakMap;for(const r of o){const o=l.get(r.key);if(o)for(const n of r.data){const r=e.getX(n),i=e.getY(n);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!o.has(r)||t.set(n,o.get(r))}}const r=o=>t.get(o)??e.getY(o);yt(e,o,c,r)}return c}(n,t);case"scatter":case"bubble":return function(e,t){const o=[],r="bubble"===e.config.chartType?10:5,n=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const o=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(o.length>0){let e=1/0,t=-1/0;for(const r of o)e>r&&(e=r),r>t&&(t=r);i=o=>e===t?(n[0]+n[1])/2:n[0]+(o-e)/(t-e)*(n[1]-n[0])}}const a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=c?.[e];if(t)return t;let o=u.get(e);return o||(o=_t[d%_t.length],d++,u.set(e,o)),o};for(const n of t){let t=e.config.pointStyle?e.config.pointStyle(n):{fill:s,opacity:.8},c=t.r||r;if(i&&e.getSize){const t=e.getSize(n);null==t||Number.isNaN(t)||(c=i(t))}if(a&&e.getColor&&!t.fill){const o=e.getColor(n);o&&a.has(o)&&(t={...t,fill:a.get(o)})}const u=e.getPointId?e.getPointId(n)+"":void 0;if(l){const r=h(l(n)+""),i=lt(n,e.scales,e.getX,e.getY,Math.PI*c*c,r,t,u);i&&o.push(i)}else{const r=st(n,e.scales,e.getX,e.getY,c,t,u);r&&o.push(r)}}return o}(n,t);case"heatmap":return function(e,t,o){if(e.config.heatmapAggregation)return function(e,t,o){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),n=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",a=ne(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/n,p=r*n;if(p>1e6)return[];const m=new Int32Array(p),f=new Float64Array(p);for(let o=0;t.length>o;o++){const i=t[o],l=e.getX(i),u=e.getY(i);if(!isFinite(l)||!isFinite(u))continue;const p=Math.min(Math.floor((l-s)/d),r-1),g=Math.min(Math.floor((u-c)/h),n-1);if(0>p||0>g)continue;const y=g*r+p;m[y]++;const b=a(i);f[y]+=isFinite(b)?b:0}let g=1/0,y=-1/0;for(let e=0;p>e;e++){if(0===m[e])continue;let t;switch(i){case"sum":t=f[e];break;case"mean":t=f[e]/m[e];break;default:t=m[e]}g>t&&(g=t),t>y&&(y=t)}if(!isFinite(g))return[];const b=y-g||1,v=o.width/r,x=o.height/n,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let e=0;n>e;e++){const t=e*r;for(let o=0;r>o;o++){const r=t+o;if(0===m[r])continue;let a;switch(i){case"sum":a=f[r];break;case"mean":a=f[r]/m[r];break;default:a=m[r]}const l=(a-g)/b;S.push(ut(o*v,(n-1-e)*x,v,x,`rgb(${220-(180*l+.5)|0},${220-(100*l+.5)|0},${255-(50*l+.5)|0})`,{xi:o,yi:e,value:a,count:m[r],sum:f[r],xCenter:s+(o+.5)*d,yCenter:c+(e+.5)*h,agg:i},w?{value:a,showValues:!0,valueFormat:k}:void 0))}}return S}(e,t,o);if(0===t.length)return[];const r=ne(e.config.valueAccessor,"value"),n=ie(e.config.xAccessor,"x"),i=ie(e.config.yAccessor,"y"),a=new Map,s=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const o=t[e],r=n(o),u=i(o);l[e]=r,c[e]=u,a.has(r)||a.set(r,a.size),s.has(u)||s.set(u,s.size)}const u=a.size,d=s.size;if(0===u||0===d)return[];const h=Array.from(a.keys()),p=Array.from(s.keys()),m=h.every(e=>"number"==typeof e&&!isNaN(e)),f=p.every(e=>"number"==typeof e&&!isNaN(e));if(m){h.sort((e,t)=>e-t),a.clear();for(let e=0;h.length>e;e++)a.set(h[e],e)}if(f){p.sort((e,t)=>e-t),s.clear();for(let e=0;p.length>e;e++)s.set(p[e],e)}const g=new Float64Array(t.length),y=new Float64Array(t.length),b=Array(t.length),v=new Map;let x=0;for(let e=0;t.length>e;e++){const o=t[e],n=a.get(l[e]),i=s.get(c[e]);if(void 0===n||void 0===i)continue;const d=r(o),h=i*u+n,p=v.get(h);let m;void 0!==p?m=p:(m=x++,v.set(h,m)),g[m]=h,y[m]=d,b[m]=o}let w=1/0,k=-1/0;for(let e=0;x>e;e++){const t=y[e];isFinite(t)&&(w>t&&(w=t),t>k&&(k=t))}if(!isFinite(w)||!isFinite(k))return[];const S=function(e){const t=e in Ie?e:"blues";let o=Tt.get(t);if(o)return o;o=Array(256);const r=_e(t);for(let e=0;256>e;e++)o[e]=r(e/255);return Tt.set(t,o),o}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),A=255/(k-w||1),C=o.width/u,M=o.height/d,P=e.config.showValues,I=e.config.heatmapValueFormat,_=[];for(let e=0;x>e;e++){const t=y[e];if(!isFinite(t))continue;const o=g[e],r=o%u;_.push(ut(r*C,(d-1-(o-r)/u)*M,C,M,S[Math.min((t-w)*A+.5|0,255)],b[e],P?{value:t,showValues:!0,valueFormat:I}:void 0))}return _}(n,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const o=Nt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of o.values())for(const o of e.categories.keys())t.add(o);const n=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(n),a=Array.from(t).filter(e=>!i.has(e)).sort(),s=n.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}const n=[],i=e.scales,[a,s]=i.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"!=typeof u||0>u?1:u,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity);for(const t of o.values()){const o=Math.max(t.start,a),u=Math.min(t.end,s);if(o>=u)continue;const p=i.x(o),m=i.x(u),f=Math.abs(m-p),g=f>d+1?d:0,y=Math.min(p,m)+g/2,b=Math.max(f-g,1);if(b>0)if(r&&t.categories.size>0){let o=0;for(const a of r){const r=t.categories.get(a)||0;if(0===r)continue;const s=i.y(o),u=i.y(o+r);n.push(ct(y,Math.min(s,u),b,Math.abs(s-u),{fill:e.config.barColors?.[a]||l?.fill||c||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},a)),o+=r}}else{const e=i.y(0),o=i.y(t.total);n.push(ct(y,Math.min(e,o),b,Math.abs(e-o),{fill:l?.fill||c||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of o.values())p.add(e.start),p.add(e.end);return{nodes:n,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(n,t);return this._barCategoryCache=n.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const o=[],r=e.config.swarmStyle||{},n=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",a=r.opacity??.7,s=r.stroke,l=r.strokeWidth;for(const r of t){const t=e.getX(r),c=e.getY(r);if(null==c||Number.isNaN(c))continue;const u=e.scales.x(t),d=e.scales.y(c);let h=i;if(e.getCategory){const t=e.getCategory(r);h=e.config.barColors?.[t]||h}const{r:p,...m}=e.config.pointStyle?.(r)??{},f={type:"point",x:u,y:d,r:p??n,style:{fill:h,opacity:a,stroke:s,strokeWidth:l,...m},datum:r};e.getPointId&&(f.pointId=e.getPointId(r)+""),o.push(f)}return o}(n,t);case"waterfall":return function(e,t,o){const r=[],n=e.scales,i=e.config.waterfallStyle,a=t.filter(t=>{const o=e.getY(t),r=e.getX(t);return null!=o&&!Number.isNaN(o)&&null!=r&&isFinite(r)});if(0===a.length)return r;const s=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=i?.gap??1,u=i?.stroke,d=i?.strokeWidth,h=i?.opacity;let p=0;for(let t=0;a.length>t;t++){const m=a[t],f=e.getX(m),g=e.getY(m),y=p+g;let b;b=a.length-1>t?e.getX(a[t+1])-f:t>0?f-e.getX(a[t-1]):0;const v=n.x(f),x=0!==b?n.x(f+b):v+o.width/10,w=Math.min(v,x)+c/2,k=Math.max(v,x)-c/2-w;if(0>=k){p=y;continue}const S=n.y(p),A=n.y(y),C=Math.min(S,A),M=Math.abs(S-A),P={fill:0>g?l:s,stroke:u,strokeWidth:d};null!=h&&(P.opacity=h),r.push(ct(w,C,k,M,P,{...m,baseline:p,cumEnd:y,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),p=y}return r}(n,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const o=e.config.candlestickRangeMode??!1;if(!(o||e.getOpen&&e.getClose))return[];const r=[],n=e.config.candlestickStyle||{},i=n.rangeColor||"#6366f1",a=o?i:n.upColor||"#28a745",s=o?i:n.downColor||"#dc3545",l=o?i:n.wickColor||"#333",c=n.wickWidth||(o?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let t=1/0;for(let o=1;u.length>o;o++){const r=Math.abs(e.scales.x(u[o])-e.scales.x(u[o-1]));r>0&&t>r&&(t=r)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(n),u=e.getLow(n);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const h=o?i:e.getOpen(n),p=o?u:e.getClose(n);if(!o&&[h,p].some(e=>null==e||Number.isNaN(e)))continue;const m=p>=h,f={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(h),closeY:e.scales.y(p),highY:e.scales.y(i),lowY:e.scales.y(u),bodyWidth:d,upColor:a,downColor:s,wickColor:l,wickWidth:c,isUp:m,datum:n};o&&(f.isRange=!0),r.push(f)}return r}(n,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,o,r){const n=e.boundsStyle;return"function"==typeof n?n(o||{},t):n&&"object"==typeof n?n:{fill:r(t,o).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?Ze(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Je(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,o,r=Je(o)){const n=o.length;if(n>1)for(const o of t){if("line"===o.type){const t=Array.isArray(o.datum)?o.datum:[];if(2>t.length)continue;const i=Array(t.length);let a=!1;for(let o=0;t.length>o;o++){const s=r.get(t[o]);null!=s?(i[o]=Ze(e,s,n),1>i[o]&&(a=!0)):i[o]=1}a&&(o._decayOpacities=i);continue}if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[],i=o.topPath?o.topPath.length:t.length;if(2>i)continue;if(t.length===i){const a=Array(i);let s=!1;for(let o=0;t.length>o;o++){const i=r.get(t[o]);null!=i?(a[o]=Ze(e,i,n),1>a[o]&&(s=!0)):a[o]=1}s&&(o._decayOpacities=a)}else{let a=1;for(const o of t){const t=r.get(o);if(null!=t){const o=Ze(e,t,n);a>o&&(a=o)}}if(1>a){const e=Array(i);e.fill(a),o._decayOpacities=e}}continue}const t=r.get(o.datum);if(null==t)continue;const i=Ze(e,t,n);"heatcell"===o.type?o.style={opacity:i}:"candlestick"===o.type?o._decayOpacity=i:o.style={...o.style,opacity:(o.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&ot(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ue())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,o,r){o.clear(),r.clear();for(let n=0;t.length>n;n++){const i=t[n],a=rt(e,i,n);a&&("point"===i.type?o.set(a,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?o.set(a,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?o.set(a,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?o.set(a,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?o.set(a,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(a,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(a,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],r=rt(this.transitionContext,o,t);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:0,opacity:0}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:e,w:o.w,h:0,opacity:o.style.opacity??1}):"heatcell"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:0}):"line"===o.type?(o._introClipFraction=0,this.prevPathMap.set(r,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style.opacity})):"area"===o.type&&(o._introClipFraction=0,this.prevPathMap.set(r,{topPath:o.topPath.map(e=>[e[0],e[1]]),bottomPath:o.bottomPath.map(e=>[e[0],e[1]]),opacity:o.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,o,r,n){if(0===r.size&&0===n.size)return o;const i=t.duration??300;if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}let a=!1;const s=new Set,l=new Set;for(let t=0;o.scene.length>t;t++){const i=o.scene[t],c=rt(e,i,t);if(!c)continue;if(i._transitionKey=c,"line"===i.type||"area"===i.type){const e=n.get(c);if(e){if(l.add(c),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=r.get(c);if("point"===i.type)if(u){s.add(c);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){s.add(c);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){s.add(c);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){s.add(c);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){s.add(c);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of n)if(!l.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!s.has(e)){if(e.startsWith("p:"))o.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)o.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))o.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))o.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;o.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),a&&(o.activeTransition={startTime:Ue(),duration:i}),o}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},o=function(e,t,o,r){if(!o.activeTransition)return!1;const n=Ve(e,o.activeTransition),i=Ye(n,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of o.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?r.get(t):void 0;e.style.opacity=Xe(o?o.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const o=r.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,i),e.y=Xe(o.y,e._targetY,i),void 0!==e._targetR&&void 0!==o.r&&(e.r=Xe(o.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const o=t?r.get(t):void 0;e.style.opacity=Xe(o?o.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const o=r.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,i),e.y=Xe(o.y,e._targetY,i),void 0!==e._targetR&&void 0!==o.r&&(e.size=Xe(o.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=t?r.get(t):void 0;e.style.opacity=Xe(o?o.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const o=r.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,i),e.y=Xe(o.y,e._targetY,i),void 0!==o.w&&(e.w=Xe(o.w,e._targetW,i)),void 0!==o.h&&(e.h=Xe(o.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const o=t?r.get(t):void 0;e.style={...e.style||{},opacity:Xe(o?o.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const o=r.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,i),e.y=Xe(o.y,e._targetY,i),void 0!==o.w&&(e.w=Xe(o.w,e._targetW,i)),void 0!==o.h&&(e.h=Xe(o.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const o=t?r.get(t):void 0;e.style={...e.style||{},opacity:Xe(o?o.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const o=r.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,i),void 0!==o.openY&&(e.openY=Xe(o.openY,e._targetOpenY,i)),void 0!==o.closeY&&(e.closeY=Xe(o.closeY,e._targetCloseY,i)),void 0!==o.highY&&(e.highY=Xe(o.highY,e._targetHighY,i)),void 0!==o.lowY&&(e.lowY=Xe(o.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Xe(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,o=e._targetPath;if(t&&o&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=Xe(t[r][0],o[r][0],i),e.path[r][1]=Xe(t[r][1],o[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Xe(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,o=e._prevBottomPath,r=e._targetTopPath,n=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let o=0;e.topPath.length>o;o++)e.topPath[o][0]=Xe(t[o][0],r[o][0],i),e.topPath[o][1]=Xe(t[o][1],r[o][1],i);if(o&&n&&o.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Xe(o[t][0],n[t][0],i),e.bottomPath[t][1]=Xe(o[t][1],n[t][1],i)}}if(n>=1){for(const e of o.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}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("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=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}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let o=0;e.path.length>o;o++)e.path[o]=t[o];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,o=e._targetBottomPath;if(t)for(let o=0;e.topPath.length>o;o++)e.topPath[o]=t[o];if(o)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=o[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}return o.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,o}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:o}=function(e,t,o,r){if(r&&r.version===o&&r.group===t&&r.data===e)return{result:r.result,cache:r};let n;if(t){const o=new Map;for(const r of e){const e=t(r);o.has(e)||o.set(e,[]),o.get(e).push(r)}n=Array.from(o.entries()).map(([e,t])=>({key:e,data:t}))}else n=[{key:"_default",data:e}];return{result:n,cache:{version:o,group:t,data:e,result:n}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=o,t}resolveColorMap(e){const{map:t,cache:o}=function(e,t,o,r,n){if(n&&n.version===r)return{map:n.map,cache:n};const i=new Set;if(t)for(const o of e){const e=t(o);e&&i.add(e)}const a=Array.from(i).sort(),s=a.join("\0");if(n&&n.key===s){const e={...n,version:r};return{map:e.map,cache:e}}const l=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical||ze,c=new Map;for(let e=0;a.length>e;e++)c.set(a[e],l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=o,t}resolveLineStyle(e,t){return function(e,t,o,r){const n=e.lineStyle;if("function"==typeof n){const e=n(o||{},t);if(e&&!e.stroke&&t){const o=r(t);if(o)return{...e,stroke:o}}return e}const i=e.themeSemantic?.primary;return n&&"object"==typeof n?{stroke:n.stroke||i||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,o,r){if(e.areaStyle){const n=e.areaStyle(o||{});if(n&&!n.fill&&t){const e=r(t);if(e)return{...n,fill:e,stroke:n.stroke||e}}return n}const n=e.lineStyle;if("function"==typeof n){const e=n(o||{},t);if(e&&!e.fill&&t){const o=r(t);if(o)return{...e,fill:o,stroke:e.stroke||o}}return e}const i=e.themeSemantic?.primary;if(n&&"object"==typeof n)return{fill:n.fill||n.stroke||i||"#4e79a7",fillOpacity:n.fillOpacity??.7,stroke:n.stroke||i||"#4e79a7",strokeWidth:n.strokeWidth||2};const a=r(t)||i||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:o,groupColorCounter:r}=function(e){const{group:t,colorMapCache:o,groupColorMap:r,groupColorMapCap:n,config:i}=e;let{groupColorCounter:a}=e;if(o){const e=o.map.get(t);if(e)return{color:e,groupColorCounter:a}}const s=r.get(t);if(s)return{color:s,groupColorCounter:a};const l=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||ze;if(0===l.length)return{color:null,groupColorCounter:a};const c=l[a%l.length];if(a++,r.set(t,c),r.size>n){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:c,groupColorCounter:a}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ue(e),o=this.getPointId,r=e=>t.has(o(e));Ut(this.buffer,this.timestampBuffer,r);const n=this.buffer.remove(r);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const e of n)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ue(),this.updateResults.recordData("remove",n.length),n}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const o=ue(e),r=this.getPointId,n=new Set;this.buffer.forEach((e,t)=>{o.has(r(e))&&n.add(t)});const i=this.buffer.update(e=>o.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{n.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=Ue(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}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._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},n=o(r,t);r.style=n?{...e,...n}:e}}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this._stylePaintPending=!0,this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,n=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,o=e&&this.config.valueAccessor||this.config.yAccessor,a=e&&t.valueAccessor||t.yAccessor,s=i||!re(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=i||!re(o,a);(s||l)&&(e?(this.getX=ne(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=ne(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=ne(this.config.xAccessor,"x"),this.getY=ne(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=zt(this.config)),r=!0,n=!0)}if("groupAccessor"in e&&!re(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?ae(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!re(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?ae(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!re(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?ne(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!re(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ae(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!re(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ae(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!re(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?ne(this.config.y0Accessor,"y0"):void 0,r=!0,n=!0),("boundsAccessor"in e&&!re(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=zt(this.config),r=!0,n=!0),"pointIdAccessor"in e&&!re(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?ae(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!re(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!re(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!re(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!re(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?ne(this.config.openAccessor,"open"):void 0,this.getHigh=ne(this.config.highAccessor,"high"),this.getLow=ne(this.config.lowAccessor,"low"),this.getClose=t?ne(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,n=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,n=!0),!r){const o=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const n of o)if(e[n]!==t[n]){r=!0;break}}r&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(o,r,n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};ao.GROUP_COLOR_MAP_CAP=1e3;var so=ao,lo={sceneGeometry:0,layout:0,domain:0},co="production"!==process.env.NODE_ENV,uo={revisions:lo,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},ho=class{constructor(){this.lastConsumed=lo,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}beforeCompute(e,t){if(!co)return uo;const o=function(e){const{domain:t,layout:o,sceneGeometry:r}=e.revisions;return{domain:t,layout:o,sceneGeometry:r}}(e),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(o),n=!((i=o).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:o,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:n,warnUnconsumed:!t&&n&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,o){if(co){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] StreamXYFrame observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!o&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] StreamXYFrame performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};import*as po from"react";function mo(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:po.createElement(po.Fragment,null,...t)}import*as fo from"react";import{jsx as go}from"react/jsx-runtime";var yo=fo.createContext(null);function bo({value:e,children:t}){return go(yo.Provider,{value:e,children:t})}function vo(e,t){return null!=e?go(bo,{value:t,children:e}):e}import{useEffect as xo,useRef as wo}from"react";function ko(e,t,o,r){xo(()=>{e.current?.updateConfig(t),o.current=!0,r()},[t,r,e,o])}function So(e,t,o,r){const n=wo(null);xo(()=>{const i=e.current;if(!i)return;const a=t??null;n.current!==a&&(n.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):o.current=!0,r())},[t,r,e,o])}function Ao(e,t,o){return o.x>e||e>o.x+o.w||o.y>t||t>o.y+o.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:o.x+o.w/2,cy:o.y+o.h/2}}function Co(e,t=30){return Math.max((e??4)+5,12,t)}function Mo(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Po(e,t){const o=Mo(e);if(!o)return!1;const r=Mo(t);return!r||o.getFullYear()!==r.getFullYear()||o.getMonth()!==r.getMonth()}function Io(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var _o=[40,40],Lo=[.5,.5];function Ro(e,t){const[o,r]=e.viewBox??_o,[n,i]=e.anchor??Lo,a=r>0?r:1,s=Math.max(0,t)/a,l=(o>0?o:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-n*l,offsetY:-i*c}}function To(e,t,o,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?o:e}var No=null;function $o(e){if("undefined"==typeof Path2D)return null;No||(No=new Map);const t=No.get(e);if(t)return t;const o=new Path2D(e);return No.size>1024&&No.clear(),No.set(e,o),o}function Bo(e,t,o=0,r="horizontal"){const[n,i]=e.viewBox??_o,a=Math.min(1,Math.max(0,o)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:i*(1-s),width:n,height:i*(s-a)}:{x:n*a,y:0,width:n*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function Do(e,t){const o=Ro(e,t);return{centerDx:o.offsetX+o.width/2,centerDy:o.offsetY+o.height/2,halfWidth:o.width/2,halfHeight:o.height/2,radius:Math.hypot(o.width,o.height)/2}}function Fo(e,t,o,r,n,i=e=>e){for(const a of t.parts){const t=$o(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=n?"none"===a.fill?void 0:n:To(a.fill,o,r);c&&(e.fillStyle=i(c),e.fill(t));const u=n?a.stroke&&"none"!==a.stroke?n:void 0:To(a.stroke??"none",o,r);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Eo(e,t,o,r,n,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(r,n+5,12),c=t-l,u=t+l,d=o-l,h=o+l;let p=null,m=1/0;return e.visit((e,n,l,f,g)=>{if(n>u||c>f||l>h||d>g)return!0;if(!e.length){let n=e;do{const e=n.data,l=i(e)-t,c=a(e)-o,u=Math.sqrt(l*l+c*c);Co(s(e),r)>=u&&m>u&&(p=e,m=u),n=n.next}while(n)}return!1}),p?{node:p,distance:m}:null}var zo=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,jo=new WeakMap,Oo=0,Ho=!1,Wo=null,qo=null;function Go(e,t){if(!t)return t;const o=zo.exec(t);if(!o)return t;const r=e.canvas;if(!r)return o[2]?.trim()||t;!function(){if(Ho)return;if("undefined"==typeof window||"undefined"==typeof document)return;Ho=!0;const e=()=>{Oo++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Wo=window.matchMedia("(prefers-color-scheme: dark)"),qo=e,"function"==typeof Wo.addEventListener?Wo.addEventListener("change",qo):"function"==typeof Wo.addListener&&Wo.addListener(qo)}catch{}}();let n=jo.get(r);n&&n.version===Oo||(n={version:Oo,map:new Map},jo.set(r,n));const i=n.map.get(t);if(void 0!==i)return i;const a=getComputedStyle(r).getPropertyValue(o[1]).trim()||o[2]?.trim()||t;return n.map.set(t,a),a}function Yo(e,t){const o=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=o,[78,121,167]}const n=e.fillStyle;if(e.fillStyle=o,"string"!=typeof n)return[78,121,167];if(n.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(n.startsWith("#"))return[parseInt(n.slice(1,3),16),parseInt(n.slice(3,5),16),parseInt(n.slice(5,7),16)];const i=n.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}import{curveMonotoneX as Vo,curveMonotoneY as Xo,curveCardinal as Uo,curveCatmullRom as Ko,curveStep as Qo,curveStepBefore as Zo,curveStepAfter as Jo,curveBasis as er,curveNatural as tr}from"d3-shape";function or(e){switch(e){case"monotoneX":return Vo;case"monotoneY":return Xo;case"cardinal":return Uo;case"catmullRom":return Ko;case"step":return Qo;case"stepBefore":return Zo;case"stepAfter":return Jo;case"basis":return er;case"natural":return tr;default:return null}}function rr(e,t,o){return null==t?o:"string"!=typeof t?t:Go(e,t)||o}function nr(e,t,o,r,n,i,a){if("colorStops"in t){const o=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>o.length)return null;const s=e.createLinearGradient(r,n,i,a);for(const e of o)s.addColorStop(e.offset,e.color);return s}const{topOpacity:s,bottomOpacity:l}=t;if(!Number.isFinite(s)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,s)),u=Math.max(0,Math.min(1,l)),d=e.createLinearGradient(r,n,i,a),[h,p,m]=Yo(e,o);return d.addColorStop(0,`rgba(${h},${p},${m},${c})`),d.addColorStop(1,`rgba(${h},${p},${m},${u})`),d}function ir(e,t,o,r,n,i){const a=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>a.length)return null;const s=e.createLinearGradient(o,r,n,i);for(const e of a)s.addColorStop(e.offset,e.color);return s}import{line as ar}from"d3-shape";var sr=new WeakMap;function lr(e,t){const o=or(t);if(!o)return e;const r=sr.get(e);if(r)return r;const n=function(e,t,o=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let n=null;const i={moveTo(e,t){n=[e,t],r.push([e,t])},lineTo(e,t){n=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,a,s,l){if(!n)return n=[s,l],void r.push([s,l]);const[c,u]=n;for(let n=1;o>=n;n++){const d=n/o,h=1-d;r.push([h*h*h*c+3*h*h*d*e+3*h*d*d*i+d*d*d*s,h*h*h*u+3*h*h*d*t+3*h*d*d*a+d*d*d*l])}n=[s,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,o,i){n=[o,i],r.push([o,i])}};return ar().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,o);return sr.set(e,n),n}function cr(e,t,o,r=30,n,i=0){let a=null;if(n){const e=Eo(n,t,o,r,i);e&&(a={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(n)break;e=dr(i,t,o,r);break;case"symbol":e=hr(i,t,o,r);break;case"glyph":e=pr(i,t,o,r);break;case"line":e=mr(i,t,o,r);break;case"rect":if(null==i.datum)break;e=gr(i,t,o);break;case"heatcell":e=yr(i,t,o);break;case"area":if(!1===i.interactive)break;e=vr(i,t,o);break;case"candlestick":e=br(i,t,o)}e&&r>e.distance&&(a&&e.distance>=a.distance||(a=e))}return a}function ur(e,t,o){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=xr(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>o)return null;let n=r,i=r;r>0&&e[r][0]>=t?(n=r-1,i=r):e.length-1>r&&(n=r,i=r+1);const[a,s]=e[n],[l,c]=e[i];return l===a?s:s+Math.max(0,Math.min(1,(t-a)/(l-a)))*(c-s)}function dr(e,t,o,r=30){const n=t-e.x,i=o-e.y,a=Math.sqrt(n*n+i*i);return a>Co(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function hr(e,t,o,r=30){const n=t-e.x,i=o-e.y,a=Math.sqrt(n*n+i*i);return a>Co(Rt(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function pr(e,t,o,r=30){if(null==e.datum)return null;const n=Do(e.glyph,e.size),i=e.x+n.centerDx,a=e.y+n.centerDy,s=t-i,l=o-a,c=Math.sqrt(s*s+l*l);return c>Co(n.radius,r)?null:{node:e,datum:e.datum,x:i,y:a,distance:c}}function mr(e,t,o,r=30){if(0===e.path.length)return null;const n=xr(e.path,t);if(0>n)return null;const[i,a]=e.path[n];let s;if(e.path.length>1){let r=1/0;const i=Math.max(0,n-1),a=Math.min(e.path.length-2,n);for(let n=i;a>=n;n++){const[i,a]=e.path[n],[s,l]=e.path[n+1],c=fr(t,o,i,a,s,l);r>c&&(r=c)}s=r}else{const e=t-i,r=o-a;s=Math.sqrt(e*e+r*r)}const l=e.style;return s>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:i,y:a,distance:s}}function fr(e,t,o,r,n,i){const a=n-o,s=i-r,l=a*a+s*s;if(0===l)return Math.sqrt((e-o)**2+(t-r)**2);let c=((e-o)*a+(t-r)*s)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(o+c*a))**2+(t-(r+c*s))**2)}function gr(e,t,o){const r=Ao(t,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function yr(e,t,o){const r=Ao(t,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function br(e,t,o){const r=e.bodyWidth/2,n=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>o||o>e.lowY+3)){const r=n+Math.max(Math.max(e.openY,e.closeY)-n,1)/2,i=t-e.x,a=o-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+a*a)}}return null}function vr(e,t,o){if(0===e.topPath.length)return null;const r=xr(e.topPath,t);if(0>r)return null;const[n,i]=e.topPath[r],a=t-n,s=o-i,l=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:n,y:i,distance:l}}function xr(e,t){if(0===e.length)return-1;let o=0,r=e.length-1;for(;r>o;){const n=o+r>>1;t>e[n][0]?o=n+1:r=n}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}function wr(e){const t=new Map;for(const o of e){const e=o.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(o)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const o=Array.from(t.keys()).sort((e,o)=>{const r=t.get(e),n=t.get(o);return(r.length>0?r[0].y:0)-(n.length>0?n[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const n=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&n.set(t+"",e)}return{flat:r,groups:o,byGroup:t,idToIdx:n}}function kr(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[o];return{flatIndex:o,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Sr(e,t,o){const{group:r,indexInGroup:n}=t,i=o.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>n?i[n+1]._flatIndex:t.flatIndex;case"ArrowLeft":return n>0?i[n-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=o.groups.indexOf(r);return o.groups.length-1>e?Ar(o,o.groups[e+1],i[n]):t.flatIndex}case"ArrowUp":{const e=o.groups.indexOf(r);return e>0?Ar(o,o.groups[e-1],i[n]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*o.flat.length)),o.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*o.flat.length)),0);case"Home":return 0;case"End":return o.flat.length-1;case"Escape":return-1;default:return null}}function Ar(e,t,o){const r=e.byGroup.get(t);let n=0,i=Math.abs(r[0].x-o.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-o.x);i>t&&(i=t,n=e)}return r[n]._flatIndex}function Cr(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Mr(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}import{useEffect as Pr,useRef as Ir}from"react";var _r={fresh:1,aging:.7,stale:.45,expired:.25},Lr={alpha:1,band:"fresh",isStale:!1};function Rr(e,t){if(!e||0>=t)return Lr;const o=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},n=Qe(t,o,e.thresholds);return{alpha:{..._r,...e.opacities??{}}[n],band:n,isStale:"fresh"!==n}}return t>o?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Lr}function Tr(e,t,o,r,n,i){const a=Ir("fresh");Pr(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Rr(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===n||(a.current=c.band,c.isStale!==n&&i(c.isStale),o.current=!0,r())},1e3);return()=>clearInterval(s)},[e,n,r])}import{jsx as Nr}from"react/jsx-runtime";function $r({isStale:e,position:t}){return Nr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Br,useRef as Dr,useEffect as Fr}from"react";import*as Er from"react";import{jsx as zr,jsxs as jr}from"react/jsx-runtime";var Or={fill:(e,t)=>zr("rect",{style:e,width:t,height:t}),line:(e,t)=>zr("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Hr(e,t,o,r,n){let i;return i="function"==typeof o?o(e):(0,Or[o])(r(e,t),n),i}function Wr({swatchSize:e}){return zr("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function qr(e,t,o){return o&&o.size>0?o.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Gr=(e,t,o,r,n,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:p}=e,m=[];let f=0;const g=!(!t&&!o),y="isolate"===c||void 0===c&&null!=n,{swatchSize:b,labelGap:v,rowHeight:x}=u;return p.forEach((e,c)=>{const u=Hr(e,c,d,h,b),w=qr(e,r,n),k=n&&n.size>0&&n.has(e.label);m.push(jr("g",{transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:g?s===i&&c===a?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&y?k||!1:void 0,"aria-current":g&&!y&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?o=>{if("Enter"!==o.key&&" "!==o.key||(o.preventDefault(),t&&t(e)),"ArrowDown"===o.key||"ArrowUp"===o.key){o.preventDefault();const e=(c+("ArrowDown"===o.key?1:-1)+p.length)%p.length;l(s,e);const t=o.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{l(s,c),o&&o(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&zr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+v+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&zr(Wr,{swatchSize:b}),zr("text",{y:b/2,x:b+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),f+=x}),m};function Yr({config:e,orientation:t="vertical",width:o=100}){const{colorFn:r,domain:n,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Er.useId();if("horizontal"===t){const e=12,t=Math.min(o,200),a=Math.max(0,(o-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(zr("stop",{offset:100*t+"%",stopColor:r(n[0]+t*(n[1]-n[0]))},e))}return jr("g",{"aria-label":i||"Gradient legend",children:[zr("defs",{children:zr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&zr("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),zr("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),zr("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(n[0])}),zr("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(n[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(zr("stop",{offset:100*t+"%",stopColor:r(n[1]-t*(n[1]-n[0]))},e))}return jr("g",{"aria-label":i||"Gradient legend",children:[i&&zr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),zr("defs",{children:zr("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),zr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),zr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(n[1])}),zr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(n[0])})]})}function Vr(e){const{legendGroups:t,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:n,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),o=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:o,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[p,m]=Er.useState(0),[f,g]=Er.useState(0),y=Er.useCallback((e,t)=>{m(e),g(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:n,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let d=24;const h=[];return e.forEach((e,p)=>{d+=5,h.push(zr("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+p)),d+=8,e.label&&(d+=16,h.push(zr("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+p)),d+=8),h.push(zr("g",{className:"legend-item",transform:`translate(0,${d})`,children:Gr(e,o,r,n,i,a,s,p,l,c,u)},"legend-group-"+p)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:l,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:n,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:o,customClickBehavior:r,customHoverBehavior:n,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const p=[];e.forEach((e,t)=>{let m=0;e.label&&(m+=16);const f=((e,t,o,r,n,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:p,items:m}=e,f=[],{swatchSize:g,labelGap:y,itemGap:b,rowHeight:v,align:x}=u,w=!(!t&&!o),k="isolate"===c||void 0===c&&null!=n,S=m.map(e=>g+y+7*e.label.length),A=[];let C=0,M=0;S.forEach((e,t)=>{const o=0===M?e:M+b+e;d&&d>0&&M>0&&o>d?(A.push({start:C,end:t,width:M}),C=t,M=e):M=o}),m.length>0&&A.push({start:C,end:m.length,width:M}),A.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=m[d],x=Hr(e,d,h,p,g),A=qr(e,r,n),C=n&&n.size>0&&n.has(e.label);f.push(jr("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:w?s===i&&d===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?C||!1:void 0,"aria-current":w&&!k&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:w?o=>{if("Enter"!==o.key&&" "!==o.key||(o.preventDefault(),t&&t(e)),"ArrowRight"===o.key||"ArrowLeft"===o.key){o.preventDefault();const e=(d+("ArrowRight"===o.key?1:-1)+m.length)%m.length;l(s,e);const t=o.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{l(s,d),o&&o(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&zr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+y+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,C&&zr(Wr,{swatchSize:g}),zr("text",{y:g/2,x:g+y,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const P=Math.max(0,...A.map(e=>e.width)),I=A.length;return{items:f,offset:P,totalRows:I,totalHeight:I*v}})(e,r,n,i,a,s,l,t,c,u,d,d.maxWidth??o);m+=f.offset+5,p.push({label:e.label,...f,offset:m,totalRows:f.totalRows,totalHeight:f.totalHeight}),h+=m+12});const m=d.maxWidth??o;let f=h>m?0:"center"===d.align?Math.max(0,(m-h)/2):"end"===d.align?Math.max(0,m-h):0;const g=[];return p.forEach((o,r)=>{const n=e[r];n.label&&(g.push(zr("text",{transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label},"legend-text-"+r)),f+=16),g.push(zr("g",{className:"legend-item",transform:`translate(${f},0)`,children:o.items},"legend-group-"+r)),f+=o.offset+5,e[r+1]&&g.push(zr("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(o.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),f+=12}),zr("g",{children:g})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:n,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:f,onFocusedIndexChange:y,legendInteraction:a,metrics:h}),v=!(!o&&!r);return jr("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&zr("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}function Xr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as Ur}from"react/jsx-runtime";function Kr(e){const{legend:t,totalWidth:o,totalHeight:r,margin:n,legendPosition:i="right",legendLayout:a,title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const p="top"===i||"bottom"===i,m=!!s,f=Math.max(0,o-n.left-n.right),g=Math.max(1,p?a?.maxWidth??f:100);let y,b;return"left"===i?(y=Math.max(4,n.left-g-10),b=n.top):"top"===i?(y=n.left,b=m?32:8):"bottom"===i?(y=n.left,b=r-n.bottom+38):(y=o-n.right+10,b=n.top),Ur("g",{transform:`translate(${y}, ${b})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?Ur(Yr,{config:t.gradient,orientation:p?"horizontal":"vertical",width:g}):Xr(t)?Ur(Vr,{legendGroups:t.legendGroups,title:"",width:g,orientation:p?"horizontal":"vertical",legendLayout:a,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t)});var v}import{useMemo as Qr}from"react";import{bin as Zr}from"d3-array";import{jsx as Jr,jsxs as en}from"react/jsx-runtime";function tn(e){return"string"==typeof e?{type:e}:e}function on({orient:t,config:o,values:r,scale:n,size:i,length:a}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(o),l="top"===t||"bottom"===t,c=Qr(()=>{if(0===r.length)return null;const o=n.domain(),c=i-8;if("boxplot"===s.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const r=t[Math.floor(.25*o)],n=t[Math.floor(.5*o)],i=t[Math.floor(.75*o)],a=i-r;return{q1:r,median:n,q3:i,whiskerLow:Math.max(t[0],r-1.5*a),whiskerHigh:Math.min(t[o-1],i+1.5*a)}}(r);if(!e)return null;const{q1:o,median:i,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*c,20),p=(c-h)/2+4;if(l){const e=n(o),r=n(a),l=n(i),c=n(u),m=n(d),f="top"===t?-1:1,g=0;return en("g",{"data-testid":"marginal-boxplot-"+t,children:[Jr("line",{x1:c,y1:g+f*(p+h/2),x2:m,y2:g+f*(p+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("line",{x1:c,y1:g+f*p,x2:c,y2:g+f*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("line",{x1:m,y1:g+f*p,x2:m,y2:g+f*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("rect",{x:Math.min(e,r),y:"top"===t?g-p-h:g+p,width:Math.abs(r-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Jr("line",{x1:l,y1:"top"===t?g-p-h:g+p,x2:l,y2:"top"===t?g-p:g+p+h,stroke:s.fill,strokeWidth:2})]})}{const e=n(o),r=n(a),l=n(i),c=n(u),m=n(d),f="left"===t?-1:1,g=0;return en("g",{"data-testid":"marginal-boxplot-"+t,children:[Jr("line",{x1:g+f*(p+h/2),y1:c,x2:g+f*(p+h/2),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("line",{x1:g+f*p,y1:c,x2:g+f*(p+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("line",{x1:g+f*p,y1:m,x2:g+f*(p+h),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),Jr("rect",{x:"left"===t?g-p-h:g+p,y:Math.min(e,r),width:h,height:Math.abs(r-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Jr("line",{x1:"left"===t?g-p-h:g+p,y1:l,x2:"left"===t?g-p:g+p+h,y2:l,stroke:s.fill,strokeWidth:2})]})}}const u=Zr().domain(o).thresholds(s.bins)(r);if(0===u.length)return null;const d=e(u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return Jr("g",{"data-testid":"marginal-histogram-"+t,children:u.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/d*c;if(l){const i=n(e.x0),a=n(e.x1)-n(e.x0);return Jr("rect",{x:i,y:"top"===t?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},o)}{const i=n(e.x0),a=n(e.x1)-n(e.x0);return Jr("rect",{x:"left"===t?-4-r:4,y:Math.min(i,i+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},o)}})});if("violin"===s.type){const e=c/2+4,o=[];for(const r of u){if(null==r.x0||null==r.x1)continue;const i=r.length/d*(c/2),a=n((r.x0+r.x1)/2);o.push(l?`${a},${"top"===t?-(e-i):e-i}`:`${"left"===t?-(e-i):e-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/d*(c/2),s=n((i.x0+i.x1)/2);o.push(l?`${s},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${s}`)}return Jr("g",{"data-testid":"marginal-violin-"+t,children:Jr("polygon",{points:o.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const e=[];if(l){const o=0,r=null!=u[0].x0?n(u[0].x0):0;e.push(`M${r},${o}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*c,i=n((o.x0+o.x1)/2);e.push(`L${i},${"top"===t?-r-4:r+4}`)}const i=null!=u[u.length-1].x1?n(u[u.length-1].x1):a;e.push(`L${i},${o}`),e.push("Z")}else{const o=0,r=null!=u[0].x0?n(u[0].x0):0;e.push(`M${o},${r}`);for(const o of u){if(null==o.x0||null==o.x1)continue;const r=o.length/d*c,i=n((o.x0+o.x1)/2);e.push(`L${"left"===t?-r-4:r+4},${i}`)}const i=null!=u[u.length-1].x1?n(u[u.length-1].x1):a;e.push(`L${o},${i}`),e.push("Z")}return Jr("g",{"data-testid":"marginal-ridgeline-"+t,children:Jr("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[r,n,s,i,a,t,l,4]);return c?Jr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:c}):null}import*as rn from"react";import{jsx as nn,jsxs as an}from"react/jsx-runtime";function sn(e,t=120,o=8){if(!e)return[];const r=Math.max(1,Math.floor(t/o)),n=e.split(/\s+/),i=[];let a="";for(const e of n)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function ln(e,t,o,r){return"curly"===e?r?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:r?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function cn(e,t,o,r){if(!e)return nn("g",{className:"annotation-note"});const{label:n,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!n&&!i)return nn("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(o)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>o?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const p=16,m=i?c?[i]:sn(i,l):[],f=n?c?[n]:sn(n,l):[],g="leftRight"===u?"end"===h?-4:4:0;let y=0;const b=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push(nn("foreignObject",{className:"annotation-note-html",x:"end"===h?g-l:"middle"===h?g-l/2:g,y:-16,width:l,height:Math.max(p,(m.length+f.length)*p+(i&&n?2:0))+p,style:{overflow:"visible"},children:an("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&nn("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),n&&nn("div",{className:"annotation-note-label",children:n})]})},"annotation-note-html")):(m.length>0&&(b.push(nn("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:m.map((e,t)=>nn("tspan",{x:g,dy:0===t?0:p,children:e},t))},"annotation-note-title")),y=m.length*p),f.length>0&&b.push(nn("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:y,children:f.map((e,t)=>nn("tspan",{x:g,dy:0===t?0:p,children:e},t))},"annotation-note-label")));let x=null;if((i||n)&&(0!==t||0!==o))if("topBottom"===u){const e=Math.min(l,120);let t=0,o=e;"end"===h?(t=-e,o=0):"middle"===h&&(t=-e/2,o=e/2),x=nn("line",{className:"note-line",x1:t,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(m.length+f.length)*p+(f.length>0?p:0);let t=0,o=e;"bottom"===d?(t=-e,o=0):"middle"===d&&(t=-e/2,o=e/2),x=nn("line",{className:"note-line",x1:0,x2:0,y1:t,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,m.length+f.length-1)*p;let k=0;return"topBottom"===u?k=0>o?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(f.length>0&&m.length>0?2:0))/2+8:"bottom"===d||0>o?-(w+2):18),an("g",{className:"annotation-note",transform:`translate(${t},${o})`,children:[nn("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:b}),x]})}function un(e,t,o,r,n){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(nn("circle",{r:e,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(nn("rect",{width:e,height:r,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,a=n||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(nn("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push(nn("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(nn("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(nn("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(nn("path",{d:ln(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return nn("g",{className:"annotation-subject",children:i})}function dn(e,t,o,r,n,i){const a=[];let s=0,l=0;if("callout-circle"!==n&&"label"!==n||!i?.radius){if("callout-rect"===n&&i){const o=i.width||0,r=i.height||0;if(o>0||r>0){const n=o/2,i=r/2,a=e-n,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=o/2,d=r/2,h=e*d>t*u?u/e:d/t;s=n+a*h,l=i+c*h}}}else if("bracket"===n&&i){const e=i.width,t=i.height,o=i.depth||30;void 0!==e?(s=e/2,l=o):void 0!==t&&(s=o,l=t/2)}}else{const o=(i.radius||0)+(i.radiusPadding||0);if(o>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);s=Math.cos(r)*o,l=Math.sin(r)*o}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const n=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===o?.type;let u=Math.atan2(t-l,e-s);if(i){const r=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,p=(o?.curve??.25)*c,m=r+d*p,f=i+h*p;a.push(nn("path",{className:"connector-curve",d:`M${s},${l}Q${m},${f} ${e},${t}`,fill:"none",stroke:n},"connector-line")),u=Math.atan2(f-l,m-s)}else a.push(nn("line",{x1:s,y1:l,x2:e,y2:t,stroke:n},"connector-line"));if("arrow"===o?.end){const e=10,t=16/180*Math.PI;a.push(nn("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:n,stroke:"none"},"connector-arrow"))}}return nn("g",{className:"annotation-connector",children:a})}function hn(e){const{x:t=0,y:o=0,dx:r,dy:n,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:p,opacity:m,strokeDasharray:f,events:g={},"data-testid":y}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(o)?o[0]??0:o,x=new Set(Array.isArray(p)?p:[]);let w=r||0,k=n||0;null!=i&&(w=i-b),null!=a&&(k=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;const e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return an("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":y,...null!=m&&{opacity:m},...f&&{strokeDasharray:f},...g,children:[!x.has("connector")&&dn(w,k,l,d,S,c),!x.has("subject")&&un(S,c,d,b,v),!x.has("note")&&cn(s,w,k,d)]})}function pn(e){const{noteData:t}=e,{screenCoordinates:o}=t,r="string"==typeof t.type?t.type:"label",n=t.eventListeners||t.events||{};if(t.coordinates&&o){const e=t.nx||o[0][0]+(t.dx??0),n=t.ny||o[0][1]+(t.dy??0),i=o.map((o,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:o[0],y:o[1],nx:e,ny:n});return nn(hn,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return nn("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return nn(hn,{"data-testid":"semiotic-annotation",events:n,...t,type:r},a)}import{packEnclose as mn}from"d3-hierarchy";import{area as fn,curveLinear as gn,curveMonotoneX as yn,curveMonotoneY as bn,curveStep as vn,curveStepAfter as xn,curveStepBefore as wn,curveBasis as kn,curveCardinal as Sn,curveCatmullRom as An}from"d3-shape";import Cn from"regression";function Mn(e,t){const o=t.scales?.x??t.scales?.time;return o?null!=e.x?o(e.x):t.xAccessor&&null!=e[t.xAccessor]?o(e[t.xAccessor]):null:null}function Pn(e,t){const o=t.scales?.y??t.scales?.value;return o?null!=e.y?o(e.y):t.yAccessor&&null!=e[t.yAccessor]?o(e[t.yAccessor]):null:null}function In(e){return null==e?null:e+""}function _n(e,t,o){return t.stickyPositionCache?.set(e,o),o}function Ln(e,t,o){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let r=o.pointNodes.length-1;r>=0;r--){const n=o.pointNodes[r];if(n.pointId===e.pointId)return _n(t,o,{x:n.x,y:n.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const o=t[t.length-1],r=e.scales?.x??e.scales?.time,n=e.scales?.y??e.scales?.value;if(!r||!n)return null;const i=o[e.xAccessor||"x"],a=o[e.yAccessor||"y"];return null==i||null==a?null:{x:r(i),y:n(a)}}(o);return r?_n(t,o,r):null}if("semantic"===r){const r=function(e,t,o){const r=function(e){return In(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const n=o.pointNodes?.find(e=>In(e.pointId)===r);if(n)return _n(t,o,{x:n.x,y:n.y});const i=o.data?.find(e=>function(e){return In(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const a=Mn(i,o),s=Pn(i,o);return null==a||null==s?null:_n(t,o,{x:a,y:s})}(e,t,o);if(r)return r}let n=null,i=null;if(null!=e.pointId&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===e.pointId);t&&(n=t.x,i=t.y)}if(null!=n&&null!=i||(n=Mn(e,o),i=Pn(e,o)),null!=n&&null!=i)return _n(t,o,{x:n,y:i});if("sticky"===r){const e=o.stickyPositionCache?.get(t);if(e)return e}return null}function Rn(e,t,o,r=50){return!(-r>e||e>(o.width||0)+r||-r>t||t>(o.height||0)+r)}import{jsx as Tn}from"react/jsx-runtime";var Nn={secondary:0,primary:3},$n=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function Bn(e){return!0===e?._annotationDeferred}function Dn(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Fn(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function En(e){return Math.max(.72,.95-.06*e)}import{jsx as zn,jsxs as jn}from"react/jsx-runtime";var On={linear:gn,monotoneX:yn,monotoneY:bn,step:vn,stepAfter:xn,stepBefore:wn,basis:kn,cardinal:Sn,catmullRom:An};function Hn(e,t,o,r){const n=[];return e.forEach((e,i)=>{let a;if(o){const n=o(e,i,r);a=null!=n?n:t(e,i,r)}else a=t(e,i,r);a&&n.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(o=e.annotation,"primary"===o?.emphasis||"secondary"===o?.emphasis?o.emphasis:null),confidence:Fn(e.annotation),readingOrder:null,rank:1};var o}),o=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Bn(e.annotation)),n=e.some(e=>null!=Dn(e.annotation)),i=e.some(e=>"layer"===Dn(e.annotation));if(!o&&!r&&!n)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=Nn[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:o,emphasis:r,readingOrder:n}=e,i=Bn(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=n){const e=null==r&&null!=n;a=Tn("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:En(n),"data-annotation-reading-order":n}:{},children:t.node},"annotation-emphasis-"+o)}const s=Dn(t.annotation);return s&&(a=Tn("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+o)),i&&(a=Tn("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return r&&s.unshift(Tn("style",{children:$n},"annotation-disclosure-style")),i&&s.unshift(Tn("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(n)}function Wn(e){return function(e,t,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const o=Ln(e,t,r);if(!o)return null;const{x:n,y:i}=o;if(!Rn(n,i,r))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return zn(pn,{noteData:{x:n,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+t)}case"x-threshold":{const o=Mn(null!=e.value?{...e,x:e.value}:e,r);if(null==o)return null;const n=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:12;const s=o>.6*(r.width||0),l=s?o-4:o+4,c=s?"end":"start";return jn("g",{opacity:e.opacity,children:[zn("line",{x1:o,y1:0,x2:o,y2:r.height||0,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&zn("text",{x:l,y:a,textAnchor:c,fill:n,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const o=Pn(null!=e.value?{...e,y:e.value}:e,r);if(null==o)return null;const n=e.color||"#f97316",i=e.labelPosition||"right";let a,s;return"left"===i?(a=4,s="start"):"center"===i?(a=(r.width||0)/2,s="middle"):(a=(r.width||0)-4,s="end"),jn("g",{opacity:e.opacity,children:[zn("line",{x1:0,y1:o,x2:r.width||0,y2:o,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&zn("text",{x:a,y:o-4,textAnchor:s,fill:n,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const o=(e.coordinates||[]).map(e=>({x:Mn({...e,type:"point"},r),y:Pn({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>o.length)return null;const n=mn(o),i=e.padding||10;return jn("g",{children:[zn("circle",{cx:n.x,cy:n.y,r:n.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&zn("text",{x:n.x,y:n.y-n.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const n=(e.coordinates||[]).map(e=>({x:Mn({...e,type:"point"},r),y:Pn({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const i=e.padding||10,a=n.map(e=>e.x),s=n.map(e=>e.y),[l,c]=o(a),[u,d]=o(s),h=l-i,p=c+i,m=u-i;return jn("g",{children:[zn("rect",{x:h,y:m,width:p-h,height:d+i-m,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&zn("text",{x:(h+p)/2,y:m-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const o=r.data||[],n="function"==typeof e.filter?o.filter(e.filter):e.field&&null!=e.value?o.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return zn("g",{children:n.map((t,o)=>{const n=Mn(t,r),a=Pn(t,r);if(null==n||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return zn("circle",{cx:n,cy:a,r:s,...l},"hl-"+o)})},"ann-"+t)}case"bracket":{const o=Mn(e,r),n=Pn(e,r);return zn(pn,{noteData:{x:o??0,y:n??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}},"ann-"+t)}case"trend":{const o=r.data||[];if(2>o.length)return null;const n=r.xAccessor||"x",i=r.yAccessor||"y",a="ordinal"===r.frameType,s="horizontal"===r.projection,l=a?n:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of o){const t=e[l];if(null==t)continue;const o=t+"";h.has(o)||(h.set(o,d.length),d.push(o))}u=o.map(e=>{const t=e[l],o=e[c];if(null==t||null==o)return null;const r=h.get(t+"");return null!=r?[r,+o]:null}).filter(e=>null!==e)}else u=o.map(e=>[e[n],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const p=r.scales?.x??r.scales?.time,m=r.scales?.y??r.scales?.value;if(!p||!m)return null;const f=e=>t=>{const o=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,o+1),n=t-o,i=e(d[o]);return i+(e(d[r])-i)*n},g=p,y=m;let b;if(a)if(s){const e=f(y);b=(t,o)=>[g(o),e(t)]}else{const e=f(g);b=(t,o)=>[e(t),y(o)]}else b=(e,t)=>[g(e),y(t)];const v=e.method||"linear";let x;x="loess"===v?function(e,t=.3){const o=e.length;if(2>o)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),n=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*o)),s=[];for(let e=0;o>e;e++){const t=n[e],r=n.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(a-1,o-1)]||1,c=[];for(let e=0;o>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,p=0,m=0;for(let e=0;o>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*n[e],h+=t*i[e],p+=t*n[e]*n[e],m+=t*n[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const f=u*p-d*d;if(1e-12>Math.abs(f))s.push([t,h/u]);else{const e=(u*m-d*h)/f;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3):("polynomial"===v?Cn.polynomial(u,{order:e.order||2}):Cn.linear(u)).points;const w=x.map(([e,t])=>{const[o,r]=b(e,t);return`${o},${r}`}).join(" "),k=e.color||"#6366f1",S=x[x.length-1],[A,C]=b(S[0],S[1]);return jn("g",{children:[zn("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&zn("text",{x:A+4,y:C-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const o=r.scales?.y??r.scales?.value,n=o?.(e.y0)??0,i=o?.(e.y1)??(r.height||0);return jn("g",{opacity:e.opacity,children:[zn("rect",{x:0,y:Math.min(n,i),width:r.width||0,height:Math.abs(i-n),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&zn("text",{x:(r.width||0)-4,y:Math.max(Math.min(n,i),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"x-band":{const o=r.scales?.x??r.scales?.time,n=null!=e.x0&&o?o(e.x0):null,i=null!=e.x1&&o?o(e.x1):null;return null==n||null==i?null:jn("g",{opacity:e.opacity,children:[zn("rect",{x:Math.min(n,i),y:0,width:Math.abs(i-n),height:r.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&zn("text",{x:Math.min(n,i)+4,y:13,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"envelope":{const o=r.data||[];if(2>o.length)return null;const n=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=o.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[n]-t[n]);if(2>u.length)return null;const d=On[r.curve||"linear"]||gn,h=fn().x(e=>i(e[n])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const p=e.fill||"#6366f1";return jn("g",{children:[zn("path",{d:h,fill:p,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&zn("text",{x:i(u[u.length-1][n])+4,y:a(u[u.length-1][s])-4,fill:p,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const o=r.data||[];if(2>o.length)return null;const n=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=o.map(e=>e[n]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,p=!1!==e.showBand,m=e.fill||"#6366f1",f=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",y=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=o.filter(e=>{const t=e[n];return null!=t&&Math.abs(t-l)>d*u});return jn("g",{children:[p&&zn("rect",{x:0,y:Math.min(b,v),width:r.width||0,height:Math.abs(v-b),fill:m,fillOpacity:f}),x.map((e,t)=>{const o=Mn(e,r),n=Pn(e,r);return null==o||null==n?null:zn("circle",{cx:o,cy:n,r:y,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&zn("text",{x:(r.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:m,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const o=r.data||[];if(3>o.length)return null;const n=r.xAccessor||"x",i=r.yAccessor||"y",a=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!a||!s)return null;const l=o.map(e=>[e[n],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=Cn.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,o,r)=>t+o*Math.pow(e,r),0)}else{const e=l.length;let t=0,o=0,r=0,n=0;for(const[e,i]of l)t+=e,o+=i,r+=e*e,n+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const a=(e*n-t*o)/i,s=(o-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,m=l.reduce((e,t)=>e+(t[0]-p)**2,0),f=e.confidence??.95,g=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,y=e.steps??5,b=l[u-1][0],v=(b-l[0][0])/Math.max(u-1,1),x=[];for(let e=1;y>=e;e++)x.push(b+e*v);const w=[];for(const e of x){const t=c(e),o=h*Math.sqrt(1+1/u+(m>0?(e-p)**2/m:0))*g;w.push({x:e,yCenter:t,yUpper:t+o,yLower:t-o})}const k=`M${w.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),A=`${a(b)},${s(c(b))}`,C=e.strokeColor||"#6366f1";return jn("g",{children:[zn("path",{d:k,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),zn("polyline",{points:`${A} ${S}`,fill:"none",stroke:C,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&zn("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:C,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let o,n;if(null!=e.px&&null!=e.py)o=e.px,n=e.py;else{const i=Ln(e,t,r);if(!i)return null;o=i.x,n=i.y}if(!Rn(o,n,r))return null;const i=e.width??32,a=e.height??32;return zn("foreignObject",{x:o+(e.dx??0)-i/2,y:n+(e.dy??0)-a/2,width:i,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:zn("div",{style:{width:i,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??zn("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const o=Ln(e,t,r);if(!o)return null;const{x:n,y:i}=o,a=n+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=zn("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?rn.cloneElement(c,{key:"ann-text-"+t}):jn("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[zn("line",{x1:n,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),rn.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const o=e.category;if(null==o)return null;const n=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,a=r.scales?.x,s=r.scales?.y,l=n(i)?i:n(a)?a:n(s)?s:null;if(!l)return null;const c=l(o+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,p=e.label;return jn("g",(r.projection?"vertical"===r.projection:l===a)?{children:[zn("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),p&&zn("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:p})]}:{children:[zn("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),p&&zn("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:p})]},"ann-"+t)}default:return null}}}var qn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Gn=new Set(["label","callout","callout-circle","callout-rect"]);function Yn(e){return"string"==typeof e?.type?e.type:""}function Vn(e){return!!e&&"object"==typeof e&&qn.has(Yn(e))}function Xn(e){return Gn.has(Yn(e))&&!function(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}(e)}function Un(e){return"primary"===e?.emphasis||!0===e?.defensive}function Kn(e,t,o={}){return"number"==typeof o.maxAnnotations&&Number.isFinite(o.maxAnnotations)?Math.max(0,Math.floor(o.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(o.areaPerAnnotation&&o.areaPerAnnotation>0?o.areaPerAnnotation:2e4))):1/0}function Qn(e){let t;const o=e?.emphasis;t="primary"===o?100:"secondary"===o?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var Zn=32,Jn=6,ei=4,ti=8,oi=72;var ri={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ni(e){if(!ii(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function ii(e){return Vn(e)}function ai(e,t){if(!e)return[];const o=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),n=[];let i="";for(const e of r)i&&i.length+e.length+1>o?(n.push(i),i=e):i=i?`${i} ${e}`:e;return i&&n.push(i),n}function si(e,t,o,r,n){const i=e+o,a=t+r;return Math.abs(o)>Math.abs(r)?{x:0>o?i-n.width-4:i+4,y:0>r?a-n.height:a,width:n.width,height:n.height}:{x:0>o?i-n.width:i,y:0>r?a-n.height-4:a+4,width:n.width,height:n.height}}function li(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function ci(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function ui(e,t,o,r,n,i,a,s){const l=li(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,o,r){const n=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(n+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(o-r)))*e.width}(l,n,i,s);for(const e of o)c+=12*ci(l,e);for(const e of r)c+=4*ci(l,e);return c}function di(e){const{annotations:t,context:o,defaultOffset:r=Zn,notePadding:n=Jn,markPadding:i=ei,edgePadding:a=ti,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=oi,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:m,cohesion:f,audience:g}=e,y=o.width||0,b=o.height||0,v="object"==typeof m?m:{},x=v.breakpoint??480,w=!!m&&x>=y,k=w&&!1!==v.preferShortText?t.map(ni):t,S=w&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,A=d||w&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),C=w&&!p?v.responsive??{minWidth:x}:p,M=w&&!f?v.cohesion:f;if(0===k.length||0>=y||0>=b)return k.slice();const P=[],I=function(e,t){return(e.pointNodes||[]).map(e=>{const o=Math.max(1,e.r||1)+t;return{x:e.x-o,y:e.y-o,width:2*o,height:2*o}})}(o,i);let _=!1;const L=k.map((e,t)=>{if(!ii(e))return e;const i=function(e,t,o){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&o.pointNodes){const e=o.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const n=e.coordinates,i=o.scales?.geoProjection;if(Array.isArray(n)&&n.length>=2&&i){const e=n[0],t=n[1];if("number"==typeof e&&"number"==typeof t){const o=i([e,t]);if(o&&"number"==typeof o[0]&&"number"==typeof o[1])return{x:o[0],y:o[1]}}}return o.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ln(e,t,o):{x:e.x,y:e.y}}(e,t,o);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,o=[...ai("string"==typeof e.title?e.title:void 0,t),...ai("string"==typeof e.label?e.label:void 0,t)],r=o.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*o.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return P.push(li(si(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),n)),e}var d;let h=null,p=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=ui(si(i.x,i.y,e.dx,e.dy,u),e,P,I,y,b,n,a);p>t&&(h=e,p=t)}if(!h)return e;const m=li(si(i.x,i.y,h.dx,h.dy,u),n);P.push(m);const f=Math.hypot(h.dx,h.dy),g=l&&f>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return _=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),R=_?L:k.slice();let T=R;if(h){let e=!1;const t=R.map(t=>{const o=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return o!==t&&(e=!0),o});T=e?t:R}{let e=!1;const t=T.map(t=>{if(!0!==t?.defensive)return t;const o=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const o="string"==typeof t.source?ri[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!o&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const n=[o,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${n})`)?e:{...e,label:i?`${i} (${n})`:`(${n})`}}(t);return o!==t&&(e=!0),o});T=e?t:T}const N=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const o=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===o.length?3:o.reduce((e,t)=>e+t,0)/o.length}(e);return t>2?4>t?1:.6:1.5}(g),o=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Kn(y,b,e))*t))},{deferred:r}=function(e){const{annotations:t,width:o,height:r}=e,n=Math.max(0,e.minVisible??1),i=Kn(o,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(o=e,Vn(o))};var o}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>Un(e.annotation)),c=s.filter(e=>!Un(e.annotation)).sort((e,t)=>Qn(t.annotation)-Qn(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,n-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],p=[];for(const{annotation:e,index:t,note:o}of a)!o||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:i}}({annotations:T,width:y,height:b,...o});for(const e of r)N.add(e)}if(C&&("object"==typeof C&&"number"==typeof C.minWidth?C.minWidth:480)>=y)for(const e of T)ii(e)&&"secondary"===e.emphasis&&N.add(e);if(N.size>0)for(const e of T)!0===e?.defensive&&N.delete(e);let $;return $=0===N.size?T:A?T.map(e=>N.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!N.has(e)),M?function(e,t){let o=!1;const r=e.map(e=>ii(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(o=!0,{...e,cohesion:t}):e);return o?r:e}($,M):$}import{useSyncExternalStore as hi}from"react";var pi={positions:new Map},mi=new Set;function fi(){for(const e of mi)e()}function gi(e,t){const o=pi.positions.get(e);if(o?.locked)return;if(!o||o.sourceId!==t)return;const r=new Map(pi.positions);r.delete(e),pi={positions:r},fi()}function yi(e,t){const o=pi.positions.get(e);if(!o?.locked)return;if(t&&o.sourceId!==t)return;const r=new Map(pi.positions);r.delete(e),pi={positions:r},fi()}function bi(){return pi}function vi(e){return mi.add(e),()=>mi.delete(e)}var xi={positions:new Map};function wi(){return()=>{}}function ki(){return xi}function Si(e,t,o){return"exact"===o?function(e,t){const o=e.domain(),r=o[0],n=o[o.length-1],i=r instanceof Date,a=r instanceof Date?r.getTime():r,s=n instanceof Date?n.getTime():n;if(2>t||a===s)return i?[new Date(a),new Date(s)]:[a,s];const l=(s-a)/(t-1),c=Array(t);for(let e=0;t>e;e++){const o=e===t-1?s:a+e*l;c[e]=i?new Date(o):o}return c}(e,t):e.ticks(t)}import{Fragment as Ai,jsx as Ci,jsxs as Mi}from"react/jsx-runtime";function Pi(e,t,o){if("edges"===e){if(t)return"start";if(o)return"end"}return"middle"}function Ii(e,t,o){if("edges"===e){if(t)return"hanging";if(o)return"auto"}return"middle"}function _i(e){if(0===e.length)return{min:null,max:null};let t=1/0,o=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>o&&(o=r.pixel);return{min:t,max:o}}function Li(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ri(e,t,o){if("left"===e||"right"===e){const r="left"===e?o:0,n="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+r;for(let e=0;i>e;e++){const o=8*(e+1);a+=`L${Math.min(8*e+4,t)},${r+4*n}`,a+=`L${Math.min(o,t)},${r}`}return a}{const r="bottom"===e?0:t,n="bottom"===e?1:-1,i=Math.ceil(o/8);let a=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${r+4*n},${Math.min(8*e+4,o)}`,a+=`L${r},${Math.min(t,o)}`}return a}}function Ti(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,scales:a,showAxes:s,axes:l,showGrid:c,xFormat:u,yFormat:d,axisExtent:h}=e,p=Br(()=>{if(!a)return[];const e=l?.find(e=>"bottom"===e.orient),o=e?.tickFormat||u||Ni,r=Math.max(2,Math.floor(t/70)),n=e?.ticks??5,i="exact"===h?Math.max(2,n):Math.min(n,r),s=e?.tickValues??Si(a.x,i,h),c=s.map(e=>e.valueOf()),d=s.map((e,t)=>({value:e,pixel:a.x(e),label:o(e,t,c)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return $i(d,Math.max(55,p+8))},[a,l,u,t,h]),m=Br(()=>{if(!a)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Ni,r=Math.max(2,Math.floor(o/30)),n=e?.ticks??5,i="exact"===h?Math.max(2,n):Math.min(n,r);return $i((e?.tickValues??Si(a.y,i,h)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[a,l,d,o,h]),f=c&&a,g=s&&a;if(!f&&!g)return null;const y=l?.find(e=>"bottom"===e.orient),b=l?.find(e=>"left"===e.orient),v=g&&(!y||!1!==y.baseline),x=g&&(!b||!1!==b.baseline),w=y?.jaggedBase||!1,k=b?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return Ci("svg",{width:r,height:n,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Mi("g",{transform:`translate(${i.left},${i.top})`,children:[f&&(()=>{const e=Li(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=Li(l?.find(e=>"left"===e.orient)?.gridStyle);return Mi("g",{className:"stream-grid",children:[p.map((t,r)=>Ci("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),m.map((e,o)=>Ci("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+o))]})})(),v&&!w&&Ci("line",{x1:0,y1:o,x2:t,y2:o,stroke:S,strokeWidth:1}),w&&Ci("path",{d:Ri("bottom",t,o),fill:"none",stroke:S,strokeWidth:1}),x&&!k&&Ci("line",{x1:0,y1:0,x2:0,y2:o,stroke:S,strokeWidth:1}),k&&Ci("path",{d:Ri("left",t,o),fill:"none",stroke:S,strokeWidth:1})]})})}function Ni(e,t,o){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function $i(e,t){if(2>=e.length)return e;const o=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-o[o.length-1].pixel)||o.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-o[o.length-1].pixel)?o[o.length-1]=r:o.push(r),o}function Bi(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,scales:a,showAxes:s,axes:l,xLabel:c,yLabel:u,yLabelRight:d,xFormat:h,yFormat:p,axisExtent:m,showGrid:f,title:g,legend:y,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:C,xValues:M,yValues:P,annotations:I,autoPlaceAnnotations:_,svgAnnotationRules:L,xAccessor:R,yAccessor:T,annotationData:N,pointNodes:$,curve:B,underlayRendered:D,canvasObscuresUnderlay:F=!0,linkedCrosshairName:E,linkedCrosshairSourceId:z,children:j}=e,O=Br(()=>{if(!s||!a)return[];const e=l?.find(e=>"bottom"===e.orient),o=e?.tickFormat||h||Ni,r=Math.max(2,Math.floor(t/70)),n=e?.ticks??5,i="exact"===m?Math.max(2,n):Math.min(n,r),c=e?.tickValues??Si(a.x,i,m),u=c.map(e=>e.valueOf()),d=c.map((e,t)=>({value:e,pixel:a.x(e),label:o(e,t,u)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),f=e?.autoRotate?Math.max(20,Math.min(p+8,55)):Math.max(55,p+8);let g=$i(d,f);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==m&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const n=o(e,g.length,u);f>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:n})}}return g},[s,a,l,h,t,m]),H=Br(()=>{if(!s||!a)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||p||Ni,r=Math.max(2,Math.floor(o/30)),n=e?.ticks??5,i="exact"===m?Math.max(2,n):Math.min(n,r);let c=$i((e?.tickValues??Si(a.y,i,m)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(c.length>1&&(c=c.filter((e,t)=>0===t||e.label+""!=c[t-1].label+"")),e?.includeMax&&c.length>0&&"exact"!==m&&!e?.tickValues){const e=a.y.domain()[1],o=a.y(e),r=c[c.length-1].pixel;if(Math.abs(o-r)>1){const n=t(e);22>Math.abs(o-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:e,pixel:o,label:n})}}return c},[s,a,l,p,o,m]),W=Br(()=>{if(!s||!a)return[];const e=l?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||Ni,r=Math.max(2,Math.floor(o/30)),n=e.ticks??5;return $i((e.tickValues??Si(a.y,"exact"===m?Math.max(2,n):Math.min(n,r),m)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[s,a,l,p,o,m]),q=Dr(new Map),G=Dr(I?.length??0),Y=I?.length??0;G.current!==Y&&(G.current=Y,q.current=new Map);const V=Br(()=>{if(!I||0===I.length)return null;const e=Wn(),r={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:R,yAccessor:T,width:t,height:o,data:N,frameType:"xy",pointNodes:$,curve:B,stickyPositionCache:q.current};return Hn(_?di({annotations:I,context:r,..."object"==typeof _?_:{}}):I,e,L,r)},[I,_,L,t,o,R,T,N,a,$,B]),X=function(e){const t=hi(e?vi:wi,e?bi:ki,e?bi:ki);return e?t.positions.get(e)??null:null}(E);return Fr(()=>{if(!X?.locked||!E)return;const e=e=>{"Escape"===e.key&&yi(E)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[X?.locked,E]),s||g||y||A||C||V&&V.length>0||f||j||X?Mi("svg",{role:"img",width:r,height:n,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Ci("title",{children:"string"==typeof g?g:"XY Chart"}),Ci("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),Mi("g",{transform:`translate(${i.left},${i.top})`,children:[f&&a&&(!D||F)&&(()=>{const e=Li(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=Li(l?.find(e=>"left"===e.orient)?.gridStyle);return Mi("g",{className:"stream-grid",children:[O.map((t,r)=>Ci("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),H.map((e,o)=>Ci("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+o))]})})(),s&&a&&(()=>{const e=l?.find(e=>"left"===e.orient),r=l?.find(e=>"bottom"===e.orient),n=!e||!1!==e.baseline,a=!r||!1!==r.baseline,s=e?.jaggedBase||!1,h=r?.jaggedBase||!1,p=r?.landmarkTicks,m=e?.landmarkTicks,f="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",y="var(--semiotic-text, #333)",b=!!r?.autoRotate&&O.length>1&&(()=>{const e=t/Math.max(O.length-1,1);return O.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),v=b?12:18,x=o+(b?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=r?.tickAnchor,C=e?.tickAnchor,M=_i(O),P=_i(H);return Mi("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Mi("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!D||F)&&a&&!h&&Ci("line",{x1:0,y1:o,x2:t,y2:o,stroke:f,strokeWidth:1}),(!D||F)&&h&&Ci("path",{d:Ri("bottom",t,o),fill:"none",stroke:f,strokeWidth:1}),O.map((e,t)=>{const r=!!p&&("function"==typeof p?p(e.value,t):Po(e.value,t>0?O[t-1].value:void 0));return Mi("g",{transform:`translate(${e.pixel},${o})`,children:[Ci("line",{y2:5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Ci("text",{y:v,textAnchor:b?"end":Pi(A,e.pixel===M.min,e.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?k:w},transform:b?"rotate(-45)":void 0,children:e.label}):Ci("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:Ci("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),c&&Ci("text",{x:t/2,y:x,textAnchor:"middle",fill:y,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:c})]}),Mi("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!D||F)&&n&&!s&&Ci("line",{x1:0,y1:0,x2:0,y2:o,stroke:f,strokeWidth:1}),(!D||F)&&s&&Ci("path",{d:Ri("left",t,o),fill:"none",stroke:f,strokeWidth:1}),H.map((e,t)=>{const o=!!m&&("function"==typeof m?m(e.value,t):Po(e.value,t>0?H[t-1].value:void 0));return Mi("g",{transform:`translate(0,${e.pixel})`,children:[Ci("line",{x2:-5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Ci("text",{x:-8,textAnchor:"end",dominantBaseline:Ii(C,e.pixel===P.min,e.pixel===P.max),fontWeight:o?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...o?k:w},children:e.label}):Ci("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:Ci("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?Ci("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:y,transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=l?.find(e=>"right"===e.orient);if(!e||0===W.length)return null;const r=!1!==e.baseline,n=e.landmarkTicks,a=e.label||d,s=e.tickAnchor,c=_i(W);return Mi("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&Ci("line",{x1:t,y1:0,x2:t,y2:o,stroke:f,strokeWidth:1}),W.map((e,o)=>{const r=!!n&&("function"==typeof n?n(e.value,o):Po(e.value,o>0?W[o-1].value:void 0));return Mi("g",{transform:`translate(${t},${e.pixel})`,children:[Ci("line",{x2:5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Ci("text",{x:8,textAnchor:"start",dominantBaseline:Ii(s,e.pixel===c.min,e.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?k:w},children:e.label}):Ci("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:Ci("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+o)}),a&&Ci("text",{x:t+i.right-15,y:o/2,textAnchor:"middle",fill:y,transform:`rotate(90, ${t+i.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),V,C&&a&&M&&P&&Mi(Ai,{children:[C.top&&Ci("g",{transform:"translate(0, 0)",children:Ci(on,{orient:"top",config:tn(C.top),values:M,scale:a.x,size:i.top,length:t})}),C.bottom&&Ci("g",{transform:`translate(0, ${o})`,children:Ci(on,{orient:"bottom",config:tn(C.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),C.left&&Ci("g",{transform:"translate(0, 0)",children:Ci(on,{orient:"left",config:tn(C.left),values:P,scale:a.y,size:i.left,length:o})}),C.right&&Ci("g",{transform:`translate(${t}, 0)`,children:Ci(on,{orient:"right",config:tn(C.right),values:P,scale:a.y,size:i.right,length:o})})]}),A,X&&X.sourceId!==z&&a?.x&&(()=>{const e=a.x(X.xValue);if(null==e||0>e||e>t)return null;const r=X.locked;return Ci("line",{x1:e,y1:0,x2:e,y2:o,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),j]}),g&&Ci("text",{x:r/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof g?g:null}),Kr({legend:y,totalWidth:r,totalHeight:n,margin:i,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w})]}):null}import*as Di from"react";import{arc as Fi}from"d3-shape";function Ei(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function zi(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const o=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,o));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}var ji=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Oi(e){const{innerRadius:t,outerRadius:o,startAngle:r,endAngle:n}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=ji(o,r),t=ji(o,n);return`M0,0 L${e.x},${e.y} A${o},${o} 0 ${n-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=ji(o,r),a=ji(o,n),s=ji(t,n),l=ji(t,r),c=n-r>Math.PI?1:0;return`M${e.x},${e.y} A${o},${o} 0 ${c} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}const a=Math.max(0,Math.min(e.cornerRadius??0,(o-t)/2));if(0===a)return Oi({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const s=Math.asin(Math.min(1,a/Math.max(1e-9,o-a))),l=i?0:Math.asin(Math.min(1,a/Math.max(1e-9,t+a))),c=n-r,u=e.roundStart&&e.roundEnd?c/2:c,d=!!e.roundStart&&u>s,h=!!e.roundEnd&&u>s;if(!d&&!h)return Oi({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const p=r+(d?s:0),m=n-(h?s:0),f=r+(d?l:0),g=n-(h?l:0),y=ji(o,p),b=ji(o,m),v=(o-a)*Math.cos(s),x=ji(v,r),w=ji(v,n),k=i?null:ji(t,g),S=i?null:ji(t,f),A=i?0:(t+a)*Math.cos(l),C=i?null:ji(A,r),M=i?null:ji(A,n),P=m-p>Math.PI?1:0,I=i?0:g-f>Math.PI?1:0;let _="";if(d)_+=`M${x.x},${x.y}`,_+=` A${a},${a} 0 0 1 ${y.x},${y.y}`;else{const e=ji(o,r);_+=`M${e.x},${e.y}`}if(h)_+=` A${o},${o} 0 ${P} 1 ${b.x},${b.y}`,_+=` A${a},${a} 0 0 1 ${w.x},${w.y}`;else{const e=ji(o,n);_+=` A${o},${o} 0 ${P} 1 ${e.x},${e.y}`}if(i)_+=" L0,0";else{if(h)_+=` L${M.x},${M.y}`,_+=` A${a},${a} 0 0 1 ${k.x},${k.y}`;else{const e=ji(t,n);_+=` L${e.x},${e.y}`}if(d)_+=` A${t},${t} 0 ${I} 0 ${S.x},${S.y}`,_+=` A${a},${a} 0 0 1 ${C.x},${C.y}`;else{const e=ji(t,r);_+=` A${t},${t} 0 ${I} 0 ${e.x},${e.y}`}}return _+=" Z",_}function Hi(e){const t=Oi({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),o=[],r=e.colors;if(r.length>0){const t=(e.endAngle-e.startAngle)/r.length;for(let n=0;r.length>n;n++)o.push({d:Oi({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+n*t,endAngle:e.endAngle}),color:r[n]})}return{clipPath:t,slices:o}}import{jsx as Wi,jsxs as qi}from"react/jsx-runtime";var Gi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Yi(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function Vi(e,t,o){const r=Lt(e.symbolType,e.size,e.path);return Wi("path",{d:r,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Yi(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${o??""}symbol-${t}`)}function Xi(e,t,o,r){const n=e.glyph;if(!n?.parts?.length||0>=e.size)return null;const i=Ro(n,e.size);if(0>=i.scale)return null;const a=`translate(${t},${o})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Bo(n,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?Ui(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>n.parts.map((o,r)=>{const n=t?"none"===o.fill?void 0:t:To(o.fill,s,e.accent),i=t?o.stroke&&"none"!==o.stroke?t:void 0:To(o.stroke??"none",s,e.accent);return n||i?Wi("path",{d:o.d,fill:n??"none",stroke:i,strokeWidth:i?o.strokeWidth??1:void 0,strokeLinecap:o.strokeLinecap,strokeLinejoin:o.strokeLinejoin,opacity:o.opacity},r):null});return qi("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&Wi("clipPath",{id:c,children:Wi("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?Wi("g",{children:d(e.ghostColor)}):null,l&&c?Wi("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function Ui(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Ki(e,t,o){switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([e,t])=>`${e},${t}`).join("L");return Wi("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const n=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(r.clipRect){const e=`${o?o+"-":""}area-clip-${t}`;return qi("g",{children:[Wi("defs",{children:Wi("clipPath",{id:e,children:Wi("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})}),Wi("path",{d:n,fill:Yi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return Wi("path",{d:n,fill:Yi(r.style.fill),fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+t)}case"point":{const o=e;return Wi("circle",{cx:o.x,cy:o.y,r:o.r,fill:Yi(o.style.fill),opacity:o.style.opacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+t)}case"symbol":return Vi(e,t);case"glyph":return Xi(e,e.x,e.y,`${o??""}glyph-${e.pointId??t}`);case"rect":{const o=e;return Wi("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Yi(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+t)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(o.fill),a=.299*r+.587*n+.114*i>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return qi("g",{children:[Wi("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),Wi("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px",children:e})]},"heatcell-"+t)}return Wi("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+t)}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),i=o.isUp?o.upColor:o.downColor;return qi("g",{children:[Wi("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),Wi("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var Qi="undefined"==typeof window||"undefined"==typeof document;import{useEffect as Zi,useLayoutEffect as Ji,useRef as ea,useState as ta,useSyncExternalStore as oa}from"react";var ra="undefined"!=typeof window?Ji:Zi;function na(){const[e,t]=ta(!1);return ra(()=>{t(!0)},[]),e}var ia=()=>()=>{},aa=()=>!1,sa=()=>!0;function la(){const e=oa(ia,aa,sa);return ea(e).current}function ca(e){const{hydrated:t,wasHydratingFromSSR:o,storeRef:r,dirtyRef:n,renderFnRef:i,cancelRender:a,cleanup:s}=e;ra(()=>{t&&o&&r.current?.cancelIntroAnimation?.(),n.current=!0,a?.(),i.current()},[t,o]);const l=ea(s);l.current=s,Zi(()=>()=>l.current?.(),[])}import{useRef as ua}from"react";function da(e){const t=ua(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return pa(e,t);if(!ma(e)||!ma(t))return!1;const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const r of o){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const o=e[r],n=t[r];if(!Object.is(o,n))if(Array.isArray(o)&&Array.isArray(n)){if(!pa(o,n))return!1}else{if(!ma(o)||!ma(n))return!1;if(!ha(o,n))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function ha(e,t){const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const r of o){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function pa(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(!Object.is(e[o],t[o]))return!1;return!0}function ma(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function fa(e,t){const{background:o,hasBackgroundGraphics:r=!1,themeBackground:n="",x:i=0,y:a=0,width:s,height:l}=t;if("transparent"===o)return!1;if(r)return!1;const c=o||(n&&"transparent"!==n?n:"")||null;if(!c)return!1;const u=Go(e,c);return!!u&&(e.fillStyle=u,e.fillRect(i,a,s,l),!0)}function ga(e){return!!(e.dirtyOrRebuilt||e.transitioning||e.animationTicked||e.continuous||e.liveEncoding||e.forced)}function ya(e,t){return e||t}var ba={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",primary:"#007bff",background:""};function va(e,t){const o=e.trim();if(/^#[0-9a-f]{3}$/i.test(o)){const e=o[1],r=o[2],n=o[3];return`#${e}${e}${r}${r}${n}${n}${t}`}if(/^#[0-9a-f]{6}$/i.test(o))return`${o}${t}`;const r=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:o}import*as xa from"react";import*as wa from"react";import{jsx as ka}from"react/jsx-runtime";var Sa=wa.createContext(null);function Aa({children:e}){const[t,o]=wa.useState(!1),r=wa.useCallback(()=>o(e=>!e),[]),n=wa.useMemo(()=>({visible:t,setVisible:o,toggle:r}),[t,r]);return ka(Sa.Provider,{value:n,children:e})}function Ca(){return wa.useContext(Sa)}function Ma(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[o,r]of Object.entries(e))o.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[o]=r):"string"==typeof r?t[o]=r:"boolean"==typeof r?t[o]=r+"":r instanceof Date&&(t[o]=r.toISOString().slice(0,10)));return t}function Pa(e){return e&&"object"==typeof e?e:{}}function Ia(e){return Pa(e.accessibility).tableFields??e.accessibleDatum??e.datum}function _a(e){const t=[];if(!Array.isArray(e))return t;const o=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(o)break;t.push({label:"Point",values:Ma(Ia(r))});break;case"line":case"area":{const e=Ia(r),o=Array.isArray(e)?e:[],n="line"===r.type?"Line point":"Area point";for(const e of o)t.push({label:n,values:Ma(e)});break}case"rect":{const e=Ia(r),o=null!=e&&"object"==typeof e?e:{},n=o.category??r.group??"",i=o.value??o.__aggregateValue??o.total,a=Ma(o);null==a.category&&""!==n&&(a.category=n+""),null==a.value&&null!=i&&(a.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:a});break}case"heatcell":{const e=Ma(Ia(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Ia(r),o=Ma(e);if(null==o.category){const t=Pa(e),r=t.category??t.label;null!=r&&(o.category=r+"")}t.push({label:"Wedge",values:o});break}case"circle":t.push({label:"Node",values:Ma(Ia(r))});break;case"arc":t.push({label:"Arc",values:Ma(Ia(r))});break;case"candlestick":t.push({label:"Candlestick",values:Ma(Ia(r))});break;case"geoarea":{const e=Pa(Ia(r)),o=Ma(e);if(null==o.name){const t=Pa(e.properties).name??e.name;null!=t&&(o.name=t+"")}t.push({label:"Region",values:o});break}}}catch{}return t}import{jsx as La,jsxs as Ra}from"react/jsx-runtime";var Ta={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Na(e,t){if(!e||0===e.length)return t+", empty";const o={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";o[e]=(o[e]||0)+1}if(0===Object.keys(o).length)return t+", empty";const r=[],n={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(o).sort((e,t)=>{const o=i.indexOf(e),r=i.indexOf(t);return(-1===o?999:o)-(-1===r?999:r)});for(const e of a)r.push(`${o[e]} ${n[e]||e}`);return`${t}, ${r.join(", ")}`}function $a(e,t,o){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?o+", empty":`${o}, ${r.join(", ")}`}var Ba=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Da="semiotic-accessible-data-table",Fa=Da+" semiotic-accessible-data-table-hidden",Ea=Da+" semiotic-accessible-data-table-visible",za=Ea+" semiotic-accessible-data-table-network",ja={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Oa={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Ha={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Wa={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},qa={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Ga={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Ya={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Va={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Xa({scene:e,chartType:t,tableId:o,chartTitle:r}){const[n,i]=xa.useState(!1),[a,s]=xa.useState(5),l=Ca(),c=l?.visible??!1,u=n||c,d=xa.useRef(null),h=r?"Data summary for "+r:o?`Data summary for ${t} ${o}`:"Data summary for "+t;xa.useEffect(()=>{u||s(5)},[u]);const p=xa.useCallback(e=>{e.target===e.currentTarget&&(n||c||i(!0))},[n,c]),m=xa.useCallback(e=>{c||d.current?.contains(e.relatedTarget)||i(!1)},[c]);if(!e||0===e.length)return o?La("span",{id:o,tabIndex:-1,style:Ta}):null;if(!u)return La("div",{id:o,className:Fa,tabIndex:-1,onFocus:p,style:Ta,role:"region","aria-label":h,children:Ra("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const f=_a(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const o of e)if(o&&o.values)for(const e of Object.keys(o.values))t.add(e);const o=[];for(const r of t){const t=[],n=new Set;for(const o of e){if(!o||!o.values)continue;const e=o.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&n.add(e+""))}if(t.length>0){let e=t[0],n=t[0],i=0;for(const o of t)e>o&&(e=o),o>n&&(n=o),i+=o;o.push({name:r,count:t.length,numeric:!0,min:e,max:n,mean:i/t.length})}else if(n.size>0){const e=Array.from(n);o.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return o}(f),y=function(e,t){const o=[e+" data points."];for(const e of t)if(e.numeric)o.push(`${e.name}: ${Ba(e.min)} to ${Ba(e.max)}, mean ${Ba(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");o.push(`${e.name}: ${r}.`)}return o.join(" ")}(f.length,g),b=Math.min(a,f.length),v=f.slice(0,b),x=f.length-b,w=new Set;for(const e of v)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return Ra("div",{ref:d,id:o,className:Ea,tabIndex:-1,onBlur:m,style:ja,role:"region","aria-label":h,children:[La("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Ha,children:"×"}),La("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Oa,children:y}),Ra("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Wa,children:[La("caption",{className:"semiotic-accessible-data-table-caption",style:Ya,children:x>0?`First ${b} of ${f.length} data points`:`All ${f.length} data points`}),La("thead",{children:Ra("tr",{children:[La("th",{style:qa,children:"type"}),k.map(e=>La("th",{style:qa,children:e},e))]})}),La("tbody",{children:v.map((e,t)=>Ra("tr",{children:[La("td",{style:Ga,children:e.label}),k.map(t=>{return La("td",{style:Ga,children:(o=e.values[t],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Ba(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},t);var o})]},t))})]}),x>0&&Ra("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:Va,children:["Show ",Math.min(25,x)," more"," ",1===x?"row":"rows"," (",x," remaining)"]})]})}function Ua({nodes:e,edges:t,chartType:o,tableId:r,chartTitle:n}){const[i,a]=xa.useState(!1),[s,l]=xa.useState(5),c=Ca(),u=c?.visible??!1,d=i||u,h=n?"Data summary for "+n:r?`Data summary for ${o} ${r}`:"Data summary for "+o,p=xa.useRef(null);xa.useEffect(()=>{d||l(5)},[d]);const m=xa.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),f=xa.useCallback(e=>{u||p.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return r?La("span",{id:r,tabIndex:-1,style:Ta}):null;if(!d)return La("div",{id:r,className:Fa,tabIndex:-1,onFocus:m,style:Ta,role:"region","aria-label":h,children:Ra("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],y=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,w=new Map;for(const e of y){if(!e||"object"!=typeof e)continue;const t=e.datum??e,o="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,n="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=o&&""!==o){const e=o+"";v.set(e,(v.get(e)??0)+1),w.set(e,(w.get(e)??0)+n)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+n)}}const k=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const o=t.datum?.id??t.id,r=null!=o?o+"":"node-"+e,n=b.get(r)??0,i=v.get(r)??0,a=x.get(r)??0,s=w.get(r)??0;k.push({id:r,degree:n+i,inDeg:n,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}k.sort((e,t)=>t.degree-e.degree);let S=0,A=0;if(k.length>0){let e=0;for(const t of k)e+=t.degree,t.degree>A&&(A=t.degree);S=e/k.length}const C=y.some(e=>{const t=e?.datum??e;return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${k.length} nodes, ${y.length} edges.`];k.length>0&&M.push(`Mean degree: ${Ba(S)}, max degree: ${A}.`);const P=Math.min(s,k.length),I=k.slice(0,P),_=k.length-P;return Ra("div",{ref:p,id:r,className:za,tabIndex:-1,onBlur:f,style:ja,role:"region","aria-label":h,children:[La("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Ha,children:"×"}),La("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Oa,children:M.join(" ")}),Ra("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+o,style:Wa,children:[La("caption",{className:"semiotic-accessible-data-table-caption",style:Ya,children:_>0?`Top ${P} of ${k.length} nodes by degree`:`All ${k.length} nodes by degree`}),La("thead",{children:Ra("tr",{children:[La("th",{style:qa,children:"id"}),La("th",{style:qa,children:"degree"}),La("th",{style:qa,children:"in"}),La("th",{style:qa,children:"out"}),C&&La("th",{style:qa,children:"w. degree"}),C&&La("th",{style:qa,children:"w. in"}),C&&La("th",{style:qa,children:"w. out"})]})}),La("tbody",{children:I.map((e,t)=>Ra("tr",{children:[La("td",{style:Ga,children:e.id}),La("td",{style:Ga,children:e.degree}),La("td",{style:Ga,children:e.inDeg}),La("td",{style:Ga,children:e.outDeg}),C&&La("td",{style:Ga,children:Ba(e.wDegree)}),C&&La("td",{style:Ga,children:Ba(e.wInDeg)}),C&&La("td",{style:Ga,children:Ba(e.wOutDeg)})]},t))})]}),_>0&&Ra("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:Va,children:["Show ",Math.min(25,_)," more"," ",1===_?"node":"nodes"," (",_," remaining)"]})]})}function Ka({summary:e}){return e?La("div",{role:"note",style:Ta,children:e}):null}function Qa({tableId:e}){return La("a",{href:"#"+e,style:Ta,onClick:t=>{t.preventDefault();const o=document.getElementById(e);o&&requestAnimationFrame(()=>o.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ta)},children:"Skip to data table"})}function Za({hoverPoint:e}){let t="";if(e){const o=e.data||e;t="object"==typeof o?"Data point: "+Object.entries(o).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+o}return La("div",{"aria-live":"polite","aria-atomic":"true",style:Ta,children:t})}import{jsx as Ja}from"react/jsx-runtime";var es="var(--semiotic-focus, #005fcc)";function ts({active:e,hoverPoint:t,margin:o,size:r,shape:n="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+o.left,c=t.y+o.top;let u;if("geoarea"!==n&&"path"!==n||!s)if("rect"===n&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=Ja("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:es,strokeWidth:2,strokeDasharray:"4,2"})}else u=Ja("circle","wedge"===n?{cx:l,cy:c,r:12,fill:"none",stroke:es,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:es,strokeWidth:2,strokeDasharray:"4,2"});else u=Ja("g",{transform:`translate(${o.left},${o.top})`,children:Ja("path",{d:s,fill:"none",stroke:es,strokeWidth:2.5,strokeDasharray:"6,3"})});return Ja("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as os from"react";function rs(e,t){return"touch"===t?Math.max(e,24):e}function ns(e){return Array.isArray(e)?e[0]:e}function is(e,t,o,r){return{data:ns(e),x:t,y:o,__semioticHoverData:!0,...r}}var as=["name","label","title"],ss=["type","kind","category","group","class","status","role","shape"],ls=["value","amount","total","count","weight","score"],cs=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function us(e,t){for(const o of t){const t=e.find(e=>e.lower===o);if(t)return t}}function ds(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const o=t.maxEntries??6,r=!1!==t.skipPositional,n=[];for(const[t,o]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&cs.has(t.toLowerCase()))continue;if(null==o)continue;const e=typeof o;("string"===e||"number"===e||"boolean"===e||o instanceof Date)&&n.push({key:t,lower:t.toLowerCase(),value:o})}if(0===n.length)return{entries:[]};let i=n.findIndex(e=>as.includes(e.lower));const a=i>=0;0>i&&(i=n.findIndex(e=>"id"===e.lower)),0>i&&(i=n.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:n[i];let l=n.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=us(l,ss),u=us(l,ls),d=new Set(ss),h=new Set(ls),p=[];c&&p.push({key:c.key,value:c.value}),u&&p.push({key:u.key,value:u.value});for(const e of l){if(p.length>=o)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||p.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:p}}import{jsx as hs,jsxs as ps}from"react/jsx-runtime";var ms={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function fs(e,t){return"function"==typeof t?t(e):e[t]}function gs(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 ys(e={}){const{fields:t,title:o,format:r,style:n={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(o){const t=fs(e,o);a=gs(t,r)}if(t&&t.length>0)t.forEach(t=>{let o,n,i;"string"==typeof t?(o=t,n=t,i=r):(o=t.label,n=t.accessor||t.key||"",i=t.format||r);const a=fs(e,n);s.push({label:o,value:gs(a,i)})});else if(!o){const t=["value","y","name","id","label"];for(const o of t)if(void 0!==e[o]){a=gs(e[o],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=gs(e[t[0]],r))}}const l={...ms,...n};return ps("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&hs("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>ps("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&ps("span",{children:[e.label,": "]}),e.value]},t))]})}}function bs(e={}){const{fields:t=[],title:o,format:r,style:n={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(o){const t=fs(e,o);l.push({value:gs(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let o,n,i;"string"==typeof t?(o=t,n=t,i=r):(o=t.label,n=t.accessor||t.key||"",i=t.format||r);const s=gs(fs(e,n),i);l.push({label:a?o:void 0,value:s})});else{const t=ds(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:gs(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:a?e.key:void 0,value:gs(e.value,r)})})}const c={...ms,...n};return Array.isArray(l)&&0!==l.length?hs("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>ps("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&ps("strong",{children:[e.label,s]}),e.value]},t))}):null}}function vs(){return e=>{const t=e.allSeries;if(!t||0===t.length)return hs("div",{className:"semiotic-tooltip",style:ms,children:hs("div",{children:gs(e.data?.value??e.data?.y)})});const o=e.xValue??e.data?.time??e.data?.x;return ps("div",{className:"semiotic-tooltip",style:ms,children:[null!=o&&hs("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:gs(o)}),t.map((e,t)=>ps("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[hs("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),hs("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),hs("span",{style:{fontWeight:500,fontSize:"0.85em"},children:gs(e.value)})]},t))]})}}function xs(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let o=ns(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);("node"===e?.nodeOrEdge&&"number"==typeof o?.x0&&"number"==typeof o?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof o?.sankeyWidth)&&o.data&&"object"==typeof o.data&&(o=o.data);const r=t(o);return null==r?null:hs("div",{className:"semiotic-tooltip",style:ms,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?ys(e):ys())}}import{jsx as ws}from"react/jsx-runtime";function ks({x:e,y:t,containerWidth:o,containerHeight:r,margin:n,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=os.useRef(null),[u,d]=os.useState(null);os.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,o,r]);let h;h=u?`translate(${u.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const p=function(e){if(!os.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const o=e.props;if(!0===o["data-semiotic-tooltip-chrome"])return!0;if("true"===o["data-semiotic-tooltip-chrome"])return!0;const r=o.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),m=p?null:ms;return l?ws("div",{ref:c,className:p?a:(a+" semiotic-tooltip").trim(),style:{...m||{},position:"absolute",left:n.left+e,top:n.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}import*as Ss from"react";import{useCallback as As,useEffect as Cs,useLayoutEffect as Ms,useMemo as Ps,useRef as Is}from"react";import{useState as _s,useEffect as Ls}from"react";function Rs(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const o=e;return o.addListener(t),()=>o.removeListener(t)}function Ts(){const[e,t]=_s(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Ls(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),Rs(e,e=>t(e.matches))},[]),e}import{useRef as Ns,useState as $s,useEffect as Bs}from"react";function Ds(e,t,o){const r=Ns(null),[n,i]=$s(null);return Bs(()=>{if(!t&&!o)return;const e=r.current;if(!e)return;const n=new ResizeObserver(e=>{for(const t of e){const{width:e,height:o}=t.contentRect;i(t=>t&&t.w===e&&t.h===o?t:{w:e,h:o})}});return n.observe(e),()=>n.disconnect()},[t,o]),[r,[t&&n?n.w:e[0],o&&n?n.h:e[1]]]}var Fs="undefined"==typeof window?Cs:Ms,Es={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function zs(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function js(e){const t=Ts(),o=Is(t);o.current=t;const[r,n]=Ds(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=Ps(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),a=n[0]-i.left-i.right,s=n[1]-i.top-i.bottom,l=zs(e.foregroundGraphics,n,i),c=zs(e.backgroundGraphics,n,i),u=ee(e=>e.theme),{transition:d,introEnabled:h}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(o||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+Ss.useId(),m=Is(null),f=Is(e.frameScheduler??Es);f.current=e.frameScheduler??Es;const g=Is(null),y=Is(!1),b=Is(()=>{}),v=As(()=>{if(null!==m.current||y.current)return;const e=f.current;let t=!1,o=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!o;e&&(y.current=!0),m.current=null,g.current=null;try{b.current()}finally{e&&(y.current=!1)}});o=!0,t||(m.current=r,g.current=e)},[]),x=As(()=>{null!==m.current&&((g.current??f.current).cancelAnimationFrame(m.current),m.current=null,g.current=null)},[]);Cs(()=>()=>{x()},[x]);const w=Is(()=>{}),k=Is(()=>{}),S=Is(null),A=Is(null),C=Is(null),M=As(()=>{const e=S.current;S.current=null,e&&w.current(e)},[]),P=As(e=>{if(S.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===A.current){const e=f.current;let t=!1;const o=e.requestAnimationFrame(()=>{t=!0,A.current=null,C.current=null,M()});t||(A.current=o,C.current=e)}},[M]),I=As(()=>{S.current=null,null!==A.current&&((C.current??f.current).cancelAnimationFrame(A.current),A.current=null,C.current=null),k.current()},[]);Cs(()=>()=>{S.current=null,null!==A.current&&((C.current??f.current).cancelAnimationFrame(A.current),A.current=null,C.current=null)},[]);const _=e.themeDirtyRef;return Fs(()=>{_&&(Oo++,_.current=!0,v())},[u,v,_]),{reducedMotion:t,reducedMotionRef:o,responsiveRef:r,size:n,margin:i,adjustedWidth:a,adjustedHeight:s,resolvedForeground:l,resolvedBackground:c,currentTheme:u,transition:d,introEnabled:h,tableId:p,rafRef:m,renderFnRef:b,scheduleRender:v,cancelRender:x,hoverHandlerRef:w,hoverLeaveRef:k,onPointerMove:P,onPointerLeave:I}}function Os(e,t,o,r){const n=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,a=!i&&e.hasActivePulsesAt(t),s=!(o||i||!a&&!n)&&e.refreshPulse(t);return r.current=a,{changed:s,pending:a}}function Hs(e,t,o,r){const n=e.getContext("2d");if(!n)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),n.setTransform(s,0,0,l,0,0),n.translate(o.left,o.top),n}function Ws(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}import{useCallback as qs}from"react";function Gs(e,t){if(!t)return[];const o=new Set,r=[];for(const n of e){if(!n||"object"!=typeof n)continue;const e="function"==typeof t?t(n):n[t];if(null==e)continue;const i=e+"";o.has(i)||(o.add(i),r.push(i))}return r}function Ys(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function Vs(e,t,o,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}function Xs(e,t,o){return r=>{if(!r||!o||!e.fn&&!t.fn)return r;let n=!1;const i=r.map(o=>{const r=e.fn&&e.key&&!(e.key in o),i=t.fn&&t.key&&!(t.key in o);if(!r&&!i)return o;n=!0;const a={...o};return r&&(a[e.key]=e.fn(o)),i&&(a[t.key]=t.fn(o)),a});return n?i:r}}var Us=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ks=3156e7;function Qs(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Ks>t?e=>{const t=new Date(e);return`${Us[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Ks>t?e=>{const t=new Date(e);return`${Us[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Zs(e){if(!e)return;const t=[];for(const o of e)if("point"===o.type)t.push(o);else if("symbol"===o.type)t.push({pointId:o.pointId,x:o.x,y:o.y,r:Rt(o.size)});else if("glyph"===o.type){const e=Do(o.glyph,o.size);t.push({pointId:o.pointId,x:o.x+e.centerDx,y:o.y+e.centerDy,r:e.radius})}return t}import{line as Js}from"d3-shape";function el(e,t,o){let r=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(r=o.color):e>o.value&&(r=o.color);return r}function tl(e,t,o,r,n,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const o=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(o*o+r*r))}const s=a[a.length-1];if(0===s)return;const l=Math.min(.2*s,40);e.strokeStyle=o,e.lineWidth=r,e.lineCap=i;for(let o=0;t.length-1>o;o++){const r=(a[o]+a[o+1])/2;let i=n;l>r&&(i*=r/l),l>s-r&&(i*=(s-r)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[o][0],t[o][1]),e.lineTo(t[o+1][0],t[o+1][1]),e.stroke()}}var ol=(e,t,o,r)=>{const n=t.filter(e=>"line"===e.type);for(const t of n){if(2>t.path.length)continue;const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const n=t.style.stroke||"#007bff",i=Go(e,n)||n,a=t.style.strokeWidth||2,s=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=a,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){tl(e,t.path,i,a,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=or(t.curve),u=s&&s.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=i;const o=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(d[r]+d[r+1])*o,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let o=function(t,o,r){e.beginPath(),e.strokeStyle=t,e.moveTo(o,r),d=!0},r=function(){d&&(e.stroke(),d=!1)},n=null,a=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,p]=t.path[d],m=l[d],f=el(m,s,i);if(null!==n&&null!==u&&null!==c){if(f===u)e.lineTo(h,p);else{const t=[];for(const e of s){const o=e.value;(c>o||o>m)&&(o>c||m>o)||c===o||m===o||t.push({t:(o-c)/(m-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=n+(h-n)*l.t,u=a+(p-a)*l.t,d=el(c+(m-c)*Math.min(l.t+1e-4,1),s,i);e.lineTo(t,u),r(),o(d,t,u)}e.lineTo(h,p)}n=h,a=p,c=m,u=f}else o(f,h,p),n=h,a=p,c=m,u=f}r()}else{e.beginPath();const o=t.strokeGradient&&t.path.length>=2?ir(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=o||i,c)Js().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[o,r]=t.path[0];e.moveTo(o,r);for(let o=1;t.path.length>o;o++)e.lineTo(t.path[o][0],t.path[o][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=rr(e,t.style.fill,t.style.fill),c&&!u)Js().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[o,r]=t.path[0];e.moveTo(o,r);for(let o=1;t.path.length>o;o++)e.lineTo(t.path[o][0],t.path[o][1])}const o=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(o,r.height),e.closePath(),e.fill()}void 0!==o&&1>o&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function rl(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function nl(e,t,o=.3){rl(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function il(e,t,o=.6){if(!rl(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,n=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(n,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*o,e.stroke()}function al(e,t,o,r=.35){rl(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",o?e.fill(o):e.fill())}import{area as sl,line as ll}from"d3-shape";function cl(e,t){const o=or(t.curve);if(!o||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath()}else{const r=sl().x(e=>e[0]).y0((e,o)=>t.bottomPath[o][1]).y1(e=>e[1]).curve(o).context(e);e.beginPath(),r(t.topPath)}}var ul=(e,t,o,r)=>{const n=t.filter(e=>"area"===e.type);for(const t of n){if(2>t.topPath.length)continue;let o=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),o=!0);const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const i=rr(e,t.style.fill,"#4e79a7"),a=t._decayOpacities;if(a&&a.length===t.topPath.length){const o=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(a[r]+a[r+1])*o,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(a[o]+a[o+1]),e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=t.style.opacity??1;if(cl(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const n=nr(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,o,0,r);e.fillStyle=n||i,e.globalAlpha=s}else e.globalAlpha=(t.style.fillOpacity??.7)*s,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(cl(e,t),al(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=s;const o=t.strokeGradient&&t.topPath.length>=2?ir(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=o||Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=or(t.curve);if(e.beginPath(),r)ll().x(e=>e[0]).y(e=>e[1]).curve(r).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1])}e.stroke()}void 0!==n&&1>n&&e.restore(),o&&e.restore(),e.globalAlpha=1}},dl=(e,t,o,r)=>{const n=t.filter(e=>"point"===e.type);if(0!==n.length){e.save();try{const t=e.globalAlpha;for(const o of n)e.beginPath(),e.arc(o.x,o.y,o.r,0,2*Math.PI),e.globalAlpha=t*(o.style.opacity??o.style.fillOpacity??1),e.fillStyle=rr(e,o.style.fill,"#4e79a7"),e.fill(),o.style.stroke&&(e.strokeStyle=rr(e,o.style.stroke,o.style.stroke),e.lineWidth=o.style.strokeWidth||1,e.stroke()),il(e,o)}finally{e.restore()}}},hl=new Map;function pl(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let o=hl.get(t);return o||(o=new Path2D(Lt(e.symbolType,e.size)),hl.size>256&&hl.clear(),hl.set(t,o)),o}catch{return null}}var ml=(e,t)=>{const o=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const n=pl(t);if(!n)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*i*(t.style.fillOpacity??1),e.fillStyle=rr(e,t.style.fill,"#4e79a7"),e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*i,e.strokeStyle=rr(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(n)),e.restore()}e.globalAlpha=o};function fl(e,t,o,r,n){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=Ro(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const o=rr(e,t,t);return"string"==typeof o?o:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(o,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=n*s*(t.style.fillOpacity??1);const u=Bo(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Fo(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Fo(e,i,c,t.accent,void 0,l),e.restore()}var gl=(e,t)=>{const o=e.globalAlpha;for(const r of t)"glyph"===r.type&&fl(e,r,r.x,r.y,o);e.globalAlpha=o};function yl(e,t){const{x:o,y:r,w:n,h:i}=t,{tl:a,tr:s,br:l,bl:c}=zi(t);e.beginPath(),e.moveTo(o+a,r),e.lineTo(o+n-s,r),s>0&&e.arcTo(o+n,r,o+n,r+s,s),e.lineTo(o+n,r+i-l),l>0&&e.arcTo(o+n,r+i,o+n-l,r+i,l),e.lineTo(o+c,r+i),c>0&&e.arcTo(o,r+i,o,r+i-c,c),e.lineTo(o,r+a),a>0&&e.arcTo(o,r,o+a,r,a),e.closePath()}function bl(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var vl=(e,t,o,r)=>{const n=t.filter(e=>"rect"===e.type);for(const t of n){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)xl(e,t);else if(t.cornerRadii&&Ei(t.cornerRadii)){const o=rr(e,t.style.fill,Go(e,"var(--semiotic-primary, #007bff)")),r=bl(t),n=t.fillGradient&&"string"==typeof o?nr(e,t.fillGradient,o,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=n||o,yl(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const o=rr(e,t.style.fill,Go(e,"var(--semiotic-primary, #007bff)")),r=bl(t),n=t.fillGradient&&"string"==typeof o?nr(e,t.fillGradient,o,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=n||o;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:a,y:s,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(a,s),e.lineTo(a+l-i,s),e.arcTo(a+l,s,a+l,s+i,i),e.lineTo(a+l,s+c-i),e.arcTo(a+l,s+c,a+l-i,s+c,i),e.lineTo(a,s+c);break;case"left":e.moveTo(a+l,s),e.lineTo(a+i,s),e.arcTo(a,s,a,s+i,i),e.lineTo(a,s+c-i),e.arcTo(a,s+c,a+i,s+c,i),e.lineTo(a+l,s+c);break;case"bottom":e.moveTo(a,s),e.lineTo(a+l,s),e.lineTo(a+l,s+c-i),e.arcTo(a+l,s+c,a+l-i,s+c,i),e.lineTo(a+i,s+c),e.arcTo(a,s+c,a,s+c-i,i);break;default:e.moveTo(a,s+c),e.lineTo(a,s+i),e.arcTo(a,s,a+i,s,i),e.lineTo(a+l-i,s),e.arcTo(a+l,s,a+l,s+i,i),e.lineTo(a+l,s+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const o=rr(e,t.style.fill,Go(e,"var(--semiotic-primary, #007bff)")),r=bl(t),n=t.fillGradient&&"string"==typeof o?nr(e,t.fillGradient,o,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=n||o,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}nl(e,t),e.globalAlpha=1}};function xl(e,t){const o=t.style.icon,r=t.style.iconPadding||2,n=Math.min(t.w,t.h)-r;if(0>=n)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=n+r,a=t.x+(t.w-n)/2;for(let r=t.y+t.h-n;r>=t.y-n;r-=i)e.drawImage(o,a,r,n,n)}else{const i=n+r,a=t.y+(t.h-n)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(o,r,a,n,n)}e.restore()}function wl(e){const[t,o,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*r>128?"#000":"#fff"}function kl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Sl=(e,t,o,r)=>{const n=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of n){const o=t.style;if(null!=o?.opacity&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Go(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),nl(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const o=t.valueFormat?t.valueFormat(t.value):kl(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),n=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=wl(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(o,n,i)}}}finally{e.restore()}},Al=(e,t,o,r)=>{for(const o of t){if("candlestick"!==o.type)continue;const t=o;e.save();const n=(t._decayOpacity??1)*(t.style?.opacity??1);1!==n&&(e.globalAlpha=n);const i=Go(e,t.wickColor)||t.wickColor,a=60>r.height,s=a?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=s,e.stroke()};if(a||l(),t.isRange){const o=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,o,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,o,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const o=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),n=t.isUp?t.upColor:t.downColor,i=Go(e,n)||n;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(r,1))}a&&l(),e.restore()}},Cl={line:[ul,ol,dl],area:[ul,dl],stackedarea:[ul,dl],scatter:[dl,ml],bubble:[dl,ml],heatmap:[Sl],bar:[vl],swarm:[dl],waterfall:[(e,t,o,r)=>{vl(e,t);const n=t.filter(e=>"rect"===e.type);if(2>n.length)return;const i=n[0].datum,a=i?._connectorStroke;if(a){e.save(),e.strokeStyle=Go(e,a)||a,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;n.length-1>t;t++){const r=n[t],i=n[t+1],a=r.datum,s=i.datum;if(null==a?.cumEnd||null==s?.baseline)continue;const l=o.y(a.cumEnd),c=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Al],mixed:[ul,ol,dl],custom:[ul,vl,Sl,ol,dl,ml,gl,Al]};function Ml(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const o="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||o||null:o||t.stroke||null}import{jsx as Pl,jsxs as Il}from"react/jsx-runtime";function _l(e){return"string"==typeof e?e:"value"}function Ll(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Rl(e,t){if(!t)return Ll(e);try{const o=t(e);return null==o?Ll(e):o}catch{return Ll(e)}}function Tl(e,t){return"function"==typeof t?t(e):e[t]}function Nl(e,t){if(!e)return[];const o=[];return(Array.isArray(e)?e:[e]).forEach((e,r)=>{const n="string"==typeof e?.y0Accessor?e.y0Accessor:"low",i="string"==typeof e?.y1Accessor?e.y1Accessor:"high";o.push({label:n,accessor:e=>e?.bands?.[r]?.y0??(0===r?e?.band?.y0:void 0),format:t}),o.push({label:i,accessor:e=>e?.bands?.[r]?.y1??(0===r?e?.band?.y1:void 0),format:t})}),o}function $l(e){const t=e.find(e=>"title"===e.role),o=e.filter(e=>"title"!==e.role);return e=>{const r=e.data;if(!r)return null;const n=t?Rl(Tl(r,t.accessor),t.format):null;return Il("div",{className:"semiotic-tooltip",style:ms,children:[null!=n&&Pl("div",{style:{fontWeight:"bold",marginBottom:o.length>0?4:0},children:n}),o.map((e,t)=>{const o=Rl(Tl(r,e.accessor),e.format);return Il("div",{style:t>0?{marginTop:2}:void 0,children:[Il("span",{style:{opacity:.7},children:[e.label,": "]}),Pl("span",{children:o})]},t)})]})}}function Bl({categoryAccessor:e,valueAccessor:t,groupAccessor:o,groupLabel:r,pieData:n=!1,valueFormat:i}){return a=>{const s=n?a.data?.[0]||a.data||a:a.data||a,l=Tl(s,e),c=Tl(s,t),u=o?Tl(s,o):void 0;return Il("div",{className:"semiotic-tooltip",style:ms,children:[Pl("div",{style:{fontWeight:"bold"},children:Ll(l)}),Pl("div",{style:{marginTop:4},children:Rl(c,i)}),null!=u&&Il("div",{style:{marginTop:2,opacity:.8},children:[r||_l(o),": ",Ll(u)]})]})}}import{jsx as Dl,jsxs as Fl}from"react/jsx-runtime";function El(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function zl({hover:e}){const t=e.data??{},o=t.y??t.value,r=t.x??t.time;if(void 0===o&&void 0===r){const e=ds(t);if(null!=e.title||e.entries.length>0)return Fl("div",{className:"semiotic-tooltip",style:ms,children:[null!=e.title&&Dl("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>Fl("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",Dl("span",{style:{fontWeight:600},children:El(e.value)})]},e.key))]})}return Fl("div",{className:"semiotic-tooltip",style:ms,children:[Dl("div",{style:{fontWeight:600,marginBottom:2},children:El(o)}),Dl("div",{style:{opacity:.7,fontSize:11},children:El(r)})]})}zl.ownsChrome=!0;import{jsx as jl,jsxs as Ol}from"react/jsx-runtime";var Hl={top:20,right:20,bottom:30,left:40},Wl=ba;function ql(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Gl=x(v(function(e,t){const{chartType:o,runtimeMode:r,data:n,chunkThreshold:i,chunkSize:a,xAccessor:s,yAccessor:l,accessorRevision:c,colorAccessor:v,sizeAccessor:x,symbolAccessor:w,symbolMap:k,groupAccessor:S,lineDataAccessor:A,curve:C,normalize:M,baseline:P,stackOrder:I,binSize:_,valueAccessor:L,arrowOfTime:R="right",windowMode:T="sliding",windowSize:N=200,timeAccessor:$,xExtent:F,yExtent:E,extentPadding:z=.1,scalePadding:j,sizeRange:O,size:H=[500,300],responsiveWidth:W,responsiveHeight:q,margin:G,className:V,background:X,lineStyle:U,pointStyle:K,areaStyle:Q,barStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:oe,boundsAccessor:re,boundsStyle:ne,y0Accessor:ie,band:ae,gradientFill:se,lineGradient:le,areaGroups:ce,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:pe,candlestickStyle:me,showAxes:fe=!0,axes:ge,xLabel:ye,yLabel:be,yLabelRight:ve,xFormat:xe,yFormat:we,axisExtent:ke,tickFormatTime:Se,tickFormatValue:Ae,hoverAnnotation:Ce,tooltipContent:Me,customHoverBehavior:Pe,customClickBehavior:Ie,enableHover:_e,hoverRadius:Le=30,tooltipMode:Re,annotations:Te,autoPlaceAnnotations:Ne,svgAnnotationRules:$e,showGrid:Be,legend:De,legendHoverBehavior:Fe,legendClickBehavior:Ee,legendHighlightedCategory:ze,legendIsolatedCategories:je,legendPosition:Oe,legendLayout:He,legendCategoryAccessor:We,onCategoriesChange:qe,backgroundGraphics:Ge,foregroundGraphics:Ye,canvasPreRenderers:Ve,svgPreRenderers:Xe,title:Ue,categoryAccessor:Ke,brush:Qe,onBrush:Ze,decay:Je,pulse:et,transition:tt,animate:ot,staleness:rt,heatmapAggregation:nt,heatmapXBins:it,heatmapYBins:at,showValues:st,heatmapValueFormat:lt,marginalGraphics:ct,pointIdAccessor:ut,xScaleType:dt,yScaleType:ht,accessibleTable:pt=!0,description:mt,summary:ft,linkedCrosshairName:yt,linkedCrosshairSourceId:bt,customLayout:vt,onLayoutError:xt,layoutConfig:wt,layoutSelection:kt}=e,St=b().replace(/:/g,""),At=h(!1),Ct=h({w:-1,h:-1}),Mt=h(!1),Pt=js({sizeProp:H,responsiveWidth:W,responsiveHeight:q,userMargin:G,marginDefault:Hl,animate:ot,transitionProp:tt,themeDirtyRef:At}),It=na(),_t=la(),{reducedMotionRef:Lt,responsiveRef:Rt,size:Tt,currentTheme:Nt,transition:$t,introEnabled:Bt,tableId:Dt,rafRef:Ft,renderFnRef:Et,scheduleRender:zt,cancelRender:jt}=Pt;let Ot=Pt.margin;if(ct){const e=60,t={...Pt.margin};ct.top&&e>t.top&&(t.top=e),ct.bottom&&e>t.bottom&&(t.bottom=e),ct.left&&e>t.left&&(t.left=e),ct.right&&e>t.right&&(t.right=e),Ot=t}const Ht=Tt[0]-Ot.left-Ot.right,Wt=Tt[1]-Ot.top-Ot.bottom,qt=f(()=>u(n),[n]),Gt=Ce??_e,Yt=h(null),Vt=h(null),[Xt,Ut]=p(0),Kt=h(0),[Qt,Zt]=p(null),Jt=(e,t)=>"function"==typeof e?e({size:Tt,margin:Ot,scales:t}):e,eo=Jt(Ye,Qt),to=Jt(Ge,Qt),oo=h(null),ro=h(null),no=h(void 0),[io,ao]=p(null),lo=h(Wl.primary),co=h(function(){let e=-1,t=ba;return{resolve(o){if(!o)return ba;const r=Oo;return r===e||(t=function(e){if(!e)return ba;const t=getComputedStyle(e),o=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),n=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),a=r||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),l=o||t.getPropertyValue("--surface-3").trim(),c=n||t.getPropertyValue("--surface-0").trim();return a||s||o||i?{axisStroke:l||ba.axisStroke,tickText:a||ba.tickText,crosshair:a?va(a,"66"):ba.crosshair,hoverFill:c?va(c,"4D"):ba.hoverFill,hoverStroke:a?va(a,"99"):ba.hoverStroke,pointRing:c||ba.pointRing,primary:i||ba.primary,background:c||ba.background}:ba}(o),e=r),t},invalidate(){e=-1}}}()),uo=h(!1),po=h(new ho),fo=h([]),go=h(We),yo=h(qe);go.current=We,yo.current=qe;const[bo,xo]=p(!1),[wo,Ao]=p([]),[Co,Mo]=p([]),Po="streaming"===r||["bar","swarm","waterfall"].includes(o),Io=da(f(()=>({chartType:o,runtimeMode:Po?"streaming":"bounded",windowSize:N,windowMode:T,arrowOfTime:Po?R:"right",extentPadding:z,scalePadding:j,axisExtent:ke,xAccessor:s,yAccessor:l,accessorRevision:c,timeAccessor:Po?$:void 0,valueAccessor:L,colorAccessor:v,sizeAccessor:x,symbolAccessor:w,symbolMap:k,groupAccessor:S||(A?"_lineGroup":void 0),categoryAccessor:Ke,lineDataAccessor:A,xScaleType:dt,yScaleType:ht,xExtent:F,yExtent:E,sizeRange:O,binSize:_,normalize:M,baseline:P,stackOrder:I,boundsAccessor:re,boundsStyle:ne,y0Accessor:ie,band:ae,gradientFill:!0===se?{topOpacity:.8,bottomOpacity:.05}:!1===se?void 0:se,areaGroups:ce?new Set(ce):void 0,lineGradient:le,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:pe,candlestickStyle:me,lineStyle:U,pointStyle:K,areaStyle:Q,swarmStyle:ee,waterfallStyle:J,colorScheme:oe,barColors:te,barStyle:Z,annotations:Te,decay:Je,pulse:et,transition:$t,introAnimation:Bt,staleness:rt,heatmapAggregation:nt,heatmapXBins:it,heatmapYBins:at,showValues:st,heatmapValueFormat:lt,pointIdAccessor:ut,curve:C,themeCategorical:Nt?.colors?.categorical,themeSemantic:Y(Nt),themeSequential:Nt?.colors?.sequential,themeDiverging:Nt?.colors?.diverging,customLayout:vt,onLayoutError:xt,layoutConfig:wt,layoutMargin:Ot}),[o,N,T,R,z,j,ke,s,l,c,$,L,dt,ht,v,x,w,k,S,Ke,A,F,E,O,_,M,P,I,re,ne,ie,ae,se,le,ce,ue,de,he,pe,me,U,K,Q,ee,J,Z,oe,te,Te,Je,et,$t?.duration,$t?.easing,Bt,rt,nt,it,at,st,lt,Po,ut,C,Nt,vt,xt,wt,Ot])),_o=h(null);_o.current||(_o.current=new so(Io));const Lo=function(e,t,o,r){return qs(()=>{const n=t.current,i=o.current;if(!i||!n)return;const a=Gs(e.current?.getData()??[],n);Ys(a,r.current)||(r.current=a,i(a))},[t,o,r,e])}(_o,go,yo,fo);ko(_o,Io,At,zt),So(_o,kt,At,zt);const Ro=h(null);Ro.current||(Ro.current=new D(e=>{const t=_o.current;t&&t.ingest(e)&&(At.current=!0,zt())},{chunkThreshold:i,chunkSize:a})),m(()=>{Ro.current?.updateChunkOptions({chunkThreshold:i,chunkSize:a})},[i,a]);const To=g(e=>{Ro.current?.push(e)},[]),No=g(e=>{Ro.current?.pushMany(e)},[]),$o=g(()=>{Ro.current?.clear(),_o.current?.clear(),At.current=!0,zt()},[zt]);y(t,()=>({push:To,pushMany:No,remove:e=>{Ro.current?.flush();const t=_o.current?.remove(e)??[];return t.length>0&&(oo.current&&t.some(e=>e===oo.current?.data)&&(oo.current=null,ao(null)),At.current=!0,zt()),t},update:(e,t)=>{Ro.current?.flush();const o=_o.current?.update(e,t)??[];return o.length>0&&(At.current=!0,zt()),o},clear:$o,getData:()=>(Ro.current?.flush(),_o.current?.getData()??[]),getScales:()=>_o.current?.scales??null,getExtents:()=>_o.current?.getExtents()??null,getCustomLayout:()=>_o.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>_o.current?.lastCustomLayoutFailure??null}),[To,No,$o,zt]),m(()=>{if(n){if(A&&qt.length>0&&"object"==typeof qt[0]&&null!==qt[0]){const e="string"==typeof A?A:"coordinates";if(Array.isArray(qt[0][e])){const t=[];for(const o of qt){const r=o[e];if(Array.isArray(r)){const e=o.label||o.id||o.key;if(null!=e)for(const o of r)t.push({...o,_lineGroup:e});else for(const e of r)t.push(e)}}return void Ro.current?.setBoundedData(t)}}Ro.current?.setBoundedData(qt)}},[n,qt,A]);const{hoverHandlerRef:Bo,hoverLeaveRef:Fo,onPointerMove:Eo,onPointerLeave:zo}=Pt;Bo.current=e=>{if(!Gt)return;const t=Yt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-Ot.left,i=e.clientY-r.top-Ot.top;if(0>n||n>Ht||0>i||i>Wt)return void(oo.current&&(oo.current=null,ro.current=null,ao(null),Pe&&(Pe(null),At.current=!0),zt()));const a=_o.current;if(!a||0===a.scene.length)return;const l=rs(Le,e.pointerType),c=cr(a.scene,n,i,l,a.quadtree,a.maxPointRadius),u="multi"===Re,d=()=>{oo.current&&(oo.current=null,ro.current=null,ao(null),Pe&&Pe(null),zt())};if(!c&&!u)return void d();const h=u||!c?n:c.x,p=u||!c?i:c.y,m=c?.datum?gt(c.datum,a.resolvedRibbons):{},f=a.scales?.x?.invert,g="function"==typeof f?f(h):void 0;let y=is(m,h,p,null!=g?{xValue:g,xPx:h}:void 0);if(u&&a.scene.length>0&&a.scales){const e=function(e,t,o=30){const r=[];for(const n of e)if("line"===n.type){const e=n;if(2>e.path.length)continue;const i=ur(lr(e.path,e.curve),t,o);if(null===i)continue;const a=xr(e.path,t);r.push({node:n,datum:Array.isArray(e.datum)&&e.datum[a]?e.datum[a]:e.datum,x:e.path[a][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===n.type){const e=n;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=lr(e.topPath,e.curve),a=lr(e.bottomPath,e.curve),s=ur(i,t,o);if(null===s)continue;const l=ur(a,t,o),c=xr(e.topPath,t);r.push({node:n,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:s,y0:l??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(a.scene,h,Math.max(l,Ht));if(e.length>0){const t=a.scales.y.invert,r=lo.current,n=f?f(h):h;if(c)y.xValue=n,y.xPx=h;else{const e={xValue:n};"string"==typeof s&&(e[s]=n),y=is(e,h,p,{xValue:n,xPx:h})}y.allSeries=e.map(e=>{const n=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===o&&null!=i?n-i:n,valuePx:e.y,color:e.color||r,datum:gt(e.datum,a.resolvedRibbons)}})}}c||y.allSeries?.length?(oo.current=y,ro.current=c?.node??null,ao(y),Pe&&(Pe(y),At.current=!0),zt()):d()},Fo.current=()=>{oo.current&&(oo.current=null,ro.current=null,ao(null),Pe&&(Pe(null),At.current=!0),zt())};const jo=h(()=>{});jo.current=e=>{if(!Ie)return;const t=Yt.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-Ot.left,n=e.clientY-o.top-Ot.top;if(0>r||r>Ht||0>n||n>Wt)return void Ie(null);const i=_o.current;if(!i||0===i.scene.length)return void Ie(null);const a=rs(Le,no.current),s=cr(i.scene,r,n,a,i.quadtree,i.maxPointRadius);if(!s)return void Ie(null);const l=s.datum||{},c=i.scales?.x?.invert,u="function"==typeof c?c(s.x):void 0;Ie(is(l,s.x,s.y,null!=u?{xValue:u,xPx:s.x}:void 0))};const Ho=g(e=>jo.current(e),[]),Wo=h(-1),qo=h(null),Go=h(null),Yo=g(e=>{const t=_o.current;if(!t||0===t.scene.length)return;const o=t.version;let r;if(Go.current&&Go.current.version===o)r=Go.current.graph;else{const e=function(e){const t=[];for(const o of e)switch(o.type){case"point":t.push({x:o.x,y:o.y,datum:o.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=o.size)break;t.push({x:o.x,y:o.y,datum:o.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=o.size||null==o.datum)break;const e=Do(o.glyph,o.size);t.push({x:o.x+e.centerDx,y:o.y+e.centerDy,datum:o.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=o,r=Array.isArray(e.datum)?e.datum:[],n=e.group??"_default";for(let o=0;e.path.length>o&&r.length>o;o++)t.push({x:e.path[o][0],y:e.path[o][1],datum:r[o],shape:"circle",group:n});break}case"area":{const e=o,r=Array.isArray(e.datum)?e.datum:[],n=e.group??"_default";for(let o=0;e.topPath.length>o&&r.length>o;o++)t.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:r[o],shape:"circle",group:n});break}case"rect":t.push({x:o.x+o.w/2,y:o.y+o.h/2,datum:o.datum,shape:"rect",w:o.w,h:o.h,group:o.group??"_default"});break;case"heatcell":t.push({x:o.x+o.w/2,y:o.y+o.h/2,datum:o.datum,shape:"rect",w:o.w,h:o.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===e.length)return;r=wr(e),Go.current={version:o,graph:r}}const n=Wo.current;if(0>n){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Wo.current=0;const o=r.flat[0];qo.current={shape:o.shape,w:o.w,h:o.h};const n=Mr({...o,datum:gt(o.datum,t.resolvedRibbons)});return oo.current=n,ao(n),Pe&&Pe(n),void zt()}const i=kr(r,n),a=Sr(e.key,i,r);if(null===a)return;if(e.preventDefault(),0>a)return Wo.current=-1,qo.current=null,oo.current=null,ro.current=null,ao(null),Pe&&Pe(null),void zt();Wo.current=a;const s=r.flat[a];qo.current={shape:s.shape,w:s.w,h:s.h};const l=Mr({...s,datum:gt(s.datum,t.resolvedRibbons)});oo.current=l,ao(l),Pe&&Pe(l),zt()},[Pe,zt]),Vo=g(e=>{no.current=e.pointerType,Wo.current=-1,qo.current=null,Eo(e)},[Eo]),Xo=g(e=>{no.current="mouse",Wo.current=-1,qo.current=null,Eo({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Eo]),Uo=g(e=>{no.current=e.pointerType},[]);Et.current=()=>{Ft.current=null;const e=Yt.current,t=Vt.current;if(!e||!t)return;const r=_o.current;if(!r)return;const n="undefined"!=typeof performance?performance.now():Date.now(),i=r.advanceTransition(Lt.current?n+1e6:n),a=!Lt.current&&i,c=Ct.current.w!==Ht||Ct.current.h!==Wt,u=At.current||i||c,d=r.consumeStylePaintPending();let h=!1;const p=r.getLastUpdateResult(),m=po.current.beforeCompute(p,a);!u||a&&!c||(r.computeScene({width:Ht,height:Wt}),Ct.current={w:Ht,h:Wt},h=!0,Lo()),po.current.afterCompute(m,h,c);const f=Os(r,n,h,Mt),g=Ws(),y=co.current.resolve(e);lo.current=y.primary;const b=Rr(rt,r.lastIngestTime>0?n-r.lastIngestTime:0),v=rt&&b.isStale;if(u||d||f.changed){const t=Hs(e,Tt,Ot,g);if(t){if(t.clearRect(-Ot.left,-Ot.top,Tt[0],Tt[1]),rt&&1>b.alpha&&(t.globalAlpha=b.alpha),fa(t,{background:X,hasBackgroundGraphics:!!Ge,themeBackground:y.background,x:-Ot.left,y:-Ot.top,width:Tt[0],height:Tt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ht,Wt),t.clip()),Ve&&r.scales)for(const e of Ve)t.save(),e(t,r.scene,r.scales,{width:Ht,height:Wt}),t.restore();const e=vt?Cl.custom:Cl[o];if(e&&r.scales)for(const o of e)o(t,r.scene,r.scales,{width:Ht,height:Wt});t.restore(),rt&&1>b.alpha&&(t.globalAlpha=1)}}const x=!!(Gt&&oo.current&&r.scales),w=!!(ro.current&&Array.isArray(Ce)&&Ce.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=x||w;if(ya(k,uo.current)){const e=Hs(t,Tt,Ot,g);if(e&&(e.clearRect(-Ot.left,-Ot.top,Tt[0],Tt[1]),x&&oo.current&&function(e,t,o,r,n,i,a){if(!1===n.crosshair)return;const s=t.allSeries,l=s&&s.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof n.crosshair?n.crosshair:{};if(e.strokeStyle=u.stroke||a.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(l?c:t.x,0),e.lineTo(l?c:t.x,r),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=a.pointRing;for(const t of s)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||a.primary,e.fill(),e.stroke())}else{const o=n.pointColor||Ml(i)||a.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}}(e,oo.current,Ht,Wt,"object"==typeof Gt?Gt:{},ro.current,y),w&&ro.current&&Array.isArray(Ce))){const t=Ce.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,o,r,n){if(!o)return;const i="group"in o?o.group:void 0;if(void 0!==i)for(const o of t){if("line"!==o.type)continue;if(o.group!==i)continue;if(2>o.path.length)continue;const t="function"==typeof r.style?o.datum?r.style(o.datum):{}:r.style||{};e.save(),e.beginPath(),e.moveTo(o.path[0][0],o.path[0][1]);for(let t=1;o.path.length>t;t++)e.lineTo(o.path[t][0],o.path[t][1]);e.strokeStyle=t.stroke||o.style.stroke||n.primary,e.lineWidth=t.strokeWidth||(o.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,r.scene,ro.current,t,y)}uo.current=k}u&&e&&e.setAttribute("aria-label",Na(r.scene,o+" chart"));const S=At.current;if(At.current=S&&a&&!h,S&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Qt||e(Qt.x.domain()[0])!==e(r.scales.x.domain()[0])||e(Qt.x.domain()[1])!==e(r.scales.x.domain()[1])||e(Qt.y.domain()[0])!==e(r.scales.y.domain()[0])||e(Qt.y.domain()[1])!==e(r.scales.y.domain()[1])||Qt.x.range()[0]!==r.scales.x.range()[0]||Qt.x.range()[1]!==r.scales.x.range()[1]||Qt.y.range()[0]!==r.scales.y.range()[0]||Qt.y.range()[1]!==r.scales.y.range()[1])&&Zt(r.scales),ct){const e=r.getData(),t="function"==typeof s?s:e=>e[s||"x"],o="function"==typeof l?l:e=>e[l||"y"];Ao(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Mo(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((Te&&Te.length>0||vt)&&(h||a))||!h&&33>n-Kt.current||(Ut(e=>e+1),Kt.current=n),rt?.showBadge&&xo(!!v),(a||null!=r.activeTransition||f.pending)&&zt()},ca({hydrated:It,wasHydratingFromSSR:_t,storeRef:_o,dirtyRef:At,renderFnRef:Et,cancelRender:jt,cleanup:()=>Ro.current?.clear()}),m(()=>{At.current=!0,zt()},[o,Ht,Wt,fe,X,Ge,U,Ve,zt]),Tr(rt,_o,At,zt,bo,xo);const Ko=f(()=>{if(xe||Se)return;const e=_o.current;return e?.xIsDate&&Qt?Qs(Qt.x.domain()):void 0},[xe,Se,Qt]),Qo=xe||Se||Ko,Zo=Gt&&io?Me?Me(io):jl(zl,{hover:io}):null,Jo=Zo?jl(ks,{x:io.x,y:io.y,containerWidth:Ht,containerHeight:Wt,margin:Ot,className:"stream-frame-tooltip",children:Zo}):null,er=qo.current,tr=jl(ts,{active:Wo.current>=0,hoverPoint:io,margin:Ot,size:Tt,shape:er?.shape,width:er?.w,height:er?.h}),or=Vs(s,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),rr=Vs(l,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),nr=or.key,ir=rr.key,ar=Xs(or,rr,Te&&Te.length>0||!1);if(Qi||!It&&_t){const e=_o.current;e&&n&&(e.ingest({inserts:qt,bounded:!0}),e.computeScene({width:Ht,height:Wt}));const t=e?.scene??[],o=e?.scales??null,r=Jt(Ye,o),i=Jt(Ge,o),a=Qo||(()=>{if(e?.xIsDate&&o)return Qs(o.x.domain())})();return Ol("div",{ref:Rt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":mt||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:W?"100%":Tt[0],height:q?"100%":Tt[1]},children:[jl(Ka,{summary:ft}),Ol("svg",{xmlns:"http://www.w3.org/2000/svg",width:Tt[0],height:Tt[1],style:{position:"absolute",left:0,top:0},children:[jl("g",{transform:`translate(${Ot.left},${Ot.top})`,children:i}),Ol("g",{transform:`translate(${Ot.left},${Ot.top})`,children:[X&&jl("rect",{x:0,y:0,width:Ht,height:Wt,fill:X}),Xe&&o&&Xe.map((e,r)=>jl(d.Fragment,{children:e(t,o,{width:Ht,height:Wt})},"svgpre-"+r)),t.map((e,t)=>Ki(e,t,St)).filter(Boolean)]})]}),jl(Bi,{width:Ht,height:Wt,totalWidth:Tt[0],totalHeight:Tt[1],margin:Ot,scales:o,showAxes:fe,axes:ge,xLabel:ye,yLabel:be,yLabelRight:ve,xFormat:a,yFormat:we||Ae,axisExtent:ke,showGrid:Be,title:Ue,legend:De,legendHoverBehavior:Fe,legendClickBehavior:Ee,legendHighlightedCategory:ze,legendIsolatedCategories:je,legendPosition:Oe,legendLayout:He,foregroundGraphics:mo(r,vo(_o.current?.customLayoutOverlays,kt??null)),marginalGraphics:ct,xValues:[],yValues:[],annotations:Te,autoPlaceAnnotations:Ne,svgAnnotationRules:$e,annotationFrame:0,xAccessor:nr,yAccessor:ir,annotationData:ar(e?.getData()),pointNodes:Zs(e?.scene),curve:"string"==typeof C?C:void 0,linkedCrosshairName:yt,linkedCrosshairSourceId:bt})]})}return Ol("div",{ref:Rt,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":mt||("string"==typeof Ue?Ue:"XY chart"),tabIndex:0,style:{position:"relative",width:W?"100%":Tt[0],height:q?"100%":Tt[1],overflow:"visible",touchAction:ql(Qe)},onKeyDown:Yo,children:[pt&&jl(Qa,{tableId:Dt}),pt&&jl(Xa,{scene:_o.current?.scene??[],chartType:o+" chart",tableId:Dt,chartTitle:"string"==typeof Ue?Ue:void 0}),jl(Ka,{summary:ft}),jl(Za,{hoverPoint:io}),Ol("div",{role:"img","aria-label":mt||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Gt?Vo:void 0,onMouseMove:Gt?Xo:void 0,onPointerLeave:Gt?zo:void 0,onMouseLeave:Gt?zo:void 0,onPointerDown:Gt||Ie?Uo:void 0,onClick:Ie?Ho:void 0,children:[to&&jl("svg",{style:{position:"absolute",left:0,top:0,width:Tt[0],height:Tt[1],pointerEvents:"none"},children:jl("g",{transform:`translate(${Ot.left},${Ot.top})`,children:to})}),jl(Ti,{width:Ht,height:Wt,totalWidth:Tt[0],totalHeight:Tt[1],margin:Ot,scales:Qt,showAxes:fe,axes:ge,showGrid:Be,xFormat:Qo,yFormat:we||Ae,axisExtent:ke}),jl("canvas",{ref:Yt,"aria-label":Na(_o.current?.scene??[],o+" chart"),style:{position:"absolute",left:0,top:0}}),jl("canvas",{ref:Vt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),jl(Bi,{width:Ht,height:Wt,totalWidth:Tt[0],totalHeight:Tt[1],margin:Ot,scales:Qt,showAxes:fe,axes:ge,xLabel:ye,yLabel:be,yLabelRight:ve,xFormat:Qo,yFormat:we||Ae,axisExtent:ke,showGrid:Be,title:Ue,legend:De,legendHoverBehavior:Fe,legendClickBehavior:Ee,legendHighlightedCategory:ze,legendIsolatedCategories:je,legendPosition:Oe,legendLayout:He,foregroundGraphics:mo(eo,vo(_o.current?.customLayoutOverlays,kt??null)),marginalGraphics:ct,xValues:wo,yValues:Co,annotations:Te,autoPlaceAnnotations:Ne,svgAnnotationRules:$e,annotationFrame:Xt,xAccessor:nr,yAccessor:ir,annotationData:ar(_o.current?.getData()),pointNodes:Zs(_o.current?.scene),curve:"string"==typeof C?C:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==X&&!Ge,linkedCrosshairName:yt,linkedCrosshairSourceId:bt}),(Qe||Ze)&&jl(B,{width:Ht,height:Wt,totalWidth:Tt[0],totalHeight:Tt[1],margin:Ot,dimension:Qe?.dimension??"xy",scales:Qt,onBrush:Ze??(()=>{}),binSize:_,snap:Qe?.snap,binBoundaries:Qe?.binBoundaries??("bar"===o?_o.current?.getBinBoundaries():void 0),snapDuring:Qe?.snapDuring,streaming:"streaming"===r}),rt?.showBadge&&jl($r,{isStale:bo,position:rt.badgePosition}),tr,Jo]})]})}));Gl.displayName="StreamXYFrame";var Yl=Gl;import{useMemo as Vl,useCallback as Xl,useState as Ul,useId as Kl,useEffect as Ql,useRef as Zl}from"react";import{createContext as Jl,useContext as ec,useMemo as tc}from"react";import{jsx as oc}from"react/jsx-runtime";var rc=Jl(null);function nc({colors:e,categories:t,colorScheme:o="category10",children:r}){const n=tc(()=>{if(e)return e;if(t){if(o&&"object"==typeof o&&!Array.isArray(o)){const e=o,r={};let n=0;for(const o of t)r[o]=We(e,o)??Ee[n++%Ee.length];return r}const e=Array.isArray(o)?o:Fe[o]||Ee,r={};for(let o=0;t.length>o;o++)r[t[o]]=e[o%e.length];return r}return{}},[e,t,o]);return oc(rc.Provider,{value:n,children:r})}function ic(){return ec(rc)}nc.displayName="CategoryColorProvider";import{createContext as ac,useContext as sc,useEffect as lc,useId as cc,useLayoutEffect as uc,useMemo as dc,useRef as hc,useState as pc,useCallback as mc}from"react";function fc(e){const t=[];for(const[o,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[o]));else{const[e,n]=r.range;t.push(t=>{const r=t[o];return r>=e&&n>=r})}return e=>t.every(t=>t(e))}function gc(e,t){const o=[];for(const[r,n]of e.clauses)"crossfilter"===e.resolution&&r===t||o.push(fc(n));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function yc(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}function bc(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const o of e.values)if(!t.values.has(o))return!1;return!0}return!1}var[vc,xc]=q(e=>({selections:new Map,setClause(t,o){e(e=>{const r=e.selections.get(t),n=r?.clauses.get(o.clientId);if(n&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const o=Object.entries(e.fields);if(o.length!==function(e){let t=0;for(const o in e)t++;return t}(t.fields))return!1;for(const[e,r]of o){const o=t.fields[e];if(!o||!bc(r,o))return!1}return!0}(n,o))return{};const i=new Map(e.selections),a=yc(i,t),s=new Map(a.clauses);return s.set(o.clientId,o),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,o){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(o))return{};const n=new Map(e.selections),i=new Map(r.clauses);return i.delete(o),n.set(t,{...r,clauses:i}),{selections:n}})},setResolution(t,o){e(e=>{const r=e.selections.get(t);if(r?.resolution===o)return{};const n=new Map(e.selections),i=yc(n,t);return n.set(t,{...i,resolution:o}),{selections:n}})},clearSelection(t){e(e=>{const o=e.selections.get(t);if(!o||0===o.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...o,clauses:new Map}),{selections:r}})}})),[wc,kc]=q(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const o=e.observations;return o.push(t),o.length>e.maxObservations&&o.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));import{useId as Sc,useMemo as Ac,useCallback as Cc}from"react";function Mc(e){const t=Sc(),o=e.clientId||t,{name:r}=e,n=xc(e=>e.selections.get(r)),i=xc(e=>e.setClause),a=xc(e=>e.clearClause),s=Ac(()=>!!n&&n.clauses.size>0,[n]);return{predicate:Ac(()=>n&&0!==n.clauses.size?gc(n,o):()=>!0,[n,o]),isActive:s,selectPoints:Cc(e=>{const t={};let n=!1;for(const[o,r]of Object.entries(e))t[o]={type:"point",values:new Set(r)},n=!0;n&&i(r,{clientId:o,type:"point",fields:t})},[o,r,i]),selectInterval:Cc(e=>{const t={};let n=!1;for(const[o,r]of Object.entries(e))t[o]={type:"interval",range:r},n=!0;n&&i(r,{clientId:o,type:"interval",fields:t})},[o,r,i]),clear:Cc(()=>{a(r,o)},[a,r,o]),clientId:o}}function Pc(e,t){const o=Sc(),r=t||o,n=xc(e=>e.setClause),i=xc(e=>e.clearClause);return{selectPoints:Cc(t=>{const o={};let i=!1;for(const[e,r]of Object.entries(t))o[e]={type:"point",values:new Set(r)},i=!0;i&&n(e,{clientId:r,type:"point",fields:o})},[e,r,n]),clear:Cc(()=>i(e,r),[e,r,i]),clientId:r}}function Ic(e){const t=e.name||"hover",{fields:o}=e,{predicate:r,isActive:n,selectPoints:i,clear:a}=Mc({name:t,fields:o});return{onHover:Cc(e=>{if(!e)return void a();const t={};for(const r of o){const o=e[r];void 0!==o&&(t[r]=[o])}Rc(t)&&i(t)},[o,i,a,t]),predicate:r,isActive:n}}function _c(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Lc(e){const{name:t,xField:o,yField:r}=e,{predicate:n,isActive:i,selectInterval:a,clear:s}=Mc({name:t,fields:[o,r].filter(Boolean)}),l=o&&r?"xyBrush":o?"xBrush":"yBrush",c=Cc(e=>{if(!e)return void s();const t={};"xyBrush"===l&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===l&&_c(e)?o&&(t[o]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===l&&_c(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Rc(t)&&a(t)},[l,o,r,a,s]);return{brushInteraction:Ac(()=>({brush:l,during:c,end:c}),[l,c]),predicate:n,isActive:i,clear:s}}function Rc(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Tc(e,t,o){const r=xc(e=>e.selections.get(t));return Ac(()=>{if(!r||0===r.clauses.size)return e;const t=gc(r,o);return e.filter(t)},[e,r,o])}import{useMemo as Nc}from"react";function $c(e={}){const{limit:t=50,types:o,chartId:r}=e,n=kc(e=>e.version),i=kc(e=>e.observations),a=kc(e=>e.clearObservations),s=Nc(()=>{let e=i;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return r&&(e=e.filter(e=>e.chartId===r)),e.length>t&&(e=e.slice(e.length-t)),e},[i,o,r,t,n]);return{observations:s,latest:s.length>0?s[s.length-1]:null,clear:a}}import{jsx as Bc,jsxs as Dc}from"react/jsx-runtime";var Fc=ac(!1),Ec=ac(!1);function zc(){return sc(Ec)}var jc=ac(null),Oc="undefined"==typeof window?lc:uc;function Hc(e){const t=new Set,o=[];for(const r of e)t.has(r)||(t.add(r),o.push(r));return o}function Wc(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function qc(e){const t=sc(jc),o=cc(),r=Hc(e),n=hc([]);Wc(n.current,r)||(n.current=r);const i=n.current;Oc(()=>{if(t)return()=>t.unregisterCategories(o)},[t,o]),Oc(()=>{t&&t.registerCategories(o,i)},[t,o,i])}var Gc="__linked-legend-isolate__",Yc="__linked-legend-highlight__";function Vc({categoryColors:e,interaction:t,selectionName:o,field:r}){const n=Object.entries(e),i=n.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:n.map(([e,t])=>({label:e,color:t})),label:""}],{selectPoints:s,clear:l}=Mc({name:o,fields:[r],clientId:Gc}),{selectPoints:c,clear:u}=Mc({name:o,fields:[r],clientId:Yc}),d=xc(e=>e.selections.get(o)),{isolatedCategories:h,highlightedCategory:p}=dc(()=>{const e=new Set;let t=null;const o=d?.clauses.get(Gc)?.fields[r];if("point"===o?.type)for(const t of o.values)e.add(t+"");const n=d?.clauses.get(Yc)?.fields[r];if("point"===n?.type){const e=n.values.values().next().value;null!=e&&(t=e+"")}return{isolatedCategories:e,highlightedCategory:t}},[d,r]),m=mc(e=>{"highlight"===t&&(e?c({[r]:[e.label]}):u())},[t,r,c,u]),f=mc(e=>{if("isolate"!==t)return;const o=new Set(h);o.has(e.label)?o.delete(e.label):o.add(e.label),0===o.size||o.size===i.length?l():s({[r]:Array.from(o)})},[t,r,h,i.length,s,l]),[g,[y]]=Ds([0,0],!0,!1),b=dc(()=>function(e,t){if(!t||0===e.length)return 1;let o=0,r=1;for(const n of e){const e=26+7*n.length;o>0&&o+e>t&&(r++,o=0),o+=e}return r}(n.map(([e])=>e),y),[n,y]);return 0===n.length?null:Bc("div",{ref:g,style:{width:"100%",display:"block"},children:Bc("svg",{width:"100%",height:Math.max(30,22*b+8),style:{display:"block",overflow:"visible"},children:Bc(Vr,{legendGroups:a,title:!1,orientation:"horizontal",width:y,height:20,customHoverBehavior:"highlight"===t?m:void 0,customClickBehavior:"isolate"===t?f:void 0,highlightedCategory:p,isolatedCategories:h})})})}function Xc({children:e,selections:t,showLegend:o,legendPosition:r="top",legendInteraction:n="none",legendSelectionName:i="legend",legendField:a="category"}){const s=dc(()=>{if(!t)return;const e=new Map;for(const[o,r]of Object.entries(t))r.resolution&&e.set(o,{name:o,resolution:r.resolution,clauses:new Map});return e.size>0?{selections:e}:void 0},[t]),l=ic(),[c,u]=pc({}),d=hc({}),h=dc(()=>({registerCategories:(e,t)=>{const o=Hc(t);u(t=>Wc(t[e]??[],o)?t:{...t,[e]:o})},unregisterCategories:e=>{u(t=>{if(!(e in t))return t;const o={...t};return delete o[e],o})}}),[]),p=dc(()=>{const e=[];for(const t of Object.values(c))for(const o of t)e.push(o);return Hc(e)},[c]),m=dc(()=>{const e=l??{},t=d.current;let o=Object.keys(e).length+Object.keys(t).length;for(const r of p)e[r]||t[r]||(t[r]=Ee[o%Ee.length],o++);const r={...e};for(const o of p)r[o]=e[o]??t[o];return r},[l,p]),f=void 0===o||o,g=Object.keys(m).length>0;return Bc(vc,{initialState:s,children:Bc(wc,{children:Bc(Ec.Provider,{value:!0,children:Bc(jc.Provider,{value:h,children:Bc(nc,{colors:m,children:Dc(Fc.Provider,{value:f&&g,children:[f&&"top"===r&&Bc(Vc,{categoryColors:m,interaction:n,selectionName:i,field:a}),e,f&&"bottom"===r&&Bc(Vc,{categoryColors:m,interaction:n,selectionName:i,field:a})]})})})})})})}function Uc({data:e,colorBy:t,colorScale:o,getColor:r,strokeColor:n,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",o={fill:t,stroke:t};return void 0!==n&&(o.stroke=n),void 0!==i&&(o.strokeWidth=i),o},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((n,i)=>{const a=e.find("function"==typeof t?e=>t(e)===n:e=>e[t]===n),s=a?r(a,t,o):o?o(n):ze[i%ze.length];return{label:n+"",color:s}}),label:""}]}}function Kc(e){return e?"string"==typeof e?{name:e}:e:null}function Qc(e,t,o){return t?(r,...n)=>{const i={...e(r,...n)};if(t.isActive)if(t.predicate(r))o?.selectedStyle&&Object.assign(i,o.selectedStyle);else{const e=o?.unselectedOpacity??.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,o?.unselectedStyle&&Object.assign(i,o.unselectedStyle)}return i}:e}import*as Zc from"react";var Jc={light:U,dark:K,"high-contrast":Q,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function eu(e){return Jc[e]}import{jsx as tu,jsxs as ou}from"react/jsx-runtime";var ru=Zc.createContext(void 0),nu="undefined"==typeof window?Zc.useEffect:Zc.useLayoutEffect;function iu(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return eu(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function au({theme:e}){const t=ee(e=>e.setTheme),o=ee(e=>e.theme),r=Zc.useRef(o);r.current=o;const n=Zc.useRef(null);Zc.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return o.matches&&(n.current=r.current===Q?U:r.current,t("high-contrast")),Rs(o,e=>{e.matches?(n.current=r.current===Q?n.current??U:r.current,t("high-contrast")):(function(e,t){e(t===U?"light":t===K?"dark":t===Q?"high-contrast":t)}(t,n.current??U),n.current=null)})},[e,t]);const i=Zc.useRef(!1);return nu(()=>{i.current?void 0!==e&&t(iu(e)):i.current=!0},[e,t]),null}function su({children:e}){const t=ee(e=>e.theme),o={position:"relative","--semiotic-bg":t.colors.background,"--semiotic-text":t.colors.text,"--semiotic-text-secondary":t.colors.textSecondary,"--semiotic-grid":t.colors.grid,"--semiotic-border":t.colors.border,"--semiotic-cell-border":t.colors.cellBorder||t.colors.border,"--semiotic-primary":t.colors.primary,"--semiotic-font-family":t.typography.fontFamily,...t.colors.focus?{"--semiotic-focus":t.colors.focus}:{},...t.tooltip?.background?{"--semiotic-tooltip-bg":t.tooltip.background}:{},...t.tooltip?.text?{"--semiotic-tooltip-text":t.tooltip.text}:{},...t.tooltip?.borderRadius?{"--semiotic-tooltip-radius":t.tooltip.borderRadius}:{},...t.tooltip?.fontSize?{"--semiotic-tooltip-font-size":t.tooltip.fontSize}:{},...t.tooltip?.shadow?{"--semiotic-tooltip-shadow":t.tooltip.shadow}:{},...t.borderRadius?{"--semiotic-border-radius":t.borderRadius}:{},...t.colors.selection?{"--semiotic-selection-color":t.colors.selection}:{},...null!=t.colors.selectionOpacity?{"--semiotic-selection-opacity":t.colors.selectionOpacity+""}:{},...t.colors.diverging?{"--semiotic-diverging":t.colors.diverging}:{},...t.colors.annotation?{"--semiotic-annotation-color":t.colors.annotation}:{},...null!=t.typography.legendSize?{"--semiotic-legend-font-size":t.typography.legendSize+"px"}:{},...null!=t.typography.titleFontSize?{"--semiotic-title-font-size":t.typography.titleFontSize+"px"}:{},...null!=t.typography.tickFontFamily?{"--semiotic-tick-font-family":t.typography.tickFontFamily}:{},...null!=t.typography.tickSize?{"--semiotic-tick-font-size":t.typography.tickSize+"px"}:{},...null!=t.typography.labelSize?{"--semiotic-axis-label-font-size":t.typography.labelSize+"px"}:{},"--semiotic-secondary":t.colors.secondary||t.colors.primary,"--semiotic-surface":t.colors.surface||t.colors.background,...t.colors.success?{"--semiotic-success":t.colors.success}:{},...t.colors.danger?{"--semiotic-danger":t.colors.danger}:{},...t.colors.warning?{"--semiotic-warning":t.colors.warning}:{},...t.colors.error?{"--semiotic-error":t.colors.error}:{},...t.colors.info?{"--semiotic-info":t.colors.info}:{}},r=Zc.useContext(ru),n={};return r&&(n["data-semiotic-theme"]=r),tu("div",{style:o,...n,children:e})}function lu({theme:e,children:t}){const o="string"==typeof e&&eu(e)?e:void 0,r=Zc.useMemo(()=>function(e){return void 0!==e?Z(U,iu(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?Q:U}(e),[e]);return tu(J,{initialState:{theme:r},children:ou(ru.Provider,{value:o,children:[tu(au,{theme:e}),tu(su,{children:t})]})})}function cu(){return ee(e=>e.theme)}function uu(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function du(e,t){const{when:o}=e,r=t.width,n=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof o.minWidth&&o.minWidth>r||"number"==typeof o.maxWidth&&r>o.maxWidth||"number"==typeof o.minHeight&&("number"!=typeof n||o.minHeight>n)||"number"==typeof o.maxHeight&&("number"!=typeof n||n>o.maxHeight)||"number"==typeof o.minAspectRatio&&("number"!=typeof i||o.minAspectRatio>i)||"number"==typeof o.maxAspectRatio&&("number"!=typeof i||i>o.maxAspectRatio)||o.orientation&&a!==o.orientation)}function hu(e,t,o=e.responsiveRules){if(!Array.isArray(o)||0===o.length)return{props:e,matches:[]};const r=o.map((e,t)=>({rule:e,index:t})).filter(e=>du(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const o={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])uu(e[r])&&uu(t[r])&&(o[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(o.className=`${e.className} ${t.className}`),o}(e,t.rule.transform),e),matches:r}}var pu="#007bff";function mu(e,t,o){const r=e.xValue??t?.[o];if(null==r)return null;const n=Number(r);return Number.isFinite(n)?n:null}function fu(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function gu(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var yu={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function bu(e,t={}){const o=t.mobileSemantics?.interaction,r="number"==typeof o?.targetSize?o.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,n="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!o||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!n&&!i)return yu;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function vu(){const e=cu(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function xu(e,t,o,r,n){if(e)return e;if(o&&"object"==typeof o&&!Array.isArray(o)){const e=We(o,r);if(e)return e}let i;if(Array.isArray(o))i=o;else if(t&&t.length>0)i=t;else if("string"==typeof o){const e=Fe[o];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(n.has(r)||n.set(r,n.size),i[n.get(r)%i.length]):i[0]:pu}function wu(e,t,o){const r=ic(),n=vu();return Vl(()=>{if(!t)return;const i=r??void 0,a=o??(n&&n.length>0?n:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const o=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&gu(i)){const e=qe(o.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return qe(o.map(e=>({_cat:e})),"_cat",a)}if(i&&gu(i)){const o=qe(e,t,a);return e=>i[e]||o(e)}return qe(e,t,a)}if(i&&gu(i)){const e=qe([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,o,r,n])}function ku(e,t,o){return Vl(()=>{if(!t||"auto"===t||"function"==typeof t)return e;const r=[...e],n="function"==typeof(i=o)?i:e=>e[i];var i;return r.sort("asc"===t?(e,t)=>n(e)-n(t):(e,t)=>n(t)-n(e))},[e,t,o])}function Su({selection:e,linkedHover:t,fallbackFields:o=[],unwrapData:r=!1,onObservation:n,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=Kl(),h=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||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,o),p="series"===h?.mode?[h.seriesField||c||o[0]].filter(e=>!!e):h?.fields||o||[],m=Mc({name:e?.name||"__unused__",fields:p}),f=Ic({name:h?.name||"hover",fields:p}),g=kc(e=>e.pushObservation),y=e?{isActive:m.isActive,predicate:m.predicate}:null,[b,v]=Ul(null),x=Zl(!1),w=c||o[0],k=Vl(()=>{if(!l||null==b||!w)return null;const e=b,t=w;return{isActive:!0,predicate:o=>("string"==typeof o[t]?o[t]:(o[t]??"")+"")===e}},[l,b,w]),S=Xl(e=>{const o=!e&&x.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const o=mu(e,t,h.xField);null!=o&&function(e,t,o){const r=pi.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===o||(pi={positions:new Map(pi.positions).set(e,{xValue:t,sourceId:o})},fi())}(h.name||"hover",o,d)}"x-position"!==h?.mode&&f.onHover(t)}else"x-position"!==h?.mode||o||gi(h.name||"hover",d),"x-position"===h?.mode||o||f.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const o=t?.[w];v(null!=o?o+"":null)}else o||v(null);if(n||g){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(e){const o=fu(e),r={...t,type:"hover",datum:o||{},x:e.x??0,y:e.y??0};n&&n(r),g&&g(r)}else{const e={...t,type:"hover-end"};n&&n(e),g&&g(e)}}},[t,f,h,d,n,i,a,g,l,w,u]),A=Xl((o=!0)=>{x.current=!1,t&&"x-position"!==h?.mode&&f.onHover(null),e&&u?.tapToSelect&&m.clear(),o&&l&&v(null),"x-position"===h?.mode&&(yi(h.name||"hover",d),gi(h.name||"hover",d))},[t,h,f,e,u,m,l,d]),C=Xl(o=>{const r=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),c=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&o){let e=o.data||o.datum||o;Array.isArray(e)&&(e=e[0]);const t=mu(o,e,h.xField);null!=t&&function(e,t,o){const r=pi.positions.get(e);if(r?.locked){const t=new Map(pi.positions);return t.delete(e),pi={positions:t},fi(),!1}pi={positions:new Map(pi.positions).set(e,{xValue:t,sourceId:o,locked:!0})},fi()}(h.name||"hover",t,d)}if(r)if(o){x.current=!0;const r=fu(o);if(t&&"x-position"!==h?.mode&&f.onHover(r),e&&u?.tapToSelect&&p.length>0){const e={};for(const t of p){const o=r[t];void 0!==o&&(e[t]=[o])}gu(e)&&m.selectPoints(e)}if(l&&w){const e=r?.[w];v(null!=e?e+"":null)}}else c&&A();if(o||c){if(o&&s){let e=o.data||o.datum||o;Array.isArray(e)&&(e=e[0]),s(e,{x:o.x??0,y:o.y??0})}if(n||g){const e={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(o){const t=fu(o),r={...e,type:"click",datum:t||{},x:o.x??0,y:o.y??0};n&&n(r),g&&g(r)}else{const t={...e,type:"click-end"};n&&n(t),g&&g(t)}}}},[s,n,g,i,a,h,d,u,t,f,e,m,p,l,w,A]);return Ql(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&x.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),Ql(()=>()=>{x.current&&A(!1)},[A]),Ql(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{yi(e,d),gi(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:y,hoverSelectionHook:k,customHoverBehavior:S,customClickBehavior:C,crosshairSourceId:d}}function Au(e,t){const o="object"==typeof e&&null!==e?e:void 0;if("x-position"===o?.mode)return{linkedCrosshairName:o.name||"hover",linkedCrosshairSourceId:t}}function Cu({data:e,colorBy:t,colorScale:o,showLegend:r,legendPosition:n="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s}){const l=sc(Fc),c=null!==sc(jc),u=void 0!==r?r:!l&&!!t,d=!!t&&(u||c),h=Vl(()=>{if(!d)return[];if(void 0!==s)return s;const o=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&o.add(e+"")}return Array.from(o)},[s,t,e,d]);qc(c&&t?h:[]);const p=Vl(()=>{if(!u||!t)return;const r=Uc({data:e,colorBy:t,colorScale:o,getColor:He,categories:h});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[u,t,e,o,h]),m=Vl(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const o=e[t];return"number"==typeof o?o:a[t]},o={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return p&&("right"===n&&!r("right")&&110>o.right?o.right=110:"left"===n&&!r("left")&&110>o.left?o.left=110:"top"===n&&!r("top")&&50>o.top?o.top=50:"bottom"===n&&!r("bottom")&&80>o.bottom&&(o.bottom=80)),o},[a,i,p,n]);return{legend:p,margin:m,legendPosition:n}}function Mu(e,t,o){const[r,n]=Ul(null),[i,a]=Ul(new Set),s=Vl(()=>new Set,[]),l=Xl(t=>{"highlight"===e&&n(t?t.label:null)},[e]),c=Xl(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===o.length?new Set:r})},[e,o.length]),u=Vl(()=>{if(!e||"none"===e||!t)return null;const o="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(o?e[o]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=o?e[o]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}var Pu={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Iu(e,t,o){const r=Pu[e||"primary"],n=e&&"primary"!==e||!o?.width?r.width:o.width,i=e&&"primary"!==e||!o?.height?r.height:o.height,a=hu({...t,mode:e},{width:t.width??n,height:t.height??i}).props,s=a.mode||e,l=Pu[s||"primary"],c="context"===s||"sparkline"===s,u=s&&"primary"!==s||!o?.width?l.width:o.width;return{width:a.width??u,height:a.height??(s&&"primary"!==s||!o?.height?l.height:o.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:_u(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:bu(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function _u(e,t,o){if(!1!==t)return e;const r={...e};return"horizontal"===o?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as Lu,jsxs as Ru}from"react/jsx-runtime";function Tu({componentName:e,message:t,diagnosticHint:o,width:r,height:n}){return Lu("div",{role:"alert",style:{width:r,height:Math.max(n,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:Ru("div",{style:{textAlign:"center",maxWidth:400},children:[Lu("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),Lu("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),o&&Lu("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}import*as Nu from"react";import{jsx as $u}from"react/jsx-runtime";var Bu=class extends Nu.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:$u(Tu,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as Du}from"react/jsx-runtime";var Fu="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function Eu({componentName:e,width:t,height:o,children:r}){return Du(Bu,{fallback:r=>Du(Tu,{componentName:e,message:r.message,width:t,height:o}),children:r})}var zu={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},ju={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ou(e,t,o,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?Du("div",{style:{...zu,width:t,height:o},children:r||"No data available"}):null}function Hu(e,t,o,r){if(!e)return null;if(!1===r)return null;if(null!=r)return Du("div",{style:{width:t,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const n=Math.min(5,Math.floor(o/40)),i=Math.max(8,Math.floor(o/(3*n))),a=Math.max(6,Math.floor(o/(2.5*n))),s=Math.floor((o-(n*(i+a)-a))/2);return Du("div",{style:{width:t,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:n},(e,o)=>Du("div",{className:"semiotic-loading-bar",style:{...ju,position:"absolute",top:s+o*(i+a),left:Math.floor(.1*t),width:30+(37*o+13)%50+"%",height:i,opacity:.5+o%2*.2}},o))})}function Wu(e,t,o,r){if(!Fu)return;if(!t||0===t.length)return;if("string"!=typeof r)return;const n=t[0];if(!n||"object"!=typeof n)return;if(r in n)return;const i=Object.keys(n).join(", ");console.warn(`[semiotic] ${e}: ${o} "${r}" not found in data. Available keys: ${i}`)}function qu(e,t){const o=e.length,r=t.length,n=Array(r+1);for(let e=0;r>=e;e++)n[e]=e;for(let i=1;o>=i;i++){let o=n[0];n[0]=i;for(let a=1;r>=a;a++){const r=n[a];n[a]=e[i-1]===t[a-1]?o:1+Math.min(o,n[a],n[a-1]),o=r}}return n[r]}function Gu(e,t,o=3){let r,n=o+1;for(const o of t){const t=qu(e.toLowerCase(),o.toLowerCase());n>t&&(n=t,r=o)}return n>o?void 0:r}function Yu(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function Vu(e,t){if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(Gu(e,t,3)??null)}function Xu({componentName:e,data:t,accessors:o,requiredProps:r}){if(r)for(const[t,o]of Object.entries(r))if(null==o)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(o){const r=Yu(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[n,i]of Object.entries(o))if(i&&"string"==typeof i&&!(i in r)){const o=Vu(i,t),r=o?` Try ${n}="${o}".`:"";return`${e}: ${n} "${i}" not found in data. Available fields: ${t.join(", ")}.${r}`}}}return null}function Uu({componentName:e,data:t,dataLabel:o="data"}){return null==t?`${e}: No ${o} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${o} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Ku({componentName:e,nodes:t,edges:o,nodesRequired:r=!1,edgesRequired:n=!0,accessors:i}){if(null==t&&null==o)return null;if(n&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const o=Yu(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,n]of Object.entries(i))if(n&&"string"==typeof n&&!(n in o)){const o=Vu(n,t),i=o?` Try ${r}="${o}".`:"";return`${e}: ${r} "${n}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}import{useCallback as Qu,useMemo as Zu,useState as Ju}from"react";import{useMemo as ed}from"react";function td(e){const t=ee(e=>e.theme.colors.selectionOpacity);return ed(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}function od(e){const{data:t,rawData:o,colorBy:r,colorScheme:n,legendInteraction:i,legendPosition:a,selection:s,linkedHover:l,fallbackFields:c,unwrapData:d=!1,onObservation:h,chartType:p,chartId:m,showLegend:f,userMargin:g,marginDefaults:y,onClick:b,hoverHighlight:v,mobileInteraction:x,mobileSemantics:w,loading:k,loadingContent:S,emptyContent:A,width:C,height:M}=e,P=void 0===o,I=Zu(()=>u(t),[t]),[_,L]=Ju([]),R=Qu(e=>{L(t=>t.length===e.length&&t.every((t,o)=>t===e[o])?t:e)},[]),T="string"==typeof e.colorBy?e.colorBy:void 0,N=Zu(()=>bu(x,{width:C,mobileSemantics:w}),[x,C,w]),{activeSelectionHook:$,hoverSelectionHook:B,customHoverBehavior:D,customClickBehavior:F,crosshairSourceId:E}=Su({selection:s,linkedHover:l,fallbackFields:c,unwrapData:d,onObservation:h,chartType:p,chartId:m,onClick:b,hoverHighlight:v,colorByField:T,mobileInteraction:N}),z=Au(l,E),j=wu(I,r,n),O=Zu(()=>{if(!r)return[];const e=new Set;for(const t of I){const o="function"==typeof r?r(t):t[r];null!=o&&e.add(o+"")}return Array.from(e)},[I,r]),H=Zu(()=>P&&_.length>0?_:O,[P,_,O]),W=Mu(i,r,H),q=Zu(()=>B||(W.legendSelectionHook?W.legendSelectionHook:$),[B,W.legendSelectionHook,$]),G=td(s),Y=vu(),V=ic(),X=Zu(()=>{if(j)return j;if(!r||0===H.length)return;const e=Array.isArray(n)&&n.length>0||"string"==typeof n&&n.length>0?n:Y&&Y.length>0?Y:ze,t="__streamCat",o=qe(H.map(e=>({[t]:e})),t,e);return e=>V?.[e]||o(e)||"#999"},[j,r,H,n,Y,V]),{legend:U,margin:K,legendPosition:Q}=Cu({data:I,colorBy:r,colorScale:X,showLegend:f,legendPosition:a,userMargin:g,defaults:y,categories:H}),Z=Zu(()=>{const e={};return U&&(e.legend=U,e.legendPosition=Q),i&&"none"!==i&&(e.legendHoverBehavior=W.onLegendHover,e.legendClickBehavior=W.onLegendClick,e.legendHighlightedCategory=W.highlightedCategory,e.legendIsolatedCategories=W.isolatedCategories),P&&r&&(e.legendCategoryAccessor=r,e.onCategoriesChange=R),e},[U,Q,i,W.onLegendHover,W.onLegendClick,W.highlightedCategory,W.isolatedCategories,P,r,R]),J=Array.isArray(o)?u(o):o,ee=Hu(k,C,M,S),te=ee?null:Ou(J,C,M,A);return{data:I,colorScale:j,allCategories:H,legendState:W,effectiveSelectionHook:q,activeSelectionHook:$,customHoverBehavior:D,customClickBehavior:F,mobileInteraction:N,legend:U,margin:K,legendPosition:Q,earlyReturn:ee||te||null,legendBehaviorProps:Z,crosshairProps:z,resolvedSelection:G}}import{useMemo as rd}from"react";function nd(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??(()=>({}));const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...o}):(...e)=>({...o})}function id(e){const{lineWidth:t=2,colorBy:o,colorScale:r,color:n,resolveStroke:i,fillArea:a,areaOpacity:s=.3,stroke:l,strokeWidth:c,opacity:u,effectiveSelectionHook:d,resolvedSelection:h}=e,p=rd(()=>(e,l)=>{const c={strokeWidth:t},u=!0===a||Array.isArray(a)&&null!=l&&a.includes(l);let d;return i?d=i(e,l):o?r&&(d=He(e,o,r)):d=n||pu,void 0!==d&&(c.stroke=d,u&&(c.fill=d,c.fillOpacity=s)),c},[t,o,r,n,i,a,s]),m=rd(()=>nd(p,{stroke:l,strokeWidth:c,opacity:u}),[p,l,c,u]);return rd(()=>Qc(m,d??null,h),[m,d,h])}import{useImperativeHandle as ad}from"react";function sd(e,t){const{variant:o,frameRef:r,overrides:n,deps:i}=t;ad(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,o)=>e.current?.update(t,o)??[],clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const o=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],n=[];for(const t of o){const o=r.find(e=>e.id===t);o&&n.push({...o.data??{},id:t}),e.current?.removeNode(t)}return n},update:(t,o)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,o);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,o)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(o(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const o=t;return{push:e=>o.current?.pushLine(e),pushMany:e=>o.current?.pushManyLines(e),remove:e=>o.current?.removeLine(e)??[],update:(e,t)=>{const r=o.current?.removeLine(e)??[];for(const e of r)o.current?.pushLine(t(e));return r},clear:()=>o.current?.clear(),getData:()=>o.current?.getLines()??[],getCustomLayout:()=>o.current?.getCustomLayout?.()??null,getLayoutFailure:()=>o.current?.getLayoutFailure?.()??null}}(o,r);return{...e,...n}},i??[])}function ld(e){const{title:t,description:o,summary:r,accessibleTable:n,className:i,animate:a,axisExtent:s,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),o&&(c.description=o),r&&(c.summary=r),void 0!==n&&(c.accessibleTable=n),i&&(c.className=i),null!=a&&(c.animate=a),void 0!==s&&(c.axisExtent=s),void 0!==l&&(c.autoPlaceAnnotations=l),c}function cd(e){const{linkedHover:t,selection:o,onObservation:r,onClick:n,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,p={},m=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||r||n||a)&&(p.customHoverBehavior=u),d&&(l||(h?r||n||t:r||n)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||o))&&(p.customClickBehavior=d),null!=m&&(p.hoverRadius=m),p}function ud(e){const{tooltip:t,defaultTooltipContent:o}=e;return{tooltipContent:!1===t?()=>null:xs(t)||o}}var dd="__forecastSegment",hd=null;async function pd(){return hd||(hd=await import("./semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js")),hd}import{useEffect as md,useMemo as fd,useRef as gd,useState as yd}from"react";var bd="__semiotic_resolvedX",vd="__semiotic_resolvedY";function xd(e){const{data:t,xAccessor:o,yAccessor:r,forecast:n,anomaly:i,groupBy:a}=e,s="string"==typeof o?o:bd,l="string"==typeof r?r:vd,c=fd(()=>{if(!n&&!i)return t;const e="function"==typeof o,a="function"==typeof r;return e||a?t.map(t=>{const n={...t};return e&&(n[bd]=o(t)),a&&(n[vd]=r(t)),n}):t},[t,n,i,o,r]),[u,d]=yd(null),[h,p]=yd([]),m=gd(n),f=gd(i);return md(()=>{if(!n&&!i)return void((m.current||f.current)&&(d(null),p([]),m.current=n,f.current=i));let e=!1;const t=n!==m.current||i!==f.current;if(m.current=n,f.current=i,t&&(d(null),p([])),n){const t=a&&"string"==typeof a&&"object"==typeof n?{...n,_groupBy:a}:n;(async function(...e){return(await pd()).buildForecast(...e)})(c,s,l,t,i).then(t=>{e||(d(t),p(t.annotations))}).catch(()=>{e||(d(null),p([]))})}else i&&async function(...e){return(await pd()).buildAnomalyAnnotations(...e)}(i).then(t=>{e||(d(null),p(t))}).catch(()=>{e||p([])});return()=>{e=!0}},[c,n,i,s,l,a]),{effectiveData:u?u.processedData:t,statisticalAnnotations:h,hasForecast:!!u,xAccessorKey:s,yAccessorKey:l}}import{jsx as wd}from"react/jsx-runtime";var kd="__lineObjectSeries",Sd=s(function(e,t){const o=l(null);sd(t,{variant:"xy",frameRef:o});const s=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:c,margin:d,className:h,xFormat:p,yFormat:m,axisExtent:f,xAccessor:g="x",yAccessor:y="y",lineBy:b,lineDataAccessor:v="coordinates",colorBy:x,colorScheme:w,curve:k="linear",showPoints:S=!1,pointRadius:A=3,fillArea:C=!1,areaOpacity:M=.3,lineWidth:P=2,lineGradient:I,tooltip:_,pointIdAccessor:L,annotations:R,directLabel:T,gapStrategy:N="break",anomaly:$,forecast:B,band:D,xExtent:F,yExtent:E,frameProps:z={},selection:j,linkedHover:O,onObservation:H,onClick:W,hoverHighlight:q,hoverRadius:G,chartId:Y,loading:V,loadingContent:X,emptyContent:U,legendInteraction:K,legendPosition:Q,xScaleType:Z,yScaleType:J,color:ee,stroke:te,strokeWidth:oe,opacity:re}=e,{width:ne,height:ie,enableHover:ae,showGrid:se,showLegend:le,title:ce,description:ue,summary:de,accessibleTable:he,xLabel:pe,yLabel:me}=s,fe=r(()=>u(c),[c]),ge=Array.isArray(fe[0]?.[v])?fe[0][v]:fe;Wu("LineChart",ge,"xAccessor",g),Wu("LineChart",ge,"yAccessor",y);const{effectiveData:ye,statisticalAnnotations:be}=xd({data:fe,xAccessor:g,yAccessor:y,forecast:B,anomaly:$,groupBy:b}),ve="__compoundGroup",xe=!(!B||!b),we=xe?ve:B?dd:b,ke=r(()=>{if(!xe)return ye;const e="function"==typeof b?b:e=>e[b];return ye.map(t=>{const o={...t};return o[ve]=`${e(t)}__${t[dd]||"observed"}`,o})},[ye,xe,b]),Se=xe?ke:ye,Ae=x||b,Ce=r(()=>{if(!B)return;const e=B.upperBounds,t=B.lowerBounds;if(!e&&!t)return;const o="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,r="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let n=1/0,i=-1/0;const a=ye;for(const e of a){const t="function"==typeof y?y(e):+e[y];if(isFinite(t)&&(n>t&&(n=t),t>i&&(i=t)),o){const t=o(e);null!=t&&isFinite(t)&&(t>i&&(i=t),n>t&&(n=t))}if(r){const t=r(e);null!=t&&isFinite(t)&&(n>t&&(n=t),t>i&&(i=t))}}return isFinite(n)&&isFinite(i)?[n,i]:void 0},[B,ye,y]),Me=n(e=>{const t="function"==typeof g?g(e):e[g],o="function"==typeof y?y(e):e[y];return null==t||null==o||Number.isNaN(t)||Number.isNaN(o)},[g,y]),Pe=void 0!==Se[0]?.[v],Ie=Pe?kd:we,_e=r(()=>{if(Pe)return Se.map((e,t)=>{const o="function"==typeof b?b(e):"string"==typeof b?e[b]:void 0,r=null==o?"line-"+t:o+"",n=Array.isArray(e[v])?e[v]:[];return{...e,[kd]:r,[v]:n.map(t=>({...t,[kd]:r,parentLine:e,..."string"==typeof b&&void 0!==e[b]?{[b]:e[b]}:{}}))}});if(we){const e=Se.reduce((e,t)=>{const o="function"==typeof we?we(t):t[we];if(!e[o]){const r={[v]:[]};"string"==typeof we&&(r[we]=o),xe&&(r[dd]=t[dd],"string"==typeof b&&(r[b]=t[b])),e[o]=r}return e[o][v].push(t),e},{});return Object.values(e)}return[{[v]:Se}]},[Se,we,v,Pe,b]),{gapProcessedLineData:Le,hasGaps:Re}=r(()=>{if("interpolate"===N){let e=!1;const t=[];for(const o of _e){const r=(o[v]||[]).filter(t=>!Me(t)||(e=!0,!1));r.length>0&&t.push({...o,[v]:r})}return{gapProcessedLineData:t,hasGaps:e}}if("break"===N){let e=!1;const t=[];for(const o of _e){const r=o[v]||[];let n=[],i=0;const a=Ie&&"string"==typeof Ie?o[Ie]:void 0;for(const s of r)if(Me(s))e=!0,n.length>0&&(t.push({...o,[v]:n}),n=[],i++);else{const e=null!=a?`${a}__seg${i}`:"__seg"+i;n.push({...s,_gapSegment:e})}n.length>0&&t.push({...o,[v]:n})}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===N){let e=!1;const t="string"==typeof y?y:"y",o=[];for(const r of _e){const n=r[v]||[],i=[];for(const o of n)Me(o)?(e=!0,i.push({...o,[t]:0})):i.push(o);o.push({...r,[v]:i})}return{gapProcessedLineData:o,hasGaps:e}}return{gapProcessedLineData:_e,hasGaps:!1}},[_e,N,v,Me,Ie,y]),Te="object"==typeof T?T:{},Ne=Te.position||"end",$e=Te.fontSize||11,Be=r(()=>{if(!T||!Ae)return[];const e="function"==typeof Ae?Ae:e=>e[Ae],t=new Set;for(const o of Le){const r=o[v]||[];if(0===r.length)continue;const n=e("end"===Ne?r[r.length-1]:r[0])??e(o);if(null==n)continue;const i=n+"";""!==i&&t.add(i)}return Array.from(t)},[T,Ae,Le,v,Ne]),De=r(()=>{if(!T)return s.marginDefaults;const e=Be.reduce((e,t)=>Math.max(e,t.length*(.6*$e)),0)+10,t="end"===Ne?"right":"left";return{...s.marginDefaults,[t]:Math.max(s.marginDefaults[t]||0,e)}},[T,Be,$e,Ne,s.marginDefaults]),Fe=od({data:ye,rawData:c,colorBy:Ae,colorScheme:w,legendInteraction:K,legendPosition:Q,selection:j,linkedHover:O,fallbackFields:Ae?["string"==typeof Ae?Ae:""]:[],unwrapData:!1,onObservation:H,onClick:W,hoverHighlight:q,mobileInteraction:s.mobileInteraction,mobileSemantics:s.mobileSemantics,chartType:"LineChart",chartId:Y,showLegend:(!T||void 0!==le)&&le,userMargin:d,marginDefaults:De,loading:V,loadingContent:X,emptyContent:U,width:ne,height:ie}),Ee=Fe.colorScale,ze=Fe.effectiveSelectionHook,je=Fe.resolvedSelection,Oe=Fe.customHoverBehavior,We=Fe.customClickBehavior,qe=Fe.crosshairProps,Ge=id({lineWidth:P,colorBy:r(()=>{if(Ae)return Pe?e=>{const t=e.parentLine||e;return"function"==typeof Ae?Ae(t):t[Ae]}:Ae},[Ae,Pe]),colorScale:Ee,color:ee,fillArea:C,areaOpacity:M,stroke:te,strokeWidth:oe,opacity:re,effectiveSelectionHook:ze,resolvedSelection:je}),[Ye,Ve]=i(null);a(()=>{if(!B)return void Ve(null);let e=!1;return async function(...e){return(await pd()).createSegmentLineStyle(...e)}(Ge,B).then(t=>{e||Ve(()=>t)}).catch(()=>{e||Ve(null)}),()=>{e=!0}},[Ge,B]);const Xe=Ye||Ge,Ue=r(()=>{if(S)return e=>{const t={r:A,fillOpacity:1};return Ae?Ee&&(t.fill=He(e.parentLine||e,Ae,Ee)):t.fill=ee||pu,t}},[S,A,Ae,Ee,ee]),Ke=Array.isArray(C)?"mixed":C?"area":"line",Qe=r(()=>{if(!T||!Ae)return[];const e="function"==typeof g?g:e=>e[g],t="function"==typeof y?y:e=>e[y],o="function"==typeof Ae?Ae:e=>e[Ae],r=new Map;for(const e of Le){const t=e[v]||[];if(0===t.length)continue;const n="end"===Ne?t[t.length-1]:t[0],i=o(n)??o(e);if(null==i)continue;const a=i+"";""===a||r.has(a)||r.set(a,n)}const n=Array.from(r.entries()).map(([o,r])=>({type:"text",label:o,["string"==typeof g?g:"x"]:e(r),["string"==typeof y?y:"y"]:t(r),dx:"end"===Ne?6:-6,dy:0,color:Ee?Ee(o):pu,fontSize:$e}));n.sort((e,t)=>{const o="string"==typeof y?y:"y";return e[o]-t[o]});for(let e=1;n.length>e;e++){const t="string"==typeof y?y:"y",o=n[e-1],r=n[e];$e+2>Math.abs(r[t]+r.dy-(o[t]+o.dy))&&(r.dy+=$e+2)}return n},[T,Ae,Ee,Le,v,g,y,Ne,$e]),Ze=Fe.margin,Je=b||x,et=r(()=>$l([{label:pe||_l(g),accessor:g,role:"x",format:p},{label:me||_l(y),accessor:y,role:"y",format:m},...Je?[{label:_l(Je),accessor:Je,role:"group"}]:[],...Nl(D,m)]),[g,y,pe,me,Je,p,m,D]),tt=Xu({componentName:"LineChart",data:Pe?ye[0]?.[v]||[]:c,accessors:{xAccessor:g,yAccessor:y}}),ot=r(()=>Pe||Ie||Re?Le.flatMap(e=>{const t=e[v]||[];return Ie&&"string"==typeof Ie?t.map(t=>({...t,[Ie]:t[Ie]??e[Ie]})):t}):Se,[Le,v,Pe,Ie,Se,Re]),rt={chartType:Ke,...Array.isArray(C)&&{areaGroups:C},...I&&{lineGradient:I},...null!=c&&{data:ot},xAccessor:g,yAccessor:y,xScaleType:Z,yScaleType:J,...F&&{xExtent:F},...!E||null==E[0]&&null==E[1]?Ce?{yExtent:Ce}:{}:{yExtent:E},groupAccessor:"break"===N&&Re?"_gapSegment":Ie||void 0,...D&&{band:D},curve:k,lineStyle:Xe,...S&&{pointStyle:Ue},size:[ne,ie],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Ze,showAxes:s.showAxes,xLabel:pe,yLabel:me,xFormat:p,yFormat:m,...void 0!==f&&{axisExtent:f},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},enableHover:ae,showGrid:se,...Fe.legendBehaviorProps,...ce&&{title:ce},...ue&&{description:ue},...de&&{summary:de},...void 0!==he&&{accessibleTable:he},...h&&{className:h},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===_?()=>null:"multi"===_?vs():xs(_)||et,..."multi"===_&&{tooltipMode:"multi"},...cd({linkedHover:O,selection:j,onObservation:H,onClick:W,hoverRadius:G,hoverHighlight:q,mobileInteraction:Fe.mobileInteraction,customHoverBehavior:Oe,customClickBehavior:We}),...L&&{pointIdAccessor:L},...(R?.length||be.length||Qe.length)&&{annotations:[...R||[],...be,...Qe]},...qe,...z};return Fe.earlyReturn?Fe.earlyReturn:tt?wd(Tu,{componentName:"LineChart",message:tt,width:ne,height:ie}):wd(Eu,{componentName:"LineChart",width:ne,height:ie,children:wd(Yl,{ref:o,...rt})})});Sd.displayName="LineChart";import{useMemo as Ad,forwardRef as Cd,useRef as Md}from"react";import{useMemo as Pd}from"react";function Id(e){const{safeData:t,data:o,areaBy:r,lineDataAccessor:n,colorBy:i,colorScale:a,color:s,stroke:l,strokeWidth:c,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,areaOpacity:p,showLine:m,lineWidth:f,showPoints:g,pointRadius:y,xAccessor:b,yAccessor:v,xLabel:x,yLabel:w,xFormat:k,yFormat:S,groupField:A}=e,C=void 0!==t[0]?.[n],M=Pd(()=>{if(null==o)return[];if(!C&&!r)return t;let e;if(C)e=t;else{const o=r,i=t.reduce((e,t)=>{const r="function"==typeof o?o(t):t[o];if(!e[r]){const t={[n]:[]};"string"==typeof o&&(t[o]=r),e[r]=t}return e[r][n].push(t),e},{});e=Object.values(i)}return e.flatMap(e=>{const t=e[n]||[];return r&&"string"==typeof r?t.map(t=>({...t,[r]:e[r]})):t})},[o,t,r,n,C]),P=Pd(()=>e=>{const t={};if(i){if(a){const o=He(e,i,a);t.fill=o,m?(t.stroke=o,t.strokeWidth=f):t.stroke="none"}}else{const e=s||pu;t.fill=e,m?(t.stroke=e,t.strokeWidth=f):t.stroke="none"}return t.fillOpacity=p,t},[i,a,s,p,m,f]),I=Pd(()=>nd(P,{stroke:l,strokeWidth:c,opacity:u}),[P,l,c,u]);return{flattenedData:M,lineStyle:Pd(()=>Qc(I,d??null,h),[I,d,h]),pointStyle:Pd(()=>{if(g)return e=>{const t={r:y,fillOpacity:1};return i?a&&(t.fill=He(e.parentLine||e,i,a)):t.fill=s||pu,t}},[g,y,i,a,s]),defaultTooltipContent:Pd(()=>$l([{label:x||_l(b),accessor:b,role:"x",format:k},{label:w||_l(v),accessor:v,role:"y",format:S},...A?[{label:_l(A),accessor:A,role:"group"}]:[],...Nl(e.band,S)]),[b,v,x,w,A,k,S,e.band])}}import{jsx as _d}from"react/jsx-runtime";function Ld(e,t){if(null==t)return e;const o=e.trim(),r=o.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(r){const e=r[1],o=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}if(o.startsWith("rgba(")){const e=o.lastIndexOf(","),r=o.lastIndexOf(")");if(-1!==e&&r>e)return`${o.slice(0,e+1)} ${t})`}return o.startsWith("rgb(")?o.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}var Rd=Cd(function(e,t){const o=Md(null);sd(t,{variant:"xy",frameRef:o});const r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:d="y",areaBy:h,y0Accessor:p,gradientFill:m=!1,semanticGradient:f,lineDataAccessor:g="coordinates",colorBy:y,colorScheme:b,curve:v="monotoneX",areaOpacity:x=.7,lineGradient:w,showLine:k=!0,lineWidth:S=2,showPoints:A=!1,pointRadius:C=3,tooltip:M,annotations:P,forecast:I,anomaly:_,band:L,xExtent:R,yExtent:T,frameProps:N={},selection:$,linkedHover:B,onObservation:D,onClick:F,hoverHighlight:E,chartId:z,loading:j,loadingContent:O,emptyContent:H,legendInteraction:W,legendPosition:q,color:G,stroke:Y,strokeWidth:V,opacity:X}=e,{width:U,height:K,enableHover:Q,showGrid:Z,showLegend:J,title:ee,description:te,summary:oe,accessibleTable:re,xLabel:ne,yLabel:ie}=r,ae=Ad(()=>u(n),[n]),se=y||h,le=Ad(()=>{return f&&f.length>0?{colorStops:(e=f,e.filter(e=>Number.isFinite(e.at)).map(e=>({offset:1-Math.max(0,Math.min(100,e.at))/100,color:Ld(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset))}:m;var e},[f,m]);Wu("AreaChart",ae,"xAccessor",c),Wu("AreaChart",ae,"yAccessor",d);const ce=od({data:ae,rawData:n,colorBy:se,colorScheme:b,legendInteraction:W,legendPosition:q,selection:$,linkedHover:B,fallbackFields:se?["string"==typeof se?se:""]:[],unwrapData:!1,onObservation:D,onClick:F,hoverHighlight:E,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"AreaChart",chartId:z,showLegend:J,userMargin:i,marginDefaults:r.marginDefaults,loading:j,loadingContent:O,emptyContent:H,width:U,height:K}),{effectiveData:ue,statisticalAnnotations:de}=xd({data:ae,xAccessor:c,yAccessor:d,forecast:I,anomaly:_,groupBy:h}),{flattenedData:he,lineStyle:pe,pointStyle:me,defaultTooltipContent:fe}=Id({safeData:ue,data:n,areaBy:h,lineDataAccessor:g,colorBy:se,colorScale:ce.colorScale,color:G,stroke:Y,strokeWidth:V,opacity:X,effectiveSelectionHook:ce.effectiveSelectionHook,resolvedSelection:ce.resolvedSelection,areaOpacity:x,showLine:k,lineWidth:S,showPoints:A,pointRadius:C,xAccessor:c,yAccessor:d,xLabel:ne,yLabel:ie,xFormat:s,yFormat:l,groupField:h||y,band:L}),ge=Xu({componentName:"AreaChart",data:n,accessors:{xAccessor:c,yAccessor:d}}),ye={chartType:"area",...null!=n&&{data:he},xAccessor:c,yAccessor:d,groupAccessor:h||void 0,...p&&{y0Accessor:p},...L&&{band:L},...le&&{gradientFill:le},...w&&{lineGradient:w},curve:v,lineStyle:pe,...A&&me&&{pointStyle:me},size:[U,K],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ce.margin,showAxes:r.showAxes,xLabel:ne,yLabel:ie,xFormat:s,yFormat:l,enableHover:Q,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:Z,...ce.legendBehaviorProps,...ld({title:ee,description:te,summary:oe,accessibleTable:re,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===M?{tooltipContent:vs(),tooltipMode:"multi"}:ud({tooltip:M,defaultTooltipContent:fe}),...cd({linkedHover:B,selection:$,onObservation:D,onClick:F,hoverHighlight:E,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior}),...(P&&P.length>0||de.length>0)&&{annotations:[...P||[],...de]},...R&&{xExtent:R},...T&&{yExtent:T},...ce.crosshairProps,...N};return ce.earlyReturn?ce.earlyReturn:ge?_d(Tu,{componentName:"AreaChart",message:ge,width:U,height:K}):_d(Eu,{componentName:"AreaChart",width:U,height:K,children:_d(Yl,{ref:o,...ye})})});Rd.displayName="AreaChart";import{useMemo as Td,forwardRef as Nd,useRef as $d,useState as Bd,useImperativeHandle as Dd,useCallback as Fd}from"react";import{jsx as Ed,jsxs as zd}from"react/jsx-runtime";function jd(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}var Od=Nd(function(e,t){const o=$d(null),r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",seriesAAccessor:d="a",seriesBAccessor:h="b",seriesALabel:p="A",seriesBLabel:m="B",seriesAColor:f="var(--semiotic-danger, #dc2626)",seriesBColor:g="var(--semiotic-info, #2563eb)",showLines:y=!0,lineWidth:b=1.5,showPoints:v=!1,pointRadius:x=3,curve:w="linear",areaOpacity:k=.6,gradientFill:S,tooltip:A,annotations:C,xExtent:M,yExtent:P,frameProps:I={},selection:_,linkedHover:L,onObservation:R,onClick:T,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:F,legendInteraction:E,legendPosition:z,pointIdAccessor:j,windowSize:O}=e,{width:H,height:W,enableHover:q,showGrid:G,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,xLabel:Q,yLabel:Z}=r,J=Td(()=>"function"==typeof c?e=>jd(c(e)):e=>jd(e[c]),[c]),ee=Td(()=>"function"==typeof d?e=>jd(d(e)):e=>jd(e[d]),[d]),te=Td(()=>"function"==typeof h?e=>jd(h(e)):e=>jd(e[h]),[h]),[oe,re]=Bd([]),ne=$d([]),ie=null==n,ae=Td(()=>u(ie?oe:n),[ie,oe,n]),se=Td(()=>function(e,t,o,r){if(!e.length)return[];const n=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),i=[];let a=0,s=null,l=null,c=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${a}-${e}`,h=e=>i.push(e),p=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;n.length>e;e++){const i=n[e],m=t(i),f=o(i),g=r(i);if(!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(g))continue;const y=u(f,g);if(null!==y)if(null!=s){if(l&&l.w!==y){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{const o=f-l.a-(g-l.b);if(0!==o){const r=Math.max(0,Math.min(1,(l.b-l.a)/o));e=l.x+r*(m-l.x),t=l.a+r*(f-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=y,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;c.length>e;e++)p(c[e],s)}else for(const e of c)p(e,s);c=[],h({__x:m,__y:g>f?g:f,__y0:g>f?f:g,__diffSegment:d(s),__diffWinner:s,__valA:f,__valB:g,__sourceDatum:i}),l={x:m,a:f,b:g,w:y}}else{s=y;for(const e of c)p(e,s);c=[],h({__x:m,__y:g>f?g:f,__y0:g>f?f:g,__diffSegment:d(s),__diffWinner:s,__valA:f,__valB:g,__sourceDatum:i}),l={x:m,a:f,b:g,w:y}}else c.push({x:m,y:f,datum:i})}for(const e of c)p(e,s??"A");return i}(ae,J,ee,te),[ae,J,ee,te]),le=Td(()=>y?function(e,t,o,r){if(!e.length)return[];const n=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),i=[];for(const e of n){const n=t(e),a=o(e),s=r(e);Number.isFinite(a)&&i.push({__x:n,__y:a,__diffSegment:"line-A"}),Number.isFinite(s)&&i.push({__x:n,__y:s,__diffSegment:"line-B"})}return i}(ae,J,ee,te):[],[y,ae,J,ee,te]),ce=Td(()=>[...se,...le],[se,le]),ue=Td(()=>{const e=new Set;for(const t of se)e.add(t.__diffSegment);return Array.from(e)},[se]);Dd(t,()=>{const e=e=>{const t=O&&e.length>O?e.slice(e.length-O):e;ne.current=t,re(t)},t=j?"function"==typeof j?j:e=>e[j]:null;return{push:t=>e([...ne.current,t]),pushMany:t=>e([...ne.current,...t]),remove:o=>{if(!t)return[];const r=Array.isArray(o)?o:[o],n=[],i=[];for(const e of ne.current)r.includes(t(e))?n.push(e):i.push(e);return e(i),n},update:(o,r)=>{if(!t)return[];const n=Array.isArray(o)?o:[o],i=[],a=ne.current.map(e=>{if(n.includes(t(e))){const t=r(e);return i.push(t),t}return e});return e(a),i},clear:()=>e([]),getData:()=>ie?ne.current:ae,getScales:()=>o.current?.getScales()??null}},[ie,ae,j,O]);const de=od({data:ae,rawData:n,colorBy:"__diffWinner",colorScheme:[f,g],legendInteraction:E,legendPosition:z,selection:_,linkedHover:L,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"DifferenceChart",chartId:$,showLegend:Y,userMargin:i,marginDefaults:r.marginDefaults,loading:B,loadingContent:D,emptyContent:F,width:H,height:W}),he=Td(()=>{if(!1!==Y)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:p,color:f},{label:m,color:g}]}]}},[Y,p,m,f,g]),pe=Fd(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?f:g,stroke:"none",fillOpacity:k}},[f,g,k]),me=Fd(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?f:g,strokeWidth:b,fill:"none"}),[f,g,b]),fe=Fd(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?f:g,r:x}),[f,g,x]),ge=Fd(e=>{const t=e.data,o=e.allSeries,r=e.xValue??t?.__x;let n=t?.__valA,i=t?.__valB;if(o&&o.length>0){const e=o.find(e=>"line-A"===e.group),t=o.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(n=e.value),null!=t?.value&&Number.isFinite(t.value)&&(i=t.value)}if(null!=r&&(null==n||null==i)){const e=ae.find(e=>J(e)===r);e&&(null==n&&(n=ee(e)),null==i&&(i=te(e)))}const a=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",l=s&&null!=r?s(r):null!=r?r+"":"";return zd("div",{className:"semiotic-tooltip",style:ms,children:[l&&Ed("div",{style:{fontWeight:600,marginBottom:4},children:l}),zd("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Ed("span",{style:{width:10,height:10,background:f,display:"inline-block",borderRadius:2}}),zd("span",{children:[p,": ",a(n)]})]}),zd("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Ed("span",{style:{width:10,height:10,background:g,display:"inline-block",borderRadius:2}}),zd("span",{children:[m,": ",a(i)]})]}),null!=n&&null!=i&&Number.isFinite(n)&&Number.isFinite(i)&&zd("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",a(n-i)]})]})},[ae,J,ee,te,s,f,g,p,m]),ye="multi"===A,be=Td(()=>!1===A?()=>null:ye?ge:xs(A)||ge,[A,ye,ge]);if(de.earlyReturn)return de.earlyReturn;const ve={chartType:"mixed",data:ce,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:ue,curve:w,areaStyle:pe,lineStyle:me,...v&&{pointStyle:fe},size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:de.margin,showAxes:r.showAxes,xLabel:Q,yLabel:Z,xFormat:s,yFormat:l,enableHover:q,showGrid:G,...S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S},...he&&{legend:he,legendPosition:de.legendPosition},...ld({title:V,description:X,summary:U,accessibleTable:K,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:be,...ye&&{tooltipMode:"multi"},...cd({linkedHover:L,selection:_,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:de.mobileInteraction,customHoverBehavior:de.customHoverBehavior,customClickBehavior:de.customClickBehavior}),...C&&C.length>0&&{annotations:C},...M&&{xExtent:M},...P&&{yExtent:P},...de.crosshairProps,...I};return Ed(Eu,{componentName:"DifferenceChart",width:H,height:W,children:Ed(Yl,{ref:o,...ve})})});"function"==typeof Od&&(Od.displayName="DifferenceChart");import{useMemo as Hd,forwardRef as Wd,useRef as qd}from"react";import{jsx as Gd}from"react/jsx-runtime";var Yd=Wd(function(e,t){const o=qd(null),r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:d="y",areaBy:h,lineDataAccessor:p="coordinates",colorBy:m,colorScheme:f,curve:g="monotoneX",areaOpacity:y=.7,showLine:b=!0,lineWidth:v=2,showPoints:x=!1,pointRadius:w=3,normalize:k=!1,baseline:S="zero",stackOrder:A,tooltip:C,annotations:M,xExtent:P,yExtent:I,frameProps:_={},selection:L,linkedHover:R,onObservation:T,onClick:N,hoverHighlight:$,chartId:B,loading:D,loadingContent:F,emptyContent:E,legendInteraction:z,legendPosition:j,color:O,stroke:H,strokeWidth:W,opacity:q}=e,{width:G,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,oe=Hd(()=>u(n),[n]),re=m||h;sd(t,{variant:"xy",frameRef:o});const ne=od({data:oe,rawData:n,colorBy:re,colorScheme:f,legendInteraction:z,legendPosition:j,selection:L,linkedHover:R,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:T,onClick:N,hoverHighlight:$,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"StackedAreaChart",chartId:B,showLegend:U,userMargin:i,marginDefaults:r.marginDefaults,loading:D,loadingContent:F,emptyContent:E,width:G,height:Y}),{flattenedData:ie,lineStyle:ae,pointStyle:se,defaultTooltipContent:le}=Id({safeData:oe,data:n,areaBy:h,lineDataAccessor:p,colorBy:re,colorScale:ne.colorScale,color:O,stroke:H,strokeWidth:W,opacity:q,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection,areaOpacity:y,showLine:b,lineWidth:v,showPoints:x,pointRadius:w,xAccessor:c,yAccessor:d,xLabel:ee,yLabel:te,xFormat:s,yFormat:l,groupField:h||m}),ce=Xu({componentName:"StackedAreaChart",data:n,accessors:{xAccessor:c,yAccessor:d}}),ue={chartType:"stackedarea",...null!=n&&{data:ie},xAccessor:c,yAccessor:d,groupAccessor:h||void 0,curve:g,normalize:k,baseline:k?"zero":S,stackOrder:A,lineStyle:ae,...x&&se&&{pointStyle:se},size:[G,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ne.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:s,yFormat:l,enableHover:V,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:X,...ne.legendBehaviorProps,...ld({title:K,description:Q,summary:Z,accessibleTable:J,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===C?{tooltipContent:vs(),tooltipMode:"multi"}:ud({tooltip:C,defaultTooltipContent:le}),...cd({linkedHover:R,selection:L,onObservation:T,onClick:N,hoverHighlight:$,mobileInteraction:ne.mobileInteraction,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior}),...M&&M.length>0&&{annotations:M},...P&&{xExtent:P},...I&&{yExtent:I},...ne.crosshairProps,..._};return ne.earlyReturn?ne.earlyReturn:ce?Gd(Tu,{componentName:"StackedAreaChart",message:ce,width:G,height:Y}):Gd(Eu,{componentName:"StackedAreaChart",width:G,height:Y,children:Gd(Yl,{ref:o,...ue})})});Yd.displayName="StackedAreaChart";import*as Vd from"react";import{useMemo as Xd,useCallback as Ud,forwardRef as Kd,useRef as Qd}from"react";import{useMemo as Zd}from"react";function Jd(e){const{colorBy:t,colorScale:o,color:r,pointRadius:n=5,radiusFn:i,fillOpacity:a=1,fallbackFill:s,baseStyleExtras:l,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:p,colorDatumAccessor:m}=e,f=Zd(()=>e=>{const c="function"==typeof l?l(e):l,u=c?{...c}:{};if(void 0===u.fillOpacity&&(u.fillOpacity=a),void 0===u.fill)if(t){if(o){const r=m?m(e):e;u.fill=He(r,t,o)}}else u.fill=s?s(e):r||pu;return void 0===u.r&&(u.r=i?i(e):n),u},[t,o,r,n,i,a,s,l,m]),g=Zd(()=>nd(f,{stroke:c,strokeWidth:u,opacity:d}),[f,c,u,d]);return Zd(()=>Qc(g,h??null,p),[g,h,p])}import{useCallback as eh,useMemo as th,useRef as oh,useState as rh}from"react";function nh(e){const{accessor:t,data:o,isPushMode:r}=e,n=oh(null),[i,a]=rh(0),s=eh(e=>{if(!r||!t)return;let o=!1;for(const r of e){const e="function"==typeof t?t(r):r[t];if(null==e)continue;const i="number"==typeof e?e:Number(e);Number.isFinite(i)&&(n.current?(n.current[0]>i&&(n.current[0]=i,o=!0),i>n.current[1]&&(n.current[1]=i,o=!0)):(n.current=[i,i],o=!0))}o&&a(e=>e+1)},[r,t]),l=eh(()=>{r&&(n.current=null,a(e=>e+1))},[r]);return{domain:th(()=>{if(r)return n.current??void 0;if(!t||0===o.length)return;const e="function"==typeof t?t:e=>e[t];let i=1/0,a=-1/0;for(const t of o){const o=e(t);if(null==o)continue;const r="number"==typeof o?o:Number(o);Number.isFinite(r)&&(i>r&&(i=r),r>a&&(a=r))}return Number.isFinite(i)&&Number.isFinite(a)?[i,a]:void 0},[o,t,r,i]),trackPushed:s,reset:l}}function ih(e){if(!e)return;const t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}import{jsx as ah}from"react/jsx-runtime";var sh=Kd(function(e,t){const o=Qd(null),r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:d="y",xScaleType:h,yScaleType:p,colorBy:m,colorScheme:f,sizeBy:g,sizeRange:y=[3,15],symbolBy:b,symbolMap:v,pointRadius:x=5,pointOpacity:w=.8,tooltip:k,marginalGraphics:S,pointIdAccessor:A,annotations:C,regression:M,forecast:P,anomaly:I,xExtent:_,yExtent:L,frameProps:R={},selection:T,linkedHover:N,linkedBrush:$,onObservation:B,onClick:D,hoverHighlight:F,chartId:E,loading:z,loadingContent:j,emptyContent:O,legendInteraction:H,legendPosition:W,color:q,stroke:G,strokeWidth:Y,opacity:V}=e,{width:X,height:U,enableHover:K,showGrid:Q,showLegend:Z,title:J,description:ee,summary:te,accessibleTable:oe,xLabel:re,yLabel:ne}=r,ie=Xd(()=>u(n),[n]),ae=void 0===n,{domain:se,trackPushed:le,reset:ce}=nh({accessor:g,data:ie,isPushMode:ae}),ue=Ud(e=>{le([e]),o.current?.push(e)},[le]),de=Ud(e=>{le(e),o.current?.pushMany(e)},[le]);sd(t,{variant:"xy",frameRef:o,overrides:{push:ue,pushMany:de,clear:()=>{ce(),o.current?.clear()}},deps:[ue,de,ce]});const he=od({data:ie,rawData:n,colorBy:m,colorScheme:f,legendInteraction:H,legendPosition:W,selection:T,linkedHover:N,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!1,onObservation:B,onClick:D,hoverHighlight:F,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"Scatterplot",chartId:E,showLegend:Z,userMargin:i,marginDefaults:r.marginDefaults,loading:z,loadingContent:j,emptyContent:O,width:X,height:U}),pe=Kc($),me=Lc({name:pe?.name||"__unused_brush__",xField:pe?.xField||("string"==typeof c?c:void 0),yField:pe?.yField||("string"==typeof d?d:void 0)}),fe=pe?"xyBrush"===me.brushInteraction.brush?"xy":"xBrush"===me.brushInteraction.brush?"x":"y":void 0,ge=Vd.useRef(me.brushInteraction);ge.current=me.brushInteraction;const ye=Ud(e=>{const t=ge.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);Wu("Scatterplot",ie,"xAccessor",c),Wu("Scatterplot",ie,"yAccessor",d);const be=Xd(()=>g?se??[0,1]:void 0,[g,se]),ve=Xd(()=>g?e=>Ge(e,g,y,be):void 0,[g,y,be]),xe=Jd({colorBy:m,colorScale:he.colorScale,color:q,pointRadius:x,fillOpacity:w,radiusFn:ve,stroke:G,strokeWidth:Y,opacity:V,effectiveSelectionHook:he.effectiveSelectionHook,resolvedSelection:he.resolvedSelection}),we=Xd(()=>$l([{label:re||_l(c),accessor:c,role:"x",format:s},{label:ne||_l(d),accessor:d,role:"y",format:l},...m?[{label:_l(m),accessor:m,role:"color"}]:[],...g?[{label:_l(g),accessor:g,role:"size"}]:[]]),[c,d,re,ne,m,g,s,l]),{effectiveData:ke,statisticalAnnotations:Se}=xd({data:ie,xAccessor:c,yAccessor:d,forecast:P,anomaly:I}),Ae=Xd(()=>{const e=ih(M);return e||0!==Se.length?[...e?[e]:[],...C||[],...Se]:C},[M,C,Se]);if(he.earlyReturn)return he.earlyReturn;const Ce=Xu({componentName:"Scatterplot",data:n,accessors:{xAccessor:c,yAccessor:d}});if(Ce)return ah(Tu,{componentName:"Scatterplot",message:Ce,width:X,height:U});const Me={chartType:"scatter",...null!=n&&{data:ke},xAccessor:c,yAccessor:d,xScaleType:h,yScaleType:p,colorAccessor:m||void 0,sizeAccessor:g||void 0,...b&&{symbolAccessor:b},...v&&{symbolMap:v},sizeRange:y,pointStyle:xe,colorScheme:f,size:[X,U],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:he.margin,showAxes:r.showAxes,xLabel:re,yLabel:ne,xFormat:s,yFormat:l,enableHover:K,showGrid:Q,...he.legendBehaviorProps,...ld({title:J,description:ee,summary:te,accessibleTable:oe,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:k,defaultTooltipContent:we}),...cd({linkedHover:N,selection:T,onObservation:B,onClick:D,hoverHighlight:F,mobileInteraction:he.mobileInteraction,customHoverBehavior:he.customHoverBehavior,customClickBehavior:he.customClickBehavior}),...S&&{marginalGraphics:S},...A&&{pointIdAccessor:A},...Ae&&Ae.length>0&&{annotations:Ae},..._&&{xExtent:_},...L&&{yExtent:L},...pe&&{brush:{dimension:fe},onBrush:ye},...he.crosshairProps,...R};return ah(Eu,{componentName:"Scatterplot",width:X,height:U,children:ah(Yl,{ref:o,...Me})})});sh.displayName="Scatterplot";import{useMemo as lh,forwardRef as ch,useRef as uh}from"react";import{Fragment as dh,jsx as hh}from"react/jsx-runtime";function ph(e,t){return ke(1===t?.5:e/(t-1))}var mh=ch(function(e,t){const o=uh(null);sd(t,{variant:"xy",frameRef:o});const r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,pointRadius:p=4,tooltip:m,pointIdAccessor:f,annotations:g,regression:y,forecast:b,anomaly:v,xExtent:x,yExtent:w,frameProps:k={},selection:S,linkedHover:A,onObservation:C,onClick:M,hoverHighlight:P,chartId:I,loading:_,loadingContent:L,emptyContent:R,legendInteraction:T,stroke:N,strokeWidth:$,opacity:B}=e,{width:D,height:F,enableHover:E,showGrid:z,title:j,description:O,summary:H,accessibleTable:W,xLabel:q,yLabel:G}=r,Y=n||[],{safeData:V,orderMap:X}=lh(()=>{const e="function"==typeof c?c:e=>e[c],t="function"==typeof u?u:e=>e[u];let o=Y;if(d&&Y.length>0){const e="function"==typeof d?d:e=>e[d];o=[...Y].sort((t,o)=>{const r=e(t),n=e(o);return(r instanceof Date?r.getTime():+r)-(n instanceof Date?n.getTime():+n)})}const r=new WeakMap;let n=0;for(const r of o){const o=e(r),i=t(r);null!=o&&null!=i&&isFinite(o)&&isFinite(i)&&n++}let i=0;for(const a of o){const o=e(a),s=t(a);null!=o&&null!=s&&isFinite(o)&&isFinite(s)&&r.set(a,{idx:i++,total:n})}return{safeData:o,orderMap:r}},[Y,d,c,u]);Wu("ConnectedScatterplot",V,"xAccessor",c),Wu("ConnectedScatterplot",V,"yAccessor",u);const U=od({data:V,rawData:n,colorBy:void 0,colorScheme:void 0,legendInteraction:T,selection:S,linkedHover:A,fallbackFields:[],unwrapData:!1,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ConnectedScatterplot",chartId:I,showLegend:void 0,userMargin:i,marginDefaults:{top:50,right:40,bottom:60,left:70},loading:_,loadingContent:L,emptyContent:R,width:D,height:F}),K=U.resolvedSelection?.unselectedOpacity??.5,Q=lh(()=>(e,t)=>{const o=t.filter(e=>"point"===e.type);if(2>o.length)return;const r=U.effectiveSelectionHook?.isActive,n=U.effectiveSelectionHook?.predicate,i=100>o.length,a=o.length;e.lineCap="round";for(let t=0;a-1>t;t++){const s=o[t],l=o[t+1],c=ph(t,a),u=!r||!n||n(s.datum??s)||n(l.datum??l),d=r?u?1:K:1;i&&(e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(l.x,l.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*d,e.stroke()),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(l.x,l.y),e.strokeStyle=c,e.lineWidth=p,e.globalAlpha=d,e.stroke()}e.globalAlpha=1},[p,U.effectiveSelectionHook,K]),Z=lh(()=>[Q],[Q]),J=lh(()=>(e,t,o)=>{const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const n=r.length,i=100>n,a=[];for(let e=0;n-1>e;e++){const t=r[e],o=r[e+1],s=ph(e,n),l=Math.min("number"==typeof t.style?.opacity?t.style.opacity:1,"number"==typeof o.style?.opacity?o.style.opacity:1);i&&a.push(hh("line",{x1:t.x,y1:t.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:p+2,strokeLinecap:"round",opacity:.5*l},"halo-"+e)),a.push(hh("line",{x1:t.x,y1:t.y,x2:o.x,y2:o.y,stroke:s,strokeWidth:p,strokeLinecap:"round",opacity:l},"seg-"+e))}return hh(dh,{children:a})},[p]),ee=lh(()=>[J],[J]),te=Jd({colorScale:void 0,baseStyleExtras:lh(()=>e=>{const t=X.get(e),o=t?.idx??0,r=t?.total??1;return{fill:r>0?ph(o,r):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}},[p,X]),stroke:N,strokeWidth:$,opacity:B,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection}),oe=h||("string"==typeof d?d:"Order"),re=lh(()=>$l([{label:q||_l(c),accessor:c,role:"x",format:s},{label:G||_l(u),accessor:u,role:"y",format:l},...d?[{label:oe,accessor:d,role:"group"}]:[]]),[c,u,q,G,d,oe,s,l]),ne=Xu({componentName:"ConnectedScatterplot",data:n,accessors:{xAccessor:c,yAccessor:u}}),{effectiveData:ie,statisticalAnnotations:ae}=xd({data:V,xAccessor:c,yAccessor:u,forecast:b,anomaly:v});if(U.earlyReturn)return U.earlyReturn;const se=ih(y),le=se||ae.length>0?[...se?[se]:[],...g||[],...ae]:g,ce={chartType:"scatter",...null!=n&&{data:ie},xAccessor:c,yAccessor:u,pointStyle:te,size:[D,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,showAxes:r.showAxes,xLabel:q,yLabel:G,xFormat:s,yFormat:l,enableHover:E,showGrid:z,...ld({title:j,description:O,summary:H,accessibleTable:W,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:m,defaultTooltipContent:re}),...cd({linkedHover:A,selection:S,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...f&&{pointIdAccessor:f},canvasPreRenderers:Z,svgPreRenderers:ee,...le&&le.length>0&&{annotations:le},...x&&{xExtent:x},...w&&{yExtent:w},...U.crosshairProps,...k};return ne?hh(Tu,{componentName:"ConnectedScatterplot",message:ne,width:D,height:F}):hh(Eu,{componentName:"ConnectedScatterplot",width:D,height:F,children:hh(Yl,{ref:o,...ce})})});mh.displayName="ConnectedScatterplot";import{useMemo as fh,useCallback as gh,forwardRef as yh,useRef as bh}from"react";import{jsx as vh}from"react/jsx-runtime";var xh=yh(function(e,t){const o=bh(null),r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",yAccessor:d="y",sizeBy:h,sizeRange:p=[5,40],colorBy:m,colorScheme:f,bubbleOpacity:g=.6,bubbleStrokeWidth:y=1,bubbleStrokeColor:b="white",tooltip:v,marginalGraphics:x,pointIdAccessor:w,annotations:k,regression:S,xExtent:A,yExtent:C,frameProps:M={},selection:P,linkedHover:I,linkedBrush:_,onObservation:L,onClick:R,hoverHighlight:T,chartId:N,loading:$,loadingContent:B,emptyContent:D,legendInteraction:F,legendPosition:E,color:z,stroke:j,strokeWidth:O,opacity:H}=e,{width:W,height:q,enableHover:G,showGrid:Y,showLegend:V,title:X,description:U,summary:K,accessibleTable:Q,xLabel:Z,yLabel:J}=r,ee=fh(()=>u(n),[n]),te=void 0===n,oe=od({data:ee,rawData:n,colorBy:m,colorScheme:f,legendInteraction:F,legendPosition:E,selection:P,linkedHover:I,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!1,onObservation:L,onClick:R,hoverHighlight:T,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"BubbleChart",chartId:N,showLegend:V,userMargin:i,marginDefaults:r.marginDefaults,loading:$,loadingContent:B,emptyContent:D,width:W,height:q}),{domain:re,trackPushed:ne,reset:ie}=nh({accessor:h,data:ee,isPushMode:te}),ae=gh(e=>{ne([e]),o.current?.push(e)},[ne]),se=gh(e=>{ne(e),o.current?.pushMany(e)},[ne]);sd(t,{variant:"xy",frameRef:o,overrides:{push:ae,pushMany:se,clear:()=>{ie(),o.current?.clear()}},deps:[ae,se,ie]});const le=Kc(_),ce=(Lc({name:le?.name||"__unused_brush__",xField:le?.xField||("string"==typeof c?c:void 0),yField:le?.yField||("string"==typeof d?d:void 0)}),fh(()=>({stroke:b,strokeWidth:y}),[b,y])),ue=fh(()=>re??[0,1],[re]),de=gh(e=>Ge(e,h,p,ue),[h,p,ue]),he=Jd({colorBy:m,colorScale:oe.colorScale,color:z,fillOpacity:g,radiusFn:de,baseStyleExtras:ce,stroke:j,strokeWidth:O,opacity:H,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection}),pe=fh(()=>$l([{label:Z||_l(c),accessor:c,role:"x",format:s},{label:J||_l(d),accessor:d,role:"y",format:l},{label:_l(h),accessor:h,role:"size"},...m?[{label:_l(m),accessor:m,role:"color"}]:[]]),[c,d,Z,J,h,m,s,l]);if(oe.earlyReturn)return oe.earlyReturn;const me=Xu({componentName:"BubbleChart",data:n,accessors:{xAccessor:c,yAccessor:d},requiredProps:{sizeBy:h}});if(me)return vh(Tu,{componentName:"BubbleChart",message:me,width:W,height:q});const fe=ih(S),ge=fe?[fe,...k||[]]:k,ye={chartType:"bubble",...null!=n&&{data:ee},xAccessor:c,yAccessor:d,colorAccessor:m||void 0,sizeAccessor:h,sizeRange:p,pointStyle:he,colorScheme:f,size:[W,q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe.margin,showAxes:r.showAxes,xLabel:Z,yLabel:J,xFormat:s,yFormat:l,enableHover:G,showGrid:Y,...oe.legendBehaviorProps,...ld({title:X,description:U,summary:K,accessibleTable:Q,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:v,defaultTooltipContent:pe}),...cd({linkedHover:I,selection:P,onObservation:L,onClick:R,hoverHighlight:T,mobileInteraction:oe.mobileInteraction,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior}),...x&&{marginalGraphics:x},...w&&{pointIdAccessor:w},...ge&&ge.length>0&&{annotations:ge},...A&&{xExtent:A},...C&&{yExtent:C},...oe.crosshairProps,...M};return vh(Eu,{componentName:"BubbleChart",width:W,height:q,children:vh(Yl,{ref:o,...ye})})});xh.displayName="BubbleChart";import{useMemo as wh,forwardRef as kh,useRef as Sh}from"react";import{scaleSequential as Ah}from"d3-scale";import{jsx as Ch}from"react/jsx-runtime";var Mh=kh(function(e,t){const r=Sh(null);sd(t,{variant:"xy",frameRef:r});const n=Iu(e.mode,{width:e.width,height:e.height,showGrid:void 0,enableHover:e.enableHover,showLegend:void 0,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:i,margin:a,className:s,xAccessor:l="x",yAccessor:c="y",valueAccessor:d="value",xFormat:h,yFormat:p,colorScheme:m,customColorScale:f,showValues:g=!1,valueFormat:y,cellBorderColor:b="#fff",cellBorderWidth:v=1,tooltip:x,annotations:w,xExtent:k,yExtent:S,frameProps:A={},selection:C,linkedHover:M,onObservation:P,onClick:I,hoverHighlight:_,chartId:L,loading:R,loadingContent:T,emptyContent:N,showLegend:$,legendPosition:B,legendInteraction:D}=e,{width:F,height:E,enableHover:z,title:j,description:O,summary:H,accessibleTable:W,xLabel:q,yLabel:G}=n,Y=Hu(R,F,E,T),V=Y?null:Ou(i,F,E,N),X=wh(()=>u(i),[i]),U=function(){const e=cu();return e?.colors?.sequential||void 0}(),K=m??U??"blues",Q=$??!1,Z=B??"right",{margin:J}=Cu({data:X,colorBy:Q?"value":void 0,colorScale:void 0,showLegend:Q,legendPosition:Z,userMargin:a,defaults:n.marginDefaults}),{customHoverBehavior:ee,customClickBehavior:te,crosshairSourceId:oe}=Su({selection:C,linkedHover:M,fallbackFields:[],onObservation:P,onClick:I,chartType:"Heatmap",chartId:L,hoverHighlight:_,colorByField:void 0,mobileInteraction:n.mobileInteraction});td(C);const re=Au(M,oe);Mu(D,void 0,[]);const ne=wh(()=>"function"==typeof d?e=>d(e):e=>e[d],[d]),ie=wh(()=>{const e=X.map(ne);return o(e)},[X,ne]),ae=wh(()=>{if("custom"===K&&f)return f;const e=_e(K);return Ah(e).domain(ie)},[K,f,ie]),se=wh(()=>$l([{label:q||_l(l),accessor:l,role:"x",format:h},{label:G||_l(c),accessor:c,role:"y",format:p},{label:_l(d),accessor:d,role:"value",format:y}]),[l,c,q,G,d,h,p,y]),le=Xu({componentName:"Heatmap",data:i,accessors:{xAccessor:l,yAccessor:c,valueAccessor:d}}),ce=wh(()=>{if(Q)return{gradient:{colorFn:e=>ae(e),domain:ie,label:"string"==typeof d?d:"value",format:y}}},[Q,ae,ie,d,y]),ue={chartType:"heatmap",...null!=i&&{data:X},xAccessor:l,yAccessor:c,valueAccessor:d,colorScheme:"custom"!==K?K:void 0,showValues:g,heatmapValueFormat:y,size:[F,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J,showAxes:n.showAxes,xLabel:q,yLabel:G,xFormat:h,yFormat:p,enableHover:z,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...ce&&{legend:ce,legendPosition:Z},...ld({title:j,description:O,summary:H,accessibleTable:W,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:x,defaultTooltipContent:se}),...cd({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:_,mobileInteraction:n.mobileInteraction,customHoverBehavior:ee,customClickBehavior:te}),...w&&w.length>0&&{annotations:w},...k&&{xExtent:k},...S&&{yExtent:S},...re,...A};return Y||V||(le?Ch(Tu,{componentName:"Heatmap",message:le,width:F,height:E}):Ch(Eu,{componentName:"Heatmap",width:F,height:E,children:Ch(Yl,{ref:r,...ue})}))});Mh.displayName="Heatmap";import*as Ph from"react";import{useMemo as Ih,useCallback as _h,useState as Lh,useRef as Rh,useEffect as Th}from"react";import{brush as Nh}from"d3-brush";import{select as $h}from"d3-selection";import{jsx as Bh,jsxs as Dh}from"react/jsx-runtime";var Fh="__splomIdx",Eh={top:4,bottom:4,left:4,right:4};function zh({frameRef:e,cellSize:t,onBrush:o}){const r=Rh(null),n=t-Eh.left-Eh.right,i=t-Eh.top-Eh.bottom;return Th(()=>{if(!r.current)return;const t=$h(r.current).select(".brush-g"),a=Nh().extent([[0,0],[n,i]]).on("brush end",t=>{const r=e.current?.getScales();if(!r)return;if(!t.selection)return void o(null);const[[n,i],[a,s]]=t.selection,l=[[r.x.invert(n),r.y.invert(i)],[r.x.invert(a),r.y.invert(s)]];o(l)});return t.call(a),t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{a.on("brush end",null)}},[n,i,e,o]),Bh("svg",{ref:r,width:t,height:t,style:{position:"absolute",top:0,left:0},children:Bh("g",{className:"brush-g",transform:`translate(${Eh.left},${Eh.top})`})})}function jh({data:e,xField:t,yField:o,cellSize:r,pointRadius:n,pointOpacity:i,colorBy:a,colorScale:s,brushSelectionName:l,hoverSelectionName:c,unselectedOpacity:u,mobileInteraction:d,mode:h,onPointHover:p,onPointClick:m}){const f=Rh(null),g=Mc({name:l,clientId:`splom-${t}-${o}`,fields:[t,o]}),y=Lc({name:l,xField:t,yField:o}),b=Mc({name:c,clientId:"splom-hover-source",fields:[Fh]}),v=b.selectPoints,x=_h(e=>{e?y.brushInteraction.during(e):y.brushInteraction.end(null)},[y.brushInteraction]),w=_h(e=>{if(!e)return void p?.(null);const t=e.data,o=t?.[Fh];void 0!==o&&(v({[Fh]:[o]}),p?.(t,e.x+Eh.left,e.y+Eh.top))},[v,p]),k=_h(e=>{if(!e)return void m?.(null);const t=e.data;t&&m?.(t,e.x+Eh.left,e.y+Eh.top)},[m]),S=_h(e=>{const t={opacity:i,r:n};return t.fill=a?He(e,a,s):pu,"hover"===h?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*n,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*i):g.isActive&&!g.predicate(e)&&(t.opacity=u),t},[a,s,i,n,h,g.isActive,g.predicate,b.isActive,b.predicate,u]);return Dh("div",{style:{position:"relative",width:r,height:r},children:[Bh(Yl,{ref:f,chartType:"scatter",data:e,size:[r,r],xAccessor:t,yAccessor:o,pointStyle:S,margin:Eh,showAxes:!1,enableHover:"hover"===h,...cd({forceHoverBehavior:"hover"===h,forceClickBehavior:!!m,mobileInteraction:d,customHoverBehavior:w,customClickBehavior:k}),tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&Bh(zh,{frameRef:f,cellSize:r,xField:t,yField:o,onBrush:x})]})}function Oh({data:t,field:r,label:n,cellSize:i,bins:a,colorBy:s,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=Mc({name:c,clientId:"splom-diag-"+r,fields:[r]}),p=Mc({name:u,clientId:`splom-diag-${r}-hover`,fields:[Fh]}),m="hover"===d?p:h,f=m.isActive,g=m.predicate,y=Ih(()=>{const n="string"==typeof s?s:null,l=[],c=new Set;for(const e of t){const t=e[r];if(null==t||isNaN(t)||l.push(Number(t)),n){const t=e[n];null!=t&&c.add(t+"")}}if(0===l.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const[u,d]=o(l),h=(d-u)/a||1,p=Array.from(c),m=new Map(p.map((e,t)=>[e,t])),y=Array(a).fill(0),b=Array(a).fill(0),v=Array.from({length:a},()=>Array(p.length).fill(0)),x=Array.from({length:a},()=>Array(p.length).fill(0));for(const e of t){const t=e[r];if(null==t||isNaN(t))continue;const o=Math.min(Math.floor((t-u)/h),a-1);if(y[o]++,f&&!g(e)||b[o]++,n){const t=m.get(e[n]+"");void 0!==t&&(v[o][t]++,f&&!g(e)||x[o][t]++)}}const w=e(y,1),k=v.map((e,t)=>{let o=0;return e.map((e,r)=>{const n=e/w*(i-24),s={x:t/a*i,w:i/a-1,h:n,y0:o,category:p[r]};return o+=n,s})}),S=x.map((e,t)=>{let o=0;return e.map((e,r)=>{const n=e/w*(i-24),s={x:t/a*i,w:i/a-1,h:n,y0:o,category:p[r]};return o+=n,s})});return{bars:y.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/w*(i-24),count:e})),selectedBars:b.map((e,t)=>({x:t/a*i,w:i/a-1,h:e/w*(i-24),count:e})),categoryBars:k,selectedCategoryBars:S,max:w,categories:p}},[t,r,a,i,f,g,s]);return Dh("svg",{width:i,height:i,style:{overflow:"hidden"},children:[Bh("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:n}),y.categories.length>0?y.categoryBars.map((e,t)=>e.map((e,o)=>Bh("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:l?l(e.category):pu,opacity:f?.3:.6},`bg-${t}-${o}`))):y.bars.map((e,t)=>Bh("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:pu,opacity:f?.3:.6},"bg-"+t)),f&&(y.categories.length>0?y.selectedCategoryBars.map((e,t)=>e.map((e,o)=>Bh("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:l?l(e.category):pu,opacity:.7},`sel-${t}-${o}`))):y.selectedBars.map((e,t)=>Bh("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:pu,opacity:.7},"sel-"+t)))]})}function Hh({label:e,cellSize:t}){return Bh("svg",{width:t,height:t,children:Bh("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:e})})}function Wh(e){const{data:t,fields:o,fieldLabels:r={},colorBy:n,colorScheme:i,cellSize:a=150,cellGap:s=4,pointRadius:l=2,pointOpacity:c=.5,diagonal:u="histogram",histogramBins:d=20,brushMode:h="crossfilter",hoverMode:p=!0,unselectedOpacity:m=.1,showGrid:f=!1,tooltip:g,showLegend:y,idAccessor:b,width:v,className:x,onObservation:w,onClick:k,chartId:S}=e,A="splom",C="splom-hover",M=bu(e.mobileInteraction,{mode:e.mode,width:v??o.length*a,mobileSemantics:e.mobileSemantics}),P=p?"hover":h?"brush":"hover",I=xc(e=>e.clearSelection),[_,L]=Lh(null),R=_h(()=>{I(C),L(null)},[I,C]),T=Ih(()=>(t||[]).map((e,t)=>void 0!==e[Fh]?e:{...e,[Fh]:t}),[t]),N=wu(T,n,i),$=_h((e,t,o,r)=>[40+e*(a+s)+(o??0),t*(a+s)+(r??0)],[40,a,s]),B=void 0!==y?y:!!n,D=Ih(()=>{if(!B||!n)return null;const e="string"==typeof n?n:null;return e?Array.from(new Set(T.map(t=>t[e]).filter(e=>null!=e))).map(e=>({label:e+"",color:N?N(e+""):pu})):null},[B,n,T,N]),F=Ih(()=>({display:"grid",gridTemplateColumns:"40px "+o.map(()=>a+"px").join(" "),gridTemplateRows:o.map(()=>a+"px").join(" ")+" 40px",gap:s+"px",width:"fit-content"}),[o,a,s,40]);return Dh("div",{className:x,style:{position:"relative"},children:[D&&Bh("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:D.map(e=>Dh("div",{style:{display:"flex",alignItems:"center",gap:4},children:[Bh("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),Bh("span",{style:{fontSize:11},children:e.label})]},e.label))}),Dh("div",{style:F,onMouseLeave:"hover"===P?R:void 0,children:[o.map((e,t)=>Dh(Ph.Fragment,{children:[Bh("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"},children:r[e]||e}),o.map((o,i)=>t===i?"label"===u?Bh(Hh,{label:r[e]||e,cellSize:a},"diag-"+e):Bh(Oh,{data:T,field:e,label:r[e]||e,cellSize:a,bins:d,colorBy:n,colorScale:N,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,mode:P},"diag-"+e):Bh(jh,{data:T,xField:o,yField:e,fieldLabels:r,cellSize:a,pointRadius:l,pointOpacity:c,colorBy:n,colorScale:N,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,showGrid:f,tooltip:g,mobileInteraction:M,mode:P,onPointHover:"hover"===P?(r,n,a)=>{if(r){if(L({datum:r,xField:o,yField:e,colIndex:i,rowIndex:t,px:n??0,py:a??0}),w){const[e,o]=$(i,t,n,a);w({type:"hover",datum:r,x:e,y:o,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}}else L(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0,onPointClick:k||w?(e,o,r)=>{if(!e)return;const[n,a]=$(i,t,o,r);k&&k(e,{x:n,y:a}),w&&w({type:"click",datum:e,x:n,y:a,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0},`cell-${e}-${o}`))]},"row-"+e)),Bh("div",{})," ",o.map(e=>Bh("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:r[e]||e},"col-label-"+e))]}),_&&"hover"===P&&(()=>{const e=_.datum,t=r[_.xField]||_.xField,o=r[_.yField]||_.yField,i=n?"function"==typeof n?n(e):e[n]:null,l=b?"function"==typeof b?b(e):e[b]:"Row "+e[Fh];return Dh("div",{style:{position:"absolute",left:40+_.colIndex*(a+s)+_.px,top:_.rowIndex*(a+s)+_.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10},children:[Bh("div",{style:{fontWeight:"bold",marginBottom:2},children:l+""}),Dh("div",{children:[t,": ",null!=e[_.xField]?Number(e[_.xField]).toFixed(1):"–"]}),Dh("div",{children:[o,": ",null!=e[_.yField]?Number(e[_.yField]).toFixed(1):"–"]}),null!=i&&Dh("div",{style:{opacity:.8},children:["string"==typeof n?n:"group",": ",i+""]})]})})()]})}function qh(e){const{brushMode:t="crossfilter",hoverMode:o=!0}=e,r={};return!o&&t&&(r.splom={resolution:t}),o&&(r["splom-hover"]={resolution:"union"}),Bh(Xc,{selections:r,children:Bh(Wh,{...e})})}qh.displayName="ScatterplotMatrix";import{useState as Gh,useRef as Yh,useEffect as Vh,useMemo as Xh,useCallback as Uh}from"react";import{brushX as Kh,brushY as Qh}from"d3-brush";import{select as Zh}from"d3-selection";import{jsx as Jh,jsxs as ep}from"react/jsx-runtime";function tp({width:e,height:t,margin:o,scales:r,brushDirection:n,extent:i,onBrush:a}){const s=Yh(null),l=Yh(null),c=Yh(!1),u=e+o.left+o.right,d=t+o.top+o.bottom;return Vh(()=>{if(!s.current||!r)return;const o=Zh(s.current).select(".brush-group"),i="x"===n?Kh().extent([[0,0],[e,t]]):Qh().extent([[0,0],[e,t]]);return i.on("brush end",e=>{if(c.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void a(null);const o=("x"===n?r.x:r.y).invert;if(!o)return;const i=[o(t[0]),o(t[1])];a(i)}),o.call(i),l.current=i,o.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null)}},[r,e,t,n,a]),Vh(()=>{if(!l.current||!r||!s.current)return;const e=Zh(s.current).select(".brush-group"),t="x"===n?r.x:r.y;if(c.current=!0,i){const o=[t(i[0]),t(i[1])];e.call(l.current.move,o)}else e.call(l.current.move,null);c.current=!1},[i,r,n]),Jh("svg",{ref:s,width:u,height:d,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:Jh("g",{className:"brush-group",transform:`translate(${o.left},${o.top})`})})}function op(e){const{data:t,width:o=600,height:r=400,margin:n,className:i,title:a,description:s,summary:l,xLabel:c,yLabel:d,xFormat:h,yFormat:p,xAccessor:m="x",yAccessor:f="y",lineBy:g,lineDataAccessor:y="coordinates",colorBy:b,colorScheme:v,curve:x="linear",lineWidth:w=2,fillArea:k=!1,areaOpacity:S=.3,showPoints:A=!1,pointRadius:C=3,enableHover:M=!0,showGrid:P=!1,showLegend:I,legendPosition:_,tooltip:L,minimap:R={},renderBefore:T=!1,onBrush:N,brushExtent:$,yExtent:B,frameProps:D={},loading:F,loadingContent:E,emptyContent:z}=e,j=Hu(F,o,r,E),O=j?null:Ou(t,o,r,z),H=Xh(()=>u(t),[t]),[W,q]=Gh(null),G=$??W,Y=Uh(e=>{$||q(e),N?.(e)},[$,N]),V=Yh(null),[X,U]=Gh(null);Vh(()=>{let e=0,t=!1;const o=()=>{if(t)return;const r=V.current?.getScales?.();r?U(r):e=requestAnimationFrame(o)};return e=requestAnimationFrame(o),()=>{t=!0,e&&cancelAnimationFrame(e)}},[t]);const K=void 0!==H[0]?.[y],Q=Xh(()=>{if(K)return H;if(g){const e=H.reduce((e,t)=>{const o="function"==typeof g?g(t):t[g];if(!e[o]){const t={[y]:[]};"string"==typeof g&&(t[g]=o),e[o]=t}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:H}]},[H,g,y,K]),Z=Xh(()=>K||g?Q.flatMap(e=>{const t=e[y]||[];return g&&"string"==typeof g?t.map(t=>({...t,[g]:e[g]})):t}):H,[Q,y,K,g,H]),J=wu(H,b,v),ee=id({lineWidth:w,colorBy:b,colorScale:J,fillArea:k,areaOpacity:S}),te=Xh(()=>{if(R.lineStyle)return R.lineStyle},[R.lineStyle]),oe=id({lineWidth:1,colorBy:b,colorScale:J}),re=te??oe,ne=Xh(()=>{if(A)return e=>{const t={r:C,fillOpacity:1};return t.fill=b?He(e.parentLine||e,b,J):pu,t}},[A,C,b,J]),{legend:ie,margin:ae,legendPosition:se}=Cu({data:Q,colorBy:b,colorScale:J,showLegend:I,legendPosition:_,userMargin:n}),le=R.height||60,ce=Xh(()=>({top:R.margin?.top??0,bottom:R.margin?.bottom??20,left:R.margin?.left??ae.left,right:R.margin?.right??ae.right}),[R.margin,ae]),ue=R.brushDirection||"x",de=Xh(()=>$l([{label:c||_l(m),accessor:m,role:"x",format:h},{label:d||_l(f),accessor:f,role:"y",format:p}]),[m,f,c,d,h,p]),he=Xu({componentName:"MinimapChart",data:t,accessors:{xAccessor:m,yAccessor:f}});if(he)return Jh(Tu,{componentName:"MinimapChart",message:he,width:o,height:r});const pe=k?"area":"line",me={chartType:pe,data:Z,xAccessor:m,yAccessor:f,groupAccessor:g||void 0,curve:x,lineStyle:ee,...A&&{pointStyle:ne},size:[o,r],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ae,showAxes:!0,xLabel:c,yLabel:d,xFormat:h,yFormat:p,enableHover:M,showGrid:P,...ie&&{legend:ie,legendPosition:se},...a&&{title:a},...s&&{description:s},...l&&{summary:l},tooltipContent:!1===L?()=>null:xs(L)||de,...G&&{xExtent:G},...B&&{yExtent:B},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...D},fe={chartType:pe,data:Z,xAccessor:m,yAccessor:f,groupAccessor:g||void 0,curve:x,lineStyle:re,size:[o,le+ce.top+ce.bottom],margin:ce,showAxes:R.showAxes??!1,background:R.background,enableHover:!1,...B&&{yExtent:B}},ge=ep("div",{style:{position:"relative",width:o,overflow:"hidden"},children:[Jh(Yl,{ref:V,...fe}),Jh(tp,{width:o-ce.left-ce.right,height:le,margin:ce,scales:X,brushDirection:ue,extent:G,onBrush:Y})]},"minimap"),ye=Jh("div",{style:{overflow:"hidden"},children:Jh(Yl,{...me})},"main");return j||O||Jh(Eu,{componentName:"MinimapChart",width:o,height:r,children:ep("div",{className:"minimap-chart"+(i?" "+i:""),children:[T?ge:ye,T?ye:ge]})})}op.displayName="MinimapChart";import{useMemo as rp,forwardRef as np,useRef as ip}from"react";var ap={topLeft:{label:"Low / High",color:"#E9C46A",opacity:.08},topRight:{label:"High / High",color:"#2A9D8F",opacity:.08},bottomLeft:{label:"Low / Low",color:"#E76F51",opacity:.08},bottomRight:{label:"High / Low",color:"#86BBD8",opacity:.08}};import{Fragment as sp,jsx as lp,jsxs as cp}from"react/jsx-runtime";function up(e,t){return{label:t?.label??e.label,color:t?.color??e.color,opacity:t?.opacity??e.opacity}}var dp=np(function(e,t){const r=ip(null);sd(t,{variant:"xy",frameRef:r});const n=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:i,margin:a,className:s,xFormat:l,yFormat:c,xAccessor:d="x",yAccessor:h="y",xCenter:p,yCenter:m,quadrants:f,centerlineStyle:g={},showQuadrantLabels:y=!0,quadrantLabelSize:b=12,colorBy:v,colorScheme:x,sizeBy:w,sizeRange:k=[3,15],pointRadius:S=5,pointOpacity:A=.8,tooltip:C,pointIdAccessor:M,annotations:P,frameProps:I={},selection:_,linkedHover:L,onObservation:R,onClick:T,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:F,legendInteraction:E,legendPosition:z,color:j,stroke:O,strokeWidth:H,opacity:W}=e,{width:q,height:G,enableHover:Y,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=n,te=rp(()=>({topLeft:up(ap.topLeft,f?.topLeft),topRight:up(ap.topRight,f?.topRight),bottomLeft:up(ap.bottomLeft,f?.bottomLeft),bottomRight:up(ap.bottomRight,f?.bottomRight)}),[f]),oe=rp(()=>u(i),[i]),re=od({data:oe,rawData:i,colorBy:v,colorScheme:x,legendInteraction:E,legendPosition:z,selection:_,linkedHover:L,fallbackFields:"string"==typeof v?[v]:[],unwrapData:!1,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"QuadrantChart",chartId:$,showLegend:X,userMargin:a,marginDefaults:n.marginDefaults,loading:B,loadingContent:D,emptyContent:F,width:q,height:G});Wu("QuadrantChart",oe,"xAccessor",d),Wu("QuadrantChart",oe,"yAccessor",h);const ne=rp(()=>{if(!oe.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let o=1/0,r=-1/0,n=1/0,i=-1/0;for(const a of oe){const s=e(a),l=t(a);isFinite(s)&&(o>s&&(o=s),s>r&&(r=s)),isFinite(l)&&(n>l&&(n=l),l>i&&(i=l))}if(null!=p&&isFinite(p)&&(o>p&&(o=p),p>r&&(r=p)),null!=m&&isFinite(m)&&(n>m&&(n=m),m>i&&(i=m)),o===1/0)return;const a=.1*(r-o)||1,s=.1*(i-n)||1;return{xExtent:[o-a,r+a],yExtent:[n-s,i+s]}},[oe,d,h,p,m]),ie=rp(()=>{if(!w||0===oe.length)return;const e=oe.map(e=>"function"==typeof w?w(e):e[w]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?o(e):void 0},[oe,w]),ae=rp(()=>"function"==typeof d?d:e=>+e[d],[d]),se=rp(()=>"function"==typeof h?h:e=>+e[h],[h]),le=rp(()=>e=>{const t=ae(e),o=se(e),r=null!=p?t>=p:void 0,n=null!=m?o>=m:void 0;return void 0===n||void 0===r?j||pu:n&&r?te.topRight.color:n&&!r?te.topLeft.color:!n&&r?te.bottomRight.color:te.bottomLeft.color},[ae,se,p,m,te,j]),ce=rp(()=>w?e=>Ge(e,w,k,ie):void 0,[w,k,ie]),ue=Jd({colorBy:v,colorScale:re.colorScale,color:j,pointRadius:S,fillOpacity:A,radiusFn:ce,fallbackFill:le,stroke:O,strokeWidth:H,opacity:W,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection}),de=rp(()=>{if(!oe.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof v&&e.add(v),"string"==typeof w&&e.add(w);const t=oe[0];for(const o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[oe,d,h,v,w]),he=rp(()=>$l([...de?[{label:de,accessor:de,role:"title"}]:[],{label:J||_l(d),accessor:d,role:"x",format:l},{label:ee||_l(h),accessor:h,role:"y",format:c},...v?[{label:_l(v),accessor:v,role:"color"}]:[],...w?[{label:_l(w),accessor:w,role:"size"}]:[]]),[de,d,h,J,ee,v,w,l,c]),pe=Xu({componentName:"QuadrantChart",data:i,accessors:{xAccessor:d,yAccessor:h}}),me=rp(()=>{const e={stroke:g.stroke||"#999",strokeWidth:g.strokeWidth??1,dashArray:g.strokeDasharray||[]};return[(t,o,r,n)=>{if(!r?.x||!r?.y)return;const i=n.width,a=n.height,s=null!=p?r.x(p):i/2,l=null!=m?r.y(m):a/2;if(null!=p&&!isFinite(s))return;if(null!=m&&!isFinite(l))return;const c=Math.max(0,Math.min(i,s)),u=Math.max(0,Math.min(a,l)),d=[{config:te.topLeft,x:0,y:0,w:c,h:u},{config:te.topRight,x:c,y:0,w:i-c,h:u},{config:te.bottomLeft,x:0,y:u,w:c,h:a-u},{config:te.bottomRight,x:c,y:u,w:i-c,h:a-u}];for(const e of d)e.w>0&&e.h>0&&(t.fillStyle=e.config.color,t.globalAlpha=e.config.opacity??.08,t.fillRect(e.x,e.y,e.w,e.h));t.globalAlpha=1,t.strokeStyle=e.stroke,t.lineWidth=e.strokeWidth,e.dashArray.length>0&&t.setLineDash(e.dashArray),t.beginPath(),t.moveTo(c,0),t.lineTo(c,a),t.stroke(),t.beginPath(),t.moveTo(0,u),t.lineTo(i,u),t.stroke(),t.setLineDash([])}]},[p,m,te,g]),fe=rp(()=>y?[...me,(e,t,o,r)=>{if(!o?.x||!o?.y)return;const n=r.width,i=r.height,a=null!=p?o.x(p):n/2,s=null!=m?o.y(m):i/2;(null==p||isFinite(a))&&(null==m||isFinite(s))&&(e.font=`600 ${b}px sans-serif`,e.globalAlpha=.5,e.fillStyle=te.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(te.topLeft.label,8,8),e.fillStyle=te.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(te.topRight.label,n-8,8),e.fillStyle=te.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(te.bottomLeft.label,8,i-8),e.fillStyle=te.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(te.bottomRight.label,n-8,i-8),e.globalAlpha=1)}]:me,[me,y,b,te,p,m]),ge=rp(()=>{const e=I.canvasPreRenderers||[];return[...fe,...e]},[fe,I.canvasPreRenderers]),ye=rp(()=>{const e={stroke:g.stroke||"#999",strokeWidth:g.strokeWidth??1,dashArray:g.strokeDasharray?Array.isArray(g.strokeDasharray)?g.strokeDasharray.join(","):g.strokeDasharray:void 0};return[(t,o,r)=>{if(!o?.x||!o?.y)return null;const n=r.width,i=r.height,a=null!=p?o.x(p):n/2,s=null!=m?o.y(m):i/2;if(null!=p&&!isFinite(a))return null;if(null!=m&&!isFinite(s))return null;const l=Math.max(0,Math.min(n,a)),c=Math.max(0,Math.min(i,s));return cp(sp,{children:[[{config:te.topLeft,x:0,y:0,w:l,h:c},{config:te.topRight,x:l,y:0,w:n-l,h:c},{config:te.bottomLeft,x:0,y:c,w:l,h:i-c},{config:te.bottomRight,x:l,y:c,w:n-l,h:i-c}].map((e,t)=>e.w>0&&e.h>0?lp("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:e.config.color,opacity:e.config.opacity??.08},"qf-"+t):null),lp("line",{x1:l,y1:0,x2:l,y2:i,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),lp("line",{x1:0,y1:c,x2:n,y2:c,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),y&&cp(sp,{children:[lp("text",{x:8,y:8+b,fill:te.topLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:te.topLeft.label}),lp("text",{x:n-8,y:8+b,fill:te.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:te.topRight.label}),lp("text",{x:8,y:i-8,fill:te.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:te.bottomLeft.label}),lp("text",{x:n-8,y:i-8,fill:te.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:te.bottomRight.label})]})]})}]},[p,m,te,g,y,b]);if(re.earlyReturn)return re.earlyReturn;const be={chartType:"scatter",...null!=i&&{data:oe},xAccessor:d,yAccessor:h,colorAccessor:v||void 0,sizeAccessor:w||void 0,sizeRange:k,pointStyle:ue,colorScheme:x,size:[q,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:re.margin,showAxes:n.showAxes,xLabel:J,yLabel:ee,xFormat:l,yFormat:c,enableHover:Y,showGrid:V,...ne&&{xExtent:ne.xExtent,yExtent:ne.yExtent},...re.legendBehaviorProps,...U&&{title:U},...K&&{description:K},...Q&&{summary:Q},...void 0!==Z&&{accessibleTable:Z},...s&&{className:s},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:!1===C?()=>null:!0===C||void 0===C?he:xs(C)||he,...cd({linkedHover:L,selection:_,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...M&&{pointIdAccessor:M},...P&&P.length>0&&{annotations:P},canvasPreRenderers:ge,...re.crosshairProps,...I,...ge.length>0&&{canvasPreRenderers:ge},svgPreRenderers:ye};return pe?lp(Tu,{componentName:"QuadrantChart",message:pe,width:q,height:G}):lp(Eu,{componentName:"QuadrantChart",width:q,height:G,children:lp(Yl,{ref:r,...be})})});dp.displayName="QuadrantChart";import*as hp from"react";import{useMemo as pp,useCallback as mp,forwardRef as fp,useRef as gp,useImperativeHandle as yp}from"react";import{jsx as bp}from"react/jsx-runtime";var vp="__ma_unitized",xp="__ma_series";function wp(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function kp(e,t){return t[0]+e*(t[1]-t[0])}var Sp=fp(function(e,t){const o=gp(null),r=gp([]),n=gp(e.series);n.current=e.series,yp(t,()=>{const e=()=>(n.current??[]).filter(e=>null!=e&&"object"==typeof e);return{push:t=>{if(!o.current)return;const n=e(),i=t;for(let e=0;n.length>e&&2>e;e++){const t=n[e],a=t.extent||r.current[e];if(!a)continue;const s=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(i);null!=s&&isFinite(s)&&o.current.push({...i,[vp]:wp(s,a),[xp]:t.label||"Series "+(e+1)})}},pushMany:t=>{if(!o.current)return;const n=e(),i=[];for(const e of t)for(let t=0;n.length>t&&2>t;t++){const o=n[t],a=o.extent||r.current[t];if(!a)continue;const s=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=s&&isFinite(s)&&i.push({...e,[vp]:wp(s,a),[xp]:o.label||"Series "+(t+1)})}o.current.pushMany(i)},remove:e=>o.current?.remove(e)??[],update:(e,t)=>o.current?.update(e,t)??[],clear:()=>o.current?.clear(),getData:()=>o.current?.getData()??[],getScales:()=>o.current?.getScales()??null}},[]);const i=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:400}),{data:a,margin:s,className:l,xFormat:c,xAccessor:d="x",series:h,colorScheme:p,curve:m="monotoneX",lineWidth:f=2,tooltip:g,annotations:y,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:_,stroke:L,strokeWidth:R,opacity:T}=e,{width:N,height:$,enableHover:B,showGrid:D,showLegend:F=!0,title:E,description:z,summary:j,accessibleTable:O,xLabel:H}=i,W=pp(()=>u(a),[a]),q=pp(()=>u(h),[h]),G=q,Y=2===q.length;"undefined"==typeof process||"production"===process.env?.NODE_ENV||Y||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${q.length}. Rendering as a standard multi-line chart.`);const V=Hu(C,N,$,M),X=V?null:Ou(a,N,$,P),U=vu(),K=pp(()=>{let e;if(Array.isArray(p))e=p;else if(U&&U.length>0)e=U;else{const t=Fe[p];e=Array.isArray(t)?t:Ee}return G.map((t,o)=>t.color||e[o%e.length])},[G,p,U]),Q=pp(()=>q.map((e,t)=>e.label||"Series "+(t+1)),[q]),{unitizedData:Z,extents:J}=pp(()=>{if(0===W.length){const e=q.map(e=>e.extent||null).filter(Boolean);return e.length===q.length&&(r.current=e),{unitizedData:[],extents:e.length===q.length?e:[]}}const e=q.map(e=>e.extent||function(e,t){let o=1/0,r=-1/0;const n="function"==typeof t?t:e=>e[t];for(const t of e){const e=n(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>r&&(r=e))}if(!isFinite(o)||!isFinite(r))return[0,1];if(o===r){const e=0===o?1:.1*Math.abs(o);return[o-e,r+e]}return[o,r]}(W,e.yAccessor));if(r.current=e,!Y){const t=[];for(const e of W)for(let o=0;q.length>o;o++){const r=q[o],n=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(e);null!=n&&t.push({...e,[vp]:n,[xp]:Q[o]})}return{unitizedData:t,extents:e}}const t=[];for(const o of W)for(let r=0;2>r;r++){const n=q[r],i=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(o);null!=i&&t.push({...o,[vp]:wp(i,e[r]),[xp]:Q[r]})}return{unitizedData:t,extents:e}},[W,q,Y,Q]),ee=pp(()=>{if(Y&&J.length>=2)return[{orient:"left",label:Q[0],tickFormat:q[0].format||(e=>{const t=kp(e,J[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:Q[1],tickFormat:q[1].format||(e=>{const t=kp(e,J[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[Y,J,q,Q]),te=od({data:pp(()=>Z.length>0?Z:Q.map(e=>({[xp]:e})),[Z,Q]),rawData:a,colorBy:xp,colorScheme:K,legendInteraction:I,legendPosition:_,selection:v,linkedHover:x,fallbackFields:[xp],unwrapData:!1,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"MultiAxisLineChart",chartId:A,showLegend:F,userMargin:s,marginDefaults:Y?{...i.marginDefaults,left:70,right:70}:i.marginDefaults,loading:C,loadingContent:M,emptyContent:P,width:N,height:$}),oe=pp(()=>{const e=new Map;return Q.forEach((t,o)=>e.set(t,K[o])),e},[Q,K]),re=id({lineWidth:f,resolveStroke:mp(e=>oe.get(e[xp])||K[0],[oe,K]),stroke:L,strokeWidth:R,opacity:T,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),ne=pp(()=>{if(!1===g)return()=>null;return xs(g)||(e=>{const t=e.data||e,o=t[xp],r=Q.indexOf(o),n=t[vp],i=Y&&r>=0&&J[r]?kp(n,J[r]):n,a=r>=0&&q[r]?.format?q[r].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),s="function"==typeof d?d(t):t[d];return hp.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},hp.createElement("div",{style:{fontWeight:600,marginBottom:4,color:K[r]||"inherit"}},o),hp.createElement("div",null,`${"string"==typeof d?d:"x"}: ${s}`),hp.createElement("div",null,`${o}: ${a(i)}`))})},[g,Q,K,J,Y,q,d]);if(te.earlyReturn)return te.earlyReturn;const ie=Xu({componentName:"MultiAxisLineChart",data:a,accessors:{xAccessor:d}}),ae=Y?[0,1]:void 0,se={chartType:"line",...null!=a&&{data:Z},xAccessor:d,yAccessor:vp,groupAccessor:xp,lineStyle:re,colorScheme:K,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,showAxes:i.showAxes,...ee&&{axes:ee},xLabel:H,...Y?{}:{yLabel:Q[0]},xFormat:c,...Y&&ae&&{yExtent:ae},enableHover:B,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:D,curve:m,...te.legendBehaviorProps,...E&&{title:E},...z&&{description:z},...j&&{summary:j},...void 0!==O&&{accessibleTable:O},...l&&{className:l},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:ne,...y&&{annotations:y},...cd({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:te.mobileInteraction,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior}),...te.crosshairProps,...b};return V||X||(ie?bp(Tu,{componentName:"MultiAxisLineChart",message:ie,width:N,height:$}):bp(Eu,{componentName:"MultiAxisLineChart",width:N,height:$,children:bp(Yl,{ref:o,...se})}))});Sp.displayName="MultiAxisLineChart";import{useMemo as Ap,forwardRef as Cp,useRef as Mp}from"react";function Pp(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import{jsx as Ip}from"react/jsx-runtime";var _p=Cp(function(e,t){const o=Mp(null);sd(t,{variant:"xy",frameRef:o});const r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:n,margin:i,className:a,xFormat:s,yFormat:l,xAccessor:c="x",highAccessor:d="high",lowAccessor:h="low",openAccessor:p,closeAccessor:m,candlestickStyle:f,tooltip:g,annotations:y,xExtent:b,yExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,chartId:C,loading:M,loadingContent:P,emptyContent:I}=e,{width:_,height:L,enableHover:R,showGrid:T,title:N,description:$,summary:B,accessibleTable:D,xLabel:F,yLabel:E}=r,z=Hu(M,_,L,P),j=z?null:Ou(n,_,L,I),O=Ap(()=>u(n),[n]),H=null==p||null==m;Wu("CandlestickChart",O,"xAccessor",c),Wu("CandlestickChart",O,"highAccessor",d),Wu("CandlestickChart",O,"lowAccessor",h),H||(Wu("CandlestickChart",O,"openAccessor",p),Wu("CandlestickChart",O,"closeAccessor",m));const{customHoverBehavior:W,customClickBehavior:q,crosshairSourceId:G}=Su({selection:w,linkedHover:k,onObservation:S,onClick:A,chartType:"CandlestickChart",chartId:C,mobileInteraction:r.mobileInteraction}),Y=Au(k,G),V=Ap(()=>{const t=r.marginDefaults,o="sparkline"===e.mode?{...t,top:0,bottom:0}:t;return null==i?o:{...o,...Pp(i)}},[i,r.marginDefaults,e.mode]),X=Ap(()=>{const e=[{label:F||_l(c),accessor:c,role:"x",format:s}];return H?(e.push({label:"High",accessor:d,role:"y",format:l}),e.push({label:"Low",accessor:h,format:l})):(e.push({label:"Open",accessor:p,format:l}),e.push({label:"High",accessor:d,format:l}),e.push({label:"Low",accessor:h,format:l}),e.push({label:"Close",accessor:m,format:l})),$l(e)},[c,F,s,l,d,h,p,m,H]),U=Xu({componentName:"CandlestickChart",data:n,accessors:{xAccessor:c,highAccessor:d,lowAccessor:h,...!H&&{openAccessor:p,closeAccessor:m}}}),K={chartType:"candlestick",...null!=n&&{data:O},xAccessor:c,yAccessor:d,highAccessor:d,lowAccessor:h,...!H&&{openAccessor:p,closeAccessor:m},...f&&{candlestickStyle:f},scalePadding:Math.max(2,Math.min(12,Math.round(_/40))),extentPadding:_>200?.1:.02,size:[_,L],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:V,showAxes:r.showAxes,xLabel:F,yLabel:E,xFormat:s,yFormat:l,enableHover:R,showGrid:T,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...ld({title:N,description:$,summary:B,accessibleTable:D,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:g,defaultTooltipContent:X}),...cd({linkedHover:k,selection:w,onObservation:S,onClick:A,mobileInteraction:r.mobileInteraction,customHoverBehavior:W,customClickBehavior:q}),...y&&y.length>0&&{annotations:y},...b&&{xExtent:b},...v&&{yExtent:v},...Y,...x};return z||j||(U?Ip(Tu,{componentName:"CandlestickChart",message:U,width:_,height:L}):Ip(Eu,{componentName:"CandlestickChart",width:_,height:L,children:Ip(Yl,{ref:o,...K})}))});_p.displayName="CandlestickChart";import{useMemo as Lp,forwardRef as Rp,useRef as Tp}from"react";import{useRef as Np,useState as $p,useEffect as Bp,useMemo as Dp,useCallback as Fp,useImperativeHandle as Ep,forwardRef as zp,memo as jp}from"react";import{scaleBand as Op,scaleLinear as Hp}from"d3-scale";function Wp(e){const t=e.getSymbol;if(!t)return null;const o=e.config.symbolMap,r=new Map;let n=0;return e=>{const i=t(e)+"",a=o?.[i];if(a)return a;let s=r.get(i);return s||(s=_t[n%_t.length],n++,r.set(i,s)),s}}function qp(e,t,o,r,n,i,a){e.push(t?{type:"symbol",x:r,y:n,size:Math.PI*i*i,symbolType:t(o),style:a,datum:o}:{type:"point",x:r,y:n,r:i,style:a,datum:o})}function Gp(e,t){const{columns:o,config:r,resolvePieceStyle:n}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===r.chartType?r.innerRadius||60:0,l=-Math.PI/2+(r.startAngle||0)*Math.PI/180,c=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI,u=null!=r.sweepAngle&&360>r.sweepAngle,d=Object.values(o),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),p=u&&!h&&d.length>1&&(r.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],o=t.pieceData[0],u="number"==typeof o?._pctStart?o._pctStart:t.pctStart,h=l+u*c,m=l+(u+("number"==typeof o?._pct?o._pct:t.pct))*c,f=n(t.pieceData[0],t.name),g=0===e,y=e===d.length-1,b={type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:h,endAngle:m,...r.cornerRadius&&{cornerRadius:r.cornerRadius},style:f,datum:o?._nonInteractive?null:t.pieceData,category:t.name};o?._roundedEnds?b.roundedEnds=o._roundedEnds:p&&(b.roundedEnds={start:g,end:y}),o?._gradientBand&&(b._gradientBand=o._gradientBand),i.push(b)}return i}import{quantile as Yp}from"d3-array";function Vp(e){const t=e.length,o=e[0],r=e[t-1];return{n:t,min:o,q1:Yp(e,.25)??o,median:Yp(e,.5)??(o+r)/2,q3:Yp(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as Xp}from"d3-scale";var Up={bar:function(e,t){const{scales:o,columns:r,config:n,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h="horizontal"===c,p=n.normalize,m=[];if(a){const e=new Set;for(const t of Object.values(r))for(const o of t.pieceData){const t=a(o);e.has(t)||(e.add(t),m.push(t))}}else m.push("_default");for(const e of Object.values(r)){const t=new Map;for(const o of e.pieceData){const e=a?a(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const r=t.get(e);r.total+=i(o),r.pieces.push(o)}let o=0;if(p)for(const e of t.values())o+=Math.abs(e.total);let r=0,n=0;for(const i of m){const c=t.get(i);if(!c)continue;let m=c.total;p&&o>0&&(m/=o);const f=s(c.pieces[0],a?i:e.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(d){const t=l(0>m?n:r+m),o=0>m?l(n+m)-l(n):l(r)-l(r+m);u.push(ct(e.x,t,e.width,Math.abs(o),f,g,i)),0>m?n+=m:r+=m}else if(h){const t=l(0>m?n+m:r),o=0>m?l(n)-l(n+m):l(r+m)-l(r);u.push(ct(t,e.x,Math.abs(o),e.width,f,g,i)),0>m?n+=m:r+=m}}}const f="vertical"===c,g=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=f?0>t?"bottom":"top":0>t?"left":"right",n.gradientFill&&(e.fillGradient=n.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const o=t.datum?.category||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),o=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(f?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),o.length>0&&(o.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:o,columns:r,config:n,getR:i,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h=[],p=new Set;for(const e of Object.values(r))for(const t of e.pieceData){const e=a?a(t):"_default";p.has(e)||(p.add(e),h.push(e))}const m=h.length||1;for(const e of Object.values(r)){const t=e.width/m,o=.2*t,r=t-o,n=new Map;for(const t of e.pieceData){const e=a?a(t):"_default";n.has(e)||n.set(e,[]),n.get(e).push(t)}for(let a=0;h.length>a;a++){const c=n.get(h[a])||[];for(const n of c){const c=i(n),p=s(n,h[a]);if(d){const i=e.x+a*t+o/2,s=l(0),d=l(c);u.push(ct(i,Math.min(s,d),r,Math.abs(s-d),p,n,h[a]))}else{const i=e.x+a*t+o/2,s=l(0),d=l(c);u.push(ct(Math.min(s,d),i,Math.abs(d-s),r,p,n,h[a]))}}}}const f=n.roundedTop&&n.roundedTop>0?Math.max(0,n.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=i(e.datum);f>0&&(e.roundedTop=f),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",n.gradientFill&&(e.fillGradient=n.gradientFill)}return u},point:function(e,t){const{scales:o,columns:r,getR:n,multiScales:i,resolvePieceStyle:a}=e,{r:s,projection:l}=o,c=[],u="vertical"===l,d="radial"===l,h=i.length>0,p=Wp(e),m=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const o=t.__rIndex??0,r=t.__rValue??n(t),l=h&&i[o]||s,g=a(t,e.name),y=g.r||5;let b,v;if(d){const t=f+(e.pctStart+e.pct/2)*m,o=l(r);b=Math.cos(t)*o,v=Math.sin(t)*o}else u?(b=e.middle,v=l(r)):(b=l(r),v=e.middle);qp(c,p,t,b,v,y,g)}return c},swarm:function(e,t){const{scales:o,columns:r,getR:n,resolvePieceStyle:i}=e,{r:a,projection:s}=o,l=[],c="vertical"===s,u=Wp(e);for(const e of Object.values(r)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const r=e.pieceData[o],s=n(r),d=i(r,e.name),h=d.r||4,p=(7919*o%100/100-.5)*t*.8;qp(l,u,r,c?e.middle+p:a(s),c?a(s):e.middle+p,h,d)}}return l},pie:Gp,donut:Gp,boxplot:function(e,t){const{scales:o,columns:r,config:n,getR:i,resolveSummaryStyle:a}=e,{r:s,projection:l}=o,c=[],u="vertical"===l,d=!1!==n.showOutliers;for(const t of Object.values(r)){const o=t.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===o.length)continue;const r=o[0],n=o[o.length-1],l=Yp(o,.25)??r,h=Yp(o,.5)??(r+n)/2,p=Yp(o,.75)??n,m=p-l,f=l-1.5*m,g=p+1.5*m,y=o.find(e=>e>=f)??r,b=[...o].reverse().find(e=>g>=e)??n,v=a(t.pieceData[0],t.name),x=[];if(d)for(const e of t.pieceData){const o=i(e);if(f>o||o>g){const r=u?t.middle:s(o),n=u?s(o):t.middle;x.push({px:r,py:n,value:o,datum:e})}}if(c.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:s(y),q1Pos:s(l),medianPos:s(h),q3Pos:s(p),maxPos:s(b),stats:{n:o.length,min:y,q1:l,median:h,q3:p,max:b,mean:o.reduce((e,t)=>e+t,0)/o.length},style:v,datum:t.pieceData,category:t.name,outliers:x}),d)for(const t of x)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return c},violin:function(t,o){const{scales:r,columns:n,config:i,getR:a,resolveSummaryStyle:s}=t,{r:l,projection:c}=r,u=[],d="vertical"===c,h=i.bins||20,p=!1!==i.showIQR;for(const t of Object.values(n)){const o=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>o.length)continue;const r=o[0],n=o[o.length-1],i=(n-r)/h||1,c=Array(h).fill(0);for(const e of o)c[Math.min(Math.floor((e-r)/i),h-1)]++;const m=e(c,1),f=t.width/2*.9;let g;if(d){g=`M ${t.middle} ${l(r)}`;for(let e=0;h>e;e++){const o=l(r+(e+.5)*i);g+=` L ${t.middle+c[e]/m*f} ${o}`}g+=` L ${t.middle} ${l(n)}`;for(let e=h-1;e>=0;e--){const o=l(r+(e+.5)*i);g+=` L ${t.middle-c[e]/m*f} ${o}`}g+=" Z"}else{g=`M ${l(r)} ${t.middle}`;for(let e=0;h>e;e++)g+=` L ${l(r+(e+.5)*i)} ${t.middle-c[e]/m*f}`;g+=` L ${l(n)} ${t.middle}`;for(let e=h-1;e>=0;e--)g+=` L ${l(r+(e+.5)*i)} ${t.middle+c[e]/m*f}`;g+=" Z"}const y=s(t.pieceData[0],t.name);let b;if(p&&o.length>=4){const e=Yp(o,.25)??r,i=Yp(o,.5)??(r+n)/2,a=Yp(o,.75)??n;b={q1Pos:l(e),medianPos:l(i),q3Pos:l(a),centerPos:t.middle,isVertical:d}}const v=d?{x:t.x,y:Math.min(l(n),l(r)),width:t.width,height:Math.abs(l(n)-l(r))}:{x:Math.min(l(r),l(n)),y:t.x,width:Math.abs(l(n)-l(r)),height:t.width};u.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:v,iqrLine:b,stats:Vp(o),style:y,datum:t.pieceData,category:t.name})}return u},histogram:function(t,r){const{scales:n,columns:i,config:a,getR:s,resolveSummaryStyle:l}=t,{r:c}=n,u=[],d=a.bins||25,h=a.normalize,p=c.domain?.(),m=p?+p[0]:void 0,f=p?+p[1]:void 0;for(const t of Object.values(i)){const r=t.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===r.length)continue;const[n,i]=o(r),a=null!=m&&isFinite(m)?m:n,p=null!=f&&isFinite(f)?f:i,g=(p-a)/d||1,y=Array(d).fill(0);for(const e of r)a>e||e>p||y[Math.min(Math.floor((e-a)/g),d-1)]++;const b=r.length,v=e(y,1),x=l(t.pieceData[0],t.name);for(let e=0;d>e;e++){if(0===y[e])continue;const o=(h?y[e]/b:y[e]/v)*t.width*.9,r=c(a+e*g),n=c(a+(e+1)*g);u.push(ct(Math.min(r,n),t.x+t.width-o,Math.abs(n-r),o,x,{bin:e,count:y[e],range:[a+e*g,a+(e+1)*g],category:t.name},t.name))}}return u},ridgeline:function(t,o){const{scales:r,columns:n,config:i,getR:a,resolveSummaryStyle:s}=t,{r:l,projection:c}=r,u=[],d=i.bins||20,h="horizontal"===c,p=i.amplitude||1.5;for(const t of Object.values(n)){const o=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>o.length)continue;const r=o[0],n=o[o.length-1],i=(n-r)/d||1,c=Array(d).fill(0);for(const e of o)r>e||e>n||c[Math.min(Math.floor((e-r)/i),d-1)]++;const m=e(c,1),f=s(t.pieceData[0],t.name),g=t.width*p;let y;if(h){const e=t.x+t.width;y=`M ${l(r)} ${e}`;for(let t=0;d>t;t++)y+=` L ${l(r+(t+.5)*i)} ${e-c[t]/m*g}`;y+=` L ${l(n)} ${e} Z`}else{const e=t.x;y=`M ${e} ${l(r)}`;for(let t=0;d>t;t++){const o=l(r+(t+.5)*i);y+=` L ${e+c[t]/m*g} ${o}`}y+=` L ${e} ${l(n)} Z`}const b=h?{x:Math.min(l(r),l(n)),y:t.x,width:Math.abs(l(n)-l(r)),height:t.width}:{x:t.x,y:Math.min(l(n),l(r)),width:t.width,height:Math.abs(l(n)-l(r))};u.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:b,stats:Vp(o),style:{...f,fillOpacity:f.fillOpacity??.5},datum:t.pieceData,category:t.name})}return u},timeline:function(e,t){const{scales:o,columns:r,getRawRange:n,resolvePieceStyle:i}=e,{r:a,projection:s}=o,l=[],c="horizontal"===s;for(const e of Object.values(r))for(const t of e.pieceData){const o=n(t);if(!o)continue;const[r,s]=o,u=i(t,e.name);if(c){const o=a(Math.min(r,s)),n=a(Math.max(r,s));l.push(ct(o,e.x,n-o,e.width,u,t,e.name))}else{const o=a(Math.max(r,s)),n=a(Math.min(r,s));l.push(ct(e.x,o,e.width,n-o,u,t,e.name))}}return l},funnel:function(e,t){const{columns:o,getR:r,getStack:n,resolvePieceStyle:i}=e,a=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>o[e]).filter(Boolean);if(0===c.length)return a;const u=[],d=new Set;for(const e of c)for(const t of e.pieceData){const e=n?n(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],p=[];let m=0;for(const e of c){const t=new Map;let o=0;for(const i of e.pieceData){const e=n?n(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const a=t.get(e),s=r(i);a.total+=s,a.pieces.push(i),o+=s}p.push({col:e,groups:t,stepTotal:o}),h||o>m&&(m=o)}if(h)for(const e of p){let t=0,o=0;for(let r=0;u.length>r;r++){const n=e.groups.get(u[r]);n&&(r%2==0?t+=n.total:o+=n.total)}const r=Math.max(t,o);r>m&&(m=r)}if(0===m)return a;const f=new Map;for(const e of u){const t=p[0].groups.get(e);f.set(e,t?.total??0)}const g=p[0].stepTotal,y=h?.95*s:.9*t.width,b=Xp().domain([0,m]).range([0,y]),v=e.config.connectorOpacity??.3;let x=new Map;for(let t=0;p.length>t;t++){const o=p[t],r=o.col,n=0===t,c=r.width,d=.55*c,m=r.x+(c-d)/2,y=new Map;if(h){let e=0;for(const t of u){const r=o.groups.get(t);r&&(e+=b(r.total))}let t=s,c=s;for(let h=0;u.length>h;h++){const p=u[h],g=o.groups.get(p);if(!g)continue;const v=b(g.total),x=h%2==0,w=x?t:c-v;x?t+=v:c-=v;const k=i(g.pieces[0],p),S=f.get(p)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:r.name,__funnelIsFirstStep:n,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:p};l&&(0===h&&(A.__funnelStepLabel=r.name,A.__funnelStepLabelX=s,A.__funnelStepLabelY=m,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+v/2,A.__funnelValueLabelY=m,A.__funnelBarW=v),a.push(ct(w,m,v,d,k,A,p)),y.set(p,{x:w,y:m,w:v,h:d})}}else{const e=o.stepTotal,t=b(e),c=s-t/2,h=u[0],p="_default"!==h,f=o.groups.get(h)?.pieces[0]??r.pieceData[0],v=p?h:r.name,x=i(f,v),w=g>0?e/g*100:0,k={...f,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:n,category:p?h:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=m,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=m,k.__funnelBarW=t),a.push(ct(c,m,t,d,x,k,v)),y.set(h,{x:c,y:m,w:t,h:d})}if(t>0&&x.size>0){const t=h?u:[u[0]];for(const n of t){const t=x.get(n),s=y.get(n);if(!t||!s)continue;const l=(()=>{const e=o.groups.get(n);return i(e?e.pieces[0]:r.pieceData[0],"_default"===n?r.name:n)})(),c={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:v},datum:o.groups.get(n)?.pieces[0]??r.pieceData[0],category:"_default"===n?r.name:n};a.push(c)}}x=y}return a},"bar-funnel":function(e,t){const{columns:o,getR:r,getStack:n,resolvePieceStyle:i,scales:a}=e,s=[],l=a.o.domain().map(e=>o[e]).filter(Boolean);if(0===l.length)return s;const c=[],u=new Set;for(const e of l)for(const t of e.pieceData){const e=n?n(t):"_default";u.has(e)||(u.add(e),c.push(e))}const d=c.length>1&&"_default"!==c[0],h=[];for(const e of l){const t=new Map;let o=0;for(const i of e.pieceData){const e=n?n(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const a=t.get(e),s=r(i);a.total+=s,a.pieces.push(i),o+=s}h.push({col:e,groups:t,stepTotal:o})}const p=new Map;for(const e of c){const t=h[0]?.groups.get(e);p.set(e,t?.total??0)}const m=a.r,f=d?c.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],o=t.col,r=0===e,n=e>0?h[e-1]:null,a=o.width/f,l=a*g,u=a-l;for(let e=0;c.length>e;e++){const h=c[e],f=t.groups.get(h);if(!f)continue;const g=f.total,y=p.get(h)??g,b=y>0?g/y*100:0,v=n?.groups.get(h),x=r?0:Math.max(0,(v?.total??g)-g),w=o.x+e*a+l/2,k=m(g),S=m(0)-k,A=i(f.pieces[0],d?h:o.name),C={...f.pieces[0],__barFunnelValue:g,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:x,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:m(g+x)};if(s.push(ct(w,k,u,S,A,C,d?h:o.name)),x>0){const e=m(g+x),t=k-e,r={...A},n={...f.pieces[0],__barFunnelValue:x,__barFunnelPercent:y>0?x/y*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:o.name};s.push(ct(w,e,u,t,r,n,d?h:o.name))}}}return s},swimlane:function(e,t){const{scales:o,columns:r,getR:n,getStack:i,resolvePieceStyle:a}=e,{r:s,projection:l}=o,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",p=e.config.trackFill;if(p){const e="string"==typeof p?p:p.color,t="string"==typeof p?1:p.opacity??1,[o,n]=s.range(),i=Math.min(o,n),a=Math.abs(n-o);for(const o of Object.values(r)){const r={fill:e,opacity:t},n=u?ct(i,o.x,a,o.width,r,null,"__track__"):ct(o.x,i,o.width,a,r,null,"__track__");c.push(n)}}const m=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(r)){let t=0;const o=c.length;for(const o of e.pieceData){const r=Math.abs(n(o));if(0===r)continue;const l=i?i(o):e.name,p=a(o,l);let m;if(u){const n=s(t),i=s(t+r);m=ct(n,e.x,i-n,e.width,p,o,l)}else{const n=s(t+r),i=s(t);m=ct(e.x,n,e.width,i-n,p,o,l)}d&&(m.fillGradient=d,m.roundedEdge=h),c.push(m),t+=r}if(m>0&&c.length>o){const e=c.slice(o),t=e[0],r=e[e.length-1];1===e.length?t.cornerRadii={tl:m,tr:m,br:m,bl:m}:u?(t.cornerRadii={tl:m,bl:m},r.cornerRadii={tr:m,br:m}):(t.cornerRadii={bl:m,br:m},r.cornerRadii={tl:m,tr:m})}}return c}};function Kp(e,t,o){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Fe[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:o}function Qp(e,t){const o=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>o&&We(o,e)||"#4e79a7":t=>{if(o){const e=We(o,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var Zp=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Jp=["scene-style","data-paint","accessibility","evidence"],em=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],tm=new Set(["accessorRevision","axisExtent","categoryAccessor","chartType","extentPadding","groupBy","multiAxis","normalize","oAccessor","oExtent","oSort","rAccessor","rExtent","runtimeMode","stackBy","timeAccessor","valueAccessor"]),om=new Set(["barColors","colorScheme","connectorStyle","pieceStyle","summaryStyle","themeCategorical","themeDiverging","themeSemantic","themeSequential"]),rm=class{constructor(){this.tracker=new Jt}get last(){return this.tracker.last}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Zp)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Jp):this.recordNoop("restyle")}recordConfig(e){if(0===e.length)return this.tracker.record({kind:"config",keys:e},[]);const t=new Set(em);return e.some(e=>tm.has(e))&&t.add("domain"),e.some(e=>om.has(e))&&t.add("scene-style"),this.tracker.record({kind:"config",keys:e},t)}};import{quadtree as nm}from"d3-quadtree";var im=class{constructor(e){this.rExtent=new oe,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new rm,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new te(e.windowSize),this.getO=ae(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>ne(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new oe)):(this.getR=ne(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=ae(e.stackBy),this.getGroup=ae(e.groupBy),this.getColor=ae(e.colorAccessor),this.getSymbol=ae(e.symbolAccessor),this.getConnector=ae(e.connectorAccessor),this.getDataId=ae(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new te(e.windowSize))}syncPulseTimestampBuffer(){var e,t,o,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,o=this.timestampBuffer,r=Ue(),e?null!=o&&o.capacity===t.capacity&&o.size===t.size?o:Vt(t,r):null)}ingest(e){const t=Ue();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Yt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)Xt(this.buffer,o,this.timestampBuffer,t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=Xt(this.buffer,o,this.timestampBuffer,t);this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this,r=this.scales,n=this.multiScales,i=this.columns;if(0===o.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const a=this.getBufferArray(),s=t.projection||"vertical",l=t.oExtent||this.resolveCategories(a),c=this.computeValueDomain(a,l),u="horizontal"===s,d="radial"===s,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===s?e.width:e.height):.1));let p,m;if(d){p=Op().domain(l).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,r=t.innerRadius||0;m=Hp().domain(c).range([r,o])}else u?(p=Op().domain(l).range([0,e.height]).padding(h),m=Hp().domain(c).range([0,e.width])):(p=Op().domain(l).range([0,e.width]).padding(h),m=Hp().domain(c).range([e.height,0]));this.scales={o:p,r:m,projection:s},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,n)=>{const i=this.rExtents[n];i.dirty&&i.recalculate(o,r);let[a,s]=i.extent;a===1/0&&(a=0,s=1);const l=s-a,c=l>0?l*(t.extentPadding??.05):1;return a-=c,s+=c,a>0&&(a=0),u?Hp().domain([a,s]).range([0,e.width]):Hp().domain([a,s]).range([e.height,0])}):[];let f=a;this.rAccessors.length>1&&(f=a.flatMap(e=>this.rAccessors.map((t,o)=>({...e,__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(f,l,p,s,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=n,this.columns=i):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,a),this.config.pulse&&this.applyPulse(this.scene,a),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t;let n=null;if(o){n=new Set;for(const t of e)n.add(this.getO(t))}const i=n?Array.from(this.categories).filter(e=>n.has(e)):Array.from(this.categories);if(o&&void 0===r){const e=Math.max(50,3*n.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;n.has(e)||(this.categories.delete(e),t--)}}return i}if(!1===r)return i;if("function"==typeof r)return i.sort(r);const a=new Map;for(const t of e){const e=this.getO(t);a.set(e,(a.get(e)||0)+Math.abs(this.getR(t)))}return i.sort("asc"===r?(e,t)=>(a.get(e)||0)-(a.get(t)||0):(e,t)=>(a.get(t)||0)-(a.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:o,projection:r,normalize:n,rExtent:i,extentPadding:a=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,p=a;if("radial"===r&&("pie"===o||"donut"===o))return[0,1];let m=0,f=0;if("bar"===o&&d&&n)m=0,f=1;else if("bar"===o&&d){const e=new Map,o=new Map;for(const r of t){const t=c(r),n=u(r);0>n?o.set(t,(o.get(t)||0)+n):e.set(t,(e.get(t)||0)+n)}for(const t of e.values())t>f&&(f=t);for(const e of o.values())m>e&&(m=e)}else if("bar"===o){const e=new Map;for(const o of t){const t=c(o),r=u(o);e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>f&&(f=t),m>t&&(m=t)}else if("swimlane"===o){const e=new Map;for(const o of t){const t=c(o),r=Math.abs(u(o));e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===o||"bar-funnel"===o)for(const e of t){const t=u(e);t>f&&(f=t),m>t&&(m=t)}else{const e=h[0],t=h[1];e!==1/0&&(m=e),t!==-1/0&&(f=t)}i&&(null!=i[0]&&(m=i[0]),null!=i[1]&&(f=i[1]));const g="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(g&&null==i?.[0]&&null==i?.[1]&&(m>0&&(m=0),0>f&&(f=0)),"bar-funnel"!==o&&"exact"!==l){const e=f-m,t=e>0?e*p:1,r=g&&!s&&0===m,n=g&&!s&&0===f||"swimlane"===o;null!=i?.[0]||r||(m-=t),null!=i?.[1]||n||(f+=t)}return[m,f]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,o,r,n){return function(e){const{data:t,oExtent:o,oScale:r,projection:n,layout:i,dynamicColumnWidth:a,getO:s,getR:l}=e,c={},u=new Map;for(const e of t){const t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===n)for(const e of t)d+=Math.abs(l(e));let h=null;if(a&&"radial"!==n){h=new Map;let e=0;for(const t of o){const o=u.get(t)||[];let r;r="string"==typeof a?o.reduce((e,t)=>e+(Number(t[a])||0),0):a(o),h.set(t,r),e+=r}const t=("horizontal"===n?i.height:i.width)-r.padding()*r.step()*o.length;if(e>0)for(const[o,r]of h)h.set(o,r/e*t)}let p=0,m=0;for(const e of o){const t=u.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(l(t)),0),n=d>0?o/d:0;let i,a;h?(i=m,a=h.get(e)||r.bandwidth(),m+=a+r.padding()*r.step()):(i=r(e)??0,a=r.bandwidth()),c[e]={name:e,x:i,y:0,width:a,middle:i+a/2,padding:r.padding()*r.step(),pieceData:t,pct:n,pctStart:p},p+=n}return c}({data:e,oExtent:t,oScale:o,projection:r,layout:n,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(e,t);let r;try{r=this.config.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,o=Ft("ordinal",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const n=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of n)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return $t({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const o=this.getSceneContext(),r=Up[this.config.chartType];let n=r?r(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:r,getConnector:n,getO:i}=e;if(!n||!o)return[];const a=[],{projection:s}=o,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=n(t);if(!o)continue;let r,a;"point"===e.type?(r=e.x,a=e.y):(r=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),l.has(o)||l.set(o,[]),l.get(o).push({x:r,y:a,datum:t,category:i(t)})}const c=o.o.domain(),u=r.connectorStyle;for(const[t,o]of l)if(o.length>=2){o.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let r=0;o.length-1>r;r++){const n=o[r],i=o[r+1],s="function"==typeof u?u(n.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:n.x,y1:n.y,x2:i.x,y2:i.y,style:s,datum:n.datum,group:t})}}return a}(o,n);n=[...e,...n]}return n}buildLayoutContext(e,t){const o=this.config,r=o.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Kp(o.colorScheme,o.themeCategorical,ze),i=this.scales;return{data:e,scales:{o:i.o,r:i.r,projection:i.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:"radial"===i.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:[...n]},resolveColor:Qp(n,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const o=this.config.pieceStyle(e,t);return o&&!o.fill&&t?{...o,fill:this.getColorFromScheme(t)}:o}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ze,r=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,r),r}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?Ze(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Je(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const o="function"==typeof t,r=o?null:t||"category",n=new Map;for(let i=0;e.length>i;i++){const a=e[i],s=o?t(a):a[r],l=n.get(s);l?l.push(i):n.set(s,[i])}return n}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,o=0;for(const r of e)"point"===r.type&&(t++,r.r>o&&(o=r.r));if(500>=t)return{quadtree:null,maxRadius:o};const r=Array(t);let n=0;for(const t of e)"point"===t.type&&(r[n++]=t);return{maxRadius:o,quadtree:nm().x(e=>e.x).y(e=>e.y).addAll(r)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const o=t.length;if(1>=o)return;const r=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const n=this.computeDecayOpacity(e,o);t.style={...t.style,opacity:(t.style?.opacity??1)*n}}}applyPulse(e,t,o=Ue()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,r,n,i){const a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4;let l=!1;for(const c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){const t=c.category;if(!t)continue;let r=0;for(const a of n(t)??[]){const t=o.get(a);null!=t&&(r=Math.max(r,et(e,t,i)))}l=tt(c,r,a)||l;continue}if(null==c.datum)continue;const t=r.get(c.datum);if(null==t)continue;const u=o.get(t);l=tt(c,null==u?0:et(e,u,i),a,s)||l}return l}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),o)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&ot(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(Ue())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,o="horizontal"!==this.scales?.projection;let r;for(let n=0;this.scene.length>n;n++){const i=this.scene[n],a=this.getNodeKey(i,e);a&&("rect"===i.type?this.prevPositionMap.set(a,o?{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}:{x:t,y:i.y,w:0,h:i.h,opacity:i.style.opacity??1}):"point"===i.type?this.prevPositionMap.set(a,{x:i.x,y:i.y,r:0,opacity:0}):"wedge"===i.type&&(void 0===r&&(r=i.startAngle),this.prevPositionMap.set(a,{x:i.cx,y:i.cy,startAngle:r,endAngle:r,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(o)||0;return t.set(o,r+1),`${o}:${r}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const o=new Set,r=new Map;for(let e=0;this.scene.length>e;e++){const n=this.scene[e],i=this.getNodeKey(n,r);if(!i)continue;n._transitionKey=i;const a=this.prevPositionMap.get(i);if("point"===n.type)a?(o.add(i),n._targetOpacity=n.style.opacity??1,(a.x!==n.x||a.y!==n.y||void 0!==a.r&&a.r!==n.r)&&(n._targetX=n.x,n._targetY=n.y,n._targetR=n.r,n.x=a.x,n.y=a.y,void 0!==a.r&&(n.r=a.r),t=!0)):(n._targetOpacity=n.style.opacity??1,n._targetR=n.r,n.r=0,n.style={...n.style,opacity:0},t=!0);else if("rect"===n.type)a?(o.add(i),n._targetOpacity=n.style.opacity??1,a.x===n.x&&a.y===n.y&&a.w===n.w&&a.h===n.h||(n._targetX=n.x,n._targetY=n.y,n._targetW=n.w,n._targetH=n.h,n.x=a.x,n.y=a.y,n.w=a.w??n.w,n.h=a.h??n.h,t=!0)):(n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},t=!0);else if("wedge"===n.type)if(a)o.add(i),n._targetOpacity=n.style.opacity??1,a.startAngle===n.startAngle&&a.endAngle===n.endAngle||(n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle,n.startAngle=a.startAngle,n.endAngle=a.endAngle,t=!0);else{n._targetOpacity=n.style.opacity??1,n._targetStartAngle=n.startAngle,n._targetEndAngle=n.endAngle;const e=n.startAngle;n.startAngle=e,n.endAngle=e,n.style={...n.style,opacity:0},this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:e,endAngle:e,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,r]of this.prevPositionMap)if(!o.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((r.startAngle??0)+(r.endAngle??0))/2,o={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:Ue(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=Ve(e,this.activeTransition),o=Ye(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const r=this.prevPositionMap.get(t);e.style.opacity=Xe(r?r.opacity??1:0,e._targetOpacity,o)}const r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=Xe(r.x,e._targetX,o),e.y=Xe(r.y,e._targetY,o)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=Xe(r.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const r=this.prevPositionMap.get(t);e.style.opacity=Xe(r?r.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;const r=this.prevPositionMap.get(t);if(!r)continue;e.x=Xe(r.x,e._targetX,o),e.y=Xe(r.y,e._targetY,o),void 0!==r.w&&(e.w=Xe(r.w,e._targetW,o),e.h=Xe(r.h,e._targetH,o))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const r=this.prevPositionMap.get(t);e.style={...e.style,opacity:Xe(r?r.opacity??1:0,e._targetOpacity,o)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=Xe(r.startAngle,e._targetStartAngle,o),e.endAngle=Xe(r.endAngle,e._targetEndAngle,o))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(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"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}getLastUpdateResult(){return this.updateResults.last}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ue(e),o=this.getDataId,r=e=>t.has(o(e));Ut(this.buffer,this.timestampBuffer,r);const n=this.buffer.remove(r);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const e of n)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=Ue(),this.updateResults.recordData("remove",n.length),n}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=ue(e),r=this.getDataId,n=new Set;this.buffer.forEach((e,t)=>{o.has(r(e))&&n.add(t)});const i=this.buffer.update(e=>o.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),n.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=Ue(),this.updateResults.recordData("update",i.length),i}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this._colorSchemeMap=null,this._colorSchemeIndex=0,this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}setLayoutSelection(e){this.config.layoutSelection=e}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},n=o(r,t);r.style=n?{...e,...n}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!re(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!re(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!re(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;("categoryAccessor"in e||"oAccessor"in e)&&(re(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=ae(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let n=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],i=Array.isArray(o)?o:[o];if(n=r.length!==i.length||r.some((e,t)=>!re(e,i[t])),n){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>ne(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new oe)):(this.getR=ne(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!re(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?ae(this.config.stackBy):void 0),"groupBy"in e&&!re(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?ae(this.config.groupBy):void 0),"colorAccessor"in e&&!re(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ae(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!re(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ae(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!re(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?ae(this.config.connectorAccessor):void 0),(r||n||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function am(e,t,o,r=30,n,i=0){let a=null;if(n){const e=Eo(n,t,o,r,i);e&&(a={datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"rect":if(null==i.datum)break;e=sm(i,t,o);break;case"point":if(n)break;e=lm(i,t,o,r);break;case"symbol":e=cm(i,t,o,r);break;case"glyph":e=um(i,t,o,r);break;case"wedge":if(null===i.datum)break;e=dm(i,t,o);break;case"boxplot":e=hm(i,t,o);break;case"violin":e=pm(i,t,o)}e&&r>e.distance&&(a&&e.distance>=a.distance||(a=e))}return a}function sm(e,t,o){const r=Ao(t,o,e);return r.hit?{datum:e.datum,x:r.cx,y:e.y,distance:0,category:e.group}:null}function lm(e,t,o,r=30){const n=t-e.x,i=o-e.y,a=Math.sqrt(n*n+i*i);return a>Co(e.r,r)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function cm(e,t,o,r=30){const n=t-e.x,i=o-e.y,a=Math.sqrt(n*n+i*i);return a>Co(Rt(e.size),r)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function um(e,t,o,r=30){if(null==e.datum)return null;const n=Do(e.glyph,e.size),i=e.x+n.centerDx,a=e.y+n.centerDy,s=t-i,l=o-a,c=Math.sqrt(s*s+l*l);return c>Co(n.radius,r)?null:{datum:e.datum,x:i,y:a,distance:c}}function dm(e,t,o){const r=t-e.cx,n=o-e.cy,i=Math.sqrt(r*r+n*n);if(e.innerRadius>i||i>e.outerRadius)return null;const a=Io(Math.atan2(n,r)),s=Io(e.startAngle),l=Io(e.endAngle);if(!(s>l?a>=s||l>=a:a>=s&&l>=a))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function hm(e,t,o){const r=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-r>t||t>e.x+r||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const n=e.y-r,i=e.y+r;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||n>o||o>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function pm(e,t,o){if(!e.bounds)return null;const{x:r,y:n,width:i,height:a}=e.bounds;return r>t||t>r+i||n>o||o>n+a?null:{datum:e.datum,x:r+i/2,y:n+a/2,distance:0,category:e.category,stats:e.stats}}import{useMemo as mm,useRef as fm}from"react";import{Fragment as gm,jsx as ym,jsxs as bm}from"react/jsx-runtime";function vm(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,scales:a,showAxes:s,showGrid:l,rFormat:c}=e,{rTickValues:u,axisExtent:d}=e,h="radial"===a?.projection,p="horizontal"===a?.projection,m=mm(()=>!a||h?[]:(u||Si(a.r,5,d)).map(e=>({value:e,pixel:a.r(e),label:(c||xm)(e)})),[a,c,h,u,d]),f=l&&a&&!h,g=s&&a&&!h;return f||g?ym("svg",{width:r,height:n,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:bm("g",{transform:`translate(${i.left},${i.top})`,children:[f&&ym("g",{className:"ordinal-grid",children:m.map((e,r)=>ym("line",{x1:p?e.pixel:0,y1:p?0:e.pixel,x2:p?e.pixel:t,y2:p?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+r))}),g&&ym(gm,{children:bm(gm,p?{children:[ym("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ym("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[ym("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ym("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function xm(e){return Math.round(100*e)/100+""}function wm(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,scales:a,showAxes:s,showCategoryTicks:l,oLabel:c,rLabel:u,oFormat:d,rFormat:h,showGrid:p,title:m,legend:f,legendHoverBehavior:g,legendClickBehavior:y,legendHighlightedCategory:b,legendIsolatedCategories:v,legendPosition:x="right",legendLayout:w,foregroundGraphics:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,xAccessor:M,yAccessor:P,annotationData:I,underlayRendered:_,children:L}=e,R="radial"===a?.projection,T="horizontal"===a?.projection,N=!1!==l,$=mm(()=>{if(!s||!N||!a||R)return[];const e=a.o.bandwidth(),t=a.o.domain().map((t,o)=>({value:t,pixel:(a.o(t)??0)+e/2,label:d?d(t,o):t}));if(2>=t.length)return t;const o=Math.abs(t[1].pixel-t[0].pixel)||e;let r,n=0,i=!1;for(const e of t)"string"==typeof e.label?n=Math.max(n,e.label.length):"number"==typeof e.label?n=Math.max(n,(e.label+"").length):i=!0;r=T?i?24:16:Math.max(6.5*n,i?60:0)+6;const l=Math.max(1,Math.ceil(r/o));return 1===l?t:t.filter((e,t)=>t%l===0)},[s,N,a,d,R,T]),B=e.rTickValues,D=e.tickLabelEdgeAlign,F=e.axisExtent,E=mm(()=>s&&a&&!R?(B||Si(a.r,5,F)).map(e=>({value:e,pixel:a.r(e),label:(h||xm)(e)})):[],[s,a,h,R,B,F]),z=fm(new Map),j=fm(S?.length??0),O=S?.length??0;j.current!==O&&(j.current=O,z.current=new Map);const H=mm(()=>{if(!S||0===S.length)return null;const e=Wn(),r="horizontal"===a?.projection,n=a?.o?e=>(a.o(e)??0)+a.o.bandwidth()/2:null,i={scales:a?{x:r?a.r:n||a.r,y:r&&n||a.r,time:a.r,value:a.r,o:a.o}:null,timeAxis:"x",xAccessor:M,yAccessor:P,width:t,height:o,data:I,frameType:"ordinal",projection:r?"horizontal":"vertical",stickyPositionCache:z.current};return Hn(A?di({annotations:S,context:i,..."object"==typeof A?A:{}}):S,e,C,i)},[S,A,C,t,o,a,M,P,I]);return s||m||f||k||H&&H.length>0||p||L?bm("svg",{role:"img",width:r,height:n,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[ym("title",{children:"string"==typeof m?m:"Ordinal Chart"}),ym("desc",{children:"string"==typeof m?m+" — ordinal data visualization":"Ordinal data visualization"}),bm("g",{transform:`translate(${i.left},${i.top})`,children:[p&&a&&!R&&!_&&ym("g",{className:"ordinal-grid",children:E.map((e,r)=>ym("line",{x1:T?e.pixel:0,y1:T?0:e.pixel,x2:T?e.pixel:t,y2:T?o:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+r))}),s&&a&&!R&&(()=>{const e={fontSize:"var(--semiotic-tick-font-size, 12px)"},r={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return ym("g",{className:"ordinal-axes",children:bm(gm,T?{children:[bm("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!_&&ym("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),$.map((t,o)=>bm("g",{transform:`translate(0,${t.pixel})`,children:[ym("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ym("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):ym("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:ym("div",{style:{textAlign:"right",userSelect:"none",...e},children:t.label})})]},"cat-"+o)),c&&ym("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...r},children:c})]}),bm("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!_&&ym("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!_&&a?.r&&(()=>{const e=a.r(0);return e>1&&t-1>e?ym("line",{x1:e,y1:0,x2:e,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),E.map((t,r)=>{const n=D?0===r?"start":r===E.length-1?"end":"middle":"middle";return bm("g",{transform:`translate(${t.pixel},${o})`,children:[ym("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ym("text",{y:18,textAnchor:n,fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label})]},"val-"+r)}),u&&ym("text",{x:t/2,y:o+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:{userSelect:"none",...r},children:u})]})]}:{children:[bm("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!_&&(()=>{const e=a?.r?a.r(0):o,r=0>e||e>o?o:e;return ym("line",{x1:0,y1:r,x2:t,y2:r,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),$.map((t,r)=>bm("g",{transform:`translate(${t.pixel},${o})`,children:[ym("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ym("text",{y:18,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):ym("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:ym("div",{style:{textAlign:"center",userSelect:"none",...e},children:t.label})})]},"cat-"+r)),c&&ym("text",{x:t/2,y:o+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:{userSelect:"none",...r},children:c})]}),bm("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!_&&ym("line",{x1:0,y1:0,x2:0,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),E.map((t,o)=>bm("g",{transform:`translate(0,${t.pixel})`,children:[ym("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ym("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label})]},"val-"+o)),u&&ym("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...r},children:u})]})]})})})(),H,k,L]}),m&&ym("text",{x:r/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof m?m:null}),Kr({legend:f,totalWidth:r,totalHeight:n,margin:i,legendPosition:x,title:m,legendLayout:w,legendHoverBehavior:g,legendClickBehavior:y,legendHighlightedCategory:b,legendIsolatedCategories:v})]}):null}import{useRef as km,useEffect as Sm}from"react";import{select as Am}from"d3-selection";import{brushX as Cm,brushY as Mm}from"d3-brush";import{jsx as Pm,jsxs as Im}from"react/jsx-runtime";function _m({width:e,height:t,totalWidth:o,totalHeight:r,margin:n,scales:i,onBrush:a}){const s=km(null),l=km(null),c=km(a);c.current=a;const u=km(i);u.current=i;const d=km(!1),h=km(null),p="horizontal"===i?.projection,m=km(p);m.current=p;const f=_({label:"Ordinal value range brush",onAction:e=>{const t=u.current,o=l.current;if(!t||!o||!s.current)return;const r=Am(s.current).select(".brush-g");if("clear"===e.type)return d.current=!0,r.call(o.move,null),d.current=!1,h.current=null,void c.current(null);if(("left"===e.direction||"right"===e.direction)!=!!m.current)return;const n=t.r.domain(),[i,a]=[Math.min(...n),Math.max(...n)],p=(a-i)/20,f=h.current?.r??[i+.4*(a-i),i+.6*(a-i)],g="left"===e.direction||"down"===e.direction?-1:1;let[y,b]=f;if(e.resize)0>g?y=Math.max(i,y-p):b=Math.min(a,b+p);else{const e=b-y;y=Math.max(i,Math.min(a-e,y+g*p)),b=y+e}const v={r:[y,b]};d.current=!0,r.call(o.move,m.current?[t.r(y),t.r(b)]:[t.r(b),t.r(y)]),d.current=!1,h.current=v,c.current(v)}});return Sm(()=>{if(!s.current)return;const o=Am(s.current).select(".brush-g"),r=p?Cm():Mm();return r.extent([[0,0],[e,t]]),r.on("brush end",e=>{if(d.current)return;const t=u.current;if(!t)return;if(!e.selection)return h.current=null,void c.current(null);const[o,r]=e.selection;let n;n=m.current?[t.r.invert(o),t.r.invert(r)]:[t.r.invert(r),t.r.invert(o)];const i={r:n};h.current=i,c.current(i)}),o.call(r),l.current=r,o.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),l.current=null}},[e,t,p]),Sm(()=>{if(!i||!l.current||!h.current)return;if(!s.current)return;const e=h.current,t=Am(s.current).select(".brush-g"),o=i.r(e.r[0]),r=i.r(e.r[1]);p?(d.current=!0,t.call(l.current.move,[o,r]),d.current=!1):(d.current=!0,t.call(l.current.move,[r,o]),d.current=!1)},[i,p]),Im("svg",{ref:s,width:o,height:r,...f.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Pm("title",{children:f.svgProps["aria-label"]}),Pm("desc",{id:f.descriptionId,children:f.description}),Pm("g",{className:"brush-g",transform:`translate(${n.left},${n.top})`,style:{pointerEvents:"all"}})]})}import{arc as Lm}from"d3-shape";function Rm(e,t){const o=t._gradientBand.colors;if(0===o.length)return;const{clipPath:r,slices:n}=Hi({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds?.start??!0,roundEnd:t.roundedEnds?.end??!0,colors:o}),i=new Path2D(r);e.save(),e.translate(t.cx,t.cy),e.clip(i);for(const t of n)e.fillStyle=Go(e,t.color)||t.color||"#007bff",e.fill(new Path2D(t.d));e.restore(),t.style.stroke&&"none"!==t.style.stroke&&(e.save(),e.translate(t.cx,t.cy),e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(i),e.restore())}function Tm(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}function Nm(e,t){const o={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},r=Lm().cornerRadius(t.cornerRadius)(o);if(!r)return;e.save(),e.translate(t.cx,t.cy);const n=new Path2D(r);e.fill(n),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(n),e.restore()}var $m=(e,t,o,r)=>{const n=t.filter(e=>"wedge"===e.type);for(const t of n)if(e.globalAlpha=(t.style.fillOpacity??1)*(t.style.opacity??1),t._gradientBand&&t._gradientBand.colors.length>0)Rm(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(Tm(e,t),al(e,t)),e.globalAlpha=1;else{if(e.fillStyle=("string"==typeof t.style.fill?Go(e,t.style.fill):t.style.fill)||"#007bff",t.roundedEnds){t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1);const o=Oi({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds.start,roundEnd:t.roundedEnds.end});e.save(),e.translate(t.cx,t.cy);const r=new Path2D(o);e.fill(r),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(r),e.restore()}else t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),Nm(e,t)):(Tm(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()));t._pulseIntensity&&t._pulseIntensity>0&&(Tm(e,t),al(e,t)),e.globalAlpha=1}},Bm=(e,t,o,r)=>{const n=t.filter(e=>"boxplot"===e.type);for(const t of n){const o=t.columnWidth/2,r="vertical"===t.projection,n=Go(e,"var(--semiotic-primary, #007bff)"),i=Go(e,"var(--semiotic-text, #333)"),a=t.style.fill,s="string"==typeof a?Go(e,a)||a:a??n,l=t.style.stroke,c="string"==typeof l?Go(e,l)||l:i,u=t.style.strokeWidth||1,d=t.style.fillOpacity??t.style.opacity??.6;if(e.save(),e.strokeStyle=c,e.lineWidth=u,e.beginPath(),r?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),r?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=d,e.fillStyle=s,r){const r=Math.min(t.q1Pos,t.q3Pos),n=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,r,t.columnWidth,n),e.globalAlpha=1,e.strokeRect(t.x-o,r,t.columnWidth,n)}else{const r=Math.min(t.q1Pos,t.q3Pos),n=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(r,t.y-o,n,t.columnWidth),e.globalAlpha=1,e.strokeRect(r,t.y-o,n,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),r?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},Dm=(e,t,o,r)=>{const n=t.filter(e=>"violin"===e.type);for(const t of n){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);if(e.globalAlpha=t.style.fillOpacity??t.style.opacity??.6,e.fillStyle=("string"==typeof t.style.fill?Go(e,t.style.fill):t.style.fill)||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const o=t.iqrLine.centerPos,r=!1!==t.iqrLine.isVertical;e.beginPath(),r?(e.moveTo(o,t.iqrLine.q1Pos),e.lineTo(o,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,o),e.lineTo(t.iqrLine.q3Pos,o)),e.stroke(),e.beginPath(),r?e.arc(o,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,o,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Fm=(e,t,o,r)=>{const n=t.filter(e=>"connector"===e.type);if(0===n.length)return;const i=new Map;for(const e of n){const t=e.group||"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(const[,t]of i){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=o.fillOpacity??o.opacity??.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=Go(e,o.style.stroke)||("string"==typeof o.style.fill?Go(e,o.style.fill):o.style.fill)||Go(e,"var(--semiotic-border, #999)"),e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=o.style.opacity??.5,e.stroke(),e.globalAlpha=1}},Em=(e,t,o,r)=>{const n=t.filter(e=>"trapezoid"===e.type);for(const t of n){const o=t.points;if(o.length>=4){e.globalAlpha=t.style?.opacity??1,e.beginPath(),e.moveTo(o[0][0],o[0][1]);for(let t=1;o.length>t;t++)e.lineTo(o[t][0],o[t][1]);e.closePath(),e.fillStyle=t.style?.fill||"#999",e.fill(),t.style?.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}};function zm(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function jm(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}var Om=null;var Hm=new Map;function Wm(e,t){const o=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,r=Hm.get(o);if(void 0!==r)return r;const n=function(e={},t){const{background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:i=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Om||(Om=document.createElement("canvas")),Om.width=e,Om.height=e,Om)}(s)}catch{return null}const c=l.getContext("2d");if(!c)return null;o&&"transparent"!==o?(c.fillStyle=o,c.fillRect(0,0,s,s)):c.clearRect(0,0,s,s),c.strokeStyle=r,c.lineWidth=n,c.lineCap="square";const u=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-s;2*s>=t;t+=i)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*s,s),c.stroke()}else{c.save(),c.translate(s/2,s/2),c.rotate(u);const e=2*s;for(let t=-e;e>=t;t+=i)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Hm.set(o,n),n}function qm(e,t,o,r,n,i){e.moveTo(t+i,o),e.lineTo(t+r-i,o),e.quadraticCurveTo(t+r,o,t+r,o+i),e.lineTo(t+r,o+n-i),e.quadraticCurveTo(t+r,o+n,t+r-i,o+n),e.lineTo(t+i,o+n),e.quadraticCurveTo(t,o+n,t,o+n-i),e.lineTo(t,o+i),e.quadraticCurveTo(t,o,t+i,o),e.closePath()}function Gm(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Ym(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}var Vm=e=>[Fm,...e],Xm={bar:Vm([vl]),clusterbar:Vm([vl]),point:Vm([dl,ml]),swarm:Vm([dl,ml]),pie:[$m],donut:[$m],boxplot:Vm([Bm,dl]),violin:Vm([Dm]),histogram:Vm([vl]),ridgeline:Vm([Dm]),timeline:Vm([vl]),funnel:[vl,Em,(e,t,o,r)=>{const n=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==n.length&&n.some(e=>null!=e.datum?.__funnelStepLabel||null!=e.datum?.__funnelValueLabelX)){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of n){const o=t.datum;if(!o)continue;if(!o.__funnelStepLabel)continue;const r=o.__funnelStepLabel;if(e.measureText(r).width+16>(o.__funnelRowWidth??o.__funnelBarW??0))continue;const n=o.__funnelStepLabelX,i=o.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(r,n,i),e.fillStyle="#fff",e.fillText(r,n,i)}e.font="bold 13px sans-serif";for(const t of n){const o=t.datum;if(!o)continue;if(null==o.__funnelValueLabelX)continue;const r=o.__funnelBarW??0;if(60>r)continue;const n=o.__funnelValue;if(null==n||0===n)continue;const i=o.__funnelPercent,a=!0===o.__funnelIsFirstStep;let s;if(s=a?zm(n):null!=i?`${zm(n)} (${jm(i)})`:zm(n),e.measureText(s).width+16>r){if(a||null==i)continue;if(s=zm(n),e.measureText(s).width+16>r)continue}const l=o.__funnelValueLabelX,c=(o.__funnelValueLabelY??t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(s,l,c),e.fillStyle="#fff",e.fillText(s,l,c)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[vl,(e,t,o,r)=>{const n=t.filter(e=>"rect"===e.type&&!0===e.datum?.__barFunnelIsDropoff);for(const t of n){const o=("string"==typeof t.style.fill?t.style.fill:null)||Go(e,"var(--semiotic-border, #999)"),r=Wm(o,e);e.globalAlpha=t.style.opacity??1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),r?e.fillStyle=r:(e.fillStyle=o,e.globalAlpha=.4*(t.style.opacity??1)),e.fill(),e.globalAlpha=1}},(e,t,o,r)=>{const n=t.filter(e=>"rect"===e.type&&!0!==e.datum?.__barFunnelIsDropoff&&null!=e.datum?.__barFunnelLabelX);if(0===n.length)return;const i=function(e,t){const[o,r,n]=Yo(e,t);return(.2126*o+.7152*r+.0722*n)/255>.6}(e,Go(e,"var(--semiotic-text, #333)")),a=i?"#1f2937":"#ffffff",s=i?"rgba(255,255,255,0.18)":"rgba(0,0,0,0.12)",l=i?"#f3f4f6":"#1a1a1a",c=l;for(const t of n){const o=t.datum;if(!o)continue;const r=o.__barFunnelValue;if(null==r)continue;if(25>t.w)continue;const n=o.__barFunnelPercent,i=!(!0===o.__barFunnelIsFirstStep)&&null!=n,u=i?Ym(n):"",d=Gm(r);e.font="bold 13px sans-serif";const h=i?e.measureText(u).width:0;e.font="11px sans-serif";const p=e.measureText(d).width,m=Math.max(h,p)+12,f=i?32:17,g=o.__barFunnelLabelX,y=g-m/2,b=o.__barFunnelLabelY-f-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=a,e.beginPath(),qm(e,y,b,m,f,4),e.fill(),e.restore(),e.strokeStyle=s,e.lineWidth=.5,e.beginPath(),qm(e,y,b,m,f,4),e.stroke(),e.textAlign="center",e.textBaseline="top",i?(e.font="bold 13px sans-serif",e.fillStyle=l,e.fillText(u,g,b+3),e.font="11px sans-serif",e.fillStyle=c,e.fillText(d,g,b+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=l,e.fillText(d,g,b+3))}e.lineWidth=1}],swimlane:Vm([vl]),custom:Vm([vl,dl,ml,gl,$m,Bm,Dm,Em])};import{jsx as Um,jsxs as Km}from"react/jsx-runtime";function Qm(e){const t=ds(e,{skipPositional:!1});return null==t.title&&0===t.entries.length?null:Km("div",{className:"semiotic-tooltip",style:ms,children:[null!=t.title&&Um("div",{style:{fontWeight:"bold"},children:t.title+""}),t.entries.map(e=>Km("div",{children:[Km("span",{style:{opacity:.7},children:[e.key,":"]})," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]},e.key))]})}function Zm({hover:e}){const t=e.data||{},o=e.stats,r=e.category;if(Array.isArray(t)){const e=r||t[0]?.category||"";if(o)return Km("div",{className:"semiotic-tooltip",style:ms,children:[e&&Um("div",{style:{fontWeight:"bold"},children:e+""}),Km("div",{children:["n = ",o.n]}),Km("div",{children:["Min: ",o.min.toLocaleString()]}),Km("div",{children:["Q1: ",o.q1.toLocaleString()]}),Km("div",{children:["Median: ",o.median.toLocaleString()]}),Km("div",{children:["Q3: ",o.q3.toLocaleString()]}),Km("div",{children:["Max: ",o.max.toLocaleString()]}),Km("div",{style:{opacity:.8},children:["Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const n=t.length;return Km("div",{className:"semiotic-tooltip",style:ms,children:[e&&Um("div",{style:{fontWeight:"bold"},children:e+""}),Km("div",{children:[n," items"]})]})}if(null!=t.bin&&null!=t.count){const e=t.range||[];return Km("div",{className:"semiotic-tooltip",style:ms,children:[t.category&&Um("div",{style:{fontWeight:"bold"},children:t.category+""}),Km("div",{children:["Count: ",t.count]}),2===e.length&&Km("div",{style:{opacity:.8},children:[Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)]})]})}const n=e.__oAccessor,i=e.__rAccessor,a=e.__chartType;if("swarm"===a||"point"===a)return Qm(t);const s=(n&&null!=t[n]?t[n]:null)||t.category||t.name||t.group||t.__rName||"",l=t.__aggregateValue??(i&&null!=t[i]?t[i]:null)??t.value??t.__rValue??t.pct??"";return s||""!==l?Km("div",{className:"semiotic-tooltip",style:ms,children:[s&&Um("div",{style:{fontWeight:"bold"},children:s+""}),""!==l&&Um("div",{children:"number"==typeof l?l.toLocaleString():l+""})]}):Qm(t)}Zm.ownsChrome=!0;import{jsx as Jm,jsxs as ef}from"react/jsx-runtime";var tf={top:50,right:40,bottom:60,left:70},of=jp(zp(function(e,t){const{chartType:o,runtimeMode:r,data:n,oAccessor:i="category",rAccessor:a="value",colorAccessor:s,symbolAccessor:l,symbolMap:c,stackBy:d,groupBy:h,multiAxis:p,timeAccessor:m,valueAccessor:f,categoryAccessor:g,accessorRevision:y,projection:b="vertical",size:v=[600,400],responsiveWidth:x,responsiveHeight:w,margin:k,barPadding:S,roundedTop:A,gradientFill:C,trackFill:M,baselinePadding:P,innerRadius:I,cornerRadius:_,normalize:L,startAngle:R,sweepAngle:T,dynamicColumnWidth:N,bins:$,showOutliers:B,showIQR:F,amplitude:E,connectorOpacity:z,showLabels:j,connectorAccessor:O,connectorStyle:H,dataIdAccessor:W,rExtent:q,oExtent:G,extentPadding:V=.05,oSort:X,windowMode:U="sliding",windowSize:K=200,pieceStyle:Q,summaryStyle:Z,colorScheme:J,barColors:ee,showAxes:te=!0,showCategoryTicks:oe,categoryLabel:re,valueLabel:ne,categoryFormat:ie,valueFormat:ae,oLabel:se,rLabel:le,oFormat:ce,rFormat:ue,rTickValues:de,tickLabelEdgeAlign:he,axisExtent:pe,enableHover:me=!0,hoverAnnotation:fe,tooltipContent:ge,customHoverBehavior:ye,customClickBehavior:be,annotations:ve,autoPlaceAnnotations:xe,svgAnnotationRules:we,showGrid:ke=!1,legend:Se,legendHoverBehavior:Ae,legendClickBehavior:Ce,legendHighlightedCategory:Me,legendIsolatedCategories:Pe,legendPosition:Ie,legendLayout:_e,legendCategoryAccessor:Le,onCategoriesChange:Re,backgroundGraphics:Te,foregroundGraphics:Ne,title:$e,className:Be,background:De,centerContent:Fe,decay:Ee,pulse:ze,transition:je,animate:Oe,staleness:He,brush:We,onBrush:qe,accessibleTable:Ge=!0,description:Ye,summary:Ve,customLayout:Xe,onLayoutError:Ue,layoutConfig:Ke,layoutSelection:Qe}=e,Ze=Np(!0),Je=js({sizeProp:v,responsiveWidth:x,responsiveHeight:w,userMargin:k,marginDefault:tf,animate:Oe,transitionProp:je,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:ot,margin:rt,adjustedWidth:nt,adjustedHeight:it,currentTheme:at,transition:st,introEnabled:lt,tableId:ct,rafRef:ut,renderFnRef:dt,scheduleRender:ht,cancelRender:pt}=Je,mt=na(),ft=la(),gt=Dp(()=>u(n),[n]),yt=re??se,bt=ne??le,vt=ie??ce,xt=ae??ue,wt=Np(null),kt=Np(null),St=Np([]),At=Np(Le),Ct=Np(Re);At.current=Le,Ct.current=Re;const[Mt,Pt]=$p(null),[It,_t]=$p(null),Lt=(e,t)=>"function"==typeof e?e({size:ot,margin:rt,scales:t}):e,Rt=Lt(Ne,It),Tt=Lt(Te,It),[Nt,$t]=$p(0),Bt=Np(0),[Dt,Ft]=$p(!1),Et=Np({w:-1,h:-1}),zt=Np(!1),jt=me||fe,Ot="streaming"===r,Ht=da(Dp(()=>({chartType:o,runtimeMode:Ot?"streaming":"bounded",windowSize:K,windowMode:U,extentPadding:V,projection:b,oAccessor:Ot?void 0:i,rAccessor:Ot?void 0:a,accessorRevision:y,colorAccessor:s,symbolAccessor:l,symbolMap:c,stackBy:d,groupBy:h,multiAxis:p,timeAccessor:Ot?m:void 0,valueAccessor:Ot?f||("string"==typeof a||"function"==typeof a?a:void 0):void 0,categoryAccessor:Ot?g||i:void 0,rExtent:q,oExtent:G,axisExtent:pe,barPadding:S,roundedTop:A,gradientFill:C,trackFill:M,baselinePadding:P,innerRadius:I,cornerRadius:_,normalize:L,startAngle:R,sweepAngle:T,dynamicColumnWidth:N,bins:$,showOutliers:B,showIQR:F,amplitude:E,connectorOpacity:z,showLabels:j,connectorAccessor:O,connectorStyle:H,dataIdAccessor:W,oSort:X,pieceStyle:Q,summaryStyle:Z,colorScheme:J,themeCategorical:at?.colors?.categorical,themeSemantic:Y(at),themeSequential:at?.colors?.sequential,themeDiverging:at?.colors?.diverging,barColors:ee,decay:Ee,pulse:ze,transition:st,introAnimation:lt,staleness:He,customLayout:Xe,onLayoutError:Ue,layoutConfig:Ke,layoutMargin:rt}),[o,K,U,V,b,i,a,y,s,l,c,d,h,p,m,f,g,q,G,pe,S,A,C,M,P,I,_,L,R,T,N,$,B,F,E,z,j,O,H,W,X,Q,Z,J,ee,Ee,ze,st?.duration,st?.easing,lt,He,Ot,at,Xe,Ue,Ke,rt])),Wt=Np(null);Wt.current||(Wt.current=new im(Ht));const qt=Fp(()=>{const e=At.current,t=Ct.current;if(!t||!e)return;const o=Gs(Wt.current?.getData()??[],e);Ys(o,St.current)||(St.current=o,t(o))},[]);ko(Wt,Ht,Ze,ht),So(Wt,Qe,Ze,ht);const Gt=Np(null);Gt.current||(Gt.current=new D(e=>{const t=Wt.current;t&&t.ingest(e)&&(Ze.current=!0,ht())}));const Yt=Fp(e=>{Gt.current?.push(e)},[]),Vt=Fp(e=>{Gt.current?.pushMany(e)},[]),Xt=Fp(()=>{Gt.current?.clear(),Wt.current?.clear(),Ze.current=!0,ht()},[ht]),Ut=Fp(e=>{Gt.current?.clearLastData(),Gt.current?.setReplacementData(e)},[]);Ep(t,()=>({push:Yt,pushMany:Vt,replace:Ut,remove:e=>{Gt.current?.flush();const t=Wt.current?.remove(e)??[];if(t.length>0){const e=kt.current?.data;!!kt.current&&t.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(kt.current=null,Pt(null)),Ze.current=!0,ht()}return t},update:(e,t)=>{Gt.current?.flush();const o=Wt.current?.update(e,t)??[];return o.length>0&&(Ze.current=!0,ht()),o},clear:Xt,getData:()=>(Gt.current?.flush(),Wt.current?.getData()??[]),getScales:()=>Wt.current?.scales??null,getCustomLayout:()=>Wt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Wt.current?.lastCustomLayoutFailure??null}),[Yt,Vt,Ut,Xt,ht]),Bp(()=>{n&&Gt.current?.setBoundedData(gt)},[n,gt]);const{hoverHandlerRef:Kt,hoverLeaveRef:Qt,onPointerMove:Zt,onPointerLeave:Jt}=Je;Kt.current=e=>{if(!jt)return;const t=wt.current;if(!t)return;const r=t.getBoundingClientRect(),n=e.clientX-r.left-rt.left,s=e.clientY-r.top-rt.top;if(0>n||n>nt||0>s||s>it)return void(kt.current&&(kt.current=null,Pt(null),ye&&ye(null),ht()));const l=Wt.current;if(!l||0===l.scene.length)return;const c="radial"===b,u=am(l.scene,c?n-nt/2:n,c?s-it/2:s,30,l.pointQuadtree,l.maxPointRadius);if(!u)return void(kt.current&&(kt.current=null,Pt(null),ye&&ye(null),ht()));const d=is(u.datum||{},u.x,u.y,{...u.stats&&{stats:u.stats},...u.category&&{category:u.category},__oAccessor:"string"==typeof i?i:void 0,__rAccessor:"string"==typeof a?a:void 0,__chartType:o});kt.current=d,Pt(d),ye&&(ye(d),Ze.current=!0),ht()},Qt.current=()=>{kt.current&&(kt.current=null,Pt(null),ye&&(ye(null),Ze.current=!0),ht())};const eo=Fp(e=>{if(!be)return;const t=wt.current;if(!t)return be(null),Ze.current=!0,void ht();const r=t.getBoundingClientRect(),n=e.clientX-r.left-rt.left,s=e.clientY-r.top-rt.top;if(0>n||n>nt||0>s||s>it)return be(null),Ze.current=!0,void ht();const l=Wt.current;if(!l||0===l.scene.length)return be(null),Ze.current=!0,void ht();const c="radial"===b,u=am(l.scene,c?n-nt/2:n,c?s-it/2:s,30,l.pointQuadtree,l.maxPointRadius);if(!u)return be(null),Ze.current=!0,void ht();be(is(u.datum||{},u.x,u.y,{...u.stats&&{stats:u.stats},...u.category&&{category:u.category},__oAccessor:"string"==typeof i?i:void 0,__rAccessor:"string"==typeof a?a:void 0,__chartType:o})),Ze.current=!0,ht()},[it,nt,o,be,rt,i,b,a,ht]),to=Np(-1),oo=Np(null),ro=Np(null),no=Fp(e=>{const t=Wt.current;if(!t||0===t.scene.length)return;const r=t.version;let n;if(ro.current&&ro.current.version===r)n=ro.current.graph;else{const e=function(e){const t=[];for(const o of e)if("rect"===o.type&&null!=o.x){if(null==o.datum)continue;t.push({x:o.x+o.w/2,y:o.y+o.h/2,datum:o.datum,shape:"rect",w:o.w,h:o.h,group:o.group??o.datum?.category??""})}else if("point"===o.type)t.push({x:o.x,y:o.y,datum:o.datum,shape:"circle",group:"_default"});else if("symbol"===o.type){if(0>=o.size)continue;t.push({x:o.x,y:o.y,datum:o.datum,shape:"circle",group:"_default"})}else if("glyph"===o.type){if(0>=o.size||null==o.datum)continue;const e=Do(o.glyph,o.size);t.push({x:o.x+e.centerDx,y:o.y+e.centerDy,datum:o.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"})}else if("wedge"===o.type&&null!=o.cx){if(null===o.datum)continue;const e=((o.startAngle||0)+(o.endAngle||0))/2,r=((o.innerRadius||0)+(o.outerRadius||50))/2;t.push({x:o.cx+Math.cos(e)*r,y:o.cy+Math.sin(e)*r,datum:o.datum,shape:"wedge",group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===e.length)return;n=wr(e),ro.current={version:r,graph:n}}const s=to.current;if(0>s){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),to.current=0;const t=n.flat[0];oo.current={shape:t.shape,w:t.w,h:t.h};const r={...Mr(t),__oAccessor:"string"==typeof i?i:void 0,__rAccessor:"string"==typeof a?a:void 0,__chartType:o};return kt.current=r,Pt(r),ye&&ye(r),void ht()}const l=kr(n,s),c=Sr(e.key,l,n);if(null===c)return;if(e.preventDefault(),0>c)return to.current=-1,oo.current=null,kt.current=null,Pt(null),ye&&ye(null),void ht();to.current=c;const u=n.flat[c];oo.current={shape:u.shape,w:u.w,h:u.h};const d={...Mr(u),__oAccessor:"string"==typeof i?i:void 0,__rAccessor:"string"==typeof a?a:void 0,__chartType:o};kt.current=d,Pt(d),ye&&ye(d),ht()},[ye,ht]),io=Fp(e=>{to.current=-1,oo.current=null,Zt(e)},[Zt]);dt.current=()=>{ut.current=null;const e=wt.current;if(!e)return;const t=e.getContext("2d");if(!t)return;const r=Wt.current;if(!r)return;const n="undefined"!=typeof performance?performance.now():Date.now(),i=r.advanceTransition(et.current?n+1e6:n),a=!et.current&&i,s=Et.current.w!==nt||Et.current.h!==it,l=Ze.current;let c=!1;!l&&!s||a&&!s||(r.computeScene({width:nt,height:it}),Et.current={w:nt,h:it},c=!0,qt()),Ze.current=l&&a&&!c;const u=Os(r,n,c,zt);(c||a)&&e.setAttribute("aria-label",Na(r.scene,o+" chart"));const d=Ws(),h=ot[0]*d,p=ot[1]*d;e.width===h&&e.height===p||(e.width=h,e.height=p,e.style.width=ot[0]+"px",e.style.height=ot[1]+"px"),t.setTransform(d,0,0,d,0,0),t.clearRect(0,0,ot[0],ot[1]);const m=He&&r.lastIngestTime>0&&n-r.lastIngestTime>(He?.threshold??5e3);m&&(t.globalAlpha=He?.dimOpacity??.5),fa(t,{background:De,hasBackgroundGraphics:!!Te,themeBackground:Te||"transparent"===De||De?"":getComputedStyle(e).getPropertyValue("--semiotic-bg").trim(),width:ot[0],height:ot[1]});const f="radial"===b;t.save(),t.beginPath(),t.rect(rt.left,rt.top,nt,it),t.clip(),f?(t.save(),t.translate(rt.left+nt/2,rt.top+it/2)):t.translate(rt.left,rt.top);const g=Xe?Xm.custom:Xm[o]||[],y={width:nt,height:it};for(const e of g)e(t,r.scene,r.scales,y);f&&t.restore(),t.restore(),m&&(t.globalAlpha=1),c&&r.scales?(_t(r.scales),$t(e=>e+1),Bt.current=n):a&&r.scales&&n-Bt.current>=33&&($t(e=>e+1),Bt.current=n),He?.showBadge&&Ft(!!m),(a||null!=r.activeTransition||u.pending)&&ht()},ca({hydrated:mt,wasHydratingFromSSR:ft,storeRef:Wt,dirtyRef:Ze,renderFnRef:dt,cancelRender:pt,cleanup:()=>Gt.current?.clear()}),Bp(()=>{Ze.current=!0,ht()},[o,nt,it,te,De,ht]),Tr(He,Wt,Ze,ht,Dt,Ft);const ao=jt&&Mt?ge?ge(Mt):Jm(Zm,{hover:Mt}):null,so="radial"===b,lo=ao?Jm(ks,{x:Mt?so?Mt.x+nt/2:Mt.x:0,y:Mt?so?Mt.y+it/2:Mt.y:0,containerWidth:nt,containerHeight:it,margin:rt,className:"stream-ordinal-tooltip",children:ao}):null,co=Vs(i,void 0,"__semiotic_resolvedO",""),uo=Vs(a,void 0,"__semiotic_resolvedR",""),ho=co.key,po=uo.key,fo=Xs(co,uo,ve&&ve.length>0||!1);if(Qi||!mt&&ft){const e=Wt.current;e&&n&&(e.ingest({inserts:gt,bounded:!0}),e.computeScene({width:nt,height:it}));const t=e?.scene??[],o=e?.scales??null,r=Lt(Ne,o),i=Lt(Te,o),a="radial"===b,s=a?rt.left+nt/2:rt.left,l=a?rt.top+it/2:rt.top;return ef("div",{ref:tt,className:"stream-ordinal-frame"+(Be?" "+Be:""),role:"img","aria-label":Ye||("string"==typeof $e?$e:"Ordinal chart"),style:{position:"relative",width:x?"100%":ot[0],height:w?"100%":ot[1]},children:[Jm(Ka,{summary:Ve}),ef("svg",{xmlns:"http://www.w3.org/2000/svg",width:ot[0],height:ot[1],style:{position:"absolute",left:0,top:0},children:[i&&Jm("g",{transform:`translate(${rt.left},${rt.top})`,children:i}),ef("g",{transform:`translate(${s},${l})`,children:[De&&Jm("rect",{x:0,y:0,width:nt,height:it,fill:De}),t.map((e,t)=>function(e,t,o){const r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",n=o=>`ord-${e.type}-${r}-${t}-${o}`,i=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{const t=e,o=Ui(i)+"-grad",r=function(e,t){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,i=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,i=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,i=e.x+e.w,a=e.y);const s=[];if("colorStops"in o){const e=o.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>e.length)return null;for(let t=0;e.length>t;t++)s.push(Wi("stop",{offset:e[t].offset,stopColor:e[t].color},t))}else{const t=Yi(e.style.fill);s.push(Wi("stop",{offset:0,stopColor:t,stopOpacity:o.topOpacity},"0")),s.push(Wi("stop",{offset:1,stopColor:t,stopOpacity:o.bottomOpacity},"1"))}return Wi("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:i,y2:a,children:s})}(t,o),n=r?`url(#${o})`:Yi(t.style.fill);if(t.cornerRadii&&Ei(t.cornerRadii)){const e=function(e){const{x:t,y:o,w:r,h:n}=e,{tl:i,tr:a,br:s,bl:l}=zi(e);let c=`M${t+i},${o}`;return c+=` L${t+r-a},${o}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${o+a}`),c+=` L${t+r},${o+n-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${o+n}`),c+=` L${t+l},${o+n}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${o+n-l}`),c+=` L${t},${o+i}`,i>0&&(c+=` A${i},${i} 0 0 1 ${t+i},${o}`),c+=" Z",c}(t);return qi(Di.Fragment,{children:[r&&Wi("defs",{children:r}),Wi("path",{d:e,fill:n,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:o,y:a,w:s,h:l}=t;let c;switch(t.roundedEdge){case"right":c=`M${o},${a} L${o+s-e},${a} A${e},${e} 0 0 1 ${o+s},${a+e} L${o+s},${a+l-e} A${e},${e} 0 0 1 ${o+s-e},${a+l} L${o},${a+l} Z`;break;case"left":c=`M${o+s},${a} L${o+e},${a} A${e},${e} 0 0 0 ${o},${a+e} L${o},${a+l-e} A${e},${e} 0 0 0 ${o+e},${a+l} L${o+s},${a+l} Z`;break;case"bottom":c=`M${o},${a} L${o+s},${a} L${o+s},${a+l-e} A${e},${e} 0 0 1 ${o+s-e},${a+l} L${o+e},${a+l} A${e},${e} 0 0 1 ${o},${a+l-e} Z`;break;default:c=`M${o},${a+l} L${o},${a+e} A${e},${e} 0 0 1 ${o+e},${a} L${o+s-e},${a} A${e},${e} 0 0 1 ${o+s},${a+e} L${o+s},${a+l} Z`}return qi(Di.Fragment,{children:[r&&Wi("defs",{children:r}),Wi("path",{d:c,fill:n,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return qi(Di.Fragment,{children:[r&&Wi("defs",{children:r}),Wi("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:n,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}case"point":{const t=e;return Wi("circle",{cx:t.x,cy:t.y,r:t.r,fill:Yi(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return Vi(e,t,o);case"glyph":return Xi(e,e.x,e.y,`${o??""}ord-glyph-${e.pointId??t}`);case"wedge":{const r=e;if(r._gradientBand&&r._gradientBand.colors.length>0){const e=Ui(`${o?o+"-":""}gauge-grad-${r.category||i}-${t}`),{clipPath:n,slices:a}=Hi({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds?.start??!0,roundEnd:r.roundedEnds?.end??!0,colors:r._gradientBand.colors});return qi("g",{transform:`translate(${r.cx},${r.cy})`,opacity:r.style.opacity,fillOpacity:r.style.fillOpacity,children:[Wi("defs",{children:Wi("clipPath",{id:e,children:Wi("path",{d:n})})}),Wi("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>Wi("path",{d:e.d,fill:Yi(e.color)},t))}),r.style.stroke&&"none"!==r.style.stroke&&Wi("path",{d:n,fill:"none",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},i)}let n;if(r.roundedEnds)n=Oi({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds.start,roundEnd:r.roundedEnds.end});else{const e=Fi().innerRadius(r.innerRadius).outerRadius(r.outerRadius).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2);r.cornerRadius&&e.cornerRadius(r.cornerRadius),n=e(Gi)||""}return Wi("path",{d:n,transform:`translate(${r.cx},${r.cy})`,fill:Yi(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},i)}case"boxplot":{const t=e,o=t.columnWidth/2;return qi("g","vertical"===t.projection?{children:[Wi("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("rect",{x:t.x-o,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Yi(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("line",{x1:t.x-o,y1:t.medianPos,x2:t.x+o,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),Wi("line",{x1:t.x-.5*o,y1:t.minPos,x2:t.x+.5*o,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("line",{x1:t.x-.5*o,y1:t.maxPos,x2:t.x+.5*o,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[Wi("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-o,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Yi(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("line",{x1:t.medianPos,y1:t.y-o,x2:t.medianPos,y2:t.y+o,stroke:t.style.stroke||"#333",strokeWidth:2}),Wi("line",{x1:t.minPos,y1:t.y-.5*o,x2:t.minPos,y2:t.y+.5*o,stroke:t.style.stroke||"#333",strokeWidth:1}),Wi("line",{x1:t.maxPos,y1:t.y-.5*o,x2:t.maxPos,y2:t.y+.5*o,stroke:t.style.stroke||"#333",strokeWidth:1})]},i)}case"violin":{const t=e,o=[Wi("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Yi(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},n("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,r=e.x+e.width/2,i=e.y+e.height/2;e.height>e.width?o.push(Wi("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},n("iqr")),Wi("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},n("med"))):o.push(Wi("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},n("iqr")),Wi("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},n("med")))}return Wi("g",{children:o},i)}case"connector":return Wi("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},i);case"trapezoid":{const t=e,o=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return Wi("polygon",{points:o,fill:Yi(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}default:return null}}(e,t,ct)).filter(Boolean)]})]}),Jm(wm,{width:nt,height:it,totalWidth:ot[0],totalHeight:ot[1],margin:rt,scales:o,showAxes:te,showCategoryTicks:oe,oLabel:yt,rLabel:bt,oFormat:vt,rFormat:xt,rTickValues:de,tickLabelEdgeAlign:he,axisExtent:pe,showGrid:ke,title:$e,legend:Se,legendHoverBehavior:Ae,legendClickBehavior:Ce,legendHighlightedCategory:Me,legendIsolatedCategories:Pe,legendPosition:Ie,legendLayout:_e,foregroundGraphics:mo(r,vo(Wt.current?.customLayoutOverlays,Qe??null)),annotations:ve,autoPlaceAnnotations:xe,svgAnnotationRules:we,annotationFrame:0,xAccessor:ho,yAccessor:po,annotationData:fo(e?.getData())}),Fe&&"radial"===b&&Jm("div",{style:{position:"absolute",left:rt.left+nt/2,top:rt.top+it/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Fe})]})}return ef("div",{ref:tt,className:"stream-ordinal-frame"+(Be?" "+Be:""),role:"group","aria-label":Ye||("string"==typeof $e?$e:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:x?"100%":ot[0],height:w?"100%":ot[1],overflow:"visible"},onKeyDown:no,children:[Ge&&Jm(Qa,{tableId:ct}),Ge&&Jm(Xa,{scene:Wt.current?.scene??[],chartType:o+" chart",tableId:ct,chartTitle:"string"==typeof $e?$e:void 0}),Jm(Ka,{summary:Ve}),Jm(Za,{hoverPoint:Mt}),ef("div",{role:"img","aria-label":Ye||("string"==typeof $e?$e:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:jt?io:void 0,onMouseLeave:jt?Jt:void 0,onClick:be?eo:void 0,children:[Tt&&Jm("svg",{style:{position:"absolute",top:0,left:0,width:ot[0],height:ot[1],pointerEvents:"none"},children:Jm("g",{transform:`translate(${rt.left},${rt.top})`,children:Tt})}),Jm(vm,{width:nt,height:it,totalWidth:ot[0],totalHeight:ot[1],margin:rt,scales:It,showAxes:te,showGrid:ke,rFormat:xt,rTickValues:de,axisExtent:pe}),Jm("canvas",{ref:wt,"aria-label":Na(Wt.current?.scene??[],o+" chart"),style:{position:"absolute",top:0,left:0,width:ot[0],height:ot[1]}}),Jm(wm,{width:nt,height:it,totalWidth:ot[0],totalHeight:ot[1],margin:rt,scales:It,showAxes:te,showCategoryTicks:oe,oLabel:yt,rLabel:bt,oFormat:vt,rFormat:xt,rTickValues:de,axisExtent:pe,showGrid:ke,title:$e,legend:Se,legendHoverBehavior:Ae,legendClickBehavior:Ce,legendHighlightedCategory:Me,legendIsolatedCategories:Pe,legendPosition:Ie,legendLayout:_e,foregroundGraphics:mo(Rt,vo(Wt.current?.customLayoutOverlays,Qe??null)),annotations:ve,autoPlaceAnnotations:xe,svgAnnotationRules:we,annotationFrame:Nt,xAccessor:ho,yAccessor:po,annotationData:fo(Wt.current?.getData()),underlayRendered:!0}),(We||qe)&&"radial"!==b&&Jm(_m,{width:nt,height:it,totalWidth:ot[0],totalHeight:ot[1],margin:rt,scales:It,onBrush:qe||(()=>{})}),Fe&&"radial"===b&&Jm("div",{style:{position:"absolute",left:rt.left+nt/2,top:rt.top+it/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Fe}),He?.showBadge&&Jm($r,{isStale:Dt,position:He.badgePosition}),Jm(ts,{active:to.current>=0,hoverPoint:Mt,margin:rt,size:ot,shape:oo.current?.shape,width:oo.current?.w,height:oo.current?.h}),lo]})]})}));of.displayName="StreamOrdinalFrame";var rf=of;import{useImperativeHandle as nf}from"react";function af({ref:e,frameRef:t,setup:o}){return nf(e,()=>({push:e=>t.current?.push(e),pushMany:e=>t.current?.pushMany(e),remove:e=>t.current?.remove(e)??[],update:(e,o)=>t.current?.update(e,o)??[],clear:()=>t.current?.clear(),getData:()=>t.current?.getData()??[],getScales:()=>t.current?.getScales()??null}),[t]),{effectiveLegendProps:o.legendBehaviorProps,effectiveMargin:o.margin}}import{useMemo as sf}from"react";function lf(e){const{colorBy:t,colorScale:o,color:r,themeCategorical:n,colorScheme:i,categoryIndexMap:a,userPieceStyle:s,stroke:l,strokeWidth:c,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,cycleByCategory:p=!1,baseStyleExtras:m,linkStrokeToFill:f=!1}=e,g=sf(()=>(e,s)=>{const l="function"==typeof m?m(e,s):m,c=l?{...l}:{};if(void 0===c.fill)if(t){if(!o)return c;c.fill=He(e,t,o)}else c.fill=xu(r,n,i,p?s:void 0,a);return f&&void 0===c.stroke&&void 0!==c.fill&&(c.stroke=c.fill),c},[t,o,r,n,i,a,p,m,f]),y=sf(()=>nd(s?"function"==typeof s?(e,t)=>({...g(e,t),...s(e,t)||{}}):(e,t)=>({...g(e,t),...s}):g,{stroke:l,strokeWidth:c,opacity:u}),[g,s,l,c,u]);return sf(()=>Qc(y,d??null,h),[y,d,h])}import{jsx as cf}from"react/jsx-runtime";var uf=Rp(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=Tp(null),{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:d,colorBy:h,colorScheme:p,sort:m=!1,barPadding:f=40,roundedTop:g,gradientFill:y=!1,baselinePadding:b=!1,tooltip:v,annotations:x,regression:w,valueExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:P,hoverHighlight:I,chartId:_,loading:L,loadingContent:R,emptyContent:T,legendInteraction:N,legendPosition:$,color:B,stroke:D,strokeWidth:F,opacity:E,showCategoryTicks:z,categoryFormat:j,dataIdAccessor:O}=e,{width:H,height:W,enableHover:q,showGrid:G,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=o,J=Lp(()=>u(n),[n]),ee=od({data:J,rawData:n,colorBy:h,colorScheme:p,legendInteraction:N,legendPosition:$,selection:A,linkedHover:C,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"BarChart",chartId:_,showLegend:Y,userMargin:i,marginDefaults:o.marginDefaults,loading:L,loadingContent:R,emptyContent:T,width:H,height:W}),{effectiveLegendProps:te,effectiveMargin:oe}=af({ref:t,frameRef:r,setup:ee});Wu("BarChart",J,"categoryAccessor",s),Wu("BarChart",J,"valueAccessor",l);const re=ku(J,m,l),ne=vu(),ie=Lp(()=>new Map,[J]),ae=lf({colorBy:h,colorScale:ee.colorScale,color:B,themeCategorical:ne,colorScheme:p,categoryIndexMap:ie,userPieceStyle:S?.pieceStyle,stroke:D,strokeWidth:F,opacity:E,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),se=Lp(()=>Bl({categoryAccessor:s,valueAccessor:l,groupAccessor:h&&h!==s?h:void 0,groupLabel:"string"==typeof h?h:"group",valueFormat:d}),[s,l,h,d]);if(ee.earlyReturn)return ee.earlyReturn;const le=Xu({componentName:"BarChart",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(le)return cf(Tu,{componentName:"BarChart",message:le,width:H,height:W});const ce=ih(w),ue=ce?[ce,...x||[]]:x,de={chartType:"bar",...null!=n&&{data:re},oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:ae,size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe,barPadding:f,...null!=g&&{roundedTop:g},...y&&{gradientFill:!0===y?{topOpacity:.8,bottomOpacity:.05}:y},...O&&{dataIdAccessor:O},baselinePadding:b,enableHover:q,showAxes:o.showAxes,oLabel:Q,rLabel:Z,rFormat:d,...j&&{oFormat:j},showGrid:G,showCategoryTicks:z,oSort:m,...te,...ld({title:V,description:X,summary:U,accessibleTable:K,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:v,defaultTooltipContent:se}),...cd({linkedHover:C,selection:A,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:ee.mobileInteraction,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior}),...ue&&ue.length>0&&{annotations:ue},...k&&{rExtent:k},...Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e))};return cf(Eu,{componentName:"BarChart",width:H,height:W,children:cf(rf,{ref:r,...de})})});uf.displayName="BarChart";import{useMemo as df,forwardRef as hf,useRef as pf}from"react";import{jsx as mf}from"react/jsx-runtime";var ff=hf(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=pf(null),{data:n,margin:i,className:a,categoryAccessor:s="category",stackBy:l,valueAccessor:c="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,normalize:f=!1,sort:g=!1,barPadding:y=40,roundedTop:b,baselinePadding:v=!1,tooltip:x,annotations:w,valueExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:P,hoverHighlight:I,chartId:_,loading:L,loadingContent:R,emptyContent:T,legendInteraction:N,legendPosition:$,color:B,stroke:D,strokeWidth:F,opacity:E,categoryFormat:z}=e,{width:j,height:O,enableHover:H,showGrid:W,showLegend:q,title:G,description:Y,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=o,Q=df(()=>u(n),[n]),Z=p||l,J=od({data:Q,rawData:n,colorBy:Z,colorScheme:m,legendInteraction:N,legendPosition:$,selection:A,linkedHover:C,fallbackFields:Z?["string"==typeof Z?Z:""]:[],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"StackedBarChart",chartId:_,showLegend:q,userMargin:i,marginDefaults:o.marginDefaults,loading:L,loadingContent:R,emptyContent:T,width:j,height:O}),ee=vu(),te=df(()=>new Map,[Q]),oe=lf({colorBy:Z,colorScale:J.colorScale,color:B,themeCategorical:ee,colorScheme:m,categoryIndexMap:te,userPieceStyle:S?.pieceStyle,stroke:D,strokeWidth:F,opacity:E,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),re=df(()=>Bl({categoryAccessor:l,valueAccessor:c,groupAccessor:s,valueFormat:h}),[l,s,c,h]),ne=Xu({componentName:"StackedBarChart",data:n,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{stackBy:l}}),{effectiveLegendProps:ie,effectiveMargin:ae}=af({ref:t,frameRef:r,setup:J});if(J.earlyReturn)return J.earlyReturn;const se={chartType:"bar",...null!=n&&{data:Q},oAccessor:s,rAccessor:c,stackBy:l,normalize:f,oSort:g,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:oe,size:[j,O],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ae,barPadding:y,...null!=b&&{roundedTop:b},baselinePadding:v,enableHover:H,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:U,rLabel:K,rFormat:h,...z&&{oFormat:z},showGrid:W,...ie,...ld({title:G,description:Y,summary:V,accessibleTable:X,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:x,defaultTooltipContent:re}),...cd({linkedHover:C,selection:A,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior}),...w&&w.length>0&&{annotations:w},...k&&{rExtent:k},...Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e))};return ne?mf(Tu,{componentName:"StackedBarChart",message:ne,width:j,height:O}):mf(Eu,{componentName:"StackedBarChart",width:j,height:O,children:mf(rf,{ref:r,...se})})});ff.displayName="StackedBarChart";import{useMemo as gf,forwardRef as yf,useRef as bf}from"react";import{jsx as vf}from"react/jsx-runtime";var xf=yf(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=bf(null),{data:n,margin:i,className:a,categoryAccessor:s="category",groupBy:l,valueAccessor:c="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,sort:f=!1,barPadding:g=60,roundedTop:y,baselinePadding:b=!1,tooltip:v,annotations:x,valueExtent:w,frameProps:k={},selection:S,linkedHover:A,onObservation:C,onClick:M,hoverHighlight:P,chartId:I,loading:_,loadingContent:L,emptyContent:R,legendInteraction:T,legendPosition:N,color:$,stroke:B,strokeWidth:D,opacity:F,categoryFormat:E}=e,{width:z,height:j,enableHover:O,showGrid:H,showLegend:W,title:q,description:G,summary:Y,accessibleTable:V,categoryLabel:X,valueLabel:U}=o,K=gf(()=>u(n),[n]),Q=p||l,Z=od({data:K,rawData:n,colorBy:Q,colorScheme:m,legendInteraction:T,legendPosition:N,selection:S,linkedHover:A,fallbackFields:Q?["string"==typeof Q?Q:""]:[],unwrapData:!0,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"GroupedBarChart",chartId:I,showLegend:W,userMargin:i,marginDefaults:o.marginDefaults,loading:_,loadingContent:L,emptyContent:R,width:z,height:j}),J=vu(),ee=gf(()=>new Map,[K]),te=lf({colorBy:Q,colorScale:Z.colorScale,color:$,themeCategorical:J,colorScheme:m,categoryIndexMap:ee,userPieceStyle:k.pieceStyle,stroke:B,strokeWidth:D,opacity:F,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection}),oe=gf(()=>Bl({categoryAccessor:l,valueAccessor:c,groupAccessor:s,valueFormat:h}),[l,s,c,h]),re=Xu({componentName:"GroupedBarChart",data:n,accessors:{categoryAccessor:s,valueAccessor:c},requiredProps:{groupBy:l}}),{effectiveLegendProps:ne,effectiveMargin:ie}=af({ref:t,frameRef:r,setup:Z});if(Z.earlyReturn)return Z.earlyReturn;const ae={chartType:"clusterbar",...null!=n&&{data:K},oAccessor:s,rAccessor:c,groupBy:l,oSort:f,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:te,size:[z,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ie,barPadding:g,...null!=y&&{roundedTop:y},baselinePadding:b,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:X,rLabel:U,rFormat:h,...E&&{oFormat:E},showGrid:H,...ne,...ld({title:q,description:G,summary:Y,accessibleTable:V,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:v,defaultTooltipContent:oe}),...cd({linkedHover:A,selection:S,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:Z.mobileInteraction,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior}),...x&&x.length>0&&{annotations:x},...w&&{rExtent:w},...Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e))};return re?vf(Tu,{componentName:"GroupedBarChart",message:re,width:z,height:j}):vf(Eu,{componentName:"GroupedBarChart",width:z,height:j,children:vf(rf,{ref:r,...ae})})});xf.displayName="GroupedBarChart";import{useMemo as wf,forwardRef as kf,useRef as Sf}from"react";import{useCallback as Af,useRef as Cf}from"react";function Mf({brushProp:e,onBrushProp:t,linkedBrush:o,valueAccessor:r}){const n=Kc("string"==typeof o?o:o?{name:o.name,xField:o.rField}:void 0),i="string"==typeof r?r:"value",a=Lc({name:n?.name||"__unused_ordinal_brush__",xField:n?.xField||i}),s=Cf(a.brushInteraction);s.current=a.brushInteraction;const l=Af(e=>{if(n){s.current.end(e?e.r:null)}t?.(e)},[t,n]),c=!!(e||o||t);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}import{jsx as Pf}from"react/jsx-runtime";var If=kf(function(e,t){const r=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),n=Sf(null);sd(t,{variant:"xy",frameRef:n});const{data:i,margin:a,className:s,categoryAccessor:l="category",valueAccessor:c="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,sizeBy:f,sizeRange:g=[3,8],symbolBy:y,symbolMap:b,pointRadius:v=4,pointOpacity:x=.7,categoryPadding:w=20,tooltip:k,annotations:S,valueExtent:A,brush:C,onBrush:M,linkedBrush:P,frameProps:I={},selection:_,linkedHover:L,onObservation:R,onClick:T,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:F,legendInteraction:E,legendPosition:z,color:j,stroke:O,strokeWidth:H,opacity:W,showCategoryTicks:q,categoryFormat:G}=e,{width:Y,height:V,enableHover:X,showGrid:U,showLegend:K,title:Q,description:Z,summary:J,accessibleTable:ee,categoryLabel:te,valueLabel:oe}=r,re=wf(()=>u(i),[i]),ne=od({data:re,rawData:i,colorBy:p,colorScheme:m,legendInteraction:E,legendPosition:z,selection:_,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof l?l:""],unwrapData:!0,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SwarmPlot",chartId:$,showLegend:K,userMargin:a,marginDefaults:r.marginDefaults,loading:B,loadingContent:D,emptyContent:F,width:Y,height:V}),ie=Mf({brushProp:C,onBrushProp:M,linkedBrush:P,valueAccessor:c}),ae=wf(()=>{if(!f)return;const e=re.map(e=>"function"==typeof f?f(e):e[f]);return o(e)},[re,f]),se=vu(),le=wf(()=>new Map,[re]),ce=lf({colorBy:p,colorScale:ne.colorScale,color:j,themeCategorical:se,colorScheme:m,categoryIndexMap:le,userPieceStyle:I?.pieceStyle,stroke:O,strokeWidth:H,opacity:W,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection,baseStyleExtras:e=>({fillOpacity:x,r:f?Ge(e,f,g,ae):v})}),ue=wf(()=>Bl({categoryAccessor:l,valueAccessor:c,groupAccessor:p||void 0,valueFormat:h}),[l,c,p,h]);if(ne.earlyReturn)return ne.earlyReturn;const de=Xu({componentName:"SwarmPlot",data:i,accessors:{categoryAccessor:l,valueAccessor:c}});if(de)return Pf(Tu,{componentName:"SwarmPlot",message:de,width:Y,height:V});const he={chartType:"swarm",...null!=i&&{data:re},oAccessor:l,rAccessor:c,...y&&{symbolAccessor:y},...b&&{symbolMap:b},projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ce,size:[Y,V],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ne.margin,barPadding:w,enableHover:X,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:r.showAxes,oLabel:te,rLabel:oe,rFormat:h,...G&&{oFormat:G},showGrid:U,showCategoryTicks:q,...ne.legendBehaviorProps,...ld({title:Q,description:Z,summary:J,accessibleTable:ee,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:k,defaultTooltipContent:ue}),...cd({linkedHover:L,selection:_,onObservation:R,onClick:T,hoverHighlight:N,mobileInteraction:ne.mobileInteraction,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior}),...S&&S.length>0&&{annotations:S},...A&&{rExtent:A},...ie.brushStreamProps,...Object.fromEntries(Object.entries(I).filter(([e])=>"pieceStyle"!==e))};return Pf(Eu,{componentName:"SwarmPlot",width:Y,height:V,children:Pf(rf,{ref:n,...he})})});If.displayName="SwarmPlot";import{useMemo as _f,forwardRef as Lf,useRef as Rf}from"react";import{jsx as Tf,jsxs as Nf}from"react/jsx-runtime";function $f(e){return t=>{const o=t.category||t.data&&t.data[0]?.category||"",r=t.stats||(t.data||t).stats;if(r&&null!=r.median)return Nf("div",{className:"semiotic-tooltip",style:ms,children:[o&&Tf("div",{style:{fontWeight:"bold"},children:o+""}),null!=r.n&&Nf("div",{children:["n = ",r.n]}),null!=r.min&&Nf("div",{children:["Min: ",r.min.toLocaleString()]}),null!=r.q1&&Nf("div",{children:["Q1: ",r.q1.toLocaleString()]}),Nf("div",{children:["Median: ",r.median.toLocaleString()]}),null!=r.q3&&Nf("div",{children:["Q3: ",r.q3.toLocaleString()]}),null!=r.max&&Nf("div",{children:["Max: ",r.max.toLocaleString()]}),null!=r.mean&&Nf("div",{style:{opacity:.8},children:["Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(e?.valueAccessor){const r=e.valueAccessor,n=(Array.isArray(t.data)?t.data:[]).map(e=>Number("function"==typeof r?r(e):e[r])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),i=n.length,a=i>0?i%2!=0?n[Math.floor(i/2)]:(n[i/2-1]+n[i/2])/2:null;return Nf("div",{className:"semiotic-tooltip",style:ms,children:[o&&Tf("div",{style:{fontWeight:"bold"},children:o+""}),i>0&&Nf("div",{children:["n = ",i]}),null!=a&&Nf("div",{children:["Median: ",a.toLocaleString()]})]})}return Tf("div",{className:"semiotic-tooltip",style:ms,children:Tf("div",{style:{fontWeight:"bold"},children:o+""})})}}import{jsx as Bf}from"react/jsx-runtime";var Df=Lf(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=Rf(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",valueFormat:d,colorBy:h,colorScheme:p,showOutliers:m=!0,outlierRadius:f=3,categoryPadding:g=20,tooltip:y,annotations:b,valueExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:P,loadingContent:I,emptyContent:_,legendInteraction:L,legendPosition:R,color:T,stroke:N,strokeWidth:$,opacity:B,showCategoryTicks:D,categoryFormat:F}=e,{width:E,height:z,enableHover:j,showGrid:O,showLegend:H,title:W,description:q,summary:G,accessibleTable:Y,categoryLabel:V,valueLabel:X}=o,U=_f(()=>u(n),[n]),K=od({data:U,rawData:n,colorBy:h,colorScheme:p,legendInteraction:L,legendPosition:R,selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"BoxPlot",chartId:M,showLegend:H,userMargin:i,marginDefaults:o.marginDefaults,loading:P,loadingContent:I,emptyContent:_,width:E,height:z}),Q=vu(),Z=_f(()=>new Map,[U]),J=lf({colorBy:h,colorScale:K.colorScale,color:T,themeCategorical:Q,colorScheme:p,categoryIndexMap:Z,userPieceStyle:void 0,stroke:N,strokeWidth:$,opacity:B,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),ee=_f(()=>$f(),[]);if(K.earlyReturn)return K.earlyReturn;const te=Xu({componentName:"BoxPlot",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(te)return Bf(Tu,{componentName:"BoxPlot",message:te,width:E,height:z});const oe={chartType:"boxplot",...null!=n&&{data:U},oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:J,showOutliers:m,size:[E,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:g,enableHover:j,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:V,rLabel:X,rFormat:d,...F&&{oFormat:F},showGrid:O,showCategoryTicks:D,...K.legendBehaviorProps,...ld({title:W,description:q,summary:G,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:y,defaultTooltipContent:ee}),...cd({linkedHover:k,selection:w,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior}),...b&&b.length>0&&{annotations:b},...v&&{rExtent:v},...Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e))};return Bf(Eu,{componentName:"BoxPlot",width:E,height:z,children:Bf(rf,{ref:r,...oe})})});Df.displayName="BoxPlot";import{useMemo as Ff,forwardRef as Ef,useRef as zf}from"react";import{jsx as jf,jsxs as Of}from"react/jsx-runtime";var Hf=e=>{const t=e?.category;return null==t?"All":t+""},Wf=Ef(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:"horizontal",mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=zf(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,categoryAccessor:s=Hf,valueAccessor:l="value",bins:c=25,relative:d=!1,valueFormat:h,colorBy:p,colorScheme:m,categoryPadding:f=20,tooltip:g,annotations:y,valueExtent:b,brush:v,onBrush:x,linkedBrush:w,frameProps:k={},selection:S,linkedHover:A,onObservation:C,onClick:M,hoverHighlight:P,chartId:I,loading:_,loadingContent:L,emptyContent:R,legendInteraction:T,legendPosition:N,color:$,stroke:B,strokeWidth:D,opacity:F,showCategoryTicks:E,categoryFormat:z}=e,{width:j,height:O,enableHover:H,showGrid:W,showLegend:q,title:G,description:Y,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=o,Q=Ff(()=>u(n),[n]),Z=od({data:Q,rawData:n,colorBy:p,colorScheme:m,legendInteraction:T,legendPosition:N,selection:S,linkedHover:A,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"Histogram",chartId:I,showLegend:q,userMargin:i,marginDefaults:o.marginDefaults,loading:_,loadingContent:L,emptyContent:R,width:j,height:O}),J=Mf({brushProp:v,onBrushProp:x,linkedBrush:w,valueAccessor:l}),ee=Ff(()=>{if(0===Q.length)return;const e="function"==typeof l?l:e=>e[l];let t=1/0,o=-1/0;for(const r of Q){const n=e(r);null!=n&&isFinite(n)&&(t>n&&(t=n),n>o&&(o=n))}return t>o?void 0:[t,o]},[Q,l]),te=vu(),oe=Ff(()=>new Map,[Q]),re=lf({colorBy:p,colorScale:Z.colorScale,color:$,themeCategorical:te,colorScheme:m,categoryIndexMap:oe,userPieceStyle:void 0,stroke:B,strokeWidth:D,opacity:F,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),ne=Ff(()=>e=>{const t=e.data||e,o=t.category||e.category||"",r=t.count,n=t.range;return Of("div",{className:"semiotic-tooltip",style:ms,children:[o&&jf("div",{style:{fontWeight:"bold"},children:o+""}),null!=r&&Of("div",{children:["Count: ",r]}),n&&2===n.length&&Of("div",{style:{opacity:.8},children:[Number(n[0]).toFixed(1)," – ",Number(n[1]).toFixed(1)]})]})},[]);if(Z.earlyReturn)return Z.earlyReturn;const ie=Xu({componentName:"Histogram",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(ie)return jf(Tu,{componentName:"Histogram",message:ie,width:j,height:O});const ae={chartType:"histogram",...null!=n&&{data:Q},oAccessor:s,rAccessor:l,projection:"horizontal",summaryStyle:re,bins:c,normalize:d,...b?{rExtent:b}:ee&&{rExtent:ee},size:[j,O],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Z.margin,barPadding:f,enableHover:H,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:U,rLabel:K,rFormat:h,...z&&{oFormat:z},showGrid:W,showCategoryTicks:E,...Z.legendBehaviorProps,...ld({title:G,description:Y,summary:V,accessibleTable:X,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:g,defaultTooltipContent:ne}),...cd({linkedHover:A,selection:S,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:Z.mobileInteraction,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior}),...y&&y.length>0&&{annotations:y},...J.brushStreamProps,...Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e))};return jf(Eu,{componentName:"Histogram",width:j,height:O,children:jf(rf,{ref:r,...ae})})});Wf.displayName="Histogram";import{useMemo as qf,forwardRef as Gf,useRef as Yf}from"react";import{jsx as Vf}from"react/jsx-runtime";var Xf=Gf(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=Yf(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="vertical",bins:d=25,curve:h="catmullRom",showIQR:p=!0,valueFormat:m,colorBy:f,colorScheme:g,categoryPadding:y=20,tooltip:b,annotations:v,valueExtent:x,brush:w,onBrush:k,linkedBrush:S,frameProps:A={},selection:C,linkedHover:M,onObservation:P,onClick:I,hoverHighlight:_,chartId:L,loading:R,loadingContent:T,emptyContent:N,legendInteraction:$,legendPosition:B,color:D,stroke:F,strokeWidth:E,opacity:z,showCategoryTicks:j,categoryFormat:O}=e,{width:H,height:W,enableHover:q,showGrid:G,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=o,J=qf(()=>u(n),[n]),ee=od({data:J,rawData:n,colorBy:f,colorScheme:g,legendInteraction:$,legendPosition:B,selection:C,linkedHover:M,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:P,onClick:I,hoverHighlight:_,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ViolinPlot",chartId:L,showLegend:Y,userMargin:i,marginDefaults:o.marginDefaults,loading:R,loadingContent:T,emptyContent:N,width:H,height:W}),te=Mf({brushProp:w,onBrushProp:k,linkedBrush:S,valueAccessor:l}),oe=vu(),re=qf(()=>new Map,[J]),ne=lf({colorBy:f,colorScale:ee.colorScale,color:D,themeCategorical:oe,colorScheme:g,categoryIndexMap:re,userPieceStyle:void 0,stroke:F,strokeWidth:E,opacity:z,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),ie=qf(()=>$f({valueAccessor:l}),[l]);if(ee.earlyReturn)return ee.earlyReturn;const ae=Xu({componentName:"ViolinPlot",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(ae)return Vf(Tu,{componentName:"ViolinPlot",message:ae,width:H,height:W});const se={chartType:"violin",...null!=n&&{data:J},oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:ne,bins:d,showIQR:p,size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ee.margin,barPadding:y,enableHover:q,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:Q,rLabel:Z,rFormat:m,...O&&{oFormat:O},showGrid:G,showCategoryTicks:j,...ee.legendBehaviorProps,...ld({title:V,description:X,summary:U,accessibleTable:K,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:b,defaultTooltipContent:ie}),...cd({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:_,mobileInteraction:ee.mobileInteraction,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior}),...v&&v.length>0&&{annotations:v},...x&&{rExtent:x},...te.brushStreamProps,...Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e))};return Vf(Eu,{componentName:"ViolinPlot",width:H,height:W,children:Vf(rf,{ref:r,...se})})});Xf.displayName="ViolinPlot";import{useMemo as Uf,forwardRef as Kf,useRef as Qf}from"react";import{jsx as Zf}from"react/jsx-runtime";var Jf=Kf(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid??!0,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=Qf(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",valueFormat:d,colorBy:h,colorScheme:p,sort:m="auto",dotRadius:f=5,categoryPadding:g=10,tooltip:y,annotations:b,regression:v,valueExtent:x,frameProps:w={},selection:k,linkedHover:S,onObservation:A,onClick:C,hoverHighlight:M,chartId:P,loading:I,loadingContent:_,emptyContent:L,legendInteraction:R,legendPosition:T,color:N,stroke:$,strokeWidth:B,opacity:D,categoryFormat:F}=e,{width:E,height:z,enableHover:j,showGrid:O,showLegend:H,title:W,description:q,summary:G,accessibleTable:Y,categoryLabel:V,valueLabel:X}=o,U=Uf(()=>u(n),[n]),K=od({data:U,rawData:n,colorBy:h,colorScheme:p,legendInteraction:R,legendPosition:T,selection:k,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DotPlot",chartId:P,showLegend:H,userMargin:i,marginDefaults:o.marginDefaults,loading:I,loadingContent:_,emptyContent:L,width:E,height:z}),Q=ku(U,m,l),Z=vu(),J=Uf(()=>new Map,[U]),ee=lf({colorBy:h,colorScale:K.colorScale,color:N,themeCategorical:Z,colorScheme:p,categoryIndexMap:J,userPieceStyle:w?.pieceStyle,stroke:$,strokeWidth:B,opacity:D,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection,baseStyleExtras:{r:f,fillOpacity:.8}}),te=Uf(()=>Bl({categoryAccessor:s,valueAccessor:l,valueFormat:d}),[s,l,d]);if(K.earlyReturn)return K.earlyReturn;const oe=Xu({componentName:"DotPlot",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(oe)return Zf(Tu,{componentName:"DotPlot",message:oe,width:E,height:z});const re=ih(v),ne=re?[re,...b||[]]:b,ie={chartType:"point",...null!=n&&{data:Q},oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",pieceStyle:ee,size:[E,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:g,enableHover:j,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:V,rLabel:X,rFormat:d,...F&&{oFormat:F},showGrid:O,oSort:m,...K.legendBehaviorProps,...ld({title:W,description:q,summary:G,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:y,defaultTooltipContent:te}),...cd({linkedHover:S,selection:k,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior}),...ne&&ne.length>0&&{annotations:ne},...x&&{rExtent:x},...Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e))};return Zf(Eu,{componentName:"DotPlot",width:E,height:z,children:Zf(rf,{ref:r,...ie})})});Jf.displayName="DotPlot";import{useMemo as eg,forwardRef as tg,useRef as og}from"react";import{jsx as rg}from"react/jsx-runtime";var ng=tg(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=og(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",orientation:c="horizontal",bins:d=20,amplitude:h=1.5,valueFormat:p,colorBy:m,colorScheme:f,categoryPadding:g=5,tooltip:y,annotations:b,valueExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:P,loadingContent:I,emptyContent:_,legendInteraction:L,legendPosition:R,color:T,stroke:N,strokeWidth:$,opacity:B,showCategoryTicks:D,categoryFormat:F}=e,{width:E,height:z,enableHover:j,showGrid:O,showLegend:H,title:W,description:q,summary:G,accessibleTable:Y,categoryLabel:V,valueLabel:X}=o,U=eg(()=>u(n),[n]),K=od({data:U,rawData:n,colorBy:m,colorScheme:f,legendInteraction:L,legendPosition:R,selection:w,linkedHover:k,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"RidgelinePlot",chartId:M,showLegend:H,userMargin:i,marginDefaults:o.marginDefaults,loading:P,loadingContent:I,emptyContent:_,width:E,height:z}),Q=vu(),Z=eg(()=>new Map,[U]),J=lf({colorBy:m,colorScale:K.colorScale,color:T,themeCategorical:Q,colorScheme:f,categoryIndexMap:Z,userPieceStyle:void 0,stroke:N,strokeWidth:$,opacity:B,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),ee=eg(()=>$f(),[]);if(K.earlyReturn)return K.earlyReturn;const te=Xu({componentName:"RidgelinePlot",data:n,accessors:{categoryAccessor:s,valueAccessor:l}});if(te)return rg(Tu,{componentName:"RidgelinePlot",message:te,width:E,height:z});const oe={chartType:"ridgeline",...null!=n&&{data:U},oAccessor:s,rAccessor:l,projection:"horizontal"===c?"horizontal":"vertical",summaryStyle:J,bins:d,size:[E,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:g,enableHover:j,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:V,rLabel:X,rFormat:p,...F&&{oFormat:F},showGrid:O,showCategoryTicks:D,oSort:!1,amplitude:h,...K.legendBehaviorProps,...ld({title:W,description:q,summary:G,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:y,defaultTooltipContent:ee}),...cd({linkedHover:k,selection:w,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior}),...b&&b.length>0&&{annotations:b},...v&&{rExtent:v},...Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e))};return rg(Eu,{componentName:"RidgelinePlot",width:E,height:z,children:rg(rf,{ref:r,...oe})})});ng.displayName="RidgelinePlot";import{useMemo as ig,forwardRef as ag,useRef as sg}from"react";import{jsx as lg}from"react/jsx-runtime";var cg=ag(function(e,t){const o=Iu(e.mode,{width:e.width??400,height:e.height??400,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,showCategoryTicks:e.showCategoryTicks,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=sg(null),{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",colorBy:c,colorScheme:d,startAngle:h=0,cornerRadius:p,tooltip:m,annotations:f,frameProps:g={},selection:y,linkedHover:b,onObservation:v,onClick:x,hoverHighlight:w,chartId:k,loading:S,loadingContent:A,emptyContent:C,legendInteraction:M,legendPosition:P,color:I,stroke:_,strokeWidth:L,opacity:R}=e,{width:T,height:N,enableHover:$,showLegend:B,title:D,description:F,summary:E,accessibleTable:z}=o,j=ig(()=>u(n),[n]),O=c||s,H=od({data:j,rawData:n,colorBy:O,colorScheme:d,legendInteraction:M,legendPosition:P,selection:y,linkedHover:b,fallbackFields:O?["string"==typeof O?O:""]:[],unwrapData:!0,onObservation:v,onClick:x,hoverHighlight:w,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"PieChart",chartId:k,showLegend:B,userMargin:i,marginDefaults:o.marginDefaults,loading:S,loadingContent:A,emptyContent:C,width:T,height:N}),W=vu(),q=ig(()=>new Map,[j]),G=lf({colorBy:O,colorScale:H.colorScale,color:I,themeCategorical:W,colorScheme:d,categoryIndexMap:q,userPieceStyle:g?.pieceStyle,stroke:_,strokeWidth:L,opacity:R,effectiveSelectionHook:H.effectiveSelectionHook,resolvedSelection:H.resolvedSelection,cycleByCategory:!0}),Y=ig(()=>Bl({categoryAccessor:s,valueAccessor:l,groupAccessor:c&&c!==s?c:void 0,groupLabel:"string"==typeof c?c:"group",pieData:!0}),[s,l,c]),V=Xu({componentName:"PieChart",data:n,accessors:{categoryAccessor:s,valueAccessor:l}}),{effectiveLegendProps:X,effectiveMargin:U}=af({ref:t,frameRef:r,setup:H});if(H.earlyReturn)return H.earlyReturn;const K={chartType:"pie",...null!=n&&{data:j},oAccessor:s,rAccessor:l,projection:"radial",pieceStyle:G,startAngle:h,...null!=p&&{cornerRadius:p},size:[T,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U,enableHover:$,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...X,...ld({title:D,description:F,summary:E,accessibleTable:z,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:m,defaultTooltipContent:Y}),...cd({linkedHover:b,selection:y,onObservation:v,onClick:x,hoverHighlight:w,mobileInteraction:H.mobileInteraction,customHoverBehavior:H.customHoverBehavior,customClickBehavior:H.customClickBehavior}),...f&&f.length>0&&{annotations:f},...Object.fromEntries(Object.entries(g).filter(([e])=>"pieceStyle"!==e))};return V?lg(Tu,{componentName:"PieChart",message:V,width:T,height:N}):lg(Eu,{componentName:"PieChart",width:T,height:N,children:lg(rf,{ref:r,...K})})});cg.displayName="PieChart";import{useMemo as ug,forwardRef as dg,useRef as hg}from"react";import{jsx as pg}from"react/jsx-runtime";var mg=dg(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,showCategoryTicks:e.showCategoryTicks,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:400,height:400}),r=hg(null),{data:n,margin:i,className:a,categoryAccessor:s="category",valueAccessor:l="value",innerRadius:c,centerContent:d,colorBy:h,colorScheme:p,startAngle:m=0,cornerRadius:f,tooltip:g,annotations:y,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:_,color:L,stroke:R,strokeWidth:T,opacity:N}=e,{width:$,height:B,enableHover:D,showLegend:F,title:E,description:z,summary:j,accessibleTable:O}=o,H=ug(()=>u(n),[n]),W=h||s,q=od({data:H,rawData:n,colorBy:W,colorScheme:p,legendInteraction:I,legendPosition:_,selection:v,linkedHover:x,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DonutChart",chartId:A,showLegend:F,userMargin:i,marginDefaults:o.marginDefaults,loading:C,loadingContent:M,emptyContent:P,width:$,height:B}),G=c??Math.max(2,.15*Math.min($,B)),Y=vu(),V=ug(()=>new Map,[H]),X=lf({colorBy:W,colorScale:q.colorScale,color:L,themeCategorical:Y,colorScheme:p,categoryIndexMap:V,userPieceStyle:b?.pieceStyle,stroke:R,strokeWidth:T,opacity:N,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),U=ug(()=>Bl({categoryAccessor:s,valueAccessor:l,groupAccessor:h&&h!==s?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[s,l,h]),K=Xu({componentName:"DonutChart",data:n,accessors:{categoryAccessor:s,valueAccessor:l}}),{effectiveLegendProps:Q,effectiveMargin:Z}=af({ref:t,frameRef:r,setup:q});if(q.earlyReturn)return q.earlyReturn;const J={chartType:"donut",...null!=n&&{data:H},oAccessor:s,rAccessor:l,projection:"radial",pieceStyle:X,innerRadius:G,startAngle:m,...null!=f&&{cornerRadius:f},centerContent:d,size:[$,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Z,enableHover:D,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...Q,...ld({title:E,description:z,summary:j,accessibleTable:O,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:g,defaultTooltipContent:U}),...cd({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:q.mobileInteraction,customHoverBehavior:q.customHoverBehavior,customClickBehavior:q.customClickBehavior}),...y&&y.length>0&&{annotations:y},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return K?pg(Tu,{componentName:"DonutChart",message:K,width:$,height:B}):pg(Eu,{componentName:"DonutChart",width:$,height:B,children:pg(rf,{ref:r,...J})})});mg.displayName="DonutChart";import{useMemo as fg,forwardRef as gg,useRef as yg}from"react";function bg(e=240){const t=360-e,o=180+t/2,r=o*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:o,startAngleRad:r,offsetRad:-Math.PI/2+r}}function vg(e){return Math.max(0,Math.min(1,e))}function xg(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function wg(e,t,o){const r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(o)}`}function kg(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:vg(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const r=vg(t);if(o[0].offset>=r)return o[0].color;if(r>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1];if(t.offset>r||r>n.offset)continue;const i=n.offset-t.offset,a=i>0?(r-t.offset)/i:0,s=xg(t.color),l=xg(n.color);if(!s||!l)return.5>a?t.color:n.color;const[c,u,d]=s,[h,p,m]=l;return wg(c+(h-c)*a,u+(p-u)*a,d+(m-d)*a)}return o[o.length-1].color}function Sg(e,t,o){return null==o?`${e}-${t}`:`${e}-${t}-${o}`}import{jsx as Ag,jsxs as Cg}from"react/jsx-runtime";var Mg=gg(function(e,t){const r=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:!1,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:300,height:250}),n=yg(null),i="context"===e.mode,{compactMode:a}=r,{value:s,min:l=0,max:c=100,thresholds:u,gradientFill:d,color:h,backgroundColor:p="var(--semiotic-grid, #e0e0e0)",arcWidth:m=.3,cornerRadius:f,showNeedle:g=!0,needleColor:y="var(--semiotic-text, #333)",centerContent:b,valueFormat:v,showScaleLabels:x=!a,sweep:w=240,fillZones:k=!0,tooltip:S,annotations:A,frameProps:C={},className:M,stroke:P,strokeWidth:I,opacity:_}=e,{width:L,height:R,title:T,description:N,summary:$,accessibleTable:B}=r,D=d&&"object"==typeof d?d:void 0,F=Math.max(l,Math.min(c,s)),E=c-l||1,z=(F-l)/E,{gaugeData:j,pieceStyle:O,gaugeAnnotations:H}=fg(()=>function(e){const{min:t,max:o,value:r,thresholds:n,fillColor:i,backgroundColor:a,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=o-t||1,h=(Math.max(t,Math.min(o,r))-t)/d;let p=n&&n.length>0?[...n].sort((e,t)=>e.value-t.value):[{value:o,color:i||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(o,e.value))})),o>p[p.length-1].value&&p.push({value:o,color:p[p.length-1].color});const m=!!c&&c.colorStops.length>=2,f=[],g=new Map,y=[];if(m){const e=s?h:1,t=Sg("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:a,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),o=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;o>t;t++)r.push(kg(c.colorStops,e*(t+.5)/o));const n=Sg("fill",0);f.push({category:n,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),g.set(n,{fill:r[0]||a})}}else{let e=t;for(let o=0;p.length>o;o++){const r=p[o],n=(r.value-e)/d,i=(e-t)/d,l=(r.value-t)/d,c=Math.max(0,(s?Math.min(h,l):l)-i),u=s?Math.max(0,n-c):0;if(c>0){const e=Sg("fill",o);f.push({category:e,value:c,_zone:r.label||"Zone "+(o+1),_isFill:!0}),g.set(e,{fill:r.color})}if(u>0){const e=Sg("bg",o);f.push({category:e,value:u,_zone:r.label||"Zone "+(o+1),_isFill:!1}),g.set(e,{fill:a,opacity:.4})}e=r.value}}if(l&&n&&n.length>0)for(const e of n)e.value>t&&o>e.value&&y.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:a},gaugeAnnotations:y}}({min:l,max:c,value:s,thresholds:u,fillColor:h,backgroundColor:p,fillZones:k,showScaleLabels:x,gradientFill:D}),[s,l,c,u,h,p,x,k,D]),W=fg(()=>nd(O,{stroke:P,strokeWidth:I,opacity:_}),[O,P,I,_]),{sweepRad:q,startAngleDeg:G}=bg(w),Y=function(e=240){const{sweepRad:t,offsetRad:r}=bg(e),n=[[Math.cos(r),Math.sin(r)],[Math.cos(r+t),Math.sin(r+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-r)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||n.push([Math.cos(e),Math.sin(e)]);const i=n.map(e=>e[0]),a=n.map(e=>e[1]),[s,l]=o(i),[c,u]=o(a);return{minX:s,maxX:l,minY:c,maxY:u,width:l-s,height:u-c,cx:(s+l)/2,cy:(c+u)/2}}(w),V=Math.min(10,Math.max(1,Math.min(L,R)/12)),X=Y.cx,U=Y.cy,K=Math.max(4,Math.min((L-2*V)/Y.width,(R-2*V)/Y.height)-2),Q=Math.max(0,Math.min(K-1.5,K*(1-m))),Z=L/2-X*K,J=R/2-U*K,ee=2*(K+4),te=fg(()=>{if(a&&null==b)return null;if(null!=b)return"function"==typeof b?b(F,l,c):b;const e=v?v(F):Math.round(F)+"";return Cg("div",{style:{textAlign:"center",lineHeight:1.2},children:[Ag("div",{style:{fontSize:Math.max(16,.3*K),fontWeight:700,color:"var(--semiotic-text, #333)"},children:e}),x&&Cg("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[l," – ",c]})]})},[b,F,l,c,v,x,K,a]),oe=fg(()=>i&&null==b?{type:"gauge-value",text:v?v(F):Math.round(F)+""}:null,[i,b,F,v]),re=fg(()=>{if(!g)return null;const e=-Math.PI/2+G*Math.PI/180+z*q,t=Q>20?Q-8:K-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:y}},[g,z,G,q,Q,y]),ne=fg(()=>(e,t,o)=>{if("gauge-needle"===e.type){const r=(o.width||L)/2,n=(o.height||R)/2,i=Math.max(1,K-Q),a=Math.max(1,Math.min(2.5,.4*i)),s=Math.max(1,Math.min(5,.6*i));return Cg("g",{transform:`translate(${r},${n})`,children:[Ag("line",{x1:0,y1:0,x2:e.tipX,y2:e.tipY,stroke:e.color,strokeWidth:a,strokeLinecap:"round"}),Ag("circle",{cx:0,cy:0,r:s,fill:e.color})]},"gauge-needle-"+t)}if("gauge-label"===e.type){const r=-Math.PI/2+G*Math.PI/180+(e.value-l)/E*q,n=(o.width||L)/2,i=(o.height||R)/2,a=Q-1,s=K+1,c=Math.cos(r)*a,u=Math.sin(r)*a,d=Math.cos(r)*s,h=Math.sin(r)*s,p=K+10,m=Math.cos(r)*p,f=Math.sin(r)*p,g=((r+Math.PI/2)/(2*Math.PI)*12+12)%12;let y,b;return g>=11||1>g?(y="middle",b="auto"):g>=1&&5>g?(y="start",b="middle"):g>=5&&7>g?(y="middle",b="hanging"):(y="end",b="middle"),Cg("g",{transform:`translate(${n},${i})`,children:[Ag("line",{x1:c,y1:u,x2:d,y2:h,stroke:"var(--semiotic-border)",strokeWidth:2,strokeLinecap:"round"}),Ag("text",{x:m,y:f,textAnchor:y,dominantBaseline:b,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none",fontSize:"var(--semiotic-gauge-label-font-size, 10px)"},children:e.label})]},"gauge-label-"+t)}return"gauge-value"===e.type?Ag("text",{x:(o.width||L)/2,y:(o.height||R)/2-.2*Q,textAnchor:"middle",dominantBaseline:"middle",fontSize:Math.max(12,Math.min(22,.28*K)),fontWeight:700,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:e.text},"gauge-value-"+t):null},[L,R,l,E,G,q,Q,K]),ie=fg(()=>{const e=[...H,...A||[]];return re&&e.push(re),oe&&e.push(oe),e},[H,A,re,oe]),ae=fg(()=>e=>{const t=e?.data?.[0]||e?.data||e,o=t?._zone||"",r=t?._isFill;return Cg("div",{className:"semiotic-tooltip",style:{padding:"6px 10px",background:"var(--semiotic-tooltip-bg, white)",borderRadius:"var(--semiotic-tooltip-radius, 6px)",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0,0,0,0.15))"},children:[Ag("div",{style:{fontWeight:600},children:o}),Ag("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:r?"Current: "+Math.round(F):"Remaining"})]})},[F]);if(0===j.length)return Ag(Tu,{componentName:"GaugeChart",message:"No data to display",width:L,height:R});const se={chartType:"donut",data:j,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:W,innerRadius:Q,startAngle:G,sweepAngle:w,...null!=f&&{cornerRadius:f},centerContent:te,size:[L,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:{top:J-ee/2,bottom:R-J-ee/2,left:Z-ee/2,right:L-Z-ee/2},enableHover:r.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===S?()=>null:xs(S)||ae,svgAnnotationRules:ne,...ie.length>0&&{annotations:ie},...T&&{title:T},...N&&{description:N},...$&&{summary:$},...void 0!==B&&{accessibleTable:B},...M&&{className:M},...null!=e.animate&&{animate:e.animate},...C};return Ag(Eu,{componentName:"GaugeChart",width:L,height:R,children:Ag(rf,{ref:n,...se})})});Mg.displayName="GaugeChart";import{useMemo as Pg,forwardRef as Ig,useRef as _g}from"react";import{jsx as Lg,jsxs as Rg}from"react/jsx-runtime";var Tg=Ig(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:!1,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,showCategoryTicks:!1,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=_g(null);sd(t,{variant:"xy",frameRef:r});const{data:n,margin:i,className:a,stepAccessor:s="step",valueAccessor:l="value",categoryAccessor:c,colorBy:d,colorScheme:h,orientation:p="horizontal",connectorOpacity:m=.3,showLabels:f=!0,tooltip:g,annotations:y,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:_,color:L,stroke:R,strokeWidth:T,opacity:N,categoryFormat:$}=e,B="vertical"===p,{width:D,height:F,enableHover:E,showLegend:z,title:j,description:O,summary:H,accessibleTable:W}=o,q=B?{top:j?60:40,right:20,bottom:60,left:60}:{top:j?40:10,right:10,bottom:10,left:10},G=Pg(()=>u(n),[n]),Y=d||c,V=!Y,X=od({data:G,rawData:n,colorBy:Y,colorScheme:h,legendInteraction:I,legendPosition:_,selection:v,linkedHover:x,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"FunnelChart",chartId:A,showLegend:z,userMargin:i,marginDefaults:q,loading:C,loadingContent:M,emptyContent:P,width:D,height:F});Wu("FunnelChart",G,"stepAccessor",s),Wu("FunnelChart",G,"valueAccessor",l);const U=vu(),K=Pg(()=>new Map,[G]),Q=Pg(()=>{if(V)return L||(U?.[0]?U[0]:Array.isArray(h)&&h[0]?h[0]:"#4e79a7")},[V,L,U,h]),Z=lf({colorBy:Q?void 0:Y,colorScale:X.colorScale,color:Q??L,themeCategorical:U,colorScheme:h,categoryIndexMap:K,userPieceStyle:b?.pieceStyle,stroke:R,strokeWidth:T,opacity:N,effectiveSelectionHook:X.effectiveSelectionHook,resolvedSelection:X.resolvedSelection}),J=Pg(()=>e=>{const t=e?.data||e,o=t?.__funnelStep||t?.__barFunnelStep||t?.step||"",r=t?.__funnelValue??t?.__barFunnelValue??t?.value??"",n=t?.__funnelPercent??t?.__barFunnelPercent,i=t?.__funnelIsFirstStep??t?.__barFunnelIsFirstStep,a=t?.__barFunnelIsDropoff,s=t?.__barFunnelCategory??t?.category,l=null==n||i?"":` (${.05>Math.abs(n-Math.round(n))?Math.round(n)+"%":n.toFixed(1)+"%"})`;return Rg("div",{className:"semiotic-tooltip",style:ms,children:[o&&Lg("div",{style:{fontWeight:"bold"},children:o+""}),s&&s!==o&&Lg("div",{style:{marginTop:2,opacity:.8},children:s+""}),a&&Lg("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),Rg("div",{style:{marginTop:4},children:[r+"",l]})]})},[]);if(X.earlyReturn)return X.earlyReturn;const ee=Xu({componentName:"FunnelChart",data:n,accessors:{stepAccessor:s,valueAccessor:l}});if(ee)return Lg(Tu,{componentName:"FunnelChart",message:ee,width:D,height:F});const te={chartType:B?"bar-funnel":"funnel",...null!=n&&{data:G},oAccessor:s,rAccessor:l,...c&&{stackBy:c},projection:B?"vertical":"horizontal",barPadding:B?40:0,pieceStyle:Z,size:[D,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:X.margin,enableHover:E,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:B,showCategoryTicks:B,...$&&{oFormat:$},showGrid:B,...!B&&{connectorOpacity:m},showLabels:f,...X.legendBehaviorProps,...j&&{title:j},...O&&{description:O},...H&&{summary:H},...void 0!==W&&{accessibleTable:W},...a&&{className:a},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===g?()=>null:!0===g||null==g?J:xs(g)||J,...cd({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:X.mobileInteraction,customHoverBehavior:X.customHoverBehavior,customClickBehavior:X.customClickBehavior}),...y&&y.length>0&&{annotations:y},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return Lg(Eu,{componentName:"FunnelChart",width:D,height:F,children:Lg(rf,{ref:r,...te})})});Tg.displayName="FunnelChart";import*as Ng from"react";import{useMemo as $g,useCallback as Bg,forwardRef as Dg,useRef as Fg,useImperativeHandle as Eg}from"react";import{useRef as zg,useState as jg,useCallback as Og,useMemo as Hg}from"react";import{useMemo as Wg,useCallback as qg,useRef as Gg}from"react";var Yg={RdBu:Le,PiYG:Re,PRGn:Te,BrBG:Ne,RdYlBu:$e,RdYlGn:Be,Spectral:De},Vg="__likert_neutral_neg",Xg="__likert_neutral_pos";function Ug(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function Kg(e,t,o,r,n,i){const a=new Map,s=new Set(t);for(const l of e){const e=o(l);a.has(e)||a.set(e,new Map);const c=a.get(e);if(r){const e=r(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const n=t[o];c.set(n,(c.get(n)||0)+1)}else if(n&&i){const e=n(l),t=i(l);if(!s.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,o]of a){let r=0;for(const e of t)r+=o.get(e)||0;if(0!==r)for(let n=0;t.length>n;n++){const i=t[n],a=o.get(i)||0;l.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:a,__likertPct:a/r*100,__likertLevelIndex:n})}}return l}function Qg(e,t){const o=t.length,r=o%2!=0,n=Math.floor(o/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(r&&e===n){const e=t.__likertPct/2;i.push({...t,__likertLevel:Vg,__likertPct:-e}),i.push({...t,__likertLevel:Xg,__likertPct:e})}else i.push(n>e?{...t,__likertPct:-t.__likertPct}:t)}return i}function Zg(e,t){const o=t.length,r=o%2!=0,n=Math.floor(o/2),i=new Map;for(const t of e){const e=i.get(t.__likertCategory)||[];e.push(t),i.set(t.__likertCategory,e)}const a=[];for(const[,e]of i){const t=new Map;let i,s;for(const o of e)o.__likertLevel===Vg?i=o:o.__likertLevel===Xg?s=o:t.set(o.__likertLevelIndex,o);r&&i&&a.push(i);for(let e=n-1;e>=0;e--){const o=t.get(e);o&&a.push(o)}r&&s&&a.push(s);for(let e=r?n+1:n;o>e;e++){const o=t.get(e);o&&a.push(o)}}return a}var Jg=["Very Low","Low","Neutral","High","Very High"];import{jsx as ey}from"react/jsx-runtime";var ty=new Map,oy=Dg(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=Fg(null),{data:n,margin:i,className:a,categoryAccessor:s="question",valueAccessor:l,levelAccessor:c,countAccessor:u="count",levels:d=Jg,orientation:h="horizontal",colorScheme:p,barPadding:m=20,tooltip:f,annotations:g,valueExtent:y,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,valueFormat:C,loading:M,loadingContent:P,emptyContent:I,legendInteraction:_,legendPosition:L,categoryFormat:R,stroke:T,strokeWidth:N,opacity:$}=e,{width:B,height:D,enableHover:F,showGrid:E,showLegend:z,title:j,description:O,summary:H,accessibleTable:W,categoryLabel:q,valueLabel:G}=o,Y="horizontal"===h,V=void 0===n,X=!c,U=function(){const e=cu();return e?.colors?.diverging||void 0}(),K=$g(()=>p&&Array.isArray(p)&&p.length>=d.length?p:function(e,t){if(0>=e)return[];if(t){const o=Yg[t];if(o){if(1===e)return[o(.5)];const t=[];for(let r=0;e>r;r++)t.push(o(r/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],n="#a8a8a8";if(1===e)return[n];const i=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;a>e;e++)s.push(o[Math.min(Math.floor(e*o.length/a),o.length-1)]);i&&s.push(n);for(let e=0;a>e;e++)s.push(r[Math.min(Math.floor(e*r.length/a),r.length-1)]);return s}(d.length,U),[p,d.length,U]),Q=$g(()=>{const e=new Map;for(let t=0;d.length>t;t++)e.set(d[t],K[t]||"#888");return e},[d,K]),{processedData:Z,reAggregate:J,accumulatorRef:ee}=function({data:e,levels:t,categoryAccessor:o,valueAccessor:r,levelAccessor:n,countAccessor:i,isDiverging:a,frameRef:s}){const l=!n,c=Wg(()=>Ug(o,"question"),[o]),u=Wg(()=>l?Ug(r,"score"):null,[l,r]),d=Wg(()=>l?null:Ug(n,"level"),[l,n]),h=Wg(()=>l?null:Ug(i,"count"),[l,i]),p=e||[],m=Gg([]);return{processedData:Wg(()=>{if(0===p.length)return[];let e=Kg(p,t,c,u,d,h);return a&&(e=Qg(e,t),e=Zg(e,t)),e},[p,t,c,u,d,h,a]),reAggregate:qg(e=>{let o=Kg(e,t,c,u,d,h);a&&(o=Qg(o,t),o=Zg(o,t)),s.current?.replace(o)},[t,c,u,d,h,a,s]),accumulatorRef:m}}({data:n,levels:d,categoryAccessor:s,valueAccessor:l,levelAccessor:c,countAccessor:u,isDiverging:Y,frameRef:r}),te="__likertLevelLabel",oe=function({isPushMode:e,colorBy:t,colorScheme:o,showLegend:r,legendPosition:n="right"}){const i=zg(new Set),a=zg([]),[s,l]=jg(0),c=ic(),u=vu(),d=Og(e=>{if(!t)return null;const o="function"==typeof t?t(e):e[t];return null!=o?o+"":null},[t]),h=Og(o=>{if(!e||!t)return;let r=!1;for(const e of o){if(!e||"object"!=typeof e)continue;const t=d(e);null==t||i.current.has(t)||(i.current.add(t),a.current.push(t),r=!0)}r&&l(e=>e+1)},[e,t,d]),p=Og(o=>{if(!e||!t)return;const r=Array.from(new Set(o.map(String))),n=a.current;n.length===r.length&&n.every((e,t)=>e===r[t])||(i.current=new Set(r),a.current=r,l(e=>e+1))},[e,t]),m=Og(e=>t=>{h([t]),e(t)},[h]),f=Og(e=>t=>{h(t),e(t)},[h]),g=Og(()=>{i.current=new Set,a.current=[],l(e=>e+1)},[]);qc(e&&t?a.current:[]);const y=Hg(()=>{if(!e||!t||!1===r)return;const n=a.current;if(0===n.length)return;const i=Array.isArray(o)&&o.length>0||"string"==typeof o&&o.length>0?o:u&&u.length>0?u:ze,s="string"==typeof t?t:"__streamCat",l=n.map(e=>({[s]:e})),d=qe(l,s,i);return Uc({data:l,colorBy:s,colorScale:e=>c?.[e]||d(e)||"#999",getColor:He})},[e,t,r,o,c,u,s]),b=Hg(()=>{if(y)return"right"===n?{right:110}:"left"===n?{left:110}:"top"===n?{top:50}:"bottom"===n?{bottom:80}:{right:110}},[y,n]);return{wrapPush:m,wrapPushMany:f,resetCategories:g,categories:a.current,categoryDomainProps:e&&t?{legendCategoryAccessor:t,onCategoriesChange:p}:{},streamingLegend:y,streamingMarginAdjust:b}}({isPushMode:V,colorBy:te,colorScheme:K,showLegend:z,legendPosition:L}),re=Bg(oe.wrapPush(e=>{ee.current.push(e),J(ee.current)}),[oe.wrapPush,J,ee]),ne=Bg(oe.wrapPushMany(e=>{ee.current.push(...e),J(ee.current)}),[oe.wrapPushMany,J,ee]);Eg(t,()=>({push:re,pushMany:ne,remove:e=>r.current?.remove(e)??[],update:(e,t)=>r.current?.update(e,t)??[],clear:()=>{ee.current=[],oe.resetCategories(),r.current?.clear()},getData:()=>r.current?.getData()??[],getScales:()=>r.current?.getScales()??null}),[re,ne,oe.resetCategories,ee]);const ie=od({data:Z,rawData:n,colorBy:te,colorScheme:K,legendInteraction:_,legendPosition:L,selection:v,linkedHover:x,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"LikertChart",chartId:A,showLegend:z,userMargin:i,marginDefaults:o.marginDefaults,loading:M,loadingContent:P,emptyContent:I,width:B,height:D}),ae=$g(()=>{const e=d.length;return e%2!=0&&Q.get(d[Math.floor(e/2)])||"#888"},[d,Q]),se=lf({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:ty,userPieceStyle:b?.pieceStyle,stroke:T,strokeWidth:N,opacity:$,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection,baseStyleExtras:e=>{const t=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertLevel||e.data?.__likertLevel;if(o===Vg||o===Xg)return{fill:ae};const r=t||o;return r&&Q.has(r)?{fill:Q.get(r)}:{fill:"#888"}}}),le=$g(()=>{const e=d.length;return e%2!=0?d[Math.floor(e/2)]:""},[d]),ce=$g(()=>e=>{const t=e.data||e,o=t.__likertLevel||"Unknown",r=o===Vg||o===Xg?le:o,n=t.__likertCategory||"",i=Math.abs(t.__likertPct||0),a=o===Vg||o===Xg?2*i:i,s=t.__likertCount||0;return Ng.createElement("div",{className:"semiotic-tooltip",style:ms},Ng.createElement("div",{style:{fontWeight:"bold"}},n),Ng.createElement("div",{style:{marginTop:4}},`${r}: ${a.toFixed(1)}% (n=${s})`))},[le]),ue=$g(()=>{if(!d||2>d.length)return"LikertChart requires `levels` with at least 2 entries.";if(l&&c)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(c&&!u)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==n&&0===n.length)return null;const e={categoryAccessor:s};return X?l&&(e.valueAccessor=l):(c&&(e.levelAccessor=c),u&&(e.countAccessor=u)),Xu({componentName:"LikertChart",data:n,accessors:e,requiredProps:{levels:d}})},[n,s,l,c,u,d,X]),de=$g(()=>[{styleFn:e=>({fill:Q.get(e.label)||"#888"}),items:d.map(e=>({label:e})),label:""}],[d,Q]),he=$g(()=>!1!==z?{...ie.legendBehaviorProps,legend:{legendGroups:de},legendPosition:L||ie.legendPosition||"bottom"}:ie.legendBehaviorProps,[ie.legendBehaviorProps,ie.legendPosition,L,z,de]),pe=$g(()=>{const e={...ie.margin};if(V&&!1!==z){const t=L||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(oe.streamingMarginAdjust)for(const[t,o]of Object.entries(oe.streamingMarginAdjust))o>e[t]&&(e[t]=o);return Y&&100>e.left&&(e.left=100),e},[ie.margin,oe.streamingMarginAdjust,Y,V,z,L]),me=$g(()=>C||(Y?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[Y,C]);if(ie.earlyReturn)return ie.earlyReturn;const fe={chartType:"bar",...null!=n&&{data:Z},oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:Y?"horizontal":"vertical",pieceStyle:se,size:[B,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:pe,barPadding:m,enableHover:F,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:q,rLabel:G||(Y?void 0:"Percentage"),rFormat:me,...R&&{oFormat:R},showGrid:E,...he,...j&&{title:j},...O&&{description:O},...H&&{summary:H},...void 0!==W&&{accessibleTable:W},...a&&{className:a},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:!1===f?()=>null:!0===f?ce:xs(f)||ce,...cd({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:ie.mobileInteraction,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior}),...g&&g.length>0&&{annotations:g},...y&&{rExtent:y},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return ue?ey(Tu,{componentName:"LikertChart",message:ue,width:B,height:D}):ey(Eu,{componentName:"LikertChart",width:B,height:D,children:ey(rf,{ref:r,...fe})})});oy.displayName="LikertChart";import{useMemo as ry,forwardRef as ny,useRef as iy}from"react";import{jsx as ay}from"react/jsx-runtime";var sy=ny(function(e,t){const o=Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,categoryLabel:e.categoryLabel,valueLabel:e.valueLabel,showCategoryTicks:e.showCategoryTicks,orientation:e.orientation,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),r=iy(null),{data:n,margin:i,className:a,categoryAccessor:s="category",subcategoryAccessor:l,valueAccessor:c="value",orientation:d="horizontal",valueFormat:h,colorBy:p,colorScheme:m,barPadding:f,tooltip:g,annotations:y,brush:b,onBrush:v,linkedBrush:x,frameProps:w={},selection:k,linkedHover:S,onObservation:A,onClick:C,hoverHighlight:M,chartId:P,loading:I,loadingContent:_,emptyContent:L,legendInteraction:R,legendPosition:T,color:N,stroke:$,strokeWidth:B,opacity:D,categoryFormat:F,rTickValues:E,tickLabelEdgeAlign:z,showCategoryTicks:j,gradientFill:O,trackFill:H,roundedTop:W,valueExtent:q}=e,{width:G,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=o,oe=ry(()=>u(n),[n]),re=p||l,ne=ry(()=>{if(null!=f)return f;if("sparkline"!==e.mode)return 40;const t=new Set(oe.map(e=>"function"==typeof s?s(e):e[s])),o=Math.max(1,t.size);return o>1?Math.max(0,Math.min(1,(("horizontal"===d?Y:G)-2*o)/(o-1))):1},[f,e.mode,oe,s,d,G,Y]),ie=od({data:oe,rawData:n,colorBy:re,colorScheme:m,legendInteraction:R,legendPosition:T,selection:k,linkedHover:S,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!0,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"SwimlaneChart",chartId:P,showLegend:U,userMargin:i,marginDefaults:o.marginDefaults,loading:I,loadingContent:_,emptyContent:L,width:G,height:Y}),ae=Mf({brushProp:b,onBrushProp:v,linkedBrush:x,valueAccessor:c}),se=vu(),le=ry(()=>new Map,[oe]),ce=lf({colorBy:re,colorScale:ie.colorScale,color:N,themeCategorical:se,colorScheme:m,categoryIndexMap:le,userPieceStyle:w?.pieceStyle,stroke:$,strokeWidth:B,opacity:D,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection,cycleByCategory:!0}),ue=ry(()=>Bl({categoryAccessor:l,valueAccessor:c,groupAccessor:s,valueFormat:h}),[l,s,c,h]),de=Xu({componentName:"SwimlaneChart",data:n,accessors:{categoryAccessor:s,valueAccessor:c,subcategoryAccessor:l},requiredProps:{subcategoryAccessor:l}}),{effectiveLegendProps:he,effectiveMargin:pe}=af({ref:t,frameRef:r,setup:ie});if(ie.earlyReturn)return ie.earlyReturn;const me={chartType:"swimlane",...null!=n&&{data:oe},oAccessor:s,rAccessor:c,stackBy:l,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ce,size:[G,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:pe,barPadding:ne,enableHover:V,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:!1===j?void 0:ee,rLabel:te,rFormat:h,...E&&{rTickValues:E},...null!=z&&{tickLabelEdgeAlign:z},...F&&{oFormat:F},...void 0!==j&&{showCategoryTicks:j},showGrid:X,...he,...ld({title:K,description:Q,summary:Z,accessibleTable:J,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...ud({tooltip:g,defaultTooltipContent:ue}),...cd({linkedHover:S,selection:k,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:ie.mobileInteraction,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior}),...y&&y.length>0&&{annotations:y},...O&&{gradientFill:!0===O?{topOpacity:.8,bottomOpacity:.05}:O},...null!=H&&{trackFill:H},...null!=W&&{roundedTop:W},...q&&{rExtent:q},...ae.brushStreamProps,...Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e))};return de?ay(Tu,{componentName:"SwimlaneChart",message:de,width:G,height:Y}):ay(Eu,{componentName:"SwimlaneChart",width:G,height:Y,children:ay(rf,{ref:r,...me})})});sy.displayName="SwimlaneChart";import{useMemo as ly,forwardRef as cy,useRef as uy}from"react";import{useRef as dy,useState as hy,useEffect as py,useMemo as my,useCallback as fy,useImperativeHandle as gy,forwardRef as yy,memo as by}from"react";var vy={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},xy={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},wy=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const o=this.particles[t];return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,o,r){for(let n=0;this.capacity>n;n++){const i=this.particles[n];if(!i.active)continue;const a=o[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?ky(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(n))):(i.active=!1,this._freeIndices.push(n))}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let o=0;e>o;o++)t.length>o?this.particles[o]=t[o]:(this.particles[o]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(o));this.capacity=e}};function ky(e,t,o,r){if(e.circular&&e.segments)return void function(e,t,o,r,n){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];Sy(c,u,d,h,l,n);const p=h.x-c.x,m=h.y-c.y,f=Math.sqrt(p*p+m*m);if(f>.001){const e=p/f;n.x+=-m/f*o*r*2,n.y+=e*o*r*2}}(e.segments,t,o,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[n,i,a,s]=e.points;Sy(n,i,a,s,t,r);const l=s.x-n.x,c=s.y-n.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*o*e.halfWidth*2,r.y+=t*o*e.halfWidth*2}}function Sy(e,t,o,r,n,i){const a=1-n,s=a*a,l=s*a,c=n*n,u=c*n;i.x=l*e.x+3*s*n*t.x+3*a*c*o.x+u*r.x,i.y=l*e.y+3*s*n*t.y+3*a*c*o.y+u*r.y}function Ay(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function Cy(e,t){var o,r=[],n=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(n.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===o?(u(o,n),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return n.pop(),d}function u(e,o){var n=[].concat(o).concat(e);t?t(n):r.push(n)}function d(t){!function(t){for(var o=0;e.length>o;o++)o>=t&&e[o]||(e[o]=[]),e[o]=e[o].filter(function(e){return e>=t})}(t);for(var o,r=function(e){for(var t=e.length,o=Array(t),r=Array(t),n=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)o[l]=-1,r[l]=0,n[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function p(t){var l=[t],c=[t];for(o[t]=r[t]=u,n[t]=!0,u+=1;c.length>0;){var p=e[t=c[c.length-1]];if(p.length>i[t]){for(var m=i[t];p.length>m;++m){var f=p[m];if(0>o[f]){o[f]=r[f]=u,n[f]=!0,u+=1,l.push(f),c.push(f);break}n[f]&&(r[t]=0|Math.min(r[t],r[f])),0>a[f]||s[t].push(a[f])}i[t]=m}else{if(r[t]===o[t]){var g=[],y=[],b=0;for(m=l.length-1;m>=0;--m){var v=l[m];if(n[v]=!1,g.push(v),y.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){l.length=m;break}}d.push(g);var x=Array(b);for(m=0;y.length>m;m++)for(var w=0;y[m].length>w;w++)x[--b]=y[m][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>o[l]&&p(l);for(l=0;h.length>l;l++){var m=h[l];if(0!==m.length){m.sort(function(e,t){return e-t}),c=[m[0]];for(var f=1;m.length>f;f++)m[f]!==m[f-1]&&c.push(m[f]);h[l]=c}}return{components:d,adjacencyList:h}}(e),n=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)i>n[a][s]&&(i=n[a][s],o=a);var l=n[o];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}o=0;for(var h=e.length;h>o;){var p=d(o);if(o=p.leastVertex,s=p.adjList){for(var m=0;s.length>m;m++)for(var f=0;s[m].length>f;f++){var g=s[m][f];i[+g]=!1,a[g]={}}c(o),o+=1}else o=h}return t?void 0:r}function My(e){return e.y0-e.y1>0?"up":"down"}function Py(e,t){return t(e.source)==t(e.target)}function Iy(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var o=0;return e.target.targetLinks.forEach(function(e){o=e.circular?o+1:o}),1>=t&&1>=o}function _y(e){return e.target.x0-e.source.x1}function Ly(e,t){var o=Ty(e),r=_y(t)/Math.tan(o);return"up"==My(e)?e.y1-r:e.y1+r}function Ry(e,t){var o=Ty(e),r=_y(t)/Math.tan(o);return"up"==My(e)?e.y1+r:e.y1-r}function Ty(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ny(e,t){return t(e)}function $y(e){return Dy(e.source)}function By(e){return Dy(e.target)}function Dy(e){return(e.y0+e.y1)/2}function Fy(e){return e.virtual?0:e.value}function Ey(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!Py(e,t)?o+1:o});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!Py(e,t)?r+1:r}),o+r}function zy(e){return e.target.depth}function jy(e,t){return e.sourceLinks.length?e.depth:t-1}function Oy(e,t){return e.y0-t.y0}function Hy(e,t){return t.y0-e.y0}function Wy(e,t){return e.y1-t.y1}function qy(e,t){return t.y1-e.y1}function Gy(e,t){return Vy(e.source,t.source)||e.index-t.index}function Yy(e,t){return Vy(e.target,t.target)||e.index-t.index}function Vy(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Xy(e,t){return Uy(e)==Uy(t)?"bottom"==e.circularLinkType?Hy(e,t):Oy(e,t):Uy(t)-Uy(e)}function Uy(e){return e.target.column-e.source.column}function Ky(e,t){return Qy(e)==Qy(t)}function Qy(e){return e.y0-e.y1>0?"up":"down"}import{min as Zy}from"d3-array";function Jy(e,t,o,r,n){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=Zy(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),eb(i.links.filter(function(e){return"top"==e.circularLinkType}),t,o),eb(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,o),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Py(e,t)&&Iy(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+n+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-n-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Hy:Oy);var u=0;c.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+n*o+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?qy:Wy),u=0,c.forEach(function(t,n){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+n*o+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+n+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-n-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,o=e.y0,r=e.target.x0,n=e.y1,i=(t+r)/2;return"M"+t+","+o+"C"+i+","+o+" "+i+","+n+" "+r+","+n}(e)}),i}function eb(e,t,o){e.sort(Xy);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,n){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Py(e,t)&&Iy(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&tb(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+o;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function tb(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as ob,max as rb,sum as nb,mean as ib,group as ab,groups as sb}from"d3-array";function lb(e){return function(){return e}}function cb(e){return e.index}function ub(e){return e.nodes}function db(e){return e.links}function hb(e,t,o){var r=sb(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(n,i){var a=n.length;if(t)n.sort(t);else if(i>0){var s=new Map;n.forEach(function(e,t){var o,r,n,i=(r=0,n=0,(o=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;n+=Dy(e.source)*t,r+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;n+=Dy(e.target)*t,r+=t}}),r>0?n/r:NaN);s.set(e,{bc:i,idx:t})}),n.sort(function(e,t){var o=s.get(e),r=s.get(t),n=o.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(n)||isNaN(i)?isNaN(n)?isNaN(i)?o.idx-r.idx:1:-1:n-i})}else n.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Ey(t,o)-Ey(e,o):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});n.forEach(function(t,n){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Ey(t,o)?(t.y0=e.y1/2+n,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+n,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-n,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*n,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+n,t.y1=t.y0+t.value*e.ky)})})}function pb(e,t,o,r,n,i){var a=sb(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,o),u();function c(t,o){var r=a.length;a.forEach(function(n){var i=n.length,a=n[0].depth;n.forEach(function(n){var s;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&Ey(n,o)>0){var l=ib(n.sourceLinks,By),c=ib(n.targetLinks,$y),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Dy(n))*t*.3;n.y0+=d,n.y1+=d}}else if(0==a&&1==i)n.y0=e.y1/2-(s=n.y1-n.y0)/2,n.y1=e.y1/2+s/2;else if(a==r-1&&1==i)n.y0=e.y1/2-(s=n.y1-n.y0)/2,n.y1=e.y1/2+s/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)s=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+s;else{var h=ib(n.sourceLinks,By),p=ib(n.targetLinks,$y),m=((h&&p?(h+p)/2:h||p)-Dy(n))*t;n.y0+=m,n.y1+=m}})})}function u(){a.forEach(function(o){var i,a,s,l=e.y0,c=o.length;for(o.sort(t||Vy),s=0;c>s;++s)(a=l-(i=o[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+r;if((a=l-r-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=o[s]).y1+n-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function mb(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Yy),e.targetLinks.sort(Gy)}),e.nodes.forEach(function(e){var t=e.y0,o=t,r=e.y1,n=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=n-e.width/2,n-=e.width):(e.y1=o+e.width/2,o+=e.width)})})}function fb(){var e=0,t=0,o=1,r=1,n=24,i=8,a=null,s=cb,l=jy,c=void 0,u=32,d=2,h=ub,p=db;function m(){var m={nodes:h.apply(null,arguments),links:p.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=o,h.y1=r,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var o=function(e,t){var o=new Map;return ab(e,t).forEach(function(e,t){o.set(t,e[0])}),o}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,n=e.target;"object"!=typeof r&&(r=e.source=Ay(o,r)),"object"!=typeof n&&(n=e.target=Ay(o,n)),r.sourceLinks.push(e),n.targetLinks.push(e)})}(h,s),function(e,t){var o=0;if(null==t){for(var r=[],n=0;e.links.length>n;n++){var i=e.links[n],a=i.source.index,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=Cy(r);l.sort(function(e,t){return e.length-t.length});var c={};for(n=0;l.length>n;n++){var u=l[n].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=o++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=o++)})}(h,c),function(e,t){var o=0,r=0;e.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:r>o?"top":"bottom","top"==n.circularLinkType?o++:r++,e.nodes.forEach(function(e){Ny(e,t)!=Ny(n.source,t)&&Ny(e,t)!=Ny(n.target,t)||(e.circularLinkType=n.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Py(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(nb(e.sourceLinks,Fy),nb(e.targetLinks,Fy)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,o){var r,n,i;if(null!=t){e.nodes.sort(function(e,o){return t(e)<t(o)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,n=[],i=0;r.length;++i,r=n,n=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>n.indexOf(e.target)&&!e.circular&&n.push(e.target)})});for(r=e.nodes,n=[],i=0;r.length;++i,r=n,n=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>n.indexOf(e.source)&&!e.circular&&n.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?o(e,i):e.column})}(h,c,l);var p=i;if(null!==a){var m=sb(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),f=rb(m,function(e){return e.length});f>1&&(p=Math.max(1,(r-t)*a/(f-1)))}(function(e,t,o){var r=sb(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var n=ob(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/nb(t,function(e){return e.value})});e.ky=n,e.links.forEach(function(t){t.width=t.value*e.ky});var i=rb(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-o)/i),t.x1=t.x0+o}:function(t){t.x0=e.x0,t.x1=t.x0+o})})(h,p,n),hb(h,c,s),pb(h,c,s,p,p,u),mb(h),Jy(h,s,d,10,8),hb(h,c,s),pb(h,c,s,p,p,u),mb(h),Jy(h,s,d,10,8),function(e,t){let o=e;o.nodes.forEach(function(e){e.y+(e.y1-e.y0)>o.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-o.y1));var r=o.links.filter(function(o){return Ny(o.source,t)==Ny(e,t)}),n=r.length;n>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ky(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=Ly(t,e);return e.y1-o}if(t.target.column>e.target.column)return Ly(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var i=o+1,a=0;n>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let o=e;o.nodes.forEach(function(e){var r=o.links.filter(function(o){return Ny(o.target,t)==Ny(e,t)}),n=r.length;n>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ky(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=Ry(t,e);return e.y0-o}if(t.source.column>e.source.column)return Ry(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var i=o+1,a=0;n>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,o=e.links,r=!1,n=!1;if(o.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(n=!0)}),0==r||0==n){let r=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=ob(t,function(e){return e.y0}),a=rb(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),o.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,o=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+o}),e.targetLinks.forEach(function(e){e.y1=e.y1+o})})}}(h),Jy(h,s,d,10,8)}(m),m}return m.update=function(e){return mb(e),Jy(e,s,d,10,8),e},m.nodeWidth=function(e){return arguments.length?(n=+e,m):n},m.nodePadding=function(e){return arguments.length?(i=+e,m):i},m.nodePaddingRatio=function(e){return arguments.length?(a=+e,m):a},m.nodes=function(e){return arguments.length?(h="function"==typeof e?e:lb(e),m):h},m.links=function(e){return arguments.length?(p="function"==typeof e?e:lb(e),m):p},m.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:lb(e),m):s},m.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:lb(e),m):l},m.nodeSort=function(e){return arguments.length?(c=e,m):c},m.iterations=function(e){return arguments.length?(u=+e,m):u},m.circularLinkGap=function(e){return arguments.length?(d=+e,m):d},m.extent=function(n){return arguments.length?(e=+n[0][0],t=+n[0][1],o=+n[1][0],r=+n[1][1],m):[[e,t],[o,r]]},m.size=function(n){return arguments.length?(e=t=0,o=+n[0],r=+n[1],m):[o-e,r-t]},m}import{interpolateNumber as gb}from"d3-interpolate";import{line as yb,curveLinearClosed as bb}from"d3-shape";function vb(e){const{sx:t,sTop:o,sBot:r,tx:n,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(o+r)/2,u=(i+a)/2;return{pathD:[`M${t},${o}`,`C${s},${o} ${l},${i} ${n},${i}`,`L${n},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:n,y:u}],halfWidth:(r-o)/2}}}var xb=e=>{let t,o,r,n,i,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,n=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=gb(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${o},${c} ${o},${a}L${r},${a}C${r},${c} ${n},${l} ${n},${i}Z`;const u=e.sankeyWidth/2,d=gb(e.source.x1,e.target.x0),{pathD:h}=vb({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function wb(e){const t=e.sankeyWidth/2,o=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const o=r.sourceX,n=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-o))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${o},${n-t}L${o+s},${n-t}L${o+s},${n+t}L${o},${n+t}ZM${i},${a-t}L${i-l},${a-t}L${i-l},${a+t}L${i},${a+t}Z`}const n=r.sourceX,i=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(o,15));return`M${n},${i-d*t}L${l},${i-d*t}L${l+o},${i-d*t+d*h}L${l+o},${u+d*o-d*h}L${l+o-h},${u+d*o}L${c-o+h},${u+d*o}L${c-o},${u+d*o-d*h}L${c-o},${s-d*t+d*h}L${c-o+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+o},${s+d*t}L${c+o},${u-d*o}L${l-o},${u-d*o}L${l-o},${i+d*t}L${n},${i+d*t}Z`}var kb=new Set,Sb=new WeakMap;function Ab(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let o=Sb.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,Sb.set(e,o);const r=new Proxy(e,{get(e,o,r){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;kb.has(e)||(kb.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,o,r)}});return o.set(t,r),r}var Cb={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(zy))-1:0},justify:jy};function Mb(e){return"string"==typeof e?e:e.id}var Pb={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,r){if(0===e.length)return;const n="vertical"===o.orientation?"down":"right",i=o.nodeAlign||"justify",a=o.nodeWidth??15,s=o.nodePaddingRatio??.05,l=o.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===n?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=fb().extent(d).links(u).nodes(c).nodeAlign(Cb[i]||jy).nodeId(e=>e.id).nodeWidth(a).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,o=1/0,n=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),o>r.y0&&(o=r.y0),r.y1>n&&(n=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),o>i.verticalFullExtent-a&&(o=i.verticalFullExtent-a),i.verticalFullExtent+a>n&&(n=i.verticalFullExtent+a)}const i=t-e,a=n-o,s=r[0],l=r[1];if(i>0&&a>0&&(0>e||0>o||t>s||n>l)){const t=Math.min(s/i,l/a),r=-e*t+(s-i*t)/2,n=-o*t+(l-a*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+n,e.y1=e.y1*t+n;for(const e of u)if(e.y0=e.y0*t+n,e.y1=e.y1*t+n,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const o=e.circularPathData;o.sourceX=o.sourceX*t+r,o.targetX=o.targetX*t+r,o.sourceY=o.sourceY*t+n,o.targetY=o.targetY*t+n,o.rightFullExtent=o.rightFullExtent*t+r,o.leftFullExtent=o.leftFullExtent*t+r,o.verticalFullExtent=o.verticalFullExtent*t+n,o.rightInnerExtent=o.rightInnerExtent*t+r,o.leftInnerExtent=o.leftInnerExtent*t+r,o.verticalRightInnerExtent=o.verticalRightInnerExtent*t+n,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*t+n,o.rightSmallArcRadius*=t,o.rightLargeArcRadius*=t,o.leftSmallArcRadius*=t,o.leftLargeArcRadius*=t,o.sourceWidth*=t,o.rightNodeBuffer*=t,o.leftNodeBuffer*=t,o.arcRadius*=t}}}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of c){const t=p.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const m=new Map;for(const e of t)m.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Mb(e.source),o=Mb(e.target),r=m.get(e._edgeKey?e._edgeKey:`${t}\0${o}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=n;const i=p.get(t),a=p.get(o);i&&(r.source=i),a&&(r.target=a)}}},buildScene(e,t,o,r){const n="vertical"===o.orientation?"down":"right",i=o.nodeStyle,a=o.edgeStyle,s=o.edgeOpacity??.5,l=o.edgeColorBy||"source",c=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:fe,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],p=[],m=new Map;for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const r=i?i(Ab(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};m.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===n?{type:"rect",x:t.y0,y:t.x0,w:o,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:o,style:a,datum:t,id:t.id,label:t.id})}const f=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of f){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";n="function"==typeof l?l(e)||n:"target"===l?m.get(r.id)||u.get(r.id)||n:m.get(t.id)||u.get(t.id)||n;const i=a?a(Ab(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,o=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||n;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-o}L${t.sourceX+r},${t.sourceY-o}L${t.sourceX+r},${t.sourceY+o}L${t.sourceX},${t.sourceY+o}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-o}L${t.targetX-a},${t.targetY-o}L${t.targetX-a},${t.targetY+o}L${t.targetX},${t.targetY+o}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?wb(e):xb(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||n,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==o.showLabels){const t=(g=o.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const a=t?t(o):o.id;if(!a)continue;let s,l,c;"down"===n?(s=o.y0+(o.y1-o.y0)/2,l=o.x1+14,c="start"):(r[0]/2>o.x0+e/2?(s=o.x0-6,c="end"):(s=o.x1+6,c="start"),l=o.y0+i/2),p.push({x:s,y:l,text:a+"",anchor:"down"===n?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:d,sceneEdges:h,labels:p}}};import{forceSimulation as Ib,forceCenter as _b,forceX as Lb,forceY as Rb,forceLink as Tb,forceManyBody as Nb,forceCollide as $b}from"d3-force";import{scaleLinear as Bb}from"d3-scale";var Db={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,r){if(0===e.length)return;const n=o.forceStrength??.1,i=r[0]/2,a=r[1]/2,s=o.__previousPositions;let l=0;const c=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=s?.get(t.id);e?l++:o?(t.x=o.x,t.y=o.y,l++):c.push(t)}const u=l>0&&.3>=(e.length>0?c.length/e.length:1);if(u){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of c){const r=Fb(e.id,t,o);if(r.length>0){let t=0,o=0;for(const e of r)t+=e.x,o+=e.y;const n=Eb(e.id),i=n%360*(Math.PI/180),a=10+n%20;e.x=t/r.length+a*Math.cos(i),e.y=o/r.length+a*Math.sin(i)}else{const t=Eb(e.id),o=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(o),e.y=a+r*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const r=e[o];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(o+.5),n=o*t;r.x=i+e*Math.cos(n),r.y=a+e*Math.sin(n)}}}const d=o.__skipForceSimulation||0===o.iterations?0:u?40:o.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=zb(o.nodeSize,o.nodeSizeRange,e),p=e=>h(e);if(d>0){const o=new Map,r=new Map;for(const t of e)o.set(t.id,0),r.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id;o.set(t,(o.get(t)??0)+1),o.set(r,(o.get(r)??0)+1)}const s=Tb().strength(e=>{const t=e.weight,r="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(o.get("string"==typeof e.source?e.source:e.source.id)??1,o.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*n/(.1*i))}).distance(e=>{const t="string"==typeof e.source?r.get(e.source):e.source,o="string"==typeof e.target?r.get(e.target):e.target,n=(t?p(t):0)+(o?p(o):0)+12;return Math.max(40,n)}).id(e=>e.id),l=Ib().force("charge",Nb().strength(e=>{const t=o.get(e.id)??0;return-15*p(e)*Math.sqrt(t+1)})).force("collide",$b(e=>p(e)+3).strength(.9).iterations(2)).force("center",_b(i,a).strength(.8)).force("x",Lb(i).strength(.06)).force("y",Rb(a).strength(.06));if(l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));s.links(e),l.force("link",s)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;d>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=p(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,r){const n=o.nodeStyle,i=o.edgeStyle,a=zb(o.nodeSize,o.nodeSizeRange,e),s=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:fe,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Ab(t,"nodeSize")),r=n?n(Ab(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||o.themeSemantic?.primary||"#007bff",stroke:r.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const n=i?i(Ab(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:n.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.6},datum:e})}if(!1!==o.showLabels){const t=(p=o.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const r=a(Ab(o,"nodeSize"));d.push({x:o.x,y:o.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:c,sceneEdges:u,labels:d}}};function Fb(e,t,o){const r=[];for(const n of t){const t="string"==typeof n.source?n.source:n.source.id,i="string"==typeof n.target?n.target:n.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=o.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Eb(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function zb(e,t,r){if(r.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],i=[];for(const t of r){const o=t.data?.[e];"number"==typeof o&&i.push(o)}if(0===i.length)return()=>n[0];const[a,s]=o(i);if(a===s)return()=>(n[0]+n[1])/2;const l=Bb().domain([a,s]).range(n).clamp(!0);return t=>{const o=t.data?.[e];return null==o||"number"!=typeof o?n[0]:l(o)}}import{chord as jb,ribbon as Ob}from"d3-chord";import{arc as Hb}from"d3-shape";var Wb=fe,qb={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,r){if(0===e.length)return;const{padAngle:n=.01,groupWidth:i=20,sortGroups:a}=o,s=Math.min(r[0],r[1])/2,l=s-i,c=r[0]/2,u=r[1]/2,d=(h=o.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const m=e.length,f=Array.from({length:m},()=>Array.from({length:m},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=p.get("string"==typeof e.source?e.source:e.source.id),r=p.get(t);if(void 0===o||void 0===r)continue;const n=d(e);f[o][r]=n}const g=jb().padAngle(n);a&&g.sortGroups(a);const y=g(f),b=y.groups,v=Hb().innerRadius(l).outerRadius(s);for(const t of b){const o=e[t.index],r=v.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});o.x=r[0]+c,o.y=r[1]+u,o.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=x.get("string"==typeof e.source?e.source:e.source.id),r=x.get(t);o&&(e.source=o),r&&(e.target=r)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of y){const o=e[t.source.index].id,r=e[t.target.index].id,n=w.get(`${o}\0${r}`)||w.get(`${r}\0${o}`);n&&(n.__chordData=t)}},buildScene(e,t,o,r){const{groupWidth:n=20,edgeOpacity:i=.5}=o,a=Math.min(r[0],r[1])/2,s=a-n,l=r[0]/2,c=r[1]/2,u=o.nodeStyle,d=o.edgeStyle,h=o.edgeColorBy||"source",p=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:Wb,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const f=Ob().radius(s),g=[],y=[],b=[];for(let t=0;e.length>t;t++){const o=e[t],r=o.__arcData;if(!r)continue;let n;n=u?u(Ab(o,"nodeStyle")).fill||m.get(o.id)||p[t%p.length]:m.get(o.id)||p[t%p.length];const i=u?u(Ab(o,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:n,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=f(t);if(!r)continue;const n=Gb(r,l,c);let a=o.themeSemantic?.border||o.themeSemantic?.secondary||"#999";if(d)a=d(Ab(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===h&&o?a=m.get(o.id)||a:t&&(a=m.get(t.id)||a)}const s=d?d(Ab(e,"edgeStyle")):{};y.push({type:"ribbon",pathD:n,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==o.showLabels){const t=(v=o.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=a+12;for(const o of e){const e=o.__arcData;if(!e)continue;const n=t?t(o):o.id;if(!n)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:n+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:y,labels:b}}};function Gb(e,t,o){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const n=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(n.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)n.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(n.push(Number(r[i])+o+""),i++);else if("C"===e)for(n.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)n.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(n.push(Number(r[i])+o+""),i++);else if("Q"===e)for(n.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)n.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(n.push(Number(r[i])+o+""),i++);else if("A"===e)for(n.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)n.push(r[i++]),r.length>i&&n.push(r[i++]),r.length>i&&n.push(r[i++]),r.length>i&&n.push(r[i++]),r.length>i&&n.push(r[i++]),r.length>i&&(n.push(Number(r[i])+t+""),i++),r.length>i&&(n.push(Number(r[i])+o+""),i++);else"Z"===e||"z"===e?(n.push(e),i++):(n.push(r[i]),i++)}return n.join(" ")}import{hierarchy as Yb,tree as Vb,cluster as Xb,treemap as Ub,pack as Kb,partition as Qb,treemapBinary as Zb}from"d3-hierarchy";var Jb=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ev(e){const[t,o,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*r>150?"#222":"#fff"}function tv(e,t,o){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+o}function ov(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function rv(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Jb}function nv(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function iv(e,t,o,r,n){if("horizontal"===n){const n=(e+o)/2;return`M ${e},${t} C ${n},${t} ${n},${r} ${o},${r}`}if("radial"===n){const n=(e+o)/2;return`M ${e},${t} Q ${n},${t} ${n},${(t+r)/2} T ${o},${r}`}{const n=(t+r)/2;return`M ${e},${t} C ${e},${n} ${o},${n} ${o},${r}`}}var av={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,r){const n=o.__hierarchyRoot;if(!n)return;const i=o.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(o.childrenAccessor),s=o.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=Yb(n,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,o,r){const n=t.treeOrientation||"vertical",i=Vb();i.size("horizontal"===n?[r,o]:"radial"===n?[2*Math.PI,Math.min(o,r)/2*.8]:[o,r]),i(e)}(c,o,u,d);break;case"cluster":!function(e,t,o,r){const n=t.treeOrientation||"vertical",i=Xb();i.size("horizontal"===n?[r,o]:"radial"===n?[2*Math.PI,Math.min(o,r)/2*.8]:[o,r]),i(e)}(c,o,u,d);break;case"treemap":!function(e,t,o,r){const n=t.padding??4,i=t.paddingTop??0,a=Ub().size([o,r]).tile(Zb).padding(n);i>0&&a.paddingTop(i),a(e)}(c,o,u,d);break;case"circlepack":!function(e,t,o,r){const n=t.padding??4;Kb().size([o,r]).padding(n)(e)}(c,o,u,d);break;case"partition":!function(e,t,o,r){Qb().size([o,r]).padding(t.padding??1)(e)}(c,o,u,d)}const h=c.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;h.length>t;t++){const r=h[t],n={id:tv(r,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?sv(n,r,o):"treemap"===i||"partition"===i?lv(n,r):"circlepack"===i&&cv(n,r),n.__hierarchyNode=r,e.push(n),p.set(r,n)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const o=p.get(e.parent),r=p.get(e);o&&r&&t.push({source:o,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,r){const n=o.nodeStyle||(()=>({})),i=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,r,n,i){const a=[],s=[],l=[],c=o.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,p="number"==typeof(m=o.nodeSize)?m:5;var m;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=n(Ab(t,"nodeStyle"));let s=i.fill||nv(o);if(o.colorByDepth&&void 0!==t.depth){const e=rv(o);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:p,style:{fill:s,stroke:i.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const f=o.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let n=t.x,a=t.y,l=r.x,p=r.y;u&&(n+=d,a+=h,l+=d,p+=h);const m=iv(n,a,l,p,c),g=i(Ab(e,"edgeStyle"));s.push({type:"curved",pathD:m,style:{fill:"none",stroke:g.stroke||o.themeSemantic?.border||o.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??f},datum:e})}if(!1!==o.showLabels){const t=ov(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let r,n,i,a=o.x,s=o.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,o=Math.sqrt(e*e+t*t);o>0?(r=a+e/o*10,n=s+t/o*10,i=0>e?"end":"start"):(r=a,n=s-12,i="middle")}else"horizontal"===c?(o.data?.children&&0!==o.data.children.length?(r=a-p-6,i="end"):(r=a+p+6,i="start"),n=s):(r=a,n=s+p+14,i="middle");l.push({x:r,y:n,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,o,r,n,i);case"treemap":case"partition":return function(e,t,o,r){const n=[],i=[];for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const a=r(Ab(o,"nodeStyle"));let s=a.fill||nv(t);if(t.colorByDepth&&void 0!==o.depth){const e=rv(t);s=e[o.depth%e.length]}n.push({type:"rect",x:o.x0,y:o.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=ov(t.nodeLabel),n=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;const c=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===n&&!c)continue;if("parent"===n&&c)continue}const u=o?o(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Ab(s,"nodeStyle")).fill||nv(t);if(t.colorByDepth&&void 0!==s.depth){const e=rv(t);d=e[s.depth%e.length]}const h="string"==typeof d?ev(d):t.themeSemantic?.text??"#000";i.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:n,sceneEdges:[],labels:i}}(e,o,0,n);case"circlepack":return function(e,t,o,r){const n=[],i=[];for(const o of e){const e=o.__radius??5;if(0>=e)continue;const i=r(Ab(o,"nodeStyle"));let a=i.fill||nv(t);if(t.colorByDepth&&void 0!==o.depth){const e=rv(t);a=e[o.depth%e.length]}n.push({type:"circle",cx:o.x,cy:o.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=ov(t.nodeLabel);for(const n of e){const e=n.__radius??5,a=o?o(n):n.id;if(!a)continue;if(15>e)continue;const s=!(n.data?.children&&n.data.children.length>0);let l=r(Ab(n,"nodeStyle")).fill||nv(t);if(t.colorByDepth&&void 0!==n.depth){const e=rv(t);l=e[n.depth%e.length]}if(s){const o="string"==typeof l?ev(l):t.themeSemantic?.text??"#000";i.push({x:n.x,y:n.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:o})}else i.push({x:n.x,y:n.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:n,sceneEdges:[],labels:i}}(e,o,0,n);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function sv(e,t,o){const r=o.treeOrientation||"vertical";if("radial"===r){const o=t.x,r=t.y;e.x=r*Math.cos(o-Math.PI/2),e.y=r*Math.sin(o-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function lv(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function cv(e,t){const o=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}import{pie as uv}from"d3-shape";function dv(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var hv={sankey:Pb,force:Db,chord:qb,tree:av,cluster:av,treemap:av,circlepack:av,partition:av,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,o,r){const n=o.__hierarchyRoot;n&&function(e,t,o,r,n){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(o.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(o.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),l=o.orbitSize??2.95,c=o.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=dv(o);h.metaMap.clear(),r.length=0,n.length=0;const p=new Map;function m(e){const t=p.get(e)??0;return p.set(e,t+1),0===t?e:`${e}__${t}`}const f=t[0]/2,g=t[1]/2,y=Math.min(t[0],t[1])/2*.85,b=m(a(e));r.push({id:b,x:f,y:g,x0:f,x1:f,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,o,l,c,p,f,g){const y=i(t);if(!y?.length)return;const b=y.length;let v=0,x=0,w=0;for(;b>x;)x+=s[Math.min(w,s.length-1)],w++,v++;let k=0;for(let b=0;v>b;b++){const x=s[Math.min(b,s.length-1)],w=y.slice(k,k+x);if(!w.length)break;const S=(b+1)/v,A={id:o,depth:f,data:t,parentId:o},C=g?p/u(A)*S:p*S,M=uv().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(w),P=d(A);for(let t=0;w.length>t;t++){const i=(M[t].startAngle+M[t].endAngle)/2,s=w[t],u=m(a(s)),d=l+C*Math.sin(i),p=c+C*Math.cos(i)*P;r.push({id:u,x:d,y:p,x0:d,x1:d,y0:p,y1:p,width:0,height:0,value:0,depth:f,data:s}),h.metaMap.set(u,{ring:C,angle:i,depth:f,parentId:o,eccentricity:P}),n.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),e(s,u,d,p,C,f+1,!0)}k+=x}}(e,b,f,g,y,1,!1)}(n,r,o,e,t)},buildScene(e,t,o,r){const n=o.nodeStyle,i=o.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],l=[],c=[];if(!1!==o.orbitShowRings){const t=dv(o),r=new Map;for(const t of e)r.set(t.id,t);const n=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const o=`${e.parentId}:${e.ring}`;n.has(o)||n.set(o,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:o,ecc:r}]of n)for(let n=0;i>n;n++){const s=n/i*Math.PI*2,c=(n+1)/i*Math.PI*2;l.push({type:"line",x1:e+o*Math.sin(s),y1:t+o*Math.cos(s)*r,x2:e+o*Math.sin(c),y2:t+o*Math.cos(c)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Ab(t,"nodeSize")),r=n?n(Ab(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||o.themeSemantic?.primary||"#6366f1",stroke:r.stroke||o.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),o="object"==typeof e.target?e.target:u.get(e.target);t&&o&&(null!=t.x&&null!=o.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(o.showLabels){const t=o.nodeLabel;for(const o of e){const e=a(Ab(o,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(o):t?o.data?.[t]??o.id:o.id;c.push({x:o.x,y:o.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:l,labels:c}},tick:(e,t,o,r,n)=>!1!==o.orbitAnimated&&(function(e,t){const o=dv(t),r=t.orbitSpeed??.25,n=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const l=e.angle+i*a*n({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,o),!0)}};function pv(e){return hv[e]}import{quadtree as mv}from"d3-quadtree";function fv(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function gv(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!yv(e))return!1;return!0}return yv(t.points)}function yv(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as bv}from"d3-interpolate";var vv="rgba(34, 197, 94, 0.7)",xv=2e3,wv=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this._stylePaintPending=!1,this.config=e,this.tensionConfig={...vy,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new wy(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(e.layoutSelection=t.layoutSelection),this.config=e,this.tensionConfig={...vy,...e.tensionConfig},!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new wy(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,o,r){const{nodeIDAccessor:n="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,l="function"==typeof n?n:e=>e[n],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...fv(e),data:t})}for(let e=0;t.length>e;e++){const o=t[e],r=c(o)+"",n=u(o)+"",i=d(o),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,{...fv(r),data:o}),this.nodes.has(n)||this.nodes.set(n,{...fv(n),data:o});const l=`${r}\0${n}\0${e}`,h={source:r,target:n,value:s,y0:0,y1:0,sankeyWidth:0,data:o,_edgeKey:l};o&&"object"==typeof o&&gv(o.bezier)&&(h.bezier=o.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(o)}applyForceLayoutPositions(e,t){for(const[t,o]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=o.x,e.y=o.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:r}=e,n=0===this.nodes.size;let i=!1;const a=Ue();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,fv(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(o)||(this.nodes.set(o,fv(o)),this.nodeTimestamps.set(o,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,o),l=this.edges.get(s);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:o,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),n||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=pv(this.config.chartType);if(!t)return;let o=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===o.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of o)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,o]of this._lastPositionSnapshot)e.has(t)||e.set(t,o);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(o,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&o.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of o)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],o=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=o,this.edges.set(o,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const o=e.get(t.id);o&&(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,o=Array.from(this.nodes.values())}this.finalizeLayout();const n=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||n.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=n,this.saveTargetPositions();const i=o.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&o.length>0&&a>0){const t=e[0]/2,o=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=o,e._prevY1=o;for(const e of this.edges.values())e._prevY0=o,e._prevY1=o,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:Ue(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:Ue(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=Ue()),this.previousNodeIds=e,this.previousEdgeKeys=t}setLayoutSelection(e){this.config.layoutSelection=e}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const e of this.sceneNodes)this._baseStyles.set(e,e.style);for(const e of this.sceneEdges)this._baseStyles.set(e,e.style)}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){if(this._customRestyle){const t=this._customRestyle;for(const o of this.sceneNodes){const r=this._baseStyles.get(o)??o.style,n=t(o,e);o.style=n?{...r,...n}:r}}if(this._customRestyleEdge){const t=this._customRestyleEdge;for(const o of this.sceneEdges){const r=this._baseStyles.get(o)??o.style,n=t(o,e);o.style=n?{...r,...n}:r}}this._stylePaintPending=!0}buildScene(e){if(this.config.customNetworkLayout){const t=Array.from(this.nodes.values()),o=Array.from(this.edges.values()),r=Kp(this.config.colorScheme,this.config.themeCategorical,fe),n={nodes:t,edges:o,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:this.config.themeSemantic??{},categorical:[...r]},resolveColor:Qp(r,this.config.colorScheme),config:this.config.layoutConfig??{},selection:this.config.layoutSelection??null};let i;try{i=this.config.customNetworkLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,o=Ft("network",e,t,this.layoutVersion);this.lastCustomLayoutFailure=o,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e);try{this.config.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return void(t||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++))}return this.sceneNodes=i.sceneNodes??[],this.sceneEdges=i.sceneEdges??[],this.labels=i.labels??[],this.customLayoutOverlays=i.overlays??null,this.customLayoutHtmlMarks=i.htmlMarks??[],this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=i.restyle,this._customRestyleEdge=i.restyleEdge,this.hasCustomRestyle=!(!i.restyle&&!i.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(this.config.layoutSelection??null)),void $t({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=pv(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const o=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:n,sceneEdges:i,labels:a}=t.buildScene(o,r,this.config,e);this.sceneNodes=n,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,o=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>o&&(o=e.r));if(this._maxNodeRadius=o,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let n=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[n++]=e);this._nodeQuadtree=mv().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=pv(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=pv(this.config.chartType);if(!o?.tick)return!1;const r=o.hierarchical?Array.from(this.nodes.values()):this.nodesArray,n=o.hierarchical?Array.from(this.edges.values()):this.edgesArray;return o.tick(r,n,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Ve(e,this.transition),o=Ye(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Xe(e._prevX0,e._targetX0,o),e.x1=Xe(e._prevX1,e._targetX1,o),e.y0=Xe(e._prevY0,e._targetY0,o),e.y1=Xe(e._prevY1,e._targetY1,o));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Xe(e._prevY0,e._targetY0,o),e.y1=Xe(e._prevY1,e._targetY1,o),e.sankeyWidth=Xe(e._prevSankeyWidth,e._targetSankeyWidth,o));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const o=e?.get(t.id);o&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const o=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(o){e._prevY0=o.y0,e._prevY1=o.y1,e._prevSankeyWidth=o.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,o=.5){const r="string"==typeof e.source?t.get(e.source):e.source,n="string"==typeof e.target?t.get(e.target):e.target;!r||!n||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,o=e.circularPathData;if(!o)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(o.rightFullExtent-o.sourceX))),r=Math.max(15,Math.min(40,.33*(o.targetX-o.leftFullExtent)));return{circular:!0,segments:[[{x:o.sourceX,y:o.sourceY},{x:o.sourceX+.33*e,y:o.sourceY},{x:o.sourceX+.66*e,y:o.sourceY},{x:o.sourceX+e,y:o.sourceY}],[{x:o.targetX-r,y:o.targetY},{x:o.targetX-.66*r,y:o.targetY},{x:o.targetX-.33*r,y:o.targetY},{x:o.targetX,y:o.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.targetY,y:o.leftFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.rightFullExtent,y:o.sourceY},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const n=[];for(let e=0;r.length-1>e;e++){const t=r[e],o=r[e+1],i=o.x-t.x,a=o.y-t.y;n.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},o])}return{circular:!0,segments:n,halfWidth:t}}(e):function(e,t,o,r=.5){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=o.x0,s=bv(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(r)},{x:e.y1,y:s(1-r)},{x:e.y1,y:a}],halfWidth:n}}const i=t.x1,a=o.x0,s=bv(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(r),y:e.y0},{x:s(1-r),y:e.y1},{x:a,y:e.y1}],halfWidth:n}}(e,r,n,o))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const o=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",n=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const l=i-s;o>l&&(t._pulseIntensity=1-l/o,t._pulseColor=r,t._pulseGlowRadius=n)}for(const t of e.sceneEdges){const n=t.datum;if(!n)continue;const a="object"==typeof n.source?n.source?.id:n.source,s="object"==typeof n.target?n.target?.id:n.target;if(!a||!s)continue;const l=e.edgeTimestamps.get(`${a}\0${s}`);if(!l)continue;const c=i-l;o>c&&(t._pulseIntensity=1-c/o,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const o=e.nodeTimestamps.size;if(1>=o)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let o=0;e.cache.sortedNodes.length>o;o++)t.set(e.cache.sortedNodes[o][0],o);e.cache.ageMap=t}const r=e.cache.ageMap;for(const n of e.sceneNodes){const e=n.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const a=Ze(t,i,o);n.style={...n.style,opacity:(n.style?.opacity??1)*a}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===vv&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=xv)return;const o=1-t/xv;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,o),t._pulseColor=vv,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,o=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&xv>o-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const o=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",n=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const l=t.metric(s);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=o):c=r,c&&(i.style={...i.style,fill:c},n&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const o of e){const e=t.metric(o);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const o=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>o-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const o=this.nodes.get(e);if(!o)return null;const r=o.data?{...o.data}:{};return o.data=t(o.data??{}),this.layoutVersion++,this.lastIngestTime=Ue(),r}updateEdge(e,t,o){const r=this.config.valueAccessor,n="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=o(r.data??{});const e=n(r.data);null!=e&&(r.value=Number(e))}return i.length>0&&(this.layoutVersion++,this.lastIngestTime=Ue()),i}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)!==e&&("string"==typeof o.target?o.target:o.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=Ue(),!0}removeEdge(e,t){const o=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,n]of this.edges)n.data&&r(n.data)===e&&o.push(t)}else for(const[r,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)===e&&("string"==typeof n.target?n.target:n.target.id)===t&&o.push(r);for(const e of o)this.edges.delete(e),this.edgeTimestamps.delete(e);return o.length>0&&(this.layoutVersion++,this.lastIngestTime=Ue()),o.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear()}};wv.QUADTREE_THRESHOLD=500;var kv=wv;import*as Sv from"react";import{Fragment as Av,jsx as Cv,jsxs as Mv}from"react/jsx-runtime";function Pv(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p="right",legendLayout:m,foregroundGraphics:f,sceneNodes:g,annotations:y,autoPlaceAnnotations:b,svgAnnotationRules:v}=e,x=Sv.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,o=e.cy??e.y;if("number"!=typeof t||"number"!=typeof o)return null;const r=Do(e.glyph,e.size);return{x:t+r.centerDx,y:o+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),o=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof o?null:{x:t,y:o,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Rt(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),o=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:o,...t}]:[]});return{scales:null,width:t,height:o,frameType:"network",pointNodes:e,sceneNodes:g}},[o,g,t]),w=Sv.useMemo(()=>y&&b?di({annotations:y,context:x,..."object"==typeof b?b:{}}):y,[y,b,x]),k=Sv.useMemo(()=>Wn(),[]),S=w?Hn(w.filter(e=>"widget"!==e.type),k,v,x):null,A=!0===w?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Mv(Av,{children:[A&&Cv("style",{children:$n},"annotation-widget-disclosure-style"),Mv("svg",{role:"img",width:r,height:n,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Cv("title",{children:"string"==typeof s?s:"Network Chart"}),Cv("desc",{children:"string"==typeof s?s+" — network data visualization":"Network data visualization"}),Mv("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>Cv("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),S,f]}),s&&"string"==typeof s?Cv("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?Cv("foreignObject",{x:0,y:0,width:r,height:i.top,children:s}):null,Kr({legend:l,totalWidth:r,totalHeight:n,margin:i,legendPosition:p,title:s,legendLayout:m,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),w?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const o=!0===e._annotationDeferred,r=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const n=e.width??32,a=e.height??32;return Cv("div",{className:o?"annotation-deferred":void 0,"data-annotation-disclosure":o?"deferred":void 0,style:{position:"absolute",left:i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0))+(e.dx??0)-n/2,top:i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0))+(e.dy??-16)-a/2,width:n,height:a,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:e.content??Cv("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"})},"widget-"+t)})]})}Pv.displayName="NetworkSVGOverlay";import*as Iv from"react";import{jsx as _v}from"react/jsx-runtime";var Lv={position:"absolute",top:0,left:0,pointerEvents:"none"};function Rv({marks:e,margin:t,selection:o=null,overscan:r=400}){const n=Iv.useRef(null),i=function(e,t,o){const[r,n]=Iv.useState(null);return Iv.useLayoutEffect(()=>{const e=t.current,o=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:o,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${o}`))return t;t=t.parentElement}return null}(e);if(!e||!o)return void n(null);let r=0;const i=()=>{r=0;const t=o.getBoundingClientRect(),i=e.getBoundingClientRect();n(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),o.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(o),()=>{0!==r&&window.cancelAnimationFrame(r),o.removeEventListener("scroll",a),s.disconnect()}},[t,e,o]),Iv.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:n,originY:i}=r,a=t.left-o,s=t.right+o,l=t.top-o,c=t.bottom+o;return e.filter(e=>{const t=n+e.x,o=i+e.y;return!(a>t+e.width||t>s||l>o+e.height||o>c)})},[e,r,o])}(e,n,r);if(!e||0===e.length)return null;const a=_v("div",{className:"semiotic-network-html-marks",ref:n,style:{...Lv,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>_v("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=o?_v(bo,{value:o,children:a}):a}function Tv(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),o=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+o)}throw Error("Cannot resolve module worker asset: "+e)}function Nv(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function $v(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Bv=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):Tv("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,o=t.requestId,r=null!=o?this.pending.get(o):this.pending.values().next().value;if(r){if(null!=o?this.pending.delete(o):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject($v());const o=this.nextRequestId;this.nextRequestId+=1;const r={requestId:o,request:e};return new Promise((e,n)=>{const i=()=>{this.pending.delete(o),t?.removeEventListener("abort",i),n($v())},a=()=>t?.removeEventListener("abort",i);this.pending.set(o,{cleanup:a,reject:n,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(o),a(),n(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Dv=null;import{jsx as Fv,jsxs as Ev}from"react/jsx-runtime";var zv=/^(value|amount|total|count|weight|score)$/i;function jv({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?Ev("div",{className:"semiotic-tooltip",style:ms,children:[Ev("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&Ev("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const o=t.__hierarchyNode;if(o){const e=[];let r=o;for(;r;){const o=r.data?.name??r.data?.id??t.id;null!=o&&e.unshift(o+""),r=r.parent}e.length>1&&e.shift();const n=e.length-1;return Ev("div",{className:"semiotic-tooltip",style:ms,children:[Fv("div",{children:e.map((e,t)=>Ev("span",{children:[t>0&&Fv("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===n?Fv("strong",{children:e}):Fv("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&Fv("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),n=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=ds(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>zv.test(e.key));return Ev("div",{className:"semiotic-tooltip",style:ms,children:[Fv("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>Ev("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",Ll(e.value)]},e.key)),!s&&null!=t.value&&t.value>0&&Ev("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&Ev("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,n!==r&&` (weighted: ${n.toLocaleString()})`]})]})}function Ov(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Hv(e,t){if(!t.pathD)return;e.save();const o=Ov(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const o=e.createLinearGradient(r.x0,0,r.x1,0),n=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=Go(e,i)||i;o.addColorStop(0,1===r.from?a:"transparent"),o.addColorStop(1,1===r.to?a:"transparent"),e.fillStyle=o,e.globalAlpha=n}else e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(o)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(o)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(o)),e.restore()}function Wv(e,t){e.save();const o=t.style.stroke||"#999";e.strokeStyle=Go(e,o)||o,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function qv(e,t){if(!t.pathD)return;e.save();const o=Ov(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(o)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(o)),e.restore()}function Gv(e,t){if(!t.pathD)return;e.save();const o=Ov(t),r=t.style.stroke||"#999";e.strokeStyle=Go(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(o),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??.1,e.fill(o)),e.restore()}jv.ownsChrome=!0;var Yv=new Map;function Vv(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let o=Yv.get(t);return o||(o=new Path2D(Lt(e.symbolType,e.size)),Yv.size>256&&Yv.clear(),Yv.set(t,o)),o}catch{return null}}function Xv(e){const{sceneNodes:t,nodes:o,nodeColorMap:r,colorScheme:n}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(n)?n:Ee,a=Array.from(o);for(let e=0;a.length>e;e++){const t=a[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return a.length}function Uv(e,t,o,r=30){switch(e.type){case"circle":return function(e,t,o,r=30){const n=t-e.cx,i=o-e.cy,a=Math.sqrt(n*n+i*i);return a>Co(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,o,r);case"rect":return function(e,t,o){const r=Ao(t,o,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,o);case"arc":return function(e,t,o){const r=t-e.cx,n=o-e.cy,i=Math.sqrt(r*r+n*n);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Io(Math.atan2(n,r)),s=Io(e.startAngle),l=Io(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);case"symbol":return function(e,t,o,r=30){const n=t-e.cx,i=o-e.cy,a=Math.sqrt(n*n+i*i);return a>Co(Rt(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,o,r);case"glyph":return function(e,t,o,r=30){if(null==e.datum)return null;const n=Do(e.glyph,e.size),i=e.cx+n.centerDx,a=e.cy+n.centerDy,s=t-i,l=o-a,c=Math.sqrt(s*s+l*l);return c>Co(n.radius,r)?null:{type:"node",datum:e.datum,x:i,y:a,distance:c}}(e,t,o,r);default:return null}}var Kv=null,Qv=null;function Zv(){return Qv||((Kv=document.createElement("canvas")).width=1,Kv.height=1,Qv=Kv.getContext("2d")),Qv}function Jv(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function ex(e,t,o){switch(e.type){case"bezier":return function(e,t,o){if(!e.pathD)return null;const r=Jv(e),n=Zv();if(!r||!n)return null;try{if(n.isPointInPath(r,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const i=n.lineWidth;n.lineWidth=10;const a=n.isPointInStroke(r,t,o);if(n.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch{}return null}(e,t,o);case"line":return function(e,t,o){const r=e.x2-e.x1,n=e.y2-e.y1,i=r*r+n*n;if(0===i)return null;let a=((t-e.x1)*r+(o-e.y1)*n)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*r,l=e.y1+a*n,c=Math.sqrt((t-s)**2+(o-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;const r=Jv(e),n=Zv();if(!r||!n)return null;try{if(n.isPointInPath(r,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const i=n.lineWidth;n.lineWidth=10;const a=n.isPointInStroke(r,t,o);if(n.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch{}return null}(e,t,o);default:return null}}function tx(e){const{clientX:t,clientY:o,canvasRect:r,margin:n,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-r.left-n.left,p=o-r.top-n.top;if(0>h||h>i||0>p||p>a)return{kind:"miss-outside"};const m=function(e,t,o,r,n=30,i,a=0){let s=null,l=n,c=1/0;if(i){const e=Eo(i,o,r,n,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Uv(t,o,r,n);if(e)if("rect"===t.type){const o=t.w*t.h;c>o&&(s=e,c=o)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=ex(e,o,r);t&&l>t.distance&&(s=t,l=t.distance)}return s}(s,l,h,p,d,c,u);return m?{kind:"hit",hover:is(m.datum||{},m.x,m.y,{nodeOrEdge:m.type})}:{kind:"miss"}}import{jsx as ox,jsxs as rx}from"react/jsx-runtime";var nx={top:20,right:80,bottom:20,left:80},ix={top:40,right:40,bottom:40,left:40},ax=new Set(["chord","force","circlepack","orbit"]),sx=[800,600],lx=by(yy(function(e,t){const{chartType:o,nodes:r,edges:n,data:i,initialEdges:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:d="value",edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f="horizontal",nodeAlign:g="justify",nodePaddingRatio:y=.05,nodeWidth:b=15,iterations:v=300,forceStrength:x=.1,layoutExecution:w="auto",layoutLoadingContent:k,onLayoutStateChange:S,padAngle:A=.01,groupWidth:C=20,sortGroups:M,edgeSort:P,treeOrientation:I="vertical",edgeType:_="curve",padding:L,paddingTop:R,tensionConfig:T,showParticles:N=!1,particleStyle:$,nodeStyle:B,edgeStyle:D,colorBy:F,colorScheme:E="category10",edgeColorBy:z="source",edgeOpacity:j=.5,colorByDepth:O=!1,nodeSize:H=8,nodeSizeRange:W=[5,20],nodeLabel:q,showLabels:G=!0,labelMode:V,size:X=sx,responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,enableHover:ee=!0,tooltipContent:te,customHoverBehavior:oe,customClickBehavior:re,onObservation:ne,chartId:ie,onTopologyChange:ae,annotations:se,autoPlaceAnnotations:le,svgAnnotationRules:ce,legend:ue,legendPosition:de,legendLayout:he,legendHoverBehavior:pe,legendClickBehavior:me,legendHighlightedCategory:fe,legendIsolatedCategories:ge,title:ye,foregroundGraphics:be,backgroundGraphics:ve,decay:xe,pulse:we,transition:ke,animate:Se,staleness:Ae,thresholds:Ce,accessibleTable:Me=!0,description:Pe,summary:Ie,orbitMode:_e,orbitSize:Le,orbitSpeed:Re,orbitRevolution:Te,orbitRevolutionStyle:Ne,orbitEccentricity:$e,orbitShowRings:Be,orbitAnimated:De,customNetworkLayout:Fe,onLayoutError:ze,layoutConfig:je,layoutSelection:Oe}=e,He=ax.has(o)?ix:nx,We=dy(!0),qe=js({sizeProp:X,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:He,foregroundGraphics:be,backgroundGraphics:ve,animate:Se,transitionProp:ke,themeDirtyRef:We}),{reducedMotionRef:Ge,responsiveRef:Ye,size:Ve,margin:Xe,adjustedWidth:Ue,adjustedHeight:Ke,resolvedForeground:Qe,resolvedBackground:Ze,transition:Je,introEnabled:et,tableId:tt,rafRef:ot,renderFnRef:rt,scheduleRender:nt,cancelRender:it,currentTheme:at}=qe,st=na(),lt=la(),ct=my(()=>u(r),[r]),ut=my(()=>Array.isArray(n)?u(n):n,[n]),dt=my(()=>({...vy,...T}),[T]),ht=my(()=>({...xy,...$}),[$]),pt=my(()=>{return{chartType:(e={chartType:o,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:d,edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f,nodeAlign:g,nodePaddingRatio:y,nodeWidth:b,iterations:v,forceStrength:x,padAngle:A,groupWidth:C,sortGroups:M,edgeSort:P,treeOrientation:I,edgeType:_,padding:L,paddingTop:R,tensionConfig:dt,showParticles:N,particleStyle:ht,nodeStyle:B,edgeStyle:D,nodeLabel:q,showLabels:G,labelMode:V,colorBy:F,colorScheme:E,edgeColorBy:z,edgeOpacity:j,colorByDepth:O,nodeSize:H,nodeSizeRange:W,decay:xe,pulse:we,transition:Je,introAnimation:et,staleness:Ae,thresholds:Ce,orbitMode:_e,orbitSize:Le,orbitSpeed:Re,orbitRevolution:Te,orbitRevolutionStyle:Ne,orbitEccentricity:$e,orbitShowRings:Be,orbitAnimated:De,customNetworkLayout:Fe,onLayoutError:ze,layoutConfig:je,currentTheme:at}).chartType,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Y(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[o,s,l,c,d,p,m,f,g,y,b,v,x,A,C,M,P,I,_,L,R,dt,N,ht,B,D,q,G,V,F,E,z,j,O,H,W,xe,we,Je?.duration,Je?.easing,et,Ae,Ce,_e,Le,Re,Te,Ne,$e,Be,De,at,Fe,ze,je]),mt=da(pt),ft=da({chartType:(gt={chartType:o,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:d,edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f,nodeAlign:g,nodePaddingRatio:y,nodeWidth:b,iterations:v,forceStrength:x,padAngle:A,groupWidth:C,sortGroups:M,edgeSort:P,treeOrientation:I,edgeType:_,padding:L,paddingTop:R,tensionConfig:dt,customNetworkLayout:Fe,orbitMode:_e,orbitSize:Le,orbitEccentricity:$e}).chartType,nodeIDAccessor:gt.nodeIDAccessor,sourceAccessor:gt.sourceAccessor,targetAccessor:gt.targetAccessor,valueAccessor:gt.valueAccessor,edgeIdAccessor:gt.edgeIdAccessor,childrenAccessor:gt.childrenAccessor,hierarchySum:gt.hierarchySum,orientation:gt.orientation,nodeAlign:gt.nodeAlign,nodePaddingRatio:gt.nodePaddingRatio,nodeWidth:gt.nodeWidth,iterations:gt.iterations,forceStrength:gt.forceStrength,padAngle:gt.padAngle,groupWidth:gt.groupWidth,sortGroups:gt.sortGroups,edgeSort:gt.edgeSort,treeOrientation:gt.treeOrientation,edgeType:gt.edgeType,padding:gt.padding,paddingTop:gt.paddingTop,tensionConfig:gt.tensionConfig,customNetworkLayout:gt.customNetworkLayout,orbitMode:gt.orbitMode,orbitSize:gt.orbitSize,orbitEccentricity:gt.orbitEccentricity});var gt;const yt=dy(null),bt=dy(0),vt=dy(0),xt=dy(!1),wt=dy(null);wt.current||(wt.current=new kv(mt));const[kt,St]=hy(null),[At,Ct]=hy(0),[Mt,Pt]=hy(0),[It,_t]=hy(!1),[Rt,Tt]=hy(!1),Nt=dy(0),$t=dy(null),Bt=dy(!1),Dt=dy(S);Dt.current=S;const Ft=dy(mt);Ft.current=mt;const Et=dy(null),zt=dy(new Map),jt=dy(0),Ot=fy(e=>function(e){const{node:t,colorBy:o,colorScheme:r,nodeColorMap:n,colorIndexRef:i}=e;if("function"==typeof o)return o(t)+"";if("string"==typeof o&&t.data){const e=t.data[o];if(void 0!==e){if(!n.has(e+"")){const t=Array.isArray(r)?r:Ee;n.set(e+"",t[i.current++%t.length])}return n.get(e+"")}}if(n.has(t.id))return n.get(t.id);const a=Array.isArray(r)?r:Ee,s=o?a[i.current++%a.length]:a[0];return n.set(t.id,s),s}({node:e,colorBy:F,colorScheme:E,nodeColorMap:zt.current,colorIndexRef:jt}),[F,E]),Ht=(Wt=at,Wt?.colors?.border||Wt?.colors?.secondary||Wt?.colors?.primary||"#999");var Wt;const qt=fy(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,wt.current?.nodes),[]),Gt=fy(e=>function(e){const{edge:t,edgeColorBy:o,getNodeColor:r,resolveEndpoint:n,fallback:i}=e;if("function"==typeof o)return o(t);const a=n(t.source),s=n(t.target);return"target"===o&&s?r(s):a?r(a):i}({edge:e,edgeColorBy:z,getNodeColor:Ot,resolveEndpoint:qt,fallback:Ht}),[z,Ot,Ht,qt]),Yt=fy(e=>function(e){const{edge:t,particleStyleColor:o,particleColorBy:r,hasExplicitParticleColorBy:n,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:l}=e;if("function"==typeof o){const e=s(t.source);return e?o(t,e):l}if(!n)return i(t);const c=r,u=s(t.source),d=s(t.target);return"target"===c&&d?a(d):u?a(u):l}({edge:e,particleStyleColor:ht.color,particleColorBy:ht.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:Gt,getNodeColor:Ot,resolveEndpoint:qt,fallback:Ht}),[$?.colorBy,ht.color,ht.colorBy,Ot,Gt,Ht,qt]),Vt=("sankey"===o||!!Fe)&&N||!!we||(wt.current?.isAnimating??!1);ko(wt,mt,We,nt),So(wt,Oe,We,nt),py(()=>{const e=wt.current;e&&(e.buildScene([Ue,Ke]),jt.current=Xv({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:zt.current,colorScheme:E}),We.current=!0,nt())},[at,Ue,Ke,nt]);const Xt=fy(()=>{const e=wt.current;if(e&&(e.runLayout([Ue,Ke]),e.buildScene([Ue,Ke]),We.current=!0,jt.current=Xv({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:zt.current,colorScheme:E}),Ct(e.layoutVersion),ae)){const{nodes:t,edges:o}=e.getLayoutData();ae(t,o)}},[Ue,Ke,ae,E]),Ut=fy(e=>{if(null==e||"object"!=typeof e)return;const t=wt.current;t&&(t.ingestEdge(e)&&Xt(),nt())},[Xt,nt]),Kt=fy(e=>{const t=wt.current;if(!t)return;let o=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(o=!0);o&&Xt(),nt()},[Xt,nt]),Qt=fy(()=>{wt.current?.clear(),zt.current.clear(),jt.current=0,Ct(wt.current?.layoutVersion??0),St(null),Et.current=null,We.current=!0,nt()},[nt]),Zt=fy(()=>{const e=wt.current;e&&(e.tension+=999,Xt(),nt())},[Xt,nt]);gy(t,()=>({push:Ut,pushMany:Kt,removeNode:e=>{const t=wt.current?.removeNode(e)??!1;if(t){const t=Et.current?.data?"function"==typeof s?s(Et.current.data):Et.current.data[s]:void 0;Et.current&&"node"===Et.current.nodeOrEdge&&t===e&&(Et.current=null,St(null)),zt.current.delete(e),Xt(),We.current=!0,nt()}return t},removeEdge:(e,t)=>{const o=wt.current?.removeEdge(e,t)??!1;if(o){if(Et.current&&"edge"===Et.current.nodeOrEdge){const o=Et.current.data;let r;r=void 0!==t?("object"==typeof o?.source?o.source.id:o?.source)===e&&("object"==typeof o?.target?o.target.id:o?.target)===t:!h||!o||("function"==typeof h?h:e=>e?.[h])(o)===e,r&&(Et.current=null,St(null))}Xt(),We.current=!0,nt()}return o},updateNode:(e,t)=>{const o=wt.current?.updateNode(e,t)??null;return o&&(We.current=!0,nt()),o},updateEdge:(e,t,o)=>{const r=wt.current?.updateEdge(e,t,o)??[];return r.length>0&&(Xt(),We.current=!0,nt()),r},clear:Qt,getTopology:()=>wt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>wt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>wt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=wt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Zt,getTension:()=>wt.current?.tension??0}),[Ut,Kt,Qt,Zt,Xt,nt]);const Jt=["tree","cluster","treemap","circlepack","partition","orbit"].includes(o),eo=Jt?i||(Array.isArray(n)?void 0:n):void 0;py(()=>{const e=wt.current;if(!e)return;const t=++Nt.current;if($t.current?.abort(),$t.current=null,Jt&&eo)e.ingestHierarchy(eo,[Ue,Ke]),e.buildScene([Ue,Ke]),Tt(!1),Dt.current?.("ready"),We.current=!0,nt();else{const i=ct,a=Array.isArray(ut)?ut:[];if(0===i.length&&0===a.length)return null==r&&null==n||0>=e.nodes.size&&0>=e.edges.size||Qt(),Tt(!1),void Dt.current?.("ready");const s=[Ue,Ke],l="force"===o&&!Fe&&Nv()&&function(e,t,o,r,n=4e4){return"sync"!==e&&("worker"===e||r*(t+o)>=n)}(w,i.length,a.length,v);if(l&&lt&&!Bt.current&&e.sceneNodes.length>0)return Bt.current=!0,Tt(!1),Dt.current?.("ready"),We.current=!0,void nt();if(l){const o=new AbortController;$t.current=o;const r=e._lastPositionSnapshot;e.ingestBounded(i,a,s,{deferLayout:!0});const n=e.getLayoutData(),l=function(e,t,o,r,n){const i=zb(o.nodeSize,o.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=n?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,n="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:o,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:n}}),config:{chartType:"force",iterations:o.iterations,forceStrength:o.forceStrength},size:r}}(n.nodes,n.edges,Ft.current,s,r);return Tt(!0),Dt.current?.("pending"),function(e,t){return Nv()?t?.aborted?Promise.reject($v()):(Dv&&!Dv.isDead||(Dv=new Bv),Dv).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(l,o.signal).then(({positions:o})=>{t===Nt.current&&(e.applyForceLayoutPositions(o,s),e.buildScene(s),jt.current=Xv({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:zt.current,colorScheme:E}),Tt(!1),Dt.current?.("ready"),Ct(e.layoutVersion),We.current=!0,nt())}).catch(o=>{"AbortError"!==o.name&&t===Nt.current&&(e.runLayout(s),e.buildScene(s),jt.current=Xv({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:zt.current,colorScheme:E}),Tt(!1),Dt.current?.("error"),Ct(e.layoutVersion),We.current=!0,nt())}),()=>o.abort()}e.ingestBounded(i,a,s),e.buildScene(s),Tt(!1),Dt.current?.("ready"),jt.current=Xv({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:zt.current,colorScheme:E}),We.current=!0,nt()}},[ct,ut,r,n,i,eo,Jt,Ue,Ke,ft,w,v,lt,o,Fe,nt,Qt,E]),py(()=>{a&&a.length>0&&Kt(a)},[]);const to=fy(e=>{if(oe&&oe(e),ne){const t=Date.now();ne(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[oe,ne,ie]),oo=fy(e=>{if(re&&re(e),ne){const t=Date.now();ne(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:ie}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:ie})}},[re,ne,ie]),{hoverHandlerRef:ro,hoverLeaveRef:no,onPointerMove:io,onPointerLeave:ao}=qe,so=()=>!Fe||(wt.current?.hasCustomRestyle??!1);ro.current=e=>{if(!ee)return;const t=so(),o=yt.current;if(!o)return;const r=wt.current;if(!r)return;const n=tx({clientX:e.clientX,clientY:e.clientY,canvasRect:o.getBoundingClientRect(),margin:Xe,adjustedWidth:Ue,adjustedHeight:Ke,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===n.kind?(Et.current=n.hover,St(n.hover),to&&(to(n.hover),t&&(We.current=!0)),t&&nt()):Et.current&&(Et.current=null,St(null),to&&(to(null),t&&(We.current=!0)),t&&nt())},no.current=()=>{if(Et.current){const e=so();Et.current=null,St(null),to&&(to(null),e&&(We.current=!0)),e&&nt()}};const lo=dy(()=>{});lo.current=e=>{if(!re&&!ne)return;const t=yt.current;if(!t)return;const o=wt.current;if(!o)return;const r=tx({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:Xe,adjustedWidth:Ue,adjustedHeight:Ke,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?oo(r.hover):"miss"===r.kind&&oo(null)};const co=fy(e=>lo.current(e),[]),uo=dy(-1),ho=dy(null),po=dy(-1),fo=fy(e=>{const t=wt.current;if(!t)return;const o=function(e){const t=[];for(const o of e)if("circle"===o.type&&null!=o.cx){if(0>=o.r)continue;t.push({x:o.cx,y:o.cy,datum:o.datum,shape:"circle",group:o.datum?.id??"_default"})}else if("rect"===o.type&&null!=o.x){if(0>=o.w||0>=o.h)continue;t.push({x:o.x+o.w/2,y:o.y+o.h/2,datum:o.datum,shape:"rect",w:o.w,h:o.h,group:o.datum?.id??"_default"})}else if("arc"===o.type&&null!=o.cx)t.push({x:o.cx,y:o.cy,datum:o.datum,shape:"circle",group:o.datum?.id??"_default"});else if("symbol"===o.type&&null!=o.cx){if(0>=o.size)continue;t.push({x:o.cx,y:o.cy,datum:o.datum,shape:"circle",group:o.datum?.id??"_default"})}else if("glyph"===o.type&&null!=o.cx){if(0>=o.size||null==o.datum)continue;const e=Do(o.glyph,o.size);t.push({x:o.cx+e.centerDx,y:o.cy+e.centerDy,datum:o.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:o.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return;const r=wr(o),n=uo.current;if(0>n){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),uo.current=0,po.current=-1;const t=r.flat[0];ho.current={shape:t.shape,w:t.w,h:t.h};const o=is(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Et.current=o,St(o),to&&(to(o),We.current=!0),void nt()}const i=kr(r,n),a=function(e,t,o,r,n){const i=o.flat[t.flatIndex];if(!i)return Sr(e,t,o);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,o){let r=null,n=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(o){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;n>u&&(n=u,r=i)}return r}(o,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(n.current=-1),r}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const o=e+"",r=[];for(const e of t){const t=e.datum??e,n=Cr(t.source),i=Cr(t.target),a=null!=n,s=null!=i;a&&n+""===o&&s?r.push(i+""):s&&i+""===o&&a&&r.push(n+"")}return r}(a,r);if(0===e.length)return t.flatIndex;const i=o.idToIdx.get(e[(n.current+1)%e.length])??-1;return 0>i?t.flatIndex:(n.current=-1,i)}default:{const r=Sr(e,t,o);return null!==r&&r!==t.flatIndex&&(n.current=-1),r}}}(e.key,i,r,t.sceneEdges??[],po);if(null===a)return;if(e.preventDefault(),0>a)return uo.current=-1,ho.current=null,po.current=-1,Et.current=null,St(null),to&&(to(null),We.current=!0),void nt();uo.current=a;const s=r.flat[a];ho.current={shape:s.shape,w:s.w,h:s.h};const l={data:s.datum||{},x:s.x,y:s.y,__semioticHoverData:!0,nodeOrEdge:"node"};Et.current=l,St(l),to&&(to(l),We.current=!0),nt()},[to,nt]),go=fy(e=>{uo.current=-1,ho.current=null,io(e)},[io]);rt.current=()=>{ot.current=null;const e=yt.current;if(!e)return;const t=wt.current;t&&function(e){const{canvas:t,store:o,size:r,margin:n,adjustedWidth:i,adjustedHeight:a,background:s,dirtyRef:l,lastFrameTimeRef:c,reducedMotion:u,showParticles:d,isContinuous:h,animate:p,decay:m,pulse:f,thresholds:g,staleness:y,particleStyle:b,getParticleColor:v,pendingAnnotationFrameRef:x,lastAnnotationFrameTimeRef:w,setAnnotationFrame:k,scheduleNextFrame:S}=e,A=t.getContext("2d");if(!A)return;const C=performance.now(),M=c.current?Math.min((C-c.current)/1e3,.1):.016;c.current=C;const P=o.advanceTransition(u?C+1e6:C),I=!u&&P,_=!u&&o.tickAnimation([i,a],M),L=l.current;(P||L||_)&&o.buildScene([i,a]);const R=d&&!u&&!!o.particlePool,T=ga({dirtyOrRebuilt:L,transitioning:I,animationTicked:_,continuous:R||h,liveEncoding:!!m||!!f||!!g||!1!==p&&o.hasActiveTopologyDiff||o.hasActivePulses||o.hasActiveThresholds,forced:o.consumeStylePaintPending()}),N=!!y&&o.lastIngestTime>0&&C-o.lastIngestTime>(y?.threshold??5e3);if(T){if(!Hs(t,r,n,Ws()))return;if(A.clearRect(-n.left,-n.top,r[0],r[1]),fa(A,{background:s,width:i,height:a}),m&&o.applyDecay(),f&&o.applyPulse(C),g&&o.applyThresholds(C),!1!==p&&o.applyTopologyDiff(C),N&&(A.globalAlpha=y?.dimOpacity??.5),function(e,t){for(const o of t)switch(o.type){case"bezier":Hv(e,o);break;case"line":Wv(e,o);break;case"ribbon":qv(e,o);break;case"curved":Gv(e,o)}}(A,o.sceneEdges),function(e,t){for(const o of t){if("rect"!==o.type)continue;const t=o;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),nl(e,t),e.restore())}}(A,o.sceneNodes),function(e,t){for(const o of t){if("circle"!==o.type)continue;const t=o;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),il(e,t),e.restore())}}(A,o.sceneNodes),function(e,t){for(const o of t){if("arc"!==o.type)continue;const t=o;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(A,o.sceneNodes),function(e,t){const o=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const n=Vv(t);if(!n)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=o*i*(t.style.fillOpacity??1),e.fillStyle="string"==typeof t.style.fill&&Go(e,t.style.fill)||t.style.fill,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*i,e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(n)),e.restore()}}(A,o.sceneNodes),function(e,t){const o=e.globalAlpha;for(const r of t)"glyph"===r.type&&fl(e,r,r.cx,r.cy,o);e.globalAlpha=o}(A,o.sceneNodes),R&&!N){const e=o.edgesArray;if(e.length>0){!function(e,t,o,r){const n=r.spawnRate??.1,i=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=i)continue;const s=a.value*n*o*(a.bezier.circular?.3:1),l=Math.floor(s),c=s-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<i;t++)e.spawn(r)}}(o.particlePool,e,M,b);const t=.5*(b.speedMultiplier??1);let r;if(b.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}o.particlePool.step(M,t,e,r),function(e,t,o,r,n){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const l=o[s.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:n(l),e.fillStyle=Go(e,c)||c,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(A,o.particlePool,e,b,v)}}N&&(A.globalAlpha=1)}l.current=!1,(L||I||_)&&t.setAttribute("aria-label",$a(o.sceneNodes?.length??0,o.sceneEdges?.length??0,"Network chart"));const $=L||I||_||x.current;$&&C-w.current>=33?(k(e=>e+1),w.current=C,x.current=!1):x.current=!!$,(h||I||null!=o.transition||_||o.hasActivePulses||o.hasActiveThresholds||!1!==p&&o.hasActiveTopologyDiff||x.current)&&S()}({canvas:e,store:t,size:Ve,margin:Xe,adjustedWidth:Ue,adjustedHeight:Ke,background:J,dirtyRef:We,lastFrameTimeRef:bt,reducedMotion:!!Ge.current,showParticles:N,isContinuous:Vt,animate:Se,decay:xe,pulse:we,thresholds:Ce,staleness:Ae,particleStyle:ht,getParticleColor:Yt,pendingAnnotationFrameRef:xt,lastAnnotationFrameTimeRef:vt,setAnnotationFrame:Pt,scheduleNextFrame:()=>{nt()}})},ca({hydrated:st,wasHydratingFromSSR:lt,storeRef:wt,dirtyRef:We,renderFnRef:rt,cancelRender:it}),py(()=>{We.current=!0,nt()},[o,Ue,Ke,J,nt]),Tr(Ae,wt,We,nt,It,_t);const yo=ee&&kt?ox(ks,{x:kt.x,y:kt.y,containerWidth:Ue,containerHeight:Ke,margin:Xe,className:"stream-network-tooltip",zIndex:2,children:te?te(kt):ox(jv,{data:kt})}):null;if(Qi||!st&&lt){const e=wt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(o),r=t?i||(Array.isArray(n)?void 0:n):void 0;if(t&&r)e.ingestHierarchy(r,[Ue,Ke]),e.buildScene([Ue,Ke]);else{const t=ct,o=Array.isArray(ut)?ut:[];(t.length>0||o.length>0)&&(e.ingestBounded(t,o,[Ue,Ke]),e.buildScene([Ue,Ke]))}}const t=e?.sceneNodes??[],r=e?.sceneEdges??[],a=e?.labels??[];return rx("div",{ref:Ye,className:"stream-network-frame"+(Z?" "+Z:""),role:"img","aria-label":Pe||("string"==typeof ye?ye:"Network chart"),style:{position:"relative",width:U?"100%":Ve[0],height:K?"100%":Ve[1]},children:[ox(Ka,{summary:Ie}),rx("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ve[0],height:Ve[1],style:{position:"absolute",left:0,top:0},children:[Ze&&ox("g",{transform:`translate(${Xe.left},${Xe.top})`,children:Ze}),rx("g",{transform:`translate(${Xe.left},${Xe.top})`,children:[J&&ox("rect",{x:0,y:0,width:Ue,height:Ke,fill:J}),r.map((e,t)=>function(e,t){switch(e.type){case"line":return Wi("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const o=e;return Wi("path",{d:o.pathD,fill:Yi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+t)}case"ribbon":{const o=e;return Wi("path",{d:o.pathD,fill:Yi(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+t)}case"curved":{const o=e;return Wi("path",{d:o.pathD,fill:Yi(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+t)}default:return null}}(e,t)).filter(Boolean),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const o=e;return Wi("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+t)}case"rect":{const o=e;return Wi("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+t)}case"arc":{const o=e,r=Fi().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(Gi)||"";return Wi("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Yi(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+t)}case"symbol":{const o=e,r=Lt(o.symbolType,o.size,o.path);return Wi("path",{d:r,transform:o.rotation?`translate(${o.cx},${o.cy}) rotate(${180*o.rotation/Math.PI})`:`translate(${o.cx},${o.cy})`,fill:o.style.fill?Yi(o.style.fill):"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-symbol-"+t)}case"glyph":return Xi(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),a.map((e,t)=>function(e,t){return Wi("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),ox(Pv,{width:Ue,height:Ke,totalWidth:Ve[0],totalHeight:Ve[1],margin:Xe,labels:a,sceneNodes:t,title:ye,legend:ue,legendPosition:de,legendLayout:he,legendHoverBehavior:pe,legendClickBehavior:me,legendHighlightedCategory:fe,legendIsolatedCategories:ge,foregroundGraphics:mo(Qe,vo(wt.current?.customLayoutOverlays,Oe??null)),annotations:se,autoPlaceAnnotations:le,svgAnnotationRules:ce,annotationFrame:0}),ox(Rv,{marks:e?.customLayoutHtmlMarks,margin:Xe,selection:Oe??null})]})}const bo=wt.current;return rx("div",{ref:Ye,className:"stream-network-frame"+(Z?" "+Z:""),role:"group","aria-label":Pe||("string"==typeof ye?ye:"Network chart"),tabIndex:0,"aria-busy":Rt||void 0,style:{position:"relative",width:U?"100%":Ve[0],height:K?"100%":Ve[1],overflow:"visible"},onKeyDown:fo,children:[Me&&ox(Qa,{tableId:tt}),Me&&ox(Ua,{nodes:bo?.sceneNodes??[],edges:bo?.sceneEdges??[],chartType:"Network chart",tableId:tt,chartTitle:"string"==typeof ye?ye:void 0}),ox(Ka,{summary:Ie}),ox(Za,{hoverPoint:kt}),rx("div",{role:"img","aria-label":Pe||("string"==typeof ye?ye:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ee?go:void 0,onMouseLeave:ee?ao:void 0,onClick:re||ne?co:void 0,children:[Rt&&!1!==k&&ox("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Hu(!0,Ve[0],Ve[1],k)}),Ze&&ox("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:Ve[0],height:Ve[1],pointerEvents:"none",overflow:"visible"},children:ox("g",{transform:`translate(${Xe.left},${Xe.top})`,children:Ze})}),ox("canvas",{ref:yt,"aria-label":$a(bo?.sceneNodes?.length??0,bo?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),ox(Pv,{width:Ue,height:Ke,totalWidth:Ve[0],totalHeight:Ve[1],margin:Xe,labels:bo?.labels||[],sceneNodes:bo?.sceneNodes,title:ye,legend:ue,legendPosition:de,legendLayout:he,legendHoverBehavior:pe,legendClickBehavior:me,legendHighlightedCategory:fe,legendIsolatedCategories:ge,foregroundGraphics:mo(Qe,vo(wt.current?.customLayoutOverlays,Oe??null)),annotations:se,autoPlaceAnnotations:le,svgAnnotationRules:ce,annotationFrame:Mt}),ox(Rv,{marks:bo?.customLayoutHtmlMarks,margin:Xe,selection:Oe??null}),ox(ts,{active:uo.current>=0,hoverPoint:kt,margin:Xe,size:Ve,shape:ho.current?.shape,width:ho.current?.w,height:ho.current?.h}),yo,Ae?.showBadge&&ox($r,{isStale:It,position:Ae.badgePosition})]})]})}));lx.displayName="StreamNetworkFrame";var cx=lx;import{useMemo as ux}from"react";function dx(e,t){if(!e)return[];const o=[],r=e=>{o.push(e);const n="function"==typeof t?t(e):e[t];n&&Array.isArray(n)&&n.forEach(r)};return r(e),o}function hx(e,t,o,r){if(e&&e.length>0)return e;const n=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],i="function"==typeof r?r(e):e[r];n.add(t),n.add(i)}),Array.from(n).map(e=>({id:e}))}function px(e){return"function"==typeof e?e:t=>t[e]||1}function mx({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:r,edgeOpacity:n,baseStyle:i={}}){return a=>{const s={fillOpacity:n,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=He(e.data||e,t,o):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=He(e.data||e,t,o):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*n);return s}}function fx(e){const{nodes:t,edges:o,inferNodes:r=!0,sourceAccessor:n="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:c,legendInteraction:d,selection:h,linkedHover:p,onObservation:m,onClick:f,mobileInteraction:g,mobileSemantics:y,chartType:b,chartId:v,marginDefaults:x,userMargin:w,width:k,height:S,loading:A,loadingContent:C,emptyContent:M,emptyDataKey:P="edges"}=e,I=ux(()=>u(o),[o]),_=ux(()=>u(t),[t]),L=Hu(A,k,S,C),R=L?null:Ou("nodes"===P?void 0===t?void 0:_:void 0===o?void 0:I,k,S,M),T=ux(()=>r?hx(_,I,n,i):_,[r,_,I,n,i]),N=wu(T,a,s),$=vu(),B=ux(()=>{if(Array.isArray(s))return s;if($&&$.length>0)return $;if("string"==typeof s){const e=Fe[s];if(Array.isArray(e)&&e.length>0)return e}return Ee},[s,$]),D=ux(()=>{if(!a)return[];const e=new Set;for(const t of T){const o="function"==typeof a?a(t):t[a];null!=o&&e.add(o+"")}return Array.from(e)},[T,a]),F=Mu(d,a,D),{legend:E,margin:z,legendPosition:j}=Cu({data:T,colorBy:a,colorScale:N,showLegend:l,legendPosition:c,userMargin:w,defaults:x,categories:D}),O=ux(()=>bu(g,{width:k,mobileSemantics:y}),[g,k,y]),H=Su({selection:h,linkedHover:p,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:m,onClick:f,mobileInteraction:O,chartType:b,chartId:v}),{customHoverBehavior:W,customClickBehavior:q,activeSelectionHook:G,hoverSelectionHook:Y,crosshairSourceId:V}=H;return{safeNodes:T,safeEdges:I,colorScale:N,effectivePalette:B,themeCategorical:$,allCategories:D,legendState:F,legend:E,margin:z,legendPosition:j,mobileInteraction:O,customHoverBehavior:W,customClickBehavior:q,activeSelectionHook:G,hoverSelectionHook:Y,crosshairSourceId:V,loadingEl:L,emptyEl:R}}import{jsx as gx}from"react/jsx-runtime";var yx=cy(function(e,t){const o=uy(null);sd(t,{variant:"network",frameRef:o});const r=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:n,edges:i,margin:a,className:s,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:p,colorScheme:m,nodeSize:f=8,nodeSizeRange:g=[5,20],edgeWidth:y=1,edgeColor:b="#999",edgeOpacity:v=.6,iterations:x=300,forceStrength:w=.1,layoutExecution:k="auto",layoutLoadingContent:S,onLayoutStateChange:A,tooltip:C,frameProps:M={},onObservation:P,onClick:I,chartId:_,selection:L,linkedHover:R,loading:T,loadingContent:N,emptyContent:$,legendInteraction:B,legendPosition:D,stroke:F,strokeWidth:E,opacity:z}=e,j=l??c??"id",{width:O,height:H,enableHover:W,showLegend:q,showLabels:G=!1,title:Y,description:V,summary:X,accessibleTable:U}=r,K=fx({nodes:n,edges:i,inferNodes:!1,nodeIdAccessor:j,sourceAccessor:u,targetAccessor:d,colorBy:p,colorScheme:m,showLegend:q,legendPosition:D,legendInteraction:B,selection:L,linkedHover:R,onObservation:P,onClick:I,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:_,marginDefaults:r.marginDefaults,userMargin:a,width:O,height:H,loading:T,loadingContent:N,emptyContent:$,emptyDataKey:"nodes"}),Q=ly(()=>new Map,[]),Z=ly(()=>e=>{const t={};return t.fill=p?He(e.data||e,p,K.colorScale):xu(void 0,K.themeCategorical,m,void 0,Q),"number"==typeof f&&(t.r=f),t},[p,K.colorScale,f,K.themeCategorical,m,Q]),J=ly(()=>nd(Z,{stroke:F,strokeWidth:E,opacity:z}),[Z,F,E,z]),ee=ly(()=>e=>{const t=e.data||e;let o;if("number"==typeof y)o=y;else if("function"==typeof y)o=y(t);else{const e=t[y],r="number"==typeof e?e:Number(e);o=Number.isFinite(r)&&r>0?r:1}return{stroke:b,strokeWidth:o,opacity:v}},[y,b,v]),te=ly(()=>nd(ee,{stroke:F,strokeWidth:E,opacity:z}),[ee,F,E,z]),oe=ly(()=>{if(G&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[G,h]),re=Ku({componentName:"ForceDirectedGraph",nodes:n,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:j}});return re?gx(Tu,{componentName:"ForceDirectedGraph",message:re,width:O,height:H}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:gx(Eu,{componentName:"ForceDirectedGraph",width:O,height:H,children:gx(cx,{ref:o,chartType:"force",...null!=n&&{nodes:K.safeNodes},...null!=i&&{edges:K.safeEdges},size:[O,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,nodeIDAccessor:j,sourceAccessor:u,targetAccessor:d,iterations:x,forceStrength:w,layoutExecution:k,layoutLoadingContent:S,onLayoutStateChange:A,nodeStyle:J,edgeStyle:te,colorBy:p,colorScheme:K.effectivePalette,nodeSize:f,nodeSizeRange:g,nodeLabel:oe,showLabels:G,enableHover:W,tooltipContent:!1===C?()=>null:xs(C)||void 0,...cd({linkedHover:R,selection:L,onObservation:P,onClick:I,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:K.legend,legendPosition:K.legendPosition,...B&&"none"!==B&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},className:s,title:Y,description:V,summary:X,accessibleTable:U,...null!=e.animate&&{animate:e.animate},...M})})});yx.displayName="ForceDirectedGraph";import{useMemo as bx,forwardRef as vx,useRef as xx}from"react";import{jsx as wx}from"react/jsx-runtime";var kx=vx(function(e,t){const o=xx(null);sd(t,{variant:"network",frameRef:o,overrides:{getData:()=>o.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:n,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,edgeColorBy:m="source",padAngle:f=.01,groupWidth:g=20,sortGroups:y,nodeLabel:b,edgeOpacity:v=.5,tooltip:x,frameProps:w={},onObservation:k,onClick:S,chartId:A,selection:C,linkedHover:M,loading:P,loadingContent:I,emptyContent:_,legendInteraction:L,stroke:R,strokeWidth:T,opacity:N}=e,{width:$,height:B,enableHover:D,showLabels:F=!0,title:E,description:z,summary:j,accessibleTable:O}=r,H=fx({nodes:n,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:p,showLegend:!1,legendInteraction:L,selection:C,linkedHover:M,onObservation:k,onClick:S,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:a,width:$,height:B,loading:P,loadingContent:I,emptyContent:_}),W=bx(()=>new Map,[]),q=H.safeNodes.length>0,G=bx(()=>{if(q)return(e,t)=>{const o={stroke:"black",strokeWidth:1};if(h)o.fill=He(e.data||e,h,H.colorScale);else{const r=Array.isArray(p)?p:Fe[p]||Ee,n=Array.isArray(r)?r:Ee;o.fill=n[(e.index??t??0)%n.length]}return o}},[q,h,H.colorScale,p]),Y=bx(()=>G?nd(G,{stroke:R,strokeWidth:T,opacity:N}):void 0,[G,R,T,N]),V=bx(()=>{if(q)return mx({edgeColorBy:m,colorBy:h,colorScale:H.colorScale,nodeStyleFn:Y||(e=>({fill:xu(void 0,H.themeCategorical,p,void 0,W)})),edgeOpacity:v,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:v}})},[q,m,h,H.colorScale,Y,v,H.themeCategorical,p,W]),X=bx(()=>V?nd(V,{stroke:R,strokeWidth:T,opacity:N}):void 0,[V,R,T,N]),U=bx(()=>{if(!F)return;const e=b||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[F,b,d]),K=Ku({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return K?wx(Tu,{componentName:"ChordDiagram",message:K,width:$,height:B}):H.loadingEl?H.loadingEl:H.emptyEl?H.emptyEl:wx(Eu,{componentName:"ChordDiagram",width:$,height:B,children:wx(cx,{ref:o,chartType:"chord",...H.safeNodes.length>0&&{nodes:H.safeNodes},...null!=i&&{edges:H.safeEdges},size:[$,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:H.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:f,groupWidth:g,sortGroups:y,nodeStyle:Y,edgeStyle:X,colorBy:h,colorScheme:H.effectivePalette,edgeColorBy:m,edgeOpacity:v,nodeLabel:U,showLabels:F,enableHover:D,tooltipContent:!1===x?()=>null:xs(x)||void 0,...cd({linkedHover:M,selection:C,onObservation:k,onClick:S,mobileInteraction:H.mobileInteraction,customHoverBehavior:H.customHoverBehavior,customClickBehavior:H.customClickBehavior,linkedHoverInClickPredicate:!1}),...L&&"none"!==L&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},className:s,title:E,description:z,summary:j,accessibleTable:O,...null!=e.animate&&{animate:e.animate},...w})})});kx.displayName="ChordDiagram";import{useMemo as Sx,forwardRef as Ax,useRef as Cx}from"react";import{jsx as Mx}from"react/jsx-runtime";var Px=Ax(function(e,t){const o=Cx(null);sd(t,{variant:"network",frameRef:o,overrides:{getData:()=>o.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:n,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,edgeColorBy:m="source",orientation:f="horizontal",nodeAlign:g="justify",nodePaddingRatio:y=.05,nodeWidth:b=15,nodeLabel:v,edgeOpacity:x=.5,edgeSort:w,tooltip:k,frameProps:S={},onObservation:A,onClick:C,chartId:M,selection:P,linkedHover:I,loading:_,loadingContent:L,emptyContent:R,showLegend:T,legendPosition:N,legendInteraction:$,stroke:B,strokeWidth:D,opacity:F}=e,{width:E,height:z,enableHover:j,showLabels:O=!0,title:H,description:W,summary:q,accessibleTable:G}=r,Y=fx({nodes:n,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:p,showLegend:T,legendPosition:N,legendInteraction:$,selection:P,linkedHover:I,onObservation:A,onClick:C,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:M,marginDefaults:r.marginDefaults,userMargin:a,width:E,height:z,loading:_,loadingContent:L,emptyContent:R}),V=Sx(()=>new Map,[]),X=Sx(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?He(e.data||e,h,Y.colorScale):xu(void 0,Y.themeCategorical,p,void 0,V),t},[h,Y.colorScale,Y.themeCategorical,p,V]),U=Sx(()=>nd(X,{stroke:B,strokeWidth:D,opacity:F}),[X,B,D,F]),K=Sx(()=>mx({edgeColorBy:m,colorBy:h,colorScale:Y.colorScale,nodeStyleFn:U,edgeOpacity:x,baseStyle:{stroke:"none",strokeWidth:0}}),[m,h,Y.colorScale,U,x]),Q=Sx(()=>nd(K,{stroke:B,strokeWidth:D,opacity:F}),[K,B,D,F]),Z=Sx(()=>{if(!O)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[O,v,d]),J=Ku({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return J?Mx(Tu,{componentName:"SankeyDiagram",message:J,width:E,height:z}):Y.loadingEl?Y.loadingEl:Y.emptyEl?Y.emptyEl:Mx(Eu,{componentName:"SankeyDiagram",width:E,height:z,children:Mx(cx,{ref:o,chartType:"sankey",...Y.safeNodes.length>0&&{nodes:Y.safeNodes},...null!=i&&{edges:Y.safeEdges},size:[E,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Y.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:f,nodeAlign:g,nodePaddingRatio:y,nodeWidth:b,nodeStyle:U,edgeStyle:Q,colorBy:h,colorScheme:Y.effectivePalette,edgeColorBy:m,edgeOpacity:x,edgeSort:w,nodeLabel:Z,showLabels:O,enableHover:j,tooltipContent:!1===k?()=>null:xs(k)||void 0,...cd({linkedHover:I,selection:P,onObservation:A,onClick:C,mobileInteraction:Y.mobileInteraction,customHoverBehavior:Y.customHoverBehavior,customClickBehavior:Y.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:Y.legend,legendPosition:Y.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:Y.legendState.onLegendHover,legendClickBehavior:Y.legendState.onLegendClick,legendHighlightedCategory:Y.legendState.highlightedCategory,legendIsolatedCategories:Y.legendState.isolatedCategories},className:s,title:H,description:W,summary:q,accessibleTable:G,...null!=e.animate&&{animate:e.animate},...S})})});Px.displayName="SankeyDiagram";import{useMemo as Ix,useState as _x,useRef as Lx,useCallback as Rx}from"react";import{scaleTime as Tx}from"d3-scale";import{forwardRef as Nx}from"react";function $x(e,o,r){const n=o.incoming[e.id],i=o.outgoing[e.id],a=[];for(const e of n)a.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:r.get(e.id).targetSide});for(const e of i)a.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:r.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{a.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=a.length?t(a.map(e=>e.time)):null,u=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=u?u-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(a.map(e=>e.time))].sort((e,t)=>e-t),p=new Map;for(let e=1;h.length>e;e++)p.set(h[e],h[e-1]);const m=e=>{const t=p.get(e);return null!=t?(t+e)/2:null!=d?d:e};l();const f=[];let g=0,y=0;for(const e of a)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?g:y);if(o>0){const t="top"===e.side?"bot":"top",r=Math.min(o,"top"===t?g:y);if(r>0){const n=m(e.time);f.push({time:n,delta:-r,kind:"transfer-out",side:t}),f.push({time:n,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?g-=r:y-=r,"top"===e.side?g+=r:y+=r,o-=r}o>0&&null!==d&&(f.push({time:d,delta:+o,kind:"create",side:e.side}),"top"===e.side?g+=o:y+=o)}"top"===e.side?g-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?g+=t:y+=t}a.push(...f),l();let b=0,v=0,x=0,w=0,k=0;const S=[],A=new Map;for(const e of a){if(S.push({t:e.time,topMass:b,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?b:v;A.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?b+=e.delta:v+=e.delta,b+v>x&&(x=b+v),b>w&&(w=b),v>k&&(k=v),S.push({t:e.time,topMass:b,botMass:v})}const C=[];let M=0;for(;S.length>M;){let e=M;for(;S.length>e+1&&S[e+1].t===S[M].t;)e++;C.push(S[M]);for(let t=M+1;e>=t;t++){const e=C[C.length-1];S[t].topMass===e.topMass&&S[t].botMass===e.botMass||C.push(S[t])}M=e+1}const P=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let I=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===I||I>e.systemInTime)&&(I=e.systemInTime);let _=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===_||e.systemOutTime>_)&&(_=e.systemOutTime);if(C.length>0){const e=C[C.length-1],t=Math.max(null!=P?P:-1/0,null!=_?_:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&C.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=C[0],r=Math.min(null!=u?u:1/0,null!=I?I:1/0);Number.isFinite(r)&&o.t>r&&o.topMass+o.botMass>0&&C.unshift({t:r,topMass:o.topMass,botMass:o.botMass})}return{samples:C,peak:x,topPeak:w,botPeak:k,localAttachments:A}}function Bx(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Dx(e,t){return e.map(e=>({t:Bx(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Fx(e,t,o){const r=e.value*o;if("out"===e.kind){const n=e.sideMassBefore*o;if("top"===e.side){const e=t-n;return[e,e+r]}const i=t+n;return[i-r,i]}const n=e.sideMassAfter*o;if("top"===e.side){const e=t-n;return[e,e+r]}const i=t+n;return[i-r,i]}function Ex(e,t){let o=0;for(let r=0;t.length>r;r++)for(let n=r+1;t.length>n;n++){const i=t[r],a=t[n];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&o++)}return o}function zx(e,t){let o=0;for(const r of t)o+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return o}function jx(e,t){return 1e3*Ex(e,t)+zx(e,t)}function Ox(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Hx(e,t,o){e.length>8||o.length>40?(function(e,t,o,r=6){const n=e.length;if(1>=n)return;let i=Ox(e,t),a=jx(t,o);for(let s=0;r>s;s++){const r=Array(n).fill(0),s=Array(n).fill(0);for(const e of o){const o=t[e.source],n=t[e.target];r[o]+=n*(e.value||1),s[o]+=e.value||1,r[n]+=o*(e.value||1),s[n]+=e.value||1}const l=Array.from({length:n},(e,t)=>t).sort((e,t)=>(s[e]>0?r[e]/s[e]:e)-(s[t]>0?r[t]/s[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=jx(t,o);if(a>d)a=d,i=Ox(e,t);else if(d===a)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,i)}(e,t,o,6),function(e,t,o,r=6){const n=e.length;if(1>=n)return;let i=jx(t,o);for(let a=0;r>a;a++){let r=!1;for(let a=0;n-1>a;a++){const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const s=jx(t,o);if(i>s)i=s,r=!0;else{const o=e[a];e[a]=e[a+1],e[a+1]=o;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!r)break}}(e,t,o,6)):function(e,t,o){const r=e.length;if(1>=r)return;const n={...t},i=Object.keys(n),a=Array.from({length:r},(e,t)=>t),s=a.slice(),l={...n};let c=a.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=s[n[e]];const e=jx(l,o);u>e&&(u=e,c=a.slice())},h=(e,t)=>{const o=a[e],r=a[t];a[e]=r,a[t]=o,s[o]=t,s[r]=e};d();const p=Array(r).fill(0);let m=0;for(;r>m;)m>p[m]?(h(m%2==0?0:p[m],m),d(),p[m]++,m=0):(p[m]=0,m++);const f=c.map(t=>e[t]),g=new Map;c.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function Wx(e,t,o,r,n){const{plotH:i,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="full"}=n,d={},h={};for(const t of e)d[t.id]=o[t.id].topPeak||0,h[t.id]=o[t.id].botPeak||0;const p="half"===u,m={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let n=null!=e&&Number.isFinite(e)?e:1/0,i=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of r.outgoing[t.id]){n>e.startTime&&(n=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&n>e.systemInTime&&(n=e.systemInTime);const t=p?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=p?(e.startTime+e.endTime)/2:e.startTime;n>t&&(n=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}m[t.id]={start:Number.isFinite(n)?n:null,end:Number.isFinite(i)?i:null}}const f={},g=[];if("reuse"===l){const o=new Map;for(const t of e)o.set(t.id,0);const n=new Map;for(const t of e)n.set(t.id,0);for(const e of t)n.set(e.target,(n.get(e.target)??0)+1);const i=[];for(const t of e)0===(n.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of r.outgoing[e]??[]){const r=(o.get(e)??0)+1;r>(o.get(t.target)??0)&&o.set(t.target,r),n.set(t.target,n.get(t.target)-1),0===n.get(t.target)&&i.push(t.target)}}const a=[...e].filter(e=>null!==m[e.id].start).sort((e,t)=>{const r=o.get(e.id)??0,n=o.get(t.id)??0;return r!==n?r-n:m[e.id].start-m[t.id].start}),s=e.filter(e=>null===m[e.id].start);for(const e of[...a,...s]){const t=m[e.id];let o=-1;for(let e=0;g.length>e;e++){const r=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.end){o=e;break}}-1===o&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=g.length-1),g[o].occupants.push({id:e.id,end:t?.end??-1/0}),g[o].peak.topPeak=Math.max(g[o].peak.topPeak,d[e.id]),g[o].peak.botPeak=Math.max(g[o].peak.botPeak,h[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:m[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),f[e.id]=t});let y=null,b=null,v=null,x=null;const w=()=>{y=Ex(f,t),v=zx(f,t)},k=()=>{b=Ex(f,t),x=zx(f,t)};"crossing-min"===c?(w(),Hx(g,f,t),k()):"inside-out"===c?(w(),function(e,t){const o=e.length;if(1>=o)return;const r=e=>e.peak.topPeak+e.peak.botPeak,n=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(o),a=Math.floor((o-1)/2);i[a]=n[0].idx;let s=a-1,l=a+1;for(let e=1;n.length>e;e++)e%2==1&&o>l||0>s?i[l++]=n[e].idx:i[s--]=n[e].idx;const c=i.map(t=>e[t]),u=new Map;i.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(g,f),k()):"crossing-min+inside-out"===c&&(w(),Hx(g,f,t),function(e,t,o){const r=e.length;if(1>=r)return;const n=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((r-1)/2);let a=jx(t,o);for(const{slot:s}of n){const n=e.indexOf(s);if(0>n)continue;const l=i;if(n===l)continue;const c=e[n];e.splice(n,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>n){for(let e=n+1;l>=e;e++)u.set(e,e-1);u.set(n,l)}else{for(let e=l;n>e;e++)u.set(e,e+1);u.set(n,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=jx(t,o);if(d>a){const o=e[l];e.splice(l,1),e.splice(n,0,o);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(n>l){for(let e=l+1;n>=e;e++)i.set(e,e-1);i.set(l,n)}else{for(let e=n;l>e;e++)i.set(e,e+1);i.set(l,n)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=d}}(g,f,t),k());const S=g.map(e=>{const t=new Map;for(const r of e.occupants){const e=o[r.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let o={top:0,bot:0};for(const[r,n]of e){if(r>t)break;o=n}return o},C=[];for(let e=0;g.length-1>e;e++){const t=S[e],o=S[e+1],r=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let n=0;for(const e of r){const r=A(t,e),i=A(o,e);r.bot+i.top>n&&(n=r.bot+i.top)}C.push(n)}const M=[];let P=a+(g[0]?.peak.topPeak??0)*s;g.length>0&&M.push(P);for(let e=1;g.length>e;e++)P+=C[e-1]*s+a,M.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*s+a),P>i){const e=i/P;for(let t=0;M.length>t;t++)M[t]*=e}const I=0===g.length?0:g[0].peak.topPeak+C.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,_={};for(const t of e)_[t.id]=M[f[t.id]];return{effectiveSlotsHeight:I,centerlines:_,laneLifetime:m,slots:g,slotByNode:f,slotCenter:M,crossingsBefore:y,crossingsAfter:b,lengthBefore:v,lengthAfter:x}}var qx=e=>{const{bands:t=[],ribbons:o=[],showLabels:r=!0}=e.config,n=[];for(const e of o)n.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];n.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)n.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const i=r?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:n,labels:i}};function Gx(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Yx,jsx as Vx,jsxs as Xx}from"react/jsx-runtime";function Ux(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Kx(e,t){return"function"==typeof e?e(t):t[e]}var Qx=Nx(function(e,t){const{nodes:o,edges:r,domain:n,axisTicks:i=[],nodeIdAccessor:a="id",sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:c="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:m,xExtentAccessor:f="xExtent",edgeIdAccessor:g="id",colorBy:y,colorScheme:b,showLegend:v,legendPosition:x="right",pairing:w="temporal",packing:k="reuse",laneOrder:S="crossing-min",ribbonLane:A="both",lifetimeMode:C="half",showLaneRails:M=!1,showQualityReadout:P=!1,showLabels:I=!0,width:_=600,height:L=400,margin:R,title:T,description:N,summary:$,accessibleTable:B,responsiveWidth:D,responsiveHeight:F,loading:E,loadingContent:z,emptyContent:j,edgeOpacity:O=.35,timeFormat:H,valueFormat:W,tooltip:q,enableHover:G=!0,onObservation:Y,onClick:V,showParticles:X=!1,particleStyle:U,chartId:K,frameProps:Q={}}=e,[Z,J]=_x([]),[ee,te]=_x([]),oe=Lx(Z),re=Lx(ee);oe.current=Z,re.current=ee;const ne=Rx(e=>{oe.current=e,J(e)},[]),ie=Rx(e=>{re.current=e,te(e)},[]),ae=void 0!==r,se=u(ae?r:Z),le=Ix(()=>{const e=u(o??[]),t=ee;if(0===e.length&&0===t.length)return hx([],se,s,l);const r=new Set,n=[];for(const t of e){const e=Kx(a,t)+"";r.has(e)||(r.add(e),n.push(t))}for(const e of t){const t=Kx(a,e)+"";r.has(t)||(r.add(t),n.push(e))}const i=hx([],se,s,l);for(const e of i)r.has(e.id)||(r.add(e.id),n.push(e));return n},[o,ee,se,a,s,l]),ce=Lx(null),ue=Rx((e,t)=>{const o=Kx(g,e);return null!=o?o+"":`${Kx(s,e)}-${Kx(l,e)}-${t}`},[g,s,l]),de=Rx(e=>{if(null==e)return!1;const t=e;return null!=Kx(s,t)&&null!=Kx(l,t)},[s,l]);sd(t,{variant:"network",frameRef:ce,overrides:{push(e){if(de(e)){if(ae)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ne([...oe.current,e])}else ie([...re.current,e])},pushMany(e){const t=[],o=[];for(const r of e)de(r)?t.push(r):o.push(r);t.length>0&&(ae?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ne([...oe.current,...t])),o.length>0&&ie([...re.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!ae){const e=oe.current,r=[];for(let n=0;e.length>n;n++){const i=e[n];t.has(ue(i,n))?o.push(i):r.push(i)}r.length!==e.length&&ne(r)}const r=re.current,n=[];for(const e of r){const r=Kx(a,e)+"";t.has(r)?o.push(e):n.push(e)}return n.length!==r.length&&ie(n),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),r=[];if(!ae){let e=!1;const n=oe.current.map((n,i)=>o.has(ue(n,i))?(r.push(n),e=!0,t(n)):n);e&&ne(n)}let n=!1;const i=re.current.map(e=>{const i=Kx(a,e)+"";return o.has(i)?(r.push(e),n=!0,t(e)):e});return n&&ie(i),r},clear(){ae||ne([]),ie([]),ce.current?.clear()},getData:()=>se??[],getScales:()=>null},deps:[ae,de,ue,a,se,ne,ie]});const he=ue,pe=Rx(e=>Kx(a,e)+"",[a]),{nodes:me,edges:fe,domain:ge,rawNodeById:ye,rawEdgeById:be}=Ix(()=>{const e=(le??[]).map(e=>{const t={id:pe(e),__raw:e},o=f?Kx(f,e):null;if(Array.isArray(o)&&2===o.length){const e=Ux(o[0]),r=Ux(o[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(se??[]).map((e,t)=>{const o={id:he(e,t),source:Kx(s,e)+"",target:Kx(l,e)+"",value:Number(Kx(c,e)),startTime:Ux(Kx(d,e)),endTime:Ux(Kx(h,e)),__raw:e};if(p){const t=Ux(Kx(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(m){const t=Ux(Kx(m,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Ux(n[0]),Ux(n[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:r,rawEdgeById:i}},[le,se,n,pe,he,f,s,l,c,d,h,p,m]),ve=fx({nodes:le,edges:se,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:s,targetAccessor:l,colorBy:y,colorScheme:b,showLegend:!1,legendPosition:x,selection:void 0,linkedHover:void 0,onObservation:Y,onClick:V,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:K,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:R,width:_,height:L,loading:E,loadingContent:z,emptyContent:j}),xe=(v??!!y)&&!!y,we=Rx(e=>null!=R&&("number"==typeof R||null!=R[e]),[R]),ke=Ix(()=>{const e={...ve.margin};return xe&&("right"===x&&!we("right")&&140>e.right?e.right=140:"bottom"===x&&!we("bottom")&&80>e.bottom&&(e.bottom=80)),e},[ve.margin,xe,x,we]),Se=_-ke.left-ke.right,Ae=L-ke.top-ke.bottom,Ce=Ix(()=>function(e,t,o){const r=[],n=new Set(e.map(e=>e.id)),i=Array.isArray(o)&&2===o.length,a=i&&Number.isFinite(o[0])&&Number.isFinite(o[1]);i&&a&&a&&o[1]>=o[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)n.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),n.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}(me,fe,ge),[me,fe,ge]),Me=Ix(()=>Ce.length>0?null:function(e,t,o){const{plotH:r,pairing:n="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half"}=o,l=function(e,t){const o={},r={};for(const t of e)o[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:r}}(e,t),c=function(e,t,o,r="value"){const n="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const o=new Map;for(const r of e){const e=r[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const n=o.get(e);n.edges.push(r),n.total+=r.value,n.earliestStart=Math.min(n.earliestStart,r.startTime),n.latestEnd=Math.max(n.latestEnd,r.endTime)}const a=[...o.values()];a.sort("temporal"===r?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:n);return a};for(const t of e){const e=o.outgoing[t.id],r=o.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=o});else if(0===e.length)s(r,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=o});else{const t=s(r,"source"),o=s(e,"target"),n=Math.max(t.length,o.length);for(let e=0;n>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)a.get(o.id).targetSide=r;if(o[e])for(const t of o[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,l,n);let u={};for(const t of e)u[t.id]=$x(t,l,c);const d=Wx(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],o=d.slotByNode[e.target];if(void 0===t||void 0===o)continue;const r=c.get(e.id);t!==o?t>o?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(h.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],o=l.incoming[t.id],r=new Set(e.map(e=>c.get(e.id).sourceSide)),n=new Set(o.map(e=>c.get(e.id).targetSide));if(1===r.size&&o.length>0){const e=[...r][0];for(const t of o)d.slotByNode[t.source]===d.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===n.size&&e.length>0){const t=[...n][0];for(const o of e)d.slotByNode[o.source]===d.slotByNode[o.target]&&(c.get(o.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],o=l.outgoing[t.id];if(0===e.length||0===o.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===c.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},n=(e,t)=>{const n=r(),i="top"===e?n.outTop-n.inTop:n.outBot-n.inBot,a="top"===t?n.inTop-n.outTop:n.inBot-n.outBot;if(0>=i||0>=a)return!1;const s=Math.min(i,a),l=o.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let i=o.length+1;for(;i-- >0&&(n("top","bot")||n("bot","top")););}u={};for(const t of e)u[t.id]=$x(t,l,c);const p=Wx(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),m=p.effectiveSlotsHeight??p.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*r/Math.max(p.slots.length+1,1)),g=m>0?Math.max(0,(r-f*(p.slots.length+1))/m):1,y=Wx(e,t,u,l,{plotH:r,padding:f,valueScale:g,packing:i,laneOrder:a,lifetimeMode:s});return{nodeData:u,sides:c,valueScale:g,padding:f,compressedPadding:12>f,centerlines:y.centerlines,laneLifetime:y.laneLifetime,slots:y.slots,slotByNode:y.slotByNode,crossingsBefore:y.crossingsBefore,crossingsAfter:y.crossingsAfter,lengthBefore:y.lengthBefore,lengthAfter:y.lengthAfter}}(me,fe,{plotH:Ae,pairing:w,packing:k,laneOrder:S,lifetimeMode:C}),[Ce,me,fe,Ae,w,k,S,C]),Pe=Ix(()=>Tx().domain(ge).range([0,Se]),[ge,Se]),Ie=Rx((e,t)=>{if(y&&le){const t=ye.get(e);if(t)return He(t,y,ve.colorScale)}return ve.effectivePalette[t%ve.effectivePalette.length]||"#475569"},[y,le,ye,ve.colorScale,ve.effectivePalette]),_e=Ix(()=>{const e=new Map;return me.forEach((t,o)=>e.set(t.id,o)),e},[me]),Le=Ix(()=>{if(!Me)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=Me,r=[],n=[];return me.forEach((n,i)=>{const a=t[n.id];if(!a||0===a.samples.length)return;const s=function(e,t,o,r,n){if(0===e.length)return null;const i=Dx(e,n),a=e=>t-i[e].topMass*o,s=e=>t+i[e].botMass*o;let l=`M${r(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${a(e)}`;l+=` L${r(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${s(e)}`;return l+" Z"}(a.samples,e[n.id],o,Pe,ge);if(!s)return;const l=Dx(a.samples,ge),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=e[n.id]+(c.botMass-c.topMass)*o/2,d=Ie(n.id,i),h=ye.get(n.id)??n,p=function(e,t,o,r,n){const i=o.nodeData[e];if(!i||0===i.samples.length)return[];const a=o.valueScale,s=o.centerlines[e],l=Dx(i.samples,n),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=r(c.t),h=r(u.t),p=e=>r(Bx(e,n)),m=[],f=(e,t,o,r)=>`M${e},${t} L${o},${t} L${o},${r} L${e},${r} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=i.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=p(o.systemInTime),r=p(o.startTime),n=t-20,i=Math.max(d,n);if(r>i){const[o,l]=Fx(e,s,a);m.push({pathD:f(i,o,r,l),x0:n,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=i.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=p(o.systemOutTime),r=p(o.endTime),n=t+20,i=Math.min(h,n);if(i>r){const[o,l]=Fx(e,s,a);m.push({pathD:f(r,o,i,l),x0:t,x1:n,from:1,to:0})}}}}return m}(n.id,fe,Me,Pe,ge);r.push({id:n.id,pathD:s,fill:d,stroke:d,strokeWidth:.5,...p.length>0&&{gradientStubs:p},rawDatum:h,labelX:Pe(c.t)-4,labelY:u,labelText:n.id})}),fe.forEach(r=>{const i=t[r.source]?.localAttachments.get(r.id),a=t[r.target]?.localAttachments.get(r.id);if(!i||!a)return;const s=_e.get(r.source)??0,l=Ie(r.source,s),c=function(e,t,o,r,n,i,a,s){const l=n,c=e=>s?Math.max(s[0],Math.min(s[1],e)):e,u=i(c(e.time)),d=i(c(o.time)),h=e.value*l,p=o.value*l,m=e.sideMassBefore*l,f=o.sideMassAfter*l;let g,y,b,v;"top"===e.side?(g=t-m,y=g+h):(y=t+m,g=y-h),"top"===o.side?(b=r-f,v=b+p):(v=r+f,b=v-p);const x="source"===a?u+.85*(d-u):"target"===a?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:y,tx:d,tTop:b,tBot:v,cp1X:x,cp2X:x}}(i,e[r.source],a,e[r.target],o,Pe,A,ge),{pathD:u,bezier:d}=vb(c),h=be.get(r.id)??r;n.push({id:r.id,pathD:u,fill:l,opacity:O,rawDatum:h,bezier:d})}),{bands:r,ribbons:n}},[Me,me,fe,Pe,ge,Ie,ye,be,A,O,_e]),Re=Ix(()=>({bands:Le.bands,ribbons:Le.ribbons,showLabels:I}),[Le,I]),Te=Ix(()=>{if(!xe||!y)return;const e=new Map;(le??[]).forEach((t,o)=>{const r=Kx(y,t),n=null==r?"":r+"";n&&!e.has(n)&&e.set(n,{label:n,color:Ie(pe(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[xe,y,le,Ie,pe]),Ne=Ix(()=>!1!==q&&G?void 0===q||!0===q?null:xs(q)||null:null,[q,G]),$e=Rx(e=>H?H(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[H]),Be=Rx(e=>W?W(e):e+"",[W]),De=Rx(e=>{if(!e||!e.data)return null;const t=e.data;if(!Gx(t))return null;const o=t.data;if(Ne)return Ne(o);if("band"===t.__kind){const e=t.id,o=Me?function(e){if(!e)return[];const t=new Set,o=[];for(const r of e.samples){const e=r.topMass+r.botMass,n=`${r.t}:${e}`;t.has(n)||(t.add(n),o.push({t:r.t,total:e}))}return o}(Me.nodeData[e]):[],r=5,n=o.length>r?o.length:null,i=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),r=o.length-1,n=[{...o[0],mark:"min"},{...o[Math.floor(.25*r)],mark:"q25"},{...o[Math.floor(.5*r)],mark:"median"},{...o[Math.floor(.75*r)],mark:"q75"},{...o[r],mark:"max"}],i=new Set,a=[];for(const e of n)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(o,r);return Xx("div",{style:{minWidth:160},children:[Vx("div",{style:{fontWeight:600,marginBottom:4},children:e}),i.length>0&&Xx("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Vx("thead",{children:Xx("tr",{style:{opacity:.6},children:[Vx("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Vx("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=n&&Vx("th",{})]})}),Vx("tbody",{children:i.map((e,t)=>Xx("tr",{children:[Vx("td",{style:{paddingRight:8},children:$e(e.t)}),Vx("td",{style:{textAlign:"right"},children:Be(e.total)}),null!=n&&Vx("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=n&&Xx("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",i.length," of ",n," samples"]})]})}const r=o,n=Kx(s,r),i=Kx(l,r),a=Kx(c,r),u=Kx(d,r),p=Kx(h,r);return Xx("div",{style:{minWidth:160},children:[Xx("div",{style:{fontWeight:600,marginBottom:4},children:[n+""," → ",i+""]}),Xx("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&Xx(Yx,{children:[Vx("span",{style:{opacity:.6},children:"value"}),Vx("span",{style:{textAlign:"right"},children:Be(Number(a))})]}),null!=u&&Xx(Yx,{children:[Vx("span",{style:{opacity:.6},children:"start"}),Vx("span",{style:{textAlign:"right"},children:$e(Ux(u))})]}),null!=p&&Xx(Yx,{children:[Vx("span",{style:{opacity:.6},children:"end"}),Vx("span",{style:{textAlign:"right"},children:$e(Ux(p))})]})]})]})},[Me,Ne,$e,Be,s,l,c,d,h]),Fe=Ix(()=>{if(!Me)return null;const{centerlines:e,laneLifetime:t,nodeData:o,valueScale:r,compressedPadding:n,crossingsBefore:a,crossingsAfter:s,lengthBefore:l,lengthAfter:c}=Me;let u=null,d=null;for(const e of me){const o=t[e.id];if(!o||null===o.start||null===o.end)continue;const r=Pe(o.start),n=Pe(o.end);(null===u||u>r)&&(u=r),(null===d||n>d)&&(d=n)}const h=e=>Math.max(0,Math.min(Se,e)),p=h(u??0),m=Math.max(p,h(d??Se));return Xx("g",{children:[P&&null!==(s??null)&&Xx("text",{x:Se,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(l)," → ",Math.round(c)]}),n&&Vx("text",{x:Se,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),i.map((e,t)=>{const o=Pe(Ux(e.date));return p-.5>o||o>m+.5?null:Vx("line",{x1:o,y1:0,x2:o,y2:Ae,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),M&&me.map((n,i)=>{const a=t[n.id];if(!a||null===a.start)return null;const s=o[n.id],l=s?{topPeak:s.topPeak,botPeak:s.botPeak}:{topPeak:0,botPeak:0},c=e[n.id]+(l.botPeak-l.topPeak)*r/2,u=Pe(a.start),d=Pe(a.end),h=Ie(n.id,i);return Xx("g",{children:[Vx("line",{x1:u,y1:c,x2:d,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Vx("line",{x1:u,y1:c-4,x2:u,y2:c+4,stroke:h,strokeOpacity:.5}),Vx("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+n.id)}),Vx("line",{x1:p,y1:Ae+4,x2:m,y2:Ae+4,stroke:"#94a3b8"}),i.map((e,t)=>{const o=Ux(e.date),r=Pe(o);if(p-.5>r||r>m+.5)return null;const n=null!=e.label?e.label:H?H(new Date(o)):"";return Xx("g",{transform:`translate(${r},${Ae+4})`,children:[Vx("line",{y2:6,stroke:"#94a3b8"}),Vx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:n})]},t)})]})},[Me,i,Pe,Se,Ae,M,me,Ie,P,H]),Ee=Ix(()=>(le??[]).map(e=>({id:pe(e),data:e})),[le,pe]),ze=Ix(()=>{const e=new Map;for(const t of Le.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Le]),je=Ix(()=>(se??[]).map((e,t)=>{const o=he(e,t),r=Number(Kx(c,e));return{id:o,source:Kx(s,e)+"",target:Kx(l,e)+"",value:Number.isFinite(r)?r:0,bezier:ze.get(o),data:e}}),[se,he,s,l,c,ze]),Oe=ve.loadingEl,We=ve.emptyEl;return Ce.length>0?Xx("svg",{width:_,height:L,role:"img","aria-label":T??"Process Sankey validation failed",children:[Vx("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ce.map((e,t)=>{return Vx("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+(o=e,"invalid-node-time"===o.kind?`node ${o.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===o.kind?`edge ${o.id} has an invalid startTime or endTime`:"invalid-domain"===o.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===o.kind?`edge ${o.id} must have a positive finite value`:"missing-node"===o.kind?`edge ${o.id} references missing ${o.endpoint} node "${o.nodeId}"`:"backward-edge"===o.kind?`edge ${o.id} (${o.source}->${o.target}) ends before it starts`:o.kind)},t);var o})]}):Oe||We||Vx(cx,{ref:ce,chartType:"force",nodes:Ee,edges:je,customNetworkLayout:qx,layoutConfig:Re,size:[_,L],responsiveWidth:D,responsiveHeight:F,margin:ke,title:T,description:N??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:$,accessibleTable:B,enableHover:G,tooltipContent:!1===q?()=>null:De,backgroundGraphics:Fe,showParticles:X,particleStyle:U,legend:Te,legendPosition:x,onObservation:Y,...V&&{customClickBehavior:e=>{if(!e||!e.data||!V)return;const t=e.data;Gx(t)&&V(t.data,{x:e.x,y:e.y})}},chartId:K,colorScheme:Array.isArray(b)?b:void 0,...Q})});Qx.displayName="ProcessSankey";import{useMemo as Zx}from"react";import{jsx as Jx}from"react/jsx-runtime";function ew(e){const t=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:o,margin:r,className:n,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:f=5,tooltip:g,frameProps:y={},onObservation:b,onClick:v,chartId:x,selection:w,linkedHover:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:P,opacity:I}=e,{width:_,height:L,enableHover:R,showLabels:T=!0,title:N,description:$,summary:B,accessibleTable:D}=t,F=fx({nodes:Zx(()=>dx(o??null,s),[o,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:C,selection:w,linkedHover:k,onObservation:b,onClick:v,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:_,height:L,loading:S,loadingContent:A}),E=Zx(()=>new Map,[]),z=Zx(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?je[(e.depth||0)%je.length]:u?He(e.data||e,u,F.colorScale):xu(void 0,F.themeCategorical,d,void 0,E),t},[u,h,F.colorScale,F.themeCategorical,d,E]),j=Zx(()=>nd(z,{stroke:M,strokeWidth:P,opacity:I}),[z,M,P,I]),O=Zx(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=Zx(()=>nd(O,{stroke:M,strokeWidth:P,opacity:I}),[O,M,P,I]),W=Zx(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return px(l)},[i,l]),q=Uu({componentName:"TreeDiagram",data:o});return q?Jx(Tu,{componentName:"TreeDiagram",message:q,width:_,height:L}):F.loadingEl?F.loadingEl:Jx(Eu,{componentName:"TreeDiagram",width:_,height:L,children:Jx(cx,{chartType:i,...null!=o&&{data:o},size:[_,L],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:F.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:W,treeOrientation:a,edgeType:p,nodeStyle:j,edgeStyle:H,colorBy:u,colorScheme:F.effectivePalette,colorByDepth:h,nodeSize:f,nodeLabel:T?m||c:void 0,showLabels:T,enableHover:R,tooltipContent:!1===g?()=>null:xs(g)||void 0,...cd({linkedHover:k,selection:w,onObservation:b,onClick:v,mobileInteraction:F.mobileInteraction,customHoverBehavior:F.customHoverBehavior,customClickBehavior:F.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&"none"!==C&&{legendHoverBehavior:F.legendState.onLegendHover,legendClickBehavior:F.legendState.onLegendClick,legendHighlightedCategory:F.legendState.highlightedCategory,legendIsolatedCategories:F.legendState.isolatedCategories},className:n,title:N,description:$,summary:B,accessibleTable:D,...null!=e.animate&&{animate:e.animate},...y})})}ew.displayName="TreeDiagram";import{useMemo as tw,useCallback as ow}from"react";import{jsx as rw}from"react/jsx-runtime";function nw(e){const t=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:o,margin:r,className:n,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:p=4,paddingTop:m,nodeStyle:f,tooltip:g,frameProps:y={},selection:b,linkedHover:v,onObservation:x,onClick:w,chartId:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:P,opacity:I}=e,{nodeStyle:_,...L}=y,{width:R,height:T,enableHover:N,showLabels:$=!0,title:B,description:D,summary:F,accessibleTable:E}=t,z=fx({nodes:tw(()=>dx(o??null,i),[o,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:C,selection:b,linkedHover:v,onObservation:x,onClick:w,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:k,marginDefaults:t.marginDefaults,userMargin:r,width:R,height:T,loading:S,loadingContent:A}),j=td(b),O=z.customHoverBehavior,H=ow(e=>{if(!e)return O(null);const t=e.data||e;O({data:t?.data||t})},[O]),W=tw(()=>new Map,[]),q=tw(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?je[(e.depth||0)%je.length]:l?He(e.data||e,l,z.colorScale):xu(void 0,z.themeCategorical,c,void 0,W),t},[l,u,z.colorScale,z.themeCategorical,c,W]),G=tw(()=>f||_?e=>({...q(e),..._?_(e)??{}:{},...f?f(e)??{}:{}}):q,[q,f,_]),Y=tw(()=>nd(G,{stroke:M,strokeWidth:P,opacity:I}),[G,M,P,I]),V=tw(()=>z.activeSelectionHook?e=>{const t={...Y(e)};if(z.activeSelectionHook.isActive)if(z.activeSelectionHook.predicate(e.data||e))j?.selectedStyle&&Object.assign(t,j.selectedStyle);else{const e=j?.unselectedOpacity??.5;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,j?.unselectedStyle&&Object.assign(t,j.unselectedStyle)}return t}:Y,[Y,z.activeSelectionHook,j]),X=tw(()=>px(a),[a]),U=void 0!==m?m:!$||"parent"!==d&&"all"!==d?void 0:18,K=Uu({componentName:"Treemap",data:o});return K?rw(Tu,{componentName:"Treemap",message:K,width:R,height:T}):z.loadingEl?z.loadingEl:rw(Eu,{componentName:"Treemap",width:R,height:T,children:rw(cx,{chartType:"treemap",...null!=o&&{data:o},size:[R,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:X,padding:p,paddingTop:U,nodeStyle:V,colorBy:l,colorScheme:z.effectivePalette,colorByDepth:u,nodeLabel:$?h||s:void 0,showLabels:$,labelMode:d,enableHover:N,tooltipContent:!1===g?()=>null:xs(g)||void 0,...cd({linkedHover:v,selection:b,onObservation:x,onClick:w,mobileInteraction:z.mobileInteraction,customHoverBehavior:H,customClickBehavior:z.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&"none"!==C&&{legendHoverBehavior:z.legendState.onLegendHover,legendClickBehavior:z.legendState.onLegendClick,legendHighlightedCategory:z.legendState.highlightedCategory,legendIsolatedCategories:z.legendState.isolatedCategories},className:n,title:B,description:D,summary:F,accessibleTable:E,...null!=e.animate&&{animate:e.animate},...L})})}nw.displayName="Treemap";import{useMemo as iw}from"react";import{jsx as aw}from"react/jsx-runtime";function sw(e){const t=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:o,margin:r,className:n,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:p=4,tooltip:m,frameProps:f={},onObservation:g,onClick:y,chartId:b,selection:v,linkedHover:x,loading:w,loadingContent:k,legendInteraction:S,stroke:A,strokeWidth:C,opacity:M}=e,{width:P,height:I,enableHover:_,showLabels:L=!0,title:R,description:T,summary:N,accessibleTable:$}=t,B=fx({nodes:iw(()=>dx(o??null,i),[o,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:g,onClick:y,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:r,width:P,height:I,loading:w,loadingContent:k}),D=iw(()=>new Map,[]),F=iw(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?je[(e.depth||0)%je.length]:l?He(e.data||e,l,B.colorScale):xu(void 0,B.themeCategorical,c,void 0,D),t},[l,u,B.colorScale,h,B.themeCategorical,c,D]),E=iw(()=>nd(F,{stroke:A,strokeWidth:C,opacity:M}),[F,A,C,M]),z=iw(()=>px(a),[a]),j=Uu({componentName:"CirclePack",data:o});return j?aw(Tu,{componentName:"CirclePack",message:j,width:P,height:I}):B.loadingEl?B.loadingEl:aw(Eu,{componentName:"CirclePack",width:P,height:I,children:aw(cx,{chartType:"circlepack",...null!=o&&{data:o},size:[P,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:z,padding:p,nodeStyle:E,colorBy:l,colorScheme:B.effectivePalette,colorByDepth:u,nodeLabel:L?d||s:void 0,showLabels:L,enableHover:_,tooltipContent:!1===m?()=>null:xs(m)||void 0,...cd({linkedHover:x,selection:v,onObservation:g,onClick:y,mobileInteraction:B.mobileInteraction,customHoverBehavior:B.customHoverBehavior,customClickBehavior:B.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},className:n,title:R,description:T,summary:N,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...f})})}sw.displayName="CirclePack";import{useMemo as lw}from"react";import{jsx as cw}from"react/jsx-runtime";var uw=je;function dw(e){const t=Iu(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:o,margin:r,className:n,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:p,revolutionStyle:m,eccentricity:f=1,showRings:g=!0,nodeRadius:y=6,showLabels:b=!1,animated:v=!0,tooltip:x,foregroundGraphics:w,annotations:k,frameProps:S={},onObservation:A,onClick:C,chartId:M,selection:P,linkedHover:I,loading:_,loadingContent:L,stroke:R,strokeWidth:T,opacity:N}=e,{width:$,height:B,enableHover:D,title:F,description:E,summary:z,accessibleTable:j}=t,O=fx({nodes:lw(()=>dx(o,i),[o,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:s,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:P,linkedHover:I,onObservation:A,onClick:C,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:M,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:$,height:B,loading:_,loadingContent:L}),H=lw(()=>new Map,[]),{colorScale:W,customClickBehavior:q,customHoverBehavior:G,themeCategorical:Y}=O,V=lw(()=>{if(Array.isArray(l))return l;const e=Fe[l];return Array.isArray(e)?e:Ee},[l]),X=lw(()=>e=>{const t={stroke:"#fff",strokeWidth:1},o=0===(e.depth??0);return t.fill=c?o?V[0]:uw[(e.depth||0)%uw.length]:s?He(e.data||e,s,W):xu(void 0,Y,l,void 0,H),t.opacity=o?1:.85,t},[s,c,W,V,Y,l,H]),U=lw(()=>nd(X,{stroke:R,strokeWidth:T,opacity:N}),[X,R,T,N]),K=lw(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=lw(()=>e=>{G(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[G]),Z=lw(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=Uu({componentName:"OrbitDiagram",data:o});return J?cw(Tu,{componentName:"OrbitDiagram",message:J,width:$,height:B}):O.loadingEl?O.loadingEl:cw(Eu,{componentName:"OrbitDiagram",width:$,height:B,children:cw(cx,{chartType:"orbit",...null!=o&&{data:o},size:[$,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:O.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:U,edgeStyle:K,colorBy:s,colorScheme:O.effectivePalette,colorByDepth:c,nodeSize:y,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&D,tooltipContent:v?void 0:!1===x?()=>null:xs(x)||void 0,...cd({linkedHover:I,selection:P,onObservation:A,onClick:C,mobileInteraction:O.mobileInteraction,customHoverBehavior:Q,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:w,annotations:k,className:n,title:F,description:E,summary:z,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:p,orbitRevolutionStyle:m,orbitEccentricity:f,orbitShowRings:g,orbitAnimated:v,accessibleTable:j,...null!=e.animate&&{animate:e.animate},...S})})}dw.displayName="OrbitDiagram";import{useRef as hw,useImperativeHandle as pw,forwardRef as mw,useCallback as fw,useState as gw,useEffect as yw}from"react";import{jsx as bw,jsxs as vw}from"react/jsx-runtime";var xw={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ww={opacity:.7,marginRight:4};function kw(e,t,o){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:o]}function Sw(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Aw(e={}){const{timeAccessor:t,valueAccessor:o,xLabel:r="x",yLabel:n="y"}=e;return e=>{const i=e?.data??null,a=kw(i,t,"time"),s=kw(i,o,"value");return vw("div",{className:"semiotic-tooltip",style:xw,children:[vw("div",{children:[vw("span",{style:ww,children:[r,":"]}),Sw(a)]}),vw("div",{children:[vw("span",{style:ww,children:[n,":"]}),Sw(s)]})]})}}function Cw(e,t){return null!=e?e:Math.max(t?.length??0,200)}var Mw=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,o=e._mean-this._mean;this._mean+=o*e._count/t,this._m2+=e._m2+o*o*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Pw=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const o=this.hop,r=Math.floor(e/o);for(let n=Math.floor((e-this.size)/o)+1;r>=n;n++)this.bump(n*o,t)}bump(e,t){let o=this.windows.get(e);o||(o=new Mw,this.windows.set(e,o)),o.push(t)}pushSession(e,t){const o=this.gap,r=new Mw;r.push(t);let n=e,i=e;const a=[],s={start:n,end:i,stats:r};for(const t of this.sessions)e-o>t.end||t.start>e+o?a.push(t):(s.stats.merge(t.stats),n>t.start&&(n=t.start),t.end>i&&(i=t.end));s.start=n,s.end=i,a.push(s),a.sort((e,t)=>e.start-t.start),this.sessions=a}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let o=0;t>o;o++)this.windows.delete(e[o])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,o]of this.windows){const r=t+this.size;e.push(this.row(t,r,o,r>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,o,r){return{start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Iw(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}var _w={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Lw=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Rw(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Lw.lastIndex=0;let o,r=0,n=0;for(;null!==(o=Lw.exec(t));){const e=parseFloat(o[1]),t=_w[o[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,n+=o[0].length}return n!==t.length?null:r>0?r:null}var Tw="time",Nw="value",$w="__aggLower",Bw="__aggUpper",Dw="__aggPartial",Fw="count",Ew="__aggStart",zw="__aggEnd";function jw(e,t){const o=t.stat??"mean",r=t.band??"none",n=t.sigma??1;return e.emit().map(e=>{const t={[Tw]:(e.start+e.end)/2,[Nw]:Iw(e,o),[Fw]:e.count,[Dw]:e.partial,[Ew]:e.start,[zw]:e.end},i=function(e,t,o,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const n=Iw(e,o),i=e.stddev*r;return[n-i,n+i]}(e,r,o,n);return i&&(t[$w]=i[0],t[Bw]=i[1]),t})}var Ow=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const o=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,o.push(e),"drop"===this.latePolicy?{released:[],late:o}:{released:[e],late:o}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:o})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],o=[];for(const r of this.held)this.getTime(r)>e?o.push(r):t.push(r);return this.held=o,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{jsx as Hw}from"react/jsx-runtime";function Ww(e,t,o){const r="function"==typeof t?t(e):e[t??o];if(null==r)return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isFinite(n)?n:null}var qw=mw(function(e,t){const o=Iu(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:n,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,stroke:f="#007bff",strokeWidth:g=2,strokeDasharray:y,opacity:b,background:v,tooltipContent:x,tooltip:w,onHover:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:_,staleness:L,transition:R,linkedHover:T,selection:N,onObservation:$,chartId:B,loading:D,loadingContent:F,emptyContent:E,emphasis:z,legendPosition:j,aggregate:O,eventTime:H}=e,W=o.showAxes,q=o.enableHover,G=n??o.marginDefaults,Y=r??[o.width,o.height],V=x??w??Aw({timeAccessor:u,valueAccessor:d}),X=hw(null),{customHoverBehavior:U}=Su({selection:N,linkedHover:T,unwrapData:!0,onObservation:$,chartType:"RealtimeLineChart",chartId:B}),K=fw(e=>{k&&k(e),U(e)},[k,U]),Q=null!=O,[Z,J]=gw([]),ee=hw(null),te=hw(O);te.current=O;const oe=hw(Q);oe.current=Q;const re=hw(Z);re.current=Z;const ne=hw({timeAccessor:u,valueAccessor:d});ne.current={timeAccessor:u,valueAccessor:d},yw(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",o=Rw("session"===t?e.gap??e.size:e.size);if(null==o)return null;const r=null!=e.hop?Rw(e.hop):void 0,n=null!=e.gap?Rw(e.gap):void 0;return new Pw({window:t,size:o,hop:r??void 0,gap:n??void 0,retain:e.retain})}(e);if(ee.current=t,t&&c){const{timeAccessor:e,valueAccessor:o}=ne.current;for(const r of c){const n=Ww(r,e,"time"),i=Ww(r,o,"value");null!=n&&null!=i&&t.push(n,i)}}J(t?jw(t,e):[])},[Q?[O.window??"tumbling",O.size,O.hop??"",O.gap??"",O.retain??""].join("|"):"",Q,c]),yw(()=>{Q&&ee.current&&J(jw(ee.current,te.current))},[O?.stat,O?.band,O?.sigma]);const ie=fw(e=>{const t=ee.current,o=te.current;if(!t||!o)return;const{timeAccessor:r,valueAccessor:n}=ne.current;for(const o of e){const e=Ww(o,r,"time"),i=Ww(o,n,"value");null!=e&&null!=i&&t.push(e,i)}J(jw(t,o))},[]),ae=null!=H,se=hw(null),le=hw(H);le.current=H;const ce=hw(ae);ce.current=ae;const ue=hw($);ue.current=$;const de=hw(B);de.current=B,yw(()=>{se.current=ae?function(e){const t=Rw(e.lateness);return null==t?null:new Ow({lateness:t,getTime:e=>Ww(e,ne.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(le.current):null},[ae?`${H.lateness}|${H.latePolicy??"drop"}`:"",ae]);const he=fw(e=>{0!==e.length&&(oe.current?ie(e):X.current?.pushMany(e))},[ie]),pe=fw(e=>{const t=se.current;if(!ce.current||!t)return void he(e);const o=[];for(const r of e){const e=t.push(r);if(e.released.length&&o.push(...e.released),e.late.length){const o=ue.current;if(o){const{timeAccessor:r}=ne.current,n=le.current?.latePolicy??"drop";for(const i of e.late)o({type:"late-data",datum:i,eventTime:Ww(i,r,"time")??NaN,watermark:t.watermark,policy:n,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:de.current})}}}he(o)},[he]);pw(t,()=>({push:e=>pe([e]),pushMany:e=>pe(e),remove:e=>oe.current?[]:X.current?.remove(e)??[],update:(e,t)=>oe.current?[]:X.current?.update(e,t)??[],clear:()=>{se.current?.clear(),oe.current?(ee.current?.clear(),J([])):X.current?.clear()},getData:()=>oe.current?re.current:X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[pe]);const me=Hu(D,Y[0],Y[1],F),fe=me?null:Ou(Q?void 0:c,Y[0],Y[1],E),ge={stroke:f,strokeWidth:g,strokeDasharray:y};null!=b&&(ge.opacity=b);const ye=Cw(l,c),be=Q?Z:c,ve=Q?Tw:u,xe=Q?Nw:d,we=Q&&O&&"none"!==(O.band??"none")?{y0Accessor:$w,y1Accessor:Bw,perSeries:!1}:void 0;return me||fe||Hw(Yl,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,margin:G,className:z?`${i||""} semiotic-emphasis-${z}`.trim():i,arrowOfTime:a,windowMode:Q?"growing":s,windowSize:Q?Math.max(1,O?.retain??Math.max(Z.length,600)):ye,data:be,timeAccessor:ve,valueAccessor:xe,xExtent:h,yExtent:p,extentPadding:m,band:we,lineStyle:ge,showAxes:W,background:v,hoverAnnotation:q,tooltipContent:V,...cd({linkedHover:T,selection:N,onObservation:$,forceHoverBehavior:!0,mobileInteraction:o.mobileInteraction,customHoverBehavior:K}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:_,staleness:L,transition:R,pointIdAccessor:e.pointIdAccessor,legendPosition:j})});qw.displayName="RealtimeLineChart";import{useRef as Gw,useImperativeHandle as Yw,forwardRef as Vw,useCallback as Xw,useMemo as Uw}from"react";import{jsx as Kw}from"react/jsx-runtime";function Qw(e,t,o){const r="function"==typeof t?t(e):e[t??o];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const n=Number(r);return Number.isFinite(n)?n:null}var Zw=Vw(function(e,t){const o=Iu(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:r,size:n,margin:i,className:a,arrowOfTime:s="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:d,valueAccessor:h,direction:p="up",timeExtent:m,valueExtent:f,extentPadding:g,categoryAccessor:y,colors:b,fill:v,stroke:x,strokeWidth:w,opacity:k,gap:S,background:A,tooltipContent:C,tooltip:M,onHover:P,annotations:I,autoPlaceAnnotations:_,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:T,linkedHover:N,selection:$,decay:B,pulse:D,staleness:F,transition:E,onObservation:z,chartId:j,loading:O,loadingContent:H,emptyContent:W,emphasis:q,legendPosition:G,brush:Y,onBrush:V,linkedBrush:X}=e,U=o.showAxes,K=o.enableHover,Q=i??o.marginDefaults,Z=n??[o.width,o.height],J=C??M??function(e={}){const{timeAccessor:t,valueAccessor:o}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=kw(r,t,"time"),n=kw(r,o,"value");return vw("div",{className:"semiotic-tooltip",style:xw,children:[vw("div",{children:[bw("span",{style:ww,children:"x:"}),Sw(e)]}),vw("div",{children:[bw("span",{style:ww,children:"y:"}),Sw(n)]})]})}return vw("div",{className:"semiotic-tooltip",style:xw,children:[vw("div",{children:[bw("span",{style:ww,children:"range:"}),Sw(r.binStart),"–",Sw(r.binEnd)]}),null!=r.total&&vw("div",{children:[bw("span",{style:ww,children:"count:"}),Sw(r.total)]}),null!=r.category&&vw("div",{children:[bw("span",{style:ww,children:"category:"}),Sw(r.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ee=Gw(null),{customHoverBehavior:te}=Su({selection:$,linkedHover:N,unwrapData:!0,onObservation:z,chartType:"RealtimeHistogram",chartId:j}),oe=Xw(e=>{P&&P(e),te(e)},[P,te]),re=!0===Y?{dimension:"x",snap:"bin"}:"x"===Y?{dimension:"x"}:"object"==typeof Y?Y:void 0,ne=Kc(X),ie="string"==typeof d?d:"time",ae=Lc({name:ne?.name||"__unused_hist_brush__",xField:ne?.xField||ie,...ne?.yField?{yField:ne.yField}:{}}),se=Gw(ae.brushInteraction);se.current=ae.brushInteraction;const le=Xw(e=>{if(V&&V(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}),ne){const t=se.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[V,z,j,ne]);Yw(t,()=>({push:e=>ee.current?.push(e),pushMany:e=>ee.current?.pushMany(e),remove:e=>ee.current?.remove(e)??[],update:(e,t)=>ee.current?.update(e,t)??[],clear:()=>ee.current?.clear(),getData:()=>ee.current?.getData()??[],getScales:()=>ee.current?.getScales()??null}),[]);const ce=Hu(O,Z[0],Z[1],H),ue=ce?null:Ou(u,Z[0],Z[1],W),de={};null!=v&&(de.fill=v),null!=x&&(de.stroke=x),null!=w&&(de.strokeWidth=w),null!=k&&(de.opacity=k),null!=S&&(de.gap=S);const he=q?`${a||""} semiotic-emphasis-${q}`.trim():a,pe=Cw(c,u),me=Uw(()=>"down"!==p?f:function({data:e,valueAccessor:t,timeAccessor:o,binSize:r,valueExtent:n,extentPadding:i}){if(n)return[n[1],n[0]];if(!e||0===e.length)return;const a=new Map;for(const n of e){const e=Qw(n,o,"time"),i=Qw(n,t,"value");if(null==e||null==i)continue;const s=Math.floor(e/r)*r;a.set(s,(a.get(s)??0)+i)}let s=0;for(const e of a.values())e>s&&(s=e);return[s>0?s+s*(i??.1):1,0]}({data:u,valueAccessor:h,timeAccessor:d,binSize:r,valueExtent:f,extentPadding:g}),[p,u,h,d,r,f,g]);return ce||ue||Kw(Yl,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:he,arrowOfTime:s,windowMode:l,windowSize:pe,data:u,timeAccessor:d,valueAccessor:h,xExtent:m,yExtent:me,extentPadding:g,binSize:r,categoryAccessor:y,barColors:b,barStyle:de,showAxes:U,background:A,hoverAnnotation:K,tooltipContent:J,...cd({linkedHover:N,selection:$,onObservation:z,forceHoverBehavior:!0,mobileInteraction:o.mobileInteraction,customHoverBehavior:oe}),annotations:I,autoPlaceAnnotations:_,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:T,decay:B,pulse:D,staleness:F,transition:E,pointIdAccessor:e.pointIdAccessor,legendPosition:G,brush:re||(X?{dimension:"x"}:void 0),onBrush:re||X?le:void 0})});function Jw(e){return Kw(Zw,{...e,windowMode:"growing"})}Zw.displayName="RealtimeHistogram",Jw.displayName="TemporalHistogram";import{useRef as ek,useImperativeHandle as tk,forwardRef as ok,useCallback as rk}from"react";import{jsx as nk}from"react/jsx-runtime";var ik=ok(function(e,t){const o=Iu(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:n,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,yScaleType:m,extentPadding:f,categoryAccessor:g,colors:y,radius:b,fill:v,opacity:x,stroke:w,strokeWidth:k,pointStyle:S,background:A,tooltipContent:C,tooltip:M,onHover:P,annotations:I,autoPlaceAnnotations:_,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:T,linkedHover:N,selection:$,onObservation:B,chartId:D,loading:F,loadingContent:E,emptyContent:z,emphasis:j,legendPosition:O}=e,H=o.showAxes,W=o.enableHover,q=n??o.marginDefaults,G=r??[o.width,o.height],Y=C??M??Aw({timeAccessor:u,valueAccessor:d}),V=ek(null),{customHoverBehavior:X}=Su({selection:$,linkedHover:N,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:D}),U=rk(e=>{P&&P(e),X(e)},[P,X]);tk(t,()=>({push:e=>V.current?.push(e),pushMany:e=>V.current?.pushMany(e),remove:e=>V.current?.remove(e)??[],update:(e,t)=>V.current?.update(e,t)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=Hu(F,G[0],G[1],E),Q=K?null:Ou(c,G[0],G[1],z),Z={};null!=b&&(Z.radius=b),null!=v&&(Z.fill=v),null!=x&&(Z.opacity=x),null!=w&&(Z.stroke=w),null!=k&&(Z.strokeWidth=k);const J=S,ee=j?`${i||""} semiotic-emphasis-${j}`.trim():i,te=Cw(l,c);return K||Q||nk(Yl,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:G,margin:q,className:ee,arrowOfTime:a,windowMode:s,windowSize:te,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,yScaleType:m,extentPadding:f,categoryAccessor:g,barColors:y,swarmStyle:Z,pointStyle:J,showAxes:H,background:A,hoverAnnotation:W,tooltipContent:Y,...cd({linkedHover:N,selection:$,onObservation:B,forceHoverBehavior:!0,mobileInteraction:o.mobileInteraction,customHoverBehavior:U}),annotations:I,autoPlaceAnnotations:_,svgAnnotationRules:L,tickFormatTime:R,tickFormatValue:T,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});ik.displayName="RealtimeSwarmChart";import{useRef as ak,useImperativeHandle as sk,forwardRef as lk,useCallback as ck}from"react";import{jsx as uk}from"react/jsx-runtime";var dk=lk(function(e,t){const o=Iu(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:n,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,positiveColor:f,negativeColor:g,connectorStroke:y,connectorWidth:b,gap:v,stroke:x,strokeWidth:w,opacity:k,background:S,tooltipContent:A,tooltip:C,onHover:M,annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:_,tickFormatTime:L,tickFormatValue:R,linkedHover:T,selection:N,onObservation:$,chartId:B,loading:D,loadingContent:F,emptyContent:E,emphasis:z,legendPosition:j}=e,O=o.showAxes,H=o.enableHover,W=n??o.marginDefaults,q=r??[o.width,o.height],G=A??C??function(e={}){const{timeAccessor:t,valueAccessor:o}=e;return e=>{const r=e?.data??null,n=kw(r,t,"time"),i=r?.delta??kw(r,o,"value"),a=r?.cumEnd,s="number"==typeof i?0>i?Sw(i):"+"+Sw(i):Sw(i);return vw("div",{className:"semiotic-tooltip",style:xw,children:[vw("div",{children:[bw("span",{style:ww,children:"x:"}),Sw(n)]}),vw("div",{children:[bw("span",{style:ww,children:"Δ:"}),s]}),null!=a&&vw("div",{children:[bw("span",{style:ww,children:"total:"}),Sw(a)]})]})}}({timeAccessor:u,valueAccessor:d}),Y=ak(null),{customHoverBehavior:V}=Su({selection:N,linkedHover:T,unwrapData:!0,onObservation:$,chartType:"RealtimeWaterfallChart",chartId:B}),X=ck(e=>{M&&M(e),V(e)},[M,V]);sk(t,()=>({push:e=>Y.current?.push(e),pushMany:e=>Y.current?.pushMany(e),remove:e=>Y.current?.remove(e)??[],update:(e,t)=>Y.current?.update(e,t)??[],clear:()=>Y.current?.clear(),getData:()=>Y.current?.getData()??[],getScales:()=>Y.current?.getScales()??null}),[]);const U=Hu(D,q[0],q[1],F),K=U?null:Ou(c,q[0],q[1],E),Q={};null!=f&&(Q.positiveColor=f),null!=g&&(Q.negativeColor=g),null!=y&&(Q.connectorStroke=y),null!=b&&(Q.connectorWidth=b),null!=v&&(Q.gap=v),null!=x&&(Q.stroke=x),null!=w&&(Q.strokeWidth=w),null!=k&&(Q.opacity=k);const Z=z?`${i||""} semiotic-emphasis-${z}`.trim():i,J=Cw(l,c);return U||K||uk(Yl,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:q,margin:W,className:Z,arrowOfTime:a,windowMode:s,windowSize:J,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,extentPadding:m,waterfallStyle:Q,showAxes:O,background:S,hoverAnnotation:H,tooltipContent:G,...cd({linkedHover:T,selection:N,onObservation:$,forceHoverBehavior:!0,mobileInteraction:o.mobileInteraction,customHoverBehavior:X}),annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:_,tickFormatTime:L,tickFormatValue:R,legendPosition:j,pointIdAccessor:e.pointIdAccessor})});dk.displayName="RealtimeWaterfallChart";import{useRef as hk,useImperativeHandle as pk,forwardRef as mk,useCallback as fk}from"react";import{jsx as gk}from"react/jsx-runtime";var yk=mk(function(e,t){const o=Iu(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:n,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:p,valueExtent:m,extentPadding:f,heatmapXBins:g=20,heatmapYBins:y=20,aggregation:b="count",background:v,tooltipContent:x,tooltip:w,onHover:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:_,staleness:L,linkedHover:R,selection:T,onObservation:N,chartId:$,loading:B,loadingContent:D,emptyContent:F,emphasis:E,legendPosition:z}=e,j=o.showAxes,O=o.enableHover,H=n??o.marginDefaults,W=r??[o.width,o.height],q=x??w??function(e={}){const{timeAccessor:t,valueAccessor:o,xLabel:r="x",yLabel:n="y"}=e;return e=>{const i=e?.data??null,a=i?.xCenter??kw(i,t,"time"),s=i?.yCenter??kw(i,o,"value"),l=i?.count,c=i?.sum,u=i?.value,d=i?.agg??"count";return vw("div",{className:"semiotic-tooltip",style:xw,children:[vw("div",{children:[vw("span",{style:ww,children:[r,":"]}),Sw(a)]}),vw("div",{children:[vw("span",{style:ww,children:[n,":"]}),Sw(s)]}),null!=l&&vw("div",{children:[bw("span",{style:ww,children:"count:"}),Sw(l)]}),"sum"===d&&null!=c&&vw("div",{children:[bw("span",{style:ww,children:"sum:"}),Sw(c)]}),"mean"===d&&null!=u&&vw("div",{children:[bw("span",{style:ww,children:"mean:"}),Sw(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=hk(null),{customHoverBehavior:Y}=Su({selection:T,linkedHover:R,unwrapData:!0,onObservation:N,chartType:"RealtimeHeatmap",chartId:$}),V=fk(e=>{k&&k(e),Y(e)},[k,Y]);pk(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const X=Hu(B,W[0],W[1],D),U=X?null:Ou(c,W[0],W[1],F),K=E?`${i||""} semiotic-emphasis-${E}`.trim():i,Q=Cw(l,c);return X||U||gk(Yl,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:W,margin:H,className:K,arrowOfTime:a,windowMode:s,windowSize:Q,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:p,yExtent:m,extentPadding:f,heatmapXBins:g,heatmapYBins:y,heatmapAggregation:b,showAxes:j,background:v,hoverAnnotation:O,tooltipContent:q,...cd({linkedHover:R,selection:T,onObservation:N,forceHoverBehavior:!0,mobileInteraction:o.mobileInteraction,customHoverBehavior:V}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:_,staleness:L,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});yk.displayName="RealtimeHeatmap";import{forwardRef as bk,useCallback as vk,useMemo as xk,useRef as wk}from"react";import*as kk from"react";import{forwardRef as Sk,memo as Ak,useCallback as Ck,useEffect as Mk,useImperativeHandle as Pk,useId as Ik,useRef as _k}from"react";var Lk={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},Rk={names:["--semiotic-border","--surface-3"],fallback:"#334155"},Tk={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},Nk={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},$k={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},Bk={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},Dk={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},Fk={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},Ek={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},zk={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function jk(e,t){const o=e.canvas;if("function"!=typeof getComputedStyle||!o)return t.fallback;const r=getComputedStyle(o);for(const o of t.names){const t=r.getPropertyValue(o).trim();if(t)return Go(e,t)??t}return t.fallback}function Ok(e,t){const o=Math.max(0,Math.min(1,t)),r=e.trim(),n=r.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(n){const[,e,t,r]=n;return Ok(`#${e}${e}${t}${t}${r}${r}`,o)}const i=r.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i){const[,e,t,r]=i;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(r,16)}, ${o})`}const a=r.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(a)return`rgba(${a[1]}, ${o})`;const s=r.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return s?`rgba(${s[1]}, ${o})`:r}import*as Hk from"react";import{scaleLinear as Wk}from"d3-scale";import{Fragment as qk,jsx as Gk,jsxs as Yk}from"react/jsx-runtime";function Vk(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Xk(e){const{width:t,height:o,totalWidth:r,totalHeight:n,margin:i,title:a,legend:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:p,pointNodes:m=[],annotations:f,autoPlaceAnnotations:g,svgAnnotationRules:y,children:b}=e,v=Hk.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(f),[f]),x=Hk.useMemo(()=>function(e){const{width:t,height:o,pointNodes:r=[],data:n}=e;return{scales:{x:Wk().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:Wk().domain([0,Math.max(1,o)]).range([0,Math.max(1,o)])},width:t,height:o,frameType:"network",pointNodes:r,data:n,xAccessor:"x",yAccessor:"y"}}({width:t,height:o,pointNodes:m}),[o,m,t]),w=Hk.useMemo(()=>v&&g?di({annotations:v,context:x,..."object"==typeof g?g:{}}):v,[x,g,v]),k=Hk.useMemo(()=>Wn(),[]),S=w?Hn(w.filter(e=>"widget"!==e.type),k,y,x):null,A=!0===w?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Yk(qk,{children:[A?Gk("style",{children:$n},"physics-annotation-disclosure-style"):null,Yk("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:r,height:n,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Yk("g",{transform:`translate(${i.left},${i.top})`,children:[S,b]}),a&&"string"==typeof a?Gk("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Gk("foreignObject",{x:0,y:0,width:r,height:Math.max(i.top,28),children:a}):null,s?Kr({legend:s,totalWidth:r,totalHeight:n,margin:i,legendPosition:h,legendLayout:p,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function Uk(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Kk(e,t){const o="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,Uk(e.thickness)??Uk(o)??Uk(t.thickness)??4)}var Qk=2500;function Zk(e){return"function"==typeof e}function Jk(e){return void 0===e||!1===e||!Zk(e.binAccessor)&&!Zk(e.labelAccessor)&&!Zk(e.valueAccessor)}function eS(e){if(void 0!==e){if(!1===e)return!1;if(!Jk(e))throw new TypeError("Physics worker sediment config only supports string or numeric accessors");return{binAccessor:"string"==typeof e.binAccessor?e.binAccessor:void 0,labelAccessor:"string"==typeof e.labelAccessor?e.labelAccessor:void 0,valueAccessor:"string"==typeof e.valueAccessor||"number"==typeof e.valueAccessor?e.valueAccessor:void 0,retainBodyIds:e.retainBodyIds}}}function tS(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function oS(e){return function(e){return!Zk(e?.timeAccessor)}(e)}function rS(e={}){if(e.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:t,observation:o,sediment:r,...n}=e;return{...n,observation:tS(o),sediment:eS(r)}}function nS(){if("undefined"!=typeof DOMException)return new DOMException("Physics worker request aborted","AbortError");const e=Error("Physics worker request aborted");return e.name="AbortError",e}var iS=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./physicsWorker.js",import.meta.url):Tv("physicsWorker.js");return new Worker(e,{type:"module",name:"semiotic-physics"})}()){this.nextRequestId=1,this.pending=new Map,this.worker=e,this.worker.onmessage=e=>{const t=e.data,o=this.pending.get(t.requestId);o&&(this.pending.delete(t.requestId),o.cleanup(),t.ok?o.resolve(t.payload):o.reject(function(e){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),t}(t)))},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Physics worker failed")),this.worker.terminate()}}request(e,t){if(t?.aborted)return Promise.reject(nS());const o=this.nextRequestId;this.nextRequestId+=1;const r={command:e,requestId:o};return new Promise((e,n)=>{const i=()=>{this.pending.delete(o),t?.removeEventListener("abort",i),n(nS())},a=()=>t?.removeEventListener("abort",i);this.pending.set(o,{cleanup:a,reject:n,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(o),a(),n(e)}})}async init(e,t,o,r){if(!oS(o))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const n=await this.request({type:"init",config:rS(e),initialSpawns:t,initialSpawnPacing:o},r);if("frame"!==n.type)throw Error("Physics worker returned a non-frame init response");return n.frame}async restore(e,t){const o=await this.request({type:"restore",snapshot:e},t);if("frame"!==o.type)throw Error("Physics worker returned a non-frame restore response");return o.frame}async initFromSnapshot(e,t,o){const r=await this.request({type:"init",config:rS(e),snapshot:t},o);if("frame"!==r.type)throw Error("Physics worker returned a non-frame init response");return r.frame}async enqueue(e,t,o){if(!oS(t))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"enqueue",spawns:e,pacing:t},o);if("frame"!==r.type)throw Error("Physics worker returned a non-frame enqueue response");return r.frame}async tick(e,t){const o=await this.request({type:"tick",deltaSeconds:e},t);if("frame"!==o.type)throw Error("Physics worker returned a non-frame tick response");return o.frame}async settle(e,t){const o=await this.request({type:"settle",maxSteps:e},t);if("frame"!==o.type)throw Error("Physics worker returned a non-frame settle response");return o.frame}async snapshot(e){const t=await this.request({type:"snapshot"},e);if("snapshot"!==t.type)throw Error("Physics worker returned a non-snapshot response");return t.snapshot}async remove(e,t){const o=await this.request({type:"remove",ids:e},t);if("removed"!==o.type)throw Error("Physics worker returned a non-remove response");return{frame:o.frame,removed:o.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(e){for(const[t,o]of this.pending)this.pending.delete(t),o.cleanup(),o.reject(e)}};function aS(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var sS={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},lS=1e-9,cS=.005;function uS(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function dS(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function hS(e,t,o){return Math.max(t,Math.min(o,e))}function pS(e){return 0>e?-1:1}function mS(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,o=e.shape.height/2;return{minX:e.x-t,minY:e.y-o,maxX:e.x+t,maxY:e.y+o}}function fS(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,o=t.height/2;return{minX:t.x-e,minY:t.y-o,maxX:t.x+e,maxY:t.y+o}}const o=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-o,minY:Math.min(t.y1,t.y2)-o,maxX:Math.max(t.x1,t.x2)+o,maxY:Math.max(t.y1,t.y2)+o}}function gS(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function yS(e,t,o,r,n,i,a,s){const l=n-e,c=(o+a)/2-Math.abs(l);if(0>=c)return null;const u=i-t,d=(r+s)/2-Math.abs(u);return d>0?d>c?{nx:pS(l),ny:0,penetration:c}:{nx:0,ny:pS(u),penetration:d}:null}function bS(e,t,o,r,n,i,a){const s=i/2,l=a/2;let c=e-hS(e,r-s,r+s),u=t-hS(t,n-l,n+l);const d=c*c+u*u;if(d>o*o)return null;if(lS>=d){const i=Math.abs(e-(r-s)),a=Math.abs(e-(r+s)),d=Math.abs(t-(n-l)),h=Math.abs(t-(n+l)),p=Math.min(i,a,d,h);return p===i?(c=-1,u=0,{nx:c,ny:u,penetration:o+i}):p===a?(c=1,u=0,{nx:c,ny:u,penetration:o+a}):p===d?(c=0,u=-1,{nx:c,ny:u,penetration:o+d}):(c=0,u=1,{nx:c,ny:u,penetration:o+h})}const h=Math.sqrt(d);return{nx:c/h,ny:u/h,penetration:o-h}}function vS(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,o,r,n,i){const a=r-e,s=n-t,l=o+i,c=a*a+s*s;if(c>=l*l)return null;if(lS>=c)return{nx:1,ny:0,penetration:l};const u=Math.sqrt(c);return{nx:a/u,ny:s/u,penetration:l-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return yS(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const o=bS(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return o?{nx:-o.nx,ny:-o.ny,penetration:o.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?bS(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function xS(e,t){const o=t.shape;return"aabb"===o.type?"circle"===e.shape.type?bS(e.x,e.y,e.shape.radius,o.x,o.y,o.width,o.height):yS(o.x,o.y,o.width,o.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,o,r,n,i,a,s=0){const l=i-r,c=a-n,u=l*l+c*c,d=u>lS?hS(((e-r)*l+(t-n)*c)/u,0,1):0,h=o+s/2,p=e-(r+l*d),m=t-(n+c*d),f=p*p+m*m;if(f>=h*h)return null;if(lS>=f){const e=Math.sqrt(u);return e>lS?{nx:-c/e,ny:l/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(f);return{nx:p/g,ny:m/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,o.x1,o.y1,o.x2,o.y2,o.thickness??0)}function wS(e,t){return`${e}\0${t}`}function kS(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function SS(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:uS(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function AS(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function CS(e){return{id:e.id,shape:dS(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:AS(e.bodyFilter),index:e.index}}function MS(e,t){return!!t?.some(t=>Object.is(e,t))}function PS(e,t){const o=e.bodyFilter;if(!o)return!0;if("function"==typeof o)return o(t);const r=function(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(null==o||"object"!=typeof o)return;o=o[e]}return o}(t,o.property);return!("equals"in o&&!Object.is(r,o.equals)||"notEquals"in o&&Object.is(r,o.notEquals)||o.oneOf&&!MS(r,o.oneOf)||o.notOneOf&&MS(r,o.notOneOf))}var IS=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...sS,...e},this.random=aS(this.options.seed)}init(e={}){this.options={...sS,...e},this.random=aS(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(lS,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:uS(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))kS(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:dS(t.shape),bodyFilter:AS(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,o){const r=this.bodies.get(e);r&&(r.vx+=t/r.mass,r.vy+=o/r.mass,this.wake(r))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const o=this.sortedBodies();for(const e of o)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const r=this.options.maxVelocity;for(const e of o)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,r>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>r){const o=r/t;e.vx*=o,e.vy*=o}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const n=this.bodyPairKeys(o),i=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(o,n,0===e),this.resolveColliders(o,i,0===e);this.updateSensors(o),this.updateSleeping(o,t)}settle(e=1200,t=this.options.fixedDt){let o=0;for(;e>o&&!this.allSleeping();)this.step(t),o+=1;return o}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:uS(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(kS)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(SS),colliders:this.sortedColliders().map(CS),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=aS(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=SS(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=CS(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const o=this.bodies.get(t.bodyId);if(!o||o.sleeping)continue;const r="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!r)continue;const n=r.x-o.x,i=r.y-o.y,a=Math.sqrt(n*n+i*i);if(lS>=a)continue;const s=n/a,l=i/a,c=(a-t.restLength)*t.stiffness+((("vx"in r?r.vx:0)-o.vx)*s+(("vy"in r?r.vy:0)-o.vy)*l)*t.damping;o.vx+=c*s*e/o.mass,o.vy+=c*l*e/o.mass}}resolveBodyPairs(e,t,o){for(const r of t){const[t,n]=r.split(":").map(Number),i=e[t],a=e[n];if(!i||!a)continue;const s=vS(i,a);s&&(this.resolveDynamicCollision(i,a,s),o&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:a.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),o=new Map;for(let r=0;e.length>r;r+=1){if(!1===e[r].bodyCollisions)continue;const n=mS(e[r]),i=Math.floor(n.minX/t),a=Math.floor(n.maxX/t),s=Math.floor(n.minY/t),l=Math.floor(n.maxY/t);for(let e=i;a>=e;e+=1)for(let t=s;l>=t;t+=1){const n=`${e}:${t}`,i=o.get(n);i?i.push(r):o.set(n,[r])}}const r=new Set;for(const t of Array.from(o.keys()).sort()){const n=o.get(t)??[];n.sort((e,t)=>e-t);for(let t=0;n.length>t;t+=1)for(let o=t+1;n.length>o;o+=1){const i=n[t],a=n[o];!1!==e[i].bodyCollisions&&!1!==e[a].bodyCollisions&&gS(mS(e[i]),mS(e[a]))&&r.add(`${i}:${a}`)}}return Array.from(r).sort((e,t)=>{const[o,r]=e.split(":").map(Number),[n,i]=t.split(":").map(Number);return o===n?r-i:o-n})}resolveDynamicCollision(e,t,o){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const r=e.sleeping?0:1/e.mass,n=t.sleeping?0:1/t.mass,i=r+n;if(lS>=i)return;const a=Math.max(0,o.penetration-cS)/i;e.x-=o.nx*a*r,e.y-=o.ny*a*r,t.x+=o.nx*a*n,t.y+=o.ny*a*n;const s=(t.vx-e.vx)*o.nx+(t.vy-e.vy)*o.ny;if(s>0)return;const l=Math.abs(s),c=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*s/i,u=c*o.nx,d=c*o.ny;e.vx-=u*r,e.vy-=d*r,t.vx+=u*n,t.vy+=d*n,this.applyFriction(e,t,o,c,r,n),l>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,o,r,n,i){const a=-o.ny,s=o.nx,l=(t.vx-e.vx)*a+(t.vy-e.vy)*s,c=n+i;if(lS>=Math.abs(l)||lS>=c)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=hS(-l/c,-r*u,r*u),h=d*a,p=d*s;e.vx-=h*n,e.vy-=p*n,t.vx+=h*i,t.vy+=p*i}resolveColliders(e,t,o){for(const r of e)for(const e of t){if(!PS(e,r))continue;if(!gS(mS(r),fS(e)))continue;const t=xS(r,e);t&&(this.resolveStaticCollision(r,e,t),this.supportedThisStep.add(r.id),o&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,o){e.x+=o.nx*Math.max(0,o.penetration-cS),e.y+=o.ny*Math.max(0,o.penetration-cS);const r=e.vx*o.nx+e.vy*o.ny;if(0>r){const n=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+n)*r*o.nx,e.vy-=(1+n)*r*o.ny;const i=-o.ny,a=o.nx,s=e.vx*i+e.vy*a,l=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=s*i*l,e.vy-=s*a*l}}updateSensors(e){const t=new Set,o=this.sortedColliders().filter(e=>e.sensor);for(const r of e){const e=mS(r);for(const n of o){if(!PS(n,r))continue;if(!gS(e,fS(n)))continue;if(!xS(r,n))continue;const o=wS(n.id,r.id);t.add(o),this.activeSensors.has(o)||this.lastEvents.push({type:"sensor-enter",bodyId:r.id,sensorId:n.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:o,bodyId:r}=kS(e);this.lastEvents.push({type:"sensor-exit",bodyId:r,sensorId:o})}this.activeSensors=t}updateSleeping(e,t){const o=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const r of e)Math.sqrt(r.vx*r.vx+r.vy*r.vy)>=this.options.sleepSpeed||Math.sqrt((r.x-r.prevX)*(r.x-r.prevX)+(r.y-r.prevY)*(r.y-r.prevY))>=this.options.sleepSpeed*t||o&&!this.supportedThisStep.has(r.id)?r.sleeping?this.wake(r):r.sleepTime=0:(r.sleepTime+=t,r.sleeping||this.options.sleepAfter>r.sleepTime||(r.sleeping=!0,r.vx=0,r.vy=0,this.lastEvents.push({type:"sleep",bodyId:r.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},_S=class{constructor(e={}){this.id="builtin",this.capabilities={...(new IS).capabilities,engine:"builtin"},this.world=new IS(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,o){this.world.applyImpulse(e,t,o)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function LS(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new _S(e)}(t)}var RS=["binId","targetBin","category","windowIndex","lane","group"];function TS(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const o=t-e.mean;e.mean+=o/e.count,e.m2+=o*(t-e.mean)}function NS(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function $S(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function BS(e,t){if(null!=e[t])return e[t];const o=e.datum;return o&&"object"==typeof o?o[t]:void 0}function DS(e,t,o){return"function"==typeof e?e(t,o):"string"==typeof e?BS(t,e):void 0}function FS(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function ES(e){const t=NS(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:NS(e.x),y:NS(e.y),value:t}}var zS=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const o=FS(DS(this.config.binAccessor,e,t))??function(e){for(const t of RS){const o=FS(BS(e,t));if(o)return o}return"sediment"}(e),r=FS(DS(this.config.labelAccessor,e,t))??o,n=function(e,t,o){if("number"==typeof e)return e;const r="function"==typeof e?e(t,o):"string"==typeof e?BS(t,e):1,n="number"==typeof r?r:Number(r);return Number.isFinite(n)?n:1}(this.config.valueAccessor,e,t),i=Math.max(0,Math.floor(this.config.retainBodyIds??12));let a=this.bins.get(o);return a||(a={id:o,label:r,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(o,a)),a.label=r,a.lastBodyId=e.id,a.lastDatum=e.datum,TS(a.x,e.x),TS(a.y,e.y),TS(a.value,n),i>0&&(a.bodyIds.push(e.id),a.bodyIds.length>i&&(a.bodyIds=a.bodyIds.slice(a.bodyIds.length-i))),ES(a)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(ES)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:$S(t.x),y:$S(t.y),value:$S(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function jS(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var OS={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},HS={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function WS(e={},t=HS){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function qS(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function GS(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function YS(e,t){if(null!=e[t])return e[t];const o=e.datum;return o&&"object"==typeof o?o[t]:void 0}function VS(e){return{...qS(e),sequence:e.sequence,spawnAt:e.spawnAt}}function XS(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function US(e){return!1!==e&&{...e}}function KS(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function QS(e){return{...e,gravity:{...e.gravity}}}function ZS(e,t,o,r){if("circle"===e.shape.type){const n=e.x-t,i=e.y-o,a=e.shape.radius+r,s=n*n+i*i;return s>a*a?null:s}const n=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),i=Math.max(Math.abs(o-e.y)-e.shape.height/2,0),a=n*n+i*i;return a>r*r?null:a}function JS(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function eA(e,t={}){const{idPrefix:o="plot",includeFloor:r=!0,includeCeiling:n=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:l=s}=t,c=[],u=e.x+e.width/2,d=e.y+e.height/2;return r&&c.push({id:o+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+l/2,width:e.width+2*s,height:l}}),n&&c.push({id:o+"-ceiling",shape:{type:"aabb",x:u,y:e.y-l/2,width:e.width+2*s,height:l}}),i&&c.push({id:o+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*l}}),a&&c.push({id:o+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*l}}),c}function tA(e){const{idPrefix:t="bin",count:o,domainStart:r,domainStep:n,xScale:i,yTop:a,yBottom:s,wallThickness:l=4,includeBoundaryWalls:c=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:p=Math.max(2,l)}=e,m=[],f=a+(s-a)/2,g=Math.abs(s-a),y=c?o:o-1;if(u||c)for(let e=c?0:1;y>=e;e+=1){if(!u&&e>0&&o>e)continue;const a=i(r+e*n);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:f,width:l,height:g}})}if(null!=d)for(let e=0;o>e;e+=1){const o=r+e*n,a=o+n;if(a>=d)continue;const s=i(o),c=i(a);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,c)+l/2,y1:h,x2:Math.max(s,c)-l/2,y2:h,thickness:p}})}return m}import{quadtree as oA}from"d3-quadtree";var rA=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,o,r,n,i=0){const a=this.ensure(e,t);if(!a)return null;let s=null,l=1/0;const c=Math.max(0,i)+this.maxSearchRadius,u=r-c,d=r+c,h=n-c,p=n+c;return a.visit((e,t,a,c,m)=>{if(u>c||t>d||h>m||a>p)return!0;if(e.length)return!1;let f=e;for(;f;){const e=f.data;if(e){const t=ZS(e,r,n,Math.max(0,i));null!=t&&(l>t||t===l&&o.indexOf(e.id)>o.indexOf(s?.id??""))&&(s=e,l=t)}f=f.next}return!1}),s}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const o=e.readState();return 0===o.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=o.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=oA().x(e=>e.x).y(e=>e.y).addAll(o),this.revision=t,this.tree)}},nA=["data","scene-geometry","data-paint","accessibility","evidence"],iA=["scene-geometry","data-paint","accessibility","evidence"],aA=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sA=["overlay","accessibility","evidence"],lA=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function cA(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&lA.every(o=>e[o]===t[o])}function uA(e,t,o,r){return e||!t?"paused":o||!r?"running":"settled"}var dA=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new rA,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Jt,this.simulationState="settled",this.visible=!0;const{bodyBudget:t,colliders:o,engine:r,kernel:n,observation:i,sediment:a,...s}=e;this.config={...OS,...s},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=r,this.observation=WS(i),this.sediment=new zS(a??!1),this.world=LS(r,{fixedDt:this.config.fixedDt,...n}),o&&this.world.setColliders(XS(o))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(o=>"kernel"===o?!cA(e.kernel,t.kernel):e[o]!==t[o])}(e,this.configInput),{colliders:o,bodyBudget:r,engine:n,kernel:i,observation:a,sediment:s,...l}=e;if(this.config={...this.config,...l},void 0!==r&&(this.bodyBudget=r,!1===r&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=LS(n,e.options),this.world.restore(e),this.revision+=1}if(i&&!cA(i,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...i,gravity:{...e.options.gravity,...i.gravity}};this.world.restore({...e,options:t}),this.revision+=1}a&&(this.observation=WS(a,this.observation)),this.sediment.updateConfig(s),o&&(this.world.setColliders(XS(o)),this.revision+=1),this.configInput={...this.configInput,...e},this.updateResults.record({kind:"config",keys:t},t.length?aA:[])}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(XS(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},aA)}enqueue(e,t){const o=Array.isArray(e)?e:[e],r=t?function(e,t={}){const o=GS(t.startAt)??0,r=t.pacing??"immediate";if("arrival"===r){const r=e.map((e,o)=>function(e,t,o){return"function"==typeof o?GS(o(e,t)):"string"==typeof o?GS(YS(e,o)):GS(e.spawnAt)??GS(YS(e,"arrivalTime"))??GS(YS(e,"timestamp"))??GS(YS(e,"time"))??GS(YS(e,"eventTime"))}(e,o,t.timeAccessor)),n=r.filter(e=>null!=e),i=n.length>0?Math.min(...n):0,a=GS(t.timeScale)??1,s=a>0?a:1;return e.map((e,t)=>{const n=r[t],a=null==n?0:Math.max(0,n-i);return{...qS(e),spawnAt:o+a/s}})}if("object"==typeof r){const t=GS(r.ratePerSec);if(t&&t>0)return e.map((e,r)=>({...qS(e),spawnAt:o+r/t}))}return e.map(e=>({...qS(e),spawnAt:o}))}(o,{...t,startAt:t.startAt??this.elapsedSeconds}):o;for(const e of r)this.queue.push({...qS(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(KS),r.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:r.length},r.length?nA:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(qS(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},nA)}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},nA)}tick(e){const t=this.revision,o=[],r=[],n=[],i=[],a=[];if(this.paused||!this.visible){const e=this.result(0,o,r,n,i,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const s=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=s,this.spawnDue(o,a);const l=this.observeBodyBudget(a),c=this.evictOverflow(a);r.push(...c.evicted),n.push(...c.sedimented),this.syncSimulationState(a),this.accumulator+=s;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,a),this.observeSensorTransitions(a),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||o.length>0||r.length>0||n.length>0||i.length>0)&&(this.revision+=1);const d=this.result(u,o,r,n,i,a,void 0,l);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?o.length||r.length||n.length?nA:iA:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const o=this.world.settle(e,this.config.fixedDt);return o>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:o},this.revision!==t?iA:[]),o}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,o=[],r=[],n=[],i=[],a=[];if(this.paused||!this.visible){const e=this.result(0,o,r,n,i,a,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,a);const s=this.observeBodyBudget(a),l=this.evictOverflow(a);r.push(...l.evicted),n.push(...l.sedimented),this.syncSimulationState(a);let c=0;for(;e>c&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,a),this.observeSensorTransitions(a),c+=1}(c>0||o.length>0||r.length>0||n.length>0||i.length>0)&&(this.revision+=1);const u=this.result(c,o,r,n,i,a,void 0,s);return this.updateResults.record({kind:"settle",count:c},this.revision!==t?o.length||r.length||n.length?nA:iA:[]),u}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:o=0,binWidth:r=24,gap:n=2,maxHeight:i=80,value:a="count",x:s}=t,l=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{const c=Math.max(0,e[a]/l*i),u=s?.(e,t)??t*(r+n);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:o-c,width:r,height:c,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,o=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,o)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:o,chartId:r,...n}=e,i={...n,timestamp:t??this.elapsedSeconds,chartType:o??this.observation.chartType,chartId:r??this.observation.chartId};return this.emitObservation(i),this.updateResults.record({kind:"update",count:1},["evidence"]),i}getLastUpdateResult(){return this.updateResults.last}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?sA:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?sA:[])}remove(e){const t=new Set(e),o=new Set(this.liveBodyOrder),r=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const n=e.filter(e=>o.has(e)||r.has(e));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?nA:[]),n}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},iA),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},iA)}applyImpulse(e,t,o){this.world.applyImpulse(e,t,o),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},iA)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,o,r)=>e.applyImpulse(t,o,r),clear:()=>e.clear(),hitTest:(t,o,r)=>e.hitTest(t,o,r),pause:()=>e.setPaused(!0),push:(t,o)=>e.enqueue(t,o),pushMany:(t,o)=>e.enqueue(t,o),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:US(this.bodyBudget),config:{...this.config,kernel:QS(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(VS),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:US(e.bodyBudget??{}),kernel:QS(e.world.options)},this.bodyBudget=US(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(VS).sort(KS),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??uA(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},aA)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const o=this.queue.shift();if(!o)return;this.spawnOne(o,t),e.push(o.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const o=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:o?.datum??e.datum,x:o?.x??e.x,y:o?.y??e.y},t)}result(e,t,o,r,n,i,a,s=this.evaluateBodyBudget()){this.syncSimulationState(i);const l=this.world.allSleeping();return{budget:s,elapsedSeconds:this.elapsedSeconds,evicted:o,events:n,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:a??(this.queue.length>0||!l),sleeping:l,sedimented:r,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,o){if(0===t.length)return;const r=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=r.get(e.bodyId);o.emit({type:"physics-settle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,o){const r=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===r.size&&0===t.size)return r;const n=new Map(e.readState().map(e=>[e.id,e])),i=(e,t)=>{const{sensorId:r,bodyId:i}=JS(t),a=o.observation.sensors[r],s=n.get(i);o.emit({type:"enter"===e?a?.enterType??"physics-bin-enter":a?.exitType??"physics-bin-exit",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:i,datum:s?.datum,x:s?.x,y:s?.y,sensorId:r,binId:a?.binId??r})};for(const e of Array.from(r).sort())t.has(e)||i("enter",e);for(const e of Array.from(t).sort())r.has(e)||i("exit",e);return r}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const o of e)t.has(JS(o).bodyId)&&e.delete(o)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),o=Math.max(0,Math.floor(e.queuedBodies??0)),r=t+o,n=jS(e.bodyLimit),i=jS(e.engineMaxBodiesHint),a=function(e,t,o){if(!1===o)return;const r=jS(o?.warnAt);return null!=r?r:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(n,i,e.options),s=null==n?0:Math.max(0,t-n),l=s>0?"overflow":null==a||a>r?"ok":"warning";return{action:"overflow"!==l?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:i,liveBodies:t,overflow:s,projectedBodies:r,queuedBodies:o,state:l,warnAt:a}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const o=`${t.state}:${t.action}`;return o===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=o,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=uA(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(t===this.simulationState)return;const o=this.simulationState;this.simulationState=t,function(e,t,o){o.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||o.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,simulationState:t,previousSimulationState:e})}(o,t,this.observationContext(e))}evictOverflow(e){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const t=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(t))return{evicted:[],sedimented:[]};const o=this.liveBodyOrder.length-t;if(0>=o)return{evicted:[],sedimented:[]};const r=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,o);if(0===r.length)return{evicted:[],sedimented:[]};const n=this.absorbSediment(r,e);this.world.remove(r);const i=new Set(r);return this.liveBodyOrder=this.liveBodyOrder.filter(e=>!i.has(e)),this.removeActiveSensorPairsForBodies(i),{evicted:r,sedimented:n}}absorbSediment(e,t){const o=new Map(this.world.readState().map(e=>[e.id,e])),r=[];for(const n of e){const e=o.get(n);if(!e)continue;const i=this.sediment.add(e);i&&(r.push(n),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:n,datum:e.datum,x:e.x,y:e.y,binId:i.id,count:i.count,total:i.total},t))}return r}sleepingFirstEvictionOrder(){const e=new Map(this.world.readState().map(e=>[e.id,e.sleeping])),t=[],o=[];for(const r of this.liveBodyOrder)e.get(r)?t.push(r):o.push(r);return[...t,...o]}};import*as hA from"react-dom/server";function pA(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var mA={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function fA(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function gA(e,t){const o="function"==typeof t?t(e):t;return{...mA,...o??{}}}function yA(e,t={}){const o=e.settle(t.maxSteps),r=e.readBodies(),n=e.snapshot(),i=function(e,t={}){return e.map(e=>function(e,t={}){const o=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),r={label:t.getBodyLabel?.(e)??fA(e)},n={style:gA(e,t.bodyStyle),datum:o,accessibleDatum:o,accessibility:r,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...n}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...n}}(e,t))}(r,t),a=function(e,t={}){const o=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),r=o.filter(e=>e.sleeping).length;return{bodyCount:o.length,sleepingCount:r,settled:"settled"===e.simulationState&&0===e.queue.length&&r===o.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:pA(t.projectionRows)}}(n,{bodies:r,projectionRows:t.projectionRows,stepsRun:o});return{snapshot:n,bodies:r,sceneNodes:i,evidence:a,stepsRun:o}}import{jsx as bA,jsxs as vA}from"react/jsx-runtime";function xA(e,t){if("function"==typeof t){const o=t(e);return Number.isFinite(o)&&o>0?Number(o):1}const o=e.datum;if(t&&o&&"object"==typeof o){const e=Number(o[t]);if(Number.isFinite(e)&&e>0)return e}const r=Number(o?.work??o?.reviewWork??o?.value);return Number.isFinite(r)&&r>0?r:1}function wA(e,t){if("function"==typeof t){const o=t(e);if(null!=o&&(o+"").length>0)return o+""}else if(t){const o=SA(e.datum,t),r=SA(e,t),n=o??r;if(null!=n&&(n+"").length>0)return n+""}return e.id}function kA(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const o=Math.max(0,Math.min(1,t))*(e.length-1),r=Math.floor(o);return e[r]+(e[Math.ceil(o)]-e[r])*(o-r)}function SA(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(null==o||"object"!=typeof o)return;o=o[e]}return o}function AA(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const o=SA(e,t.property);return!("equals"in t&&!Object.is(o,t.equals)||"notEquals"in t&&Object.is(o,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(o,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(o,e)))}function CA(e){const t=e.regionId,o=Math.max(0,e.unitsPerSecond),r=e.queueLayout??"lane",n=e.queueSlotSpacing??14,i=e.queueStiffness??.35,a=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,s=Math.max(.25,e.metricWindowSeconds??30),l=Math.max(1/60,e.snapshotIntervalSeconds??.25),c=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,p=new Map,m=new Map,f=new Map,g=new Map,y=[];let b=0,v=new Map,x=new Map,w=0,k=0,S=0,A=null,C=0,M=0,P=0,I=0,_=0,L=0,R=0,T=0,N=0,$=0,B=0,D=0,F=-1,E=!1;function z(e,o){const r=o(e);return!!r&&r.activeRegionIds.includes(t)}function j(){D+=1}function O(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function H(o,r,n,i){const a={bodyId:o.id,jobId:r.jobId,visitId:r.visitId,visit:r.visit,remaining:r.work,total:r.work,queuedAt:r.queuedAt,sequence:i};return u.set(r.jobId,a),g.delete(o.id),f.set(o.id,r.jobId),M+=1,P+=r.work,j(),function(o,r,n){const i=O(r);e.onQueued?.(o,i),n.controls.recordObservation({type:"physics-capacity-queued",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:t,work:r.total,jobId:r.jobId,visitId:r.visitId,visit:r.visit,queuedAt:r.queuedAt,queueDepth:u.size})}(o,a,n),a}function W(e){if(u.size>=a||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const o of t){if(u.size>=a)break;const t=m.get(o.jobId);t&&h.has(o.jobId)?(d.delete(o.jobId),g.delete(o.bodyId),H(t,o,e,o.sequence)):d.delete(o.jobId)}}function q(){let e=0;for(const t of u.values())e+=t.remaining;return e}function G(){N=Math.max(N,u.size),$=Math.max($,q())}function Y(){const e=S-s,t=Math.max(0,Math.min(s,S-(A??S)));let r=0,n=0,i=0,a=0,l=0;for(const t of y){if(e>t.end)continue;r+=t.arrivals,n+=t.arrivalWork,i+=t.completions,a+=t.completedWork;const o=t.end-t.start;l+=o>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/o):t.processedWork}const c=t>0?n/t:0;return{seconds:t,arrivals:r,arrivalWork:n,completions:i,completedWork:a,processedWork:l,arrivalsPerSecond:t>0?r/t:0,throughputPerSecond:t>0?i/t:0,utilization:t>0&&o>0?Math.max(0,Math.min(1,l/(o*t))):0,pressure:o>0?c/o:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:r=>{const n=r.controls.readBodies(),i=new Map,M=new Map;for(const t of n){if(i.set(t.id,t),!z(t.id,r.getRegionState))continue;if(!AA(t,e.bodyFilter))continue;const o=wA(t,e.jobKey),n=M.get(o)??[];n.push(t),M.set(o,n)}const P=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!E){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):P;S=Math.max(0,e-P),E=!0}const N=S,$=N+P;S=$,A=null==A?N:Math.min(A,N);const D={start:N,end:$,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},q=new Map;for(const[e,t]of M){const o=h.get(e)?.bodyId,r=t.find(e=>e.id===o)??t[0];q.set(e,r),m.set(e,r)}for(const[o,n]of h){if(q.has(o))continue;const a=u.get(o),s=i.get(n.bodyId)??m.get(o);if(a){u.delete(o),f.delete(a.bodyId),R+=1,T+=a.remaining,j();const i={...O(a),abandonedAt:S,remainingWork:a.remaining,queueSeconds:Math.max(0,S-a.queuedAt)};s&&e.onAbandoned?.(s,i),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:n.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:t,work:a.total,remainingWork:a.remaining,jobId:o,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:S,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(o),g.delete(n.bodyId),h.delete(o),m.delete(o)}for(const[o,n]of q){if(h.has(o))continue;const i=(p.get(o)??0)+1;p.set(o,i);const s=xA(n,e.unitAccessor),l={bodyId:n.id,jobId:o,visitId:`${t}:${o}:${i}`,visit:i,regionId:t,work:s,queuedAt:S};h.set(o,l),C+=1,D.arrivals+=1,D.arrivalWork+=s;const c=b++;if(a>u.size)H(n,l,r,c);else{const a={...l,blockedAt:S,sequence:c};d.set(o,a),g.set(n.id,o),L+=1,j(),e.onBlocked?.(n,a),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:s,jobId:o,visitId:l.visitId,visit:i,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}W(r),G();const Y=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let V=o*P;for(const o of Y){if(0>=V)break;const n=Math.min(o.remaining,V);if(o.remaining-=n,V-=n,I+=n,D.processedWork+=n,o.remaining>1e-6)continue;u.delete(o.jobId),f.delete(o.bodyId),k+=1,_+=o.total,D.completions+=1,D.completedWork+=o.total;const a=Math.max(0,S-o.queuedAt);B+=a,j();const s=i.get(o.bodyId);if(!s)continue;r.controls.applyImpulse(o.bodyId,c.x??0,c.y??0);const l={...O(o),completedAt:S,queueSeconds:a};e.onProcessed?.(s,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:o.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:t,work:o.total,jobId:o.jobId,visitId:o.visitId,visit:o.visit,queuedAt:o.queuedAt,completedAt:S,queueSeconds:a,queueDepth:u.size})}W(r),G(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);v=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);x=new Map(t.map((e,t)=>[e.bodyId,t])),w=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&y.push(e);const t=S-s;for(;y.length>0&&t>y[0].end;)y.shift()}(D);const X=Math.floor(S/l);X!==F&&(F=X,j())},getSnapshot:()=>{const e=q(),r=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),n=u.size,i=Array.from(u.values()).map(e=>Math.max(0,S-e.queuedAt)).sort((e,t)=>e-t),a=i.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:n,processedCount:k,unitsPerSecond:o,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+r,blockedDepth:d.size,blockedWork:r,arrivalCount:C,admittedCount:M,admittedWork:P,processedWork:I,completedWork:_,blockedCount:L,abandonedCount:R,abandonedWork:T,peakQueueDepth:N,peakRemainingWork:$,queueAge:{count:i.length,meanSeconds:i.length>0?a/i.length:0,p50Seconds:kA(i,.5),p95Seconds:kA(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:k>0?B/k:0,window:Y(),simulatedAt:S,metricRevision:D}},bodyForce:e=>{if("none"===r)return null;const o=f.get(e.body.id),a=g.get(e.body.id),s=o?u.get(o):void 0,l=a?d.get(a):void 0;if(!s&&!l)return null;const c=s?v.get(e.body.id):x.get(e.body.id);if(null==c)return null;let h;const p=e.regions;if(p)for(let e=0;p.length>e;e+=1)if(p[e].id===t){const t=p[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((l?h.x-.44*h.width:h.x-.22*h.width-c*(.15*n))-e.body.x)*i,y:(h.y-(c-((l?d.size:w)-1)/2)*n/Math.max(1,Math.sqrt(l?d.size:w))-e.body.y)*i*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function MA(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}import{useEffect as PA,useRef as IA}from"react";function _A(){return"undefined"==typeof document||!document.hidden}function LA(e,t,o){const r=o.fill??"#4e79a7",n=o.stroke,i=o.strokeWidth??0,a=o.opacity??1,s=o.fillOpacity??1,l=function(e,t){const o=t.mark;if(o)return o;const r=e.datum,n=r?.__physicsMark??r?.mark;return"circle"===n||"halo"===n||"faceted"===n||"pill"===n||"diamond"===n||"square"===n?n:"circle"===e.shape.type?"circle":"square"}(t,o),c="circle"===t.shape.type?o.r??t.shape.radius:Math.max(t.shape.width,t.shape.height)/2;if(e.save(),e.globalAlpha*=a,e.beginPath(),"pill"===l||"square"===l||"aabb"===t.shape.type){const o="pill"===l?2.4*c:"aabb"===t.shape.type?t.shape.width:1.7*c,r="pill"===l?1.35*c:"aabb"===t.shape.type?t.shape.height:1.7*c,n=t.x-o/2,i=t.y-r/2,a="pill"===l?r/2:Math.min(4,o/4);e.moveTo(n+a,i),e.arcTo(n+o,i,n+o,i+r,a),e.arcTo(n+o,i+r,n,i+r,a),e.arcTo(n,i+r,n,i,a),e.arcTo(n,i,n+o,i,a),e.closePath()}else if("diamond"===l)e.moveTo(t.x,t.y-c),e.lineTo(t.x+c,t.y),e.lineTo(t.x,t.y+c),e.lineTo(t.x-c,t.y),e.closePath();else if("faceted"===l){const o=6;for(let r=0;o>r;r+=1){const n=2*Math.PI*r/o-Math.PI/2,i=t.x+Math.cos(n)*c,a=t.y+Math.sin(n)*c;0===r?e.moveTo(i,a):e.lineTo(i,a)}e.closePath()}else e.arc(t.x,t.y,c,0,2*Math.PI);r&&(e.save(),e.globalAlpha*=s,e.fillStyle=r,e.fill(),e.restore()),"halo"===l&&(e.beginPath(),e.arc(t.x,t.y,1.35*c,0,2*Math.PI),e.strokeStyle=n??r,e.lineWidth=Math.max(1.5,i||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),n&&i>0&&(e.strokeStyle=n,e.lineWidth=i,o.strokeDasharray&&e.setLineDash(o.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function RA(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function TA(e){return e.sensorId??"stream-region-"+e.id}function NA(e){const t=TA(e),o={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){const r=e.colliderThickness??8,n=e.shape.x-e.shape.width/2,i=e.shape.x+e.shape.width/2,a=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...o,id:t+"-top",shape:{type:"segment",x1:n,y1:a,x2:i,y2:a,thickness:r}},{...o,id:t+"-right",shape:{type:"segment",x1:i,y1:a,x2:i,y2:s,thickness:r}},{...o,id:t+"-bottom",shape:{type:"segment",x1:i,y1:s,x2:n,y2:s,thickness:r}},{...o,id:t+"-left",shape:{type:"segment",x1:n,y1:s,x2:n,y2:a,thickness:r}}]}return e.collider?[{...o,id:t+"-collider",shape:e.shape}]:[]}function $A(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function BA(e,t){const o="function"==typeof e?e(t):e;if(!o)return null;const r=Number(o.x??0),n=Number(o.y??0);return Number.isFinite(r)||Number.isFinite(n)?{x:Number.isFinite(r)?r:0,y:Number.isFinite(n)?n:0}:null}function DA(e){if(!1===e.semanticItem)return null;const t=e.shape,o=e.semanticItem??{},r="aabb"===t.type?{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:t.x,y:t.y,width:t.width,height:t.height}:{id:e.id,label:e.label??e.id,description:e.description,group:e.kind??"region",x:(t.x1+t.x2)/2,y:(t.y1+t.y2)/2,pathData:`M ${t.x1} ${t.y1} L ${t.x2} ${t.y2}`};return{...r,...o,id:o.id??r.id}}function FA(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function EA(e,t){const o="function"==typeof e?e(t):e;if(!o)return null;const r=Number(o.x??0),n=Number(o.y??0);return Number.isFinite(r)||Number.isFinite(n)?{x:Number.isFinite(r)?r:0,y:Number.isFinite(n)?n:0}:null}var zA=[];function jA(e){const t=e.store.controls(),o=e.store.snapshot(),r=Math.max(0,e.result.steps*(o.config.fixedDt||1/60)),n=function(e,t,o,r){const n=Number.isFinite(r)?Math.max(0,r):0;if(0>=n||!FA(t))return!1;const i=new Map(t.map(e=>[e.id,e])),a=e.readBodies();let s=!1;for(const t of a){const r=o.get(t.id);if(!r||!r.activeRegionIds.size)continue;const a=$A(r);if(a)for(const o of r.activeRegionIds){const r=i.get(o);if(!r)continue;const l=BA(r.force,{body:t,region:r,regionState:a}),c=Number(r.damping??0),u=(l?.x??0)*n-(Number.isFinite(c)?t.vx*c*n:0),d=(l?.y??0)*n-(Number.isFinite(c)?t.vy*c*n:0);(u||d)&&(e.applyImpulse(t.id,u,d),s=!0)}}return s}(t,e.regionEffects,e.regionState,r),i=function(e,t,o,r,n,i){const a=Number.isFinite(i)?Math.max(0,i):0;if(0>=a||!t)return!1;const s=new Map(o.map(e=>[e.id,e])),l=e.readBodies();let c=!1;for(let o=0;l.length>o;o+=1){const i=l[o],u=r.get(i.id),d=$A(u);let h=zA;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const o=s.get(t);o&&e.push(o)}h=e}const p=EA(t,{body:i,bodies:l,index:o,regionState:d,regions:h,simulationState:n});if(!p)continue;const m=(p.x??0)*a,f=(p.y??0)*a;(m||f)&&(e.applyImpulse(i.id,m,f),c=!0)}return c}(t,e.bodyForces,e.regionEffects,e.regionState,o.simulationState,r);return e.composed&&e.composed.onTick(e.result,t,{dt:r,elapsed:e.result.elapsedSeconds,getRegionState:t=>$A(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:n,bodyForcesApplied:i,snapshot:o}}function OA(e,t,o,r,n,i,a,s,l,c){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,n),d={selected:u,simulationState:t,regionState:i,regions:a},h="function"==typeof o?o(e,d):o,p=a.reduce((t,o)=>o.bodyStyle?{...t,..."function"==typeof o.bodyStyle?o.bodyStyle(e,d):o.bodyStyle}:t,{}),m=u?"function"==typeof r?r(e,d):r:void 0;return{fill:c?.color??s,stroke:c?.stroke??l,strokeWidth:c?.strokeWidth??1,opacity:c?.opacity??.9,...h,...p,...m}}import*as HA from"react";import{jsx as WA,jsxs as qA}from"react/jsx-runtime";var GA={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},YA="semiotic-accessible-data-table",VA=YA+" semiotic-accessible-data-table-hidden",XA=YA+" semiotic-accessible-data-table-visible",UA={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},KA={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},QA={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},ZA={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},JA={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},eC={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},tC={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},oC={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function rC(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function nC(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function iC(e){if("circle"===e.shape.type){const t=Math.max(4,2*e.shape.radius);return{height:t,shape:"circle",width:t}}return{height:e.shape.height,shape:"rect",width:e.shape.width}}function aC(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e+""}return e.id}function sC(e){const t=lC(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function lC(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const o=rC(t);return null==o?null:[e,o]}).filter(e=>null!=e).slice(0,8):[]}function cC({hover:e}){const t=lC(e.data);return qA("div",{className:"semiotic-tooltip",style:ms,children:[WA("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>qA("div",{children:[qA("span",{style:{opacity:.72},children:[e,": "]}),WA("span",{children:t})]},e))]})}function uC(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const o=rC(t);return null==o?null:`${e}: ${o}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function dC(e){const t=[`${e.length} semantic item${1===e.length?"":"s"}.`],o=new Map;for(const t of e)t.group&&o.set(t.group,(o.get(t.group)??0)+1);return o.size&&t.push(Array.from(o).map(([e,t])=>`${e}: ${t}`).join(", ")),t.join(" ")}function hC(e){const{chartTitle:t,items:o,tableId:r}=e,[n,i]=HA.useState(!1),[a,s]=HA.useState(5),l=Ca(),c=l?.visible??!1,u=n||c,d=HA.useRef(null),h="Data summary for "+(t??"physics chart");HA.useEffect(()=>{u||s(5)},[u]);const p=HA.useCallback(e=>{e.target===e.currentTarget&&(n||c||i(!0))},[n,c]),m=HA.useCallback(e=>{c||d.current?.contains(e.relatedTarget)||i(!1)},[c]);if(!o.length)return WA("span",{id:r,tabIndex:-1,style:GA});if(!u)return WA("div",{id:r,className:VA,role:"region","aria-label":h,tabIndex:-1,style:GA,onFocus:p,children:qA("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",o.length," semantic items)"]})});const f=Math.min(a,o.length),g=o.slice(0,f),y=o.length-f;return qA("div",{ref:d,id:r,className:XA,role:"region","aria-label":h,tabIndex:-1,onBlur:m,style:UA,children:[WA("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},style:QA,children:"×"}),WA("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:KA,children:dC(o)}),qA("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:ZA,children:[WA("caption",{className:"semiotic-accessible-data-table-caption",style:tC,children:y>0?`First ${f} of ${o.length} semantic items`:`All ${o.length} semantic items`}),WA("thead",{children:qA("tr",{children:[WA("th",{scope:"col",style:JA,children:"Item"}),WA("th",{scope:"col",style:JA,children:"Description"}),WA("th",{scope:"col",style:JA,children:"Group"}),WA("th",{scope:"col",style:JA,children:"Position"}),WA("th",{scope:"col",style:JA,children:"Data"})]})}),WA("tbody",{children:g.map((e,t)=>qA("tr",{children:[WA("th",{scope:"row",style:eC,children:e.label}),WA("td",{style:eC,children:e.description??e.label}),WA("td",{style:eC,children:e.group??""}),qA("td",{style:eC,children:[Math.round(e.x),", ",Math.round(e.y)]}),WA("td",{style:eC,children:uC(e)})]},e.id??`${e.label}-${t}`))})]}),y>0?qA("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:oC,children:["Show ",Math.min(25,y)," more"," ",1===y?"row":"rows"," (",y," remaining)"]}):null]})}cC.ownsChrome=!0;import{jsx as pC,jsxs as mC}from"react/jsx-runtime";var fC=[640,360],gC={top:0,right:0,bottom:0,left:0},yC=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]);function bC(e,t,o){const r=new dA(e);return t?.length&&r.enqueue(t,o),r}var vC="StreamPhysicsFrame";function xC(){return"undefined"!=typeof performance?performance.now():Date.now()}var wC=Ak(Sk(function(e,t){const{accessibleTable:o=!0,annotations:r,autoPlaceAnnotations:n,background:i,backgroundGraphics:a,bodySemanticItemLimit:s=200,bodySemanticItems:l=!1,bodySemanticUpdateMs:c=200,bodyForces:u,bodyStyle:d,chartId:h,className:p,frameScheduler:m,clock:f,color:g,config:y,controllers:b,continuous:v=!1,description:x,emphasis:w,chartMode:k,enableHover:S=!0,foregroundGraphics:A,hoverRadius:C=16,initialSpawns:M,initialSpawnPacing:P,legend:I,legendClickBehavior:_,legendHighlightedCategory:L,legendHoverBehavior:R,legendIsolatedCategories:T,legendLayout:N,legendPosition:$,margin:B,onClick:D,onObservation:F,onRegionEvent:E,onSimulationExecutionChange:z,onBodyHover:j,onBodyPointerDown:O,onSemanticItemActivate:H,onSemanticItemFocus:W,onTick:q,opacity:G,paused:Y=!1,regionEffects:V=[],responsiveHeight:X,responsiveWidth:U,selectedBodyStyle:K={stroke:"#111827",strokeWidth:2,opacity:1},selection:Q,semanticItems:Z=[],simulationExecution:J="auto",size:ee=fC,stroke:te,strokeWidth:oe,summary:re,suspendWhenHidden:ne=!0,svgAnnotationRules:ie,title:ae,tooltipContent:se,workerBodyThreshold:le=Qk,renderBody:ce,beforePaint:ue,afterPaint:de}=e,he=kk.useMemo(()=>({color:g,stroke:te,strokeWidth:oe,opacity:G}),[g,G,te,oe]),pe=_k(F);pe.current=F;const me=_k(h);me.current=h;const fe=_k(new Map),ge=_k(V);ge.current=V;const ye=_k(u);ye.current=u;const be=_k(q);be.current=q;const ve=kk.useMemo(()=>function(e){if(!e?.length)return null;const t=e.slice(),o=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:o,onTick:(e,o,r)=>{const n={result:e,controls:o,dt:r.dt,elapsed:r.elapsed,getRegionState:r.getRegionState};for(const e of t)e.tick(n)},bodyForce:e=>{let o=null;for(const r of t)r.bodyForce&&(o=MA(o,r.bodyForce(e)));return o}}}(b),[b]),xe=_k(ve);xe.current=ve;const we=v||!!ve?.continuous,ke=_k(we);ke.current=we;const Se=kk.useMemo(()=>{if(!u&&!ve?.bodyForce)return u;if(!ve?.bodyForce)return u;if(!u)return ve.bodyForce;const e=ve.bodyForce;return t=>{const o="function"==typeof u?u(t):u,r="function"==typeof e?e(t):e;return o||r?{x:(o?.x??0)+(r?.x??0),y:(o?.y??0)+(r?.y??0)}:null}},[u,ve]);ye.current=Se;const Ae=kk.useMemo(()=>new Map(V.map(e=>[TA(e),e])),[V]),Ce=kk.useMemo(()=>new Map(V.map(e=>[e.id,e])),[V]),Me=kk.useMemo(()=>V.map(DA).filter(e=>null!=e),[V]),[Pe,Ie]=kk.useState([]),_e=kk.useMemo(()=>Pe.length||Me.length?[...Z,...Pe,...Me]:Z,[Pe,Me,Z]),Le=kk.useMemo(()=>FA(V),[V]),Re=!!Se,Te=_k(null),Ne=_k(f??xC);Ne.current=f??xC;const $e=Ck((e,t,o)=>{const r=Te.current;if(!r||!o)return!1;const n=r.readBodies().find(t=>t.id===e),i=$A(fe.current.get(e));if(!n||!i)return!1;const a=BA(o,{body:n,region:t,regionState:i});return!(!a||!a.x&&!a.y||(r.applyImpulse(e,a.x??0,a.y??0),0))},[]),Be=Ck((e,t,o)=>{if(!o.bodyId)return;const r=$A(fe.current.get(o.bodyId));if(!r)return;const n={bodyId:o.bodyId,datum:o.datum,observation:o,region:t,regionState:r,type:e};"region-enter"===e?t.onEnter?.(n):t.onExit?.(n),E?.(n)},[E]),De=Ck(e=>{const t=e.sensorId?Ae.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const o=function(e,t){let o=e.get(t);return o||(o={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,o)),o}(fe.current,e.bodyId),r=Te.current?.readBodies().find(t=>t.id===e.bodyId),n=$A(o),i=r&&n?{body:r,region:t,regionState:n}:null;if("physics-proximity-enter"===e.type){if(o.activeRegionIds.add(t.id),o.regionIds.add(t.id),o.energy+=t.energyDelta??0,i){!function(e,t,o){const r="function"==typeof e.attributes?e.attributes(t):e.attributes;r&&(o.attributes={...o.attributes,...r})}(t,i,o);const e=function(e,t){return void 0!==e.charge?"function"==typeof e.charge?e.charge(t):e.charge:"charge-gate"===e.kind?1:void 0}(t,i);void 0!==e&&(o.charges[t.id]=e)}$e(e.bodyId,t,t.impulseOnEnter),Be("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(o.activeRegionIds.delete(t.id),$e(e.bodyId,t,t.impulseOnExit),Be("region-exit",t,e))},[$e,Be,Ae]),Fe=kk.useMemo(()=>{if(!r?.length)return[];const e=r.filter(e=>"barrier"===e.physics||"sensor"===e.physics);return e.length?function(e=[],t={}){const o=t.idPrefix?t.idPrefix+"-":"",r=[];for(const n of e){if("barrier"!==n.physics&&"sensor"!==n.physics)continue;const e=n.axis??t.defaultAxis??"x",i=Kk(n,t),a=n.colliderId??`${o}${n.id}`;let s;if("x"===e){const e=Uk(n.x),o=Uk(n.y1)??Uk(t.plotBounds?.y)??Uk(n.y),r=Uk(n.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??Uk(n.y);if(null==e||null==o||null==r)continue;s={type:"segment",x1:e,y1:o,x2:e,y2:r,thickness:i}}else{const e=Uk(n.y),o=Uk(n.x1)??Uk(t.plotBounds?.x)??Uk(n.x),r=Uk(n.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??Uk(n.x);if(null==e||null==o||null==r)continue;s={type:"segment",x1:o,y1:e,x2:r,y2:e,thickness:i}}r.push({id:a,shape:s,sensor:"sensor"===n.physics,..."barrier"!==n.physics||null==n.restitution&&null==t.barrierRestitution?{}:{restitution:Uk(n.restitution)??Uk(t.barrierRestitution)},..."barrier"!==n.physics||null==n.friction&&null==t.barrierFriction?{}:{friction:Uk(n.friction)??Uk(t.barrierFriction)}})}return r}(e,{idPrefix:h?h+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:ee?.[0]??fC[0],height:ee?.[1]??fC[1]}}):[]},[r,h,ee]),Ee=kk.useMemo(()=>{const e=V.flatMap(e=>[{id:TA(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...NA(e)]),t=Object.fromEntries(V.map(e=>[TA(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),o=y?.observation,r=V.length>0;return r||e.length>0||Fe.length>0||null!=h||o?{...y,colliders:[...y?.colliders??[],...e,...Fe],observation:{...o,chartId:h??o?.chartId,chartType:o?.chartType??vC,sensors:{...o?.sensors??{},...t},onObservation:e=>{r&&De(e),o?.onObservation?.(e)}}}:y},[Fe,h,y,De,V]);if(!Te.current){const e=bC(Ee,M,P);e.setPaused(Y),ne&&e.setVisible(_A()),Te.current=e}const ze=_k(null),je=_k(-1),Oe=_k(null),He=_k(!0),We=_k(""),qe=Ik().replace(/:/g,""),Ge=_k(!1),Ye=_k(!1),Ve=_k(0),Xe=_k(!1),Ue=_k(null),Ke=_k(!1),Qe=js({sizeProp:ee,responsiveWidth:U,responsiveHeight:X,userMargin:B,marginDefault:gC,foregroundGraphics:A,backgroundGraphics:a,frameScheduler:m}),{margin:Ze,rafRef:Je,reducedMotionRef:et,renderFnRef:tt,cancelRender:ot,resolvedBackground:rt,resolvedForeground:nt,responsiveRef:it,scheduleRender:at,size:st}=Qe,lt=na(),ct=la(),[ut,dt]=kk.useState(null),[ht,pt]=kk.useState(null),mt=_k(null),ft=_k(0),gt=_k(new Map),yt=qe+"-physics-live",bt=Ck((e,t,o=!1)=>{if(!l)return void Ie(e=>e.length?[]:e);const r=Ne.current();if(!o&&c>0&&c>r-ft.current)return;ft.current=r;const n=function(e,t,o,r){if(!o)return[];const n=Math.max(0,Math.floor(r));if(!n)return[];const i=[];for(let r=0;e.length>r&&n>i.length;r+=1){const n=e[r],a="function"==typeof o?o(n,{index:r,simulationState:t}):void 0;if(!1===a)continue;const s=iC(n);i.push({datum:n.datum??n,description:sC(n),group:"body",label:aC(n),...s,...a??{},bodyId:a?.bodyId??n.id,id:a?.id??"body:"+n.id,x:a?.x??n.x,y:a?.y??n.y})}return i}(e,t,l,s);Ie(e=>function(e,t){if(e.length!==t.length)return!0;for(let o=0;e.length>o;o+=1){const r=e[o],n=t[o];if(r.id!==n.id||r.label!==n.label||r.description!==n.description||r.group!==n.group||r.bodyId!==n.bodyId||Math.round(r.x)!==Math.round(n.x)||Math.round(r.y)!==Math.round(n.y))return!0}return!1}(e,n)?n:e)},[s,l,c]),vt=Ck(e=>{if(!_e.length)return;const t=Math.max(0,Math.min(e,_e.length-1));je.current=t;const o=_e[t];if(mt.current=o.bodyId??null,dt(o),W?.(o),o.bodyId&&Te.current){const e=Te.current.readBodies().find(e=>e.id===o.bodyId);if(e){const t=nC(e);pt(t),j?.(e,t)}}},[_e,j,W]),xt=Ck(()=>{je.current=-1,mt.current=null,dt(null),W?.(null)},[W]),wt=Ck((e,t)=>{const o=pe.current;if(!o)return;const r=Ne.current();o("hover"!==e&&"click"!==e?{type:e,timestamp:r,chartType:vC,chartId:me.current}:{type:e,datum:t?.datum??{},x:t?.x??0,y:t?.y??0,timestamp:r,chartType:vC,chartId:me.current})},[]),kt=Ck(()=>{pt(e=>e?(j?.(null,null),wt("hover-end"),null):e)},[wt,j]),St=Ck(e=>{if(!S||!Te.current)return;const t=e.currentTarget.getBoundingClientRect(),o=Te.current.hitTest(e.clientX-t.left,e.clientY-t.top,C);if(!o)return void kt();const r=nC(o);pt(e=>e&&e.id===r.id&&e.x===r.x&&e.y===r.y?e:(j?.(o,r),wt("hover",{datum:o.datum,x:o.x,y:o.y}),r))},[kt,wt,S,C,j]),At=Ck(e=>{xt();const t=Te.current,o=e.currentTarget.getBoundingClientRect(),r=e.clientX-o.left,n=e.clientY-o.top,i=t?t.hitTest(r,n,Math.max(16,C)):null;O?.(i,e),i?(wt("click",{datum:i.datum,x:i.x,y:i.y}),D?.(i.datum??null,{x:i.x,y:i.y,body:i})):(wt("click-end"),D?.(null,{x:r,y:n,body:null}),kt())},[kt,xt,wt,C,O,D]);Mk(()=>{if(!_e.length)return void xt();const e=je.current;if(_e.length>e){if(e>=0){const t=_e[e];if(mt.current=t.bodyId??null,dt(e=>null!=e&&e.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t),t.bodyId&&Te.current){const e=Te.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=nC(e);pt(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else vt(_e.length-1)},[_e,xt,vt]),Mk(()=>{S||kt()},[kt,S]);const Ct=Ck(e=>{if(!_e.length)return;if("Escape"===e.key)return e.preventDefault(),void xt();if(("Enter"===e.key||" "===e.key)&&je.current>=0)return e.preventDefault(),void H?.(_e[je.current]);if(!yC.has(e.key))return;e.preventDefault();const t=je.current;if(0>t)return void vt(0);const o=Math.max(1,Math.floor(.1*_e.length));let r=t;"Home"===e.key?r=0:"End"===e.key?r=_e.length-1:"PageDown"===e.key?r=Math.min(_e.length-1,t+o):"PageUp"===e.key?r=Math.max(0,t-o):"ArrowRight"===e.key||"ArrowDown"===e.key?r=Math.min(_e.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(r=Math.max(0,t-1)),vt(r)},[xt,vt,H,_e]),[Mt,Pt]=kk.useState([]),It=_k(0),_t=!!r?.length&&r.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),Lt=Ck(()=>{const e=ze.current,t=Te.current;if(!e||!t)return;const o=Ws(),r=Hs(e,st,Ze,o);if(!r)return;const n=function(e){const t=jk(e,Bk),o=jk(e,Tk),r=jk(e,zk),n=jk(e,Dk),i=jk(e,Rk),a=jk(e,Lk),s=jk(e,Fk),l=jk(e,Ek),c=jk(e,Nk),u=jk(e,$k);return{annotationBackground:Ok(a,.94),annotationStroke:i,annotationText:s,background:a,border:i,closedWindowFill:Ok(o,.08),closedWindowStroke:Ok(o,.55),danger:o,focus:c,grid:u,gutterFill:Ok(l,.14),lateFill:r,openWindowFill:Ok(t,.07),openWindowStroke:Ok(t,.3),primary:t,selectedFill:r,selectedStroke:c,success:n,text:s,textSecondary:l,warning:r}}(r);r.clearRect(-Ze.left,-Ze.top,st[0],st[1]),a||"transparent"===i||(r.fillStyle=i??n.background,r.fillRect(-Ze.left,-Ze.top,st[0],st[1]));const s=t.snapshot(),l=t.readBodies();if(bt(l,s.simulationState),_t){const e=Ne.current();if(e-It.current>=100){It.current=e;const t=function(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,Vk(e))}))}(l);Pt(e=>e.length===t.length&&e.every((e,o)=>e.pointId===t[o].pointId&&Math.round(e.x)===Math.round(t[o].x)&&Math.round(e.y)===Math.round(t[o].y))?e:t)}}ue&&(r.save(),ue(r,l),r.restore());for(const e of l){const t=fe.current.get(e.id),o=t?Array.from(t.activeRegionIds).map(e=>Ce.get(e)).filter(e=>null!=e):[],i=OA(e,s.simulationState,d,K,Q,$A(t),o,n.primary,n.text,he);ce?(r.save(),ce(r,e,i),r.restore()):LA(r,e,i)}de&&(r.save(),de(r,l),r.restore()),function(e,t,o){let r=!1;for(const[n,i]of t){const a=Math.min(1,Math.max(0,(o-i.startedAt)/i.durationMs));if(a>=1){t.delete(n);continue}r=!0;const s=1-Math.pow(1-a,3),{body:l}=i,c=i.radius+28*s,u=1-a;e.save(),e.globalAlpha*=u,e.strokeStyle=i.color,e.fillStyle=i.color,e.lineWidth=2.4*u+.4,e.beginPath(),e.arc(l.x,l.y,c,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(l.x,l.y,.52*c,0,2*Math.PI),e.fill(),e.restore(),e.save(),e.globalAlpha*=u,e.strokeStyle=i.color,e.lineWidth=1.8;for(let t=0;8>t;t+=1){const o=t*(Math.PI/4)+1.4*a,r=i.radius+5+12*s,n=i.radius+12+34*s;e.beginPath(),e.moveTo(l.x+Math.cos(o)*r,l.y+Math.sin(o)*r),e.lineTo(l.x+Math.cos(o)*n,l.y+Math.sin(o)*n),e.stroke()}e.restore()}}(r,gt.current,Ne.current()),He.current=!1},[de,i,a,ue,d,Ze,_t,Ce,ce,K,Q,he,bt,st]),Rt=Ck((e,t)=>{const o=Te.current,r=`${J}:${e}:${t??""}`;We.current!==r&&(We.current=r,z?.({execution:e,liveBodies:o?.liveBodyCount()??0,queuedBodies:o?.queueSize()??0,reason:t,requested:J}))},[z,J]),Tt=Ck((e,t=!0)=>{Ve.current+=1,Ge.current=!1,Xe.current=!1,Ke.current=!1,Ue.current?.terminate(),Ue.current=null,t&&Rt("sync",e)},[Rt]),Nt=Ck(()=>lt?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Le?"runtime region effects require sync":Re?"body forces require sync":ve?"physics controllers require sync":function(e){return!e||!e.engine&&Jk(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(Ee??{})?oS(P)?Ye.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Ee,ve,Re,Le,lt,P]),$t=Ck(()=>{const e=Te.current,t=Nt();if(!e||t)return{reason:t,useWorker:!1};const o=e.liveBodyCount(),r=e.queueSize(),n=function(e,t,o=0,r=Qk){return"sync"!==e&&("worker"===e||t+o>=r)}(J,o,r,le);return{reason:n?"worker"===J?"forced worker":"body threshold":"below threshold",useWorker:n}},[J,le,Nt]),Bt=Ck(e=>{const t=Te.current;return t&&e.snapshot?(t.restore(e.snapshot),He.current=!0,t):t},[]),Dt=Ck((e,t=!0)=>{const o=Bt(e);if(!o)return;t&&q?.(e.result,o.controls()),Lt();const r=o.snapshot();!e.result.shouldContinue&&gt.current.size<=0||r.paused||!r.visible||et.current||at()},[Bt,q,Lt,et,at]),Ft=Ck(e=>{Ye.current=!0,Tt("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Tt]),Et=Ck(()=>{const e=Te.current;if(!e)return!1;const t=$t();if(!t.useWorker)return Ge.current||Ke.current?Tt(t.reason??"sync fallback"):Rt("sync",t.reason??"sync"),!1;if(Ge.current||Ke.current)return!0;const o=Ue.current??new iS;Ue.current=o,Ke.current=!0;const r=Ve.current+1;return Ve.current=r,o.initFromSnapshot(Ee??{},e.snapshot()).then(e=>{if(Ve.current!==r)return;Ke.current=!1,Ge.current=!0,Ye.current=!1,Bt(e),Rt("worker",t.reason??"worker"),Lt();const o=Te.current?.snapshot();e.result.shouldContinue&&o&&!o.paused&&o.visible&&!et.current&&(Oe.current=null,at())}).catch(e=>{Ve.current===r&&Ft(e)}),!0},[Bt,Ee,Ft,Lt,et,Rt,at,Tt,$t]),zt=Ck(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),jt=Ck((e,t=!0)=>{const o=Ue.current;if(!o||!Ge.current)return;const r=Ve.current;o.request(e).then(e=>{if(Ve.current!==r)return;const o=zt(e);o&&Dt(o,t)}).catch(Ft)},[Dt,zt,Ft]),Ot=Ck(()=>{const e=Te.current;if(!e)return;const t=Et(),o=e.snapshot(),r=we||Re||Le||!!ve;o.paused||!o.visible||!e.hasPendingWork()&&!r||et.current?tt.current():t&&Ke.current||(Oe.current=null,at())},[ve,we,Re,Le,et,tt,at,Et]),Ht=Ck(()=>{ot(),Je.current=null;const e=Te.current;if(!e)return;if(Ge.current&&Ue.current){if(Xe.current)return;let t=0;if(!et.current){const e=Ne.current();t=null!==Oe.current?(e-Oe.current)/1e3:0,Oe.current=e}const o=Ue.current,r=Ve.current;return Xe.current=!0,void(et.current?o.settle():o.tick(t)).then(e=>{Xe.current=!1,Ve.current===r&&Dt(e)}).catch(o=>{if(Xe.current=!1,Ve.current!==r)return;Ft(o);const n=et.current?e.settleWithObservations():e.tick(t);jA({store:e,result:n,regionEffects:ge.current,regionState:fe.current,bodyForces:ye.current,composed:xe.current,onTick:be.current}),Lt()})}let t;if(et.current)t=e.settleWithObservations();else{const o=Ne.current(),r=null!==Oe.current?(o-Oe.current)/1e3:0;Oe.current=o,t=e.tick(r)}const o=xe.current,{regionEffectsApplied:r,bodyForcesApplied:n,snapshot:i}=jA({store:e,result:t,regionEffects:ge.current,regionState:fe.current,bodyForces:ye.current,composed:o,onTick:be.current});Lt(),(ke.current||t.shouldContinue||r||n||o||gt.current.size>0)&&!i.paused&&i.visible&&!et.current&&at()},[Dt,Ft,Lt,ot,at,et,Je]);tt.current=Ht,ca({hydrated:lt,wasHydratingFromSSR:ct,storeRef:Te,dirtyRef:He,renderFnRef:tt,cancelRender:ot}),Mk(()=>{Ye.current=!1,(Ge.current||Ke.current)&&Tt("config changed",!1),Te.current?.updateConfig(Ee??{}),Ot()},[Ee,Tt]),Mk(()=>{Ye.current=!1,Ot()},[lt,J,le]),function({cancelRender:e,lastFrameTimeRef:t,paused:o,postWorkerCommand:r,requestRender:n,storeRef:i,suspendWhenHidden:a}){const s=IA(r);s.current=r;const l=IA(n);l.current=n,PA(()=>{const r=i.current;r&&(r.setPaused(o),o&&(t.current=null,e()),s.current({type:"setPaused",paused:o},!1),l.current())},[e,o]),PA(()=>{if(!a||"undefined"==typeof document)return;const o=()=>{const o=i.current;if(!o)return;const r=_A();o.setVisible(r),r||(t.current=null,e()),s.current({type:"setVisible",visible:r},!1),l.current()};return o(),document.addEventListener("visibilitychange",o),()=>document.removeEventListener("visibilitychange",o)},[e,a])}({cancelRender:ot,lastFrameTimeRef:Oe,paused:Y,postWorkerCommand:jt,requestRender:Ot,storeRef:Te,suspendWhenHidden:ne}),Mk(()=>()=>Tt("unmount",!1),[Tt]),Mk(()=>{Lt()},[Lt]),Pk(t,()=>({...Te.current.controls(),applyImpulse:(e,t,o)=>{Te.current.applyImpulse(e,t,o),jt({type:"applyImpulse",id:e,ix:t,iy:o}),Ot()},clear:()=>{Te.current.clear(),fe.current.clear(),gt.current.clear(),jt({type:"clear"}),Ot()},clearRegionState:e=>{e?fe.current.delete(e):fe.current.clear(),Ot()},getData:()=>Te.current.readBodies(),getRegionState:e=>e?$A(fe.current.get(e)):function(e){const t={};return e.forEach((e,o)=>{const r=$A(e);r&&(t[o]=r)}),t}(fe.current),getStore:()=>Te.current,pause:()=>{Te.current.setPaused(!0),jt({type:"setPaused",paused:!0},!1),Ot()},push:(e,t)=>{Te.current.enqueue(e,t),oS(t)?jt({type:"enqueue",spawns:[e],pacing:t}):(Ge.current||Ke.current)&&Tt("spawn pacing is not worker-cloneable"),Ot()},pushMany:(e,t)=>{Te.current.enqueue(e,t),oS(t)?jt({type:"enqueue",spawns:e,pacing:t}):(Ge.current||Ke.current)&&Tt("spawn pacing is not worker-cloneable"),Ot()},popBodies:(e,t={})=>{const o=Te.current,r=new Map(o.readBodies().map(e=>[e.id,e])),n=o.remove(e),i=Ne.current();for(const e of n){const o=r.get(e);o&&(fe.current.delete(e),gt.current.set(e,{body:o,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??RA(o),startedAt:i}),mt.current===e&&(mt.current=null,dt(null)),pt(t=>t?.id===e?null:t))}return n.length&&(jt({type:"remove",ids:n}),Ot()),n},remove:e=>{const t=Te.current.remove(e);for(const t of e)fe.current.delete(t);return jt({type:"remove",ids:e}),Ot(),t},restore:e=>{Te.current.restore(e),fe.current.clear(),gt.current.clear(),jt({type:"restore",snapshot:e},!1),Ot()},resume:()=>{Te.current.setPaused(!1),jt({type:"setPaused",paused:!1},!1),Ot()},settle:e=>{const t=Te.current.settle(e);return jt({type:"settle",maxSteps:e}),Ot(),t},settleWithObservations:e=>{const t=Te.current.settleWithObservations(e);return jt({type:"settle",maxSteps:e}),Ot(),t},step:e=>{const t=Te.current,o=t.tick(e);return jA({store:t,result:o,regionEffects:ge.current,regionState:fe.current,bodyForces:ye.current,composed:xe.current,onTick:be.current}),jt({type:"tick",deltaSeconds:e}),Lt(),o}}),[Lt,jt,Ot,Tt]);const Wt=Qi||!lt&&ct,qt=["stream-physics-frame",k?"stream-physics-frame--mode-"+k:null,w?"stream-physics-frame--emphasis-"+w:null,p].filter(Boolean).join(" "),Gt=x??("string"==typeof ae?ae:void 0)??"Physics chart",Yt=qe+"-physics-table",Vt=Math.max(1,st[0]-Ze.left-Ze.right),Xt=Math.max(1,st[1]-Ze.top-Ze.bottom),Ut=S&&ht?se?se(ht):pC(cC,{hover:ht}):null,Kt=Ut&&ht?pC(ks,{x:ht.x-Ze.left,y:ht.y-Ze.top,containerWidth:Math.max(1,st[0]-Ze.left-Ze.right),containerHeight:Math.max(1,st[1]-Ze.top-Ze.bottom),margin:Ze,className:"stream-physics-tooltip",children:Ut}):null;if(Wt){const e=Te.current??bC(Ee,M,P),t="string"==typeof ae?ae:void 0,{svg:o}=function(e,t={}){const{width:o=640,height:r=360,title:n,description:i,background:a,className:s,idPrefix:l="physics",...c}=t,u=yA(e,c),d=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(l),h=n?d+"-title":void 0,p=i?d+"-desc":void 0,m=[h,p].filter(Boolean).join(" ")||void 0;return{svg:hA.renderToStaticMarkup(vA("svg",{xmlns:"http://www.w3.org/2000/svg",className:s??"stream-physics-frame",width:o,height:r,viewBox:`0 0 ${o} ${r}`,role:"img","aria-labelledby":m,children:[n&&bA("title",{id:h,children:n}),i&&bA("desc",{id:p,children:i}),a&&"transparent"!==a?bA("rect",{x:0,y:0,width:o,height:r,fill:a}):null,bA("g",{id:d+"-data-area",children:u.sceneNodes.map((e,t)=>Ki(e,t,d))})]})),scene:u,evidence:u.evidence}}(e,{width:st[0],height:st[1],title:t,description:x,background:"transparent"===i?void 0:i,className:"stream-physics-frame__svg",idPrefix:"physics-"+qe});return mC("div",{ref:it,className:qt,"data-semiotic-mode":k,role:"img","aria-label":Gt,style:{width:st[0],height:st[1]},children:[pC(Ka,{summary:re}),pC("div",{dangerouslySetInnerHTML:{__html:o}})]})}return mC("div",{ref:it,className:qt,"data-semiotic-mode":k,role:"group","aria-label":Gt,"aria-describedby":ut?yt:void 0,tabIndex:0,style:{position:"relative",width:st[0],height:st[1]},onKeyDown:Ct,children:[o?pC(Qa,{tableId:Yt}):null,o?pC(hC,{chartTitle:"string"==typeof ae?ae:Gt,items:_e,tableId:Yt}):null,pC(Ka,{summary:re}),pC(Za,{hoverPoint:ht}),pC("div",{id:yt,"aria-live":"polite","aria-atomic":"true",style:GA,children:ut?ut.description??ut.label:""}),mC("div",{role:"img","aria-label":Gt,style:{position:"relative",width:"100%",height:"100%"},children:[rt,pC("canvas",{ref:ze,width:st[0],height:st[1],"aria-hidden":"true",onPointerDown:At,onPointerMove:S?St:void 0,onPointerLeave:S?kt:void 0}),nt,pC(Xk,{width:Vt,height:Xt,totalWidth:st[0],totalHeight:st[1],margin:Ze,title:ae,legend:I,legendPosition:$,legendLayout:N,legendHoverBehavior:R,legendClickBehavior:_,legendHighlightedCategory:L,legendIsolatedCategories:T,pointNodes:Mt,annotations:r,autoPlaceAnnotations:n,svgAnnotationRules:ie}),pC(ts,{active:null!=ut,hoverPoint:ut?{x:ut.x,y:ut.y}:null,margin:Ze,size:st,shape:ut?.shape,width:ut?.width,height:ut?.height,pathData:ut?.pathData}),Kt]})]})}));wC.displayName="StreamPhysicsFrame";var kC=wC;function SC(e){const[t,o]=e;return{width:t,height:o,plot:{x:32,y:24,width:Math.max(80,t-64),height:Math.max(80,o-58)}}}function AC(e){const t=(e??"")+"";if(!t)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let r=0;for(let e=0;t.length>e;e+=1)r=31*r+t.charCodeAt(e)>>>0;return o[r%o.length]}function CC(e,t="#4e79a7"){return o=>{const r=o.datum,n=r&&e?"function"==typeof e?e(r,0):r[e]:void 0;return{fill:null==n?t:AC(n),stroke:"#111827",strokeWidth:1,opacity:.9}}}function MC(e,t,o,r){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:o},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...r}}}function PC(e,t,o){if(!e.length)return[];const r=SC(t),n=r.plot.width/Math.max(1,e.length),i=Math.max(1,...e.map(e=>e.value)),a=.62*r.plot.height,s=r.plot.y+r.plot.height;return e.map((e,t)=>{const l=Math.max(8,e.value/i*a),c=`${o} ${e.label}: ${e.value}${null==e.secondary?"":`, ${e.secondary} secondary`}`;return{id:`${o}-${e.label}`,label:c,description:c,datum:e,x:r.plot.x+(t+.5)*n,y:s-l/2,shape:"rect",width:Math.max(12,.58*n),height:l,group:o}})}function IC(e,t,o){return"function"==typeof o?o(e,t):e[o]}function _C(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function LC(e,t,o){return Math.max(t,Math.min(o,e))}function RC(e,t){const o=_C(e);return null!=o&&o>0?o:t}function TC(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function NC(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}import{scaleLinear as $C}from"d3-scale";function BC(e){const{data:t,valueAccessor:o,bins:r,ballRadius:n,seed:i,size:a,valueExtent:s}=e,l=SC(a),c=t.map((e,t)=>_C(IC(e,t,o))).filter(e=>null!=e),u=function(e){if(!e)return;const t=_C(e[0]),o=_C(e[1]);return null!=t&&null!=o?t>o?[o,t]:[t,o]:void 0}(s),d=u?.[0]??(c.length?Math.min(...c):0),h=u?.[1]??(c.length?Math.max(...c):1),p=h===d?1:h-d,m=$C().domain([0,r]).range([l.plot.x,l.plot.x+l.plot.width]),f=Array.from({length:r},()=>0),g=[];t.forEach((e,t)=>{const i=_C(IC(e,t,o));if(null==i)return;const a=Math.max(0,Math.min(r-1,Math.floor((i-d)/p*r)));f[a]+=1,g.push({id:(e.id??"galton-"+t)+"",x:m(a+.5),y:l.plot.y+n+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:n},datum:{...e,value:i,bin:a}})});const y=l.plot.y+l.plot.height;return{config:MC(i,[...eA({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...tA({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:m,yTop:l.plot.y-400,yBottom:y,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:f.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:r,plot:l.plot,valueExtent:[d,h]}}}import{scaleLinear as DC}from"d3-scale";function FC(e){const{count:t,idPrefix:o,wallThickness:r,xScale:n,yBottom:i,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{const l=Math.min(i-1,s?.(t)??a),c=Math.max(1,i-l);return{id:`${o}-wall-${t}`,shape:{type:"aabb",x:n(t),y:l+c/2,width:r,height:c}}})}function EC(e,t,o){const r=e.width/Math.max(1,t),n=Math.max(2,2*o),i=Math.min(.7*r,Math.max(3.2*n,n+8)),a=Math.max(1,Math.floor(i/n));return{laneWidth:r,tubeWidth:i,ballDiameter:n,perRow:a,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/a)*n}}function zC(e){const{data:t,categoryAccessor:o,valueAccessor:r,unitValue:n,ballRadius:i,seed:a,size:s}=e,l=RC(n,1),c=SC(s),u=[],d=new Map,h=new Map,p=[];function m(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{m((IC(e,t,o)??"unknown")+"")});const f=Math.max(1,u.length),g=EC(c.plot,f,i),y=Math.max(0,g.tubeWidth/2-i-1),b=u.map(()=>[]);t.forEach((e,t)=>{const n=(IC(e,t,o)??"unknown")+"",a=m(n),s=r?_C(IC(e,t,r)):1,u=Math.max(0,Math.round((s??0)/l)),d=g.centerX(a);for(let o=0;u>o;o+=1){const r=h.get(n)??0,s=g.perRow>1?((g.perRow>1?r%g.perRow:0)/(g.perRow-1)*2-1)*y:0;h.set(n,r+1),b[a].push({id:`${(e.id??"pile-"+t)+""}-${o}`,x:d+s,y:c.plot.y+i+2,vx:(o%3-1)*i/2,vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...e,category:n,unitIndex:o}})}});const v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(const t of b)t.length>e&&p.push(t[e]);const x=c.plot.y+c.plot.height,w=[...eA({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=c.plot.y-400;for(let e=0;f>e;e+=1){const t=g.centerX(e);for(const o of[-1,1])w.push({id:`pile-tube-${e}-${0>o?"l":"r"}`,shape:{type:"aabb",x:t+o*g.tubeWidth/2,y:(k+x)/2,width:6,height:x-k}})}return{config:MC(a,w,"PhysicsPileChart"),initialSpawns:p,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}import{scaleLinear as jC}from"d3-scale";function OC(e){const{data:t,xAccessor:o,groupAccessor:r,radiusAccessor:n,pointRadius:i,seed:a,size:s,xExtent:l,collisionIterations:c,settle:u}=e,d=SC(s),h=NC(a),p=[],m=[],f=new Map;t.forEach((e,t)=>{const a=_C(IC(e,t,o));if(null==a)return;const s=r?(IC(e,t,r)??"All")+"":"All",l=n?_C(IC(e,t,n)):null,c=LC(null!=l&&l>0?l:i,2,18);!function(e){let t=f.get(e);null==t&&(t=m.length,m.push(e),f.set(e,t))}(s),p.push({datum:e,index:t,value:a,group:s,radius:c})});const g=p.map(e=>e.value),y=l?_C(l[0]):null,b=l?_C(l[1]):null,v=g.length?Math.min(...g):0,x=g.length?Math.max(...g):1;let w=y??v,k=b??x;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(i,...p.map(e=>e.radius)),A=d.plot.x+S+8,C=d.plot.x+d.plot.width-S-8,M=jC().domain([w,k]).range([A,C]),P=Math.max(1,m.length),I=d.plot.y+Math.max(28,3*S),_=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-I),L=e=>{const t=f.get(e)??0;return 1===P?d.plot.y+.54*d.plot.height:I+t/(P-1)*_},R=new Map,T=p.map((e,t)=>{R.set(e.group,(R.get(e.group)??0)+1);const o=M(e.value),r=L(e.group),n=(h()-.5)*e.radius*1.6,i=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?o+n:LC(o+(t%9-4)*e.radius*2.5,A,C),y:u?r+i:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:o,targetY:r},springs:[{target:{type:"point",x:o,y:r},restLength:0,stiffness:34,damping:5.5}]}});return{config:MC(a,eA({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(c??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:T,projectionRows:m.map(e=>({label:e,value:R.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,C],groups:m.map(e=>({label:e,y:L(e),count:R.get(e)??0})),plot:d.plot}}}function HC(e){if(Array.isArray(e)&&e.length>=2){const t=_C(e[0]),o=_C(e[1]);return null!=t&&null!=o?{x:t,y:o}:null}if(e&&"object"==typeof e){const t=e,o=_C(t.x),r=_C(t.y);return null!=o&&null!=r?{x:o,y:r}:null}return null}function WC(e){return Array.isArray(e)?e.map(HC).filter(e=>null!=e):[]}function qC(e,t,o){return"normalized"===o?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:LC(e.x,t.plot.x,t.plot.x+t.plot.width),y:LC(e.y,t.plot.y,t.plot.y+t.plot.height)}}function GC(e){let t=0;for(let o=1;e.length>o;o+=1)t+=Math.hypot(e[o].x-e[o-1].x,e[o].y-e[o-1].y);return t}function YC(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const o=LC(t,0,1)*GC(e);let r=0;for(let t=1;e.length>t;t+=1){const n=e[t-1],i=e[t],a=Math.hypot(i.x-n.x,i.y-n.y);if(a>0){if(r+a>=o){const e=(o-r)/a;return{x:n.x+(i.x-n.x)*e,y:n.y+(i.y-n.y)*e}}r+=a}}return{...e[e.length-1]}}function VC(e,t){const o=YC(e,Math.max(0,t-.02)),r=YC(e,Math.min(1,t+.02)),n=r.x-o.x,i=r.y-o.y,a=Math.hypot(n,i)||1;return{x:n/a,y:i/a}}function XC(e){const{coordinateMode:t,flowSpeed:o,links:r,maxParticles:n,nodeIdAccessor:i,nodeXAccessor:a,nodeYAccessor:s,nodes:l,particleRadius:c,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:p,seed:m,size:f,sourceAccessor:g,targetAccessor:y,throughputAccessor:b}=e,v=SC(f),x=NC(m),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof i){const e=i(t,0);if(null!=e)return e+""}if("string"==typeof i&&null!=t[i])return t[i]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}l.forEach((e,t)=>{const o=(IC(e,t,i)??e.id??t)+"",r=_C(IC(e,t,a)),n=_C(IC(e,t,s));if(null!=r&&null!=n){const e={x:r,y:n};w.set(o,e),S.push(e)}k.set(o,(e.label??e.name??o)+"")});const C=[];r.forEach((e,t)=>{const o=A(IC(e,t,g)),r=A(IC(e,t,y)),n=Math.max(0,_C(IC(e,t,b))??0),i=WC(d?IC(e,t,d):void 0),a=i.length?i:WC(e.path??e.points??e.route);a.forEach(e=>S.push(e)),C.push({id:(e.id??`physical-flow-${o}-${r}-${t}`)+"",link:e,index:t,source:o,target:r,throughput:n,rawPath:a})});const M=(I=S,"normalized"===(P=t)||"pixels"===P?P:I.length>0&&I.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var P,I;const _=new Map;for(const[e,t]of w)_.set(e,qC(t,v,M));const L=[];for(const e of C){let t=e.rawPath.map(e=>qC(e,v,M));if(2>t.length){const o=_.get(e.source),r=_.get(e.target);o&&r&&(t=[o,r])}else _.has(e.source)||_.set(e.source,t[0]),_.has(e.target)||_.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),L.push({...e,path:t,packetCount:0}))}const R=RC(u,.12),T=Math.max(1,Math.round(n)),N=L.map(e=>Math.max(1,Math.round(e.throughput*R))),$=N.reduce((e,t)=>e+t,0),B=$>T?T/$:1;L.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(N[t]*B))});let D=L.reduce((e,t)=>e+t.packetCount,0);for(;D>T;){const e=L.reduce((e,t,o)=>t.packetCount>1&&(-1===e||t.packetCount>L[e].packetCount)?o:e,-1);if(-1===e)break;L[e].packetCount-=1,D-=1}const F=new Map,E=new Map,z=[],j=RC(o,90),O=RC(c,4);L.forEach((e,t)=>{F.set(e.target,(F.get(e.target)??0)+e.throughput),E.set(e.source,(E.get(e.source)??0)+e.throughput);const o=GC(e.path);for(let r=0;e.packetCount>r;r+=1){const n=(r+.5)/e.packetCount,i=p?n:LC(.12+.84*n+.04*(x()-.5),.04,.98),a=p?i:Math.max(0,i-(.18+.12*x())),s=YC(e.path,a),l=YC(e.path,i),c=VC(e.path,a),u={x:-c.y,y:c.x},d=(x()-.5)*O*1.5;z.push({id:`${e.id}-packet-${r}`,x:s.x+u.x*d,y:s.y+u.y*d,vx:p?0:c.x*j+10*(x()-.5),vy:p?0:c.y*j+10*(x()-.5),mass:.8,spawnAt:p?0:.04*t+r/32,shape:{type:"circle",radius:O},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:i,flowPath:e.path,flowPathLength:o,flowRouteId:e.id,flowSpeed:j,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&p?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*O,stiffness:26,damping:4.25}]:void 0})}});const H=Math.max(18,5*O),W=Array.from(_,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+TC(e),point:t})),q=W.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:H,height:H}})),G=Object.fromEntries(W.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),Y=MC(m,[...eA({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*O),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});Y.bodyLimit=T,Y.eviction="oldest",Y.observation={...Y.observation,sensors:G};const V=Array.from(_,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+TC(e),incoming:F.get(e)??0,outgoing:E.get(e)??0})),X=L.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:Y,initialSpawns:z,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:M,particleCount:z.length,totalThroughput:L.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:X}}}function UC(e,t,o){return Math.max(t,Math.min(o,e))}function KC(e,t,o,r,n,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:o,x2:r,y2:n,thickness:i.thickness??8}}}function QC(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,o=e.y,r=e.width,n=e.height,{type:"aabb",x:t,y:o,width:r,height:n}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,o,r,n}function ZC(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...QC({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function JC(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function eM(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=e.size,r=SC(o),n=LC(e.ballRadius??6,2,18),i=e.seed??1,a=NC(i),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,p=e.groupCompletion??(c?"allAbsorbed":"none"),m=e.springStiffness??.28,f=e.springDamping??.72,g=!0===e.settle,y=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),b=function(e){const t=e.shape??"lane",o=Math.max(1,Math.round(e.width)),r=Math.max(1,Math.round(e.height)),n=e.padX??46,i=e.padY??72,a=n,s=o-n,l=i,c=r-Math.max(24,Math.round(.45*i)),u=(l+c)/2,d=Math.max(1,c-l),h=UC(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,f=UC(d*h+m,.06*d,.5*d),g=f/2,y=u-g,b=u+g,v=e.idPrefix??"process",x=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=UC(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),C=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),M=s-a;let P=a;const I=S.map((e,t)=>{const o=P,r=t===S.length-1?s:P+(e.share??1)/C*M;return P=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:o,x1:r,x:(o+r)/2,width:r-o,y:u,height:d}}),_=I[A],L=_.x0,R=_.x1,T=(e,o)=>{if("lane"===t)return"top"===o?l:c;if("funnel"===t){const t=UC((e-a)/Math.max(1,s-a),0,1);return"top"===o?l+(y-l)*t:c+(b-c)*t}if(L>=e){const t=UC((e-a)/Math.max(1,L-a),0,1);return"top"===o?l+(y-l)*t:c+(b-c)*t}if(R>=e)return"top"===o?y:b;const r=UC((e-R)/Math.max(1,s-R),0,1);return"top"===o?y+(l-y)*r:b+(c-b)*r},N=I.map(e=>{const t=Math.min(T(e.x0,"top"),T(e.x1,"top")),o=Math.max(T(e.x0,"bottom"),T(e.x1,"bottom"));return{...e,y:(t+o)/2,height:Math.max(1,o-t)}}),$={thickness:k,friction:x,restitution:w},B=[];"lane"===t?B.push(KC(v+"-top",a,l,s,l,$),KC(v+"-bottom",a,c,s,c,$),KC(v+"-left",a,l,a,c,{...$,thickness:Math.max(6,k-2)}),KC(v+"-right",s,l,s,c,{...$,thickness:Math.max(6,k)})):"funnel"===t?B.push(KC(v+"-top",a,l,s,y,$),KC(v+"-bottom",a,c,s,b,$),KC(v+"-left",a,l,a,c,{...$,thickness:Math.max(6,k-2)}),KC(v+"-right",s,y,s,b,{...$,thickness:Math.max(6,k)})):B.push(KC(v+"-left-top",a,l,L,y,$),KC(v+"-left-bottom",a,c,L,b,$),KC(v+"-center-top",L,y,R,y,$),KC(v+"-center-bottom",L,b,R,b,$),KC(v+"-right-top",R,y,s,l,$),KC(v+"-right-bottom",R,b,s,c,$),KC(v+"-left",a,l,a,c,{...$,thickness:Math.max(6,k-2)}),KC(v+"-right",s,l,s,c,{...$,thickness:Math.max(6,k)}));const D=e.membraneDampingScale??.5,F=a,E=Math.max(1,("bowtie"===t?L:s)-F),z=(e.membranes??[]).map(e=>{const t=F+UC(e.offset,0,1)*E,o=e.width??18+18*e.cost,r=d-16,n=u+.25*(e.wobble??0);return{...e,x:t,y:n,width:o,height:r}}),j=!1===e.includeMembraneRegions?[]:z.map(e=>function(e){const t=e.dampingScale??.5,o=e.energyScale??1,r=UC(e.cost,0,2);return{...QC({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:r,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:r*t,energyDelta:-r*o}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:o,height:r,padX:n,padY:i,left:a,right:s,topY:l,bottomY:c,midY:u,centerLeft:L,centerRight:R,pinchHeight:f,pinchTop:y,pinchBottom:b,stages:N,membranes:z,colliders:B,regionEffects:j,boundaryY:T}}({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:y,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),v=new Map(b.stages.map((e,t)=>[e.id,t])),x=new Map(b.stages.map(e=>[e.id,e])),w=b.stages[0].id,k=b.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=x.get(e.id)??k;return function(e,t){const o={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...QC({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...o,kind:e.kind??"sink",force:JC(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return r={...o,kind:e.kind??"force-field",force:JC(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...QC({...r,kind:r.kind??"force-field",attributes:{primitive:"portal",targetStage:r.targetStage,..."object"==typeof r.attributes&&r.attributes?r.attributes:{}}}),force:r.force,impulseOnEnter:r.impulseOnEnter,damping:r.damping??.08}}var r;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...QC({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...o,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:JC(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...o.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,o=e.baseDamping??.08,r=e.dampingPerUnit??.12,n=e.energyPerUnit??0;return{...QC({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o+t*r,energyDelta:n?-t*n:void 0,force:e.force}}({...o,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:JC(e.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?ZC({...o,kind:e.kind??"force-field",force:JC(e.force,14),damping:e.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):function(e){return{...QC({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...o,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(e,{x:t.x,y:b.midY,width:t.width,height:b.bottomY-b.topY})});A.unshift(ZC({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(b.left+b.right)/2,y:b.midY,width:b.right-b.left,height:b.bottomY-b.topY-12,force:8,damping:.012,semanticItem:!1}));const C=new Map;for(const e of b.stages)C.set(e.id,0);const M=[];e.data.forEach((e,t)=>{const o=(s?IC(e,t,s)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(IC(e,t,l)??w)+"",i=v.has(r)?r:w;C.set(i,(C.get(i)??0)+1);const a=c?(IC(e,t,c)??"")+"":void 0,p=a&&u?(IC(e,t,u)??a)+"":a,m=d?_C(IC(e,t,d))??1:1,f=h?_C(IC(e,t,h)):null,g=LC(null!=f&&f>0?f:n,2,18);M.push({datum:e,id:o,stageId:i,groupId:a||void 0,groupLabel:p||void 0,work:m,radius:g,index:t})});const P=new Map,I=new Map;for(const e of M){if(!e.groupId)continue;const t=P.get(e.groupId)??[];t.push(e.id),P.set(e.groupId,t),e.groupLabel&&I.set(e.groupId,e.groupLabel)}const _=LC(e.groupAnchorAlong??.55,.15,.9),L=b.left+(b.right-b.left)*_,R=Array.from(P.keys()),T=R.map((e,o)=>{const r=P.get(e)??[],n=R.length>1?b.topY+28+o/Math.max(1,R.length-1)*(b.bottomY-b.topY-56):b.midY;return function(e){const t=e.x??e.anchor?.x??0,o=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:o,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:o},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:I.get(e)??e,bodyIds:r,anchor:{x:L,y:n},x:L,y:n,completion:"allAbsorbed"===p?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),N=function(e,t){const o=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],r=t.filter(e=>!o.has(e)),n=t.length-r.length,i=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{const t=a?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},l=t.reduce((e,t)=>e+s(t),0),c=t.reduce((e,t)=>e+(o.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):l:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?n>0:"threshold"===i?c>=(d??l):0===r.length),absorbed:n,total:t.length,absorbedValue:c,totalValue:l,threshold:d,missing:r}})}(T,M.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(T.map(e=>[e.id,e])),B=M.map((e,t)=>{const o=x.get(e.stageId)??k,r=o.x+(a()-.5)*Math.min(24,.2*o.width),n=b.boundaryY(r,"top")+e.radius+10,i=b.boundaryY(r,"bottom")-e.radius-10,s=i>n?n+a()*Math.max(1,i-n):b.midY,l=g?r:b.left+18+t%7*4,c=g?s:b.midY+(a()-.5)*(b.bottomY-b.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:m,damping:f}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:l,y:c,vx:g?0:40+40*a(),vy:g?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),D={kernel:{seed:i,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:b.colliders,fixedDt:1/60,maxSubsteps:8},F=b.stages.map(e=>({label:e.label??e.id,value:C.get(e.id)??0})),E=t.map(e=>{const t=x.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:C.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:D,initialSpawns:B,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:r.plot,volume:b,stages:E,groups:T,groupCompletion:N,regionEffects:A}}}import{useImperativeHandle as tM,useRef as oM}from"react";function rM(e,t){if(!t?.length)return[e];const o=t.filter(t=>{if(t.id===e||t.id.startsWith(e+"-"))return!0;const o=t.datum;return!(!o||"object"!=typeof o||null==o.id)&&o.id+""===e}).map(e=>e.id);return o.length?o:[e]}function nM(e,t,o){if("function"==typeof o)return o(e,t)+"";if("string"==typeof o){const t=e[o];if(null!=t)return t+""}return null!=e&&"object"==typeof e&&"id"in e&&null!=e.id?e.id+"":"physics-row-"+t}function iM(e,t){const o=e?.getData().find(e=>e.id===t),r=o?.datum;if(r&&"object"==typeof r)return r}function aM(e,t){const{frameRef:o,spawnDatum:r,seedRows:n,idAccessor:i,bodyIdsForSeed:a,seedSpawns:s}=t,l=oM(new Map),c=oM(new Map),u=oM(""),d=n?n.map((e,t)=>nM(e,t,i)).join("\0"):"";if(d!==u.current&&(u.current=d,n))for(let e=0;n.length>e;e+=1){const t=n[e],o=nM(t,e,i);l.current.set(o,t),c.current.set(o,a?.(t,o,e)??rM(o,s))}tM(e,()=>{const e=l.current,t=c.current;function n(e,t){const o=r(e,t);return{datumId:o.datumId||nM(e,t,i),spawns:o.spawns.map(e=>({...e,spawnAt:void 0}))}}function a(r){const n=[];for(const{datum:o,result:i}of r)e.set(i.datumId,o),t.set(i.datumId,i.spawns.map(e=>e.id)),n.push(...i.spawns);if(!n.length)return;const i=o.current;i?(i.pushMany(n),i.step(0)):"production"!==process.env.NODE_ENV&&console.warn("[semiotic/physics] push() called before the physics frame mounted (loading/empty early-return). Omit data for push mode and ensure the chart is mounted.")}function s(r){const n=e.get(r);if(n)return n;const i=t.get(r)??[r];for(const n of i){const i=iM(o.current,n);if(i)return e.set(r,i),t.has(r)||t.set(r,[n]),i}}return{push:t=>{a([{datum:t,result:n(t,e.size)}])},pushMany:t=>{const o=e.size;a(t.map((e,t)=>({datum:e,result:n(e,o+t)})))},remove:r=>{const n=Array.isArray(r)?r:[r],i=[],a=[];for(const o of n){const r=s(o);r&&i.push(r),e.delete(o),a.push(...t.get(o)??[o]),t.delete(o)}return a.length&&o.current?.remove(a),i},update:(r,i)=>{const l=Array.isArray(r)?r:[r],c=[];for(const r of l){const l=s(r);if(!l)continue;c.push(l);const u=t.get(r)??[r];o.current?.remove(u),e.delete(r),t.delete(r);const d=i(l);a([{datum:d,result:n(d,e.size)}])}return c},clear:()=>{e.clear(),t.clear(),u.current="",o.current?.clear()},getData:()=>{const t=o.current;if(!t)return Array.from(e.values());const r=t.getData().map(e=>e.datum).filter(e=>!!e&&"object"==typeof e);return r.length?r:Array.from(e.values())},getScales:()=>null,getCustomLayout:()=>o.current?.snapshot()??null,popBodies:(e,t)=>o.current?.popBodies(e,t)??[]}},[a,o,i,r])}import{useMemo as sM}from"react";import{Fragment as lM,jsx as cM,jsxs as uM}from"react/jsx-runtime";var dM=new Set(["sample","mechanical"]);function hM(e,t,o){const r=o?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&dM.has(e);return e.simulationMode?{chartMode:t(e.mode)?void 0:e.mode,simulationMode:e.simulationMode}:t(e.mode)?{chartMode:void 0,simulationMode:e.mode}:{chartMode:e.mode,simulationMode:"sample"}}({mode:e.mode,simulationMode:e.simulationMode}):{chartMode:"sample"===e.mode||"mechanical"===e.mode?void 0:e.mode,simulationMode:"sample"},n=Iu(r.chartMode,{width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:t[0],height:t[1]}),i=e.size?.[0],a=e.size?.[1],s=t[0],l=t[1],c=sM(()=>{return e=[s,l],(null!=i&&null!=a?[i,a]:void 0)??[n.width??e[0],n.height??e[1]];var e},[l,s,n.height,n.width,a,i]),u=n.compactMode?"sparkline"===r.chartMode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0};const d=e.showProjection??!n.compactMode,h=e.showChrome??!n.compactMode,p=gM(e.tooltip,void 0),m=void 0!==p.enableHover?p.enableHover:n.enableHover,f=n.compactMode?n.title:n.title??e.title,g=[e.className,r.chartMode&&"primary"!==r.chartMode?"semiotic-physics--"+r.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:r.chartMode,simulationMode:r.simulationMode,resolved:n,chartSize:c,margin:u,showProjection:d,showChrome:h,enableHover:m,title:f,description:n.description??e.description,summary:n.summary??e.summary,accessibleTable:n.accessibleTable??e.accessibleTable,className:g,compactMode:n.compactMode,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics}}function pM(e){const[t,o]=e.size;return Hu(e.loading,t,o,e.loadingContent)||Ou(e.data,t,o,e.emptyContent)}function mM(e,t,o){return cM(Eu,{componentName:e,width:t[0],height:t[1],children:o})}function fM(e,t){return e?t?o=>uM(lM,{children:["function"==typeof e?e(o):e,"function"==typeof t?t(o):t]}):e:t}function gM(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:xs(e)||t?.tooltipContent}}function yM(e,t,o,r){return{accessibleTable:r?.accessibleTable??e.accessibleTable??t?.accessibleTable,annotations:e.annotations??t?.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations??t?.autoPlaceAnnotations,background:e.background??t?.background,chartId:e.chartId??t?.chartId,chartMode:r?.chartMode??t?.chartMode,className:r?.className??e.className??t?.className,color:e.color??t?.color,description:r?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:r?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:r?.margin??t?.margin,onClick:null!=e.onClick?(t,o)=>{e.onClick?.(t,{x:o.x,y:o.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,opacity:e.opacity??t?.opacity,semanticItems:t?.semanticItems??o,stroke:e.stroke??t?.stroke,strokeWidth:e.strokeWidth??t?.strokeWidth,summary:r?.summary??e.summary??t?.summary,svgAnnotationRules:e.svgAnnotationRules??t?.svgAnnotationRules,title:r?.title??e.title??t?.title}}import{Fragment as bM,jsx as vM,jsxs as xM}from"react/jsx-runtime";var wM=bk(function(e,t){const{data:o,valueAccessor:r="value",bins:n=21,ballRadius:i=6,colorBy:a,branchProbability:s=.5,emptyContent:l,frameProps:c,loading:u,loadingContent:d,mechanicalCount:h,paused:p,pegRows:m,referenceLines:f,responsiveHeight:g,responsiveWidth:y,seed:b=1,valueExtent:v}=e,x=hM(e,[700,420],{hasSimulationMode:!0}),{chartSize:w,simulationMode:k,showProjection:S,className:A,title:C,chartMode:M,margin:P,enableHover:I,description:_,summary:L,accessibleTable:R}=x,T=wk(null),N=Math.max(1,Math.round(m??n-1)),$=xk(()=>"mechanical"===k?[0,N]:function(e){if(!e)return;const t=Number(e[0]),o=Number(e[1]);return Number.isFinite(t)&&Number.isFinite(o)?t>o?[o,t]:[t,o]:void 0}(v),[N,k,v]),B=xk(()=>"mechanical"===k?function(e){const t=Math.max(2,Math.round(e.bins)),o=Math.max(1,Math.round(e.pegRows??t-1)),r=Math.max(1,Math.round(e.count??Math.max(64,4*t))),n=LC(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=NC(e.seed??1),a=e.idPrefix??"mechanical";return Array.from({length:r},(e,t)=>{let r=0;for(let e=0;o>e;e+=1)i()<n&&(r+=1);const s=o/2;return{id:`${a}-${t}`,value:r,mechanical:!0,pegRows:o,branchProbability:n,pathRights:r,side:s>r?"left":r>s?"right":"center"}})}({bins:n,branchProbability:s,count:h,pegRows:N,seed:b}):o??[],[n,s,o,h,N,b,k]),D=xk(()=>BC({data:B,valueAccessor:r,bins:n,ballRadius:i,seed:b,size:w,valueExtent:$}),[i,n,B,w,$,b,r]);aM(t,{frameRef:T,spawnDatum:vk((e,t)=>{const o=BC({data:[e],valueAccessor:r,bins:n,ballRadius:i,seed:b+t+1,size:w,valueExtent:$}).initialSpawns[0]??{id:(e.id??"galton-push-"+t)+"",x:SC(w).plot.x,y:SC(w).plot.y,mass:1,shape:{type:"circle",radius:i},datum:e};return{datumId:(e.id??o.id)+"",spawns:[o]}},[i,n,w,$,b,r]),seedRows:B,seedSpawns:D.initialSpawns});const F="mechanical"===k&&null==a?"side":a,E=xk(()=>CC(F),[F]),z=xk(()=>PC(D.projectionRows,w,"bin"),[w,D.projectionRows]),j=pM({data:"mechanical"===k?B:o,emptyContent:l,loading:u,loadingContent:d,size:w});if(j)return j;const O=function(e,t,o,r,n){const i=Array.isArray(n)?n:n?[n]:[];if(!1!==o||0!==i.length)return({size:n})=>{const a=[Number(n[0])||700,Number(n[1])||420],s=SC(a),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==o,[p,m]=r?.valueExtent??[0,l],f=m===p?1:m-p,g=e.map((e,t)=>{const o=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${(s.plot.x+(t+.5)*c).toFixed(1)} ${o.toFixed(1)}`}).join(" ");return xM("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?xM(bM,{children:[Array.from({length:l+1},(e,t)=>{const o=s.plot.x+t*c;return vM("line",{"data-testid":"galton-board-bin-wall",x1:o,x2:o,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),vM("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),vM("path",{d:g,fill:"none",stroke:"var(--semiotic-accent, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?vM("text",{x:s.plot.x+(t+.5)*c,y:Math.max(s.plot.y+10,u-e.value/d*s.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,i.map((e,t)=>{const o=Number(e.value);if(!Number.isFinite(o))return null;const r=s.plot.x+Math.max(0,Math.min(1,(o-p)/f))*s.plot.width,n=e.color??"var(--semiotic-warning, #f28e2b)",i="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;return xM("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[vM("line",{x1:r,x2:r,y1:s.plot.y+8,y2:u-4,stroke:n,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:vM("text",{x:Math.min(s.plot.x+s.plot.width-4,r+6),y:i,fill:n,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${o}`)})]})}}(D.projectionRows,n,S,D.metadata,f),H=gM(e.tooltip,c),W=yM(e,c,z,{chartMode:M,className:A,title:C,description:_,summary:L,accessibleTable:R,enableHover:I,margin:P});return mM("GaltonBoardChart",w,vM(kC,{...c,...H,...W,ref:T,config:D.config,foregroundGraphics:fM(O,c?.foregroundGraphics),initialSpawns:D.initialSpawns,initialSpawnPacing:D.initialSpawnPacing,paused:p,responsiveHeight:g,responsiveWidth:y,size:w,bodyStyle:E}))});import{forwardRef as kM,useCallback as SM,useMemo as AM,useRef as CM}from"react";import{jsx as MM,jsxs as PM}from"react/jsx-runtime";var IM=kM(function(e,t){const{arrivalAccessor:o="arrivalTime",ballRadius:r=7,colorBy:n,data:i,emptyContent:a,frameProps:s,loading:l,loadingContent:c,paused:u,responsiveHeight:d,responsiveWidth:h,seed:p=1,timeAccessor:m="time",timeExtent:f,timeScale:g=1,watermark:y,windows:b={size:10}}=e,v=hM(e,[760,360]),{chartSize:x,showProjection:w,className:k,title:S,chartMode:A,margin:C,enableHover:M,description:P,summary:I,accessibleTable:_}=v,L=CM(null),R=AM(()=>i??[],[i]),T=AM(()=>function(e){const{data:t,timeAccessor:o,arrivalAccessor:r,windows:n,watermark:i,ballRadius:a,seed:s,size:l,timeExtent:c,timeScale:u=1}=e,d=SC(l),h=t.map((e,t)=>_C(IC(e,t,o))).filter(e=>null!=e),p=_C(c?.[0]),m=_C(c?.[1]),f=h.length?Math.min(...h):0,g=h.length?Math.max(...h):f+n.size,y=Math.min(p??f,f),b=Math.max(m??g,g),v=Math.floor(y/n.size)*n.size,x=Math.max(1,Math.ceil((b-v+n.size)/n.size)),w=h.length?Math.max(...h):0,k="function"==typeof i?i(w):_C(i?.value)??w-(i?.delay??n.size),S=Math.max(0,Math.min(x,Array.from({length:x},(e,t)=>t).reduce((e,t)=>v+(t+1)*n.size>k?e:e+1,0))),A=function(e,t){const o=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:o,height:e.plot.height},windowPlot:{x:e.plot.x+o,y:e.plot.y,width:Math.max(40,e.plot.width-o),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,a),C=v+x*n.size,M=DC().domain([v,C]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:x},()=>({value:0,secondary:0})),I=[];t.forEach((e,t)=>{const i=_C(IC(e,t,o));if(null==i)return;const s=_C(IC(e,t,r))??i,l=Math.max(0,Math.min(x-1,Math.floor((i-v)/n.size))),c=k>=v+(l+1)*n.size;P[l].value+=c?0:1,P[l].secondary+=c?1:0,I.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+a,Math.min(A.windowPlot.x+A.windowPlot.width-a,M(i))),y:d.plot.y+a+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:s,shape:{type:"circle",radius:a},datum:{...e,eventTime:i,arrivalTime:s,windowIndex:l,late:c}})});const _=d.plot.y+d.plot.height,L=function(e,t){const o=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!o)return[];const r=e.windowStart,n=e.windowStart+e.windowCount*e.windowSize,i=DC().domain([r,n]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=i(e.windowStart+o*e.windowSize),s=e.windowPlot.x,l=t+Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),c=e=>a===s?t:l+(e-s)/(a-s)*(t-l),u=[];for(let t=0;o>t;t+=1){const o=e.windowStart+t*e.windowSize,r=o+e.windowSize,n=i(o),a=i(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:n,y1:c(n),x2:a,y2:c(a)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:x,windowPlot:A.windowPlot,windowSize:n.size,windowStart:v},d.plot.y+.28*d.plot.height);return{config:MC(s,[...eA({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...FC({idPrefix:"eventdrop-window",count:x,xScale:e=>M(v+e*n.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?L[0]?.y1:L[e-1]?.y2??L[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*a},yBottom:_,wallThickness:6}),...L.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*a)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:P.map((e,t)=>({label:`${v+t*n.size}-${v+(t+1)*n.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:L,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:x,windowSize:n.size,windowStart:v}}}({data:R,timeAccessor:m,arrivalAccessor:o,windows:b,watermark:y,ballRadius:r,seed:p,size:x,timeExtent:f,timeScale:g}),[o,r,x,R,p,m,f,g,y,b]),N=T.metadata;aM(t,{frameRef:L,spawnDatum:SM((e,t)=>{const n=N?function(e,t,o,r){const n=_C(IC(e,t,r.timeAccessor));if(null==n)return null;const i=_C(IC(e,t,r.arrivalAccessor))??n,{windowPlot:a,windowStart:s,windowCount:l,windowSize:c,watermarkValue:u}=o,d=s+l*c,h=DC().domain([s,d]).range([a.x,a.x+a.width]),p=Math.max(0,Math.min(l-1,Math.floor((n-s)/c))),m=u>=s+(p+1)*c,{ballRadius:f}=r;return{id:(e.id??"event-push-"+t)+"",x:Math.max(a.x+f,Math.min(a.x+a.width-f,h(n))),y:a.y+f+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,shape:{type:"circle",radius:f},datum:{...e,eventTime:n,arrivalTime:i,windowIndex:p,late:m}}}(e,t,N,{timeAccessor:m,arrivalAccessor:o,ballRadius:r}):null,i=n??{id:(e.id??"event-push-"+t)+"",x:SC(x).plot.x,y:SC(x).plot.y,mass:1,shape:{type:"circle",radius:r},datum:e};return{datumId:(e.id??i.id)+"",spawns:[i]}},[o,r,x,N,m]),seedRows:R,seedSpawns:T.initialSpawns});const $=AM(()=>CC(n),[n]),B=AM(()=>function(e,t,o){if(!t)return PC(e,o,"window");const r=t.windowPlot.width/Math.max(1,e.length),n=Math.max(1,...e.map(e=>e.value+(e.secondary??0))),i=.62*t.windowPlot.height,a=t.windowPlot.y+t.windowPlot.height;return e.map((e,o)=>{const s=Math.max(8,(e.value+(e.secondary??0))/n*i),l=`window ${e.label}: ${e.value} on time${e.secondary?`, ${e.secondary} late`:""}`;return{id:"window-"+e.label,label:l,description:l,datum:e,x:t.windowPlot.x+(o+.5)*r,y:a-s/2,shape:"rect",width:Math.max(12,.58*r),height:s,group:"window"}})}(T.projectionRows,N,x),[x,T.projectionRows,N]),D=pM({data:i,emptyContent:a,loading:l,loadingContent:c,size:x});if(D)return D;const F=function(e,t,o){if(!1!==o&&t)return({size:o})=>{const r=[Number(o[0])||760,Number(o[1])||360],n=SC(r),i=Math.max(1,t.windowCount),a=t.plot??n.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},l=t.windowPlot??a,c=l.width/i,u=a.y+a.height,d=a.y+.48*a.height,h=t.lidSegments[0]?.y1??d,p=t.windowStart,m=t.windowStart+i*t.windowSize,f=l.x+Math.max(0,Math.min(1,m===p?0:(t.watermarkValue-p)/(m-p)))*l.width;return PM("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[MM("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?PM("g",{children:[MM("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-negative, #e15759)",fillOpacity:.07,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.55,strokeWidth:1}),MM("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-negative, #e15759)",fontSize:10,fontWeight:700,children:"gutter"})]}):null,Array.from({length:i},(o,n)=>{const i=e[n],a=l.x+n*c,s=t.closedWindowCount>n,h=i?.secondary??0;return PM("g",{children:[MM("rect",{x:a,y:d,width:c,height:u-d,fill:s?"var(--semiotic-negative, #e15759)":"var(--semiotic-accent, #4e79a7)",fillOpacity:s?.08:.06,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.68,strokeWidth:1}),s?t.lidSegments.filter(e=>e.windowIndex===n).map(e=>MM("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-negative, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,PM("text",{x:a+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:[i?.value??0,h?` / ${h} late`:""]}),MM("text",{x:a+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:i?.label??""})]},"window-"+n)}),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>MM("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-negative, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),MM("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),MM("line",{"data-testid":"event-drop-watermark",x1:f,x2:f,y1:a.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),PM("text",{x:Math.min(a.x+a.width-4,f+6),y:a.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]}),t.lateCount>0?PM("text",{x:s.x+s.width/2,y:a.y+32,textAnchor:"middle",fill:"var(--semiotic-negative, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]}):null]})}}(T.projectionRows,T.metadata,w),E=gM(e.tooltip,s),z=yM(e,s,B,{chartMode:A,className:k,title:S,description:P,summary:I,accessibleTable:_,enableHover:M,margin:C});return mM("EventDropChart",x,MM(kC,{...s,...E,...z,ref:L,config:T.config,foregroundGraphics:fM(F,s?.foregroundGraphics),initialSpawns:T.initialSpawns,initialSpawnPacing:T.initialSpawnPacing,paused:u,responsiveHeight:d,responsiveWidth:h,size:x,bodyStyle:$}))});import{forwardRef as _M,useCallback as LM,useMemo as RM,useRef as TM}from"react";import{scaleLinear as NM}from"d3-scale";import{jsx as $M}from"react/jsx-runtime";function BM(e,t){const o=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),n=[...t.colliders??[],...r],i=[...e.colliders??[],...o.colliders??[],...n];return{...e,...o,observation:{...e.observation,...o.observation},...i.length>0&&{colliders:i}}}function DM(e){const t=function(e,t,o){const r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:o??r?.onObservation}}}(e.config,e.chartId,e.onObservation),o=Kp(e.colorScheme,e.themeCategorical,fe),r=SC(e.size),n={data:e.data,scales:{x:NM().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:NM().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...o]},resolveColor:Qp(o,e.colorScheme),config:e.layoutConfig??{},world:new dA(t)},i=e.skipLayout?{}:e.layout(n)??{},a=function(e,t){if(!t?.length)return e;const o=new Map;for(const e of t){const{bodyId:t,...r}=e,n=o.get(t)??[];n.push(r),o.set(t,n)}return e.map(e=>{const t=o.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...i.initialSpawns??i.bodies??[]],i.constraints);return{config:BM(t,i),context:n,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:a,result:i}}var FM=_M(function(e,t){const{chartId:o,color:r,colorBy:n,colorScheme:i,config:a,controllers:s,data:l,emptyContent:c,frameProps:d={},layout:h,layoutConfig:p,loading:m,loadingContent:f,onObservation:g,opacity:y,paused:b,spawnDatum:v,stroke:x,strokeWidth:w,title:k,xExtent:S,yExtent:A}=e,C=hM(e,[700,380]),{chartSize:M,className:P,title:I,chartMode:_,margin:L,enableHover:R,description:T,summary:N,accessibleTable:$}=C,B=TM(null),D=TM(null),F=TM(""),E=pM({data:l,emptyContent:c,loading:m,loadingContent:f,size:M}),z=null!=E,j=RM(()=>u(l??[]),[l]),O=ee(e=>e.theme),H=RM(()=>Y(O)??{},[O]),W=O?.colors?.categorical??U.colors.categorical,q=RM(()=>[M[0],M[1],j.length,j.map((e,t)=>(e.id??t)+"").join("|"),S?.join(",")??"",A?.join(",")??""].join("::"),[M,j,S,A]),G=RM(()=>DM({chartId:o,colorScheme:i,config:a,data:j,layout:h,layoutConfig:p,onObservation:g,semantic:H,skipLayout:z,size:M,themeCategorical:W,xExtent:S,yExtent:A}),[o,M,i,a,h,p,g,j,H,z,W,S,A]);F.current===q&&null!=D.current||(F.current=q,D.current=G.initialSpawns);const V=D.current,X=RM(()=>{const e=[...G.result.controllers??[],...s??[],...d.controllers??[]];return e.length?e:void 0},[d.controllers,s,G.result.controllers]),K=RM(()=>{const e=[...G.result.regionEffects??[],...d.regionEffects??[]];return e.length?e:void 0},[d.regionEffects,G.result.regionEffects]),Q=LM(e=>{const t=e.datum,o=t&&n?function(e,t,o){return"function"==typeof o?o(e,0):e[o]}(t,0,n)+"":e.id;return{fill:r??G.context.resolveColor(o,t),stroke:x??"#111827",strokeWidth:w??1,opacity:y??.9}},[r,n,y,G.context,x,w]);aM(t,{frameRef:B,spawnDatum:LM((e,t)=>{const r=e;if(v)return function(e,t,o){return Array.isArray(o)?{datumId:(e.id??o[0]?.id??"physics-custom-"+t)+"",spawns:o}:"spawns"in o?o:{datumId:(e.id??o.id??"physics-custom-"+t)+"",spawns:[o]}}(e,t,v(r,t,G.context));const n=DM({chartId:o,colorScheme:i,config:a,data:[r],layout:h,layoutConfig:p,onObservation:g,semantic:H,size:M,themeCategorical:W,xExtent:S,yExtent:A}),s=n.initialSpawns.length?n.initialSpawns:[{id:(e.id??"physics-custom-"+t)+"",x:n.context.dimensions.plot.x+n.context.dimensions.plot.width/2,y:n.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:e}];return{datumId:(e.id??s[0].id)+"",spawns:s}},[o,M,i,a,v,h,p,g,G.context,H,W,S,A]),seedRows:j,seedSpawns:V});const Z=LM((e,t)=>{d.onBodyPointerDown?.(e,t)},[d]);if(E)return E;const J=gM(e.tooltip,d),te=yM(e,d,G.result.semanticItems,{chartMode:_,className:P,title:I??k,description:T,summary:N,accessibleTable:$,enableHover:R,margin:L});return mM("PhysicsCustomChart",M,$M(kC,{...d,...J,...te,ref:B,backgroundGraphics:fM(d.backgroundGraphics,G.result.backgroundOverlays),bodyForces:G.result.bodyForces??d.bodyForces,bodyStyle:G.result.bodyStyle??d.bodyStyle??Q,config:G.config,controllers:X,foregroundGraphics:fM(d.foregroundGraphics,G.result.overlays),initialSpawnPacing:G.initialSpawnPacing,initialSpawns:V,onBodyPointerDown:Z,paused:b,regionEffects:K,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:G.result.selectedBodyStyle??d.selectedBodyStyle,size:M}))});FM.displayName="PhysicsCustomChart";import{forwardRef as EM,useCallback as zM,useMemo as jM,useRef as OM}from"react";import{jsx as HM,jsxs as WM}from"react/jsx-runtime";var qM=EM(function(e,t){const{ballRadius:o=8,categoryAccessor:r="category",colorBy:n,data:i,emptyContent:a,frameProps:s,loading:l,loadingContent:c,mechanicalCategories:u,mechanicalCount:d,paused:h,responsiveHeight:p,responsiveWidth:m,seed:f=1,unitValue:g=1,valueAccessor:y}=e,b=hM(e,[700,380],{hasSimulationMode:!0}),{chartSize:v,simulationMode:x,showProjection:w,className:k,title:S,chartMode:A,margin:C,enableHover:M,description:P,summary:I,accessibleTable:_}=b,L=OM(null),R="mechanical"===x&&null==y?"value":y,T=jM(()=>"mechanical"===x?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),o=t.length?t:["Intake"],r=Math.max(o.length,Math.round(e.count??Math.max(48,12*o.length))),n=RC(e.unitValue,1),i=NC(e.seed??1),a=e.idPrefix??"mechanical-pile",s=o.map(()=>.65+.9*i()),l=s.reduce((e,t)=>e+t,0)||1,c=r-o.length,u=s.map(e=>e/l*c),d=u.map(e=>1+Math.floor(e));let h=r-d.reduce((e,t)=>e+t,0);const p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return o.map((e,t)=>({id:`${a}-${t}`,category:e,value:d[t]*n,mechanical:!0,unitCount:d[t],unitValue:n,share:d[t]/r}))}({categories:u,count:d,seed:f,unitValue:g}):i??[],[i,u,d,f,x,g]),N=jM(()=>zC({data:T,categoryAccessor:r,valueAccessor:R,unitValue:g,ballRadius:o,seed:f,size:v}),[o,r,v,T,R,f,g]);aM(t,{frameRef:L,spawnDatum:zM((e,t)=>{const n=zC({data:[e],categoryAccessor:r,valueAccessor:R,unitValue:g,ballRadius:o,seed:f+t+1,size:v}),i={id:(e.id??"pile-push-"+t)+"",x:SC(v).plot.x,y:SC(v).plot.y,mass:1,shape:{type:"circle",radius:o},datum:e},a=n.initialSpawns.length?n.initialSpawns:[i];return{datumId:(e.id??a[0].id)+"",spawns:a}},[o,r,v,R,f,g]),seedRows:T,seedSpawns:N.initialSpawns});const $="mechanical"===x&&null==n?"category":n,B=jM(()=>CC($),[$]),D=jM(()=>PC(N.projectionRows,v,"category"),[v,N.projectionRows]),F=pM({data:"mechanical"===x?T:i,emptyContent:a,loading:l,loadingContent:c,size:v});if(F)return F;const E=function(e,t,o){if(!1!==o&&0!==e.length)return({size:o})=>{const r=[Number(o[0])||700,Number(o[1])||380],n=SC(r),i=EC(n.plot,e.length,t),a=n.plot.y+n.plot.height;return WM("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[HM("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:a,y2:a,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{const o=Math.min(n.plot.height,i.pileHeight(e.value)),s=i.tubeWidth,l=i.centerX(t),c=a-o;return WM("g",{children:[HM("rect",{x:l-s/2,y:c,width:s,height:o,rx:3,fill:"var(--semiotic-accent, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-accent, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),HM("text",{x:l,y:Math.max(n.plot.y+12,c-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),HM("text",{x:l,y:Math.min(r[1]-8,a+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)})]})}}(N.projectionRows,o,w),z=gM(e.tooltip,s),j=yM(e,s,D,{chartMode:A,className:k,title:S,description:P,summary:I,accessibleTable:_,enableHover:M,margin:C});return mM("PhysicsPileChart",v,HM(kC,{...s,...z,...j,ref:L,config:N.config,foregroundGraphics:fM(E,s?.foregroundGraphics),initialSpawns:N.initialSpawns,initialSpawnPacing:N.initialSpawnPacing,paused:h,responsiveHeight:p,responsiveWidth:m,size:v,bodyStyle:B}))});import{forwardRef as GM,useCallback as YM,useMemo as VM,useRef as XM}from"react";import{jsx as UM,jsxs as KM}from"react/jsx-runtime";function QM(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}var ZM=GM(function(e,t){const{colorBy:o,collisionIterations:r,data:n,emptyContent:i,frameProps:a,groupAccessor:s,loading:l,loadingContent:c,paused:u,pointRadius:d=5,radiusAccessor:h,responsiveHeight:p,responsiveWidth:m,seed:f=1,settle:g,xAccessor:y="x",xExtent:b}=e,v=hM(e,[700,360]),{chartSize:x,showProjection:w,className:k,title:S,chartMode:A,margin:C,enableHover:M,description:P,summary:I,accessibleTable:_}=v,L=XM(null),R=VM(()=>n??[],[n]),T=VM(()=>OC({data:R,xAccessor:y,groupAccessor:s,radiusAccessor:h,pointRadius:d,seed:f,size:x,xExtent:b,collisionIterations:r,settle:g}),[R,x,r,s,d,h,f,g,y,b]);aM(t,{frameRef:L,spawnDatum:YM((e,t)=>{const o=OC({data:[e],xAccessor:y,groupAccessor:s,radiusAccessor:h,pointRadius:d,seed:f+t+1,size:x,xExtent:b,collisionIterations:r,settle:g}).initialSpawns[0]??{id:(e.id??"collision-swarm-push-"+t)+"",x:SC(x).plot.x,y:SC(x).plot.y,mass:1,shape:{type:"circle",radius:d},datum:e};return{datumId:(e.id??o.id)+"",spawns:[o]}},[x,r,s,d,h,f,g,y,b]),seedRows:R,seedSpawns:T.initialSpawns});const N=o??s,$=VM(()=>CC(N),[N]),B=pM({data:n,emptyContent:i,loading:l,loadingContent:c,size:x});if(B)return B;const D=function(e,t){if(!1!==t&&e)return({size:t})=>{const o=[Number(t[0])||700,Number(t[1])||360],r=SC(o),n=r.plot.y+r.plot.height,[i,a]=e.xExtent,s=i+(a-i)/2,l=[{label:QM(i),x:e.xRange[0]},{label:QM(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:QM(a),x:e.xRange[1]}];return KM("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.map(e=>KM("g",{children:[UM("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),UM("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),KM("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count]})]},e.label)),UM("line",{x1:e.xRange[0],x2:e.xRange[1],y1:n,y2:n,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>KM("g",{children:[UM("line",{x1:e.x,x2:e.x,y1:n,y2:n+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),UM("text",{x:e.x,y:Math.min(o[1]-8,n+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}(T.metadata,w),F=function(e){if(!e)return[];const t=Math.max(24,e.xRange[1]-e.xRange[0]),o=e.xRange[0]+t/2;return e.groups.map(e=>{const r=`${e.label} lane: ${e.count} points`;return{id:"collision-swarm-"+e.label,label:r,description:r,datum:e,x:o,y:e.y,shape:"rect",width:t,height:28,group:"lane"}})}(T.metadata),E=gM(e.tooltip,a),z=yM(e,a,F,{chartMode:A,className:k,title:S,description:P,summary:I,accessibleTable:_,enableHover:M,margin:C});return mM("CollisionSwarmChart",x,UM(kC,{...a,...E,...z,ref:L,config:T.config,foregroundGraphics:fM(D,a?.foregroundGraphics),initialSpawns:T.initialSpawns,paused:u,responsiveHeight:p,responsiveWidth:m,size:x,bodyStyle:$}))});import{forwardRef as JM,useCallback as eP,useMemo as tP,useRef as oP}from"react";import{jsx as rP,jsxs as nP}from"react/jsx-runtime";function iP(e){return e.toLocaleString(void 0,1e3>Math.abs(e)?{maximumFractionDigits:1}:{maximumFractionDigits:0})}function aP(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function sP(e){if(!e||"object"!=typeof e)return null;const t=e,o=Number(t.x),r=Number(t.y);return Number.isFinite(o)&&Number.isFinite(r)?{x:o,y:r}:null}function lP(e){if(!e||"object"!=typeof e)return[];const t=e.flowPath;return Array.isArray(t)?t.map(sP).filter(e=>null!=e):[]}function cP(e,t){if(2>t.length)return null;let o=0;const r=[];for(let e=1;t.length>e;e+=1){const n=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);r.push(n),o+=n}if(0>=o)return null;let n=null,i=0;for(let a=1;t.length>a;a+=1){const s=t[a-1],l=t[a],c=r[a-1];if(0>=c)continue;const u=l.x-s.x,d=l.y-s.y,h=Math.max(0,Math.min(1,((e.x-s.x)*u+(e.y-s.y)*d)/(c*c))),p={x:s.x+u*h,y:s.y+d*h},m={distance:Math.hypot(e.x-p.x,e.y-p.y),point:p,progress:(i+h*c)/o,tangent:{x:u/c,y:d/c},totalLength:o};n&&m.distance>=n.distance||(n=m),i+=c}return n}function uP(e,t,o){if(0===e.length)return{x:0,y:0};if(1===e.length||0>=o)return{...e[0]};let r=0;const n=Math.max(0,Math.min(1,t))*o;for(let t=1;e.length>t;t+=1){const o=e[t-1],i=e[t],a=Math.hypot(i.x-o.x,i.y-o.y);if(a>0){if(r+a>=n){const e=(n-r)/a;return{x:o.x+(i.x-o.x)*e,y:o.y+(i.y-o.y)*e}}r+=a}}return{...e[e.length-1]}}function dP(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function hP(e,t,o){const r=Math.hypot(e,t);if(o>=r||0>=r)return[e,t];const n=o/r;return[e*n,t*n]}function pP(e,t,o){const r=cP({...e,x:t[0].x,y:t[0].y},t),n=r?.tangent??{x:t[1].x-t[0].x,y:t[1].y-t[0].y},i=Math.hypot(n.x,n.y)||1,a=n.x/i,s=n.y/i,l=dP(e),c=function(e,t){let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return(o%1e3/1e3-.5)*t*1.4}(e.id,l);return{id:e.id,x:t[0].x+-s*c,y:t[0].y+a*c,vx:a*o,vy:s*o,mass:e.mass,shape:e.shape,datum:{...e.datum&&"object"==typeof e.datum?e.datum:{},routeProgress:0}}}var mP=JM(function(e,t){const{chartId:o,colorBy:r,coordinateMode:n="auto",data:i,edges:a,emptyContent:s,flowSpeed:l=90,frameProps:c,links:u,loading:d,loadingContent:h,maxParticles:p=180,nodeIdAccessor:m="id",nodeXAccessor:f="x",nodeYAccessor:g="y",nodes:y,onObservation:b,particleRadius:v=4,particleRate:x=.16,pathAccessor:w="path",pathConstraint:k="path",paused:S,reducedMotion:A=!1,responsiveHeight:C,responsiveWidth:M,seed:P=1,showNodeLabels:I=!0,showSensors:_=!1,showStaticFlow:L=!0,sourceAccessor:R="source",targetAccessor:T="target",throughputAccessor:N="value"}=e,$=hM(e,[760,420]),{chartSize:B,className:D,title:F,chartMode:E,margin:z,enableHover:j,description:O,summary:H,accessibleTable:W}=$,q=oP(null),G=tP(()=>y??[],[y]),Y=tP(()=>u??a??i??[],[i,a,u]),V=tP(()=>XC({nodes:G,links:Y,nodeIdAccessor:m,nodeXAccessor:f,nodeYAccessor:g,sourceAccessor:R,targetAccessor:T,throughputAccessor:N,pathAccessor:w,coordinateMode:n,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:l,pathConstraint:k,reducedMotion:A,seed:P,size:B}),[Y,G,B,n,l,p,m,f,g,v,x,w,k,A,P,R,T,N]);aM(t,{frameRef:q,spawnDatum:eP((e,t)=>{const o=XC({nodes:G,links:[e],nodeIdAccessor:m,nodeXAccessor:f,nodeYAccessor:g,sourceAccessor:R,targetAccessor:T,throughputAccessor:N,pathAccessor:w,coordinateMode:n,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:l,pathConstraint:k,reducedMotion:A,seed:P+t+1,size:B}),r={id:(e.id??"physical-flow-push-"+t)+"",x:SC(B).plot.x,y:SC(B).plot.y,mass:1,shape:{type:"circle",radius:v},datum:e},i=o.initialSpawns.length?o.initialSpawns:[r];return{datumId:(e.id??i[0].id)+"",spawns:i}},[G,B,n,l,p,m,f,g,v,x,w,k,A,P,R,T,N]),seedRows:Y,seedSpawns:V.initialSpawns});const X=r??"source",U=tP(()=>CC(X,"#2563eb"),[X]),K=tP(()=>function(e,t,o){return{...e,observation:{...e.observation,chartId:t??e.observation?.chartId??"physical-flow",chartType:"PhysicalFlowChart",onObservation:o??e.observation?.onObservation}}}(V.config,o,b),[o,V.config,b]),Q=oP(c?.onTick);Q.current=c?.onTick;const Z=eP((e,t)=>{A||"none"===k||function(e,t){const o=e.readBodies(),r=[],n=[];for(const i of o){const o=lP(i.datum);if(2>o.length)continue;const a=cP(i,o);if(!a)continue;const s=i.datum,l=Number(s?.flowSpeed),c=Number.isFinite(l)&&l>0?l:t;if(a.progress>=.985||a.distance>Math.max(90,14*dP(i))){r.push(i.id),n.push(pP(i,o,c));continue}const u=uP(o,Math.min(1,a.progress+Math.max(.035,Math.min(.12,c/a.totalLength*.16))),a.totalLength),d=a.tangent,h=(d.x*c-i.vx)*i.mass*.16+(u.x-i.x)*i.mass*.045+(a.point.x-i.x)*i.mass*.08,p=(d.y*c-i.vy)*i.mass*.16+(u.y-i.y)*i.mass*.045+(a.point.y-i.y)*i.mass*.08,[m,f]=hP(h,p,i.mass*c*.35);e.applyImpulse(i.id,m,f)}r.length&&e.remove(r),n.length&&e.pushMany(n)}(t,l),Q.current?.(e,t)},[l,k,A]),J=pM({data:null==u&&null==a&&null==i?void 0:Y,emptyContent:s,loading:d,loadingContent:h,size:B});if(J)return J;const ee=function(e,t){const{showNodeLabels:o,showSensors:r,showStaticFlow:n}=t;if(e&&(n||r))return({size:t})=>{const i=[Number(t[0])||760,Number(t[1])||420],a=Math.max(1,...e.links.map(e=>e.throughput)),s=new Set(e.nodes.map(e=>e.sensorId));return nP("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[n?e.links.map(e=>{const t=3+e.throughput/a*16,o=e.path[Math.floor(e.path.length/2)];return nP("g",{children:[rP("path",{d:aP(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),rP("path",{d:aP(e.path),fill:"none",stroke:"var(--semiotic-accent, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),o?rP("text",{x:o.x,y:o.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:iP(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>nP("g",{children:[r&&s.has(e.sensorId)?rP("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,n?rP("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,o?rP("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text-primary, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}(V.metadata,{showNodeLabels:I,showSensors:_,showStaticFlow:L}),te=(oe=V.metadata)?oe.links.map(e=>{const t=e.path[Math.floor(e.path.length/2)]??e.path[0],o=`${e.sourceLabel} to ${e.targetLabel}: ${iP(e.throughput)} throughput, ${e.packetCount} packets`;return{id:e.id,label:o,description:o,datum:e,x:t?.x??0,y:t?.y??0,shape:"path",pathData:aP(e.path),group:"flow"}}):[];var oe;const re=gM(e.tooltip,c),ne=yM(e,c,te,{chartMode:E,className:D,title:F,description:O,summary:H,accessibleTable:W,enableHover:j,margin:z});return mM("PhysicalFlowChart",B,rP(kC,{...c,...re,...ne,ref:q,config:K,continuous:!A&&"none"!==k,foregroundGraphics:fM(ee,c?.foregroundGraphics),initialSpawns:V.initialSpawns,onTick:Z,paused:S||A,responsiveHeight:C,responsiveWidth:M,simulationExecution:"none"===k?c?.simulationExecution:"sync",size:B,bodyStyle:U,workerBodyThreshold:c?.workerBodyThreshold??1/0}))});mP.displayName="PhysicalFlowChart";import{forwardRef as fP,useCallback as gP,useEffect as yP,useMemo as bP,useRef as vP,useState as xP}from"react";import{Fragment as wP,jsx as kP,jsxs as SP}from"react/jsx-runtime";var AP={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};function CP(e,t,o){return Math.max(t,Math.min(o,e))}function MP(e){return 6.2*e.length}function PP(e,t){const o=e.trim();if(t>=o.length)return o;if(1>=t)return o.slice(0,1);const r=o.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return r.length>1&&t>=r.length?r:t>3?o.slice(0,Math.max(1,t-2))+"..":o.slice(0,t).toUpperCase()}function IP(e,t,o="auto"){const r=Math.max(1,Math.floor(t/6.2)),n="compact"===o?PP(e,r):"full"===o?e:MP(e)>t?PP(e,r):e;return{text:n,textLength:MP(n)>t?Math.max(4,t):void 0}}function _P(e){return e.flatMap(e=>{if(!1===e.semanticItem)return[];const t=e.semanticItem??{},o={id:e.id,label:e.label??e.id,description:e.description,datum:e.datum,group:e.group??e.state??"body group",x:e.x??0,y:e.y??0,width:e.width,height:e.height};return[{...o,...t,id:t.id??o.id}]})}import{jsx as LP}from"react/jsx-runtime";var RP=fP(function(e,t){const{ballRadius:o=6,chromeOptions:r,colorBy:n,data:i,emptyContent:a,frameProps:s={},groupAnchorAlong:l,groupBy:c,groupCompletion:d,groupLabelAccessor:h,gravityX:p,gravityY:m,idAccessor:f,initialSpawnPacing:g,liveCapacity:y=!0,onCapacityChange:b,selection:v,bodyLimit:x,bodyMark:w,loading:k,loadingContent:S,paused:A,radiusAccessor:C,responsiveHeight:M,responsiveWidth:P,route:I="horizontal",seed:_=1,settle:L,springDamping:R,springStiffness:T,stageAccessor:N="stage",stages:$,workAccessor:B}=e,D=hM(e,[900,420]),{chartSize:F,showProjection:E,showChrome:z,className:j,title:O,chartMode:H,margin:W,enableHover:q,description:G,summary:Y,accessibleTable:V}=D,X=vP(null),U=bP(()=>u(i??[]),[i]),K=bP(()=>({data:U,stages:$,size:F,idAccessor:f,stageAccessor:N,groupBy:c,groupLabelAccessor:h,workAccessor:B,radiusAccessor:C,ballRadius:o,seed:_,route:I,groupCompletion:d,groupAnchorAlong:l,springStiffness:T,springDamping:R,gravityX:p,gravityY:m,settle:L}),[o,F,p,m,l,c,d,h,f,C,I,U,_,L,R,T,N,$,B]),Q=bP(()=>eM(K),[K]),Z=Q.metadata;aM(t,{frameRef:X,spawnDatum:gP((e,t)=>{const r=eM({...K,data:[e],seed:_+t+1,settle:!0}).initialSpawns[0]??{id:(e.id??"process-flow-push-"+t)+"",x:SC(F).plot.x,y:SC(F).plot.y,mass:1,shape:{type:"circle",radius:o},datum:e};return{datumId:(e.id??r.id)+"",spawns:[r]}},[o,K,F,_]),seedRows:U,seedSpawns:Q.initialSpawns});const J=bP(()=>CC(n),[n]),ee=bP(()=>{if(!y)return s.controllers;const e=[...$.filter(e=>e.capacity&&e.capacity.unitsPerSecond>0).map(e=>{const t=e.capacity.unitsPerSecond;return CA({id:"process-capacity-"+e.id,regionId:"process-stage-"+e.id,unitsPerSecond:t,unitAccessor:e.capacity.unitAccessor??(B?"string"==typeof B?B:e=>{const t=e.datum;if(!t)return 1;try{return Number(B(t,0))||1}catch{return 1}}:"work"),releaseImpulse:{x:70+Math.min(40,2*t),y:0},queueLayout:"lane",continuous:!0})}),...s.controllers??[]];return e.length?e:void 0},[s.controllers,y,$,B]),[te,oe]=xP({}),re=vP(ee);re.current=ee;const ne=vP(s.onTick);ne.current=s.onTick;const ie=!1!==z||null!=b;yP(()=>{if(!b)return;const e=Object.values(te);e.length&&b(e)},[te,b]);const ae=gP((e,t)=>{if(ne.current?.(e,t),!ie)return;const o=re.current;if(!o?.length)return;const r={};for(const e of o){const t=e.getSnapshot?.();t&&"string"==typeof t.regionId&&(r[t.regionId]=t)}oe(e=>function(e,t){const o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(const r of o){const o=e[r],n=t[r];if(!n)return!1;if(o.queueDepth!==n.queueDepth||o.blockedDepth!==n.blockedDepth||o.processedCount!==n.processedCount||o.unitsPerSecond!==n.unitsPerSecond||o.regionId!==n.regionId||o.metricRevision!==n.metricRevision)return!1}return!0}(e,r)?e:r)},[ie]),se=bP(()=>{const e=J,t=s.bodyStyle;return w||t?(o,r)=>{const n="function"==typeof t?t(o,r):t;return{..."function"==typeof e?e(o):e,...n,mark:n?.mark??o.datum?.__physicsMark??o.datum?.mark??w}}:e},[w,J,s.bodyStyle]),le=pM({data:i,emptyContent:a,loading:k,loadingContent:S,size:F});if(le)return le;if(!$?.length)return mM("ProcessFlowChart",F,LP("div",{role:"status",style:{width:F[0],height:F[1],display:"grid",placeItems:"center",color:"var(--semiotic-text-secondary, #64748b)"},children:"ProcessFlowChart requires a non-empty stages array."}));const ce=function(e,t,o={},r){if(!1===t||!e)return;const{volume:n,stages:i,groups:a,groupCompletion:s}=e,l=new Map(n.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{const t=Number(e[0])||n.width,s=Number(e[1])||n.height,u=i.map(e=>{const t=l.get(e.id),r=o["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=a.map(e=>{const t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return function(e,t={}){const{showFlowSpine:o=!0,showStageCounts:r=!0,showCapacityBadges:n=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:l="process-flow-chrome"}=t,{width:c,height:u,left:d,right:h,topY:p,bottomY:m,midY:f,stages:g,groups:y=[]}=e,b=m-p;return SP("svg",{"aria-hidden":"true","data-testid":l,"data-outline-stages":s?"true":void 0,width:c,height:u,viewBox:`0 0 ${c} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[kP("defs",{children:SP("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[kP("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),kP("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),kP("rect",{x:0,y:0,width:c,height:u,fill:"url(#semiotic-process-floor)"}),kP("rect",{x:d-6,y:p-8,width:h-d+12,height:b+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),o?kP("line",{x1:d+8,x2:h-8,y1:f,y2:f,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const o=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=AP[o],l=Math.max(12,e.width-8),c=CP(l-8,22,88),d=IP(e.label,Math.max(8,c-10),a),h="none"!==a&&l-8>=22,y=function(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),v=IP(y,Math.max(16,l-10),"auto"),x=n&&!1!==e.showBadge&&l>=32,w=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",k=IP(w,Math.max(16,l-8),"auto"),S=Math.max(30,p-15),A=S-13;return SP("g",{"data-stage":e.id,"data-role":o,children:[kP("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:l,height:b-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===o?1:1.6}),g.length-1>t?kP("polygon",{points:`${e.x1-2},${f-7} ${e.x1+8},${f} ${e.x1-2},${f+7}`,fill:i.accent,opacity:.85}):null,h?SP(wP,{children:[kP("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-c/2,y:A,width:c,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),SP("text",{x:e.x,y:S,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[kP("title",{children:e.label}),d.text]})]}):null,x?SP("text",{x:e.x,y:p+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[kP("title",{children:y}),v.text]}):null,r&&null!=e.count?SP("text",{x:e.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[kP("title",{children:w}),k.text]}):null]},e.id)}),i?y.map((e,t)=>{const o=e.total??0,r=e.absorbed??0,n=e.complete??(o>0&&r>=o),i=!n&&o>0&&r/o>=.75,a=n?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=n?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",l=o>0?`${r}/${o}${n?" shipped":i?" almost":""}`:"feature "+(t+1),c=CP(Math.max(54,MP(e.label)+18,MP(l)+16),54,104),u=IP(e.label,c-12,"auto"),d=IP(l,c-12,"auto");return SP("g",{"data-group":e.id,children:[kP("rect",{x:e.x-c/2,y:e.y-22,width:c,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),SP("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[kP("title",{children:e.label}),u.text]}),SP("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[kP("title",{children:l}),d.text]})]},e.id)}):null]})}({width:t,height:s,left:n.left,right:n.right,topY:n.topY,bottomY:n.bottomY,midY:n.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}(Z,z,te,r),ue=function(e,t,o){if(!1===o||!t||0===e.length)return;const r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:o})=>{const n=[Number(o[0])||t.volume.width,Number(o[1])||t.volume.height],i=SC(n),a=Math.max(1,...e.map(e=>e.value)),s=Math.min(48,.18*i.plot.height),l=i.plot.y+6;return LP("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,o)=>{const n=e[o];if(!n)return null;const i=r.get(t.id);if(!i)return null;const c=Math.max(2,n.value/a*s),u=Math.max(8,.35*i.width);return LP("rect",{x:i.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}(Q.projectionRows,Z,E),de=[...PC(Q.projectionRows,F,"stage"),..._P(Z?.groups??[])],he=gM(e.tooltip,s),pe=yM(e,s,de,{chartMode:H,className:j,title:O,description:G,summary:Y,accessibleTable:V,enableHover:q,margin:W}),me=[...Z?.regionEffects??[],...s.regionEffects??[]];return mM("ProcessFlowChart",F,LP(kC,{...s,...he,...pe,ref:X,controllers:ee,regionEffects:me,selection:v??s.selection,backgroundGraphics:fM(ce,s.backgroundGraphics),foregroundGraphics:fM(ue,s.foregroundGraphics),initialSpawns:Q.initialSpawns,initialSpawnPacing:g??Q.initialSpawnPacing,onTick:ae,paused:A,responsiveHeight:M,responsiveWidth:P,size:F,bodyStyle:se,config:{...Q.config,...null!=x?{bodyLimit:x,eviction:"oldest"}:{},...s.config}}))});RP.displayName="ProcessFlowChart";import{forwardRef as TP,useCallback as NP,useEffect as $P,useImperativeHandle as BP,useMemo as DP,useRef as FP,useState as EP}from"react";var zP="gauntlet-core",jP="gauntlet-positive",OP="gauntlet-negative";function HP(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function WP(e,t,o,r){return o?"function"==typeof o?o(e,t):e[o]??r:r}function qP(e){return e?.label??e?.id??"property"}function GP(e){return`gauntlet:${e}:core`}function YP(e,t){return`gauntlet:${e}:positive:${t}`}function VP(e,t,o){return`gauntlet:${e}:negative:${t}:${o}`}function XP(e,t,o,r){const n=Math.max(2,o+2),i=80+n,a=r.floorY-n;return{x:Math.max(32+n,Math.min(r.width-30-4-n,e)),y:Math.max(i,Math.min(a,t))}}function UP(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function KP(e,t,o,r){const n=UP(o),i=r?.(e,t,o)??{};return{...n,...i,startY:i.startY??i.routeY??n.startY,socketY:i.socketY??i.routeY??n.socketY,graveyardY:i.graveyardY??n.graveyardY}}function QP(e,t){const o=[...e].sort((e,t)=>e.localeCompare(t)),r=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?r/(o.length-1):.5)*Math.PI*.64,index:r,radius:48+r%2*6}}function ZP(e,t,o){const r=e.activePositiveIds.reduce((e,o)=>e+(t.get(o)?.value??1),0),n=e.missingPositiveIds.length+e.poppedPositiveIds.length,i=e.negativeIds.reduce((e,t)=>e+(o.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*i-1.2*e.delay-5*n))}function JP(e,t,o,r,n){const i=WP(e,t,o.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",a=r.map(e=>e.id),s=[...WP(e,t,o.positiveAccessor,a)],l=[...WP(e,t,o.negativeAccessor,[])].filter(e=>n.has(e));return{id:i,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...WP(e,t,o.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(WP(e,t,o.startTimeAccessor,0))||0),stage:"project filed",viability:WP(e,t,o.initialViability,100)}}function eI(e,t,o,r,n,i,a){const s=r.startX,l=r.startY+(r.startY===o.routeY?38*t:0),c=a?.(e,t,o,r)??{},u={__gauntlet:!0,kind:zP,projectId:e.id,sourceDatum:e.datum},d=[{...c,id:GP(e.id),x:c.x??s,y:c.y??l,vx:c.vx??42,vy:c.vy??0,mass:c.mass??7,bodyCollisions:c.bodyCollisions??!0,shape:c.shape??{type:"circle",radius:28},spawnAt:c.spawnAt??e.startedAt,datum:u}],h=XP(s,l,c.shape&&"radius"in c.shape&&Number(c.shape.radius)||28,o);d[0].x=h.x,d[0].y=h.y;for(const t of e.activePositiveIds){const r=n.get(t);if(!r)continue;const i=QP(e.activePositiveIds,t),a=r.radius??10,s=XP(h.x+Math.cos(i.angle)*i.radius,h.y+Math.sin(i.angle)*i.radius,a,o);d.push({id:YP(e.id,t),x:s.x,y:s.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:c.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:jP,projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:GP(e.id)},stiffness:.56,damping:.9,restLength:52+i.index%2*4,...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{const n=i.get(t);n&&d.push(tI(e,n,r,h.x,h.y,o,c.spawnAt??e.startedAt))}),d}function tI(e,t,o,r,n,i,a){const s=t.radius??7.2,l=XP(r-12+o%4*12,n+54+12*Math.floor(o/4),s,i);return{id:VP(e.id,t.id,o),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:a,datum:{__gauntlet:!0,kind:OP,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:GP(e.id)},stiffness:.62,damping:.92,restLength:52+o%4*3,...t.spring??{}}]}}function oI(e){return e?Array.isArray(e)?[...e]:Object.entries(e).flatMap(([e,t])=>Array.from({length:Math.max(0,Math.round(Number(t)||0))},()=>e)):[]}function rI(e,t){return t?Array.isArray(t)?[...t]:t.ids?[...t.ids]:t.candidates?t.candidates.filter(t=>e.includes(t)).slice(0,t.count??1):[]:[]}function nI(e,t){return rI(e.activePositiveIds,t.popPositive)}function iI(e,t){const o=rI(e.negativeIds,t.popNegative);if(!o.length)return[];const r=new Map;for(const e of o)r.set(e,(r.get(e)??0)+1);const n=[];return e.negativeIds.forEach((e,t)=>{const o=r.get(e)??0;o>0&&(n.push({propertyId:e,index:t}),r.set(e,o-1))}),n}function aI(e,t,o){if(t.when&&!t.when(o))return e;let r={...e};const n=nI(r,t);n.length&&(r={...r,activePositiveIds:r.activePositiveIds.filter(e=>!n.includes(e)),poppedPositiveIds:Array.from(new Set([...r.poppedPositiveIds,...n]))});const i=iI(r,t);if(i.length){const e=new Set(i.map(e=>e.index));r={...r,negativeIds:r.negativeIds.filter((t,o)=>!e.has(o)),poppedNegativeIds:[...r.poppedNegativeIds,...i.map(e=>e.propertyId)]}}const a=oI(t.addPositive);a.length&&(r={...r,activePositiveIds:Array.from(new Set([...r.activePositiveIds,...a])),missingPositiveIds:r.missingPositiveIds.filter(e=>!a.includes(e))});const s=oI(t.addNegative);if(s.length&&(r={...r,negativeIds:[...r.negativeIds,...s]}),t.delayDelta&&(r={...r,delay:r.delay+t.delayDelta}),t.metricsDelta){const e={...r.metrics};for(const[o,r]of Object.entries(t.metricsDelta))e[o]=Number(e[o]??0)+r;r={...r,metrics:e}}return t.viabilityDelta&&(r={...r,viability:r.viability+t.viabilityDelta}),t.stage&&(r={...r,stage:t.stage}),t.outcome&&(r={...r,outcome:t.outcome}),r}function sI(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function lI(e,t){return e.eventsApplied.includes(t.id)?e:{...e,eventsApplied:[...e.eventsApplied,t.id],eventHistory:[...e.eventHistory??[],t],lastEvent:t,stage:t.label??e.stage}}function cI(e,t){const o=e.datum;return!(!o?.__gauntlet||o.projectId!==t||o.kind!==OP)}function uI(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),o=Number(t);return Number.isFinite(o)?o:-1}import{jsx as dI,jsxs as hI}from"react/jsx-runtime";function pI(e){const t=e.data;return t?.__gauntlet?hI("div",{className:"semiotic-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(15, 23, 42, 0.94))",color:"var(--semiotic-tooltip-text, #f8fafc)",padding:"8px 12px",borderRadius:6,boxShadow:"var(--semiotic-tooltip-shadow, 0 8px 24px rgba(0,0,0,0.35))",maxWidth:280},children:[dI("strong",{children:t.kind===zP?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:qP(t.property)}),dI("div",{children:t.kind===jP?"Positive property":t.kind===OP?"Negative property":"Project core"})]}):null}function mI(e,t,o){const r=t.datum;if(!r?.__gauntlet)return;const n="circle"===t.shape.type?t.shape.radius:8;if(e.save(),e.translate(t.x,t.y),r.kind===zP)e.fillStyle=fI(e,o.fill,"#0f766e"),e.strokeStyle=fI(e,o.stroke,"#f8fafc"),e.lineWidth=2.4,e.beginPath(),e.arc(0,0,n,0,2*Math.PI),e.fill(),e.stroke();else{const t=r.property;e.fillStyle=fI(e,o.fill??t?.color,"#38bdf8"),e.strokeStyle=fI(e,o.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),r.kind===OP?e.rect(-n,-n,2*n,2*n):e.arc(0,0,n,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=fI(e,"var(--semiotic-background, #07111f)","#07111f"),e.font=`900 ${r.kind===OP?9:8}px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,e.textAlign="center",e.textBaseline="middle",e.fillText(t?.short??t?.id?.slice(0,1).toUpperCase()??"?",0,.5)}e.restore()}function fI(e,t,o){if("string"!=typeof t)return o;if("function"!=typeof getComputedStyle||!e.canvas)return t||o;const r=t.startsWith("var(")?t.match(/var\((--[^,\s)]+)/)?.[1]:t.startsWith("--")?t:null;return r?getComputedStyle(e.canvas).getPropertyValue(r).trim()||o:t||o}function gI({layout:e,states:t}){return hI("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[dI("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-accent, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),dI("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-negative, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),dI("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),e.gates.map(t=>hI("g",{children:[dI("rect",{x:t.x-t.width/2,y:Math.max(80,e.routeY-180),width:t.width,height:Math.min(360,e.height-170),rx:12,fill:t.color??"var(--semiotic-accent, #38bdf8)",fillOpacity:.1,stroke:t.color??"var(--semiotic-accent, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),dI("text",{x:t.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:t.label??t.id})]},t.id)),hI("g",{children:[dI("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-positive, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-positive, #22c55e)",strokeWidth:1.5}),dI("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),hI("g",{children:[dI("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-negative, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-negative, #ef4444)",strokeOpacity:.7}),dI("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),dI("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function yI(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===zP?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${qP(t.property)} ${t.kind===jP?"positive":"negative"} property`,group:t.kind===jP?"positive property":"negative property",description:`${qP(t.property)} attached to ${t.projectId}.`})}function bI({states:e,layout:t}){const o=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!o.length)return null;const r=Math.max(1,...o.map(e=>e.value)),n=Math.max(40,(t.width-80)/o.length);return hI("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[dI("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),o.map((e,t)=>{const o=40+t*n,i=Math.max(2,e.value/r*28),a=/kill|crash|block|grave/i.test(e.outcome);return hI("g",{children:[dI("rect",{x:o+.18*n,y:28-i+22,width:Math.max(10,.45*n),height:i,rx:2,fill:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),dI("text",{x:o+.4*n,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}import{jsx as vI}from"react/jsx-runtime";import{createElement as xI}from"react";var wI=[],kI=TP(function(e,t){const{bodyGroups:o,coreBody:r,coreForceMode:n="route",crashDetection:i=!0,crashOffset:a=30,data:s,emptyContent:l,events:c,frameProps:d={},gates:h,initialSpawnPacing:p,loading:m,loadingContent:f,negativeProperties:g,onCapacityChange:y,onClick:b,onStateChange:v,outcome:x,paused:w,positiveProperties:k=wI,projectPlacement:S,responsiveHeight:A,responsiveWidth:C,showTethers:M=!0,terminalBehavior:P="outcome",viability:I}=e,_=FP(null),L=DP(()=>({idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor}),[e.idAccessor,e.initialViability,e.metricsAccessor,e.negativeAccessor,e.positiveAccessor,e.startTimeAccessor]),R=hM(e,[900,520]),{chartSize:T,showProjection:N,showChrome:$,className:B,title:D,chartMode:F,margin:E,enableHover:z,description:j,summary:O,accessibleTable:H}=R,W=pM({data:s,emptyContent:l,loading:m,loadingContent:f,size:T}),q=DP(()=>u(s??[]),[s]),G=DP(()=>q.map((e,t)=>WP(e,t,L.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[q,L.idAccessor]),Y=DP(()=>new Map(k.map(e=>[e.id,e])),[k]),V=DP(()=>new Map(g.map(e=>[e.id,e])),[g]),X=DP(()=>function(e,t,o){const[r,n]=e,i=Math.round(.48*n),a=n-36,s=(t??[]).filter(e=>!1!==e.enabled),l=Math.max(1,s.length),c=.22*r,u=l>1?(.78*r-c)/(l-1):0,d=Math.max(Math.round(.14*r),110);return{crashY:a-o,floorY:a,gates:s.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(c+t*u),width:e.width??Math.max(54,Math.round(.07*r))})),graveyardX:Math.round(.84*r),graveyardY:a-4,height:n,routeY:i,socketX:Math.round(.92*r),startX:d,width:r}}(T,h,a),[T,a,h]),U=DP(()=>new Map(X.gates.map(e=>[e.id,e])),[X.gates]),K=DP(()=>X.gates.map(e=>({kind:"force-field",damping:.035,force:{x:12,y:0},semanticItem:!1,...e.regionEffect,id:"gauntlet-gate-"+e.id,label:e.label??e.id,description:e.description,bodyFilter:e.capacity?{property:"datum.kind",equals:zP}:e.regionEffect?.bodyFilter,shape:{type:"aabb",x:e.x,y:X.routeY,width:e.capacity?e.capacity.sensorWidth??Math.max(96,6*e.width):Math.max(e.width,54),height:Math.min(360,X.height-170)}})),[X.gates,X.height,X.routeY]),[Q,Z]=EP(()=>q.map((e,t)=>{const o=JP(e,t,L,k,V);return{...o,viability:I?.(o,{negativeProperties:V,positiveProperties:Y})??ZP(o,Y,V)}})),J=FP(Q),ee=FP(0),te=FP(new Map),oe=FP([]),re=FP(y);re.current=y;const ne=DP(()=>function(e){const{dataKey:t,gates:o,statesRef:r,processedGateVisitsRef:n}=e;return o.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[CA({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:zP},maxQueue:e.capacity.maxQueue,queueLayout:e.capacity.queueLayout,queueSlotSpacing:e.capacity.queueSlotSpacing,queueStiffness:e.capacity.queueStiffness??24,releaseImpulse:{x:36,y:0},unitAccessor:t=>{const o=t.datum,n=o?.sourceDatum,i=e.capacity?.unitAccessor,a=r.current.find(e=>e.id===o?.projectId);let s;"function"==typeof i?s=a?i(a):void 0:i&&(s=n?.[i]);const l=Number(s??n?.reviewWork??n?.work??a?.metrics.reviewWork??n?.points);return Number.isFinite(l)&&l>0?l:1},onProcessed:t=>{const o=t.datum;if(!o?.projectId)return;const r=`${o.projectId}:${e.id}`;n.current.set(r,(n.current.get(r)??0)+1)}})]:[])}({dataKey:G,gates:X.gates,statesRef:J,processedGateVisitsRef:te}),[G,X.gates]),ie=DP(()=>[...ne,...d.controllers??[]],[ne,d.controllers]),ae=FP(q);ae.current=q;const se=FP(v);se.current=v;const le=FP({negativeById:V,positiveById:Y,positiveProperties:k,stateAccessors:L,viability:I});le.current={negativeById:V,positiveById:Y,positiveProperties:k,stateAccessors:L,viability:I};const ce=NP((e,t,o=0)=>{const r=le.current,n=JP(e,t,r.stateAccessors,r.positiveProperties,r.negativeById);return r.stateAccessors.startTimeAccessor||(n.startedAt=Math.max(0,o)),{...n,viability:r.viability?.(n,{negativeProperties:r.negativeById,positiveProperties:r.positiveById})??ZP(n,r.positiveById,r.negativeById)}},[]);$P(()=>{te.current.clear(),oe.current=[];const e=ae.current.map((e,t)=>ce(e,t));J.current=e,Z(e)},[ce,G]),$P(()=>{J.current=Q,se.current?.(Q)},[Q]);const ue=NP(e=>[...("function"==typeof c?c(e,X):c)??[]].sort((e,t)=>e.time-t.time),[c,X]),de=NP((e,t,o)=>{if(!t.gateId||!U.get(t.gateId)?.capacity)return!0;const r=Number(t.gateVisit),n=Number.isFinite(r)&&r>0?Math.floor(r):o.filter(e=>e.gateId===t.gateId).findIndex(e=>e.id===t.id)+1;return n>0&&(te.current.get(`${e.id}:${t.gateId}`)??0)>=n},[U]),he=NP(()=>{if(!ne.length)return;const e=ne.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,o;(t=oe.current).length===(o=e).length&&t.every((e,t)=>{const r=o[t];return!!r&&e.regionId===r.regionId&&e.queueDepth===r.queueDepth&&e.blockedDepth===r.blockedDepth&&e.processedCount===r.processedCount&&e.metricRevision===r.metricRevision})||(oe.current=e,re.current?.(e))},[ne]),pe=DP(()=>Q.flatMap((e,t)=>{const o=KP(e,t,X,S);return eI(e,t,X,o,Y,V,r)}),[r,X,V,Y,S,Q]),me=NP((e,t)=>{let o=!1;const r=J.current.map(r=>{if(r.id!==e)return r;const n=t(r);return o=o||n!==r,n});o&&(J.current=r,Z(r))},[]);BP(t,()=>function(e){const{statesRef:t,setStates:o,elapsedRef:r,frameRef:n,layout:i,projectPlacement:a,positiveById:s,negativeById:l,coreBody:c,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,r.current),h=KP(d,t.current.length,i,a),p=eI(d,t.current.length,i,h,s,l,c),m=[...t.current,d];t.current=m,o(m),n.current?.pushMany(p),n.current?.step(0)},pushMany:e=>{const d=[...t.current],h=[],p=r.current;e.forEach(e=>{const t=u(e,d.length,p),o=KP(t,d.length,i,a);h.push(...eI(t,d.length,i,o,s,l,c)),d.push(t)}),t.current=d,o(d),h.length&&n.current?.pushMany(h),n.current?.step(0)},remove:e=>{const r=Array.isArray(e)?e:[e],i=[],a=[];for(const e of r){const o=t.current.find(t=>t.id===e);o&&(i.push(o.datum),a.push(GP(o.id),...o.activePositiveIds.map(e=>YP(o.id,e))),o.negativeIds.forEach((e,t)=>{a.push(VP(o.id,e,t))}))}return t.current=t.current.filter(e=>!r.includes(e.id)),o(t.current),n.current?.remove(a),i},update:(e,d)=>{const h=Array.isArray(e)?e:[e],p=[];for(const e of h){const o=t.current.find(t=>t.id===e);if(!o)continue;const h=t.current.findIndex(t=>t.id===e);p.push(o.datum);const m=d(o.datum),f=u(m,0>h?t.current.length:h,o.startedAt??r.current),g=KP(f,0>h?t.current.length:h,i,a);n.current?.remove([GP(o.id),...o.activePositiveIds.map(e=>YP(o.id,e)),...o.negativeIds.map((e,t)=>VP(o.id,e,t))]),n.current?.pushMany(eI(f,0>h?t.current.length:h,i,g,s,l,c)),t.current=t.current.map(t=>t.id===e?f:t)}return o(t.current),p},clear:()=>{t.current=[],o([]),n.current?.clear()},getData:()=>t.current.map(e=>e.datum),getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(e,t)=>n.current?.popBodies(e,t)??[]}}({statesRef:J,setStates:Z,elapsedRef:ee,frameRef:_,layout:X,projectPlacement:S,positiveById:Y,negativeById:V,coreBody:r,createState:ce}),[r,ce,X,V,Y,S]);const fe=NP((e,t,o)=>{!function(e){const{project:t,effect:o,controls:r,layout:n,positiveById:i,negativeById:a,coreBody:s,popBodies:l}=e,c=r.readBodies().find(e=>e.id===GP(t.id)),u=r.readBodies(),d=c?.x??n.startX,h=c?.y??n.routeY,p=function(e,t){let o=-1;for(const r of t)cI(r,e.id)&&(o=Math.max(o,uI(r)));return Math.max(e.negativeIds.length,o+1)}(t,u),m=oI(o.addNegative).flatMap((e,o)=>{const r=a.get(e);return r?[tI(t,r,p+o,d,h,n)]:[]}),f=oI(o.addPositive).flatMap(e=>{if(!i.get(e)||t.activePositiveIds.includes(e))return[];const o={...UP(n),routeY:h,socketY:h,startX:d,startY:h};return eI({...t,activePositiveIds:[e],negativeIds:[]},0,n,o,i,a,s).filter(e=>e.id.includes(":positive:"))});(m.length||f.length)&&r.pushMany([...m,...f]);const g=nI(t,o);for(const e of g){const o=i.get(e);l([YP(t.id,e)],{color:o?.popColor??o?.color,durationMs:900,radius:(o?.radius??10)+3})}const y=iI(t,o),b=function(e,t,o){const r=t.filter(t=>cI(t,e.id)).sort((e,t)=>uI(e)-uI(t)||e.id.localeCompare(t.id)),n=new Set;return o.map(t=>{const o=r.find(e=>!n.has(e.id)&&e.datum.property?.id===t.propertyId);return o?(n.add(o.id),o.id):VP(e.id,t.propertyId,t.index)})}(t,u,y);y.forEach((e,t)=>{const o=a.get(e.propertyId);l([b[t]],{color:o?.popColor??o?.color,durationMs:900,radius:(o?.radius??7)+3})})}({project:e,effect:t,controls:o,layout:X,positiveById:Y,negativeById:V,coreBody:r,popBodies:(e,t)=>_.current?.popBodies(e,t)})},[r,X,V,Y]),ge=NP(({body:e,bodies:t})=>function(e){const{body:t,bodies:o,layout:r,states:n,projectPlacement:i,positiveById:a,negativeById:s,projectEvents:l,gateById:c,coreForceMode:u,terminalBehavior:d,elapsed:h}=e,p=t.datum;if(!p?.__gauntlet)return null;const m=n.findIndex(e=>e.id===p.projectId),f=0>m?void 0:n[m];if(!f)return null;const g=KP(f,m,r,i),y=o.find(e=>e.id===GP(f.id)),b=f.negativeIds.reduce((e,t)=>e+(s.get(t)?.load??1),0),v=f.killed?0:58;if(p.kind!==zP){if(!y)return null;let e;const n=p.property;if(n?.target){const i=o.filter(e=>{const t=e.datum;return t?.__gauntlet&&t.projectId===f.id&&t.kind===p.kind}).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),a=Math.max(0,i.findIndex(e=>e.id===t.id));e=n.target({body:t,bodies:o,core:y,index:a,layout:r,placement:g,project:f})??{x:y.x,y:y.y}}else if(p.kind===jP&&p.property){const t=QP(f.activePositiveIds,p.property.id);e={x:y.x+Math.cos(t.angle)*t.radius,y:y.y+Math.sin(t.angle)*t.radius-2}}else{const r=o.filter(e=>e.datum?.kind===OP&&e.datum.projectId===f.id).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),n=Math.max(0,r.findIndex(e=>e.id===t.id)),i=Math.floor(n/4);e={x:y.x+18*(n%4-(Math.min(4,r.length-4*i)-1)/2),y:y.y+54+13*i}}const i="circle"===t.shape.type?t.shape.radius:8;e=XP(e.x,e.y,i,r);const a=XP(t.x,t.y,i,r);if(Math.abs(a.x-t.x)>.5||Math.abs(a.y-t.y)>.5)return{x:48*(a.x-t.x)-6*t.vx,y:48*(a.y-t.y)-6*t.vy};const s=p.kind!==jP||f.killed?0:3.2*(n?.buoyancy??n?.value??1),l=p.kind===OP?{x:.22*(n?.pull?.x??-8),y:.22*(n?.pull?.y??22)}:{x:0,y:0};return{x:28*(e.x-t.x)-3*(t.vx-y.vx)+l.x+.01*v,y:28*(e.y-t.y)-3*(t.vy-y.vy)+l.y-s}}if(f.killed)return{x:44*((f.crashX??f.metrics.lastX??t.x)-t.x)-9*t.vx,y:160+12*b-1.6*t.vy};const x=l(f),w=function(e,t,o,r,n,i,a){if(t.killed)return{x:t.metrics.lastX??r.graveyardX,y:r.graveyardY};const s=n[n.length-1];if(!s)return{x:r.socketX,y:r.routeY};const l=n.find(o=>e>=o.time&&!t.eventsApplied.includes(o.id)&&!(!o.gateId||!i.get(o.gateId)?.capacity)),c=l?Math.min(e,l.time):e,u="built"===t.outcome||"built_diminished"===t.outcome;if(c>s.time+.85){if("hold-last"===a){const e=s.gateId?i.get(s.gateId):void 0;return{x:s.routeX??e?.x??r.socketX,y:s.routeY??r.routeY}}return u?{x:r.socketX,y:r.socketY}:{x:r.graveyardX,y:r.graveyardY-14}}const d=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),h=[{time:0,x:r.startX,y:r.startY},...n.map(e=>{const t=e.gateId?i.get(e.gateId):void 0;return{time:e.time,x:e.routeX??t?.x??r.startX,y:e.routeY??r.routeY+.28*Math.min(180,d)}})].sort((e,t)=>e.time-t.time);let p=h[0],m=h[h.length-1];for(let e=1;h.length>e;e+=1){if(h[e].time>=c){m=h[e];break}p=h[e]}const f=Math.max(0,Math.min(1,(c-p.time)/Math.max(.1,m.time-p.time))),g=f*f*(3-2*f);return{x:p.x+(m.x-p.x)*g,y:p.y+(m.y-p.y)*g+7*Math.sin(2.6*c)}}(Math.max(0,h-(f.startedAt??0)),f,0,g,x,c,d),k=f.activePositiveIds.reduce((e,t)=>e+(a.get(t)?.buoyancy??a.get(t)?.value??1),0);return"net"===u?{x:15*(w.x-t.x)-1.8*t.vx+.18*v,y:1.25*(g.routeY-t.y)-1.4*t.vy+32*(b-k)}:{x:15*(w.x-t.x)-1.8*t.vx+.18*v,y:15*(w.y-t.y)-1.8*t.vy+13*b-2.2*k}}({body:e,bodies:t,layout:X,states:J.current,projectPlacement:S,positiveById:Y,negativeById:V,projectEvents:ue,gateById:U,coreForceMode:n,terminalBehavior:P,elapsed:ee.current}),[n,U,X,V,Y,ue,S,P]),ye=NP((e,t)=>{!function(e,t,o){const{frameProps:r,elapsedRef:n,statesRef:i,crashDetection:a,layout:s,projectEvents:l,gateById:c,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:p,positiveById:m,negativeById:f,outcome:g,reportCapacity:y}=o;r.onTick?.(e,t),n.current=e.elapsedSeconds??t.snapshot().elapsedSeconds,y();for(const e of i.current){const o=t.readBodies().find(t=>t.id===GP(e.id));if(!o)continue;if(a&&!e.killed&&o.y+("circle"===o.shape.type?o.shape.radius:28)>=s.crashY){t.readBodies().forEach(o=>{const r=o.datum;r?.__gauntlet&&r.projectId===e.id&&t.applyImpulse(o.id,-o.vx*o.mass,0)}),h(e.id,e=>{const t={appliedAt:Math.max(0,n.current-(e.startedAt??0)),id:"gauntlet-crash-line",label:"Crash Line",summary:"The project hit the crash threshold; lift and forward motion shut off.",time:Math.max(0,n.current-(e.startedAt??0))};return{...e,crashX:o.x,eventHistory:[...e.eventHistory??[],t],killed:!0,lastEvent:t,metrics:{...e.metrics,lastX:o.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,e.viability)}});continue}if(e.killed)continue;const r=Math.max(0,n.current-(e.startedAt??0)),i=l(e),y=i.filter(t=>r>=t.time&&!e.eventsApplied.includes(t.id)&&u(e,t,i));let b=e;for(const o of y){const n=o.gateId?c.get(o.gateId):void 0,i=o.effects??[];for(const e of i){const r={event:o,gate:n,negativeProperties:f,positiveProperties:m,project:b};e.when&&!e.when(r)||(d(b,e,t),b=aI(b,e,r))}const a={...sI(o,i),appliedAt:r};b=lI(b,a),h(e.id,e=>{let t=lI(e,a);if(t===e)return e;for(const e of i)t=aI(t,e,{event:o,gate:n,negativeProperties:f,positiveProperties:m,project:t});const r=p?.(t,{negativeProperties:f,positiveProperties:m})??ZP(t,m,f);return t={...t,viability:r},o.final&&(t={...t,outcome:o.outcome??g?.(t,{layout:s,negativeProperties:f,positiveProperties:m})??(t.viability>20?"built":"approved_not_built")}),t})}}}(e,t,{frameProps:d,elapsedRef:ee,statesRef:J,crashDetection:i,layout:X,projectEvents:ue,gateById:U,capacityEventReady:de,addBodiesForEffect:fe,updateProjectState:me,viability:I,positiveById:Y,negativeById:V,outcome:x,reportCapacity:he})},[fe,de,i,d,U,X,V,x,Y,ue,he,me,I]),be=NP((e,t)=>{const o="function"==typeof d.bodyStyle?d.bodyStyle(e,t):d.bodyStyle,r=e.datum;return r?.__gauntlet?{fill:r.kind===zP?"var(--semiotic-accent, #0f766e)":r.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:r.kind===zP?"#f8fafc":"#0f172a",opacity:.96,...o}:o??{}},[d]),ve=DP(()=>"function"==typeof o?o(Q,X):o??[],[o,X,Q]),xe=DP(()=>_P(ve),[ve]),we=DP(()=>N?function(e,t){if(!e.length)return[];const o=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const r=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:r,description:r,datum:e,x:40+(t+.5)*o,y:28,shape:"rect",width:Math.max(16,.55*o),height:22,group:"settled projection"}})}(Q,X):[],[X,N,Q]),ke=DP(()=>[...we,...xe],[xe,we]),Se=NP((e,t)=>{d.onBodyPointerDown?.(e,t)},[d]),Ae=NP((e,t)=>{b&&b(e&&"object"==typeof e&&e.__gauntlet?e.sourceDatum:e,{x:t.x,y:t.y})},[b]);if(W)return W;const Ce=gM(e.tooltip,d),Me=yM(e,d,ke,{chartMode:F,className:B,title:D,description:j,summary:O,accessibleTable:H,enableHover:z,margin:E}),Pe=N?vI(bI,{states:Q,layout:X}):void 0,Ie=fM($?vI(gI,{layout:X,states:Q}):void 0,d.backgroundGraphics),_e=fM(Pe,d.foregroundGraphics),Le=d.renderBody??mI,Re=Ce.tooltipContent??pI;return mM("GauntletChart",T,xI(kC,{...d,...Ce,...Me,key:`${T[0]}x${T[1]}:${G}`,ref:_,accessibleTable:e.accessibleTable??d.accessibleTable,backgroundGraphics:Ie,bodyForces:ge,bodySemanticItems:d.bodySemanticItems??yI,bodyStyle:be,beforePaint:(e,t)=>{d.beforePaint?.(e,t),M&&function(e,t){const o=new Map(t.filter(e=>e.datum?.kind===zP).map(e=>[e.datum.projectId,e]));e.save(),e.lineWidth=1.1,e.setLineDash([3,4]);for(const r of t){const t=r.datum;if(!t?.__gauntlet||t.kind===zP)continue;const n=o.get(t.projectId);n&&(e.globalAlpha=t.kind===OP?.24:.36,e.strokeStyle=t.kind===OP?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke())}e.restore()}(e,t)},onClick:b?Ae:Me.onClick,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...d.config?.kernel??{}},colliders:[...HP(X),...d.config?.colliders??[]]},controllers:ie,enableHover:Ce.enableHover??!0,foregroundGraphics:_e,hoverRadius:e.hoverRadius??d.hoverRadius??18,initialSpawns:pe,initialSpawnPacing:p,onBodyPointerDown:Se,onTick:ye,paused:w,regionEffects:[...K,...d.regionEffects??[]],renderBody:Le,responsiveHeight:A,responsiveWidth:C,size:T,tooltipContent:Re}))});kI.displayName="GauntletChart";import{forwardRef as SI,useCallback as AI,useEffect as CI,useImperativeHandle as MI,useMemo as PI,useRef as II,useState as _I}from"react";function LI(e,t={}){if("function"==typeof e)return e;const o=t.locale??"en-US";if("currency"===e){const e=t.precision??2,r=new Intl.NumberFormat(o,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>r.format(e)}if("percent"===e){const e=new Intl.NumberFormat(o,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(o,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",o=Math.abs(e);if(1e3>o)return`${t}${Math.round(o)}ms`;const r=o/1e3;if(60>r)return`${t}${n=r,Math.round(100*n)/100+""}s`;var n;const i=r/60;if(60>i){const e=Math.floor(i),o=Math.round(r-60*e);return 0===o?`${t}${e}m`:`${t}${e}m ${o}s`}const a=i/60;if(24>a){const e=Math.floor(a),o=Math.round(i-60*e);return 0===o?`${t}${e}h`:`${t}${e}h ${o}m`}const s=Math.floor(a/24),l=Math.round(a-24*s);return 0===l?`${t}${s}d`:`${t}${s}d ${l}h`}(e);const r=new Intl.NumberFormat(o,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>r.format(e)}function RI(e,t,o){return`${t??""}${e}${o??""}`}import{Fragment as TI,jsx as NI,jsxs as $I}from"react/jsx-runtime";var BI={tile:{width:280,height:184,align:"start",labelSize:13,captionSize:11,valueSize:40,deltaSize:13,padding:{top:14,right:16,bottom:14,left:16},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:44},presentation:{width:540,height:320,align:"center",labelSize:18,captionSize:14,valueSize:96,deltaSize:18,padding:{top:32,right:32,bottom:32,left:32},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:80},inline:{width:void 0,height:void 0,align:"inherit",labelSize:0,captionSize:0,valueSize:0,deltaSize:0,padding:{top:0,right:0,bottom:0,left:0},background:"transparent",border:!1,showHeader:!1,showDelta:!0,showTrend:!1,showChart:!1,chartSize:0},thumbnail:{width:96,height:56,align:"center",labelSize:0,captionSize:0,valueSize:22,deltaSize:0,padding:{top:4,right:6,bottom:4,left:6},background:"transparent",border:!1,showHeader:!1,showDelta:!1,showTrend:!1,showChart:!1,chartSize:0}};function DI(e,t,o){return void 0===e?o:"function"==typeof e?e(t):e}function FI(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function EI(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var zI=SI((e,t)=>{const{value:o,label:r,caption:n,format:i,locale:a,currency:s,precision:l,prefix:c,suffix:u,unit:d,comparison:h,target:p,delta:m,deltaFormat:f,showDeltaPercent:g,direction:y,sentiment:b,thresholds:v,windowSize:x=60,mode:w="tile",align:k,width:S,height:A,padding:C,emphasis:M,color:P,background:I,borderColor:_,borderRadius:L,className:R,style:T,animate:N,stalenessThreshold:$,staleLabel:B,headerSlot:D,valueSlot:F,deltaSlot:E,trendSlot:z,chartSlot:j,chartSize:O,footerSlot:H,onClick:W,onObservation:q,chartId:G,description:Y,summary:V,loading:X,loadingContent:U,emptyContent:K}=e,Q=BI[w]??BI.tile,Z=k??Q.align,J=S??Q.width,ee=A??Q.height,te=Ts(),[oe,re]=_I([]),[ne,ie]=_I(null),[ae,se]=_I(null),[le,ce]=_I(null),ue=II([]),de=II(null),he=II(o);CI(()=>{he.current=o},[o]);const pe=II(x);CI(()=>{pe.current=x},[x]);const me=AI(e=>{const t="number"==typeof e?{value:e,time:Date.now()}:{time:Date.now(),...e},o="number"==typeof t.time?t.time:t.time instanceof Date?t.time.getTime():Date.now();return{...t,time:o}},[]),fe=AI(e=>{if(0===e.length)return;const t=pe.current,o=e.map(me);let r=ue.current.concat(o);r.length>t&&(r=r.slice(r.length-t)),ue.current=r;const n=o[o.length-1];de.current=n.value,re(r),ie(n.value);for(let e=o.length-1;e>=0;e--){const t=o[e].comparison;if(null!=t){se(t);break}}ce(n.time)},[me]),ge=AI(e=>fe([e]),[fe]);MI(t,()=>({push:e=>ge(e),pushMany:e=>fe(e),clear:()=>{ue.current=[],de.current=null,re([]),ie(null),se(null),ce(null)},getValue:()=>de.current??(Number.isFinite(he.current)?he.current:null),getData:()=>ue.current.slice()}),[ge,fe]);const ye=ne??o,be=null==ye||"number"!=typeof ye||!Number.isFinite(ye),ve=PI(()=>LI(i??"number",{locale:a,currency:s,precision:l}),[i,a,s,l]),xe=PI(()=>LI(f??i??"number",{locale:a,currency:s,precision:null==f&&null==i?0:l}),[f,i,a,s,l]),we=N??!1,ke=II(("object"==typeof we&&!1===we.intro||!we)&&Number.isFinite(o)?o:0),Se=function(e,t,o){const[r,n]=_I(e),i=II(null),a=II(e),s=II(0),l=II(e);return CI(()=>{if(!Number.isFinite(e))return void n(e);if(!t||o)return void n(e);const c="object"==typeof t&&t.duration?t.duration:300,u="object"==typeof t&&"linear"===t.easing?"linear":"ease-out";a.current=r,l.current=e,s.current="undefined"!=typeof performance?performance.now():Date.now();const d="linear"===u?e=>e:e=>1-Math.pow(1-e,3),h=e=>{const t=Math.min(1,(e-s.current)/c),o=d(t);n(a.current+(l.current-a.current)*o),1>t?i.current=requestAnimationFrame(h):(i.current=null,n(l.current))};return i.current=requestAnimationFrame(h),()=>{null!=i.current&&cancelAnimationFrame(i.current),i.current=null}},[e,t,o]),r}(Number.isFinite(ye)?ye:ke.current,we,te),Ae=we?Se:Number.isFinite(ye)?ye:0,Ce=PI(()=>function(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const o=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let r=null;for(const t of o){if(t.at>e)break;r=t}return r}(Number.isFinite(ye)?ye:NaN,v),[ye,v]),Me=Ce?Ce.level:"neutral",Pe=P??function(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}(Me,Ce?.color),Ie=ae??h?.value??null,_e=null!=m?m:null!=Ie&&Number.isFinite(ye)?ye-Ie:null,Le=function(e,t,o){if(o&&"auto"!==o)return o;if(null==e||0===e||!Number.isFinite(e))return"neutral";const r=t??"higher-is-better";return"neutral"===r?"neutral":("higher-is-better"===r?e>0:0>e)?"positive":"negative"}(_e,h?.direction??p?.direction??y,b),Re=null!=_e&&Number.isFinite(_e)?function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(_e,xe):null,Te=PI(()=>new Intl.NumberFormat(a??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[a]),Ne=null!=Ie&&Number.isFinite(ye)&&(g??1)&&0!==Ie?Te.format((ye-Ie)/Math.abs(Ie)):null,$e=PI(()=>new Intl.NumberFormat(a??"en-US",{style:"percent",maximumFractionDigits:0}),[a]),Be=PI(()=>p&&Number.isFinite(ye)&&p.value?$e.format(ye/p.value):null,[p,ye,$e]),De=PI(()=>LI(p?.format??i??"number",{locale:a,currency:s,precision:l}),[p?.format,i,a,s,l]),Fe=PI(()=>LI(h?.format??i??"number",{locale:a,currency:s,precision:l}),[h?.format,i,a,s,l]),Ee=function(e,t){const[o,r]=_I(!1);return CI(()=>{if(!t||null==e)return void r(!1);const o=()=>{r(Date.now()-e>=t)};o();const n=setInterval(o,Math.max(250,Math.floor(t/4)));return()=>clearInterval(n)},[e,t]),o}(le,$),ze=Number.isFinite(Ae)?RI(ve(Ae),c,u):"",je={value:be?null:ye,formattedValue:ze,level:Me,color:Pe,delta:_e,deltaFormatted:Re,deltaPercent:Ne,sentiment:Le,isStale:Ee,pushBuffer:oe},Oe=Y??function(e){const t=[];if(e.label&&t.push(e.label+":"),t.push(e.unit?`${e.formattedValue} ${e.unit}`:e.formattedValue),e.deltaFormatted){const o=e.delta,r=null!=o&&Number.isFinite(o)&&0!==o?o>0?"up":"down":"change";t.push(`${r} ${e.deltaFormatted}${e.deltaPercent?` (${e.deltaPercent})`:""}${e.comparisonLabel?" from "+e.comparisonLabel:""}`)}return e.targetPercent&&e.targetLabel&&t.push(`${e.targetPercent} of ${e.targetLabel}`),e.stale&&t.push(e.staleLabel??"stale"),t.join(", ")}({label:r,formattedValue:Number.isFinite(ye)?RI(ve(ye),c,u):"",unit:d,comparisonLabel:h?.label,delta:_e,deltaFormatted:Re,deltaPercent:Ne,targetLabel:p?.label,targetPercent:Be,stale:Ee,staleLabel:B}),He="number"==typeof C?{top:C,right:C,bottom:C,left:C}:{...Q.padding,...C??{}},We="end"===Z?"flex-end":"center"===Z?"center":"start"===Z?"flex-start":"inherit",qe={position:"relative",boxSizing:"border-box",width:J,height:ee,padding:`${He.top}px ${He.right}px ${He.bottom}px ${He.left}px`,background:I??Q.background,border:Q.border?"1px solid "+(_??"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof L?L+"px":L??"var(--semiotic-border-radius, 8px)",display:"inline"===w?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===We?void 0:We,textAlign:Z,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:Ee?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===M?"span 2":void 0,cursor:W?"pointer":void 0,...T},Ge=AI(e=>{const t=e.currentTarget.getBoundingClientRect(),o=e.clientX-t.left,r=e.clientY-t.top,n={value:be?NaN:ye,level:Me,delta:_e};W&&W(n,{x:o,y:r}),q&&q({type:"click",datum:n,x:o,y:r,chartType:"BigNumber",chartId:G,timestamp:Date.now()})},[W,q,G,be,ye,Me,_e]),Ye="inline"===w?"span":"div",Ve=["semiotic-bignumber","semiotic-bignumber--mode-"+w,"semiotic-bignumber--level-"+Me,"semiotic-bignumber--sentiment-"+Le,Ee?"semiotic-bignumber--stale":null,R].filter(Boolean).join(" "),Xe="positive"===Le?"up":"negative"===Le?"down":"flat";if(X){const e="number"==typeof J?J:280,t="number"==typeof ee?ee:160;return NI(Ye,{role:"status","aria-live":"polite","aria-busy":"true",className:Ve+" semiotic-bignumber--loading",style:{...qe,opacity:1},children:U??NI(OI,{width:e,height:t,mode:w})})}return be?!1===K?null:NI(Ye,{role:"status","aria-label":r?r+": no value":"no value",className:Ve+" semiotic-bignumber--empty",style:{...qe,color:"var(--semiotic-text-secondary, #666)",fontSize:13,alignItems:"center",justifyContent:"center"},children:K??"—"}):NI(Eu,{componentName:"BigNumber",width:"number"==typeof J?J:280,height:"number"==typeof ee?ee:160,children:$I(Ye,{role:"group","aria-label":Oe,"data-chart":"BigNumber","data-mode":w,"data-level":Me,"data-stale":Ee?"true":void 0,"data-sentiment":Le,className:Ve,style:qe,onClick:W||q?Ge:void 0,children:[Q.showHeader&&(r||n||D)?NI("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:Q.showChart&&null!=j?(O??Q.chartSize)+8:0},children:DI(D,je,$I(TI,{children:[r?NI("span",{className:"semiotic-bignumber__label",style:{fontSize:Q.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:r}):null,n?NI("span",{className:"semiotic-bignumber__caption",style:{fontSize:Q.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:n}):null]}))}):null,DI(F,je,$I(Ye,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Me,style:{display:"inline"===w?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Pe,fontSize:Q.valueSize||void 0,lineHeight:1.05},children:[NI("span",{className:"semiotic-bignumber__value-text",children:ze}),d?NI("span",{className:"semiotic-bignumber__unit",style:{fontSize:Q.valueSize?Math.max(11,Math.round(.32*Q.valueSize)):"0.75em",color:"var(--semiotic-text-secondary, #9ca3af)",fontWeight:500},children:d}):null]})),Q.showDelta&&(Re||p||h)?NI(Ye,{className:"semiotic-bignumber__delta semiotic-bignumber__delta--"+Xe,style:{display:"inline"===w?"inline-flex":"flex",flexWrap:"wrap",gap:8,alignItems:"baseline",marginTop:"inline"===w?0:6,fontSize:Q.deltaSize||void 0,color:"var(--semiotic-text-secondary, #6b7280)"},children:DI(E,je,$I(TI,{children:[Re?$I("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+Xe,style:{display:"inline-flex",alignItems:"center",gap:4,color:FI(Le),fontWeight:600},children:[NI("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+Xe,children:EI(Le)}),NI("span",{className:"semiotic-bignumber__delta-amount",children:Re}),Ne?$I("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",Ne,")"]}):null]}):null,h?.label?NI("span",{className:"semiotic-bignumber__comparison-label",children:h.label}):null,p?$I("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[Re||h?.label?NI("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,NI("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:Be}),$I("span",{className:"semiotic-bignumber__target-value",children:["of ",De(p.value),p.label?" "+p.label:""]})]}):null]}))}):null,Q.showChart&&null!=j?NI("div",{className:"semiotic-bignumber__chart",style:{position:"absolute",top:He.top,right:He.right,width:O??Q.chartSize,height:O??Q.chartSize,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:NI("div",{style:{pointerEvents:"auto",lineHeight:0},children:DI(j,je,null)})}):null,Q.showTrend&&null!=z?NI("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:He.left,right:He.right,bottom:He.bottom+(null!=H?28:0)},children:DI(z,je,null)}):null,null!=H?NI(Ye,{className:"semiotic-bignumber__footer",style:{position:"absolute",left:He.left,right:He.right,bottom:He.bottom,fontSize:Q.deltaSize||void 0,color:"var(--semiotic-text-secondary, #9ca3af)"},children:DI(H,je,null)}):null,V?NI("span",{style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:V}):null,NI("span",{"aria-hidden":"true",style:{display:"none"},children:null!=Ie?Fe(Ie):null})]})})});zI.displayName="BigNumber";var jI=zI;function OI(e){const t=Math.floor(.45*e.width),o=Math.floor(.6*e.width),r=(e,t)=>NI("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return $I("div",{style:{display:"flex",flexDirection:"column",gap:10,justifyContent:"center",width:"100%",height:"100%"},children:["thumbnail"!==e.mode&&"inline"!==e.mode?r(t,10):null,r(o,"presentation"===e.mode?48:28),"tile"===e.mode||"presentation"===e.mode?r(Math.floor(.35*e.width),8):null]})}var[HI,WI]=q(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));async function qI(e,t){const{format:o="png",filename:r="chart",scale:n=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),GI(a,s),"svg"===o){const e=(new XMLSerializer).serializeToString(s);YI(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),r+".svg")}else{const t=l.width*n,o=l.height*n,a=document.createElement("canvas");a.width=t,a.height=o;const c=a.getContext("2d");c.fillStyle=i,c.fillRect(0,0,t,o),c.scale(n,n);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(s),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),p=URL.createObjectURL(h),m=new Image;m.width=l.width,m.height=l.height,await new Promise((e,t)=>{m.onload=()=>{c.drawImage(m,0,0),a.toBlob(o=>{o?(YI(o,r+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(p)},m.onerror=()=>{URL.revokeObjectURL(p),t(Error("Failed to load SVG image"))},m.src=p})}}function GI(e,t){const o=e.children,r=t.children,n=window.getComputedStyle(e),i=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of i){const o=n.getPropertyValue(e);o&&"none"!==o&&""!==o&&t.style?.setProperty(e,o)}for(let e=0;Math.min(o.length,r.length)>e;e++)GI(o[e],r[e])}function YI(e,t){const o=URL.createObjectURL(e),r=document.createElement("a");r.href=o,r.download=t,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(o)}import*as VI from"react";var XI={common:{width:{type:"number",default:600},height:{type:"number",default:400},margin:{type:"object",description:'Object margin. A side value of "auto" or null leaves that side available for auto-reservation.'},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean",default:!0},showLegend:{type:"boolean"},showGrid:{type:"boolean",default:!1},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"],default:"category10"},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"],default:!1,description:"Opt-in annotation placement pass. Chooses dx/dy for note-like annotations without manual offsets and avoids note/mark/edge overlaps where possible."},responsiveRules:{type:"array",description:"Semantic responsive transforms applied before chart-mode defaults."},mobileSemantics:{type:"object",description:"Phone/mobile contract consumed by audits, recipes, adapters, and agents."},mobileInteraction:{type:["boolean","object"],description:"Touch-first interaction policy for phone-sized chart slots."},axisExtent:{type:"string",enum:["nice","exact"],default:"nice",description:'Tick endpoint mode. "nice" rounds endpoints to readable values; "exact" pins the first and last tick to the actual data min and max with equidistant intermediates. Affects XY x/y axes and ordinal value axis only.'},frameProps:{type:"object",omitFromSchema:!0},onClick:{type:"function",omitFromSchema:!0}},xyAxis:{xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function",omitFromSchema:!0},yFormat:{type:"function",omitFromSchema:!0},xScaleType:{type:"string",enum:["linear","log","time"],description:'x scale type. "time" builds a scaleTime (required for landmark ticks on timestamps).'},yScaleType:{type:"string",enum:["linear","log","time"],description:"y scale type."}},ordinalAxis:{categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function",omitFromSchema:!0}},realtime:{size:{type:"array",description:"[width, height] in pixels"},width:{type:"number",description:"Alias for size[0]"},height:{type:"number",description:"Alias for size[1]"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"],description:"Key for time/x values"},valueAccessor:{type:["string","function"],description:"Key for y values"},windowSize:{type:"number",description:"Number of data points visible"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"],description:"Tooltip content function or config"},tooltipContent:{type:"function",omitFromSchema:!0},onHover:{type:"function",omitFromSchema:!0},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"],description:"Opt-in annotation placement pass for note-like annotations without manual offsets."},responsiveRules:{type:"array",description:"Semantic responsive transforms applied before chart-mode defaults."},mobileSemantics:{type:"object",description:"Phone/mobile contract consumed by audits, recipes, adapters, and agents."},mobileInteraction:{type:["boolean","object"],description:"Touch-first interaction policy for phone-sized chart slots."},svgAnnotationRules:{type:"function",omitFromSchema:!0},tickFormatTime:{type:"function",omitFromSchema:!0},tickFormatValue:{type:"function",omitFromSchema:!0},decay:{type:"object",description:"Decay config: { type, halfLife, minOpacity }"},pulse:{type:"object",description:"Pulse config: { duration, color, glowRadius }"},staleness:{type:"object",description:"Staleness config: { threshold, dimOpacity, showBadge }"}},physics:{data:{type:"array",description:"Array of source records. Each record becomes one or more simulated bodies."},size:{type:"array",description:"[width, height] in pixels"},width:{type:"number",description:"Alias for size[0]"},height:{type:"number",description:"Alias for size[1]"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"],description:"Categorical field or accessor used to color simulated bodies."},seed:{type:"number",default:1,description:"Deterministic simulation seed."},ballRadius:{type:"number",description:"Radius of each simulated circular body in pixels."},hoverRadius:{type:"number",description:"Pixel hit radius for body hover tooltips."},paused:{type:"boolean",description:"Pause the simulation at mount or on prop update."},tooltip:{type:["boolean","function","object"],description:"Tooltip content function/config, true for the default body tooltip, or false to disable hover tooltips."},frameProps:{type:"object",omitFromSchema:!0}}},UI=["vertical","horizontal"],KI=["horizontal","vertical"],QI=["right","left","top","bottom"],ZI=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"];function JI(e){const t={type:e.type};return e.enum&&(t.enum=[...e.enum]),t}function e_(e){const t={};for(const[o,r]of Object.entries(function(e){const t={};for(const o of e.propBags)Object.assign(t,XI[o]);return Object.assign(t,e.ownProps),t}(e)))t[o]=JI(r);return{required:[...e.required],dataShape:e.dataShape,dataAccessors:[...e.dataAccessors],props:t}}var t_=Object.fromEntries(Object.entries({BarChart:{name:"BarChart",category:"ordinal",description:"Vertical or horizontal bars for categorical comparisons.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category",description:"Key for category labels"},valueAccessor:{type:["string","function"],default:"value",description:"Key for bar values"},orientation:{type:"string",enum:UI,default:"vertical"},sort:{type:["boolean","string","function"],default:!1,description:"Sort bars: false, true, 'asc', 'desc', or comparator function"},barPadding:{type:"number",default:40},roundedTop:{type:"number",omitFromSchema:!0},valueExtent:{type:"array",omitFromSchema:!0},regression:{type:["boolean","string","object"],description:"Overlay a regression line through the bar tops. Accepts true (linear), a method ('linear' | 'polynomial' | 'loess'), or a full RegressionConfig. Pixels resolve through the band scale."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["regression-overlay"]}},StackedBarChart:{name:"StackedBarChart",category:"ordinal",description:"Stacked bars for part-to-whole comparisons across categories. Requires stackBy to define the stacking dimension.",required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},stackBy:{type:["string","function"],description:"Key to define the stacking dimension (required)"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"vertical"},normalize:{type:"boolean",default:!1,description:"Normalize stacks to 100%"},sort:{type:["boolean","string","function"],omitFromSchema:!0},barPadding:{type:"number",default:40},roundedTop:{type:"number",omitFromSchema:!0},showLegend:{type:"boolean",default:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["stack"]}},GroupedBarChart:{name:"GroupedBarChart",category:"ordinal",description:"Side-by-side bars for comparing sub-categories within categories. Requires groupBy to define grouping.",required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},groupBy:{type:["string","function"],description:"Key to define the grouping dimension (required)"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"vertical"},sort:{type:["boolean","string","function"],omitFromSchema:!0},barPadding:{type:"number",default:60},roundedTop:{type:"number",omitFromSchema:!0},showLegend:{type:"boolean",default:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},SwarmPlot:{name:"SwarmPlot",category:"ordinal",description:"Beeswarm/jittered dot plot showing individual data points within categories. Good for distributions.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"vertical"},sizeBy:{type:["string","function"],description:"Key for variable point sizing"},sizeRange:{type:"array",default:[3,8]},symbolBy:{type:["string","function"],description:"Categorical field → glyph shape; each point renders as a d3-shape glyph instead of a circle."},symbolMap:{type:"object",description:"Explicit {category → shape} map for symbolBy; unmapped categories auto-assign."},pointRadius:{type:"number",default:4},pointOpacity:{type:"number",default:.7},categoryPadding:{type:"number",default:20},brush:{type:"boolean",omitFromSchema:!0},onBrush:{type:"function",omitFromSchema:!0},linkedBrush:{type:["string","object"],omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},BoxPlot:{name:"BoxPlot",category:"ordinal",description:"Box-and-whisker plots showing statistical distribution (median, quartiles, outliers) per category.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"vertical"},showOutliers:{type:"boolean",default:!0,description:"Show outlier points"},outlierRadius:{type:"number",default:3},categoryPadding:{type:"number",default:20}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["statistical"]}},Histogram:{name:"Histogram",category:"ordinal",description:"Binned frequency distribution chart. Shows how data values are distributed across bins within categories.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},bins:{type:"number",default:25,description:"Number of bins for the histogram"},relative:{type:"boolean",default:!1,description:"Normalize counts per category to show relative frequency"},categoryPadding:{type:"number",default:20},brush:{type:"boolean",omitFromSchema:!0},onBrush:{type:"function",omitFromSchema:!0},linkedBrush:{type:["string","object"],omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},ViolinPlot:{name:"ViolinPlot",category:"ordinal",description:"Violin plots showing the full distribution shape (kernel density) per category. Combines density estimation with optional IQR lines.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"vertical"},bins:{type:"number",default:25,description:"Number of bins for density estimation"},curve:{type:"string",default:"catmullRom",description:"Interpolation curve for the violin shape"},showIQR:{type:"boolean",default:!0,description:"Show interquartile range lines"},categoryPadding:{type:"number",default:20},brush:{type:"boolean",omitFromSchema:!0},onBrush:{type:"function",omitFromSchema:!0},linkedBrush:{type:["string","object"],omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["statistical"]}},RidgelinePlot:{name:"RidgelinePlot",category:"ordinal",description:"Overlapping density distributions for comparing distributions across categories. Each category gets a density curve that can overlap with adjacent rows.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],description:"Key for category grouping"},valueAccessor:{type:["string","function"],description:"Key for numeric values to build distributions from"},bins:{type:"number",description:"Number of bins for density estimation"},amplitude:{type:"number",default:1.5,description:"Unitless multiplier of row height (>1 creates overlap)"},categoryPadding:{type:"number",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},DotPlot:{name:"DotPlot",category:"ordinal",description:"Cleveland-style dot plot for comparing values across categories. Sorted by default.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},orientation:{type:"string",enum:UI,default:"horizontal"},sort:{type:["boolean","string","function"],default:!0,description:"Sort dots: true, false, 'asc', 'desc'"},dotRadius:{type:"number",default:5},categoryPadding:{type:"number",default:10},showGrid:{type:"boolean",default:!0},regression:{type:["boolean","string","object"],description:"Overlay a regression line through the dots. Same shape as Scatterplot's regression prop."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["regression-overlay"]}},PieChart:{name:"PieChart",category:"ordinal",description:"Proportional slices in a circle for part-to-whole relationships.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},startAngle:{type:"number",default:0,description:"Starting angle in radians"},cornerRadius:{type:"number",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},DonutChart:{name:"DonutChart",category:"ordinal",description:"Pie chart with a hole in the center. Supports center content like summary statistics.",required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["common"],ownProps:{data:{type:"array",description:"Array of data objects"},categoryAccessor:{type:["string","function"],default:"category"},valueAccessor:{type:["string","function"],default:"value"},innerRadius:{type:"number",default:60,description:"Inner radius of the donut hole in pixels"},centerContent:{type:["object","string","number"],description:"React node to render in the center of the donut (accepts string key or JSX)"},startAngle:{type:"number",default:0},cornerRadius:{type:"number",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},GaugeChart:{name:"GaugeChart",category:"ordinal",description:"Single-value gauge with threshold zones, needle indicator, and configurable sweep angle. Built on StreamOrdinalFrame radial projection.",required:["value"],dataShape:"none",dataAccessors:[],propBags:["common"],ownProps:{value:{type:"number",description:"Current gauge value"},min:{type:"number",default:0},max:{type:"number",default:100},thresholds:{type:"array",description:"Array of { value, color, label? } defining threshold zones. Last value should equal max."},gradientFill:{type:"object",description:"Arc-length gradient for the gauge band. Color stops are sampled along the sweep from start to end."},arcWidth:{type:"number",default:.3,description:"Arc thickness as fraction of radius (0-1)"},cornerRadius:{type:"number",description:"Pixel radius for rounded segment ends. Same semantics as DonutChart's cornerRadius. Omit for sharp corners."},sweep:{type:"number",default:240,description:"Arc sweep angle in degrees (gap centered at bottom)"},fillZones:{type:"boolean",default:!0,description:"When true, the arc fills up to the current value; when false, the full arc is shown."},showNeedle:{type:"boolean",default:!0},needleColor:{type:"string"},color:{type:"string",description:"Fallback fill color used when no thresholds are defined"},valueFormat:{type:"function"},centerContent:{type:["object","string","number","function"],omitFromSchema:!0},showScaleLabels:{type:"boolean",default:!0},backgroundColor:{type:"string",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!1,supportsSSR:!0,colorModel:"threshold",layoutMode:"synthetic",specialFeatures:["threshold-zones","value-only","controlled-prop-streaming"]}},FunnelChart:{name:"FunnelChart",category:"ordinal",description:"Funnel visualization with two orientations. Horizontal (default): steps top-to-bottom with centered bars and trapezoid connectors; multi-category mirrors around center axis. Vertical: steps on x-axis as vertical bars with hatched dropoff stacking (solid = retained, hatched = dropoff from previous step); multi-category renders grouped bars.",required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects with step and value fields"},stepAccessor:{type:["string","function"],default:"step",description:"Key for funnel step/stage name"},valueAccessor:{type:["string","function"],default:"value",description:"Key for numeric value per step"},categoryAccessor:{type:["string","function"],description:"Key to split each step into mirrored categories (optional)"},orientation:{type:"string",enum:KI,default:"horizontal",description:"Horizontal (default): centered bars top-to-bottom with trapezoid connectors. Vertical: vertical bars with hatched dropoff stacking — solid = retained, hatched = dropoff from previous step. Multi-category renders grouped bars in vertical mode."},connectorOpacity:{type:"number",default:.3,description:"Opacity of trapezoid connectors between steps (0-1). Horizontal orientation only."},showCategoryTicks:{type:"boolean",default:!1,description:"Show category tick labels on ordinal axis"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:QI}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},SwimlaneChart:{name:"SwimlaneChart",category:"ordinal",description:"Categorical lanes with sequentially stacked items colored by subcategory. Unlike StackedBarChart, the same subcategory can appear multiple times in the same lane — items stack left-to-right (horizontal) or bottom-to-top (vertical) in data order. Supports brush for value-axis selection and push API for streaming.",required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of data objects. Omit for push API mode."},categoryAccessor:{type:["string","function"],default:"category",description:"Key for lane categories (swim lanes)"},subcategoryAccessor:{type:["string","function"],description:"Key for item subcategory (color grouping within lanes). Required. Duplicate subcategories in the same lane stack sequentially."},valueAccessor:{type:["string","function"],default:"value",description:"Key for item size/duration along the value axis"},orientation:{type:"string",enum:KI,default:"horizontal",description:"Horizontal renders lanes as rows; vertical as columns."},barPadding:{type:"number",default:40,description:"Padding between lanes in pixels"},roundedTop:{type:"number",description:"Rounded corner radius (px) applied to the outermost ends of each lane — left+right for horizontal, top+bottom for vertical. Middle segments stay square; single-segment lanes round all four corners."},brush:{type:"boolean",description:"Enable value-axis brush selection"},onBrush:{type:"function",description:"Callback with { r: [min, max] } or null when brush clears"},linkedBrush:{type:["string","object"],description:"LinkedCharts brush integration name"},showCategoryTicks:{type:"boolean",description:"Show lane labels on the category axis"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:QI}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["brush"]}},LikertChart:{name:"LikertChart",category:"ordinal",description:"Visualize Likert scale survey responses. Horizontal (default): diverging bar chart centered at 0% — negative levels extend left, positive right, neutral (if odd count) split 50/50 across centerline. Vertical: stacked 100% bar chart. Supports raw integer scores (1-based, aggregated automatically) or pre-aggregated (question, level, count) data. The levels array defines polarity: first half = negative, second half = positive, center = neutral (if odd). Works with any scale size (3-point to 7-point+). Supports push API for streaming — accumulates raw data and re-aggregates on each push.",required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],propBags:["common","ordinalAxis"],ownProps:{data:{type:"array",description:"Array of raw response or pre-aggregated data objects"},levels:{type:"array",default:Jg,description:"Ordered response labels, most negative to most positive. Defaults to a 5-point Very Low to Very High scale. Odd count = center is neutral."},categoryAccessor:{type:["string","function"],default:"question",description:"Question/item field (ordinal axis)"},valueAccessor:{type:["string","function"],default:"score",description:"Integer score field for raw response mode (1-based: score 1 → levels[0])"},levelAccessor:{type:["string","function"],description:"Level name field for pre-aggregated mode. Each value must match an entry in levels."},countAccessor:{type:["string","function"],default:"count",description:"Count/frequency field for pre-aggregated mode"},orientation:{type:"string",enum:UI,default:"horizontal"},barPadding:{type:"number",default:20}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},LineChart:{name:"LineChart",category:"xy",description:"Line traces with curve interpolation, area fill, and point markers. Use for time series, trends, and continuous data.",required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x",description:"Key or accessor function for x-axis values"},yAccessor:{type:["string","function"],default:"y",description:"Key or accessor function for y-axis values"},lineBy:{type:["string","function"],description:"Key to group data into separate lines"},lineDataAccessor:{type:"string",default:"coordinates",description:"Key for the coordinates array within each line object"},curve:{type:"string",enum:ZI,default:"linear",description:"Curve interpolation method"},lineWidth:{type:"number",default:2,description:"Stroke width of the line"},showPoints:{type:"boolean",default:!1,description:"Show data point markers on the line"},pointRadius:{type:"number",default:3,description:"Radius of point markers when showPoints is true"},fillArea:{type:"boolean",default:!1,description:"Fill the area under the line"},areaOpacity:{type:"number",default:.3,description:"Opacity of the filled area (0-1)"},forecast:{type:"object",description:"Forecast overlay config — tagged training/observed/forecast region with optional envelope. See ForecastConfig."},anomaly:{type:"object",description:"Anomaly overlay config — ±σ band + anomaly dot annotations. See AnomalyConfig."},band:{type:["object","array"],description:"Asymmetric min/max envelope drawn under the line. `{ y0Accessor, y1Accessor, style?, perSeries?, interactive? }` or an array of those for percentile fans. Distinct from `forecast`/`anomaly` (computed) — band is pure data passthrough. Hovered datum is enriched with `band: { y0, y1 }` and `bands: [...]`."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["forecast","anomaly","band","series-features","gap-handling","direct-labels","endpoint-labels"]}},AreaChart:{name:"AreaChart",category:"xy",description:"Filled area chart with optional stroke line. Use for showing volume or magnitude over time.",required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x",description:"Key for x-axis values"},yAccessor:{type:["string","function"],default:"y",description:"Key for y-axis values"},areaBy:{type:["string","function"],description:"Key to group data into separate areas"},lineDataAccessor:{type:"string",default:"coordinates",description:"Key for the coordinates array within each area object"},curve:{type:"string",enum:ZI,default:"monotoneX"},gradientFill:{type:["boolean","object"],description:"Renderer-space area gradient. true uses default opacity; object supports opacity or colorStops."},semanticGradient:{type:"array",description:"User-facing gradient stops: [{ at: 0-100, color, opacity? }], where 0 is baseline and 100 is line/top. Takes precedence over gradientFill."},areaOpacity:{type:"number",default:.7,description:"Area fill opacity (0-1)"},showLine:{type:"boolean",default:!0,description:"Show stroke line on top of area"},lineWidth:{type:"number",default:2},forecast:{type:"object",description:"Forecast overlay config — tagged training/observed/forecast region with optional envelope. See ForecastConfig."},anomaly:{type:"object",description:"Anomaly overlay config — ±σ band + anomaly dot annotations. See AnomalyConfig."},band:{type:["object","array"],description:"Asymmetric min/max envelope drawn under the area. See LineChart.band — same shape, same enrichment."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["forecast","anomaly","band","series-features"]}},DifferenceChart:{name:"DifferenceChart",category:"xy",description:"Two-series difference chart: fills the area between series A and series B with a color that switches at each crossover — A's color where A > B, B's color where B > A. Crossovers are linearly interpolated so segments meet at zero-width vertices. Both series can be drawn as overlay lines on top of the fill. Classic uses: temperature anomaly (actual vs. normal), forecast accuracy (actual vs. predicted), budget variance.",required:[],dataShape:"array",dataAccessors:["xAccessor","seriesAAccessor","seriesBAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of `{x, a, b}` objects. Omit for push API mode."},xAccessor:{type:["string","function"],default:"x",description:"Key for x values"},seriesAAccessor:{type:["string","function"],default:"a",description:"Key for series A values"},seriesBAccessor:{type:["string","function"],default:"b",description:"Key for series B values"},seriesALabel:{type:"string",default:"A",description:"Display label for series A in legend + tooltip"},seriesBLabel:{type:"string",default:"B",description:"Display label for series B"},seriesAColor:{type:"string",description:"Fill color when series A is higher. Defaults to var(--semiotic-danger)."},seriesBColor:{type:"string",description:"Fill color when series B is higher. Defaults to var(--semiotic-info)."},showLines:{type:"boolean",default:!0,description:"Draw the two series as overlay lines on top of the fill"},lineWidth:{type:"number",default:1.5},showPoints:{type:"boolean",default:!1,description:"Show points at each data vertex on the overlay lines"},pointRadius:{type:"number",default:3},curve:{type:"string",enum:ZI,default:"linear"},areaOpacity:{type:"number",default:.6,description:"Difference fill opacity (0-1)"},gradientFill:{type:["boolean","object"],description:"Tip→base gradient across each segment; same shape as AreaChart.gradientFill"},xExtent:{type:"array",description:"Fixed x domain `[min, max]`. Either bound may be `undefined`."},yExtent:{type:"array",description:"Fixed y domain `[min, max]`. Either bound may be `undefined`."},pointIdAccessor:{type:["string","function"],description:"Stable ID for push-mode remove()/update()"},windowSize:{type:"number",description:"Max raw rows in the push buffer; older rows evict FIFO. Recommended for long-running streams."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["crossover-segmentation"]}},StackedAreaChart:{name:"StackedAreaChart",category:"xy",description:"Stacked area chart with optional normalization to 100%. Use for part-to-whole trends over time.",required:["data","areaBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x"},yAccessor:{type:["string","function"],default:"y"},areaBy:{type:["string","function"],description:"Key to group data into stacked areas"},lineDataAccessor:{type:"string",default:"coordinates"},curve:{type:"string",enum:ZI,default:"monotoneX"},areaOpacity:{type:"number",default:.7},showLine:{type:"boolean",default:!0},lineWidth:{type:"number",default:2},normalize:{type:"boolean",default:!1,description:"Normalize stacks to 100%"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["stack","streamgraph"]}},Scatterplot:{name:"Scatterplot",category:"xy",description:"Individual data points plotted by x/y position with optional size and color encoding.",required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x"},yAccessor:{type:["string","function"],default:"y"},sizeBy:{type:["string","function"],description:"Key for variable point sizing"},sizeRange:{type:"array",default:[3,15],description:"Min and max radius for sizeBy scaling"},symbolBy:{type:["string","function"],description:"Categorical field → glyph shape; each mark renders as a d3-shape glyph (circle/square/triangle/diamond/star/cross/wye/chevron) instead of a circle."},symbolMap:{type:"object",description:"Explicit {category → shape} map for symbolBy; unmapped categories auto-assign."},pointRadius:{type:"number",default:5,description:"Fixed point radius"},pointOpacity:{type:"number",default:.8},regression:{type:["boolean","string","object"],description:"Overlay a regression line. true = linear, 'linear' | 'polynomial' | 'loess' = method, or full RegressionConfig object. Sugar over the trend annotation."},forecast:{type:"object",description:"Forecast overlay config — tagged future points + optional envelope. See ForecastConfig."},anomaly:{type:"object",description:"Anomaly overlay config — ±σ band + anomaly dot annotations. See AnomalyConfig."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["regression-overlay","forecast","anomaly","series-features"]}},BubbleChart:{name:"BubbleChart",category:"xy",description:"Scatterplot with required size dimension for three-variable comparison. Bubble area encodes a numeric value.",required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},sizeBy:{type:["string","function"],description:"Key for bubble size (required)"},xAccessor:{type:["string","function"],default:"x"},yAccessor:{type:["string","function"],default:"y"},sizeRange:{type:"array",default:[5,40]},bubbleOpacity:{type:"number",default:.6},bubbleStrokeWidth:{type:"number",default:1},bubbleStrokeColor:{type:"string",default:"white"},regression:{type:["boolean","string","object"],description:"Overlay a regression line on the bubbles. Same shape as Scatterplot's regression prop."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["size-encoding","streaming-domain","regression-overlay"]}},Heatmap:{name:"Heatmap",category:"xy",description:"Grid/matrix visualization with color-encoded cell values. Use for correlation matrices, time-frequency analysis.",required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects with x, y, and value"},xAccessor:{type:["string","function"],default:"x"},yAccessor:{type:["string","function"],default:"y"},valueAccessor:{type:["string","function"],default:"value",description:"Key for the cell value"},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"],omitFromSchema:!0},showValues:{type:"boolean",default:!1,description:"Display numeric values in cells"},valueFormat:{type:"function"},cellBorderColor:{type:"string",default:"#fff"},cellBorderWidth:{type:"number",default:1},legendPosition:{type:"string",enum:QI,default:"right",description:"Position of the gradient legend"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"sequential",layoutMode:"plugin",specialFeatures:[]}},QuadrantChart:{name:"QuadrantChart",category:"xy",description:"Scatterplot divided into four labeled, colored quadrants by center lines. Use for BCG matrices, priority matrices, and any 2x2 strategic framework.",required:[],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x"},yAccessor:{type:["string","function"],default:"y"},xCenter:{type:"number",description:"X-coordinate of the vertical center line. Defaults to midpoint of x domain."},yCenter:{type:"number",description:"Y-coordinate of the horizontal center line. Defaults to midpoint of y domain."},quadrants:{type:"object",default:ap,description:"Optional configuration overrides for the four quadrants: { topRight, topLeft, bottomRight, bottomLeft }, each with partial { label, color, opacity }. Omitted quadrants and fields use built-in defaults."},centerlineStyle:{type:"object",omitFromSchema:!0},showQuadrantLabels:{type:"boolean",default:!0},quadrantLabelSize:{type:"number",default:12},sizeBy:{type:["string","function"],description:"Key for variable point sizing"},sizeRange:{type:"array",default:[3,15]},pointRadius:{type:"number",default:5},pointOpacity:{type:"number",default:.8}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["quadrants"]}},MultiAxisLineChart:{name:"MultiAxisLineChart",category:"xy",description:"Dual Y-axis line chart for comparing two series with different scales on the same x axis. Data is unitized (normalized to [0,1]) internally; left axis shows series[0] values and right axis shows series[1] values in original units. Falls back to standard multi-line if not exactly 2 series.",required:["series"],dataShape:"array",dataAccessors:["xAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects shared by both series"},xAccessor:{type:["string","function"],default:"x",description:"Key for x values"},series:{type:"array",description:"Exactly 2 series configs for dual-axis mode. Each: { yAccessor, label?, color?, format?, extent? }"},colorScheme:{type:["string","array"]},curve:{type:"string",default:"monotoneX"},lineWidth:{type:"number",default:2}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["dual-axis","hoc-ssr-only"]}},CandlestickChart:{name:"CandlestickChart",category:"xy",description:"OHLC candlestick bars, or a range chart when open/close are omitted. Honors mode (primary/context/sparkline). Range variant degrades cleanly: endpoint dots + wick, sized against canvas height so sparkline rows don't render marble-sized dots.",required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array"},xAccessor:{type:["string","function"],default:"x"},highAccessor:{type:["string","function"],default:"high",description:"Required. Upper bound (candlestick high or range top)."},lowAccessor:{type:["string","function"],default:"low",description:"Required. Lower bound (candlestick low or range bottom)."},openAccessor:{type:["string","function"],description:"Optional. Pair with closeAccessor for OHLC; omit both to render a range chart."},closeAccessor:{type:["string","function"],description:"Optional. See openAccessor."},candlestickStyle:{type:"object",description:"Style overrides."},mode:{type:"string",enum:["primary","context","sparkline"]}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["ohlc"]}},ConnectedScatterplot:{name:"ConnectedScatterplot",category:"xy",description:"Scatterplot where points are connected in order, showing trajectories through 2D space. Viridis-colored start→end, white halo under lines.",required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common","xyAxis"],ownProps:{data:{type:"array",description:"Array of data objects"},xAccessor:{type:["string","function"],default:"x",description:"Key for x-axis values"},yAccessor:{type:["string","function"],default:"y",description:"Key for y-axis values"},orderAccessor:{type:["string","function"],description:"Key for point ordering (number or Date field)"},orderLabel:{type:"string",description:"Label for the ordering metric in tooltips"},pointRadius:{type:"number",default:4,description:"Point radius"},pointIdAccessor:{type:["string","function"],description:"Accessor for unique point IDs, used by point-anchored annotations"},regression:{type:["boolean","string","object"],description:"Overlay a regression line under the connected path. Same shape as Scatterplot's regression prop."},forecast:{type:"object",description:"Forecast overlay config — same shape as LineChart's forecast prop."},anomaly:{type:"object",description:"Anomaly overlay config — ±σ band + anomaly dot annotations."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["regression-overlay","forecast","anomaly","series-features"]}},ScatterplotMatrix:{name:"ScatterplotMatrix",category:"xy",description:"Multi-panel scatterplot grid with crossfilter brushing. Requires data array with numeric fields.",required:["data","fields"],dataShape:"array",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"array"},fields:{type:"array"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!1,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["matrix","brush","composite-delegates-interaction","hoc-ssr-only"]}},MinimapChart:{name:"MinimapChart",category:"xy",description:"Overview + detail chart with linked zoom. Wraps an XY chart with a minimap navigation pane.",required:["data"],dataShape:"array",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"array"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!1,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["brush","overview-detail","composite-delegates-interaction","hoc-ssr-only"]}},ForceDirectedGraph:{name:"ForceDirectedGraph",category:"network",description:"Physics-based node-link diagram. Use for relationships, social networks, knowledge graphs.",required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],propBags:["common"],ownProps:{nodes:{type:"array",description:"Array of node objects"},edges:{type:"array",description:"Array of edge objects with source and target"},nodeIDAccessor:{type:["string","function"],default:"id",description:"Key for node unique identifier"},sourceAccessor:{type:["string","function"],default:"source",description:"Key for edge source node ID"},targetAccessor:{type:["string","function"],default:"target",description:"Key for edge target node ID"},nodeLabel:{type:["string","function"],description:"Key or accessor for node labels"},nodeSize:{type:["number","string","function"],default:8,description:"Fixed node radius or key for variable sizing"},nodeSizeRange:{type:"array",default:[5,20]},edgeWidth:{type:["number","string","function"],default:1,description:"Fixed edge width or key for variable width"},edgeColor:{type:"string",default:"#999"},edgeOpacity:{type:"number",default:.6},iterations:{type:"number",default:300,description:"Force simulation iterations"},forceStrength:{type:"number",default:.1},layoutExecution:{type:"string",enum:["auto","worker","sync"],default:"auto",description:"Force layout execution: auto, worker, or sync"},showLabels:{type:"boolean",default:!1}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["force-simulation"]}},SankeyDiagram:{name:"SankeyDiagram",category:"network",description:"Flow diagram showing weighted connections between nodes. Use for flows, budgets, process mapping.",required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],propBags:["common"],ownProps:{edges:{type:"array",description:"Array of edge objects with source, target, and value"},nodes:{type:"array",description:"Optional array of node objects (auto-derived from edges if omitted)"},sourceAccessor:{type:["string","function"],default:"source"},targetAccessor:{type:["string","function"],default:"target"},valueAccessor:{type:["string","function"],default:"value",description:"Key for edge flow value"},nodeIdAccessor:{type:["string","function"],default:"id"},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"],default:"source",description:"How to color edges"},orientation:{type:"string",enum:UI,default:"horizontal"},nodeAlign:{type:"string",enum:["justify","left","right","center"],default:"justify"},nodePaddingRatio:{type:"number",default:.05},nodeWidth:{type:"number",default:15},nodeLabel:{type:["string","function"],description:"Key for node labels"},showLabels:{type:"boolean",default:!0},edgeOpacity:{type:"number",default:.5},edgeSort:{type:"function",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},ProcessSankey:{name:"ProcessSankey",category:"network",description:"Temporal sankey with a real time x-axis. Edges carry startTime/endTime; nodes can declare an explicit xExtent lifetime. Use for timestamped flow events (PR commits, campaign-finance contributions, supply-chain shipments).",required:["domain"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],propBags:["common"],ownProps:{edges:{type:"array",description:"Array of timed edge records with source, target, value, startTime, endTime. Omit for push-mode."},nodes:{type:"array",description:"Optional array of node objects. Nodes may carry an `xExtent: [start, end]` to bound the lane explicitly."},domain:{type:"array",description:"[tStart, tEnd] of the chart's x-axis (required)."},axisTicks:{type:"array",description:"Optional [{ date, label }] tick array for the time axis."},sourceAccessor:{type:["string","function"],default:"source"},targetAccessor:{type:["string","function"],default:"target"},valueAccessor:{type:["string","function"],default:"value"},nodeIdAccessor:{type:["string","function"],default:"id"},startTimeAccessor:{type:["string","function"],default:"startTime"},endTimeAccessor:{type:["string","function"],default:"endTime"},xExtentAccessor:{type:["string","function"],default:"xExtent"},edgeIdAccessor:{type:["string","function"],default:"id"},legendPosition:{type:"string",enum:["right","left","top","bottom"],default:"right"},pairing:{type:"string",enum:["value","temporal"],default:"temporal",description:"Edge-side pairing strategy at transit nodes."},packing:{type:"string",enum:["off","reuse"],default:"reuse",description:"Lane reuse — pack lifetime-disjoint nodes into the same row."},laneOrder:{type:"string",enum:["insertion","crossing-min","inside-out","crossing-min+inside-out"],default:"crossing-min"},ribbonLane:{type:"string",enum:["source","target","both"],default:"both"},lifetimeMode:{type:"string",enum:["full","half"],default:"half"},showLaneRails:{type:"boolean",default:!1},showQualityReadout:{type:"boolean",default:!1},edgeOpacity:{type:"number",default:.35},timeFormat:{type:"function",omitFromSchema:!0},valueFormat:{type:"function",omitFromSchema:!0},showParticles:{type:"boolean",default:!1},particleStyle:{type:"object",description:"ParticleStyle config — same shape as SankeyDiagram. Defaults from DEFAULT_PARTICLE_STYLE (radius 3, opacity 0.7, spawnRate 0.1, maxPerEdge 50)."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"custom",specialFeatures:["temporal","particles","lane-reuse"]}},ChordDiagram:{name:"ChordDiagram",category:"network",description:"Circular diagram showing inter-relationships and flow volumes between groups.",required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],propBags:["common"],ownProps:{edges:{type:"array",description:"Array of edge objects with source, target, and value"},nodes:{type:"array",description:"Optional array of node objects"},sourceAccessor:{type:["string","function"],default:"source"},targetAccessor:{type:["string","function"],default:"target"},valueAccessor:{type:["string","function"],default:"value"},nodeIdAccessor:{type:["string","function"],default:"id"},edgeColorBy:{type:["string","function"],enum:["source","target"],default:"source"},padAngle:{type:"number",default:.01},groupWidth:{type:"number",default:20},sortGroups:{type:"function",omitFromSchema:!0},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean",default:!0},edgeOpacity:{type:"number",default:.5}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:[]}},TreeDiagram:{name:"TreeDiagram",category:"network",description:"Hierarchical tree layout. Supports tree, cluster, partition, and radial orientations. Data is a single root node with children.",required:["data"],dataShape:"object",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"object",description:"Root node object with nested children"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"],default:"tree"},orientation:{type:"string",enum:["vertical","horizontal","radial"],default:"vertical"},childrenAccessor:{type:["string","function"],default:"children",description:"Key for the children array in each node"},valueAccessor:{type:["string","function"],default:"value"},nodeIdAccessor:{type:["string","function"],default:"name"},colorByDepth:{type:"boolean",default:!1,description:"Color nodes by their depth in the hierarchy"},edgeStyle:{type:"string",enum:["line","curve"],default:"curve"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean",default:!0},nodeSize:{type:"number",default:5}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["hierarchy"]}},Treemap:{name:"Treemap",category:"network",description:"Space-filling rectangular hierarchy visualization. Data is a single root node with nested children.",required:["data"],dataShape:"object",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"object",description:"Root node object with nested children"},childrenAccessor:{type:["string","function"],default:"children"},valueAccessor:{type:["string","function"],default:"value"},nodeIdAccessor:{type:["string","function"],default:"name"},colorByDepth:{type:"boolean",default:!1},showLabels:{type:"boolean",default:!0},nodeLabel:{type:["string","function"]},nodeStyle:{type:"function",omitFromSchema:!0,description:"Per-node style overlay merged on top of Treemap's built-in color encoding"}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["hierarchy"]}},CirclePack:{name:"CirclePack",category:"network",description:"Nested circles representing hierarchical data. Data is a single root node with nested children.",required:["data"],dataShape:"object",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"object",description:"Root node object with nested children"},childrenAccessor:{type:["string","function"],default:"children"},valueAccessor:{type:["string","function"],default:"value"},nodeIdAccessor:{type:["string","function"],default:"name"},colorByDepth:{type:"boolean",default:!1},showLabels:{type:"boolean",default:!0},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number",default:.7}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["hierarchy"]}},OrbitDiagram:{name:"OrbitDiagram",category:"network",description:"Animated orbital diagram showing hierarchical data as nodes orbiting a center. Supports flat, solar, atomic, and custom ring arrangements.",required:["data"],dataShape:"object",dataAccessors:[],propBags:["common"],ownProps:{data:{type:"object",description:"Hierarchical root object with children: { name: 'root', children: [...] }"},childrenAccessor:{type:["string","function"],default:"children",description:"Key to access children from each datum"},nodeIdAccessor:{type:["string","function"],default:"name",description:"Key to identify each node"},colorByDepth:{type:"boolean",default:!1,description:"Color by hierarchy depth"},orbitMode:{type:["string","array"],default:"flat",description:"Ring arrangement: 'flat', 'solar', 'atomic', or number[]"},orbitSize:{type:["number","function"],default:2.95,description:"Ring size divisor per depth"},speed:{type:"number",default:.25,description:"Orbit speed in degrees per frame"},eccentricity:{type:["number","function"],default:1,description:"Vertical squash for elliptical orbits (1 = circle)"},showRings:{type:"boolean",default:!0,description:"Show orbital ring paths"},nodeRadius:{type:["number","function"],default:6,description:"Node radius"},showLabels:{type:"boolean",default:!1,description:"Show node labels"},animated:{type:"boolean",default:!0,description:"Enable animation"},revolution:{type:"function",omitFromSchema:!0},foregroundGraphics:{type:"object",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["hierarchy","animated","hoc-ssr-only"]}},ChoroplethMap:{name:"ChoroplethMap",category:"geo",description:"Geographic choropleth map with colored regions based on data values.",required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],propBags:["common"],ownProps:{areas:{type:["array","string"],description:"GeoJSON features or reference geography name"},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string",default:"equalEarth"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!0,colorModel:"sequential",layoutMode:"plugin",specialFeatures:["controlled-prop-streaming"]}},ProportionalSymbolMap:{name:"ProportionalSymbolMap",category:"geo",description:"Geographic map with sized symbols at point locations.",required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],propBags:["common"],ownProps:{points:{type:"array"},xAccessor:{type:["string","function"],default:"lon"},yAccessor:{type:["string","function"],default:"lat"},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"sequential",layoutMode:"plugin",specialFeatures:[]}},FlowMap:{name:"FlowMap",category:"geo",description:"Geographic flow map showing movement between locations with animated particles.",required:["flows"],dataShape:"array",dataAccessors:[],propBags:["common"],ownProps:{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]},lineIdAccessor:{type:["string","function"]}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["particles"]}},DistanceCartogram:{name:"DistanceCartogram",category:"geo",description:"Cartogram distorting geographic positions based on travel time or cost from a center point.",required:["points"],dataShape:"array",dataAccessors:[],propBags:["common"],ownProps:{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["distortion","hoc-ssr-only"]}},RealtimeLineChart:{name:"RealtimeLineChart",category:"realtime",description:"Streaming line chart rendered on canvas. Uses ref-based push API for high-frequency data.",required:[],dataShape:"realtime",dataAccessors:[],propBags:["realtime"],ownProps:{stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},transition:{type:"object",description:"Transition config: { duration, easing }"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["live-stream"]}},RealtimeHistogram:{name:"RealtimeHistogram",category:"realtime",description:"Streaming bar chart with binned aggregation. Uses ref-based push API.",required:["binSize"],dataShape:"realtime",dataAccessors:[],propBags:["realtime"],ownProps:{binSize:{type:"number",description:"Time bin size in milliseconds (required)"},direction:{type:"string",enum:["up","down"],default:"up",description:'Bar growth direction. Use "down" for mirrored histograms; explicit valueExtent is reversed.'},categoryAccessor:{type:["string","function"],description:"Key for category grouping"},colors:{type:"object",description:"Map of category to color string"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"],description:'Enable brush selection. true defaults to { dimension: "x", snap: "bin" }. String: "x". Object: { dimension, snap: "continuous"|"bin", snapDuring }.'},onBrush:{type:"function",description:"Callback when brush extent changes: (extent | null) => void"},linkedBrush:{type:["string","object"],description:"Cross-chart brush coordination via LinkedCharts. String: selection name. Object: { name, xField, yField }."},transition:{type:"object",description:"Transition config: { duration, easing }"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["live-stream","brush"]}},TemporalHistogram:{name:"TemporalHistogram",category:"realtime",description:"Static-data temporal histogram with binned aggregation. Use when data is a bounded array rather than a push stream.",required:["data","binSize"],dataShape:"array",dataAccessors:["timeAccessor","valueAccessor","categoryAccessor"],propBags:[],ownProps:{data:{type:"array",description:"Array of temporal observations"},binSize:{type:"number",description:"Time bin size in milliseconds (required)"},size:{type:"array",description:"[width, height] in pixels"},width:{type:"number",description:"Alias for size[0]"},height:{type:"number",description:"Alias for size[1]"},margin:{type:"object",description:'Object margin. A side value of "auto" or null leaves that side available for auto-reservation.'},className:{type:"string"},timeAccessor:{type:["string","function"],description:"Key for time/x values"},valueAccessor:{type:["string","function"],description:"Key for y values"},direction:{type:"string",enum:["up","down"],default:"up",description:'Bar growth direction. Use "down" for mirrored histograms; explicit valueExtent is reversed.'},categoryAccessor:{type:["string","function"],description:"Key for category grouping"},colors:{type:"object",description:"Map of category to color string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"],description:"Tooltip content function or config"},tooltipContent:{type:"function",omitFromSchema:!0},onHover:{type:"function",omitFromSchema:!0},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"],description:"Opt-in annotation placement pass for note-like annotations without manual offsets."},responsiveRules:{type:"array",description:"Semantic responsive transforms applied before chart-mode defaults."},mobileSemantics:{type:"object",description:"Phone/mobile contract consumed by audits, recipes, adapters, and agents."},mobileInteraction:{type:["boolean","object"],description:"Touch-first interaction policy for phone-sized chart slots."},svgAnnotationRules:{type:"function",omitFromSchema:!0},tickFormatTime:{type:"function",omitFromSchema:!0},tickFormatValue:{type:"function",omitFromSchema:!0},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},linkedHover:{type:["boolean","string","object"]},linkedBrush:{type:["string","object"],description:"Cross-chart brush coordination via LinkedCharts. String: selection name. Object: { name, xField, yField }."},brush:{type:["boolean","string","object"],description:'Enable brush selection. true defaults to { dimension: "x", snap: "bin" }. String: "x". Object: { dimension, snap: "continuous"|"bin", snapDuring }.'},onBrush:{type:"function",description:"Callback when brush extent changes: (extent | null) => void",omitFromSchema:!0}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!1,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["brush"]}},RealtimeSwarmChart:{name:"RealtimeSwarmChart",category:"realtime",description:"Streaming swarm/scatter chart showing individual data points over time.",required:[],dataShape:"realtime",dataAccessors:[],propBags:["realtime"],ownProps:{categoryAccessor:{type:["string","function"]},colors:{type:"object"},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},pointStyle:{type:"function",description:"Per-datum style callback. Overrides fill, stroke, strokeWidth, opacity, and radius via r.",omitFromSchema:!0},yScaleType:{type:"string",enum:["linear","log","symlog"],description:"Value-axis scale. symlog preserves zero and negative values while compressing large magnitudes."},transition:{type:"object",description:"Transition config: { duration, easing }"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["live-stream"]}},RealtimeWaterfallChart:{name:"RealtimeWaterfallChart",category:"realtime",description:"Streaming waterfall chart with positive/negative bars and connectors.",required:[],dataShape:"realtime",dataAccessors:[],propBags:["realtime"],ownProps:{positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},transition:{type:"object",description:"Transition config: { duration, easing }"}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"categorical",layoutMode:"plugin",specialFeatures:["live-stream"]}},RealtimeHeatmap:{name:"RealtimeHeatmap",category:"realtime",description:"Streaming 2D heatmap with binned time and value aggregation.",required:[],dataShape:"realtime",dataAccessors:[],propBags:["realtime"],ownProps:{heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!0,supportsLinkedHover:!0,supportsPush:!0,supportsSSR:!1,colorModel:"sequential",layoutMode:"plugin",specialFeatures:["live-stream"]}},GaltonBoardChart:{name:"GaltonBoardChart",category:"physics",description:"Physics-backed Galton board / Plinko-style dot distribution. Values enter deterministic bins and settle into a readable histogram-like projection; mechanical mode can generate a seeded no-data demonstration.",required:[],dataShape:"array",dataAccessors:["valueAccessor"],propBags:["physics"],ownProps:{valueAccessor:{type:["string","function"],default:"value",description:"Numeric field used to assign bodies to Galton bins."},valueExtent:{type:"array",description:"Stable numeric [min, max] domain for binning and reference-line placement."},bins:{type:"number",default:21,description:"Number of landing bins / histogram columns."},mode:{type:"string",enum:["sample","mechanical"],default:"sample",description:"sample uses data values; mechanical emits a deterministic demonstration when no data is supplied."},pegRows:{type:"number",description:"Number of Bernoulli branch rows used by mechanical mode."},mechanicalCount:{type:"number",description:"Number of generated bodies in mechanical mode."},branchProbability:{type:"number",default:.5,description:"Probability that each mechanical sample branches right at a peg."},referenceLines:{type:["object","array"],description:"One or more value markers drawn over the board: { value, label, color, strokeWidth, strokeDasharray, labelPosition }."},showProjection:{type:"boolean",description:"Whether companion docs or wrappers should show the settled projection."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","settled-projection","deterministic-seed"]}},EventDropChart:{name:"EventDropChart",category:"physics",description:"Physics-backed event-time drop chart for arrival replay, window barriers, and late/watermark handling.",required:["data"],dataShape:"array",dataAccessors:["timeAccessor","arrivalAccessor"],propBags:["physics"],ownProps:{timeAccessor:{type:["string","function"],default:"time",description:"Event-time field used to assign drops to windows."},arrivalAccessor:{type:["string","function"],default:"arrivalTime",description:"Arrival-time field used to pace event ingestion."},windows:{type:"object",description:"Windowing config, currently { size, gapPolicy? }."},watermark:{type:["object","function"],description:"Watermark config: { delay }, { value }, or a function of latest event time."},timeExtent:{type:"array",description:"Optional stable event-time extent [min, max] for the window layout."},timeScale:{type:"number",default:1,description:"Playback speed for event-arrival pacing; higher is faster (1 = real event-time)."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","event-time","watermark","arrival-pacing","settled-projection"]}},PhysicsPileChart:{name:"PhysicsPileChart",category:"physics",description:"Physics-backed unit pile chart. Numeric values are unitized into repeated bodies that settle into category piles.",required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],propBags:["physics"],ownProps:{categoryAccessor:{type:["string","function"],default:"category",description:"Categorical field that chooses the pile / bin."},valueAccessor:{type:["string","function"],default:"value",description:"Numeric field converted into repeated unit bodies."},mode:{type:"string",enum:["sample","mechanical"],default:"sample",description:"sample uses data values; mechanical emits a deterministic no-data unit pile for design sketches."},mechanicalCount:{type:"number",description:"Number of generated unit bodies in mechanical mode."},mechanicalCategories:{type:"array",description:"Category labels generated by mechanical mode."},unitValue:{type:"number",default:1,description:"Value represented by one simulated body."},showProjection:{type:"boolean",default:!0,description:"Draw an exact settled-projection overlay behind the moving units so category totals remain readable."},sediment:{type:"boolean",description:"Reserved for future sediment/aggregation mode."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","unitized","settled-projection"]}},CollisionSwarmChart:{name:"CollisionSwarmChart",category:"physics",description:"Physics-backed swarm / dot-strip chart. Quantitative records spring toward an x-position while collisions separate overlapping dots into a readable distribution.",required:[],dataShape:"array",dataAccessors:["xAccessor","groupAccessor","radiusAccessor"],propBags:["physics"],ownProps:{xAccessor:{type:["string","function"],default:"x",description:"Quantitative field that anchors each body along the x-axis."},groupAccessor:{type:["string","function"],description:"Optional categorical field that creates separate swarm lanes."},radiusAccessor:{type:["string","function"],description:"Optional numeric field used as per-body radius in pixels."},pointRadius:{type:"number",default:5,description:"Fallback radius for each simulated body."},xExtent:{type:"array",description:"Optional [min, max] domain for the quantitative axis."},collisionIterations:{type:"number",default:6,description:"Collision solver iterations per fixed physics step."},settle:{type:"boolean",description:"Start bodies near their target positions for a calmer first paint or reduced-motion demo."},showProjection:{type:"boolean",default:!0,description:"Draw x-axis and group-lane guides behind the moving bodies."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","collision-layout","settled-projection"]}},GauntletChart:{name:"GauntletChart",category:"physics",description:"Physics-backed compound-plan gauntlet. A project core carries tethered positive/negative property bodies through timed gate events; settled projection is viability and outcome, not trajectories.",required:["negativeProperties"],dataShape:"array",dataAccessors:["idAccessor","positiveAccessor","negativeAccessor","metricsAccessor","startTimeAccessor"],propBags:["physics"],ownProps:{positiveProperties:{type:"array",default:[],description:"Optional lift/value property definitions attached to each project core. Omit or pass an empty array for negative-only compound bodies."},negativeProperties:{type:"array",description:"Drag/cost property definitions attached to each project core."},gates:{type:"array",description:"Named process gates along the route, with optional shared FIFO capacity."},events:{type:["array","function"],description:"Timed gate effects that add/pop properties and set outcomes."},startTimeAccessor:{type:["string","function"],description:"Optional per-project simulation second used as the local event-timeline origin."},onCapacityChange:{type:"function",description:"Receives visit-aware queue work, wait, overflow, throughput, utilization, and pressure snapshots."},crashDetection:{type:"boolean",default:!0,description:"Treat the crash line as a live failure trigger."},showChrome:{type:"boolean",default:!0,description:"Draw route, socket, and graveyard chrome."},showProjection:{type:"boolean",default:!0,description:"Draw settled viability/outcome strip."},showTethers:{type:"boolean",default:!0,description:"Draw tethers between cores and property bodies."},coreForceMode:{type:"string",enum:["route","net"],default:"route",description:"Core-body vertical force model: authored route guidance or net lift/drag drift."},terminalBehavior:{type:"string",enum:["outcome","hold-last"],default:"outcome"}},capabilities:{renderModes:["hybrid"],supportsLegend:!1,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","process-gauntlet","settled-projection"]}},ProcessFlowChart:{name:"ProcessFlowChart",category:"physics",description:"Physics-backed multi-body process flow. Work items move through ordered stages with optional capacity, pressure, portals, absorb sinks, and feature groups that complete only when every member is absorbed.",required:["stages"],dataShape:"array",dataAccessors:["idAccessor","stageAccessor","groupBy","workAccessor","radiusAccessor"],propBags:["physics"],ownProps:{stages:{type:"array",description:"Ordered process stages: { id, label?, force?, damping?, capacity?, pressure?, portal?, absorb? }."},stageAccessor:{type:["string","function"],default:"stage",description:"Field or accessor for each work item's current stage id."},idAccessor:{type:["string","function"],description:"Stable work-item id."},groupBy:{type:["string","function"],description:"Optional feature/group key. Groups complete when all members reach an absorb stage."},groupLabelAccessor:{type:["string","function"],description:"Display label for group anchors."},workAccessor:{type:["string","function"],description:"Work-units field stamped for capacity metadata."},radiusAccessor:{type:["string","function"],description:"Optional per-body radius in pixels."},ballRadius:{type:"number",default:6,description:"Fallback body radius."},groupCompletion:{type:"string",enum:["allAbsorbed","none"],default:"allAbsorbed when groupBy is set",description:"How feature groups report completion."},groupAnchorAlong:{type:"number",description:"0–1 position along the lane for group anchors."},showProjection:{type:"boolean",default:!0,description:"Draw settled stage-count bars."},showChrome:{type:"boolean",default:!0,description:"Draw stage labels, capacity notes, and group anchors."},settle:{type:"boolean",description:"Start bodies at stage targets for a calmer first paint."},seed:{type:"number",default:1,description:"Deterministic seed for placement jitter."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","process-flow","capacitated-stages","group-completion","settled-projection"]}},PhysicalFlowChart:{name:"PhysicalFlowChart",category:"physics",description:"Experimental physics-backed flow chart. Packets move along authored node coordinates or link paths while a static throughput layer keeps the route quantities readable.",required:[],dataShape:"network",dataAccessors:["nodeIdAccessor","nodeXAccessor","nodeYAccessor","sourceAccessor","targetAccessor","throughputAccessor","pathAccessor"],propBags:["common"],ownProps:{size:{type:"array",description:"[width, height] in pixels"},nodes:{type:"array",description:"Route nodes with explicit x/y geometry. x/y may be normalized 0-1 coordinates or chart pixels."},links:{type:"array",description:"Flow links with source, target, throughput, and optional path geometry."},edges:{type:"array",description:"Alias for links, for network-shaped inputs."},data:{type:"array",description:"Alias for links when using chart-generator style data props."},nodeIdAccessor:{type:["string","function"],default:"id",description:"Key for node unique identifier."},nodeXAccessor:{type:["string","function"],default:"x",description:"Node x-coordinate. Use 0-1 normalized values by default."},nodeYAccessor:{type:["string","function"],default:"y",description:"Node y-coordinate. Use 0-1 normalized values by default."},sourceAccessor:{type:["string","function"],default:"source",description:"Link source node id."},targetAccessor:{type:["string","function"],default:"target",description:"Link target node id."},throughputAccessor:{type:["string","function"],default:"value",description:"Numeric throughput field that controls pipe width and packet count."},pathAccessor:{type:["string","function"],default:"path",description:"Optional link path as [{x,y}, ...] or [[x,y], ...]."},coordinateMode:{type:"string",enum:["auto","normalized","pixels"],default:"auto",description:"How node and path coordinates are mapped into the plot area."},particleRate:{type:"number",default:.16,description:"Packets generated per throughput unit before maxParticles downsampling."},maxParticles:{type:"number",default:180,description:"Maximum live packets generated for the initial flow scene."},particleRadius:{type:"number",default:4,description:"Packet body radius in pixels."},flowSpeed:{type:"number",default:90,description:"Initial packet velocity along each authored route."},pathConstraint:{type:"string",enum:["path","none"],default:"path",description:"Whether live packets are steered along authored route paths."},reducedMotion:{type:"boolean",default:!1,description:"Start packets on their route positions and pause the simulation."},showStaticFlow:{type:"boolean",default:!0,description:"Draw the route/pipe throughput layer behind animated packets."},showNodeLabels:{type:"boolean",default:!0},showSensors:{type:"boolean",default:!1,description:"Draw destination/node proximity sensors used for observation events."},paused:{type:"boolean",default:!1,description:"Pause the physics simulation."},seed:{type:"number",default:1,description:"Deterministic seed for packet jitter and initial flow."}},capabilities:{renderModes:["hybrid"],supportsLegend:!0,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!0,colorModel:"categorical",layoutMode:"synthetic",specialFeatures:["physics-simulation","path-constrained-flow","static-flow","proximity-sensors","settled-projection"]}},BigNumber:{name:"BigNumber",category:"value",description:"Focal-value display: one number, optionally with comparison / target / threshold zones (mapped to semantic theme roles) / four layout modes (tile / presentation / inline / thumbnail). Ships with NO chart-family dependency — embed your own Semiotic chart via two slots: `trendSlot` for wide / rectangular charts (LineChart, AreaChart) under the value, and `chartSlot` for square charts (DonutChart, PieChart, Scatterplot, Treemap) beside the value. The slot context exposes the resolved threshold colour + sentiment + push buffer so embedded charts can theme-link. Forward-looking POC for a future SingleValueFrame.",required:[],dataShape:"none",dataAccessors:[],propBags:[],ownProps:{width:{type:["number","string"],default:280,description:"Reserved width in pixels (or any CSS length). Mode-keyed defaults: 280 (tile) / 540 (presentation) / unset (inline / thumbnail)."},height:{type:["number","string"],default:184,description:"Reserved height in pixels (or any CSS length). Mode-keyed defaults: 184 (tile) / 320 (presentation) / unset (inline / thumbnail)."},className:{type:"string",description:"Composed with the BEM root class on the outer container."},value:{type:"number",description:"The focal number this card exists to display"},label:{type:"string",description:"Top-line descriptor rendered above the value"},caption:{type:"string",description:"Secondary descriptor, smaller, below the label"},format:{type:["string","function"],enum:["number","currency","percent","compact","duration"],default:"number",description:"Number-format shortcut or custom (value) => string"},locale:{type:"string",default:"en-US",description:"BCP-47 locale for Intl.NumberFormat"},currency:{type:"string",default:"USD",description:'ISO 4217 code for format: "currency"'},precision:{type:"number",description:"maximumFractionDigits passed to Intl.NumberFormat"},prefix:{type:"string",description:"Prepend to formatted value"},suffix:{type:"string",description:"Append to formatted value"},unit:{type:"string",description:'Unit label rendered after the value as small text (e.g. "USD", "req/s")'},comparison:{type:"object",description:"Comparison value: { value, label?, format?, direction? }. Drives the delta when explicit delta is not set."},target:{type:"object",description:'Target value: { value, label?, format?, direction? }. Renders "X% of target" next to the comparison row.'},delta:{type:"number",description:"Explicit delta override; bypasses comparison-derived subtraction"},deltaFormat:{type:["string","function"],enum:["number","currency","percent","compact","duration"],description:"Format the delta; defaults to format"},showDeltaPercent:{type:"boolean",default:!0,description:"Render percent change next to absolute delta when a comparison is present"},direction:{type:"string",enum:["higher-is-better","lower-is-better","neutral"],default:"higher-is-better",description:"Default direction used to infer sentiment from the sign of the delta"},sentiment:{type:"string",enum:["auto","positive","negative","neutral"],default:"auto",description:'Force sentiment; "auto" infers from direction + delta sign'},thresholds:{type:"array",description:"Threshold zones: [{ at, level, color?, label? }] ordered ascending by `at`. Resolved by highest `at` ≤ value. `level` maps to a semantic CSS variable (--semiotic-{success|warning|danger|info})."},chartSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:"Square chart to render beside the value — e.g. a DonutChart / PieChart / Scatterplot / Treemap. ReactNode or (ctx) => ReactNode; the function form receives the resolved level / color / sentiment / pushBuffer."},chartSize:{type:"number",description:"Pixel size reserved for chartSlot (rendered as a square). Mode-keyed defaults: 44 (tile) / 80 (presentation) — sparkline scale; pass a larger value for a hero anchor."},windowSize:{type:"number",default:60,description:"Cap on the trend buffer when fed via push API"},mode:{type:"string",enum:["tile","presentation","inline","thumbnail"],default:"tile",description:"Layout mode — chrome envelope around the value"},align:{type:"string",enum:["start","center","end"],description:"Horizontal alignment within the card"},padding:{type:["number","object"],description:"Inner padding: number for uniform, or { top, right, bottom, left }"},emphasis:{type:"string",enum:["primary","secondary"],description:'Visual emphasis hint; "primary" spans two ChartGrid columns'},color:{type:"string",description:"Override the value text colour. CSS variables work."},background:{type:"string",description:"Card background. CSS variables work."},borderColor:{type:"string"},borderRadius:{type:["number","string"]},animate:{type:["boolean","object"],description:'Tween between value changes. true = 300ms ease-out + intro. Object: { duration?, easing?: "linear"|"ease-out", intro? }'},stalenessThreshold:{type:"number",description:"Mark stale (dimmed) when no push occurs for this many ms"},staleLabel:{type:"string",default:"stale"},headerSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:"Replace the entire header (label + caption) slot"},valueSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:"Replace the focal value slot"},deltaSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:"Replace the delta / comparison / target row"},trendSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:'Wide / rectangular chart embedded beneath the value — e.g. a LineChart / AreaChart in mode="sparkline". ReactNode or (ctx) => ReactNode; the function form receives the resolved level / color / sentiment / pushBuffer.'},footerSlot:{type:["string","number","array","object","function"],omitFromSchema:!0,description:"Free-form footer below the trend"},onClick:{type:"function",omitFromSchema:!0},onObservation:{type:"function",omitFromSchema:!0}},capabilities:{renderModes:["svg"],supportsLegend:!1,supportsSelection:!1,supportsLinkedHover:!1,supportsPush:!0,supportsSSR:!1,colorModel:"threshold",layoutMode:"synthetic",specialFeatures:["threshold-zones","value-only","comparison","target","staleness","intl-format","chart-slot","trend-slot","hoc-ssr-only"]}}}).map(([e,t])=>[e,e_(t)]));function o_(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function r_(e,t){const o=[];null!=t&&"object"==typeof t||(t={});const r=t_[e];if(!r)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(t_).join(", ")}`]};for(const n of r.required)null==t[n]&&o.push(`"${n}" is required for ${e}.`);"array"!==r.dataShape||!Object.prototype.hasOwnProperty.call(r.props,"data")||r.required.includes("data")||function(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"PhysicsPileChart"===e)}(e,t)||null!=t.data||o.push(`"data" is required for ${e}.`);for(const[e,n]of Object.entries(t)){if(null==n)continue;const t=r.props[e];if(t){if(!o_(n,t.type)){const r=Array.isArray(t.type)?t.type.join(" | "):t.type;o.push(`"${e}" should be ${r}, got ${Array.isArray(n)?"array":typeof n}.`);continue}t.enum&&"string"==typeof n&&!t.enum.includes(n)&&o.push(`"${e}" value "${n}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const n=Object.keys(r.props),i=new Set(n);for(const r of Object.keys(t))if(void 0!==t[r]&&!i.has(r)){const t=Gu(r,n),i=t?`Unknown prop "${r}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${r}" for ${e}. Valid props: ${n.join(", ")}.`;o.push(i)}if("array"===r.dataShape){const n=t.data,i={};for(const e of r.dataAccessors){const o=t[e];"string"==typeof o&&(i[e]=o)}const a=Xu({componentName:e,data:n,accessors:Object.keys(i).length>0?i:void 0});a&&o.push(a)}else if("object"===r.dataShape){const r=Uu({componentName:e,data:t.data});r&&o.push(r)}else if("network"===r.dataShape){const n=Ku({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:r.required.includes("nodes"),edgesRequired:r.required.includes("edges")});n&&o.push(n)}return{valid:0===o.length,errors:o}}var n_=["value","threshold","partition-boundary","time-window","range-boundary"];function i_(e,t,o,r,n){return{id:e,...t?{controlId:t}:{},status:o,message:r,...n?{remediation:n}:{}}}function a_({controls:e=[],minimumTargetSize:t=24}){const o=[],r=new Set;for(const n of e){const e=n?.id,i="controls."+(e||"unknown"),a=n?.domain,s=Array.isArray(a)&&2===a.length&&Number.isFinite(a[0])&&Number.isFinite(a[1])&&a[1]>a[0],l=n_.includes(n?.type),c="string"==typeof n?.target&&n.target.trim().length>0,u=["slider","buttons","native-range"].includes(n?.keyboard??""),d=n?.minimumTargetSize;o.push(i_(i+".semantic-type",e,l?"pass":"fail",l?`Control uses the semantic type "${n.type}".`:"Control has no recognized semantic type.","Use one of VISUALIZATION_CONTROL_TYPES.")),o.push(i_(i+".state-binding",e,c?"pass":"fail",c?`Control is bound to "${n.target}".`:"Control has no declarative state binding.","Declare the controlled state key with target.")),o.push(i_(i+".domain",e,s?"pass":"fail",s?"Control has a finite ordered value domain.":"Control has no finite ordered value domain.","Declare domain as [minimum, maximum].")),o.push(i_(i+".keyboard",e,u?"pass":"fail",u?`Control declares a ${n.keyboard} keyboard path.`:"Control does not declare a keyboard path.","Declare slider, buttons, or native-range keyboard interaction.")),o.push(i_(i+".value-text",e,"string"==typeof n?.valueText&&n.valueText.trim().length>0?"pass":"fail","string"==typeof n?.valueText&&n.valueText.trim().length>0?"Control declares human-readable value text.":"Control does not declare human-readable value text.","Provide valueText, typically with a {value} placeholder.")),o.push(i_(i+".target-size",e,"number"!=typeof d||t>d?"fail":"pass","number"!=typeof d||t>d?`Control target is below the ${t}px minimum or undeclared.`:`Control declares a ${d}px target.`,`Declare minimumTargetSize of at least ${t}.`)),null!=n?.step&&o.push(i_(i+".step",e,Number.isFinite(n.step)&&n.step>0?"pass":"fail",Number.isFinite(n.step)&&n.step>0?"Control has a positive quantization step.":"Control step must be a positive finite number.","Use a positive finite step.")),n?.observations?.length&&o.push(i_(i+".observations",e,n.observations.includes("control-change")?"pass":"warn",n.observations.includes("control-change")?"Control declares control-change observation coverage.":"Control declares observations but omits control-change.","Include control-change so observable state changes are represented.")),e&&!r.has(e)||o.push(i_(i+".identity",e,"fail",e?"Control id is duplicated.":"Control id is missing.","Use a unique stable control id.")),e&&r.add(e)}return{ok:o.every(e=>"fail"!==e.status),findings:o}}function s_(e){return l_(e),e}function l_(e){if(!e||"object"!=typeof e)throw Error("Chart recipe must be an object.");if("string"!=typeof e.id||""===e.id.trim())throw Error("Chart recipe requires a non-empty id.");if("string"!=typeof e.name||""===e.name.trim())throw Error(`Chart recipe "${e.id}" requires a non-empty name.`);if(!Array.isArray(e.dataRoles)||0===e.dataRoles.length)throw Error(`Chart recipe "${e.id}" requires at least one data role.`);if(!Array.isArray(e.intents)||0===e.intents.length)throw Error(`Chart recipe "${e.id}" requires at least one intent.`);for(const t of e.intents)if("string"!=typeof t&&(!t||"string"!=typeof t.id&&"string"!=typeof t.name))throw Error(`Chart recipe "${e.id}" has an intent without an id or name.`);if(!e.designContract?.whyCustom)throw Error(`Chart recipe "${e.id}" requires designContract.whyCustom.`);if(!e.accessibility||"object"!=typeof e.accessibility)throw Error(`Chart recipe "${e.id}" requires accessibility expectations.`);if(void 0!==e.controls){const t=a_({controls:e.controls}).findings.filter(e=>"fail"===e.status);if(t.length>0)throw Error(`Chart recipe "${e.id}" has invalid controls: ${t.map(e=>e.message).join(" ")}`)}if("portable"===e.portability){if(!c_(e.layout))throw Error(`Portable chart recipe "${e.id}" must reference a registered layout by id.`);const t=e.layoutConfigSchema??e.portabilityConfig?.schema;if(!t)throw Error(`Portable chart recipe "${e.id}" requires a serializable layout config schema.`);if(!u_(t))throw Error(`Portable chart recipe "${e.id}" has a layout config schema that is not JSON-safe.`)}}function c_(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function u_(e,t=new Set){if(null===e)return!0;const o=typeof e;if("string"===o||"boolean"===o)return!0;if("number"===o)return Number.isFinite(e);if("object"!==o)return!1;if(t.has(e))return!1;t.add(e);const r=Array.isArray(e)?e.every(e=>u_(e,t)):Object.entries(e).every(([,e])=>u_(e,t));return t.delete(e),r}function d_(e){return"string"==typeof e?e:e.id??e.name}function h_(e){return"string"==typeof e?3:"number"==typeof e.score&&Number.isFinite(e.score)?Math.max(0,Math.min(5,e.score>1?e.score:5*e.score)):"primary"===e.strength?5:"secondary"===e.strength?3:"supporting"===e.strength?2:3}function p_(e){const t=new Set(e.intents.map(d_));return t.has("geo")?"geo":t.has("hierarchy")?"hierarchy":t.has("flow")?"flow":t.has("relationship")?"network":t.has("distribution")?"distribution":t.has("correlation")?"relationship":t.has("trend")||t.has("composition-over-time")?"time-series":t.has("compare-categories")||t.has("rank")||t.has("part-to-whole")?"categorical":"custom"}function m_(e){const t=Object.values(e.audience?.familiarity??{}),o=t.find(e=>"number"==typeof e);if(void 0!==o)return Math.max(1,Math.min(5,Math.round(o)));const r=t.filter(e=>"string"==typeof e);return r.includes("high")?4:r.includes("medium")?3:r.includes("low")?2:e.reception?.memorableForm?3:2}function f_(e,t){return"nodes"===t?e.network?.nodes??[]:"edges"===t?e.network?.edges??[]:"areas"===t?e.geo?.features??[]:"points"===t?e.geo?.points??[]:"lines"===t?e.geo?.flows??[]:e.data}function g_(e,t,o){return f_(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,o))}function y_(e,t,o){if(t.field&&g_(o,t,t.field))return t.field;if("nodes"===t.source||"edges"===t.source){const e="node-id"===t.role?"id":"edge-source"===t.role?"source":"edge-target"===t.role?"target":void 0;if(e&&g_(o,t,e))return e}switch(t.semanticType){case"quantitative":return o.primary.y??o.primary.size??o.primary.x;case"temporal":return o.primary.time??o.primary.x;case"nominal":case"ordinal":return o.primary.category??o.primary.series;case"identifier":{const e=f_(o,t.source);return["id","key","name"].find(t=>e.some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,t)))}case"geographic":return o.hasGeo?t.field:void 0;default:return t.field}}function b_(e){const t={},o=[];for(const r of e.intents){const e=d_(r);e&&(t[e]=h_(r),"string"!=typeof r&&r.rationale&&o.push(r.rationale))}o.push(...(e.reception?.strengths??[]).map(e=>"Reception strength: "+e));const r=e.reception?.risks??[],n=e.designContract.misuse??[],i=[...e.designContract.caveats??[],...e.caveats??[]];return{component:e.id,displayName:e.name,candidateKind:"recipe",family:p_(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:m_(e),accuracy:4,precision:r.some(e=>/precis|comparison/i.test(e))?2:3},fits:t=>function(e,t){for(const o of e.dataRoles)if(!1!==o.required&&!y_(0,o,t))return`needs data role "${o.role}" (${o.semanticType})`;const o=e.audit?.maxCategories;return"number"==typeof o&&"number"==typeof t.categoryCount&&t.categoryCount>o?`${t.categoryCount} categories exceeds this recipe's declared maximum of ${o}`:null}(e,t),intentScores:t,caveats:()=>[...r,...n,...i],buildProps:t=>function(e,t){const o={};for(const r of e.dataRoles){const e=y_(0,r,t);e&&r.accessor&&(o[r.accessor]=e)}const r={recipeId:e.id,layoutConfig:o};e.frameFamily.startsWith("Network")?(r.nodes=t.network?.nodes??t.data,r.edges=t.network?.edges??[]):e.frameFamily.startsWith("Geo")?(r.areas=t.geo?.features??[],r.points=t.geo?.points??t.data,r.lines=t.geo?.flows??[]):r.data=t.data;const n=e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0);return n&&(r.mobileSemantics=n),r}(e,t),mobile:e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0),recipe:e,positiveRationale:o,whyCustom:{defaultAlternative:e.designContract.defaultAlternative,reason:e.designContract.whyNotDefault??e.designContract.whyCustom,tradeoff:e.designContract.tradeoff??(r.length>0?r[0]:void 0)}}}var v_=Symbol.for("semiotic.chartRecipeRegistry");function x_(){const e=globalThis;return e[v_]||(e[v_]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[v_]}function w_(e){l_(e),x_().recipes.set(e.id,e),x_().capabilities.set(e.id,b_(e))}function k_(e){x_().recipes.delete(e),x_().capabilities.delete(e)}function S_(e){return x_().recipes.get(e)}function A_(){return Array.from(x_().recipes.values())}function C_(e,t){if(!e)throw Error("Recipe layout requires a non-empty id.");if("function"!=typeof t)throw Error(`Recipe layout "${e}" must be a function.`);x_().layouts.set(e,t)}function M_(e){x_().layouts.delete(e)}function P_(e){return x_().layouts.get(e)}function I_(e){return"string"==typeof e?S_(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function __(e){return"string"==typeof e?e:e.id??e.name}function L_(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function R_(e){return Array.isArray(e.data)?e.data:Array.isArray(e.nodes)?e.nodes:Array.isArray(e.points)?e.points:Array.isArray(e.areas)?e.areas:[]}function T_(e,t,o){return o??I_(t.recipe)??I_(t.recipeId)??S_(e)}function N_(e,t,o=[]){const r=e.accessor?t[e.accessor]:void 0;if("string"==typeof r&&r)return r;if(e.field)return e.field;const n=o.find(e=>e&&"object"==typeof e);if(!n)return;const i=Object.entries(n).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?i.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in n):i.find(([,e])=>"string"==typeof e)?.[0]}function $_(e,t){return e.dataRoles.find(e=>e.role===t)}function B_(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function D_(e,t,o,r,n,i={}){const a={...i};if(t)for(const[e,o]of Object.entries(t))a[e]=o;for(const e of o.dataRoles){const o=N_(e,r,n),i=t&&o?t[o]:o;void 0!==i&&(a[e.role]=i)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const o=a[t];return null==o?`{${t}}`:o+""})}var F_=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend","recipe","layout"]),E_=new Set(["data","nodes","edges","points","areas","lines","flows"]);function z_(e,t){return!!E_.has(e)&&("areas"!==e||"string"!=typeof t)}var j_="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function O_(e,t,o){const r=S_(e)??I_(t.recipe)??I_(t.recipeId);if(r)return function(e,t,o){const r=function(e,t,o){const r={};for(const[n,i]of Object.entries(e))if(null!=i&&!F_.has(n)&&"recipeId"!==n&&(t||!z_(n,i)))if("function"==typeof i||i?.$$typeof){if(o)throw Error(`Portable recipe prop "${n}" is not JSON-safe.`)}else if(u_(i))r[n]=j_(i);else if(o)throw Error(`Portable recipe prop "${n}" is not JSON-safe.`);return r}(t,!1!==o?.includeData,"portable"===e.portability),n=e.intents.map(__).filter(e=>!!e),i={name:e.name,intents:n,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!u_(r))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:r,manifest:i,version:"1",createdAt:(new Date).toISOString(),...o?.selections?{selections:o.selections}:{}}}return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:"Recipe contains or may depend on non-serializable local layout callbacks.",warnings:["This config is inspectable but cannot be rendered remotely by CLI or MCP."],props:r,manifest:i,version:"1",createdAt:(new Date).toISOString(),...o?.selections?{selections:o.selections}:{}}}(r,t,o);if(!t_[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(t_).join(", ")}`);const n=!1!==o?.includeData,i={};for(const[e,o]of Object.entries(t))null!=o&&(F_.has(e)||!n&&z_(e,o)||"function"!=typeof o&&(o?.$$typeof||(i[e]=j_(o))));return{component:e,props:i,version:"1",createdAt:(new Date).toISOString(),...o?.selections?{selections:o.selections}:{}}}function H_(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if("ChartRecipe"===e.component||"LocalChartRecipe"===e.component){if(!e.recipeId)throw Error("Invalid chart recipe config: missing recipeId");const t=S_(e.recipeId);if(!t)throw Error(`Unknown chart recipe "${e.recipeId}". Register it before deserializing this config.`);if("LocalChartRecipe"!==e.component&&!1!==e.portable&&"portable"!==t.portability)throw Error(`Chart recipe "${e.recipeId}" is registered as local, not portable.`);return{componentName:"ChartRecipe",props:{...j_(e.props),recipeId:e.recipeId}}}if(!t_[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:j_(e.props)}}function W_(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function q_(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const o=t.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(escape(atob(o)));return JSON.parse(r)}async function G_(e,t="json"){const o="jsx"===t?Y_(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");await navigator.clipboard.writeText(o)}function Y_(e){const{props:t}=e,o=["<"+("LocalChartRecipe"===e.component?"ChartRecipe":e.component)];e.recipeId&&o.push(` recipeId="${e.recipeId}"`);for(const[e,r]of Object.entries(t))if("string"==typeof r)o.push(` ${e}="${r}"`);else if("boolean"==typeof r&&!0===r)o.push(" "+e);else if("boolean"==typeof r&&!1===r)o.push(` ${e}={false}`);else if("number"==typeof r)o.push(` ${e}={${r}}`);else{const t=JSON.stringify(r);o.push(80>t.length?` ${e}={${t}}`:` ${e}={${JSON.stringify(r,null,2)}}`)}return o.push("/>"),o.join("\n")}var V_=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),X_=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),U_=new Set(["PieChart","DonutChart","FunnelChart"]),K_=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function Q_(e,t){return X_.has(e)||U_.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:t.categoryAccessor??t.stepAccessor,dimensionFallback:"category"}:{measure:t.yAccessor??t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function Z_(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const o=e[t];if("string"==typeof o&&o)return o}}function J_(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function eL(e,t){const o={...e};return t.provenance&&(o.provenance=t.provenance),t.lifecycle&&(o.lifecycle=t.lifecycle),o}function tL(){return(new Date).toISOString()}function oL(e,t={}){const o=e.provenance;return{...e,provenance:{...o,...t,createdAt:t.createdAt??o?.createdAt??tL()}}}function rL(e){if(null==e)return null;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=Date.parse(e);return Number.isFinite(t)?t:null}function nL(e){const t=rL(e?.now);if(null!=t)return t;const o=e?.dataExtent;if(o)if(Array.isArray(o)){const e=rL(o[o.length-1]);if(null!=e)return e}else if("max"in o){const e=rL(o.max);if(null!=e)return e}return Date.now()}function iL(e,t,o={}){const r=e?.lifecycle?.freshness,n=rL(e?.provenance?.createdAt),i=function(e){if(null==e)return null;if("number"==typeof e)return e;const t=function(e){const t=/^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/.exec(e);return t?1e3*(3600*(24*parseInt(t[1]||"0",10)+parseInt(t[2]||"0",10))+60*parseInt(t[3]||"0",10)+parseInt(t[4]||"0",10)):0}(e);return t>0?t:null}(e?.lifecycle?.ttlHint);return null==n||null==i?r??"fresh":Qe(t-n,i,o)}function aL(e,t={}){const o=nL(t);return e.map(e=>{const r=iL(e,o,t.thresholds);return{...e,lifecycle:{...e.lifecycle,freshness:r}}})}var sL={fresh:null,aging:.55,stale:.35,expired:.2},lL={fresh:null,aging:null,stale:"4 4",expired:"2 4"};function cL(e,t,o){return e&&o in e?e[o]:t[o]}function uL(e,t={}){const o=nL(t),r=!0===t.showExpiredAnnotations,n=[];for(const i of e){const e=iL(i,o,t.thresholds);if("expired"===e&&!r)continue;const a=cL(t.opacity,sL,e),s=cL(t.strokeDasharray,lL,e),l=t.labelSuffix?.[e],c={...i,lifecycle:{...i.lifecycle,freshness:e}};null!=a&&null==c.opacity&&(c.opacity=a),null!=s&&null==c.strokeDasharray&&(c.strokeDasharray=s),l&&"string"==typeof c.label&&(c.label=c.label+l);const u=i.lifecycle?.anchor;u&&null==c.anchor&&(c.anchor=u),n.push(c)}return n}var dL={proposed:.7,accepted:null,disputed:.7,retracted:.25},hL={proposed:"3 3",accepted:null,disputed:"2 3",retracted:"2 4"},pL={proposed:" (proposed)",accepted:"",disputed:" (?)",retracted:""};function mL(e,t,o){return e&&o in e?e[o]:t[o]}function fL(e,t={}){const o=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,n=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&n.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!o)return!1;const t=e?.provenance?.stableId;return!(t&&n.has(t)&&!r)})}function gL(e,t={}){const o=[];for(const r of fL(e,t)){const e=r?.lifecycle?.status;if(!e){o.push(r);continue}const n=mL(t.opacity,dL,e),i=mL(t.strokeDasharray,hL,e),a=t.labelSuffix?.[e]??pL[e],s={...r};null!=n&&(s.opacity=("number"==typeof s.opacity?s.opacity:1)*n),null!=i&&null==s.strokeDasharray&&(s.strokeDasharray=i),a&&"string"==typeof s.label&&(s.label=s.label+a),o.push(s)}return o}function yL(e,t,o={}){const r=R_(t),n=L_(t),i=o.locale??"en",a="function"==typeof e.description?e.description({data:r,config:n,locale:i}):void 0,s=a?.levels??function(e,t,o,r){const n=B_(e,["nominal","ordinal"]),i=B_(e,["quantitative"]),a=n?N_(n,o,t):void 0,s=i?N_(i,o,t):void 0,l=n?.role??a??"category",c=i?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:h,percent:p}=function(e){try{return{number:new Intl.NumberFormat(e,{maximumFractionDigits:2}),percent:new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:1})}}catch{return{number:new Intl.NumberFormat("en",{maximumFractionDigits:2}),percent:new Intl.NumberFormat("en",{style:"percent",maximumFractionDigits:1})}}}(r),m=new Map;if(a&&s)for(const e of t){const t=(e[a]??"Uncategorized")+"",o=Number(e[s]);Number.isFinite(o)&&m.set(t,(m.get(t)??0)+o)}const f=[...m].sort((e,t)=>t[1]-e[1]),g=f.reduce((e,[,t])=>e+t,0),y=f[0],b=f[1],v=g>0?((y?.[1]??0)+(b?.[1]??0))/g:0,x=e.intents.map(e=>({id:__(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,w=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${k=d,k?k.charAt(0).toUpperCase()+k.slice(1):k}.`,l2:f.length>0?`${f.length} categories total ${h.format(g)}. ${y[0]} accounts for ${h.format(y[1])}${g>0?` (${p.format(y[1]/g)})`:""}${b?`, followed by ${b[0]} at ${h.format(b[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>f.length?y?y[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>v?`The total is distributed across ${f.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${y[0]} and ${b[0]}, which together account for ${p.format(v)}.`,l4:`The chart is intended for ${x??"explanation"}${w?` with a ${w} audience`:""}: ${e.designContract.whyCustom}`};var k}(e,r,n,i),l=o.levels??["l1","l2","l3","l4"],c={};for(const e of l)s[e]&&(c[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>c[e]).filter(e=>!!e).join(" "),d=o.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:u,levels:c,...d?.length?{caveats:d}:{}}}var bL={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value",StreamPhysicsFrame:"physics stream frame",EventDropChart:"event-drop physics chart",GaltonBoardChart:"Galton board chart",PhysicsPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PhysicalFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",PhysicsCustomChart:"custom physics chart"},vL=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),xL=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","PhysicsCustomChart"]);function wL(e){return bL[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function kL(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var SL=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),AL={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},CL={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},ML=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],PL={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function IL(e){return AL[e]}function _L(e,t){const o=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,o={};for(const[e,r]of Object.entries(t.intentScores))"number"==typeof r&&Number.isFinite(r)&&(o[e]=r);return{family:t.family,intentScores:Object.keys(o).length?o:void 0}}return e}}(t);if(o?.act)return o.act;if(o?.intentScores){const e=function(e){let t,o=0;for(const[r,n]of Object.entries(e))if("number"==typeof n&&n>0)if(n>o)t=r,o=n;else if(n===o&&void 0!==t){const e=ML.indexOf(r),o=ML.indexOf(t);-1===e||-1!==o&&e>=o||(t=r)}return t}(o.intentScores);if(e&&AL[e]&&(o.intentScores[e]??0)>=3)return AL[e]}return o?.family?CL[o.family]:function(e){return U_.has(e)||"StackedAreaChart"===e?"apportioning":SL.has(e)?"relating":X_.has(e)?"comparing":K_.has(e)?"characterizing":V_.has(e)?"tracking":vL.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var LL=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),RL=new Set(["system","agent","watcher"]),TL=new Set(["ai","agent","system","computed","dbt","great-expectations"]),NL=new Set(["rule","statistical-test","llm-inference","computed"]);function $L(e){const t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;const t=e;if("string"!=typeof t.type||!LL.has(t.type))return!1;const o=t.provenance;return!(!o||"object"!=typeof o)&&(RL.has(o.authorKind)||TL.has(o.source)||NL.has(o.basis))})}function BL(e="en"){let t,o;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),o=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),o=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?o.format(e):t.format(e):e+""}var DL={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band","x-band":"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function FL(e){const t=DL["string"==typeof e.type?e.type:"annotation"]||"an annotation",o=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,o=t?.authorKind??t?.source??t?.basis;return"watcher"===o?"a watcher-flagged ":"agent"===o||"ai"===o||"llm-inference"===o?"an AI-suggested ":""}(e),r=o?o+t.replace(/^an? /,""):t,n="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return n?`${r} labeled "${n}"`:r}function EL(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const o=fL(t.filter(e=>!!e&&"object"==typeof e));if(0===o.length)return;const r=o.map(FL),n=r.slice(0,5),i=r.length-n.length,a=function(e){return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:e[0]??""}(n)+(i>0?`, and ${i} more`:""),s=o.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${a}.`}function zL(e,t,o={}){const r=void 0!==o.levels,n=new Set(o.levels??["l1","l2","l3"]);r||!o.capability&&!$L(t)||n.add("l4");const i=T_(e,t,o.recipe);if(i){const e=["l1","l2","l3","l4"].filter(e=>n.has(e));r||e.includes("l4")||e.push("l4");const a=yL(i,t,{levels:e,locale:o.locale,audience:o.audience,includeCaveats:o.includeCaveats}),s=EL(t);return{...a,text:s?`${s} ${a.text}`.trim():a.text,...s?{annotations:s}:{}}}const a=BL(o.locale??"en"),s=wL(e),l=Array.isArray(t.data)?t.data:null,c=Z_(t),u=xL.has(e)?function(e,t){const o=e.physics&&"object"==typeof e.physics?e.physics:null,r=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,n=[e.settledProjectionRows,e.projectionRows,r?.rows,o?.settledProjectionRows,o?.projectionRows,o?.settledProjection&&"object"==typeof o.settledProjection?o.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(n)?n.map((e,o)=>{if(!e||"object"!=typeof e)return null;const r=e,n=kL(r.count??r.value??r.total??r.bodies??r.events);if(null==n)return null;const i=r.label??r.id??r.name??"container "+(o+1),a=kL(r.secondary??r.secondaryCount),s=kL(r.observed??r.observedCount);return{label:J_(i,t),count:n,...null!=a?{secondary:a}:{},..."string"==typeof r.secondaryLabel&&r.secondaryLabel?{secondaryLabel:r.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(t,a):null,{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=Q_(e,t),f="string"==typeof d&&d?d:h,g="string"==typeof p&&p?p:m,y={};if(xL.has(e)&&function(e,t,o,r,n,i){const a=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PhysicalFlowChart"===e?"flow node":"container"}(e),s=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PhysicalFlowChart"===e?"packet":"body"}(e);if(n.has("l1")&&(r.l1=function(e,t){return"EventDropChart"===e?"An event-drop physics chart that collapses moving events into a settled projection by event-time window.":"GaltonBoardChart"===e?"A Galton board chart that collapses falling samples into a settled histogram projection.":"PhysicsPileChart"===e?"A physics pile chart that collapses moving bodies into a settled bar-style projection by container.":"CollisionSwarmChart"===e?"A collision swarm chart that separates overlapping points while preserving their quantitative axis position.":"PhysicalFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":`A ${t} whose accessible reading is the settled projection rather than individual trajectories.`}(e,t)),!n.has("l2")&&!n.has("l3"))return;if(!o||0===o.length)return void(n.has("l2")&&(r.l2="No settled projection is loaded yet."));const l=o.reduce((e,t)=>e+t.count,0),c=o.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),u=c[0]??o.slice().sort((e,t)=>t.count-e.count)[0];if(!u)return;const d=o.reduce((e,t)=>e+(t.secondary??0),0),h=o.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(n.has("l2"))if(0===c.length)r.l2=`The settled projection contains ${i(l)} ${OL(l,s)} across ${o.length} ${OL(o.length,a)}; no ${OL(2,a)} are non-empty yet.`;else{const e=d>0?` ${i(d)} ${OL(d,s)} ${1===d?"is":"are"} marked ${h}.`:"";r.l2=`The settled projection contains ${i(l)} ${OL(l,s)} across ${o.length} ${OL(o.length,a)}; ${c.length} ${OL(c.length,a)} ${1===c.length?"is":"are"} non-empty. The largest ${a} is ${u.label} with ${i(u.count)} ${OL(u.count,s)}.${e}`}if(n.has("l3")&&l>0&&c.length>0){const e=c.find(e=>e!==u),t=function(e,t){if(0>=t)return"0%";const o=e/t*100;return(10>o?Math.round(10*o)/10:Math.round(o))+"%"}(u.count,l);r.l3=e?`The settled projection is most concentrated in ${u.label}, which holds ${i(u.count)} ${OL(u.count,s)} (${t}); ${e.label} follows with ${i(e.count)} ${OL(e.count,s)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${i(u.count)} ${OL(u.count,s)}.`}}(e,s,u,y,n,a),n.has("l1")&&!xL.has(e))if(V_.has(e)||X_.has(e))y.l1=`A ${s} of ${f} by ${g}`+(c?`, split by ${c}.`:".");else if(U_.has(e))y.l1=`A ${s} showing ${f} across ${g} categories.`;else if(K_.has(e))y.l1=`A ${s} of the distribution of ${f}`+(c?` by ${c}.`:".");else if(vL.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,o=Array.isArray(t.edges)?t.edges.length:void 0,r=[null!=e?`${e} ${OL(e,"node")}`:null,null!=o?`${o} ${OL(o,"edge")}`:null].filter(Boolean);y.l1=`A ${s}${r.length?" with "+r.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:f;y.l1=`A single value${e?" for "+e:""}.`}else y.l1=`A ${s}.`;const b=V_.has(e)||X_.has(e)||U_.has(e)||K_.has(e);let v=null;if((n.has("l2")||n.has("l3")||n.has("l4"))&&b&&l&&l.length>0&&(v=function(e,t,o,r){let n=0,i=0,a=1/0,s=-1/0,l=null,c=null,u=0,d=0,h=null,p=null,m=NaN,f=NaN;for(const o of e){const e=t(o);Number.isFinite(e)&&(0===n&&(m=e,h=o),f=e,p=o,a>e&&(a=e,l=o,u=n),e>s&&(s=e,c=o,d=n),n++,i+=e)}return 0===n?null:{count:n,min:a,max:s,mean:i/n,minLabel:J_(null!=l?o(l):null,r),maxLabel:J_(null!=c?o(c):null,r),first:m,last:f,firstLabel:J_(null!=h?o(h):null,r),lastLabel:J_(null!=p?o(p):null,r),minIndex:u,maxIndex:d}}(l,ne(d,h),ie(p,m),a)),n.has("l2")&&b&&(l&&0!==l.length?v&&(y.l2=U_.has(e)?`${v.count} segments totaling ${a(function(e){return e.mean*e.count}(v))}. Largest is ${v.maxLabel} at ${a(v.max)}; smallest is ${v.minLabel} at ${a(v.min)}.`:`${f} ranges from ${a(v.min)} (${v.minLabel}) to ${a(v.max)} (${v.maxLabel}), with a mean of ${a(v.mean)} across ${v.count} points.`):y.l2="No data is loaded yet."),n.has("l3")&&v&&!c&&V_.has(e)?y.l3=function(e,t,o){const{first:r,last:n,min:i,max:a,maxLabel:s,minLabel:l,firstLabel:c,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,m=a-i,f=n-r;if(0===m)return`${jL(t)} is constant at ${o(r)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${jL(t)} ends roughly where it started (${o(r)} at ${c} to ${o(n)} at ${u}), ranging between ${o(i)} and ${o(a)}.`;const g=h>0&&p-1>h,y=d>0&&p-1>d,b=(a-Math.max(r,n))/m,v=(Math.min(r,n)-i)/m;return g&&b>.15?`Overall ${t} climbs to a peak of ${o(a)} (${s}), then falls to ${o(n)} (${u}).`:y&&v>.15?`Overall ${t} drops to a low of ${o(i)} (${l}), then recovers to ${o(n)} (${u}).`:.05>Math.abs(f)/m?`${jL(t)} ends roughly where it started (${o(r)} at ${c} to ${o(n)} at ${u}), ranging between ${o(i)} and ${o(a)}.`:f>0?h===p-1?`Overall ${t} rises from ${o(r)} (${c}) to a peak of ${o(n)} (${u}).`:`Overall ${t} rises from ${o(r)} (${c}) to ${o(n)} (${u}), after peaking at ${o(a)} (${s}).`:d===p-1?`Overall ${t} falls from ${o(r)} (${c}) to a low of ${o(n)} (${u}).`:`Overall ${t} falls from ${o(r)} (${c}) to ${o(n)} (${u}), after dipping to ${o(i)} (${l}).`}(v,f,a):n.has("l3")&&v&&!c&&X_.has(e)&&(y.l3=`The highest ${g} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),n.has("l4")){const r=$L(t)?"alerting":_L(e,o.capability);r&&(y.l4=function(e,t,o,r,n,i,a,s){const l=PL[e],c=/^[aeiou]/i.test(l)?"an":"a";let u,d;switch(e){case"locating":u="This is a map",d="read values by location";break;case"presenting":u="This is a single-value display",d=`read ${"string"==typeof o.label&&o.label?o.label:n} as the headline number`;break;case"tracing":u=`This is ${c} ${l} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${c} ${l} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${c} ${l} chart`,d=`read it for whether ${i} and ${n} move together`;break;default:u=`This is ${c} ${l} chart`,d=function(e,t,o,r,n,i){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+o;case"comparing":return`compare ${o} across ${r}`;case"ranking":return"read it top to bottom by "+o;case"apportioning":return`read each ${r}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+o;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,o){if(X_.has(o)||U_.has(o))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:r,last:n,min:i,max:a,minLabel:s,maxLabel:l,lastLabel:c,minIndex:u,maxIndex:d,count:h}=e,p=a-i;if(p>0){const e=d>0&&h-1>d,o=u>0&&h-1>u,m=(a-Math.max(r,n))/p,f=(Math.min(r,n)-i)/p;if(e&&m>.15)return`the peak of ${t(a)} at ${l} is the point to investigate`;if(o&&f>.15)return`the dip to ${t(i)} at ${s} is the point to investigate`;if(n>=a)return`the climb to ${t(n)} at ${c} warrants a closer look`;if(i>=n)return`the drop to ${t(n)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(a)}) and ${s} (${t(i)}) — are the points to check`}(t,n,i);case"tracking":return`read it for the trajectory of ${o}, which ${function(e){const t=e.max-e.min,o=e.last-e.first;return 0===t||.05>Math.abs(o)/t?"holds roughly steady":o>0?"rises":"falls"}(t)} from ${n(t.first)} (${t.firstLabel}) to ${n(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${o} across ${r}; ${t.maxLabel} leads at ${n(t.max)}`;case"ranking":return`read it top to bottom by ${o}; ${t.maxLabel} ranks highest at ${n(t.max)}`;case"apportioning":{const e=t.mean*t.count,o=e>0?Math.round(t.max/e*100):null;return`read each ${r}'s share of the ${n(e)} total; ${t.maxLabel} is the largest at ${n(t.max)}${null!=o?` (${o}%)`:""}`}case"characterizing":return`read it for the spread of ${o}, from ${n(t.min)} to ${n(t.max)}`;default:return"read the highlighted features"}}(e,r,n,i,a,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const o=t.familiarity?.[e];return"number"!=typeof o||o>2?"":` This ${wL(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(r,e,t,c?null:v,f,g,a,o.audience))}const x=["l1","l2","l3","l4"].filter(e=>n.has(e)&&y[e]).map(e=>y[e]).join(" "),w=EL(t);return{text:w?`${w} ${x}`.trim():x,levels:y,...w?{annotations:w}:{}}}function jL(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function OL(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function HL(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function WL(e,t,o={}){const r=R_(t),n=L_(t),i=Math.max(1,o.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:r,config:n,locale:o.locale??"en"});const a=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const l=(a?.groupByRole?$_(e,a.groupByRole):void 0)??(a?.groupBy?.[0]?$_(e,a.groupBy[0])??e.dataRoles.find(e=>e.field===a.groupBy?.[0]):void 0)??B_(e,["nominal","ordinal"]),c=l?N_(l,n,r):void 0,u=(a?.idRole?$_(e,a.idRole):void 0)??B_(e,["identifier"]),d=u?N_(u,n,r):void 0,h={id:"root",role:"chart",label:a?.summaryTemplate?D_(a.summaryTemplate,void 0,e,n,r,{count:r.length}):`${e.name}: ${r.length} ${1===r.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const m=(t,o,i)=>{const s=d?t[d]:void 0,l=a?.itemLabelTemplate?D_(a.itemLabelTemplate,t,e,n,r,{count:r.length}):function(e,t,o,r){const n=B_(t,["nominal","ordinal"]),i=t.dataRoles.filter(e=>"quantitative"===e.semanticType),a=n?N_(n,o,r):void 0,s=[];a&&null!=e[a]&&s.push(e[a]+"");for(const t of i){const n=N_(t,o,r);n&&null!=e[n]&&s.push(`${t.role}: ${e[n]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,n,r);return{id:"datum-"+HL(s??o),role:"datum",label:l,level:i,datum:t}};if(c){const e=new Map;for(const t of r){const o=(t[c]??"Uncategorized")+"",r=e.get(o);r?r.push(t):e.set(o,[t])}h.children=[...e].map(([e,t],o)=>{const r=t.slice(0,Math.max(0,i-p));p+=r.length;const n=r.map((e,t)=>m(e,1e5*o+t,3));return t.length>r.length&&n.push({id:"more-"+HL(e),role:"datum",label:`…and ${t.length-r.length} more items`,level:3}),{id:"group-"+HL(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:n}})}else{const e=r.slice(0,i);h.children=e.map((e,t)=>m(e,t,2)),r.length>e.length&&h.children.push({id:"more",role:"datum",label:`…and ${r.length-e.length} more items`,level:2})}return h}function qL(e,t,o={}){const r=o.locale??"en",n=Math.max(1,o.maxLeaves??200),i=BL(r),a=T_(e,t,o.recipe);if(a)return WL(a,t,{maxLeaves:n,locale:r});const s={id:"root",role:"chart",label:zL(e,t,{locale:r}).text||"Chart.",level:1,children:[]},l=function(e,t){const o=Array.isArray(e.annotations)?e.annotations:null;if(!o)return null;const r=fL(o.filter(e=>!!e&&"object"==typeof e));if(0===r.length)return null;let n=0;const i=r.slice(0,t).map(e=>{const t=e.lifecycle?.status,o=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+n++,role:"annotation",level:3,label:`${r=FL(e),r?r.charAt(0).toUpperCase()+r.slice(1):r}${o}.`,datum:e};var r});r.length>t&&i.push({id:"annotation-"+n++,role:"annotation",level:3,label:`…and ${r.length-t} more annotations.`});const a=r.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===a?"one marked feature":a+" marked features"}.`,children:i}}(t,n),c=Array.isArray(t.data)?t.data:null,u=V_.has(e)||X_.has(e)||U_.has(e)||K_.has(e);if(!c||0===c.length||!u)return l&&(s.children=[l]),s;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=Q_(e,t),f=ne(d,h),g=ie(p,m),y="string"==typeof d&&d?d:h,b="string"==typeof p&&p?p:m,v=Z_(t);let x=0;const w=e=>`${e}-${x++}`,k=(e,t)=>{const o=e.slice(0,n).map(e=>((e,t)=>{const o=f(e),r=J_(g(e),i);return{id:w("datum"),role:"datum",level:t,label:`${r}: ${Number.isFinite(o)?i(o):"—"}`,value:Number.isFinite(o)?o:void 0,datum:e}})(e,t));return e.length>n&&o.push({id:w("more"),role:"datum",level:t,label:`…and ${e.length-n} more points`}),o},S=[];if(V_.has(e)||X_.has(e)){let t=1/0,o=-1/0,r=1/0,n=-1/0;const a=[];let s=!0;for(const e of c){const i=f(e);Number.isFinite(i)&&(t>i&&(t=i),i>o&&(o=i));const l=g(e);a.push(l),"number"==typeof l&&Number.isFinite(l)?(r>l&&(r=l),l>n&&(n=l)):s=!1}const l=new Set,u=[];for(const e of a){const t=e+"";l.has(t)||(l.add(t),u.push(e))}const d=s?`${i(r)} to ${i(n)}`:`${J_(u[0],i)} to ${J_(u[u.length-1],i)} (${X_.has(e)?u.length+" categories":c.length+" points"})`;S.push({id:w("axis"),role:"axis",level:2,label:`${X_.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>o||S.push({id:w("axis"),role:"axis",level:2,label:`Value axis: ${y}, ${i(t)} to ${i(o)}.`})}if(v){const o=ie(v,v),n=new Map;for(const e of c){const t=(o(e)??"—")+"",r=n.get(t);r?r.push(e):n.set(t,[e])}const i=[];for(const[o,a]of n){const n=zL(e,{...t,data:a},{levels:["l2","l3"],locale:r}).text;i.push({id:w("series"),role:"series",level:2,label:`Series ${o}: ${n}`,children:k(a,3)})}s.children=[...S,...i]}else s.children=[...S,...k(c,2)];return l&&s.children.push(l),s}function GL(e,t){const o=[],r=e=>{if(o.push(e),e.children&&e.children.length>0&&t.has(e.id))for(const t of e.children)r(t)};return r(e),o}function YL(e){let t=1;if(e.children)for(const o of e.children)t+=YL(o);return t}import*as VL from"react";var XL=null,UL=new Set,KL=new Set,QL=1e3;function ZL(e,t,o){const r=e??t;if(!Number.isFinite(r)||0>=r)throw new RangeError(`${o} must be a positive number, got ${r+""}`);return Math.floor(r)}function JL(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function eR(e,t){try{const o=t();o&&"function"==typeof o.then&&Promise.resolve(o).catch(t=>JL(e,t))}catch(t){JL(e,t)}}function tR(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function oR(e,t){if(!e)return[];try{return function(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return JL("localStorage load",e),[]}}(e.getItem(t))}catch(e){return JL("localStorage read",e),[]}}var rR=Object.freeze([]),nR=rR,iR=!1;function aR(){return iR?(nR=XL?Object.freeze(XL.buffer.slice()):rR,iR=!1,nR):nR}function sR(){iR=!0}var lR=new Set;function cR(){for(const e of lR)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function uR(e){return lR.add(e),()=>{lR.delete(e)}}function dR(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return KL.add(e),()=>{KL.delete(e)}}function hR(e={}){const t=e.key??"semiotic:conversation-arc",o=ZL(e.maxEvents,QL,"createLocalStorageConversationArcSink: maxEvents");return{record(r){const n=tR(e.storage),i=oR(n,t);i.push(r),function(e,t,o,r){if(e)try{e.setItem(t,JSON.stringify(o.slice(-r)))}catch(e){JL("localStorage write",e)}}(n,t,i,o)},clear(){const o=tR(e.storage);if(o)try{o.removeItem(t)}catch(e){JL("localStorage clear",e)}},load:()=>oR(tR(e.storage),t)}}function pR(e={}){const t=e.dbName??"semiotic-conversation-arc",o=e.storeName??"events",r=ZL(e.maxEvents,QL,"createIndexedDBConversationArcSink: maxEvents");let n=null;const i=()=>(n??(n=function(e,t,o){const r=function(e){if(e)return e;try{return globalThis.indexedDB??null}catch{return null}}(o);return r?new Promise(o=>{let n;try{n=r.open(e,1)}catch(e){return JL("IndexedDB open",e),void o(null)}n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id",autoIncrement:!0})},n.onsuccess=()=>o(n.result),n.onerror=()=>{JL("IndexedDB open",n.error),o(null)},n.onblocked=()=>{JL("IndexedDB open",Error("upgrade blocked")),o(null)}}):Promise.resolve(null)}(t,o,e.indexedDB)),n);return{async record(e){const t=await i();t&&(await new Promise(r=>{try{const n=t.transaction(o,"readwrite");n.objectStore(o).add({event:e}),n.oncomplete=()=>r(),n.onerror=()=>{JL("IndexedDB record",n.error),r()}}catch(e){JL("IndexedDB record",e),r()}}),await function(e,t,o){return e?new Promise(r=>{try{const n=e.transaction(t,"readwrite"),i=n.objectStore(t),a=i.getAll();a.onsuccess=()=>{const e=Array.isArray(a.result)?a.result:[],t=e.length-o;if(t>0)for(const o of e.slice(0,t))null!=o.id&&i.delete(o.id)},a.onerror=()=>JL("IndexedDB trim",a.error),n.oncomplete=()=>r(),n.onerror=()=>{JL("IndexedDB trim",n.error),r()}}catch(e){JL("IndexedDB trim",e),r()}}):Promise.resolve()}(t,o,r))},async clear(){const e=await i();e&&await new Promise(t=>{try{const r=e.transaction(o,"readwrite");r.objectStore(o).clear(),r.oncomplete=()=>t(),r.onerror=()=>{JL("IndexedDB clear",r.error),t()}}catch(e){JL("IndexedDB clear",e),t()}})},load:async()=>function(e,t){return e?new Promise(o=>{try{const r=e.transaction(t,"readonly").objectStore(t).getAll();r.onsuccess=()=>{o((Array.isArray(r.result)?r.result:[]).map(e=>e.event).filter(Boolean))},r.onerror=()=>{JL("IndexedDB load",r.error),o([])}}catch(e){JL("IndexedDB load",e),o([])}}):Promise.resolve([])}(await i(),o)}}function mR(e){if(!e.url)throw new TypeError("createWebhookConversationArcSink: url is required");const t=e.method??"POST";return{record(o){const r=e.fetch??globalThis.fetch;if(!r)return;const n=e.mapEvent?e.mapEvent(o):o;return r(e.url,{method:t,headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify(n)}).then(()=>{})}}}function fR(e,t={}){const o=Array.isArray(e)?e.slice():[],r=ZL(t.capacity,Math.max(XL?.capacity??QL,o.length,1),"loadConversationArc: capacity"),n=t.sessionId??o[0]?.sessionId??XL?.sessionId??vR();for(XL?(XL.enabled=t.enabled??!1,XL.sessionId=n,XL.capacity=r):XL={enabled:t.enabled??!1,sessionId:n,capacity:r,buffer:[]},t.append||(XL.buffer=[]),XL.buffer.push(...o);XL.buffer.length>XL.capacity;)XL.buffer.shift();return sR(),cR(),aR()}function gR(e,t={}){return fR(e,t)}function yR(e,t,o){return AR.record({type:"audience-set",audience:e,previous:t??void 0,...o})}function bR(e,t){return AR.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function vR(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function xR(){return XL}function wR(e={}){const t=e.capacity??1e3;if(!Number.isFinite(t)||0>=t)throw new RangeError("enableConversationArc: capacity must be a positive number, got "+t);if(XL){if(XL.enabled=!0,e.sessionId&&(XL.sessionId=e.sessionId),null!=e.capacity){for(XL.capacity=t;XL.buffer.length>XL.capacity;)XL.buffer.shift();sR()}}else XL={enabled:!0,sessionId:e.sessionId??vR(),capacity:t,buffer:[]},sR();return cR(),AR}function kR(){XL&&(XL.enabled=!1,cR())}function SR(){return AR}var AR={get enabled(){return XL?.enabled??!1},get sessionId(){return XL?.sessionId??null},get capacity(){return XL?.capacity??0},record(e){const t=xR();if(!t||!t.enabled)return null;const o={...e,timestamp:e.timestamp??Date.now(),sessionId:e.sessionId??t.sessionId};for(t.buffer.push(o);t.buffer.length>t.capacity;)t.buffer.shift();sR(),cR();for(const e of UL)try{e(o)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of KL)t.record&&eR("sink record",()=>t.record?.(e))}(o),o},flush(){const e=xR();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],sR(),cR(),function(e){for(const t of KL)t.flush&&eR("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>aR(),subscribe:e=>(UL.add(e),()=>{UL.delete(e)}),clear(){const e=xR();e&&(e.buffer=[],sR(),cR()),function(){for(const e of KL)e.clear&&eR("sink clear",()=>e.clear?.())}()},reset(){if(UL.clear(),KL.clear(),nR=rR,iR=!1,!XL)return cR(),void lR.clear();XL.buffer=[],XL.enabled=!1,XL=null,cR(),lR.clear()}};import{jsx as CR,jsxs as MR}from"react/jsx-runtime";var PR={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function IR({tree:e,label:t,visible:o=!1,className:r,onActiveChange:n,activeId:i,chartId:a}){const[s,l]=VL.useState(()=>new Set([e.id])),[c,u]=VL.useState(e.id),d=void 0!==i,h=d?i:c,p=VL.useRef(null),m=VL.useRef(new Map),f=VL.useMemo(()=>function(e){const t=new Map,o=e=>{for(const r of e.children??[])t.set(r.id,e),o(r)};return o(e),t}(e),[e]),g=VL.useMemo(()=>GL(e,s),[e,s]);VL.useEffect(()=>{d||g.some(e=>e.id===c)||u(e.id)},[g,c,e.id,d]),VL.useEffect(()=>{const e=[];let t=f.get(h);for(;t;)e.push(t.id),t=f.get(t.id);e.length>0&&l(t=>{if(e.every(e=>t.has(e)))return t;const o=new Set(t);for(const t of e)o.add(t);return o})},[h,f]),VL.useEffect(()=>{p.current?.contains(document.activeElement)&&m.current.get(h)?.focus()},[h]);const y=VL.useCallback((e,t,o)=>{const r=SR();r.enabled&&r.record("focus"===t?{type:"nav-node-focused",chartId:a,nodeId:e.id,role:e.role,level:e.level,label:e.label.length>200?e.label.slice(0,200):e.label}:{type:"nav-branch-expanded",chartId:a,nodeId:e.id,role:e.role,level:e.level,expanded:!!o})},[a]),b=VL.useCallback(e=>{e.id!==h&&(d||u(e.id),n?.(e),y(e,"focus"))},[n,d,y,h]),v=e=>{l(t=>new Set(t).add(e.id)),y(e,"toggle",!0)},x=e=>{l(t=>{const o=new Set(t);return o.delete(e.id),o}),y(e,"toggle",!1)},w=(e,t,r)=>{const n=!!e.children&&e.children.length>0,i=s.has(e.id);return MR("li",{role:"treeitem","aria-label":e.label,"aria-level":e.level,"aria-posinset":t,"aria-setsize":r,"aria-expanded":n?i:void 0,"aria-selected":e.id===h,tabIndex:e.id===h?0:-1,ref:t=>{m.current.set(e.id,t)},onClick:t=>{t.stopPropagation(),b(e),n&&(i?x:v)(e)},style:o?{listStyle:"none",padding:"2px 6px",paddingLeft:6+16*(e.level-1),cursor:n?"pointer":"default",fontSize:13,color:"var(--semiotic-text, currentColor)",background:e.id===h?"var(--semiotic-surface, var(--semiotic-grid, var(--semiotic-bg, #f0f4f8)))":"transparent",outline:"none"}:void 0,children:[MR("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[o&&n?i?"▾ ":"▸ ":"",e.label]}),n&&i&&CR("ul",{role:"group",style:o?{margin:0,padding:0}:void 0,children:e.children.map((t,o)=>w(t,o+1,e.children.length))})]},e.id)};return CR("div",{ref:p,className:"semiotic-nav-tree"+(r?" "+r:""),style:o?void 0:PR,onKeyDown:e=>{const t=g.findIndex(e=>e.id===h);if(-1===t)return;const o=g[t],r=!!o.children&&o.children.length>0,n=s.has(o.id);let i=!0;switch(e.key){case"ArrowDown":b(g[Math.min(t+1,g.length-1)]);break;case"ArrowUp":b(g[Math.max(t-1,0)]);break;case"Home":b(g[0]);break;case"End":b(g[g.length-1]);break;case"ArrowRight":r&&!n?v(o):r&&n?b(o.children[0]):i=!1;break;case"ArrowLeft":if(r&&n)x(o);else{const e=f.get(o.id);e?b(e):i=!1}break;case"Enter":case" ":r?(n?x:v)(o):i=!1;break;default:i=!1}i&&(e.preventDefault(),e.stopPropagation())},children:CR("ul",{role:"tree","aria-label":t||"Chart navigation",style:o?{margin:0,padding:0}:void 0,children:w(e,1,1)})})}import*as _R from"react";import{jsx as LR,jsxs as RR}from"react/jsx-runtime";function TR(e,t,o=0){const r=Math.min(t[0],t[1]),n=Math.max(t[0],t[1]),i=Math.max(r,Math.min(n,e[0])),a=Math.max(r,Math.min(n,e[1])),s=i>a?[a,i]:[i,a];if(s[1]-s[0]>=o)return s;const l=(s[0]+s[1])/2,c=o/2;return[Math.max(r,Math.min(n-o,l-c)),Math.min(n,Math.max(r+o,l+c))]}function NR(e,t,o,r=1,n=r){const i="in"===o?r:-r;return TR([e[0]+i,e[1]-i],t,n)}function $R(e){const{domain:t,initialValue:o=t,step:r=1,minSpan:n=r,label:i,formatValue:a,onChange:s}=e,[l,c]=_R.useState(()=>TR(o,t,n)),u=TR(l,t,n),d=_R.useCallback(e=>{const o=TR(e,t,n);c(o),s?.(o)},[t,n,s]),h=_R.useMemo(()=>({label:i,domain:t,value:u,step:r,formatValue:a,onChange:d,onClear:()=>d(t)}),[t,a,i,d,r,u]),p=_R.useMemo(()=>({onZoomIn:()=>d(NR(u,t,"in",r,n)),onZoomOut:()=>d(NR(u,t,"out",r,n)),onReset:()=>d(t)}),[t,n,d,r,u]);return{value:u,setValue:d,xExtent:u,brush:h,zoom:p}}var BR={display:"grid",gap:8,padding:"10px 12px",border:"1px solid var(--semiotic-border, #d8dee4)",borderRadius:12,background:"var(--semiotic-surface, var(--semiotic-bg, rgba(255,255,255,0.92)))"},DR={fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #57606a)"};function FR(e,t){return{minWidth:e,minHeight:e,padding:"0 12px",borderRadius:999,border:"1px solid var(--semiotic-border, #d8dee4)",background:t?"var(--semiotic-primary, #0969da)":"var(--semiotic-bg, #fff)",color:t?"var(--semiotic-on-primary, #fff)":"var(--semiotic-text, #24292f)",fontSize:13,fontWeight:650,touchAction:"manipulation"}}function ER(e){return"function"==typeof e}function zR({brush:e,targetSize:t}){const o=e?.value,r=e?.domain,n=!!o&&!!r,i=!0===e?.disabled,a=e?.formatValue??(e=>e),s=!!e?.onChange&&n&&!i,l=r?.[0]??0,c=r?.[1]??1,u=o?.[0]??l,d=o?.[1]??c,h=e?.step??((c-l)/100||1);return RR("section",{style:BR,"aria-label":"Brush controls",children:[LR("div",{style:DR,children:e?.label??"Filter range"}),n?RR("div",{style:{display:"grid",gap:8},children:[RR("label",{style:{display:"grid",gap:4,fontSize:12},children:[RR("span",{children:["Start: ",a(u)]}),LR("input",{type:"range",min:l,max:c,step:h,value:u,disabled:!s,style:{minHeight:t},onChange:t=>{const o=Number(t.currentTarget.value);e?.onChange?.([Math.min(o,d),d])}})]}),RR("label",{style:{display:"grid",gap:4,fontSize:12},children:[RR("span",{children:["End: ",a(d)]}),LR("input",{type:"range",min:l,max:c,step:h,value:d,disabled:!s,style:{minHeight:t},onChange:t=>{const o=Number(t.currentTarget.value);e?.onChange?.([u,Math.max(o,u)])}})]})]}):LR("div",{style:{fontSize:12,color:"var(--semiotic-text-secondary, #57606a)"},children:"Provide a brush domain and value to expose range inputs beside the drag gesture."}),LR("button",{type:"button",disabled:i||!ER(e?.onClear),onClick:e?.onClear,style:FR(t),children:"Clear range"})]})}function jR({zoom:e,targetSize:t}){const o=!0===e?.disabled;return RR("section",{style:BR,"aria-label":"Zoom controls",children:[LR("div",{style:DR,children:e?.label??"Zoom"}),RR("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[LR("button",{type:"button","aria-label":"Zoom out",disabled:o||!ER(e?.onZoomOut),onClick:e?.onZoomOut,style:FR(t),children:"-"}),LR("button",{type:"button","aria-label":"Reset zoom",disabled:o||!ER(e?.onReset),onClick:e?.onReset,style:FR(t),children:"Reset"}),LR("button",{type:"button","aria-label":"Zoom in",disabled:o||!ER(e?.onZoomIn),onClick:e?.onZoomIn,style:FR(t),children:"+"})]})]})}function OR({legend:e,targetSize:t}){const o=!0===e?.disabled,r=e?.items??[];return RR("section",{style:BR,"aria-label":"Legend controls",children:[LR("div",{style:DR,children:e?.label??"Series"}),r.length>0&&LR("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:r.map(r=>{const n=!1!==r.active;return RR("button",{type:"button",disabled:o||r.disabled||!e?.onToggle,onClick:()=>e?.onToggle?.(r.id,!n),style:FR(t,n),"aria-pressed":n,children:[r.color&&LR("span",{"aria-hidden":"true",style:{display:"inline-block",width:9,height:9,marginRight:6,borderRadius:999,background:r.color}}),r.label??r.id]},r.id)})}),RR("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[LR("button",{type:"button",disabled:o||!ER(e?.onShowAll),onClick:e?.onShowAll,style:FR(t),children:"Show all"}),LR("button",{type:"button",disabled:o||!ER(e?.onHideAll),onClick:e?.onHideAll,style:FR(t),children:"Hide all"})]})]})}function HR({controls:e,targetSize:t=44,compact:o=!1,className:r,style:n,ariaLabel:i="Mobile chart controls",brush:a,zoom:s,legend:l}){const c=function(e,t){if(!1===e)return[];if(!0===e||"all"===e)return["brush","zoom","legend"];if(Array.isArray(e))return e;if(e)return[e];const o=[];return t.brush&&o.push("brush"),t.zoom&&o.push("zoom"),t.legend&&o.push("legend"),o}(e,{brush:a,zoom:s,legend:l});return 0===c.length?null:RR("div",{className:r,role:"group","aria-label":i,style:{display:"grid",gridTemplateColumns:o?"1fr":"repeat(auto-fit, minmax(180px, 1fr))",gap:10,...n},children:[c.includes("brush")&&LR(zR,{brush:a,targetSize:t}),c.includes("zoom")&&LR(jR,{zoom:s,targetSize:t}),c.includes("legend")&&LR(OR,{legend:l,targetSize:t})]})}var WR=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),qR=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),GR={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function YR(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function VR(e){return"string"==typeof e&&e.trim().length>0}function XR(e){const t=YR(e.capability)?e.capability:null,o=YR(e.recipe)?e.recipe:null,r=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,o?.mobile];for(const e of r)if(YR(e))return e;return null}function UR(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&"number"==typeof e[1]&&Number.isFinite(e[0])&&Number.isFinite(e[1])?[e[0],e[1]]:null}function KR(e){return UR(e.size)||UR(YR(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function QR(e,t){e.push({...t,status:"pass"})}function ZR(e,t){e.push({...t,status:"warn"})}function JR(e,t){e.push({...t,status:"manual"})}function eT(e,t={},o={}){const r=o.viewportWidth??390,n=o.targetSize??44,i=KR(t),a=hu(t,{width:r,height:i?.[1]}),s=[],l=KR(t=a.props),c=XR(t),u=function(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}(e,t),d=function(e){const t=XR(e);return!0===e.responsive||!0===e.mobile||!0===t?.responsive||!0===t?.supportsResponsiveLayout||Array.isArray(t?.breakpoints)||"number"==typeof t?.minViewportWidth||"responsive"===t?.strategy||"small-multiples"===t?.strategy||"summary-cards"===t?.strategy||null!=e.mobileLayout||null!=e.responsiveRules||"mobile-readable"===e.density}(t),h=!0===o.inChartContainer,p=VR(t.title)||VR(t.summary)||VR(t.description)||!0===c?.summary||VR(c?.summary);if(a.matches.length>0&&QR(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${a.matches.length} responsive rule(s) applied for the ${r}px mobile audit.`}),l){const[t,o]=l;t>r&&!d?ZR(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${r}px mobile viewport with no responsive/mobile transform hint.`,fix:"Use responsive sizing, responsiveRules/mobileLayout, or an explicit mobile variant that preserves the task instead of clipping the desktop chart."}):QR(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof c?.minViewportWidth&&c.minViewportWidth>r&&ZR(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${c.minViewportWidth}px minimum, wider than the audited ${r}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const n=t/Math.max(1,o);430>=r&&n>2.4&&"BigNumber"!==e&&ZR(s,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${n.toFixed(1)}:1, which tends to compress phone charts vertically.`,fix:"Prefer stacked sections, small multiples, cards plus a sparkline, or a taller mobile-specific chart ratio."}),160>o&&"BigNumber"!==e&&ZR(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${o}px; most phone charts need enough vertical room for marks plus readable labels.`,fix:"Reserve more vertical space, remove nonessential axes, or switch to a card/sparkline pattern with external labels."})}else JR(s,{id:"layout.unknown-size",category:"layout",impact:"medium",message:"No explicit size is available to audit. This may be responsive, but static mobile overflow cannot be checked.",fix:"Audit rendered widths at 320, 360, 390, and 430px, or pass size/responsiveRules metadata into the config."});const m=function(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,YR(e.frameProps)?e.frameProps.data:void 0];let o=0;for(const e of t)Array.isArray(e)&&(o+=e.length);return o}(t);m>0&&(m>("number"==typeof c?.maxMarks?c.maxMarks:WR.has(e)?1.25*r:qR.has(e)?Math.max(8,Math.floor(r/34)):r)?ZR(s,{id:"density.mark-budget",category:"density",impact:WR.has(e)?"medium":"high",message:`${m} data item(s) exceed the rough mobile density budget for ${e} at ${r}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):QR(s,{id:"density.mark-budget",category:"density",impact:"medium",message:m+" data item(s) are within the rough mobile density budget for this component."}));const f=function(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let o=0;for(const e of t)Array.isArray(e)&&(o+=e.length);return o>0?o:null}(t),g=!1!==t.showAxes&&!1!==t.axis;if(g&&null!=f){const e=Math.max(3,Math.floor(r/58));f>e&&ZR(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${f} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${r}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else g&&(WR.has(e)||qR.has(e))&&JR(s,{id:"density.axis-label-collision",category:"density",impact:"medium",message:"Axes are enabled, but label collision depends on rendered tick text and cannot be checked statically.",fix:"Verify tick labels at phone widths or provide explicit mobile tick density."});!function(e){const t=YR(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=XR(e),o=YR(e.mobileInteraction)?e.mobileInteraction:null;return null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||null!=e.selection||null!=e.onClick||null!=e.onSelect||!0===e.mobileInteraction||!0===o?.tapToSelect||!0===o?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||VR(t?.interaction?.hoverFallback)}(e)}(t)?QR(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):ZR(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"The chart exposes tooltip/hover detail without an obvious tap, selection, or control alternative.",fix:"Enable tap-to-select, a persistent details panel, visible segment buttons, or another non-hover path for the same information."});const y=function(e,t){const o=GR[e];if(!o)return null;let r=o.includes("hoverRadius")?30:null;for(const e of o){const o=t[e];"number"==typeof o&&Number.isFinite(o)&&o>0&&(r=null==r?o:Math.max(r,o))}return null==r?null:2*r}(e,t),b=YR(t.mobileInteraction)?t.mobileInteraction:null,v=y??("number"==typeof b?.targetSize?b.targetSize:!0===t.mobileInteraction?44:"number"==typeof c?.minimumHitTarget?c.minimumHitTarget:"number"==typeof c?.interaction?.targetSize?c.interaction.targetSize:null);null!=v&&(24>v?ZR(s,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${v}px pointer target, below WCAG's 24px minimum.`,fix:"Increase mark radius/hoverRadius, add tap snapping to nearest datum, or provide larger external controls."}):n>v?ZR(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}px, above 24px but below the ${n}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):QR(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}px, meeting the configured ${n}px target.`}));const x=[];null==t.brush&&null==t.onBrush||x.push("brush"),!0===t.zoomable&&x.push("pan/zoom"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||x.push("legend filtering"),x.length>0&&!function(e,t){const o=XR(e),r=YR(e.mobileInteraction)?e.mobileInteraction:null,n=r?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(o?.interaction?.alternatives)&&o.interaction.alternatives.length>0)||!0===n||"all"===n||t.every(e=>"brush"===e?Array.isArray(n)?n.includes("brush"):"brush"===n:"pan/zoom"===e?Array.isArray(n)?n.includes("zoom"):"zoom"===n:"legend filtering"===e&&(Array.isArray(n)?n.includes("legend"):"legend"===n))}(t,x)&&ZR(s,{id:"interaction.complex-gesture-alternative",category:"interaction",impact:"high",message:`Mobile-hostile complex interaction detected: ${x.join(", ")} without standard control alternatives.`,fix:"Pair gestures with buttons, range inputs, chips, or a details panel that works with touch and keyboard."}),!1===t.showLegend||!1===t.legend||!0!==t.showLegend&&!0!==t.legend&&null==t.colorBy&&null==t.groupBy&&null==t.lineBy&&null==t.areaBy&&null==t.stackBy||!0===t.directLabel||!0===t.showLabels||"direct"===t.labelStrategy||"direct-end"===t.labelStrategy||"direct"===c?.labels?.strategy||"inline"===c?.labels?.strategy||"external"===c?.labels?.strategy||r>430||ZR(s,{id:"semantics.legend-over-direct-labels",category:"semantics",impact:"medium",message:"The chart appears to rely on a legend instead of direct labels at phone width.",fix:"Prefer direct end labels, inline labels, or a compact chip selector so readers do not bounce between plot and legend."});const w=Array.isArray(t.annotations)?t.annotations.filter(e=>YR(e)):[];if(w.length>("number"==typeof c?.maxAnnotations?c.maxAnnotations:3)&&430>=r&&ZR(s,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:w.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),w.length>0){const e=w.filter(e=>!VR(e.mobileText)&&!VR(e.shortText)&&!VR(e.label));e.length>0&&JR(s,{id:"annotation.mobile-copy",category:"annotation",impact:"low",message:e.length+" annotation(s) lack explicit short/mobile copy.",fix:"Add mobileText or shortText for notes that need to survive narrow layouts."})}d||"BigNumber"===e||JR(s,{id:"layout.no-responsive-transform",category:"layout",impact:"low",message:"No explicit responsive transformation hint is present.",fix:"Declare responsiveRules/mobileLayout or a density/label strategy so the mobile version is a designed transformation, not an accidental resize."}),u&&(c?(QR(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart/recipe provides a mobileSemantics/mobile contract, so the audit can inspect its authored phone behavior."}),!1===c.custom?.dataBearingSceneNodes?ZR(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"medium",message:"Custom mobile contract says emitted scene nodes are not data-bearing.",fix:"Preserve datum references, semantic roles, or accessible-table fields so intelligence, navigation, and tap details can recover the chart's meaning."}):!0!==c.custom?.dataBearingSceneNodes&&JR(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"low",message:"Custom chart mobile contract does not state whether scene nodes are data-bearing.",fix:"Set mobile.custom.dataBearingSceneNodes and mobile.custom.navigationGranularity for custom layouts and interoperability adapters."})):JR(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart layout is opaque to static mobile analysis because no mobileSemantics/mobile contract is present.",fix:"Declare mobileSemantics with strategy, breakpoints, mark budgets, touch target size, interaction alternatives, and custom scene semantics."})),p||h||ZR(s,{id:"semantics.no-mobile-summary",category:"semantics",impact:"medium",message:"No title, summary, description, or ChartContainer context is visible from the config.",fix:"Add title/summary text or wrap in ChartContainer so the small-screen reader gets the task before the chart."});const k=s.filter(e=>"warn"===e.status),S={highRisk:k.filter(e=>"high"===e.impact).length,warnings:k.length,manual:s.filter(e=>"manual"===e.status).length,passes:s.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:r,ok:0===S.highRisk,summary:S,findings:s,reference:"Mobile visualization audit: informed by MobileVisFixer, mobile exploratory interaction research, small-multiple mobile studies, responsive visualization grammars, constraint-based breakpoints, and WCAG 2.2 input modalities."}}var tT={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},oT=["layout","density","interaction","annotation","semantics"];function rT(e){const t=[],o=e.summary,r=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${o.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${r} - ${o.warnings} warning(s) - ${o.manual} manual check(s)`);for(const o of oT){const r=e.findings.filter(e=>e.category===o&&"not-applicable"!==e.status);if(0!==r.length){t.push(""),t.push(" "+o.toUpperCase());for(const e of r)t.push(` ${tT[e.status]} [${e.impact}] ${e.id}: ${e.message}`),!e.fix||"warn"!==e.status&&"manual"!==e.status||t.push(" -> "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function nT(){return["Static audit only: rendered label collision, CSS-resolved type size, and actual touch behavior still require viewport testing.","Use multiple widths, usually 320, 360, 390, 430, and 768 CSS pixels.","A mobile pass means no high-risk static warnings, not that the chart is perceptually or ergonomically optimal."]}import{Fragment as iT,jsx as aT,jsxs as sT}from"react/jsx-runtime";var lT={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function cT(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function uT(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function dT(e){return Array.isArray(e)?e.length>0:!!e}function hT(){const e=function(){const e=wa.useContext(Sa);return e?e.toggle:null}();return e?aT("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:kT,children:sT("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[aT("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),aT("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),aT("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var pT={info:"var(--semiotic-info, #2563eb)",success:"var(--semiotic-success, #16a34a)",warning:"var(--semiotic-warning, #d97706)",error:"var(--semiotic-error, var(--semiotic-danger, #dc2626))",neutral:"var(--semiotic-text-secondary, #6b7280)"},mT={error:4,warning:3,info:2,success:1,neutral:0};function fT({level:e}){const t={width:15,height:15,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(e){case"error":case"warning":return sT("svg",{...t,children:[aT("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),aT("path",{d:"M8 6.4v3.4"}),aT("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return sT("svg",{...t,children:[aT("circle",{cx:"8",cy:"8",r:"6.4"}),aT("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return sT("svg",{...t,children:[aT("circle",{cx:"8",cy:"8",r:"6.4"}),aT("path",{d:"M8 7.4V11"}),aT("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return sT("svg",{...t,children:[aT("path",{d:"M8 2a3.5 3.5 0 0 0-3.5 3.5c0 4-1.5 5-1.5 5h10s-1.5-1-1.5-5A3.5 3.5 0 0 0 8 2Z"}),aT("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function gT({notification:e,level:t,onDismiss:o}){const r=pT[t]??pT.info,n=!1!==e.dismissible;return sT("div",{className:"semiotic-chart-notification semiotic-chart-notification--"+t,style:{display:"flex",alignItems:"flex-start",gap:8,padding:"6px 10px",borderRadius:4,borderLeft:"3px solid "+r,background:"var(--semiotic-surface, rgba(127, 127, 127, 0.08))"},children:[sT("div",{style:{flex:1,minWidth:0},children:[e.source&&aT("div",{className:"semiotic-chart-notification-source",style:{fontSize:9,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #666)"},children:e.source}),e.title&&aT("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:r},children:e.title}),aT("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),n&&aT("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:o,style:{...kT,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function yT({visible:e,onDismiss:t}){const[o,r]=VI.useState(!1),n=VI.useRef(null),i=VI.useRef(null);if(VI.useEffect(()=>{0===e.length&&o&&r(!1)},[e.length,o]),VI.useEffect(()=>{if(!o)return;const e=e=>{n.current&&!n.current.contains(e.target)&&r(!1)},t=e=>{"Escape"===e.key&&(r(!1),i.current?.focus())};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[o]),0===e.length)return null;const a=e.reduce((e,t)=>mT[t.level]>mT[e]?t.level:e,e[0].level),s=pT[a]??pT.info,l=e.length,c=`${l} chart notification${1===l?"":"s"}, most severe: ${a}`;return sT("div",{ref:n,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[aT("span",{style:lT,role:"status","aria-live":"polite",children:c}),sT("button",{ref:i,className:"semiotic-chart-action semiotic-chart-notifications-toggle","aria-haspopup":"dialog","aria-expanded":o,"aria-label":`${c}. ${o?"Hide":"Show"} notifications`,title:c,onClick:()=>r(e=>!e),style:{...kT,color:s,position:"relative"},children:[aT(fT,{level:a}),aT("span",{className:"semiotic-chart-notifications-badge","aria-hidden":"true",style:{position:"absolute",top:-3,right:-3,minWidth:15,height:15,padding:"0 3px",boxSizing:"border-box",borderRadius:8,background:s,color:"#fff",fontSize:9,fontWeight:700,lineHeight:"15px",textAlign:"center"},children:l>99?"99+":l})]}),o&&aT("div",{className:"semiotic-chart-notifications-popover",role:"dialog","aria-label":"Chart notifications",style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:20,width:320,maxWidth:"min(360px, 90vw)",maxHeight:320,overflowY:"auto",display:"flex",flexDirection:"column",gap:6,padding:10,textAlign:"left",background:"var(--semiotic-bg, #fff)",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:6,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)"},children:e.map(e=>aT(gT,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var bT={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function vT({height:e}){return aT("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function xT({error:e}){return aT("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:aT("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var wT=VI.forwardRef(function({title:e,subtitle:t,children:o,width:r="100%",height:n=400,actions:i,chartConfig:a,describe:s,navigable:l,controls:c,banner:u,notifications:d,onNotificationDismiss:h,loading:p=!1,error:m,errorBoundary:f=!1,status:g,detailsPanel:y,mobile:b,mobileAudit:v,className:x,style:w},k){const S=VI.useRef(null),A=VI.useRef(null),[C,M]=VI.useState(!1),[P,I]=VI.useState(()=>new Set);VI.useEffect(()=>{I(e=>{if(0===e.size)return e;const t=new Set((d??[]).map((e,t)=>e.id??t+""));let o=!1;const r=new Set;for(const n of e)t.has(n)?r.add(n):o=!0;return o?r:e})},[d]);const _=VI.useMemo(()=>d?d.map((e,t)=>({notification:e,index:t,key:e.id??t+"",level:e.level??"info"})).filter(({key:e})=>!P.has(e)):[],[d,P]),L=VI.useCallback(e=>{I(t=>new Set(t).add(e.key)),h?.(e.notification,e.index)},[h]),R=!1!==i?.export&&void 0!==i?.export,T=!1!==i?.fullscreen&&void 0!==i?.fullscreen,N=!1!==i?.copyConfig&&void 0!==i?.copyConfig&&a,$=!0===i?.dataSummary,B=VI.useMemo(()=>{if(!s||!a?.component||!a?.props)return"";const e="object"==typeof s?s.levels:void 0;try{return zL(a.component,a.props,e?{levels:e}:{}).text}catch{return""}},[s,a]),D="object"==typeof s&&!0===s.visible,F=VI.useMemo(()=>{if(!l||!a?.component||!a?.props)return null;const e="object"==typeof l?l.maxLeaves:void 0;try{return qL(a.component,a.props,e?{maxLeaves:e}:{})}catch{return null}},[l,a]),E="object"==typeof l&&!0===l.visible,z=VI.useMemo(()=>"object"==typeof i?.export?i.export:{},[i?.export]),j="object"==typeof i?.copyConfig?i.copyConfig.format:"json",O=VI.useCallback(async e=>{A.current&&await qI(A.current,{...z,...e})},[z]),H=VI.useCallback(()=>{S.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):S.current.requestFullscreen().catch(()=>{}))},[]),W=VI.useCallback(async e=>{a&&await G_({...a,version:a.version??"1",createdAt:a.createdAt??(new Date).toISOString()},e||j||"json")},[a,j]);VI.useEffect(()=>{const e=()=>{M(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),VI.useImperativeHandle(k,()=>({export:O,toggleFullscreen:H,copyConfig:W,element:S.current}),[O,H,W]);const q=!0===b?{}:b&&"object"==typeof b?b:null,G=!!b,Y=q?.breakpoint??480,V=void 0===q?.chartMode?"mobile":q.chartMode,X=q?.semantics,U=q?.mobileInteraction??(!!G||void 0),K=q?.standardControls,Q=cT(K)?K:null,Z=Q?.controls??(cT(K)?void 0:K)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(U),J=dT(Z)?U&&"object"==typeof U?{...U,standardControls:Z}:!1===U||null==U?U:{standardControls:Z}:U,ee=G&&dT(Z)?aT(HR,{controls:Z,targetSize:Q?.targetSize??uT(U)??44,compact:Q?.compact??!0,className:Q?.className,style:Q?.style,ariaLabel:Q?.ariaLabel,brush:Q?.brush,zoom:Q?.zoom,legend:Q?.legend}):null,te=q?.summary,oe=!0===q?.allowHorizontalScroll,re=!0===q?.hideToolbar,ne=VI.useMemo(()=>{if(!v||!a?.component||!a?.props)return null;const e="object"==typeof v?v:{},t=a.props;try{return eT(a.component,{...t,mobileSemantics:t.mobileSemantics??X,mobileInteraction:t.mobileInteraction??J},{viewportWidth:e.viewportWidth??390,targetSize:e.targetSize??44,inChartContainer:!0})}catch{return null}},[v,a,X,J]);VI.useEffect(()=>{if(!ne||ne.ok)return;const e=ne.findings.filter(e=>"pass"!==e.status).slice(0,5);console.warn(`[Semiotic mobile audit] ${a?.component}: ${ne.summary.highRisk} high-risk mobile finding(s), ${ne.summary.warnings} warning(s).`,e)},[ne,a?.component]);const ie=ne&&!ne.ok&&"object"==typeof v&&!0===v.visible?sT("div",{className:"semiotic-chart-mobile-audit",role:"status",style:{padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-warning, #6b3f00)",background:"color-mix(in srgb, var(--semiotic-warning, #d97706) 14%, var(--semiotic-bg, #fff))",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:["Mobile audit: ",ne.summary.highRisk," high-risk finding",1===ne.summary.highRisk?"":"s"," and"," ",ne.summary.warnings," warning",1===ne.summary.warnings?"":"s"," at"," ",("object"==typeof v?v.viewportWidth:void 0)??390,"px."]}):null,ae=_.length>0,se=e||t||c||R||T||N||$||g||ae,le=VI.useMemo(()=>{if(!G||!VI.isValidElement(o))return o;const e=o.props,t={};return V&&null==e.mode&&(t.mode=V),X&&null==e.mobileSemantics&&(t.mobileSemantics=X),void 0!==J&&null==e.mobileInteraction&&(t.mobileInteraction=J),Object.keys(t).length>0?VI.cloneElement(o,t):o},[o,G,V,X,J]),ce=p?aT(vT,{height:n}):m?aT(xT,{error:m}):f?aT(Bu,{children:le}):le;return ue=sT(iT,{children:[aT("style",{dangerouslySetInnerHTML:{__html:`@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n@media (max-width: ${Y}px) {\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-header {\n padding: 10px 12px !important;\n gap: 10px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-title-area {\n flex-basis: 100% !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-toolbar {\n width: 100% !important;\n margin-left: 0 !important;\n justify-content: flex-start !important;\n overflow-x: auto !important;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-hide-toolbar="true"] .semiotic-chart-toolbar {\n display: none !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-action {\n min-width: 32px !important;\n min-height: 32px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-summary {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-standard-controls {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-scroll="true"] .semiotic-chart-body {\n overflow-x: auto !important;\n justify-content: flex-start !important;\n -webkit-overflow-scrolling: touch;\n }\n}`}}),sT("div",{ref:S,className:"semiotic-chart-container"+(x?" "+x:""),"data-semiotic-mobile":G?"true":void 0,"data-semiotic-mobile-scroll":oe?"true":void 0,"data-semiotic-mobile-hide-toolbar":re?"true":void 0,style:{width:r,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative",...C?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{},...w},children:[se&&sT("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:8,borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[sT("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[e&&aT("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:e}),t&&aT("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0},children:t})]}),sT("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[c,ae&&aT(yT,{visible:_,onDismiss:L}),R&&aT("button",{className:"semiotic-chart-action",onClick:()=>O(),title:"Export chart","aria-label":"Export chart",style:kT,children:sT("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[aT("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),aT("path",{d:"M2 12h10"})]})}),$&&aT(hT,{}),T&&aT("button",{className:"semiotic-chart-action",onClick:H,title:C?"Exit fullscreen":"Fullscreen","aria-label":C?"Exit fullscreen":"Enter fullscreen",style:kT,children:aT("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:sT(iT,C?{children:[aT("path",{d:"M9 1v4h4"}),aT("path",{d:"M5 13V9H1"}),aT("path",{d:"M13 5H9V1"}),aT("path",{d:"M1 9h4v4"})]}:{children:[aT("path",{d:"M1 5V1h4"}),aT("path",{d:"M13 9v4H9"}),aT("path",{d:"M9 1h4v4"}),aT("path",{d:"M5 13H1V9"})]})})}),N&&aT("button",{className:"semiotic-chart-action",onClick:()=>W(),title:"Copy config","aria-label":"Copy chart configuration",style:kT,children:sT("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[aT("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),aT("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),g&&aT("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:bT[g].bg,color:bT[g].color,lineHeight:"18px"},children:g})]})]}),u&&aT("div",{className:"semiotic-chart-banner",children:u}),ie,te&&aT("div",{className:"semiotic-chart-mobile-summary",style:{display:"none",padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:te}),ee&&aT("div",{className:"semiotic-chart-mobile-standard-controls",style:{display:"none",padding:"10px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-surface, var(--semiotic-bg, #f6f8fa))"},children:ee}),B&&aT("div",{className:"semiotic-chart-description",role:"note",style:D?{padding:"8px 16px",fontSize:12,lineHeight:1.5,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}:lT,children:B}),F&&aT("div",{className:"semiotic-chart-nav",style:E?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:aT(IR,{tree:F,label:"string"==typeof e&&e?e+" — navigable structure":"Chart navigable structure",visible:E,chartId:"string"==typeof a?.props?.chartId?a.props.chartId:void 0})}),sT("div",{className:"semiotic-chart-body",ref:A,style:{position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",...C?{flex:1}:{height:n}},children:[ce,y]})]})]}),$?aT(Aa,{children:ue}):ue;var ue}),kT={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};import*as ST from"react";import{jsx as AT,jsxs as CT}from"react/jsx-runtime";function MT({children:e,controls:t,mobile:o,breakpoint:r=480,chartMode:n="mobile",mobileInteraction:i=!0,mobileSemantics:a,mobileSummary:s,chips:l=[],activeChip:c,onChipChange:u,detail:d,detailTitle:h="Details",detailMode:p="sheet",initialDetailOpen:m=!1,allowHorizontalScroll:f=!1,hideToolbar:g=!1,chartDefaults:y,...b}){const[v,x]=ST.useState(()=>c??l.find(e=>!e.disabled)?.id),[w,k]=ST.useState(m);ST.useEffect(()=>{void 0===c&&(l.length?l.some(e=>e.id===v&&!e.disabled)||x(l.find(e=>!e.disabled)?.id):x(void 0))},[c,l,v]);const S=c??v,A=ST.useCallback(e=>{e.disabled||(void 0===c&&x(e.id),u?.(e))},[c,u]),C=l.length?AT("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:l.map(e=>CT("button",{type:"button",className:"semiotic-mobile-chip","aria-pressed":e.id===S,disabled:e.disabled,onClick:()=>A(e),title:"string"==typeof e.description?e.description:void 0,children:[AT("span",{children:e.label}),e.description&&AT("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,M=s||C?CT("div",{className:"semiotic-mobile-summary-card",children:[s&&AT("div",{className:"semiotic-mobile-summary-copy",children:s}),C]}):o?.summary,P={breakpoint:r,chartMode:n,mobileInteraction:i,semantics:a,allowHorizontalScroll:f,hideToolbar:g,...o,summary:M},I=ST.useMemo(()=>{if(!y||!ST.isValidElement(e))return e;const t=e.props,o={};for(const[e,r]of Object.entries(y))null==t[e]&&(o[e]=r);return Object.keys(o).length>0?ST.cloneElement(e,o):e},[e,y]),_=!!d&&"sheet"===p,L=!!d&&"inline"===p||_&&w,R=_?AT("button",{type:"button",className:"semiotic-mobile-detail-toggle","aria-expanded":w,onClick:()=>k(e=>!e),children:w?"Hide details":"Show details"}):null,T=t||R?CT("div",{className:"semiotic-mobile-control-stack",children:[t,R]}):void 0;return CT("div",{className:"semiotic-mobile-chart-shell",children:[AT("style",{children:`\n .semiotic-mobile-chart-shell {\n display: grid;\n gap: 10px;\n width: 100%;\n }\n .semiotic-mobile-summary-card {\n display: grid;\n gap: 10px;\n }\n .semiotic-mobile-summary-copy {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-chip-row {\n display: flex;\n gap: 8px;\n overflow-x: auto;\n padding-bottom: 2px;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-mobile-chip {\n display: inline-flex;\n flex: 0 0 auto;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n min-height: 40px;\n min-width: 44px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 7px 12px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-chip[aria-pressed="true"] {\n border-color: var(--semiotic-accent, #1f7a6d);\n background: color-mix(in srgb, var(--semiotic-accent, #1f7a6d) 14%, transparent);\n }\n .semiotic-mobile-chip:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n }\n .semiotic-mobile-chip-description {\n display: block;\n max-width: 160px;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 10px;\n font-weight: 500;\n line-height: 1.2;\n }\n .semiotic-mobile-control-stack {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n }\n .semiotic-mobile-detail-toggle {\n min-height: 32px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 5px 10px;\n background: transparent;\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-detail-panel {\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);\n overflow: hidden;\n }\n .semiotic-mobile-detail-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 12px;\n border-bottom: 1px solid var(--semiotic-border, #d8d8d8);\n font-size: 13px;\n font-weight: 800;\n }\n .semiotic-mobile-detail-body {\n padding: 12px;\n font-size: 13px;\n line-height: 1.5;\n }\n @media (max-width: ${r}px) {\n .semiotic-mobile-detail-panel[data-mode="sheet"] {\n position: sticky;\n bottom: 8px;\n z-index: 2;\n max-height: min(55vh, 420px);\n overflow: auto;\n }\n }\n `}),AT(wT,{...b,controls:T,mobile:P,children:I}),L&&CT("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof h?h:"Chart details",children:[CT("div",{className:"semiotic-mobile-detail-header",children:[AT("span",{children:h}),_&&AT("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),AT("div",{className:"semiotic-mobile-detail-body",children:d})]})]})}import*as PT from"react";import{jsx as IT,jsxs as _T}from"react/jsx-runtime";function LT(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function RT(e,t){const o="function"==typeof t?t(e):e[t];return Array.isArray(o)?o:[]}function TT(e){return{strategy:"small-multiples",responsive:!0,supportsResponsiveLayout:!0,summary:`${e} vertically stacked small multiple panel${1===e?"":"s"} with shared scale guidance.`,interaction:{primary:"tap",alternatives:["panel summary","linked selection"],hoverFallback:"tap-to-lock",targetSize:44},labels:{strategy:"external",minFontSize:12}}}function NT(e,t){if(!PT.isValidElement(e))return e;const o=e.props,r={};for(const[e,n]of Object.entries(t))void 0!==n&&null==o[e]&&(r[e]=n);return Object.keys(r).length>0?PT.cloneElement(e,r):e}function $T({items:e,children:t,columns:o=3,tabletColumns:r=2,mobileColumns:n=1,mobileBreakpoint:i=480,tabletBreakpoint:a=860,gap:s=12,mode:l="mobile",chartHeight:c=220,sharedExtent:u=!0,valueAccessor:d,dataAccessor:h="data",extentProps:p=["yExtent","valueExtent"],linkedHover:m,selection:f,linkedBy:g,linkProvider:y="auto",selections:b,showLegend:v=!1,legendPosition:x,legendInteraction:w,legendSelectionName:k,legendField:S,mobileInteraction:A=!0,mobileSemantics:C,labelMode:M="panel",chartDefaults:P,className:I,style:_}){const L=zc(),R=e||"function"==typeof t?[]:PT.Children.toArray(t),T=e??R.map((e,t)=>({id:"panel-"+(t+1)})),N=T.length,$=PT.useMemo(()=>function(e,t,o,r){if(t&&"object"==typeof t)return t;if(!1===t)return{};const n=[],i=[];for(const t of e)if(t.extent&&n.push(t.extent[0],t.extent[1]),r)for(const e of RT(t,o))i.push(LT(e,r));const a=function(e){let t=1/0,o=-1/0;for(const r of e){const e=Number(r);Number.isFinite(e)&&(t>e&&(t=e),e>o&&(o=e))}if(Number.isFinite(t)&&Number.isFinite(o))return t===o?[t-1,o+1]:[t,o]}(i.length?i:n);return a?{yExtent:a,valueExtent:a}:{}}(T,u,h,d),[T,u,h,d]),B=PT.useMemo(()=>{if(!g)return{name:void 0,fields:void 0,linkedHover:m,selection:f};const e=Array.isArray(g)?"small-multiples":g.name||"small-multiples",t=Array.isArray(g)?g:g.fields||[];return{name:e,fields:t,linkedHover:m??{name:e,fields:t},selection:f??{name:e}}},[g,m,f]),D=PT.useMemo(()=>({linkedHover:B.linkedHover,selection:B.selection}),[B.linkedHover,B.selection]),F=PT.useMemo(()=>{const e={mode:l,height:c,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:C??TT(N),...D,...P};"legend"!==M&&(e.showLegend=!1),"direct"===M&&(e.directLabel=!0);for(const t of p)t in $&&(e[t]=$[t]);return e},[l,c,A,C,N,D,P,M,p,$]),E=_T("section",{className:["semiotic-small-multiple-chart",I].filter(Boolean).join(" "),style:_,"data-semiotic-small-multiple":"true",children:[IT("style",{children:`\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${o};\n --semiotic-small-multiple-gap: ${s}px;\n display: grid;\n grid-template-columns: repeat(var(--semiotic-small-multiple-columns), minmax(0, 1fr));\n gap: var(--semiotic-small-multiple-gap);\n width: 100%;\n }\n .semiotic-small-multiple-panel {\n min-width: 0;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n overflow: hidden;\n }\n .semiotic-small-multiple-heading {\n display: grid;\n gap: 3px;\n padding: 10px 12px 0;\n }\n .semiotic-small-multiple-title {\n margin: 0;\n color: var(--semiotic-text, #222);\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-small-multiple-subtitle,\n .semiotic-small-multiple-summary {\n margin: 0;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.35;\n }\n .semiotic-small-multiple-plot {\n min-width: 0;\n padding: 4px 6px 8px;\n overflow: hidden;\n }\n @media (max-width: ${a}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${r};\n }\n }\n @media (max-width: ${i}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${n};\n }\n .semiotic-small-multiple-panel {\n border-radius: 14px;\n }\n .semiotic-small-multiple-heading {\n padding: 9px 10px 0;\n }\n }\n `}),T.map((e,o)=>{const r={...F},n="function"==typeof t?t(e,{item:e,index:o,count:N,chartProps:r,sharedExtent:$}):R[o];return _T("article",{className:"semiotic-small-multiple-panel","aria-label":"string"==typeof e.title?e.title:void 0,children:[(e.title||e.subtitle||e.summary)&&_T("header",{className:"semiotic-small-multiple-heading",children:[e.title&&IT("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&IT("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&IT("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),IT("div",{className:"semiotic-small-multiple-plot",children:NT(n,r)})]},e.id??o)})]});return!0===y||"auto"===y&&(g||m||f||b||!0===v)&&!L?IT(Xc,{selections:b,showLegend:v,legendPosition:x,legendInteraction:w,legendSelectionName:k??B.name??"small-multiples",legendField:S??B.fields?.[0]??"category",children:E}):E}import*as BT from"react";import{Fragment as DT,jsx as FT,jsxs as ET}from"react/jsx-runtime";function zT({children:e,columns:t="auto",minCellWidth:o=300,gap:r=16,tabletColumns:n,mobileColumns:i=1,mobileBreakpoint:a=480,tabletBreakpoint:s=860,chartDefaults:l,className:c,style:u}){const d="semiotic-chart-grid-"+BT.useId().replace(/[^a-zA-Z0-9_-]/g,""),h="number"==typeof t?t:void 0,p="auto"===t?`repeat(auto-fill, minmax(${o}px, 1fr))`:`repeat(${t}, 1fr)`,m=["semiotic-chart-grid",d,c].filter(Boolean).join(" ");return ET(DT,{children:[FT("style",{children:`\n ${n?`\n @media (max-width: ${s}px) {\n .${d} {\n grid-template-columns: repeat(${n}, minmax(0, 1fr)) !important;\n }\n }`:""}\n @media (max-width: ${a}px) {\n .${d} {\n grid-template-columns: repeat(${i}, minmax(0, 1fr)) !important;\n }\n .${d} > [data-semiotic-chart-grid-primary="true"] {\n grid-column: span ${i} !important;\n }\n }\n `}),FT("div",{className:m,style:{display:"grid",gridTemplateColumns:p,gap:r,width:"100%",...u},children:BT.Children.map(e,e=>{if(!BT.isValidElement(e))return e;const t=e.props,o={};if(l)for(const[e,r]of Object.entries(l))null==t[e]&&(o[e]=r);const r=Object.keys(o).length>0?BT.cloneElement(e,o):e;return"primary"!==e.props.emphasis||void 0!==h&&2>h?r:FT("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:r})})})]})}zT.displayName="ChartGrid";import*as jT from"react";import{Fragment as OT,jsx as HT,jsxs as WT}from"react/jsx-runtime";function qT({children:e,context:t,position:o="right",contextSize:r=250,mobilePosition:n="bottom",mobileBreakpoint:i=480,gap:a=12,className:s,style:l}){const c="semiotic-context-layout-"+jT.useId().replace(/[^a-zA-Z0-9_-]/g,""),u="left"===o||"right"===o,d="left"===o||"top"===o,h={display:"flex",flexDirection:u?d?"row-reverse":"row":d?"column-reverse":"column",gap:a,width:"100%",...l},p=u?{flex:`0 0 ${r}px`,width:r,minHeight:0}:{flex:`0 0 ${r}px`,height:r,minWidth:0};return WT(OT,{children:[HT("style",{children:`\n @media (max-width: ${i}px) {\n .${c}[data-mobile-position="bottom"] {\n flex-direction: column !important;\n }\n .${c}[data-mobile-position="top"] {\n flex-direction: column-reverse !important;\n }\n .${c}[data-mobile-position="bottom"] > .semiotic-context-panel,\n .${c}[data-mobile-position="top"] > .semiotic-context-panel {\n flex: 0 0 auto !important;\n width: 100% !important;\n height: auto !important;\n }\n }\n `}),WT("div",{className:["semiotic-context-layout",c,s].filter(Boolean).join(" "),"data-mobile-position":n,style:h,children:[HT("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),HT("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}qT.displayName="ContextLayout";import{useState as GT,useEffect as YT,useRef as VT,useCallback as XT}from"react";import{jsx as UT,jsxs as KT}from"react/jsx-runtime";function QT({children:e,position:t="right",size:o=300,trigger:r="click",chartId:n,observation:i,dismissOnEmpty:a=!0,showClose:s=!0,onToggle:l,className:c,style:u}){const[d,h]=GT(null),[p,m]=GT(null),[f,g]=GT(!1),[y,b]=GT(!1),v=VT(null),x=VT(void 0),w="click"===r?["click","click-end"]:["hover","hover-end"],{latest:k}=$c({types:w,chartId:n,limit:1}),S=void 0!==i?i:k,A=XT(()=>{b(!0),g(!1),clearTimeout(x.current),x.current=setTimeout(()=>{b(!1),h(null),m(null)},200)},[]);if(YT(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;h(e.datum),m(e),g(e=>(e||(b(!0),clearTimeout(x.current),x.current=setTimeout(()=>b(!1),200)),!0))}else!a||"click-end"!==S.type&&"hover-end"!==S.type||A()},[a,A,S]),YT(()=>{l?.(f)},[f,l]),YT(()=>()=>clearTimeout(x.current),[]),!d&&!y)return null;const C=d&&p?e(d,p):null;if(null===C&&!y)return null;const M=function(e,t,o,r){const n={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:r?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return"right"===e?{...n,top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:o?"translateX(0)":`translateX(${t}px)`,opacity:o?1:0}:"bottom"===e?{...n,bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:o?"translateY(0)":`translateY(${t}px)`,opacity:o?1:0}:{...n,top:"50%",left:"50%",transform:o?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:o?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"}}(t,o,f,y);return KT("div",{ref:v,className:`semiotic-details-panel semiotic-details-${t}${c?" "+c:""}`,style:{...M,...u},children:[s&&UT("button",{className:"semiotic-details-close",onClick:A,"aria-label":"Close details",style:ZT,children:UT("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:UT("path",{d:"M2 2l8 8M10 2l-8 8"})})}),UT("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:C})]})}var ZT={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};QT.displayName="DetailsPanel";import{interpolateLab as JT}from"d3-interpolate";function eN(e){const t=e.unitValue??e.unit,o=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=o&&{icon:o}}}function tN(e,t={}){const o=[],r=e.tokenSemantics,n=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==n||function(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}(e.denominator)>100?80:100);return r||o.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),n||o.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||o.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&o.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==r||"icon"!==e.tokenType&&"glyph"!==e.tokenType||o.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===r&&n&&"unitized"!==n&&o.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===r&&n&&"fixed-denominator"!==n&&o.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==r&&"posterior-sample"!==r&&"hypothetical-case"!==r||!n||"quantile"===n||"sample"===n||"posterior-sample"===n||"random-sample"===n||o.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===r&&"unitized"===n&&null==e.unitValue&&null==e.unit&&o.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==r||"unitized"!==n||e.unitMeaning||o.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),o}function oN(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function rN(e){const t=oN(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function nN(e){const t=oN(e.taskIntent),o="small"===(r=e.availableSpace)?25:"large"===r?100:50;var r;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:o,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:tN(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:tN(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:tN(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:o,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:tN(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function iN(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));const o=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!o)return null;const[r,n,i]=[parseInt(o[1],16)/255,parseInt(o[2],16)/255,parseInt(o[3],16)/255],a=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*a(r)+.7152*a(n)+.0722*a(i)}function aN(e,t){const o=iN(e),r=iN(t);return null===o||null===r?null:(Math.max(o,r)+.05)/(Math.min(o,r)+.05)}var sN=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),lN=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),cN=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),uN=new Set(["LineChart","AreaChart","StackedAreaChart"]),dN=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]),hN=new Set(["LineChart","AreaChart","StackedAreaChart","ConnectedScatterplot"]),pN=new Set(["PieChart","DonutChart"]),mN={PieChart:"valueAccessor",DonutChart:"valueAccessor",FunnelChart:"valueAccessor"},fN=new Set(Object.keys(mN)),gN={StackedBarChart:"valueAccessor",StackedAreaChart:"yAccessor"},yN=new Set(["BigNumber"]),bN=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),vN=new Set(["StreamPhysicsFrame","GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]),xN=new Set(["OrbitDiagram",...vN]),wN=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart"]),kN=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","PhysicsCustomChart"]),SN=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),AN=new Set(["MultiAxisLineChart"]),CN=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),MN={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},PN=["xExtent","yExtent","rExtent"];function IN(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function _N(e,t,o){if("function"==typeof t)return t(e);const r="string"==typeof t?t:o;return e?.[r]}var LN=new Set(["category10","tableau10","set3","blues","reds","greens","oranges","purples","greys","viridis","plasma","inferno","magma","cividis","turbo"]),RN=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function TN(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function NN(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function $N(e,t){const o=NN(e.visibleTokens);if(null!=o)return o;const r=NN(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=r)return r;const n=NN(t.tokenCount),i=NN(t.maxTokens);return null!=n&&null!=i?Math.min(n,i):n??r??i}function BN(e,t){const o=[],r=r_(e,function(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,TN(t.encoding)&&delete t.encoding,t}(t));for(const e of r.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return t_[e]?(function(e,t,o){const r=t_[e];if(r){if("array"===r.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&o.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===r.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&o.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,o),function(e,t,o){const r=t.width,n=t.height;if(void 0===r||"number"==typeof r&&r>0||o.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===n||"number"==typeof n&&n>0||o.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,r]=t.size;(null!=e&&0>=e||null!=r&&0>=r)&&o.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${r}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,o),function(e,t,o){const r=t_[e];if(!r||"array"!==r.dataShape)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of r.dataAccessors){const r=t[e];"string"==typeof r&&(r in i||o.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${r}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,o),function(e,t,o){sN.has(e)&&Array.isArray(t.data)&&o.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,o),function(e,t,o){lN.has(e)&&(t.edges||t.data||o.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,o),function(e,t,o){const r=t_[e];if(!r||"array"!==r.dataShape)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&o.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${a}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,o),function(e,t,o){t.linkedHover&&!t.selection&&o.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,o),function(e,t,o){if(!cN.has(e))return;const r=t.rExtent||t.yExtent||t.valueExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&o.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${r[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,o),function(e,t,o){if(!uN.has(e))return;if(t.gapStrategy)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const n=t.yAccessor||"y";"string"==typeof n&&r.some(e=>{const t=e[n];return null==t||Number.isNaN(t)})&&o.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${n}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,o),function(e,t,o){const r=t.width??600,n=t.height??400,i=t.margin;if(!i||"object"!=typeof i)return;const a=(i.left||0)+(i.right||0),s=(i.top||0)+(i.bottom||0);r>a||o.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${a}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),n>s||o.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${s}px) >= height (${n}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,o),function(e,t,o){const r=t_[e];if(!r||"array"!==r.dataShape)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=[];t.xAccessor&&"string"==typeof t.xAccessor&&i.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&i.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&i.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(n.length,5);for(const e of i){let t=!0;for(let o=0;a>o;o++){const r=n[o]?.[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&o.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,o),function(e,t,o){if(!dN.has(e))return;const r=t.barPadding;"number"==typeof r&&10>r&&o.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${r} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,o),function(e,t,o){if("bottom"!==t.legendPosition)return;const r=t.margin;if(!r||"object"!=typeof r)return;const n=r.bottom;"number"==typeof n&&70>n&&o.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${n}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,o),function(e,t,o){if(!t.showLegend)return;if("right"!==(t.legendPosition??"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const n=r.right;"number"==typeof n&&100>n&&o.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${n}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,o),function(e,t,o){if("Heatmap"!==e)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const n=r[0];if(n&&"object"==typeof n)for(const e of["xAccessor","yAccessor"]){const r=t[e];if("string"!=typeof r)continue;const i=n[r];"string"==typeof i&&o.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${r}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,o),function(e,t,o){const r=t.colorScheme;if(!r||!Array.isArray(r))return;const n="string"==typeof t.background?t.background:"#ffffff";if(!n.startsWith("#"))return;const i=[];for(const e of r){if("string"!=typeof e||!e.startsWith("#"))continue;const t=aN(e,n);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&o.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${n}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,o),function(e,t,o){const r=t.colorScheme;if(!r||!Array.isArray(r)||2>r.length)return;const n=r.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>n.length)return;const i=[];for(let e=0;n.length-1>e;e++){const t=aN(n[e],n[e+1]);null!==t&&1.5>t&&i.push(`${n[e]} / ${n[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&o.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,o),function(e,t,o){const r=t.colorScheme;if("string"!=typeof r)return;const n=t_[e];n?.props?.colorScheme?.enum||LN.has(r)||o.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${r}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...LN].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}(e,t,o),function(e,t,o){const r="string"==typeof t.title&&t.title.trim().length>0,n="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;r||n||i||o.push({severity:"warning",code:"MISSING_DESCRIPTION",message:"No title, description, or summary provided. Screen readers will fall back to a generic chart-type label.",fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,o),function(e,t,o){const r=[];for(const e of RN)"function"==typeof t[e]&&r.push(e);r.length>0&&o.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${r.length>1?"s":""} detected: ${r.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference; closures over changing values can force unnecessary scene rebuilds on resize/rotation.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,o),function(e,t,o){const r=t.hoverRadius;"number"==typeof r&&r>0&&24>r&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&o.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${r}px is below the ~24px radius needed for reliable 48px touch targets on mobile screens.`,fix:"Use hoverRadius={24} or larger for touch-heavy views. Semiotic floors touch pointer hit testing to 24px, but explicit desktop-only radii should be documented."})}(0,t,o),function(e,t,o){!0===t.responsiveWidth&&!0===t.responsiveHeight&&o.push({severity:"warning",code:"RESPONSIVE_BOTH_AXES",message:"responsiveWidth and responsiveHeight are both true. On mobile this can create resize feedback loops when the parent height depends on chart content.",fix:"Prefer responsiveWidth={true} with a fixed parent height or size={[width, fixedHeight]}; use a ResizeObserver outside the chart if the height must follow aspect ratio."})}(0,t,o),function(e,t,o){if(!0!==t.showParticles)return;const r=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},n="number"==typeof r.maxPerLine?r.maxPerLine:void 0,i="number"==typeof r.spawnRate?r.spawnRate:void 0;("number"==typeof n&&n>20||"number"==typeof i&&i>.08)&&o.push({severity:"warning",code:"GEO_PARTICLE_MOBILE_COST",message:"Animated geo particles run a continuous canvas loop that can drain battery and trigger thermal throttling on mobile GPUs.",fix:"Set particleStyle={{ maxPerLine: 12, spawnRate: 0.06 }} for mobile-heavy views, or disable showParticles when reduced-motion or low-power modes are active."})}(0,t,o),function(e,t,o){const r=[];TN(t.tokenEncoding)&&r.push({source:"tokenEncoding",encoding:t.tokenEncoding}),TN(t.encoding)&&r.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:n}of r){const r=$N(t,n);for(const t of tN(n,{visibleTokens:r}))o.push({severity:"warning",code:"TOKEN_"+t.code,message:t.message,fix:"MISSING_UNIT_VALUE"===t.code?`Set ${e}.unitValue to the value represented by one full token.`:"MISSING_UNIT_MEANING"===t.code?`Set ${e}.unitMeaning so readers know what one full token represents.`:"MISSING_COUNT_STRATEGY"===t.code?`Set ${e}.countStrategy to actual, unitized, fixed-denominator, quantile, sample, posterior-sample, or random-sample.`:"TOKEN_SEMANTICS_UNCLEAR"===t.code?`Set ${e}.tokenSemantics to observed-unit, unitized-measure, risk-case, possible-outcome, posterior-sample, hypothetical-case, topic-anchor, or decorative.`:`Adjust ${e} so its semantics, strategy, labels, and visible token count match the task.`})}}(0,t,o),function(e,t,o){const r=Array.isArray(t.annotations)?t.annotations:null;if(r)for(const e of r){if(!e||"object"!=typeof e)continue;const t=Yn(e);if(!Vn(e)||"widget"===t)continue;const r=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),n="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,i=Xn(e);!i&&r>120?o.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${n}" sits ~${Math.round(r)}px from its anchor with no connector — a reader can't tell what it refers to.`,fix:'Add a connector (connector: { end: "arrow" }, the label/callout default) or place the note adjacent to its target (smaller dx/dy).'}):i&&r>250&&o.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${n}" uses a very long connector (~${Math.round(r)}px); prefer placing the note adjacent to its target when space allows.`,fix:"Reduce dx/dy so the note sits near its target, or keep the long connector only if proximity is genuinely infeasible."})}}(0,t,o),function(e,t,o){const r=Array.isArray(t.annotations)?t.annotations:null;if(!r)return;const n=r.filter(Vn).length;if(0===n)return;const i="number"==typeof t.width?t.width:600,a="number"==typeof t.height?t.height:400,s=Kn(i,a);Number.isFinite(s)&&n>s&&o.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${n} note annotations on a ${i}×${a} chart exceed the ~${s} notes the plot area carries comfortably — the chart may read as cluttered.`,fix:'Mark the essential notes emphasis: "primary" and let density management shed the rest (autoPlaceAnnotations: { density: true }), enable progressive disclosure to reveal secondary notes on hover, or give the chart more room.'})}(0,t,o),function(e,t,o){for(const e of PN){const r=t[e];if(!Array.isArray(r)||2>r.length)continue;const[n,i]=r;"number"==typeof n&&"number"==typeof i&&n>i&&o.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${n}, ${i}] is descending — the axis renders inverted, so "up" reads as less. Inverted axes are a classic misleading-design pattern unless the inversion is the point.`,fix:`Order the extent ascending (${e}={[${i}, ${n}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}(0,t,o),function(e,t,o){if("MultiAxisLineChart"!==e)return;const r=t.series;if(!Array.isArray(r)||2!==r.length)return;const n=r.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);n.length>0&&o.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${n.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}(e,t,o),function(e,t,o){if(!uN.has(e))return;const r=t.xExtent;if(!Array.isArray(r)||2>r.length)return;const[n,i]=r;if("number"!=typeof n||"number"!=typeof i||n>=i)return;const a=t.data;if(!a||!Array.isArray(a)||4>a.length)return;const s=t.xAccessor??"x";if("string"!=typeof s)return;let l=1/0,c=-1/0;for(const e of a){const t=e?.[s];"number"==typeof t&&Number.isFinite(t)&&(l>t&&(l=t),t>c&&(c=t))}if(!Number.isFinite(l)||!Number.isFinite(c)||l>=c)return;const u=c-l,d=Math.max(0,Math.min(i,c)-Math.max(n,l))/u;.7>d&&o.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${n}, ${i}] shows only ~${Math.round(100*d)}% of the data's x range [${l}, ${c}] — a trend cropped to a favorable window is a classic misleading-design pattern.`,fix:'Widen xExtent to cover the data, filter the data itself so the chart shows what it has, or annotate the visible window ("Q4 only") so the cropping is explicit.'})}(e,t,o),function(e,t,o){const r=mN[e],n=gN[e];if(!r&&!n)return;if(n&&!t.normalize)return;const i=r??n,a=t[i],s="string"==typeof a?a:"yAccessor"===i?"y":"value",l=t.data;if(!l||!Array.isArray(l)||0===l.length)return;const c=l.filter(e=>{const t=e?.[s];return"number"==typeof t&&0>t});c.length>0&&o.push({severity:r?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${c.length} negative value(s) in "${s}" — a part-to-whole encoding cannot represent negative parts${r?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:r?"Filter or transform negative values first, or switch to a BarChart/WaterfallChart, which encode signed values honestly.":"Drop normalize for signed data, or use a diverging BarChart so negative contributions read as negative."})}(e,t,o),function(e,t,o){hN.has(e)&&"basis"===t.curve&&o.push({severity:"warning",code:"NON_PASSING_CURVE",message:'curve="basis" draws a B-spline that does NOT pass through your data points — rendered values differ from actual values everywhere except the endpoints.',fix:'Use curve="monotoneX" or curve="catmullRom" (both interpolate through every point), or keep "basis" only for deliberately schematic, clearly-labeled smoothing.'})}(e,t,o),function(e,t,o){if("LineChart"!==e&&"AreaChart"!==e)return;if("sparkline"===t.mode)return;if(t.responsiveWidth||t.responsiveHeight)return;const r="number"==typeof t.width?t.width:600,n="number"==typeof t.height?t.height:400;if(0>=r||0>=n)return;const i=r/n;if(i>8||.25>i){const e=i>8?"flattens":"exaggerates";o.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${r}×${n} (${i.toFixed(1)}:1) is an extreme aspect ratio that ${e} the slopes a reader perceives — aspect-ratio distortion is a documented misleading-design pattern.`,fix:i>8?'Use a more balanced aspect (e.g. width/height between 1 and 3), or set mode="sparkline" if this is genuinely a sparkline strip.':"Use a more balanced aspect (e.g. width/height between 1 and 3); very tall trend charts overstate every change."})}}(e,t,o),function(e,t,o){if(!pN.has(e))return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const n=t.categoryAccessor,i="string"==typeof n?n:"category",a=new Set;for(const e of r){const t=e?.[i];null!=t&&a.add(t)}a.size>8&&o.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:a.size+" slices — angle judgments degrade rapidly past ~8 categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.",fix:`Use a BarChart or DotPlot for ${a.size} categories, or group the long tail into an "Other" slice before charting.`})}(e,t,o),function(e,t,o){if(kN.has(e)){if("GaltonBoardChart"===e){const e=t.bins;"number"==typeof e&&2>e&&o.push({severity:"error",code:"PHYSICS_BAD_BINS",message:`bins=${e} leaves no meaningful settled projection for a Galton board.`,fix:"Use at least two bins; 8-24 bins is a practical range for physics distributions."});const r=IN(t.branchProbability);null!=t.branchProbability&&(null==r||0>r||r>1)&&o.push({severity:"error",code:"PHYSICS_BAD_BRANCH_PROBABILITY",message:`branchProbability=${t.branchProbability+""} must be between 0 and 1.`,fix:"Use branchProbability={0.5} for a balanced Galton board, or bias it within the [0, 1] range."});const n=IN(t.mechanicalCount);null==t.mechanicalCount||null!=n&&n>0||o.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical Galton board.`,fix:"Use a positive mechanicalCount, for example 96."})}if("EventDropChart"===e){const e=t.windows,r=e&&"object"==typeof e?IN(e.size):null;null==r||r>0||o.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${r} cannot form event-time barriers.`,fix:"Set windows={{ size: positiveNumber }} so each event can settle into a real time window."}),"number"!=typeof t.timeScale||t.timeScale>0||o.push({severity:"error",code:"PHYSICS_BAD_TIME_SCALE",message:`timeScale=${t.timeScale} prevents arrival replay from advancing.`,fix:"Use a positive timeScale, or omit it for the default pace."});const n=Array.isArray(t.data)?t.data:[];if(n.length>0){const e=t.timeAccessor||"time",r=t.arrivalAccessor||"arrivalTime";n.some(t=>{const o=IN(_N(t,e,"time")),n=IN(_N(t,r,"arrivalTime"));return null!=o&&null!=n&&o!==n})||o.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("PhysicsPileChart"===e){const e=IN(t.mechanicalCount);null==t.mechanicalCount||null!=e&&e>0||o.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical pile chart.`,fix:"Use a positive mechanicalCount, for example 80."}),"mechanical"===t.mode&&Array.isArray(t.mechanicalCategories)&&0===t.mechanicalCategories.length&&o.push({severity:"error",code:"PHYSICS_EMPTY_MECHANICAL_CATEGORIES",message:"mechanicalCategories=[] leaves no containers for the generated unit pile.",fix:"Provide at least one category label, or omit mechanicalCategories for the default set."});const r=IN(t.unitValue??1)??1;if(0>=r)return void o.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});const n=t.valueAccessor||"value",i=(Array.isArray(t.data)?t.data:[]).reduce((e,t)=>{const o=IN(_N(t,n,"value"))??0;return e+Math.max(0,Math.round(o/r))},0);i>1500&&o.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`PhysicsPileChart would create about ${i} live bodies; motion may dominate the chart and stress the frame budget.`,fix:"Increase unitValue, cap visible units, or aggregate before rendering so the settled projection remains readable."})}if("CollisionSwarmChart"===e){if((IN(t.pointRadius??5)??5)>0||o.push({severity:"error",code:"PHYSICS_BAD_POINT_RADIUS",message:`pointRadius=${t.pointRadius} cannot produce collision bodies.`,fix:"Use a positive pointRadius, for example 5."}),(IN(t.collisionIterations??6)??6)>0||o.push({severity:"error",code:"PHYSICS_BAD_COLLISION_ITERATIONS",message:`collisionIterations=${t.collisionIterations} disables collision relaxation.`,fix:"Use at least one collision iteration; 4-8 is a practical range for swarms."}),null!=t.xExtent){const e=Array.isArray(t.xExtent)?t.xExtent:[],r=IN(e[0]),n=IN(e[1]);(2>e.length||null==r||null==n)&&o.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}const e=Array.isArray(t.data)?t.data:[];e.length>1200&&o.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`CollisionSwarmChart would create ${e.length} live bodies; collision relaxation may dominate the frame budget.`,fix:"Sample, aggregate, reduce point radius, or move to a static SwarmPlot when every row does not need a physical body."});const r=t.groupAccessor;if(e.length>0&&r){const t=new Set;for(const o of e){const e=_N(o,r,"group");null!=e&&t.add(e)}t.size>12&&o.push({severity:"warning",code:"PHYSICS_TOO_MANY_SWARM_LANES",message:`CollisionSwarmChart has ${t.size} group lanes, which leaves little vertical room for collision separation.`,fix:"Facet or filter groups, or use an ordinary SwarmPlot/BoxPlot for dense grouped comparison."})}}if("GaltonBoardChart"!==e&&"PhysicsPileChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"EventDropChart"!==e||(null!=t.massBy||null!=t.massAccessor||t.frameProps&&"object"==typeof t.frameProps&&null!=t.frameProps.bodyMassBy)&&o.push({severity:"warning",code:"PHYSICS_DATA_IN_DYNAMICS",message:e+" appears to map a data field to mass/dynamics. Mass is not a readable quantitative channel.",fix:"Encode quantities in spawn position, bin, size, color, or glyph — keep mass/friction/restitution as process texture. Use showProjection for the truth layer."}),"PhysicsPileChart"!==e&&"GaltonBoardChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e||!1!==t.showProjection||o.push({severity:"warning",code:"PHYSICS_NO_PROJECTION",message:e+" has showProjection={false}. Without a settled projection, motion is easy to over-read as data.",fix:"Keep showProjection enabled (default) so the chart collapses to a legible static reading, or document why the process alone is the claim."}),"ProcessFlowChart"===e){const e=Array.isArray(t.stages)?t.stages:[];if(0===e.length)o.push({severity:"error",code:"PROCESS_FLOW_MISSING_STAGES",message:"ProcessFlowChart requires a non-empty stages array.",fix:'Provide stages={[{ id: "coding", force: 12 }, { id: "merged", absorb: true }]}.'});else{e.some(e=>!e||null==e.id||""===(e.id+"").trim())&&o.push({severity:"error",code:"PROCESS_FLOW_BAD_STAGE",message:"Every ProcessFlowChart stage needs a stable id.",fix:'Use stages like { id: "review", label: "Review", capacity: { unitsPerSecond: 4 } }.'});const r=e.filter(e=>e?.absorb).length;t.groupBy&&0===r&&o.push({severity:"warning",code:"PROCESS_FLOW_GROUP_NO_ABSORB",message:"groupBy is set but no stage has absorb: true, so all-members completion cannot resolve.",fix:'Mark a terminal stage with absorb: true (e.g. merged), or set groupCompletion="none".'})}}if("GauntletChart"===e&&(Array.isArray(t.negativeProperties)||o.push({severity:"warning",code:"GAUNTLET_MISSING_NEGATIVE_PROPERTIES",message:"GauntletChart usually needs negativeProperties for drag/cost bodies (empty array is ok if intentional).",fix:'Provide negativeProperties={[{ id: "cost", label: "Cost", load: 1 }]} or explicitly pass [].'})),"PhysicsPileChart"===e||"GaltonBoardChart"===e||"CollisionSwarmChart"===e||"ProcessFlowChart"===e||"EventDropChart"===e){const r=Array.isArray(t.data)?t.data:[],n=IN(t.mechanicalCount)??0,i=r.length>0?r.length*("PhysicsPileChart"===e?Math.max(1,(IN(t.unitValue),1)):1):n;i>2500&&o.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(i)} live bodies, which can overwhelm the simulation loop.`,fix:"Lower mechanicalCount / unitize with a larger unitValue, enable sediment/windowSize, or sample the data before spawn."})}}}(e,t,o),{ok:o.every(e=>"warning"===e.severity),diagnoses:o}):{ok:0===o.length,diagnoses:o}}var DN=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]);function FN(e){return"string"==typeof e&&e.trim().length>0}function EN(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=function(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}(e)}function zN(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const o=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return o?o.length:1}function jN(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function ON(e,t,o={}){const r=[],n=S_(e),i=vN.has(e),a=!!t_[e]||!!n||i,s=!0===o.inChartContainer,l=!0===o.describe,c=!0===o.navigable,u=yN.has(e),d=sN.has(e),h=!1!==t.accessibleTable&&!u,p=FN(t.title),m=FN(t.description),f=FN(t.summary),g=p||m||f,y=function(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}(t),b=function(e){const t=jN(e),o=e.controls&&"object"==typeof e.controls?e.controls:{};return!0===e.pauseControl||!0===t.pauseControl||!0===o.pause||"function"==typeof o.pause}(t),v=i,x=function(e){const t=jN(e);return!0===e.settledProjection||!0===t.settledProjection}(t)||wN.has(e)&&h,w=function(e){const t=jN(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}(t)||v,k=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],S=a?"pass":"manual",A=a?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(r.push(function(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},o=e.colorScheme,r="string"==typeof e.background?e.background:null;if(r&&!r.startsWith("#"))return{...t,status:"manual",message:`Background "${r}" isn't a hex literal (theme/CSS variable) — contrast can't be verified statically.`,fix:'Pass a hex `background` (e.g. "#ffffff"/"#000000"), or verify contrast manually once the theme resolves.'};const n=r??"#ffffff";if(!Array.isArray(o))return{...t,status:"manual",message:"Mark colors come from the theme/CSS variables — contrast can't be verified statically.",fix:"Confirm geometries/large text have ≥ 3:1 and regular text ≥ 4.5:1 contrast against the background."};const i=[];let a=0;for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=aN(e,n);null!=t&&(a++,3>t&&i.push(`${e} (${t.toFixed(1)}:1)`))}return 0===a?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:i.length>0?{...t,status:"fail",message:`${i.length} color(s) fall below 3:1 contrast vs ${n}: ${i.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${a} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${n}.`}}(t)),r.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...u?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:h?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:m&&f?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."}}),r.push({id:"perceivable.small-text",principle:"perceivable",heuristic:"Small text size",critical:!0,status:"pass",message:"Semiotic's default tick and axis-label fonts are 12px, meeting Chartability's 9pt/12px floor.",fix:"If a theme or override lowers --semiotic-tick-font-size below 12px, raise it back for low-vision audiences."}),r.push({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0,...null!=t.pulse||xN.has(e)?{status:"manual",message:"Pulse/continuous animation is in use. Confirm nothing flashes more than 3×/sec, especially saturated red.",fix:"Avoid red flashes and rapid (>3 Hz) flicker; reduced-motion is auto-honored, but verify the default presentation."}:{status:"manual",message:"No flashing detected statically. Confirm no element flashes more than 3×/sec.",fix:"Manual check — most static charts pass trivially."}}),null!=t.colorBy){r.push({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...!0===t.directLabel||!0===t.showLabels?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:"Categories are encoded by color (colorBy) with no redundant channel — Semiotic does not yet ship texture/pattern fills.",fix:"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy), keep categories ≤ ~7, and use a CVD-safe palette."}});const e=Array.isArray(t.colorScheme)?t.colorScheme:null,o=e?e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase()):[],n=o.length>0&&o.every(e=>DN.has(e));r.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...n?{status:"pass",message:"colorScheme uses Semiotic's Wong colorblind-safe palette."}:{status:"manual",message:"Color encodes meaning; statically we can't confirm the palette is colorblind-safe.",fix:'Use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic", or test your scheme with Viz Palette / Chroma.'}}),r.push({id:"flexible.textures-adjustable",principle:"flexible",heuristic:"Contrast and textures cannot be adjusted",critical:!1,status:"warn",message:"There's no per-category texture/pattern channel to toggle as an alternative to color.",fix:"Until texture fills land, ensure the encoding survives color removal: direct labels + a CVD-safe palette. Contrast itself is themeable via CSS variables."})}{const e=k.filter(Vn);if(e.length>0){const o=t.autoPlaceAnnotations,n="object"==typeof o&&null!==o&&!0===o.redundantCues,i=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=Yn(e),o=n&&"text"===t;return!(Xn(e)||o)});r.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===i.length?{status:"pass",message:"No annotation relies on color alone to indicate its target — wherever color is used, a connector, enclosure, or reference-line cue is present too."}:{status:"warn",message:`${i.length} of ${e.length} annotation(s) carry a color but no connector, enclosure, or reference-line cue, so a color-blind or non-visual reader can't tie them to their target (the correspondence problem).`,fix:"Add a connector (the label/callout default), place the note adjacent to its target, enclose the target, or enable autoPlaceAnnotations: { redundantCues: true } to give colored text notes a leader line — don't rely on color matching alone."}})}}r.push({id:"operable.single-input-modality",principle:"operable",heuristic:"Interaction modality only has one input type",critical:!0,...a?{status:"pass",message:"Built-in keyboard navigation (arrows/Home/End/PageUp-Down/Enter) mirrors mouse hover."}:{status:"manual",message:`Can't confirm keyboard support for "${e}".`,fix:"Verify Tab + arrow-key operation."}});{const e=[];null==t.brush&&null==t.onBrush||e.push("brushing"),!0===t.zoomable&&e.push("zoom/pan"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||e.push("legend filtering"),e.length>0&&r.push({id:"operable.complex-action-alternatives",principle:"operable",heuristic:"Complex actions have no alternatives",critical:!1,status:"warn",message:`Mouse-driven ${e.join(", ")} ${e.length>1?"have":"has"} no built-in keyboard/standard-UI equivalent.`,fix:"Pair the complex interaction with a standard control (range inputs for a brush, buttons for zoom, a checkbox list for legend filtering) operable by keyboard and screen reader."})}{const o=MN[e];if(o&&y){const e=t[o];"number"==typeof e&&e>0&&24>2*e&&r.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${o}=${e} gives a ~${2*e}px hit target, below the 24×24px minimum for pointer interaction.`,fix:"Increase the radius, or rely on the chart's hoverRadius / keyboard navigation as the alternative for precise selection."})}}r.push({id:"operable.tab-stops",principle:"operable",heuristic:"Inappropriate tab stops",critical:!1,status:S,message:`The chart takes a single tab stop and navigates data with arrow keys${A} — the recommended pattern for dense charts (no per-datum tab stops to wade through).`}),r.push({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0,...y?f||m?{status:"manual",message:"Chart is interactive and has descriptive text. Confirm that text explains how to interact (keyboard + pointer).",fix:'State the interaction model in summary, e.g. "Use arrow keys to move between points."'}:{status:"warn",message:"Chart is interactive but nothing explains how to use it.",fix:"Describe the interaction in a summary or nearby text (keyboard navigation, what hover/click reveals)."}:{status:"not-applicable",message:"No interactive behavior detected."}}),r.push({id:"operable.controls-override-at",principle:"operable",heuristic:"Controls override AT controls",critical:!0,status:S,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${A}.`}),r.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:S,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${A}.`,fix:a?"Ensure --semiotic-focus keeps ≥ 3:1 contrast against your background.":void 0}),r.push({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0,...g?{status:"pass",message:`Provided: ${[p&&"title",m&&"description",f&&"summary"].filter(Boolean).join(", ")}.`}:s?{status:"manual",message:"No title/description/summary on the chart. If the wrapping ChartContainer supplies a title/subtitle, this is covered at that layer — verify it does.",fix:"Give the ChartContainer a title (and optionally enable describe), or set title/description/summary on the chart."}:{status:"fail",message:"No title, description, or summary — the screen reader falls back to a generic label.",fix:"Add title/description/summary on the chart, or wrap it in a ChartContainer (the opt-in layer for title/caption/description chrome)."}}),r.push({id:"understandable.explain-purpose",principle:"understandable",heuristic:"No explanation for purpose or for how to read",critical:!0,...m||f?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:l?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:p?{status:"warn",message:"Only a title is set — a label, not an explanation of purpose or how to read the chart.",fix:"Add a summary, or enable ChartContainer's describe option for an auto-generated how-to-read description."}:{status:"fail",message:"Nothing explains the chart's purpose or how to read it.",fix:"Add a summary/description, or wrap in a ChartContainer with a title and the describe option (the opt-in full-accessibility layer)."}});{const e=[t.description,t.summary].filter(FN).join(". "),o=e?function(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),o=e.trim().split(/\s+/).filter(Boolean);if(0===o.length||0===t.length)return null;let r=0;for(const e of o)r+=zN(e);return o.length/t.length*.39+r/o.length*11.8-15.59}(e):null;r.push({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0,...null==o?{status:"not-applicable",message:"No description/summary text to grade."}:o>9?{status:"warn",message:`Description/summary reads at ~grade ${o.toFixed(0)}; Chartability targets grade 9 or lower.`,fix:"Shorten sentences and prefer common words."}:{status:"pass",message:`Description/summary reads at ~grade ${Math.max(0,Math.round(o))} (≤ 9).`}})}if(bN.has(e)){const e=FN(t.xLabel),o=FN(t.yLabel);r.push({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1,...e&&o?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!o&&"yLabel"].filter(Boolean).join(", ")}. Ticks alone may not name the variable.`,fix:"Set xLabel and yLabel to name each axis's variable and units."}})}if(AN.has(e)&&r.push({id:"understandable.information-complexity",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,status:"warn",message:"Dual-axis chart: two y-scales are hard to read accurately and notoriously easy to misinterpret (the crossover point is arbitrary).",fix:"Confirm the second axis is necessary; consider two aligned charts (small multiples) or indexing both series to a common baseline. Label each axis and its series unambiguously."}),k.length>1){const e=k.filter(EN).length;r.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===k.length?{status:"pass",message:`All ${k.length} annotation(s) declare hierarchy through emphasis or provenance confidence, so the renderer can resolve reading order and visual priority.`}:0===e?{status:"warn",message:k.length+" annotations are present with no emphasis or provenance confidence; readers may not know which note is primary.",fix:'Mark the main annotation with emphasis="primary", set supporting notes to emphasis="secondary", or provide provenance.confidence so Semiotic can infer order.'}:{status:"warn",message:`${k.length-e} of ${k.length} annotation(s) have no emphasis or provenance confidence; readers may not know which note is primary among the unordered notes.`,fix:"Set emphasis on each annotation (primary/secondary), or provide provenance.confidence on all annotations so Semiotic can infer order."}})}(null!=t.forecast||null!=t.anomaly||null!=t.band||null!=t.regression)&&r.push({id:"understandable.uncertainty",principle:"understandable",heuristic:"Statistical uncertainty isn't clearly communicated",critical:!1,status:"manual",message:"The chart shows a forecast/regression/band/anomaly overlay. Confirm the uncertainty it represents is explained in text, not just drawn.",fix:"State the confidence interval / method in the summary, and label the band so it isn't mistaken for data."}),null!=t.animate&&!1!==t.animate&&r.push({id:"understandable.changes-followable",principle:"understandable",heuristic:"Changes are not easy to follow",critical:!1,status:S,message:`Transitions animate with object constancy and data changes are mirrored to the live region${A}.`,fix:a?"Keep transition durations in the 250ms–2s range so changes are followable but not slow.":void 0}),r.push({id:"robust.conforms-to-standards",principle:"robust",heuristic:"Does not conform to standards",critical:!1,status:"manual",message:"WCAG 2.1 / Section 508 conformance can't be settled from config alone.",fix:"Run an automated checker (axe) on the rendered output and test with real assistive tech."}),r.push({id:"robust.semantically-valid",principle:"robust",heuristic:"Semantically invalid",critical:!1,status:"manual",message:"Whether interactive elements expose correct roles/names is a render-time, screen-reader question.",fix:"Verify with a screen reader that buttons read as buttons, the chart as an image/group, etc."}),r.push({id:"robust.fragile-technology-support",principle:"robust",heuristic:"Fragile technology support",critical:!1,status:S,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${A}.`,fix:a?"Still test across NVDA+Firefox, JAWS+Chrome, and VoiceOver+Safari — AT support varies.":void 0}),r.push({id:"compromising.table",principle:"compromising",heuristic:"No table",critical:!0,...u?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:h?{status:"pass",message:"A human-readable data table is provided (accessibleTable)."}:{status:"fail",message:"accessibleTable is disabled — no human-readable table of the underlying data.",fix:"Remove accessibleTable={false} (unless title/summary/annotations already convey all the data)."}}),u||r.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...s?{status:"manual",message:"Rendered in a ChartContainer. If a data-download action is enabled, the data is exportable.",fix:"Enable the ChartContainer data-download action so users can save the underlying data (keep it opt-in)."}:{status:"warn",message:"The data table is read-only — not downloadable, sortable, or filterable.",fix:"Wrap the chart in a ChartContainer and enable its data-download action (opt-in, so deployments can withhold it where export isn't allowed)."}}),r.push({id:"compromising.shareable-state",principle:"compromising",heuristic:"State is not easy to share and reproduce",critical:!1,status:a?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${a?"":A}.`,fix:a?"Expose it to users via the ChartContainer copyConfig action or a shareable URL.":void 0}),r.push({id:"compromising.navigable-structure",principle:"compromising",heuristic:"Information cannot be navigated according to narrative or structure",critical:!1,...c?{status:"pass",message:"ChartContainer's navigable option mounts a structured tree (chart → axes/series → data points) that screen readers can traverse."}:d?{status:"warn",message:"Hierarchical chart: built-in keyboard navigation is largely flat — it doesn't descend the tree structure.",fix:"Enable ChartContainer's navigable option for a structured navigation tree, or lean on the data table and a summary that conveys the hierarchy."}:{status:S,message:`Keyboard navigation steps through points and switches series/groups${A}.`,fix:a?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{const o=Array.isArray(t.data)?t.data:null,n=Array.isArray(t.nodes)?t.nodes:null,i={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let a;a=fN.has(e)&&o&&o.length>7?{...i,status:"warn",message:o.length+" slices in a part-to-whole chart. Chartability suggests ≤ 5 categories; many thin slices are hard to perceive and to describe.",fix:'Group small slices into an "Other" category, or switch to a ranked bar chart.'}:n&&n.length>200?{...i,status:"warn",message:n.length+" nodes. A network this size is hard to navigate non-visually node by node.",fix:"Provide a summary of structure (clusters, hubs, components) and consider filtering or aggregating the graph."}:o&&o.length>5e3?{...i,status:"warn",message:o.length+" data points. Canvas renders this fine, but the non-visual table/navigation become unwieldy.",fix:"Aggregate or bin for the accessible representation, or expose summary statistics rather than every row."}:o?{...i,status:"pass",message:o.length+" data points — a reasonable density for non-visual consumption."}:n?{...i,status:"pass",message:n.length+" nodes — a reasonable density for non-visual consumption."}:{...i,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},r.push(a)}{const e=Array.isArray(t.data)?t.data:null,o=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let n=!1;if(e&&!o)for(const t of e.slice(0,50))if(t&&"object"==typeof t){for(const e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){n=!0;break}if(n)break}n&&r.push({id:"assistive.human-readable-numbers",principle:"assistive",heuristic:"Data in text is not human-readable",critical:!1,status:"warn",message:'Data includes large numbers (≥ 100,000) and no value/tick formatter — screen readers will read every digit (e.g. "six hundred fifty thousand…").',fix:'Pass valueFormat / yFormat (e.g. a compact formatter so 6,500,000 reads as "6.5M"); the formatter flows to ticks, tooltips, and the data table.'})}r.push({id:"assistive.features-described",principle:"assistive",heuristic:"Visually apparent features and relationships are not described",critical:!1,...l?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:f?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."}}),r.push({id:"assistive.skippable-navigation",principle:"assistive",heuristic:"Navigation and interaction is tedious",critical:!0,...u?{status:"not-applicable",message:"Single value — nothing to skip."}:h?{status:"pass",message:'A "Skip to data table" link lets screen-reader users bypass point-by-point navigation.'}:{status:"warn",message:"accessibleTable is off, removing the skip-to-table affordance.",fix:"Keep accessibleTable enabled so users can skip past dense point navigation."}}),r.push({id:"flexible.user-style-respected",principle:"flexible",heuristic:"User style change not respected",critical:!0,status:S,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${A}.`,fix:a?"Avoid hardcoding colors via frameProps style fns that bypass theme variables.":void 0}),r.push({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...xN.has(e)||SN.has(e)?b?{status:"pass",message:e+" animates continuously and declares an in-chart pause/stop control."}:{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:S,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${A}.`}}),i&&(r.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...b?{status:"pass",message:"Physics simulation exposes a pause/stop control for users who need to stop motion."}:{status:"warn",message:"Physics simulation has no declared pause/stop control.",fix:"Provide a visible pause control and set physics.pauseControl=true (or pauseControl=true) so the contract is auditable."}}),r.push({id:"flexible.settled-projection",principle:"flexible",heuristic:"User style change not respected",critical:!1,...x?{status:"pass",message:"A settled-projection table is declared, so non-visual readers get aggregate chart semantics instead of trajectories."}:{status:"warn",message:"Physics chart does not declare a settled projection for its accessible table.",fix:"Provide aggregate rows from the settled projection and set physics.settledProjection=true."}}),r.push({id:"flexible.reduced-motion-settle",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...w?{status:"pass",message:"Reduced-motion mode settles the simulation to a static chart state instead of freezing bodies mid-flight."}:{status:"warn",message:"Physics chart does not declare reduced-motion synchronous settle behavior.",fix:"In reduced motion, run the world to its settled projection and paint once; set physics.reducedMotionSettle=true."}}));{const o=!0===t.responsiveWidth||!0===t.responsiveHeight,n=CN.has(e)&&!0===t.zoomable;r.push({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1,...o?{status:"pass",message:`Chart reflows to its container (${[!0===t.responsiveWidth&&"responsiveWidth",!0===t.responsiveHeight&&"responsiveHeight"].filter(Boolean).join(", ")}), so page zoom doesn't clip it.`}:n?{status:"pass",message:"Geo chart is zoomable/pannable."}:{status:"manual",message:"Fixed width/height — verify the chart survives browser zoom and reflow without clipping or loss of function.",fix:"Use responsiveWidth/responsiveHeight so the chart reflows to its container."}})}if(n){const e=n.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));e&&r.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:n.name+" declares a color encoding without a redundant cue.",fix:"Add shape, label, position, texture, or a textual category summary to the recipe encoding."}),"required"!==n.accessibility.description||FN(t.description)||r.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:n.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),n.accessibility.fallbackTable&&!1===t.accessibleTable&&r.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:n.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."})}const C=r.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),M={criticalsPassed:C.filter(e=>"pass"===e.status).length,criticalsEvaluated:C.length,fails:r.filter(e=>"fail"===e.status).length,warnings:r.filter(e=>"warn"===e.status).length,manual:r.filter(e=>"manual"===e.status).length,passes:r.filter(e=>"pass"===e.status).length};return{component:e,ok:!C.some(e=>"fail"===e.status),summary:M,findings:r,reference:"Chartability (POUR-CAF) — https://chartability.github.io/POUR-CAF/. Not a pass/fail cert; pair with manual screen-reader testing (NVDA+Firefox, JAWS+Chrome, VoiceOver+Safari)."}}function HN(e,{onlyCritical:t=!1}={}){const o=[];for(const r of e.findings)"fail"!==r.status&&"warn"!==r.status||t&&!r.critical||o.push(r.message);return o}var WN={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},qN=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function GN(e){const t=[],o=e.summary,r=e.ok?`${o.criticalsPassed}/${o.criticalsEvaluated} critical heuristics pass`:`${o.fails} blocking failure(s) — ${o.criticalsPassed}/${o.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${r} · ${o.warnings} warning(s) · ${o.manual} to verify manually`);for(const o of qN){const r=e.findings.filter(e=>e.principle===o&&"not-applicable"!==e.status);if(0!==r.length){t.push(""),t.push(" "+o.toUpperCase());for(const e of r)t.push(` ${WN[e.status]} ${e.id}${e.critical?" [critical]":""}: ${e.message}`),!e.fix||"fail"!==e.status&&"warn"!==e.status&&"manual"!==e.status||t.push(" → "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function YN(e){const t={};for(const[o,r]of e){const e=[];for(const[,t]of r.clauses){const o={};for(const[e,r]of Object.entries(t.fields))o[e]="point"===r.type?{type:"point",values:Array.from(r.values)}:{type:"interval",range:r.range};e.push({clientId:t.clientId,type:t.type,fields:o})}t[o]={name:r.name,resolution:r.resolution,clauses:e}}return t}function VN(e){const t=new Map;for(const[o,r]of Object.entries(e)){const e=new Map;for(const t of r.clauses){const o={};for(const[e,r]of Object.entries(t.fields))o[e]="point"===r.type?{type:"point",values:new Set(r.values)}:{type:"interval",range:r.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:o})}t.set(o,{name:r.name,resolution:r.resolution,clauses:e})}return t}function XN(e){return"nominal"===e||"ordinal"===e}function UN(e){return"quantitative"===e||"temporal"===e}function KN(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var QN={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},ZN={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},JN={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function e$(e){e=function(e){const t=e;if(!function(e){const t=e.usermeta;if(KN(t)&&KN(t.idid))return t.idid}(e)||!Array.isArray(t.layer))return e;const o=t.layer.filter(e=>KN(e)&&!function(e){return!!(KN(e)&&KN(e.usermeta)&&KN(e.usermeta.idid))&&"annotation-layer"===e.usermeta.idid.role}(e));if(1!==o.length||void 0===o[0].mark)return e;const{layer:r,...n}=t,{usermeta:i,...a}=o[0];return{...n,...a}}(e);const t=[],{type:r,markProps:n}=function(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};const{type:t,...o}=e;return{type:t,markProps:o}}(e.mark),i=e.encoding||{},a=i.x,s=i.y,l=i.color,c=i.size,u=i.theta,d=i.opacity;let h;e.data?.values?h=e.data.values:e.data?.url&&t.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&t.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&t.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&t.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||i.facet||i.row||i.column)&&t.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&t.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&t.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const p={};e.width&&(p.width=e.width),e.height&&(p.height=e.height);const m=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(m&&(p.title=m),l?.field&&(p.colorBy=l.field,l.scale?.scheme)){const e=QN[l.scale.scheme];e&&(p.colorScheme=e)}void 0!==d?.value&&(p.pointOpacity=d.value);const f=a?.aggregate,g=s?.aggregate;if(h&&(f||g)){const e=g?s:a,t=g?a:s,r=JN[e.aggregate];if(r&&t?.field&&e.field)h=function(e,t){const{groupBy:r,value:n,agg:i="sum"}=t,a=new Map;for(const t of e){const e=t[r]+"";a.has(e)||a.set(e,[]),a.get(e).push(Number(t[n]))}const s=[];for(const[e,t]of a){let n;switch(i){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=o(t)[0];break;case"max":n=o(t)[1];break;default:n=t.reduce((e,t)=>e+t,0)}s.push({[r]:e,value:n})}return s}(h,{groupBy:t.field,value:e.field,agg:r});else if(("count"===r||"count"===e.aggregate)&&t?.field&&h){const e=new Map;for(const o of h){const r=o[t.field]+"";e.set(r,(e.get(r)||0)+1)}h=Array.from(e,([e,o])=>({[t.field]:e,value:o}))}}if(a?.bin||s?.bin){const e="Histogram";h&&(p.data=h),a?.bin?(p.valueAccessor=a.field,s?.field&&(p.categoryAccessor=s.field),a.axis?.title&&(p.valueLabel=a.axis.title)):s?.bin&&(p.valueAccessor=s.field,a?.field&&(p.categoryAccessor=a.field),s.axis?.title&&(p.valueLabel=s.axis.title));const o=a?.bin||s?.bin,r="object"==typeof o?o.maxbins:void 0;return r&&(p.bins=r),o$(e,p,t)}let y;switch(r){case"bar":y=function(e,t,o,r,n,i,a){let s;return o?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(s="StackedBarChart",r.stackBy=o.field):s="BarChart",XN(e?.type)&&UN(t?.type)?(r.categoryAccessor=e.field,r.valueAccessor=a?"value":t.field,e?.axis?.title&&(r.categoryLabel=e.axis.title),t?.axis?.title&&(r.valueLabel=t.axis.title)):UN(e?.type)&&XN(t?.type)?(r.categoryAccessor=t.field,r.valueAccessor=i?"value":e.field,r.orientation="horizontal",t?.axis?.title&&(r.categoryLabel=t.axis.title),e?.axis?.title&&(r.valueLabel=e.axis.title)):(e?.field&&(r.categoryAccessor=e.field),t?.field&&(r.valueAccessor=a?"value":t.field),e?.axis?.title&&(r.categoryLabel=e.axis.title),t?.axis?.title&&(r.valueLabel=t.axis.title)),n&&(r.data=n),s}(a,s,l,p,h,f,g);break;case"line":if(y="LineChart",t$(a,s,p,f,g),l?.field&&(p.lineBy=l.field),n.interpolate){const e=ZN[n.interpolate];e&&(p.curve=e)}!0===n.point&&(p.showPoints=!0),h&&(p.data=h);break;case"area":if(l?.field?(y="StackedAreaChart",p.areaBy=l.field):y="AreaChart",t$(a,s,p,f,g),n.interpolate){const e=ZN[n.interpolate];e&&(p.curve=e)}void 0!==n.opacity&&(p.areaOpacity=n.opacity),h&&(p.data=h);break;case"point":case"circle":case"square":c?.field?(y="BubbleChart",p.sizeBy=c.field,c.scale?.range&&(p.sizeRange=c.scale.range)):y="Scatterplot",t$(a,s,p,f,g),h&&(p.data=h);break;case"rect":y="Heatmap",a?.field&&(p.xAccessor=a.field),s?.field&&(p.yAccessor=s.field),l?.field&&(p.valueAccessor=l.field,delete p.colorBy),a?.axis?.title&&(p.xLabel=a.axis.title),s?.axis?.title&&(p.yLabel=s.axis.title),h&&(p.data=h);break;case"arc":n.innerRadius&&n.innerRadius>0?(y="DonutChart",p.innerRadius=n.innerRadius):y="PieChart",u?.field?p.valueAccessor=u.field:s?.field&&(p.valueAccessor=g?"value":s.field),l?.field&&(p.categoryAccessor=l.field),a?.field&&!u?.field&&(p.categoryAccessor=a.field),h&&(p.data=h);break;case"tick":y="DotPlot",XN(a?.type)?(p.categoryAccessor=a.field,s?.field&&(p.valueAccessor=g?"value":s.field),a?.axis?.title&&(p.categoryLabel=a.axis.title),s?.axis?.title&&(p.valueLabel=s.axis.title)):XN(s?.type)?(p.categoryAccessor=s.field,a?.field&&(p.valueAccessor=f?"value":a.field),p.orientation="horizontal",s?.axis?.title&&(p.categoryLabel=s.axis.title),a?.axis?.title&&(p.valueLabel=a.axis.title)):(a?.field&&(p.categoryAccessor=a.field),s?.field&&(p.valueAccessor=g?"value":s.field)),h&&(p.data=h);break;default:t.push(`Unsupported mark type "${r}". Defaulting to Scatterplot.`),y="Scatterplot",t$(a,s,p,f,g),h&&(p.data=h)}return o$(y,p,t)}function t$(e,t,o,r,n){e?.field&&(o.xAccessor=r?"value":e.field),t?.field&&(o.yAccessor=n?"value":t.field),e?.axis?.title&&(o.xLabel=e.axis.title),t?.axis?.title&&(o.yLabel=t.axis.title)}function o$(e,t,o){const r={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(o.length>0){r.warnings=o;for(const e of o)console.warn("[semiotic/fromVegaLite] "+e)}return r}import{useCallback as r$,useMemo as n$,useRef as i$,useState as a$}from"react";var s$=/^\d{4}[-/]\d{2}/,l$=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function c$(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?s$.test(e)&&!Number.isNaN(Date.parse(e))?"date":l$.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function u$(e){let t=1/0,o=-1/0;for(let r=0;e.length>r;r++){const n=e[r];t>n&&(t=n),n>o&&(o=n)}return{min:t,max:o}}function d$(e){const t=e.length;if(0===t)return NaN;const o=t>>1;return t%2==0?(e[o-1]+e[o])/2:e[o]}function h$(e,t={}){const{maxDistinct:o=10,sampleSize:r=5,keyScanRows:n=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const i=new Set,a=Math.min(e.length,n);for(let t=0;a>t;t++){const o=e[t];if(o&&"object"==typeof o)for(const e of Object.keys(o))i.add(e)}const s={};for(const t of i){const r=[];for(let o=0;e.length>o;o++){const n=e[o]?.[t];null!=n&&r.push(n)}if(0===r.length){s[t]={type:"unknown"};continue}const n=c$(r[0]);if("numeric"===n){const e=[];for(let t=0;r.length>t;t++){const o=Number(r[t]);Number.isFinite(o)&&e.push(o)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:o,max:n}=u$(e);let i=0;for(let t=0;e.length>t;t++)i+=e[t];const a=[...e].sort((e,t)=>e-t);s[t]={type:"numeric",min:o,max:n,mean:i/e.length,median:d$(a)}}else if("date"===n){const e=[];for(let t=0;r.length>t;t++){const o=r[t],n=o instanceof Date?o.getTime():Date.parse(o);Number.isFinite(n)&&e.push(n)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:o,max:n}=u$(e);s[t]={type:"date",min:new Date(o).toISOString(),max:new Date(n).toISOString()}}else if("categorical"===n){const e=new Map;for(let t=0;r.length>t;t++){const o=r[t]+"";e.set(o,(e.get(o)??0)+1)}const n=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,o).map(([e,t])=>({value:e,count:t}));s[t]={type:"categorical",distinctCount:e.size,topValues:n,distinctValues:e.size>o?void 0:n.map(e=>e.value)}}else s[t]={type:"unknown"}}return{rowCount:e.length,fields:s,sample:e.slice(0,r)}}var p$=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,m$=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,f$=/(size|magnitude|volume|weight|count|amount)/i,g$=/^(category|label|name|type|group|region|segment|kind|class)$/i,y$=/^(series|group|type|category|segment|cohort|product)$/i,b$=new Set(["numeric"]),v$=new Set(["numeric","date"]),x$=new Set(["numeric"]),w$=new Set(["date"]),k$=new Set(["categorical","boolean"]);function S$(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function A$(e,t){return t.test(e)?.2:0}function C$(e,t){let o=null;for(let r=0;e.length>r;r++){const n=e[r]?.[t];if(null==n)continue;const i=n instanceof Date?n.getTime():Number(n);if(!Number.isFinite(i))return!1;if(null!==o&&o>i)return!1;o=i}return null!==o}function M$(e,t,o,r,n={}){const i=[];for(const[a,s]of Object.entries(e)){const e=S$(s);if(!o.has(e))continue;let l,c=.5;c+=A$(a,r),"categorical"===s.type&&(l=s.distinctCount,!l||2>l||l>12||(c+=.2),l&&l>50&&(c-=.2)),"numeric"===s.type&&Number.isFinite(s.min)&&Number.isFinite(s.max)&&s.max>s.min&&(c+=.1);const u={field:a,kind:e,quality:Math.max(0,Math.min(1,c)),distinctCount:l};!n.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=C$(t,a),u.monotonic&&(u.quality=Math.min(1,u.quality+.2))),i.push(u)}return i.sort((e,t)=>t.quality-e.quality),i}function P$(e,t){const o=new Set;for(let r=0;e.length>r;r++){const n=e[r]?.[t];null!=n&&o.add(n+"")}return o.size}var I$=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,_$=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,L$=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,R$=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,T$=/^(value|weight|amount|count|magnitude|volume)$/i;function N$(e,t){return e.find(e=>t.test(e))}function $$(e,t={}){const o=h$(e??[]),r=Array.isArray(e)?e:[],n=function(e){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if("FeatureCollection"===t.type&&Array.isArray(t.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:t.features,points:Array.isArray(t.points)?t.points:void 0,flows:Array.isArray(t.flows)?t.flows:void 0}};if(Array.isArray(t.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:t};if(Array.isArray(t.nodes)&&(Array.isArray(t.edges)||Array.isArray(t.links)))return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:t.nodes,edges:t.edges??t.links}}}return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!1}}(t.rawInput);if(!n.hasNetwork&&!n.hasHierarchy&&!n.hasGeo){const e=function(e){if(3>e.length)return null;const t=e[0];if(!t||"object"!=typeof t)return null;const o=Object.keys(t),r=N$(o,I$),n=N$(o,_$);if(!r||!n||r===n)return null;const i=N$(o,L$),a=N$(o,R$),s=N$(o,T$),l=[];for(const t of e){if(!t)continue;const e=t[r],o=t[n];if(null==e||null==o)continue;const i=(e+"").trim(),a=(o+"").trim();i&&a&&i!==a&&l.push(t)}if(3>l.length)return null;const c=new Map,u=new Map,d=new Map;for(const e of l){const t=(e[r]+"").trim(),o=(e[n]+"").trim();c.has(t)||c.set(t,{id:t,label:t}),c.has(o)||c.set(o,{id:o,label:o});const l=`${t}->${o}`,h=s?Number(e[s]):1,p=Number.isFinite(h)?h:1;u.set(l,(u.get(l)??0)+p),d.has(l)||d.set(l,{source:t,target:o,...i?{startTime:e[i]}:{},...a?{endTime:e[a]}:{}})}const h=[];for(const[e,t]of d)h.push({...t,value:u.get(e)??1});return{nodes:Array.from(c.values()),edges:h}}(r);e&&(n.hasNetwork=!0,n.network=e)}const i=M$(o.fields,r,v$,p$,{computeMonotonic:!0}),a=M$(o.fields,r,x$,m$),s=M$(o.fields,r,b$,f$),l=M$(o.fields,r,k$,g$),c=M$(o.fields,r,k$,y$),u=M$(o.fields,r,w$,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let h=d,p=d?"time":"none";if(!h){const e=i.find(e=>p$.test(e.field)&&"numeric"===e.kind);e&&(h=e.field,p="named")}const m=a.find(e=>e.field!==h)?.field;if(!h&&m){const e=Object.entries(o.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(h=e.find(e=>e!==m),h&&(p="scatter"))}const f=s.find(e=>e.field!==h&&e.field!==m)?.field,g="time"===p||"named"===p,y=l.map(e=>e.field);let b,v;g?(v=t.seriesField??y[0],b=y.find(e=>e!==v)):(b=y[0],v=t.seriesField??y.find(e=>e!==b));const x=b?P$(r,b):void 0,w=v?P$(r,v):void 0,k=h?P$(r,h):void 0,S=!!h&&function(e,t){const o=new Set;for(let r=0;e.length>r;r++){const n=e[r]?.[t];if(null==n)continue;const i=n+"";if(o.has(i))return!0;o.add(i)}return!1}(r,h),A=i.find(e=>e.field===h)?.monotonic??!1,C=u.length>0;return{...o,data:r,candidates:{x:i,y:a,size:s,category:l,series:c,time:u},primary:{x:h,y:m,size:f,category:b,series:v,time:d},categoryCount:x,seriesCount:w,uniqueXCount:k,hasRepeatedX:S,monotonicX:A,hasTimeAxis:C,hasHierarchy:n.hasHierarchy,hasNetwork:n.hasNetwork,hasGeo:n.hasGeo,xProvenance:p,network:n.network,hierarchy:n.hierarchy,geo:n.geo}}var B$={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},D$=["tiny","small","medium","large","huge"];function F$(e){return{rows:{...B$.rows,...e?.rows??{}},cardinality:{...B$.cardinality,...e?.cardinality??{}},fields:{...B$.fields,...e?.fields??{}}}}function E$(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const o=F$(t?.thresholds).rows;return e>o.tiny?e>o.small?e>o.medium?e>o.large?"huge":"large":"medium":"small":"tiny"}function z$(e,t){if(!Number.isFinite(e)||0>e)return"low";const o=F$(t?.thresholds).cardinality;return e>o.low?e>o.medium?"high":"medium":"low"}function j$(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const o=F$(t?.thresholds).fields;return e>o.narrow?e>o.typical?"wide":"typical":"narrow"}function O$(e,t){return D$.indexOf(e)-D$.indexOf(t)}function H$(e,t,o){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=F$(o?.thresholds).rows;switch(e){case"tiny":return Math.max(1,Math.floor(t.tiny/2));case"small":return Math.floor((t.tiny+t.small)/2);case"medium":return Math.floor((t.small+t.medium)/2);case"large":return Math.floor((t.medium+t.large)/2);case"huge":return Math.floor(2*t.large)}}return t}function W$(e,t,o){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=F$(o?.thresholds).cardinality;switch(e){case"low":return Math.max(1,Math.floor(t.low/2));case"medium":return Math.floor((t.low+t.medium)/2);case"high":return Math.floor(2*t.medium)}}return t}function q$(e,t){const o=e.rowCount??0,r=t?.rows,n=H$(r,o,t),i=E$(n,t),a=Object.keys(e.fields??{}).length,s=t?.fields,l="number"==typeof s?s:"string"==typeof s?function(e,t){const o=F$(t?.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(o.narrow/2));case"typical":return Math.floor((o.narrow+o.typical)/2);case"wide":return Math.floor(2*o.typical)}}(s,t):a,c=j$(l,t),u=e.primary.category,d=W$((u?t?.cardinality?.[u]:void 0)??t?.typicalCardinality,e.categoryCount,t);return{rows:n,rowBand:i,fields:l,fieldBand:c,typicalCardinality:d,cardinalityBand:void 0!==d?z$(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==r?"declared":"measured"}}var G$=2.5;function Y$(e,t,o,r,n){const i=[],a=[];let s=0,l=!1;if(e.scaleFit){const n=e.scaleFit(t,o,r);if(n&&(s+=Math.max(-2.5,Math.min(G$,n.delta??0)),n.reason&&i.push(n.reason),n.caveats))for(const e of n.caveats)a.push(e)}const c=r?.charts?.[e.component];if(c&&(c.minBand&&0>O$(o.rowBand,c.minBand)||c.maxBand&&O$(o.rowBand,c.maxBand)>0?l=!0:"number"==typeof c.bias?(s+=Math.max(-3,Math.min(3,c.bias)),c.reason&&i.push(`${r?.name?r.name+": ":""}${c.reason}`)):c.reason&&i.push(`${r?.name?r.name+": ":""}${c.reason}`)),n&&e.qualityFit){const o=e.qualityFit(t,n);if(o&&(s+=Math.max(-1,Math.min(1,o.delta??0)),o.reason&&i.push(o.reason),o.caveats))for(const e of o.caveats)a.push(e)}else if(n){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const o=e[t];return"number"==typeof o?o:void 0}(n.completeness,e);void 0!==t&&.85>t&&a.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:s,reasons:i,caveats:a,excluded:l}}function V$(e){return(t,o)=>{let r=0;const n=[];let i;if(e.rows){const[t,a]=e.rows.sweetSpot;t>o.rows||o.rows>a?t>o.rows?(r-=Math.min(G$,.8*(0===t?1:(t-o.rows)/t)),void 0===e.rows.caveatBelow||o.rows>e.rows.caveatBelow||n.push(`only ${o.rows} rows — chart may feel sparse`)):(r-=Math.min(G$,.4*(0===a?1:(o.rows-a)/a)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>o.rows||n.push(o.rows+" rows is past this chart's comfortable density")):(r+=.6,i=o.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==o.typicalCardinality){const t=o.typicalCardinality,[i,a]=e.cardinality.sweetSpot;i>t||t>a?t>a&&(r-=Math.min(G$,.5*(0===a?1:(t-a)/a)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||n.push(t+" distinct categories may overwhelm this chart")):r+=.4}return 0!==r||0!==n.length||i?{delta:r,reason:i,caveats:n}:null}}var X$={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},fits:e=>{if(2>e.rowCount)return"needs at least 2 rows";if(!e.primary.x)return"needs a numeric or time x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return t&&"numeric"!==t&&"date"!==t?`x field "${e.primary.x}" is ${t}, LineChart needs numeric or time`:"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence"},intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?!e.uniqueXCount||4>e.uniqueXCount?3:!e.seriesCount||2>e.seriesCount?4:5:1,"compare-series":e=>"scatter"!==e.xProvenance||e.monotonicX?!e.seriesCount||2>e.seriesCount?1:e.seriesCount>8?2:4:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?4:1,"outlier-detection":2,correlation:2},caveats:e=>{const t=[];return!e.hasRepeatedX||e.seriesCount&&e.seriesCount>=2||t.push("x values repeat — consider aggregating or adding a series field"),e.seriesCount&&e.seriesCount>8&&t.push(e.seriesCount+" series may produce a spaghetti chart"),t},variants:[{key:"linear",label:"Linear trend",props:{curve:"linear",showPoints:!1},tags:["linear"]},{key:"smooth",label:"Smooth trend",description:"Monotone smoothing — emphasizes the shape over individual points.",props:{curve:"monotoneX",showPoints:!1},tags:["smooth","narrative"],intentDeltas:{trend:1,"outlier-detection":-2},rubricDeltas:{precision:-1},caveats:["smoothing hides individual outliers"]},{key:"stepped-with-points",label:"Discrete steps",description:"Step curve plus visible points — for state changes or discrete events.",props:{curve:"step",showPoints:!0,pointRadius:3},tags:["step","discrete"],intentDeltas:{"change-detection":1,trend:-1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or band turns the chart from a report into an alert — read it for breaches of the expected range. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the chart\'s communicative act becomes "alerting".',props:{showGrid:!0,showPoints:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{const o={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(o.lineBy=e.primary.series,o.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(o.xScaleType="time"),{...o,...t?.props??{}}},scaleFit:V$({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},U$={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>3>e.rowCount?"needs at least 3 rows":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a numeric or time x field",intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?e.seriesCount&&e.seriesCount>=2||!e.uniqueXCount||4>e.uniqueXCount?3:5:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?3:1},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&t.push(`showing only the leading "${e.primary.series}" series — for multi-series comparison use LineChart or DifferenceChart`),t},variants:[{key:"smooth",label:"Smooth gradient",props:{curve:"monotoneX"},tags:["smooth","gradient","narrative"]},{key:"linear",label:"Linear",props:{curve:"linear",gradientFill:!1,areaOpacity:.5},tags:["linear"]},{key:"stepped",label:"Stepped",props:{curve:"stepAfter"},tags:["step"],intentDeltas:{"change-detection":1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or expected band turns the area into an alert — read for breaches. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{let o=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,r=e.primary.y,n=new Map;for(const o of e.data){const e=o[t];if(null==e||""===e)continue;const i=Number(o[r]);n.set(e,(n.get(e)??0)+(Number.isFinite(i)?i:0))}let i,a=-1/0;for(const[e,t]of n)t>a&&(a=t,i=e);null!=i&&n.size>0&&(o=e.data.filter(e=>e[t]===i))}const r={data:o,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:!0,areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:V$({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},K$={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.y?!e.seriesCount||2>e.seriesCount?"needs 2+ stack groups (series field)":e.seriesCount>10?e.seriesCount+" series is too many to stack legibly":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — stacking only makes sense across a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{"composition-over-time":5,"part-to-whole":e=>e.hasTimeAxis?4:3,trend:3,"compare-series":2},caveats:()=>["readability of individual layers degrades below the baseline"],variants:[{key:"baseline-zero",label:"Zero baseline",props:{baseline:"zero",stackOrder:"key"},tags:["zero-baseline"]},{key:"streamgraph",label:"Streamgraph",description:"Wiggle baseline + inside-out ordering — emphasizes momentum over precise totals.",props:{baseline:"wiggle",stackOrder:"insideOut",showLine:!1},tags:["streamgraph","narrative"],intentDeltas:{"composition-over-time":0,trend:1,"part-to-whole":-2},rubricDeltas:{accuracy:-1,precision:-1},caveats:["streamgraph hides absolute totals; precise reads not possible"]},{key:"centered",label:"Centered baseline",props:{baseline:"silhouette",stackOrder:"insideOut"},tags:["silhouette"],intentDeltas:{"part-to-whole":-1}}],buildProps:(e,t)=>{const o={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,areaBy:e.primary.series,colorBy:e.primary.series};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(o.xScaleType="time"),{...o,...t?.props??{}}},scaleFit:V$({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},Q$={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},fits:e=>{if(3>e.rowCount)return"needs at least 3 rows";if(!e.primary.x)return"needs a numeric x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return"date"===t?null:t&&"numeric"!==t?`x field "${e.primary.x}" is ${t}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,o=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&o.length>=2||e.primary.size?4:5},"outlier-detection":5,distribution:3,"compare-series":e=>!e.seriesCount||2>e.seriesCount||e.seriesCount>6?1:3,rank:1},variants:[{key:"points",label:"Points only",props:{},tags:["points"]},{key:"with-trend",label:"Points with regression line",props:{regression:"linear"},tags:["regression","trend"],intentDeltas:{correlation:0,trend:1}}],buildProps:(e,t)=>{const o={data:e.data},r="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,n=r?e.candidates.y.filter(e=>e.field!==r).map(e=>e.field):[];return r&&n.length>=2?(o.xAccessor=n[0],o.yAccessor=n[1]):(o.xAccessor=e.primary.x,o.yAccessor=e.primary.y,e.primary.size&&(o.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(o.colorBy=e.primary.series),{...o,...t?.props??{}}},scaleFit:V$({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},Z$={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 ordered points":e.primary.x?e.primary.y?e.monotonicX||e.hasTimeAxis?null:"needs an ordered x sequence":"needs a y field":"needs an x field",intentScores:{trend:3,correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,o=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&o.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{const t={data:e.data},o="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=o?e.candidates.y.filter(e=>e.field!==o).map(e=>e.field):[];return o&&r.length>=2?(t.xAccessor=r[0],t.yAccessor=r[1],t.orderAccessor=o):(t.xAccessor=e.primary.x,t.yAccessor=e.primary.y,t.orderAccessor=e.primary.time??e.primary.x),e.primary.series&&6>=(e.seriesCount??0)&&(t.colorBy=e.primary.series),t}},J$={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?e.primary.size?null:"needs a third numeric measure for bubble size":"needs a numeric y field":"needs a numeric x field",intentScores:{correlation:5,"compare-categories":3,"outlier-detection":4},caveats:()=>["bubble area is harder to compare than length — large dynamic ranges distort"],buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,sizeBy:e.primary.size,...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{}}),scaleFit:V$({rows:{sweetSpot:[10,500],caveatAbove:1500}})},eB={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?null:"needs a numeric y field":"needs a numeric x field",intentScores:{"compare-categories":2,correlation:3,"outlier-detection":3},buildProps:e=>{const t=e.primary.x,o=e.primary.y,r=e.fields[t],n=e.fields[o],i="numeric"===r?.type?r.median:void 0,a="numeric"===n?.type?n.median:void 0;return{data:e.data,xAccessor:t,yAccessor:o,...void 0!==i?{xCenter:i}:{},...void 0!==a?{yCenter:a}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...ap.topLeft},topRight:{...ap.topRight},bottomLeft:{...ap.bottomLeft},bottomRight:{...ap.bottomRight}}}}},tB={component:"MultiAxisLineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?2>Object.entries(e.fields).filter(([t,o])=>"numeric"===o.type&&t!==e.primary.x).map(([e])=>e).length?"needs at least 2 numeric measures":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — multi-axis lines need a shared sequence":"needs an x field",intentScores:{"compare-series":4,trend:3,correlation:3},caveats:()=>["dual axes can mislead — only use when measures share interpretation"],buildProps:e=>{const t=Object.entries(e.fields).filter(([t,o])=>"numeric"===o.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},oB={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},fits:e=>30>e.rowCount?"minimap pays off only on long sequences (30+ rows)":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — minimap previews a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{trend:4,"change-detection":4,"outlier-detection":3},buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,...e.hasTimeAxis&&e.primary.x===e.primary.time?{xScaleType:"time"}:{}})},rB={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.series?!e.seriesCount||2>e.seriesCount?`needs 2+ series (got ${e.seriesCount??0})`:e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a series field with at least two groups":"needs an x field (numeric or time)",intentScores:{"compare-series":e=>2===e.seriesCount?5:3,"change-detection":4,trend:3},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>2&&t.push(`showing the top 2 of ${e.seriesCount} series — for full multi-series comparison use LineChart`),t},buildProps:e=>{const t=e.primary.x,o=e.primary.y,r=e.primary.series,n=e=>null!=e&&(e+"").length>0,i=new Map;for(const t of e.data){const e=t[r];if(!n(e))continue;const a=e+"",s=Number(t[o]);i.set(a,(i.get(a)??0)+(Number.isFinite(s)?s:0))}const a=[...i.entries()].sort((e,t)=>t[1]-e[1]),s=a[0]?.[0],l=a[1]?.[0],c=e=>e instanceof Date?e.getTime():e,u=new Map;for(const i of e.data){const e=i[r];if(!n(e))continue;const a=e+"";if(a!==s&&a!==l)continue;const d=i[t],h=i[o],p=c(d);let m=u.get(p);m||(m={[t]:d},u.set(p,m)),a===s?m.a=h:a===l&&(m.b=h)}return{data:Array.from(u.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:t,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:s,seriesBLabel:l}}},nB={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.x)return"needs an x field (typically date)";const t=new Set(Object.keys(e.fields).map(e=>e.toLowerCase())),o=t.has("high"),r=t.has("low");return o&&r?null:"needs at minimum high/low fields (open/close optional)"},intentScores:{"change-detection":4,trend:3,"outlier-detection":3},buildProps:e=>{const t=Object.keys(e.fields),o=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:o("high"),lowAccessor:o("low"),openAccessor:o("open"),closeAccessor:o("close")}}},iB={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>{if(4>e.rowCount)return"needs at least 4 cells";if(!e.primary.y)return"needs a numeric value to encode in cell color";const t=e.candidates.category.length;return t>=2||t>=1&&e.hasTimeAxis?(e.uniqueXCount??0)>50?"too many x cells for a legible heatmap":null:"needs two categorical-or-time dimensions for the axes"},intentScores:{correlation:3,distribution:2,"compare-categories":e=>2>e.candidates.category.length?1:4,"composition-over-time":e=>e.hasTimeAxis&&e.candidates.category.length>=1?4:1},caveats:e=>{const t=[];return(e.uniqueXCount??0)>30&&t.push("many x values — cells will be narrow"),t},variants:[{key:"default",label:"Sequential color",props:{},tags:["sequential"]},{key:"show-values",label:"With cell labels",props:{showValues:!0},tags:["labeled"],intentDeltas:{"compare-categories":1},rubricDeltas:{precision:1},caveats:["cell labels crowd dense matrices"]}],buildProps:(e,t)=>{const o=e.candidates.category.map(e=>e.field),r=e.primary.time??o[0],n=o.find(e=>e!==r)??o[0]??e.primary.series;return{data:e.data,xAccessor:r,yAccessor:n,valueAccessor:e.primary.y,...t?.props??{}}},scaleFit:V$({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},aB=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,sB=/^(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec|january|february|march|april|june|july|august|september|october|november|december|mon|tue|wed|thu|fri|sat|sun|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i,lB=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,cB={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},fits:e=>e.primary.category?e.primary.y?1>(e.categoryCount??0)?"needs at least 1 category":(e.categoryCount??0)>50?"too many categories — consider aggregating or use a different chart":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?2>e.candidates.category.length?10>e.rowCount/e.categoryCount?5:2:3:0,rank:5,"part-to-whole":e=>(e.categoryCount??0)>8?2:3,distribution:1},caveats:e=>{const t=[];return function(e){const t=e.primary.category;if(!t)return!1;const o=t.replace(/([a-z])([A-Z])/g,"$1 $2");if(aB.test(o))return!0;const r=e.data;if(!r||0===r.length)return!1;let n=0,i=0;for(const e of r){const o=e[t];if(null==o)continue;i++;const r=(o+"").trim();(sB.test(r)||lB.test(r))&&n++}return i>0&&n/i>=.6}(e)&&t.push("category axis looks like time bins — for a time series, supply real dates and use LineChart/AreaChart (reads trend, scales the time axis); for streaming counts use a temporal histogram"),t},variants:[{key:"sorted-desc",label:"Ranked",props:{sort:"desc"},tags:["sorted","ranked"],intentDeltas:{rank:0,"compare-categories":0}},{key:"source-order",label:"Source order",props:{sort:!1},tags:["source-order"],intentDeltas:{rank:-2}},{key:"horizontal",label:"Horizontal bars",props:{orientation:"horizontal",sort:"desc"},tags:["horizontal","ranked"],intentDeltas:{rank:1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A target/threshold reference turns the bars into an alert — read for which categories breach. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:V$({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},uB={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ groups":(e.seriesCount??0)>6?e.seriesCount+" groups is too many for grouped bars":(e.categoryCount??0)>25?"too many categories for grouped bars":null:"needs a series field to group by":"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":5,"compare-series":4,rank:3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,groupBy:e.primary.series,colorBy:e.primary.series})},dB={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ stack groups":(e.seriesCount??0)>8?e.seriesCount+" stacked groups is too many":null:"needs a series field to stack by":"needs a numeric value field":"needs a category field",intentScores:{"part-to-whole":4,"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":2},caveats:()=>["only the bottom segment shares a baseline; others are harder to compare across categories"],variants:[{key:"absolute",label:"Absolute stacks",props:{normalize:!1},tags:["absolute"]},{key:"normalized",label:"100% stacked",description:"Each bar normalized to 1 — emphasizes composition, hides totals.",props:{normalize:!0},tags:["normalized","part-to-whole"],intentDeltas:{"part-to-whole":1,"compare-categories":-1},caveats:["absolute magnitudes are no longer comparable across bars"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series,...t?.props??{}})},hB={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>30?"too many categories for a dot plot":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"outlier-detection":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y}),scaleFit:V$({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},pB={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a pie chart":null},intentScores:{"part-to-whole":4,"compare-categories":2,rank:1},caveats:()=>["angle comparisons are less accurate than length — prefer a bar chart unless part-to-whole is the explicit message"],variants:[{key:"pie",label:"Pie",props:{},tags:["pie"]},{key:"donut",label:"Donut",description:"Hollow center — easier to fit a label or KPI inside.",props:{innerRadius:60},tags:["donut"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:V$({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},mB={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a donut":null},intentScores:{"part-to-whole":4,"compare-categories":2},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,innerRadius:40})},fB=/(stage|step|funnel|status|outcome|phase)/i,gB={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.primary.y?Object.keys(e.fields).find(e=>fB.test(e))?null:"needs a stage/step/funnel-named field":"needs a numeric value field",intentScores:{flow:4,rank:3,"part-to-whole":2},caveats:()=>["readers infer conversion drop-off — make sure rows actually represent sequential stages"],buildProps:e=>{const t=Object.keys(e.fields).find(e=>fB.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},yB={component:"GaugeChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:2,precision:2},fits:e=>e.rowCount>1?"GaugeChart shows a single value — provide a 1-row dataset or use BarChart":e.primary.y?null:"needs a numeric value",intentScores:{"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,o=e.data[0],r=o?Number(o[t]):0,n=e.fields[t],i="numeric"===n?.type?n.max:100;return{value:Number.isFinite(r)?r:0,min:0,max:i}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},bB=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,vB={component:"LikertChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?Object.keys(e.fields).find(e=>bB.test(e))?null:"needs an ordinal rating/level field (rating, score, level...)":"needs a numeric rating/count field":"needs a category (question) field",intentScores:{"compare-categories":4,distribution:3,"part-to-whole":3},buildProps:e=>{const t=Object.keys(e.fields).find(e=>bB.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},xB={component:"SwimlaneChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.category?e.primary.series?e.primary.y?2>(e.categoryCount??0)?"needs 2+ categories":null:"needs a numeric value field":"needs a sub-category (lane) field":"needs a category field",intentScores:{"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,subcategoryAccessor:e.primary.series,valueAccessor:e.primary.y,colorBy:e.primary.series})},wB={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{if(10>e.rowCount)return"histograms need at least ~10 observations";if(!e.primary.y)return"needs a numeric field to bin";const t=e.primary.y,o=e.candidates.y.find(e=>e.field===t);return void 0!==o?.distinctCount&&6>o.distinctCount?"too few distinct numeric values; a bar chart of counts is a better fit":null},intentScores:{distribution:5,"outlier-detection":3,"compare-categories":1},variants:[{key:"count-bins",label:"Count bins",props:{bins:10,relative:!1},tags:["count"]},{key:"share-bins",label:"Share bins (relative)",props:{bins:10,relative:!0},tags:["share"],intentDeltas:{distribution:0}}],buildProps:(e,t)=>({data:e.data,valueAccessor:e.primary.y,...t?.props??{}})},kB={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.primary.y?e.primary.category?3>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 3+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4,"outlier-detection":4},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},SB={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.y?e.primary.category?4>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 4+ observations per category":e.rowCount>2e3?"too many points for a swarm — consider a violin or box":null:"needs a category":"needs a numeric field",intentScores:{distribution:4,"outlier-detection":5,"compare-categories":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...e.primary.series&&e.primary.series!==e.primary.category?{colorBy:e.primary.series}:{}})},AB={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.y?e.primary.category?6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4},variants:[{key:"density",label:"Density only",props:{showIQR:!1},tags:["density"]},{key:"density-iqr",label:"Density with IQR",props:{showIQR:!0},tags:["density","iqr"],intentDeltas:{distribution:0},rubricDeltas:{precision:1}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}})},CB={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},fits:e=>e.primary.y?e.primary.category?3>(e.categoryCount??0)?"needs 3+ categories to make a ridgeline meaningful":6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category dimension to stack distributions":"needs a numeric field",intentScores:{distribution:4,"compare-categories":3,"composition-over-time":2},caveats:()=>["readers can confuse overlapping ridges — limit categories or use small multiples"],buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},MB={component:"ForceDirectedGraph",family:"network",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.nodes.length?"needs at least 2 nodes":1>e.network.edges.length?"needs at least 1 edge":null:"needs a {nodes, edges} network passed via rawInput",intentScores:{flow:3,correlation:2},caveats:e=>(e.network?.nodes.length??0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}),scaleFit:e=>{const t=e.network?.nodes.length??0;return 5>t?{delta:-.4,caveats:[`only ${t} nodes — force layout is overkill for this size`]}:t>100?t>300?{delta:-.8,caveats:[t+" nodes — expect a hairball; filter or aggregate before rendering"]}:{delta:0}:{delta:.5,reason:t+" nodes is in the readable range for force layout"}}},PB={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.edges.length?"needs 2+ weighted edges":null:"needs a {nodes, edges} network with edge weights",intentScores:{flow:5,"part-to-whole":3},buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"})},IB={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasNetwork&&e.network?3>e.network.nodes.length?"needs 3+ nodes":3>e.network.edges.length?"needs 3+ edges":null:"needs a {nodes, edges} network",intentScores:{flow:4},caveats:()=>["chord diagrams trade accuracy for symmetry; use Sankey if direction matters"],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],valueAccessor:"value"})},_B={component:"ProcessSankey",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>{if(!e.hasNetwork||!e.network)return"needs a {nodes, edges} network";const t=e.network.edges[0];return t?void 0===t.startTime&&void 0===t.start||void 0===t.endTime&&void 0===t.end?"edges need both startTime and endTime (or start/end) for a temporal sankey":null:"needs at least one edge with start/end times"},intentScores:{flow:5,"composition-over-time":4,"change-detection":3},buildProps:e=>{const t={nodes:e.network?.nodes??[],edges:e.network?.edges??[],pairing:"temporal",laneOrder:"crossing-min"},o=e.network?.edges[0];return o&&(void 0===o.startTime&&void 0!==o.start&&(t.startTimeAccessor="start"),void 0===o.endTime&&void 0!==o.end&&(t.endTimeAccessor="end")),t}},LB={component:"TreeDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root (object with children) via rawInput",intentScores:{hierarchy:5},variants:[{key:"vertical-tree",label:"Vertical tree",props:{layout:"tree",orientation:"vertical"},tags:["vertical"]},{key:"horizontal-cluster",label:"Horizontal cluster",props:{layout:"cluster",orientation:"horizontal"},tags:["horizontal"]}],buildProps:(e,t)=>({data:e.hierarchy??{name:"root",children:[]},...t?.props??{}})};function RB(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+RB(t),0):1}var TB={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?4>e.rowCount?"declared scale is too small to render a hierarchy meaningfully":null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":e=>e.hasHierarchy?5:4,"compare-categories":3},caveats:()=>["rectangle area comparisons are less precise than length — prefer a bar chart for ranking"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"}),scaleFit:(e,t)=>{const o=RB(e.hierarchy);let r=0;const n=[];let i;return 5>o?(r-=.5,n.push(`only ${o} leaves — treemap needs more cells to show structure`)):o>100?o>500&&(r-=.7,n.push(o+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(r+=.4,i=o+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(r-=.5,n.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:r,reason:i,caveats:n}}},NB={component:"CirclePack",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":3},caveats:()=>["circle area is harder to compare than rectangle area"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"})},$B={component:"OrbitDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:1,accuracy:2,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root",intentScores:{hierarchy:3},caveats:()=>["decorative — readers without context will not infer hierarchy easily"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},orbitMode:"solar"})},BB={component:"ChoroplethMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?2>e.geo.features.length?"needs at least 2 area features to compare":null:"needs a GeoJSON FeatureCollection via rawInput",intentScores:{geo:5,"compare-categories":3},caveats:()=>["large areas dominate visual weight regardless of measurement"],buildProps:e=>({areas:e.geo?.features??[],valueAccessor:e.primary.y??"value"})},DB={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?(e.geo.points?.length??0)>0||0!==(e.geo.features.length??0)?null:"needs points or area features":"needs a GeoJSON FeatureCollection (with points or area centroids)",intentScores:{geo:4,rank:3,"compare-categories":3},buildProps:e=>({points:e.geo?.points??[],areas:e.geo?.features??void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:e.primary.size??"value"})},FB={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?e.geo.flows?.length?e.geo.points?.length?null:"needs point nodes with lat/lon":"needs flow records (source/target/value)":"needs a geo dataset",intentScores:{geo:4,flow:5},buildProps:e=>({flows:e.geo?.flows??[],nodes:e.geo?.points??[],valueAccessor:"value"})},EB={component:"DistanceCartogram",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:1,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?e.geo.points?.length?null:"needs point nodes with lat/lon and a cost field":"needs a geo dataset",intentScores:{geo:3,rank:3,"compare-categories":2},caveats:()=>["non-standard projection — requires explanation for most readers"],buildProps:e=>({points:e.geo?.points??[],costAccessor:"cost"})};function zB(e){return Number.isFinite("number"==typeof e?e:Number(e))}function jB(e){return["value","throughput","traffic","rate","volume","count"].find(t=>e.some(e=>{const o=Number(e?.[t]);return Number.isFinite(o)&&o>0}))??"value"}function OB(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var HB=[X$,U$,K$,Q$,Z$,J$,eB,tB,oB,rB,nB,iB,cB,uB,dB,hB,pB,mB,gB,yB,vB,xB,wB,kB,SB,AB,CB,MB,PB,IB,_B,LB,TB,NB,$B,BB,DB,FB,EB,{component:"GaltonBoardChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>20>e.rowCount?"Galton boards need enough observations for a distribution to form":e.primary.y?null:"needs a numeric field to drop into bins",intentScores:{distribution:4,"outlier-detection":1},caveats:()=>["The settled projection is the chart; motion is explanatory context and should not be used for exact value reading"],buildProps:e=>({data:e.data,valueAccessor:e.primary.y,bins:Math.max(8,Math.min(24,Math.round(Math.sqrt(e.rowCount))))})},{component:"EventDropChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.time??e.primary.x?3>e.rowCount?"needs multiple events to show arrival/window behavior":null:"needs an event-time field",intentScores:{"change-detection":3,trend:1,distribution:1},caveats:()=>["Use for event-time arrival stories, watermarks, and lateness; use a line or histogram for precise temporal values"],buildProps:e=>{const t=e.primary.time??e.primary.x,o=(function(e){return e.data.some(e=>e&&"object"==typeof e&&"arrivalTime"in e)}(e)?"arrivalTime":e.candidates.time.find(e=>e.field!==t)?.field)||t;return{data:e.data,timeAccessor:t,arrivalAccessor:o,windows:{size:Math.max(1,Math.ceil(e.rowCount/8))},watermark:{delay:1}}}},{component:"PhysicsPileChart",family:"categorical",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>12?"too many categories for readable physics piles":null:"needs a numeric value to unitize into bodies":"needs a categorical field for piles",intentScores:{"compare-categories":3,"part-to-whole":2,distribution:1},caveats:()=>["Physics piles dramatize accumulation; use bars or dots when exact rank or precise value comparison is the task"],buildProps:e=>{const t=e.primary.y,o=t?e.data.map(e=>Number(e?.[t])).filter(e=>Number.isFinite(e)):[],r=o.length?Math.max(...o):1;return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:t,unitValue:Math.max(1,Math.ceil(r/40))}}},{component:"CollisionSwarmChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.primary.y??e.primary.x?8>e.rowCount?"needs enough points for collision density to matter":e.rowCount>1200?"too many points for browser collision relaxation":(e.categoryCount??0)>12?"too many group lanes for a physics swarm":null:"needs a numeric field for the swarm axis",intentScores:{distribution:3,"outlier-detection":3,"compare-categories":2},caveats:()=>["CollisionSwarmChart makes overlap and settling visible; use SwarmPlot when a static distribution is enough"],buildProps:e=>{const t=e.primary.category&&8>=(e.categoryCount??0)?e.primary.category:void 0;return{data:e.data,xAccessor:e.primary.y??e.primary.x,...t?{groupAccessor:t,colorBy:t}:{},...e.primary.size?{radiusAccessor:e.primary.size}:{}}}},{component:"PhysicalFlowChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:1},fits:e=>{return e.hasNetwork&&e.network?1>e.network.edges.length?"needs at least 1 flow link":e.network.edges.length>160?"too many links for animated particle flow":(t=e.network.edges,e.network.nodes.some(e=>zB(e.x)&&zB(e.y))||t.some(e=>Array.isArray(e.path)||Array.isArray(e.points)||Array.isArray(e.route))?null:"requires authored node x/y coordinates or per-link path geometry; use SankeyDiagram for plain source-target-value data"):"needs explicit {nodes, edges} or {nodes, links} route input";var t},intentScores:{flow:4,"change-detection":1,"part-to-whole":1},caveats:()=>["PhysicalFlowChart is experimental: keep showStaticFlow enabled so throughput remains readable when animation is paused or reduced","Requires explicit route geometry; it does not infer physical pipe paths from a flat source-target table"],buildProps:e=>{const t=e.network?.edges??[];return{nodes:e.network?.nodes??[],links:e.network?.edges??[],nodeIdAccessor:"id",nodeXAccessor:"x",nodeYAccessor:"y",sourceAccessor:"source",targetAccessor:"target",throughputAccessor:jB(t),showStaticFlow:!0,showSensors:!0,maxParticles:160}},scaleFit:e=>{const t=e.network?.edges.length??0;return t>4?t>60?{delta:-.7,caveats:[t+" links can create occlusion and packet budget pressure; aggregate routes first"]}:{delta:.2,reason:t+" links is small enough for route-constrained packet animation"}:{delta:-.2,caveats:[`only ${t} links — a static Sankey may communicate the flow more directly`]}}},{component:"ProcessFlowChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>3>e.rowCount?"needs multiple work items to show stage flow":OB(e,"stage")||OB(e,"status")||e.primary.category?null:"needs a categorical stage/status field",intentScores:{flow:4,"change-detection":3,"compare-categories":2,rank:1},caveats:()=>["Use for capacitated multi-body process stories (review queues, triage, merge pipelines); use a bar or Sankey for precise stage totals without motion","Motion dramatizes backlog and capacity; settled stage counts and group completion are the readable chart"],buildProps:e=>{const t=(OB(e,"stage")?"stage":OB(e,"status")&&"status")||e.primary.category||"stage",o=OB(e,"id")?"id":void 0,r=(OB(e,"featureId")?"featureId":OB(e,"group")&&"group")||e.primary.series||void 0,n=new Set;for(const o of e.data){if(!o||"object"!=typeof o)continue;const e=o[t];null!=e&&""!==e&&n.add(e+"")}const i=n.size>0?Array.from(n):["coding","review","merged"],a=i.map((t,o)=>{const r=o===i.length-1,n=o===Math.floor(i.length/2);return{id:t,label:t,force:r?20:12,capacity:n?{unitsPerSecond:Math.max(2,Math.round(e.rowCount/8))}:void 0,pressure:n||void 0,absorb:r||void 0}});return{data:e.data,...o?{idAccessor:o}:{},stageAccessor:t,...r?{groupBy:r,groupCompletion:"allAbsorbed"}:{},stages:a,showProjection:!0,showChrome:!0}}},{component:"GauntletChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:2},fits:e=>{if(1>e.rowCount)return"needs at least one project/plan row";const t=e.data.some(e=>e&&"object"==typeof e&&"id"in e);return e.primary.category||t?null:"needs project rows with stable ids (or a categorical identity field)"},intentScores:{flow:3,"change-detection":2,"compare-categories":1},caveats:()=>["GauntletChart is for compound entities whose attached properties transform at gates. Use ProcessFlowChart when work items do not need compound property bodies.","Read viability, property inventory, and outcomes — not body trajectories."],buildProps:e=>({data:e.data.map((e,t)=>({...e,id:e?.id??"project-"+t,positives:Array.isArray(e?.positives)?e.positives:["value"],negatives:Array.isArray(e?.negatives)?e.negatives:["cost"]})),idAccessor:"id",positiveAccessor:"positives",negativeAccessor:"negatives",positiveProperties:[{id:"value",label:"Value",short:"V",color:"#22c55e",buoyancy:2,radius:9}],negativeProperties:[{id:"cost",label:"Cost",short:"$",color:"#ef4444",load:1.1,radius:7}],gates:[{id:"review",label:"Review"},{id:"approval",label:"Approval"}],showProjection:!0,showChrome:!0})},{component:"BigNumber",family:"value",importPath:"semiotic/value",rubric:{familiarity:5,accuracy:5,precision:5},fits:e=>e.primary.y||e.primary.size||0!==e.candidates.y.length?e.rowCount>50?"BigNumber shows a single focal value — pass scalar data, or use a chart family for >50 rows":null:"needs a numeric value to display",intentScores:{trend:e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:3:0,"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1,"change-detection":e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:4:0},caveats:e=>{const t=[];return e.rowCount>1&&t.push("BigNumber renders the latest row's value as the focal number; earlier rows feed an optional sparkline"),t},buildProps:e=>{const t=e.primary.y??e.primary.size??e.candidates.y[0]?.field;if(!t)return{value:0};const o=e.data,r=o.length>0?o[o.length-1]:null,n=r?Number(r[t]):0,i={value:Number.isFinite(n)?n:0,label:t};if(o.length>=2){const e=Number(o[o.length-2][t]);Number.isFinite(e)&&(i.comparison={value:e,label:"vs previous"})}return i},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.8,reason:"single-value displays beat charts when there is one number to show"}:"small"===t.rowBand?{delta:.2,reason:"the latest value with a trend spark is often more legible than a chart at small scale"}:null}],WB=new Map;function qB(e){WB.set(e.component,e)}function GB(e){WB.delete(e)}function YB(){if(0===WB.size&&0>=x_().capabilities.size)return HB;const e=new Map;for(const t of HB)e.set(t.component,t);for(const t of Array.from(x_().capabilities.values()))e.set(t.component,t);for(const[t,o]of WB)e.set(t,o);return Array.from(e.values())}function VB(e){return YB().find(t=>t.component===e)}var XB=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),UB={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function KB(e,t){if("visual"===t)return{delta:0,caveats:[]};let o=0;const r=[],n=[];for(const t of e.findings){if(!XB.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(o-=e,r.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),n.push(t.message))}return 0===r.length?{delta:0,caveats:[]}:{delta:Math.max(-3,o),reason:`Harder to receive via ${UB[t]}: ${r.slice(0,3).join("; ")}`,caveats:n}}function QB(e,t,o,r,n){if(!r)return{score:e,rubric:t};const i=r.familiarity?.[o],a=i??t.familiarity,s=r.targets?.[o];let l,c,u=0;void 0!==i&&(u+=.5*(i-3)),s&&(u+=1*("increase"===s.direction?1:-1)*Math.max(1,Math.min(3,s.weight??1)),l=s.reason?`${r.name?r.name+": ":""}${s.reason}`:`${r.name?r.name+" ":""}target: ${s.direction} ${o}`);const d=r.receptionModality;return n&&d&&"visual"!==d&&(u+=n.delta,c=n.reason),{score:e+u,rubric:{...t,familiarity:a},appliedReason:l,receivabilityReason:c}}function ZB(e,t,o){return o?o.familiarity?.[e]??t:t}function JB(e){return e&&2===e.exposureLevel?4:3}function eD(e,t){if(void 0===e)return 0;const o="function"==typeof e?e(t):e;return Number.isFinite(o)?Math.max(0,Math.min(5,o)):0}function tD(e,t){if(!t?.intentDeltas)return e;const o={...e};for(const[e,r]of Object.entries(t.intentDeltas))o[e]=Math.max(0,Math.min(5,(o[e]??0)+r));return o}function oD(e,t){return t?.rubricDeltas?function(e){const t=e=>Math.max(1,Math.min(5,Math.round(e)));return{familiarity:t(e.familiarity),accuracy:t(e.accuracy),precision:t(e.precision)}}({familiarity:e.familiarity+(t.rubricDeltas.familiarity??0),accuracy:e.accuracy+(t.rubricDeltas.accuracy??0),precision:e.precision+(t.rubricDeltas.precision??0)}):e}function rD(e,t,o,r){const n=[],i=r.map(e=>({intent:e,score:o[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of i)n.push(`Strong fit for ${e} (${t}/5)`);if(t.primary.x&&t.primary.y&&n.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&n.push(`${t.seriesCount} series detected on field "${t.primary.series??"series"}"`),"recipe"===e.candidateKind){for(const t of e.positiveRationale?.slice(0,2)??[])n.push(t);e.whyCustom?.reason&&n.push("Why leave the catalog: "+e.whyCustom.reason)}return n}function nD(e,t){if("recipe"!==e.candidateKind||!e.recipe)return{delta:0,reasons:[],caveats:[]};const o=e.recipe;if(t.portability&&o.portability!==t.portability)return{delta:0,reasons:[],caveats:[],excluded:`requires a ${t.portability} recipe`};let r=0;const n=[],i=[],a=t.audience?.name?.trim().toLowerCase();if(a){const e=o.audienceFit?.find(e=>e.audience.trim().toLowerCase()===a);e&&(r+={strong:.75,moderate:.25,weak:-.5,avoid:-2}[e.fit],n.push(e.rationale??`${e.fit} fit for ${t.audience?.name??e.audience}`))}const s=t.receptionChannel??t.audience?.receptionModality??"visual";o.reception?.channels?.includes(s)?(r+=.25,n.push(`Designed for ${s} reception`)):o.reception?.channels?.length&&(r-=1,i.push(`Recipe does not declare support for the ${s} reception channel.`));const l=o.reception?.risks??[];return"low"===t.riskTolerance&&l.length>0?(r-=Math.min(1.5,.35*l.length),i.push(...l)):"medium"===t.riskTolerance&&l.length>2&&(r-=.25),"local"===o.portability?i.push("Local-only recipe: cannot be rendered remotely by CLI or MCP."):n.push("Portable registered recipe"),{delta:r,reasons:n,caveats:i}}function iD(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let o=0;for(const r of t)o+=e[r]??0;return o/t.length}function aD(e,t={}){const o=t.profile??$$(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),r=t.capabilities??YB(),n=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],i=!1!==t.includeVariants,a=t.minScore??0,s=t.maxResults??10,l=t.allow?new Set(t.allow):null,c=t.deny?new Set(t.deny):null,u=t.audience?.receptionModality,d=void 0!==u&&"visual"!==u,h=q$(o,t.scale),p=void 0!==t.scale&&h.rows!==o.rowCount?{...o,rowCount:h.rows}:o,m=[];for(const e of r){if(l&&!l.has(e.component))continue;if(c&&c.has(e.component))continue;if(null!==e.fits(p))continue;const r={};for(const[t,o]of Object.entries(e.intentScores))r[t]=eD(o,p);const s=e.caveats?Array.from(e.caveats(p)):[],f=i&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const i of f){const l=tD(r,i),c=iD(l,n),f=oD(e.rubric,i),g=e.buildProps(o,i);let y;d&&(y=KB(ON(e.component,g),u));const b=QB(c,f,e.component,t.audience,y),v=Y$(e,p,h,t.scale,t.quality);if(v.excluded)continue;const x=nD(e,t);if(x.excluded)continue;const w=b.score+v.delta+x.delta;if(a>w)continue;const k=rD(e,p,l,n);b.appliedReason&&k.push(b.appliedReason),b.receivabilityReason&&k.push(b.receivabilityReason);for(const e of v.reasons)k.push(e);k.push(...x.reasons);const S=[...s,...i?.caveats??[],...v.caveats,...y?.caveats.slice(0,3)??[],...x.caveats];m.push({component:e.component,displayName:e.displayName??e.component,candidateKind:e.candidateKind??"built-in",...e.recipe?{recipeId:e.recipe.id}:{},family:e.family,importPath:e.importPath,variant:i,score:w,intentScores:l,rubric:b.rubric,reasons:k,caveats:S,props:g,...e.whyCustom?{whyCustom:e.whyCustom}:{},scaleRange:{band:h.rowBand,cardinalityBand:h.cardinalityBand,rows:h.rows,rowsSource:h.rowsSource}})}}m.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity);const f=new Set;return m.filter(e=>{const t=`${e.component}:${e.score.toFixed(4)}`;return!f.has(t)&&(f.add(t),!0)}).slice(0,s)}function sD(e,t={}){const o=t.profile??$$(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),r=t.capabilities??YB(),n=t.allow?new Set(t.allow):null,i=t.deny?new Set(t.deny):null,a=q$(o,t.scale),s=void 0!==t.scale&&a.rows!==o.rowCount?{...o,rowCount:a.rows}:o,l=[];for(const e of r){if(n&&!n.has(e.component))continue;if(i&&i.has(e.component))continue;const t=e.fits(s);null!==t&&l.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:aD(e,{...t,profile:o}),rejected:l,profile:o}}function lD(e,t,o={}){const r=YB().find(t=>t.component===e);if(!r)return{reason:`No capability registered for "${e}"`};const n=o.profile??$$(t??[]),i=r.fits(n);if(null!==i)return{reason:i};const a=o.variantKey?r.variants?.find(e=>e.key===o.variantKey):void 0,s=o.intent?Array.isArray(o.intent)?o.intent:[o.intent]:[],l={};for(const[e,t]of Object.entries(r.intentScores))l[e]=eD(t,n);const c=tD(l,a),u=iD(c,s),d=oD(r.rubric,a),h=rD(r,n,c,s),p=nD(r,o);if(p.excluded)return{reason:p.excluded};h.push(...p.reasons);const m=[...r.caveats?r.caveats(n):[],...a?.caveats??[],...p.caveats];return{component:r.component,displayName:r.displayName??r.component,candidateKind:r.candidateKind??"built-in",...r.recipe?{recipeId:r.recipe.id}:{},family:r.family,importPath:r.importPath,variant:a,score:u+p.delta,intentScores:c,rubric:d,reasons:h,caveats:m,props:r.buildProps(n,a),...r.whyCustom?{whyCustom:r.whyCustom}:{}}}function cD(e,t={}){const o=t.profile??$$(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),r=q$(o,t.scale),n=t.maxPerBand??t.maxResults??5,i=["tiny","small","medium","large","huge"],a={};for(const r of i){const i={...t.scale??{},rows:r};a[r]=aD(e,{...t,profile:o,scale:i,maxResults:n})}return{tiny:a.tiny??[],small:a.small??[],medium:a.medium??[],large:a.large??[],huge:a.huge??[],effective:r}}var uD=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function dD(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function hD(e){return dD(e)?e:void 0}function pD(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function mD(e){const t=pD(e);return null==t?void 0:Math.max(0,Math.floor(t))}function fD(...e){return e.map(hD).find(Boolean)}function gD(...e){return e.find(Array.isArray)}function yD(e){const t={};for(const[o,r]of Object.entries(e))void 0!==r&&(t[o]=r);return t}function bD(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function vD(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function xD(e,t,o){const r=e?.filter(e=>!0===hD(e)?.sensor).length,n=hD(t?.observation),i=hD(n?.sensors),a=gD(o?.activeSensors);return Math.max(r??0,i?Object.keys(i).length:0,a?.length??0)||void 0}function wD(e,t,o={}){const{capability:r,audience:n,locale:i}=o,a=o.levels??["l1","l2","l3"],s=!1!==o.includeStructure,l=_L(e,r),c=zL(e,t,{levels:l?[...a,"l4"]:a,locale:i,capability:r,audience:n}),{l4:u,...d}=c.levels,h=["l1","l2","l3"].map(e=>c.levels[e]).filter(Boolean).join(" "),p={levels:d,text:c.annotations?`${c.annotations} ${h}`.trim():h,...c.annotations?{annotations:c.annotations}:{}};let m;if(l&&u){const e=(f=r)?"fits"in f||"buildProps"in f?{family:f.family}:{family:f.family,intentScores:f.intentScores}:{};m={act:l,sentence:u,family:e.family,intentScores:e.intentScores}}var f;const g=s?qL(e,t,{maxLeaves:o.maxLeaves,locale:i}):void 0,y=function(e,t,o){if(!1===o)return;const r=dD(o)?o:void 0,n=hD(t.physics),i=fD(r?.snapshot,n?.snapshot,t.physicsSnapshot,function(e){const t=hD(e);return!!t&&(dD(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),a=fD(r?.evidence,n?.evidence,t.physicsEvidence,t.settledEvidence),s=fD(r?.config,n?.config,i?.config,t.config),l=fD(hD(i?.world),hD(n?.world)),c=fD(hD(s?.kernel),hD(l?.options)),u=gD(l?.bodies),d=gD(l?.colliders,s?.colliders),h=gD(i?.queue,n?.queue),p=gD(i?.liveBodyOrder),m=gD(l?.springs),f=gD(i?.activeSensorPairs),g=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const o=hD(e);if(!o)return;const r=pD(o.count??o.value??o.total??o.bodies??o.events);if(null==r)return;const n=(o.label??o.id??o.name??"container "+(t+1))+"",i=null==o.id?void 0:o.id+"",a=pD(o.secondary??o.secondaryCount),s=pD(o.observed??o.observedCount);return yD({id:i,label:n,count:r,secondary:a,secondaryLabel:"string"==typeof o.secondaryLabel?o.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const o=t.reduce((e,t)=>e+t.count,0),r=t.filter(e=>e.count>0).length,n=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:o,populatedCount:r,...n?{leader:n}:{}}}(function(e,t,o,r){const n=hD(e.settledProjection),i=hD(t?.settledProjection);return gD(o?.projectionRows,o?.aggregates,e.settledProjectionRows,e.projectionRows,n?.rows,t?.settledProjectionRows,t?.projectionRows,i?.rows,r?.binCounts)}(t,n,r,a)),y=function(e,t){const o=e?.map((e,t)=>{const o=hD(e);if(!o)return;const r=pD(o.count)??0,n=pD(o.total),i={label:(o.label??o.id??"sediment "+(t+1))+"",count:r};return null!=o.id&&(i.id=o.id+""),null!=n&&(i.total=n),i}).filter(e=>null!=e),r=mD(t?.bins)??o?.length??0,n=pD(t?.count)??o?.reduce((e,t)=>e+t.count,0)??0,i=pD(t?.total)??o?.reduce((e,t)=>e+(t.total??0),0),a=o?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==r||0!==n||i)return{bins:r,count:n,...null!=i&&i>0?{total:i}:{},...a?{leader:a}:{}}}(gD(r?.sediment,n?.sediment,i?.sediment),fD(r?.sedimentTotals,n?.sedimentTotals)),b=p?.length??u?.length??mD(a?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===hD(e)?.sleeping).length}(u)??mD(a?.sleepingCount),x=h?.length,w="string"==typeof i?.simulationState?i.simulationState:void 0,k="boolean"==typeof a?.settled?a.settled:w?"settled"===w:null!=b||null!=v||null!=x?null!=b&&v===b&&0===(x??0):void 0,S=hD(c?.gravity),A=pD(S?.x),C=pD(S?.y),M=yD({state:w,settled:k,elapsedSeconds:pD(i?.elapsedSeconds),paused:"boolean"==typeof i?.paused?i.paused:void 0,visible:"boolean"==typeof i?.visible?i.visible:void 0,seed:pD(c?.seed),gravity:null!=A&&null!=C?{x:A,y:C}:void 0,fixedDt:pD(s?.fixedDt??c?.fixedDt),timeScale:pD(s?.timeScale),maxSubsteps:mD(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:x,bodyLimit:pD(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),P=yD({colliders:d?.length,sensors:xD(d,s,l),springs:m?.length,activeSensorPairs:f?.length}),I=Object.keys(P).length>0,_=uD.has(e);if(!(Object.keys(M).length>0||I||g||y)||!_&&null==o)return;const L={simulation:M,...I?{geometry:P}:{},...g?{aggregates:g}:{},...y?{sediment:y}:{}},R=function(e){const t=[],o=e.simulation,r=[o.state??(o.settled?"settled":void 0),null!=o.liveBodies?`${o.liveBodies} live ${bD(o.liveBodies,"body")}`:void 0,null!=o.sleepingBodies?o.sleepingBodies+" sleeping":void 0,null!=o.queued?o.queued+" queued":void 0,null!=o.seed?"seed "+vD(o.seed):void 0,o.gravity?`gravity (${vD(o.gravity.x)}, ${vD(o.gravity.y)})`:void 0,null!=o.fixedDt?`fixed step ${vD(o.fixedDt)}s`:void 0,null!=o.timeScale?vD(o.timeScale)+"x time":void 0].filter(Boolean);r.length>0&&t.push(`Physics simulation: ${r.join("; ")}.`);const n=e.geometry;if(n){const e=[null!=n.colliders?`${n.colliders} ${bD(n.colliders,"collider")}`:void 0,null!=n.sensors?`${n.sensors} ${bD(n.sensors,"sensor")}`:void 0,null!=n.springs?`${n.springs} ${bD(n.springs,"spring")}`:void 0,null!=n.activeSensorPairs?`${n.activeSensorPairs} active sensor ${bD(n.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const i=e.aggregates;if(i){const e=i.leader,o=e?` Largest is ${e.label} with ${vD(e.count)}.`:"";t.push(`Physics aggregates: ${vD(i.totalCount)} settled ${bD(i.totalCount,"body")} across ${i.rows.length} ${bD(i.rows.length,"container")}; ${i.populatedCount} populated.${o}`)}const a=e.sediment;if(a){const e=null!=a.total?", value total "+vD(a.total):"",o=a.leader?`; largest sediment bin is ${a.leader.label} with ${vD(a.leader.count)}`:"";t.push(`Physics sediment: ${a.count} retained ${bD(a.count,"body")} in ${a.bins} ${bD(a.bins,"bin")}${e}${o}.`)}return t.join(" ")}(L);return{...L,text:R}}(e,t,o.physics),b=[p.text,m?.sentence,y?.text].filter(Boolean).join(" ");return{component:e,description:p,intent:m,structure:g,physics:y,text:b}}function kD(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function SD(e){const{data:t,onQuery:o,initialAnnotations:r,componentName:n,props:i,includeProfile:a,includeSuggestions:s,suggestionsIntent:l,suggestionsMax:c,focus:u,includeGrounding:d}=e,[h,p]=a$([]),[m,f]=a$([]),[g,y]=a$(!1),[b,v]=a$(null),x=n$(()=>h$(t??[]),[t]),w=a||s,k=n$(()=>w?$$(t??[]):void 0,[w,t]),S=n$(()=>s&&k?aD(t,{profile:k,intent:l,maxResults:c??5}):void 0,[s,k,t,l,c]),A=n$(()=>{if(d&&n)return wD(n,{data:t??[],...i??{}},"object"==typeof d?d:void 0)},[d,n,i,t]),C=i$(o);C.current=o;const M=i$(n);M.current=n;const P=i$(i);P.current=i;const I=i$(t);I.current=t;const _=i$(x);_.current=x;const L=i$(k);L.current=k;const R=i$(S);R.current=S;const T=i$(u);T.current=u;const N=i$(A);N.current=A;const $=r$(async e=>{const t=e.trim();if(!t)return;y(!0),v(null),p(e=>[...e,{role:"user",text:t}]);const o="undefined"!=typeof performance?performance.now():Date.now();SR().record({type:"interrogation-asked",component:M.current,query:kD(t,500)});try{const e=await C.current(t,{data:I.current??[],summary:_.current,profile:L.current,suggestions:R.current,componentName:M.current,props:P.current,grounding:N.current,focus:T.current??void 0});p(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&f(e.annotations);const r="undefined"!=typeof performance?performance.now():Date.now();SR().record({type:"interrogation-answered",component:M.current,answer:kD(e.answer,2e3),annotationCount:e.annotations?.length,latencyMs:Math.max(0,Math.round(r-o))})}catch(e){v(e instanceof Error?e:Error(e+"")),p(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}]);const t="undefined"!=typeof performance?performance.now():Date.now();SR().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-o))})}finally{y(!1)}},[]),B=r$(({text:e,annotations:t})=>{const o=e.trim();o&&(p(e=>[...e,{role:"assistant",text:o}]),t&&t.length>0&&f(e=>[...e,...t]))},[]),D=r$(()=>{p([]),f([]),v(null)},[]);return{ask:$,announce:B,history:h,summary:x,annotations:n$(()=>{const e=r??[];return 0===e.length?m:0===m.length?e:[...e,...m]},[r,m]),loading:g,error:b,reset:D}}import{useMemo as AD}from"react";var CD=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function MD(e={}){const{chartId:t,types:o=CD}=e,{latest:r}=$c({chartId:t,types:o,limit:1});return AD(()=>{if(!r)return null;if("hover-end"===r.type||"selection-end"===r.type||"brush-end"===r.type||"click-end"===r.type)return null;let e;if("selection"===r.type)e=r.selection.fields;else{if("hover"!==r.type&&"click"!==r.type)return null;e=r.datum}return e&&"object"==typeof e?{datum:e,x:r.x,y:r.y,source:r.type}:null},[r])}function PD(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function ID(e,t){return"pass"===e?t.passColor??"var(--semiotic-success)":"warn"===e?t.warnColor??"var(--semiotic-warning)":t.failColor??"var(--semiotic-danger)"}function _D(e){if(null==e)return;const t="number"==typeof e?e:Date.parse(e);return Number.isNaN(t)?void 0:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function LD(e){const t=e.label??e.name??e.id;return"number"==typeof e.confidence&&1>e.confidence?`${t} · ${Math.round(100*e.confidence)}%`:t}function RD(e){return{author:e.name??e.id,authorKind:"system",source:e.source,basis:e.basis??"rule",confidence:e.confidence,createdAt:e.createdAt,dataVersion:e.dataVersion,stableId:e.id}}function TD(e,t={}){const o=[],r=[],n=t.valueAxis??"y",i={status:t.status??"proposed",anchor:t.anchor??"semantic",...void 0!==t.ttlHint?{ttlHint:t.ttlHint}:{}};for(const a of e){if("pass"===a.status&&!t.includePassed)continue;const e=ID(a.status,t),s=LD(a),l={provenance:RD(a),lifecycle:i},c=e=>r.push({result:a,reason:e}),u=e=>o.push(eL(e,l));switch(a.kind){case"range":if("number"!=typeof a.min||"number"!=typeof a.max){c("range check is missing numeric min/max bounds");break}u({type:"band",y0:a.min,y1:a.max,fill:e,fillOpacity:.12,color:e,label:s});break;case"min":case"max":case"threshold":{const t=a.value??("min"===a.kind?a.min:a.max);if("number"!=typeof t){c(a.kind+" check is missing a numeric value");break}u({type:"x"===n?"x-threshold":"y-threshold",value:t,label:s,color:e});break}case"freshness":{const t=void 0!==a.at?PD(a.at):void 0;if(void 0===t){c("freshness check has no parseable timestamp (`at`); render as a chart-level status badge");break}u({type:"x-threshold",value:t,label:s,color:e});break}default:c(`${a.kind} check on "${a.column??"?"}" has no single chart coordinate; surface it as a chart-level status badge or a row-level mark in your UI`)}}return{annotations:o,unplaced:r}}function ND(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function $D(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function BD(e,t={}){const o=[],r=e.sources;if(r?.results){const e=r.metadata?.generated_at,t=r.metadata?.invocation_id;for(const n of r.results){const r=ND(n.status),i=$D(n.unique_id),a=_D(n.max_loaded_at);o.push({id:n.unique_id??i,name:"dbt freshness: "+i,label:"pass"===r?i+" fresh":`${i} stale${a?" since "+a:""}`,status:r,kind:"freshness",at:n.max_loaded_at,message:`freshness ${r}${n.max_loaded_at?" — last load "+n.max_loaded_at:""}`,source:"dbt",basis:"rule",createdAt:e,dataVersion:t})}}const n=e.runResults;if(n?.results){const e=n.metadata?.generated_at,r=n.metadata?.invocation_id;for(const i of n.results){const n=ND(i.status);if("pass"===n&&!t.includePassed)continue;const a=$D(i.unique_id);o.push({id:i.unique_id??a,name:"dbt test · "+a,status:n,kind:"custom",message:i.message??void 0,observedCount:"number"==typeof i.failures?i.failures:void 0,source:"dbt",basis:"rule",createdAt:e,dataVersion:r})}}return TD(o,t)}function DD(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function FD(e){return e.replace(/^expect_/,"").replace(/column_values_to_be_|column_values_to_|column_|to_be_|to_/g," ").replace(/_/g," ").replace(/\s+/g," ").trim()||e}function ED(e,t={}){const{createdAt:o,dataVersion:r}=function(e){const t=e?.run_id;return t?"string"==typeof t?{dataVersion:t}:{createdAt:t.run_time,dataVersion:t.run_name??t.run_time}:{}}(e.meta),n=[];for(const[t,i]of(e.results??[]).entries()){const e=i.expectation_config??{},a=e.expectation_type??"unknown_expectation",s=e.kwargs??{},l=s.column,c=i.success?"pass":"fail",u=DD(s.min_value),d=DD(s.max_value),h=DD(s.value),p=DD(i.result?.observed_value),m=l??"value",f=FD(a),g=void 0!==p?`${m}: ${p} `:"",y={id:`ge:${a}:${l??t}`,name:`GE ${f}${l?` (${l})`:""}`,status:c,column:l,message:void 0!==p?"observed "+p:void 0,observedCount:i.result?.unexpected_count,source:"great-expectations",basis:"statistical-test",createdAt:o,dataVersion:r},b=/_to_be_between$/.test(a);n.push(b&&void 0!==u&&void 0!==d?{...y,kind:"range",min:u,max:d,label:`${g}(expected ${u}–${d})`}:b&&void 0!==u?{...y,kind:"min",value:u,label:`${g}(min ${u})`}:b&&void 0!==d?{...y,kind:"max",value:d,label:`${g}(max ${d})`}:void 0!==h?{...y,kind:"threshold",value:h,label:`${g}(target ${h})`}:{...y,kind:"custom",label:`${m} ${f}`})}return TD(n,t)}function zD(e,t,o={}){const r=o.profile??$$(t??[],{rawInput:o.rawInput}),n=VB(e),i=o.maxAlternatives??3,a=n?.recipe?function(e,t){const o=[];"required"===e.accessibility.description&&"string"!=typeof(t.props??{}).description&&o.push("This custom recipe needs a generated or authored description."),e.reception?.risks?.some(e=>/unfamiliar/i.test(e))&&!(e.reception.scaffolds??[]).some(e=>["legend","annotation","summary","description"].includes(e))&&o.push("This recipe is unfamiliar; add an orienting legend, annotation, or summary.");const r=e.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));r&&o.push("This recipe is color-dependent; add a shape, position, texture, or label cue."),e.reception?.channels.includes("interactive")&&!e.accessibility.fallbackTable&&"required"!==e.accessibility.accessibleTable&&o.push("This interactive recipe needs a static data fallback."),"local"===e.portability&&o.push("This recipe is local-only and cannot be exported to MCP or CLI rendering.");for(const e of t.observedSceneAudit?.observedSceneEvidence??[])"fail"!==e.status&&"warn"!==e.status||("interaction.hit-targets"===e.id?o.push("Scene audit found data-bearing marks without hit targets."):"accessibility.table-fields"===e.id?o.push("Scene audit found accessible-table field loss."):"accessibility.navigation-depth"===e.id&&o.push("The recipe navigation tree is root-only; expose groups and reachable data marks."));return[...new Set(o)]}(n.recipe,o):[];if(!n)return{status:"unknown",component:e,alternatives:aD(t,{profile:r,intent:o.intent,maxResults:i,includeVariants:!1}),profile:r};const s=n.fits(r);return null===s?{status:"ok",component:e,profile:r,...a.length?{repairs:a}:{}}:{status:"alternative",component:e,reason:s,alternatives:aD(t,{profile:r,intent:o.intent,maxResults:i,deny:[e],includeVariants:!1}),profile:r,...a.length?{repairs:a}:{}}}var jD={valid:!1,errors:[]};function OD(e,t={}){const o=e.component,r=e.props??{},n=[],i=!!t_[o];i||n.push(`Unknown component "${o}". It is not in the chart registry — pick a known chart.`);const a=i?r_(o,r):{...jD};if(!a.valid)for(const e of a.errors)n.push(e);const s=!1!==t.diagnose&&i?BN(o,r).diagnoses:[],l=s.filter(e=>"error"===e.severity),c=!1!==t.treatErrorsAsBlocking;if(c)for(const e of l)n.push(`${e.code}: ${e.message}`);let u,d,h,p,m;if((t.repair??!!t.data)&&t.data&&(u=zD(o,t.data,{intent:t.intent}),"alternative"===u.status?n.push(`${o} is a poor fit: ${u.reason}. Consider ${u.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`):"unknown"===u.status&&n.push(`${o} could not be evaluated against the data; consider ${u.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`)),i&&(d=O_(o,r),h=Y_(d)),t.render&&i){const e=t.render(o,r);m=e.svg,p=e.evidence,p.empty&&n.push("Rendered to an empty scene (no marks) — the data or accessors produce nothing to draw.");for(const e of p.warnings)n.push(e)}const f=i&&a.valid&&(!c||0===l.length)&&(!u||"ok"===u.status)&&(!p||!p.empty);return{ok:f,component:o,props:r,config:d,jsx:h,validation:a,diagnostics:s,repair:u,evidence:p,svg:m,reasons:f?[]:n}}function HD(e={}){const t=e.components??Object.keys(t_).sort();return{name:e.name??"render_semiotic_chart",description:"Render a Semiotic chart from a component name and props. The result is validated, diagnosed for anti-patterns, and (when data is supplied) checked for fit against the data. Inject a renderer to prove it paints; otherwise the result returns validation and repair reasons plus ranked alternatives.",inputSchema:{type:"object",additionalProperties:!1,required:["component"],properties:{component:{type:"string",enum:[...t],description:"The chart component to render."},props:{type:"object",description:"Props for the chart (accessors, data, encodings). See the component schema.",additionalProperties:!0}}}}}function WD(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function qD(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function GD(e,t=!0){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const o=e,r=Array.isArray(o.type)?o.type:[o.type],n=r.includes("object")||!!o.properties;if(t&&!n)return!1;if(n){if(!1!==o.additionalProperties)return!1;const e=o.properties;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=new Set(Array.isArray(o.required)?o.required:[]);if(Object.keys(e).some(e=>!t.has(e)))return!1;if(!Object.values(e).every(e=>GD(e,!1)))return!1}if(r.includes("array")&&(!o.items||!GD(o.items,!1)))return!1;for(const e of["anyOf","oneOf","allOf"]){if(void 0===o[e])continue;const t=o[e];if(!Array.isArray(t)||0===t.length)return!1;if(!t.every(e=>GD(e,!1)))return!1}return!0}function YD(e,t={}){const o=t.strict??!1;if(o&&!GD(e.inputSchema))throw Error("OpenAI strict mode requires a top-level object schema, closed object schemas, and every property required. chartGenerationTool() intentionally leaves props open for chart-specific props; use strict: false or pass a component-specific closed schema.");return{type:"function",name:e.name,description:e.description,parameters:e.inputSchema,strict:o}}function VD(e){return t=>OD(t,e?e(t):{})}import{useCallback as XD,useEffect as UD,useMemo as KD,useRef as QD,useState as ZD}from"react";function JD(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=JD(t);if(e)return e}return null}function eF(e,t){return e?t.map(t=>e[t]+"").join(""):""}function tF(e){const{tree:t,chartId:o,observe:r=["hover","click"]}=e,n=e.selectionName??"__semiotic-nav-sync"+(o?":"+o:""),i=KD(()=>{if(e.matchFields)return e.matchFields;const o=JD(t);return o?Object.keys(o).filter(e=>{return!e.startsWith("_")&&(null==(t=o[e])||"string"==typeof t||"number"==typeof t||"boolean"==typeof t);var t}):[]},[e.matchFields,t]),a=KD(()=>{const e=new Map,o=t=>{if("datum"===t.role&&t.datum){const o=eF(t.datum,i);e.has(o)||e.set(o,t.id)}for(const e of t.children??[])o(e)};return o(t),e},[t,i]),{selectPoints:s,clear:l}=Mc({name:n,fields:i}),{latest:c}=$c({chartId:o,types:[...r,"hover-end"],limit:1}),[u,d]=ZD(t.id);UD(()=>{d(t.id),l()},[t,l]);const h=XD(e=>{if(d(e.id),"datum"===e.role&&e.datum&&i.length>0){const t={};for(const o of i)t[o]=[e.datum[o]];s(t)}else l()},[i,s,l]),p=e.annotations,m=KD(()=>{const e=new Set;if(0===i.length||!p)return e;for(const t of p){const o=a.get(eF(t,i));o&&e.add(o)}return e},[p,a,i]),f=XD(e=>{const t="number"==typeof e?p?.[e]:e;if(!t||0===i.length)return!1;const o=a.get(eF(t,i));if(!o)return!1;d(o);const r={};for(const e of i)r[e]=[t[e]];return s(r),!0},[p,a,i,s]),g=QD(null);return UD(()=>{if(!c||c===g.current)return;if(g.current=c,"hover-end"===c.type)return;const e=c.datum;if(!e||0===i.length)return;const t=a.get(eF(e,i));t&&t!==u&&d(t)},[c,a,i,u]),{activeId:u,onActiveChange:h,selection:{name:n},annotatedIds:m,focusAnnotation:f}}var oF=[{intent:"outlier-detection",weight:4,patterns:[/\b(outlier|outliers|anomal|anomaly|anomalies|extreme|extremes|unusual|stands? out|sticks? out|odd one)\b/i,/\b(peak|peaks|highest|lowest|biggest spike|spike|min|max|maximum|minimum)\b/i]},{intent:"trend",weight:4,patterns:[/\b(trend|trends|trending|trajectory|over time|across time|growth|decline|rising|falling|increasing|decreasing)\b/i,/\b(history|historical|evolved|evolution|change over)\b/i]},{intent:"change-detection",weight:3,patterns:[/\b(when did|what changed|shift|shifted|breakpoint|inflection|turning point|sudden|abrupt)\b/i]},{intent:"rank",weight:4,patterns:[/\b(rank|ranking|ranked|biggest|smallest|largest|order by|sorted|best|worst|leaderboard)\b/i,/\btop\s+(\d+|sellers?|performers?|picks?|results?|categories|items?)\b/i,/\bbottom\s+(\d+|results?|items?)\b/i,/\b(who has the most|which.*most|which.*highest|which.*lowest)\b/i]},{intent:"part-to-whole",weight:4,patterns:[/\b(share|shares|composition|portion|portions|fraction|percentage of|percent of|breakdown|make up|made up of|slice|slices)\b/i,/\b(part of|part to whole|piece of the pie|how much of)\b/i]},{intent:"composition-over-time",weight:5,patterns:[/\b(composition.*time|share.*over time|share.*across|how.*mix.*changed|stacked.*time)\b/i,/\b(over time.*share|over time.*composition|over time.*breakdown)\b/i]},{intent:"distribution",weight:4,patterns:[/\b(distribution|distributions|spread|variance|variation|histogram|skew|skewed|range of|how.*spread|shape of|bell curve)\b/i,/\b(typical value|typical range|where do most|mode|median)\b/i]},{intent:"correlation",weight:4,patterns:[/\b(correl|correlation|relationship|related to|connected to|associated|connection between|relate to)\b/i,/\b(\w+ vs\.? \w+|\w+ versus \w+|\w+ against \w+|scatter)\b/i]},{intent:"compare-series",weight:3,patterns:[/\b(compare.*series|compare.*groups|compare.*cohorts|side by side|group.*vs|series.*vs)\b/i,/\b(how do.*compare|each group|each series|each cohort)\b/i]},{intent:"compare-categories",weight:3,patterns:[/\b(compare.*categor|category.*compar|which is bigger|how does.*compare|differences? between)\b/i]},{intent:"flow",weight:4,patterns:[/\b(flow|flows|transition|transitions|movement|moved from|funnel|conversion|drop[- ]off|sankey|chord)\b/i,/\b(from.*to|source.*target|path|journey|pipeline)\b/i]},{intent:"hierarchy",weight:4,patterns:[/\b(hierarchy|hierarchical|tree|nested|parent.*child|subcategory|sub-?categor|drill down|drilldown|breakdown by level)\b/i]},{intent:"geo",weight:5,patterns:[/\b(geographic|geography|geospatial|map|maps|country|countries|cities|latitude|longitude|spatial|cartogr|choropleth)\b/i,/\b(city|us state|each state|the states)\b/i,/\bacross\s+(countries|states|regions|cities|the world|the country)\b/i]}];function rF(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const o of oF)for(const r of o.patterns)if(r.test(e)){const e=t.get(o.intent)??0;t.set(o.intent,Math.min(5,0===e?o.weight:e+.5));break}if(0===t.size)return null;const o=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[r,...n]=o;return{intent:r.intent,confidence:r.confidence,alternates:n}}function nF(e,t={}){const o=t.audience;if(!o)return[];const r=t.profile??$$(e??[],{rawInput:t.rawInput}),n=JB(o),i=t.scoreTolerance??1.5,a=t.maxResults??5,s=YB(),l=new Map;for(const e of s)l.set(e.component,ZB(e.component,e.rubric.familiarity,o));const c=aD(e,{profile:r,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),u=c.filter(e=>(l.get(e.component)??e.rubric.familiarity)>=4)[0],d=[];for(const e of c)(l.get(e.component)??e.rubric.familiarity)>n||("increase"===o.targets?.[e.component]?.direction||!u||i>=u.score-e.score)&&d.push({stretch:e,familiar:u});const h=new Set,p=[];for(const{stretch:e,familiar:t}of d){const r=`${e.component}/${e.variant?.key??"base"}`;if(h.has(r))continue;h.add(r);const n=l.get(e.component)??e.rubric.familiarity,i=o.targets?.[e.component],s=i?.reason??("increase"===i?.direction?`${o.name??"your audience"} is growing adoption of ${e.component}`:t?`${e.component} is on the data, and within reach of ${t.component} which you're already familiar with`:e.component+" fits this data and would expand your team's vocabulary");if(p.push({suggestion:e,replacing:t?.component,rationale:s,familiarity:n}),p.length>=a)break}return p}function iF(e,t={}){const o=t.profile??$$(e??[],{rawInput:t.rawInput}),r=t.maxPanels??6,n=!1!==t.diversifyByFamily,i=t.intents??function(e){const t=[];return e.hasTimeAxis&&(t.push("trend"),e.seriesCount&&e.seriesCount>=2&&t.push("compare-series","composition-over-time"),t.push("change-detection")),e.categoryCount&&t.push("rank","compare-categories","part-to-whole"),e.primary.y&&e.rowCount>=10&&t.push("distribution"),2>Object.values(e.fields).filter(e=>"numeric"===e.type).length||t.push("correlation","outlier-detection"),e.hasHierarchy&&t.push("hierarchy"),e.hasNetwork&&t.push("flow"),e.hasGeo&&t.push("geo"),Array.from(new Set(t))}(o),a=[],s=[],l=[],c=new Set,u=new Set;for(const d of i){if(a.length>=r){l.push(d);continue}const i=aD(e,{profile:o,intent:d,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let h;for(const e of i)if(!(u.has(`${e.component}/${e.variant?.key??"base"}`)||n&&c.has(e.family))){h=e;break}if(!h&&n)for(const e of i)if(!u.has(`${e.component}/${e.variant?.key??"base"}`)){h=e;break}h?(a.push({intent:d,suggestion:h}),s.push(d),c.add(h.family),u.add(`${h.component}/${h.variant?.key??"base"}`)):l.push(d)}return{panels:a,intentsCovered:s,intentsMissing:l,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?nF(e,{profile:o,audience:t.audience,deny:Array.from(u).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,r)}):[],profile:o}}var aF={name:"Executive",familiarity:{BarChart:5,LineChart:5,PieChart:5,DonutChart:4,GaugeChart:5,AreaChart:4,FunnelChart:4,ChoroplethMap:4,Histogram:3,Heatmap:3,StackedBarChart:3,StackedAreaChart:3,Scatterplot:3,BubbleChart:3,GroupedBarChart:3,DotPlot:3,BoxPlot:2,ViolinPlot:1,SwarmPlot:1,RidgelinePlot:1,MultiAxisLineChart:2,CandlestickChart:2,DifferenceChart:2,QuadrantChart:3,LikertChart:3,SwimlaneChart:2,MinimapChart:2,ConnectedScatterplot:1,SankeyDiagram:2,TreeDiagram:3,Treemap:3,CirclePack:2,OrbitDiagram:1,ChordDiagram:1,ProcessSankey:2,ForceDirectedGraph:1,ProportionalSymbolMap:3,FlowMap:2,DistanceCartogram:1},targets:{PieChart:{direction:"decrease",weight:1,reason:"shifting from share-by-angle toward share-by-length for accuracy"},BarChart:{direction:"increase",weight:1}},exposureLevel:1},sF={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},lF={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},cF={executive:aF,analyst:sF,"data-scientist":lF},uF=[{component:"RealtimeLineChart",importPath:"semiotic/realtime",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"y"===e.role||"value"===e.role)?"high"===e.throughput?"for high-throughput streams, prefer RealtimeHeatmap or RealtimeWaterfallChart":null:"needs a numeric value field":"needs a date/time field for the x axis",intentScores:{trend:5,"change-detection":4,"outlier-detection":2},caveats:e=>{const t=[];return"cumulative"===e.retention&&t.push("cumulative retention will eventually exhaust the buffer — set a windowSize or downsample"),t},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,o=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:o}}},{component:"RealtimeHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric field to bin":"needs a time field",intentScores:{distribution:5,"outlier-detection":4,"change-detection":2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:o}}},{component:"RealtimeSwarmChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:4},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?e.fields.some(e=>"categorical"===e.kind||"category"===e.role)?null:"needs a category to swarm by":"needs a numeric field":"needs a time field (points are placed at (time, value))",intentScores:{"outlier-detection":5,distribution:4,"compare-categories":3},caveats:e=>"high"===e.throughput?["high-throughput swarms get crowded — consider RealtimeHistogram"]:[],buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,r=e.fields.find(e=>"category"===e.role||"categorical"===e.kind)?.name;return{timeAccessor:t,valueAccessor:o,categoryAccessor:r}}},{component:"RealtimeWaterfallChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field",intentScores:{"change-detection":5,trend:3,"outlier-detection":4,distribution:e=>"high"===e.throughput?4:2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:o}}},{component:"RealtimeHeatmap",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field for the x axis",intentScores:{trend:e=>"high"===e.throughput?4:2,distribution:3,"change-detection":3,"compare-series":e=>e.fields.find(e=>"series"===e.role||"categorical"===e.kind&&"category"!==e.role)?4:1},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,o=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name,r=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role)?.name;return{timeAccessor:t,valueAccessor:o,...r?{categoryAccessor:r}:{}}}},{component:"TemporalHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?"windowed"===e.retention?"windowed retention is RealtimeHistogram's job; TemporalHistogram serves bounded/cumulative data":null:"needs a numeric value field":"needs a time field",intentScores:{distribution:5,"change-detection":3,trend:2},buildProps:e=>{const t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,o=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name;return{timeAccessor:o,valueAccessor:t}}}],dF=new Map;function hF(e){dF.set(e.component,e)}function pF(e){dF.delete(e)}function mF(){if(0===dF.size)return uF;const e=new Map;for(const t of uF)e.set(t.component,t);for(const[t,o]of dF)e.set(t,o);return Array.from(e.values())}function fF(e,t){if(void 0===e)return 0;const o="function"==typeof e?e(t):e;return Number.isFinite(o)?Math.max(0,Math.min(5,o)):0}function gF(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let o=0;for(const r of t)o+=e[r]??0;return o/t.length}function yF(e,t,o){const r=[],n=o.map(e=>({intent:e,score:t[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of n)r.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&r.push(`tuned for ${e.throughput} throughput`),r}function bF(e,t={}){const o=t.capabilities??mF(),r=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],n=t.minScore??0,i=t.maxResults??10,a=t.allow?new Set(t.allow):null,s=t.deny?new Set(t.deny):null,l=[];for(const t of o){if(a&&!a.has(t.component))continue;if(s&&s.has(t.component))continue;if(null!==t.fits(e))continue;const o={};for(const[r,n]of Object.entries(t.intentScores))o[r]=fF(n,e);const i=gF(o,r);if(n>i)continue;const c={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=yF(e,o,r),h=t.buildProps(e);l.push({component:t.component,family:"realtime",importPath:t.importPath,score:i,intentScores:o,rubric:c,reasons:d,caveats:u,props:h})}return l.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),l.slice(0,i)}var vF=["x","y","size","category","series","time"];function xF(e,t){const o=e.fields[t];return o?"numeric"===o.type?"numeric":"categorical"===o.type?"categorical":"date"===o.type?"date":"unknown":"unknown"}function wF(e){const t=new Set;for(const o of YB())null===o.fits(e)&&t.add(o.component);return t}function kF(e,t){const o=new Set(Object.keys(e.fields)),r=new Set(Object.keys(t.fields)),n=[],i=[];for(const e of r)o.has(e)||n.push(e);for(const e of o)r.has(e)||i.push(e);n.sort(),i.sort();const a=[];for(const n of r){if(!o.has(n))continue;const r=xF(e,n),i=xF(t,n);r!==i&&a.push({field:n,from:r,to:i})}a.sort((e,t)=>e.field.localeCompare(t.field));const s=[];for(const o of vF){const r=e.primary[o],n=t.primary[o];r!==n&&s.push({role:o,from:r,to:n})}const l=wF(e),c=wF(t),u=Array.from(l).filter(e=>!c.has(e)).sort(),d=Array.from(c).filter(e=>!l.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:n,removed:i,typeChanges:a,primaryChanges:s,becameUnfit:u,becameFit:d,unchanged:0===n.length&&0===i.length&&0===a.length&&0===s.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}}function SF(e,t=YB()){const o=new Map;for(const e of t)o.set(e.component,{component:e.component,family:e.family,fitsOn:0,rejectedOn:0,inTopThreeOn:0,topPickOn:0,expertAgreementCount:0,averageScore:0,caveatCoverage:0,variantUtilization:0});const r=new Map,n=new Map,i=new Map,a=new Map,s=[];for(const l of e){let e,c;try{e=$$(l.data,{rawInput:l.rawInput}),c=sD(l.data,{profile:e,intent:l.intent,capabilities:t,maxResults:40})}catch{const e=!!l.expected&&l.expected.length>0;s.push({fixture:l.name,shape:l.shape,intent:l.intent,expected:l.expected,topPick:void 0,topThree:[],fittingCount:0,rejectedCount:0,expertAgreement:!e&&null,topPickAgreement:!e&&null,noFitHonored:null});continue}const u=[],d=new Set;for(const e of c.fitting)if(!d.has(e.component)&&(d.add(e.component),u.push({component:e.component,variantKey:e.variant?.key,score:e.score}),3===u.length))break;const h=l.expected&&l.expected.length>0?u.some(e=>l.expected.includes(e.component)):null,p=l.expected&&l.expected.length>0?u.length>0&&l.expected.includes(u[0].component):null;s.push({fixture:l.name,shape:l.shape,intent:l.intent,expected:l.expected,topPick:u[0],topThree:u,fittingCount:c.fitting.length,rejectedCount:c.rejected.length,expertAgreement:h,topPickAgreement:p,noFitHonored:!0===l.expectsNoFit?0===c.fitting.length:null});for(const e of c.fitting){const t=o.get(e.component);t&&(t.fitsOn+=1,r.set(e.component,(r.get(e.component)??0)+e.score),n.set(e.component,(n.get(e.component)??0)+1),e.caveats.length>0&&i.set(e.component,(i.get(e.component)??0)+1),e.variant&&a.set(e.component,(a.get(e.component)??0)+1))}for(const e of c.rejected){const t=o.get(e.component);t&&(t.rejectedOn+=1)}for(const e of u){const t=o.get(e.component);t&&(t.inTopThreeOn+=1)}if(u[0]){const e=o.get(u[0].component);e&&(e.topPickOn+=1)}if(l.expected&&h)for(const e of u)if(l.expected.includes(e.component)){const t=o.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of o.values()){const t=n.get(e.component)??0;e.averageScore=0===t?0:(r.get(e.component)??0)/t,e.caveatCoverage=0===t?0:(i.get(e.component)??0)/t,e.variantUtilization=0===t?0:(a.get(e.component)??0)/t}const l=Array.from(o.values()).sort((e,t)=>{const o=e.expertAgreementCount-t.expertAgreementCount;return 0!==o?o:t.fitsOn-e.fitsOn}),c=s.filter(e=>null!==e.expertAgreement),u=0===c.length?0:c.filter(e=>!0===e.expertAgreement).length/c.length,d=0===c.length?0:c.filter(e=>!0===e.topPickAgreement).length/c.length,h=Array.from(n.values()).reduce((e,t)=>e+t,0),p=Array.from(i.values()).reduce((e,t)=>e+t,0),m=Array.from(a.values()).reduce((e,t)=>e+t,0);return{perCapability:l,perFixture:s,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:u,top1AgreementRate:d,overallCaveatCoverage:0===h?0:p/h,overallVariantUtilization:0===h?0:m/h}}}var AF=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,o)=>e.map(e=>({month:e,revenue:800+e*(200+40*o)+150*Math.sin(e),region:t})))})(),CF=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),MF=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],PF=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),IF=Array.from({length:80},(e,t)=>{const o=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:o,grade:Math.min(100,1.8*o+30+20*(Math.random()-.5))}}),_F=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),LF=[{product:"Widget",region:"EU",units:480},{product:"Widget",region:"NA",units:620},{product:"Widget",region:"APAC",units:290},{product:"Gadget",region:"EU",units:320},{product:"Gadget",region:"NA",units:740},{product:"Gadget",region:"APAC",units:410},{product:"Sprocket",region:"EU",units:200},{product:"Sprocket",region:"NA",units:380},{product:"Sprocket",region:"APAC",units:150},{product:"Whatsit",region:"EU",units:290},{product:"Whatsit",region:"NA",units:550},{product:"Whatsit",region:"APAC",units:180}],RF=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:AF,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:AF,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:AF,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:CF,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:MF,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:MF,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:PF,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:PF,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:IF,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:IF,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:LF,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:LF,intent:"part-to-whole",expected:["StackedBarChart","PieChart"]},{name:"revenue vs expenses, intent=compare-series",shape:"48 rows = 24 months × 2 series",data:[...Array.from({length:24},(e,t)=>({month:t+1,amount:100+8*t+25*Math.sin(t/3),series:"revenue"})),...Array.from({length:24},(e,t)=>({month:t+1,amount:80+6*t+15*Math.cos(t/4),series:"expenses"}))],intent:"compare-series",expected:["DifferenceChart","LineChart","GroupedBarChart"]},{name:"stock OHLC prices, intent=change-detection",shape:"30 days × open/high/low/close",data:Array.from({length:30},(e,t)=>{const o=100+1.2*t+8*Math.sin(t/4),r=o+4*(Math.random()-.5),n=o+4*(Math.random()-.5);return{day:t+1,open:r,high:Math.max(r,n)+3*Math.random(),low:Math.min(r,n)-3*Math.random(),close:n}}),intent:"change-detection",expected:["CandlestickChart","LineChart"]},{name:"unemployment vs inflation by year, intent=correlation",shape:"20 years × 2 measures, ordered by year",data:Array.from({length:20},(e,t)=>({year:2005+t,unemployment:5+2*Math.sin(t/2)+(t>4&&10>t?3:0),inflation:2+1.5*Math.cos(t/3)})),intent:"correlation",expected:["ConnectedScatterplot","Scatterplot"]},{name:"transition events, intent=flow",shape:"11 stage transitions across 3 deals with startTime + value",data:[{case:"deal-001",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T09:00:00",value:18},{case:"deal-001",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-01T13:00:00",value:16},{case:"deal-001",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-02T11:00:00",value:14},{case:"deal-001",stage:"Proposal",nextStage:"Closed Won",startTime:"2024-04-04T09:00:00",value:12},{case:"deal-002",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T10:00:00",value:10},{case:"deal-002",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-02T09:00:00",value:9},{case:"deal-002",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-03T09:00:00",value:7},{case:"deal-002",stage:"Proposal",nextStage:"Closed Lost",startTime:"2024-04-04T11:00:00",value:5},{case:"deal-003",stage:"Signup",nextStage:"Activated",startTime:"2024-04-01T08:30:00",value:28},{case:"deal-003",stage:"Activated",nextStage:"Trial",startTime:"2024-04-01T10:00:00",value:24},{case:"deal-003",stage:"Trial",nextStage:"Subscribed",startTime:"2024-04-02T10:00:00",value:18}],intent:"flow",expected:["SankeyDiagram","ProcessSankey","ChordDiagram"]},{name:"incidents by service and weekday, intent=compare-categories",shape:"56 cells = 8 services × 7 weekdays, numeric incident count",data:(()=>{const e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return["auth","billing","search","ingest","notify","reports","exports","webhooks"].flatMap((t,o)=>e.map((e,r)=>({service:t,day:e,incidents:Math.round(2+9*Math.abs(Math.sin(1.7*o+r))+(5>r?1.5:-1.5))})))})(),intent:"compare-categories",expected:["Heatmap","GroupedBarChart"]},{name:"capacity utilization single value, intent=part-to-whole",shape:"1 row, one numeric value against an implicit 0–100 plan",data:[{metric:"Cluster capacity used",value:78}],intent:"part-to-whole",expected:["GaugeChart","BigNumber"]},{name:"shipping flows between cities, intent=flow",shape:"6 lat/lon nodes, 6 weighted flows, 1 outline feature",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"SEA",lon:-122.3,lat:47.6},{id:"SFO",lon:-122.4,lat:37.8},{id:"DEN",lon:-104.9,lat:39.7},{id:"ORD",lon:-87.6,lat:41.9},{id:"ATL",lon:-84.4,lat:33.7},{id:"JFK",lon:-73.8,lat:40.6}],flows:[{source:"SEA",target:"ORD",value:320},{source:"SFO",target:"JFK",value:540},{source:"SFO",target:"ATL",value:210},{source:"DEN",target:"ORD",value:180},{source:"ORD",target:"JFK",value:460},{source:"ATL",target:"JFK",value:250}]},intent:"flow",expected:["FlowMap"]},{name:"travel times from HQ, intent=geo",shape:"6 lat/lon points with a cost field measured from a center",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"HQ",lon:-122.4,lat:37.8,cost:0},{id:"Seattle",lon:-122.3,lat:47.6,cost:95},{id:"Denver",lon:-104.9,lat:39.7,cost:150},{id:"Chicago",lon:-87.6,lat:41.9,cost:245},{id:"Atlanta",lon:-84.4,lat:33.7,cost:280},{id:"New York",lon:-73.8,lat:40.6,cost:330}]},intent:"geo",expected:["DistanceCartogram","ProportionalSymbolMap"]},{name:"flat single column",shape:"50 rows, one numeric column",data:_F,expected:["Histogram"]},{name:"sparse 3-row data, intent=rank",shape:"3 rows total",data:[{name:"A",value:12},{name:"B",value:34},{name:"C",value:8}],intent:"rank",expected:["BarChart","DotPlot"]}];import{useEffect as TF,useMemo as NF,useRef as $F,useSyncExternalStore as BF}from"react";var DF=e=>uR(e),FF=()=>SR().enabled,EF=()=>!1;function zF(e,t={}){const{intent:o,allow:r,deny:n,maxResults:i,includeVariants:a,minScore:s,rawInput:l,seriesField:c,capabilities:u,audience:d,profile:h}=t,p=NF(()=>h??$$(e??[],{rawInput:l,seriesField:c}),[h,e,l,c]),m=NF(()=>aD(e,{intent:o,allow:r,deny:n,maxResults:i,includeVariants:a,minScore:s,capabilities:u,audience:d,profile:p}),[e,o,r,n,i,a,s,u,d,p]),f=BF(DF,FF,EF),g=$F(null);return TF(()=>{if(0===m.length)return void(g.current=null);if(!f)return void(g.current=null);const e=SR(),t=d?.name??(d?"custom":void 0),r=`${o??""}|${t??""}|${m.map(e=>e.component).join(",")}`;if(r===g.current)return;const n=e.getEvents();for(let e=n.length-1;e>=0;e--){const t=n[e];if("suggestion-shown"===t.type){if(`${Array.isArray(t.intent)?t.intent.join(","):t.intent??""}|${t.audience??""}|${t.components.join(",")}`===r)return void(g.current=r);break}}g.current=r,e.record({type:"suggestion-shown",intent:o,components:m.map(e=>e.component),topScore:m[0]?.score,audience:t})},[m,o,d,f]),{suggestions:m,profile:p}}import*as jF from"react";import{forwardRef as OF,useMemo as HF}from"react";import{useMemo as WF,useRef as qF}from"react";function GF(e){const t=qF(null);return sd(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Iu(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:WF(()=>Pp(e.margin),[e.margin])}}function YF(e){const t=GF(e),{resolved:o,normalizedMargin:r}=t,n=od({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:void 0,selection:e.selection,linkedHover:e.linkedHover,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:o.showLegend,userMargin:r,marginDefaults:o.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:o.width,height:o.height});return{...t,safeData:n.data,setup:n,earlyReturn:n.earlyReturn}}import{jsx as VF}from"react/jsx-runtime";var XF=OF(function(e,t){const{data:o,layout:r,layoutConfig:n,onLayoutError:i,xExtent:a,yExtent:s,showAxes:l=!1,margin:c,className:u,annotations:d,onObservation:h,onClick:p,selection:m,linkedHover:f,chartId:g,loading:y,loadingContent:b,emptyContent:v,colorBy:x,colorScheme:w,frameProps:k={}}=e,{frameRef:S,resolved:A,safeData:C,setup:M,earlyReturn:P}=YF({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:o,colorBy:x,colorScheme:w,selection:m,linkedHover:f,onObservation:h,onClick:p,chartId:g,loading:y,loadingContent:b,emptyContent:v,margin:c,width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules,xLabel:e.xLabel,yLabel:e.yLabel}),I=M.effectiveSelectionHook,_=HF(()=>I?.isActive?{isActive:!0,predicate:I.predicate}:null,[I?.isActive,I?.predicate]);if(P)return P;const{width:L,height:R,enableHover:T,showGrid:N,title:$,description:B,summary:D,accessibleTable:F,xLabel:E,yLabel:z}=A,j={chartType:"custom",...null!=o&&{data:C},customLayout:r,layoutConfig:n,onLayoutError:i,..._&&{layoutSelection:_},xExtent:a,yExtent:s,colorAccessor:x,colorScheme:w,size:[L,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M.margin,showAxes:l,xLabel:E,yLabel:z,enableHover:T,showGrid:N,...M.legendBehaviorProps,...ld({title:$,description:B,summary:D,accessibleTable:F,className:u,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...cd({linkedHover:f,selection:m,onObservation:h,onClick:p,hoverHighlight:!1,mobileInteraction:M.mobileInteraction,customHoverBehavior:M.customHoverBehavior,customClickBehavior:M.customClickBehavior}),...d&&d.length>0&&{annotations:d},...M.crosshairProps,...k};return VF(Eu,{componentName:"XYCustomChart",width:L,height:R,children:VF(Yl,{ref:S,...j})})});XF.displayName="XYCustomChart";import{forwardRef as UF,useMemo as KF}from"react";import{jsx as QF}from"react/jsx-runtime";var ZF=UF(function(e,t){const{data:o,layout:r,layoutConfig:n,onLayoutError:i,categoryAccessor:a="category",valueAccessor:s="value",oExtent:l,rExtent:c,projection:u="vertical",margin:d,className:h,colorBy:p,colorScheme:m,showAxes:f=!1,annotations:g,onObservation:y,onClick:b,selection:v,linkedHover:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,frameProps:C={}}=e,{frameRef:M,resolved:P,safeData:I,setup:_,earlyReturn:L}=YF({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"OrdinalCustomChart",unwrapData:!0,data:o,colorBy:p,colorScheme:m,selection:v,linkedHover:x,onObservation:y,onClick:b,chartId:w,loading:k,loadingContent:S,emptyContent:A,margin:d,width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,title:e.title,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),R=_.effectiveSelectionHook,T=KF(()=>R?.isActive?{isActive:!0,predicate:R.predicate}:null,[R?.isActive,R?.predicate]);if(L)return L;const{width:N,height:$,enableHover:B,showGrid:D,title:F,description:E,summary:z,accessibleTable:j}=P,O={chartType:"custom",...null!=o&&{data:I},customLayout:r,layoutConfig:n,onLayoutError:i,...T&&{layoutSelection:T},oAccessor:a,rAccessor:s,oExtent:l,rExtent:c,projection:u,colorAccessor:p,colorScheme:m,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:_.margin,enableHover:B,showAxes:f,showGrid:D,annotations:g,...ld({title:F,description:E,summary:z,accessibleTable:j,className:h,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cd({linkedHover:x,selection:v,onObservation:y,onClick:b,hoverHighlight:!1,mobileInteraction:_.mobileInteraction,customHoverBehavior:_.customHoverBehavior,customClickBehavior:_.customClickBehavior}),...C};return QF(Eu,{componentName:"OrdinalCustomChart",width:N,height:$,children:QF(rf,{ref:M,...O})})});ZF.displayName="OrdinalCustomChart";import{forwardRef as JF,useMemo as eE}from"react";import{jsx as tE}from"react/jsx-runtime";var oE=JF(function(e,t){const{nodes:o,edges:r,layout:n,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",margin:d,className:h,colorBy:p,colorScheme:m,selection:f,linkedHover:g,onObservation:y,onClick:b,chartId:v,annotations:x,autoPlaceAnnotations:w,frameProps:k={}}=e,{frameRef:S,resolved:A,normalizedMargin:C}=GF({imperativeRef:t,imperativeVariant:"network",margin:d,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),M=eE(()=>u(o??[]),[o]),P=eE(()=>u(r??[]),[r]),I=bu(e.mobileInteraction,{mode:e.mode,width:A.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:_,customClickBehavior:L,activeSelectionHook:R}=Su({selection:f,linkedHover:g,fallbackFields:"string"==typeof p?[p]:[],onObservation:y,onClick:b,chartType:"NetworkCustomChart",chartId:v,colorByField:"string"==typeof p?p:void 0,mobileInteraction:I}),T=eE(()=>R?.isActive?{isActive:!0,predicate:R.predicate}:null,[R?.isActive,R?.predicate]),{width:N,height:$,enableHover:B,title:D,description:F,summary:E,accessibleTable:z}=A,j={chartType:"force",...null!=o&&{nodes:M},...null!=r&&{edges:P},customNetworkLayout:n,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,colorBy:p,colorScheme:m,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:C,className:h,title:D,description:F,summary:E,accessibleTable:z,enableHover:B,...cd({linkedHover:g,selection:f,onObservation:y,onClick:b,mobileInteraction:I,customHoverBehavior:_,customClickBehavior:L,linkedHoverInClickPredicate:!1}),layoutSelection:T,...null!=x&&{annotations:x},...null!=w&&{autoPlaceAnnotations:w},...k};return tE(Eu,{componentName:"NetworkCustomChart",width:N,height:$,children:tE(cx,{ref:S,...j})})});oE.displayName="NetworkCustomChart";import{forwardRef as rE,useMemo as nE}from"react";import{useRef as iE,useState as aE,useEffect as sE,useMemo as lE,useCallback as cE,useImperativeHandle as uE,forwardRef as dE,memo as hE}from"react";import{geoPath as pE,geoGraticule as mE,geoDistance as fE,geoInterpolate as gE}from"d3-geo";import{quadtree as yE}from"d3-quadtree";import{geoMercator as bE,geoEqualEarth as vE,geoAlbersUsa as xE,geoOrthographic as wE,geoNaturalEarth1 as kE,geoEquirectangular as SE}from"d3-geo";var AE={mercator:bE,equalEarth:vE,albersUsa:xE,orthographic:wE,naturalEarth:kE,equirectangular:SE};function CE(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function ME(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function PE(e,t,o){return e?"function"==typeof e?{...o,...e(t)}:{...o,...e}:{...o}}function IE(e,t){if(2>e.length)return[e];const o=.4*t,r=[];let n=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>o?(2>n.length||r.push(n),n=[i]):n.push(i)}return 2>n.length||r.push(n),r}function _E(e,t,o=24){const r=t[0]-e[0],n=t[1]-e[1],i=Math.sqrt(r*r+n*n);if(0===i)return[e,t];const a=-n/i,s=r/i,l=Math.min(.3*i,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;o>=r;r++){const n=r/o,i=1-n;d.push([i*i*e[0]+2*i*n*c+n*n*t[0],i*i*e[1]+2*i*n*u+n*n*t[1]])}return d}function LE(e,t){if(2>e.length)return e;const o=t/2+1,r=[];for(let t=0;e.length>t;t++){const n=e[t];let i,a;0===t?(i=e[1][0]-n[0],a=e[1][1]-n[1]):t===e.length-1?(i=n[0]-e[t-1][0],a=n[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],a=e[t+1][1]-e[t-1][1]);const s=Math.sqrt(i*i+a*a)||1;r.push([n[0]+a/s*o,n[1]+-i/s*o])}return r}function RE(e,t,o,r,n){const i=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(i*i+a*a);if(0===s)return[e,t];const l=a/s,c=-i/s,u=n/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}import{scaleLinear as TE}from"d3-scale";var NE=class t{constructor(e){this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this._stylePaintPending=!1,this.config=e}updateConfig(e){this.config={...this.config,...e},"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e.slice()}initStreaming(e=500){this.pointBuffer=new te(e),this.timestampBuffer=new te(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=Ue();Xt(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t}pushMany(e){this.pointBuffer||this.initStreaming();const t=Ue();for(const o of e)Xt(this.pointBuffer,o,this.timestampBuffer,t);this.lastIngestTime=t}pushLine(e){null!=e&&"object"==typeof e&&(this.lineData.push(e),this.version++)}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){for(const e of t)this.lineData.push(e);this.version++}}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]),n=[];return this.lineData=this.lineData.filter(e=>!r.has(o(e)+"")||(n.push(e),!1)),n.length>0&&this.version++,n}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>r.has(o(e)+"");Ut(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!r.has(o(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++}setLayoutSelection(e){this.config.layoutSelection=e}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){const t=this._customRestyle;if(t){for(const o of this.scene){const r=this._baseStyles.get(o)??o.style,n=t(o,e);o.style=n?{...r,...n}:r}this._stylePaintPending=!0}}computeScene(e){const{config:t}=this,o=this.projection,r=this.geoPath,n=this.scales,i=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=function(e){if(!e)return vE();if("string"==typeof e){const t=AE[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),vE())}if("object"==typeof e&&"type"in e){const t=AE[e.type],o=t?t():vE();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=pE(this.projection),this.fitProjection(e),this.geoPath=pE(this.projection);const c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=o,this.geoPath=r,this.scales=n,this.baseScale=i,this.baseTranslate=a,this.baseRotation=s):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,o=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:o}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){const t=this.projection,o=this.config,r=[...this.areas],n=CE(o.xAccessor,"lon"),i=CE(o.yAccessor,"lat"),a=this.getPoints();if(a.length>0){const e=a.map(e=>[n(e),i(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const s=ME(o.lineDataAccessor);for(const e of this.lineData){const t=s(e);if(t&&t.length>0){const e=t.map(e=>[n(e),i(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(o.projectionExtent){const[[r,n],[i,a]]=o.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,n],[i,n],[i,a],[r,a],[r,n]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const r=o.fitPadding??0,n=Math.min(e.width,e.height);t.scale(n/2-n*r),t.translate([e.width/2,e.height/2])}else{const n={type:"FeatureCollection",features:r},i=o.fitPadding??0;1>i||"undefined"==typeof process||"production"===process.env.NODE_ENV||console.warn(`[semiotic] fitPadding=${i} looks like pixels, but it's a fraction of the plot (0–0.5). A value >= 1 collapses the projection off-canvas — use e.g. 0.06.`);const a=e.width*i,s=e.height*i;t.fitExtent([[a,s],[e.width-a,e.height-s]],n)}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;if(!o)return;const r=this.geoPath,n=this.scales,i=o.scale(),a=[...o.translate()],s=this.currentZoom;o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=pE(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(i),o.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;if(!o)return;const r=this.geoPath,n=this.scales,i=o.scale(),a=[...o.translate()],s=this.currentZoom;o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=pE(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(i),o.translate(a),this.currentZoom=s,this.geoPath=r,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;if(!o||!o.rotate)return;const r=this.geoPath,n=this.scales,i=[...o.rotate()];o.rotate(e),this.geoPath=pE(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(i),this.geoPath=r,this.scales=n):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,o=0;for(const t of this.scene)"point"===t.type&&(o++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const r=Array(o);let n=0;for(const e of this.scene)"point"===e.type&&(r[n++]=e);this._quadtree=yE().x(e=>e.x).y(e=>e.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,o=this.projection,r=this.geoPath,n=CE(t.xAccessor,"lon"),i=CE(t.yAccessor,"lat");if(t.customLayout&&this.scales){const o=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Kp(t.colorScheme,t.themeCategorical,ze),n={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Qp(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(n)}catch(e){const o=null!==this.lastCustomLayoutResult,r=Ft("geo",e,o,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return o?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const a=i.nodes??[];if(this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of a)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return $t({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap;const a=[],s=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),l=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),c=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const o=!0===t.graticule?{}:t.graticule,n=mE();o.step&&n.step(o.step);const i=r(n())||"";i&&a.push({type:"geoarea",pathData:i,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:o.stroke||"#e0e0e0",strokeWidth:o.strokeWidth||.5,strokeDasharray:o.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const o=r(e);if(!o)continue;const n=r.centroid(e),i=r.bounds(e),l=r.area(e),c=PE(t.areaStyle,e,s);a.push({type:"geoarea",pathData:o,centroid:n,bounds:i,screenArea:l,style:c,datum:e,interactive:!0})}const u=ME(t.lineDataAccessor);for(const r of this.lineData){const s=u(r);if(!s||2>s.length)continue;let c=[];if("geo"===t.lineType){const e=Array(s.length);for(let t=0;s.length>t;t++)e[t]=[n(s[t]),i(s[t])];for(let t=0;e.length-1>t;t++){const r=e[t],n=e[t+1],i=fE(r,n)||0,a=Math.max(2,Math.ceil(i/(Math.PI/180))),s=gE(r,n);for(let e=0;a>=e;e++){if(t>0&&0===e)continue;const r=o(s(e/a));null!=r&&c.push(r)}}}else for(let e=0;s.length>e;e++){const t=s[e],r=o([n(t),i(t)]);null!=r&&c.push(r)}if(2>c.length)continue;const d=PE(t.lineStyle,r,l),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==s.length||2>c.length||"arc"!==t.flowStyle?2!==s.length||2>c.length||"offset"!==t.flowStyle||(c="geo"===t.lineType?LE(c,h):RE(c[0],c[c.length-1],0,0,h)):c=_E(c[0],c[c.length-1]);const p=IE(c,e.width);if(p.length>1)for(const e of p){if(2>e.length)continue;const t={type:"line",path:e,style:{...d,_edgeFade:!0},datum:r};a.push(t)}else a.push({type:"line",path:2>c.length&&p[0]||c,style:d,datum:r})}const d=this.getPoints(),h=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,p=o.clipAngle?o.clipAngle()??0:0,m=p>0?p*Math.PI/180:null,f=o.rotate?o.rotate():[0,0,0],g="function"==typeof o.center?o.center():[0,0],y=[(g[0]??0)-f[0],(g[1]??0)-f[1]];for(let e=0;d.length>e;e++){const r=d[e],s=n(r),l=i(r);if(null!=m&&fE([s,l],y)>m)continue;const u=o([s,l]);if(!u)continue;const p=t.pointStyle?t.pointStyle(r):{...c},f={type:"point",x:u[0],y:u[1],r:p.r||4,style:p,datum:r,pointId:h?h(r)+"":void 0};a.push(f)}return a}applyCartogramTransform(t,o){const r=function(t,o,r,n){const i=t.filter(e=>"point"===e.type);if(2>i.length)return null;const a=o.strength??1;if(0===a)return null;const s=o.centerAccessor?"function"==typeof o.centerAccessor?o.centerAccessor:e=>e[o.centerAccessor]:e=>e.id,l="function"==typeof o.costAccessor?o.costAccessor:e=>e[o.costAccessor],c=i.find(e=>e.datum&&s(e.datum)+""==o.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${o.center}" not found in point data`),null;const u=c.x,d=c.y,h=i.map(e=>e.datum?l(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),p=e(h,1),m=Math.min(r.width,r.height)/2,f=TE().domain([0,p]).range([0,m]);n>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const o=t[e];"geoarea"===o.type&&o.interactive&&t.splice(e,1)}for(const e of i){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-d,e.x-u),o=Math.sqrt((e.x-u)**2+(e.y-d)**2),r=l(e.datum),n=o+((isFinite(r)?f(r):o)-o)*a;e.x=u+Math.cos(t)*n,e.y=d+Math.sin(t)*n}const g=r.width/2,y=r.height/2,b=g-c.x,v=y-c.y;if(Math.abs(b)>.5||Math.abs(v)>.5)for(const e of i)e.x+=b,e.y+=v;const x={cx:g,cy:y,maxCost:p,availableRadius:m},w=t.filter(e=>"line"===e.type);if(w.length>0&&"fractional"!==o.lineMode){const e=new Map;for(const t of i)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of w){const o=t.datum?.source,r=t.datum?.target;if(o&&r){const n=e.get(o+""),i=e.get(r+"");n&&i&&(t.path=[n,i])}}}return x}(this.scene,t,o,this.areas.length);r&&(this.cartogramLayout=r)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const o=this.scene.filter(e=>"point"===e.type);for(let r=0;o.length>r;r++){const n=Ze(e,r,t);o[r]._decayOpacity=n,o[r].style={...o[r].style,opacity:n}}}applyPulse(){const e=this.config.pulse;if(!e||!this.timestampBuffer)return;const t=Ue(),o=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray();for(let n=0;o.length>n&&r.length>n;n++){const i=et(e,r[n],t);i>0&&(o[n]._pulseIntensity=i,o[n]._pulseColor=e.color||"rgba(255,255,255,0.6)",o[n]._pulseGlowRadius=e.glowRadius??4)}}get hasActivePulses(){return ot(this.config.pulse??{},this.timestampBuffer)}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const o=new Map;for(const t of e)"point"===t.type&&t.pointId&&o.set(t.pointId,[t.x,t.y]);const r=this.scene.filter(e=>"point"===e.type);let n=!1;for(const e of r)if(e.pointId){const t=o.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(n=!0))}for(const e of r)e.pointId&&!o.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},n=!0);n&&(this.activeTransition={startTime:Ue(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Ve(e,this.activeTransition),o=Ye(t),r=this.scene.filter(e=>"point"===e.type);for(const e of r){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Xe(e.x,e._targetX,o),e.y=Xe(t,e._targetY,o)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*o})}if(t>=1){for(const e of r)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};NE.QUADTREE_THRESHOLD=500;var $E=NE;function BE(e,t,o,r,n,i,a=0,s=r){if(i){const e=Eo(i,t,o,r,a);if(e)return e}else{let n=null,i=r;for(const a of e){if("point"!==a.type)continue;const e=a.x-t,s=a.y-o,l=Math.sqrt(e*e+s*s);Co(a.r,r)>=l&&i>l&&(n=a,i=l)}if(n)return{node:n,distance:i}}let l=null,c=r;for(const n of e){if("glyph"!==n.type)continue;if(null==n.datum)continue;const e=Do(n.glyph,n.size),i=n.x+e.centerDx-t,a=n.y+e.centerDy-o,s=Math.sqrt(i*i+a*a);Co(e.radius,r)>=s&&c>s&&(l=n,c=s)}if(l)return{node:l,distance:c};for(let r=e.length-1;r>=0;r--){const i=e[r];if("geoarea"!==i.type)continue;const a=i;if(!1===a.interactive)continue;const[[s,l],[c,u]]=a.bounds;if(!(s>t||t>c||l>o||o>u)&&(a._cachedPath2D||(a._cachedPath2D=new Path2D(a.pathData)),n.isPointInPath(a._cachedPath2D,t,o)))return{node:a,distance:0}}let u=null,d=s;for(const r of e){if("line"!==r.type)continue;const e=r,{path:n}=e,i=Math.max((e.style.strokeWidth||2)+4,5,s);for(let r=0;n.length-1>r;r++){const[a,s]=n[r],[l,c]=n[r+1],h=DE(t,o,a,s,l,c);i>=h&&d>h&&(u=e,d=h)}}return u?{node:u,distance:d}:null}function DE(e,t,o,r,n,i){const a=n-o,s=i-r,l=a*a+s*s;if(0===l)return Math.sqrt((e-o)**2+(t-r)**2);let c=((e-o)*a+(t-r)*s)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(o+c*a))**2+(t-(r+c*s))**2)}import{zoom as FE,zoomIdentity as EE}from"d3-zoom";import{select as zE}from"d3-selection";function jE([e,t,o]){const r=1<<o;return[e-Math.floor(e/r)*r,t,o]}function OE(e,t,o,r,n){return"function"==typeof e?e(t,o,r,n):e.replace("{z}",t+"").replace("{x}",o+"").replace("{y}",r+"").replace("{r}",n>1?"@2x":"")}var HE=class{constructor(e=256){this.cache=new Map,this.limit=e}get(e){const t=this.cache.get(e);return t&&(t.lastUsed=performance.now()),t}set(e,t){this.cache.set(e,t),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let e,t=1/0;for(const[o,r]of this.cache)t>r.lastUsed&&(t=r.lastUsed,e=o);if(!e)break;{const t=this.cache.get(e);t&&(t.img.onload=null,t.img.onerror=null,t.img.src=""),this.cache.delete(e)}}}clear(){for(const e of this.cache.values())e.img.onload=null,e.img.onerror=null,e.img.src="";this.cache.clear()}};var WE=class{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const o=this.particles[t];if(!o.active)return o.active=!0,o.t=0,o.offset=.6*(Math.random()-.5),o.lineIndex=e,o.x=0,o.y=0,o}return null}step(e,t,o,r){for(let n=0;this.capacity>n;n++){const i=this.particles[n];if(!i.active)continue;const a=o[i.lineIndex];if(!a||2>a.length){i.active=!1;continue}if(i.t+=e*t,i.t>=1){i.active=!1;continue}const s=qE(a),l=GE(a,i.t*s),c=(r[i.lineIndex]||2)/2;i.x=l.x+l.nx*i.offset*c*2,i.y=l.y+l.ny*i.offset*c*2}}countForLine(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].lineIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}};function qE(e){let t=0;for(let o=1;e.length>o;o++){const r=e[o][0]-e[o-1][0],n=e[o][1]-e[o-1][1];t+=Math.sqrt(r*r+n*n)}return t}function GE(e,t){let o=0;for(let r=1;e.length>r;r++){const n=e[r][0]-e[r-1][0],i=e[r][1]-e[r-1][1],a=Math.sqrt(n*n+i*i);if(o+a>=t||r===e.length-1){const s=a>0?(t-o)/a:0,l=a>.001?a:1;return{x:e[r-1][0]+n*s,y:e[r-1][1]+i*s,nx:-i/l,ny:n/l}}o+=a}const r=e[e.length-1];return{x:r[0],y:r[1],nx:0,ny:0}}function YE(e){if(!e)return;const t=[];for(const o of e)if("point"===o.type)t.push(o);else if("glyph"===o.type){const e=o,r=Do(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}import{jsx as VE,jsxs as XE}from"react/jsx-runtime";function UE({data:e}){if(!e)return null;if(e.properties)return VE("div",{className:"semiotic-tooltip",style:ms,children:VE("div",{style:{fontWeight:600},children:e.properties.name||e.properties.NAME||e.properties.id||"Feature"})});const t=null!=e.data?e.data:e;if(!t||"object"!=typeof t)return null;const o=ds(t),r=null!=o.title?o.title+"":null;return null==r&&0===o.entries.length?null:XE("div",{className:"semiotic-tooltip",style:ms,children:[null!=r&&VE("div",{style:{fontWeight:600,marginBottom:o.entries.length?2:0},children:r}),o.entries.map(e=>XE("div",{children:[XE("span",{style:{opacity:.7},children:[e.key,": "]}),VE("span",{style:{fontWeight:600},children:Ll(e.value)})]},e.key))]})}UE.ownsChrome=!0;var KE={top:10,right:10,bottom:10,left:10},QE=null;function ZE(){if(null!==QE)return QE;if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency&&4>=navigator.hardwareConcurrency,o="undefined"!=typeof navigator&&"number"==typeof navigator.deviceMemory&&4>=navigator.deviceMemory;return QE=e||t||o}function JE(){return ZE()?12:30}var ez={width:28,height:28,border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,background:"rgba(255,255,255,0.9)",color:"#333",fontSize:16,fontWeight:600,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"};function tz(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function oz(e){return e?e.getContext("2d"):null}import{jsx as rz,jsxs as nz}from"react/jsx-runtime";var iz=hE(dE(function(e,t){const{projection:o,projectionExtent:r,fitPadding:n,projectionTransform:i,areas:a,points:s,lines:l,customLayout:c,layoutConfig:d,layoutSelection:h,onLayoutError:p,xAccessor:m,yAccessor:f,lineDataAccessor:g,pointIdAccessor:y,lineIdAccessor:b,lineType:v="geo",flowStyle:x="basic",graticule:w,zoomable:k,zoomExtent:S,onZoom:A,dragRotate:C,showParticles:M,particleStyle:P,tileURL:I,tileAttribution:_,tileCacheSize:L,size:R,width:T,height:N,responsiveWidth:$,responsiveHeight:B,margin:D,className:F,background:E,areaStyle:z,pointStyle:j,lineStyle:O,colorScheme:H,enableHover:W=!0,hoverAnnotation:q,tooltipContent:G,allowTooltipOverflow:V=!1,customClickBehavior:X,customHoverBehavior:U,annotations:K,autoPlaceAnnotations:Q,decay:Z,pulse:J,transition:ee,animate:te,staleness:oe,backgroundGraphics:re,foregroundGraphics:ne,title:ie,legend:ae,legendPosition:se,legendLayout:le,legendHoverBehavior:ce,legendClickBehavior:ue,legendHighlightedCategory:de,legendIsolatedCategories:he,legendCategoryAccessor:pe,onCategoriesChange:me,showAxes:fe,accessibleTable:ge=!0,description:ye,summary:be}=e,ve=R||[T||600,N||400],xe=iE(!0),we=js({sizeProp:ve,responsiveWidth:$,responsiveHeight:B,userMargin:D,marginDefault:KE,foregroundGraphics:ne,backgroundGraphics:re,animate:te,transitionProp:ee,themeDirtyRef:xe}),{reducedMotionRef:ke,responsiveRef:Se,size:Ae,margin:Ce,adjustedWidth:Me,adjustedHeight:Pe,resolvedForeground:Ie,resolvedBackground:_e,transition:Le,introEnabled:Re,tableId:Te,rafRef:Ne,renderFnRef:$e,scheduleRender:Be,cancelRender:De,currentTheme:Fe}=we,Ee=na(),ze=la(),je=lE(()=>Array.isArray(a)?u(a):a,[a]),Oe=lE(()=>u(s),[s]),He=lE(()=>u(l),[l]),We=lE(()=>null!=C?C:"orthographic"===tz(o),[C,o]),qe=da(lE(()=>({projection:o,projectionExtent:r,fitPadding:n,xAccessor:m,yAccessor:f,lineDataAccessor:g,lineType:v,flowStyle:x,areaStyle:z,pointStyle:j,lineStyle:O,colorScheme:H,themeSemantic:Y(Fe),themeSequential:Fe?.colors?.sequential,themeDiverging:Fe?.colors?.diverging,themeCategorical:Fe?.colors?.categorical,graticule:w,projectionTransform:i,decay:Z,pulse:J,transition:Le,introAnimation:Re,annotations:K,pointIdAccessor:y,lineIdAccessor:b,customLayout:c,layoutConfig:d,onLayoutError:p,layoutMargin:Ce}),[o,r,n,m,f,g,v,x,z,j,O,H,w,i,Z,J,Le?.duration,Le?.easing,Re,K,y,b,Fe,c,d,p,Ce])),Ge=iE(null);Ge.current||(Ge.current=new $E(qe));const Ye=iE(null),Ve=iE(null),Xe=iE(null),Ue=iE(null),Ke=iE(null);I&&!Ke.current&&(Ke.current=new HE(L||256));const Qe=iE(K),Ze=iE(null),Je=iE(EE),et=iE(!1),tt=iE(null),ot=cE(e=>{tt.current=e,Se&&"object"==typeof Se&&(Se.current=e)},[Se]),rt=iE(null),nt=iE(null),it=iE(null),at=iE(0);if(M&&!it.current){const e=P?.maxPerLine??JE();it.current=new WE(50*e)}const st=iE(null),lt=iE(null),ct=iE(!1),ut=iE(void 0),[dt,ht]=aE(null),[pt,mt]=aE(0),ft=iE(0),[gt,yt]=aE(!1),bt=iE([]),vt=iE(pe),xt=iE(me);vt.current=pe,xt.current=me;const wt=cE(()=>{const e=vt.current,t=xt.current;if(!t||!e)return;const o=Gs(Ge.current?.getPoints()??[],e);Ys(o,bt.current)||(bt.current=o,t(o))},[]);ko(Ge,qe,xe,Be),So(Ge,h,xe,Be),sE(()=>{const e=Ge.current;e&&(je&&e.setAreas(je),s&&e.setPoints(Oe),l&&e.setLines(He),xe.current=!0,Be())},[je,s,Oe,l,He,Be]);const kt=cE(e=>{null!=e&&"object"==typeof e&&(Ge.current?.pushPoint(e),xe.current=!0,Be())},[Be]),St=cE(e=>{const t=u(e);0!==t.length&&(Ge.current?.pushMany(t),xe.current=!0,Be())},[Be]),At=cE(e=>{null!=e&&"object"==typeof e&&(Ge.current?.pushLine(e),xe.current=!0,Be())},[Be]),Ct=cE(e=>{const t=u(e);0!==t.length&&(Ge.current?.pushManyLines(t),xe.current=!0,Be())},[Be]),Mt=cE(()=>{Ge.current?.clear(),xe.current=!0,Be()},[Be]);uE(t,()=>({push:kt,pushMany:St,removePoint:e=>{const t=Ge.current?.removePoint(e)??[];return t.length>0&&(xe.current=!0,Be()),t},pushLine:At,pushManyLines:Ct,removeLine:e=>{const t=Ge.current?.removeLine(e)??[];return t.length>0&&(xe.current=!0,Be()),t},getLines:()=>Ge.current?.getLines()??[],clear:Mt,getProjection:()=>Ge.current?.scales?.projection??null,getGeoPath:()=>Ge.current?.scales?.geoPath??null,getCartogramLayout:()=>Ge.current?.cartogramLayout??null,getCustomLayout:()=>Ge.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Ge.current?.lastCustomLayoutFailure??null,getZoom:()=>Je.current.k,resetZoom:()=>{const e=tt.current;e&&Ze.current&&zE(e).call(Ze.current.transform,EE)},getData:()=>Ge.current?.getPoints()??[]}),[kt,St,At,Ct,Mt,Be]);const{hoverHandlerRef:Pt,onPointerMove:It,onPointerLeave:_t}=we;sE(()=>{Pt.current=e=>{if(!W)return;const t=Ge.current;if(!t||!t.scene.length)return;const o=Ve.current;if(!o)return;const r=o.getBoundingClientRect(),n=e.clientX-r.left-Ce.left,i=e.clientY-r.top-Ce.top;if(0>n||n>Me||0>i||i>Pe)return st.current=null,lt.current=null,ht(null),U?.(null),void Be();Ue.current||(Ue.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const a=oz(Ue.current);if(!a)return;const s=rs(30,e.pointerType),l=rs(6,e.pointerType),c=BE(t.scene,n,i,s,a,t.quadtree,t.maxPointRadius,l);if(c){const e=c.node,t=e.datum,o=Array.isArray(t)?null:t?.properties?t:t?.data||t;let r,a;"point"===e.type?(r=e.x,a=e.y):"geoarea"===e.type?(r=e.centroid[0],a=e.centroid[1]):(r=n,a=i);const s={...o,...o?.properties||{},data:o,properties:o?.properties,__semioticHoverData:!0,x:r,y:a};st.current=s,lt.current=e,ht(s),U?.(s),Be()}else st.current&&(st.current=null,lt.current=null,ht(null),U?.(null),Be())}},[W,Me,Pe,Ce,U,Be]),we.hoverLeaveRef.current=()=>{st.current=null,lt.current=null,ht(null),U?.(null),Be()};const Lt=cE(e=>{if(!X)return;const t=Ge.current;if(!t||!t.scene.length)return void X(null);const o=e.currentTarget.getBoundingClientRect(),r=e.clientX-o.left-Ce.left,n=e.clientY-o.top-Ce.top;if(0>r||r>Me||0>n||n>Pe)return void X(null);Ue.current||(Ue.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=oz(Ue.current);if(!i)return void X(null);const a=rs(30,ut.current),s=rs(6,ut.current),l=BE(t.scene,r,n,a,i,t.quadtree,t.maxPointRadius,s);if(l){const e=l.node.datum,t=Array.isArray(e)?null:e?.properties?e:e?.data||e,o=t?.properties?{...t,...t.properties}:t;return void X({...o,data:t,properties:t?.properties,__semioticHoverData:!0,x:r,y:n,time:r,value:n})}X(null)},[Pe,Me,X,Ce]),Rt=iE(-1),Tt=iE(null),Nt=cE(e=>{const t=Ge.current;if(!t||0===t.scene.length)return;const o=function(e){const t=[];for(const o of e)if("point"===o.type&&null!=o.x)t.push({x:o.x,y:o.y,datum:o.datum,shape:"circle"});else if("glyph"===o.type){if(0>=o.size||null==o.datum)continue;const e=Do(o.glyph,o.size);t.push({x:o.x+e.centerDx,y:o.y+e.centerDy,datum:o.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight})}else"geoarea"===o.type&&o.centroid&&!1!==o.interactive&&t.push({x:o.centroid[0],y:o.centroid[1],datum:o.datum,shape:"geoarea",pathData:o.pathData});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===o.length)return;const r=Rt.current,n=function(e,t,o){switch(e){case"ArrowRight":case"ArrowDown":return o-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"PageDown":return Math.min(t+Math.max(1,Math.floor(.1*o)),o-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*o)),0);case"Home":return 0;case"End":return o-1;case"Escape":return-1;default:return null}}(e.key,0>r?-1:r,o.length);if(null===n)return;if(e.preventDefault(),0>n)return Rt.current=-1,Tt.current=null,st.current=null,lt.current=null,ht(null),U?.(null),void Be();const i=0>r?0:n;Rt.current=i;const a=o[i];Tt.current={shape:a.shape,w:a.w,h:a.h,pathData:a.pathData};const s=a.datum,l={...s||{},...s?.properties||{},data:s,properties:s?.properties,x:a.x,y:a.y,__semioticHoverData:!0};st.current=l,ht(l),U?.(l),Be()},[U,Be]),$t=cE(e=>{ut.current=e.pointerType,Rt.current=-1,Tt.current=null,It(e)},[It]),Bt=cE(e=>{ut.current=e.pointerType},[]);$e.current=()=>{Ne.current=null;const e=Ve.current,t=Ge.current;if(!e||!t)return;const o=performance.now();let r=!1;const n=nt.current;let i=!1;n&&(nt.current=null,t.applyRotation(n,{width:Me,height:Pe}),i=!0);const a=t.advanceTransition(ke.current?o+1e6:o),s=!ke.current&&a;let l=!1;if(xe.current&&!a){const o={width:Me,height:Pe},r=We?t.getRotation():null;t.computeScene(o);const n=Je.current,i=1!==n.k||0!==n.x||0!==n.y;We&&r?i?(t.setRotation(r),t.applyZoomScale(n.k,o)):t.applyRotation(r,o):i&&t.applyZoomTransform(n,o),xe.current=!1,l=!0,e.setAttribute("aria-label",Na(t.scene,"Geographic chart")),wt()}const c=Ws(),u=M&&!ke.current&&!!it.current,d=t.consumeStylePaintPending(),h=ga({dirtyOrRebuilt:l,transitioning:s,continuous:u,liveEncoding:t.hasActivePulses,forced:i||d});if(I&&Ke.current){const e=Ye.current;if(e&&t.scales?.projection){const o=Hs(e,Ae,Ce,c);if(o){o.clearRect(-Ce.left,-Ce.top,Ae[0],Ae[1]),o.save(),o.beginPath(),o.rect(0,0,Me,Pe),o.clip();const e=function(e,t){const{tileURL:o,projection:r,width:n,height:i,tileCache:a,onTileLoad:s}=t,l=r.scale(),c=r.translate(),u=function(e){const{size:t,scale:o,translate:r,clampX:n=!0,clampY:i=!0}=e,a=Math.max(Math.log(o)/Math.LN2-8,0),s=Math.round(a),l=1<<s,c=Math.pow(2,a-s+8),u=r[0]-o/2,d=r[1]-o/2,h=Math.max(n?0:-1/0,Math.floor((0-u)/c)),p=Math.min(n?l:1/0,Math.ceil((t[0]-u)/c)),m=Math.max(i?0:-1/0,Math.floor((0-d)/c)),f=Math.min(i?l:1/0,Math.ceil((t[1]-d)/c)),g=[];for(let e=m;f>e;++e)for(let t=h;p>t;++t)g.push([t,e,s]);return{tiles:g,translate:[u/c,d/c],scale:c}}({size:[n,i],scale:2*l*Math.PI,translate:c}),d=Ws();let h=!0;for(const t of u.tiles){const[r,n,i]=jE(t),l=`${i}/${r}/${n}`;let c=a.get(l);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:l,lastUsed:performance.now()};a.set(l,t),e.onload=()=>{t.loaded=!0,s?.()},e.onerror=()=>{t.loaded=!0},e.src=OE(o,i,r,n,d),c=t}if(!c.loaded){h=!1;continue}const p=u.scale;e.drawImage(c.img,(t[0]+u.translate[0])*p-.5,(t[1]+u.translate[1])*p-.5,p+1,p+1)}return h}(o,{tileURL:I,projection:t.scales.projection,width:Me,height:Pe,tileCache:Ke.current,onTileLoad:()=>Be()});o.restore(),e||(r=!0)}}}if(h){const n=Hs(e,Ae,Ce,c);if(!n)return;n.clearRect(-Ce.left,-Ce.top,Ae[0],Ae[1]),I||fa(n,{background:E,width:Me,height:Pe}),n.save(),n.beginPath(),n.rect(0,0,Me,Pe),n.clip();const i=t.scene,a={width:Me,height:Pe};if(function(e,t){const o=t.filter(e=>"geoarea"===e.type);for(const t of o){if(!t.pathData)continue;t._cachedPath2D||(t._cachedPath2D=new Path2D(t.pathData));const o=t._cachedPath2D,r=t.style.fill||"#e0e0e0";if("none"!==r&&(e.fillStyle=r,e.globalAlpha=(t._decayOpacity??1)*(t.style.fillOpacity??1),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=Go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=t._decayOpacity??1,t.style.strokeDasharray){const o=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(o)}else e.setLineDash([]);e.stroke(o)}al(e,t,o),e.globalAlpha=1,e.setLineDash([])}}(n,i),ol(n,i,0,a),dl(n,i),gl(n,i),u&&it.current){const e=it.current,t=i.filter(e=>"line"===e.type);if(t.length>0){const i=P||{},a=.3*(i.speedMultiplier??1),s=i.maxPerLine??JE(),l=i.spawnRate??(ZE()?.06:.15),c=i.radius??2,u=i.opacity??.7,d=o/1e3,h=at.current>0?Math.min(d-at.current,.1):.016;at.current=d;const p=t.map(e=>e.path),m=t.map(e=>e.style.strokeWidth||2);for(let o=0;t.length>o;o++)Math.random()<l&&e.countForLine(o)<s&&e.spawn(o);e.step(h,a,p,m),n.globalAlpha=u;for(let o=0;e.particles.length>o;o++){const r=e.particles[o];if(!r.active)continue;const a=t[r.lineIndex],s="function"==typeof i.color?i.color(a?.datum??{}):"source"!==i.color&&i.color?i.color:a?.style.stroke||"#fff";n.beginPath(),n.arc(r.x,r.y,c,0,2*Math.PI),n.fillStyle=s,n.fill()}n.globalAlpha=1,r=!0}}n.restore()}const p=lt.current,m=!(!p||"geoarea"!==p.type&&"point"!==p.type),f=ya(m,ct.current),g=Xe.current;if(g&&f){const e=Hs(g,Ae,Ce,c);if(e){if(e.clearRect(-Ce.left,-Ce.top,Ae[0],Ae[1]),p&&"geoarea"===p.type){const t=new Path2D(p.pathData);e.fillStyle="rgba(255, 255, 255, 0.3)",e.fill(t),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke(t)}if(p&&"point"===p.type){const t=p,o="object"==typeof q?q:void 0,r=o?.pointColor||Ml(p);e.beginPath(),e.arc(t.x,t.y,t.r+3,0,2*Math.PI),r?(e.save(),e.globalAlpha=.4,e.fillStyle=r,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=r||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}ct.current=m}const y=K!==Qe.current;y&&(Qe.current=K),(l||y||s&&K&&K.length>0)&&(l||y||o-ft.current>=33)&&(mt(e=>e+1),ft.current=o),(s||null!=t.activeTransition||t.hasActivePulses||r)&&Be()},ca({hydrated:Ee,wasHydratingFromSSR:ze,storeRef:Ge,dirtyRef:xe,renderFnRef:$e,cancelRender:De,cleanup:()=>Ke.current?.clear()}),sE(()=>{xe.current=!0,Be()},[Me,Pe,E,Be]),Tr(oe,Ge,xe,Be,gt,yt),sE(()=>{if("production"!==process.env.NODE_ENV&&I){const e=tz(o);e&&"mercator"!==e&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${e}". Raster tiles use Web Mercator and will not align with other projections.`)}},[I,o]),sE(()=>{const e=tt.current;if(!k||!e)return Ze.current&&e&&(zE(e).on(".zoom",null),Ze.current=null),void(e&&zE(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,o]=S||[1,8],r={width:Me,height:Pe};if(We){let n=Je.current.k;const i=e=>{n=Math.max(t,Math.min(o,e)),Je.current=EE.scale(n);const i=Ge.current;i&&(i.applyZoomScale(n,r),xe.current=!1,Be(),i.scales?.projection&&A?.({projection:i.scales.projection,zoom:i.currentZoom}))};Ze.current={scaleBy:(e,t)=>i(n*t),transform:(e,t)=>i(t?.k??1)};const a=e=>{e.preventDefault(),i(n*(0>e.deltaY?1.1:1/1.1))},s=e=>{const t=e.target;t&&(t.closest("button")||t.closest(".stream-geo-zoom-controls"))||(e.preventDefault(),i(1.5*n))};e.addEventListener("wheel",a,{passive:!1}),e.addEventListener("dblclick",s);const l=.4,c=t=>{if(0!==t.button)return;const o=t.target;if(o.closest("button")||o.closest(".stream-geo-zoom-controls"))return;const r=Ge.current;if(!r)return;const n=r.getRotation();rt.current={x:t.clientX,y:t.clientY,rotation:[...n]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=rt.current;t&&(nt.current=[t.rotation[0]+(e.clientX-t.x)*l,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*l)),t.rotation[2]],Be())},d=t=>{if(!rt.current)return;rt.current=null,e.releasePointerCapture(t.pointerId);const o=nt.current;if(o){nt.current=null;const e=Ge.current;e&&(e.applyRotation(o,r),Be())}const n=Ge.current;n?.scales?.projection&&A?.({projection:n.scales.projection,zoom:n.currentZoom})};return e.addEventListener("pointerdown",c),e.addEventListener("pointermove",u),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("wheel",a),e.removeEventListener("dblclick",s),e.removeEventListener("pointerdown",c),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),Ze.current=null}}const n=FE().scaleExtent([t,o]).extent([[0,0],[Ae[0],Ae[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;Je.current=t,et.current=!0;const o=Ge.current;o&&(o.applyZoomTransform(t,r),xe.current=!1,Be())}).on("end",e=>{Je.current=e.transform,et.current=!1;const t=Ge.current;t?.scales?.projection&&A?.({projection:t.scales.projection,zoom:t.currentZoom})});return Ze.current=n,zE(e).call(n),()=>{zE(e).on(".zoom",null)}},[k,S,We,Ae,Me,Pe,Ce,A,Be]);const Dt=W&&!1!==q,Ft=Dt&&dt?G?G(dt):rz(UE,{data:dt}):null,Et=Ft?rz(ks,{x:dt.x,y:dt.y,containerWidth:Me,containerHeight:Pe,margin:Ce,className:"stream-frame-tooltip",zIndex:10,children:Ft}):null;if(Qi||!Ee&&ze){const e=Ge.current;e&&(je||s||l)&&(je&&e.setAreas(je),s&&e.setPoints(Oe),l&&e.setLines(He),e.computeScene({width:Me,height:Pe}));const t=e?.scene??[];return nz("div",{ref:ot,className:"stream-geo-frame"+(F?" "+F:""),role:"img","aria-label":ye||("string"==typeof ie?ie:"Geographic chart"),style:{position:"relative",width:$?"100%":Ae[0],height:B?"100%":Ae[1]},children:[rz(Ka,{summary:be}),nz("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ae[0],height:Ae[1],style:{position:"absolute",left:0,top:0},children:[rz("g",{transform:`translate(${Ce.left},${Ce.top})`,children:_e}),nz("g",{transform:`translate(${Ce.left},${Ce.top})`,children:[E&&rz("rect",{x:0,y:0,width:Me,height:Pe,fill:E}),t.map((e,t)=>function(e,t){switch(e.type){case"geoarea":{const o=e;return o.pathData?Wi("path",{d:o.pathData,fill:Yi(o.style.fill,"#e0e0e0"),fillOpacity:o.style.fillOpacity??1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:o._decayOpacity??1},"geoarea-"+t):null}case"point":{const o=e;return Wi("circle",{cx:o.x,cy:o.y,r:o.r,fill:Yi(o.style.fill),fillOpacity:o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o._decayOpacity??o.style.opacity??1},"point-"+t)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(e=>`${e[0]},${e[1]}`).join("L");return Wi("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity??1},"line-"+t)}case"glyph":return Xi(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t))]})]}),rz(Bi,{width:Me,height:Pe,totalWidth:Ae[0],totalHeight:Ae[1],margin:Ce,scales:null,showAxes:!1,title:ie,legend:ae,legendPosition:se,legendLayout:le,legendHoverBehavior:ce,legendClickBehavior:ue,legendHighlightedCategory:de,legendIsolatedCategories:he,foregroundGraphics:mo(Ie,vo(Ge.current?.customLayoutOverlays,h??null)),annotations:K,autoPlaceAnnotations:Q,annotationFrame:0,xValues:[],yValues:[],pointNodes:YE(t)})]})}return nz("div",{ref:ot,className:"stream-geo-frame"+(F?" "+F:""),role:"group","aria-label":ye||("string"==typeof ie?ie:"Geographic chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Ae[0],height:B?"100%":Ae[1],overflow:V?"visible":"hidden",...k?{touchAction:"none"}:{}},onKeyDown:Nt,children:[ge&&rz(Qa,{tableId:Te}),ge&&rz(Xa,{scene:Ge.current?.scene??[],chartType:"Geographic chart",tableId:Te,chartTitle:"string"==typeof ie?ie:void 0}),rz(Ka,{summary:be}),rz(Za,{hoverPoint:dt}),nz("div",{role:"img","aria-label":ye||("string"==typeof ie?ie:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Dt?$t:void 0,onPointerLeave:Dt?_t:void 0,onPointerDown:Dt||X?Bt:void 0,onClick:X?Lt:void 0,children:[_e&&rz("svg",{style:{position:"absolute",left:0,top:0,width:Ae[0],height:Ae[1],pointerEvents:"none"},children:rz("g",{transform:`translate(${Ce.left},${Ce.top})`,children:_e})}),I&&rz("canvas",{ref:Ye,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),rz("canvas",{ref:Ve,"aria-label":Na(Ge.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),rz("canvas",{ref:Xe,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),rz(Bi,{width:Me,height:Pe,totalWidth:Ae[0],totalHeight:Ae[1],margin:Ce,scales:null,showAxes:fe??!1,title:ie,legend:ae,legendPosition:se,legendLayout:le,legendHoverBehavior:ce,legendClickBehavior:ue,legendHighlightedCategory:de,legendIsolatedCategories:he,foregroundGraphics:mo(Ie,vo(Ge.current?.customLayoutOverlays,h??null)),annotations:K,autoPlaceAnnotations:Q,annotationFrame:pt,xValues:[],yValues:[],pointNodes:YE(Ge.current?.scene)}),oe?.showBadge&&rz($r,{isStale:gt,position:oe.badgePosition}),k&&nz("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Ce.bottom+8,left:Ce.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[rz("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=tt.current,o=Ze.current;t&&o?.scaleBy&&o.scaleBy(zE(t),1.5)},style:ez,children:"+"}),rz("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=tt.current,o=Ze.current;t&&o?.scaleBy&&o.scaleBy(zE(t),1/1.5)},style:ez,children:"−"})]}),_&&rz("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Ce.bottom+2,right:Ce.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2},children:_}),rz(ts,{active:Rt.current>=0,hoverPoint:dt,margin:Ce,size:Ae,shape:Tt.current?.shape,width:Tt.current?.w,height:Tt.current?.h,pathData:Tt.current?.pathData}),Et]})]})}));iz.displayName="StreamGeoFrame";var az=iz;import{jsx as sz}from"react/jsx-runtime";var lz=rE(function(e,t){const{points:o,areas:r,lines:n,layout:i,layoutConfig:a,onLayoutError:s,projection:l="equirectangular",xAccessor:c="lon",yAccessor:d="lat",lineDataAccessor:h,colorBy:p,colorScheme:m,tooltip:f,annotations:g,margin:y,selection:b,linkedHover:v,onObservation:x,onClick:w,chartId:k,loading:S,loadingContent:A,emptyContent:C,className:M,frameProps:P={}}=e,{frameRef:I,resolved:_,normalizedMargin:L}=GF({imperativeRef:t,imperativeVariant:"geo-points",margin:y,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),R=nE(()=>u(o),[o]),T=nE(()=>u(r),[r]),N=nE(()=>u(n),[n]),$=nE(()=>[...R,...N,...T],[R,N,T]),B=od({data:$,rawData:void 0!==o||void 0!==n||void 0!==r?$:void 0,colorBy:p,colorScheme:m,legendInteraction:void 0,selection:b,linkedHover:v,fallbackFields:"string"==typeof p?[p]:[],unwrapData:!1,onObservation:x,onClick:w,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"GeoCustomChart",chartId:k,showLegend:!1,userMargin:L,marginDefaults:_.marginDefaults,loading:S,loadingContent:A,emptyContent:C,width:_.width,height:_.height}),D=B.effectiveSelectionHook,F=nE(()=>D?.isActive?{isActive:!0,predicate:D.predicate}:null,[D?.isActive,D?.predicate]);if(B.earlyReturn)return B.earlyReturn;const{width:E,height:z,enableHover:j,title:O,description:H,summary:W,accessibleTable:q}=_,G=xs(f),Y={projection:l,...null!=o&&{points:R},...null!=r&&{areas:T},...null!=n&&{lines:N},xAccessor:c,yAccessor:d,...null!=h&&{lineDataAccessor:h},customLayout:i,layoutConfig:a,onLayoutError:s,layoutSelection:F,colorBy:p,colorScheme:m,size:[E,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B.margin,enableHover:j,...ld({title:O,description:H,summary:W,accessibleTable:q,className:M,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations}),...!1===f?{tooltipContent:()=>null}:G?{tooltipContent:G}:{},...cd({linkedHover:v,selection:b,onObservation:x,onClick:w,hoverHighlight:!1,mobileInteraction:B.mobileInteraction,customHoverBehavior:B.customHoverBehavior,customClickBehavior:B.customClickBehavior,linkedHoverInClickPredicate:!1}),...g&&g.length>0&&{annotations:g},...P};return sz(Eu,{componentName:"GeoCustomChart",width:E,height:z,children:sz(az,{ref:I,...Y})})});function cz(e){const t=I_(e.recipe)??(e.recipeId?S_(e.recipeId):void 0);if(!t)throw Error(`Unknown chart recipe "${e.recipeId??"(missing recipeId)"}". Register it before rendering.`);const o=function(e){return"function"==typeof e.layout?e.layout:c_(e.layout)?P_(e.layout.id):void 0}(t);if(!o){const e=c_(t.layout)?t.layout.id:t.id;throw Error(`No runtime layout registered for chart recipe "${t.id}" (${e}).`)}const r="semiotic-chart-recipe semiotic-chart-recipe-"+t.id.replace(/[^a-zA-Z0-9_-]+/g,"-"),n={...e,chartId:e.chartId??t.id,className:e.className?`${r} ${e.className}`:r,recipeId:t.id,recipe:t,layout:o},i="XYFrame"===t.frameFamily||"XYCustomChart"===t.frameFamily?XF:"OrdinalFrame"===t.frameFamily||"OrdinalCustomChart"===t.frameFamily?ZF:"NetworkFrame"===t.frameFamily||"NetworkCustomChart"===t.frameFamily?oE:"GeoFrame"===t.frameFamily||"GeoCustomChart"===t.frameFamily?lz:void 0;if(!i)throw Error(`Chart recipe "${t.id}" uses unsupported frame family "${t.frameFamily}".`);return jF.createElement(i,n)}function uz(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function dz(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function hz(e){return"number"==typeof e&&Number.isFinite(e)}function pz(e){if(hz(e.x)&&hz(e.y)&&hz(e.w)&&hz(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(hz(e.x)&&hz(e.y)&&hz(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(hz(e.cx)&&hz(e.cy)&&hz(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(hz(e.cx)&&hz(e.cy)&&hz(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&hz(e[0])&&hz(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function mz(e,t){const o=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),r=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return r>0?o/r:0}function fz(e,t,o,r,n){if(e===t)return!0;const i=o.dataRoles.map(e=>N_(e,r,n)).filter(e=>!!e).filter(o=>null!=e[o]&&null!=t[o]);return i.length>0&&i.every(o=>e[o]+""==t[o]+"")}function gz(e,t,o,r,n,i="warn",a){return{id:e,category:t,status:o?"pass":i,message:o?r:n,...a?{evidence:a}:{}}}function yz(e){const{recipe:t}=e,o=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(e.scene),r=e.layoutConfig??L_({layoutConfig:e.layoutConfig}),n=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},i=n.x??0,a=n.y??0,s=[],l=o.filter(e=>null!=dz(e)),c=o.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));s.push(gz("geometry.finite","geometry",0===c.length,"All emitted geometry is finite.",c.length+" marks contain non-finite geometry.","fail",{count:c.length}));const u=o.map(pz),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;s.push(gz("geometry.nonzero-area","geometry",0===d,"All bounded marks have positive area.",d+" marks have zero or negative area.","warn",{count:d}));const h=u.filter(e=>e&&(i>e.x0||a>e.y0||e.x1>i+n.width||e.y1>a+n.height)).length;s.push(gz("geometry.bounds","geometry",0===h,"All bounded marks stay inside the plot.",h+" marks extend outside the plot bounds.","warn",{count:h}));const p=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,m=u.filter(e=>!!e&&(p>e.x1-e.x0||p>e.y1-e.y0)).length;s.push(gz("interaction.target-size","interaction",0===m,`All bounded targets meet the declared ${p}px minimum.`,`${m} targets are smaller than ${p}px in at least one dimension.`,"warn",{count:m,minimumTarget:p}));const f=l.map(uz),g=f.filter(e=>!e).length,y=new Set,b=f.filter(e=>!(!e||!y.has(e)&&(y.add(e),1)));s.push(gz("identity.stable-ids","identity",0===g,"Every data-bearing mark exposes a stable id.",g+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:g})),s.push(gz("identity.unique-ids","identity",0===b.length,"Stable mark ids are unique.",b.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(b)].slice(0,10)}));const v=f.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;v>0&&s.push({id:"identity.index-pattern",category:"identity",status:"warn",message:v+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const x=new Set;let w=0;const k=e.inputData;for(const e of l){const o=dz(e),n=Array.isArray(o)?o:[o];let i=!1;for(const e of n)if(e&&"object"==typeof e)for(let o=0;k.length>o;o+=1)fz(e,k[o],t,r,k)&&(x.add(o),i=!0);i||(w+=1)}const S=Math.max(0,k.length-x.size);s.push(gz("coverage.input-data","coverage",0===S,"Every input datum is represented by the observed scene.",S+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:x.size,input:k.length})),s.push(gz("coverage.scene-data","coverage",0===w,"Every data-bearing scene mark maps back to input data.",w+" scene marks do not map back to an input datum.","warn",{count:w}));const A=t.encodings?.some(e=>"count"===e.channel);!A&&l.length>x.size&&x.size>0&&s.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const C=l.filter(e=>!1===e.interactive).length;s.push(gz("interaction.hit-targets","interaction",0===C&&l.length>0,"Every observed data-bearing scene node participates in hit testing.",0===l.length?"No data-bearing scene nodes were emitted for interaction.":C+" data-bearing marks explicitly disable interaction.","fail"));const M=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),P=M.filter(e=>!y.has(e));s.push(gz("coverage.annotation-anchors","coverage",0===P.length,M.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",P.length+" annotations point to missing scene ids.","fail",{unresolved:P}));const I=(e.chart?.selectedIds??[]).filter(e=>!y.has(e));e.chart?.selectedIds&&s.push(gz("interaction.selection-reachability","interaction",0===I.length,"Selected/highlighted states resolve to observed marks.",I.length+" selected ids are not reachable in the scene.","fail",{missing:I}));const _=_a(o),L=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const o=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return o?N_(o,r,k):void 0}).filter(e=>!!e),R=new Set(_.flatMap(e=>Object.keys(e.values))),T=L.filter(e=>!R.has(e));s.push(gz("accessibility.table-fields","accessibility",0===T.length,L.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${T.join(", ")}.`,"fail",{expectedFields:L,observedFields:[...R]})),new Set(k.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=R.size&&[...R].every(e=>"category"===e||"value"===e)&&s.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const N=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);s.push(gz("accessibility.color-only","accessibility",0===N.length,"Every declared color encoding names a redundant cue.",N.length+" color encodings have no declared redundant cue.","warn"));const $=e.chart;if($){for(const[e,o]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])o&&s.push(gz("accessibility."+e,"accessibility","string"==typeof $[e]&&$[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&s.push(gz("accessibility.fallback-table","accessibility",!1!==$.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),$.navigationTree&&s.push(gz("accessibility.navigation-depth","accessibility",($.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const B=e.theme?.background??"#ffffff",D=o.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!B.startsWith("#"))return!1;const o=aN(t,B);return null!=o&&3>o}).length;s.push(gz("visual.contrast","visual",0===D,"All statically checkable mark fills meet 3:1 contrast.",D+" marks have fill contrast below 3:1.","warn",{background:B}));let F=0;const E=u.filter(e=>!!e).slice(0,500);for(let e=0;E.length>e;e+=1)for(let t=e+1;E.length>t;t+=1).8>mz(E[e],E[t])||(F+=1);F>E.length&&s.push({id:"visual.overlap-density",category:"visual",status:"warn",message:F+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const z=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),j={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(__).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},O=[...s,...z],H=s.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===H,summary:{marks:o.length,passes:O.filter(e=>"pass"===e.status).length,warnings:O.filter(e=>"warn"===e.status).length,failures:H,manual:O.filter(e=>"manual"===e.status).length},declaredSemantics:j,observedSceneEvidence:s,manualATChecks:z}}lz.displayName="GeoCustomChart";import*as bz from"react";function vz(e){const t=e.designContract?.chartFamily??e.title??"chart",o=e.audience?.primary?" for "+e.audience.primary:"",r=e.designContract?.whyThisForm;return`${t}: ${e.intent.primary}${o}${r?". "+r:""}`}function xz(e,t){const o=e.intents.map(e=>"string"==typeof e?e:e.id??e.name).filter(e=>!!e),r=e.intents.find(e=>"string"!=typeof e&&"primary"===e.strength),n=("object"==typeof r?r.id??r.name:void 0)??o[0]??"explanation";return{ididVersion:"0.1",chartId:t.chartId,title:t.title??e.name,intent:{primary:n,secondary:o.filter(e=>e!==n)},audience:{primary:e.audience?.primary,familiarityAssumptions:Object.fromEntries(Object.entries(e.audience?.familiarity??{}).map(([e,t])=>[e,t+""])),literacyTargets:e.audience?.literacyTargets?.map(e=>({feature:e.concept,rationale:e.rationale}))},reception:e.reception?{channels:e.reception.channels,strengths:e.reception.strengths,risks:e.reception.risks,scaffolds:e.reception.scaffolds,memorableForm:e.reception.memorableForm}:void 0,designContract:{chartFamily:e.frameFamily,whyThisForm:e.designContract.whyThisForm??e.designContract.whyCustom,whyNotDefault:e.designContract.whyNotDefault,risks:e.reception?.risks,misuse:e.designContract.misuse},accessibility:{description:t.description,navigation:"required"===e.accessibility.keyboardNavigation||null!=e.navigation,dataFallback:!0===e.accessibility.fallbackTable||"required"===e.accessibility.accessibleTable||!0===e.accessibility.requiresAccessibleTable,manualChecks:["real screen-reader behavior","keyboard order quality","custom metaphor comprehension","animation distraction"]},provenance:t.dataSources||t.reviewStatus?{dataSources:t.dataSources,reviewStatus:t.reviewStatus,generatedBy:"Semiotic recipe intelligence"}:void 0}}import{jsx as wz,jsxs as kz}from"react/jsx-runtime";function Sz({manifest:e,label:t="Intent Mark",className:o,showSummary:r=!0}){const[n,i]=bz.useState(!1),a=bz.useMemo(()=>JSON.stringify(e,null,2),[e]),s=bz.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(a),i(!0),window.setTimeout(()=>i(!1),1200))},[a]);return kz("details",{className:o?"semiotic-intent-mark "+o:"semiotic-intent-mark",style:{border:"1px solid var(--semiotic-border, #c8c8c8)",borderRadius:6,background:"var(--semiotic-surface, #fff)",color:"var(--semiotic-text, #222)",fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[kz("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),kz("div",{style:{padding:"0 10px 10px"},children:[r&&wz("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:vz(e)}),wz("button",{type:"button",onClick:s,style:{border:"1px solid currentColor",borderRadius:4,background:"transparent",color:"inherit",padding:"4px 8px",font:"inherit",fontSize:12,cursor:"pointer"},children:n?"Copied":"Copy manifest"}),wz("pre",{style:{maxHeight:280,overflow:"auto",margin:"10px 0 0",padding:10,background:"var(--semiotic-background, #f5f5f5)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap"},children:a})]})]})}var Az=[{id:"trend",label:"Trend over time",description:"How a single metric changes over an ordered sequence (typically time).",familyHint:"time-series"},{id:"compare-series",label:"Compare series",description:"Compare multiple measured series across a shared x domain.",familyHint:"time-series"},{id:"compare-categories",label:"Compare categories",description:"Compare a single measure across discrete categories.",familyHint:"categorical"},{id:"rank",label:"Rank",description:"Show category ordering by a measure (largest to smallest).",familyHint:"categorical"},{id:"part-to-whole",label:"Part to whole",description:"Show how individual categories share a total.",familyHint:"categorical"},{id:"distribution",label:"Distribution",description:"Show the shape, spread, and central tendency of a numeric variable.",familyHint:"distribution"},{id:"correlation",label:"Correlation",description:"Show the relationship between two (or more) numeric variables.",familyHint:"relationship"},{id:"flow",label:"Flow",description:"Show movement, transitions, or transfers between states.",familyHint:"flow"},{id:"hierarchy",label:"Hierarchy",description:"Show parent/child structure or nested totals.",familyHint:"hierarchy"},{id:"geo",label:"Geography",description:"Show values bound to geographic locations or regions.",familyHint:"geo"},{id:"outlier-detection",label:"Outlier detection",description:"Surface individual data points that diverge from the rest.",familyHint:"distribution"},{id:"composition-over-time",label:"Composition over time",description:"Show how the share of categories changes across an ordered sequence.",familyHint:"time-series"},{id:"change-detection",label:"Change detection",description:"Surface where or when a metric shifted meaningfully.",familyHint:"time-series"}],Cz=new Map(Az.map(e=>[e.id,e]));function Mz(e){return Cz.get(e)}function Pz(){return Array.from(Cz.values())}function Iz(e){Cz.set(e.id,e)}var _z=new Set(Az.map(e=>e.id)),Lz=new Set;function Rz(e,t,o){return Number.isFinite(e)?Math.max(t,Math.min(o,e)):t}function Tz(e,t){return void 0===e?0:Rz("function"==typeof e?e(t):e,0,5)}function Nz(e){return e?Array.isArray(e)?[...e]:[e]:[]}function $z(e,t,o){const r={};for(const[o,n]of Object.entries(e.intentScores))r[o]=Tz(n,t);if(o)for(const[e,t]of Object.entries(o))r[e]=Rz((r[e]??0)+t,0,5);return r}function Bz(e,t){if(t.length>0)return t.reduce((t,o)=>t+(e[o]??0),0)/t.length;const o=Object.values(e).filter(e=>"number"==typeof e&&e>0);return o.length?o.reduce((e,t)=>e+t,0)/o.length:0}function Dz(e,t){return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:o=>e.buildProps(o,t),rationale:t.description??`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function Fz(e,t,o){return e.some(e=>e.props?.[t]===o)}var Ez=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var zz=(e,t,o)=>function(e,t,o){const r=new Map,n=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(r.has(t.id)||r.set(t.id,t))};n(function(e,t,o){const r=o.profile,n=o.existingVariants??t.variants??[],i=Nz(o.intent),a=[];for(const e of n)a.push(Dz(t,e));const s=i.includes("rank")||i.includes("compare-categories");!Ez.has(e)||"categorical"!==t.family||Fz(n,"orientation","horizontal")||!s&&6>(r.categoryCount??0)||a.push({id:e+":heuristic-horizontal",baseComponent:e,label:"Horizontal ranked view",intentDeltas:{rank:1,"compare-categories":.5},rubricDeltas:{precision:1},buildProps:e=>({...t.buildProps(e),orientation:"horizontal",sort:"desc"}),rationale:"Horizontal orientation improves label legibility and rank scanning for categorical comparisons.",source:"heuristic",tags:["horizontal","ranked"]});const l=Fz(n,"normalize",!0)||Fz(n,"type","percent")||n.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!l&&(i.includes("part-to-whole")||i.includes("composition-over-time"))&&a.push({id:e+":heuristic-normalized",baseComponent:e,label:"Normalized composition",intentDeltas:{"part-to-whole":1,"compare-categories":-.5},rubricDeltas:{precision:-1},buildProps:e=>({...t.buildProps(e),normalize:!0}),rationale:"Normalization emphasizes proportional composition when absolute magnitude is secondary.",source:"heuristic",tags:["normalized","part-to-whole"]}),i.length>0){const t=YB().filter(t=>t.component!==e).filter(e=>null===e.fits(r)).map(e=>{const t=$z(e,r);return{candidate:e,fit:Bz(t,i),scores:t}}).filter(e=>e.fit>=4).sort((e,t)=>t.fit!==e.fit?t.fit-e.fit:t.candidate.rubric.accuracy!==e.candidate.rubric.accuracy?t.candidate.rubric.accuracy-e.candidate.rubric.accuracy:t.candidate.rubric.familiarity-e.candidate.rubric.familiarity).slice(0,3);for(const{candidate:e,fit:o}of t)a.push({id:`${e.component}:heuristic-${i.join("-")}`,baseComponent:e.component,label:e.component+" alternative",buildProps:t=>e.buildProps(t),rationale:`${e.component} is a strong ${i.join(" + ")} alternative (${o.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return a}(e,t,o));for(const r of Lz)try{n(r(e,t,o)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(r.values())}(e,t,o),jz=(e,t,o,r={})=>{const n=VB(e.baseComponent);if(!n)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const i=n.fits(t);if(null!==i)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+i]};const a=Nz(r.intent),s=$z(n,t,e.intentDeltas),l=Bz(s,a),c=function(e,t){return t?{familiarity:Math.round(Rz((o={familiarity:e.familiarity+(t.familiarity??0),accuracy:e.accuracy+(t.accuracy??0),precision:e.precision+(t.precision??0)}).familiarity,1,5)),accuracy:Math.round(Rz(o.accuracy,1,5)),precision:Math.round(Rz(o.precision,1,5))}:e;var o}(n.rubric,e.rubricDeltas);let u;const d=o?.receptionModality;if(d&&"visual"!==d){const r=e.variantKey?n.variants?.find(t=>t.key===e.variantKey):void 0,i=e.buildProps?e.buildProps(t,o):n.buildProps(t,r);u=KB(ON(e.baseComponent,i),d)}const h=QB(l,c,e.baseComponent,o,u),p=Rz(h.score,0,5);let m="manual"===e.source?.15:"heuristic"===e.source?.45:.75;r.baselineComponent&&r.baselineComponent!==e.baseComponent&&(m+=.2),e.variantKey||(m+=.05),m=Rz(m,0,1);let f="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(e.rubricDeltas?.accuracy??0)&&(f+=.15),0>(e.rubricDeltas?.precision??0)&&(f+=.1),c.accuracy>3||(f+=.1),3>p&&(f+=.2),f=Rz(f,0,1);const g=[];if(e.rationale&&g.push(e.rationale),a.length>0){const e=a.map(e=>`${e}: ${(s[e]??0).toFixed(1)}/5`).join(", ");g.push(`Intent fit — ${e}.`)}else g.push(`Mean non-zero intent fit ${l.toFixed(1)}/5.`);return"manual"!==e.source&&g.push(e.source+" proposal; verify against domain context."),h.appliedReason&&g.push(h.appliedReason),h.receivabilityReason&&g.push(h.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&g.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:p,novelty:m,risk:f,reasons:g}};function Oz(e){return Lz.add(e),()=>{Lz.delete(e)}}function Hz(){return Array.from(Lz)}function Wz(){Lz.clear()}import{useCallback as qz,useEffect as Gz,useMemo as Yz,useState as Vz,useSyncExternalStore as Xz}from"react";var Uz={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function Kz(e){if(0===e.length)return Uz;const t={},o=new Set,r=[];let n;for(const i of e){t[i.type]=(t[i.type]??0)+1,i.arcId&&(n=i.arcId);const e="component"in i&&"string"==typeof i.component?i.component:void 0;if(e&&o.add(e),"from"in i&&"string"==typeof i.from&&o.add(i.from),"to"in i&&"string"==typeof i.to&&o.add(i.to),"components"in i&&Array.isArray(i.components))for(const e of i.components)"string"==typeof e&&o.add(e);"audience-set"===i.type&&"string"==typeof i.audience&&r.push(i.audience)}const i=e[0].timestamp,a=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(o),audiencesSeen:r,latestArcId:n,startedAt:i,lastAt:a,durationMs:Math.max(0,a-i)}}function Qz(e={}){const{enableOnMount:t=!0,disableOnUnmount:o=!1,capacity:r,sessionId:n}=e;Gz(()=>(t&&wR({capacity:r,sessionId:n}),()=>{o&&kR()}),[t,o,r,n]);const i=qz(e=>uR(e),[]),a=qz(()=>SR().getEvents(),[]),s=Xz(i,a,a),[l,c]=Vz(()=>SR().enabled),[u,d]=Vz(()=>SR().sessionId);Gz(()=>(c(SR().enabled),d(SR().sessionId),uR(()=>{const e=SR();c(e.enabled),d(e.sessionId)})),[]);const h=Yz(()=>Kz(s),[s]),p=qz(e=>SR().record(e),[]),m=qz(()=>SR().clear(),[]);return{history:s,summary:h,enabled:l,sessionId:u,record:p,clear:m}}import{Fragment as Zz,jsx as Jz,jsxs as ej}from"react/jsx-runtime";function tj({items:e,title:t="Additional notes",empty:o=null,ordered:r=!0,renderItem:n,className:i,style:a}){if(!e.length)return o?Jz(Zz,{children:o}):null;const s=r?"ol":"ul";return ej("section",{className:["semiotic-mobile-annotation-callouts",i].filter(Boolean).join(" "),style:a,children:[Jz("style",{children:"\n .semiotic-mobile-annotation-callouts {\n display: grid;\n gap: 8px;\n padding: 10px 12px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 14px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n }\n .semiotic-mobile-annotation-callouts h3 {\n margin: 0;\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-mobile-annotation-callouts ol,\n .semiotic-mobile-annotation-callouts ul {\n display: grid;\n gap: 8px;\n margin: 0;\n padding-left: 18px;\n }\n .semiotic-mobile-annotation-callouts li {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-annotation-callouts small {\n display: block;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.3;\n }\n "}),t&&Jz("h3",{children:t}),Jz(s,{children:e.map((e,t)=>Jz("li",{children:n?n(e,t):ej(Zz,{children:[Jz("span",{children:e.label}),(e.source||e.emphasis)&&Jz("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}export{IR as AccessibleNavTree,Rd as AreaChart,U$ as AreaChartCapability,cF as BUILT_IN_AUDIENCES,_z as BUILT_IN_INTENT_IDS,uf as BarChart,cB as BarChartCapability,jI as BigNumber,Df as BoxPlot,kB as BoxPlotCapability,xh as BubbleChart,J$ as BubbleChartCapability,RF as CANONICAL_FIXTURES,_p as CandlestickChart,nB as CandlestickChartCapability,nc as CategoryColorProvider,wT as ChartContainer,zT as ChartGrid,cz as ChartRecipe,kx as ChordDiagram,IB as ChordDiagramCapability,BB as ChoroplethMapCapability,sw as CirclePack,NB as CirclePackCapability,ZM as CollisionSwarmChart,mh as ConnectedScatterplot,Z$ as ConnectedScatterplotCapability,qT as ContextLayout,Ke as DEFAULT_LIFECYCLE_THRESHOLDS,B$ as DEFAULT_SCALE_THRESHOLDS,QT as DetailsPanel,Od as DifferenceChart,rB as DifferenceChartCapability,EB as DistanceCartogramCapability,mg as DonutChart,mB as DonutChartCapability,Jf as DotPlot,hB as DotPlotCapability,IM as EventDropChart,FB as FlowMapCapability,yx as ForceDirectedGraph,MB as ForceDirectedGraphCapability,Tg as FunnelChart,gB as FunnelChartCapability,wM as GaltonBoardChart,Mg as GaugeChart,yB as GaugeChartCapability,kI as GauntletChart,xf as GroupedBarChart,uB as GroupedBarChartCapability,Mh as Heatmap,iB as HeatmapCapability,Wf as Histogram,wB as HistogramCapability,Sz as IntentMark,oy as LikertChart,vB as LikertChartCapability,Sd as LineChart,X$ as LineChartCapability,Xc as LinkedCharts,op as MinimapChart,oB as MinimapChartCapability,tj as MobileAnnotationCalloutList,MT as MobileChartContainer,HR as MobileStandardControls,Sp as MultiAxisLineChart,tB as MultiAxisLineChartCapability,bs as MultiLineTooltip,dw as OrbitDiagram,$B as OrbitDiagramCapability,mP as PhysicalFlowChart,FM as PhysicsCustomChart,qM as PhysicsPileChart,cg as PieChart,pB as PieChartCapability,RP as ProcessFlowChart,Qx as ProcessSankey,_B as ProcessSankeyCapability,DB as ProportionalSymbolMapCapability,dp as QuadrantChart,eB as QuadrantChartCapability,yk as RealtimeHeatmap,Zw as RealtimeHistogram,qw as RealtimeLineChart,ik as RealtimeSwarmChart,dk as RealtimeWaterfallChart,ng as RidgelinePlot,CB as RidgelinePlotCapability,Px as SankeyDiagram,PB as SankeyDiagramCapability,sh as Scatterplot,Q$ as ScatterplotCapability,qh as ScatterplotMatrix,$T as SmallMultipleChart,Yd as StackedAreaChart,K$ as StackedAreaChartCapability,ff as StackedBarChart,dB as StackedBarChartCapability,If as SwarmPlot,SB as SwarmPlotCapability,sy as SwimlaneChart,xB as SwimlaneChartCapability,Jw as TemporalHistogram,lu as ThemeProvider,HI as TooltipProvider,ew as TreeDiagram,LB as TreeDiagramCapability,nw as Treemap,TB as TreemapCapability,Xf as ViolinPlot,AB as ViolinPlotCapability,HN as accessibilityCaveats,sF as analystPersona,iL as annotationFreshnessFor,uL as applyAnnotationLifecycle,gL as applyAnnotationStatus,QB as applyAudienceBias,Y$ as applyScaleBias,ON as auditAccessibility,eT as auditMobileVisualization,yz as auditObservedScene,a_ as auditVisualizationControls,Qe as bandFromAge,qL as buildNavigationTree,wD as buildReaderGrounding,WL as buildRecipeNavigationTree,HD as chartGenerationTool,TR as clampMobileRange,z$ as classifyCardinalityBand,j$ as classifyFieldBand,E$ as classifyRowBand,Wz as clearVariantDiscovery,IL as communicativeActForIntent,O$ as compareBands,aL as computeAnnotationFreshness,q$ as computeEffectiveScale,Y_ as configToJSX,G_ as copyConfig,YL as countNodes,VD as createChartToolHandler,pR as createIndexedDBConversationArcSink,hR as createLocalStorageConversationArcSink,mR as createWebhookConversationArcSink,tL as currentTimestamp,TD as dataQualityToAnnotations,lF as dataScientistPersona,s_ as defineChartRecipe,zL as describeChart,yL as describeRecipeChart,VN as deserializeSelections,BN as diagnoseConfig,tN as diagnoseTokenEncoding,kF as diffProfile,kR as disableConversationArc,ZB as effectiveFamiliarity,wR as enableConversationArc,jz as evaluateVariantProposal,aF as executivePersona,sD as explainCapabilityFit,qI as exportChart,fL as filterAnnotationsByStatus,GL as flattenVisible,GN as formatAccessibilityAudit,rT as formatMobileVisualizationAudit,H_ as fromConfig,BD as fromDbtArtifacts,ED as fromGreatExpectations,q_ as fromURL,e$ as fromVegaLite,YB as getCapabilities,VB as getCapability,S_ as getChartRecipe,SR as getConversationArcStore,Mz as getIntent,P_ as getRecipeLayout,Hz as getRegisteredVariantDiscovery,mF as getStreamCapabilities,rF as inferIntent,xz as intentManifestFromRecipe,u_ as isJsonSafe,c_ as isRegisteredRecipeLayout,A_ as listChartRecipes,Pz as listIntents,fR as loadConversationArc,nT as mobileVisualizationCaveats,eN as normalizeTokenEncoding,OD as prepareChart,$$ as profileData,zz as proposeVariant,KB as receivabilityBias,b_ as recipeToChartCapability,bR as recordAnnotationStatusChange,yR as recordAudienceChange,qB as registerChartCapability,w_ as registerChartRecipe,dR as registerConversationArcSink,Iz as registerIntent,C_ as registerRecipeLayout,hF as registerStreamChartCapability,Oz as registerVariantDiscovery,zD as repairChartConfig,gR as replayConversationArc,W$ as resolveCardinalityToNumber,I_ as resolveChartRecipe,_L as resolveCommunicativeAct,y_ as resolveRecipeRoleField,hu as resolveResponsiveRules,H$ as resolveRowsToNumber,du as responsiveRuleMatches,SF as runQualityScorecard,V$ as scaleHints,lD as scoreChart,YN as serializeSelections,JB as stretchFamiliarityCeiling,uR as subscribeToConversationArcChange,aD as suggestCharts,cD as suggestChartsGrouped,iF as suggestDashboard,bF as suggestStreamCharts,nF as suggestStretchCharts,nN as suggestTokenEncoding,Kz as summarizeArc,h$ as summarizeData,vz as summarizeIntentManifest,WD as toAnthropicTool,O_ as toConfig,YD as toOpenAIResponsesTool,qD as toOpenAITool,W_ as toURL,rN as tokenTaskIntentToCapabilityIntents,GB as unregisterChartCapability,k_ as unregisterChartRecipe,M_ as unregisterRecipeLayout,pF as unregisterStreamChartCapability,Lc as useBrushSelection,ic as useCategoryColors,MD as useChartFocus,SD as useChartInterrogation,$c as useChartObserver,zF as useChartSuggestions,Qz as useConversationArc,Tc as useFilteredData,zc as useLinkedChartsActive,Ic as useLinkedHover,$R as useMobileRangeControls,tF as useNavigationSync,Mc as useSelection,Pc as useSelectionActions,cu as useTheme,l_ as validateChartRecipe,r_ as validateProps,oL as withCurrentProvenance,eL as withProvenance,NR as zoomMobileRange};
2
+ import{GeoCustomChart as e}from"./chunk-chunk-P6UBCMSQ.module.min.js";import{BigNumber as t}from"./chunk-chunk-FYY2ACNJ.module.min.js";import{AccessibleNavTree as r,ChartContainer as n,ChartGrid as a,ContextLayout as o,DetailsPanel as i,IntentMark as s,MobileAnnotationCalloutList as c,MobileChartContainer as l,SmallMultipleChart as p,annotationFreshnessFor as u,applyAnnotationLifecycle as d,applyAnnotationStatus as y,auditMobileVisualization as m,buildNavigationTree as h,buildRecipeNavigationTree as g,communicativeActForIntent as b,computeAnnotationFreshness as f,configToJSX as v,copyConfig as w,countNodes as x,createIndexedDBConversationArcSink as A,createLocalStorageConversationArcSink as C,createWebhookConversationArcSink as k,currentTimestamp as S,defineChartRecipe as P,describeChart as j,describeRecipeChart as T,deserializeSelections as N,disableConversationArc as R,enableConversationArc as $,exportChart as I,fieldForRole as M,filterAnnotationsByStatus as B,flattenVisible as E,formatMobileVisualizationAudit as F,fromConfig as L,fromURL as D,fromVegaLite as _,getChartRecipe as O,getConversationArcStore as z,getRecipeLayout as H,getRegisteredRecipeCapabilities as G,hasRegisteredRecipeCapabilities as q,intentManifestFromRecipe as V,isJsonSafe as W,isRegisteredRecipeLayout as U,listChartRecipes as Y,loadConversationArc as X,mobileVisualizationCaveats as K,recipeConfig as Q,recipeIntentId as J,recipeToChartCapability as Z,recordAnnotationStatusChange as ee,recordAudienceChange as te,registerChartRecipe as re,registerConversationArcSink as ne,registerRecipeLayout as ae,replayConversationArc as oe,resolveChartRecipe as ie,resolveCommunicativeAct as se,resolveRecipeRoleField as ce,serializeSelections as le,subscribeToConversationArcChange as pe,summarizeIntentManifest as ue,toConfig as de,toURL as ye,unregisterChartRecipe as me,unregisterRecipeLayout as he,useNavigationSync as ge,validateChartRecipe as be,withCurrentProvenance as fe,withProvenance as ve}from"./chunk-chunk-C6EJ4IOD.module.min.js";import{MobileStandardControls as we,auditVisualizationControls as xe,clampMobileRange as Ae,useMobileRangeControls as Ce,zoomMobileRange as ke}from"./chunk-chunk-RCF52Z42.module.min.js";import{AreaChart as Se,BubbleChart as Pe,CandlestickChart as je,ConnectedScatterplot as Te,DEFAULT_QUADRANTS as Ne,DifferenceChart as Re,Heatmap as $e,LineChart as Ie,MinimapChart as Me,MultiAxisLineChart as Be,QuadrantChart as Ee,Scatterplot as Fe,ScatterplotMatrix as Le,StackedAreaChart as De,XYCustomChart as _e}from"./chunk-chunk-U3AGQ5EF.module.min.js";import{BarChart as Oe,BoxPlot as ze,DonutChart as He,DotPlot as Ge,FunnelChart as qe,GaugeChart as Ve,GroupedBarChart as We,Histogram as Ue,LikertChart as Ye,OrdinalCustomChart as Xe,PieChart as Ke,RidgelinePlot as Qe,StackedBarChart as Je,SwarmPlot as Ze,SwimlaneChart as et,ViolinPlot as tt}from"./chunk-chunk-W3DB2MN4.module.min.js";import"./chunk-chunk-YCQYG6J5.module.min.js";import{ChordDiagram as rt,CirclePack as nt,ForceDirectedGraph as at,NetworkCustomChart as ot,OrbitDiagram as it,ProcessSankey as st,SankeyDiagram as ct,TreeDiagram as lt,Treemap as pt}from"./chunk-chunk-E7MIQX7D.module.min.js";import{closestMatch as ut,validateArrayData as dt,validateNetworkData as yt,validateObjectData as mt}from"./chunk-chunk-JCG72SGW.module.min.js";import"./chunk-chunk-BHYTYMY2.module.min.js";import{RealtimeHeatmap as ht,RealtimeHistogram as gt,RealtimeLineChart as bt,RealtimeSwarmChart as ft,RealtimeWaterfallChart as vt,TemporalHistogram as wt}from"./chunk-chunk-ZTNVDWAK.module.min.js";import"./chunk-chunk-L6D3I3V7.module.min.js";import"./chunk-chunk-CYIML3AV.module.min.js";import"./chunk-chunk-ZLKRTF5N.module.min.js";import"./chunk-chunk-5WEFWNUW.module.min.js";import"./chunk-chunk-2UN3ANRN.module.min.js";import"./chunk-chunk-XOYX77KF.module.min.js";import"./chunk-chunk-FAKO3RGQ.module.min.js";import"./chunk-chunk-5UKL5W76.module.min.js";import{CollisionSwarmChart as xt,EventDropChart as At,GaltonBoardChart as Ct,GauntletChart as kt,PhysicalFlowChart as St,PhysicsCustomChart as Pt,PhysicsPileChart as jt,ProcessFlowChart as Tt}from"./chunk-chunk-Z5KXAVQD.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-STZFFTAN.module.min.js";import{CategoryColorProvider as Nt,DEFAULT_LIFECYCLE_THRESHOLDS as Rt,LinkedCharts as $t,MultiLineTooltip as It,annotationBudget as Mt,annotationDrawsConnector as Bt,annotationStableId as Et,annotationType as Ft,bandFromAge as Lt,extractAllRows as Dt,isNoteAnnotation as _t,resolveResponsiveRules as Ot,responsiveRuleMatches as zt,useBrushSelection as Ht,useCategoryColors as Gt,useChartObserver as qt,useFilteredData as Vt,useLinkedChartsActive as Wt,useLinkedHover as Ut,useSelection as Yt,useSelectionActions as Xt}from"./chunk-chunk-ODUZEEBH.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import{ThemeProviderWrapper as Kt,createStore as Qt,useTheme as Jt}from"./chunk-chunk-WCX6U47H.module.min.js";import"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";var[Zt,er]=Qt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}})),tr={BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},valueExtent:{type:"array"},styleRules:{type:"array"},gradientFill:{type:["boolean","object"]},regression:{type:["boolean","string","object"]}}},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},stackBy:{type:["string","function"]},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},styleRules:{type:"array"},gradientFill:{type:["boolean","object"]}}},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},groupBy:{type:["string","function"]},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},styleRules:{type:"array"},gradientFill:{type:["boolean","object"]}}},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},symbolBy:{type:["string","function"]},symbolMap:{type:"object"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}}},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}}},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"},regression:{type:["boolean","string","object"]}}},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}}},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}}},GaugeChart:{required:["value"],dataShape:"none",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},gradientFill:{type:"object"},arcWidth:{type:"number"},cornerRadius:{type:"number"},sweep:{type:"number"},fillZones:{type:"boolean"},showNeedle:{type:"boolean"},needleColor:{type:"string"},color:{type:"string"},valueFormat:{type:"function"},centerContent:{type:["object","string","number","function"]},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}}},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}}},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},roundedTop:{type:"number"},trackFill:{type:["string","object"]},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}}},LikertChart:{required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},levels:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},barPadding:{type:"number"}}},LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"]},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}}},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"]},gradientFill:{type:["boolean","object"]},semanticGradient:{type:"array"},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}}},DifferenceChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","seriesAAccessor","seriesBAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},data:{type:"array"},xAccessor:{type:["string","function"]},seriesAAccessor:{type:["string","function"]},seriesBAccessor:{type:["string","function"]},seriesALabel:{type:"string"},seriesBLabel:{type:"string"},seriesAColor:{type:"string"},seriesBColor:{type:"string"},showLines:{type:"boolean"},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},curve:{type:"string",enum:["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"]},areaOpacity:{type:"number"},gradientFill:{type:["boolean","object"]},xExtent:{type:"array"},yExtent:{type:"array"},pointIdAccessor:{type:["string","function"]},windowSize:{type:"number"}}},StackedAreaChart:{required:["data","areaBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"]},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}}},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},symbolBy:{type:["string","function"]},symbolMap:{type:"object"},pointRadius:{type:"number"},pointOpacity:{type:"number"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}}},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},sizeBy:{type:["string","function"]},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"},regression:{type:["boolean","string","object"]}}},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}}},QuadrantChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},xCenter:{type:"number"},yCenter:{type:"number"},quadrants:{type:"object"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}}},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},curve:{type:"string"},lineWidth:{type:"number"}}},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]}}},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},xScaleType:{type:"string",enum:["linear","log","time"]},yScaleType:{type:"string",enum:["linear","log","time"]},styleRules:{type:"array"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"},fields:{type:"array"}}},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"}}},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},layoutExecution:{type:"string",enum:["auto","worker","sync"]},showLabels:{type:"boolean"}}},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},edges:{type:"array"},nodes:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:["vertical","horizontal"]},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}}},ProcessSankey:{required:["domain"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},edges:{type:"array"},nodes:{type:"array"},domain:{type:"array"},axisTicks:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},startTimeAccessor:{type:["string","function"]},endTimeAccessor:{type:["string","function"]},xExtentAccessor:{type:["string","function"]},edgeIdAccessor:{type:["string","function"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},pairing:{type:"string",enum:["value","temporal"]},packing:{type:"string",enum:["off","reuse"]},laneOrder:{type:"string",enum:["insertion","crossing-min","inside-out","crossing-min+inside-out"]},ribbonLane:{type:"string",enum:["source","target","both"]},lifetimeMode:{type:"string",enum:["full","half"]},showLaneRails:{type:"boolean"},showQualityReadout:{type:"boolean"},edgeOpacity:{type:"number"},timeFormat:{type:"function"},valueFormat:{type:"function"},showParticles:{type:"boolean"},particleStyle:{type:"object"}}},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},edges:{type:"array"},nodes:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}}},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}}},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},nodeStyle:{type:"function"}}},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}}},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},orbitMode:{type:["string","array"]},orbitSize:{type:["number","function"]},speed:{type:"number"},eccentricity:{type:["number","function"]},showRings:{type:"boolean"},nodeRadius:{type:["number","function"]},showLabels:{type:"boolean"},animated:{type:"boolean"},revolution:{type:"function"},foregroundGraphics:{type:"object"}}},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},projection:{type:"string"}}},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}}},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]},lineIdAccessor:{type:["string","function"]}}},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}}},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},binSize:{type:"number"},direction:{type:"string",enum:["up","down"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},transition:{type:"object"}}},TemporalHistogram:{required:["data","binSize"],dataShape:"array",dataAccessors:["timeAccessor","valueAccessor","categoryAccessor"],props:{data:{type:"array"},binSize:{type:"number"},size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},direction:{type:"string",enum:["up","down"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},linkedHover:{type:["boolean","string","object"]},linkedBrush:{type:["string","object"]},brush:{type:["boolean","string","object"]},onBrush:{type:"function"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},categoryAccessor:{type:["string","function"]},colors:{type:"object"},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},pointStyle:{type:"function"},yScaleType:{type:"string",enum:["linear","log","symlog"]},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]}}},GaltonBoardChart:{required:[],dataShape:"array",dataAccessors:["valueAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},styleRules:{type:"array"},valueAccessor:{type:["string","function"]},valueExtent:{type:"array"},bins:{type:"number"},mode:{type:"string",enum:["sample","mechanical"]},pegRows:{type:"number"},mechanicalCount:{type:"number"},branchProbability:{type:"number"},referenceLines:{type:["object","array"]},showProjection:{type:"boolean"}}},EventDropChart:{required:["data"],dataShape:"array",dataAccessors:["timeAccessor","arrivalAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},styleRules:{type:"array"},timeAccessor:{type:["string","function"]},arrivalAccessor:{type:["string","function"]},windows:{type:"object"},watermark:{type:["object","function"]},timeExtent:{type:"array"},timeScale:{type:"number"}}},PhysicsPileChart:{required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},styleRules:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},mode:{type:"string",enum:["sample","mechanical"]},mechanicalCount:{type:"number"},mechanicalCategories:{type:"array"},unitValue:{type:"number"},showProjection:{type:"boolean"},sediment:{type:"boolean"}}},CollisionSwarmChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","groupAccessor","radiusAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},styleRules:{type:"array"},xAccessor:{type:["string","function"]},groupAccessor:{type:["string","function"]},radiusAccessor:{type:["string","function"]},pointRadius:{type:"number"},xExtent:{type:"array"},collisionIterations:{type:"number"},settle:{type:"boolean"},showProjection:{type:"boolean"}}},GauntletChart:{required:["negativeProperties"],dataShape:"array",dataAccessors:["idAccessor","positiveAccessor","negativeAccessor","metricsAccessor","startTimeAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},positiveProperties:{type:"array"},negativeProperties:{type:"array"},gates:{type:"array"},events:{type:["array","function"]},startTimeAccessor:{type:["string","function"]},onCapacityChange:{type:"function"},crashDetection:{type:"boolean"},showChrome:{type:"boolean"},showProjection:{type:"boolean"},showTethers:{type:"boolean"},coreForceMode:{type:"string",enum:["route","net"]},terminalBehavior:{type:"string",enum:["outcome","hold-last"]}}},ProcessFlowChart:{required:["stages"],dataShape:"array",dataAccessors:["idAccessor","stageAccessor","groupBy","workAccessor","radiusAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:"number"},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},stages:{type:"array"},stageAccessor:{type:["string","function"]},idAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},groupLabelAccessor:{type:["string","function"]},workAccessor:{type:["string","function"]},radiusAccessor:{type:["string","function"]},groupCompletion:{type:"string",enum:["allAbsorbed","none"]},groupAnchorAlong:{type:"number"},showProjection:{type:"boolean"},showChrome:{type:"boolean"},settle:{type:"boolean"}}},PhysicalFlowChart:{required:[],dataShape:"network",dataAccessors:["nodeIdAccessor","nodeXAccessor","nodeYAccessor","sourceAccessor","targetAccessor","throughputAccessor","pathAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"},size:{type:"array"},nodes:{type:"array"},links:{type:"array"},edges:{type:"array"},data:{type:"array"},nodeIdAccessor:{type:["string","function"]},nodeXAccessor:{type:["string","function"]},nodeYAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},throughputAccessor:{type:["string","function"]},pathAccessor:{type:["string","function"]},coordinateMode:{type:"string",enum:["auto","normalized","pixels"]},particleRate:{type:"number"},maxParticles:{type:"number"},particleRadius:{type:"number"},flowSpeed:{type:"number"},pathConstraint:{type:"string",enum:["path","none"]},reducedMotion:{type:"boolean"},showStaticFlow:{type:"boolean"},showNodeLabels:{type:"boolean"},showSensors:{type:"boolean"},paused:{type:"boolean"},seed:{type:"number"}}},BigNumber:{required:[],dataShape:"none",dataAccessors:[],props:{width:{type:["number","string"]},height:{type:["number","string"]},className:{type:"string"},value:{type:"number"},label:{type:"string"},caption:{type:"string"},format:{type:["string","function"],enum:["number","currency","percent","compact","duration"]},locale:{type:"string"},currency:{type:"string"},precision:{type:"number"},prefix:{type:"string"},suffix:{type:"string"},unit:{type:"string"},comparison:{type:"object"},target:{type:"object"},delta:{type:"number"},deltaFormat:{type:["string","function"],enum:["number","currency","percent","compact","duration"]},showDeltaPercent:{type:"boolean"},direction:{type:"string",enum:["higher-is-better","lower-is-better","neutral"]},sentiment:{type:"string",enum:["auto","positive","negative","neutral"]},thresholds:{type:"array"},chartSlot:{type:["string","number","array","object","function"]},chartSize:{type:"number"},windowSize:{type:"number"},mode:{type:"string",enum:["tile","presentation","inline","thumbnail"]},align:{type:"string",enum:["start","center","end"]},padding:{type:["number","object"]},emphasis:{type:"string",enum:["primary","secondary"]},color:{type:"string"},background:{type:"string"},borderColor:{type:"string"},borderRadius:{type:["number","string"]},animate:{type:["boolean","object"]},stalenessThreshold:{type:"number"},staleLabel:{type:"string"},headerSlot:{type:["string","number","array","object","function"]},valueSlot:{type:["string","number","array","object","function"]},deltaSlot:{type:["string","number","array","object","function"]},trendSlot:{type:["string","number","array","object","function"]},footerSlot:{type:["string","number","array","object","function"]},onClick:{type:"function"},onObservation:{type:"function"}}}};function rr(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function nr(e,t){const r=[];null!=t&&"object"==typeof t||(t={});const n=tr[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(tr).join(", ")}`]};for(const a of n.required)null==t[a]&&r.push(`"${a}" is required for ${e}.`);"array"!==n.dataShape||!Object.prototype.hasOwnProperty.call(n.props,"data")||n.required.includes("data")||function(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"PhysicsPileChart"===e)}(e,t)||null!=t.data||r.push(`"data" is required for ${e}.`);for(const[e,a]of Object.entries(t)){if(null==a)continue;const t=n.props[e];if(t){if(!rr(a,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;r.push(`"${e}" should be ${n}, got ${Array.isArray(a)?"array":typeof a}.`);continue}t.enum&&"string"==typeof a&&!t.enum.includes(a)&&r.push(`"${e}" value "${a}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const a=Object.keys(n.props),o=new Set(a);for(const n of Object.keys(t))if(void 0!==t[n]&&!o.has(n)){const t=ut(n,a),o=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${a.join(", ")}.`;r.push(o)}if("array"===n.dataShape){const a=t.data,o={};for(const e of n.dataAccessors){const r=t[e];"string"==typeof r&&(o[e]=r)}const i=dt({componentName:e,data:a,accessors:Object.keys(o).length>0?o:void 0});i&&r.push(i)}else if("object"===n.dataShape){const n=mt({componentName:e,data:t.data});n&&r.push(n)}else if("network"===n.dataShape){const a=yt({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});a&&r.push(a)}return{valid:0===r.length,errors:r}}import{interpolateLab as ar}from"d3-interpolate";function or(e){const t=e.unitValue??e.unit,r=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=r&&{icon:r}}}function ir(e,t={}){const r=[],n=e.tokenSemantics,a=e.countStrategy,o=t.maxRecommendedTokens??("fixed-denominator"!==a||function(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}(e.denominator)>100?80:100);return n||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),a||r.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>o&&r.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==n||"icon"!==e.tokenType&&"glyph"!==e.tokenType||r.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===n&&a&&"unitized"!==a&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===n&&a&&"fixed-denominator"!==a&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==n&&"posterior-sample"!==n&&"hypothetical-case"!==n||!a||"quantile"===a||"sample"===a||"posterior-sample"===a||"random-sample"===a||r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===n&&"unitized"===a&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==n||"unitized"!==a||e.unitMeaning||r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function sr(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function cr(e){const t=sr(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function lr(e){const t=sr(e.taskIntent),r="small"===(n=e.availableSpace)?25:"large"===n?100:50;var n;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:r,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:ir(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:ir(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:ir(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:r,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:ir(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function pr(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));const r=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!r)return null;const[n,a,o]=[parseInt(r[1],16)/255,parseInt(r[2],16)/255,parseInt(r[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(a)+.0722*i(o)}function ur(e,t){const r=pr(e),n=pr(t);return null===r||null===n?null:(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}var dr=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),yr=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),mr=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),hr=new Set(["LineChart","AreaChart","StackedAreaChart"]),gr=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]),br=new Set(["LineChart","AreaChart","StackedAreaChart","ConnectedScatterplot"]),fr=new Set(["PieChart","DonutChart"]),vr={PieChart:"valueAccessor",DonutChart:"valueAccessor",FunnelChart:"valueAccessor"},wr=new Set(Object.keys(vr)),xr={StackedBarChart:"valueAccessor",StackedAreaChart:"yAccessor"},Ar=new Set(["BigNumber"]),Cr=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),kr=new Set(["StreamPhysicsFrame","GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]),Sr=new Set(["OrbitDiagram",...kr]),Pr=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart"]),jr=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","PhysicsCustomChart"]),Tr=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),Nr=new Set(["MultiAxisLineChart"]),Rr=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),$r={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},Ir=["xExtent","yExtent","rExtent"];function Mr(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function Br(e,t,r){if("function"==typeof t)return t(e);const n="string"==typeof t?t:r;return e?.[n]}var Er=new Set(["category10","tableau10","set3","blues","reds","greens","oranges","purples","greys","viridis","plasma","inferno","magma","cividis","turbo"]),Fr=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Lr(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function Dr(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function _r(e,t){const r=Dr(e.visibleTokens);if(null!=r)return r;const n=Dr(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=n)return n;const a=Dr(t.tokenCount),o=Dr(t.maxTokens);return null!=a&&null!=o?Math.min(a,o):a??n??o}function Or(e,t){const r=[],n=nr(e,function(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,Lr(t.encoding)&&delete t.encoding,t}(t));for(const e of n.errors)r.push({severity:"error",code:"VALIDATION",message:e,fix:""});return tr[e]?(function(e,t,r){const n=tr[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&r.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&r.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,r),function(e,t,r){const n=t.width,a=t.height;if(void 0===n||"number"==typeof n&&n>0||r.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===a||"number"==typeof a&&a>0||r.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(a)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&r.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,r),function(e,t,r){const n=tr[e];if(!n||"array"!==n.dataShape)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=a[0];if(!o||"object"!=typeof o)return;const i=Object.keys(o);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in o||r.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${i.join(", ")}.`,fix:`Change ${e} to one of: ${i.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,r),function(e,t,r){dr.has(e)&&Array.isArray(t.data)&&r.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,r),function(e,t,r){yr.has(e)&&(t.edges||t.data||r.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,r),function(e,t,r){const n=tr[e];if(!n||"array"!==n.dataShape)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=a[0];if(!o||"object"!=typeof o)return;const i=t.xAccessor;"string"==typeof i&&o[i]instanceof Date&&!t.xFormat&&r.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${i}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,r),function(e,t,r){t.linkedHover&&!t.selection&&r.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,r),function(e,t,r){if(!mr.has(e))return;const n=t.rExtent||t.yExtent||t.valueExtent;n&&Array.isArray(n)&&n.length>=1&&null!=n[0]&&0!==n[0]&&r.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${n[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${n[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,r),function(e,t,r){if(!hr.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const a=t.yAccessor||"y";"string"==typeof a&&n.some(e=>{const t=e[a];return null==t||Number.isNaN(t)})&&r.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${a}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,r),function(e,t,r){const n=t.width??600,a=t.height??400,o=t.margin;if(!o||"object"!=typeof o)return;const i=(o.left||0)+(o.right||0),s=(o.top||0)+(o.bottom||0);n>i||r.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${i}px) >= width (${n}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),a>s||r.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${s}px) >= height (${a}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,r),function(e,t,r){const n=tr[e];if(!n||"array"!==n.dataShape)return;const a=t.data;if(!a||!Array.isArray(a)||0===a.length)return;const o=[];t.xAccessor&&"string"==typeof t.xAccessor&&o.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&o.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&o.push({prop:"valueAccessor",name:t.valueAccessor});const i=Math.min(a.length,5);for(const e of o){let t=!0;for(let r=0;i>r;r++){const n=a[r]?.[e.name];if("number"==typeof n&&Number.isFinite(n)){t=!1;break}}t&&r.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,r),function(e,t,r){if(!gr.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&r.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,r),function(e,t,r){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const a=n.bottom;"number"==typeof a&&70>a&&r.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${a}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,r),function(e,t,r){if(!t.showLegend)return;if("right"!==(t.legendPosition??"right"))return;const n=t.margin;if(!n||"object"!=typeof n)return;const a=n.right;"number"==typeof a&&100>a&&r.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${a}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,r),function(e,t,r){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const a=n[0];if(a&&"object"==typeof a)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const o=a[n];"string"==typeof o&&r.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${o}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const a="string"==typeof t.background?t.background:"#ffffff";if(!a.startsWith("#"))return;const o=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ur(e,a);null!==t&&3>t&&o.push(`${e} (${t.toFixed(1)}:1)`)}o.length>0&&r.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${o.length} color(s) in colorScheme have < 3:1 contrast against background "${a}": ${o.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,r),function(e,t,r){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const a=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>a.length)return;const o=[];for(let e=0;a.length-1>e;e++){const t=ur(a[e],a[e+1]);null!==t&&1.5>t&&o.push(`${a[e]} / ${a[e+1]} (${t.toFixed(1)}:1)`)}o.length>0&&r.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${o.length} adjacent color pair(s) in colorScheme have very similar luminance: ${o.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,r),function(e,t,r){const n=t.colorScheme;if("string"!=typeof n)return;const a=tr[e];a?.props?.colorScheme?.enum||Er.has(n)||r.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${n}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...Er].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}(e,t,r),function(e,t,r){const n=tr[e]?.props,a=e=>!!n?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,o=a("title"),i=a("description"),s=a("summary");o||i||s||r.push({severity:"warning",code:"MISSING_DESCRIPTION",message:"No title, description, or summary provided. Screen readers will fall back to a generic chart-type label.",fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(e,t,r),function(e,t,r){const n=[];for(const e of Fr)"function"==typeof t[e]&&n.push(e);n.length>0&&r.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference; closures over changing values can force unnecessary scene rebuilds on resize/rotation.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,r),function(e,t,r){const n=t.hoverRadius;"number"==typeof n&&n>0&&24>n&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&r.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${n}px is below the ~24px radius needed for reliable 48px touch targets on mobile screens.`,fix:"Use hoverRadius={24} or larger for touch-heavy views. Semiotic floors touch pointer hit testing to 24px, but explicit desktop-only radii should be documented."})}(0,t,r),function(e,t,r){!0===t.responsiveWidth&&!0===t.responsiveHeight&&r.push({severity:"warning",code:"RESPONSIVE_BOTH_AXES",message:"responsiveWidth and responsiveHeight are both true. On mobile this can create resize feedback loops when the parent height depends on chart content.",fix:"Prefer responsiveWidth={true} with a fixed parent height or size={[width, fixedHeight]}; use a ResizeObserver outside the chart if the height must follow aspect ratio."})}(0,t,r),function(e,t,r){if(!0!==t.showParticles)return;const n=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},a="number"==typeof n.maxPerLine?n.maxPerLine:void 0,o="number"==typeof n.spawnRate?n.spawnRate:void 0;("number"==typeof a&&a>20||"number"==typeof o&&o>.08)&&r.push({severity:"warning",code:"GEO_PARTICLE_MOBILE_COST",message:"Animated geo particles run a continuous canvas loop that can drain battery and trigger thermal throttling on mobile GPUs.",fix:"Set particleStyle={{ maxPerLine: 12, spawnRate: 0.06 }} for mobile-heavy views, or disable showParticles when reduced-motion or low-power modes are active."})}(0,t,r),function(e,t,r){const n=[];Lr(t.tokenEncoding)&&n.push({source:"tokenEncoding",encoding:t.tokenEncoding}),Lr(t.encoding)&&n.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:a}of n){const n=_r(t,a);for(const t of ir(a,{visibleTokens:n}))r.push({severity:"warning",code:"TOKEN_"+t.code,message:t.message,fix:"MISSING_UNIT_VALUE"===t.code?`Set ${e}.unitValue to the value represented by one full token.`:"MISSING_UNIT_MEANING"===t.code?`Set ${e}.unitMeaning so readers know what one full token represents.`:"MISSING_COUNT_STRATEGY"===t.code?`Set ${e}.countStrategy to actual, unitized, fixed-denominator, quantile, sample, posterior-sample, or random-sample.`:"TOKEN_SEMANTICS_UNCLEAR"===t.code?`Set ${e}.tokenSemantics to observed-unit, unitized-measure, risk-case, possible-outcome, posterior-sample, hypothetical-case, topic-anchor, or decorative.`:`Adjust ${e} so its semantics, strategy, labels, and visible token count match the task.`})}}(0,t,r),function(e,t,r){const n=Array.isArray(t.annotations)?t.annotations:null;if(n)for(const e of n){if(!e||"object"!=typeof e)continue;const t=Ft(e);if(!_t(e)||"widget"===t)continue;const n=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),a="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,o=Bt(e);!o&&n>120?r.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${a}" sits ~${Math.round(n)}px from its anchor with no connector — a reader can't tell what it refers to.`,fix:'Add a connector (connector: { end: "arrow" }, the label/callout default) or place the note adjacent to its target (smaller dx/dy).'}):o&&n>250&&r.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${a}" uses a very long connector (~${Math.round(n)}px); prefer placing the note adjacent to its target when space allows.`,fix:"Reduce dx/dy so the note sits near its target, or keep the long connector only if proximity is genuinely infeasible."})}}(0,t,r),function(e,t,r){const n=Array.isArray(t.annotations)?t.annotations:null;if(!n)return;const a=n.filter(_t).length;if(0===a)return;const o="number"==typeof t.width?t.width:600,i="number"==typeof t.height?t.height:400,s=Mt(o,i);Number.isFinite(s)&&a>s&&r.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${a} note annotations on a ${o}×${i} chart exceed the ~${s} notes the plot area carries comfortably — the chart may read as cluttered.`,fix:'Mark the essential notes emphasis: "primary" and let density management shed the rest (autoPlaceAnnotations: { density: true }), enable progressive disclosure to reveal secondary notes on hover, or give the chart more room.'})}(0,t,r),function(e,t,r){const n=Array.isArray(t.annotations)?t.annotations:null;if(n)for(const e of n)e&&"object"==typeof e&&"widget"===Ft(e)&&null!=e.content&&!Et(e)&&r.push({severity:"warning",code:"ANNOTATION_INTERACTIVE_ID",message:"An interactive widget annotation has no stable id, so its activation cannot be normalized or replayed reliably.",fix:"Add id, stableId, or provenance.stableId to the widget annotation. Do not identify interactive annotations by array index."})}(0,t,r),function(e,t,r){for(const e of Ir){const n=t[e];if(!Array.isArray(n)||2>n.length)continue;const[a,o]=n;"number"==typeof a&&"number"==typeof o&&a>o&&r.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${a}, ${o}] is descending — the axis renders inverted, so "up" reads as less. Inverted axes are a classic misleading-design pattern unless the inversion is the point.`,fix:`Order the extent ascending (${e}={[${o}, ${a}]}). If the inversion is deliberate (e.g. rank #1 at top), say so in the title or an annotation so readers aren't misled.`})}}(0,t,r),function(e,t,r){if("MultiAxisLineChart"!==e)return;const n=t.series;if(!Array.isArray(n)||2!==n.length)return;const a=n.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);a.length>0&&r.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${a.length} unlabeled series. Two y-scales invite false equivalence between the lines; without per-series labels a reader can't tell which scale is whose.`,fix:'Give every series a label: series={[{ yAccessor: "a", label: "Revenue ($)" }, { yAccessor: "b", label: "Users" }]} — and consider whether two separate charts read more honestly.'})}(e,t,r),function(e,t,r){if(!hr.has(e))return;const n=t.xExtent;if(!Array.isArray(n)||2>n.length)return;const[a,o]=n;if("number"!=typeof a||"number"!=typeof o||a>=o)return;const i=t.data;if(!i||!Array.isArray(i)||4>i.length)return;const s=t.xAccessor??"x";if("string"!=typeof s)return;let c=1/0,l=-1/0;for(const e of i){const t=e?.[s];"number"==typeof t&&Number.isFinite(t)&&(c>t&&(c=t),t>l&&(l=t))}if(!Number.isFinite(c)||!Number.isFinite(l)||c>=l)return;const p=l-c,u=Math.max(0,Math.min(o,l)-Math.max(a,c))/p;.7>u&&r.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${a}, ${o}] shows only ~${Math.round(100*u)}% of the data's x range [${c}, ${l}] — a trend cropped to a favorable window is a classic misleading-design pattern.`,fix:'Widen xExtent to cover the data, filter the data itself so the chart shows what it has, or annotate the visible window ("Q4 only") so the cropping is explicit.'})}(e,t,r),function(e,t,r){const n=vr[e],a=xr[e];if(!n&&!a)return;if(a&&!t.normalize)return;const o=n??a,i=t[o],s="string"==typeof i?i:"yAccessor"===o?"y":"value",c=t.data;if(!c||!Array.isArray(c)||0===c.length)return;const l=c.filter(e=>{const t=e?.[s];return"number"==typeof t&&0>t});l.length>0&&r.push({severity:n?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${l.length} negative value(s) in "${s}" — a part-to-whole encoding cannot represent negative parts${n?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:n?"Filter or transform negative values first, or switch to a BarChart/WaterfallChart, which encode signed values honestly.":"Drop normalize for signed data, or use a diverging BarChart so negative contributions read as negative."})}(e,t,r),function(e,t,r){br.has(e)&&"basis"===t.curve&&r.push({severity:"warning",code:"NON_PASSING_CURVE",message:'curve="basis" draws a B-spline that does NOT pass through your data points — rendered values differ from actual values everywhere except the endpoints.',fix:'Use curve="monotoneX" or curve="catmullRom" (both interpolate through every point), or keep "basis" only for deliberately schematic, clearly-labeled smoothing.'})}(e,t,r),function(e,t,r){if("LineChart"!==e&&"AreaChart"!==e)return;if("sparkline"===t.mode)return;if(t.responsiveWidth||t.responsiveHeight)return;const n="number"==typeof t.width?t.width:600,a="number"==typeof t.height?t.height:400;if(0>=n||0>=a)return;const o=n/a;if(o>8||.25>o){const e=o>8?"flattens":"exaggerates";r.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${n}×${a} (${o.toFixed(1)}:1) is an extreme aspect ratio that ${e} the slopes a reader perceives — aspect-ratio distortion is a documented misleading-design pattern.`,fix:o>8?'Use a more balanced aspect (e.g. width/height between 1 and 3), or set mode="sparkline" if this is genuinely a sparkline strip.':"Use a more balanced aspect (e.g. width/height between 1 and 3); very tall trend charts overstate every change."})}}(e,t,r),function(e,t,r){if(!fr.has(e))return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const a=t.categoryAccessor,o="string"==typeof a?a:"category",i=new Set;for(const e of n){const t=e?.[o];null!=t&&i.add(t)}i.size>8&&r.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:i.size+" slices — angle judgments degrade rapidly past ~8 categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.",fix:`Use a BarChart or DotPlot for ${i.size} categories, or group the long tail into an "Other" slice before charting.`})}(e,t,r),function(e,t,r){if(jr.has(e)){if("GaltonBoardChart"===e){const e=t.bins;"number"==typeof e&&2>e&&r.push({severity:"error",code:"PHYSICS_BAD_BINS",message:`bins=${e} leaves no meaningful settled projection for a Galton board.`,fix:"Use at least two bins; 8-24 bins is a practical range for physics distributions."});const n=Mr(t.branchProbability);null!=t.branchProbability&&(null==n||0>n||n>1)&&r.push({severity:"error",code:"PHYSICS_BAD_BRANCH_PROBABILITY",message:`branchProbability=${t.branchProbability+""} must be between 0 and 1.`,fix:"Use branchProbability={0.5} for a balanced Galton board, or bias it within the [0, 1] range."});const a=Mr(t.mechanicalCount);null==t.mechanicalCount||null!=a&&a>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical Galton board.`,fix:"Use a positive mechanicalCount, for example 96."})}if("EventDropChart"===e){const e=t.windows,n=e&&"object"==typeof e?Mr(e.size):null;null==n||n>0||r.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${n} cannot form event-time barriers.`,fix:"Set windows={{ size: positiveNumber }} so each event can settle into a real time window."}),"number"!=typeof t.timeScale||t.timeScale>0||r.push({severity:"error",code:"PHYSICS_BAD_TIME_SCALE",message:`timeScale=${t.timeScale} prevents arrival replay from advancing.`,fix:"Use a positive timeScale, or omit it for the default pace."});const a=Array.isArray(t.data)?t.data:[];if(a.length>0){const e=t.timeAccessor||"time",n=t.arrivalAccessor||"arrivalTime";a.some(t=>{const r=Mr(Br(t,e,"time")),a=Mr(Br(t,n,"arrivalTime"));return null!=r&&null!=a&&r!==a})||r.push({severity:"warning",code:"PHYSICS_EVENTDROP_NO_ARRIVAL_SPREAD",message:"EventDropChart data does not show distinct arrival times, so the physics replay collapses to event order.",fix:"Provide an arrivalAccessor field with event-arrival times when demonstrating lateness, watermarks, or out-of-order streams."})}}if("PhysicsPileChart"===e){const e=Mr(t.mechanicalCount);null==t.mechanicalCount||null!=e&&e>0||r.push({severity:"error",code:"PHYSICS_BAD_MECHANICAL_COUNT",message:`mechanicalCount=${t.mechanicalCount+""} cannot generate a mechanical pile chart.`,fix:"Use a positive mechanicalCount, for example 80."}),"mechanical"===t.mode&&Array.isArray(t.mechanicalCategories)&&0===t.mechanicalCategories.length&&r.push({severity:"error",code:"PHYSICS_EMPTY_MECHANICAL_CATEGORIES",message:"mechanicalCategories=[] leaves no containers for the generated unit pile.",fix:"Provide at least one category label, or omit mechanicalCategories for the default set."});const n=Mr(t.unitValue??1)??1;if(0>=n)return void r.push({severity:"error",code:"PHYSICS_BAD_UNIT_VALUE",message:`unitValue=${t.unitValue} cannot unitize values into physical bodies.`,fix:"Set unitValue to a positive number represented by one body."});const a=t.valueAccessor||"value",o=(Array.isArray(t.data)?t.data:[]).reduce((e,t)=>{const r=Mr(Br(t,a,"value"))??0;return e+Math.max(0,Math.round(r/n))},0);o>1500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`PhysicsPileChart would create about ${o} live bodies; motion may dominate the chart and stress the frame budget.`,fix:"Increase unitValue, cap visible units, or aggregate before rendering so the settled projection remains readable."})}if("CollisionSwarmChart"===e){if((Mr(t.pointRadius??5)??5)>0||r.push({severity:"error",code:"PHYSICS_BAD_POINT_RADIUS",message:`pointRadius=${t.pointRadius} cannot produce collision bodies.`,fix:"Use a positive pointRadius, for example 5."}),(Mr(t.collisionIterations??6)??6)>0||r.push({severity:"error",code:"PHYSICS_BAD_COLLISION_ITERATIONS",message:`collisionIterations=${t.collisionIterations} disables collision relaxation.`,fix:"Use at least one collision iteration; 4-8 is a practical range for swarms."}),null!=t.xExtent){const e=Array.isArray(t.xExtent)?t.xExtent:[],n=Mr(e[0]),a=Mr(e[1]);(2>e.length||null==n||null==a)&&r.push({severity:"error",code:"PHYSICS_BAD_X_EXTENT",message:"xExtent must be a numeric [min, max] pair for CollisionSwarmChart.",fix:"Pass xExtent={[min, max]} or omit it so the chart infers the domain from data."})}const e=Array.isArray(t.data)?t.data:[];e.length>1200&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`CollisionSwarmChart would create ${e.length} live bodies; collision relaxation may dominate the frame budget.`,fix:"Sample, aggregate, reduce point radius, or move to a static SwarmPlot when every row does not need a physical body."});const n=t.groupAccessor;if(e.length>0&&n){const t=new Set;for(const r of e){const e=Br(r,n,"group");null!=e&&t.add(e)}t.size>12&&r.push({severity:"warning",code:"PHYSICS_TOO_MANY_SWARM_LANES",message:`CollisionSwarmChart has ${t.size} group lanes, which leaves little vertical room for collision separation.`,fix:"Facet or filter groups, or use an ordinary SwarmPlot/BoxPlot for dense grouped comparison."})}}if("GaltonBoardChart"!==e&&"PhysicsPileChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"EventDropChart"!==e||(null!=t.massBy||null!=t.massAccessor||t.frameProps&&"object"==typeof t.frameProps&&null!=t.frameProps.bodyMassBy)&&r.push({severity:"warning",code:"PHYSICS_DATA_IN_DYNAMICS",message:e+" appears to map a data field to mass/dynamics. Mass is not a readable quantitative channel.",fix:"Encode quantities in spawn position, bin, size, color, or glyph — keep mass/friction/restitution as process texture. Use showProjection for the truth layer."}),"PhysicsPileChart"!==e&&"GaltonBoardChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e||!1!==t.showProjection||r.push({severity:"warning",code:"PHYSICS_NO_PROJECTION",message:e+" has showProjection={false}. Without a settled projection, motion is easy to over-read as data.",fix:"Keep showProjection enabled (default) so the chart collapses to a legible static reading, or document why the process alone is the claim."}),"ProcessFlowChart"===e){const e=Array.isArray(t.stages)?t.stages:[];if(0===e.length)r.push({severity:"error",code:"PROCESS_FLOW_MISSING_STAGES",message:"ProcessFlowChart requires a non-empty stages array.",fix:'Provide stages={[{ id: "coding", force: 12 }, { id: "merged", absorb: true }]}.'});else{e.some(e=>!e||null==e.id||""===(e.id+"").trim())&&r.push({severity:"error",code:"PROCESS_FLOW_BAD_STAGE",message:"Every ProcessFlowChart stage needs a stable id.",fix:'Use stages like { id: "review", label: "Review", capacity: { unitsPerSecond: 4 } }.'});const n=e.filter(e=>e?.absorb).length;t.groupBy&&0===n&&r.push({severity:"warning",code:"PROCESS_FLOW_GROUP_NO_ABSORB",message:"groupBy is set but no stage has absorb: true, so all-members completion cannot resolve.",fix:'Mark a terminal stage with absorb: true (e.g. merged), or set groupCompletion="none".'})}}if("GauntletChart"===e&&(Array.isArray(t.negativeProperties)||r.push({severity:"warning",code:"GAUNTLET_MISSING_NEGATIVE_PROPERTIES",message:"GauntletChart usually needs negativeProperties for drag/cost bodies (empty array is ok if intentional).",fix:'Provide negativeProperties={[{ id: "cost", label: "Cost", load: 1 }]} or explicitly pass [].'})),"PhysicsPileChart"===e||"GaltonBoardChart"===e||"CollisionSwarmChart"===e||"ProcessFlowChart"===e||"EventDropChart"===e){const n=Array.isArray(t.data)?t.data:[],a=Mr(t.mechanicalCount)??0,o=n.length>0?n.length*("PhysicsPileChart"===e?Math.max(1,(Mr(t.unitValue),1)):1):a;o>2500&&r.push({severity:"warning",code:"PHYSICS_BODY_BUDGET",message:`${e} may spawn ~${Math.round(o)} live bodies, which can overwhelm the simulation loop.`,fix:"Lower mechanicalCount / unitize with a larger unitValue, enable sediment/windowSize, or sample the data before spawn."})}}}(e,t,r),{ok:r.every(e=>"warning"===e.severity),diagnoses:r}):{ok:0===r.length,diagnoses:r}}var zr=["title","description","summary"];function Hr(e){return"string"==typeof e&&e.trim().length>0}var Gr=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]);function qr(e){return"primary"===e?.emphasis||"secondary"===e?.emphasis||null!=function(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?t:null}(e)}function Vr(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const r=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return r?r.length:1}function Wr(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function Ur(e,t,r={}){const n=[],a=O(e),o=kr.has(e),i=!!tr[e]||!!a||o,s=!0===r.inChartContainer,c=!0===r.describe,l=!0===r.navigable,p=Ar.has(e),u=dr.has(e),{hasTitle:d,hasDescription:y,hasSummary:m,unsupportedFinding:h}=function(e,t){const r=tr[e]?.props,n=e=>!!r?.[e],a=zr.filter(e=>Hr(t[e])&&!n(e));return{hasTitle:n("title")&&Hr(t.title),hasDescription:n("description")&&Hr(t.description),hasSummary:n("summary")&&Hr(t.summary),unsupportedFinding:a.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${a.join(" and ")} text was supplied, but ${1===a.length?"that prop is":"those props are"} not supported by ${e}'s declared chart API and cannot be credited as rendered accessibility text.`,fix:"Use the component's declared title, description, and summary props when available; for richer generated description or navigation, use ChartContainer with chartConfig plus describe and/or navigable."}:void 0}}(e,t),g=!1!==t.accessibleTable&&!p,b=d||y||m,f=function(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}(t),v=function(e){const t=Wr(e),r=e.controls&&"object"==typeof e.controls?e.controls:{};return!0===e.pauseControl||!0===t.pauseControl||!0===r.pause||"function"==typeof r.pause}(t),w=o,x=function(e){const t=Wr(e);return!0===e.settledProjection||!0===t.settledProjection}(t)||Pr.has(e)&&g,A=function(e){const t=Wr(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}(t)||w,C=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],k=i?"pass":"manual",S=i?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(h&&n.push(h),n.push(function(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},r=e.colorScheme,n="string"==typeof e.background?e.background:null;if(n&&!n.startsWith("#"))return{...t,status:"manual",message:`Background "${n}" isn't a hex literal (theme/CSS variable) — contrast can't be verified statically.`,fix:'Pass a hex `background` (e.g. "#ffffff"/"#000000"), or verify contrast manually once the theme resolves.'};const a=n??"#ffffff";if(!Array.isArray(r))return{...t,status:"manual",message:"Mark colors come from the theme/CSS variables — contrast can't be verified statically.",fix:"Confirm geometries/large text have ≥ 3:1 and regular text ≥ 4.5:1 contrast against the background."};const o=[];let i=0;for(const e of r){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ur(e,a);null!=t&&(i++,3>t&&o.push(`${e} (${t.toFixed(1)}:1)`))}return 0===i?{...t,status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:o.length>0?{...t,status:"fail",message:`${o.length} color(s) fall below 3:1 contrast vs ${a}: ${o.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{...t,status:"pass",message:`All ${i} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${a}.`}}(t)),n.push({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0,...p?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:g?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:y&&m?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."}}),n.push({id:"perceivable.small-text",principle:"perceivable",heuristic:"Small text size",critical:!0,status:"pass",message:"Semiotic's default tick and axis-label fonts are 12px, meeting Chartability's 9pt/12px floor.",fix:"If a theme or override lowers --semiotic-tick-font-size below 12px, raise it back for low-vision audiences."}),n.push({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0,...null!=t.pulse||Sr.has(e)?{status:"manual",message:"Pulse/continuous animation is in use. Confirm nothing flashes more than 3×/sec, especially saturated red.",fix:"Avoid red flashes and rapid (>3 Hz) flicker; reduced-motion is auto-honored, but verify the default presentation."}:{status:"manual",message:"No flashing detected statically. Confirm no element flashes more than 3×/sec.",fix:"Manual check — most static charts pass trivially."}}),null!=t.colorBy){n.push({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...!0===t.directLabel||!0===t.showLabels?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:"Categories are encoded by color (colorBy) with no redundant channel — Semiotic does not yet ship texture/pattern fills.",fix:"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy), keep categories ≤ ~7, and use a CVD-safe palette."}});const e=Array.isArray(t.colorScheme)?t.colorScheme:null,r=e?e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase()):[],a=r.length>0&&r.every(e=>Gr.has(e));n.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...a?{status:"pass",message:"colorScheme uses Semiotic's Wong colorblind-safe palette."}:{status:"manual",message:"Color encodes meaning; statically we can't confirm the palette is colorblind-safe.",fix:'Use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic", or test your scheme with Viz Palette / Chroma.'}}),n.push({id:"flexible.textures-adjustable",principle:"flexible",heuristic:"Contrast and textures cannot be adjusted",critical:!1,status:"warn",message:"There's no per-category texture/pattern channel to toggle as an alternative to color.",fix:"Until texture fills land, ensure the encoding survives color removal: direct labels + a CVD-safe palette. Contrast itself is themeable via CSS variables."})}{const e=C.filter(_t);if(e.length>0){const r=t.autoPlaceAnnotations,a="object"==typeof r&&null!==r&&!0===r.redundantCues,o=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=Ft(e),r=a&&"text"===t;return!(Bt(e)||r)});n.push({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...0===o.length?{status:"pass",message:"No annotation relies on color alone to indicate its target — wherever color is used, a connector, enclosure, or reference-line cue is present too."}:{status:"warn",message:`${o.length} of ${e.length} annotation(s) carry a color but no connector, enclosure, or reference-line cue, so a color-blind or non-visual reader can't tie them to their target (the correspondence problem).`,fix:"Add a connector (the label/callout default), place the note adjacent to its target, enclose the target, or enable autoPlaceAnnotations: { redundantCues: true } to give colored text notes a leader line — don't rely on color matching alone."}})}}n.push({id:"operable.single-input-modality",principle:"operable",heuristic:"Interaction modality only has one input type",critical:!0,...i?{status:"pass",message:"Built-in keyboard navigation (arrows/Home/End/PageUp-Down/Enter) mirrors mouse hover."}:{status:"manual",message:`Can't confirm keyboard support for "${e}".`,fix:"Verify Tab + arrow-key operation."}});{const e=[];null==t.brush&&null==t.onBrush||e.push("brushing"),!0===t.zoomable&&e.push("zoom/pan"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||e.push("legend filtering"),e.length>0&&n.push({id:"operable.complex-action-alternatives",principle:"operable",heuristic:"Complex actions have no alternatives",critical:!1,status:"warn",message:`Mouse-driven ${e.join(", ")} ${e.length>1?"have":"has"} no built-in keyboard/standard-UI equivalent.`,fix:"Pair the complex interaction with a standard control (range inputs for a brush, buttons for zoom, a checkbox list for legend filtering) operable by keyboard and screen reader."})}{const r=$r[e];if(r&&f){const e=t[r];"number"==typeof e&&e>0&&24>2*e&&n.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${r}=${e} gives a ~${2*e}px hit target, below the 24×24px minimum for pointer interaction.`,fix:"Increase the radius, or rely on the chart's hoverRadius / keyboard navigation as the alternative for precise selection."})}}n.push({id:"operable.tab-stops",principle:"operable",heuristic:"Inappropriate tab stops",critical:!1,status:k,message:`The chart takes a single tab stop and navigates data with arrow keys${S} — the recommended pattern for dense charts (no per-datum tab stops to wade through).`}),n.push({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0,...f?m||y?{status:"manual",message:"Chart is interactive and has descriptive text. Confirm that text explains how to interact (keyboard + pointer).",fix:'State the interaction model in summary, e.g. "Use arrow keys to move between points."'}:{status:"warn",message:"Chart is interactive but nothing explains how to use it.",fix:"Describe the interaction in a summary or nearby text (keyboard navigation, what hover/click reveals)."}:{status:"not-applicable",message:"No interactive behavior detected."}}),n.push({id:"operable.controls-override-at",principle:"operable",heuristic:"Controls override AT controls",critical:!0,status:k,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${S}.`}),n.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:k,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${S}.`,fix:i?"Ensure --semiotic-focus keeps ≥ 3:1 contrast against your background.":void 0}),n.push({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0,...b?{status:"pass",message:`Provided: ${[d&&"title",y&&"description",m&&"summary"].filter(Boolean).join(", ")}.`}:s?{status:"manual",message:"No title/description/summary on the chart. If the wrapping ChartContainer supplies a title/subtitle, this is covered at that layer — verify it does.",fix:"Give the ChartContainer a title (and optionally enable describe), or set title/description/summary on the chart."}:{status:"fail",message:"No title, description, or summary — the screen reader falls back to a generic label.",fix:"Add title/description/summary on the chart, or wrap it in a ChartContainer (the opt-in layer for title/caption/description chrome)."}}),n.push({id:"understandable.explain-purpose",principle:"understandable",heuristic:"No explanation for purpose or for how to read",critical:!0,...y||m?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:c?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:d?{status:"warn",message:"Only a title is set — a label, not an explanation of purpose or how to read the chart.",fix:"Add a summary, or enable ChartContainer's describe option for an auto-generated how-to-read description."}:{status:"fail",message:"Nothing explains the chart's purpose or how to read it.",fix:"Add a summary/description, or wrap in a ChartContainer with a title and the describe option (the opt-in full-accessibility layer)."}});{const e=[t.description,t.summary].filter(Hr).join(". "),r=e?function(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),r=e.trim().split(/\s+/).filter(Boolean);if(0===r.length||0===t.length)return null;let n=0;for(const e of r)n+=Vr(e);return r.length/t.length*.39+n/r.length*11.8-15.59}(e):null;n.push({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0,...null==r?{status:"not-applicable",message:"No description/summary text to grade."}:r>9?{status:"warn",message:`Description/summary reads at ~grade ${r.toFixed(0)}; Chartability targets grade 9 or lower.`,fix:"Shorten sentences and prefer common words."}:{status:"pass",message:`Description/summary reads at ~grade ${Math.max(0,Math.round(r))} (≤ 9).`}})}if(Cr.has(e)){const e=Hr(t.xLabel),r=Hr(t.yLabel);n.push({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1,...e&&r?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!r&&"yLabel"].filter(Boolean).join(", ")}. Ticks alone may not name the variable.`,fix:"Set xLabel and yLabel to name each axis's variable and units."}})}if(Nr.has(e)&&n.push({id:"understandable.information-complexity",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,status:"warn",message:"Dual-axis chart: two y-scales are hard to read accurately and notoriously easy to misinterpret (the crossover point is arbitrary).",fix:"Confirm the second axis is necessary; consider two aligned charts (small multiples) or indexing both series to a common baseline. Label each axis and its series unambiguously."}),C.length>1){const e=C.filter(qr).length;n.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===C.length?{status:"pass",message:`All ${C.length} annotation(s) declare hierarchy through emphasis or provenance confidence, so the renderer can resolve reading order and visual priority.`}:0===e?{status:"warn",message:C.length+" annotations are present with no emphasis or provenance confidence; readers may not know which note is primary.",fix:'Mark the main annotation with emphasis="primary", set supporting notes to emphasis="secondary", or provide provenance.confidence so Semiotic can infer order.'}:{status:"warn",message:`${C.length-e} of ${C.length} annotation(s) have no emphasis or provenance confidence; readers may not know which note is primary among the unordered notes.`,fix:"Set emphasis on each annotation (primary/secondary), or provide provenance.confidence on all annotations so Semiotic can infer order."}})}(null!=t.forecast||null!=t.anomaly||null!=t.band||null!=t.regression)&&n.push({id:"understandable.uncertainty",principle:"understandable",heuristic:"Statistical uncertainty isn't clearly communicated",critical:!1,status:"manual",message:"The chart shows a forecast/regression/band/anomaly overlay. Confirm the uncertainty it represents is explained in text, not just drawn.",fix:"State the confidence interval / method in the summary, and label the band so it isn't mistaken for data."}),null!=t.animate&&!1!==t.animate&&n.push({id:"understandable.changes-followable",principle:"understandable",heuristic:"Changes are not easy to follow",critical:!1,status:k,message:`Transitions animate with object constancy and data changes are mirrored to the live region${S}.`,fix:i?"Keep transition durations in the 250ms–2s range so changes are followable but not slow.":void 0}),n.push({id:"robust.conforms-to-standards",principle:"robust",heuristic:"Does not conform to standards",critical:!1,status:"manual",message:"WCAG 2.1 / Section 508 conformance can't be settled from config alone.",fix:"Run an automated checker (axe) on the rendered output and test with real assistive tech."}),n.push({id:"robust.semantically-valid",principle:"robust",heuristic:"Semantically invalid",critical:!1,status:"manual",message:"Whether interactive elements expose correct roles/names is a render-time, screen-reader question.",fix:"Verify with a screen reader that buttons read as buttons, the chart as an image/group, etc."}),n.push({id:"robust.fragile-technology-support",principle:"robust",heuristic:"Fragile technology support",critical:!1,status:k,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${S}.`,fix:i?"Still test across NVDA+Firefox, JAWS+Chrome, and VoiceOver+Safari — AT support varies.":void 0}),n.push({id:"compromising.table",principle:"compromising",heuristic:"No table",critical:!0,...p?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:g?{status:"pass",message:"A human-readable data table is provided (accessibleTable)."}:{status:"fail",message:"accessibleTable is disabled — no human-readable table of the underlying data.",fix:"Remove accessibleTable={false} (unless title/summary/annotations already convey all the data)."}}),p||n.push({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1,...s?{status:"manual",message:"Rendered in a ChartContainer. If a data-download action is enabled, the data is exportable.",fix:"Enable the ChartContainer data-download action so users can save the underlying data (keep it opt-in)."}:{status:"warn",message:"The data table is read-only — not downloadable, sortable, or filterable.",fix:"Wrap the chart in a ChartContainer and enable its data-download action (opt-in, so deployments can withhold it where export isn't allowed)."}}),n.push({id:"compromising.shareable-state",principle:"compromising",heuristic:"State is not easy to share and reproduce",critical:!1,status:i?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${i?"":S}.`,fix:i?"Expose it to users via the ChartContainer copyConfig action or a shareable URL.":void 0}),n.push({id:"compromising.navigable-structure",principle:"compromising",heuristic:"Information cannot be navigated according to narrative or structure",critical:!1,...l?{status:"pass",message:"ChartContainer's navigable option mounts a structured tree (chart → axes/series → data points) that screen readers can traverse."}:u?{status:"warn",message:"Hierarchical chart: built-in keyboard navigation is largely flat — it doesn't descend the tree structure.",fix:"Enable ChartContainer's navigable option for a structured navigation tree, or lean on the data table and a summary that conveys the hierarchy."}:{status:k,message:`Keyboard navigation steps through points and switches series/groups${S}.`,fix:i?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}});{const r=Array.isArray(t.data)?t.data:null,a=Array.isArray(t.nodes)?t.nodes:null,o={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let i;i=wr.has(e)&&r&&r.length>7?{...o,status:"warn",message:r.length+" slices in a part-to-whole chart. Chartability suggests ≤ 5 categories; many thin slices are hard to perceive and to describe.",fix:'Group small slices into an "Other" category, or switch to a ranked bar chart.'}:a&&a.length>200?{...o,status:"warn",message:a.length+" nodes. A network this size is hard to navigate non-visually node by node.",fix:"Provide a summary of structure (clusters, hubs, components) and consider filtering or aggregating the graph."}:r&&r.length>5e3?{...o,status:"warn",message:r.length+" data points. Canvas renders this fine, but the non-visual table/navigation become unwieldy.",fix:"Aggregate or bin for the accessible representation, or expose summary statistics rather than every row."}:r?{...o,status:"pass",message:r.length+" data points — a reasonable density for non-visual consumption."}:a?{...o,status:"pass",message:a.length+" nodes — a reasonable density for non-visual consumption."}:{...o,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},n.push(i)}{const e=Array.isArray(t.data)?t.data:null,r=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let a=!1;if(e&&!r)for(const t of e.slice(0,50))if(t&&"object"==typeof t){for(const e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){a=!0;break}if(a)break}a&&n.push({id:"assistive.human-readable-numbers",principle:"assistive",heuristic:"Data in text is not human-readable",critical:!1,status:"warn",message:'Data includes large numbers (≥ 100,000) and no value/tick formatter — screen readers will read every digit (e.g. "six hundred fifty thousand…").',fix:'Pass valueFormat / yFormat (e.g. a compact formatter so 6,500,000 reads as "6.5M"); the formatter flows to ticks, tooltips, and the data table.'})}n.push({id:"assistive.features-described",principle:"assistive",heuristic:"Visually apparent features and relationships are not described",critical:!1,...c?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:m?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."}}),n.push({id:"assistive.skippable-navigation",principle:"assistive",heuristic:"Navigation and interaction is tedious",critical:!0,...p?{status:"not-applicable",message:"Single value — nothing to skip."}:g?{status:"pass",message:'A "Skip to data table" link lets screen-reader users bypass point-by-point navigation.'}:{status:"warn",message:"accessibleTable is off, removing the skip-to-table affordance.",fix:"Keep accessibleTable enabled so users can skip past dense point navigation."}}),n.push({id:"flexible.user-style-respected",principle:"flexible",heuristic:"User style change not respected",critical:!0,status:k,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${S}.`,fix:i?"Avoid hardcoding colors via frameProps style fns that bypass theme variables.":void 0}),n.push({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...Sr.has(e)||Tr.has(e)?v?{status:"pass",message:e+" animates continuously and declares an in-chart pause/stop control."}:{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:k,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${S}.`}}),o&&(n.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...v?{status:"pass",message:"Physics simulation exposes a pause/stop control for users who need to stop motion."}:{status:"warn",message:"Physics simulation has no declared pause/stop control.",fix:"Provide a visible pause control and set physics.pauseControl=true (or pauseControl=true) so the contract is auditable."}}),n.push({id:"flexible.settled-projection",principle:"flexible",heuristic:"User style change not respected",critical:!1,...x?{status:"pass",message:"A settled-projection table is declared, so non-visual readers get aggregate chart semantics instead of trajectories."}:{status:"warn",message:"Physics chart does not declare a settled projection for its accessible table.",fix:"Provide aggregate rows from the settled projection and set physics.settledProjection=true."}}),n.push({id:"flexible.reduced-motion-settle",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...A?{status:"pass",message:"Reduced-motion mode settles the simulation to a static chart state instead of freezing bodies mid-flight."}:{status:"warn",message:"Physics chart does not declare reduced-motion synchronous settle behavior.",fix:"In reduced motion, run the world to its settled projection and paint once; set physics.reducedMotionSettle=true."}}));{const r=!0===t.responsiveWidth||!0===t.responsiveHeight,a=Rr.has(e)&&!0===t.zoomable;n.push({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1,...r?{status:"pass",message:`Chart reflows to its container (${[!0===t.responsiveWidth&&"responsiveWidth",!0===t.responsiveHeight&&"responsiveHeight"].filter(Boolean).join(", ")}), so page zoom doesn't clip it.`}:a?{status:"pass",message:"Geo chart is zoomable/pannable."}:{status:"manual",message:"Fixed width/height — verify the chart survives browser zoom and reflow without clipping or loss of function.",fix:"Use responsiveWidth/responsiveHeight so the chart reflows to its container."}})}if(a){const e=a.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));e&&n.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:a.name+" declares a color encoding without a redundant cue.",fix:"Add shape, label, position, texture, or a textual category summary to the recipe encoding."}),"required"!==a.accessibility.description||Hr(t.description)||n.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:a.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),a.accessibility.fallbackTable&&!1===t.accessibleTable&&n.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:a.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."})}const P=n.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),j={criticalsPassed:P.filter(e=>"pass"===e.status).length,criticalsEvaluated:P.length,fails:n.filter(e=>"fail"===e.status).length,warnings:n.filter(e=>"warn"===e.status).length,manual:n.filter(e=>"manual"===e.status).length,passes:n.filter(e=>"pass"===e.status).length};return{component:e,ok:!P.some(e=>"fail"===e.status),summary:j,findings:n,reference:"Chartability (POUR-CAF) — https://chartability.github.io/POUR-CAF/. Not a pass/fail cert; pair with manual screen-reader testing (NVDA+Firefox, JAWS+Chrome, VoiceOver+Safari)."}}function Yr(e,{onlyCritical:t=!1}={}){const r=[];for(const n of e.findings)"fail"!==n.status&&"warn"!==n.status||t&&!n.critical||r.push(n.message);return r}var Xr={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},Kr=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function Qr(e){const t=[],r=e.summary,n=e.ok?`${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`:`${r.fails} blocking failure(s) — ${r.criticalsPassed}/${r.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${n} · ${r.warnings} warning(s) · ${r.manual} to verify manually`);for(const r of Kr){const n=e.findings.filter(e=>e.principle===r&&"not-applicable"!==e.status);if(0!==n.length){t.push(""),t.push(" "+r.toUpperCase());for(const e of n)t.push(` ${Xr[e.status]} ${e.id}${e.critical?" [critical]":""}: ${e.message}`),!e.fix||"fail"!==e.status&&"warn"!==e.status&&"manual"!==e.status||t.push(" → "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}import{useCallback as Jr,useMemo as Zr,useRef as en,useState as tn}from"react";var rn=/^\d{4}[-/]\d{2}/,nn=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function an(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?rn.test(e)&&!Number.isNaN(Date.parse(e))?"date":nn.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function on(e){let t=1/0,r=-1/0;for(let n=0;e.length>n;n++){const a=e[n];t>a&&(t=a),a>r&&(r=a)}return{min:t,max:r}}function sn(e){const t=e.length;if(0===t)return NaN;const r=t>>1;return t%2==0?(e[r-1]+e[r])/2:e[r]}function cn(e,t={}){const{maxDistinct:r=10,sampleSize:n=5,keyScanRows:a=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const o=new Set,i=Math.min(e.length,a);for(let t=0;i>t;t++){const r=e[t];if(r&&"object"==typeof r)for(const e of Object.keys(r))o.add(e)}const s={};for(const t of o){const n=[];for(let r=0;e.length>r;r++){const a=e[r]?.[t];null!=a&&n.push(a)}if(0===n.length){s[t]={type:"unknown"};continue}const a=an(n[0]);if("numeric"===a){const e=[];for(let t=0;n.length>t;t++){const r=Number(n[t]);Number.isFinite(r)&&e.push(r)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:a}=on(e);let o=0;for(let t=0;e.length>t;t++)o+=e[t];const i=[...e].sort((e,t)=>e-t);s[t]={type:"numeric",min:r,max:a,mean:o/e.length,median:sn(i)}}else if("date"===a){const e=[];for(let t=0;n.length>t;t++){const r=n[t],a=r instanceof Date?r.getTime():Date.parse(r);Number.isFinite(a)&&e.push(a)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:r,max:a}=on(e);s[t]={type:"date",min:new Date(r).toISOString(),max:new Date(a).toISOString()}}else if("categorical"===a){const e=new Map;for(let t=0;n.length>t;t++){const r=n[t]+"";e.set(r,(e.get(r)??0)+1)}const a=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,r).map(([e,t])=>({value:e,count:t}));s[t]={type:"categorical",distinctCount:e.size,topValues:a,distinctValues:e.size>r?void 0:a.map(e=>e.value)}}else s[t]={type:"unknown"}}return{rowCount:e.length,fields:s,sample:e.slice(0,n)}}var ln=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,pn=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,un=/(size|magnitude|volume|weight|count|amount)/i,dn=/^(category|label|name|type|group|region|segment|kind|class)$/i,yn=/^(series|group|type|category|segment|cohort|product)$/i,mn=new Set(["numeric"]),hn=new Set(["numeric","date"]),gn=new Set(["numeric"]),bn=new Set(["date"]),fn=new Set(["categorical","boolean"]);function vn(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function wn(e,t){return t.test(e)?.2:0}function xn(e,t){let r=null;for(let n=0;e.length>n;n++){const a=e[n]?.[t];if(null==a)continue;const o=a instanceof Date?a.getTime():Number(a);if(!Number.isFinite(o))return!1;if(null!==r&&r>o)return!1;r=o}return null!==r}function An(e,t,r,n,a={}){const o=[];for(const[i,s]of Object.entries(e)){const e=vn(s);if(!r.has(e))continue;let c,l=.5;l+=wn(i,n),"categorical"===s.type&&(c=s.distinctCount,!c||2>c||c>12||(l+=.2),c&&c>50&&(l-=.2)),"numeric"===s.type&&Number.isFinite(s.min)&&Number.isFinite(s.max)&&s.max>s.min&&(l+=.1);const p={field:i,kind:e,quality:Math.max(0,Math.min(1,l)),distinctCount:c};!a.computeMonotonic||"numeric"!==e&&"date"!==e||(p.monotonic=xn(t,i),p.monotonic&&(p.quality=Math.min(1,p.quality+.2))),o.push(p)}return o.sort((e,t)=>t.quality-e.quality),o}function Cn(e,t){const r=new Set;for(let n=0;e.length>n;n++){const a=e[n]?.[t];null!=a&&r.add(a+"")}return r.size}var kn=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,Sn=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,Pn=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,jn=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,Tn=/^(value|weight|amount|count|magnitude|volume)$/i;function Nn(e,t){return e.find(e=>t.test(e))}function Rn(e,t={}){const r=cn(e??[]),n=Array.isArray(e)?e:[],a=function(e){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;if("FeatureCollection"===t.type&&Array.isArray(t.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:t.features,points:Array.isArray(t.points)?t.points:void 0,flows:Array.isArray(t.flows)?t.flows:void 0}};if(Array.isArray(t.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:t};if(Array.isArray(t.nodes)&&(Array.isArray(t.edges)||Array.isArray(t.links)))return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:t.nodes,edges:t.edges??t.links}}}return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!1}}(t.rawInput);if(!a.hasNetwork&&!a.hasHierarchy&&!a.hasGeo){const e=function(e){if(3>e.length)return null;const t=e[0];if(!t||"object"!=typeof t)return null;const r=Object.keys(t),n=Nn(r,kn),a=Nn(r,Sn);if(!n||!a||n===a)return null;const o=Nn(r,Pn),i=Nn(r,jn),s=Nn(r,Tn),c=[];for(const t of e){if(!t)continue;const e=t[n],r=t[a];if(null==e||null==r)continue;const o=(e+"").trim(),i=(r+"").trim();o&&i&&o!==i&&c.push(t)}if(3>c.length)return null;const l=new Map,p=new Map,u=new Map;for(const e of c){const t=(e[n]+"").trim(),r=(e[a]+"").trim();l.has(t)||l.set(t,{id:t,label:t}),l.has(r)||l.set(r,{id:r,label:r});const c=`${t}->${r}`,d=s?Number(e[s]):1,y=Number.isFinite(d)?d:1;p.set(c,(p.get(c)??0)+y),u.has(c)||u.set(c,{source:t,target:r,...o?{startTime:e[o]}:{},...i?{endTime:e[i]}:{}})}const d=[];for(const[e,t]of u)d.push({...t,value:p.get(e)??1});return{nodes:Array.from(l.values()),edges:d}}(n);e&&(a.hasNetwork=!0,a.network=e)}const o=An(r.fields,n,hn,ln,{computeMonotonic:!0}),i=An(r.fields,n,gn,pn),s=An(r.fields,n,mn,un),c=An(r.fields,n,fn,dn),l=An(r.fields,n,fn,yn),p=An(r.fields,n,bn,/(date|time|timestamp)/i,{computeMonotonic:!0}),u=p[0]?.field;let d=u,y=u?"time":"none";if(!d){const e=o.find(e=>ln.test(e.field)&&"numeric"===e.kind);e&&(d=e.field,y="named")}const m=i.find(e=>e.field!==d)?.field;if(!d&&m){const e=Object.entries(r.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(d=e.find(e=>e!==m),d&&(y="scatter"))}const h=s.find(e=>e.field!==d&&e.field!==m)?.field,g="time"===y||"named"===y,b=c.map(e=>e.field);let f,v;g?(v=t.seriesField??b[0],f=b.find(e=>e!==v)):(f=b[0],v=t.seriesField??b.find(e=>e!==f));const w=f?Cn(n,f):void 0,x=v?Cn(n,v):void 0,A=d?Cn(n,d):void 0,C=!!d&&function(e,t){const r=new Set;for(let n=0;e.length>n;n++){const a=e[n]?.[t];if(null==a)continue;const o=a+"";if(r.has(o))return!0;r.add(o)}return!1}(n,d),k=o.find(e=>e.field===d)?.monotonic??!1,S=p.length>0;return{...r,data:n,candidates:{x:o,y:i,size:s,category:c,series:l,time:p},primary:{x:d,y:m,size:h,category:f,series:v,time:u},categoryCount:w,seriesCount:x,uniqueXCount:A,hasRepeatedX:C,monotonicX:k,hasTimeAxis:S,hasHierarchy:a.hasHierarchy,hasNetwork:a.hasNetwork,hasGeo:a.hasGeo,xProvenance:y,network:a.network,hierarchy:a.hierarchy,geo:a.geo}}var $n={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},In=["tiny","small","medium","large","huge"];function Mn(e){return{rows:{...$n.rows,...e?.rows??{}},cardinality:{...$n.cardinality,...e?.cardinality??{}},fields:{...$n.fields,...e?.fields??{}}}}function Bn(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const r=Mn(t?.thresholds).rows;return e>r.tiny?e>r.small?e>r.medium?e>r.large?"huge":"large":"medium":"small":"tiny"}function En(e,t){if(!Number.isFinite(e)||0>e)return"low";const r=Mn(t?.thresholds).cardinality;return e>r.low?e>r.medium?"high":"medium":"low"}function Fn(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const r=Mn(t?.thresholds).fields;return e>r.narrow?e>r.typical?"wide":"typical":"narrow"}function Ln(e,t){return In.indexOf(e)-In.indexOf(t)}function Dn(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Mn(r?.thresholds).rows;switch(e){case"tiny":return Math.max(1,Math.floor(t.tiny/2));case"small":return Math.floor((t.tiny+t.small)/2);case"medium":return Math.floor((t.small+t.medium)/2);case"large":return Math.floor((t.medium+t.large)/2);case"huge":return Math.floor(2*t.large)}}return t}function _n(e,t,r){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=Mn(r?.thresholds).cardinality;switch(e){case"low":return Math.max(1,Math.floor(t.low/2));case"medium":return Math.floor((t.low+t.medium)/2);case"high":return Math.floor(2*t.medium)}}return t}function On(e,t){const r=e.rowCount??0,n=t?.rows,a=Dn(n,r,t),o=Bn(a,t),i=Object.keys(e.fields??{}).length,s=t?.fields,c="number"==typeof s?s:"string"==typeof s?function(e,t){const r=Mn(t?.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(r.narrow/2));case"typical":return Math.floor((r.narrow+r.typical)/2);case"wide":return Math.floor(2*r.typical)}}(s,t):i,l=Fn(c,t),p=e.primary.category,u=_n((p?t?.cardinality?.[p]:void 0)??t?.typicalCardinality,e.categoryCount,t);return{rows:a,rowBand:o,fields:c,fieldBand:l,typicalCardinality:u,cardinalityBand:void 0!==u?En(u,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==n?"declared":"measured"}}var zn=2.5;function Hn(e,t,r,n,a){const o=[],i=[];let s=0,c=!1;if(e.scaleFit){const a=e.scaleFit(t,r,n);if(a&&(s+=Math.max(-2.5,Math.min(zn,a.delta??0)),a.reason&&o.push(a.reason),a.caveats))for(const e of a.caveats)i.push(e)}const l=n?.charts?.[e.component];if(l&&(l.minBand&&0>Ln(r.rowBand,l.minBand)||l.maxBand&&Ln(r.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(s+=Math.max(-3,Math.min(3,l.bias)),l.reason&&o.push(`${n?.name?n.name+": ":""}${l.reason}`)):l.reason&&o.push(`${n?.name?n.name+": ":""}${l.reason}`)),a&&e.qualityFit){const r=e.qualityFit(t,a);if(r&&(s+=Math.max(-1,Math.min(1,r.delta??0)),r.reason&&o.push(r.reason),r.caveats))for(const e of r.caveats)i.push(e)}else if(a){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const r=e[t];return"number"==typeof r?r:void 0}(a.completeness,e);void 0!==t&&.85>t&&i.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:s,reasons:o,caveats:i,excluded:c}}function Gn(e){return(t,r)=>{let n=0;const a=[];let o;if(e.rows){const[t,i]=e.rows.sweetSpot;t>r.rows||r.rows>i?t>r.rows?(n-=Math.min(zn,.8*(0===t?1:(t-r.rows)/t)),void 0===e.rows.caveatBelow||r.rows>e.rows.caveatBelow||a.push(`only ${r.rows} rows — chart may feel sparse`)):(n-=Math.min(zn,.4*(0===i?1:(r.rows-i)/i)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>r.rows||a.push(r.rows+" rows is past this chart's comfortable density")):(n+=.6,o=r.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==r.typicalCardinality){const t=r.typicalCardinality,[o,i]=e.cardinality.sweetSpot;o>t||t>i?t>i&&(n-=Math.min(zn,.5*(0===i?1:(t-i)/i)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||a.push(t+" distinct categories may overwhelm this chart")):n+=.4}return 0!==n||0!==a.length||o?{delta:n,reason:o,caveats:a}:null}}var qn={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},fits:e=>{if(2>e.rowCount)return"needs at least 2 rows";if(!e.primary.x)return"needs a numeric or time x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return t&&"numeric"!==t&&"date"!==t?`x field "${e.primary.x}" is ${t}, LineChart needs numeric or time`:"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence"},intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?!e.uniqueXCount||4>e.uniqueXCount?3:!e.seriesCount||2>e.seriesCount?4:5:1,"compare-series":e=>"scatter"!==e.xProvenance||e.monotonicX?!e.seriesCount||2>e.seriesCount?1:e.seriesCount>8?2:4:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?4:1,"outlier-detection":2,correlation:2},caveats:e=>{const t=[];return!e.hasRepeatedX||e.seriesCount&&e.seriesCount>=2||t.push("x values repeat — consider aggregating or adding a series field"),e.seriesCount&&e.seriesCount>8&&t.push(e.seriesCount+" series may produce a spaghetti chart"),t},variants:[{key:"linear",label:"Linear trend",props:{curve:"linear",showPoints:!1},tags:["linear"]},{key:"smooth",label:"Smooth trend",description:"Monotone smoothing — emphasizes the shape over individual points.",props:{curve:"monotoneX",showPoints:!1},tags:["smooth","narrative"],intentDeltas:{trend:1,"outlier-detection":-2},rubricDeltas:{precision:-1},caveats:["smoothing hides individual outliers"]},{key:"stepped-with-points",label:"Discrete steps",description:"Step curve plus visible points — for state changes or discrete events.",props:{curve:"step",showPoints:!0,pointRadius:3},tags:["step","discrete"],intentDeltas:{"change-detection":1,trend:-1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or band turns the chart from a report into an alert — read it for breaches of the expected range. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the chart\'s communicative act becomes "alerting".',props:{showGrid:!0,showPoints:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(r.lineBy=e.primary.series,r.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:Gn({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},Vn={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>3>e.rowCount?"needs at least 3 rows":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a numeric or time x field",intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?e.seriesCount&&e.seriesCount>=2||!e.uniqueXCount||4>e.uniqueXCount?3:5:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?3:1},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&t.push(`showing only the leading "${e.primary.series}" series — for multi-series comparison use LineChart or DifferenceChart`),t},variants:[{key:"smooth",label:"Smooth gradient",props:{curve:"monotoneX"},tags:["smooth","gradient","narrative"]},{key:"linear",label:"Linear",props:{curve:"linear",gradientFill:!1,areaOpacity:.5},tags:["linear"]},{key:"stepped",label:"Stepped",props:{curve:"stepAfter"},tags:["step"],intentDeltas:{"change-detection":1}},{key:"annotated-threshold",label:"With alert threshold",description:'A reference threshold or expected band turns the area into an alert — read for breaches. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2,"change-detection":1}}],buildProps:(e,t)=>{let r=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,n=e.primary.y,a=new Map;for(const r of e.data){const e=r[t];if(null==e||""===e)continue;const o=Number(r[n]);a.set(e,(a.get(e)??0)+(Number.isFinite(o)?o:0))}let o,i=-1/0;for(const[e,t]of a)t>i&&(i=t,o=e);null!=o&&a.size>0&&(r=e.data.filter(e=>e[t]===o))}const n={data:r,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:!0,areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(n.xScaleType="time"),{...n,...t?.props??{}}},scaleFit:Gn({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},Wn={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.y?!e.seriesCount||2>e.seriesCount?"needs 2+ stack groups (series field)":e.seriesCount>10?e.seriesCount+" series is too many to stack legibly":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — stacking only makes sense across a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{"composition-over-time":5,"part-to-whole":e=>e.hasTimeAxis?4:3,trend:3,"compare-series":2},caveats:()=>["readability of individual layers degrades below the baseline"],variants:[{key:"baseline-zero",label:"Zero baseline",props:{baseline:"zero",stackOrder:"key"},tags:["zero-baseline"]},{key:"streamgraph",label:"Streamgraph",description:"Wiggle baseline + inside-out ordering — emphasizes momentum over precise totals.",props:{baseline:"wiggle",stackOrder:"insideOut",showLine:!1},tags:["streamgraph","narrative"],intentDeltas:{"composition-over-time":0,trend:1,"part-to-whole":-2},rubricDeltas:{accuracy:-1,precision:-1},caveats:["streamgraph hides absolute totals; precise reads not possible"]},{key:"centered",label:"Centered baseline",props:{baseline:"silhouette",stackOrder:"insideOut"},tags:["silhouette"],intentDeltas:{"part-to-whole":-1}}],buildProps:(e,t)=>{const r={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,areaBy:e.primary.series,colorBy:e.primary.series};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),{...r,...t?.props??{}}},scaleFit:Gn({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},Un={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},fits:e=>{if(3>e.rowCount)return"needs at least 3 rows";if(!e.primary.x)return"needs a numeric x field";if(!e.primary.y)return"needs a numeric y field";const t=e.candidates.x.find(t=>t.field===e.primary.x)?.kind;return"date"===t?null:t&&"numeric"!==t?`x field "${e.primary.x}" is ${t}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2||e.primary.size?4:5},"outlier-detection":5,distribution:3,"compare-series":e=>!e.seriesCount||2>e.seriesCount||e.seriesCount>6?1:3,rank:1},variants:[{key:"points",label:"Points only",props:{},tags:["points"]},{key:"with-trend",label:"Points with regression line",props:{regression:"linear"},tags:["regression","trend"],intentDeltas:{correlation:0,trend:1}}],buildProps:(e,t)=>{const r={data:e.data},n="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,a=n?e.candidates.y.filter(e=>e.field!==n).map(e=>e.field):[];return n&&a.length>=2?(r.xAccessor=a[0],r.yAccessor=a[1]):(r.xAccessor=e.primary.x,r.yAccessor=e.primary.y,e.primary.size&&(r.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(r.colorBy=e.primary.series),{...r,...t?.props??{}}},scaleFit:Gn({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},Yn={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 ordered points":e.primary.x?e.primary.y?e.monotonicX||e.hasTimeAxis?null:"needs an ordered x sequence":"needs a y field":"needs an x field",intentScores:{trend:3,correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&r.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{const t={data:e.data},r="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,n=r?e.candidates.y.filter(e=>e.field!==r).map(e=>e.field):[];return r&&n.length>=2?(t.xAccessor=n[0],t.yAccessor=n[1],t.orderAccessor=r):(t.xAccessor=e.primary.x,t.yAccessor=e.primary.y,t.orderAccessor=e.primary.time??e.primary.x),e.primary.series&&6>=(e.seriesCount??0)&&(t.colorBy=e.primary.series),t}},Xn={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?e.primary.size?null:"needs a third numeric measure for bubble size":"needs a numeric y field":"needs a numeric x field",intentScores:{correlation:5,"compare-categories":3,"outlier-detection":4},caveats:()=>["bubble area is harder to compare than length — large dynamic ranges distort"],buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,sizeBy:e.primary.size,...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{}}),scaleFit:Gn({rows:{sweetSpot:[10,500],caveatAbove:1500}})},Kn={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?null:"needs a numeric y field":"needs a numeric x field",intentScores:{"compare-categories":2,correlation:3,"outlier-detection":3},buildProps:e=>{const t=e.primary.x,r=e.primary.y,n=e.fields[t],a=e.fields[r],o="numeric"===n?.type?n.median:void 0,i="numeric"===a?.type?a.median:void 0;return{data:e.data,xAccessor:t,yAccessor:r,...void 0!==o?{xCenter:o}:{},...void 0!==i?{yCenter:i}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...Ne.topLeft},topRight:{...Ne.topRight},bottomLeft:{...Ne.bottomLeft},bottomRight:{...Ne.bottomRight}}}}},Qn={component:"MultiAxisLineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?2>Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).map(([e])=>e).length?"needs at least 2 numeric measures":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — multi-axis lines need a shared sequence":"needs an x field",intentScores:{"compare-series":4,trend:3,correlation:3},caveats:()=>["dual axes can mislead — only use when measures share interpretation"],buildProps:e=>{const t=Object.entries(e.fields).filter(([t,r])=>"numeric"===r.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},Jn={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},fits:e=>30>e.rowCount?"minimap pays off only on long sequences (30+ rows)":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — minimap previews a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{trend:4,"change-detection":4,"outlier-detection":3},buildProps:e=>({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,...e.hasTimeAxis&&e.primary.x===e.primary.time?{xScaleType:"time"}:{}})},Zn={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.series?!e.seriesCount||2>e.seriesCount?`needs 2+ series (got ${e.seriesCount??0})`:e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a series field with at least two groups":"needs an x field (numeric or time)",intentScores:{"compare-series":e=>2===e.seriesCount?5:3,"change-detection":4,trend:3},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>2&&t.push(`showing the top 2 of ${e.seriesCount} series — for full multi-series comparison use LineChart`),t},buildProps:e=>{const t=e.primary.x,r=e.primary.y,n=e.primary.series,a=e=>null!=e&&(e+"").length>0,o=new Map;for(const t of e.data){const e=t[n];if(!a(e))continue;const i=e+"",s=Number(t[r]);o.set(i,(o.get(i)??0)+(Number.isFinite(s)?s:0))}const i=[...o.entries()].sort((e,t)=>t[1]-e[1]),s=i[0]?.[0],c=i[1]?.[0],l=e=>e instanceof Date?e.getTime():e,p=new Map;for(const o of e.data){const e=o[n];if(!a(e))continue;const i=e+"";if(i!==s&&i!==c)continue;const u=o[t],d=o[r],y=l(u);let m=p.get(y);m||(m={[t]:u},p.set(y,m)),i===s?m.a=d:i===c&&(m.b=d)}return{data:Array.from(p.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:t,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:s,seriesBLabel:c}}},ea={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.x)return"needs an x field (typically date)";const t=new Set(Object.keys(e.fields).map(e=>e.toLowerCase())),r=t.has("high"),n=t.has("low");return r&&n?null:"needs at minimum high/low fields (open/close optional)"},intentScores:{"change-detection":4,trend:3,"outlier-detection":3},buildProps:e=>{const t=Object.keys(e.fields),r=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:r("high"),lowAccessor:r("low"),openAccessor:r("open"),closeAccessor:r("close")}}},ta={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>{if(4>e.rowCount)return"needs at least 4 cells";if(!e.primary.y)return"needs a numeric value to encode in cell color";const t=e.candidates.category.length;return t>=2||t>=1&&e.hasTimeAxis?(e.uniqueXCount??0)>50?"too many x cells for a legible heatmap":null:"needs two categorical-or-time dimensions for the axes"},intentScores:{correlation:3,distribution:2,"compare-categories":e=>2>e.candidates.category.length?1:4,"composition-over-time":e=>e.hasTimeAxis&&e.candidates.category.length>=1?4:1},caveats:e=>{const t=[];return(e.uniqueXCount??0)>30&&t.push("many x values — cells will be narrow"),t},variants:[{key:"default",label:"Sequential color",props:{},tags:["sequential"]},{key:"show-values",label:"With cell labels",props:{showValues:!0},tags:["labeled"],intentDeltas:{"compare-categories":1},rubricDeltas:{precision:1},caveats:["cell labels crowd dense matrices"]}],buildProps:(e,t)=>{const r=e.candidates.category.map(e=>e.field),n=e.primary.time??r[0],a=r.find(e=>e!==n)??r[0]??e.primary.series;return{data:e.data,xAccessor:n,yAccessor:a,valueAccessor:e.primary.y,...t?.props??{}}},scaleFit:Gn({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},ra=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,na=/^(jan|feb|mar|apr|may|jun|jul|aug|sep|sept|oct|nov|dec|january|february|march|april|june|july|august|september|october|november|december|mon|tue|wed|thu|fri|sat|sun|monday|tuesday|wednesday|thursday|friday|saturday|sunday)\b/i,aa=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,oa={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},fits:e=>e.primary.category?e.primary.y?1>(e.categoryCount??0)?"needs at least 1 category":(e.categoryCount??0)>50?"too many categories — consider aggregating or use a different chart":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?2>e.candidates.category.length?10>e.rowCount/e.categoryCount?5:2:3:0,rank:5,"part-to-whole":e=>(e.categoryCount??0)>8?2:3,distribution:1},caveats:e=>{const t=[];return function(e){const t=e.primary.category;if(!t)return!1;const r=t.replace(/([a-z])([A-Z])/g,"$1 $2");if(ra.test(r))return!0;const n=e.data;if(!n||0===n.length)return!1;let a=0,o=0;for(const e of n){const r=e[t];if(null==r)continue;o++;const n=(r+"").trim();(na.test(n)||aa.test(n))&&a++}return o>0&&a/o>=.6}(e)&&t.push("category axis looks like time bins — for a time series, supply real dates and use LineChart/AreaChart (reads trend, scales the time axis); for streaming counts use a temporal histogram"),t},variants:[{key:"sorted-desc",label:"Ranked",props:{sort:"desc"},tags:["sorted","ranked"],intentDeltas:{rank:0,"compare-categories":0}},{key:"source-order",label:"Source order",props:{sort:!1},tags:["source-order"],intentDeltas:{rank:-2}},{key:"horizontal",label:"Horizontal bars",props:{orientation:"horizontal",sort:"desc"},tags:["horizontal","ranked"],intentDeltas:{rank:1},rubricDeltas:{precision:1}},{key:"annotated-threshold",label:"With alert threshold",description:'A target/threshold reference turns the bars into an alert — read for which categories breach. Pair with a provenanced annotation (e.g. from the data-quality bridge) and the communicative act becomes "alerting".',props:{showGrid:!0},tags:["alert","annotated-threshold","monitoring"],intentDeltas:{"outlier-detection":2}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:Gn({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},ia={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ groups":(e.seriesCount??0)>6?e.seriesCount+" groups is too many for grouped bars":(e.categoryCount??0)>25?"too many categories for grouped bars":null:"needs a series field to group by":"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":5,"compare-series":4,rank:3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,groupBy:e.primary.series,colorBy:e.primary.series})},sa={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?e.primary.series?2>(e.seriesCount??0)?"needs 2+ stack groups":(e.seriesCount??0)>8?e.seriesCount+" stacked groups is too many":null:"needs a series field to stack by":"needs a numeric value field":"needs a category field",intentScores:{"part-to-whole":4,"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":2},caveats:()=>["only the bottom segment shares a baseline; others are harder to compare across categories"],variants:[{key:"absolute",label:"Absolute stacks",props:{normalize:!1},tags:["absolute"]},{key:"normalized",label:"100% stacked",description:"Each bar normalized to 1 — emphasizes composition, hides totals.",props:{normalize:!0},tags:["normalized","part-to-whole"],intentDeltas:{"part-to-whole":1,"compare-categories":-1},caveats:["absolute magnitudes are no longer comparable across bars"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series,...t?.props??{}})},ca={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>30?"too many categories for a dot plot":null:"needs a numeric value field":"needs a category field",intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"outlier-detection":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y}),scaleFit:Gn({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},la={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a pie chart":null},intentScores:{"part-to-whole":4,"compare-categories":2,rank:1},caveats:()=>["angle comparisons are less accurate than length — prefer a bar chart unless part-to-whole is the explicit message"],variants:[{key:"pie",label:"Pie",props:{},tags:["pie"]},{key:"donut",label:"Donut",description:"Hollow center — easier to fit a label or KPI inside.",props:{innerRadius:60},tags:["donut"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:Gn({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},pa={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>{if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const t=e.categoryCount??0;return 2>t?"needs 2+ categories":t>8?t+" slices is too many for a donut":null},intentScores:{"part-to-whole":4,"compare-categories":2},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,innerRadius:40})},ua=/(stage|step|funnel|status|outcome|phase)/i,da={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.primary.y?Object.keys(e.fields).find(e=>ua.test(e))?null:"needs a stage/step/funnel-named field":"needs a numeric value field",intentScores:{flow:4,rank:3,"part-to-whole":2},caveats:()=>["readers infer conversion drop-off — make sure rows actually represent sequential stages"],buildProps:e=>{const t=Object.keys(e.fields).find(e=>ua.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},ya={component:"GaugeChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:2,precision:2},fits:e=>e.rowCount>1?"GaugeChart shows a single value — provide a 1-row dataset or use BarChart":e.primary.y?null:"needs a numeric value",intentScores:{"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,r=e.data[0],n=r?Number(r[t]):0,a=e.fields[t],o="numeric"===a?.type?a.max:100;return{value:Number.isFinite(n)?n:0,min:0,max:o}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},ma=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,ha={component:"LikertChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?Object.keys(e.fields).find(e=>ma.test(e))?null:"needs an ordinal rating/level field (rating, score, level...)":"needs a numeric rating/count field":"needs a category (question) field",intentScores:{"compare-categories":4,distribution:3,"part-to-whole":3},buildProps:e=>{const t=Object.keys(e.fields).find(e=>ma.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},ga={component:"SwimlaneChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.category?e.primary.series?e.primary.y?2>(e.categoryCount??0)?"needs 2+ categories":null:"needs a numeric value field":"needs a sub-category (lane) field":"needs a category field",intentScores:{"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,subcategoryAccessor:e.primary.series,valueAccessor:e.primary.y,colorBy:e.primary.series})},ba={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{if(10>e.rowCount)return"histograms need at least ~10 observations";if(!e.primary.y)return"needs a numeric field to bin";const t=e.primary.y,r=e.candidates.y.find(e=>e.field===t);return void 0!==r?.distinctCount&&6>r.distinctCount?"too few distinct numeric values; a bar chart of counts is a better fit":null},intentScores:{distribution:5,"outlier-detection":3,"compare-categories":1},variants:[{key:"count-bins",label:"Count bins",props:{bins:10,relative:!1},tags:["count"]},{key:"share-bins",label:"Share bins (relative)",props:{bins:10,relative:!0},tags:["share"],intentDeltas:{distribution:0}}],buildProps:(e,t)=>({data:e.data,valueAccessor:e.primary.y,...t?.props??{}})},fa={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.primary.y?e.primary.category?3>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 3+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4,"outlier-detection":4},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},va={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>e.primary.y?e.primary.category?4>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 4+ observations per category":e.rowCount>2e3?"too many points for a swarm — consider a violin or box":null:"needs a category":"needs a numeric field",intentScores:{distribution:4,"outlier-detection":5,"compare-categories":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...e.primary.series&&e.primary.series!==e.primary.category?{colorBy:e.primary.series}:{}})},wa={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.y?e.primary.category?6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category to split distributions":"needs a numeric field",intentScores:{distribution:5,"compare-categories":4},variants:[{key:"density",label:"Density only",props:{showIQR:!1},tags:["density"]},{key:"density-iqr",label:"Density with IQR",props:{showIQR:!0},tags:["density","iqr"],intentDeltas:{distribution:0},rubricDeltas:{precision:1}}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}})},xa={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},fits:e=>e.primary.y?e.primary.category?3>(e.categoryCount??0)?"needs 3+ categories to make a ridgeline meaningful":6>e.rowCount/Math.max(e.categoryCount??1,1)?"needs 6+ observations per category":null:"needs a category dimension to stack distributions":"needs a numeric field",intentScores:{distribution:4,"compare-categories":3,"composition-over-time":2},caveats:()=>["readers can confuse overlapping ridges — limit categories or use small multiples"],buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},Aa={component:"ForceDirectedGraph",family:"network",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.nodes.length?"needs at least 2 nodes":1>e.network.edges.length?"needs at least 1 edge":null:"needs a {nodes, edges} network passed via rawInput",intentScores:{flow:3,correlation:2},caveats:e=>(e.network?.nodes.length??0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}),scaleFit:e=>{const t=e.network?.nodes.length??0;return 5>t?{delta:-.4,caveats:[`only ${t} nodes — force layout is overkill for this size`]}:t>100?t>300?{delta:-.8,caveats:[t+" nodes — expect a hairball; filter or aggregate before rendering"]}:{delta:0}:{delta:.5,reason:t+" nodes is in the readable range for force layout"}}},Ca={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.edges.length?"needs 2+ weighted edges":null:"needs a {nodes, edges} network with edge weights",intentScores:{flow:5,"part-to-whole":3},buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"})},ka={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasNetwork&&e.network?3>e.network.nodes.length?"needs 3+ nodes":3>e.network.edges.length?"needs 3+ edges":null:"needs a {nodes, edges} network",intentScores:{flow:4},caveats:()=>["chord diagrams trade accuracy for symmetry; use Sankey if direction matters"],buildProps:e=>({nodes:e.network?.nodes??[],edges:e.network?.edges??[],valueAccessor:"value"})},Sa={component:"ProcessSankey",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>{if(!e.hasNetwork||!e.network)return"needs a {nodes, edges} network";const t=e.network.edges[0];return t?void 0===t.startTime&&void 0===t.start||void 0===t.endTime&&void 0===t.end?"edges need both startTime and endTime (or start/end) for a temporal sankey":null:"needs at least one edge with start/end times"},intentScores:{flow:5,"composition-over-time":4,"change-detection":3},buildProps:e=>{const t={nodes:e.network?.nodes??[],edges:e.network?.edges??[],pairing:"temporal",laneOrder:"crossing-min"},r=e.network?.edges[0];return r&&(void 0===r.startTime&&void 0!==r.start&&(t.startTimeAccessor="start"),void 0===r.endTime&&void 0!==r.end&&(t.endTimeAccessor="end")),t}},Pa={component:"TreeDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root (object with children) via rawInput",intentScores:{hierarchy:5},variants:[{key:"vertical-tree",label:"Vertical tree",props:{layout:"tree",orientation:"vertical"},tags:["vertical"]},{key:"horizontal-cluster",label:"Horizontal cluster",props:{layout:"cluster",orientation:"horizontal"},tags:["horizontal"]}],buildProps:(e,t)=>({data:e.hierarchy??{name:"root",children:[]},...t?.props??{}})};function ja(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+ja(t),0):1}var Ta={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?4>e.rowCount?"declared scale is too small to render a hierarchy meaningfully":null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":e=>e.hasHierarchy?5:4,"compare-categories":3},caveats:()=>["rectangle area comparisons are less precise than length — prefer a bar chart for ranking"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"}),scaleFit:(e,t)=>{const r=ja(e.hierarchy);let n=0;const a=[];let o;return 5>r?(n-=.5,a.push(`only ${r} leaves — treemap needs more cells to show structure`)):r>100?r>500&&(n-=.7,a.push(r+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(n+=.4,o=r+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(n-=.5,a.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:n,reason:o,caveats:a}}},Na={component:"CirclePack",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":3},caveats:()=>["circle area is harder to compare than rectangle area"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},valueAccessor:"value"})},Ra={component:"OrbitDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:1,accuracy:2,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root",intentScores:{hierarchy:3},caveats:()=>["decorative — readers without context will not infer hierarchy easily"],buildProps:e=>({data:e.hierarchy??{name:"root",children:[]},orbitMode:"solar"})},$a={component:"ChoroplethMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?2>e.geo.features.length?"needs at least 2 area features to compare":null:"needs a GeoJSON FeatureCollection via rawInput",intentScores:{geo:5,"compare-categories":3},caveats:()=>["large areas dominate visual weight regardless of measurement"],buildProps:e=>({areas:e.geo?.features??[],valueAccessor:e.primary.y??"value"})},Ia={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?(e.geo.points?.length??0)>0||0!==(e.geo.features.length??0)?null:"needs points or area features":"needs a GeoJSON FeatureCollection (with points or area centroids)",intentScores:{geo:4,rank:3,"compare-categories":3},buildProps:e=>({points:e.geo?.points??[],areas:e.geo?.features??void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:e.primary.size??"value"})},Ma={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?e.geo.flows?.length?e.geo.points?.length?null:"needs point nodes with lat/lon":"needs flow records (source/target/value)":"needs a geo dataset",intentScores:{geo:4,flow:5},buildProps:e=>({flows:e.geo?.flows??[],nodes:e.geo?.points??[],valueAccessor:"value"})},Ba={component:"DistanceCartogram",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:1,accuracy:3,precision:3},fits:e=>e.hasGeo&&e.geo?e.geo.points?.length?null:"needs point nodes with lat/lon and a cost field":"needs a geo dataset",intentScores:{geo:3,rank:3,"compare-categories":2},caveats:()=>["non-standard projection — requires explanation for most readers"],buildProps:e=>({points:e.geo?.points??[],costAccessor:"cost"})};function Ea(e){return Number.isFinite("number"==typeof e?e:Number(e))}function Fa(e){return["value","throughput","traffic","rate","volume","count"].find(t=>e.some(e=>{const r=Number(e?.[t]);return Number.isFinite(r)&&r>0}))??"value"}function La(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var Da=[qn,Vn,Wn,Un,Yn,Xn,Kn,Qn,Jn,Zn,ea,ta,oa,ia,sa,ca,la,pa,da,ya,ha,ga,ba,fa,va,wa,xa,Aa,Ca,ka,Sa,Pa,Ta,Na,Ra,$a,Ia,Ma,Ba,{component:"GaltonBoardChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>20>e.rowCount?"Galton boards need enough observations for a distribution to form":e.primary.y?null:"needs a numeric field to drop into bins",intentScores:{distribution:4,"outlier-detection":1},caveats:()=>["The settled projection is the chart; motion is explanatory context and should not be used for exact value reading"],buildProps:e=>({data:e.data,valueAccessor:e.primary.y,bins:Math.max(8,Math.min(24,Math.round(Math.sqrt(e.rowCount))))})},{component:"EventDropChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.time??e.primary.x?3>e.rowCount?"needs multiple events to show arrival/window behavior":null:"needs an event-time field",intentScores:{"change-detection":3,trend:1,distribution:1},caveats:()=>["Use for event-time arrival stories, watermarks, and lateness; use a line or histogram for precise temporal values"],buildProps:e=>{const t=e.primary.time??e.primary.x,r=(function(e){return e.data.some(e=>e&&"object"==typeof e&&"arrivalTime"in e)}(e)?"arrivalTime":e.candidates.time.find(e=>e.field!==t)?.field)||t;return{data:e.data,timeAccessor:t,arrivalAccessor:r,windows:{size:Math.max(1,Math.ceil(e.rowCount/8))},watermark:{delay:1}}}},{component:"PhysicsPileChart",family:"categorical",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.primary.category?e.primary.y?(e.categoryCount??0)>12?"too many categories for readable physics piles":null:"needs a numeric value to unitize into bodies":"needs a categorical field for piles",intentScores:{"compare-categories":3,"part-to-whole":2,distribution:1},caveats:()=>["Physics piles dramatize accumulation; use bars or dots when exact rank or precise value comparison is the task"],buildProps:e=>{const t=e.primary.y,r=t?e.data.map(e=>Number(e?.[t])).filter(e=>Number.isFinite(e)):[],n=r.length?Math.max(...r):1;return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:t,unitValue:Math.max(1,Math.ceil(n/40))}}},{component:"CollisionSwarmChart",family:"distribution",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.primary.y??e.primary.x?8>e.rowCount?"needs enough points for collision density to matter":e.rowCount>1200?"too many points for browser collision relaxation":(e.categoryCount??0)>12?"too many group lanes for a physics swarm":null:"needs a numeric field for the swarm axis",intentScores:{distribution:3,"outlier-detection":3,"compare-categories":2},caveats:()=>["CollisionSwarmChart makes overlap and settling visible; use SwarmPlot when a static distribution is enough"],buildProps:e=>{const t=e.primary.category&&8>=(e.categoryCount??0)?e.primary.category:void 0;return{data:e.data,xAccessor:e.primary.y??e.primary.x,...t?{groupAccessor:t,colorBy:t}:{},...e.primary.size?{radiusAccessor:e.primary.size}:{}}}},{component:"PhysicalFlowChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:1},fits:e=>{return e.hasNetwork&&e.network?1>e.network.edges.length?"needs at least 1 flow link":e.network.edges.length>160?"too many links for animated particle flow":(t=e.network.edges,e.network.nodes.some(e=>Ea(e.x)&&Ea(e.y))||t.some(e=>Array.isArray(e.path)||Array.isArray(e.points)||Array.isArray(e.route))?null:"requires authored node x/y coordinates or per-link path geometry; use SankeyDiagram for plain source-target-value data"):"needs explicit {nodes, edges} or {nodes, links} route input";var t},intentScores:{flow:4,"change-detection":1,"part-to-whole":1},caveats:()=>["PhysicalFlowChart is experimental: keep showStaticFlow enabled so throughput remains readable when animation is paused or reduced","Requires explicit route geometry; it does not infer physical pipe paths from a flat source-target table"],buildProps:e=>{const t=e.network?.edges??[];return{nodes:e.network?.nodes??[],links:e.network?.edges??[],nodeIdAccessor:"id",nodeXAccessor:"x",nodeYAccessor:"y",sourceAccessor:"source",targetAccessor:"target",throughputAccessor:Fa(t),showStaticFlow:!0,showSensors:!0,maxParticles:160}},scaleFit:e=>{const t=e.network?.edges.length??0;return t>4?t>60?{delta:-.7,caveats:[t+" links can create occlusion and packet budget pressure; aggregate routes first"]}:{delta:.2,reason:t+" links is small enough for route-constrained packet animation"}:{delta:-.2,caveats:[`only ${t} links — a static Sankey may communicate the flow more directly`]}}},{component:"ProcessFlowChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>3>e.rowCount?"needs multiple work items to show stage flow":La(e,"stage")||La(e,"status")||e.primary.category?null:"needs a categorical stage/status field",intentScores:{flow:4,"change-detection":3,"compare-categories":2,rank:1},caveats:()=>["Use for capacitated multi-body process stories (review queues, triage, merge pipelines); use a bar or Sankey for precise stage totals without motion","Motion dramatizes backlog and capacity; settled stage counts and group completion are the readable chart"],buildProps:e=>{const t=(La(e,"stage")?"stage":La(e,"status")&&"status")||e.primary.category||"stage",r=La(e,"id")?"id":void 0,n=(La(e,"featureId")?"featureId":La(e,"group")&&"group")||e.primary.series||void 0,a=new Set;for(const r of e.data){if(!r||"object"!=typeof r)continue;const e=r[t];null!=e&&""!==e&&a.add(e+"")}const o=a.size>0?Array.from(a):["coding","review","merged"],i=o.map((t,r)=>{const n=r===o.length-1,a=r===Math.floor(o.length/2);return{id:t,label:t,force:n?20:12,capacity:a?{unitsPerSecond:Math.max(2,Math.round(e.rowCount/8))}:void 0,pressure:a||void 0,absorb:n||void 0}});return{data:e.data,...r?{idAccessor:r}:{},stageAccessor:t,...n?{groupBy:n,groupCompletion:"allAbsorbed"}:{},stages:i,showProjection:!0,showChrome:!0}}},{component:"GauntletChart",family:"realtime",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:2,precision:2},fits:e=>{if(1>e.rowCount)return"needs at least one project/plan row";const t=e.data.some(e=>e&&"object"==typeof e&&"id"in e);return e.primary.category||t?null:"needs project rows with stable ids (or a categorical identity field)"},intentScores:{flow:3,"change-detection":2,"compare-categories":1},caveats:()=>["GauntletChart is for compound entities whose attached properties transform at gates. Use ProcessFlowChart when work items do not need compound property bodies.","Read viability, property inventory, and outcomes — not body trajectories."],buildProps:e=>({data:e.data.map((e,t)=>({...e,id:e?.id??"project-"+t,positives:Array.isArray(e?.positives)?e.positives:["value"],negatives:Array.isArray(e?.negatives)?e.negatives:["cost"]})),idAccessor:"id",positiveAccessor:"positives",negativeAccessor:"negatives",positiveProperties:[{id:"value",label:"Value",short:"V",color:"#22c55e",buoyancy:2,radius:9}],negativeProperties:[{id:"cost",label:"Cost",short:"$",color:"#ef4444",load:1.1,radius:7}],gates:[{id:"review",label:"Review"},{id:"approval",label:"Approval"}],showProjection:!0,showChrome:!0})},{component:"BigNumber",family:"value",importPath:"semiotic/value",rubric:{familiarity:5,accuracy:5,precision:5},fits:e=>e.primary.y||e.primary.size||0!==e.candidates.y.length?e.rowCount>50?"BigNumber shows a single focal value — pass scalar data, or use a chart family for >50 rows":null:"needs a numeric value to display",intentScores:{trend:e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:3:0,"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1,"change-detection":e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:4:0},caveats:e=>{const t=[];return e.rowCount>1&&t.push("BigNumber renders the latest row's value as the focal number; earlier rows feed an optional sparkline"),t},buildProps:e=>{const t=e.primary.y??e.primary.size??e.candidates.y[0]?.field;if(!t)return{value:0};const r=e.data,n=r.length>0?r[r.length-1]:null,a=n?Number(n[t]):0,o={value:Number.isFinite(a)?a:0,label:t};if(r.length>=2){const e=Number(r[r.length-2][t]);Number.isFinite(e)&&(o.comparison={value:e,label:"vs previous"})}return o},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.8,reason:"single-value displays beat charts when there is one number to show"}:"small"===t.rowBand?{delta:.2,reason:"the latest value with a trend spark is often more legible than a chart at small scale"}:null}],_a=new Map;function Oa(e){_a.set(e.component,e)}function za(e){_a.delete(e)}function Ha(){if(0===_a.size&&!q())return Da;const e=new Map;for(const t of Da)e.set(t.component,t);for(const t of G())e.set(t.component,t);for(const[t,r]of _a)e.set(t,r);return Array.from(e.values())}function Ga(e){return Ha().find(t=>t.component===e)}var qa=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),Va={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function Wa(e,t){if("visual"===t)return{delta:0,caveats:[]};let r=0;const n=[],a=[];for(const t of e.findings){if(!qa.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(r-=e,n.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),a.push(t.message))}return 0===n.length?{delta:0,caveats:[]}:{delta:Math.max(-3,r),reason:`Harder to receive via ${Va[t]}: ${n.slice(0,3).join("; ")}`,caveats:a}}function Ua(e,t,r,n,a){if(!n)return{score:e,rubric:t};const o=n.familiarity?.[r],i=o??t.familiarity,s=n.targets?.[r];let c,l,p=0;void 0!==o&&(p+=.5*(o-3)),s&&(p+=1*("increase"===s.direction?1:-1)*Math.max(1,Math.min(3,s.weight??1)),c=s.reason?`${n.name?n.name+": ":""}${s.reason}`:`${n.name?n.name+" ":""}target: ${s.direction} ${r}`);const u=n.receptionModality;return a&&u&&"visual"!==u&&(p+=a.delta,l=a.reason),{score:e+p,rubric:{...t,familiarity:i},appliedReason:c,receivabilityReason:l}}function Ya(e,t,r){return r?r.familiarity?.[e]??t:t}function Xa(e){return e&&2===e.exposureLevel?4:3}function Ka(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function Qa(e,t){if(!t?.intentDeltas)return e;const r={...e};for(const[e,n]of Object.entries(t.intentDeltas))r[e]=Math.max(0,Math.min(5,(r[e]??0)+n));return r}function Ja(e,t){return t?.rubricDeltas?function(e){const t=e=>Math.max(1,Math.min(5,Math.round(e)));return{familiarity:t(e.familiarity),accuracy:t(e.accuracy),precision:t(e.precision)}}({familiarity:e.familiarity+(t.rubricDeltas.familiarity??0),accuracy:e.accuracy+(t.rubricDeltas.accuracy??0),precision:e.precision+(t.rubricDeltas.precision??0)}):e}function Za(e,t,r,n){const a=[],o=n.map(e=>({intent:e,score:r[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of o)a.push(`Strong fit for ${e} (${t}/5)`);if(t.primary.x&&t.primary.y&&a.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&a.push(`${t.seriesCount} series detected on field "${t.primary.series??"series"}"`),"recipe"===e.candidateKind){for(const t of e.positiveRationale?.slice(0,2)??[])a.push(t);e.whyCustom?.reason&&a.push("Why leave the catalog: "+e.whyCustom.reason)}return a}function eo(e,t){if("recipe"!==e.candidateKind||!e.recipe)return{delta:0,reasons:[],caveats:[]};const r=e.recipe;if(t.portability&&r.portability!==t.portability)return{delta:0,reasons:[],caveats:[],excluded:`requires a ${t.portability} recipe`};let n=0;const a=[],o=[],i=t.audience?.name?.trim().toLowerCase();if(i){const e=r.audienceFit?.find(e=>e.audience.trim().toLowerCase()===i);e&&(n+={strong:.75,moderate:.25,weak:-.5,avoid:-2}[e.fit],a.push(e.rationale??`${e.fit} fit for ${t.audience?.name??e.audience}`))}const s=t.receptionChannel??t.audience?.receptionModality??"visual";r.reception?.channels?.includes(s)?(n+=.25,a.push(`Designed for ${s} reception`)):r.reception?.channels?.length&&(n-=1,o.push(`Recipe does not declare support for the ${s} reception channel.`));const c=r.reception?.risks??[];return"low"===t.riskTolerance&&c.length>0?(n-=Math.min(1.5,.35*c.length),o.push(...c)):"medium"===t.riskTolerance&&c.length>2&&(n-=.25),"local"===r.portability?o.push("Local-only recipe: cannot be rendered remotely by CLI or MCP."):a.push("Portable registered recipe"),{delta:n,reasons:a,caveats:o}}function to(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const n of t)r+=e[n]??0;return r/t.length}function ro(e,t={}){const r=t.profile??Rn(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),n=t.capabilities??Ha(),a=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],o=!1!==t.includeVariants,i=t.minScore??0,s=t.maxResults??10,c=t.allow?new Set(t.allow):null,l=t.deny?new Set(t.deny):null,p=t.audience?.receptionModality,u=void 0!==p&&"visual"!==p,d=On(r,t.scale),y=void 0!==t.scale&&d.rows!==r.rowCount?{...r,rowCount:d.rows}:r,m=[];for(const e of n){if(c&&!c.has(e.component))continue;if(l&&l.has(e.component))continue;if(null!==e.fits(y))continue;const n={};for(const[t,r]of Object.entries(e.intentScores))n[t]=Ka(r,y);const s=e.caveats?Array.from(e.caveats(y)):[],h=o&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const o of h){const c=Qa(n,o),l=to(c,a),h=Ja(e.rubric,o),g=e.buildProps(r,o);let b;u&&(b=Wa(Ur(e.component,g),p));const f=Ua(l,h,e.component,t.audience,b),v=Hn(e,y,d,t.scale,t.quality);if(v.excluded)continue;const w=eo(e,t);if(w.excluded)continue;const x=f.score+v.delta+w.delta;if(i>x)continue;const A=Za(e,y,c,a);f.appliedReason&&A.push(f.appliedReason),f.receivabilityReason&&A.push(f.receivabilityReason);for(const e of v.reasons)A.push(e);A.push(...w.reasons);const C=[...s,...o?.caveats??[],...v.caveats,...b?.caveats.slice(0,3)??[],...w.caveats];m.push({component:e.component,displayName:e.displayName??e.component,candidateKind:e.candidateKind??"built-in",...e.recipe?{recipeId:e.recipe.id}:{},family:e.family,importPath:e.importPath,variant:o,score:x,intentScores:c,rubric:f.rubric,reasons:A,caveats:C,props:g,...e.whyCustom?{whyCustom:e.whyCustom}:{},scaleRange:{band:d.rowBand,cardinalityBand:d.cardinalityBand,rows:d.rows,rowsSource:d.rowsSource}})}}m.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity);const h=new Set;return m.filter(e=>{const t=`${e.component}:${e.score.toFixed(4)}`;return!h.has(t)&&(h.add(t),!0)}).slice(0,s)}function no(e,t={}){const r=t.profile??Rn(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),n=t.capabilities??Ha(),a=t.allow?new Set(t.allow):null,o=t.deny?new Set(t.deny):null,i=On(r,t.scale),s=void 0!==t.scale&&i.rows!==r.rowCount?{...r,rowCount:i.rows}:r,c=[];for(const e of n){if(a&&!a.has(e.component))continue;if(o&&o.has(e.component))continue;const t=e.fits(s);null!==t&&c.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:ro(e,{...t,profile:r}),rejected:c,profile:r}}function ao(e,t,r={}){const n=Ha().find(t=>t.component===e);if(!n)return{reason:`No capability registered for "${e}"`};const a=r.profile??Rn(t??[]),o=n.fits(a);if(null!==o)return{reason:o};const i=r.variantKey?n.variants?.find(e=>e.key===r.variantKey):void 0,s=r.intent?Array.isArray(r.intent)?r.intent:[r.intent]:[],c={};for(const[e,t]of Object.entries(n.intentScores))c[e]=Ka(t,a);const l=Qa(c,i),p=to(l,s),u=Ja(n.rubric,i),d=Za(n,a,l,s),y=eo(n,r);if(y.excluded)return{reason:y.excluded};d.push(...y.reasons);const m=[...n.caveats?n.caveats(a):[],...i?.caveats??[],...y.caveats];return{component:n.component,displayName:n.displayName??n.component,candidateKind:n.candidateKind??"built-in",...n.recipe?{recipeId:n.recipe.id}:{},family:n.family,importPath:n.importPath,variant:i,score:p+y.delta,intentScores:l,rubric:u,reasons:d,caveats:m,props:n.buildProps(a,i),...n.whyCustom?{whyCustom:n.whyCustom}:{}}}function oo(e,t={}){const r=t.profile??Rn(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),n=On(r,t.scale),a=t.maxPerBand??t.maxResults??5,o=["tiny","small","medium","large","huge"],i={};for(const n of o){const o={...t.scale??{},rows:n};i[n]=ro(e,{...t,profile:r,scale:o,maxResults:a})}return{tiny:i.tiny??[],small:i.small??[],medium:i.medium??[],large:i.large??[],huge:i.huge??[],effective:n}}var io=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function so(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function co(e){return so(e)?e:void 0}function lo(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function po(e){const t=lo(e);return null==t?void 0:Math.max(0,Math.floor(t))}function uo(...e){return e.map(co).find(Boolean)}function yo(...e){return e.find(Array.isArray)}function mo(e){const t={};for(const[r,n]of Object.entries(e))void 0!==n&&(t[r]=n);return t}function ho(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function go(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function bo(e,t,r){const n=e?.filter(e=>!0===co(e)?.sensor).length,a=co(t?.observation),o=co(a?.sensors),i=yo(r?.activeSensors);return Math.max(n??0,o?Object.keys(o).length:0,i?.length??0)||void 0}function fo(e,t,r={}){const{capability:n,audience:a,locale:o}=r,i=r.levels??["l1","l2","l3"],s=!1!==r.includeStructure,c=se(e,n),l=c?[...i,"l4"]:i,p=j(e,t,{levels:l,locale:o,capability:n,audience:a}),{l4:u,...d}=p.levels,y=["l1","l2","l3"].map(e=>p.levels[e]).filter(Boolean).join(" "),m={levels:d,text:p.annotations?`${p.annotations} ${y}`.trim():y,...p.annotations?{annotations:p.annotations}:{}};let g;if(c&&u){const e=(b=n)?"fits"in b||"buildProps"in b?{family:b.family}:{family:b.family,intentScores:b.intentScores}:{};g={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}var b;const f=s?h(e,t,{maxLeaves:r.maxLeaves,locale:o}):void 0,v=function(e,t,r){if(!1===r)return;const n=so(r)?r:void 0,a=co(t.physics),o=uo(n?.snapshot,a?.snapshot,t.physicsSnapshot,function(e){const t=co(e);return!!t&&(so(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),i=uo(n?.evidence,a?.evidence,t.physicsEvidence,t.settledEvidence),s=uo(n?.config,a?.config,o?.config,t.config),c=uo(co(o?.world),co(a?.world)),l=uo(co(s?.kernel),co(c?.options)),p=yo(c?.bodies),u=yo(c?.colliders,s?.colliders),d=yo(o?.queue,a?.queue),y=yo(o?.liveBodyOrder),m=yo(c?.springs),h=yo(o?.activeSensorPairs),g=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const r=co(e);if(!r)return;const n=lo(r.count??r.value??r.total??r.bodies??r.events);if(null==n)return;const a=(r.label??r.id??r.name??"container "+(t+1))+"",o=null==r.id?void 0:r.id+"",i=lo(r.secondary??r.secondaryCount),s=lo(r.observed??r.observedCount);return mo({id:o,label:a,count:n,secondary:i,secondaryLabel:"string"==typeof r.secondaryLabel?r.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const r=t.reduce((e,t)=>e+t.count,0),n=t.filter(e=>e.count>0).length,a=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:r,populatedCount:n,...a?{leader:a}:{}}}(function(e,t,r,n){const a=co(e.settledProjection),o=co(t?.settledProjection);return yo(r?.projectionRows,r?.aggregates,e.settledProjectionRows,e.projectionRows,a?.rows,t?.settledProjectionRows,t?.projectionRows,o?.rows,n?.binCounts)}(t,a,n,i)),b=function(e,t){const r=e?.map((e,t)=>{const r=co(e);if(!r)return;const n=lo(r.count)??0,a=lo(r.total),o={label:(r.label??r.id??"sediment "+(t+1))+"",count:n};return null!=r.id&&(o.id=r.id+""),null!=a&&(o.total=a),o}).filter(e=>null!=e),n=po(t?.bins)??r?.length??0,a=lo(t?.count)??r?.reduce((e,t)=>e+t.count,0)??0,o=lo(t?.total)??r?.reduce((e,t)=>e+(t.total??0),0),i=r?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==n||0!==a||o)return{bins:n,count:a,...null!=o&&o>0?{total:o}:{},...i?{leader:i}:{}}}(yo(n?.sediment,a?.sediment,o?.sediment),uo(n?.sedimentTotals,a?.sedimentTotals)),f=y?.length??p?.length??po(i?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===co(e)?.sleeping).length}(p)??po(i?.sleepingCount),w=d?.length,x="string"==typeof o?.simulationState?o.simulationState:void 0,A="boolean"==typeof i?.settled?i.settled:x?"settled"===x:null!=f||null!=v||null!=w?null!=f&&v===f&&0===(w??0):void 0,C=co(l?.gravity),k=lo(C?.x),S=lo(C?.y),P=mo({state:x,settled:A,elapsedSeconds:lo(o?.elapsedSeconds),paused:"boolean"==typeof o?.paused?o.paused:void 0,visible:"boolean"==typeof o?.visible?o.visible:void 0,seed:lo(l?.seed),gravity:null!=k&&null!=S?{x:k,y:S}:void 0,fixedDt:lo(s?.fixedDt??l?.fixedDt),timeScale:lo(s?.timeScale),maxSubsteps:po(s?.maxSubsteps),liveBodies:f,sleepingBodies:v,queued:w,bodyLimit:lo(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),j=mo({colliders:u?.length,sensors:bo(u,s,c),springs:m?.length,activeSensorPairs:h?.length}),T=Object.keys(j).length>0,N=io.has(e);if(!(Object.keys(P).length>0||T||g||b)||!N&&null==r)return;const R={simulation:P,...T?{geometry:j}:{},...g?{aggregates:g}:{},...b?{sediment:b}:{}},$=function(e){const t=[],r=e.simulation,n=[r.state??(r.settled?"settled":void 0),null!=r.liveBodies?`${r.liveBodies} live ${ho(r.liveBodies,"body")}`:void 0,null!=r.sleepingBodies?r.sleepingBodies+" sleeping":void 0,null!=r.queued?r.queued+" queued":void 0,null!=r.seed?"seed "+go(r.seed):void 0,r.gravity?`gravity (${go(r.gravity.x)}, ${go(r.gravity.y)})`:void 0,null!=r.fixedDt?`fixed step ${go(r.fixedDt)}s`:void 0,null!=r.timeScale?go(r.timeScale)+"x time":void 0].filter(Boolean);n.length>0&&t.push(`Physics simulation: ${n.join("; ")}.`);const a=e.geometry;if(a){const e=[null!=a.colliders?`${a.colliders} ${ho(a.colliders,"collider")}`:void 0,null!=a.sensors?`${a.sensors} ${ho(a.sensors,"sensor")}`:void 0,null!=a.springs?`${a.springs} ${ho(a.springs,"spring")}`:void 0,null!=a.activeSensorPairs?`${a.activeSensorPairs} active sensor ${ho(a.activeSensorPairs,"pair")}`:void 0].filter(Boolean);e.length>0&&t.push(`Physics geometry: ${e.join("; ")}.`)}const o=e.aggregates;if(o){const e=o.leader,r=e?` Largest is ${e.label} with ${go(e.count)}.`:"";t.push(`Physics aggregates: ${go(o.totalCount)} settled ${ho(o.totalCount,"body")} across ${o.rows.length} ${ho(o.rows.length,"container")}; ${o.populatedCount} populated.${r}`)}const i=e.sediment;if(i){const e=null!=i.total?", value total "+go(i.total):"",r=i.leader?`; largest sediment bin is ${i.leader.label} with ${go(i.leader.count)}`:"";t.push(`Physics sediment: ${i.count} retained ${ho(i.count,"body")} in ${i.bins} ${ho(i.bins,"bin")}${e}${r}.`)}return t.join(" ")}(R);return{...R,text:$}}(e,t,r.physics),w=[m.text,g?.sentence,v?.text].filter(Boolean).join(" ");return{component:e,description:m,intent:g,structure:f,physics:v,text:w}}function vo(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function wo(e){const{data:t,onQuery:r,initialAnnotations:n,componentName:a,props:o,includeProfile:i,includeSuggestions:s,suggestionsIntent:c,suggestionsMax:l,focus:p,includeGrounding:u}=e,[d,y]=tn([]),[m,h]=tn([]),[g,b]=tn(!1),[f,v]=tn(null),w=Zr(()=>cn(t??[]),[t]),x=i||s,A=Zr(()=>x?Rn(t??[]):void 0,[x,t]),C=Zr(()=>s&&A?ro(t,{profile:A,intent:c,maxResults:l??5}):void 0,[s,A,t,c,l]),k=Zr(()=>{if(u&&a)return fo(a,{data:t??[],...o??{}},"object"==typeof u?u:void 0)},[u,a,o,t]),S=en(r);S.current=r;const P=en(a);P.current=a;const j=en(o);j.current=o;const T=en(t);T.current=t;const N=en(w);N.current=w;const R=en(A);R.current=A;const $=en(C);$.current=C;const I=en(p);I.current=p;const M=en(k);M.current=k;const B=Jr(async e=>{const t=e.trim();if(!t)return;b(!0),v(null),y(e=>[...e,{role:"user",text:t}]);const r="undefined"!=typeof performance?performance.now():Date.now();z().record({type:"interrogation-asked",component:P.current,query:vo(t,500)});try{const e=await S.current(t,{data:T.current??[],summary:N.current,profile:R.current,suggestions:$.current,componentName:P.current,props:j.current,grounding:M.current,focus:I.current??void 0});y(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&h(e.annotations);const n="undefined"!=typeof performance?performance.now():Date.now();z().record({type:"interrogation-answered",component:P.current,answer:vo(e.answer,2e3),annotationCount:e.annotations?.length,latencyMs:Math.max(0,Math.round(n-r))})}catch(e){v(e instanceof Error?e:Error(e+"")),y(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}]);const t="undefined"!=typeof performance?performance.now():Date.now();z().record({type:"interrogation-answered",component:P.current,error:!0,latencyMs:Math.max(0,Math.round(t-r))})}finally{b(!1)}},[]),E=Jr(({text:e,annotations:t})=>{const r=e.trim();r&&(y(e=>[...e,{role:"assistant",text:r}]),t&&t.length>0&&h(e=>[...e,...t]))},[]),F=Jr(()=>{y([]),h([]),v(null)},[]);return{ask:B,announce:E,history:d,summary:w,annotations:Zr(()=>{const e=n??[];return 0===e.length?m:0===m.length?e:[...e,...m]},[n,m]),loading:g,error:f,reset:F}}import{useMemo as xo}from"react";var Ao=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function Co(e={}){const{chartId:t,types:r=Ao}=e,{latest:n}=qt({chartId:t,types:r,limit:1});return xo(()=>{if(!n)return null;if("hover-end"===n.type||"selection-end"===n.type||"brush-end"===n.type||"click-end"===n.type)return null;let e;if("selection"===n.type)e=n.selection.fields;else{if("hover"!==n.type&&"click"!==n.type)return null;e=n.datum}return e&&"object"==typeof e?{datum:e,x:n.x,y:n.y,source:n.type}:null},[n])}function ko(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function So(e,t){return"pass"===e?t.passColor??"var(--semiotic-success)":"warn"===e?t.warnColor??"var(--semiotic-warning)":t.failColor??"var(--semiotic-danger)"}function Po(e){if(null==e)return;const t="number"==typeof e?e:Date.parse(e);return Number.isNaN(t)?void 0:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function jo(e){const t=e.label??e.name??e.id;return"number"==typeof e.confidence&&1>e.confidence?`${t} · ${Math.round(100*e.confidence)}%`:t}function To(e){return{author:e.name??e.id,authorKind:"system",source:e.source,basis:e.basis??"rule",confidence:e.confidence,createdAt:e.createdAt,dataVersion:e.dataVersion,stableId:e.id}}function No(e,t={}){const r=[],n=[],a=t.valueAxis??"y",o={status:t.status??"proposed",anchor:t.anchor??"semantic",...void 0!==t.ttlHint?{ttlHint:t.ttlHint}:{}};for(const i of e){if("pass"===i.status&&!t.includePassed)continue;const e=So(i.status,t),s=jo(i),c={provenance:To(i),lifecycle:o},l=e=>n.push({result:i,reason:e}),p=e=>r.push(ve(e,c));switch(i.kind){case"range":if("number"!=typeof i.min||"number"!=typeof i.max){l("range check is missing numeric min/max bounds");break}p({type:"band",y0:i.min,y1:i.max,fill:e,fillOpacity:.12,color:e,label:s});break;case"min":case"max":case"threshold":{const t=i.value??("min"===i.kind?i.min:i.max);if("number"!=typeof t){l(i.kind+" check is missing a numeric value");break}p({type:"x"===a?"x-threshold":"y-threshold",value:t,label:s,color:e});break}case"freshness":{const t=void 0!==i.at?ko(i.at):void 0;if(void 0===t){l("freshness check has no parseable timestamp (`at`); render as a chart-level status badge");break}p({type:"x-threshold",value:t,label:s,color:e});break}default:l(`${i.kind} check on "${i.column??"?"}" has no single chart coordinate; surface it as a chart-level status badge or a row-level mark in your UI`)}}return{annotations:r,unplaced:n}}function Ro(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function $o(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function Io(e,t={}){const r=[],n=e.sources;if(n?.results){const e=n.metadata?.generated_at,t=n.metadata?.invocation_id;for(const a of n.results){const n=Ro(a.status),o=$o(a.unique_id),i=Po(a.max_loaded_at);r.push({id:a.unique_id??o,name:"dbt freshness: "+o,label:"pass"===n?o+" fresh":`${o} stale${i?" since "+i:""}`,status:n,kind:"freshness",at:a.max_loaded_at,message:`freshness ${n}${a.max_loaded_at?" — last load "+a.max_loaded_at:""}`,source:"dbt",basis:"rule",createdAt:e,dataVersion:t})}}const a=e.runResults;if(a?.results){const e=a.metadata?.generated_at,n=a.metadata?.invocation_id;for(const o of a.results){const a=Ro(o.status);if("pass"===a&&!t.includePassed)continue;const i=$o(o.unique_id);r.push({id:o.unique_id??i,name:"dbt test · "+i,status:a,kind:"custom",message:o.message??void 0,observedCount:"number"==typeof o.failures?o.failures:void 0,source:"dbt",basis:"rule",createdAt:e,dataVersion:n})}}return No(r,t)}function Mo(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Bo(e){return e.replace(/^expect_/,"").replace(/column_values_to_be_|column_values_to_|column_|to_be_|to_/g," ").replace(/_/g," ").replace(/\s+/g," ").trim()||e}function Eo(e,t={}){const{createdAt:r,dataVersion:n}=function(e){const t=e?.run_id;return t?"string"==typeof t?{dataVersion:t}:{createdAt:t.run_time,dataVersion:t.run_name??t.run_time}:{}}(e.meta),a=[];for(const[t,o]of(e.results??[]).entries()){const e=o.expectation_config??{},i=e.expectation_type??"unknown_expectation",s=e.kwargs??{},c=s.column,l=o.success?"pass":"fail",p=Mo(s.min_value),u=Mo(s.max_value),d=Mo(s.value),y=Mo(o.result?.observed_value),m=c??"value",h=Bo(i),g=void 0!==y?`${m}: ${y} `:"",b={id:`ge:${i}:${c??t}`,name:`GE ${h}${c?` (${c})`:""}`,status:l,column:c,message:void 0!==y?"observed "+y:void 0,observedCount:o.result?.unexpected_count,source:"great-expectations",basis:"statistical-test",createdAt:r,dataVersion:n},f=/_to_be_between$/.test(i);a.push(f&&void 0!==p&&void 0!==u?{...b,kind:"range",min:p,max:u,label:`${g}(expected ${p}–${u})`}:f&&void 0!==p?{...b,kind:"min",value:p,label:`${g}(min ${p})`}:f&&void 0!==u?{...b,kind:"max",value:u,label:`${g}(max ${u})`}:void 0!==d?{...b,kind:"threshold",value:d,label:`${g}(target ${d})`}:{...b,kind:"custom",label:`${m} ${h}`})}return No(a,t)}function Fo(e,t,r={}){const n=r.profile??Rn(t??[],{rawInput:r.rawInput}),a=Ga(e),o=r.maxAlternatives??3,i=a?.recipe?function(e,t){const r=[];"required"===e.accessibility.description&&"string"!=typeof(t.props??{}).description&&r.push("This custom recipe needs a generated or authored description."),e.reception?.risks?.some(e=>/unfamiliar/i.test(e))&&!(e.reception.scaffolds??[]).some(e=>["legend","annotation","summary","description"].includes(e))&&r.push("This recipe is unfamiliar; add an orienting legend, annotation, or summary.");const n=e.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));n&&r.push("This recipe is color-dependent; add a shape, position, texture, or label cue."),e.reception?.channels.includes("interactive")&&!e.accessibility.fallbackTable&&"required"!==e.accessibility.accessibleTable&&r.push("This interactive recipe needs a static data fallback."),"local"===e.portability&&r.push("This recipe is local-only and cannot be exported to MCP or CLI rendering.");for(const e of t.observedSceneAudit?.observedSceneEvidence??[])"fail"!==e.status&&"warn"!==e.status||("interaction.hit-targets"===e.id?r.push("Scene audit found data-bearing marks without hit targets."):"accessibility.table-fields"===e.id?r.push("Scene audit found accessible-table field loss."):"accessibility.navigation-depth"===e.id&&r.push("The recipe navigation tree is root-only; expose groups and reachable data marks."));return[...new Set(r)]}(a.recipe,r):[];if(!a)return{status:"unknown",component:e,alternatives:ro(t,{profile:n,intent:r.intent,maxResults:o,includeVariants:!1}),profile:n};const s=a.fits(n);return null===s?{status:"ok",component:e,profile:n,...i.length?{repairs:i}:{}}:{status:"alternative",component:e,reason:s,alternatives:ro(t,{profile:n,intent:r.intent,maxResults:o,deny:[e],includeVariants:!1}),profile:n,...i.length?{repairs:i}:{}}}var Lo={valid:!1,errors:[]};function Do(e,t={}){const r=e.component,n=e.props??{},a=[],o=!!tr[r];o||a.push(`Unknown component "${r}". It is not in the chart registry — pick a known chart.`);const i=o?nr(r,n):{...Lo};if(!i.valid)for(const e of i.errors)a.push(e);const s=!1!==t.diagnose&&o?Or(r,n).diagnoses:[],c=s.filter(e=>"error"===e.severity),l=!1!==t.treatErrorsAsBlocking;if(l)for(const e of c)a.push(`${e.code}: ${e.message}`);let p,u,d,y,m;if((t.repair??!!t.data)&&t.data&&(p=Fo(r,t.data,{intent:t.intent}),"alternative"===p.status?a.push(`${r} is a poor fit: ${p.reason}. Consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`):"unknown"===p.status&&a.push(`${r} could not be evaluated against the data; consider ${p.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`)),o&&(u=de(r,n),d=v(u)),t.render&&o){const e=t.render(r,n);m=e.svg,y=e.evidence,y.empty&&a.push("Rendered to an empty scene (no marks) — the data or accessors produce nothing to draw.");for(const e of y.warnings)a.push(e)}const h=o&&i.valid&&(!l||0===c.length)&&(!p||"ok"===p.status)&&(!y||!y.empty);return{ok:h,component:r,props:n,config:u,jsx:d,validation:i,diagnostics:s,repair:p,evidence:y,svg:m,reasons:h?[]:a}}function _o(e={}){const t=e.components??Object.keys(tr).sort();return{name:e.name??"render_semiotic_chart",description:"Render a Semiotic chart from a component name and props. The result is validated, diagnosed for anti-patterns, and (when data is supplied) checked for fit against the data. Inject a renderer to prove it paints; otherwise the result returns validation and repair reasons plus ranked alternatives.",inputSchema:{type:"object",additionalProperties:!1,required:["component"],properties:{component:{type:"string",enum:[...t],description:"The chart component to render."},props:{type:"object",description:"Props for the chart (accessors, data, encodings). See the component schema.",additionalProperties:!0}}}}}function Oo(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function zo(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function Ho(e,t=!0){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const r=e,n=Array.isArray(r.type)?r.type:[r.type],a=n.includes("object")||!!r.properties;if(t&&!a)return!1;if(a){if(!1!==r.additionalProperties)return!1;const e=r.properties;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=new Set(Array.isArray(r.required)?r.required:[]);if(Object.keys(e).some(e=>!t.has(e)))return!1;if(!Object.values(e).every(e=>Ho(e,!1)))return!1}if(n.includes("array")&&(!r.items||!Ho(r.items,!1)))return!1;for(const e of["anyOf","oneOf","allOf"]){if(void 0===r[e])continue;const t=r[e];if(!Array.isArray(t)||0===t.length)return!1;if(!t.every(e=>Ho(e,!1)))return!1}return!0}function Go(e,t={}){const r=t.strict??!1;if(r&&!Ho(e.inputSchema))throw Error("OpenAI strict mode requires a top-level object schema, closed object schemas, and every property required. chartGenerationTool() intentionally leaves props open for chart-specific props; use strict: false or pass a component-specific closed schema.");return{type:"function",name:e.name,description:e.description,parameters:e.inputSchema,strict:r}}function qo(e){return t=>Do(t,e?e(t):{})}var Vo=[{intent:"outlier-detection",weight:4,patterns:[/\b(outlier|outliers|anomal|anomaly|anomalies|extreme|extremes|unusual|stands? out|sticks? out|odd one)\b/i,/\b(peak|peaks|highest|lowest|biggest spike|spike|min|max|maximum|minimum)\b/i]},{intent:"trend",weight:4,patterns:[/\b(trend|trends|trending|trajectory|over time|across time|growth|decline|rising|falling|increasing|decreasing)\b/i,/\b(history|historical|evolved|evolution|change over)\b/i]},{intent:"change-detection",weight:3,patterns:[/\b(when did|what changed|shift|shifted|breakpoint|inflection|turning point|sudden|abrupt)\b/i]},{intent:"rank",weight:4,patterns:[/\b(rank|ranking|ranked|biggest|smallest|largest|order by|sorted|best|worst|leaderboard)\b/i,/\btop\s+(\d+|sellers?|performers?|picks?|results?|categories|items?)\b/i,/\bbottom\s+(\d+|results?|items?)\b/i,/\b(who has the most|which.*most|which.*highest|which.*lowest)\b/i]},{intent:"part-to-whole",weight:4,patterns:[/\b(share|shares|composition|portion|portions|fraction|percentage of|percent of|breakdown|make up|made up of|slice|slices)\b/i,/\b(part of|part to whole|piece of the pie|how much of)\b/i]},{intent:"composition-over-time",weight:5,patterns:[/\b(composition.*time|share.*over time|share.*across|how.*mix.*changed|stacked.*time)\b/i,/\b(over time.*share|over time.*composition|over time.*breakdown)\b/i]},{intent:"distribution",weight:4,patterns:[/\b(distribution|distributions|spread|variance|variation|histogram|skew|skewed|range of|how.*spread|shape of|bell curve)\b/i,/\b(typical value|typical range|where do most|mode|median)\b/i]},{intent:"correlation",weight:4,patterns:[/\b(correl|correlation|relationship|related to|connected to|associated|connection between|relate to)\b/i,/\b(\w+ vs\.? \w+|\w+ versus \w+|\w+ against \w+|scatter)\b/i]},{intent:"compare-series",weight:3,patterns:[/\b(compare.*series|compare.*groups|compare.*cohorts|side by side|group.*vs|series.*vs)\b/i,/\b(how do.*compare|each group|each series|each cohort)\b/i]},{intent:"compare-categories",weight:3,patterns:[/\b(compare.*categor|category.*compar|which is bigger|how does.*compare|differences? between)\b/i]},{intent:"flow",weight:4,patterns:[/\b(flow|flows|transition|transitions|movement|moved from|funnel|conversion|drop[- ]off|sankey|chord)\b/i,/\b(from.*to|source.*target|path|journey|pipeline)\b/i]},{intent:"hierarchy",weight:4,patterns:[/\b(hierarchy|hierarchical|tree|nested|parent.*child|subcategory|sub-?categor|drill down|drilldown|breakdown by level)\b/i]},{intent:"geo",weight:5,patterns:[/\b(geographic|geography|geospatial|map|maps|country|countries|cities|latitude|longitude|spatial|cartogr|choropleth)\b/i,/\b(city|us state|each state|the states)\b/i,/\bacross\s+(countries|states|regions|cities|the world|the country)\b/i]}];function Wo(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const r of Vo)for(const n of r.patterns)if(n.test(e)){const e=t.get(r.intent)??0;t.set(r.intent,Math.min(5,0===e?r.weight:e+.5));break}if(0===t.size)return null;const r=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[n,...a]=r;return{intent:n.intent,confidence:n.confidence,alternates:a}}function Uo(e,t={}){const r=t.audience;if(!r)return[];const n=t.profile??Rn(e??[],{rawInput:t.rawInput}),a=Xa(r),o=t.scoreTolerance??1.5,i=t.maxResults??5,s=Ha(),c=new Map;for(const e of s)c.set(e.component,Ya(e.component,e.rubric.familiarity,r));const l=ro(e,{profile:n,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),p=l.filter(e=>(c.get(e.component)??e.rubric.familiarity)>=4)[0],u=[];for(const e of l)(c.get(e.component)??e.rubric.familiarity)>a||("increase"===r.targets?.[e.component]?.direction||!p||o>=p.score-e.score)&&u.push({stretch:e,familiar:p});const d=new Set,y=[];for(const{stretch:e,familiar:t}of u){const n=`${e.component}/${e.variant?.key??"base"}`;if(d.has(n))continue;d.add(n);const a=c.get(e.component)??e.rubric.familiarity,o=r.targets?.[e.component],s=o?.reason??("increase"===o?.direction?`${r.name??"your audience"} is growing adoption of ${e.component}`:t?`${e.component} is on the data, and within reach of ${t.component} which you're already familiar with`:e.component+" fits this data and would expand your team's vocabulary");if(y.push({suggestion:e,replacing:t?.component,rationale:s,familiarity:a}),y.length>=i)break}return y}function Yo(e,t={}){const r=t.profile??Rn(e??[],{rawInput:t.rawInput}),n=t.maxPanels??6,a=!1!==t.diversifyByFamily,o=t.intents??function(e){const t=[];return e.hasTimeAxis&&(t.push("trend"),e.seriesCount&&e.seriesCount>=2&&t.push("compare-series","composition-over-time"),t.push("change-detection")),e.categoryCount&&t.push("rank","compare-categories","part-to-whole"),e.primary.y&&e.rowCount>=10&&t.push("distribution"),2>Object.values(e.fields).filter(e=>"numeric"===e.type).length||t.push("correlation","outlier-detection"),e.hasHierarchy&&t.push("hierarchy"),e.hasNetwork&&t.push("flow"),e.hasGeo&&t.push("geo"),Array.from(new Set(t))}(r),i=[],s=[],c=[],l=new Set,p=new Set;for(const u of o){if(i.length>=n){c.push(u);continue}const o=ro(e,{profile:r,intent:u,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let d;for(const e of o)if(!(p.has(`${e.component}/${e.variant?.key??"base"}`)||a&&l.has(e.family))){d=e;break}if(!d&&a)for(const e of o)if(!p.has(`${e.component}/${e.variant?.key??"base"}`)){d=e;break}d?(i.push({intent:u,suggestion:d}),s.push(u),l.add(d.family),p.add(`${d.component}/${d.variant?.key??"base"}`)):c.push(u)}return{panels:i,intentsCovered:s,intentsMissing:c,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?Uo(e,{profile:r,audience:t.audience,deny:Array.from(p).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,n)}):[],profile:r}}var Xo={name:"Executive",familiarity:{BarChart:5,LineChart:5,PieChart:5,DonutChart:4,GaugeChart:5,AreaChart:4,FunnelChart:4,ChoroplethMap:4,Histogram:3,Heatmap:3,StackedBarChart:3,StackedAreaChart:3,Scatterplot:3,BubbleChart:3,GroupedBarChart:3,DotPlot:3,BoxPlot:2,ViolinPlot:1,SwarmPlot:1,RidgelinePlot:1,MultiAxisLineChart:2,CandlestickChart:2,DifferenceChart:2,QuadrantChart:3,LikertChart:3,SwimlaneChart:2,MinimapChart:2,ConnectedScatterplot:1,SankeyDiagram:2,TreeDiagram:3,Treemap:3,CirclePack:2,OrbitDiagram:1,ChordDiagram:1,ProcessSankey:2,ForceDirectedGraph:1,ProportionalSymbolMap:3,FlowMap:2,DistanceCartogram:1},targets:{PieChart:{direction:"decrease",weight:1,reason:"shifting from share-by-angle toward share-by-length for accuracy"},BarChart:{direction:"increase",weight:1}},exposureLevel:1},Ko={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},Qo={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},Jo={executive:Xo,analyst:Ko,"data-scientist":Qo},Zo=[{component:"RealtimeLineChart",importPath:"semiotic/realtime",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"y"===e.role||"value"===e.role)?"high"===e.throughput?"for high-throughput streams, prefer RealtimeHeatmap or RealtimeWaterfallChart":null:"needs a numeric value field":"needs a date/time field for the x axis",intentScores:{trend:5,"change-detection":4,"outlier-detection":2},caveats:e=>{const t=[];return"cumulative"===e.retention&&t.push("cumulative retention will eventually exhaust the buffer — set a windowSize or downsample"),t},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric field to bin":"needs a time field",intentScores:{distribution:5,"outlier-detection":4,"change-detection":2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeSwarmChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:4},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?e.fields.some(e=>"categorical"===e.kind||"category"===e.role)?null:"needs a category to swarm by":"needs a numeric field":"needs a time field (points are placed at (time, value))",intentScores:{"outlier-detection":5,distribution:4,"compare-categories":3},caveats:e=>"high"===e.throughput?["high-throughput swarms get crowded — consider RealtimeHistogram"]:[],buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,n=e.fields.find(e=>"category"===e.role||"categorical"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r,categoryAccessor:n}}},{component:"RealtimeWaterfallChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field",intentScores:{"change-detection":5,trend:3,"outlier-detection":4,distribution:e=>"high"===e.throughput?4:2},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:r}}},{component:"RealtimeHeatmap",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field for the x axis",intentScores:{trend:e=>"high"===e.throughput?4:2,distribution:3,"change-detection":3,"compare-series":e=>e.fields.find(e=>"series"===e.role||"categorical"===e.kind&&"category"!==e.role)?4:1},buildProps:e=>{const t=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name,r=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name,n=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role)?.name;return{timeAccessor:t,valueAccessor:r,...n?{categoryAccessor:n}:{}}}},{component:"TemporalHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?"windowed"===e.retention?"windowed retention is RealtimeHistogram's job; TemporalHistogram serves bounded/cumulative data":null:"needs a numeric value field":"needs a time field",intentScores:{distribution:5,"change-detection":3,trend:2},buildProps:e=>{const t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,r=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name;return{timeAccessor:r,valueAccessor:t}}}],ei=new Map;function ti(e){ei.set(e.component,e)}function ri(e){ei.delete(e)}function ni(){if(0===ei.size)return Zo;const e=new Map;for(const t of Zo)e.set(t.component,t);for(const[t,r]of ei)e.set(t,r);return Array.from(e.values())}function ai(e,t){if(void 0===e)return 0;const r="function"==typeof e?e(t):e;return Number.isFinite(r)?Math.max(0,Math.min(5,r)):0}function oi(e,t){if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let r=0;for(const n of t)r+=e[n]??0;return r/t.length}function ii(e,t,r){const n=[],a=r.map(e=>({intent:e,score:t[e]??0})).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of a)n.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&n.push(`tuned for ${e.throughput} throughput`),n}function si(e,t={}){const r=t.capabilities??ni(),n=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],a=t.minScore??0,o=t.maxResults??10,i=t.allow?new Set(t.allow):null,s=t.deny?new Set(t.deny):null,c=[];for(const t of r){if(i&&!i.has(t.component))continue;if(s&&s.has(t.component))continue;if(null!==t.fits(e))continue;const r={};for(const[n,a]of Object.entries(t.intentScores))r[n]=ai(a,e);const o=oi(r,n);if(a>o)continue;const l={...t.rubric},p=t.caveats?Array.from(t.caveats(e)):[],u=ii(e,r,n),d=t.buildProps(e);c.push({component:t.component,family:"realtime",importPath:t.importPath,score:o,intentScores:r,rubric:l,reasons:u,caveats:p,props:d})}return c.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),c.slice(0,o)}var ci=["x","y","size","category","series","time"];function li(e,t){const r=e.fields[t];return r?"numeric"===r.type?"numeric":"categorical"===r.type?"categorical":"date"===r.type?"date":"unknown":"unknown"}function pi(e){const t=new Set;for(const r of Ha())null===r.fits(e)&&t.add(r.component);return t}function ui(e,t){const r=new Set(Object.keys(e.fields)),n=new Set(Object.keys(t.fields)),a=[],o=[];for(const e of n)r.has(e)||a.push(e);for(const e of r)n.has(e)||o.push(e);a.sort(),o.sort();const i=[];for(const a of n){if(!r.has(a))continue;const n=li(e,a),o=li(t,a);n!==o&&i.push({field:a,from:n,to:o})}i.sort((e,t)=>e.field.localeCompare(t.field));const s=[];for(const r of ci){const n=e.primary[r],a=t.primary[r];n!==a&&s.push({role:r,from:n,to:a})}const c=pi(e),l=pi(t),p=Array.from(c).filter(e=>!l.has(e)).sort(),u=Array.from(l).filter(e=>!c.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:a,removed:o,typeChanges:i,primaryChanges:s,becameUnfit:p,becameFit:u,unchanged:0===a.length&&0===o.length&&0===i.length&&0===s.length&&0===p.length&&0===u.length&&e.rowCount===t.rowCount}}function di(e,t=Ha()){const r=new Map;for(const e of t)r.set(e.component,{component:e.component,family:e.family,fitsOn:0,rejectedOn:0,inTopThreeOn:0,topPickOn:0,expertAgreementCount:0,averageScore:0,caveatCoverage:0,variantUtilization:0});const n=new Map,a=new Map,o=new Map,i=new Map,s=[];for(const c of e){let e,l;try{e=Rn(c.data,{rawInput:c.rawInput}),l=no(c.data,{profile:e,intent:c.intent,capabilities:t,maxResults:40})}catch{const e=!!c.expected&&c.expected.length>0;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:void 0,topThree:[],fittingCount:0,rejectedCount:0,expertAgreement:!e&&null,topPickAgreement:!e&&null,noFitHonored:null});continue}const p=[],u=new Set;for(const e of l.fitting)if(!u.has(e.component)&&(u.add(e.component),p.push({component:e.component,variantKey:e.variant?.key,score:e.score}),3===p.length))break;const d=c.expected&&c.expected.length>0?p.some(e=>c.expected.includes(e.component)):null,y=c.expected&&c.expected.length>0?p.length>0&&c.expected.includes(p[0].component):null;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:p[0],topThree:p,fittingCount:l.fitting.length,rejectedCount:l.rejected.length,expertAgreement:d,topPickAgreement:y,noFitHonored:!0===c.expectsNoFit?0===l.fitting.length:null});for(const e of l.fitting){const t=r.get(e.component);t&&(t.fitsOn+=1,n.set(e.component,(n.get(e.component)??0)+e.score),a.set(e.component,(a.get(e.component)??0)+1),e.caveats.length>0&&o.set(e.component,(o.get(e.component)??0)+1),e.variant&&i.set(e.component,(i.get(e.component)??0)+1))}for(const e of l.rejected){const t=r.get(e.component);t&&(t.rejectedOn+=1)}for(const e of p){const t=r.get(e.component);t&&(t.inTopThreeOn+=1)}if(p[0]){const e=r.get(p[0].component);e&&(e.topPickOn+=1)}if(c.expected&&d)for(const e of p)if(c.expected.includes(e.component)){const t=r.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of r.values()){const t=a.get(e.component)??0;e.averageScore=0===t?0:(n.get(e.component)??0)/t,e.caveatCoverage=0===t?0:(o.get(e.component)??0)/t,e.variantUtilization=0===t?0:(i.get(e.component)??0)/t}const c=Array.from(r.values()).sort((e,t)=>{const r=e.expertAgreementCount-t.expertAgreementCount;return 0!==r?r:t.fitsOn-e.fitsOn}),l=s.filter(e=>null!==e.expertAgreement),p=0===l.length?0:l.filter(e=>!0===e.expertAgreement).length/l.length,u=0===l.length?0:l.filter(e=>!0===e.topPickAgreement).length/l.length,d=Array.from(a.values()).reduce((e,t)=>e+t,0),y=Array.from(o.values()).reduce((e,t)=>e+t,0),m=Array.from(i.values()).reduce((e,t)=>e+t,0);return{perCapability:c,perFixture:s,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:p,top1AgreementRate:u,overallCaveatCoverage:0===d?0:y/d,overallVariantUtilization:0===d?0:m/d}}}var yi=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,r)=>e.map(e=>({month:e,revenue:800+e*(200+40*r)+150*Math.sin(e),region:t})))})(),mi=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),hi=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],gi=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),bi=Array.from({length:80},(e,t)=>{const r=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:r,grade:Math.min(100,1.8*r+30+20*(Math.random()-.5))}}),fi=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),vi=[{product:"Widget",region:"EU",units:480},{product:"Widget",region:"NA",units:620},{product:"Widget",region:"APAC",units:290},{product:"Gadget",region:"EU",units:320},{product:"Gadget",region:"NA",units:740},{product:"Gadget",region:"APAC",units:410},{product:"Sprocket",region:"EU",units:200},{product:"Sprocket",region:"NA",units:380},{product:"Sprocket",region:"APAC",units:150},{product:"Whatsit",region:"EU",units:290},{product:"Whatsit",region:"NA",units:550},{product:"Whatsit",region:"APAC",units:180}],wi=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:yi,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:yi,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:yi,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:mi,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:hi,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:hi,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:gi,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:gi,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:bi,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:bi,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:vi,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:vi,intent:"part-to-whole",expected:["StackedBarChart","PieChart"]},{name:"revenue vs expenses, intent=compare-series",shape:"48 rows = 24 months × 2 series",data:[...Array.from({length:24},(e,t)=>({month:t+1,amount:100+8*t+25*Math.sin(t/3),series:"revenue"})),...Array.from({length:24},(e,t)=>({month:t+1,amount:80+6*t+15*Math.cos(t/4),series:"expenses"}))],intent:"compare-series",expected:["DifferenceChart","LineChart","GroupedBarChart"]},{name:"stock OHLC prices, intent=change-detection",shape:"30 days × open/high/low/close",data:Array.from({length:30},(e,t)=>{const r=100+1.2*t+8*Math.sin(t/4),n=r+4*(Math.random()-.5),a=r+4*(Math.random()-.5);return{day:t+1,open:n,high:Math.max(n,a)+3*Math.random(),low:Math.min(n,a)-3*Math.random(),close:a}}),intent:"change-detection",expected:["CandlestickChart","LineChart"]},{name:"unemployment vs inflation by year, intent=correlation",shape:"20 years × 2 measures, ordered by year",data:Array.from({length:20},(e,t)=>({year:2005+t,unemployment:5+2*Math.sin(t/2)+(t>4&&10>t?3:0),inflation:2+1.5*Math.cos(t/3)})),intent:"correlation",expected:["ConnectedScatterplot","Scatterplot"]},{name:"transition events, intent=flow",shape:"11 stage transitions across 3 deals with startTime + value",data:[{case:"deal-001",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T09:00:00",value:18},{case:"deal-001",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-01T13:00:00",value:16},{case:"deal-001",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-02T11:00:00",value:14},{case:"deal-001",stage:"Proposal",nextStage:"Closed Won",startTime:"2024-04-04T09:00:00",value:12},{case:"deal-002",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T10:00:00",value:10},{case:"deal-002",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-02T09:00:00",value:9},{case:"deal-002",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-03T09:00:00",value:7},{case:"deal-002",stage:"Proposal",nextStage:"Closed Lost",startTime:"2024-04-04T11:00:00",value:5},{case:"deal-003",stage:"Signup",nextStage:"Activated",startTime:"2024-04-01T08:30:00",value:28},{case:"deal-003",stage:"Activated",nextStage:"Trial",startTime:"2024-04-01T10:00:00",value:24},{case:"deal-003",stage:"Trial",nextStage:"Subscribed",startTime:"2024-04-02T10:00:00",value:18}],intent:"flow",expected:["SankeyDiagram","ProcessSankey","ChordDiagram"]},{name:"incidents by service and weekday, intent=compare-categories",shape:"56 cells = 8 services × 7 weekdays, numeric incident count",data:(()=>{const e=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];return["auth","billing","search","ingest","notify","reports","exports","webhooks"].flatMap((t,r)=>e.map((e,n)=>({service:t,day:e,incidents:Math.round(2+9*Math.abs(Math.sin(1.7*r+n))+(5>n?1.5:-1.5))})))})(),intent:"compare-categories",expected:["Heatmap","GroupedBarChart"]},{name:"capacity utilization single value, intent=part-to-whole",shape:"1 row, one numeric value against an implicit 0–100 plan",data:[{metric:"Cluster capacity used",value:78}],intent:"part-to-whole",expected:["GaugeChart","BigNumber"]},{name:"shipping flows between cities, intent=flow",shape:"6 lat/lon nodes, 6 weighted flows, 1 outline feature",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"SEA",lon:-122.3,lat:47.6},{id:"SFO",lon:-122.4,lat:37.8},{id:"DEN",lon:-104.9,lat:39.7},{id:"ORD",lon:-87.6,lat:41.9},{id:"ATL",lon:-84.4,lat:33.7},{id:"JFK",lon:-73.8,lat:40.6}],flows:[{source:"SEA",target:"ORD",value:320},{source:"SFO",target:"JFK",value:540},{source:"SFO",target:"ATL",value:210},{source:"DEN",target:"ORD",value:180},{source:"ORD",target:"JFK",value:460},{source:"ATL",target:"JFK",value:250}]},intent:"flow",expected:["FlowMap"]},{name:"travel times from HQ, intent=geo",shape:"6 lat/lon points with a cost field measured from a center",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"outline",properties:{name:"Region"},geometry:{type:"Polygon",coordinates:[[[-125,24],[-66,24],[-66,50],[-125,50],[-125,24]]]}}],points:[{id:"HQ",lon:-122.4,lat:37.8,cost:0},{id:"Seattle",lon:-122.3,lat:47.6,cost:95},{id:"Denver",lon:-104.9,lat:39.7,cost:150},{id:"Chicago",lon:-87.6,lat:41.9,cost:245},{id:"Atlanta",lon:-84.4,lat:33.7,cost:280},{id:"New York",lon:-73.8,lat:40.6,cost:330}]},intent:"geo",expected:["DistanceCartogram","ProportionalSymbolMap"]},{name:"flat single column",shape:"50 rows, one numeric column",data:fi,expected:["Histogram"]},{name:"sparse 3-row data, intent=rank",shape:"3 rows total",data:[{name:"A",value:12},{name:"B",value:34},{name:"C",value:8}],intent:"rank",expected:["BarChart","DotPlot"]}];import{useEffect as xi,useMemo as Ai,useRef as Ci,useSyncExternalStore as ki}from"react";var Si=e=>pe(e),Pi=()=>z().enabled,ji=()=>!1;function Ti(e,t={}){const{intent:r,allow:n,deny:a,maxResults:o,includeVariants:i,minScore:s,rawInput:c,seriesField:l,capabilities:p,audience:u,profile:d}=t,y=Ai(()=>d??Rn(e??[],{rawInput:c,seriesField:l}),[d,e,c,l]),m=Ai(()=>ro(e,{intent:r,allow:n,deny:a,maxResults:o,includeVariants:i,minScore:s,capabilities:p,audience:u,profile:y}),[e,r,n,a,o,i,s,p,u,y]),h=ki(Si,Pi,ji),g=Ci(null);return xi(()=>{if(0===m.length)return void(g.current=null);if(!h)return void(g.current=null);const e=z(),t=u?.name??(u?"custom":void 0),n=`${r??""}|${t??""}|${m.map(e=>e.component).join(",")}`;if(n===g.current)return;const a=e.getEvents();for(let e=a.length-1;e>=0;e--){const t=a[e];if("suggestion-shown"===t.type){if(`${Array.isArray(t.intent)?t.intent.join(","):t.intent??""}|${t.audience??""}|${t.components.join(",")}`===n)return void(g.current=n);break}}g.current=n,e.record({type:"suggestion-shown",intent:r,components:m.map(e=>e.component),topScore:m[0]?.score,audience:t})},[m,r,u,h]),{suggestions:m,profile:y}}import*as Ni from"react";function Ri(t){const r=ie(t.recipe)??(t.recipeId?O(t.recipeId):void 0);if(!r)throw Error(`Unknown chart recipe "${t.recipeId??"(missing recipeId)"}". Register it before rendering.`);const n=function(e){return"function"==typeof e.layout?e.layout:U(e.layout)?H(e.layout.id):void 0}(r);if(!n){const e=U(r.layout)?r.layout.id:r.id;throw Error(`No runtime layout registered for chart recipe "${r.id}" (${e}).`)}const a="semiotic-chart-recipe semiotic-chart-recipe-"+r.id.replace(/[^a-zA-Z0-9_-]+/g,"-"),o={...t,chartId:t.chartId??r.id,className:t.className?`${a} ${t.className}`:a,recipeId:r.id,recipe:r,layout:n},i="XYFrame"===r.frameFamily||"XYCustomChart"===r.frameFamily?_e:"OrdinalFrame"===r.frameFamily||"OrdinalCustomChart"===r.frameFamily?Xe:"NetworkFrame"===r.frameFamily||"NetworkCustomChart"===r.frameFamily?ot:"GeoFrame"===r.frameFamily||"GeoCustomChart"===r.frameFamily?e:void 0;if(!i)throw Error(`Chart recipe "${r.id}" uses unsupported frame family "${r.frameFamily}".`);return Ni.createElement(i,o)}function $i(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function Ii(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function Mi(e){return"number"==typeof e&&Number.isFinite(e)}function Bi(e){if(Mi(e.x)&&Mi(e.y)&&Mi(e.w)&&Mi(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(Mi(e.x)&&Mi(e.y)&&Mi(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(Mi(e.cx)&&Mi(e.cy)&&Mi(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(Mi(e.cx)&&Mi(e.cy)&&Mi(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&Mi(e[0])&&Mi(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function Ei(e,t){const r=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),n=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return n>0?r/n:0}function Fi(e,t,r,n,a){if(e===t)return!0;const o=r.dataRoles.map(e=>M(e,n,a)).filter(e=>!!e).filter(r=>null!=e[r]&&null!=t[r]);return o.length>0&&o.every(r=>e[r]+""==t[r]+"")}function Li(e,t,r,n,a,o="warn",i){return{id:e,category:t,status:r?"pass":o,message:r?n:a,...i?{evidence:i}:{}}}function Di(e){const{recipe:t}=e,r=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(e.scene),n=e.layoutConfig??Q({layoutConfig:e.layoutConfig}),a=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},o=a.x??0,i=a.y??0,s=[],c=r.filter(e=>null!=Ii(e)),l=r.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));s.push(Li("geometry.finite","geometry",0===l.length,"All emitted geometry is finite.",l.length+" marks contain non-finite geometry.","fail",{count:l.length}));const p=r.map(Bi),u=p.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;s.push(Li("geometry.nonzero-area","geometry",0===u,"All bounded marks have positive area.",u+" marks have zero or negative area.","warn",{count:u}));const d=p.filter(e=>e&&(o>e.x0||i>e.y0||e.x1>o+a.width||e.y1>i+a.height)).length;s.push(Li("geometry.bounds","geometry",0===d,"All bounded marks stay inside the plot.",d+" marks extend outside the plot bounds.","warn",{count:d}));const y=t.audit?.minimumHitTargetSize??t.accessibility.minimumHitTarget??24,m=p.filter(e=>!!e&&(y>e.x1-e.x0||y>e.y1-e.y0)).length;s.push(Li("interaction.target-size","interaction",0===m,`All bounded targets meet the declared ${y}px minimum.`,`${m} targets are smaller than ${y}px in at least one dimension.`,"warn",{count:m,minimumTarget:y}));const h=c.map($i),g=h.filter(e=>!e).length,b=new Set,f=h.filter(e=>!(!e||!b.has(e)&&(b.add(e),1)));s.push(Li("identity.stable-ids","identity",0===g,"Every data-bearing mark exposes a stable id.",g+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:g})),s.push(Li("identity.unique-ids","identity",0===f.length,"Stable mark ids are unique.",f.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set(f)].slice(0,10)}));const v=h.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;v>0&&s.push({id:"identity.index-pattern",category:"identity",status:"warn",message:v+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const w=new Set;let x=0;const A=e.inputData;for(const e of c){const r=Ii(e),a=Array.isArray(r)?r:[r];let o=!1;for(const e of a)if(e&&"object"==typeof e)for(let r=0;A.length>r;r+=1)Fi(e,A[r],t,n,A)&&(w.add(r),o=!0);o||(x+=1)}const C=Math.max(0,A.length-w.size);s.push(Li("coverage.input-data","coverage",0===C,"Every input datum is represented by the observed scene.",C+" input data items have no matching scene mark.",t.audit?.requireDatumCoverage?"fail":"warn",{represented:w.size,input:A.length})),s.push(Li("coverage.scene-data","coverage",0===x,"Every data-bearing scene mark maps back to input data.",x+" scene marks do not map back to an input datum.","warn",{count:x}));const k=t.encodings?.some(e=>"count"===e.channel);!k&&c.length>w.size&&w.size>0&&s.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const S=c.filter(e=>!1===e.interactive).length;s.push(Li("interaction.hit-targets","interaction",0===S&&c.length>0,"Every observed data-bearing scene node participates in hit testing.",0===c.length?"No data-bearing scene nodes were emitted for interaction.":S+" data-bearing marks explicitly disable interaction.","fail"));const P=(e.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),j=P.filter(e=>!b.has(e));s.push(Li("coverage.annotation-anchors","coverage",0===j.length,P.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",j.length+" annotations point to missing scene ids.","fail",{unresolved:j}));const T=(e.chart?.selectedIds??[]).filter(e=>!b.has(e));e.chart?.selectedIds&&s.push(Li("interaction.selection-reachability","interaction",0===T.length,"Selected/highlighted states resolve to observed marks.",T.length+" selected ids are not reachable in the scene.","fail",{missing:T}));const N=Dt(r),R=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const r=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return r?M(r,n,A):void 0}).filter(e=>!!e),$=new Set(N.flatMap(e=>Object.keys(e.values))),I=R.filter(e=>!$.has(e));s.push(Li("accessibility.table-fields","accessibility",0===I.length,R.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${I.join(", ")}.`,"fail",{expectedFields:R,observedFields:[...$]})),new Set(A.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=$.size&&[...$].every(e=>"category"===e||"value"===e)&&s.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const B=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);s.push(Li("accessibility.color-only","accessibility",0===B.length,"Every declared color encoding names a redundant cue.",B.length+" color encodings have no declared redundant cue.","warn"));const E=e.chart;if(E){for(const[e,r]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])r&&s.push(Li("accessibility."+e,"accessibility","string"==typeof E[e]&&E[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(t.accessibility.requiresAccessibleTable||"required"===t.accessibility.accessibleTable||t.accessibility.fallbackTable)&&s.push(Li("accessibility.fallback-table","accessibility",!1!==E.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),E.navigationTree&&s.push(Li("accessibility.navigation-depth","accessibility",(E.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const F=e.theme?.background??"#ffffff",L=r.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!F.startsWith("#"))return!1;const r=ur(t,F);return null!=r&&3>r}).length;s.push(Li("visual.contrast","visual",0===L,"All statically checkable mark fills meet 3:1 contrast.",L+" marks have fill contrast below 3:1.","warn",{background:F}));let D=0;const _=p.filter(e=>!!e).slice(0,500);for(let e=0;_.length>e;e+=1)for(let t=e+1;_.length>t;t+=1).8>Ei(_[e],_[t])||(D+=1);D>_.length&&s.push({id:"visual.overlap-density",category:"visual",status:"warn",message:D+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const O=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),z={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(J).filter(e=>!!e),accessibilityExpectations:[...t.accessibility.requirements??[],...t.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===t.accessibility.fallbackTable||"required"===t.accessibility.accessibleTable||!0===t.accessibility.requiresAccessibleTable,designContractDeclared:!!t.designContract?.whyCustom},H=[...s,...O],G=s.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===G,summary:{marks:r.length,passes:H.filter(e=>"pass"===e.status).length,warnings:H.filter(e=>"warn"===e.status).length,failures:G,manual:H.filter(e=>"manual"===e.status).length},declaredSemantics:z,observedSceneEvidence:s,manualATChecks:O}}var _i=[{id:"trend",label:"Trend over time",description:"How a single metric changes over an ordered sequence (typically time).",familyHint:"time-series"},{id:"compare-series",label:"Compare series",description:"Compare multiple measured series across a shared x domain.",familyHint:"time-series"},{id:"compare-categories",label:"Compare categories",description:"Compare a single measure across discrete categories.",familyHint:"categorical"},{id:"rank",label:"Rank",description:"Show category ordering by a measure (largest to smallest).",familyHint:"categorical"},{id:"part-to-whole",label:"Part to whole",description:"Show how individual categories share a total.",familyHint:"categorical"},{id:"distribution",label:"Distribution",description:"Show the shape, spread, and central tendency of a numeric variable.",familyHint:"distribution"},{id:"correlation",label:"Correlation",description:"Show the relationship between two (or more) numeric variables.",familyHint:"relationship"},{id:"flow",label:"Flow",description:"Show movement, transitions, or transfers between states.",familyHint:"flow"},{id:"hierarchy",label:"Hierarchy",description:"Show parent/child structure or nested totals.",familyHint:"hierarchy"},{id:"geo",label:"Geography",description:"Show values bound to geographic locations or regions.",familyHint:"geo"},{id:"outlier-detection",label:"Outlier detection",description:"Surface individual data points that diverge from the rest.",familyHint:"distribution"},{id:"composition-over-time",label:"Composition over time",description:"Show how the share of categories changes across an ordered sequence.",familyHint:"time-series"},{id:"change-detection",label:"Change detection",description:"Surface where or when a metric shifted meaningfully.",familyHint:"time-series"}],Oi=new Map(_i.map(e=>[e.id,e]));function zi(e){return Oi.get(e)}function Hi(){return Array.from(Oi.values())}function Gi(e){Oi.set(e.id,e)}var qi=new Set(_i.map(e=>e.id)),Vi=new Set;function Wi(e,t,r){return Number.isFinite(e)?Math.max(t,Math.min(r,e)):t}function Ui(e,t){return void 0===e?0:Wi("function"==typeof e?e(t):e,0,5)}function Yi(e){return e?Array.isArray(e)?[...e]:[e]:[]}function Xi(e,t,r){const n={};for(const[r,a]of Object.entries(e.intentScores))n[r]=Ui(a,t);if(r)for(const[e,t]of Object.entries(r))n[e]=Wi((n[e]??0)+t,0,5);return n}function Ki(e,t){if(t.length>0)return t.reduce((t,r)=>t+(e[r]??0),0)/t.length;const r=Object.values(e).filter(e=>"number"==typeof e&&e>0);return r.length?r.reduce((e,t)=>e+t,0)/r.length:0}function Qi(e,t){return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:r=>e.buildProps(r,t),rationale:t.description??`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function Ji(e,t,r){return e.some(e=>e.props?.[t]===r)}var Zi=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var es=(e,t,r)=>function(e,t,r){const n=new Map,a=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(n.has(t.id)||n.set(t.id,t))};a(function(e,t,r){const n=r.profile,a=r.existingVariants??t.variants??[],o=Yi(r.intent),i=[];for(const e of a)i.push(Qi(t,e));const s=o.includes("rank")||o.includes("compare-categories");!Zi.has(e)||"categorical"!==t.family||Ji(a,"orientation","horizontal")||!s&&6>(n.categoryCount??0)||i.push({id:e+":heuristic-horizontal",baseComponent:e,label:"Horizontal ranked view",intentDeltas:{rank:1,"compare-categories":.5},rubricDeltas:{precision:1},buildProps:e=>({...t.buildProps(e),orientation:"horizontal",sort:"desc"}),rationale:"Horizontal orientation improves label legibility and rank scanning for categorical comparisons.",source:"heuristic",tags:["horizontal","ranked"]});const c=Ji(a,"normalize",!0)||Ji(a,"type","percent")||a.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!c&&(o.includes("part-to-whole")||o.includes("composition-over-time"))&&i.push({id:e+":heuristic-normalized",baseComponent:e,label:"Normalized composition",intentDeltas:{"part-to-whole":1,"compare-categories":-.5},rubricDeltas:{precision:-1},buildProps:e=>({...t.buildProps(e),normalize:!0}),rationale:"Normalization emphasizes proportional composition when absolute magnitude is secondary.",source:"heuristic",tags:["normalized","part-to-whole"]}),o.length>0){const t=Ha().filter(t=>t.component!==e).filter(e=>null===e.fits(n)).map(e=>{const t=Xi(e,n);return{candidate:e,fit:Ki(t,o),scores:t}}).filter(e=>e.fit>=4).sort((e,t)=>t.fit!==e.fit?t.fit-e.fit:t.candidate.rubric.accuracy!==e.candidate.rubric.accuracy?t.candidate.rubric.accuracy-e.candidate.rubric.accuracy:t.candidate.rubric.familiarity-e.candidate.rubric.familiarity).slice(0,3);for(const{candidate:e,fit:r}of t)i.push({id:`${e.component}:heuristic-${o.join("-")}`,baseComponent:e.component,label:e.component+" alternative",buildProps:t=>e.buildProps(t),rationale:`${e.component} is a strong ${o.join(" + ")} alternative (${r.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return i}(e,t,r));for(const n of Vi)try{a(n(e,t,r)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(n.values())}(e,t,r),ts=(e,t,r,n={})=>{const a=Ga(e.baseComponent);if(!a)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const o=a.fits(t);if(null!==o)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+o]};const i=Yi(n.intent),s=Xi(a,t,e.intentDeltas),c=Ki(s,i),l=function(e,t){return t?{familiarity:Math.round(Wi((r={familiarity:e.familiarity+(t.familiarity??0),accuracy:e.accuracy+(t.accuracy??0),precision:e.precision+(t.precision??0)}).familiarity,1,5)),accuracy:Math.round(Wi(r.accuracy,1,5)),precision:Math.round(Wi(r.precision,1,5))}:e;var r}(a.rubric,e.rubricDeltas);let p;const u=r?.receptionModality;if(u&&"visual"!==u){const n=e.variantKey?a.variants?.find(t=>t.key===e.variantKey):void 0,o=e.buildProps?e.buildProps(t,r):a.buildProps(t,n);p=Wa(Ur(e.baseComponent,o),u)}const d=Ua(c,l,e.baseComponent,r,p),y=Wi(d.score,0,5);let m="manual"===e.source?.15:"heuristic"===e.source?.45:.75;n.baselineComponent&&n.baselineComponent!==e.baseComponent&&(m+=.2),e.variantKey||(m+=.05),m=Wi(m,0,1);let h="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(e.rubricDeltas?.accuracy??0)&&(h+=.15),0>(e.rubricDeltas?.precision??0)&&(h+=.1),l.accuracy>3||(h+=.1),3>y&&(h+=.2),h=Wi(h,0,1);const g=[];if(e.rationale&&g.push(e.rationale),i.length>0){const e=i.map(e=>`${e}: ${(s[e]??0).toFixed(1)}/5`).join(", ");g.push(`Intent fit — ${e}.`)}else g.push(`Mean non-zero intent fit ${c.toFixed(1)}/5.`);return"manual"!==e.source&&g.push(e.source+" proposal; verify against domain context."),d.appliedReason&&g.push(d.appliedReason),d.receivabilityReason&&g.push(d.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&g.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:y,novelty:m,risk:h,reasons:g}};function rs(e){return Vi.add(e),()=>{Vi.delete(e)}}function ns(){return Array.from(Vi)}function as(){Vi.clear()}import{useCallback as os,useEffect as is,useMemo as ss,useState as cs,useSyncExternalStore as ls}from"react";var ps={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function us(e){if(0===e.length)return ps;const t={},r=new Set,n=[];let a;for(const o of e){t[o.type]=(t[o.type]??0)+1,o.arcId&&(a=o.arcId);const e="component"in o&&"string"==typeof o.component?o.component:void 0;if(e&&r.add(e),"from"in o&&"string"==typeof o.from&&r.add(o.from),"to"in o&&"string"==typeof o.to&&r.add(o.to),"components"in o&&Array.isArray(o.components))for(const e of o.components)"string"==typeof e&&r.add(e);"audience-set"===o.type&&"string"==typeof o.audience&&n.push(o.audience)}const o=e[0].timestamp,i=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(r),audiencesSeen:n,latestArcId:a,startedAt:o,lastAt:i,durationMs:Math.max(0,i-o)}}function ds(e={}){const{enableOnMount:t=!0,disableOnUnmount:r=!1,capacity:n,sessionId:a}=e;is(()=>(t&&$({capacity:n,sessionId:a}),()=>{r&&R()}),[t,r,n,a]);const o=os(e=>pe(e),[]),i=os(()=>z().getEvents(),[]),s=ls(o,i,i),[c,l]=cs(()=>z().enabled),[p,u]=cs(()=>z().sessionId);is(()=>(l(z().enabled),u(z().sessionId),pe(()=>{const e=z();l(e.enabled),u(e.sessionId)})),[]);const d=ss(()=>us(s),[s]),y=os(e=>z().record(e),[]),m=os(()=>z().clear(),[]);return{history:s,summary:d,enabled:c,sessionId:p,record:y,clear:m}}export{r as AccessibleNavTree,Se as AreaChart,Vn as AreaChartCapability,Jo as BUILT_IN_AUDIENCES,qi as BUILT_IN_INTENT_IDS,Oe as BarChart,oa as BarChartCapability,t as BigNumber,ze as BoxPlot,fa as BoxPlotCapability,Pe as BubbleChart,Xn as BubbleChartCapability,wi as CANONICAL_FIXTURES,je as CandlestickChart,ea as CandlestickChartCapability,Nt as CategoryColorProvider,n as ChartContainer,a as ChartGrid,Ri as ChartRecipe,rt as ChordDiagram,ka as ChordDiagramCapability,$a as ChoroplethMapCapability,nt as CirclePack,Na as CirclePackCapability,xt as CollisionSwarmChart,Te as ConnectedScatterplot,Yn as ConnectedScatterplotCapability,o as ContextLayout,Rt as DEFAULT_LIFECYCLE_THRESHOLDS,$n as DEFAULT_SCALE_THRESHOLDS,i as DetailsPanel,Re as DifferenceChart,Zn as DifferenceChartCapability,Ba as DistanceCartogramCapability,He as DonutChart,pa as DonutChartCapability,Ge as DotPlot,ca as DotPlotCapability,At as EventDropChart,Ma as FlowMapCapability,at as ForceDirectedGraph,Aa as ForceDirectedGraphCapability,qe as FunnelChart,da as FunnelChartCapability,Ct as GaltonBoardChart,Ve as GaugeChart,ya as GaugeChartCapability,kt as GauntletChart,We as GroupedBarChart,ia as GroupedBarChartCapability,$e as Heatmap,ta as HeatmapCapability,Ue as Histogram,ba as HistogramCapability,s as IntentMark,Ye as LikertChart,ha as LikertChartCapability,Ie as LineChart,qn as LineChartCapability,$t as LinkedCharts,Me as MinimapChart,Jn as MinimapChartCapability,c as MobileAnnotationCalloutList,l as MobileChartContainer,we as MobileStandardControls,Be as MultiAxisLineChart,Qn as MultiAxisLineChartCapability,It as MultiLineTooltip,it as OrbitDiagram,Ra as OrbitDiagramCapability,St as PhysicalFlowChart,Pt as PhysicsCustomChart,jt as PhysicsPileChart,Ke as PieChart,la as PieChartCapability,Tt as ProcessFlowChart,st as ProcessSankey,Sa as ProcessSankeyCapability,Ia as ProportionalSymbolMapCapability,Ee as QuadrantChart,Kn as QuadrantChartCapability,ht as RealtimeHeatmap,gt as RealtimeHistogram,bt as RealtimeLineChart,ft as RealtimeSwarmChart,vt as RealtimeWaterfallChart,Qe as RidgelinePlot,xa as RidgelinePlotCapability,ct as SankeyDiagram,Ca as SankeyDiagramCapability,Fe as Scatterplot,Un as ScatterplotCapability,Le as ScatterplotMatrix,p as SmallMultipleChart,De as StackedAreaChart,Wn as StackedAreaChartCapability,Je as StackedBarChart,sa as StackedBarChartCapability,Ze as SwarmPlot,va as SwarmPlotCapability,et as SwimlaneChart,ga as SwimlaneChartCapability,wt as TemporalHistogram,Kt as ThemeProvider,Zt as TooltipProvider,lt as TreeDiagram,Pa as TreeDiagramCapability,pt as Treemap,Ta as TreemapCapability,tt as ViolinPlot,wa as ViolinPlotCapability,Yr as accessibilityCaveats,Ko as analystPersona,u as annotationFreshnessFor,Et as annotationStableId,d as applyAnnotationLifecycle,y as applyAnnotationStatus,Ua as applyAudienceBias,Hn as applyScaleBias,Ur as auditAccessibility,m as auditMobileVisualization,Di as auditObservedScene,xe as auditVisualizationControls,Lt as bandFromAge,h as buildNavigationTree,fo as buildReaderGrounding,g as buildRecipeNavigationTree,_o as chartGenerationTool,Ae as clampMobileRange,En as classifyCardinalityBand,Fn as classifyFieldBand,Bn as classifyRowBand,as as clearVariantDiscovery,b as communicativeActForIntent,Ln as compareBands,f as computeAnnotationFreshness,On as computeEffectiveScale,v as configToJSX,w as copyConfig,x as countNodes,qo as createChartToolHandler,A as createIndexedDBConversationArcSink,C as createLocalStorageConversationArcSink,k as createWebhookConversationArcSink,S as currentTimestamp,No as dataQualityToAnnotations,Qo as dataScientistPersona,P as defineChartRecipe,j as describeChart,T as describeRecipeChart,N as deserializeSelections,Or as diagnoseConfig,ir as diagnoseTokenEncoding,ui as diffProfile,R as disableConversationArc,Ya as effectiveFamiliarity,$ as enableConversationArc,ts as evaluateVariantProposal,Xo as executivePersona,no as explainCapabilityFit,I as exportChart,B as filterAnnotationsByStatus,E as flattenVisible,Qr as formatAccessibilityAudit,F as formatMobileVisualizationAudit,L as fromConfig,Io as fromDbtArtifacts,Eo as fromGreatExpectations,D as fromURL,_ as fromVegaLite,Ha as getCapabilities,Ga as getCapability,O as getChartRecipe,z as getConversationArcStore,zi as getIntent,H as getRecipeLayout,ns as getRegisteredVariantDiscovery,ni as getStreamCapabilities,Wo as inferIntent,V as intentManifestFromRecipe,W as isJsonSafe,U as isRegisteredRecipeLayout,Y as listChartRecipes,Hi as listIntents,X as loadConversationArc,K as mobileVisualizationCaveats,or as normalizeTokenEncoding,Do as prepareChart,Rn as profileData,es as proposeVariant,Wa as receivabilityBias,Z as recipeToChartCapability,ee as recordAnnotationStatusChange,te as recordAudienceChange,Oa as registerChartCapability,re as registerChartRecipe,ne as registerConversationArcSink,Gi as registerIntent,ae as registerRecipeLayout,ti as registerStreamChartCapability,rs as registerVariantDiscovery,Fo as repairChartConfig,oe as replayConversationArc,_n as resolveCardinalityToNumber,ie as resolveChartRecipe,se as resolveCommunicativeAct,ce as resolveRecipeRoleField,Ot as resolveResponsiveRules,Dn as resolveRowsToNumber,zt as responsiveRuleMatches,di as runQualityScorecard,Gn as scaleHints,ao as scoreChart,le as serializeSelections,Xa as stretchFamiliarityCeiling,pe as subscribeToConversationArcChange,ro as suggestCharts,oo as suggestChartsGrouped,Yo as suggestDashboard,si as suggestStreamCharts,Uo as suggestStretchCharts,lr as suggestTokenEncoding,us as summarizeArc,cn as summarizeData,ue as summarizeIntentManifest,Oo as toAnthropicTool,de as toConfig,Go as toOpenAIResponsesTool,zo as toOpenAITool,ye as toURL,cr as tokenTaskIntentToCapabilityIntents,za as unregisterChartCapability,me as unregisterChartRecipe,he as unregisterRecipeLayout,ri as unregisterStreamChartCapability,Ht as useBrushSelection,Gt as useCategoryColors,Co as useChartFocus,wo as useChartInterrogation,qt as useChartObserver,Ti as useChartSuggestions,ds as useConversationArc,Vt as useFilteredData,Wt as useLinkedChartsActive,Ut as useLinkedHover,Ce as useMobileRangeControls,ge as useNavigationSync,Yt as useSelection,Xt as useSelectionActions,Jt as useTheme,be as validateChartRecipe,nr as validateProps,fe as withCurrentProvenance,ve as withProvenance,ke as zoomMobileRange};