semiotic 3.7.5 → 3.8.1

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 (575) hide show
  1. package/CLAUDE.md +63 -18
  2. package/README.md +121 -27
  3. package/agent-skill/semiotic-charts/SKILL.md +146 -0
  4. package/ai/cli.js +133 -45
  5. package/ai/componentMetadata.cjs +6 -1
  6. package/ai/dist/mcp-server.js +1741 -163
  7. package/ai/examples.md +174 -0
  8. package/ai/schema.json +2733 -536
  9. package/ai/surface-manifest.json +201 -0
  10. package/ai/system-prompt.md +20 -4
  11. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
  12. package/dist/components/AccessibleNavTree.d.ts +7 -1
  13. package/dist/components/CategoryColors.d.ts +1 -1
  14. package/dist/components/ChartContainer.d.ts +91 -0
  15. package/dist/components/ChartGrid.d.ts +11 -1
  16. package/dist/components/CircularBrush.d.ts +61 -0
  17. package/dist/components/ContextLayout.d.ts +5 -1
  18. package/dist/components/DirectManipulationControl.d.ts +63 -0
  19. package/dist/components/LinkedCharts.d.ts +3 -1
  20. package/dist/components/MobileAnnotationCalloutList.d.ts +13 -0
  21. package/dist/components/MobileChartContainer.d.ts +51 -0
  22. package/dist/components/MobileStandardControls.d.ts +68 -0
  23. package/dist/components/SmallMultipleChart.d.ts +84 -0
  24. package/dist/components/Tooltip/FlippingTooltip.d.ts +21 -0
  25. package/dist/components/ai/ChartRecipe.d.ts +16 -0
  26. package/dist/components/ai/IntentMark.d.ts +15 -0
  27. package/dist/components/ai/chartCapabilities.d.ts +8 -1
  28. package/dist/components/ai/chartCapabilityTypes.d.ts +26 -1
  29. package/dist/components/ai/chartClinic.d.ts +91 -0
  30. package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
  31. package/dist/components/ai/chartRecipeRegistry.d.ts +14 -0
  32. package/dist/components/ai/chartRecipes.d.ts +278 -0
  33. package/dist/components/ai/dataPitfallsBridge.d.ts +102 -0
  34. package/dist/components/ai/describeChart.d.ts +7 -0
  35. package/dist/components/ai/describeRecipeChart.d.ts +16 -0
  36. package/dist/components/ai/generativeChart.d.ts +28 -3
  37. package/dist/components/ai/intentManifest.d.ts +62 -0
  38. package/dist/components/ai/navigationTree.d.ts +3 -0
  39. package/dist/components/ai/observedSceneAudit.d.ts +72 -0
  40. package/dist/components/ai/readerGrounding.d.ts +83 -0
  41. package/dist/components/ai/recipeCapability.d.ts +8 -0
  42. package/dist/components/ai/recipeNavigation.d.ts +13 -0
  43. package/dist/components/ai/recipeSemantics.d.ts +11 -0
  44. package/dist/components/ai/repairChartConfig.d.ts +9 -0
  45. package/dist/components/ai/suggestCharts.d.ts +11 -1
  46. package/dist/components/ai/useNavigationSync.d.ts +17 -2
  47. package/dist/components/chartContainerMobile.d.ts +9 -0
  48. package/dist/components/charts/custom/GeoCustomChart.d.ts +48 -0
  49. package/dist/components/charts/custom/NetworkCustomChart.d.ts +8 -2
  50. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +8 -2
  51. package/dist/components/charts/custom/XYCustomChart.d.ts +11 -2
  52. package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
  53. package/dist/components/charts/geo/DistanceCartogram.d.ts +15 -3
  54. package/dist/components/charts/geo/FlowMap.d.ts +11 -7
  55. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +15 -3
  56. package/dist/components/charts/geo/index.d.ts +2 -0
  57. package/dist/components/charts/index.d.ts +35 -1
  58. package/dist/components/charts/network/ChordDiagram.d.ts +10 -2
  59. package/dist/components/charts/network/CirclePack.d.ts +1 -1
  60. package/dist/components/charts/network/ForceDirectedGraph.d.ts +26 -5
  61. package/dist/components/charts/network/OrbitDiagram.d.ts +1 -1
  62. package/dist/components/charts/network/ProcessSankey.d.ts +1 -1
  63. package/dist/components/charts/network/SankeyDiagram.d.ts +10 -2
  64. package/dist/components/charts/network/TreeDiagram.d.ts +1 -1
  65. package/dist/components/charts/network/Treemap.d.ts +1 -1
  66. package/dist/components/charts/network/useForceLayout.d.ts +17 -0
  67. package/dist/components/charts/ordinal/BarChart.d.ts +22 -1
  68. package/dist/components/charts/ordinal/BoxPlot.d.ts +1 -1
  69. package/dist/components/charts/ordinal/DonutChart.d.ts +1 -1
  70. package/dist/components/charts/ordinal/DotPlot.d.ts +1 -1
  71. package/dist/components/charts/ordinal/FunnelChart.d.ts +1 -1
  72. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +12 -1
  73. package/dist/components/charts/ordinal/Histogram.d.ts +1 -1
  74. package/dist/components/charts/ordinal/PieChart.d.ts +1 -1
  75. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +1 -1
  76. package/dist/components/charts/ordinal/StackedBarChart.d.ts +12 -1
  77. package/dist/components/charts/ordinal/SwarmPlot.d.ts +1 -1
  78. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +1 -1
  79. package/dist/components/charts/ordinal/ViolinPlot.d.ts +1 -1
  80. package/dist/components/charts/physics/ChainReactionChart.d.ts +9 -0
  81. package/dist/components/charts/physics/CollisionSwarmChart.capability.d.ts +2 -0
  82. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +54 -0
  83. package/dist/components/charts/physics/EventDropChart.capability.d.ts +2 -0
  84. package/dist/components/charts/physics/EventDropChart.d.ts +60 -0
  85. package/dist/components/charts/physics/GaltonBoardChart.capability.d.ts +2 -0
  86. package/dist/components/charts/physics/GaltonBoardChart.d.ts +74 -0
  87. package/dist/components/charts/physics/GauntletChart.capability.d.ts +2 -0
  88. package/dist/components/charts/physics/GauntletChart.d.ts +73 -0
  89. package/dist/components/charts/physics/PhysicalFlowChart.capability.d.ts +2 -0
  90. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +63 -0
  91. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +99 -0
  92. package/dist/components/charts/physics/PhysicsPileChart.capability.d.ts +2 -0
  93. package/dist/components/charts/physics/PhysicsPileChart.d.ts +60 -0
  94. package/dist/components/charts/physics/ProcessFlowChart.capability.d.ts +2 -0
  95. package/dist/components/charts/physics/ProcessFlowChart.d.ts +96 -0
  96. package/dist/components/charts/physics/chainReactionOverlay.d.ts +22 -0
  97. package/dist/components/charts/physics/chainReactionRuntime.d.ts +37 -0
  98. package/dist/components/charts/physics/chainReactionTypes.d.ts +97 -0
  99. package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +27 -0
  100. package/dist/components/charts/physics/dependencyMachine.d.ts +188 -0
  101. package/dist/components/charts/physics/eventDropPhysics.d.ts +64 -0
  102. package/dist/components/charts/physics/galtonBoardPhysics.d.ts +28 -0
  103. package/dist/components/charts/physics/gauntletChartProps.d.ts +67 -0
  104. package/dist/components/charts/physics/gauntletChrome.d.ts +33 -0
  105. package/dist/components/charts/physics/gauntletController.d.ts +73 -0
  106. package/dist/components/charts/physics/gauntletEffects.d.ts +36 -0
  107. package/dist/components/charts/physics/gauntletPhysics.d.ts +71 -0
  108. package/dist/components/charts/physics/gauntletRuntime.d.ts +42 -0
  109. package/dist/components/charts/physics/gauntletTypes.d.ts +213 -0
  110. package/dist/components/charts/physics/physicalFlowPhysics.d.ts +57 -0
  111. package/dist/components/charts/physics/physicsChartShared.d.ts +57 -0
  112. package/dist/components/charts/physics/physicsChartUtils.d.ts +18 -0
  113. package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
  114. package/dist/components/charts/physics/physicsEncoding.d.ts +142 -0
  115. package/dist/components/charts/physics/physicsHocHandle.d.ts +53 -0
  116. package/dist/components/charts/physics/physicsHocUtils.d.ts +128 -0
  117. package/dist/components/charts/physics/physicsPilePhysics.d.ts +41 -0
  118. package/dist/components/charts/physics/physicsProcessPrimitives.d.ts +38 -0
  119. package/dist/components/charts/physics/processFlowPhysics.d.ts +97 -0
  120. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -1
  121. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +9 -1
  122. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +9 -1
  123. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +16 -2
  124. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +9 -1
  125. package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
  126. package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
  127. package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
  128. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  129. package/dist/components/charts/shared/auditMobileVisualization.d.ts +91 -0
  130. package/dist/components/charts/shared/chartDefinitionPilot.d.ts +145 -0
  131. package/dist/components/charts/shared/chartFamilySets.d.ts +20 -0
  132. package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
  133. package/dist/components/charts/shared/chartSpecCore.d.ts +165 -0
  134. package/dist/components/charts/shared/chartSpecs.d.ts +8 -127
  135. package/dist/components/charts/shared/chartSpecsGeo.d.ts +2 -0
  136. package/dist/components/charts/shared/chartSpecsNetwork.d.ts +2 -0
  137. package/dist/components/charts/shared/chartSpecsOrdinal.d.ts +2 -0
  138. package/dist/components/charts/shared/chartSpecsPhysics.d.ts +2 -0
  139. package/dist/components/charts/shared/chartSpecsRealtime.d.ts +2 -0
  140. package/dist/components/charts/shared/chartSpecsValue.d.ts +2 -0
  141. package/dist/components/charts/shared/chartSpecsXY.d.ts +2 -0
  142. package/dist/components/charts/shared/colorContrast.d.ts +3 -0
  143. package/dist/components/charts/shared/colorUtils.d.ts +16 -1
  144. package/dist/components/charts/shared/datumTypes.d.ts +2 -0
  145. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +6 -0
  146. package/dist/components/charts/shared/diagnoseConfig.d.ts +9 -14
  147. package/dist/components/charts/shared/diagnoseMisleadingChecks.d.ts +9 -0
  148. package/dist/components/charts/shared/diagnosePhysicsChecks.d.ts +3 -0
  149. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  150. package/dist/components/charts/shared/formatUtils.d.ts +3 -3
  151. package/dist/components/charts/shared/hatchFill.d.ts +87 -0
  152. package/dist/components/charts/shared/hooks.d.ts +34 -10
  153. package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
  154. package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
  155. package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
  156. package/dist/components/charts/shared/motionEncoding.d.ts +145 -0
  157. package/dist/components/charts/shared/responsiveRules.d.ts +56 -0
  158. package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
  159. package/dist/components/charts/shared/sparseArray.d.ts +1 -1
  160. package/dist/components/charts/shared/streamPropsHelpers.d.ts +17 -5
  161. package/dist/components/charts/shared/styleRules.d.ts +205 -0
  162. package/dist/components/charts/shared/temporalStrings.d.ts +7 -0
  163. package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
  164. package/dist/components/charts/shared/types.d.ts +58 -7
  165. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
  166. package/dist/components/charts/shared/useChartSetup.d.ts +11 -4
  167. package/dist/components/charts/shared/useCustomChartSetup.d.ts +17 -5
  168. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
  169. package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
  170. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +6 -2
  171. package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
  172. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +25 -2
  173. package/dist/components/charts/shared/useStreamingLegend.d.ts +2 -2
  174. package/dist/components/charts/shared/useSyncedPushData.d.ts +49 -0
  175. package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
  176. package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
  177. package/dist/components/charts/shared/validateChartData.d.ts +7 -5
  178. package/dist/components/charts/shared/validationMap.d.ts +7 -9
  179. package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
  180. package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
  181. package/dist/components/charts/value/targetPresentation.d.ts +22 -0
  182. package/dist/components/charts/value/types.d.ts +5 -6
  183. package/dist/components/charts/xy/AreaChart.d.ts +9 -1
  184. package/dist/components/charts/xy/BubbleChart.d.ts +10 -1
  185. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
  186. package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
  187. package/dist/components/charts/xy/Heatmap.d.ts +2 -2
  188. package/dist/components/charts/xy/LineChart.d.ts +12 -1
  189. package/dist/components/charts/xy/MinimapChart.d.ts +1 -1
  190. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +2 -2
  191. package/dist/components/charts/xy/QuadrantChart.d.ts +8 -1
  192. package/dist/components/charts/xy/Scatterplot.d.ts +11 -1
  193. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +11 -1
  194. package/dist/components/charts/xy/StackedAreaChart.d.ts +16 -4
  195. package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
  196. package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
  197. package/dist/components/controls/SentenceFilter.d.ts +97 -0
  198. package/dist/components/controls/controlAudit.d.ts +24 -0
  199. package/dist/components/controls/controlContract.d.ts +57 -0
  200. package/dist/components/data/fromFlintChart.d.ts +74 -0
  201. package/dist/components/data/fromVegaLite.d.ts +46 -9
  202. package/dist/components/data/portability/index.d.ts +6 -3
  203. package/dist/components/data/portability/result.d.ts +52 -0
  204. package/dist/components/data/portability/spec.d.ts +31 -0
  205. package/dist/components/data/portability/vegaLite.d.ts +24 -6
  206. package/dist/components/export/chartConfig.d.ts +11 -0
  207. package/dist/components/realtime/types.d.ts +11 -0
  208. package/dist/components/recipes/annotationLayout.d.ts +29 -0
  209. package/dist/components/recipes/axisFixedForce.d.ts +119 -0
  210. package/dist/components/recipes/{gofishBoba.d.ts → boba.d.ts} +2 -2
  211. package/dist/components/recipes/cyclical.d.ts +39 -0
  212. package/dist/components/recipes/edgeRouter.d.ts +103 -0
  213. package/dist/components/recipes/forceLayout.d.ts +48 -0
  214. package/dist/components/recipes/forceLayoutAsync.d.ts +17 -0
  215. package/dist/components/recipes/gofishBobaHandwritten.d.ts +3 -0
  216. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +37 -0
  217. package/dist/components/recipes/gofishIR.d.ts +178 -132
  218. package/dist/components/recipes/gofishIRExamples.d.ts +30 -81
  219. package/dist/components/recipes/intervalLanes.d.ts +87 -0
  220. package/dist/components/recipes/intervals.d.ts +80 -0
  221. package/dist/components/recipes/isometricLandmarks.d.ts +88 -0
  222. package/dist/components/recipes/isotypeGlyphs.d.ts +17 -0
  223. package/dist/components/recipes/mobileAnnotationStrategy.d.ts +48 -0
  224. package/dist/components/recipes/mobileChartFamilyRecipes.d.ts +59 -0
  225. package/dist/components/recipes/networkAnalysis.d.ts +102 -0
  226. package/dist/components/recipes/networkLayouts.d.ts +83 -0
  227. package/dist/components/recipes/physics.d.ts +122 -0
  228. package/dist/components/recipes/physicsReference.d.ts +102 -0
  229. package/dist/components/recipes/processAggregates.d.ts +32 -0
  230. package/dist/components/recipes/processChrome.d.ts +67 -0
  231. package/dist/components/recipes/processJourney.d.ts +54 -0
  232. package/dist/components/recipes/processPhysics.d.ts +300 -0
  233. package/dist/components/recipes/processVolumeGeometry.d.ts +28 -0
  234. package/dist/components/recipes/radialCoords.d.ts +69 -0
  235. package/dist/components/recipes/random.d.ts +2 -0
  236. package/dist/components/recipes/recipeChrome.d.ts +91 -0
  237. package/dist/components/recipes/recipeGlyph.d.ts +42 -0
  238. package/dist/components/recipes/recipeLegend.d.ts +53 -1
  239. package/dist/components/recipes/recipeUtils.d.ts +52 -0
  240. package/dist/components/recipes/runs.d.ts +59 -0
  241. package/dist/components/recipes/tokenEncoding.d.ts +157 -0
  242. package/dist/components/recipes/tokenLayer.d.ts +79 -0
  243. package/dist/components/recipes/unitize.d.ts +108 -0
  244. package/dist/components/recipes/vector.d.ts +28 -0
  245. package/dist/components/recipes/waffle.d.ts +43 -0
  246. package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
  247. package/dist/components/semiotic-ai-core.d.ts +47 -0
  248. package/dist/components/semiotic-ai.d.ts +53 -9
  249. package/dist/components/semiotic-controls.d.ts +20 -0
  250. package/dist/components/semiotic-experimental.d.ts +38 -9
  251. package/dist/components/semiotic-geo.d.ts +15 -0
  252. package/dist/components/semiotic-network.d.ts +15 -0
  253. package/dist/components/semiotic-ordinal.d.ts +14 -0
  254. package/dist/components/semiotic-physics-matter.d.ts +10 -0
  255. package/dist/components/semiotic-physics-rapier.d.ts +9 -0
  256. package/dist/components/semiotic-physics.d.ts +60 -0
  257. package/dist/components/semiotic-realtime-core.d.ts +34 -0
  258. package/dist/components/semiotic-realtime-react.d.ts +10 -0
  259. package/dist/components/semiotic-realtime.d.ts +4 -30
  260. package/dist/components/semiotic-recipes-core.d.ts +92 -0
  261. package/dist/components/semiotic-recipes-react.d.ts +7 -0
  262. package/dist/components/semiotic-recipes.d.ts +4 -43
  263. package/dist/components/semiotic-rough.d.ts +4 -0
  264. package/dist/components/semiotic-server-edge.d.ts +8 -0
  265. package/dist/components/semiotic-server-node.d.ts +5 -0
  266. package/dist/components/semiotic-server.d.ts +2 -2
  267. package/dist/components/semiotic-themes-core.d.ts +53 -0
  268. package/dist/components/semiotic-themes-react.d.ts +4 -0
  269. package/dist/components/semiotic-themes.d.ts +6 -76
  270. package/dist/components/semiotic-utils-core.d.ts +50 -0
  271. package/dist/components/semiotic-utils-react.d.ts +5 -0
  272. package/dist/components/semiotic-utils.d.ts +3 -39
  273. package/dist/components/semiotic-xy.d.ts +12 -0
  274. package/dist/components/semiotic.d.ts +44 -8
  275. package/dist/components/server/animatedGif.d.ts +36 -0
  276. package/dist/components/server/optionalImageTypes.d.ts +37 -0
  277. package/dist/components/server/renderEvidence.d.ts +1 -1
  278. package/dist/components/server/renderToStaticSVG.d.ts +3 -35
  279. package/dist/components/server/serverChartConfigShared.d.ts +21 -0
  280. package/dist/components/server/serverChartConfigs.d.ts +22 -12
  281. package/dist/components/server/serverChartConfigsCustom.d.ts +5 -0
  282. package/dist/components/server/serverChartConfigsGeo.d.ts +9 -0
  283. package/dist/components/server/serverChartConfigsNetwork.d.ts +8 -0
  284. package/dist/components/server/serverChartConfigsOrdinal.d.ts +16 -0
  285. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  286. package/dist/components/server/serverChartConfigsXY.d.ts +11 -0
  287. package/dist/components/server/staticAnnotations.d.ts +6 -3
  288. package/dist/components/server/staticGeo.d.ts +4 -0
  289. package/dist/components/server/staticLegend.d.ts +2 -2
  290. package/dist/components/server/staticNetwork.d.ts +8 -0
  291. package/dist/components/server/staticOrdinal.d.ts +11 -0
  292. package/dist/components/server/staticPhysics.d.ts +3 -0
  293. package/dist/components/server/staticSVGChrome.d.ts +110 -0
  294. package/dist/components/server/staticXY.d.ts +4 -0
  295. package/dist/components/store/ObservationStore.d.ts +23 -2
  296. package/dist/components/store/themeSerialization.d.ts +32 -0
  297. package/dist/components/store/useChartInterrogation.d.ts +9 -0
  298. package/dist/components/stream/AccessibleDataTable.d.ts +7 -23
  299. package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
  300. package/dist/components/stream/CanvasHitTester.d.ts +4 -4
  301. package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
  302. package/dist/components/stream/FocusRing.d.ts +4 -2
  303. package/dist/components/stream/FrameRuntime.d.ts +57 -0
  304. package/dist/components/stream/GeoCanvasHitTester.d.ts +1 -1
  305. package/dist/components/stream/GeoParticlePool.d.ts +1 -1
  306. package/dist/components/stream/GeoPipelineStore.d.ts +62 -3
  307. package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
  308. package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
  309. package/dist/components/stream/NetworkPipelineStore.d.ts +44 -36
  310. package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
  311. package/dist/components/stream/NetworkSVGOverlay.d.ts +10 -1
  312. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
  313. package/dist/components/stream/OrdinalPipelineStore.d.ts +55 -11
  314. package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
  315. package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
  316. package/dist/components/stream/ParticlePool.d.ts +1 -1
  317. package/dist/components/stream/PipelineStore.d.ts +81 -174
  318. package/dist/components/stream/SVGOverlay.d.ts +6 -0
  319. package/dist/components/stream/SceneGraph.d.ts +12 -4
  320. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  321. package/dist/components/stream/StreamNetworkFrame.d.ts +1 -1
  322. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  323. package/dist/components/stream/StreamXYFrame.d.ts +2 -18
  324. package/dist/components/stream/accessibleDataRows.d.ts +33 -0
  325. package/dist/components/stream/accessorUtils.d.ts +25 -12
  326. package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
  327. package/dist/components/stream/brushAccessibility.d.ts +25 -0
  328. package/dist/components/stream/canvasBackground.d.ts +24 -0
  329. package/dist/components/stream/canvasSetup.d.ts +4 -1
  330. package/dist/components/stream/customLayoutFailure.d.ts +33 -0
  331. package/dist/components/stream/customLayoutPalette.d.ts +19 -9
  332. package/dist/components/stream/frameGraphics.d.ts +4 -0
  333. package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
  334. package/dist/components/stream/frameThemeColors.d.ts +24 -0
  335. package/dist/components/stream/geoAnnotationAnchors.d.ts +14 -0
  336. package/dist/components/stream/geoCartogram.d.ts +17 -0
  337. package/dist/components/stream/geoCustomLayout.d.ts +59 -0
  338. package/dist/components/stream/geoDefaultTooltip.d.ts +11 -0
  339. package/dist/components/stream/geoFrameHelpers.d.ts +34 -0
  340. package/dist/components/stream/geoPipelineHelpers.d.ts +46 -0
  341. package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
  342. package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
  343. package/dist/components/stream/geoTypes.d.ts +97 -15
  344. package/dist/components/stream/glyphDef.d.ts +98 -0
  345. package/dist/components/stream/hitTarget.d.ts +170 -0
  346. package/dist/components/stream/hitTestUtils.d.ts +2 -2
  347. package/dist/components/stream/hoverUtils.d.ts +7 -2
  348. package/dist/components/stream/keyboardNav.d.ts +4 -1
  349. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +9 -1
  350. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +58 -0
  351. package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
  352. package/dist/components/stream/networkBezier.d.ts +10 -0
  353. package/dist/components/stream/networkColorAccessors.d.ts +49 -0
  354. package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
  355. package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
  356. package/dist/components/stream/networkDefaultTooltip.d.ts +10 -0
  357. package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
  358. package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
  359. package/dist/components/stream/networkFrameInteraction.d.ts +37 -0
  360. package/dist/components/stream/networkFrameObservations.d.ts +15 -0
  361. package/dist/components/stream/networkFramePaint.d.ts +52 -0
  362. package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
  363. package/dist/components/stream/networkPipelineConfig.d.ts +22 -0
  364. package/dist/components/stream/networkPipelineHelpers.d.ts +12 -0
  365. package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
  366. package/dist/components/stream/networkRealtimeEncoding.d.ts +41 -0
  367. package/dist/components/stream/networkTypes.d.ts +103 -51
  368. package/dist/components/stream/ordinalCanvasRenderers.d.ts +7 -0
  369. package/dist/components/stream/ordinalDataIndex.d.ts +5 -0
  370. package/dist/components/stream/ordinalDefaultTooltip.d.ts +10 -0
  371. package/dist/components/stream/ordinalDomain.d.ts +38 -0
  372. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +31 -0
  373. package/dist/components/stream/ordinalPulse.d.ts +10 -0
  374. package/dist/components/stream/ordinalPulseResources.d.ts +3 -0
  375. package/dist/components/stream/ordinalSceneBuilders/sceneBuilderMap.d.ts +5 -0
  376. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
  377. package/dist/components/stream/ordinalSpatialIndex.d.ts +9 -0
  378. package/dist/components/stream/ordinalTypes.d.ts +68 -9
  379. package/dist/components/stream/paintNeeds.d.ts +31 -0
  380. package/dist/components/stream/physics/CapacityQueueController.d.ts +5 -0
  381. package/dist/components/stream/physics/CapacityQueueTypes.d.ts +134 -0
  382. package/dist/components/stream/physics/MatterPhysicsEngineAdapter.d.ts +42 -0
  383. package/dist/components/stream/physics/PhysicsAccessibility.d.ts +48 -0
  384. package/dist/components/stream/physics/PhysicsAnnotations.d.ts +58 -0
  385. package/dist/components/stream/physics/PhysicsBodyBudget.d.ts +26 -0
  386. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +10 -0
  387. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +26 -0
  388. package/dist/components/stream/physics/PhysicsControllers.d.ts +75 -0
  389. package/dist/components/stream/physics/PhysicsEngineAdapter.d.ts +59 -0
  390. package/dist/components/stream/physics/PhysicsEngineConformance.d.ts +23 -0
  391. package/dist/components/stream/physics/PhysicsEvidence.d.ts +25 -0
  392. package/dist/components/stream/physics/PhysicsKernel.d.ts +207 -0
  393. package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +12 -0
  394. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +86 -0
  395. package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +181 -0
  396. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +78 -0
  397. package/dist/components/stream/physics/PhysicsSediment.d.ts +69 -0
  398. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +18 -0
  399. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +21 -0
  400. package/dist/components/stream/physics/PhysicsWorkerClient.d.ts +24 -0
  401. package/dist/components/stream/physics/PhysicsWorkerProtocol.d.ts +101 -0
  402. package/dist/components/stream/physics/PhysicsWorkerRuntime.d.ts +5 -0
  403. package/dist/components/stream/physics/RapierPhysicsEngineAdapter.d.ts +18 -0
  404. package/dist/components/stream/physics/ServiceOperationsControllers.d.ts +27 -0
  405. package/dist/components/stream/physics/ServiceOperationsTypes.d.ts +89 -0
  406. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +6 -0
  407. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +317 -0
  408. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +27 -0
  409. package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
  410. package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
  411. package/dist/components/stream/physics/physicsPipelineControls.d.ts +4 -0
  412. package/dist/components/stream/physics/physicsPipelineHelpers.d.ts +41 -0
  413. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +14 -0
  414. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +27 -0
  415. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +54 -0
  416. package/dist/components/stream/physics/physicsSemanticUI.d.ts +20 -0
  417. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +18 -0
  418. package/dist/components/stream/pipelineBufferUtils.d.ts +26 -0
  419. package/dist/components/stream/pipelineConfig.d.ts +179 -0
  420. package/dist/components/stream/pipelineDecay.d.ts +21 -3
  421. package/dist/components/stream/pipelineDomainResolution.d.ts +62 -0
  422. package/dist/components/stream/pipelineIdentityOps.d.ts +26 -0
  423. package/dist/components/stream/pipelinePulse.d.ts +17 -3
  424. package/dist/components/stream/pipelineRibbons.d.ts +41 -0
  425. package/dist/components/stream/pipelineSpatialIndex.d.ts +12 -0
  426. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +33 -0
  427. package/dist/components/stream/pipelineStyleResolvers.d.ts +46 -0
  428. package/dist/components/stream/pipelineTransitions.d.ts +3 -1
  429. package/dist/components/stream/pipelineUpdateContract.d.ts +69 -0
  430. package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
  431. package/dist/components/stream/pulseFrameRefresh.d.ts +22 -0
  432. package/dist/components/stream/renderBackend.d.ts +27 -0
  433. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
  434. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
  435. package/dist/components/stream/renderers/glyphCanvasRenderer.d.ts +6 -0
  436. package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
  437. package/dist/components/stream/renderers/resolveCSSColor.d.ts +6 -0
  438. package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
  439. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +45 -0
  440. package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
  441. package/dist/components/stream/streamStoreSync.d.ts +37 -0
  442. package/dist/components/stream/streamThemeTypes.d.ts +14 -0
  443. package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
  444. package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
  445. package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
  446. package/dist/components/stream/titleLayout.d.ts +31 -0
  447. package/dist/components/stream/types.d.ts +165 -72
  448. package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
  449. package/dist/components/stream/useFrame.d.ts +44 -2
  450. package/dist/components/stream/useHydration.d.ts +6 -0
  451. package/dist/components/stream/useLegendCategoryEmission.d.ts +5 -0
  452. package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
  453. package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
  454. package/dist/components/stream/workerModuleUrl.d.ts +10 -0
  455. package/dist/components/stream/xyAnnotationAnchors.d.ts +13 -0
  456. package/dist/components/stream/xyCanvasRenderers.d.ts +7 -0
  457. package/dist/components/stream/xyCrosshair.d.ts +11 -0
  458. package/dist/components/stream/xyDateTicks.d.ts +9 -0
  459. package/dist/components/stream/xyDefaultTooltip.d.ts +10 -0
  460. package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
  461. package/dist/components/stream/xySceneBuilders/types.d.ts +10 -9
  462. package/dist/controls.min.js +2 -0
  463. package/dist/controls.module.min.js +2 -0
  464. package/dist/forceLayoutWorker.js +1 -0
  465. package/dist/geo.min.js +1 -1
  466. package/dist/geo.module.min.js +1 -1
  467. package/dist/network.min.js +1 -1
  468. package/dist/network.module.min.js +1 -1
  469. package/dist/ordinal.min.js +1 -1
  470. package/dist/ordinal.module.min.js +1 -1
  471. package/dist/physics-matter.min.js +1 -0
  472. package/dist/physics-matter.module.min.js +1 -0
  473. package/dist/physics-rapier.min.js +1 -0
  474. package/dist/physics-rapier.module.min.js +1 -0
  475. package/dist/physics.min.js +2 -0
  476. package/dist/physics.module.min.js +2 -0
  477. package/dist/physicsWorker.js +1 -0
  478. package/dist/realtime.min.js +1 -1
  479. package/dist/realtime.module.min.js +1 -1
  480. package/dist/rough.min.js +1 -0
  481. package/dist/rough.module.min.js +1 -0
  482. package/dist/semiotic-ai-chunk-OG7BQUUW.module.min.js +2 -0
  483. package/dist/semiotic-ai-core.d.ts +47 -0
  484. package/dist/semiotic-ai-core.min.js +1 -0
  485. package/dist/semiotic-ai-core.module.min.js +1 -0
  486. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +2 -0
  487. package/dist/semiotic-ai.d.ts +53 -9
  488. package/dist/semiotic-ai.min.js +1 -1
  489. package/dist/semiotic-ai.module.min.js +1 -1
  490. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +2 -0
  491. package/dist/semiotic-controls.d.ts +20 -0
  492. package/dist/semiotic-data.min.js +1 -1
  493. package/dist/semiotic-data.module.min.js +1 -1
  494. package/dist/semiotic-experimental.d.ts +38 -9
  495. package/dist/semiotic-experimental.min.js +1 -1
  496. package/dist/semiotic-experimental.module.min.js +1 -1
  497. package/dist/semiotic-geo.d.ts +15 -0
  498. package/dist/semiotic-network.d.ts +15 -0
  499. package/dist/semiotic-ordinal.d.ts +14 -0
  500. package/dist/semiotic-physics-matter.d.ts +10 -0
  501. package/dist/semiotic-physics-rapier.d.ts +9 -0
  502. package/dist/semiotic-physics.d.ts +60 -0
  503. package/dist/semiotic-realtime-core.d.ts +34 -0
  504. package/dist/semiotic-realtime-core.min.js +1 -0
  505. package/dist/semiotic-realtime-core.module.min.js +1 -0
  506. package/dist/semiotic-realtime-react.d.ts +10 -0
  507. package/dist/semiotic-realtime-react.min.js +2 -0
  508. package/dist/semiotic-realtime-react.module.min.js +2 -0
  509. package/dist/semiotic-realtime.d.ts +4 -30
  510. package/dist/semiotic-recipes-core.d.ts +92 -0
  511. package/dist/semiotic-recipes-core.min.js +1 -0
  512. package/dist/semiotic-recipes-core.module.min.js +1 -0
  513. package/dist/semiotic-recipes-react.d.ts +7 -0
  514. package/dist/semiotic-recipes-react.min.js +2 -0
  515. package/dist/semiotic-recipes-react.module.min.js +2 -0
  516. package/dist/semiotic-recipes.d.ts +4 -43
  517. package/dist/semiotic-recipes.min.js +1 -1
  518. package/dist/semiotic-recipes.module.min.js +1 -1
  519. package/dist/semiotic-rough.d.ts +4 -0
  520. package/dist/semiotic-server-edge.d.ts +8 -0
  521. package/dist/semiotic-server-edge.min.js +1 -0
  522. package/dist/semiotic-server-edge.module.min.js +1 -0
  523. package/dist/semiotic-server-node.d.ts +5 -0
  524. package/dist/semiotic-server-node.min.js +1 -0
  525. package/dist/semiotic-server-node.module.min.js +1 -0
  526. package/dist/semiotic-server.d.ts +2 -2
  527. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +2 -0
  528. package/dist/semiotic-themes-core.d.ts +53 -0
  529. package/dist/semiotic-themes-core.min.js +1 -0
  530. package/dist/semiotic-themes-core.module.min.js +1 -0
  531. package/dist/semiotic-themes-react.d.ts +4 -0
  532. package/dist/semiotic-themes-react.min.js +2 -0
  533. package/dist/semiotic-themes-react.module.min.js +2 -0
  534. package/dist/semiotic-themes.d.ts +6 -76
  535. package/dist/semiotic-themes.min.js +1 -2
  536. package/dist/semiotic-themes.module.min.js +1 -2
  537. package/dist/semiotic-utils-core.d.ts +50 -0
  538. package/dist/semiotic-utils-core.min.js +1 -0
  539. package/dist/semiotic-utils-core.module.min.js +1 -0
  540. package/dist/semiotic-utils-react.d.ts +5 -0
  541. package/dist/semiotic-utils-react.min.js +2 -0
  542. package/dist/semiotic-utils-react.module.min.js +2 -0
  543. package/dist/semiotic-utils.d.ts +3 -39
  544. package/dist/semiotic-utils.min.js +1 -2
  545. package/dist/semiotic-utils.module.min.js +1 -2
  546. package/dist/semiotic-value.min.js +1 -1
  547. package/dist/semiotic-value.module.min.js +1 -1
  548. package/dist/semiotic-xy.d.ts +12 -0
  549. package/dist/semiotic.d.ts +44 -8
  550. package/dist/semiotic.min.js +1 -1
  551. package/dist/semiotic.module.min.js +1 -1
  552. package/dist/server.min.js +1 -1
  553. package/dist/server.module.min.js +1 -1
  554. package/dist/test-utils/capturedFrameProps.d.ts +67 -0
  555. package/dist/test-utils/frameMock.d.ts +12 -9
  556. package/dist/xy-chunk-IWD6IB6V.module.min.js +2 -0
  557. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +2 -0
  558. package/dist/xy.min.js +1 -1
  559. package/dist/xy.module.min.js +1 -1
  560. package/package.json +259 -88
  561. package/spec/README.md +152 -0
  562. package/spec/bindings/README.md +35 -0
  563. package/spec/bindings/vega-lite.mjs +112 -0
  564. package/spec/v0.1/annotation-provenance.schema.json +127 -0
  565. package/spec/v0.1/audience-profile.schema.json +67 -0
  566. package/spec/v0.1/chart-capability.schema.json +186 -0
  567. package/dist/components/recipes/gofish.d.ts +0 -207
  568. package/dist/components/recipes/gofishInterpreter.d.ts +0 -52
  569. package/dist/components/recipes/gofishLambdas.d.ts +0 -145
  570. package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +0 -2
  571. package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +0 -1
  572. package/dist/semiotic-semiotic-BmrYbi99.js +0 -2
  573. package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +0 -1
  574. package/dist/xy-semiotic-xy-Dufu3D0-.js +0 -2
  575. package/dist/xy-statisticalOverlays-3Ni9bRph.js +0 -1
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- export{A as AccessibleNavTree,b as AreaChart,c as AreaChartCapability,B as BUILT_IN_AUDIENCES,d as BUILT_IN_INTENT_IDS,e as BarChart,f as BarChartCapability,h as BigNumber,i as BoxPlot,j as BoxPlotCapability,k as BubbleChart,l as BubbleChartCapability,C as CANONICAL_FIXTURES,m as CandlestickChart,n as CandlestickChartCapability,o as CategoryColorProvider,p as ChartContainer,q as ChartGrid,r as ChordDiagram,s as ChordDiagramCapability,t as ChoroplethMapCapability,u as CirclePack,v as CirclePackCapability,w as ConnectedScatterplot,x as ConnectedScatterplotCapability,y as ContextLayout,D as DEFAULT_LIFECYCLE_THRESHOLDS,z as DEFAULT_SCALE_THRESHOLDS,E as DetailsPanel,F as DifferenceChart,G as DifferenceChartCapability,H as DistanceCartogramCapability,I as DonutChart,J as DonutChartCapability,K as DotPlot,L as DotPlotCapability,M as FlowMapCapability,N as ForceDirectedGraph,O as ForceDirectedGraphCapability,P as FunnelChart,Q as FunnelChartCapability,R as GaugeChart,S as GaugeChartCapability,T as GroupedBarChart,U as GroupedBarChartCapability,V as Heatmap,W as HeatmapCapability,X as Histogram,Y as HistogramCapability,Z as LikertChart,_ as LikertChartCapability,$ as LineChart,a0 as LineChartCapability,a1 as LinkedCharts,a2 as MinimapChart,a3 as MinimapChartCapability,a4 as MultiAxisLineChart,a5 as MultiAxisLineChartCapability,a6 as MultiLineTooltip,a7 as OrbitDiagram,a8 as OrbitDiagramCapability,a9 as PieChart,aa as PieChartCapability,ab as ProcessSankey,ac as ProcessSankeyCapability,ad as ProportionalSymbolMapCapability,ae as QuadrantChart,af as QuadrantChartCapability,ag as RealtimeHeatmap,ah as RealtimeHistogram,ai as RealtimeLineChart,aj as RealtimeSwarmChart,ak as RealtimeWaterfallChart,al as RidgelinePlot,am as RidgelinePlotCapability,an as SankeyDiagram,ao as SankeyDiagramCapability,ap as Scatterplot,aq as ScatterplotCapability,ar as ScatterplotMatrix,as as StackedAreaChart,at as StackedAreaChartCapability,au as StackedBarChart,av as StackedBarChartCapability,aw as SwarmPlot,ax as SwarmPlotCapability,ay as SwimlaneChart,az as SwimlaneChartCapability,aA as TemporalHistogram,aB as ThemeProvider,aC as TooltipProvider,aD as TreeDiagram,aE as TreeDiagramCapability,aF as Treemap,aG as TreemapCapability,aH as ViolinPlot,aI as ViolinPlotCapability,aJ as accessibilityCaveats,aK as analystPersona,aL as annotationFreshnessFor,aM as applyAnnotationLifecycle,aN as applyAnnotationStatus,aO as applyAudienceBias,aP as applyScaleBias,aQ as auditAccessibility,aR as bandFromAge,aS as buildDataPitfallsBridge,aT as buildNavigationTree,aU as buildReaderGrounding,aV as chartGenerationTool,aW as classifyCardinalityBand,aX as classifyFieldBand,aY as classifyRowBand,aZ as clearVariantDiscovery,a_ as communicativeActForIntent,a$ as compareBands,b0 as computeAnnotationFreshness,b1 as computeEffectiveScale,b2 as configToJSX,b3 as copyConfig,b4 as countNodes,b5 as createChartToolHandler,b6 as createIndexedDBConversationArcSink,b7 as createLocalStorageConversationArcSink,b8 as createWebhookConversationArcSink,b9 as currentTimestamp,ba as dataQualityToAnnotations,bb as dataScientistPersona,bc as describeChart,bd as deserializeSelections,be as diagnoseConfig,bf as diffProfile,bg as disableConversationArc,bh as effectiveFamiliarity,bi as enableConversationArc,bj as evaluateVariantProposal,bk as executivePersona,bl as explainCapabilityFit,bm as exportChart,bn as filterAnnotationsByStatus,bo as flattenVisible,bp as formatAccessibilityAudit,bq as fromConfig,br as fromDbtArtifacts,bs as fromGreatExpectations,bt as fromURL,bu as fromVegaLite,bv as getCapabilities,bw as getCapability,bx as getConversationArcStore,by as getIntent,bz as getRegisteredVariantDiscovery,bA as getStreamCapabilities,bB as inferIntent,bC as listIntents,bD as loadConversationArc,bE as prepareChart,bF as profileData,bG as proposeVariant,bH as receivabilityBias,bI as recordAnnotationStatusChange,bJ as recordAudienceChange,bK as registerChartCapability,bL as registerConversationArcSink,bM as registerIntent,bN as registerStreamChartCapability,bO as registerVariantDiscovery,bP as repairChartConfig,bQ as replayConversationArc,bR as resolveCardinalityToNumber,bS as resolveCommunicativeAct,bT as resolveRowsToNumber,bU as runQualityScorecard,bV as scaleHints,bW as scoreChart,bX as serializeSelections,bY as stretchFamiliarityCeiling,bZ as subscribeToConversationArcChange,b_ as suggestCharts,b$ as suggestChartsGrouped,c0 as suggestDashboard,c1 as suggestStreamCharts,c2 as suggestStretchCharts,c3 as summarizeArc,c4 as summarizeData,c5 as toAnthropicTool,c6 as toConfig,c7 as toDataPitfallsChain,c8 as toOpenAITool,c9 as toURL,ca as unregisterChartCapability,cb as unregisterStreamChartCapability,cc as useBrushSelection,cd as useCategoryColors,ce as useChartFocus,cf as useChartInterrogation,cg as useChartObserver,ch as useChartSuggestions,ci as useConversationArc,cj as useFilteredData,ck as useLinkedHover,cl as useNavigationSync,cm as useSelection,cn as useTheme,co as validateProps,cp as withCurrentProvenance,cq as withProvenance}from"./semiotic-ai-semiotic-ai-u954ylUn.js";import"react/jsx-runtime";import"react";import"d3-selection";import"d3-brush";import"d3-scale";import"d3-quadtree";import"d3-shape";import"d3-array";import"d3-hierarchy";import"regression";import"d3-interpolate";import"d3-force";import"d3-chord";
2
+ import{getMax as e,getMin as t,getMinMax as n}from"./semiotic-ai-chunk-OG7BQUUW.module.min.js";import{useMemo as o,useCallback as r,useState as i,useEffect as a,forwardRef as s,useRef as c}from"react";var l=Object.freeze([]);function u(e){if(!e)return l;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}import*as d from"react";import{useRef as h,useState as p,useEffect as m,useMemo as f,useCallback as y,useImperativeHandle as g,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 R({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:n}={}){const o=I.useId().replace(/:/g,""),r=I.useRef(n);return r.current=n,{description:t,descriptionId:"semiotic-brush-description-"+o,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+o,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(),r.current?.(t))},[])}}}import{jsx as _,jsxs as T}from"react/jsx-runtime";function L(e,t,n,o){const[r,i]=[Math.min(...t),Math.max(...t)],a=(i-r)/20;let[s,c]=e;if(o)0>n?s=Math.max(r,s-a):c=Math.min(i,c+a);else{const e=c-s;s=Math.max(r,Math.min(i-e,s+n*a)),c=s+e}return[s,c]}function N(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function $(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function B({width:e,height:t,totalWidth:n,totalHeight:o,margin:r,dimension:i,scales:a,onBrush:s,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:h}){const p=w(null),m=w(null),f=w(s);f.current=s;const y=w(a);y.current=a;const g=S(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),b=w(g);b.current=g;const v=w(!1),x=w(null),I=R({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=y.current,n=m.current;if(!t||!n||!p.current)return;const o=A(p.current).select(".brush-g");if("clear"===e.type)return v.current=!0,o.call(n.move,null),v.current=!1,x.current=null,void f.current(null);const r=t.x.domain(),a=t.y.domain(),s=x.current;let c=s?.x??[r[0]+.4*(r[1]-r[0]),r[0]+.6*(r[1]-r[0])],l=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&&(c=L(c,r,d,e.resize)),u||"x"===i||(l=L(l,a,d,e.resize)),u&&"y"===i||!u&&"x"===i)return;const h={x:c,y:l};v.current=!0,o.call(n.move,"x"===i?[t.x(c[0]),t.x(c[1])]:"y"===i?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),v.current=!1,x.current=h,f.current(h)}});return k(()=>{if(!p.current)return;const n=A(p.current).select(".brush-g"),o="x"===i?M():"y"===i?P():C();return o.extent([[0,0],[e,t]]),o.on("brush end",r=>{if(v.current)return;const a=y.current;if(!a)return;if(!r.selection)return x.current=null,void f.current(null);let s,u;if("x"===i){const[e,n]=r.selection;s=[a.x.invert(e),a.x.invert(n)],u=[a.y.invert(t),a.y.invert(0)]}else if("y"===i){const[t,n]=r.selection;s=[a.x.invert(0),a.x.invert(e)],u=[a.y.invert(n),a.y.invert(t)]}else{const[[e,t],[n,o]]=r.selection;s=[a.x.invert(e),a.x.invert(n)],u=[a.y.invert(o),a.y.invert(t)]}if("bin"===l&&"y"!==i&&("end"===r.type||"brush"===r.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):c&&c>0&&(s=[Math.floor(s[0]/c)*c,Math.ceil(s[1]/c)*c]);const t=a.x(s[0]),l=a.x(s[1]);if(v.current=!0,"x"===i)n.call(o.move,[t,l]);else if("xy"===i){const e=r.selection;n.call(o.move,[[t,e[0][1]],[l,e[1][1]]])}v.current=!1}const h={x:s,y:u};x.current=h,f.current(h)}),n.call(o),m.current=o,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),m.current=null}},[e,t,i,l,c,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],n=A(p.current).select(".brush-g");if(t>=e.x[1])return v.current=!0,n.call(m.current.move,null),v.current=!1,x.current=null,void f.current(null);let o=e.x[0],r=!1;if(t>e.x[0]){if(o=t,"bin"===l){const e=b.current;e&&e.length>0?o=$(t,e):c&&c>0&&(o=Math.ceil(t/c)*c)}if(o>=e.x[1])return v.current=!0,n.call(m.current.move,null),v.current=!1,x.current=null,void f.current(null);r=!0}const s=a.x(o),u=a.x(e.x[1]);if(v.current=!0,"x"===i)n.call(m.current.move,[s,u]);else{const t=a.y(e.y[1]),o=a.y(e.y[0]);n.call(m.current.move,[[s,t],[u,o]])}if(v.current=!1,r){const t={x:[o,e.x[1]],y:e.y};x.current=t,f.current(t)}},[a,h,i,l,c]),T("svg",{ref:p,width:n,height:o,...I.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[_("title",{children:I.svgProps["aria-label"]}),_("desc",{id:I.descriptionId,children:I.description}),_("g",{className:"brush-g",transform:`translate(${r.left},${r.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 n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}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 n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}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 n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),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 j,useCallback as E,useContext as F,useMemo as O,useRef as z,useSyncExternalStore as H}from"react";import{jsx as W}from"react/jsx-runtime";function G(e){let t=null;const n=()=>(t||(t=j(null)),t),o=q(e);return[function({children:t,initialState:o}){const r=z(o),i=O(()=>q(e,r.current),[]),a=n();return W(a.Provider,{value:i,children:t})},(e,t)=>{const r=n(),i=F(r)??o,a=z(e);a.current=e;const s=z({hasValue:!1,value:void 0}),c=E(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),l=E(()=>a.current(i.getState()),[i]);return H(i.subscribe,c,l)}]}function q(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){o={...o,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>o,subscribe:function(e){return n.add(e),()=>{n.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]=G(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 n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;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 n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,o=[];t.length>e&&(n=t.length-e,o=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return o}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,a=this.buffer[i];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},n.push(e),this.buffer[i]=t(a)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},ne=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 n of e){const e=t?t(n):n;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 oe(e,t){return e===t}function re(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function ie(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}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 ce(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=se.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const o=Date.parse(n);return Number.isFinite(o)?o:NaN}function le(e){return e instanceof Date?e.getTime():"string"==typeof e?ce(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,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function me(e){const t=e.map(he),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return pe(e,n,o)}if(e>=1){const[e,o,r]=t[n];return pe(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[a,s,c]=t[r],[l,u,d]=t[r+1];return pe(Math.round(a+(l-a)*i),Math.round(s+(u-s)*i),Math.round(c+(d-c)*i))}}var fe=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ye=me(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ge=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:ye,reds:ge,greens:be,viridis:ke,oranges:ve,purples:xe,greys:we,plasma:Se,inferno:Ae,magma:Ce,cividis:Me,turbo:Pe};function Re(e){return e&&Ie[e]||ye}var _e=me(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Te=me(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Le=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"]),je={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,Fe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Oe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],ze=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,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||ze.has(t)}(o)?n(o):o}const o=e?.[t]+"";return n?n(o):Ee[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%Ee.length]}function We(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ge(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>We(e,t)??"#999"}const o=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return de().domain(o).range(n).unknown("#999");const i=je[n]||je.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Ee;return de().domain(o).range(e).unknown("#999")}}function qe(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e?.[t],!o)return r;const[i,a]=o,[s,c]=n;if(a===i)return(s+c)/2;let l=(r-i)/(a-i);return 0>l?l=0:l>1&&(l=1),s+l*(c-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,n){return e+(t-e)*n}function Ue(){return"undefined"!=typeof performance?performance.now():Date.now()}var Ke={fresh:1,aging:1.5,stale:3};function Qe(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}function Ze(e,t,n){if(1>=n)return 1;const o=n-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 n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const o=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(o>0?o:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:o-t,extent:o,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Je(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function et(e,t,n){const o=e.duration??500,r=n-t;return o>r?1-r/o:0}function tt(e,t,n,o){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==o&&(e._pulseGlowRadius=o,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function nt(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const o=e.duration??500,r=t.peek();return null!=r&&o>n-r}function ot(e,t,n){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 n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function rt(e,t,n,o,r,i){const a=[];for(const r of e){const e=n(r),i=o(r);Number.isFinite(e)&&Number.isFinite(i)&&a.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}a.sort((e,t)=>e.px-t.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let e=0;a.length>e;e++){const t=a[e];s[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:s,rawValues:c,style:r,datum:l,group:i}}function it(e,t,n,o,r,i,a,s){const c=[];for(const i of e){const e=n(i),a=o(i);if(!Number.isFinite(e)||!Number.isFinite(a))continue;const l=t.x(e),u=s?s(i):r;c.push({px:l,topY:t.y(a),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:i,datum:e,group:a}}function at(e,t,n,o){const r=new Map;if("silhouette"===o)for(const o of e){let e=0;for(const r of t)e+=n(r,o)||0;r.set(o,-e/2)}else if("wiggle"===o){e.length>0&&r.set(e[0],0);for(let o=1;e.length>o;o++){const i=e[o-1],a=e[o];let s=0,c=0,l=0;for(const e of t){const t=n(e,a)||0;s+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=r.get(i)??0;r.set(a,u-(c>0?s/(2*c):0))}if(e.length>0){let o=0;for(const i of e){let e=0;for(const o of t)e+=n(o,i)||0;o+=(r.get(i)??0)+e/2}const i=o/e.length;for(const t of e)r.set(t,(r.get(t)??0)-i)}}else for(const t of e)r.set(t,0);return r}function st(e,t,n,o,r,i,a){const s=n(e),c=o(e);if(!Number.isFinite(s)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(s),y:t.y(c),r:r,style:i,datum:e};return void 0!==a&&(l.pointId=a),l}function ct(e,t,n,o,r,i,a,s){const c=n(e),l=o(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:i,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function lt(e,t,n,o,r,i,a){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:a}}function ut(e,t,n,o,r,i,a){const s={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return a?.showValues&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function dt(e,t,n,o){return"function"==typeof t.style?t.style(o||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,o)}function ht(e,t,n,o){if(!e.scales)return null;const r=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const a=o.getTop(n),s=o.getBottom(n);if(!Number.isFinite(a)||!Number.isFinite(s))continue;const c=e.scales.x(t),l=e.scales.y(a),u=e.scales.y(s);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),i.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,style:dt(e,o,n,t[0]),datum:t,group:n,interactive:o.interactive}}function pt(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const o of e)o.perSeries?t.push(o):n.push(o);return{perSeries:t,aggregate:n}}function mt(e,t,n){const o=[];for(const r of n){const n=ht(e,t,"__ribbon_aggregate",r);n&&o.push(n)}return o}function ft(e,t,n,o){const r=[];for(const i of o){const o=ht(e,t,n,i);o&&r.push(o)}return r}function yt(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const o of t){if("band"!==o.kind)continue;const t=o.getTop(e),r=o.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function gt(e,t,n,o){if(!e.config.pointStyle)return;const r=o??e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const i of o.data){let o=e.config.pointStyle(i);!o.fill&&t&&(o={...o,fill:t});const a=o.r??3,s=e.getPointId?e.getPointId(i)+"":void 0,c=st(i,e.scales,e.getX,r,a,o,s);c&&n.push(c)}}}function bt(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var vt={topOpacity:.8,bottomOpacity:.05};function xt(e){if(e)return!0===e?vt:"colorStops"in e?e:{topOpacity:e.topOpacity??vt.topOpacity,bottomOpacity:e.bottomOpacity??vt.bottomOpacity}}import{symbol as wt,symbolCircle as kt,symbolCross as St,symbolDiamond as At,symbolSquare as Ct,symbolStar as Mt,symbolTriangle as Pt,symbolWye as It}from"d3-shape";var Rt={circle:kt,square:Ct,triangle:Pt,diamond:At,star:Mt,cross:St,wye:It},_t=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Tt(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*Lt(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):wt(Rt[o]??kt,Math.max(1,t))()??""}function Lt(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var Nt=new Map;function $t(e,t,n,o,r){const i=new Map;for(const a of e){const e=t(a),s=n(a);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=Math.floor(e/o)*o;let l=i.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},i.set(c,l)),l.total+=s,r){const e=r(a);l.categories.set(e,(l.categories.get(e)||0)+s)}}return i}function Bt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;Dt(o)&&0===n.length&&jt(r,"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.`),n.length>0&&n.every(e=>null==e.datum)&&jt(r,"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 Dt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Dt))}function jt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function Et(e,t,n,o){const r=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: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:o}}function Ft(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function Ot(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,o=Ft(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=re(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:Ft(e.y1Accessor,"y1"),getBottom:Ft(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as zt,scaleLog as Ht,scaleSymlog as Wt,scaleTime as Gt}from"d3-scale";function qt(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Yt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return Ht().domain(e).range(n).clamp(!0)}return"symlog"===e?Wt().domain(t).range(n):"time"===e?Gt().domain([new Date(t[0]),new Date(t[1])]).range(n):zt().domain(t).range(n)}function Vt(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function Xt(e,t){const n=new te(e.capacity);return e.forEach(()=>n.push(t)),n}function Ut(e,t,n,o){const r=e.push(t);return n&&n.push(o),r}function Kt(e,t,n){if(!t||0===t.size)return;const o=new Set;if(e.forEach((e,t)=>{n(e)&&o.add(t)}),0===o.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)o.has(e)||t.push(r[e])}var Qt=new WeakMap;function Zt(){return this.updateResults.last}function Jt(){return this.updateResults.last}function en(e){return this.updateResults.subscribe(e)}function tn(e){this.config.layoutSelection=e}function nn(){Qt.set(this,!0)}function on(){const e=!0===Qt.get(this);return Qt.delete(this),e}function rn(e){Object.assign(e.prototype,{getLastUpdateResult:Zt,getUpdateSnapshot:Jt,subscribeUpdateResult:en,setLayoutSelection:tn,markStylePaintPending:nn,consumeStylePaintPending:on})}var an={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 sn(e,t){const n={...e};for(const e of t)n[an[e]]++;return n}function cn(e,t,n){const o=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:o,revisions:sn(n,o)}}var ln=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=cn({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=cn(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},un=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dn=["scene-style","data-paint","accessibility","evidence"],hn=(e,t)=>({retainedData:e,invalidations:t}),pn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gn=["scene-geometry","data-paint","accessibility","evidence"],bn=["scene-style","data-paint","accessibility","evidence"],vn=[],xn={chartType:hn("rebuild",pn),runtimeMode:hn("rebuild",pn),xAccessor:hn("rebuild",pn),yAccessor:hn("rebuild",pn),timeAccessor:hn("rebuild",pn),valueAccessor:hn("rebuild",pn),y0Accessor:hn("rebuild",pn),boundsAccessor:hn("rebuild",pn),band:hn("rebuild",pn),openAccessor:hn("rebuild",pn),highAccessor:hn("rebuild",pn),lowAccessor:hn("rebuild",pn),closeAccessor:hn("rebuild",pn),candlestickRangeMode:hn("rebuild",pn),accessorRevision:hn("rebuild",pn),groupAccessor:hn("rebuild",mn),categoryAccessor:hn("rebuild",mn),lineDataAccessor:hn("rebuild",mn),colorAccessor:hn("rebuild",bn),sizeAccessor:hn("rebuild",gn),symbolAccessor:hn("rebuild",gn),pointIdAccessor:hn("rebuild",gn),xScaleType:hn("preserve",fn),yScaleType:hn("preserve",fn),xExtent:hn("preserve",fn),yExtent:hn("preserve",fn),extentPadding:hn("preserve",fn),scalePadding:hn("preserve",fn),axisExtent:hn("preserve",fn),binSize:hn("preserve",fn),normalize:hn("preserve",fn),heatmapAggregation:hn("preserve",fn),heatmapXBins:hn("preserve",fn),heatmapYBins:hn("preserve",fn),arrowOfTime:hn("preserve",yn),baseline:hn("preserve",yn),stackOrder:hn("preserve",yn),sizeRange:hn("preserve",yn),curve:hn("preserve",yn),areaGroups:hn("preserve",yn),customLayout:hn("preserve",yn),layoutConfig:hn("preserve",yn),layoutMargin:hn("preserve",yn),symbolMap:hn("preserve",gn),showValues:hn("preserve",gn),heatmapValueFormat:hn("preserve",gn),lineStyle:hn("preserve",bn),pointStyle:hn("preserve",bn),areaStyle:hn("preserve",bn),barStyle:hn("preserve",bn),swarmStyle:hn("preserve",bn),waterfallStyle:hn("preserve",bn),candlestickStyle:hn("preserve",bn),boundsStyle:hn("preserve",bn),gradientFill:hn("preserve",bn),lineGradient:hn("preserve",bn),colorScheme:hn("preserve",bn),themeCategorical:hn("preserve",bn),themeSemantic:hn("preserve",bn),themeSequential:hn("preserve",bn),themeDiverging:hn("preserve",bn),barColors:hn("preserve",bn),decay:hn("preserve",bn),pulse:hn("preserve",bn),staleness:hn("preserve",bn),layoutSelection:hn("preserve",bn),annotations:hn("preserve",["overlay","accessibility","evidence"]),windowSize:hn("preserve",vn),windowMode:hn("preserve",vn),maxCapacity:hn("preserve",vn),clock:hn("preserve",vn),transition:hn("preserve",vn),introAnimation:hn("preserve",vn),onLayoutError:hn("preserve",vn)},wn=hn("preserve",yn),kn=class{constructor(){this.tracker=new ln}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},un)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},dn):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=xn[o]??wn;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as Sn}from"d3-quadtree";var An=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 n=0,o=0;for(const e of t)"point"===e.type&&(n++,e.r>o&&(o=e.r));if(this.maxRadius=o,500>=n)return void(this.tree=null);const r=Array(n);let i=0;for(const e of t)"point"===e.type&&(r[i++]=e);this.tree=Sn().x(e=>e.x).y(e=>e.y).addAll(r)}},Cn=class e{constructor(e){if(this.xExtent=new ne,this.yExtent=new ne,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 kn,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 An,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i=("undefined"!=typeof performance?performance.now():Date.now())){const a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4;let c=!1;const l=r??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0,s=!1;for(const n of t){const t=l.get(n);if(null==t)continue;s=!0;const a=o.get(t);if(null==a)continue;const c=et(e,a,i);c>r&&(r=c)}s&&(c=tt(n,r,a)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=o.get(t);c=tt(n,null==r?0:et(e,r,i),a,s)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new te(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=re(e.timeAccessor||e.xAccessor,"time"),this.getY=re(e.valueAccessor||e.yAccessor,"value")):(this.getX=re(e.xAccessor,"x"),this.getY=re(e.yAccessor,"y")),this.getGroup=ae(e.groupAccessor),this.getCategory=ae(e.categoryAccessor),this.getSize=e.sizeAccessor?re(e.sizeAccessor,"size"):void 0,this.getColor=ae(e.colorAccessor),this.getSymbol=ae(e.symbolAccessor),this.getY0=e.y0Accessor?re(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ot(e),this.getPointId=ae(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?re(e.openAccessor,"open"):void 0,this.getHigh=re(e.highAccessor,"high"),this.getLow=re(e.lowAccessor,"low"),this.getClose=n?re(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new te(e.windowSize))}currentTime(){return this.config.clock?.()??Ue()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Xt(this.buffer,this.currentTime())):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 n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}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 n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}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=this.currentTime();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 n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?re(this.config.timeAccessor||this.config.xAccessor,"time"):re(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&Number.isFinite(ce(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>le(t[e]):e=>le(n(e))}}Vt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)Ut(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n 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=Ut(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),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:n}=this,o=this.scales,r=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(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),a=this.yExtent.extent;let s=qt(this.xExtent.extent,t.xExtent),c=qt(a,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:o,getY:r}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}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,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=o(i),a=r(i);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),c.add(e),n+=a;const s=(u.get(e)||0)+a;u.set(e,s),s>l&&(l=s)}s.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",p=(e,t)=>t>e?-1:e>t?1:0;let m,f;if("input"===h)m=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:p(e,t)}),t=[],o=[];let r=0,i=0;for(const n of e)i>r?(t.push(n),r+=d.get(n)??0):(o.push(n),i+=d.get(n)??0);m=[...o.reverse(),...t]}else m="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:p(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:p(e,t)}):n.map(e=>e.key).sort(p);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=at(e,m,(e,t)=>s.get(e)?.get(t)||0,t.baseline);let o=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;o>e&&(o=e),e+i>r&&(r=e+i)}Number.isFinite(o)&&Number.isFinite(r)||(o=0,r=0);const a=r-o,l=i?0:a>0?a*t.extentPadding:1;f=[o-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,o]=function(e,t,n){let o=0,r=0;for(const i of e){let e=0,a=0;for(const o of t){const t=n(o,i)||0;0>t?a+=t:e+=t}o>a&&(o=a),e>r&&(r=e)}return[o,r]}(e,m,(e,t)=>s.get(e)?.get(t)||0),r=o-n,a=i?0:r>0?r*t.extentPadding:1;f=[n-a,o+a]}else f=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:a,yDomain:f}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,o,r,i,a){const[,s]=function(e,t,n,o,r){const i=$t(e,t,n,o,r);if(0===i.size)return[0,0];let a=0;for(const e of i.values())e.total>a&&(a=e.total);return[0,a]}(e,t,n,o,r);return[0,a?s:s+s*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,o){const[r,i]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(e,t),a=i-r,s=o?0:a>0?a*n:1;return[Math.min(0,r-Math.abs(s)),Math.max(0,i+Math.abs(s))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[o,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(o>n&&(o=n),n>r&&(r=n)),Number.isFinite(i)&&(o>i&&(o=i),i>r&&(r=i))}return[o,r]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],o=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-o,null!=t.userMax?e[1]:e[1]+o];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));c=function(e,t,n){if(!t||n)return e;const o=t[0],r=t[1];return null==o&&null==r?e:[null!=o?o:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:s,yDomain:c}=function(e,t,n){let o=e,r=t;if(o[0]===1/0||o[1]===-1/0)if("time"===n){const e=Date.now();o=[e-864e5,e]}else o=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:o,yDomain:r}}(s,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:o,yDomain:r}=e,i="streaming"===t.runtimeMode,a=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(s=t.arrowOfTime)||"down"===s?"y":"x")){const e="right"===t.arrowOfTime?[a,n.width-a]:[n.width-a,a];return{x:zt().domain(o).range(e),y:Yt(t.yScaleType,r,[n.height-a,a])}}const e="down"===t.arrowOfTime?[a,n.height-a]:[n.height-a,a];return{x:Yt(t.yScaleType,r,[a,n.width-a]),y:zt().domain(o).range(e)}}var s;return{x:Yt(t.xScaleType,o,[a,n.width-a]),y:Yt(t.yScaleType,r,[n.height-a,a])}}({config:t,layout:e,xDomain:s,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=r):(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.currentTime()),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,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),r=this.scales.y.domain(),i=this.scales.x.range(),a=this.scales.y.range(),s=Yt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=a[1]>a[0];this.scales={x:s(this.config.xScaleType,o,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:s(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o)return[];if(n.customLayout){const r={data:t,scales:o,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??Fe},resolveColor:(e,t)=>{const o=this.resolveGroupColor(e);if(o)return o;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,o=Et("xy",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.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=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,n.layoutSelection??null)}return Bt({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 r={scales:o,config:n,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(n.chartType){case"line":return function(e,t){const n=e.groupData(t),o=[],r=e.config.annotations?.filter(bt).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=pt(e.ribbons);if(i.length>0&&o.push(...mt(e,t,i)),r.length>0)for(const t of n)o.push(...ft(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=rt(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(i.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}return gt(e,n,o),o}(r,t);case"area":return function(e,t){const n=e.groupData(t),o=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=pt(e.ribbons);if(i.length>0&&o.push(...mt(e,t,i)),r.length>0)for(const t of n)o.push(...ft(e,t.data,t.key,r))}const r=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),a=it(t.data,e.scales,e.getX,e.getY,r,n,t.key,i),s=xt(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),o.push(a)}return gt(e,n,o),o}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=pt(e.ribbons);if(i.length>0&&o.push(...mt(e,t,i)),r.length>0)for(const t of n)o.push(...ft(e,t.data,t.key,r))}const i=e.scales.y.domain()[0],a=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=it(t.data,e.scales,e.getX,e.getY,i,n,t.key,a),s=xt(e.config.gradientFill);s&&(r.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=rt(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return gt(e,n,o),o}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),o=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===o);else if("key"===o)r();else if("asc"===o||"desc"===o||"insideOut"===o){const t=new Map;for(const o of n){let n=0;for(const t of o.data){const o=e.getX(t),r=e.getY(t);Number.isFinite(o)&&Number.isFinite(r)&&(n+=r)}t.set(o.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===o)n.sort((e,n)=>{const o=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==o?o:r(e.key,n.key)});else if("desc"===o)n.sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)}),o=[],i=[];let a=0,s=0;for(const n of e)s>a?(o.push(n),a+=t.get(n.key)??0):(i.push(n),s+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...o)}}else r();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:c}=function(e,t,n,o,r,i,a,s="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);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 l){let n=0;for(const o of e)n+=u.get(o.key)?.get(t)||0;d.set(t,n||1)}}const h=at(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,s),p="diverging"===s&&!i,m=[],f=new Map,y=new Map,g=new Map,b=new Map;for(const e of l)y.set(e,h.get(e)??0),g.set(e,0),b.set(e,0);for(const n of e){const e=u.get(n.key),o=new Map;let s=[],c=[];const h=()=>{if(s.length>=2){const e={type:"area",topPath:s,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};a&&(e.curve=a),m.push(e)}s=[],c=[]};for(const n of l){const r=e.has(n);let a,l,u=r?e.get(n):0;if(i&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}p?u>0?(a=g.get(n),l=a+u,g.set(n,l)):(a=b.get(n),l=a+u,b.set(n,l)):(a=y.get(n),l=a+u,y.set(n,l));const m=t.x(n);c.push([m,t.y(a)]),s.push([m,t.y(l)]),o.set(n,l)}h(),f.set(n.key,o)}return{nodes:m,stackedTops:f}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,a),l=s;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=c.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>t.get(n)??e.getY(n);gt(e,n,l,o)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=_t[d%_t.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:s,opacity:.8},l=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=i(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(r);n&&a.has(n)&&(t={...t,fill:a.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const o=h(c(r)+""),i=ct(r,e.scales,e.getX,e.getY,Math.PI*l*l,o,t,u);i&&n.push(i)}else{const o=st(r,e.scales,e.getX,e.getY,l,t,u);o&&n.push(o)}}return n}(r,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const o=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",a=re(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[s,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-s||1)/o,h=(u-l||1)/r,p=o*r;if(p>1e6)return[];const m=new Int32Array(p),f=new Float64Array(p);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const p=Math.min(Math.floor((c-s)/d),o-1),y=Math.min(Math.floor((u-l)/h),r-1);if(0>p||0>y)continue;const g=y*o+p;m[g]++;const b=a(i);f[g]+=isFinite(b)?b:0}let y=1/0,g=-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]}y>t&&(y=t),t>g&&(g=t)}if(!isFinite(y))return[];const b=g-y||1,v=n.width/o,x=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let e=0;r>e;e++){const t=e*o;for(let n=0;o>n;n++){const o=t+n;if(0===m[o])continue;let a;switch(i){case"sum":a=f[o];break;case"mean":a=f[o]/m[o];break;default:a=m[o]}const c=(a-y)/b;S.push(ut(n*v,(r-1-e)*x,v,x,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:a,count:m[o],sum:f[o],xCenter:s+(n+.5)*d,yCenter:l+(e+.5)*h,agg:i},w?{value:a,showValues:!0,valueFormat:k}:void 0))}}return S}(e,t,n);if(0===t.length)return[];const o=re(e.config.valueAccessor,"value"),r=ie(e.config.xAccessor,"x"),i=ie(e.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),u=i(n);c[e]=o,l[e]=u,a.has(o)||a.set(o,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)=>Number(e)-Number(t)),a.clear();for(let e=0;h.length>e;e++)a.set(h[e],e)}if(f){p.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;p.length>e;e++)s.set(p[e],e)}const y=new Float64Array(t.length),g=new Float64Array(t.length),b=Array(t.length),v=new Map;let x=0;for(let e=0;t.length>e;e++){const n=t[e],r=a.get(c[e]),i=s.get(l[e]);if(void 0===r||void 0===i)continue;const d=o(n),h=i*u+r,p=v.get(h);let m;void 0!==p?m=p:(m=x++,v.set(h,m)),y[m]=h,g[m]=d,b[m]=n}let w=1/0,k=-1/0;for(let e=0;x>e;e++){const t=g[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 n=Nt.get(t);if(n)return n;n=Array(256);const o=Re(t);for(let e=0;256>e;e++)n[e]=o(e/255);return Nt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),A=255/(k-w||1),C=n.width/u,M=n.height/d,P=e.config.showValues,I=e.config.heatmapValueFormat,R=[];for(let e=0;x>e;e++){const t=g[e];if(!isFinite(t))continue;const n=y[e],o=n%u;R.push(ut(o*C,(d-1-(n-o)/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 R}(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=$t(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let o=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const r=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(r),a=Array.from(t).filter(e=>!i.has(e)).sort(),s=r.filter(e=>t.has(e)),c=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?o=e.barCategoryCache.order:(o=[...s,...a],e.barCategoryCache={key:c,order:o})}const r=[],i=e.scales,[a,s]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,a),u=Math.min(t.end,s);if(n>=u)continue;const p=i.x(n),m=i.x(u),f=Math.abs(m-p),y=f>d+1?d:0,g=Math.min(p,m)+y/2,b=Math.max(f-y,1);if(b>0)if(o&&t.categories.size>0){let n=0;for(const a of o){const o=t.categories.get(a)||0;if(0===o)continue;const s=i.y(n),u=i.y(n+o);r.push(lt(g,Math.min(s,u),b,Math.abs(s-u),{fill:e.config.barColors?.[a]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:o},a)),n+=o}}else{const e=i.y(0),n=i.y(t.total);r.push(lt(g,Math.min(e,n),b,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of n.values())p.add(e.start),p.add(e.end);return{nodes:r,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],o=e.config.swarmStyle||{},r=o.radius??3,i=o.fill??e.config.themeSemantic?.primary??"#007bff",a=o.opacity??.7,s=o.stroke,c=o.strokeWidth;for(const o of t){const t=e.getX(o),l=e.getY(o);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=i;if(e.getCategory){const t=e.getCategory(o);h=e.config.barColors?.[t]||h}const{r:p,...m}=e.config.pointStyle?.(o)??{},f={type:"point",x:u,y:d,r:p??r,style:{fill:h,opacity:a,stroke:s,strokeWidth:c,...m},datum:o};e.getPointId&&(f.pointId=e.getPointId(o)+""),n.push(f)}return n}(r,t);case"waterfall":return function(e,t,n){const o=[],r=e.scales,i=e.config.waterfallStyle,a=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===a.length)return o;const s=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=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),y=e.getY(m),g=p+y;let b;b=a.length-1>t?e.getX(a[t+1])-f:t>0?f-e.getX(a[t-1]):0;const v=r.x(f),x=0!==b?r.x(f+b):v+n.width/10,w=Math.min(v,x)+l/2,k=Math.max(v,x)-l/2-w;if(0>=k){p=g;continue}const S=r.y(p),A=r.y(g),C=Math.min(S,A),M=Math.abs(S-A),P={fill:0>y?c:s,stroke:u,strokeWidth:d};null!=h&&(P.opacity=h),o.push(lt(w,C,k,M,P,{...m,baseline:p,cumEnd:g,delta:y,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),p=g}return o}(r,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const o=[],r=e.config.candlestickStyle||{},i=r.rangeColor||"#6366f1",a=n?i:r.upColor||"#28a745",s=n?i:r.downColor||"#dc3545",c=n?i:r.wickColor||"#333",l=r.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=r.bodyWidth??0;if(null==r.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const o=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));o>0&&t>o&&(t=o)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const r of t){const t=e.getX(r);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(r),u=e.getLow(r);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const h=n?i:e.getOpen(r),p=n?u:e.getClose(r);if(!n&&[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:c,wickWidth:l,isUp:m,datum:r};n&&(f.isRange=!0),o.push(f)}return o}(r,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,o){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:o(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Ze(n,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,n,o=Je(n)){const r=n.length;if(r>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let a=!1;for(let n=0;t.length>n;n++){const s=o.get(t[n]);null!=s?(i[n]=Ze(e,s,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const a=Array(i);let s=!1;for(let n=0;t.length>n;n++){const i=o.get(t[n]);null!=i?(a[n]=Ze(e,i,r),1>a[n]&&(s=!0)):a[n]=1}s&&(n._decayOpacities=a)}else{let a=1;for(const n of t){const t=o.get(n);if(null!=t){const n=Ze(e,t,r);a>n&&(a=n)}}if(1>a){const e=Array(i);e.fill(a),n._decayOpacities=e}}continue}const t=o.get(n.datum);if(null==t)continue;const i=Ze(e,t,r);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.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&&nt(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){n.clear(),o.clear();for(let r=0;t.length>r;r++){const i=t[r],a=ot(e,i,r);a&&("point"===i.type?n.set(a,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(a,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(a,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(a,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.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?o.set(a,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&o.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 n=this.scene[t],o=ot(this.transitionContext,n,t);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(o,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(o,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r,i=Ue()){if(0===o.size&&0===r.size)return n;const a=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let s=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],a=ot(e,i,t);if(!a)continue;if(i._transitionKey=a,"line"===i.type||"area"===i.type){const e=r.get(a);if(e){if(l.add(a),"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]];s=!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]];s=!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},s=!0;continue}const u=o.get(a);if("point"===i.type)if(u){c.add(a);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,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("glyph"===i.type)if(u){c.add(a);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,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("rect"===i.type)if(u){c.add(a);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,s=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},s=!0;else if("heatcell"===i.type)if(u){c.add(a);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,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(a);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,s=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},s=!0}for(const[e,t]of r)if(!l.has(e))if(e.startsWith("l:")&&t.path){const o={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};n.exitNodes.push(o),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={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};n.exitNodes.push(o),s=!0}for(const[e,t]of o)if(!c.has(e)){if(e.startsWith("p:"))n.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)n.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:"))n.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:"))n.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 o=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:o,closeY:t.closeY??o,highY:t.highY??o,lowY:t.lowY??o,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})}s=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),s&&(n.activeTransition={startTime:i,duration:a}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());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},n=function(e,t,n,o){if(!n.activeTransition)return!1;const r=Ve(e,n.activeTransition),i=Ye(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Xe(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Xe(n.x,e._targetX,i),e.y=Xe(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Xe(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Xe(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Xe(n.x,e._targetX,i),e.y=Xe(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Xe(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Xe(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Xe(n.x,e._targetX,i),e.y=Xe(n.y,e._targetY,i),void 0!==n.w&&(e.w=Xe(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Xe(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Xe(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Xe(n.x,e._targetX,i),e.y=Xe(n.y,e._targetY,i),void 0!==n.w&&(e.w=Xe(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Xe(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Xe(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Xe(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Xe(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Xe(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Xe(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Xe(n.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,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=Xe(t[o][0],n[o][0],i),e.path[o][1]=Xe(t[o][1],n[o][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,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Xe(t[n][0],o[n][0],i),e.topPath[n][1]=Xe(t[n][1],o[n][1],i);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Xe(n[t][0],r[t][0],i),e.bottomPath[t][1]=Xe(n[t][1],r[t][1],i)}}if(r>=1){for(const e of n.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 n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.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,n}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:n}=function(e,t,n,o){if(o&&o.version===n&&o.group===t&&o.data===e)return{result:o.result,cache:o};let r;if(t){const n=new Map;for(const o of e){const e=t(o);n.has(e)||n.set(e,[]),n.get(e).push(o)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,o,r){if(r&&r.version===o)return{map:r.map,cache:r};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const a=Array.from(i).sort(),s=a.join("\0");if(r&&r.key===s){const e={...r,version:o};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||Fe,l=new Map;for(let e=0;a.length>e;e++)l.set(a[e],c[e%c.length]);return{map:l,cache:{key:s,map:l,version:o}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,o){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=o(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||i||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:o(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,o){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=o(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=o(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||i||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||i||"#4e79a7",strokeWidth:r.strokeWidth||2};const a=o(t)||i||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:o}=function(e){const{group:t,colorMapCache:n,groupColorMap:o,groupColorMapCap:r,config:i}=e;let{groupColorCounter:a}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:a}}const s=o.get(t);if(s)return{color:s,groupColorCounter:a};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||Fe;if(0===c.length)return{color:null,groupColorCounter:a};const l=c[a%c.length];if(a++,o.set(t,l),o.size>r){const e=o.keys().next().value;void 0!==e&&o.delete(e)}return{color:l,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=o,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}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),n=this.getPointId,o=e=>t.has(n(e));Kt(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ue(e),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(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)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),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}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"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 o=!1,r=!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,n=e&&this.config.valueAccessor||this.config.yAccessor,a=e&&t.valueAccessor||t.yAccessor,s=i||!oe(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!oe(n,a);(s||c)&&(e?(this.getX=re(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=re(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=re(this.config.xAccessor,"x"),this.getY=re(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Ot(this.config)),o=!0,r=!0)}if("groupAccessor"in e&&!oe(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?ae(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in e&&!oe(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?ae(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in e&&!oe(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?re(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in e&&!oe(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ae(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in e&&!oe(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ae(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in e&&!oe(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?re(this.config.y0Accessor,"y0"):void 0,o=!0,r=!0),("boundsAccessor"in e&&!oe(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Ot(this.config),o=!0,r=!0),"pointIdAccessor"in e&&!oe(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?ae(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!oe(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!oe(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!oe(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!oe(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?re(this.config.openAccessor,"open"):void 0,this.getHigh=re(this.config.highAccessor,"high"),this.getLow=re(this.config.lowAccessor,"low"),this.getClose=t?re(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,o=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(o=!0,r=!0),!o){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){o=!0;break}}o&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Cn.GROUP_COLOR_MAP_CAP=1e3;var Mn=Cn;rn(Mn);import{memo as Pn,useEffect as In,useRef as Rn}from"react";var _n={sceneGeometry:0,layout:0,domain:0};function Tn(e){const{domain:t,layout:n,sceneGeometry:o}=e.revisions;return{domain:t,layout:n,sceneGeometry:o}}function Ln(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Nn="production"!==process.env.NODE_ENV,$n={revisions:_n,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},Bn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=_n,this.lastObserved=_n,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Nn&&(this.lastObserved=Ln(this.lastObserved,Tn(e)))}beforeCompute(e,t){if(!Nn)return $n;const n=Ln(Tn(e),this.lastObserved),o=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:o,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==o}}afterCompute(e,t,n){if(Nn){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function Dn(e){return Rn(new Bn(e))}var jn=Pn(function({store:e,diagnostics:t}){return In(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});import*as En from"react";function Fn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:En.createElement(En.Fragment,null,...t)}import*as On from"react";import{jsx as zn}from"react/jsx-runtime";var Hn=On.createContext(null);function Wn({value:e,children:t}){return zn(Hn.Provider,{value:e,children:t})}function Gn(e,t){return null!=e?zn(Wn,{value:t,children:e}):e}import{useEffect as qn,useRef as Yn}from"react";function Vn(e,t,n,o){qn(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function Xn(e,t,n,o){const r=Yn(null);qn(()=>{const i=e.current;if(!i)return;const a=t??null;r.current!==a&&(r.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,o())},[t,o,e,n])}function Un(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Kn(e,t=30){return Math.max((e??4)+5,12,t)}function Qn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Zn(e,t){const n=Qn(e);if(!n)return!1;const o=Qn(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function Jn(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var eo=[40,40],to=[.5,.5];function no(e,t){const[n,o]=e.viewBox??eo,[r,i]=e.anchor??to,a=o>0?o:1,s=Math.max(0,t)/a,c=(n>0?n:a)*s,l=a*s;return{width:c,height:l,scale:s,offsetX:-r*c,offsetY:-i*l}}function oo(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}var ro=null;function io(e){if("undefined"==typeof Path2D)return null;ro||(ro=new Map);const t=ro.get(e);if(t)return t;const n=new Path2D(e);return ro.size>1024&&ro.clear(),ro.set(e,n),n}function ao(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??eo,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function so(e,t){const n=no(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function co(e,t,n,o,r,i=e=>e){for(const a of t.parts){const t=io(a.d);if(!t)continue;const s=a.opacity??1,c=e.globalAlpha;1!==s&&(e.globalAlpha=c*s);const l=r?"none"===a.fill?void 0:r:oo(a.fill,n,o);l&&(e.fillStyle=i(l),e.fill(t));const u=r?a.stroke&&"none"!==a.stroke?r:void 0:oo(a.stroke??"none",n,o);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=c)}}function lo(e,t,n,o,r,i=e=>e.x,a=e=>e.y,s=e=>e.r){const c=Math.max(o,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let p=null,m=1/0;return e.visit((e,r,c,f,y)=>{if(r>u||l>f||c>h||d>y)return!0;if(!e.length){let r=e;do{const e=r.data,c=i(e)-t,l=a(e)-n,u=Math.sqrt(c*c+l*l);Kn(s(e),o)>=u&&m>u&&(p=e,m=u),r=r.next}while(r)}return!1}),p?{node:p,distance:m}:null}var uo=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,ho=new WeakMap,po=0,mo=!1,fo=null,yo=null;function go(e,t){if(!t)return t;const n=uo.exec(t);if(!n)return t;const o=e.canvas;if(!o)return n[2]?.trim()||t;!function(){if(mo)return;if("undefined"==typeof window||"undefined"==typeof document)return;mo=!0;const e=()=>{po++};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{fo=window.matchMedia("(prefers-color-scheme: dark)"),yo=e,"function"==typeof fo.addEventListener?fo.addEventListener("change",yo):"function"==typeof fo.addListener&&fo.addListener(yo)}catch{}}();let r=ho.get(o);r&&r.version===po||(r={version:po,map:new Map},ho.set(o,r));const i=r.map.get(t);if(void 0!==i)return i;const a=getComputedStyle(o).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return r.map.set(t,a),a}function bo(e,t){const n=e.fillStyle,o="#010203";try{e.fillStyle=o,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===o&&t.trim().toLowerCase()!==o)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const i=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}var vo=null;function xo(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(vo||(vo=document.createElement("canvas")),vo.width=e,vo.height=e,vo)}(s)}catch{return null}const l=c.getContext("2d");if(!l)return null;n&&"transparent"!==n?(l.fillStyle=n,l.fillRect(0,0,s,s)):l.clearRect(0,0,s,s),l.strokeStyle=o,l.lineWidth=r,l.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)l.beginPath(),l.moveTo(t,0),l.lineTo(t+e*s,s),l.stroke()}else{l.save(),l.translate(s/2,s/2),l.rotate(u);const e=2*s;for(let t=-e;e>=t;t+=i)l.beginPath(),l.moveTo(-e,t),l.lineTo(e,t),l.stroke();l.restore()}return(t||l).createPattern(c,"repeat")}import{jsx as wo,jsxs as ko}from"react/jsx-runtime";function So(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Ao(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var Co=new Map;function Mo(e,t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:a=45,lineOpacity:s=1}=e,c=Math.max(8,Math.ceil(2*i));return ko("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[n&&"transparent"!==n&&wo("rect",{width:c,height:c,fill:n}),wo("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:r,strokeOpacity:s}),wo("line",{x1:i,y1:0,x2:i,y2:c,stroke:o,strokeWidth:r,strokeOpacity:s})]},t)}function Po(e,t,n="#4e79a7"){if(So(e)){const n=function(e,t){let n=2166136261;const o=Ao(t);for(let e=0;o.length>e;e++)n^=o.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:Mo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}import{curveMonotoneX as Io,curveMonotoneY as Ro,curveCardinal as _o,curveCatmullRom as To,curveStep as Lo,curveStepBefore as No,curveStepAfter as $o,curveBasis as Bo,curveNatural as Do}from"d3-shape";function jo(e){switch(e){case"monotoneX":return Io;case"monotoneY":return Ro;case"cardinal":return _o;case"catmullRom":return To;case"step":return Lo;case"stepBefore":return No;case"stepAfter":return $o;case"basis":return Bo;case"natural":return Do;default:return null}}function Eo(e,t,n){if(null==t)return n;if(So(t)){const o=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,o=`${Ao(e)}@${n}`,r=Co.get(o);if(void 0!==r)return r;const i=xo({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return Co.set(o,i),i}(t,e);return o||t.background&&go(e,t.background)||n}return"string"!=typeof t?t:go(e,t)||n}function Fo(e,t){if(null==t)return;const n=Eo(e,t,"");return""===n?void 0:n}function Oo(e,t,n,o,r,i,a){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const s=e.createLinearGradient(o,r,i,a);for(const e of n)s.addColorStop(e.offset,e.color);return s}const{topOpacity:s,bottomOpacity:c}=t;if(!Number.isFinite(s)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,s)),u=Math.max(0,Math.min(1,c)),d=e.createLinearGradient(o,r,i,a),[h,p,m]=bo(e,n);return d.addColorStop(0,`rgba(${h},${p},${m},${l})`),d.addColorStop(1,`rgba(${h},${p},${m},${u})`),d}function zo(e,t,n,o,r,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(n,o,r,i);for(const e of a)s.addColorStop(e.offset,e.color);return s}import{line as Ho}from"d3-shape";var Wo=new WeakMap;function Go(e,t){const n=jo(t);if(!n)return e;const o=Wo.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const i={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,i,a,s,c){if(!r)return r=[s,c],void o.push([s,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*l+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*c])}r=[s,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){r=[n,i],o.push([n,i])}};return Ho().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),o}(e,n);return Wo.set(e,r),r}function qo(e,t,n,o=30,r,i=0){let a=null;if(r){const e=lo(r,t,n,o,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(r)break;e=Vo(i,t,n,o);break;case"symbol":e=Xo(i,t,n,o);break;case"glyph":e=Uo(i,t,n,o);break;case"line":e=Ko(i,t,n,o);break;case"rect":if(null==i.datum)break;e=Zo(i,t,n);break;case"heatcell":e=Jo(i,t,n);break;case"area":if(!1===i.interactive)break;e=tr(i,t,n);break;case"candlestick":e=er(i,t,n)}e&&o>e.distance&&(a&&e.distance>=a.distance||(a=e))}return a}function Yo(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=nr(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[a,s]=e[r],[c,l]=e[i];return c===a?s:s+Math.max(0,Math.min(1,(t-a)/(c-a)))*(l-s)}function Vo(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>Kn(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function Xo(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>Kn(Lt(e.size),o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:a}}function Uo(e,t,n,o=30){if(null==e.datum)return null;const r=so(e.glyph,e.size),i=e.x+r.centerDx,a=e.y+r.centerDy,s=t-i,c=n-a,l=Math.sqrt(s*s+c*c);return l>Kn(r.radius,o)?null:{node:e,datum:e.datum,x:i,y:a,distance:l}}function Ko(e,t,n,o=30){if(0===e.path.length)return null;const r=nr(e.path,t);if(0>r)return null;const[i,a]=e.path[r];let s;if(e.path.length>1){let o=1/0;const i=Math.max(0,r-1),a=Math.min(e.path.length-2,r);for(let r=i;a>=r;r++){const[i,a]=e.path[r],[s,c]=e.path[r+1],l=Qo(t,n,i,a,s,c);o>l&&(o=l)}s=o}else{const e=t-i,o=n-a;s=Math.sqrt(e*e+o*o)}const c=e.style;return s>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:a,distance:s}}function Qo(e,t,n,o,r,i){const a=r-n,s=i-o,c=a*a+s*s;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*a+(t-o)*s)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*a))**2+(t-(o+l*s))**2)}function Zo(e,t,n){const o=Un(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function Jo(e,t,n){const o=Un(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function er(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,a=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+a*a)}}return null}function tr(e,t,n){if(0===e.topPath.length)return null;const o=nr(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],a=t-r,s=n-i,c=Math.sqrt(a*a+s*s);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:c}}function nr(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as or,useRef as rr}from"react";var ir={fresh:1,aging:.7,stale:.45,expired:.25},ar={alpha:1,band:"fresh",isStale:!1};function sr(e,t){if(!e||0>=t)return ar;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=Qe(t,n,e.thresholds);return{alpha:{...ir,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:ar}function cr(e,t,n,o,r,i){const a=rr("fresh");or(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=sr(e,c-s.lastIngestTime);l.band===a.current&&l.isStale===r||(a.current=l.band,l.isStale!==r&&i(l.isStale),n.current=!0,o())},1e3);return()=>clearInterval(s)},[e,r,o,t,i,n])}import{jsx as lr}from"react/jsx-runtime";function ur({isStale:e,position:t}){return lr("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 dr,useRef as hr,useEffect as pr}from"react";import*as mr from"react";import{jsx as fr,jsxs as yr}from"react/jsx-runtime";var gr={fill:(e,t)=>fr("rect",{style:e,width:t,height:t}),line:(e,t)=>fr("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function br(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,gr[n])(o(e,t),r),i}function vr({swatchSize:e}){return fr("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 xr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var wr=(e,t,n,o,r,i,a,s,c,l,u)=>{const{type:d="fill",styleFn:h,items:p}=e,m=[];let f=0;const y=!(!t&&!n),g="isolate"===l||void 0===l&&null!=r,{swatchSize:b,labelGap:v,rowHeight:x}=u;return p.forEach((e,l)=>{const u=br(e,l,d,h,b),w=xr(e,o,r),k=r&&r.size>0&&r.has(e.label);m.push(yr("g",{transform:`translate(0,${f})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?s===i&&l===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&g?k||!1:void 0,"aria-current":y&&!g&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:y?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+p.length)%p.length;c(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:y?t=>{c(s,l),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&fr("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&&fr(vr,{swatchSize:b}),fr("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-"+l)),f+=x}),m};function kr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+mr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(fr("stop",{offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))},e))}return yr("g",{"aria-label":i||"Gradient legend",children:[fr("defs",{children:fr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&fr("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),fr("rect",{x:a,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),fr("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[0])}),fr("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(fr("stop",{offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))},e))}return yr("g",{"aria-label":i||"Gradient legend",children:[i&&fr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),fr("defs",{children:fr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),fr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),fr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[1])}),fr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(r[0])})]})}function Sr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[p,m]=mr.useState(0),[f,y]=mr.useState(0),g=mr.useCallback((e,t)=>{m(e),y(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let d=24;const h=[];return e.forEach((e,p)=>{d+=5,h.push(fr("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(fr("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(fr("g",{className:"legend-item",transform:`translate(0,${d})`,children:wr(e,n,o,r,i,a,s,p,c,l,u)},"legend-group-"+p)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:f,onFocusedIndexChange:g,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const p=[];e.forEach((e,t)=>{let m=0;e.label&&(m+=16);const f=((e,t,n,o,r,i,a,s,c,l,u,d)=>{const{type:h="fill",styleFn:p,items:m}=e,f=[],{swatchSize:y,labelGap:g,itemGap:b,rowHeight:v,align:x}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=m.map(e=>y+g+7*e.label.length),A=[];let C=0,M=0;S.forEach((e,t)=>{const n=0===M?e:M+b+e;d&&d>0&&M>0&&n>d?(A.push({start:C,end:t,width:M}),C=t,M=e):M=n}),m.length>0&&A.push({start:C,end:m.length,width:M}),A.forEach((e,l)=>{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=br(e,d,h,p,y),A=xr(e,o,r),C=r&&r.size>0&&r.has(e.label);f.push(yr("g",{transform:`translate(${u},${l*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(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!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+m.length)%m.length;c(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(s,d),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(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&&fr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:y+g+2+7*e.label.length,height:y+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,C&&fr(vr,{swatchSize:y}),fr("text",{y:y/2,x:y+g,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,o,r,i,a,s,c,t,l,u,d,d.maxWidth??n);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??n;let f=h>m?0:"center"===d.align?Math.max(0,(m-h)/2):"end"===d.align?Math.max(0,m-h):0;const y=[];return p.forEach((n,o)=>{const r=e[o];r.label&&(y.push(fr("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:r.label},"legend-text-"+o)),f+=16),y.push(fr("g",{className:"legend-item",transform:`translate(${f},0)`,children:n.items},"legend-group-"+o)),f+=n.offset+5,e[o+1]&&y.push(fr("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+o)),f+=12}),fr("g",{children:y})})({legendGroups:t||[],title:s,height:l,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:f,onFocusedIndexChange:g,legendInteraction:a,metrics:h}),v=!(!n&&!o);return yr("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&&fr("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}function Ar(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as Cr}from"react/jsx-runtime";function Mr(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",legendLayout:a,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const p="top"===i||"bottom"===i,m=!!s,f=Math.max(0,n-r.left-r.right),y=Math.max(1,p?a?.maxWidth??f:100);let g,b;return"left"===i?(g=Math.max(4,r.left-y-10),b=r.top):"top"===i?(g=r.left,b=m?32:8):"bottom"===i?(g=r.left,b=o-r.bottom+38):(g=n-r.right+10,b=r.top),Cr("g",{transform:`translate(${g}, ${b})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?Cr(kr,{config:t.gradient,orientation:p?"horizontal":"vertical",width:y}):Ar(t)?Cr(Sr,{legendGroups:t.legendGroups,title:"",width:y,orientation:p?"horizontal":"vertical",legendLayout:a,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t)});var v}import{useMemo as Pr}from"react";import{bin as Ir}from"d3-array";import{jsx as Rr,jsxs as _r}from"react/jsx-runtime";function Tr(e){return"string"==typeof e?{type:e}:e}function Lr({orient:t,config:n,values:o,scale:r,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}}(n),c="top"===t||"bottom"===t,l=Pr(()=>{if(0===o.length)return null;const n=r.domain(),l=i-8;if("boxplot"===s.type){const e=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],a=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*a),whiskerHigh:Math.min(t[n-1],i+1.5*a)}}(o);if(!e)return null;const{q1:n,median:i,q3:a,whiskerLow:u,whiskerHigh:d}=e,h=Math.min(.5*l,20),p=(l-h)/2+4;if(c){const e=r(n),o=r(a),c=r(i),l=r(u),m=r(d),f="top"===t?-1:1,y=0;return _r("g",{"data-testid":"marginal-boxplot-"+t,children:[Rr("line",{x1:l,y1:y+f*(p+h/2),x2:m,y2:y+f*(p+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("line",{x1:l,y1:y+f*p,x2:l,y2:y+f*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("line",{x1:m,y1:y+f*p,x2:m,y2:y+f*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("rect",{x:Math.min(e,o),y:"top"===t?y-p-h:y+p,width:Math.abs(o-e),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Rr("line",{x1:c,y1:"top"===t?y-p-h:y+p,x2:c,y2:"top"===t?y-p:y+p+h,stroke:s.fill,strokeWidth:2})]})}{const e=r(n),o=r(a),c=r(i),l=r(u),m=r(d),f="left"===t?-1:1,y=0;return _r("g",{"data-testid":"marginal-boxplot-"+t,children:[Rr("line",{x1:y+f*(p+h/2),y1:l,x2:y+f*(p+h/2),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("line",{x1:y+f*p,y1:l,x2:y+f*(p+h),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("line",{x1:y+f*p,y1:m,x2:y+f*(p+h),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),Rr("rect",{x:"left"===t?y-p-h:y+p,y:Math.min(e,o),width:h,height:Math.abs(o-e),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),Rr("line",{x1:"left"===t?y-p-h:y+p,y1:c,x2:"left"===t?y-p:y+p+h,y2:c,stroke:s.fill,strokeWidth:2})]})}}const u=Ir().domain(n).thresholds(s.bins)(o);if(0===u.length)return null;const d=e(u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return Rr("g",{"data-testid":"marginal-histogram-"+t,children:u.map((e,n)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/d*l;if(c){const i=r(e.x0),a=r(e.x1)-r(e.x0);return Rr("rect",{x:i,y:"top"===t?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(e.x0),a=r(e.x1)-r(e.x0);return Rr("rect",{x:"left"===t?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const e=l/2+4,n=[];for(const o of u){if(null==o.x0||null==o.x1)continue;const i=o.length/d*(l/2),a=r((o.x0+o.x1)/2);n.push(c?`${a},${"top"===t?-(e-i):e-i}`:`${"left"===t?-(e-i):e-i},${a}`)}for(let o=u.length-1;o>=0;o--){const i=u[o];if(null==i.x0||null==i.x1)continue;const a=i.length/d*(l/2),s=r((i.x0+i.x1)/2);n.push(c?`${s},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${s}`)}return Rr("g",{"data-testid":"marginal-violin-"+t,children:Rr("polygon",{points:n.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(c){const n=0,o=null!=u[0].x0?r(u[0].x0):0;e.push(`M${o},${n}`);for(const n of u){if(null==n.x0||null==n.x1)continue;const o=n.length/d*l,i=r((n.x0+n.x1)/2);e.push(`L${i},${"top"===t?-o-4:o+4}`)}const i=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${i},${n}`),e.push("Z")}else{const n=0,o=null!=u[0].x0?r(u[0].x0):0;e.push(`M${n},${o}`);for(const n of u){if(null==n.x0||null==n.x1)continue;const o=n.length/d*l,i=r((n.x0+n.x1)/2);e.push(`L${"left"===t?-o-4:o+4},${i}`)}const i=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;e.push(`L${n},${i}`),e.push("Z")}return Rr("g",{"data-testid":"marginal-ridgeline-"+t,children:Rr("path",{d:e.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[o,r,s,i,a,t,c,4]);return l?Rr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:l}):null}import*as Nr from"react";import{jsx as $r,jsxs as Br}from"react/jsx-runtime";function Dr(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let a="";for(const e of r)a&&a.length+1+e.length>o?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function jr(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Er(e,t,n,o){if(!e)return $r("g",{className:"annotation-note"});const{label:r,title:i,orientation:a,align:s,wrap:c=120,noWrap:l}=e;if(!r&&!i)return $r("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const p=16,m=i?l?[i]:Dr(i,c):[],f=r?l?[r]:Dr(r,c):[],y="leftRight"===u?"end"===h?-4:4:0;let g=0;const b=[],v=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push($r("foreignObject",{className:"annotation-note-html",x:"end"===h?y-c:"middle"===h?y-c/2:y,y:-16,width:c,height:Math.max(p,(m.length+f.length)*p+(i&&r?2:0))+p,style:{overflow:"visible"},children:Br("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:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&$r("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),r&&$r("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(m.length>0&&(b.push($r("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:m.map((e,t)=>$r("tspan",{x:y,dy:0===t?0:p,children:e},t))},"annotation-note-title")),g=m.length*p),f.length>0&&b.push($r("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:g,children:f.map((e,t)=>$r("tspan",{x:y,dy:0===t?0:p,children:e},t))},"annotation-note-label")));let x=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=$r("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(m.length+f.length)*p+(f.length>0?p:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=$r("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,m.length+f.length-1)*p;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(f.length>0&&m.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),Br("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[$r("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:b}),x]})}function Fr(e,t,n,o,r){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push($r("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,o=t?.height||0;(e>0||o>0)&&i.push($r("rect",{width:e,height:o,fill:"none",stroke:n||"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=o||0,a=r||0;if(void 0!==t?.x){const o=(t.x||0)-e;i.push($r("line",{x1:o,y1:(t.y1||0)-a,x2:o,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const o=(t.y||0)-a;i.push($r("line",{x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push($r("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push($r("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",o=t?.width??t?.height;void 0!==o&&i.push($r("path",{d:jr(e,o,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return $r("g",{className:"annotation-subject",children:i})}function Or(e,t,n,o,r,i){const a=[];let s=0,c=0;if("callout-circle"!==r&&"label"!==r||!i?.radius){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,a=e-r,l=t-i;if(0!==a||0!==l){const e=Math.abs(a),t=Math.abs(l),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;s=r+a*h,c=i+l*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,c=n):void 0!==t&&(s=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);s=Math.cos(o)*n,c=Math.sin(o)*n}}const l=Math.sqrt((e-s)**2+(t-c)**2);if(l>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-s);if(i){const o=(s+e)/2,i=(c+t)/2,d=-(t-c)/l,h=(e-s)/l,p=(n?.curve??.25)*l,m=o+d*p,f=i+h*p;a.push($r("path",{className:"connector-curve",d:`M${s},${c}Q${m},${f} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(f-c,m-s)}else a.push($r("line",{x1:s,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push($r("path",{d:`M${s},${c}L${s+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return $r("g",{className:"annotation-connector",children:a})}function zr(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:a,note:s,connector:c,subject:l,type:u,color:d,className:h,disable:p,opacity:m,strokeDasharray:f,events:y={},"data-testid":g}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(p)?p:[]);let w=o||0,k=r||0;null!=i&&(w=i-b),null!=a&&(k=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return Br("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":g,...null!=m&&{opacity:m},...f&&{strokeDasharray:f},...y,children:[!x.has("connector")&&Or(w,k,c,d,S,l),!x.has("subject")&&Fr(S,l,d,b,v),!x.has("note")&&Er(s,w,k,d)]})}function Hr(e){const{noteData:t}=e,{screenCoordinates:n}=t,o="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return $r(zr,{"data-testid":"semiotic-annotation",...a,type:o},"multi-annotation-"+i)});return $r("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return $r(zr,{"data-testid":"semiotic-annotation",events:r,...t,type:o},a)}import{packEnclose as Wr}from"d3-hierarchy";import{area as Gr,curveLinear as qr,curveMonotoneX as Yr,curveMonotoneY as Vr,curveStep as Xr,curveStepAfter as Ur,curveStepBefore as Kr,curveBasis as Qr,curveCardinal as Zr,curveCatmullRom as Jr}from"d3-shape";function ei(e){return Math.round(100*e)/100}function ti(e,t=2){const n=[],o=[],r=t+1;for(let t=0;r>t;t++){let i=0;for(const[n,o]of e)null!==o&&(i+=n**t*o);n.push(i);const a=[];for(let n=0;r>n;n++){let o=0;for(const[r,i]of e)null!==i&&(o+=r**(t+n));a.push(o)}o.push(a)}o.push(n);const i=function(e,t){const n=e,o=e.length-1,r=[t];for(let e=0;o>e;e++){let t=e;for(let r=e+1;o>r;r++)Math.abs(n[e][r])>Math.abs(n[e][t])&&(t=r);for(let r=e;o+1>r;r++){const o=n[r][e];n[r][e]=n[r][t],n[r][t]=o}for(let t=e+1;o>t;t++)for(let r=o;r>=e;r--)n[r][t]-=n[r][e]*n[e][t]/n[e][e]}for(let e=o-1;e>=0;e--){let t=0;for(let i=e+1;o>i;i++)t+=n[i][e]*r[i];r[e]=(n[o][e]-t)/n[e][e]}return r}(o,r).map(ei);return{points:e.map(([e])=>[ei(e),ei(i.reduce((t,n,o)=>t+n*e**o,0))]),equation:[...i].reverse()}}function ni(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function oi(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function ri(e){return null==e?null:e+""}function ii(e,t,n){return t.stickyPositionCache?.set(e,n),n}function ai(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return ii(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?ii(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return ri(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>ri(e.pointId)===o);if(r)return ii(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return ri(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const a=ni(i,n),s=oi(i,n);return null==a||null==s?null:ii(t,n,{x:a,y:s})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=ni(e,n),i=oi(e,n)),null!=r&&null!=i)return ii(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function si(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}import{jsx as ci}from"react/jsx-runtime";var li={secondary:0,primary:3},ui=".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 di(e){return!0===e?._annotationDeferred}function hi(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function pi(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function mi(e){return Math.max(.72,.95-.06*e)}import*as fi from"react";var[yi,gi]=G(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function bi(e){const t=gi(e=>e.pushObservation),n=fi.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return fi.useMemo(()=>({...e,onObservation:n}),[n,e])}function vi(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}function xi(e,t={}){const n=vi(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(o){const r=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(o);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:r}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:r,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function wi(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}import{jsx as ki,jsxs as Si}from"react/jsx-runtime";var Ai="var(--semiotic-bg, #ffffff)";function Ci(e){const{x:t,y:n,text:o,fill:r,fontSize:i=12,fontWeight:a,fontFamily:s,textAnchor:c="start",dominantBaseline:l,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),p=e=>ki("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:r,fontSize:i,fontWeight:a,fontFamily:s,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!h)return p();if("halo"===h.type)return p({stroke:h.fill??Ai,strokeWidth:h.haloWidth??3});const m=h.padding??{x:6,y:3},f="number"==typeof m?m:m.x,y="number"==typeof m?m:m.y,g=function(e,t){return(e+"").length*t*.6}(o,i),b=i+2*y;let v,x;return v="middle"===c?t-g/2-f:"end"===c?t-g-f:t-f,x="middle"===l||"central"===l?n-b/2:"hanging"===l||"text-before-edge"===l?n-y:n-.8*i-y,Si("g",{className:d,children:[ki("rect",{x:v,y:x,width:g+2*f,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Ai,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),p()]})}import{jsx as Mi,jsxs as Pi}from"react/jsx-runtime";var Ii={linear:qr,monotoneX:Yr,monotoneY:Vr,step:Xr,stepAfter:Ur,stepBefore:Kr,basis:Qr,cardinal:Zr,catmullRom:Jr};function Ri(e,t,n,o){const r=[];return e.forEach((e,i)=>{let a;if(n){const r=n(e,i,o);a=null!=r?r:t(e,i,o)}else a=t(e,i,o);a&&r.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:pi(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),o=e.some(e=>di(e.annotation)),r=e.some(e=>null!=hi(e.annotation)),i=e.some(e=>"layer"===hi(e.annotation));if(!n&&!o&&!r)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=li[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:o,readingOrder:r}=e,i=di(t.annotation);let a=t.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;a=ci("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:mi(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const s=hi(t.annotation);return s&&(a=ci("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=ci("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return o&&s.unshift(ci("style",{children:ui},"annotation-disclosure-style")),i&&s.unshift(ci("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}(r)}function _i(e,t={}){return function(e,o,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=ai(e,o,r);if(!t)return null;const{x:n,y:i}=t;if(!si(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 Mi(Hr,{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-"+o)}case"x-threshold":{const t=ni(null!=e.value?{...e,x:e.value}:e,r);if(null==t)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:16;const s=t>.6*(r.width||0),c=s?t-4:t+4,l=s?"end":"start";return Pi("g",{opacity:e.opacity,children:[Mi("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Mi(Ci,{x:c,y:a,text:e.label,textAnchor:l,fill:n,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+o)}case"y-threshold":{const t=oi(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const n=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end");const l=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return Pi("g",{opacity:e.opacity,children:[Mi("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Mi(Ci,{x:a,y:l,text:e.label,textAnchor:c,fill:n,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+o)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:ni({...e,type:"point"},r),y:oi({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const n=Wr(t),i=e.padding||10;return Pi("g",{children:[Mi("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&&Mi(Ci,{x:n.x,y:n.y-n.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+o)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:ni({...e,type:"point"},r),y:oi({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const i=e.padding||10,a=t.map(e=>e.x),s=t.map(e=>e.y),[c,l]=n(a),[u,d]=n(s),h=c-i,p=l+i,m=u-i;return Pi("g",{children:[Mi("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&&Mi(Ci,{x:(h+p)/2,y:m-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+o)}case"highlight":{const t=r.data||[],n="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return Mi("g",{children:n.map((t,n)=>{const o=ni(t,r),a=oi(t,r);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return Mi("circle",{cx:o,cy:a,r:s,...c},"hl-"+n)})},"ann-"+o)}case"bracket":{const t=ni(e,r),n=oi(e,r);return Mi(Hr,{noteData:{x:t??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-"+o)}case"trend":{const t=r.data||[];if(2>t.length)return null;const n=r.xAccessor||"x",i=r.yAccessor||"y",a="ordinal"===r.frameType,s="horizontal"===r.projection,c=a?n:null,l=a?i:null;let u;const d=[],h=new Map;if(a&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const o=h.get(t+"");return null!=o?[o,+n]:null}).filter(e=>null!==e)}else u=t.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 n=Math.max(0,Math.floor(t)),o=Math.min(d.length-1,n+1),r=t-n,i=e(d[n]);return i+(e(d[o])-i)*r},y=p,g=m;let b;if(a)if(s){const e=f(g);b=(t,n)=>[y(n),e(t)]}else{const e=f(y);b=(t,n)=>[e(t),g(n)]}else b=(e,t)=>[y(e),g(t)];const v=e.method||"linear";let x;if("loess"===v)x=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),c=o.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:o[e]/c;l[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;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],p+=t*r[e]*r[e],m+=t*r[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);else{const t="polynomial"===v?ti(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[o,r]of e)null!==r&&(n++,t[0]+=o,t[1]+=r,t[2]+=o*o,t[3]+=o*r);const o=n*t[2]-t[0]*t[0],r=0===o?0:ei((n*t[3]-t[0]*t[1])/o),i=ei(t[1]/n-r*t[0]/n);return{points:e.map(([e])=>[ei(e),ei(r*e+i)]),equation:[r,i]}}(u);x=t.points}const w=x.map(([e,t])=>{const[n,o]=b(e,t);return`${n},${o}`}).join(" "),k=e.color||"#6366f1",S=x[x.length-1],[A,C]=b(S[0],S[1]);return Pi("g",{children:[Mi("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Mi("text",{x:A+4,y:C-4,fill:k,fontSize:11,children:e.label})]},"ann-"+o)}case"band":{const t=r.scales?.y??r.scales?.value,n=t?.(e.y0)??0,s=t?.(e.y1)??(r.height||0),c=Po(e.fill,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Pi("g",{opacity:e.opacity,children:[c.def&&Mi("defs",{children:c.def}),Mi("rect",{x:0,y:Math.min(n,s),width:r.width||0,height:Math.abs(s-n),fill:c.fill,fillOpacity:e.fillOpacity||.1}),e.label&&Mi(Ci,{x:(r.width||0)-4,y:(i=n,a=s,Math.max(Math.min(i,a),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+o)}case"x-band":{const t=r.scales?.x??r.scales?.time,n=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==n||null==i)return null;const a=Po(e.fill||e.color,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Pi("g",{opacity:e.opacity,children:[a.def&&Mi("defs",{children:a.def}),Mi("rect",{x:Math.min(n,i),y:0,width:Math.abs(i-n),height:r.height||0,fill:a.fill,fillOpacity:e.fillOpacity??.1}),e.label&&Mi(Ci,{x:Math.min(n,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+o)}case"envelope":{const t=r.data||[];if(2>t.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",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[s]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[n]-t[n]);if(2>u.length)return null;const d=Ii[r.curve||"linear"]||qr,h=Gr().x(e=>i(e[n])).y0(e=>a(e[c])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const p=e.fill||"#6366f1";return Pi("g",{children:[Mi("path",{d:h,fill:p,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&Mi("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-"+o)}case"anomaly-band":{const t=r.data||[];if(2>t.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=t.map(e=>e[n]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const c=s.reduce((e,t)=>e+t,0)/s.length,l=s.reduce((e,t)=>e+(t-c)**2,0)/s.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,p=!1!==e.showBand,m=e.fill||"#6366f1",f=e.fillOpacity??.1,y=e.anomalyColor||"#ef4444",g=e.anomalyRadius??6,b=a(c+d*u),v=a(h),x=t.filter(e=>{const t=e[n];return null!=t&&Math.abs(t-c)>d*u});return Pi("g",{children:[p&&Mi("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 n=ni(e,r),o=oi(e,r);return null==n||null==o?null:Mi("circle",{cx:n,cy:o,r:g,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5},"anomaly-"+t)}),e.label&&Mi("text",{x:(r.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:m,fontSize:11,children:e.label})]},"ann-"+o)}case"forecast":{const t=r.data||[];if(3>t.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 c=t.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>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=ti(c,e.order||2).equation;l=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const a=(e*r-t*n)/i,s=(n-a*t)/e;l=e=>s+a*e}const u=c.length,d=c.map(([e,t])=>t-l(e)),h=d.reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(u-2,1)),m=c.reduce((e,t)=>e+t[0],0)/u,f=c.reduce((e,t)=>e+(t[0]-m)**2,0),y=e.confidence??.95,g=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=e.steps??5,v=c[u-1][0],x=(v-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;b>=e;e++)w.push(v+e*x);const k=[];for(const e of w){const t=l(e),n=p*Math.sqrt(1+1/u+(f>0?(e-m)**2/f:0))*g;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${k.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,A=k.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),C=`${a(v)},${s(l(v))}`,M=e.strokeColor||"#6366f1";return Pi("g",{children:[Mi("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),Mi("polyline",{points:`${C} ${A}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&Mi("text",{x:a(k[k.length-1].x)+4,y:s(k[k.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+o)}case"widget":{let n,i;if(null!=e.px&&null!=e.py)n=e.px,i=e.py;else{const t=ai(e,o,r);if(!t)return null;n=t.x,i=t.y}if(!si(n,i,r))return null;const a=e.dx??0,s=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??Mi("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return Mi("foreignObject",{x:n+a-c/2,y:i+s-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:Mi("div",{...xi(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const t=ai(e,o,r);if(!t)return null;const{x:n,y:i}=t,a=n+(e.dx||0),s=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=Mi("text",{x:a,y:s,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Nr.cloneElement(l,{key:"ann-text-"+o}):Pi("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[Mi("line",{x1:n,y1:i,x2:a,y2:s,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Nr.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+o)}case"category-highlight":{const t=e.category;if(null==t)return null;const n=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,a=r.scales?.x,s=r.scales?.y,c=n(i)?i:n(a)?a:n(s)?s:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,p=e.label;return Pi("g",(r.projection?"vertical"===r.projection:c===a)?{children:[Mi("rect",{x:l,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),p&&Mi(Ci,{x:l+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:p,background:e.labelBackground??"none"})]}:{children:[Mi("rect",{x:0,y:l,width:r.width||0,height:u,fill:d,fillOpacity:h}),p&&Mi(Ci,{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:p,background:e.labelBackground??"none"})]},"ann-"+o)}default:return null}var i,a,s}}var Ti=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Li=new Set(["label","callout","callout-circle","callout-rect"]);function Ni(e){return"string"==typeof e?.type?e.type:""}function $i(e){return!!e&&"object"==typeof e&&Ti.has(Ni(e))}function Bi(e){return Li.has(Ni(e))&&!function(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}(e)}function Di(e){return"primary"===e?.emphasis||!0===e?.defensive}function ji(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Ei(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),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 Fi=32,Oi=6,zi=4,Hi=8,Wi=72;var Gi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function qi(e){if(!Yi(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 Yi(e){return $i(e)}function Vi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function Xi(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function Ui(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ki(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 Qi(e,t,n,o,r,i,a,s){const c=Ui(e,a);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,s);for(const e of n)l+=12*Ki(c,e);for(const e of o)l+=4*Ki(c,e);return l}function Zi(e){const{annotations:t,context:n,defaultOffset:o=Fi,notePadding:r=Oi,markPadding:i=zi,edgePadding:a=Hi,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:l=Wi,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:m,cohesion:f,audience:y}=e,g=n.width||0,b=n.height||0,v="object"==typeof m?m:{},x=v.breakpoint??480,w=!!m&&x>=g,k=w&&!1!==v.preferShortText?t.map(qi):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>=g||0>=b)return k.slice();const P=[],I=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let R=!1;const _=k.map((e,t)=>{if(!Yi(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?ai(e,t,n):{x:e.x,y:e.y}}(e,t,n);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,n=[...Vi("string"==typeof e.title?e.title:void 0,t),...Vi("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.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(Ui(Xi(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),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}]}(o)){const t=Qi(Xi(i.x,i.y,e.dx,e.dy,u),e,P,I,g,b,r,a);p>t&&(h=e,p=t)}if(!h)return e;const m=Ui(Xi(i.x,i.y,h.dx,h.dy,u),r);P.push(m);const f=Math.hypot(h.dx,h.dy),y=c&&f>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return R=!0,{...e,dx:h.dx,dy:h.dy,...y?{connector:y}:{}}}),T=R?_:k.slice();let L=T;if(h){let e=!1;const t=T.map(t=>{const n=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 n!==t&&(e=!0),n});L=e?t:T}{let e=!1;const t=L.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Gi[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});L=e?t:L}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 n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(y),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ji(g,b,e))*t))},{deferred:o}=function(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??1),i=ji(n,o,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,$i(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const c=s.filter(e=>Di(e.annotation)),l=s.filter(e=>!Di(e.annotation)).sort((e,t)=>Ei(t.annotation)-Ei(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],p=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:i}}({annotations:L,width:g,height:b,...n});for(const e of o)N.add(e)}if(C&&("object"==typeof C&&"number"==typeof C.minWidth?C.minWidth:480)>=g)for(const e of L)Yi(e)&&"secondary"===e.emphasis&&N.add(e);if(N.size>0)for(const e of L)!0===e?.defensive&&N.delete(e);let $;return $=0===N.size?L:A?L.map(e=>N.has(e)?{...e,_annotationDeferred:!0}:e):L.filter(e=>!N.has(e)),M?function(e,t){let n=!1;const o=e.map(e=>Yi(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}($,M):$}import{useSyncExternalStore as Ji}from"react";var ea={positions:new Map},ta=new Set;function na(){for(const e of ta)e()}function oa(e,t){const n=ea.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(ea.positions);o.delete(e),ea={positions:o},na()}function ra(e,t){const n=ea.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const o=new Map(ea.positions);o.delete(e),ea={positions:o},na()}function ia(){return ea}function aa(e){return ta.add(e),()=>ta.delete(e)}var sa={positions:new Map};function ca(){return()=>{}}function la(){return sa}function ua(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),o=n[0],r=n[n.length-1],i=o instanceof Date,a=o instanceof Date?o.getTime():o,s=r instanceof Date?r.getTime():r;if(2>t||a===s)return i?[new Date(a),new Date(s)]:[a,s];const c=(s-a)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?s:a+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function da(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function ha(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function pa(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function ma(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function fa(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let a="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);a+=`L${Math.min(8*e+4,t)},${o+4*r}`,a+=`L${Math.min(n,t)},${o}`}return a}const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let a=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);a+=`L${o+4*r},${Math.min(8*e+4,n)}`,a+=`L${o},${Math.min(t,n)}`}return a}import{Fragment as ya,jsx as ga,jsxs as ba}from"react/jsx-runtime";function va(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:a,showAxes:s,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,p=dr(()=>{if(!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||xa,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o),s=e?.tickValues??ua(a.x,i,h),l=s.map(e=>e.valueOf()),d=s.map((e,t)=>({value:e,pixel:a.x(e),label:n(e,t,l)})),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 wa(d,Math.max(55,p+8))},[a,c,u,t,h]),m=dr(()=>{if(!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||xa,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o);return wa((e?.tickValues??ua(a.y,i,h)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[a,c,d,n,h]),f=l&&a,y=s&&a;if(!f&&!y)return null;const g=c?.find(e=>"bottom"===e.orient),b=c?.find(e=>"left"===e.orient),v=y&&(!g||!1!==g.baseline),x=y&&(!b||!1!==b.baseline),w=g?.jaggedBase||!1,k=b?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return ga("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:ba("g",{transform:`translate(${i.left},${i.top})`,children:[f&&(()=>{const e=ma(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=ma(c?.find(e=>"left"===e.orient)?.gridStyle);return ba("g",{className:"stream-grid",children:[p.map((t,o)=>ga("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),m.map((e,n)=>ga("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),v&&!w&&ga("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&ga("path",{d:fa("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),x&&!k&&ga("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&ga("path",{d:fa("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function xa(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function wa(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function ka(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:a,showAxes:s,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:p,axisExtent:m,showGrid:f,title:y,legend:g,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:C,xValues:M,yValues:P,annotations:I,onAnnotationActivate:R,onObservation:_,chartId:T,chartType:L,autoPlaceAnnotations:N,svgAnnotationRules:$,xAccessor:B,yAccessor:D,annotationData:j,pointNodes:E,curve:F,underlayRendered:O,canvasObscuresUnderlay:z=!0,linkedCrosshairName:H,linkedCrosshairSourceId:W,children:G}=e,q=bi({onAnnotationActivate:R,onObservation:_,chartId:T,chartType:L}),Y=dr(()=>{if(!s||!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||xa,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===m?Math.max(2,r):Math.min(r,o),l=e?.tickValues??ua(a.x,i,m),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:a.x(e),label:n(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 y=wa(d,f);if(y.length>1&&(y=y.filter((e,t)=>0===t||e.label+""!=y[t-1].label+"")),e?.includeMax&&y.length>0&&"exact"!==m&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),o=y[y.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,y.length,u);f>t-o&&y.length>1&&(y=y.slice(0,-1)),y.push({value:e,pixel:t,label:r})}}return y},[s,a,c,h,t,m]),V=dr(()=>{if(!s||!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||p||xa,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===m?Math.max(2,r):Math.min(r,o);let l=wa((e?.tickValues??ua(a.y,i,m)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==m&&!e?.tickValues){const e=a.y.domain()[1],n=a.y(e),o=l[l.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[s,a,c,p,n,m]),X=dr(()=>{if(!s||!a)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||xa,o=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return wa((e.tickValues??ua(a.y,"exact"===m?Math.max(2,r):Math.min(r,o),m)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[s,a,c,p,n,m]),U=hr(new Map),K=hr(I?.length??0),Q=I?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=dr(()=>{if(!I||0===I.length)return null;const e=_i(0,q),o={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:B,yAccessor:D,width:t,height:n,data:j,frameType:"xy",pointNodes:E,curve:F,stickyPositionCache:U.current};return Ri(N?Zi({annotations:I,context:o,..."object"==typeof N?N:{}}):I,e,$,o)},[I,N,$,t,n,B,D,j,a,E,F,q]),J=function(e){const t=Ji(e?aa:ca,e?ia:la,e?ia:la);return e?t.positions.get(e)??null:null}(H);return pr(()=>{if(!J?.locked||!H)return;const e=e=>{"Escape"===e.key&&ra(H)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,H]),s||y||g||A||C||Z&&Z.length>0||f||G||J?ba("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[ga("title",{children:"string"==typeof y?y:"XY Chart"}),ga("desc",{children:"string"==typeof y?y+" — XY data visualization":"XY data visualization"}),ba("g",{transform:`translate(${i.left},${i.top})`,children:[f&&a&&(!O||z)&&(()=>{const e=ma(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=ma(c?.find(e=>"left"===e.orient)?.gridStyle);return ba("g",{className:"stream-grid",children:[Y.map((t,o)=>ga("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),V.map((e,n)=>ga("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),s&&a&&(()=>{const e=c?.find(e=>"left"===e.orient),o=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,a=!o||!1!==o.baseline,s=e?.jaggedBase||!1,h=o?.jaggedBase||!1,p=o?.landmarkTicks,m=e?.landmarkTicks,f="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",b=!!o?.autoRotate&&Y.length>1&&(()=>{const e=t/Math.max(Y.length-1,1);return Y.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),v=b?12:18,x=n+(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=o?.tickAnchor,C=e?.tickAnchor,M=pa(Y),P=pa(V);return ba("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[ba("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!O||z)&&a&&!h&&ga("line",{x1:0,y1:n,x2:t,y2:n,stroke:f,strokeWidth:1}),(!O||z)&&h&&ga("path",{d:fa("bottom",t,n),fill:"none",stroke:f,strokeWidth:1}),Y.map((e,t)=>{const o=!!p&&("function"==typeof p?p(e.value,t):Zn(e.value,t>0?Y[t-1].value:void 0));return ba("g",{transform:`translate(${e.pixel},${n})`,children:[ga("line",{y2:5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?ga("text",{y:v,textAnchor:b?"end":da(A,e.pixel===M.min,e.pixel===M.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?k:w},transform:b?"rotate(-45)":void 0,children:e.label}):ga("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:ga("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),l&&ga("text",{x:t/2,y:x,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:l})]}),ba("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!O||z)&&r&&!s&&ga("line",{x1:0,y1:0,x2:0,y2:n,stroke:f,strokeWidth:1}),(!O||z)&&s&&ga("path",{d:fa("left",t,n),fill:"none",stroke:f,strokeWidth:1}),V.map((e,t)=>{const n=!!m&&("function"==typeof m?m(e.value,t):Zn(e.value,t>0?V[t-1].value:void 0));return ba("g",{transform:`translate(0,${e.pixel})`,children:[ga("line",{x2:-5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?ga("text",{x:-8,textAnchor:"end",dominantBaseline:ha(C,e.pixel===P.min,e.pixel===P.max),fontWeight:n?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:e.label}):ga("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:ga("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?ga("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===X.length)return null;const o=!1!==e.baseline,r=e.landmarkTicks,a=e.label||d,s=e.tickAnchor,l=pa(X);return ba("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&ga("line",{x1:t,y1:0,x2:t,y2:n,stroke:f,strokeWidth:1}),X.map((e,n)=>{const o=!!r&&("function"==typeof r?r(e.value,n):Zn(e.value,n>0?X[n-1].value:void 0));return ba("g",{transform:`translate(${t},${e.pixel})`,children:[ga("line",{x2:5,stroke:f,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?ga("text",{x:8,textAnchor:"start",dominantBaseline:ha(s,e.pixel===l.min,e.pixel===l.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?k:w},children:e.label}):ga("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:ga("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+n)}),a&&ga("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),Z,C&&a&&M&&P&&ba(ya,{children:[C.top&&ga("g",{transform:"translate(0, 0)",children:ga(Lr,{orient:"top",config:Tr(C.top),values:M,scale:a.x,size:i.top,length:t})}),C.bottom&&ga("g",{transform:`translate(0, ${n})`,children:ga(Lr,{orient:"bottom",config:Tr(C.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),C.left&&ga("g",{transform:"translate(0, 0)",children:ga(Lr,{orient:"left",config:Tr(C.left),values:P,scale:a.y,size:i.left,length:n})}),C.right&&ga("g",{transform:`translate(${t}, 0)`,children:ga(Lr,{orient:"right",config:Tr(C.right),values:P,scale:a.y,size:i.right,length:n})})]}),A,J&&J.sourceId!==W&&a?.x&&(()=>{const e=a.x(J.xValue);if(null==e||0>e||e>t)return null;const o=J.locked;return ga("line",{x1:e,y1:0,x2:e,y2:n,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),G]}),y&&"string"==typeof y?ga("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:y}):y?ga("foreignObject",{x:0,y:0,width:o,height:i.top,children:y}):null,Mr({legend:g,totalWidth:o,totalHeight:r,margin:i,legendPosition:k,title:y,legendLayout:S,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w})]}):null}import*as Sa from"react";import{arc as Aa}from"d3-shape";function Ca(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Ma(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,o=e=>Math.max(0,Math.min(e??0,n));return{tl:o(t.tl),tr:o(t.tr),br:o(t.br),bl:o(t.bl)}}var Pa=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Ia(e){const{innerRadius:t,outerRadius:n,startAngle:o,endAngle:r}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=Pa(n,o),t=Pa(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-o>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=Pa(n,o),a=Pa(n,r),s=Pa(t,r),c=Pa(t,o),l=r-o>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const a=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===a)return Ia({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const s=Math.asin(Math.min(1,a/Math.max(1e-9,n-a))),c=i?0:Math.asin(Math.min(1,a/Math.max(1e-9,t+a))),l=r-o,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>s,h=!!e.roundEnd&&u>s;if(!d&&!h)return Ia({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const p=o+(d?s:0),m=r-(h?s:0),f=o+(d?c:0),y=r-(h?c:0),g=Pa(n,p),b=Pa(n,m),v=(n-a)*Math.cos(s),x=Pa(v,o),w=Pa(v,r),k=i?null:Pa(t,y),S=i?null:Pa(t,f),A=i?0:(t+a)*Math.cos(c),C=i?null:Pa(A,o),M=i?null:Pa(A,r),P=m-p>Math.PI?1:0,I=i?0:y-f>Math.PI?1:0;let R="";if(d)R+=`M${x.x},${x.y}`,R+=` A${a},${a} 0 0 1 ${g.x},${g.y}`;else{const e=Pa(n,o);R+=`M${e.x},${e.y}`}if(h)R+=` A${n},${n} 0 ${P} 1 ${b.x},${b.y}`,R+=` A${a},${a} 0 0 1 ${w.x},${w.y}`;else{const e=Pa(n,r);R+=` A${n},${n} 0 ${P} 1 ${e.x},${e.y}`}if(i)R+=" L0,0";else{if(h)R+=` L${M.x},${M.y}`,R+=` A${a},${a} 0 0 1 ${k.x},${k.y}`;else{const e=Pa(t,r);R+=` L${e.x},${e.y}`}if(d)R+=` A${t},${t} 0 ${I} 0 ${S.x},${S.y}`,R+=` A${a},${a} 0 0 1 ${C.x},${C.y}`;else{const e=Pa(t,o);R+=` A${t},${t} 0 ${I} 0 ${e.x},${e.y}`}}return R+=" Z",R}function Ra(e){const t=Ia({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],o=e.colors;if(o.length>0){const t=(e.endAngle-e.startAngle)/o.length;for(let r=0;o.length>r;r++)n.push({d:Ia({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:o[r]})}return{clipPath:t,slices:n}}import{jsx as _a,jsxs as Ta}from"react/jsx-runtime";var La={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Na(e,t="#4e79a7"){return So(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function $a(e,t,n){const o=Tt(e.symbolType,e.size,e.path);return _a("path",{d:o,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Na(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}function Ba(e,t,n,o){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const i=no(r,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${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),c=ao(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?Da(o+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,o)=>{const r=t?"none"===n.fill?void 0:t:oo(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:oo(n.stroke??"none",s,e.accent);return r||i?_a("path",{d:n.d,fill:r??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},o):null});return Ta("g",{transform:a,opacity:1===u?void 0:u,children:[c&&l&&_a("clipPath",{id:l,children:_a("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?_a("g",{children:d(e.ghostColor)}):null,c&&l?_a("g",{clipPath:`url(#${l})`,children:d()}):d()]},o)}function Da(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function ja(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return _a("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,i=`${n?n+"-":""}area-${t}-hatch`,a=So(o.style.fill)?Mo(o.style.fill,i):void 0,s=a?`url(#${i})`:Na(o.style.fill);if(o.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return Ta("g",{children:[Ta("defs",{children:[a,_a("clipPath",{id:e,children:_a("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),_a("path",{d:r,fill:s,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return Ta(Sa.Fragment,{children:[a&&_a("defs",{children:a}),_a("path",{d:r,fill:s,fillOpacity:o.style.fillOpacity??o.style.opacity??.7,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"area-"+t)}case"point":{const o=e,r=`${n?n+"-":""}point-${t}-hatch`,i=So(o.style.fill)?Mo(o.style.fill,r):void 0;return Ta(Sa.Fragment,{children:[i&&_a("defs",{children:i}),_a("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#${r})`:Na(o.style.fill),opacity:o.style.opacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+t)}case"symbol":return $a(e,t);case"glyph":return Ba(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const o=e,r=`${n?n+"-":""}xyrect-${t}-hatch`,i=So(o.style.fill)?Mo(o.style.fill,r):void 0;return Ta(Sa.Fragment,{children:[i&&_a("defs",{children:i}),_a("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#${r})`:Na(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,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]}(n.fill),a=.299*o+.587*r+.114*i>128?"#000":"#fff",s=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return Ta("g",{children:[_a("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),_a("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:s+"px",children:e})]},"heatcell-"+t)}return _a("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return Ta("g",{children:[_a("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),_a("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var Ea="undefined"==typeof window||"undefined"==typeof document;import{useEffect as Fa,useLayoutEffect as Oa,useRef as za,useState as Ha,useSyncExternalStore as Wa}from"react";var Ga="undefined"!=typeof window?Oa:Fa;function qa(){const[e,t]=Ha(!1);return Ga(()=>{t(!0)},[]),e}var Ya=()=>()=>{},Va=()=>!1,Xa=()=>!0;function Ua(){const e=Wa(Ya,Va,Xa);return za(e).current}import{useRef as Ka}from"react";function Qa(e){const t=Ka(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Ja(e,t);if(!es(e)||!es(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!Ja(n,r))return!1}else{if(!es(n)||!es(r))return!1;if(!Za(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function Za(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function Ja(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function es(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 ts(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:i=0,y:a=0,width:s,height:c}=t;if("transparent"===n)return!1;if(o)return!1;const l=n||(r&&"transparent"!==r?r:"")||null;if(!l)return!1;const u=go(e,l);return!!u&&(e.fillStyle=u,e.fillRect(i,a,s,c),!0)}function ns(e){return!!(e.dirtyOrRebuilt||e.transitioning||e.animationTicked||e.continuous||e.liveEncoding||e.forced)}function os(e,t){return e||t}var rs={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 is(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}import*as as from"react";import*as ss from"react";import{jsx as cs}from"react/jsx-runtime";var ls=ss.createContext(null);function us({children:e}){const[t,n]=ss.useState(!1),o=ss.useCallback(()=>n(e=>!e),[]),r=ss.useMemo(()=>({visible:t,setVisible:n,toggle:o}),[t,o]);return cs(ls.Provider,{value:r,children:e})}function ds(){return ss.useContext(ls)}import{jsx as hs}from"react/jsx-runtime";var ps={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ms({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return hs("div",{"aria-live":"polite","aria-atomic":"true",style:ps,children:t})}function fs(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,o]of Object.entries(e))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(t[n]=o):"string"==typeof o?t[n]=o:"boolean"==typeof o?t[n]=o+"":o instanceof Date&&(t[n]=o.toISOString().slice(0,10)));return t}function ys(e){return e&&"object"==typeof e?e:{}}function gs(e){return ys(e.accessibility).tableFields??e.accessibleDatum??e.datum}function bs(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const o of e)if(o&&"object"==typeof o&&null!==o.datum)try{switch(o.type){case"point":if(n)break;t.push({label:"Point",values:fs(gs(o))});break;case"line":case"area":{const e=gs(o),n=Array.isArray(e)?e:[],r="line"===o.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:fs(e)});break}case"rect":{const e=gs(o),n=null!=e&&"object"==typeof e?e:{},r=n.category??o.group??"",i=n.value??n.__aggregateValue??n.total,a=fs(n);null==a.category&&""!==r&&(a.category=r+""),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=fs(gs(o));null==e.value&&"number"==typeof o.value&&Number.isFinite(o.value)&&(e.value=o.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=gs(o),n=fs(e);if(null==n.category){const t=ys(e),o=t.category??t.label;null!=o&&(n.category=o+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:fs(gs(o))});break;case"arc":t.push({label:"Arc",values:fs(gs(o))});break;case"candlestick":t.push({label:"Candlestick",values:fs(gs(o))});break;case"geoarea":{const e=ys(gs(o)),n=fs(e);if(null==n.name){const t=ys(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}import{jsx as vs,jsxs as xs}from"react/jsx-runtime";function ws(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const o=[],r={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(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of a)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function ks(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}var Ss=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},As="semiotic-accessible-data-table",Cs=As+" semiotic-accessible-data-table-hidden",Ms=As+" semiotic-accessible-data-table-visible",Ps=Ms+" semiotic-accessible-data-table-network",Is={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"},Rs={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},_s={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)"},Ts={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ls={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))"},Ns={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},$s={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Bs={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 Ds({scene:e,chartType:t,tableId:n,chartTitle:o}){const[r,i]=as.useState(!1),[a,s]=as.useState(5),c=ds(),l=c?.visible??!1,u=r||l,d=as.useRef(null),h=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t;as.useEffect(()=>{u||s(5)},[u]);const p=as.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),m=as.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?vs("span",{id:n,tabIndex:-1,style:ps}):null;if(!u)return vs("div",{id:n,className:Cs,tabIndex:-1,onFocus:p,style:ps,role:"region","aria-label":h,children:xs("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const f=bs(e),y=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(f),g=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Ss(e.min)} to ${Ss(e.max)}, mean ${Ss(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(f.length,y),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 xs("div",{ref:d,id:n,className:Ms,tabIndex:-1,onBlur:m,style:Is,role:"region","aria-label":h,children:[vs("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:_s,children:"×"}),vs("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Rs,children:g}),xs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Ts,children:[vs("caption",{className:"semiotic-accessible-data-table-caption",style:$s,children:x>0?`First ${b} of ${f.length} data points`:`All ${f.length} data points`}),vs("thead",{children:xs("tr",{children:[vs("th",{style:Ls,children:"type"}),k.map(e=>vs("th",{style:Ls,children:e},e))]})}),vs("tbody",{children:v.map((e,t)=>xs("tr",{children:[vs("td",{style:Ns,children:e.label}),k.map(t=>{return vs("td",{style:Ns,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ss(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),x>0&&xs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:Bs,children:["Show ",Math.min(25,x)," more"," ",1===x?"row":"rows"," (",x," remaining)"]})]})}function js({nodes:e,edges:t,chartType:n,tableId:o,chartTitle:r}){const[i,a]=as.useState(!1),[s,c]=as.useState(5),l=ds(),u=l?.visible??!1,d=i||u,h=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,p=as.useRef(null);as.useEffect(()=>{d||c(5)},[d]);const m=as.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),f=as.useCallback(e=>{u||p.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return o?vs("span",{id:o,tabIndex:-1,style:ps}):null;if(!d)return vs("div",{id:o,className:Cs,tabIndex:-1,onFocus:m,style:ps,role:"region","aria-label":h,children:xs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const y=Array.isArray(e)?e:[],g=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,w=new Map;for(const e of g){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,o="object"==typeof t.target?t.target?.id:t.target,r="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),w.set(e,(w.get(e)??0)+r)}if(null!=o&&""!==o){const e=o+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+r)}}const k=[];for(let e=0;y.length>e;e++){const t=y[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,o=null!=n?n+"":"node-"+e,r=b.get(o)??0,i=v.get(o)??0,a=x.get(o)??0,s=w.get(o)??0;k.push({id:o,degree:r+i,inDeg:r,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=g.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${k.length} nodes, ${g.length} edges.`];k.length>0&&M.push(`Mean degree: ${Ss(S)}, max degree: ${A}.`);const P=Math.min(s,k.length),I=k.slice(0,P),R=k.length-P;return xs("div",{ref:p,id:o,className:Ps,tabIndex:-1,onBlur:f,style:Is,role:"region","aria-label":h,children:[vs("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:_s,children:"×"}),vs("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Rs,children:M.join(" ")}),xs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Ts,children:[vs("caption",{className:"semiotic-accessible-data-table-caption",style:$s,children:R>0?`Top ${P} of ${k.length} nodes by degree`:`All ${k.length} nodes by degree`}),vs("thead",{children:xs("tr",{children:[vs("th",{style:Ls,children:"id"}),vs("th",{style:Ls,children:"degree"}),vs("th",{style:Ls,children:"in"}),vs("th",{style:Ls,children:"out"}),C&&vs("th",{style:Ls,children:"w. degree"}),C&&vs("th",{style:Ls,children:"w. in"}),C&&vs("th",{style:Ls,children:"w. out"})]})}),vs("tbody",{children:I.map((e,t)=>xs("tr",{children:[vs("td",{style:Ns,children:e.id}),vs("td",{style:Ns,children:e.degree}),vs("td",{style:Ns,children:e.inDeg}),vs("td",{style:Ns,children:e.outDeg}),C&&vs("td",{style:Ns,children:Ss(e.wDegree)}),C&&vs("td",{style:Ns,children:Ss(e.wInDeg)}),C&&vs("td",{style:Ns,children:Ss(e.wOutDeg)})]},t))})]}),R>0&&xs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Bs,children:["Show ",Math.min(25,R)," more"," ",1===R?"node":"nodes"," (",R," remaining)"]})]})}function Es({summary:e}){return e?vs("div",{role:"note",style:ps,children:e}):null}function Fs({tableId:e}){return vs("a",{href:"#"+e,style:ps,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.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,ps)},children:"Skip to data table"})}import{jsx as Os}from"react/jsx-runtime";var zs="var(--semiotic-focus, #005fcc)";function Hs({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!s)if("rect"===r&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=Os("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:zs,strokeWidth:2,strokeDasharray:"4,2"})}else u=Os("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:zs,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:zs,strokeWidth:2,strokeDasharray:"4,2"});else u=Os("g",{transform:`translate(${n.left},${n.top})`,children:Os("path",{d:s,fill:"none",stroke:zs,strokeWidth:2.5,strokeDasharray:"6,3"})});return Os("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as Ws from"react";function Gs(e,t){return"touch"===t?Math.max(e,24):e}function qs(e){return Array.isArray(e)?e[0]:e}function Ys(e,t,n,o){return{data:qs(e),x:t,y:n,__semioticHoverData:!0,...o}}var Vs=["name","label","title"],Xs=["type","kind","category","group","class","status","role","shape"],Us=["value","amount","total","count","weight","score"],Ks=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 Qs(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Zs(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,o=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(o&&Ks.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let i=r.findIndex(e=>Vs.includes(e.lower));const a=i>=0;0>i&&(i=r.findIndex(e=>"id"===e.lower)),0>i&&(i=r.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:r[i];let c=r.filter((e,t)=>t!==i);a&&(c=c.filter(e=>"id"!==e.lower));const l=Qs(c,Xs),u=Qs(c,Us),d=new Set(Xs),h=new Set(Us),p=[];l&&p.push({key:l.key,value:l.value}),u&&p.push({key:u.key,value:u.value});for(const e of c){if(p.length>=n)break;e!==l&&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 Js,jsxs as ec}from"react/jsx-runtime";var tc={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 nc(e,t){return"function"==typeof t?t(e):e[t]}function oc(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 rc(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=nc(e,n);a=oc(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=nc(e,r);s.push({label:n,value:oc(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=oc(e[n],o);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=oc(e[t[0]],o))}}const c={...tc,...r};return ec("div",{className:("semiotic-tooltip "+i).trim(),style:c,children:[a&&Js("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>ec("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&ec("span",{children:[e.label,": "]}),e.value]},t))]})}}function ic(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const c=[];if(n){const t=nc(e,n);c.push({value:oc(t,o)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=oc(nc(e,r),i);c.push({label:a?n:void 0,value:s})});else{const t=Zs(e,{skipPositional:!1});null!=t.title&&c.push({label:void 0,value:oc(t.title,o),bold:!0}),t.entries.forEach(e=>{c.push({label:a?e.key:void 0,value:oc(e.value,o)})})}const l={...tc,...r};return Array.isArray(c)&&0!==c.length?Js("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:l,children:c.map((e,t)=>ec("div",{style:{marginBottom:c.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&ec("strong",{children:[e.label,s]}),e.value]},t))}):null}}function ac(){return e=>{const t=e.allSeries;if(!t||0===t.length)return Js("div",{className:"semiotic-tooltip",style:tc,children:Js("div",{children:oc(e.data?.value??e.data?.y)})});const n=e.xValue??e.data?.time??e.data?.x;return ec("div",{className:"semiotic-tooltip",style:tc,children:[null!=n&&Js("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:oc(n)}),t.map((e,t)=>ec("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[Js("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),Js("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),Js("span",{style:{fontWeight:500,fontSize:"0.85em"},children:oc(e.value)})]},t))]})}}function sc(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=qs(!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);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const o=t(n);return null==o?null:Js("div",{className:"semiotic-tooltip",style:tc,children:o})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?rc(e):rc())}}import{jsx as cc}from"react/jsx-runtime";function lc({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=Ws.useRef(null),[u,d]=Ws.useState(null);Ws.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a,n,o,c]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`;const p=function(e){if(!Ws.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background&&"transparent"!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor&&"transparent"!==o.backgroundColor)return!0}return!1}(i),m=p?null:tc;return c?cc("div",{ref:l,className:p?a:(a+" semiotic-tooltip").trim(),style:{...m||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}import*as uc from"react";import{useCallback as dc,useEffect as hc,useLayoutEffect as pc,useMemo as mc,useRef as fc}from"react";import{useState as yc,useEffect as gc}from"react";function bc(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}function vc(){const[e,t]=yc(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return gc(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),bc(e,e=>t(e.matches))},[]),e}import{useRef as xc,useState as wc,useEffect as kc}from"react";function Sc(e,t,n){const o=xc(null),[r,i]=wc(null);return kc(()=>{if(!t&&!n)return;const e=o.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[o,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}var Ac=()=>"undefined"!=typeof performance?performance.now():Date.now();function Cc(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}}function Mc(e,t){const n=e();return Number.isFinite(n)?n:t}var Pc=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Ac,this.lastWallTime=Mc(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Mc(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Ac;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Mc(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Cc(n)))}},Ic="undefined"==typeof window?hc:pc,Rc={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function _c(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Tc(e){const t=vc(),n=fc(t);n.current=t;const[o,r]=Sc(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,a=!!e.legend&&"top"===e.legendPosition,s=mc(()=>function(e,t,n=!1){const o=n?t?58:34:t?36:0;return o>e.top?{...e,top:o}:e}({...e.marginDefault,...e.userMargin},i,a),[e.marginDefault,e.userMargin,i,a]),c=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,u=_c(e.foregroundGraphics,r,s),d=_c(e.backgroundGraphics,r,s),h=ee(e=>e.theme),{transition:p,introEnabled:m}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="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:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+uc.useId(),y=fc(null);if(!y.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;y.current=new Pc({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const g=y.current;g.configure({clock:e.clock,random:e.random,seed:e.seed});const b=fc(null),v=fc(e.frameScheduler??Rc);v.current=e.frameScheduler??Rc;const x=fc(null),w=fc(!1),k=fc(()=>{}),S=dc(()=>{if(null!==b.current||w.current)return;const e=v.current;let t=!1,n=!1;const o=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(w.current=!0),b.current=null,x.current=null;try{k.current()}finally{e&&(w.current=!1)}});n=!0,t||(b.current=o,x.current=e)},[]),A=dc(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);Ic(()=>{g.setPaused(!0===e.paused)},[g,e.paused]),hc(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void g.setVisible(!0);const t=()=>g.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[g,e.suspendWhenHidden]),hc(()=>()=>{A()},[A]);const C=fc(()=>{}),M=fc(()=>{}),P=fc(null),I=fc(null),R=fc(null),_=dc(()=>{const e=P.current;P.current=null,e&&C.current(e)},[]),T=dc(e=>{if(P.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===I.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,I.current=null,R.current=null,_()});t||(I.current=n,R.current=e)}},[_]),L=dc(()=>{P.current=null,null!==I.current&&((R.current??v.current).cancelAnimationFrame(I.current),I.current=null,R.current=null),M.current()},[]);hc(()=>()=>{P.current=null,null!==I.current&&((R.current??v.current).cancelAnimationFrame(I.current),I.current=null,R.current=null)},[]);const N=e.themeDirtyRef;return Ic(()=>{N&&(po++,N.current=!0,S())},[h,S,N]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:o,size:r,margin:s,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:p,introEnabled:m,tableId:f,frameRuntime:g,rafRef:b,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:C,hoverLeaveRef:M,onPointerMove:T,onPointerLeave:L}}import{useEffect as Lc,useRef as Nc}from"react";import{jsx as $c}from"react/jsx-runtime";function Bc(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,scheduleRender:i}=e,a=Nc(null),s=Nc(null),c=Nc(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:i,cancelRender:a,cleanup:s}=e;Ga(()=>{t&&n&&o.current?.cancelIntroAnimation?.(),r.current=!0,a?.(),i.current()},[t,n]);const c=za(s);c.current=s,Fa(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),Lc(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,i()):t()})},[t,n,o,r,i]),Lc(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:s}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function Dc({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?$c("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:$c("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function jc(e,t,n,o){const r=o.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,a=!i&&e.hasActivePulsesAt(t),s=!(n||i||!a&&!r)&&e.refreshPulse(t);return o.current=a,{changed:s,pending:a}}function Ec(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}function Fc(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=Math.round(t[0]*o),a=Math.round(t[1]*o),s=i/t[0],c=a/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),r.setTransform(s,0,0,c,0,0),r.translate(n.left,n.top),r}function Oc(){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 zc,useRef as Hc}from"react";function Wc(e,t,n,o){const r=Hc({accessor:t,onChange:n,readData:o}),i=Hc([]);return r.current={accessor:t,onChange:n,readData:o},zc(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const a=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),o.push(i))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(a,i.current)||(i.current=a,n(a))},[e])}function Gc(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}function qc(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const i=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!o&&!i)return n;r=!0;const a={...n};return o&&(a[e.key]=e.fn(n)),i&&(a[t.key]=t.fn(n)),a});return r?i:o}}var Yc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Vc=3156e7;function Xc(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")}`}:Vc>t?e=>{const t=new Date(e);return`${Yc[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Vc>t?e=>{const t=new Date(e);return`${Yc[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Uc(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:Lt(n.size)});else if("glyph"===n.type){const e=so(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as Kc}from"d3-shape";function Qc(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Zc(e,t,n,o,r,i){if(2>t.length)return;const a=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(n*n+o*o))}const s=a[a.length-1];if(0===s)return;const c=Math.min(.2*s,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(a[n]+a[n+1])/2;let i=r;c>o&&(i*=o/c),c>s-o&&(i*=(s-o)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Jc=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",i=go(e,r)||r,a=t.style.strokeWidth||2,s=t.colorThresholds,c=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){Zc(e,t.path,i,a,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=jo(t.curve),u=s&&s.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,a=null,l=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,p]=t.path[d],m=c[d],f=Qc(m,s,i);if(null!==r&&null!==u&&null!==l){if(f===u)e.lineTo(h,p);else{const t=[];for(const e of s){const n=e.value;(l>n||n>m)&&(n>l||m>n)||l===n||m===n||t.push({t:(n-l)/(m-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=r+(h-r)*c.t,u=a+(p-a)*c.t,d=Qc(l+(m-l)*Math.min(c.t+1e-4,1),s,i);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,p)}r=h,a=p,l=m,u=f}else n(f,h,p),r=h,a=p,l=m,u=f}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?zo(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)Kc().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Eo(e,t.style.fill,t.style.fill),l&&!u)Kc().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function el(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function tl(e,t,n=.3){el(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function nl(e,t,n=.6){if(!el(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(r,i,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function ol(e,t,n,o=.35){el(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as rl,line as il}from"d3-shape";function al(e,t){const n=jo(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=rl().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}var sl=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const i=Eo(e,t.style.fill,"#4e79a7"),a=t._decayOpacities;if(a&&a.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(a[o]+a[o+1])*n,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.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][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 n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(a[n]+a[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const s=t.style.opacity??1;if(al(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=Oo(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,o);e.fillStyle=r||i,e.globalAlpha=s}else e.globalAlpha=(t.style.fillOpacity??.7)*s,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(al(e,t),ol(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=s;const n=t.strokeGradient&&t.topPath.length>=2?zo(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=jo(t.curve);if(e.beginPath(),o)il().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},cl=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Eo(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Eo(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),nl(e,n)}finally{e.restore()}}},ll=new Map;function ul(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=ll.get(t);return n||(n=new Path2D(Tt(e.symbolType,e.size)),ll.size>256&&ll.clear(),ll.set(t,n)),n}catch{return null}}var dl=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=ul(t);if(!r)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=n*i*(t.style.fillOpacity??1),e.fillStyle=Eo(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Eo(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function hl(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=no(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const c=t=>{const n=Eo(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=r*s*(t.style.fillOpacity??1);const u=ao(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&co(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),co(e,i,l,t.accent,void 0,c),e.restore()}var pl=(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&hl(e,o,o.x,o.y,n);e.globalAlpha=n};function ml(e,t){const{x:n,y:o,w:r,h:i}=t,{tl:a,tr:s,br:c,bl:l}=Ma(t);e.beginPath(),e.moveTo(n+a,o),e.lineTo(n+r-s,o),s>0&&e.arcTo(n+r,o,n+r,o+s,s),e.lineTo(n+r,o+i-c),c>0&&e.arcTo(n+r,o+i,n+r-c,o+i,c),e.lineTo(n+l,o+i),l>0&&e.arcTo(n,o+i,n,o+i-l,l),e.lineTo(n,o+a),a>0&&e.arcTo(n,o,n+a,o,a),e.closePath()}function fl(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 yl=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)gl(e,t);else if(t.cornerRadii&&Ca(t.cornerRadii)){const n=Eo(e,t.style.fill,go(e,"var(--semiotic-primary, #007bff)")),o=fl(t),r=t.fillGradient&&"string"==typeof n?Oo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,ml(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 n=Eo(e,t.style.fill,go(e,"var(--semiotic-primary, #007bff)")),o=fl(t),r=t.fillGradient&&"string"==typeof n?Oo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:a,y:s,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(a,s),e.lineTo(a+c-i,s),e.arcTo(a+c,s,a+c,s+i,i),e.lineTo(a+c,s+l-i),e.arcTo(a+c,s+l,a+c-i,s+l,i),e.lineTo(a,s+l);break;case"left":e.moveTo(a+c,s),e.lineTo(a+i,s),e.arcTo(a,s,a,s+i,i),e.lineTo(a,s+l-i),e.arcTo(a,s+l,a+i,s+l,i),e.lineTo(a+c,s+l);break;case"bottom":e.moveTo(a,s),e.lineTo(a+c,s),e.lineTo(a+c,s+l-i),e.arcTo(a+c,s+l,a+c-i,s+l,i),e.lineTo(a+i,s+l),e.arcTo(a,s+l,a,s+l-i,i);break;default:e.moveTo(a,s+l),e.lineTo(a,s+i),e.arcTo(a,s,a+i,s,i),e.lineTo(a+c-i,s),e.arcTo(a+c,s,a+c,s+i,i),e.lineTo(a+c,s+l)}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 n=Eo(e,t.style.fill,go(e,"var(--semiotic-primary, #007bff)")),o=fl(t),r=t.fillGradient&&"string"==typeof n?Oo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,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))}tl(e,t),e.globalAlpha=1}};function gl(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,a=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,a,o,r,r)}else{const i=r+o,a=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,a,r,r)}e.restore()}function bl(e){const[t,n,o]=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*n+.114*o>128?"#000":"#fff"}function vl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var xl=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.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),tl(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):vl(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=bl(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}},wl=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const i=go(e,t.wickColor)||t.wickColor,a=60>o.height,s=a?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=s,e.stroke()};if(a||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,i=go(e,r)||r;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}a&&c(),e.restore()}},kl={line:[sl,Jc,cl],area:[sl,cl],stackedarea:[sl,cl],scatter:[cl,dl],bubble:[cl,dl],heatmap:[xl],bar:[yl],swarm:[cl],waterfall:[(e,t,n,o)=>{yl(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const i=r[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;r.length-1>t;t++){const o=r[t],i=r[t+1],a=o.datum,s=i.datum;if(null==a?.cumEnd||null==s?.baseline)continue;const c=n.y(a.cumEnd),l=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[wl],mixed:[sl,Jc,cl],custom:[sl,yl,xl,Jc,cl,dl,pl,wl]},Sl=new Set;function Al(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(o=n)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?n:void 0;var o}function Cl(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Sl.has(n)||(Sl.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Ml(e){const{context:t,nodes:n,renderMode:o,pixelRatio:r,paintBuiltIn:i}=e;if(!o||"sketchy"===o)return void i(n);let a=[];const s=()=>{a.length&&(i(a),a=[])};for(const e of n){const n=Al(o,e);if(!n){a.push(e);continue}let c;s(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:r})}finally{t.restore()}c||(Cl(n.id,e.type??"unknown"),i([e]))}s()}function Pl(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=Al(o,t);if(!i)return r();const a=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=a?a:(Cl(i.id,t.type??"unknown"),r())}function Il(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 n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}import{jsx as Rl,jsxs as _l}from"react/jsx-runtime";function Tl(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 Nl(e,t){if(!t)return Ll(e);try{const n=t(e);return null==n?Ll(e):n}catch{return Ll(e)}}function $l(e,t){return"function"==typeof t?t(e):e[t]}function Bl(e,t){if(!e)return[];const n=[];return(Array.isArray(e)?e:[e]).forEach((e,o)=>{const r="string"==typeof e?.y0Accessor?e.y0Accessor:"low",i="string"==typeof e?.y1Accessor?e.y1Accessor:"high";n.push({label:r,accessor:e=>e.bands?.[o]?.y0??(0===o?e.band?.y0:void 0),format:t}),n.push({label:i,accessor:e=>e.bands?.[o]?.y1??(0===o?e.band?.y1:void 0),format:t})}),n}function Dl(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const o=e.data;if(!o)return null;const r=t?Nl($l(o,t.accessor),t.format):null;return _l("div",{className:"semiotic-tooltip",style:tc,children:[null!=r&&Rl("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((e,t)=>{const n=Nl($l(o,e.accessor),e.format);return _l("div",{style:t>0?{marginTop:2}:void 0,children:[_l("span",{style:{opacity:.7},children:[e.label,": "]}),Rl("span",{children:n})]},t)})]})}}function jl({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1,valueFormat:i}){return a=>{const s=r?a.data?.[0]||a.data||a:a.data||a,c=$l(s,e),l=$l(s,t),u=n?$l(s,n):void 0;return _l("div",{className:"semiotic-tooltip",style:tc,children:[Rl("div",{style:{fontWeight:"bold"},children:Ll(c)}),Rl("div",{style:{marginTop:4},children:Nl(l,i)}),null!=u&&_l("div",{style:{marginTop:2,opacity:.8},children:[o||Tl(n),": ",Ll(u)]})]})}}import{jsx as El,jsxs as Fl}from"react/jsx-runtime";function Ol(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??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=Zs(t);if(null!=e.title||e.entries.length>0)return Fl("div",{className:"semiotic-tooltip",style:tc,children:[null!=e.title&&El("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,":"," ",El("span",{style:{fontWeight:600},children:Ol(e.value)})]},e.key))]})}return Fl("div",{className:"semiotic-tooltip",style:tc,children:[El("div",{style:{fontWeight:600,marginBottom:2},children:Ol(n)}),El("div",{style:{opacity:.7,fontSize:11},children:Ol(o)})]})}function Hl(e){return"touch"===e?"touch":"pointer"}function Wl(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function Gl(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:a,context:s,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:a}),"focus"===s?.type&&t({type:"focus",datum:n,inputType:"touch"===s.inputType?"pointer":s.inputType,timestamp:c,chartType:i,chartId:a})):t({type:"hover-end",timestamp:c,chartType:i,chartId:a}))}function ql(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:a,context:s,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:a}),"activate"===s?.type&&t({type:"activate",datum:n,inputType:s.inputType,timestamp:c,chartType:i,chartId:a})):t({type:"click-end",timestamp:c,chartType:i,chartId:a}))}zl.ownsChrome=!0;import{useCallback as Yl}from"react";function Vl({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:Yl((t,i)=>{e?.(t,i),Gl({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:i})},[o,r,e,n]),customClickBehavior:Yl((e,i)=>{t?.(e,i),ql({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:i})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}import{useCallback as Xl,useRef as Ul}from"react";function Kl(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}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 n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}function Ql(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}function Zl(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?Jl(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?Jl(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Jl(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function eu(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=so(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function tu(e){const t=[];for(const n of e)if("rect"===n.type&&null!=n.x){if(null==n.datum)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??n.datum?.category??""})}else if("point"===n.type)t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});else if("symbol"===n.type){if(0>=n.size)continue;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"})}else if("glyph"===n.type){if(0>=n.size||null==n.datum)continue;const e=so(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"})}else if("wedge"===n.type&&null!=n.cx){if(null===n.datum)continue;const e=((n.startAngle||0)+(n.endAngle||0))/2,o=((n.innerRadius||0)+(n.outerRadius||50))/2;t.push({x:n.cx+Math.cos(e)*o,y:n.cy+Math.sin(e)*o,datum:n.datum,shape:"wedge",group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function nu(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function ou(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}function ru({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:a,extractPoints:s,toHover:c}){const l=Ul(-1),u=Ul(null),d=Ul(null),h=Xl(h=>{if(Wl(h))return;const p=e.current;if(!p)return;const m=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),a()};if(0===p.scene.length)return void(0>l.current||m());let f;if(d.current?.version===p.version)f=d.current.graph;else{const e=s(p.scene);if(0===e.length)return void(0>l.current||m());f=Kl(e),d.current={version:p.version,graph:f}}let y=l.current;if(f.flat.length>y||(m(),y=-1),("Enter"===h.key||" "===h.key)&&y>=0)return h.preventDefault(),void i(c(f.flat[y],p),{type:"activate",inputType:"keyboard"});if(0>y){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),l.current=0;const e=f.flat[0];u.current=e;const n=c(e,p);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void a()}const g=Zl(h.key,Ql(f,y),f);if(null===g)return;if(h.preventDefault(),0>g)return void m();l.current=g;const b=f.flat[g];u.current=b;const v=c(b,p);t.current=v,o(v),r(v,{type:"focus",inputType:"keyboard"}),a()},[i,r,s,t,n,a,o,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:h}}function iu(e){const t=e.datum;return{...t||{},...t?.properties||{},data:t,properties:t?.properties,x:e.x,y:e.y,__semioticHoverData:!0}}import{jsx as au,jsxs as su}from"react/jsx-runtime";var cu={top:20,right:20,bottom:30,left:40},lu=rs;function uu(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var du=x(v(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:i,chunkSize:a,xAccessor:s,yAccessor:c,accessorRevision:l,colorAccessor:v,sizeAccessor:x,symbolAccessor:w,symbolMap:k,groupAccessor:S,lineDataAccessor:A,curve:C,normalize:M,baseline:P,stackOrder:I,binSize:R,valueAccessor:_,arrowOfTime:T="right",windowMode:L="sliding",windowSize:N=200,timeAccessor:$,xExtent:j,yExtent:E,extentPadding:F=.1,scalePadding:O,sizeRange:z,size:H=[500,300],responsiveWidth:W,responsiveHeight:G,margin:q,className:V,background:X,renderMode:U,lineStyle:K,pointStyle:Q,areaStyle:Z,barStyle:J,waterfallStyle:ee,swarmStyle:te,barColors:ne,colorScheme:oe,boundsAccessor:re,boundsStyle:ie,y0Accessor:ae,band:se,gradientFill:ce,lineGradient:le,areaGroups:ue,openAccessor:de,highAccessor:he,lowAccessor:pe,closeAccessor:me,candlestickStyle:fe,showAxes:ye=!0,axes:ge,xLabel:be,yLabel:ve,yLabelRight:xe,xFormat:we,yFormat:ke,axisExtent:Se,tickFormatTime:Ae,tickFormatValue:Ce,hoverAnnotation:Me,tooltipContent:Pe,customHoverBehavior:Ie,customClickBehavior:Re,onObservation:_e,annotationObservationCallback:Te,chartId:Le,enableHover:Ne,hoverRadius:$e=30,tooltipMode:Be,annotations:De,onAnnotationActivate:je,autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,showGrid:Oe,legend:ze,legendHoverBehavior:He,legendClickBehavior:We,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Ye,legendLayout:Ve,legendCategoryAccessor:Xe,onCategoriesChange:Ue,backgroundGraphics:Ke,foregroundGraphics:Qe,canvasPreRenderers:Ze,svgPreRenderers:Je,title:et,categoryAccessor:tt,brush:nt,onBrush:ot,decay:rt,pulse:it,transition:at,animate:st,staleness:ct,frameScheduler:lt,clock:ut,random:dt,seed:ht,paused:pt=!1,suspendWhenHidden:mt=!0,heatmapAggregation:ft,heatmapXBins:gt,heatmapYBins:bt,showValues:vt,heatmapValueFormat:xt,marginalGraphics:wt,pointIdAccessor:kt,xScaleType:St,yScaleType:At,accessibleTable:Ct=!0,description:Mt,summary:Pt,linkedCrosshairName:It,linkedCrosshairSourceId:Rt,customLayout:_t,onLayoutError:Tt,layoutConfig:Lt,layoutSelection:Nt}=e,{customHoverBehavior:$t,customClickBehavior:Bt,hasClickBehavior:Dt}=Vl({customHoverBehavior:Ie,customClickBehavior:Re,onObservation:_e,chartId:Le,chartType:"StreamXYFrame"}),jt=b().replace(/:/g,""),Et=h(!1),Ft=h({w:-1,h:-1}),Ot=h(!1),zt=Tc({sizeProp:H,responsiveWidth:W,responsiveHeight:G,userMargin:q,marginDefault:cu,title:et,legend:ze,legendPosition:Ye,animate:st,transitionProp:at,frameScheduler:lt,clock:ut,random:dt,seed:ht,paused:pt,suspendWhenHidden:mt,themeDirtyRef:Et}),Ht=qa(),Wt=Ua(),{reducedMotionRef:Gt,responsiveRef:qt,size:Yt,currentTheme:Vt,transition:Xt,introEnabled:Ut,tableId:Kt,rafRef:Qt,renderFnRef:Zt,scheduleRender:Jt,frameRuntime:en}=zt;let tn=zt.margin;if(wt){const e=60,t={...zt.margin};wt.top&&e>t.top&&(t.top=e),wt.bottom&&e>t.bottom&&(t.bottom=e),wt.left&&e>t.left&&(t.left=e),wt.right&&e>t.right&&(t.right=e),tn=t}const nn=Yt[0]-tn.left-tn.right,on=Yt[1]-tn.top-tn.bottom,rn=f(()=>u(r),[r]),an=Me??Ne,[sn,cn]=p(0),ln=h(0),[un,dn]=p(null),hn=Ec(Qe,Yt,tn,un),pn=Ec(Ke,Yt,tn,un),mn=h(null),fn=h(null),yn=h(void 0),[gn,bn]=p(null),vn=h(lu.primary),xn=h(function(){let e=-1,t=rs;return{resolve(n){if(!n)return rs;const o=po;return o===e||(t=function(e){if(!e)return rs;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),a=o||t.getPropertyValue("--text-secondary").trim(),s=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return a||s||n||i?{axisStroke:c||rs.axisStroke,tickText:a||rs.tickText,crosshair:a?is(a,"66"):rs.crosshair,hoverFill:l?is(l,"4D"):rs.hoverFill,hoverStroke:a?is(a,"99"):rs.hoverStroke,pointRing:l||rs.pointRing,primary:i||rs.primary,background:l||rs.background}:rs}(n),e=o),t},invalidate(){e=-1}}}()),wn=h(!1),kn=Dn("StreamXYFrame"),[Sn,An]=p(!1),[Cn,Pn]=p([]),[In,Rn]=p([]),_n="streaming"===o||["bar","swarm","waterfall"].includes(n),Tn=Qa(f(()=>({chartType:n,runtimeMode:_n?"streaming":"bounded",windowSize:N,windowMode:L,arrowOfTime:_n?T:"right",extentPadding:F,scalePadding:O,axisExtent:Se,xAccessor:s,yAccessor:c,accessorRevision:l,timeAccessor:_n?$:void 0,valueAccessor:_,colorAccessor:v,sizeAccessor:x,symbolAccessor:w,symbolMap:k,groupAccessor:S||(A?"_lineGroup":void 0),categoryAccessor:tt,lineDataAccessor:A,xScaleType:St,yScaleType:At,xExtent:j,yExtent:E,sizeRange:z,binSize:R,normalize:M,baseline:P,stackOrder:I,boundsAccessor:re,boundsStyle:ie,y0Accessor:ae,band:se,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:ue?new Set(ue):void 0,lineGradient:le,openAccessor:de,highAccessor:he,lowAccessor:pe,closeAccessor:me,candlestickStyle:fe,lineStyle:K,pointStyle:Q,areaStyle:Z,swarmStyle:te,waterfallStyle:ee,colorScheme:oe,barColors:ne,barStyle:J,annotations:De,decay:rt,pulse:it,transition:Xt,introAnimation:Ut,staleness:ct,clock:en.now,heatmapAggregation:ft,heatmapXBins:gt,heatmapYBins:bt,showValues:vt,heatmapValueFormat:xt,pointIdAccessor:kt,curve:C,themeCategorical:Vt?.colors?.categorical,themeSemantic:Y(Vt),themeSequential:Vt?.colors?.sequential,themeDiverging:Vt?.colors?.diverging,customLayout:_t,onLayoutError:Tt,layoutConfig:Lt,layoutMargin:tn}),[n,_n,N,L,T,F,O,Se,s,c,l,$,_,v,x,w,k,S,A,tt,St,At,j,E,z,R,M,P,I,re,ie,ae,se,ce,ue,le,de,he,pe,me,fe,K,Q,Z,te,ee,oe,ne,J,De,rt,it,Xt,Ut,ct,en.now,ft,gt,bt,vt,xt,kt,C,Vt,_t,Tt,Lt,tn])),Ln=h(null);Ln.current||(Ln.current=new Mn(Tn));const Nn=Wc(Ln,Xe,Ue,e=>e.getData());Vn(Ln,Tn,Et,Jt),Xn(Ln,Nt,Et,Jt);const $n=h(null);$n.current||($n.current=new D(e=>{const t=Ln.current;t&&t.ingest(e)&&(Et.current=!0,Jt())},{chunkThreshold:i,chunkSize:a})),m(()=>{$n.current?.updateChunkOptions({chunkThreshold:i,chunkSize:a})},[i,a]);const Bn=y(e=>{$n.current?.push(e)},[]),En=y(e=>{$n.current?.pushMany(e)},[]),On=y(()=>{$n.current?.clear(),Ln.current?.clear(),Et.current=!0,Jt()},[Jt]);g(t,()=>({push:Bn,pushMany:En,remove:e=>{$n.current?.flush();const t=Ln.current?.remove(e)??[];return t.length>0&&(mn.current&&t.some(e=>e===mn.current?.data)&&(mn.current=null,bn(null)),Et.current=!0,Jt()),t},update:(e,t)=>{$n.current?.flush();const n=Ln.current?.update(e,t)??[];return n.length>0&&(Et.current=!0,Jt()),n},clear:On,getData:()=>($n.current?.flush(),Ln.current?.getData()??[]),getScales:()=>Ln.current?.scales??null,getExtents:()=>Ln.current?.getExtents()??null,getCustomLayout:()=>Ln.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Ln.current?.lastCustomLayoutFailure??null}),[Bn,En,On,Jt]),m(()=>{if(r){if(A&&rn.length>0&&"object"==typeof rn[0]&&null!==rn[0]){const e="string"==typeof A?A:"coordinates";if(Array.isArray(rn[0][e])){const t=[];for(const n of rn){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void $n.current?.setBoundedData(t)}}$n.current?.setBoundedData(rn)}},[r,rn,A]);const{canvasRef:zn,interactionCanvasRef:Hn}=Bc(zt,{storeRef:Ln,dirtyRef:Et,hydrated:Ht,wasHydratingFromSSR:Wt,cleanup:()=>$n.current?.clear(),canvasPaintDependencies:[n,nn,on,ye,X,Ke,K,U,Ze,Jt]}),{hoverHandlerRef:Wn,hoverLeaveRef:qn,onPointerMove:Yn,onPointerLeave:Un}=zt;Wn.current=e=>{if(!an)return;const t=zn.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-tn.left,i=e.clientY-o.top-tn.top;if(0>r||r>nn||0>i||i>on)return void(mn.current&&(mn.current=null,fn.current=null,bn(null),$t&&($t(null),Et.current=!0),Jt()));const a=Ln.current;if(!a||0===a.scene.length)return;const c=Gs($e,e.pointerType),l=qo(a.scene,r,i,c,a.quadtree,a.maxPointRadius),u="multi"===Be,d=()=>{mn.current&&(mn.current=null,fn.current=null,bn(null),$t&&$t(null),Jt())};if(!l&&!u)return void d();const h=u||!l?r:l.x,p=u||!l?i:l.y,m=l?.datum?yt(l.datum,a.resolvedRibbons):{},f=a.scales?.x?.invert,y="function"==typeof f?f(h):void 0;let g=Ys(m,h,p,null!=y?{xValue:y,xPx:h}:void 0);if(u&&a.scene.length>0&&a.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=Yo(Go(e.path,e.curve),t,n);if(null===i)continue;const a=nr(e.path,t);o.push({node:r,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"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Go(e.topPath,e.curve),a=Go(e.bottomPath,e.curve),s=Yo(i,t,n);if(null===s)continue;const c=Yo(a,t,n),l=nr(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:s,y0:c??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 o}(a.scene,h,Math.max(c,nn));if(e.length>0){const t=a.scales.y.invert,o=vn.current,r=f?f(h):h;if(l)g.xValue=r,g.xPx=h;else{const e={xValue:r};"string"==typeof s&&(e[s]=r),g=Ys(e,h,p,{xValue:r,xPx:h})}g.allSeries=e.map(e=>{const r=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=i?r-i:r,valuePx:e.y,color:e.color||o,datum:yt(e.datum,a.resolvedRibbons)}})}}l||g.allSeries?.length?(mn.current=g,fn.current=l?.node??null,bn(g),$t&&($t(g),Et.current=!0),Jt()):d()},qn.current=()=>{mn.current&&(mn.current=null,fn.current=null,bn(null),$t&&($t(null),Et.current=!0),Jt())};const Kn=h(()=>{});Kn.current=e=>{if(wi(e.target))return;if(!Bt)return;const t=zn.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-tn.left,r=e.clientY-n.top-tn.top;if(0>o||o>nn||0>r||r>on)return void Bt(null);const i=Ln.current;if(!i||0===i.scene.length)return void Bt(null);const a=Gs($e,yn.current),s=qo(i.scene,o,r,a,i.quadtree,i.maxPointRadius);if(!s)return void Bt(null);const c=s.datum||{},l=i.scales?.x?.invert,u="function"==typeof l?l(s.x):void 0;Bt(Ys(c,s.x,s.y,null!=u?{xValue:u,xPx:s.x}:void 0),{type:"activate",inputType:Hl(yn.current)})};const Qn=y(e=>Kn.current(e),[]),{kbFocusIndexRef:Zn,focusedNavPointRef:Jn,onKeyDown:eo}=(to={storeRef:Ln,hoverRef:mn,hoveredNodeRef:fn,setHoverPoint:bn,customHoverBehavior:$t,customClickBehavior:Bt,scheduleRender:Jt},ru({...to,extractPoints:eu,toHover:(e,t)=>ou({...e,datum:yt(e.datum,t.resolvedRibbons)})}));var to;const no=y(e=>{yn.current=e.pointerType,Zn.current=-1,Jn.current=null,Yn(e)},[Jn,Zn,Yn]),oo=y(e=>{yn.current="mouse",Zn.current=-1,Jn.current=null,Yn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Jn,Zn,Yn]),ro=y(e=>{yn.current=e.pointerType},[]);Zt.current=()=>{if(Qt.current=null,!en.isActive)return;const e=zn.current,t=Hn.current;if(!e||!t)return;const o=Ln.current;if(!o)return;const r=en.now(),i=o.advanceTransition(Gt.current?r+1e6:r),a=!Gt.current&&i,l=Ft.current.w!==nn||Ft.current.h!==on,u=Et.current||i||l,d=o.consumeStylePaintPending();let h=!1;const p=o.getLastUpdateResult(),m=kn.current.beforeCompute(p,a);!u||a&&!l||(o.computeScene({width:nn,height:on}),Ft.current={w:nn,h:on},h=!0,Nn()),kn.current.afterCompute(m,h,l);const f=jc(o,r,h,Ot),y=Oc(),g=xn.current.resolve(e);vn.current=g.primary;const b=sr(ct,o.lastIngestTime>0?r-o.lastIngestTime:0),v=ct&&b.isStale;if(u||d||f.changed){const t=Fc(e,Yt,tn,y);if(t){if(t.clearRect(-tn.left,-tn.top,Yt[0],Yt[1]),ct&&1>b.alpha&&(t.globalAlpha=b.alpha),ts(t,{background:X,hasBackgroundGraphics:!!Ke,themeBackground:g.background,x:-tn.left,y:-tn.top,width:Yt[0],height:Yt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,nn,on),t.clip()),Ze&&o.scales)for(const e of Ze)t.save(),e(t,o.scene,o.scales,{width:nn,height:on}),t.restore();const e=_t?kl.custom:kl[n];Ml({context:t,nodes:o.scene,renderMode:U,pixelRatio:y,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:nn,height:on})}}),t.restore(),ct&&1>b.alpha&&(t.globalAlpha=1)}}const x=!!(an&&mn.current&&o.scales),w=!!(fn.current&&Array.isArray(Me)&&Me.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=x||w;if(os(k,wn.current)){const e=Fc(t,Yt,tn,y);if(e&&(e.clearRect(-tn.left,-tn.top,Yt[0],Yt[1]),x&&mn.current&&function(e,t,n,o,r,i,a){if(!1===r.crosshair)return;const s=t.allSeries,c=s&&s.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.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(c?l:t.x,0),e.lineTo(c?l:t.x,o),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=a.pointRing;for(const t of s)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||a.primary,e.fill(),e.stroke())}else{const n=r.pointColor||Il(i)||a.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=a.pointRing,e.lineWidth=2,e.stroke()}}(e,mn.current,nn,on,"object"==typeof an?an:{},fn.current,g),w&&fn.current&&Array.isArray(Me))){const t=Me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,fn.current,t,g)}wn.current=k}u&&e&&e.setAttribute("aria-label",ws(o.scene,n+" chart"));const S=Et.current;if(Et.current=S&&a&&!h,S&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!un||e(un.x.domain()[0])!==e(o.scales.x.domain()[0])||e(un.x.domain()[1])!==e(o.scales.x.domain()[1])||e(un.y.domain()[0])!==e(o.scales.y.domain()[0])||e(un.y.domain()[1])!==e(o.scales.y.domain()[1])||un.x.range()[0]!==o.scales.x.range()[0]||un.x.range()[1]!==o.scales.x.range()[1]||un.y.range()[0]!==o.scales.y.range()[0]||un.y.range()[1]!==o.scales.y.range()[1])&&dn(o.scales),wt){const e=o.getData(),t="function"==typeof s?s:e=>e[s||"x"],n="function"==typeof c?c:e=>e[c||"y"];Pn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Rn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((De&&De.length>0||_t)&&(h||a))||!h&&33>r-ln.current||(cn(e=>e+1),ln.current=r),ct?.showBadge&&An(!!v),(a||null!=o.activeTransition||f.pending)&&Jt()},cr(ct,Ln,Et,Jt,Sn,An);const io=f(()=>{if(we||Ae)return;const e=Ln.current;return e?.xIsDate&&un?Xc(un.x.domain()):void 0},[we,Ae,un]),ao=we||Ae||io,so=an&&gn?Pe?Pe(gn):au(zl,{hover:gn}):null,co=so?au(lc,{x:gn.x,y:gn.y,containerWidth:nn,containerHeight:on,margin:tn,className:"stream-frame-tooltip",children:so}):null,lo=Jn.current,uo=au(Hs,{active:Zn.current>=0,hoverPoint:gn,margin:tn,size:Yt,shape:lo?.shape,width:lo?.w,height:lo?.h}),ho=Gc(s,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),mo=Gc(c,_,"__semiotic_resolvedY","__semiotic_resolvedValue"),fo=ho.key,yo=mo.key,go=qc(ho,mo,De&&De.length>0||!1);if(Ea||!Ht&&Wt){const e=Ln.current;e&&r&&(e.ingest({inserts:rn,bounded:!0}),e.computeScene({width:nn,height:on}));const t=e?.scene??[],n=e?.scales??null,o=Ec(Qe,Yt,tn,n),i=Ec(Ke,Yt,tn,n),a=ao||(()=>{if(e?.xIsDate&&n)return Xc(n.x.domain())})();return su("div",{ref:qt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":Mt||("string"==typeof et?et:"XY chart"),style:{position:"relative",width:W?"100%":Yt[0],height:G?"100%":Yt[1]},children:[au(Es,{summary:Pt}),su("svg",{xmlns:"http://www.w3.org/2000/svg",width:Yt[0],height:Yt[1],style:{position:"absolute",left:0,top:0},children:[au("g",{transform:`translate(${tn.left},${tn.top})`,children:i}),su("g",{transform:`translate(${tn.left},${tn.top})`,children:[X&&au("rect",{x:0,y:0,width:nn,height:on,fill:X}),Je&&n&&Je.map((e,o)=>au(d.Fragment,{children:e(t,n,{width:nn,height:on})},"svgpre-"+o)),t.map((e,t)=>Pl({node:e,index:t,renderMode:U,fallback:()=>ja(e,t,jt)})).filter(Boolean)]})]}),au(ka,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:tn,scales:n,showAxes:ye,axes:ge,xLabel:be,yLabel:ve,yLabelRight:xe,xFormat:a,yFormat:ke||Ce,axisExtent:Se,showGrid:Oe,title:et,legend:ze,legendHoverBehavior:He,legendClickBehavior:We,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Ye,legendLayout:Ve,foregroundGraphics:Fn(o,Gn(Ln.current?.customLayoutOverlays,Nt??null)),marginalGraphics:wt,xValues:[],yValues:[],annotations:De,onAnnotationActivate:je,onObservation:Te??_e,chartId:Le,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,annotationFrame:0,xAccessor:fo,yAccessor:yo,annotationData:go(Ln.current?.getData()),pointNodes:Uc(Ln.current?.scene),curve:"string"==typeof C?C:void 0,linkedCrosshairName:It,linkedCrosshairSourceId:Rt})]})}return su("div",{ref:qt,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":Mt||("string"==typeof et?et:"XY chart"),tabIndex:0,style:{position:"relative",width:W?"100%":Yt[0],height:G?"100%":Yt[1],overflow:"visible",touchAction:uu(nt)},onKeyDown:eo,children:["production"!==process.env.NODE_ENV&&Ln.current&&au(jn,{store:Ln.current,diagnostics:kn.current}),Ct&&au(Fs,{tableId:Kt}),Ct&&au(Ds,{scene:Ln.current?.scene??[],chartType:n+" chart",tableId:Kt,chartTitle:"string"==typeof et?et:void 0}),au(Es,{summary:Pt}),au(ms,{hoverPoint:gn}),su("div",{role:"img","aria-label":Mt||("string"==typeof et?et:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:an?no:void 0,onMouseMove:an?oo:void 0,onPointerLeave:an?Un:void 0,onMouseLeave:an?Un:void 0,onPointerDown:an||Dt?ro:void 0,onClick:Dt?Qn:void 0,children:[au(Dc,{size:Yt,margin:tn,children:pn}),au(va,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:tn,scales:un,showAxes:ye,axes:ge,showGrid:Oe,xFormat:ao,yFormat:ke||Ce,axisExtent:Se}),au("canvas",{ref:zn,"aria-label":ws(Ln.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),au("canvas",{ref:Hn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),au(ka,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:tn,scales:un,showAxes:ye,axes:ge,xLabel:be,yLabel:ve,yLabelRight:xe,xFormat:ao,yFormat:ke||Ce,axisExtent:Se,showGrid:Oe,title:et,legend:ze,legendHoverBehavior:He,legendClickBehavior:We,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Ye,legendLayout:Ve,foregroundGraphics:Fn(hn,Gn(Ln.current?.customLayoutOverlays,Nt??null)),marginalGraphics:wt,xValues:Cn,yValues:In,annotations:De,onAnnotationActivate:je,onObservation:Te??_e,chartId:Le,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,annotationFrame:sn,xAccessor:fo,yAccessor:yo,annotationData:go(Ln.current?.getData()),pointNodes:Uc(Ln.current?.scene),curve:"string"==typeof C?C:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==X&&!Ke,linkedCrosshairName:It,linkedCrosshairSourceId:Rt}),(nt||ot)&&au(B,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:tn,dimension:nt?.dimension??"xy",scales:un,onBrush:ot??(()=>{}),binSize:R,snap:nt?.snap,binBoundaries:nt?.binBoundaries??("bar"===n?Ln.current?.getBinBoundaries():void 0),snapDuring:nt?.snapDuring,streaming:"streaming"===o}),ct?.showBadge&&au(ur,{isStale:Sn,position:ct.badgePosition}),uo,co]})]})}));du.displayName="StreamXYFrame";var hu=du;import{useMemo as pu,useCallback as mu,useState as fu,useId as yu,useEffect as gu,useRef as bu}from"react";import{createContext as vu,useContext as xu,useMemo as wu}from"react";import{jsx as ku}from"react/jsx-runtime";var Su=vu(null);function Au({colors:e,categories:t,colorScheme:n="category10",children:o}){const r=wu(()=>{if(e)return e;if(t){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n,o={};let r=0;for(const n of t)o[n]=We(e,n)??Ee[r++%Ee.length];return o}const e=Array.isArray(n)?n:je[n]||Ee,o={};for(let n=0;t.length>n;n++)o[t[n]]=e[n%e.length];return o}return{}},[e,t,n]);return ku(Su.Provider,{value:r,children:o})}function Cu(){return xu(Su)}Au.displayName="CategoryColorProvider";import{createContext as Mu,useContext as Pu,useEffect as Iu,useId as Ru,useLayoutEffect as _u,useMemo as Tu,useRef as Lu,useState as Nu,useCallback as $u}from"react";function Bu(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Du(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Bu(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function ju(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Eu(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 n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Fu,Ou]=G(e=>({selections:new Map,setClause(t,n){e(e=>{const o=e.selections.get(t),r=o?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,o]of n){const n=t.fields[e];if(!n||!Eu(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),a=ju(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o||!o.clauses.has(n))return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,{...o,clauses:i}),{selections:r}})},setResolution(t,n){e(e=>{const o=e.selections.get(t);if(o?.resolution===n)return{};const r=new Map(e.selections),i=ju(r,t);return r.set(t,{...i,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const o=new Map(e.selections);return o.set(t,{...n,clauses:new Map}),{selections:o}})}}));import{useId as zu,useMemo as Hu,useCallback as Wu}from"react";function Gu(e){const t=zu(),n=e.clientId||t,{name:o}=e,r=Ou(e=>e.selections.get(o)),i=Ou(e=>e.setClause),a=Ou(e=>e.clearClause),s=Hu(()=>!!r&&r.clauses.size>0,[r]);return{predicate:Hu(()=>r&&0!==r.clauses.size?Du(r,n):()=>!0,[r,n]),isActive:s,selectPoints:Wu(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)},r=!0;r&&i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:Wu(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o},r=!0;r&&i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:Wu(()=>{a(o,n)},[a,o,n]),clientId:n}}function qu(e,t){const n=zu(),o=t||n,r=Ou(e=>e.setClause),i=Ou(e=>e.clearClause);return{selectPoints:Wu(t=>{const n={};let i=!1;for(const[e,o]of Object.entries(t))n[e]={type:"point",values:new Set(o)},i=!0;i&&r(e,{clientId:o,type:"point",fields:n})},[e,o,r]),clear:Wu(()=>i(e,o),[e,o,i]),clientId:o}}function Yu(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:a}=Gu({name:t,fields:n});return{onHover:Wu(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Uu(t)&&i(t)},[n,i,a]),predicate:o,isActive:r}}function Vu(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Xu(e){const{name:t,xField:n,yField:o}=e,{predicate:r,isActive:i,selectInterval:a,clear:s}=Gu({name:t,fields:[n,o].filter(Boolean)}),c=n&&o?"xyBrush":n?"xBrush":"yBrush",l=Wu(e=>{if(!e)return void s();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),o&&(t[o]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Vu(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&Vu(e)&&o&&(t[o]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Uu(t)&&a(t)},[c,n,o,a,s]);return{brushInteraction:Hu(()=>({brush:c,during:l,end:l}),[c,l]),predicate:r,isActive:i,clear:s}}function Uu(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Ku(e,t,n){const o=Ou(e=>e.selections.get(t));return Hu(()=>{if(!o||0===o.clauses.size)return e;const t=Du(o,n);return e.filter(t)},[e,o,n])}import{useMemo as Qu}from"react";function Zu(e={}){const{limit:t=50,types:n,chartId:o}=e,r=gi(e=>e.version),i=gi(e=>e.observations),a=gi(e=>e.clearObservations),s=Qu(()=>{let e=i;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return o&&(e=e.filter(e=>e.chartId===o)),e.length>t&&(e=e.slice(e.length-t)),e},[i,n,o,t,r]);return{observations:s,latest:s.length>0?s[s.length-1]:null,clear:a}}import{jsx as Ju,jsxs as ed}from"react/jsx-runtime";var td=Mu(!1),nd=Mu(!1);function od(){return Pu(nd)}var rd=Mu(null),id="undefined"==typeof window?Iu:_u;function ad(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}function sd(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0}function cd(e){const t=Pu(rd),n=Ru(),o=ad(e),r=Lu([]);sd(r.current,o)||(r.current=o);const i=r.current;id(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),id(()=>{t&&t.registerCategories(n,i)},[t,n,i])}var ld="__linked-legend-isolate__",ud="__linked-legend-highlight__";function dd({categoryColors:e,interaction:t,selectionName:n,field:o}){const r=Object.entries(e),i=r.map(([e])=>e),a=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:r.map(([e,t])=>({label:e,color:t})),label:""}],{selectPoints:s,clear:c}=Gu({name:n,fields:[o],clientId:ld}),{selectPoints:l,clear:u}=Gu({name:n,fields:[o],clientId:ud}),d=Ou(e=>e.selections.get(n)),{isolatedCategories:h,highlightedCategory:p}=Tu(()=>{const e=new Set;let t=null;const n=d?.clauses.get(ld)?.fields[o];if("point"===n?.type)for(const t of n.values)e.add(t+"");const r=d?.clauses.get(ud)?.fields[o];if("point"===r?.type){const e=r.values.values().next().value;null!=e&&(t=e+"")}return{isolatedCategories:e,highlightedCategory:t}},[d,o]),m=$u(e=>{"highlight"===t&&(e?l({[o]:[e.label]}):u())},[t,o,l,u]),f=$u(e=>{if("isolate"!==t)return;const n=new Set(h);n.has(e.label)?n.delete(e.label):n.add(e.label),0===n.size||n.size===i.length?c():s({[o]:Array.from(n)})},[t,o,h,i.length,s,c]),[y,[g]]=Sc([0,0],!0,!1),b=Tu(()=>function(e,t){if(!t||0===e.length)return 1;let n=0,o=1;for(const r of e){const e=26+7*r.length;n>0&&n+e>t&&(o++,n=0),n+=e}return o}(r.map(([e])=>e),g),[r,g]);return 0===r.length?null:Ju("div",{ref:y,style:{width:"100%",display:"block"},children:Ju("svg",{width:"100%",height:Math.max(30,22*b+8),style:{display:"block",overflow:"visible"},children:Ju(Sr,{legendGroups:a,title:!1,orientation:"horizontal",width:g,height:20,customHoverBehavior:"highlight"===t?m:void 0,customClickBehavior:"isolate"===t?f:void 0,highlightedCategory:p,isolatedCategories:h})})})}function hd({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:a="category"}){const s=Tu(()=>{if(!t)return;const e=new Map;for(const[n,o]of Object.entries(t))o.resolution&&e.set(n,{name:n,resolution:o.resolution,clauses:new Map});return e.size>0?{selections:e}:void 0},[t]),c=Cu(),[l,u]=Nu({}),d=Lu({}),h=Tu(()=>({registerCategories:(e,t)=>{const n=ad(t);u(t=>sd(t[e]??[],n)?t:{...t,[e]:n})},unregisterCategories:e=>{u(t=>{if(!(e in t))return t;const n={...t};return delete n[e],n})}}),[]),p=Tu(()=>{const e=[];for(const t of Object.values(l))for(const n of t)e.push(n);return ad(e)},[l]),m=Tu(()=>{const e=c??{},t=d.current;let n=Object.keys(e).length+Object.keys(t).length;for(const o of p)e[o]||t[o]||(t[o]=Ee[n%Ee.length],n++);const o={...e};for(const n of p)o[n]=e[n]??t[n];return o},[c,p]),f=void 0===n||n,y=Object.keys(m).length>0;return Ju(Fu,{initialState:s,children:Ju(yi,{children:Ju(nd.Provider,{value:!0,children:Ju(rd.Provider,{value:h,children:Ju(Au,{colors:m,children:ed(td.Provider,{value:f&&y,children:[f&&"top"===o&&Ju(dd,{categoryColors:m,interaction:r,selectionName:i,field:a}),e,f&&"bottom"===o&&Ju(dd,{categoryColors:m,interaction:r,selectionName:i,field:a})]})})})})})})}function pd({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const a=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),s=a?o(a,t,n):n?n(r):Fe[i%Fe.length];return{label:r+"",color:s}}),label:""}]}}function md(e){return e?"string"==typeof e?{name:e}:e:null}function fd(e,t,n){return t?(o,...r)=>{const i={...e(o,...r)};if(t.isActive)if(t.predicate(o))n?.selectedStyle&&Object.assign(i,n.selectedStyle);else{const e=n?.unselectedOpacity??.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e}import*as yd from"react";var gd={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 bd(e){return gd[e]}import{jsx as vd,jsxs as xd}from"react/jsx-runtime";var wd=yd.createContext(void 0),kd="undefined"==typeof window?yd.useEffect:yd.useLayoutEffect;function Sd(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return bd(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function Ad({theme:e}){const t=ee(e=>e.setTheme),n=ee(e=>e.theme),o=yd.useRef(n);o.current=n;const r=yd.useRef(null);yd.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const n=window.matchMedia("(forced-colors: active)");return n.matches&&(r.current=o.current===Q?U:o.current,t("high-contrast")),bc(n,e=>{e.matches?(r.current=o.current===Q?r.current??U:o.current,t("high-contrast")):(function(e,t){e(t===U?"light":t===K?"dark":t===Q?"high-contrast":t)}(t,r.current??U),r.current=null)})},[e,t]);const i=yd.useRef(!1);return kd(()=>{i.current?void 0!==e&&t(Sd(e)):i.current=!0},[e,t]),null}function Cd({children:e}){const t=ee(e=>e.theme),n={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}:{}},o=yd.useContext(wd),r={};return o&&(r["data-semiotic-theme"]=o),vd("div",{style:n,...r,children:e})}function Md({theme:e,children:t}){const n="string"==typeof e&&bd(e)?e:void 0,o=yd.useMemo(()=>function(e){return void 0!==e?Z(U,Sd(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?Q:U}(e),[e]);return vd(J,{initialState:{theme:o},children:xd(wd.Provider,{value:n,children:[vd(Ad,{theme:e}),vd(Cd,{children:t})]})})}function Pd(){return ee(e=>e.theme)}function Id(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Rd(e,t){const{when:n}=e,o=t.width,r=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 n.minWidth&&n.minWidth>o||"number"==typeof n.maxWidth&&o>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function _d(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const o=n.map((e,t)=>({rule:e,index:t})).filter(e=>Rd(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:o.reduce((e,t)=>function(e,t){const n={...e,...t};for(const o of["margin","frameProps","mobileSemantics","style"])Id(e[o])&&Id(t[o])&&(n[o]={...e[o],...t[o]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:o}}function Td(e,t,n){const o=e.xValue??t?.[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function Ld(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 Nd(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var $d="#007bff",Bd=[],Dd={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function jd(e,t={}){const n=t.mobileSemantics?.interaction,o="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==o,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!r&&!i)return Dd;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??o??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function Ed(){const e=Pd(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Fd(e,t,n,o,r){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=We(n,o);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=je[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=o?(r.has(o)||r.set(o,r.size),i[r.get(o)%i.length]):i[0]:$d}function Od(e,t,n){const o=Cu(),r=Ed();return pu(()=>{if(!t)return;const i=o??void 0,a=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&Nd(i)){const e=Ge(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return Ge(n.map(e=>({_cat:e})),"_cat",a)}if(i&&Nd(i)){const n=Ge(e,t,a);return e=>i[e]||n(e)}return Ge(e,t,a)}if(i&&Nd(i)){const e=Ge([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,o,r])}function zd(e,t,n){return pu(()=>{if(!t||"auto"===t||"function"==typeof t)return e;const o=[...e],r="function"==typeof(i=n)?i:e=>e[i];var i;return o.sort("asc"===t?(e,t)=>r(e)-r(t):(e,t)=>r(t)-r(e))},[e,t,n])}function Hd({selection:e,linkedHover:t,fallbackFields:n=Bd,unwrapData:o=!1,onObservation:r,chartType:i,chartId:a,onClick:s,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=yu(),h=pu(()=>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,n),[t,n]),p=pu(()=>"series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n,[h,l,n]),m=Gu({name:e?.name||"__unused__",fields:p}),f=Yu({name:h?.name||"hover",fields:p}),y=gi(e=>e.pushObservation),g=mu(e=>{r?.(e),y?.(e)},[r,y]),b=e?{isActive:m.isActive,predicate:m.predicate}:null,[v,x]=fu(null),w=bu(!1),k=l||n[0],S=pu(()=>{if(!c||null==v||!k)return null;const e=v,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,v,k]),A=mu((e,n)=>{const o=!e&&w.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 n=Td(e,t,h.xField);null!=n&&function(e,t,n){const o=ea.positions.get(e);o?.locked||o&&o.xValue===t&&o.sourceId===n||(ea={positions:new Map(ea.positions).set(e,{xValue:t,sourceId:n})},na())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&f.onHover(t)}else"x-position"!==h?.mode||o||oa(h.name||"hover",d),"x-position"===h?.mode||o||f.onHover(null);if(c&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];x(null!=n?n+"":null)}else o||x(null);(r||y)&&Gl({onObservation:g,datum:e?Ld(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,f,h,d,r,i,a,y,g,c,k,u]),C=mu((n=!0)=>{w.current=!1,t&&"x-position"!==h?.mode&&f.onHover(null),e&&u?.tapToSelect&&m.clear(),n&&c&&x(null),"x-position"===h?.mode&&(ra(h.name||"hover",d),oa(h.name||"hover",d))},[t,h,f,e,u,m,c,d]),M=mu((n,o)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),b=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=Td(n,e,h.xField);null!=t&&function(e,t,n){const o=ea.positions.get(e);if(o?.locked){const t=new Map(ea.positions);return t.delete(e),ea={positions:t},na(),!1}ea={positions:new Map(ea.positions).set(e,{xValue:t,sourceId:n,locked:!0})},na()}(h.name||"hover",t,d)}if(l)if(n){w.current=!0;const o=Ld(n);if(t&&"x-position"!==h?.mode&&f.onHover(o),e&&u?.tapToSelect&&p.length>0){const e={};for(const t of p){const n=o[t];void 0!==n&&(e[t]=[n])}Nd(e)&&m.selectPoints(e)}if(c&&k){const e=o?.[k];x(null!=e?e+"":null)}}else b&&C();if(n||b){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}(r||y)&&ql({onObservation:g,datum:n?Ld(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:o})}},[s,r,y,g,i,a,h,d,u,t,f,e,m,p,c,k,C]);return gu(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&w.current&&C()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,C]),gu(()=>()=>{w.current&&C(!1)},[C]),gu(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{ra(e,d),oa(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:M,crosshairSourceId:d}}function Wd(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function Gd({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s}){const c=Pu(td),l=null!==Pu(rd),u=void 0!==o?o:!c&&!!t,d=!!t&&(u||l),h=pu(()=>{if(!d)return[];if(void 0!==s)return s;const n=new Set;for(const o of e){const e="function"==typeof t?t(o):o[t];null!=e&&n.add(e+"")}return Array.from(n)},[s,t,e,d]);cd(l&&t?h:[]);const p=pu(()=>{if(!u||!t)return;const o=pd({data:e,colorBy:t,colorScale:n,getColor:He,categories:h});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[u,t,e,n,h]),m=pu(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return p&&("right"===r&&!o("right")&&110>n.right?n.right=110:"left"===r&&!o("left")&&110>n.left?n.left=110:"top"===r&&!o("top")&&50>n.top?n.top=50:"bottom"===r&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,i,p,r]);return{legend:p,margin:m,legendPosition:r}}function qd(e,t,n){const[o,r]=fu(null),[i,a]=fu(new Set),s=pu(()=>new Set,[]),c=mu(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=mu(t=>{"isolate"===e&&a(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=pu(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return i.has(o)}}:null},[e,t,o,i]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}var Yd={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 Vd(e,t,n){const o=Yd[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,a=_d({...t,mode:e},{width:t.width??r,height:t.height??i}).props,s=a.mode||e,c=Yd[s||"primary"],l="context"===s||"sparkline"===s,u=s&&"primary"!==s||!n?.width?c.width:n.width;return{width:a.width??u,height:a.height??(s&&"primary"!==s||!n?.height?c.height:n.height),showAxes:a.showAxes??c.showAxes,showGrid:a.showGrid??c.showGrid,enableHover:a.enableHover??(!!a.linkedHover||c.enableHover),showLegend:a.showLegend??c.showLegend,showLabels:a.showLabels??c.showLabels,title:l?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:l?void 0:a.xLabel,yLabel:l?void 0:a.yLabel,categoryLabel:l?void 0:a.categoryLabel,valueLabel:l?void 0:a.valueLabel,marginDefaults:Xd(c.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:l,mobileInteraction:jd(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function Xd(e,t,n){if(!1!==t)return e;const o={...e};return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}import{jsx as Ud,jsxs as Kd}from"react/jsx-runtime";function Qd({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return Ud("div",{role:"alert",style:{width:o,height:Math.max(r,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:Kd("div",{style:{textAlign:"center",maxWidth:400},children:[Ud("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),Ud("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&Ud("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:n})]})})}import*as Zd from"react";import{jsx as Jd}from"react/jsx-runtime";var eh=class extends Zd.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:Jd(Qd,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as th}from"react/jsx-runtime";var nh="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function oh({componentName:e,width:t,height:n,children:o}){return th(eh,{fallback:o=>th(Qd,{componentName:e,message:o.message,width:t,height:n}),children:o})}var rh={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"},ih={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ah(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?th("div",{style:{...rh,width:t,height:n},children:o||"No data available"}):null}function sh(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return th("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*r))),a=Math.max(6,Math.floor(n/(2.5*r))),s=Math.floor((n-(r*(i+a)-a))/2);return th("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>th("div",{className:"semiotic-loading-bar",style:{...ih,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function ch(e,t,n,o){if(!nh)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function lh(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let a=1;o>=a;a++){const o=r[a];r[a]=e[i-1]===t[a-1]?n:1+Math.min(n,r[a],r[a-1]),n=o}}return r[o]}function uh(e,t,n=3){let o,r=n+1;for(const n of t){const t=lh(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function dh(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function hh(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(uh(e,t,3)??null)}function ph({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)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(n){const o=dh(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=hh(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function mh({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} 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 fh({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!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 n=dh(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=hh(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}import{useCallback as yh,useMemo as gh,useState as bh}from"react";import{useMemo as vh}from"react";function xh(e){const t=ee(e=>e.theme.colors.selectionOpacity);return vh(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}function wh(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:i,legendPosition:a,selection:s,linkedHover:c,fallbackFields:l,unwrapData:d=!1,onObservation:h,chartType:p,chartId:m,showLegend:f,userMargin:y,marginDefaults:g,onClick:b,hoverHighlight:v,mobileInteraction:x,mobileSemantics:w,loading:k,loadingContent:S,emptyContent:A,width:C,height:M}=e,P=void 0===n,I=gh(()=>u(t),[t]),[R,_]=bh([]),T=yh(e=>{_(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),L="string"==typeof e.colorBy?e.colorBy:void 0,N=gh(()=>jd(x,{width:C,mobileSemantics:w}),[x,C,w]),{activeSelectionHook:$,hoverSelectionHook:B,customHoverBehavior:D,customClickBehavior:j,crosshairSourceId:E}=Hd({selection:s,linkedHover:c,fallbackFields:l,unwrapData:d,onObservation:h,chartType:p,chartId:m,onClick:b,hoverHighlight:v,colorByField:L,mobileInteraction:N}),F=Wd(c,E),O=Od(I,o,r),z=gh(()=>{if(!o)return[];const e=new Set;for(const t of I){const n="function"==typeof o?o(t):t[o];null!=n&&e.add(n+"")}return Array.from(e)},[I,o]),H=gh(()=>P&&R.length>0?R:z,[P,R,z]),W=qd(i,o,H),G=gh(()=>B||(W.legendSelectionHook?W.legendSelectionHook:$),[B,W.legendSelectionHook,$]),q=xh(s),Y=Ed(),V=Cu(),X=gh(()=>{if(O)return O;if(!o||0===H.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:Y&&Y.length>0?Y:Fe,t="__streamCat",n=Ge(H.map(e=>({[t]:e})),t,e);return e=>V?.[e]||n(e)||"#999"},[O,o,H,r,Y,V]),{legend:U,margin:K,legendPosition:Q}=Gd({data:I,colorBy:o,colorScale:X,showLegend:f,legendPosition:a,userMargin:y,defaults:g,categories:H}),Z=gh(()=>{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&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=T),e},[U,Q,i,W.onLegendHover,W.onLegendClick,W.highlightedCategory,W.isolatedCategories,P,o,T]),J=Array.isArray(n)?u(n):n,ee=sh(k,C,M,S),te=ee?null:ah(J,C,M,A);return{data:I,colorScale:O,allCategories:H,legendState:W,effectiveSelectionHook:G,activeSelectionHook:$,customHoverBehavior:D,customClickBehavior:j,mobileInteraction:N,legend:U,margin:K,legendPosition:Q,earlyReturn:ee||te||null,legendBehaviorProps:Z,crosshairProps:F,resolvedSelection:q}}import{useMemo as kh}from"react";function Sh(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Ah(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Ph(t(e))}function Ch(e,t){const n=Ah(e),o=Ah(t);return(e,t)=>{const r=o(e);return{value:r,x:n(e),y:r,category:t}}}function Mh(e,t){const n=Ah(t??"value"),o=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=o?o(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Ph(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function Ih(e,t,n){const o=e.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(t,n):function(e,t,n){const o=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&o!==e.eq)return!1;if(void 0!==e.ne&&o===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(o))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const r=Ph(o);if(void 0===r)return!1;if(void 0!==e.gt&&e.gt>=r)return!1;if(void 0!==e.gte&&e.gte>r)return!1;if(void 0!==e.lt&&r>=e.lt)return!1;if(void 0!==e.lte&&r>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>r||r>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(r>=t&&n>=r)return!1}return!0}(o,t,n))}function Rh(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!Ih(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function _h(e,t,n,o=e=>e){const r=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const a=o(e),s={...r(e,i)};return Object.assign(s,Rh(a,t,n(a,i))),s}:r}function Th(e){const{lineWidth:t=2,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:a,areaOpacity:s=.3,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,styleRules:p,ruleContext:m}=e,f=kh(()=>(e,c)=>{const l={strokeWidth:t},u=!0===a||Array.isArray(a)&&null!=c&&a.includes(c);let d;return i?d=i(e,c):n?o&&(d=He(e,n,o)):d=r||$d,void 0!==d&&(l.stroke=d,u&&(l.fill=d,l.fillOpacity=s)),p&&p.length>0&&Object.assign(l,Rh(e,p,m?m(e,c):{value:void 0,category:c})),l},[t,n,o,r,i,a,s,p,m]),y=kh(()=>Sh(f,{stroke:c,strokeWidth:l,opacity:u}),[f,c,l,u]);return kh(()=>fd(y,d??null,h),[y,d,h])}import{useImperativeHandle as Lh}from"react";function Nh(e,t){const{variant:n,frameRef:o,overrides:r}=t;Lh(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,n)=>e.current?.update(t,n)??[],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 n=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],r=[];for(const t of n){const n=o.find(e=>e.id===t);n&&r.push({...n.data??{},id:t}),e.current?.removeNode(t)}return r},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,n);return o?[{...o,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,n)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(n(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const o=n.current?.removeLine(e)??[];for(const e of o)n.current?.pushLine(t(e));return o},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,o);return{...e,...r}},[o,r,n])}function $h(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:a,axisExtent:s,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),o&&(l.summary=o),void 0!==r&&(l.accessibleTable=r),i&&(l.className=i),null!=a&&(l.animate=a),void 0!==s&&(l.axisExtent=s),void 0!==c&&(l.autoPlaceAnnotations=c),l}function Bh(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,p={};o&&(p.annotationObservationCallback=o);const m=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(s||t||o||r||a)&&(p.customHoverBehavior=u),d&&(c||(h?o||r||t:o||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||a||n))&&(p.customClickBehavior=d),null!=m&&(p.hoverRadius=m),p}function Dh(e){const{tooltip:t,defaultTooltipContent:n}=e;return{tooltipContent:!1===t?()=>null:sc(t)||n}}var jh="__forecastSegment",Eh=null;async function Fh(){return Eh||(Eh=await import("./semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js")),Eh}import{useEffect as Oh,useMemo as zh,useRef as Hh,useState as Wh}from"react";var Gh="__semiotic_resolvedX",qh="__semiotic_resolvedY";function Yh(e){const{data:t,xAccessor:n,yAccessor:o,forecast:r,anomaly:i,groupBy:a}=e,s="string"==typeof n?n:Gh,c="string"==typeof o?o:qh,l=zh(()=>{if(!r&&!i)return t;const e="function"==typeof n,a="function"==typeof o;return e||a?t.map(t=>{const r={...t};return e&&(r[Gh]=n(t)),a&&(r[qh]=o(t)),r}):t},[t,r,i,n,o]),[u,d]=Wh(null),[h,p]=Wh([]),m=Hh(r),f=Hh(i);return Oh(()=>{if(!r&&!i)return void((m.current||f.current)&&(d(null),p([]),m.current=r,f.current=i));let e=!1;const t=r!==m.current||i!==f.current;if(m.current=r,f.current=i,t&&(d(null),p([])),r){const t=a&&"string"==typeof a&&"object"==typeof r?{...r,_groupBy:a}:r;(async function(...e){return(await Fh()).buildForecast(...e)})(l,s,c,t,i).then(t=>{e||(d(t),p(t.annotations))}).catch(()=>{e||(d(null),p([]))})}else i&&async function(...e){return(await Fh()).buildAnomalyAnnotations(...e)}(i).then(t=>{e||(d(null),p(t))}).catch(()=>{e||p([])});return()=>{e=!0}},[l,r,i,s,c,a]),{effectiveData:u?u.processedData:t,statisticalAnnotations:h,hasForecast:!!u,xAccessorKey:s,yAccessorKey:c}}import{jsx as Vh}from"react/jsx-runtime";var Xh="__lineObjectSeries",Uh=s(function(e,t){const n=c(null);Nh(t,{variant:"xy",frameRef:n});const s=Vd(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:l,margin:d,className:h,xFormat:p,yFormat:m,axisExtent:f,xAccessor:y="x",yAccessor:g="y",lineBy:b,lineDataAccessor:v="coordinates",colorBy:x,colorScheme:w,styleRules:k,curve:S="linear",showPoints:A=!1,pointRadius:C=3,fillArea:M=!1,areaOpacity:P=.3,lineWidth:I=2,lineGradient:R,tooltip:_,pointIdAccessor:T,annotations:L,directLabel:N,gapStrategy:$="break",anomaly:B,forecast:D,band:j,xExtent:E,yExtent:F,frameProps:O={},selection:z,linkedHover:H,onObservation:W,onClick:G,hoverHighlight:q,hoverRadius:Y,chartId:V,loading:X,loadingContent:U,emptyContent:K,legendInteraction:Q,legendPosition:Z,xScaleType:J,yScaleType:ee,color:te,stroke:ne,strokeWidth:oe,opacity:re}=e,{width:ie,height:ae,enableHover:se,showGrid:ce,showLegend:le,title:ue,description:de,summary:he,accessibleTable:pe,xLabel:me,yLabel:fe}=s,ye=o(()=>u(l),[l]),ge=Array.isArray(ye[0]?.[v])?ye[0][v]:ye;ch("LineChart",ge,"xAccessor",y),ch("LineChart",ge,"yAccessor",g);const{effectiveData:be,statisticalAnnotations:ve}=Yh({data:ye,xAccessor:y,yAccessor:g,forecast:D,anomaly:B,groupBy:b}),xe="__compoundGroup",we=!(!D||!b),ke=we?xe:D?jh:b,Se=o(()=>{if(!we)return be;const e="function"==typeof b?b:e=>e[b];return be.map(t=>{const n={...t};return n[xe]=`${e(t)}__${t[jh]||"observed"}`,n})},[be,we,b]),Ae=we?Se:be,Ce=x||b,Me=o(()=>{if(!D)return;const e=D.upperBounds,t=D.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let r=1/0,i=-1/0;const a=be;for(const e of a){const t="function"==typeof g?g(e):+e[g];if(isFinite(t)&&(r>t&&(r=t),t>i&&(i=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>i&&(i=t),r>t&&(r=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(r>t&&(r=t),t>i&&(i=t))}}return isFinite(r)&&isFinite(i)?[r,i]:void 0},[D,be,g]),Pe=r(e=>{const t="function"==typeof y?y(e):e[y],n="function"==typeof g?g(e):e[g];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[y,g]),Ie=void 0!==Ae[0]?.[v],Re=Ie?Xh:ke,_e=o(()=>{if(Ie)return Ae.map((e,t)=>{const n="function"==typeof b?b(e):"string"==typeof b?e[b]:void 0,o=null==n?"line-"+t:n+"",r=Array.isArray(e[v])?e[v]:[];return{...e,[Xh]:o,[v]:r.map(t=>({...t,[Xh]:o,parentLine:e,..."string"==typeof b&&void 0!==e[b]?{[b]:e[b]}:{}}))}});if(ke){const e=Ae.reduce((e,t)=>{const n="function"==typeof ke?ke(t):t[ke];if(!e[n]){const o={[v]:[]};"string"==typeof ke&&(o[ke]=n),we&&(o[jh]=t[jh],"string"==typeof b&&(o[b]=t[b])),e[n]=o}return e[n][v].push(t),e},{});return Object.values(e)}return[{[v]:Ae}]},[Ie,ke,v,Ae,b,we]),{gapProcessedLineData:Te,hasGaps:Le}=o(()=>{if("interpolate"===$){let e=!1;const t=[];for(const n of _e){const o=(n[v]||[]).filter(t=>!Pe(t)||(e=!0,!1));o.length>0&&t.push({...n,[v]:o})}return{gapProcessedLineData:t,hasGaps:e}}if("break"===$){let e=!1;const t=[];for(const n of _e){const o=n[v]||[];let r=[],i=0;const a=Re&&"string"==typeof Re?n[Re]:void 0;for(const s of o)if(Pe(s))e=!0,r.length>0&&(t.push({...n,[v]:r}),r=[],i++);else{const e=null!=a?`${a}__seg${i}`:"__seg"+i;r.push({...s,_gapSegment:e})}r.length>0&&t.push({...n,[v]:r})}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===$){let e=!1;const t="string"==typeof g?g:"y",n=[];for(const o of _e){const r=o[v]||[],i=[];for(const n of r)Pe(n)?(e=!0,i.push({...n,[t]:0})):i.push(n);n.push({...o,[v]:i})}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:_e,hasGaps:!1}},[_e,$,v,Pe,Re,g]),Ne="object"==typeof N?N:{},$e=Ne.position||"end",Be=Ne.fontSize||11,De=o(()=>{if(!N||!Ce)return[];const e="function"==typeof Ce?Ce:e=>e[Ce],t=new Set;for(const n of Te){const o=n[v]||[];if(0===o.length)continue;const r=e("end"===$e?o[o.length-1]:o[0])??e(n);if(null==r)continue;const i=r+"";""!==i&&t.add(i)}return Array.from(t)},[N,Ce,Te,v,$e]),je=o(()=>{if(!N)return s.marginDefaults;const e=De.reduce((e,t)=>Math.max(e,t.length*(.6*Be)),0)+10,t="end"===$e?"right":"left";return{...s.marginDefaults,[t]:Math.max(s.marginDefaults[t]||0,e)}},[N,De,Be,$e,s.marginDefaults]),Ee=wh({data:be,rawData:l,colorBy:Ce,colorScheme:w,legendInteraction:Q,legendPosition:Z,selection:z,linkedHover:H,fallbackFields:Ce?["string"==typeof Ce?Ce:""]:[],unwrapData:!1,onObservation:W,onClick:G,hoverHighlight:q,mobileInteraction:s.mobileInteraction,mobileSemantics:s.mobileSemantics,chartType:"LineChart",chartId:V,showLegend:(!N||void 0!==le)&&le,userMargin:d,marginDefaults:je,loading:X,loadingContent:U,emptyContent:K,width:ie,height:ae}),Fe=Ee.colorScale,Oe=Ee.effectiveSelectionHook,ze=Ee.resolvedSelection,We=Ee.customHoverBehavior,Ge=Ee.customClickBehavior,qe=Ee.crosshairProps,Ye=o(()=>{if(Ce)return Ie?e=>{const t=e.parentLine||e;return"function"==typeof Ce?Ce(t):t[Ce]}:Ce},[Ce,Ie]),Ve=o(()=>Ch(y,g),[y,g]),Xe=Th({lineWidth:I,colorBy:Ye,colorScale:Fe,color:te,fillArea:M,areaOpacity:P,stroke:ne,strokeWidth:oe,opacity:re,effectiveSelectionHook:Oe,resolvedSelection:ze,styleRules:k,ruleContext:Ve}),[Ue,Ke]=i(null);a(()=>{if(!D)return void Ke(null);let e=!1;return async function(...e){return(await Fh()).createSegmentLineStyle(...e)}(Xe,D).then(t=>{e||Ke(()=>t)}).catch(()=>{e||Ke(null)}),()=>{e=!0}},[Xe,D]);const Qe=Ue||Xe,Ze=o(()=>{if(A)return e=>{const t={r:C,fillOpacity:1};return Ce?Fe&&(t.fill=He(e.parentLine||e,Ce,Fe)):t.fill=te||$d,t}},[A,C,Ce,Fe,te]),Je=Array.isArray(M)?"mixed":M?"area":"line",et=o(()=>{if(!N||!Ce)return[];const e="function"==typeof y?y:e=>e[y],t="function"==typeof g?g:e=>e[g],n="function"==typeof Ce?Ce:e=>e[Ce],o=new Map;for(const e of Te){const t=e[v]||[];if(0===t.length)continue;const r="end"===$e?t[t.length-1]:t[0],i=n(r)??n(e);if(null==i)continue;const a=i+"";""===a||o.has(a)||o.set(a,r)}const r=Array.from(o.entries()).map(([n,o])=>({type:"text",label:n,["string"==typeof y?y:"x"]:e(o),["string"==typeof g?g:"y"]:t(o),dx:"end"===$e?6:-6,dy:0,color:Fe?Fe(n):$d,fontSize:Be}));r.sort((e,t)=>{const n="string"==typeof g?g:"y";return e[n]-t[n]});for(let e=1;r.length>e;e++){const t="string"==typeof g?g:"y",n=r[e-1],o=r[e];Be+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Be+2)}return r},[N,Ce,Fe,Te,v,y,g,$e,Be]),tt=Ee.margin,nt=b||x,ot=o(()=>Dl([{label:me||Tl(y),accessor:y,role:"x",format:p},{label:fe||Tl(g),accessor:g,role:"y",format:m},...nt?[{label:Tl(nt),accessor:nt,role:"group"}]:[],...Bl(j,m)]),[y,g,me,fe,nt,p,m,j]),rt=ph({componentName:"LineChart",data:Ie?be[0]?.[v]||[]:l,accessors:{xAccessor:y,yAccessor:g}}),it=o(()=>Ie||Re||Le?Te.flatMap(e=>{const t=e[v]||[];return Re&&"string"==typeof Re?t.map(t=>({...t,[Re]:t[Re]??e[Re]})):t}):Ae,[Te,v,Ie,Re,Ae,Le]),at={chartType:Je,...Array.isArray(M)&&{areaGroups:M},...R&&{lineGradient:R},...null!=l&&{data:it},xAccessor:y,yAccessor:g,xScaleType:J,yScaleType:ee,...E&&{xExtent:E},...!F||null==F[0]&&null==F[1]?Me?{yExtent:Me}:{}:{yExtent:F},groupAccessor:"break"===$&&Le?"_gapSegment":Re||void 0,...j&&{band:j},curve:S,lineStyle:Qe,...A&&{pointStyle:Ze},size:[ie,ae],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:tt,showAxes:s.showAxes,xLabel:me,yLabel:fe,xFormat:p,yFormat:m,...void 0!==f&&{axisExtent:f},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},enableHover:se,showGrid:ce,...Ee.legendBehaviorProps,...ue&&{title:ue},...de&&{description:de},...he&&{summary:he},...void 0!==pe&&{accessibleTable:pe},...h&&{className:h},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===_?()=>null:"multi"===_?ac():sc(_)||ot,..."multi"===_&&{tooltipMode:"multi"},...Bh({linkedHover:H,selection:z,onObservation:W,onClick:G,hoverRadius:Y,hoverHighlight:q,mobileInteraction:Ee.mobileInteraction,customHoverBehavior:We,customClickBehavior:Ge}),...T&&{pointIdAccessor:T},...(L?.length||ve.length||et.length)&&{annotations:[...L||[],...ve,...et]},...qe,...O};return Ee.earlyReturn?Ee.earlyReturn:rt?Vh(Qd,{componentName:"LineChart",message:rt,width:ie,height:ae}):Vh(oh,{componentName:"LineChart",width:ie,height:ae,children:Vh(hu,{ref:n,...at})})});Uh.displayName="LineChart";import{useMemo as Kh,forwardRef as Qh,useRef as Zh}from"react";import{useMemo as Jh}from"react";function ep(e){const{safeData:t,data:n,areaBy:o,lineDataAccessor:r,colorBy:i,colorScale:a,color:s,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,areaOpacity:p,showLine:m,lineWidth:f,showPoints:y,pointRadius:g,xAccessor:b,yAccessor:v,xLabel:x,yLabel:w,xFormat:k,yFormat:S,groupField:A,styleRules:C,ruleContext:M}=e,P=void 0!==t[0]?.[r],I=Jh(()=>{if(null==n)return[];if(!P&&!o)return t;let e;if(P)e=t;else{const n=o,i=t.reduce((e,t)=>{const o="function"==typeof n?n(t):t[n];if(!e[o]){const t={[r]:[]};"string"==typeof n&&(t[n]=o),e[o]=t}return e[o][r].push(t),e},{});e=Object.values(i)}return e.flatMap(e=>{const t=e[r]||[];return o&&"string"==typeof o?t.map(t=>({...t,[o]:e[o]})):t})},[n,t,o,r,P]),R=Jh(()=>e=>{const t={};if(i){if(a){const n=He(e,i,a);t.fill=n,m?(t.stroke=n,t.strokeWidth=f):t.stroke="none"}}else{const e=s||$d;t.fill=e,m?(t.stroke=e,t.strokeWidth=f):t.stroke="none"}return t.fillOpacity=p,C&&C.length>0&&Object.assign(t,Rh(e,C,M?M(e):{value:void 0})),t},[i,a,s,p,m,f,C,M]),_=Jh(()=>Sh(R,{stroke:c,strokeWidth:l,opacity:u}),[R,c,l,u]);return{flattenedData:I,lineStyle:Jh(()=>fd(_,d??null,h),[_,d,h]),pointStyle:Jh(()=>{if(y)return e=>{const t={r:g,fillOpacity:1};return i?a&&(t.fill=He(e.parentLine||e,i,a)):t.fill=s||$d,t}},[y,g,i,a,s]),defaultTooltipContent:Jh(()=>Dl([{label:x||Tl(b),accessor:b,role:"x",format:k},{label:w||Tl(v),accessor:v,role:"y",format:S},...A?[{label:Tl(A),accessor:A,role:"group"}]:[],...Bl(e.band,S)]),[b,v,x,w,A,k,S,e.band])}}import{jsx as tp}from"react/jsx-runtime";function np(e,t){if(null==t)return e;const n=e.trim(),o=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const e=o[1],n=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${t})`}if(n.startsWith("rgba(")){const e=n.lastIndexOf(","),o=n.lastIndexOf(")");if(-1!==e&&o>e)return`${n.slice(0,e+1)} ${t})`}return n.startsWith("rgb(")?n.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}var op=Qh(function(e,t){const n=Zh(null);Nh(t,{variant:"xy",frameRef:n});const o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",yAccessor:d="y",areaBy:h,y0Accessor:p,gradientFill:m=!1,semanticGradient:f,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:b,styleRules:v,curve:x="monotoneX",areaOpacity:w=.7,lineGradient:k,showLine:S=!0,lineWidth:A=2,showPoints:C=!1,pointRadius:M=3,tooltip:P,annotations:I,forecast:R,anomaly:_,band:T,xExtent:L,yExtent:N,frameProps:$={},selection:B,linkedHover:D,onObservation:j,onClick:E,hoverHighlight:F,chartId:O,loading:z,loadingContent:H,emptyContent:W,legendInteraction:G,legendPosition:q,color:Y,stroke:V,strokeWidth:X,opacity:U}=e,{width:K,height:Q,enableHover:Z,showGrid:J,showLegend:ee,title:te,description:ne,summary:oe,accessibleTable:re,xLabel:ie,yLabel:ae}=o,se=Kh(()=>u(r),[r]),ce=g||h,le=Kh(()=>{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:np(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset))}:m;var e},[f,m]);ch("AreaChart",se,"xAccessor",l),ch("AreaChart",se,"yAccessor",d);const ue=wh({data:se,rawData:r,colorBy:ce,colorScheme:b,legendInteraction:G,legendPosition:q,selection:B,linkedHover:D,fallbackFields:ce?["string"==typeof ce?ce:""]:[],unwrapData:!1,onObservation:j,onClick:E,hoverHighlight:F,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"AreaChart",chartId:O,showLegend:ee,userMargin:i,marginDefaults:o.marginDefaults,loading:z,loadingContent:H,emptyContent:W,width:K,height:Q}),{effectiveData:de,statisticalAnnotations:he}=Yh({data:se,xAccessor:l,yAccessor:d,forecast:R,anomaly:_,groupBy:h}),pe=Kh(()=>Ch(l,d),[l,d]),{flattenedData:me,lineStyle:fe,pointStyle:ye,defaultTooltipContent:ge}=ep({safeData:de,data:r,areaBy:h,lineDataAccessor:y,colorBy:ce,colorScale:ue.colorScale,color:Y,stroke:V,strokeWidth:X,opacity:U,effectiveSelectionHook:ue.effectiveSelectionHook,resolvedSelection:ue.resolvedSelection,areaOpacity:w,showLine:S,lineWidth:A,showPoints:C,pointRadius:M,xAccessor:l,yAccessor:d,xLabel:ie,yLabel:ae,xFormat:s,yFormat:c,groupField:h||g,band:T,styleRules:v,ruleContext:pe}),be=ph({componentName:"AreaChart",data:r,accessors:{xAccessor:l,yAccessor:d}}),ve={chartType:"area",...null!=r&&{data:me},xAccessor:l,yAccessor:d,groupAccessor:h||void 0,...p&&{y0Accessor:p},...T&&{band:T},...le&&{gradientFill:le},...k&&{lineGradient:k},curve:x,lineStyle:fe,...C&&ye&&{pointStyle:ye},size:[K,Q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ue.margin,showAxes:o.showAxes,xLabel:ie,yLabel:ae,xFormat:s,yFormat:c,enableHover:Z,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:J,...ue.legendBehaviorProps,...$h({title:te,description:ne,summary:oe,accessibleTable:re,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===P?{tooltipContent:ac(),tooltipMode:"multi"}:Dh({tooltip:P,defaultTooltipContent:ge}),...Bh({linkedHover:D,selection:B,onObservation:j,onClick:E,hoverHighlight:F,mobileInteraction:ue.mobileInteraction,customHoverBehavior:ue.customHoverBehavior,customClickBehavior:ue.customClickBehavior}),...(I&&I.length>0||he.length>0)&&{annotations:[...I||[],...he]},...L&&{xExtent:L},...N&&{yExtent:N},...ue.crosshairProps,...$};return ue.earlyReturn?ue.earlyReturn:be?tp(Qd,{componentName:"AreaChart",message:be,width:K,height:Q}):tp(oh,{componentName:"AreaChart",width:K,height:Q,children:tp(hu,{ref:n,...ve})})});op.displayName="AreaChart";import{useMemo as rp,forwardRef as ip,useRef as ap,useState as sp,useImperativeHandle as cp,useCallback as lp}from"react";import{jsx as up,jsxs as dp}from"react/jsx-runtime";function hp(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 pp=ip(function(e,t){const n=ap(null),o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",seriesAAccessor:d="a",seriesBAccessor:h="b",seriesALabel:p="A",seriesBLabel:m="B",seriesAColor:f="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:g=!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:R,linkedHover:_,onObservation:T,onClick:L,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:j,legendInteraction:E,legendPosition:F,pointIdAccessor:O,windowSize:z}=e,{width:H,height:W,enableHover:G,showGrid:q,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,xLabel:Q,yLabel:Z}=o,J=rp(()=>"function"==typeof l?e=>hp(l(e)):e=>hp(e[l]),[l]),ee=rp(()=>"function"==typeof d?e=>hp(d(e)):e=>hp(e[d]),[d]),te=rp(()=>"function"==typeof h?e=>hp(h(e)):e=>hp(e[h]),[h]),[ne,oe]=sp([]),re=ap([]),ie=null==r,ae=rp(()=>u(ie?ne:r),[ie,ne,r]),se=rp(()=>function(e,t,n,o){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),i=[];let a=0,s=null,c=null,l=[];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;r.length>e;e++){const i=r[e],m=t(i),f=n(i),y=o(i);if(!Number.isFinite(m)||!Number.isFinite(f)||!Number.isFinite(y))continue;const g=u(f,y);if(null!==g)if(null!=s){if(c&&c.w!==g){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const n=f-c.a-(y-c.b);if(0!==n){const o=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+o*(m-c.x),t=c.a+o*(f-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=g,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;l.length>e;e++)p(l[e],s)}else for(const e of l)p(e,s);l=[],h({__x:m,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(s),__diffWinner:s,__valA:f,__valB:y,__sourceDatum:i}),c={x:m,a:f,b:y,w:g}}else{s=g;for(const e of l)p(e,s);l=[],h({__x:m,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(s),__diffWinner:s,__valA:f,__valB:y,__sourceDatum:i}),c={x:m,a:f,b:y,w:g}}else l.push({x:m,y:f,datum:i})}for(const e of l)p(e,s??"A");return i}(ae,J,ee,te),[ae,J,ee,te]),ce=rp(()=>g?function(e,t,n,o){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),i=[];for(const e of r){const r=t(e),a=n(e),s=o(e);Number.isFinite(a)&&i.push({__x:r,__y:a,__diffSegment:"line-A"}),Number.isFinite(s)&&i.push({__x:r,__y:s,__diffSegment:"line-B"})}return i}(ae,J,ee,te):[],[g,ae,J,ee,te]),le=rp(()=>[...se,...ce],[se,ce]),ue=rp(()=>{const e=new Set;for(const t of se)e.add(t.__diffSegment);return Array.from(e)},[se]);cp(t,()=>{const e=e=>{const t=z&&e.length>z?e.slice(e.length-z):e;re.current=t,oe(t)},t=O?"function"==typeof O?O:e=>e[O]:null;return{push:t=>e([...re.current,t]),pushMany:t=>e([...re.current,...t]),remove:n=>{if(!t)return[];const o=Array.isArray(n)?n:[n],r=[],i=[];for(const e of re.current)o.includes(t(e))?r.push(e):i.push(e);return e(i),r},update:(n,o)=>{if(!t)return[];const r=Array.isArray(n)?n:[n],i=[],a=re.current.map(e=>{if(r.includes(t(e))){const t=o(e);return i.push(t),t}return e});return e(a),i},clear:()=>e([]),getData:()=>ie?re.current:ae,getScales:()=>n.current?.getScales()??null}},[ie,ae,O,z]);const de=wh({data:ae,rawData:r,colorBy:"__diffWinner",colorScheme:[f,y],legendInteraction:E,legendPosition:F,selection:R,linkedHover:_,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:T,onClick:L,hoverHighlight:N,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DifferenceChart",chartId:$,showLegend:Y,userMargin:i,marginDefaults:o.marginDefaults,loading:B,loadingContent:D,emptyContent:j,width:H,height:W}),he=rp(()=>{if(!1!==Y)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:p,color:f},{label:m,color:y}]}]}},[Y,p,m,f,y]),pe=lp(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?f:y,stroke:"none",fillOpacity:k}},[f,y,k]),me=lp(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?f:y,strokeWidth:b,fill:"none"}),[f,y,b]),fe=lp(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?f:y,r:x}),[f,y,x]),ye=lp(e=>{const t=e.data,n=e.allSeries,o=e.xValue??t?.__x;let r=t?.__valA,i=t?.__valB;if(n&&n.length>0){const e=n.find(e=>"line-A"===e.group),t=n.find(e=>"line-B"===e.group);null!=e?.value&&Number.isFinite(e.value)&&(r=e.value),null!=t?.value&&Number.isFinite(t.value)&&(i=t.value)}if(null!=o&&(null==r||null==i)){const e=ae.find(e=>J(e)===o);e&&(null==r&&(r=ee(e)),null==i&&(i=te(e)))}const a=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",c=s&&null!=o?s(o):null!=o?o+"":"";return dp("div",{className:"semiotic-tooltip",style:tc,children:[c&&up("div",{style:{fontWeight:600,marginBottom:4},children:c}),dp("div",{style:{display:"flex",alignItems:"center",gap:6},children:[up("span",{style:{width:10,height:10,background:f,display:"inline-block",borderRadius:2}}),dp("span",{children:[p,": ",a(r)]})]}),dp("div",{style:{display:"flex",alignItems:"center",gap:6},children:[up("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),dp("span",{children:[m,": ",a(i)]})]}),null!=r&&null!=i&&Number.isFinite(r)&&Number.isFinite(i)&&dp("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",a(r-i)]})]})},[ae,J,ee,te,s,f,y,p,m]),ge="multi"===A,be=rp(()=>!1===A?()=>null:ge?ye:sc(A)||ye,[A,ge,ye]);if(de.earlyReturn)return de.earlyReturn;const ve={chartType:"mixed",data:le,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:o.showAxes,xLabel:Q,yLabel:Z,xFormat:s,yFormat:c,enableHover:G,showGrid:q,...S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S},...he&&{legend:he,legendPosition:de.legendPosition},...$h({title:V,description:X,summary:U,accessibleTable:K,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:be,...ge&&{tooltipMode:"multi"},...Bh({linkedHover:_,selection:R,onObservation:T,onClick:L,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 up(oh,{componentName:"DifferenceChart",width:H,height:W,children:up(hu,{ref:n,...ve})})});"function"==typeof pp&&(pp.displayName="DifferenceChart");import{useMemo as mp,forwardRef as fp,useRef as yp}from"react";import{jsx as gp}from"react/jsx-runtime";var bp=fp(function(e,t){const n=yp(null),o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",yAccessor:d="y",areaBy:h,lineDataAccessor:p="coordinates",colorBy:m,colorScheme:f,styleRules:y,curve:g="monotoneX",areaOpacity:b=.7,showLine:v=!0,lineWidth:x=2,showPoints:w=!1,pointRadius:k=3,normalize:S=!1,baseline:A="zero",stackOrder:C,tooltip:M,annotations:P,xExtent:I,yExtent:R,frameProps:_={},selection:T,linkedHover:L,onObservation:N,onClick:$,hoverHighlight:B,chartId:D,loading:j,loadingContent:E,emptyContent:F,legendInteraction:O,legendPosition:z,color:H,stroke:W,strokeWidth:G,opacity:q}=e,{width:Y,height:V,enableHover:X,showGrid:U,showLegend:K,title:Q,description:Z,summary:J,accessibleTable:ee,xLabel:te,yLabel:ne}=o,oe=mp(()=>u(r),[r]),re=m||h;Nh(t,{variant:"xy",frameRef:n});const ie=wh({data:oe,rawData:r,colorBy:re,colorScheme:f,legendInteraction:O,legendPosition:z,selection:T,linkedHover:L,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:N,onClick:$,hoverHighlight:B,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"StackedAreaChart",chartId:D,showLegend:K,userMargin:i,marginDefaults:o.marginDefaults,loading:j,loadingContent:E,emptyContent:F,width:Y,height:V}),ae=mp(()=>Ch(l,d),[l,d]),{flattenedData:se,lineStyle:ce,pointStyle:le,defaultTooltipContent:ue}=ep({safeData:oe,data:r,areaBy:h,lineDataAccessor:p,colorBy:re,colorScale:ie.colorScale,color:H,stroke:W,strokeWidth:G,opacity:q,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection,areaOpacity:b,showLine:v,lineWidth:x,showPoints:w,pointRadius:k,xAccessor:l,yAccessor:d,xLabel:te,yLabel:ne,xFormat:s,yFormat:c,groupField:h||m,styleRules:y,ruleContext:ae}),de=ph({componentName:"StackedAreaChart",data:r,accessors:{xAccessor:l,yAccessor:d}}),he={chartType:"stackedarea",...null!=r&&{data:se},xAccessor:l,yAccessor:d,groupAccessor:h||void 0,curve:g,normalize:S,baseline:S?"zero":A,stackOrder:C,lineStyle:ce,...w&&le&&{pointStyle:le},size:[Y,V],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ie.margin,showAxes:o.showAxes,xLabel:te,yLabel:ne,xFormat:s,yFormat:c,enableHover:X,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:U,...ie.legendBehaviorProps,...$h({title:Q,description:Z,summary:J,accessibleTable:ee,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===M?{tooltipContent:ac(),tooltipMode:"multi"}:Dh({tooltip:M,defaultTooltipContent:ue}),...Bh({linkedHover:L,selection:T,onObservation:N,onClick:$,hoverHighlight:B,mobileInteraction:ie.mobileInteraction,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior}),...P&&P.length>0&&{annotations:P},...I&&{xExtent:I},...R&&{yExtent:R},...ie.crosshairProps,..._};return ie.earlyReturn?ie.earlyReturn:de?gp(Qd,{componentName:"StackedAreaChart",message:de,width:Y,height:V}):gp(oh,{componentName:"StackedAreaChart",width:Y,height:V,children:gp(hu,{ref:n,...he})})});bp.displayName="StackedAreaChart";import*as vp from"react";import{useMemo as xp,useCallback as wp,forwardRef as kp,useRef as Sp}from"react";import{useMemo as Ap}from"react";function Cp(e){const{colorBy:t,colorScale:n,color:o,pointRadius:r=5,radiusFn:i,fillOpacity:a=1,fallbackFill:s,baseStyleExtras:c,stroke:l,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:p,colorDatumAccessor:m,styleRules:f,ruleContext:y}=e,g=Ap(()=>e=>{const l="function"==typeof c?c(e):c,u=l?{...l}:{};if(void 0===u.fillOpacity&&(u.fillOpacity=a),void 0===u.fill)if(t){if(n){const o=m?m(e):e;u.fill=He(o,t,n)}}else u.fill=s?s(e):o||$d;return void 0===u.r&&(u.r=i?i(e):r),f&&f.length>0&&Object.assign(u,Rh(e,f,y?y(e):{value:void 0})),u},[t,n,o,r,i,a,s,c,m,f,y]),b=Ap(()=>Sh(g,{stroke:l,strokeWidth:u,opacity:d}),[g,l,u,d]);return Ap(()=>fd(b,h??null,p),[b,h,p])}import{useCallback as Mp,useMemo as Pp,useRef as Ip,useState as Rp}from"react";function _p(e){const{accessor:t,data:n,isPushMode:o}=e,r=Ip(null),[i,a]=Rp(0),s=Mp(e=>{if(!o||!t)return;let n=!1;for(const o of e){const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i="number"==typeof e?e:Number(e);Number.isFinite(i)&&(r.current?(r.current[0]>i&&(r.current[0]=i,n=!0),i>r.current[1]&&(r.current[1]=i,n=!0)):(r.current=[i,i],n=!0))}n&&a(e=>e+1)},[o,t]),c=Mp(()=>{o&&(r.current=null,a(e=>e+1))},[o]);return{domain:Pp(()=>{if(o)return r.current??void 0;if(!t||0===n.length)return;const e="function"==typeof t?t:e=>e[t];let i=1/0,a=-1/0;for(const t of n){const n=e(t);if(null==n)continue;const o="number"==typeof n?n:Number(n);Number.isFinite(o)&&(i>o&&(i=o),o>a&&(a=o))}return Number.isFinite(i)&&Number.isFinite(a)?[i,a]:void 0},[n,t,o,i]),trackPushed:s,reset:c}}function Tp(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 Lp}from"react/jsx-runtime";var Np=kp(function(e,t){const n=Sp(null),o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",yAccessor:d="y",xScaleType:h,yScaleType:p,colorBy:m,colorScheme:f,styleRules:y,sizeBy:g,sizeRange:b=[3,15],symbolBy:v,symbolMap:x,pointRadius:w=5,pointOpacity:k=.8,tooltip:S,marginalGraphics:A,pointIdAccessor:C,annotations:M,regression:P,forecast:I,anomaly:R,xExtent:_,yExtent:T,frameProps:L={},selection:N,linkedHover:$,linkedBrush:B,onObservation:D,onClick:j,hoverHighlight:E,chartId:F,loading:O,loadingContent:z,emptyContent:H,legendInteraction:W,legendPosition:G,color:q,stroke:Y,strokeWidth:V,opacity:X}=e,{width:U,height:K,enableHover:Q,showGrid:Z,showLegend:J,title:ee,description:te,summary:ne,accessibleTable:oe,xLabel:re,yLabel:ie}=o,ae=xp(()=>u(r),[r]),se=void 0===r,{domain:ce,trackPushed:le,reset:ue}=_p({accessor:g,data:ae,isPushMode:se}),de=wp(e=>{le([e]),n.current?.push(e)},[le]),he=wp(e=>{le(e),n.current?.pushMany(e)},[le]);Nh(t,{variant:"xy",frameRef:n,overrides:{push:de,pushMany:he,clear:()=>{ue(),n.current?.clear()}}});const pe=wh({data:ae,rawData:r,colorBy:m,colorScheme:f,legendInteraction:W,legendPosition:G,selection:N,linkedHover:$,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!1,onObservation:D,onClick:j,hoverHighlight:E,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"Scatterplot",chartId:F,showLegend:J,userMargin:i,marginDefaults:o.marginDefaults,loading:O,loadingContent:z,emptyContent:H,width:U,height:K}),me=md(B),fe=Xu({name:me?.name||"__unused_brush__",xField:me?.xField||("string"==typeof l?l:void 0),yField:me?.yField||("string"==typeof d?d:void 0)}),ye=me?"xyBrush"===fe.brushInteraction.brush?"xy":"xBrush"===fe.brushInteraction.brush?"x":"y":void 0,ge=vp.useRef(fe.brushInteraction);ge.current=fe.brushInteraction;const be=wp(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)},[]);ch("Scatterplot",ae,"xAccessor",l),ch("Scatterplot",ae,"yAccessor",d);const ve=xp(()=>g?ce??[0,1]:void 0,[g,ce]),xe=xp(()=>g?e=>qe(e,g,b,ve):void 0,[g,b,ve]),we=xp(()=>Ch(l,d),[l,d]),ke=Cp({colorBy:m,colorScale:pe.colorScale,color:q,pointRadius:w,fillOpacity:k,radiusFn:xe,stroke:Y,strokeWidth:V,opacity:X,styleRules:y,ruleContext:we,effectiveSelectionHook:pe.effectiveSelectionHook,resolvedSelection:pe.resolvedSelection}),Se=xp(()=>Dl([{label:re||Tl(l),accessor:l,role:"x",format:s},{label:ie||Tl(d),accessor:d,role:"y",format:c},...m?[{label:Tl(m),accessor:m,role:"color"}]:[],...g?[{label:Tl(g),accessor:g,role:"size"}]:[]]),[l,d,re,ie,m,g,s,c]),{effectiveData:Ae,statisticalAnnotations:Ce}=Yh({data:ae,xAccessor:l,yAccessor:d,forecast:I,anomaly:R}),Me=xp(()=>{const e=Tp(P);return e||0!==Ce.length?[...e?[e]:[],...M||[],...Ce]:M},[P,M,Ce]);if(pe.earlyReturn)return pe.earlyReturn;const Pe=ph({componentName:"Scatterplot",data:r,accessors:{xAccessor:l,yAccessor:d}});if(Pe)return Lp(Qd,{componentName:"Scatterplot",message:Pe,width:U,height:K});const Ie={chartType:"scatter",...null!=r&&{data:Ae},xAccessor:l,yAccessor:d,xScaleType:h,yScaleType:p,colorAccessor:m||void 0,sizeAccessor:g||void 0,...v&&{symbolAccessor:v},...x&&{symbolMap:x},sizeRange:b,pointStyle:ke,colorScheme:f,size:[U,K],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:pe.margin,showAxes:o.showAxes,xLabel:re,yLabel:ie,xFormat:s,yFormat:c,enableHover:Q,showGrid:Z,...pe.legendBehaviorProps,...$h({title:ee,description:te,summary:ne,accessibleTable:oe,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:S,defaultTooltipContent:Se}),...Bh({linkedHover:$,selection:N,onObservation:D,onClick:j,hoverHighlight:E,mobileInteraction:pe.mobileInteraction,customHoverBehavior:pe.customHoverBehavior,customClickBehavior:pe.customClickBehavior}),...A&&{marginalGraphics:A},...C&&{pointIdAccessor:C},...Me&&Me.length>0&&{annotations:Me},..._&&{xExtent:_},...T&&{yExtent:T},...me&&{brush:{dimension:ye},onBrush:be},...pe.crosshairProps,...L};return Lp(oh,{componentName:"Scatterplot",width:U,height:K,children:Lp(hu,{ref:n,...Ie})})});Np.displayName="Scatterplot";import{useMemo as $p,forwardRef as Bp,useRef as Dp}from"react";import{Fragment as jp,jsx as Ep}from"react/jsx-runtime";function Fp(e,t){return ke(1===t?.5:e/(t-1))}var Op=Bp(function(e,t){const n=Dp(null);Nh(t,{variant:"xy",frameRef:n});const o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,styleRules:p,pointRadius:m=4,tooltip:f,pointIdAccessor:y,annotations:g,regression:b,forecast:v,anomaly:x,xExtent:w,yExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:P,hoverHighlight:I,chartId:R,loading:_,loadingContent:T,emptyContent:L,legendInteraction:N,stroke:$,strokeWidth:B,opacity:D}=e,{width:j,height:E,enableHover:F,showGrid:O,title:z,description:H,summary:W,accessibleTable:G,xLabel:q,yLabel:Y}=o,{safeData:V,orderMap:X}=$p(()=>{const e=r||[],t="function"==typeof l?l:e=>e[l],n="function"==typeof u?u:e=>e[u];let o=e;if(d&&e.length>0){const t="function"==typeof d?d:e=>e[d];o=[...e].sort((e,n)=>{const o=t(e),r=t(n);return(o instanceof Date?o.getTime():+o)-(r instanceof Date?r.getTime():+r)})}const i=new WeakMap;let a=0;for(const e of o){const o=t(e),r=n(e);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&a++}let s=0;for(const e of o){const o=t(e),r=n(e);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&i.set(e,{idx:s++,total:a})}return{safeData:o,orderMap:i}},[r,d,l,u]);ch("ConnectedScatterplot",V,"xAccessor",l),ch("ConnectedScatterplot",V,"yAccessor",u);const U=wh({data:V,rawData:r,colorBy:void 0,colorScheme:void 0,legendInteraction:N,selection:A,linkedHover:C,fallbackFields:[],unwrapData:!1,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ConnectedScatterplot",chartId:R,showLegend:void 0,userMargin:i,marginDefaults:{top:50,right:40,bottom:60,left:70},loading:_,loadingContent:T,emptyContent:L,width:j,height:E}),K=U.resolvedSelection?.unselectedOpacity??.5,Q=$p(()=>(e,t)=>{const n=t.filter(e=>"point"===e.type);if(2>n.length)return;const o=U.effectiveSelectionHook?.isActive,r=U.effectiveSelectionHook?.predicate,i=100>n.length,a=n.length;e.lineCap="round";for(let t=0;a-1>t;t++){const s=n[t],c=n[t+1],l=Fp(t,a),u=!o||!r||r(s.datum??s)||r(c.datum??c),d=o?u?1:K:1;i&&(e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(c.x,c.y),e.strokeStyle="white",e.lineWidth=m+2,e.globalAlpha=.5*d,e.stroke()),e.beginPath(),e.moveTo(s.x,s.y),e.lineTo(c.x,c.y),e.strokeStyle=l,e.lineWidth=m,e.globalAlpha=d,e.stroke()}e.globalAlpha=1},[m,U.effectiveSelectionHook,K]),Z=$p(()=>[Q],[Q]),J=$p(()=>(e,t,n)=>{const o=e.filter(e=>"point"===e.type);if(2>o.length)return null;const r=o.length,i=100>r,a=[];for(let e=0;r-1>e;e++){const t=o[e],n=o[e+1],s=Fp(e,r),c=Math.min("number"==typeof t.style?.opacity?t.style.opacity:1,"number"==typeof n.style?.opacity?n.style.opacity:1);i&&a.push(Ep("line",{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:m+2,strokeLinecap:"round",opacity:.5*c},"halo-"+e)),a.push(Ep("line",{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:s,strokeWidth:m,strokeLinecap:"round",opacity:c},"seg-"+e))}return Ep(jp,{children:a})},[m]),ee=$p(()=>[J],[J]),te=Cp({colorScale:void 0,baseStyleExtras:$p(()=>e=>{const t=X.get(e),n=t?.idx??0,o=t?.total??1;return{fill:o>0?Fp(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,X]),stroke:$,strokeWidth:B,opacity:D,styleRules:p,ruleContext:$p(()=>Ch(l,u),[l,u]),effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection}),ne=h||("string"==typeof d?d:"Order"),oe=$p(()=>Dl([{label:q||Tl(l),accessor:l,role:"x",format:s},{label:Y||Tl(u),accessor:u,role:"y",format:c},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[l,u,q,Y,d,ne,s,c]),re=ph({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:l,yAccessor:u}}),{effectiveData:ie,statisticalAnnotations:ae}=Yh({data:V,xAccessor:l,yAccessor:u,forecast:v,anomaly:x});if(U.earlyReturn)return U.earlyReturn;const se=Tp(b),ce=se||ae.length>0?[...se?[se]:[],...g||[],...ae]:g,le={chartType:"scatter",...null!=r&&{data:ie},xAccessor:l,yAccessor:u,pointStyle:te,size:[j,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,showAxes:o.showAxes,xLabel:q,yLabel:Y,xFormat:s,yFormat:c,enableHover:F,showGrid:O,...$h({title:z,description:H,summary:W,accessibleTable:G,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:f,defaultTooltipContent:oe}),...Bh({linkedHover:C,selection:A,onObservation:M,onClick:P,hoverHighlight:I,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...y&&{pointIdAccessor:y},canvasPreRenderers:Z,svgPreRenderers:ee,...ce&&ce.length>0&&{annotations:ce},...w&&{xExtent:w},...k&&{yExtent:k},...U.crosshairProps,...S};return re?Ep(Qd,{componentName:"ConnectedScatterplot",message:re,width:j,height:E}):Ep(oh,{componentName:"ConnectedScatterplot",width:j,height:E,children:Ep(hu,{ref:n,...le})})});Op.displayName="ConnectedScatterplot";import{useMemo as zp,useCallback as Hp,forwardRef as Wp,useRef as Gp}from"react";import{jsx as qp}from"react/jsx-runtime";var Yp=Wp(function(e,t){const n=Gp(null),o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",yAccessor:d="y",sizeBy:h,sizeRange:p=[5,40],colorBy:m,colorScheme:f,styleRules:y,bubbleOpacity:g=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:v="white",tooltip:x,marginalGraphics:w,pointIdAccessor:k,annotations:S,regression:A,xExtent:C,yExtent:M,frameProps:P={},selection:I,linkedHover:R,linkedBrush:_,onObservation:T,onClick:L,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:j,legendInteraction:E,legendPosition:F,color:O,stroke:z,strokeWidth:H,opacity:W}=e,{width:G,height:q,enableHover:Y,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=o,te=zp(()=>u(r),[r]),ne=void 0===r,oe=wh({data:te,rawData:r,colorBy:m,colorScheme:f,legendInteraction:E,legendPosition:F,selection:I,linkedHover:R,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!1,onObservation:T,onClick:L,hoverHighlight:N,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"BubbleChart",chartId:$,showLegend:X,userMargin:i,marginDefaults:o.marginDefaults,loading:B,loadingContent:D,emptyContent:j,width:G,height:q}),{domain:re,trackPushed:ie,reset:ae}=_p({accessor:h,data:te,isPushMode:ne}),se=Hp(e=>{ie([e]),n.current?.push(e)},[ie]),ce=Hp(e=>{ie(e),n.current?.pushMany(e)},[ie]);Nh(t,{variant:"xy",frameRef:n,overrides:{push:se,pushMany:ce,clear:()=>{ae(),n.current?.clear()}}});const le=md(_),ue=(Xu({name:le?.name||"__unused_brush__",xField:le?.xField||("string"==typeof l?l:void 0),yField:le?.yField||("string"==typeof d?d:void 0)}),zp(()=>({stroke:v,strokeWidth:b}),[v,b])),de=zp(()=>re??[0,1],[re]),he=Hp(e=>qe(e,h,p,de),[h,p,de]),pe=zp(()=>Ch(l,d),[l,d]),me=Cp({colorBy:m,colorScale:oe.colorScale,color:O,fillOpacity:g,radiusFn:he,baseStyleExtras:ue,stroke:z,strokeWidth:H,opacity:W,styleRules:y,ruleContext:pe,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection}),fe=zp(()=>Dl([{label:J||Tl(l),accessor:l,role:"x",format:s},{label:ee||Tl(d),accessor:d,role:"y",format:c},{label:Tl(h),accessor:h,role:"size"},...m?[{label:Tl(m),accessor:m,role:"color"}]:[]]),[l,d,J,ee,h,m,s,c]);if(oe.earlyReturn)return oe.earlyReturn;const ye=ph({componentName:"BubbleChart",data:r,accessors:{xAccessor:l,yAccessor:d},requiredProps:{sizeBy:h}});if(ye)return qp(Qd,{componentName:"BubbleChart",message:ye,width:G,height:q});const ge=Tp(A),be=ge?[ge,...S||[]]:S,ve={chartType:"bubble",...null!=r&&{data:te},xAccessor:l,yAccessor:d,colorAccessor:m||void 0,sizeAccessor:h,sizeRange:p,pointStyle:me,colorScheme:f,size:[G,q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe.margin,showAxes:o.showAxes,xLabel:J,yLabel:ee,xFormat:s,yFormat:c,enableHover:Y,showGrid:V,...oe.legendBehaviorProps,...$h({title:U,description:K,summary:Q,accessibleTable:Z,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:x,defaultTooltipContent:fe}),...Bh({linkedHover:R,selection:I,onObservation:T,onClick:L,hoverHighlight:N,mobileInteraction:oe.mobileInteraction,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior}),...w&&{marginalGraphics:w},...k&&{pointIdAccessor:k},...be&&be.length>0&&{annotations:be},...C&&{xExtent:C},...M&&{yExtent:M},...oe.crosshairProps,...P};return qp(oh,{componentName:"BubbleChart",width:G,height:q,children:qp(hu,{ref:n,...ve})})});Yp.displayName="BubbleChart";import{useMemo as Vp,forwardRef as Xp,useRef as Up}from"react";import{scaleSequential as Kp}from"d3-scale";import{jsx as Qp}from"react/jsx-runtime";var Zp=Xp(function(e,t){const o=Up(null);Nh(t,{variant:"xy",frameRef:o});const r=Vd(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:c="x",yAccessor:l="y",valueAccessor:d="value",xFormat:h,yFormat:p,colorScheme:m,customColorScale:f,showValues:y=!1,valueFormat:g,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:R,chartId:_,loading:T,loadingContent:L,emptyContent:N,showLegend:$,legendPosition:B,legendInteraction:D}=e,{width:j,height:E,enableHover:F,title:O,description:z,summary:H,accessibleTable:W,xLabel:G,yLabel:q}=r,Y=sh(T,j,E,L),V=Y?null:ah(i,j,E,N),X=Vp(()=>u(i),[i]),U=function(){const e=Pd();return e?.colors?.sequential||void 0}(),K=m??U??"blues",Q=$??!1,Z=B??"right",{margin:J}=Gd({data:X,colorBy:Q?"value":void 0,colorScale:void 0,showLegend:Q,legendPosition:Z,userMargin:a,defaults:r.marginDefaults}),{customHoverBehavior:ee,customClickBehavior:te,crosshairSourceId:ne}=Hd({selection:C,linkedHover:M,fallbackFields:[],onObservation:P,onClick:I,chartType:"Heatmap",chartId:_,hoverHighlight:R,colorByField:void 0,mobileInteraction:r.mobileInteraction});xh(C);const oe=Wd(M,ne);qd(D,void 0,[]);const re=Vp(()=>"function"==typeof d?e=>d(e):e=>e[d],[d]),ie=Vp(()=>{const e=X.map(re);return n(e)},[X,re]),ae=Vp(()=>{if("custom"===K&&f)return f;const e=Re(K);return Kp(e).domain(ie)},[K,f,ie]),se=Vp(()=>Dl([{label:G||Tl(c),accessor:c,role:"x",format:h},{label:q||Tl(l),accessor:l,role:"y",format:p},{label:Tl(d),accessor:d,role:"value",format:g}]),[c,l,G,q,d,h,p,g]),ce=ph({componentName:"Heatmap",data:i,accessors:{xAccessor:c,yAccessor:l,valueAccessor:d}}),le=Vp(()=>{if(Q)return{gradient:{colorFn:e=>ae(e),domain:ie,label:"string"==typeof d?d:"value",format:g}}},[Q,ae,ie,d,g]),ue={chartType:"heatmap",...null!=i&&{data:X},xAccessor:c,yAccessor:l,valueAccessor:d,colorScheme:"custom"!==K?K:void 0,showValues:y,heatmapValueFormat:g,size:[j,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J,showAxes:r.showAxes,xLabel:G,yLabel:q,xFormat:h,yFormat:p,enableHover:F,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...le&&{legend:le,legendPosition:Z},...$h({title:O,description:z,summary:H,accessibleTable:W,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:x,defaultTooltipContent:se}),...Bh({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:r.mobileInteraction,customHoverBehavior:ee,customClickBehavior:te}),...w&&w.length>0&&{annotations:w},...k&&{xExtent:k},...S&&{yExtent:S},...oe,...A};return Y||V||(ce?Qp(Qd,{componentName:"Heatmap",message:ce,width:j,height:E}):Qp(oh,{componentName:"Heatmap",width:j,height:E,children:Qp(hu,{ref:o,...ue})}))});Zp.displayName="Heatmap";import*as Jp from"react";import{useMemo as em,useCallback as tm,useState as nm,useRef as om,useEffect as rm}from"react";import{brush as im}from"d3-brush";import{select as am}from"d3-selection";import{jsx as sm,jsxs as cm}from"react/jsx-runtime";var lm="__splomIdx",um={top:4,bottom:4,left:4,right:4};function dm({frameRef:e,cellSize:t,onBrush:n}){const o=om(null),r=t-um.left-um.right,i=t-um.top-um.bottom;return rm(()=>{if(!o.current)return;const t=am(o.current).select(".brush-g"),a=im().extent([[0,0],[r,i]]).on("brush end",t=>{const o=e.current?.getScales();if(!o)return;if(!(r=t.selection)||!Array.isArray(r[0]))return void n(null);var r;const[[i,a],[s,c]]=t.selection,l=[[o.x.invert(i),o.y.invert(a)],[o.x.invert(s),o.y.invert(c)]];n(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)}},[r,i,e,n]),sm("svg",{ref:o,width:t,height:t,style:{position:"absolute",top:0,left:0},children:sm("g",{className:"brush-g",transform:`translate(${um.left},${um.top})`})})}function hm({data:e,xField:t,yField:n,cellSize:o,pointRadius:r,pointOpacity:i,colorBy:a,colorScale:s,brushSelectionName:c,hoverSelectionName:l,unselectedOpacity:u,mobileInteraction:d,mode:h,onPointHover:p,onPointClick:m}){const f=om(null),y=Gu({name:c,clientId:`splom-${t}-${n}`,fields:[t,n]}),g=Xu({name:c,xField:t,yField:n}),b=Gu({name:l,clientId:"splom-hover-source",fields:[lm]}),v=b.selectPoints,x=tm(e=>{e?g.brushInteraction.during(e):g.brushInteraction.end(null)},[g.brushInteraction]),w=tm(e=>{if(!e)return void p?.(null);const t=e.data,n=t?.[lm];void 0!==n&&(v({[lm]:[n]}),p?.(t,e.x+um.left,e.y+um.top))},[v,p]),k=tm(e=>{if(!e)return void m?.(null);const t=e.data;t&&m?.(t,e.x+um.left,e.y+um.top)},[m]),S=tm(e=>{const t={opacity:i,r:r};return t.fill=a?He(e,a,s):$d,"hover"===h?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*i):y.isActive&&!y.predicate(e)&&(t.opacity=u),t},[i,r,a,h,s,b,y,u]);return cm("div",{style:{position:"relative",width:o,height:o},children:[sm(hu,{ref:f,chartType:"scatter",data:e,size:[o,o],xAccessor:t,yAccessor:n,pointStyle:S,margin:um,showAxes:!1,enableHover:"hover"===h,...Bh({forceHoverBehavior:"hover"===h,forceClickBehavior:!!m,mobileInteraction:d,customHoverBehavior:w,customClickBehavior:k}),tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&sm(dm,{frameRef:f,cellSize:o,xField:t,yField:n,onBrush:x})]})}function pm({data:t,field:o,label:r,cellSize:i,bins:a,colorBy:s,colorScale:c,brushSelectionName:l,hoverSelectionName:u,mode:d}){const h=Gu({name:l,clientId:"splom-diag-"+o,fields:[o]}),p=Gu({name:u,clientId:`splom-diag-${o}-hover`,fields:[lm]}),m="hover"===d?p:h,f=m.isActive,y=m.predicate,g=em(()=>{const r="string"==typeof s?s:null,c=[],l=new Set;for(const e of t){const t=e[o];if(null==t||isNaN(t)||c.push(Number(t)),r){const t=e[r];null!=t&&l.add(t+"")}}if(0===c.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const[u,d]=n(c),h=(d-u)/a||1,p=Array.from(l),m=new Map(p.map((e,t)=>[e,t])),g=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[o];if(null==t||isNaN(t))continue;const n=Math.min(Math.floor((t-u)/h),a-1);if(g[n]++,f&&!y(e)||b[n]++,r){const t=m.get(e[r]+"");void 0!==t&&(v[n][t]++,f&&!y(e)||x[n][t]++)}}const w=e(g,1),k=v.map((e,t)=>{let n=0;return e.map((e,o)=>{const r=e/w*(i-24),s={x:t/a*i,w:i/a-1,h:r,y0:n,category:p[o]};return n+=r,s})}),S=x.map((e,t)=>{let n=0;return e.map((e,o)=>{const r=e/w*(i-24),s={x:t/a*i,w:i/a-1,h:r,y0:n,category:p[o]};return n+=r,s})});return{bars:g.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,o,a,i,f,y,s]);return cm("svg",{width:i,height:i,style:{overflow:"hidden"},children:[sm("text",{x:i/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),g.categories.length>0?g.categoryBars.map((e,t)=>e.map((e,n)=>sm("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:c?c(e.category):$d,opacity:f?.3:.6},`bg-${t}-${n}`))):g.bars.map((e,t)=>sm("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:$d,opacity:f?.3:.6},"bg-"+t)),f&&(g.categories.length>0?g.selectedCategoryBars.map((e,t)=>e.map((e,n)=>sm("rect",{x:e.x,y:i-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:c?c(e.category):$d,opacity:.7},`sel-${t}-${n}`))):g.selectedBars.map((e,t)=>sm("rect",{x:e.x,y:i-e.h,width:Math.max(e.w,1),height:e.h,fill:$d,opacity:.7},"sel-"+t)))]})}function mm({label:e,cellSize:t}){return sm("svg",{width:t,height:t,children:sm("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:e})})}function fm(e){const{data:t,fields:n,fieldLabels:o={},colorBy:r,colorScheme:i,cellSize:a=150,cellGap:s=4,pointRadius:c=2,pointOpacity:l=.5,diagonal:u="histogram",histogramBins:d=20,brushMode:h="crossfilter",hoverMode:p=!0,unselectedOpacity:m=.1,showGrid:f=!1,tooltip:y,showLegend:g,idAccessor:b,width:v,className:x,onObservation:w,onClick:k,chartId:S}=e,A="splom",C="splom-hover",M=jd(e.mobileInteraction,{mode:e.mode,width:v??n.length*a,mobileSemantics:e.mobileSemantics}),P=p?"hover":h?"brush":"hover",I=Ou(e=>e.clearSelection),[R,_]=nm(null),T=tm(()=>{I(C),_(null)},[I,C]),L=em(()=>(t||[]).map((e,t)=>void 0!==e[lm]?e:{...e,[lm]:t}),[t]),N=Od(L,r,i),$=tm((e,t,n,o)=>[40+e*(a+s)+(n??0),t*(a+s)+(o??0)],[40,a,s]),B=void 0!==g?g:!!r,D=em(()=>{if(!B||!r)return null;const e="string"==typeof r?r:null;return e?Array.from(new Set(L.map(t=>t[e]).filter(e=>null!=e))).map(e=>({label:e+"",color:N?N(e+""):$d})):null},[B,r,L,N]),j=em(()=>({display:"grid",gridTemplateColumns:"40px "+n.map(()=>a+"px").join(" "),gridTemplateRows:n.map(()=>a+"px").join(" ")+" 40px",gap:s+"px",width:"fit-content"}),[n,a,s,40]);return cm("div",{className:x,style:{position:"relative"},children:[D&&sm("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:D.map(e=>cm("div",{style:{display:"flex",alignItems:"center",gap:4},children:[sm("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),sm("span",{style:{fontSize:11},children:e.label})]},e.label))}),cm("div",{style:j,onMouseLeave:"hover"===P?T:void 0,children:[n.map((e,t)=>cm(Jp.Fragment,{children:[sm("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"},children:o[e]||e}),n.map((n,i)=>t===i?"label"===u?sm(mm,{label:o[e]||e,cellSize:a},"diag-"+e):sm(pm,{data:L,field:e,label:o[e]||e,cellSize:a,bins:d,colorBy:r,colorScale:N,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,mode:P},"diag-"+e):sm(hm,{data:L,xField:n,yField:e,fieldLabels:o,cellSize:a,pointRadius:c,pointOpacity:l,colorBy:r,colorScale:N,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,showGrid:f,tooltip:y,mobileInteraction:M,mode:P,onPointHover:"hover"===P?(o,r,a)=>{if(o){if(_({datum:o,xField:n,yField:e,colIndex:i,rowIndex:t,px:r??0,py:a??0}),w){const[e,n]=$(i,t,r,a);w({type:"hover",datum:o,x:e,y:n,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}}else _(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0,onPointClick:k||w?(e,n,o)=>{if(!e)return;const[r,a]=$(i,t,n,o);k&&k(e,{x:r,y:a}),w&&w({type:"click",datum:e,x:r,y:a,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0},`cell-${e}-${n}`))]},"row-"+e)),sm("div",{})," ",n.map(e=>sm("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:o[e]||e},"col-label-"+e))]}),R&&"hover"===P&&(()=>{const e=R.datum,t=o[R.xField]||R.xField,n=o[R.yField]||R.yField,i=r?"function"==typeof r?r(e):e[r]:null,c=b?"function"==typeof b?b(e):e[b]:"Row "+e[lm];return cm("div",{style:{position:"absolute",left:40+R.colIndex*(a+s)+R.px,top:R.rowIndex*(a+s)+R.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:[sm("div",{style:{fontWeight:"bold",marginBottom:2},children:c+""}),cm("div",{children:[t,": ",null!=e[R.xField]?Number(e[R.xField]).toFixed(1):"–"]}),cm("div",{children:[n,": ",null!=e[R.yField]?Number(e[R.yField]).toFixed(1):"–"]}),null!=i&&cm("div",{style:{opacity:.8},children:["string"==typeof r?r:"group",": ",i+""]})]})})()]})}function ym(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),sm(hd,{selections:o,children:sm(fm,{...e})})}ym.displayName="ScatterplotMatrix";import{useState as gm,useRef as bm,useEffect as vm,useMemo as xm,useCallback as wm}from"react";import{brushX as km,brushY as Sm}from"d3-brush";import{select as Am}from"d3-selection";import{jsx as Cm,jsxs as Mm}from"react/jsx-runtime";function Pm({width:e,height:t,margin:n,scales:o,brushDirection:r,extent:i,onBrush:a}){const s=bm(null),c=bm(null),l=bm(!1),u=e+n.left+n.right,d=t+n.top+n.bottom;return vm(()=>{if(!s.current||!o)return;const n=Am(s.current).select(".brush-group"),i="x"===r?km().extent([[0,0],[e,t]]):Sm().extent([[0,0],[e,t]]);return i.on("brush end",e=>{if(l.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void a(null);const n=("x"===r?o.x:o.y).invert;if(!n)return;const i=[n(t[0]),n(t[1])];a(i)}),n.call(i),c.current=e=>{n.call(i.move,e)},n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{c.current=null,i.on("brush end",null)}},[o,e,t,r,a]),vm(()=>{if(!c.current||!o||!s.current)return;const e="x"===r?o.x:o.y;if(l.current=!0,i){const t=[e(i[0]),e(i[1])];c.current(t)}else c.current(null);l.current=!1},[i,o,r]),Cm("svg",{ref:s,width:u,height:d,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:Cm("g",{className:"brush-group",transform:`translate(${n.left},${n.top})`})})}function Im(e){const{data:t,width:n=600,height:o=400,margin:r,className:i,title:a,description:s,summary:c,xLabel:l,yLabel:d,xFormat:h,yFormat:p,xAccessor:m="x",yAccessor:f="y",lineBy:y,lineDataAccessor:g="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:R,tooltip:_,minimap:T={},renderBefore:L=!1,onBrush:N,brushExtent:$,yExtent:B,frameProps:D={},loading:j,loadingContent:E,emptyContent:F}=e,O=sh(j,n,o,E),z=O?null:ah(t,n,o,F),H=xm(()=>u(t),[t]),[W,G]=gm(null),q=$??W,Y=wm(e=>{$||G(e),N?.(e)},[$,N]),V=bm(null),[X,U]=gm(null);vm(()=>{let e=0,t=!1;const n=()=>{if(t)return;const o=V.current?.getScales?.();o?U(o):e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{t=!0,e&&cancelAnimationFrame(e)}},[t]);const K=void 0!==H[0]?.[g],Q=xm(()=>{if(K)return H;if(y){const e=H.reduce((e,t)=>{const n="function"==typeof y?y(t):t[y];if(!e[n]){const t={[g]:[]};"string"==typeof y&&(t[y]=n),e[n]=t}return e[n][g].push(t),e},{});return Object.values(e)}return[{[g]:H}]},[H,y,g,K]),Z=xm(()=>K||y?Q.flatMap(e=>{const t=e[g]||[];return y&&"string"==typeof y?t.map(t=>({...t,[y]:e[y]})):t}):H,[Q,g,K,y,H]),J=Od(H,b,v),ee=Th({lineWidth:w,colorBy:b,colorScale:J,fillArea:k,areaOpacity:S}),te=xm(()=>{if(T.lineStyle)return T.lineStyle},[T.lineStyle]),ne=Th({lineWidth:1,colorBy:b,colorScale:J}),oe=te??ne,re=xm(()=>{if(A)return e=>{const t={r:C,fillOpacity:1};return t.fill=b?He(e.parentLine||e,b,J):$d,t}},[A,C,b,J]),{legend:ie,margin:ae,legendPosition:se}=Gd({data:Q,colorBy:b,colorScale:J,showLegend:I,legendPosition:R,userMargin:r}),ce=T.height||60,le=xm(()=>({top:T.margin?.top??0,bottom:T.margin?.bottom??20,left:T.margin?.left??ae.left,right:T.margin?.right??ae.right}),[T.margin,ae]),ue=T.brushDirection||"x",de=xm(()=>Dl([{label:l||Tl(m),accessor:m,role:"x",format:h},{label:d||Tl(f),accessor:f,role:"y",format:p}]),[m,f,l,d,h,p]),he=ph({componentName:"MinimapChart",data:t,accessors:{xAccessor:m,yAccessor:f}});if(he)return Cm(Qd,{componentName:"MinimapChart",message:he,width:n,height:o});const pe=k?"area":"line",me={chartType:pe,data:Z,xAccessor:m,yAccessor:f,groupAccessor:y||void 0,curve:x,lineStyle:ee,...A&&{pointStyle:re},size:[n,o],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ae,showAxes:!0,xLabel:l,yLabel:d,xFormat:h,yFormat:p,enableHover:M,showGrid:P,...ie&&{legend:ie,legendPosition:se},...a&&{title:a},...s&&{description:s},...c&&{summary:c},tooltipContent:!1===_?()=>null:sc(_)||de,...q&&{xExtent:q},...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:y||void 0,curve:x,lineStyle:oe,size:[n,ce+le.top+le.bottom],margin:le,showAxes:T.showAxes??!1,background:T.background,enableHover:!1,...B&&{yExtent:B}},ye=Mm("div",{style:{position:"relative",width:n,overflow:"hidden"},children:[Cm(hu,{ref:V,...fe}),Cm(Pm,{width:n-le.left-le.right,height:ce,margin:le,scales:X,brushDirection:ue,extent:q,onBrush:Y})]},"minimap"),ge=Cm("div",{style:{overflow:"hidden"},children:Cm(hu,{...me})},"main");return O||z||Cm(oh,{componentName:"MinimapChart",width:n,height:o,children:Mm("div",{className:"minimap-chart"+(i?" "+i:""),children:[L?ye:ge,L?ge:ye]})})}Im.displayName="MinimapChart";import{useMemo as Rm,forwardRef as _m,useRef as Tm}from"react";var Lm={label:"Low / High",color:"#E9C46A",opacity:.08},Nm={label:"High / High",color:"#2A9D8F",opacity:.08},$m={label:"Low / Low",color:"#E76F51",opacity:.08},Bm={label:"High / Low",color:"#86BBD8",opacity:.08};import{Fragment as Dm,jsx as jm,jsxs as Em}from"react/jsx-runtime";function Fm(e,t){return{label:t?.label??e.label,color:t?.color??e.color,opacity:t?.opacity??e.opacity}}var Om=_m(function(e,t){const o=Tm(null);Nh(t,{variant:"xy",frameRef:o});const r=Vd(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:c,yFormat:l,xAccessor:d="x",yAccessor:h="y",xCenter:p,yCenter:m,quadrants:f,centerlineStyle:y={},showQuadrantLabels:g=!0,quadrantLabelSize:b=12,colorBy:v,colorScheme:x,styleRules:w,sizeBy:k,sizeRange:S=[3,15],pointRadius:A=5,pointOpacity:C=.8,tooltip:M,pointIdAccessor:P,annotations:I,frameProps:R={},selection:_,linkedHover:T,onObservation:L,onClick:N,hoverHighlight:$,chartId:B,loading:D,loadingContent:j,emptyContent:E,legendInteraction:F,legendPosition:O,color:z,stroke:H,strokeWidth:W,opacity:G}=e,{width:q,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,ne=Rm(()=>({topLeft:Fm(Lm,f?.topLeft),topRight:Fm(Nm,f?.topRight),bottomLeft:Fm($m,f?.bottomLeft),bottomRight:Fm(Bm,f?.bottomRight)}),[f]),oe=Rm(()=>u(i),[i]),re=wh({data:oe,rawData:i,colorBy:v,colorScheme:x,legendInteraction:F,legendPosition:O,selection:_,linkedHover:T,fallbackFields:"string"==typeof v?[v]:[],unwrapData:!1,onObservation:L,onClick:N,hoverHighlight:$,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"QuadrantChart",chartId:B,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:j,emptyContent:E,width:q,height:Y});ch("QuadrantChart",oe,"xAccessor",d),ch("QuadrantChart",oe,"yAccessor",h);const ie=Rm(()=>{if(!oe.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const a of oe){const s=e(a),c=t(a);isFinite(s)&&(n>s&&(n=s),s>o&&(o=s)),isFinite(c)&&(r>c&&(r=c),c>i&&(i=c))}if(null!=p&&isFinite(p)&&(n>p&&(n=p),p>o&&(o=p)),null!=m&&isFinite(m)&&(r>m&&(r=m),m>i&&(i=m)),n===1/0)return;const a=.1*(o-n)||1,s=.1*(i-r)||1;return{xExtent:[n-a,o+a],yExtent:[r-s,i+s]}},[oe,d,h,p,m]),ae=Rm(()=>{if(!k||0===oe.length)return;const e=oe.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?n(e):void 0},[oe,k]),se=Rm(()=>"function"==typeof d?d:e=>+e[d],[d]),ce=Rm(()=>"function"==typeof h?h:e=>+e[h],[h]),le=Rm(()=>e=>{const t=se(e),n=ce(e),o=null!=p?t>=p:void 0,r=null!=m?n>=m:void 0;return void 0===r||void 0===o?z||$d:r&&o?ne.topRight.color:r&&!o?ne.topLeft.color:!r&&o?ne.bottomRight.color:ne.bottomLeft.color},[se,ce,p,m,ne,z]),ue=Rm(()=>k?e=>qe(e,k,S,ae):void 0,[k,S,ae]),de=Rm(()=>Ch(d,h),[d,h]),he=Cp({colorBy:v,colorScale:re.colorScale,color:z,pointRadius:A,fillOpacity:C,radiusFn:ue,fallbackFill:le,stroke:H,strokeWidth:W,opacity:G,styleRules:w,ruleContext:de,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection}),pe=Rm(()=>{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 k&&e.add(k);const t=oe[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[oe,d,h,v,k]),me=Rm(()=>Dl([...pe?[{label:pe,accessor:pe,role:"title"}]:[],{label:ee||Tl(d),accessor:d,role:"x",format:c},{label:te||Tl(h),accessor:h,role:"y",format:l},...v?[{label:Tl(v),accessor:v,role:"color"}]:[],...k?[{label:Tl(k),accessor:k,role:"size"}]:[]]),[pe,d,h,ee,te,v,k,c,l]),fe=ph({componentName:"QuadrantChart",data:i,accessors:{xAccessor:d,yAccessor:h}}),ye=Rm(()=>{const e={stroke:y.stroke||"#999",strokeWidth:y.strokeWidth??1,dashArray:y.strokeDasharray||[]};return[(t,n,o,r)=>{if(!o?.x||!o?.y)return;const i=r.width,a=r.height,s=null!=p?o.x(p):i/2,c=null!=m?o.y(m):a/2;if(null!=p&&!isFinite(s))return;if(null!=m&&!isFinite(c))return;const l=Math.max(0,Math.min(i,s)),u=Math.max(0,Math.min(a,c)),d=[{config:ne.topLeft,x:0,y:0,w:l,h:u},{config:ne.topRight,x:l,y:0,w:i-l,h:u},{config:ne.bottomLeft,x:0,y:u,w:l,h:a-u},{config:ne.bottomRight,x:l,y:u,w:i-l,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(l,0),t.lineTo(l,a),t.stroke(),t.beginPath(),t.moveTo(0,u),t.lineTo(i,u),t.stroke(),t.setLineDash([])}]},[p,m,ne,y]),ge=Rm(()=>g?[...ye,(e,t,n,o)=>{if(!n?.x||!n?.y)return;const r=o.width,i=o.height,a=null!=p?n.x(p):r/2,s=null!=m?n.y(m):i/2;(null==p||isFinite(a))&&(null==m||isFinite(s))&&(e.font=`600 ${b}px sans-serif`,e.globalAlpha=.5,e.fillStyle=ne.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(ne.topLeft.label,8,8),e.fillStyle=ne.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(ne.topRight.label,r-8,8),e.fillStyle=ne.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(ne.bottomLeft.label,8,i-8),e.fillStyle=ne.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(ne.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:ye,[ye,g,b,ne,p,m]),be=Rm(()=>{const e=R.canvasPreRenderers||[];return[...ge,...e]},[ge,R.canvasPreRenderers]),ve=Rm(()=>{const e={stroke:y.stroke||"#999",strokeWidth:y.strokeWidth??1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(t,n,o)=>{if(!n?.x||!n?.y)return null;const r=o.width,i=o.height,a=null!=p?n.x(p):r/2,s=null!=m?n.y(m):i/2;if(null!=p&&!isFinite(a))return null;if(null!=m&&!isFinite(s))return null;const c=Math.max(0,Math.min(r,a)),l=Math.max(0,Math.min(i,s));return Em(Dm,{children:[[{config:ne.topLeft,x:0,y:0,w:c,h:l},{config:ne.topRight,x:c,y:0,w:r-c,h:l},{config:ne.bottomLeft,x:0,y:l,w:c,h:i-l},{config:ne.bottomRight,x:c,y:l,w:r-c,h:i-l}].map((e,t)=>e.w>0&&e.h>0?jm("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),jm("line",{x1:c,y1:0,x2:c,y2:i,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),jm("line",{x1:0,y1:l,x2:r,y2:l,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),g&&Em(Dm,{children:[jm("text",{x:8,y:8+b,fill:ne.topLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:ne.topLeft.label}),jm("text",{x:r-8,y:8+b,fill:ne.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:ne.topRight.label}),jm("text",{x:8,y:i-8,fill:ne.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:ne.bottomLeft.label}),jm("text",{x:r-8,y:i-8,fill:ne.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:ne.bottomRight.label})]})]})}]},[p,m,ne,y,g,b]);if(re.earlyReturn)return re.earlyReturn;const xe={chartType:"scatter",...null!=i&&{data:oe},xAccessor:d,yAccessor:h,colorAccessor:v||void 0,sizeAccessor:k||void 0,sizeRange:S,pointStyle:he,colorScheme:x,size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:re.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:l,enableHover:V,showGrid:X,...ie&&{xExtent:ie.xExtent,yExtent:ie.yExtent},...re.legendBehaviorProps,...K&&{title:K},...Q&&{description:Q},...Z&&{summary:Z},...void 0!==J&&{accessibleTable:J},...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===M?()=>null:!0===M||void 0===M?me:sc(M)||me,...Bh({linkedHover:T,selection:_,onObservation:L,onClick:N,hoverHighlight:$,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...P&&{pointIdAccessor:P},...I&&I.length>0&&{annotations:I},canvasPreRenderers:be,...re.crosshairProps,...R,...be.length>0&&{canvasPreRenderers:be},svgPreRenderers:ve};return fe?jm(Qd,{componentName:"QuadrantChart",message:fe,width:q,height:Y}):jm(oh,{componentName:"QuadrantChart",width:q,height:Y,children:jm(hu,{ref:o,...xe})})});Om.displayName="QuadrantChart";import*as zm from"react";import{useMemo as Hm,useCallback as Wm,forwardRef as Gm,useRef as qm,useImperativeHandle as Ym}from"react";import{jsx as Vm}from"react/jsx-runtime";var Xm="__ma_unitized",Um="__ma_series";function Km(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Qm(e,t){return t[0]+e*(t[1]-t[0])}var Zm=Gm(function(e,t){const n=qm(null),o=qm([]),r=qm(e.series);r.current=e.series,Ym(t,()=>{const e=()=>(r.current??[]).filter(e=>null!=e&&"object"==typeof e);return{push:t=>{if(!n.current)return;const r=e(),i=t;for(let e=0;r.length>e&&2>e;e++){const t=r[e],a=t.extent||o.current[e];if(!a)continue;const s=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(i);null!=s&&isFinite(s)&&n.current.push({...i,[Xm]:Km(s,a),[Um]:t.label||"Series "+(e+1)})}},pushMany:t=>{if(!n.current)return;const r=e(),i=[];for(const e of t)for(let t=0;r.length>t&&2>t;t++){const n=r[t],a=n.extent||o.current[t];if(!a)continue;const s=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=s&&isFinite(s)&&i.push({...e,[Xm]:Km(s,a),[Um]:n.label||"Series "+(t+1)})}n.current.pushMany(i)},remove:e=>n.current?.remove(e)??[],update:(e,t)=>n.current?.update(e,t)??[],clear:()=>n.current?.clear(),getData:()=>n.current?.getData()??[],getScales:()=>n.current?.getScales()??null}},[]);const i=Vd(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:c,xFormat:l,xAccessor:d="x",series:h,colorScheme:p,curve:m="monotoneX",lineWidth:f=2,tooltip:y,annotations:g,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:R,stroke:_,strokeWidth:T,opacity:L}=e,{width:N,height:$,enableHover:B,showGrid:D,showLegend:j=!0,title:E,description:F,summary:O,accessibleTable:z,xLabel:H}=i,W=Hm(()=>u(a),[a]),G=Hm(()=>u(h),[h]),q=G,Y=2===G.length;"undefined"==typeof process||"production"===process.env?.NODE_ENV||Y||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${G.length}. Rendering as a standard multi-line chart.`);const V=sh(C,N,$,M),X=V?null:ah(a,N,$,P),U=Ed(),K=Hm(()=>{let e;if(Array.isArray(p))e=p;else if(U&&U.length>0)e=U;else{const t=je[p];e=Array.isArray(t)?t:Ee}return q.map((t,n)=>t.color||e[n%e.length])},[q,p,U]),Q=Hm(()=>G.map((e,t)=>e.label||"Series "+(t+1)),[G]),{unitizedData:Z,extents:J}=Hm(()=>{if(0===W.length){const e=G.map(e=>e.extent||null).filter(Boolean);return e.length===G.length&&(o.current=e),{unitizedData:[],extents:e.length===G.length?e:[]}}const e=G.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const r="function"==typeof t?t:e=>e[t];for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(W,e.yAccessor));if(o.current=e,!Y){const t=[];for(const e of W)for(let n=0;G.length>n;n++){const o=G[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push({...e,[Xm]:r,[Um]:Q[n]})}return{unitizedData:t,extents:e}}const t=[];for(const n of W)for(let o=0;2>o;o++){const r=G[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push({...n,[Xm]:Km(i,e[o]),[Um]:Q[o]})}return{unitizedData:t,extents:e}},[W,G,Y,Q]),ee=Hm(()=>{if(Y&&J.length>=2)return[{orient:"left",label:Q[0],tickFormat:G[0].format||(e=>{const t=Qm(e,J[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:Q[1],tickFormat:G[1].format||(e=>{const t=Qm(e,J[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[Y,J,G,Q]),te=wh({data:Hm(()=>Z.length>0?Z:Q.map(e=>({[Um]:e})),[Z,Q]),rawData:a,colorBy:Um,colorScheme:K,legendInteraction:I,legendPosition:R,selection:v,linkedHover:x,fallbackFields:[Um],unwrapData:!1,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"MultiAxisLineChart",chartId:A,showLegend:j,userMargin:s,marginDefaults:Y?{...i.marginDefaults,left:70,right:70}:i.marginDefaults,loading:C,loadingContent:M,emptyContent:P,width:N,height:$}),ne=Hm(()=>{const e=new Map;return Q.forEach((t,n)=>e.set(t,K[n])),e},[Q,K]),oe=Th({lineWidth:f,resolveStroke:Wm(e=>ne.get(e[Um])||K[0],[ne,K]),stroke:_,strokeWidth:T,opacity:L,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=Hm(()=>{if(!1===y)return()=>null;return sc(y)||(e=>{const t=e.data||e,n=t[Um],o=Q.indexOf(n),r=t[Xm],i=Y&&o>=0&&J[o]?Qm(r,J[o]):r,a=o>=0&&G[o]?.format?G[o].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),s="function"==typeof d?d(t):t[d];return zm.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},zm.createElement("div",{style:{fontWeight:600,marginBottom:4,color:K[o]||"inherit"}},n),zm.createElement("div",null,`${"string"==typeof d?d:"x"}: ${s}`),zm.createElement("div",null,`${n}: ${a(i)}`))})},[y,Q,K,J,Y,G,d]);if(te.earlyReturn)return te.earlyReturn;const ie=ph({componentName:"MultiAxisLineChart",data:a,accessors:{xAccessor:d}}),ae=Y?[0,1]:void 0,se={chartType:"line",...null!=a&&{data:Z},xAccessor:d,yAccessor:Xm,groupAccessor:Um,lineStyle:oe,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:l,...Y&&ae&&{yExtent:ae},enableHover:B,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:D,curve:m,...te.legendBehaviorProps,...E&&{title:E},...F&&{description:F},...O&&{summary:O},...void 0!==z&&{accessibleTable:z},...c&&{className:c},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:re,...g&&{annotations:g},...Bh({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?Vm(Qd,{componentName:"MultiAxisLineChart",message:ie,width:N,height:$}):Vm(oh,{componentName:"MultiAxisLineChart",width:N,height:$,children:Vm(hu,{ref:n,...se})}))});Zm.displayName="MultiAxisLineChart";import{useMemo as Jm,forwardRef as ef,useRef as tf}from"react";function nf(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 of}from"react/jsx-runtime";var rf=ef(function(e,t){const n=tf(null);Nh(t,{variant:"xy",frameRef:n});const o=Vd(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:r,margin:i,className:a,xFormat:s,yFormat:c,xAccessor:l="x",highAccessor:d="high",lowAccessor:h="low",openAccessor:p,closeAccessor:m,candlestickStyle:f,tooltip:y,annotations:g,xExtent:b,yExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,chartId:C,loading:M,loadingContent:P,emptyContent:I}=e,{width:R,height:_,enableHover:T,showGrid:L,title:N,description:$,summary:B,accessibleTable:D,xLabel:j,yLabel:E}=o,F=sh(M,R,_,P),O=F?null:ah(r,R,_,I),z=Jm(()=>u(r),[r]),H=null==p||null==m;ch("CandlestickChart",z,"xAccessor",l),ch("CandlestickChart",z,"highAccessor",d),ch("CandlestickChart",z,"lowAccessor",h),H||(ch("CandlestickChart",z,"openAccessor",p),ch("CandlestickChart",z,"closeAccessor",m));const{customHoverBehavior:W,customClickBehavior:G,crosshairSourceId:q}=Hd({selection:w,linkedHover:k,onObservation:S,onClick:A,chartType:"CandlestickChart",chartId:C,mobileInteraction:o.mobileInteraction}),Y=Wd(k,q),V=Jm(()=>{const t=o.marginDefaults,n="sparkline"===e.mode?{...t,top:0,bottom:0}:t;return null==i?n:{...n,...nf(i)}},[i,o.marginDefaults,e.mode]),X=Jm(()=>{const e=[{label:j||Tl(l),accessor:l,role:"x",format:s}];return H?(e.push({label:"High",accessor:d,role:"y",format:c}),e.push({label:"Low",accessor:h,format:c})):(e.push({label:"Open",accessor:p,format:c}),e.push({label:"High",accessor:d,format:c}),e.push({label:"Low",accessor:h,format:c}),e.push({label:"Close",accessor:m,format:c})),Dl(e)},[l,j,s,c,d,h,p,m,H]),U=ph({componentName:"CandlestickChart",data:r,accessors:{xAccessor:l,highAccessor:d,lowAccessor:h,...!H&&{openAccessor:p,closeAccessor:m}}}),K={chartType:"candlestick",...null!=r&&{data:z},xAccessor:l,yAccessor:d,highAccessor:d,lowAccessor:h,...!H&&{openAccessor:p,closeAccessor:m},...f&&{candlestickStyle:f},scalePadding:Math.max(2,Math.min(12,Math.round(R/40))),extentPadding:R>200?.1:.02,size:[R,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:V,showAxes:o.showAxes,xLabel:j,yLabel:E,xFormat:s,yFormat:c,enableHover:T,showGrid:L,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...$h({title:N,description:$,summary:B,accessibleTable:D,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:y,defaultTooltipContent:X}),...Bh({linkedHover:k,selection:w,onObservation:S,onClick:A,mobileInteraction:o.mobileInteraction,customHoverBehavior:W,customClickBehavior:G}),...g&&g.length>0&&{annotations:g},...b&&{xExtent:b},...v&&{yExtent:v},...Y,...x};return F||O||(U?of(Qd,{componentName:"CandlestickChart",message:U,width:R,height:_}):of(oh,{componentName:"CandlestickChart",width:R,height:_,children:of(hu,{ref:n,...K})}))});rf.displayName="CandlestickChart";import{useMemo as af,forwardRef as sf,useRef as cf}from"react";import{useRef as lf,useState as uf,useEffect as df,useMemo as hf,useCallback as pf,useImperativeHandle as mf,forwardRef as ff,memo as yf}from"react";import{scaleBand as gf,scaleLinear as bf}from"d3-scale";var vf=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,n){if(t&&"function"==typeof e.pieceStyle){const o=e.pieceStyle(t,n);return o&&!o.fill&&n?{...o,fill:this.getColorFromScheme(e,n)}:o}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&n?{fill:e.barColors[n]||"#007bff"}:{fill:n?this.getColorFromScheme(e,n):"#007bff"}}resolveSummaryStyle(e,t,n){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,n):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const n=this.colorSchemeMap.get(t);if(n)return n;const o=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Fe,r=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,r),r}};function xf(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,o=new Map;let r=0;return e=>{const i=t(e)+"",a=n?.[i];if(a)return a;let s=o.get(i);return s||(s=_t[r%_t.length],r++,o.set(i,s)),s}}function wf(e,t,n,o,r,i,a){e.push(t?{type:"symbol",x:o,y:r,size:Math.PI*i*i,symbolType:t(n),style:a,datum:n}:{type:"point",x:o,y:r,r:i,style:a,datum:n})}function kf(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],a=Math.min(t.width,t.height)/2-4,s="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,d=Object.values(n),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&&(o.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,m=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,f=r(t.pieceData[0],t.name),y=0===e,g=e===d.length-1,b={type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:h,endAngle:m,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:f,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?b.roundedEnds=n._roundedEnds:p&&(b.roundedEnds={start:y,end:g}),n?._gradientBand&&(b._gradientBand=n._gradientBand),i.push(b)}return i}import{quantile as Sf}from"d3-array";function Af(e){const t=e.length,n=e[0],o=e[t-1];return{n:t,min:n,q1:Sf(e,.25)??n,median:Sf(e,.5)??(n+o)/2,q3:Sf(e,.75)??o,max:o,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as Cf}from"d3-scale";var Mf={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:a,resolvePieceStyle:s}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,p=r.normalize,m=[];if(a){const e=new Set;for(const t of Object.values(o))for(const n of t.pieceData){const t=a(n);e.has(t)||(e.add(t),m.push(t))}}else m.push("_default");for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=a?a(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(p)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const i of m){const l=t.get(i);if(!l)continue;let m=l.total;p&&n>0&&(m/=n);const f=s(l.pieces[0],a?i:e.name),y={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>m?r:o+m),n=0>m?c(r+m)-c(r):c(o)-c(o+m);u.push(lt(e.x,t,e.width,Math.abs(n),f,y,i)),0>m?r+=m:o+=m}else if(h){const t=c(0>m?r+m:o),n=0>m?c(r)-c(r+m):c(o+m)-c(o);u.push(lt(t,e.x,Math.abs(n),e.width,f,y,i)),0>m?r+=m:o+=m}}}const f="vertical"===l,y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.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",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(y>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=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=y),n.length>0&&(n.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=y)}}return u},clusterbar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getGroup:a,resolvePieceStyle:s}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],p=new Set;for(const e of Object.values(o))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(o)){const t=e.width/m,n=.2*t,o=t-n,r=new Map;for(const t of e.pieceData){const e=a?a(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let a=0;h.length>a;a++){const l=r.get(h[a])||[];for(const r of l){const l=i(r),p=s(r,h[a]);if(d){const i=e.x+a*t+n/2,s=c(0),d=c(l);u.push(lt(i,Math.min(s,d),o,Math.abs(s-d),p,r,h[a]))}else{const i=e.x+a*t+n/2,s=c(0),d=c(l);u.push(lt(Math.min(s,d),i,Math.abs(d-s),o,p,r,h[a]))}}}}const f=r.roundedTop&&r.roundedTop>0?Math.max(0,r.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",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:o,getR:r,multiScales:i,resolvePieceStyle:a}=e,{r:s,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=i.length>0,p=xf(e),m=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(o))for(const t of e.pieceData){const n=t.__rIndex??0,o=t.__rValue??r(t),c=h&&i[n]||s,y=a(t,e.name),g=y.r||5;let b,v;if(d){const t=f+(e.pctStart+e.pct/2)*m,n=c(o);b=Math.cos(t)*n,v=Math.sin(t)*n}else u?(b=e.middle,v=c(o)):(b=c(o),v=e.middle);wf(l,p,t,b,v,g,y)}return l},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,c=[],l="vertical"===s,u=xf(e);for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],s=r(o),d=i(o,e.name),h=d.r||4,p=(7919*n%100/100-.5)*t*.8;wf(c,u,o,l?e.middle+p:a(s),l?a(s):e.middle+p,h,d)}}return c},pie:kf,donut:kf,boxplot:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:a}=e,{r:s,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(o)){const n=t.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const o=n[0],r=n[n.length-1],c=Sf(n,.25)??o,h=Sf(n,.5)??(o+r)/2,p=Sf(n,.75)??r,m=p-c,f=c-1.5*m,y=p+1.5*m,g=n.find(e=>e>=f)??o,b=[...n].reverse().find(e=>y>=e)??r,v=a(t.pieceData[0],t.name),x=[];if(d)for(const e of t.pieceData){const n=i(e);if(f>n||n>y){const o=u?t.middle:s(n),r=u?s(n):t.middle;x.push({px:o,py:r,value:n,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:s(g),q1Pos:s(c),medianPos:s(h),q3Pos:s(p),maxPos:s(b),stats:{n:n.length,min:g,q1:c,median:h,q3:p,max:b,mean:n.reduce((e,t)=>e+t,0)/n.length},style:v,datum:t.pieceData,category:t.name,outliers:x}),d)for(const t of x)l.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 l},violin:function(t,n){const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=o,u=[],d="vertical"===l,h=i.bins||20,p=!1!==i.showIQR;for(const t of Object.values(r)){const n=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>n.length)continue;const o=n[0],r=n[n.length-1],i=(r-o)/h||1,l=Array(h).fill(0);for(const e of n)l[Math.min(Math.floor((e-o)/i),h-1)]++;const m=e(l,1),f=t.width/2*.9;let y;if(d){y=`M ${t.middle} ${c(o)}`;for(let e=0;h>e;e++){const n=c(o+(e+.5)*i);y+=` L ${t.middle+l[e]/m*f} ${n}`}y+=` L ${t.middle} ${c(r)}`;for(let e=h-1;e>=0;e--){const n=c(o+(e+.5)*i);y+=` L ${t.middle-l[e]/m*f} ${n}`}y+=" Z"}else{y=`M ${c(o)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${c(o+(e+.5)*i)} ${t.middle-l[e]/m*f}`;y+=` L ${c(r)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${c(o+(e+.5)*i)} ${t.middle+l[e]/m*f}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let b;if(p&&n.length>=4){const e=Sf(n,.25)??o,i=Sf(n,.5)??(o+r)/2,a=Sf(n,.75)??r;b={q1Pos:c(e),medianPos:c(i),q3Pos:c(a),centerPos:t.middle,isVertical:d}}const v=d?{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))}:{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width};u.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:v,iqrLine:b,stats:Af(n),style:g,datum:t.pieceData,category:t.name})}return u},histogram:function(t,o){const{scales:r,columns:i,config:a,getR:s,resolveSummaryStyle:c}=t,{r:l}=r,u=[],d=a.bins||25,h=a.normalize,p=l.domain?.(),m=p?+p[0]:void 0,f=p?+p[1]:void 0;for(const t of Object.values(i)){const o=t.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===o.length)continue;const[r,i]=n(o),a=null!=m&&isFinite(m)?m:r,p=null!=f&&isFinite(f)?f:i,y=(p-a)/d||1,g=Array(d).fill(0);for(const e of o)a>e||e>p||g[Math.min(Math.floor((e-a)/y),d-1)]++;const b=o.length,v=e(g,1),x=c(t.pieceData[0],t.name);for(let e=0;d>e;e++){if(0===g[e])continue;const n=(h?g[e]/b:g[e]/v)*t.width*.9,o=l(a+e*y),r=l(a+(e+1)*y);u.push(lt(Math.min(o,r),t.x+t.width-n,Math.abs(r-o),n,x,{bin:e,count:g[e],range:[a+e*y,a+(e+1)*y],category:t.name},t.name))}}return u},ridgeline:function(t,n){const{scales:o,columns:r,config:i,getR:a,resolveSummaryStyle:s}=t,{r:c,projection:l}=o,u=[],d=i.bins||20,h="horizontal"===l,p=i.amplitude||1.5;for(const t of Object.values(r)){const n=t.pieceData.map(e=>a(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>n.length)continue;const o=n[0],r=n[n.length-1],i=(r-o)/d||1,l=Array(d).fill(0);for(const e of n)o>e||e>r||l[Math.min(Math.floor((e-o)/i),d-1)]++;const m=e(l,1),f=s(t.pieceData[0],t.name),y=t.width*p;let g;if(h){const e=t.x+t.width;g=`M ${c(o)} ${e}`;for(let t=0;d>t;t++)g+=` L ${c(o+(t+.5)*i)} ${e-l[t]/m*y}`;g+=` L ${c(r)} ${e} Z`}else{const e=t.x;g=`M ${e} ${c(o)}`;for(let t=0;d>t;t++){const n=c(o+(t+.5)*i);g+=` L ${e+l[t]/m*y} ${n}`}g+=` L ${e} ${c(r)} Z`}const b=h?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:b,stats:Af(n),style:{...f,fillOpacity:f.fillOpacity??.5},datum:t.pieceData,category:t.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:a,projection:s}=n,c=[],l="horizontal"===s;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,s]=n,u=i(t,e.name);if(l){const n=a(Math.min(o,s)),r=a(Math.max(o,s));c.push(lt(n,e.x,r-n,e.width,u,t,e.name))}else{const n=a(Math.max(o,s)),r=a(Math.min(o,s));c.push(lt(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i}=e,a=[],s=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return a;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(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 l){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const a=t.get(e),s=o(i);a.total+=s,a.pieces.push(i),n+=s}p.push({col:e,groups:t,stepTotal:n}),h||n>m&&(m=n)}if(h)for(const e of p){let t=0,n=0;for(let o=0;u.length>o;o++){const r=e.groups.get(u[o]);r&&(o%2==0?t+=r.total:n+=r.total)}const o=Math.max(t,n);o>m&&(m=o)}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 y=p[0].stepTotal,g=h?.95*s:.9*t.width,b=Cf().domain([0,m]).range([0,g]),v=e.config.connectorOpacity??.3;let x=new Map;for(let t=0;p.length>t;t++){const n=p[t],o=n.col,r=0===t,l=o.width,d=.55*l,m=o.x+(l-d)/2,g=new Map;if(h){let e=0;for(const t of u){const o=n.groups.get(t);o&&(e+=b(o.total))}let t=s,l=s;for(let h=0;u.length>h;h++){const p=u[h],y=n.groups.get(p);if(!y)continue;const v=b(y.total),x=h%2==0,w=x?t:l-v;x?t+=v:l-=v;const k=i(y.pieces[0],p),S=f.get(p)??y.total,A={...y.pieces[0],__funnelValue:y.total,__funnelPercent:S>0?y.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:p};c&&(0===h&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=s,A.__funnelStepLabelY=m,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+v/2,A.__funnelValueLabelY=m,A.__funnelBarW=v),a.push(lt(w,m,v,d,k,A,p)),g.set(p,{x:w,y:m,w:v,h:d})}}else{const e=n.stepTotal,t=b(e),l=s-t/2,h=u[0],p="_default"!==h,f=n.groups.get(h)?.pieces[0]??o.pieceData[0],v=p?h:o.name,x=i(f,v),w=y>0?e/y*100:0,k={...f,__funnelValue:e,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,category:p?h:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=m,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=m,k.__funnelBarW=t),a.push(lt(l,m,t,d,x,k,v)),g.set(h,{x:l,y:m,w:t,h:d})}if(t>0&&x.size>0){const t=h?u:[u[0]];for(const r of t){const t=x.get(r),s=g.get(r);if(!t||!s)continue;const c=(()=>{const e=n.groups.get(r);return i(e?e.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),l={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:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:v},datum:n.groups.get(r)?.pieces[0]??o.pieceData[0],category:"_default"===r?o.name:r};a.push(l)}}x=g}return a},"bar-funnel":function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i,scales:a}=e,s=[],c=a.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return s;const l=[],u=new Set;for(const e of c)for(const t of e.pieceData){const e=r?r(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const a=t.get(e),s=o(i);a.total+=s,a.pieces.push(i),n+=s}h.push({col:e,groups:t,stepTotal:n})}const p=new Map;for(const e of l){const t=h[0]?.groups.get(e);p.set(e,t?.total??0)}const m=a.r,f=d?l.length:1,y=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,o=0===e,r=e>0?h[e-1]:null,a=n.width/f,c=a*y,u=a-c;for(let e=0;l.length>e;e++){const h=l[e],f=t.groups.get(h);if(!f)continue;const y=f.total,g=p.get(h)??y,b=g>0?y/g*100:0,v=r?.groups.get(h),x=o?0:Math.max(0,(v?.total??y)-y),w=n.x+e*a+c/2,k=m(y),S=m(0)-k,A=i(f.pieces[0],d?h:n.name),C={...f.pieces[0],__barFunnelValue:y,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:x,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:m(y+x)};if(s.push(lt(w,k,u,S,A,C,d?h:n.name)),x>0){const e=m(y+x),t=k-e,o={...A},r={...f.pieces[0],__barFunnelValue:x,__barFunnelPercent:g>0?x/g*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};s.push(lt(w,e,u,t,o,r,d?h:n.name))}}}return s},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:a}=e,{r:s,projection:c}=n,l=[],u="horizontal"===c,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,[n,r]=s.range(),i=Math.min(n,r),a=Math.abs(r-n);for(const n of Object.values(o)){const o={fill:e,opacity:t},r=u?lt(i,n.x,a,n.width,o,null,"__track__"):lt(n.x,i,n.width,a,o,null,"__track__");l.push(r)}}const m=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(o)){let t=0;const n=l.length;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const c=i?i(n):e.name,p=a(n,c);let m;if(u){const r=s(t),i=s(t+o);m=lt(r,e.x,i-r,e.width,p,n,c)}else{const r=s(t+o),i=s(t);m=lt(e.x,r,e.width,i-r,p,n,c)}d&&(m.fillGradient=d,m.roundedEdge=h),l.push(m),t+=o}if(m>0&&l.length>n){const e=l.slice(n),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:m,tr:m,br:m,bl:m}:u?(t.cornerRadii={tl:m,bl:m},o.cornerRadii={tr:m,br:m}):(t.cornerRadii={bl:m,br:m},o.cornerRadii={tl:m,tr:m})}}return l}};function Pf(e,t,n){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=je[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}function If(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&We(n,e)||"#4e79a7":t=>{if(n){const e=We(n,t);if(e)return e}let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return e[Math.abs(o)%e.length]??"#4e79a7"}}var Rf=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_f=["scene-style","data-paint","accessibility","evidence"],Tf=(e,t)=>({retainedData:e,invalidations:t}),Lf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$f=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bf=["scene-geometry","data-paint","accessibility","evidence"],Df=["scene-style","data-paint","accessibility","evidence"],jf=[],Ef={chartType:Tf("rebuild",Lf),runtimeMode:Tf("rebuild",Lf),categoryAccessor:Tf("rebuild",Lf),valueAccessor:Tf("rebuild",Lf),oAccessor:Tf("rebuild",Lf),rAccessor:Tf("rebuild",Lf),stackBy:Tf("rebuild",Lf),groupBy:Tf("rebuild",Lf),timeAccessor:Tf("rebuild",Lf),accessorRevision:Tf("rebuild",Lf),colorAccessor:Tf("rebuild",Df),symbolAccessor:Tf("rebuild",Bf),connectorAccessor:Tf("rebuild",Bf),dataIdAccessor:Tf("rebuild",Bf),projection:Tf("preserve",Nf),extentPadding:Tf("preserve",Nf),axisExtent:Tf("preserve",Nf),rExtent:Tf("preserve",Nf),oExtent:Tf("preserve",Nf),multiAxis:Tf("preserve",Nf),normalize:Tf("preserve",Nf),bins:Tf("preserve",Nf),oSort:Tf("preserve",$f),barPadding:Tf("preserve",$f),roundedTop:Tf("preserve",$f),baselinePadding:Tf("preserve",$f),innerRadius:Tf("preserve",$f),cornerRadius:Tf("preserve",$f),startAngle:Tf("preserve",$f),sweepAngle:Tf("preserve",$f),trackFill:Tf("preserve",$f),showOutliers:Tf("preserve",$f),showIQR:Tf("preserve",$f),amplitude:Tf("preserve",$f),connectorOpacity:Tf("preserve",$f),showLabels:Tf("preserve",$f),dynamicColumnWidth:Tf("rebuild",$f),customLayout:Tf("preserve",$f),layoutConfig:Tf("preserve",$f),layoutMargin:Tf("preserve",$f),symbolMap:Tf("preserve",Bf),pieceStyle:Tf("preserve",Df),summaryStyle:Tf("preserve",Df),connectorStyle:Tf("preserve",Df),gradientFill:Tf("preserve",Df),colorScheme:Tf("preserve",Df),themeCategorical:Tf("preserve",Df),themeSemantic:Tf("preserve",Df),themeSequential:Tf("preserve",Df),themeDiverging:Tf("preserve",Df),barColors:Tf("preserve",Df),decay:Tf("preserve",Df),pulse:Tf("preserve",Df),staleness:Tf("preserve",Df),layoutSelection:Tf("preserve",Df),windowSize:Tf("preserve",jf),windowMode:Tf("preserve",jf),clock:Tf("preserve",jf),transition:Tf("preserve",jf),introAnimation:Tf("preserve",jf),onLayoutError:Tf("preserve",jf)},Ff=Tf("preserve",$f),Of=class{constructor(){this.tracker=new ln}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Rf)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},_f):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Ef[o]??Ff;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as zf}from"d3-quadtree";var Hf=class{constructor(e){this.rExtent=new ne,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Of,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new vf,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=>re(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new ne)):(this.getR=re(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,n,o;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,o=this.currentTime(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:Xt(t,o):null)}currentTime(){return this.config.clock?.()??Ue()}ingest(e){const t=this.currentTime();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(),Vt(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)Ut(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=Ut(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),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 n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,o=this.scales,r=this.multiScales,i=this.columns;if(0===n.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(n,this.getR);const a=this.getBufferArray(),s=t.projection||"vertical",c=t.oExtent||this.resolveCategories(a),l=this.computeValueDomain(a,c),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=gf().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;m=bf().domain(l).range([o,n])}else u?(p=gf().domain(c).range([0,e.height]).padding(h),m=bf().domain(l).range([0,e.width])):(p=gf().domain(c).range([0,e.width]).padding(h),m=bf().domain(l).range([e.height,0]));this.scales={o:p,r:m,projection:s},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,r)=>{const i=this.rExtents[r];i.dirty&&i.recalculate(n,o);let[a,s]=i.extent;a===1/0&&(a=0,s=1);const c=s-a,l=c>0?c*(t.extentPadding??.05):1;return a-=l,s+=l,a>0&&(a=0),u?bf().domain([a,s]).range([0,e.width]):bf().domain([a,s]).range([e.height,0])}):[];let f=a;this.rAccessors.length>1&&(f=a.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(f,c,p,s,e),this._customLayoutFailedThisBuild=!1;const y=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=r,this.columns=i):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,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,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const i=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===o){const e=Math.max(50,3*r.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return i}if(!1===o)return i;if("function"==typeof o)return i.sort(o);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"===o?(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:n,projection:o,normalize:r,rExtent:i,extentPadding:a=.05,baselinePadding:s,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,p=a;if("radial"===o&&("pie"===n||"donut"===n))return[0,1];let m=0,f=0;if("bar"===n&&d&&r)m=0,f=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const o of t){const t=l(o),r=u(o);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>f&&(f=t);for(const e of n.values())m>e&&(m=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),o=u(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>f&&(f=t),m>t&&(m=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),o=Math.abs(u(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===n||"bar-funnel"===n)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 y="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(y&&null==i?.[0]&&null==i?.[1]&&(m>0&&(m=0),0>f&&(f=0)),"bar-funnel"!==n&&"exact"!==c){const e=f-m,t=e>0?e*p:1,o=y&&!s&&0===m,r=y&&!s&&0===f||"swimlane"===n;null!=i?.[0]||o||(m-=t),null!=i?.[1]||r||(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,n,o,r){return function(e){const{data:t,oExtent:n,oScale:o,projection:r,layout:i,dynamicColumnWidth:a,getO:s,getR:c}=e,l={},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"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(a&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let o;o="string"==typeof a?n.reduce((e,t)=>e+(Number(t[a])||0),0):a(n),h.set(t,o),e+=o}const t=("horizontal"===r?i.height:i.width)-o.padding()*o.step()*n.length;if(e>0)for(const[n,o]of h)h.set(n,o/e*t)}let p=0,m=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let i,a;h?(i=m,a=h.get(e)||o.bandwidth(),m+=a+o.padding()*o.step()):(i=o(e)??0,a=o.bandwidth()),l[e]={name:e,x:i,y:0,width:a,middle:i+a/2,padding:o.padding()*o.step(),pieceData:t,pct:r,pctStart:p},p+=r}return l}({data:e,oExtent:t,oScale:n,projection:o,layout:r,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.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const n=this.buildLayoutContext(e,t);let o;try{o=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=Et("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}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=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const r=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return Bt({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),o=Mf[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const a=[],{projection:s}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,a;"point"===e.type?(o=e.x,a=e.y):(o=e.x+e.w/2,a=e.y+("vertical"===s?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:o,y:a,datum:t,category:i(t)})}const l=n.o.domain(),u=o.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let o=0;n.length-1>o;o++){const r=n[o],i=n[o+1],s="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};a.push({type:"connector",x1:r.x,y1:r.y,x2:i.x,y2:i.y,style:s,datum:r.datum,group:t})}}return a}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,o=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Pf(n.colorScheme,n.themeCategorical,Fe),i=this.scales;return{data:e,scales:{o:i.o,r:i.r,projection:i.projection},dimensions:{width:t.width,height:t.height,margin:o,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:n.themeSemantic??{},categorical:[...r]},resolveColor:If(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Ze(n,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 n="function"==typeof t,o=n?null:t||"category",r=new Map;for(let i=0;e.length>i;i++){const a=e[i],s=n?t(a):a[o],c=r.get(s);c?c.push(i):r.set(s,[i])}return r}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,n=0;for(const o of e)"point"===o.type&&(t++,o.r>n&&(n=o.r));if(500>=t)return{quadtree:null,maxRadius:n};const o=Array(t);let r=0;for(const t of e)"point"===t.type&&(o[r++]=t);return{maxRadius:n,quadtree:zf().x(e=>e.x).y(e=>e.y).addAll(o)}}(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 n=t.length;if(1>=n)return;const o=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=o.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i){const a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let o=0;for(const a of r(t)??[]){const t=n.get(a);null!=t&&(o=Math.max(o,et(e,t,i)))}c=tt(l,o,a)||c;continue}if(null==l.datum)continue;const t=o.get(l.datum);if(null==t)continue;const u=n.get(t);c=tt(l,null==u?0:et(e,u,i),a,s)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&nt(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,n="horizontal"!==this.scales?.projection;let o;for(let r=0;this.scene.length>r;r++){const i=this.scene[r],a=this.getNodeKey(i,e);a&&("rect"===i.type?this.prevPositionMap.set(a,n?{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===o&&(o=i.startAngle),this.prevPositionMap.set(a,{x:i.cx,y:i.cy,startAngle:o,endAngle:o,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}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 n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(o,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.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 n=new Set,o=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],i=this.getNodeKey(r,o);if(!i)continue;r._transitionKey=i;const a=this.prevPositionMap.get(i);if("point"===r.type)a?(n.add(i),r._targetOpacity=r.style.opacity??1,(a.x!==r.x||a.y!==r.y||void 0!==a.r&&a.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=a.x,r.y=a.y,void 0!==a.r&&(r.r=a.r),t=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)a?(n.add(i),r._targetOpacity=r.style.opacity??1,a.x===r.x&&a.y===r.y&&a.w===r.w&&a.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=a.x,r.y=a.y,r.w=a.w??r.w,r.h=a.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(a)n.add(i),r._targetOpacity=r.style.opacity??1,a.startAngle===r.startAngle&&a.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=a.startAngle,r.endAngle=a.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const e=r.startAngle;r.startAngle=e,r.endAngle=e,r.style={...r.style,opacity:0},this.prevPositionMap.set(i,{x:r.cx,y:r.cy,startAngle:e,endAngle:e,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,o]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((o.startAngle??0)+(o.endAngle??0))/2,n={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=Ve(e,this.activeTransition),n=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 o=this.prevPositionMap.get(t);e.style.opacity=Xe(o?o.opacity??1:0,e._targetOpacity,n)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Xe(o.x,e._targetX,n),e.y=Xe(o.y,e._targetY,n)),void 0!==e._targetR&&void 0!==o?.r&&(e.r=Xe(o.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style.opacity=Xe(o?o.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Xe(o.x,e._targetX,n),e.y=Xe(o.y,e._targetY,n),void 0!==o.w&&(e.w=Xe(o.w,e._targetW,n),e.h=Xe(o.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style={...e.style,opacity:Xe(o?o.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Xe(o.startAngle,e._targetStartAngle,n),e.endAngle=Xe(o.endAngle,e._targetEndAngle,n))}}}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()}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),n=this.getDataId,o=e=>t.has(n(e));Kt(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=ue(e),o=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(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)),r.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),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.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.style=r?{...e,...r}: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},n=Object.keys(e).filter(n=>e[n]!==t[n]);"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&&!oe(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!oe(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!oe(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in e||"oAccessor"in e)&&(oe(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=ae(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,o=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(r=o.length!==i.length||o.some((e,t)=>!oe(e,i[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>re(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new ne)):(this.getR=re(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!oe(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?ae(this.config.stackBy):void 0),"groupBy"in e&&!oe(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?ae(this.config.groupBy):void 0),"colorAccessor"in e&&!oe(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ae(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!oe(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ae(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!oe(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?ae(this.config.connectorAccessor):void 0),(o||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};function Wf(e,t,n,o=30,r,i=0){let a=null;if(r){const e=lo(r,t,n,o,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=Gf(i,t,n);break;case"point":if(r)break;e=qf(i,t,n,o);break;case"symbol":e=Yf(i,t,n,o);break;case"glyph":e=Vf(i,t,n,o);break;case"wedge":if(null===i.datum)break;e=Xf(i,t,n);break;case"boxplot":e=Uf(i,t,n);break;case"violin":e=Kf(i,t,n)}e&&o>e.distance&&(a&&e.distance>=a.distance||(a=e))}return a}function Gf(e,t,n){const o=Un(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function qf(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>Kn(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function Yf(e,t,n,o=30){const r=t-e.x,i=n-e.y,a=Math.sqrt(r*r+i*i);return a>Kn(Lt(e.size),o)?null:{datum:e.datum,x:e.x,y:e.y,distance:a}}function Vf(e,t,n,o=30){if(null==e.datum)return null;const r=so(e.glyph,e.size),i=e.x+r.centerDx,a=e.y+r.centerDy,s=t-i,c=n-a,l=Math.sqrt(s*s+c*c);return l>Kn(r.radius,o)?null:{datum:e.datum,x:i,y:a,distance:l}}function Xf(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerRadius>i||i>e.outerRadius)return null;const a=Jn(Math.atan2(r,o)),s=Jn(e.startAngle),c=Jn(e.endAngle);if(!(s>c?a>=s||c>=a:a>=s&&c>=a))return null;const l=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(l)*u,y:e.cy+Math.sin(l)*u,distance:0,category:e.category}}function Uf(e,t,n){const o=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const r=e.y-o,i=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||r>n||n>i))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Kf(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:a}=e.bounds;return o>t||t>o+i||r>n||n>r+a?null:{datum:e.datum,x:o+i/2,y:r+a/2,distance:0,category:e.category,stats:e.stats}}rn(Hf);import{useMemo as Qf,useRef as Zf}from"react";import{Fragment as Jf,jsx as ey,jsxs as ty}from"react/jsx-runtime";function ny(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:a,showAxes:s,showGrid:c,rFormat:l}=e,{rTickValues:u,axisExtent:d}=e,h="radial"===a?.projection,p="horizontal"===a?.projection,m=Qf(()=>!a||h?[]:(u||ua(a.r,5,d)).map(e=>({value:e,pixel:a.r(e),label:(l||oy)(e)})),[a,l,h,u,d]),f=c&&a&&!h,y=s&&a&&!h;return f||y?ey("svg",{width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:ty("g",{transform:`translate(${i.left},${i.top})`,children:[f&&ey("g",{className:"ordinal-grid",children:m.map((e,o)=>ey("line",{x1:p?e.pixel:0,y1:p?0:e.pixel,x2:p?e.pixel:t,y2:p?n:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),y&&ey(Jf,{children:ty(Jf,p?{children:[ey("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ey("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[ey("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ey("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function oy(e){return Math.round(100*e)/100+""}function ry(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:a,showAxes:s,showCategoryTicks:c,oLabel:l,rLabel:u,oFormat:d,rFormat:h,showGrid:p,title:m,legend:f,legendHoverBehavior:y,legendClickBehavior:g,legendHighlightedCategory:b,legendIsolatedCategories:v,legendPosition:x="right",legendLayout:w,foregroundGraphics:k,annotations:S,onAnnotationActivate:A,onObservation:C,chartId:M,chartType:P,autoPlaceAnnotations:I,svgAnnotationRules:R,xAccessor:_,yAccessor:T,annotationData:L,underlayRendered:N,canvasObscuresUnderlay:$=!0,children:B}=e,D=bi({onAnnotationActivate:A,onObservation:C,chartId:M,chartType:P}),j="radial"===a?.projection,E="horizontal"===a?.projection,F=!1!==c,O=!N||$,z=Qf(()=>{if(!s||!F||!a||j)return[];const e=a.o.bandwidth(),t=a.o.domain().map((t,n)=>({value:t,pixel:(a.o(t)??0)+e/2,label:d?d(t,n):t}));if(2>=t.length)return t;const n=Math.abs(t[1].pixel-t[0].pixel)||e,o=t.map(e=>{return t=e.label,E?"string"==typeof t||"number"==typeof t?16:24:"string"==typeof t||"number"==typeof t?6.5*(t+"").length:60;var t}),r=E?0:6;if(o.every((e,t)=>0===t||n>=(o[t-1]+e)/2+r))return t;const i=Math.max(...o)+r,c=Math.max(1,Math.ceil(i/n));return 1===c?t:t.filter((e,t)=>t%c===0)},[s,F,a,d,j,E]),H=e.rTickValues,W=e.tickLabelEdgeAlign,G=e.axisExtent,q=Qf(()=>s&&a&&!j?(H||ua(a.r,5,G)).map(e=>({value:e,pixel:a.r(e),label:(h||oy)(e)})):[],[s,a,h,j,H,G]),Y=Zf(new Map),V=Zf(S?.length??0),X=S?.length??0;V.current!==X&&(V.current=X,Y.current=new Map);const U=Qf(()=>{if(!S||0===S.length)return null;const e=_i(0,D),o="horizontal"===a?.projection,r=a?.o?e=>(a.o(e)??0)+a.o.bandwidth()/2:null,i={scales:a?{x:o?a.r:r||a.r,y:o&&r||a.r,time:a.r,value:a.r,o:a.o}:null,timeAxis:"x",xAccessor:_,yAccessor:T,width:t,height:n,data:L,frameType:"ordinal",projection:o?"horizontal":"vertical",stickyPositionCache:Y.current};return Ri(I?Zi({annotations:S,context:i,..."object"==typeof I?I:{}}):S,e,R,i)},[S,I,R,t,n,a,_,T,L,D]);return s||m||f||k||U&&U.length>0||p||B?ty("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[ey("title",{children:"string"==typeof m?m:"Ordinal Chart"}),ey("desc",{children:"string"==typeof m?m+" — ordinal data visualization":"Ordinal data visualization"}),ty("g",{transform:`translate(${i.left},${i.top})`,children:[p&&a&&!j&&O&&ey("g",{className:"ordinal-grid",children:q.map((e,o)=>ey("line",{x1:E?e.pixel:0,y1:E?0:e.pixel,x2:E?e.pixel:t,y2:E?n:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),s&&a&&!j&&(()=>{const e={fontSize:"var(--semiotic-tick-font-size, 12px)"},o={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return ey("g",{className:"ordinal-axes",children:ty(Jf,E?{children:[ty("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[O&&ey("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),z.map((t,n)=>ty("g",{transform:`translate(0,${t.pixel})`,children:[ey("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ey("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):ey("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:ey("div",{style:{textAlign:"right",userSelect:"none",...e},children:t.label})})]},"cat-"+n)),l&&ey("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:l})]}),ty("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[O&&ey("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),O&&a?.r&&(()=>{const e=a.r(0);return e>1&&t-1>e?ey("line",{x1:e,y1:0,x2:e,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),q.map((t,o)=>{const r=W?0===o?"start":o===q.length-1?"end":"middle":"middle";return ty("g",{transform:`translate(${t.pixel},${n})`,children:[ey("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ey("text",{y:18,textAnchor:r,fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label})]},"val-"+o)}),u&&ey("text",{x:t/2,y:n+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:{userSelect:"none",...o},children:u})]})]}:{children:[ty("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[O&&(()=>{const e=a?.r?a.r(0):n,o=0>e||e>n?n:e;return ey("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),z.map((t,o)=>ty("g",{transform:`translate(${t.pixel},${n})`,children:[ey("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?ey("text",{y:18,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):ey("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:ey("div",{style:{textAlign:"center",userSelect:"none",...e},children:t.label})})]},"cat-"+o)),l&&ey("text",{x:t/2,y:n+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:{userSelect:"none",...o},children:l})]}),ty("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[O&&ey("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),q.map((t,n)=>ty("g",{transform:`translate(0,${t.pixel})`,children:[ey("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),ey("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-"+n)),u&&ey("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:u})]})]})})})(),U,k,B]}),m&&"string"==typeof m?ey("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?ey("foreignObject",{x:0,y:0,width:o,height:i.top,children:m}):null,Mr({legend:f,totalWidth:o,totalHeight:r,margin:i,legendPosition:x,title:m,legendLayout:w,legendHoverBehavior:y,legendClickBehavior:g,legendHighlightedCategory:b,legendIsolatedCategories:v})]}):null}import{useRef as iy,useEffect as ay}from"react";import{select as sy}from"d3-selection";import{brushX as cy,brushY as ly}from"d3-brush";import{jsx as uy,jsxs as dy}from"react/jsx-runtime";function hy({width:e,height:t,totalWidth:n,totalHeight:o,margin:r,scales:i,onBrush:a}){const s=iy(null),c=iy(null),l=iy(a);l.current=a;const u=iy(i);u.current=i;const d=iy(!1),h=iy(null),p="horizontal"===i?.projection,m=iy(p);m.current=p;const f=R({label:"Ordinal value range brush",onAction:e=>{const t=u.current,n=c.current;if(!t||!n||!s.current)return;const o=sy(s.current).select(".brush-g");if("clear"===e.type)return d.current=!0,o.call(n.move,null),d.current=!1,h.current=null,void l.current(null);if(("left"===e.direction||"right"===e.direction)!=!!m.current)return;const r=t.r.domain(),[i,a]=[Math.min(...r),Math.max(...r)],p=(a-i)/20,f=h.current?.r??[i+.4*(a-i),i+.6*(a-i)],y="left"===e.direction||"down"===e.direction?-1:1;let[g,b]=f;if(e.resize)0>y?g=Math.max(i,g-p):b=Math.min(a,b+p);else{const e=b-g;g=Math.max(i,Math.min(a-e,g+y*p)),b=g+e}const v={r:[g,b]};d.current=!0,o.call(n.move,m.current?[t.r(g),t.r(b)]:[t.r(b),t.r(g)]),d.current=!1,h.current=v,l.current(v)}});return ay(()=>{if(!s.current)return;const n=sy(s.current).select(".brush-g"),o=p?cy():ly();return o.extent([[0,0],[e,t]]),o.on("brush end",e=>{if(d.current)return;const t=u.current;if(!t)return;if(!e.selection)return h.current=null,void l.current(null);const[n,o]=e.selection;let r;r=m.current?[t.r.invert(n),t.r.invert(o)]:[t.r.invert(o),t.r.invert(n)];const i={r:r};h.current=i,l.current(i)}),n.call(o),c.current=o,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),c.current=null}},[e,t,p]),ay(()=>{if(!i||!c.current||!h.current)return;if(!s.current)return;const e=h.current,t=sy(s.current).select(".brush-g"),n=i.r(e.r[0]),o=i.r(e.r[1]);p?(d.current=!0,t.call(c.current.move,[n,o]),d.current=!1):(d.current=!0,t.call(c.current.move,[o,n]),d.current=!1)},[i,p]),dy("svg",{ref:s,width:n,height:o,...f.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[uy("title",{children:f.svgProps["aria-label"]}),uy("desc",{id:f.descriptionId,children:f.description}),uy("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`,style:{pointerEvents:"all"}})]})}import{arc as py}from"d3-shape";function my(e,t){const n=t._gradientBand.colors;if(0===n.length)return;const{clipPath:o,slices:r}=Ra({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:n}),i=new Path2D(o);e.save(),e.translate(t.cx,t.cy),e.clip(i);for(const t of r)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 fy(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 yy(e,t){const n={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},o=py().cornerRadius(t.cornerRadius)(n);if(!o)return;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()}var gy=(e,t,n,o)=>{const r=t.filter(e=>"wedge"===e.type);for(const t of r)if(e.globalAlpha=(t.style.fillOpacity??1)*(t.style.opacity??1),t._gradientBand&&t._gradientBand.colors.length>0)my(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(fy(e,t),ol(e,t)),e.globalAlpha=1;else{if(e.fillStyle=Eo(e,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 n=Ia({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 o=new Path2D(n);e.fill(o),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(o),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),yy(e,t)):(fy(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&&(fy(e,t),ol(e,t)),e.globalAlpha=1}},by=(e,t,n,o)=>{const r=t.filter(e=>"boxplot"===e.type);for(const t of r){const n=t.columnWidth/2,o="vertical"===t.projection,r=go(e,"var(--semiotic-primary, #007bff)"),i=go(e,"var(--semiotic-text, #333)"),a=Eo(e,t.style.fill,r),s=t.style.stroke,c="string"==typeof s?go(e,s)||s:i,l=t.style.strokeWidth||1,u=t.style.fillOpacity??t.style.opacity??.6;if(e.save(),e.strokeStyle=c,e.lineWidth=l,e.beginPath(),o?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=u,e.fillStyle=a,o){const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,r),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,r)}else{const o=Math.min(t.q1Pos,t.q3Pos),r=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,r,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,r,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},vy=(e,t,n,o)=>{const r=t.filter(e=>"violin"===e.type);for(const t of r){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const n=new Path2D(t.pathString);if(e.globalAlpha=t.style.fillOpacity??t.style.opacity??.6,e.fillStyle=Eo(e,t.style.fill,"#007bff"),e.fill(n),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(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},xy=(e,t,n,o)=>{const r=t.filter(e=>"connector"===e.type);if(0===r.length)return;const i=new Map;for(const e of r){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 n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=n.fillOpacity??n.opacity??.3,e.fillStyle=Fo(e,n.fill)??"#999",e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=go(e,n.style.stroke)||Eo(e,n.style.fill,"")||go(e,"var(--semiotic-border, #999)"),e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=n.style.opacity??.5,e.stroke(),e.globalAlpha=1}},wy=(e,t,n,o)=>{const r=t.filter(e=>"trapezoid"===e.type);for(const t of r){const n=t.points;if(n.length>=4){e.globalAlpha=t.style?.opacity??1,e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;n.length>t;t++)e.lineTo(n[t][0],n[t][1]);e.closePath(),e.fillStyle=Fo(e,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 ky(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 Sy(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}var Ay=new Map;function Cy(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=Ay.get(n);if(void 0!==o)return o;const r=xo({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Ay.set(n,r),r}function My(e,t,n,o,r,i){e.moveTo(t+i,n),e.lineTo(t+o-i,n),e.quadraticCurveTo(t+o,n,t+o,n+i),e.lineTo(t+o,n+r-i),e.quadraticCurveTo(t+o,n+r,t+o-i,n+r),e.lineTo(t+i,n+r),e.quadraticCurveTo(t,n+r,t,n+r-i),e.lineTo(t,n+i),e.quadraticCurveTo(t,n,t+i,n),e.closePath()}function Py(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 Iy(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}function Ry(e){return"rect"===e.type||"point"===e.type||"symbol"===e.type||"glyph"===e.type}function _y(e){return(t,n,o,r)=>{e(t,n.filter(Ry),{x:o.r,y:o.r},r)}}var Ty=_y(yl),Ly=_y(cl),Ny=_y(dl),$y=_y(pl),By=e=>[xy,...e],Dy={bar:By([Ty]),clusterbar:By([Ty]),point:By([Ly,Ny]),swarm:By([Ly,Ny]),pie:[gy],donut:[gy],boxplot:By([by,Ly]),violin:By([vy]),histogram:By([Ty]),ridgeline:By([vy]),timeline:By([Ty]),funnel:[Ty,wy,(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==r.length&&r.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 r){const n=t.datum;if(!n)continue;if(!n.__funnelStepLabel)continue;const o=n.__funnelStepLabel;if(e.measureText(o).width+16>(n.__funnelRowWidth??n.__funnelBarW??0))continue;const r=n.__funnelStepLabelX,i=n.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(o,r,i),e.fillStyle="#fff",e.fillText(o,r,i)}e.font="bold 13px sans-serif";for(const t of r){const n=t.datum;if(!n)continue;if(null==n.__funnelValueLabelX)continue;const o=n.__funnelBarW??0;if(60>o)continue;const r=n.__funnelValue;if(null==r||0===r)continue;const i=n.__funnelPercent,a=!0===n.__funnelIsFirstStep;let s;if(s=a?ky(r):null!=i?`${ky(r)} (${Sy(i)})`:ky(r),e.measureText(s).width+16>o){if(a||null==i)continue;if(s=ky(r),e.measureText(s).width+16>o)continue}const c=n.__funnelValueLabelX,l=(n.__funnelValueLabelY??t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(s,c,l),e.fillStyle="#fff",e.fillText(s,c,l)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[Ty,(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type&&!0===e.datum?.__barFunnelIsDropoff);for(const t of r){const n=("string"==typeof t.style.fill?t.style.fill:null)||go(e,"var(--semiotic-border, #999)"),o=Cy(n,e);e.globalAlpha=t.style.opacity??1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),o?e.fillStyle=o:(e.fillStyle=n,e.globalAlpha=.4*(t.style.opacity??1)),e.fill(),e.globalAlpha=1}},(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type&&!0!==e.datum?.__barFunnelIsDropoff&&null!=e.datum?.__barFunnelLabelX);if(0===r.length)return;const i=function(e,t){const[n,o,r]=bo(e,t);return(.2126*n+.7152*o+.0722*r)/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)",c=i?"#f3f4f6":"#1a1a1a",l=c;for(const t of r){const n=t.datum;if(!n)continue;const o=n.__barFunnelValue;if(null==o)continue;if(25>t.w)continue;const r=n.__barFunnelPercent,i=!(!0===n.__barFunnelIsFirstStep)&&null!=r,u=i?Iy(r):"",d=Py(o);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,y=n.__barFunnelLabelX,g=y-m/2,b=n.__barFunnelLabelY-f-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=a,e.beginPath(),My(e,g,b,m,f,4),e.fill(),e.restore(),e.strokeStyle=s,e.lineWidth=.5,e.beginPath(),My(e,g,b,m,f,4),e.stroke(),e.textAlign="center",e.textBaseline="top",i?(e.font="bold 13px sans-serif",e.fillStyle=c,e.fillText(u,y,b+3),e.font="11px sans-serif",e.fillStyle=l,e.fillText(d,y,b+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=c,e.fillText(d,y,b+3))}e.lineWidth=1}],swimlane:By([Ty]),custom:By([Ty,Ly,Ny,$y,gy,by,vy,wy])};import{jsx as jy,jsxs as Ey}from"react/jsx-runtime";function Fy(e){const t=Zs(e,{skipPositional:!1});return null==t.title&&0===t.entries.length?null:Ey("div",{className:"semiotic-tooltip",style:tc,children:[null!=t.title&&jy("div",{style:{fontWeight:"bold"},children:t.title+""}),t.entries.map(e=>Ey("div",{children:[Ey("span",{style:{opacity:.7},children:[e.key,":"]})," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]},e.key))]})}function Oy({hover:e}){const t=e.data||{},n=e.stats,o=e.category;if(Array.isArray(t)){const e=o||t[0]?.category||"";if(n)return Ey("div",{className:"semiotic-tooltip",style:tc,children:[e&&jy("div",{style:{fontWeight:"bold"},children:e+""}),Ey("div",{children:["n = ",n.n]}),Ey("div",{children:["Min: ",n.min.toLocaleString()]}),Ey("div",{children:["Q1: ",n.q1.toLocaleString()]}),Ey("div",{children:["Median: ",n.median.toLocaleString()]}),Ey("div",{children:["Q3: ",n.q3.toLocaleString()]}),Ey("div",{children:["Max: ",n.max.toLocaleString()]}),Ey("div",{style:{opacity:.8},children:["Mean: ",n.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const r=t.length;return Ey("div",{className:"semiotic-tooltip",style:tc,children:[e&&jy("div",{style:{fontWeight:"bold"},children:e+""}),Ey("div",{children:[r," items"]})]})}if(null!=t.bin&&null!=t.count){const e=t.range||[];return Ey("div",{className:"semiotic-tooltip",style:tc,children:[t.category&&jy("div",{style:{fontWeight:"bold"},children:t.category+""}),Ey("div",{children:["Count: ",t.count]}),2===e.length&&Ey("div",{style:{opacity:.8},children:[Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)]})]})}const r=e.__oAccessor,i=e.__rAccessor,a=e.__chartType;if("swarm"===a||"point"===a)return Fy(t);const s=(r&&null!=t[r]?t[r]:null)||t.category||t.name||t.group||t.__rName||"",c=t.__aggregateValue??(i&&null!=t[i]?t[i]:null)??t.value??t.__rValue??t.pct??"";return s||""!==c?Ey("div",{className:"semiotic-tooltip",style:tc,children:[s&&jy("div",{style:{fontWeight:"bold"},children:s+""}),""!==c&&jy("div",{children:"number"==typeof c?c.toLocaleString():c+""})]}):Fy(t)}Oy.ownsChrome=!0;import{jsx as zy,jsxs as Hy}from"react/jsx-runtime";var Wy={top:50,right:40,bottom:60,left:70},Gy=yf(ff(function(e,t){const{chartType:n,runtimeMode:o,data:r,oAccessor:i="category",rAccessor:a="value",colorAccessor:s,symbolAccessor:c,symbolMap:l,stackBy:d,groupBy:h,multiAxis:p,timeAccessor:m,valueAccessor:f,categoryAccessor:y,accessorRevision:g,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:R,normalize:_,startAngle:T,sweepAngle:L,dynamicColumnWidth:N,bins:$,showOutliers:B,showIQR:j,amplitude:E,connectorOpacity:F,showLabels:O,connectorAccessor:z,connectorStyle:H,dataIdAccessor:W,rExtent:G,oExtent:q,extentPadding:V=.05,oSort:X,windowMode:U="sliding",windowSize:K=200,pieceStyle:Q,summaryStyle:Z,renderMode:J,colorScheme:ee,barColors:te,showAxes:ne=!0,showCategoryTicks:oe,categoryLabel:re,valueLabel:ie,categoryFormat:ae,valueFormat:se,oLabel:ce,rLabel:le,oFormat:ue,rFormat:de,rTickValues:he,tickLabelEdgeAlign:pe,axisExtent:me,enableHover:fe=!0,hoverAnnotation:ye,tooltipContent:ge,customHoverBehavior:be,customClickBehavior:ve,onObservation:xe,annotationObservationCallback:we,chartId:ke,annotations:Se,onAnnotationActivate:Ae,autoPlaceAnnotations:Ce,svgAnnotationRules:Me,showGrid:Pe=!1,legend:Ie,legendHoverBehavior:Re,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Le,legendPosition:Ne,legendLayout:$e,legendCategoryAccessor:Be,onCategoriesChange:De,backgroundGraphics:je,foregroundGraphics:Ee,title:Fe,className:Oe,background:ze,centerContent:He,decay:We,pulse:Ge,transition:qe,animate:Ye,staleness:Ve,frameScheduler:Xe,clock:Ue,random:Ke,seed:Qe,paused:Ze=!1,suspendWhenHidden:Je=!0,brush:et,onBrush:tt,accessibleTable:nt=!0,description:ot,summary:rt,customLayout:it,onLayoutError:at,layoutConfig:st,layoutSelection:ct}=e,{customHoverBehavior:lt,customClickBehavior:ut,hasClickBehavior:dt}=Vl({customHoverBehavior:be,customClickBehavior:ve,onObservation:xe,chartId:ke,chartType:"StreamOrdinalFrame"}),ht=y??i,pt=f??a,mt=lf(!0),ft=Tc({sizeProp:v,responsiveWidth:x,responsiveHeight:w,userMargin:k,marginDefault:Wy,title:Fe,legend:Ie,legendPosition:Ne,animate:Ye,transitionProp:qe,frameScheduler:Xe,clock:Ue,random:Ke,seed:Qe,paused:Ze,suspendWhenHidden:Je,themeDirtyRef:mt}),{reducedMotionRef:yt,responsiveRef:gt,size:bt,margin:vt,adjustedWidth:xt,adjustedHeight:wt,currentTheme:kt,transition:St,introEnabled:At,tableId:Ct,rafRef:Mt,renderFnRef:Pt,scheduleRender:It,frameRuntime:Rt}=ft,_t=qa(),Tt=Ua(),Lt=hf(()=>u(r),[r]),Nt=re??ce,$t=ie??le,Bt=ae??ue,Dt=se??de,jt=lf(null),[Et,Ft]=uf(null),[Ot,zt]=uf(null),Ht=Ec(Ee,bt,vt,Ot),Wt=Ec(je,bt,vt,Ot),Gt=je||"transparent"===ze?null:zy("rect",{className:"semiotic-canvas-background","data-semiotic-layer":"canvas-background",x:-vt.left,y:-vt.top,width:bt[0],height:bt[1],fill:ze||"var(--semiotic-bg, transparent)"}),[qt,Yt]=uf(0),Vt=lf(0),[Xt,Ut]=uf(!1),Kt=lf({w:-1,h:-1}),Qt=lf(!1),Zt=Dn("StreamOrdinalFrame"),Jt=fe||ye,en="streaming"===o,tn=Qa(hf(()=>({chartType:n,runtimeMode:en?"streaming":"bounded",windowSize:K,windowMode:U,extentPadding:V,projection:b,oAccessor:en?void 0:ht,rAccessor:en?void 0:pt,accessorRevision:g,colorAccessor:s,symbolAccessor:c,symbolMap:l,stackBy:d,groupBy:h,multiAxis:p,timeAccessor:en?m:void 0,valueAccessor:en?f||("string"==typeof pt||"function"==typeof pt?pt:void 0):void 0,categoryAccessor:en?ht:void 0,rExtent:G,oExtent:q,axisExtent:me,barPadding:S,roundedTop:A,gradientFill:C,trackFill:M,baselinePadding:P,innerRadius:I,cornerRadius:R,normalize:_,startAngle:T,sweepAngle:L,dynamicColumnWidth:N,bins:$,showOutliers:B,showIQR:j,amplitude:E,connectorOpacity:F,showLabels:O,connectorAccessor:z,connectorStyle:H,dataIdAccessor:W,oSort:X,pieceStyle:Q,summaryStyle:Z,colorScheme:ee,themeCategorical:kt?.colors?.categorical,themeSemantic:Y(kt),themeSequential:kt?.colors?.sequential,themeDiverging:kt?.colors?.diverging,barColors:te,decay:We,pulse:Ge,transition:St,introAnimation:At,staleness:Ve,clock:Rt.now,customLayout:it,onLayoutError:at,layoutConfig:st,layoutMargin:vt}),[n,en,K,U,V,b,ht,pt,g,s,c,l,d,h,p,m,f,G,q,me,S,A,C,M,P,I,R,_,T,L,N,$,B,j,E,F,O,z,H,W,X,Q,Z,ee,kt,te,We,Ge,St,At,Ve,Rt.now,it,at,st,vt])),nn=lf(null);nn.current||(nn.current=new Hf(tn));const on=Wc(nn,Be,De,e=>e.getData());Vn(nn,tn,mt,It),Xn(nn,ct,mt,It);const rn=lf(null);rn.current||(rn.current=new D(e=>{const t=nn.current;t&&t.ingest(e)&&(mt.current=!0,It())}));const an=pf(e=>{rn.current?.push(e)},[]),sn=pf(e=>{rn.current?.pushMany(e)},[]),cn=pf(()=>{rn.current?.clear(),nn.current?.clear(),mt.current=!0,It()},[It]),ln=pf(e=>{rn.current?.clearLastData(),rn.current?.setReplacementData(e)},[]);mf(t,()=>({push:an,pushMany:sn,replace:ln,remove:e=>{rn.current?.flush();const t=nn.current?.remove(e)??[];if(t.length>0){const e=jt.current?.data;!!jt.current&&t.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(jt.current=null,Ft(null)),mt.current=!0,It()}return t},update:(e,t)=>{rn.current?.flush();const n=nn.current?.update(e,t)??[];return n.length>0&&(mt.current=!0,It()),n},clear:cn,getData:()=>(rn.current?.flush(),nn.current?.getData()??[]),getScales:()=>nn.current?.scales??null,getCustomLayout:()=>nn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>nn.current?.lastCustomLayoutFailure??null}),[an,sn,ln,cn,It]),df(()=>{r&&rn.current?.setBoundedData(Lt)},[r,Lt]);const{canvasRef:un}=Bc(ft,{storeRef:nn,dirtyRef:mt,hydrated:_t,wasHydratingFromSSR:Tt,cleanup:()=>rn.current?.clear(),canvasPaintDependencies:[n,xt,wt,ne,ze,je,J,It]}),{hoverHandlerRef:dn,hoverLeaveRef:hn,onPointerMove:pn,onPointerLeave:mn}=ft;dn.current=e=>{if(!Jt)return;const t=un.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-vt.left,i=e.clientY-o.top-vt.top;if(0>r||r>xt||0>i||i>wt)return void(jt.current&&(jt.current=null,Ft(null),lt&&lt(null),It()));const a=nn.current;if(!a||0===a.scene.length)return;const s="radial"===b,c=Wf(a.scene,s?r-xt/2:r,s?i-wt/2:i,30,a.pointQuadtree,a.maxPointRadius);if(!c)return void(jt.current&&(jt.current=null,Ft(null),lt&&lt(null),It()));const l=Ys(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof ht?ht:void 0,__rAccessor:"string"==typeof pt?pt:void 0,__chartType:n});jt.current=l,Ft(l),lt&&(lt(l),mt.current=!0),It()},hn.current=()=>{jt.current&&(jt.current=null,Ft(null),lt&&(lt(null),mt.current=!0),It())};const fn=pf(e=>{if(wi(e.target))return;if(!ut)return;const t=un.current;if(!t)return ut(null),mt.current=!0,void It();const o=t.getBoundingClientRect(),r=e.clientX-o.left-vt.left,i=e.clientY-o.top-vt.top;if(0>r||r>xt||0>i||i>wt)return ut(null),mt.current=!0,void It();const a=nn.current;if(!a||0===a.scene.length)return ut(null),mt.current=!0,void It();const s="radial"===b,c=Wf(a.scene,s?r-xt/2:r,s?i-wt/2:i,30,a.pointQuadtree,a.maxPointRadius);if(!c)return ut(null),mt.current=!0,void It();ut(Ys(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof ht?ht:void 0,__rAccessor:"string"==typeof pt?pt:void 0,__chartType:n}),{type:"activate",inputType:Hl(e.nativeEvent.pointerType)}),mt.current=!0,It()},[ut,un,vt.left,vt.top,xt,wt,b,ht,pt,n,It]),{kbFocusIndexRef:yn,focusedNavPointRef:gn,onKeyDown:bn}=function({chartType:e,oAccessor:t,rAccessor:n,...o}){return ru({...o,extractPoints:tu,toHover:o=>({...ou(o),__oAccessor:"string"==typeof t?t:void 0,__rAccessor:"string"==typeof n?n:void 0,__chartType:e})})}({storeRef:nn,hoverRef:jt,setHoverPoint:Ft,customHoverBehavior:lt,customClickBehavior:ut,scheduleRender:It,chartType:n,oAccessor:ht,rAccessor:pt}),vn=pf(e=>{yn.current=-1,gn.current=null,pn(e)},[gn,yn,pn]);Pt.current=()=>{if(Mt.current=null,!Rt.isActive)return;const e=un.current;if(!e)return;const t=e.getContext("2d");if(!t)return;const o=nn.current;if(!o)return;const r=Rt.now(),i=o.advanceTransition(yt.current?r+1e6:r),a=!yt.current&&i,s=Kt.current.w!==xt||Kt.current.h!==wt,c=mt.current;let l=!1;const u=Zt.current.beforeCompute(o.getLastUpdateResult(),a);!c&&!s||a&&!s||(o.computeScene({width:xt,height:wt}),Kt.current={w:xt,h:wt},l=!0,on()),Zt.current.afterCompute(u,l,s),mt.current=c&&a&&!l;const d=jc(o,r,l,Qt);(l||a)&&e.setAttribute("aria-label",ws(o.scene,n+" chart"));const h=Oc(),p=bt[0]*h,m=bt[1]*h;e.width===p&&e.height===m||(e.width=p,e.height=m,e.style.width=bt[0]+"px",e.style.height=bt[1]+"px"),t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,bt[0],bt[1]);const f=Ve&&o.lastIngestTime>0&&r-o.lastIngestTime>(Ve?.threshold??5e3);f&&(t.globalAlpha=Ve?.dimOpacity??.5);const y="radial"===b;t.save(),t.beginPath(),t.rect(vt.left,vt.top,xt,wt),t.clip(),y?(t.save(),t.translate(vt.left+xt/2,vt.top+wt/2)):t.translate(vt.left,vt.top);const g=it?Dy.custom:Dy[n]||[],v={width:xt,height:wt},x=o.scales;x&&Ml({context:t,nodes:o.scene,renderMode:J,pixelRatio:h,paintBuiltIn:e=>{for(const n of g)n(t,e,x,v)}}),y&&t.restore(),t.restore(),f&&(t.globalAlpha=1),l&&o.scales?(zt(o.scales),Yt(e=>e+1),Vt.current=r):a&&o.scales&&r-Vt.current>=33&&(Yt(e=>e+1),Vt.current=r),Ve?.showBadge&&Ut(!!f),(a||null!=o.activeTransition||d.pending)&&It()},cr(Ve,nn,mt,It,Xt,Ut);const xn=Jt&&Et?ge?ge(Et):zy(Oy,{hover:Et}):null,wn="radial"===b,kn=xn?zy(lc,{x:Et?wn?Et.x+xt/2:Et.x:0,y:Et?wn?Et.y+wt/2:Et.y:0,containerWidth:xt,containerHeight:wt,margin:vt,className:"stream-ordinal-tooltip",children:xn}):null,Sn="horizontal"===b?ht:pt,An=Gc("horizontal"===b?pt:ht,void 0,"__semiotic_resolvedO",""),Cn=Gc(Sn,void 0,"__semiotic_resolvedR",""),Mn=An.key,Pn=Cn.key,In=qc(An,Cn,Se&&Se.length>0||!1);if(Ea||!_t&&Tt){const e=nn.current;e&&r&&(e.ingest({inserts:Lt,bounded:!0}),e.computeScene({width:xt,height:wt}));const t=e?.scene??[],n=e?.scales??null,o=Ec(Ee,bt,vt,n),i=Ec(je,bt,vt,n),a="radial"===b,s=a?vt.left+xt/2:vt.left,c=a?vt.top+wt/2:vt.top;return Hy("div",{ref:gt,className:"stream-ordinal-frame"+(Oe?" "+Oe:""),role:"img","aria-label":ot||("string"==typeof Fe?Fe:"Ordinal chart"),style:{position:"relative",width:x?"100%":bt[0],height:w?"100%":bt[1]},children:[zy(Es,{summary:rt}),Hy("svg",{xmlns:"http://www.w3.org/2000/svg",width:bt[0],height:bt[1],style:{position:"absolute",left:0,top:0},children:[i&&zy("g",{transform:`translate(${vt.left},${vt.top})`,children:i}),Hy("g",{transform:`translate(${s},${c})`,children:[ze&&zy("rect",{x:0,y:0,width:xt,height:wt,fill:ze}),t.map((e,t)=>Pl({node:e,index:t,renderMode:J,fallback:()=>function(e,t,n){const o=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${o}-${t}-${n}`,i=`ord-${e.type}-${o}-${t}`;switch(e.type){case"rect":{const t=e,n=Da(i)+"-grad",o=function(e,t){const n=e.fillGradient;if(!n)return null;let o=e.x,r=e.y,i=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(o=e.x+e.w,r=e.y,i=e.x,a=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,i=e.x+e.w,a=e.y);const s=[];if("colorStops"in n){const e=n.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(_a("stop",{offset:e[t].offset,stopColor:e[t].color},t))}else{const t=Na(e.style.fill);s.push(_a("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),s.push(_a("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return _a("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:i,y2:a,children:s})}(t,n);let r,a;if(o)a=`url(#${n})`;else if(So(t.style.fill)){const e=Da(i)+"-hatch";r=Mo(t.style.fill,e),a=`url(#${e})`}else a=Na(t.style.fill);const s=o||r?Ta("defs",{children:[o,r]}):null;if(t.cornerRadii&&Ca(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:o,h:r}=e,{tl:i,tr:a,br:s,bl:c}=Ma(e);let l=`M${t+i},${n}`;return l+=` L${t+o-a},${n}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+o},${n+a}`),l+=` L${t+o},${n+r-s}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+o-s},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+i}`,i>0&&(l+=` A${i},${i} 0 0 1 ${t+i},${n}`),l+=" Z",l}(t);return Ta(Sa.Fragment,{children:[s,_a("path",{d:e,fill:a,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:n,y:o,w:r,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n},${o+c} Z`;break;case"left":l=`M${n+r},${o} L${n+e},${o} A${e},${e} 0 0 0 ${n},${o+e} L${n},${o+c-e} A${e},${e} 0 0 0 ${n+e},${o+c} L${n+r},${o+c} Z`;break;case"bottom":l=`M${n},${o} L${n+r},${o} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n+e},${o+c} A${e},${e} 0 0 1 ${n},${o+c-e} Z`;break;default:l=`M${n},${o+c} L${n},${o+e} A${e},${e} 0 0 1 ${n+e},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c} Z`}return Ta(Sa.Fragment,{children:[s,_a("path",{d:l,fill:a,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return Ta(Sa.Fragment,{children:[s,_a("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:a,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}case"point":{const t=e;return _a("circle",{cx:t.x,cy:t.y,r:t.r,fill:Na(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return $a(e,t,n);case"glyph":return Ba(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){const e=Da(`${n?n+"-":""}gauge-grad-${o.category||i}-${t}`),{clipPath:r,slices:a}=Ra({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return Ta("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[_a("defs",{children:_a("clipPath",{id:e,children:_a("path",{d:r})})}),_a("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>_a("path",{d:e.d,fill:Na(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&_a("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},i)}let r;if(o.roundedEnds)r=Ia({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const e=Aa().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(La)||""}return _a("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Na(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},i)}case"boxplot":{const t=e,n=t.columnWidth/2;return Ta("g","vertical"===t.projection?{children:[_a("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Na(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),_a("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[_a("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Na(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),_a("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),_a("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},i)}case"violin":{const t=e,n=[_a("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Na(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,i=e.y+e.height/2;e.height>e.width?n.push(_a("line",{x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),_a("circle",{cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push(_a("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),_a("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return _a("g",{children:n},i)}case"connector":return _a("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,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return _a("polygon",{points:n,fill:Na(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)]})]}),zy(ry,{width:xt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:n,showAxes:ne,showCategoryTicks:oe,oLabel:Nt,rLabel:$t,oFormat:Bt,rFormat:Dt,rTickValues:he,tickLabelEdgeAlign:pe,axisExtent:me,showGrid:Pe,title:Fe,legend:Ie,legendHoverBehavior:Re,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Le,legendPosition:Ne,legendLayout:$e,foregroundGraphics:Fn(o,Gn(nn.current?.customLayoutOverlays,ct??null)),annotations:Se,onAnnotationActivate:Ae,onObservation:we??xe,chartId:ke,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:Ce,svgAnnotationRules:Me,annotationFrame:0,xAccessor:Mn,yAccessor:Pn,annotationData:In(e?.getData())}),He&&"radial"===b&&zy("div",{style:{position:"absolute",left:vt.left+xt/2,top:vt.top+wt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:He})]})}return Hy("div",{ref:gt,className:"stream-ordinal-frame"+(Oe?" "+Oe:""),role:"group","aria-label":ot||("string"==typeof Fe?Fe:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:x?"100%":bt[0],height:w?"100%":bt[1],overflow:"visible"},onKeyDown:bn,children:["production"!==process.env.NODE_ENV&&nn.current&&zy(jn,{store:nn.current,diagnostics:Zt.current}),nt&&zy(Fs,{tableId:Ct}),nt&&zy(Ds,{scene:nn.current?.scene??[],chartType:n+" chart",tableId:Ct,chartTitle:"string"==typeof Fe?Fe:void 0}),zy(Es,{summary:rt}),zy(ms,{hoverPoint:Et}),Hy("div",{role:"img","aria-label":ot||("string"==typeof Fe?Fe:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Jt?vn:void 0,onMouseLeave:Jt?mn:void 0,onClick:dt?fn:void 0,children:[Hy(Dc,{size:bt,margin:vt,children:[Gt,Wt]}),zy(ny,{width:xt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:Ot,showAxes:ne,showGrid:Pe,rFormat:Dt,rTickValues:he,axisExtent:me}),zy("canvas",{ref:un,"aria-label":ws(nn.current?.scene??[],n+" chart"),style:{position:"absolute",top:0,left:0,width:bt[0],height:bt[1]}}),zy(ry,{width:xt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:Ot,showAxes:ne,showCategoryTicks:oe,oLabel:Nt,rLabel:$t,oFormat:Bt,rFormat:Dt,rTickValues:he,axisExtent:me,showGrid:Pe,title:Fe,legend:Ie,legendHoverBehavior:Re,legendClickBehavior:_e,legendHighlightedCategory:Te,legendIsolatedCategories:Le,legendPosition:Ne,legendLayout:$e,foregroundGraphics:Fn(Ht,Gn(nn.current?.customLayoutOverlays,ct??null)),annotations:Se,onAnnotationActivate:Ae,onObservation:we??xe,chartId:ke,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:Ce,svgAnnotationRules:Me,annotationFrame:qt,xAccessor:Mn,yAccessor:Pn,annotationData:In(nn.current?.getData()),underlayRendered:!0,canvasObscuresUnderlay:!1}),(et||tt)&&"radial"!==b&&zy(hy,{width:xt,height:wt,totalWidth:bt[0],totalHeight:bt[1],margin:vt,scales:Ot,onBrush:tt||(()=>{})}),He&&"radial"===b&&zy("div",{style:{position:"absolute",left:vt.left+xt/2,top:vt.top+wt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:He}),Ve?.showBadge&&zy(ur,{isStale:Xt,position:Ve.badgePosition}),zy(Hs,{active:yn.current>=0,hoverPoint:Et,margin:vt,size:bt,shape:gn.current?.shape,width:gn.current?.w,height:gn.current?.h}),kn]})]})}));Gy.displayName="StreamOrdinalFrame";var qy=Gy;import{useImperativeHandle as Yy}from"react";function Vy({ref:e,frameRef:t,setup:n}){return Yy(e,()=>({push:e=>t.current?.push(e),pushMany:e=>t.current?.pushMany(e),remove:e=>t.current?.remove(e)??[],update:(e,n)=>t.current?.update(e,n)??[],clear:()=>t.current?.clear(),getData:()=>t.current?.getData()??[],getScales:()=>t.current?.getScales()??null}),[t]),{effectiveLegendProps:n.legendBehaviorProps,effectiveMargin:n.margin}}import{useMemo as Xy}from"react";function Uy(e){const{colorBy:t,colorScale:n,color:o,themeCategorical:r,colorScheme:i,categoryIndexMap:a,userPieceStyle:s,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,cycleByCategory:p=!1,baseStyleExtras:m,linkStrokeToFill:f=!1,styleRules:y,resolveRuleValue:g}=e,b=Xy(()=>(e,s)=>{const c="function"==typeof m?m(e,s):m,l=c?{...c}:{};if(void 0===l.fill)if(t){if(!n)return l;l.fill=He(e,t,n)}else l.fill=Fd(o,r,i,p?s:void 0,a);if(y&&y.length>0){const t=Rh(e,y,{value:g?g(e):void 0,category:s});Object.assign(l,t)}return f&&void 0===l.stroke&&void 0!==l.fill&&(l.stroke=l.fill),l},[t,n,o,r,i,a,p,m,f,y,g]),v=Xy(()=>Sh(s?"function"==typeof s?(e,t)=>({...b(e,t),...s(e,t)||{}}):(e,t)=>({...b(e,t),...s}):b,{stroke:c,strokeWidth:l,opacity:u}),[b,s,c,l,u]);return Xy(()=>fd(v,d??null,h),[v,d,h])}import{jsx as Ky}from"react/jsx-runtime";var Qy=sf(function(e,t){const n=Vd(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}),o=cf(null),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",orientation:l="vertical",valueFormat:d,colorBy:h,colorScheme:p,sort:m=!1,barPadding:f=40,roundedTop:y,gradientFill:g=!1,styleRules:b,baselinePadding:v=!1,tooltip:x,annotations:w,regression:k,valueExtent:S,frameProps:A={},selection:C,linkedHover:M,onObservation:P,onClick:I,hoverHighlight:R,chartId:_,loading:T,loadingContent:L,emptyContent:N,legendInteraction:$,legendPosition:B,color:D,stroke:j,strokeWidth:E,opacity:F,showCategoryTicks:O,categoryFormat:z,dataIdAccessor:H}=e,{width:W,height:G,enableHover:q,showGrid:Y,showLegend:V,title:X,description:U,summary:K,accessibleTable:Q,categoryLabel:Z,valueLabel:J}=n,ee=af(()=>u(r),[r]),te=wh({data:ee,rawData:r,colorBy:h,colorScheme:p,legendInteraction:$,legendPosition:B,selection:C,linkedHover:M,fallbackFields:h?["string"==typeof h?h:""]:[],unwrapData:!0,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"BarChart",chartId:_,showLegend:V,userMargin:i,marginDefaults:n.marginDefaults,loading:T,loadingContent:L,emptyContent:N,width:W,height:G}),{effectiveLegendProps:ne,effectiveMargin:oe}=Vy({ref:t,frameRef:o,setup:te});ch("BarChart",ee,"categoryAccessor",s),ch("BarChart",ee,"valueAccessor",c);const re=zd(ee,m,c),ie=Ed(),ae=af(()=>new Map,[]),se=af(()=>Ah(c),[c]),ce=Uy({colorBy:h,colorScale:te.colorScale,color:D,themeCategorical:ie,colorScheme:p,categoryIndexMap:ae,userPieceStyle:A?.pieceStyle,stroke:j,strokeWidth:E,opacity:F,styleRules:b,resolveRuleValue:se,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),le=af(()=>jl({categoryAccessor:s,valueAccessor:c,groupAccessor:h&&h!==s?h:void 0,groupLabel:"string"==typeof h?h:"group",valueFormat:d}),[s,c,h,d]);if(te.earlyReturn)return te.earlyReturn;const ue=ph({componentName:"BarChart",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(ue)return Ky(Qd,{componentName:"BarChart",message:ue,width:W,height:G});const de=Tp(k),he=de?[de,...w||[]]:w,pe={chartType:"bar",...null!=r&&{data:re},oAccessor:s,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:ce,size:[W,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe,barPadding:f,...null!=y&&{roundedTop:y},...g&&{gradientFill:!0===g?{topOpacity:.8,bottomOpacity:.05}:g},...H&&{dataIdAccessor:H},baselinePadding:v,enableHover:q,showAxes:n.showAxes,oLabel:Z,rLabel:J,rFormat:d,...z&&{oFormat:z},showGrid:Y,showCategoryTicks:O,oSort:m,...ne,...$h({title:X,description:U,summary:K,accessibleTable:Q,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:x,defaultTooltipContent:le}),...Bh({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:te.mobileInteraction,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior}),...he&&he.length>0&&{annotations:he},...S&&{rExtent:S},...Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e))};return Ky(oh,{componentName:"BarChart",width:W,height:G,children:Ky(qy,{ref:o,...pe})})});Qy.displayName="BarChart";import{useMemo as Zy,forwardRef as Jy,useRef as eg}from"react";import{jsx as tg}from"react/jsx-runtime";var ng=Jy(function(e,t){const n=Vd(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}),o=eg(null),{data:r,margin:i,className:a,categoryAccessor:s="category",stackBy:c,valueAccessor:l="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,normalize:f=!1,sort:y=!1,barPadding:g=40,roundedTop:b,styleRules:v,baselinePadding:x=!1,tooltip:w,annotations:k,valueExtent:S,frameProps:A={},selection:C,linkedHover:M,onObservation:P,onClick:I,hoverHighlight:R,chartId:_,loading:T,loadingContent:L,emptyContent:N,legendInteraction:$,legendPosition:B,color:D,stroke:j,strokeWidth:E,opacity:F,categoryFormat:O}=e,{width:z,height:H,enableHover:W,showGrid:G,showLegend:q,title:Y,description:V,summary:X,accessibleTable:U,categoryLabel:K,valueLabel:Q}=n,Z=Zy(()=>u(r),[r]),J=p||c,ee=wh({data:Z,rawData:r,colorBy:J,colorScheme:m,legendInteraction:$,legendPosition:B,selection:C,linkedHover:M,fallbackFields:J?["string"==typeof J?J:""]:[],unwrapData:!0,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"StackedBarChart",chartId:_,showLegend:q,userMargin:i,marginDefaults:n.marginDefaults,loading:T,loadingContent:L,emptyContent:N,width:z,height:H}),te=Ed(),ne=Zy(()=>new Map,[]),oe=Zy(()=>Ah(l),[l]),re=Uy({colorBy:J,colorScale:ee.colorScale,color:D,themeCategorical:te,colorScheme:m,categoryIndexMap:ne,userPieceStyle:A?.pieceStyle,stroke:j,strokeWidth:E,opacity:F,styleRules:v,resolveRuleValue:oe,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ie=Zy(()=>jl({categoryAccessor:c,valueAccessor:l,groupAccessor:s,valueFormat:h}),[c,s,l,h]),ae=ph({componentName:"StackedBarChart",data:r,accessors:{categoryAccessor:s,valueAccessor:l},requiredProps:{stackBy:c}}),{effectiveLegendProps:se,effectiveMargin:ce}=Vy({ref:t,frameRef:o,setup:ee});if(ee.earlyReturn)return ee.earlyReturn;const le={chartType:"bar",...null!=r&&{data:Z},oAccessor:s,rAccessor:l,stackBy:c,normalize:f,oSort:y,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:re,size:[z,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ce,barPadding:g,...null!=b&&{roundedTop:b},baselinePadding:x,enableHover:W,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:K,rLabel:Q,rFormat:h,...O&&{oFormat:O},showGrid:G,...se,...$h({title:Y,description:V,summary:X,accessibleTable:U,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:w,defaultTooltipContent:ie}),...Bh({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:ee.mobileInteraction,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior}),...k&&k.length>0&&{annotations:k},...S&&{rExtent:S},...Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e))};return ae?tg(Qd,{componentName:"StackedBarChart",message:ae,width:z,height:H}):tg(oh,{componentName:"StackedBarChart",width:z,height:H,children:tg(qy,{ref:o,...le})})});ng.displayName="StackedBarChart";import{useMemo as og,forwardRef as rg,useRef as ig}from"react";import{jsx as ag}from"react/jsx-runtime";var sg=rg(function(e,t){const n=Vd(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}),o=ig(null),{data:r,margin:i,className:a,categoryAccessor:s="category",groupBy:c,valueAccessor:l="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,sort:f=!1,barPadding:y=60,roundedTop:g,styleRules:b,baselinePadding:v=!1,tooltip:x,annotations:w,valueExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:P,hoverHighlight:I,chartId:R,loading:_,loadingContent:T,emptyContent:L,legendInteraction:N,legendPosition:$,color:B,stroke:D,strokeWidth:j,opacity:E,categoryFormat:F}=e,{width:O,height:z,enableHover:H,showGrid:W,showLegend:G,title:q,description:Y,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=n,Q=og(()=>u(r),[r]),Z=p||c,J=wh({data:Q,rawData:r,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:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"GroupedBarChart",chartId:R,showLegend:G,userMargin:i,marginDefaults:n.marginDefaults,loading:_,loadingContent:T,emptyContent:L,width:O,height:z}),ee=Ed(),te=og(()=>new Map,[]),ne=og(()=>Ah(l),[l]),oe=Uy({colorBy:Z,colorScale:J.colorScale,color:B,themeCategorical:ee,colorScheme:m,categoryIndexMap:te,userPieceStyle:S.pieceStyle,stroke:D,strokeWidth:j,opacity:E,styleRules:b,resolveRuleValue:ne,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),re=og(()=>jl({categoryAccessor:c,valueAccessor:l,groupAccessor:s,valueFormat:h}),[c,s,l,h]),ie=ph({componentName:"GroupedBarChart",data:r,accessors:{categoryAccessor:s,valueAccessor:l},requiredProps:{groupBy:c}}),{effectiveLegendProps:ae,effectiveMargin:se}=Vy({ref:t,frameRef:o,setup:J});if(J.earlyReturn)return J.earlyReturn;const ce={chartType:"clusterbar",...null!=r&&{data:Q},oAccessor:s,rAccessor:l,groupBy:c,oSort:f,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:oe,size:[O,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:se,barPadding:y,...null!=g&&{roundedTop:g},baselinePadding:v,enableHover:H,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:U,rLabel:K,rFormat:h,...F&&{oFormat:F},showGrid:W,...ae,...$h({title:q,description:Y,summary:V,accessibleTable:X,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:x,defaultTooltipContent:re}),...Bh({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 ie?ag(Qd,{componentName:"GroupedBarChart",message:ie,width:O,height:z}):ag(oh,{componentName:"GroupedBarChart",width:O,height:z,children:ag(qy,{ref:o,...ce})})});sg.displayName="GroupedBarChart";import{useMemo as cg,forwardRef as lg,useRef as ug}from"react";import{useCallback as dg,useRef as hg}from"react";function pg({brushProp:e,onBrushProp:t,linkedBrush:n,valueAccessor:o}){const r=md("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),i="string"==typeof o?o:"value",a=Xu({name:r?.name||"__unused_ordinal_brush__",xField:r?.xField||i}),s=hg(a.brushInteraction);s.current=a.brushInteraction;const c=dg(e=>{if(r){s.current.end(e?e.r:null)}t?.(e)},[t,r]),l=!!(e||n||t);return{hasBrush:l,handleBrush:c,brushStreamProps:l?{brush:{dimension:"r"},onBrush:c}:{}}}import{jsx as mg}from"react/jsx-runtime";var fg=lg(function(e,t){const o=Vd(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=ug(null);Nh(t,{variant:"xy",frameRef:r});const{data:i,margin:a,className:s,categoryAccessor:c="category",valueAccessor:l="value",orientation:d="vertical",valueFormat:h,colorBy:p,colorScheme:m,sizeBy:f,sizeRange:y=[3,8],symbolBy:g,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:R,linkedHover:_,onObservation:T,onClick:L,hoverHighlight:N,chartId:$,loading:B,loadingContent:D,emptyContent:j,legendInteraction:E,legendPosition:F,color:O,stroke:z,strokeWidth:H,opacity:W,showCategoryTicks:G,categoryFormat:q}=e,{width:Y,height:V,enableHover:X,showGrid:U,showLegend:K,title:Q,description:Z,summary:J,accessibleTable:ee,categoryLabel:te,valueLabel:ne}=o,oe=cg(()=>u(i),[i]),re=wh({data:oe,rawData:i,colorBy:p,colorScheme:m,legendInteraction:E,legendPosition:F,selection:R,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:T,onClick:L,hoverHighlight:N,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"SwarmPlot",chartId:$,showLegend:K,userMargin:a,marginDefaults:o.marginDefaults,loading:B,loadingContent:D,emptyContent:j,width:Y,height:V}),ie=pg({brushProp:C,onBrushProp:M,linkedBrush:P,valueAccessor:l}),ae=cg(()=>{if(!f)return;const e=oe.map(e=>"function"==typeof f?f(e):e[f]);return n(e)},[oe,f]),se=Ed(),ce=cg(()=>new Map,[]),le=Uy({colorBy:p,colorScale:re.colorScale,color:O,themeCategorical:se,colorScheme:m,categoryIndexMap:ce,userPieceStyle:I?.pieceStyle,stroke:z,strokeWidth:H,opacity:W,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection,baseStyleExtras:e=>({fillOpacity:x,r:f?qe(e,f,y,ae):v})}),ue=cg(()=>jl({categoryAccessor:c,valueAccessor:l,groupAccessor:p||void 0,valueFormat:h}),[c,l,p,h]);if(re.earlyReturn)return re.earlyReturn;const de=ph({componentName:"SwarmPlot",data:i,accessors:{categoryAccessor:c,valueAccessor:l}});if(de)return mg(Qd,{componentName:"SwarmPlot",message:de,width:Y,height:V});const he={chartType:"swarm",...null!=i&&{data:oe},oAccessor:c,rAccessor:l,...g&&{symbolAccessor:g},...b&&{symbolMap:b},projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[Y,V],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:re.margin,barPadding:w,enableHover:X,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:o.showAxes,oLabel:te,rLabel:ne,rFormat:h,...q&&{oFormat:q},showGrid:U,showCategoryTicks:G,...re.legendBehaviorProps,...$h({title:Q,description:Z,summary:J,accessibleTable:ee,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:k,defaultTooltipContent:ue}),...Bh({linkedHover:_,selection:R,onObservation:T,onClick:L,hoverHighlight:N,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...S&&S.length>0&&{annotations:S},...A&&{rExtent:A},...ie.brushStreamProps,...Object.fromEntries(Object.entries(I).filter(([e])=>"pieceStyle"!==e))};return mg(oh,{componentName:"SwarmPlot",width:Y,height:V,children:mg(qy,{ref:r,...he})})});fg.displayName="SwarmPlot";import{useMemo as yg,forwardRef as gg,useRef as bg}from"react";import{jsx as vg,jsxs as xg}from"react/jsx-runtime";function wg(e){return t=>{const n=t.category||t.data&&t.data[0]?.category||"",o=t.stats||(t.data||t).stats;if(o&&null!=o.median)return xg("div",{className:"semiotic-tooltip",style:tc,children:[n&&vg("div",{style:{fontWeight:"bold"},children:n+""}),null!=o.n&&xg("div",{children:["n = ",o.n]}),null!=o.min&&xg("div",{children:["Min: ",o.min.toLocaleString()]}),null!=o.q1&&xg("div",{children:["Q1: ",o.q1.toLocaleString()]}),xg("div",{children:["Median: ",o.median.toLocaleString()]}),null!=o.q3&&xg("div",{children:["Q3: ",o.q3.toLocaleString()]}),null!=o.max&&xg("div",{children:["Max: ",o.max.toLocaleString()]}),null!=o.mean&&xg("div",{style:{opacity:.8},children:["Mean: ",o.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(e?.valueAccessor){const o=e.valueAccessor,r=(Array.isArray(t.data)?t.data:[]).map(e=>Number("function"==typeof o?o(e):e[o])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),i=r.length,a=i>0?i%2!=0?r[Math.floor(i/2)]:(r[i/2-1]+r[i/2])/2:null;return xg("div",{className:"semiotic-tooltip",style:tc,children:[n&&vg("div",{style:{fontWeight:"bold"},children:n+""}),i>0&&xg("div",{children:["n = ",i]}),null!=a&&xg("div",{children:["Median: ",a.toLocaleString()]})]})}return vg("div",{className:"semiotic-tooltip",style:tc,children:vg("div",{style:{fontWeight:"bold"},children:n+""})})}}import{jsx as kg}from"react/jsx-runtime";var Sg=gg(function(e,t){const n=Vd(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}),o=bg(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",orientation:l="vertical",valueFormat:d,colorBy:h,colorScheme:p,showOutliers:m=!0,outlierRadius:f=3,categoryPadding:y=20,tooltip:g,annotations:b,valueExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:P,loadingContent:I,emptyContent:R,legendInteraction:_,legendPosition:T,color:L,stroke:N,strokeWidth:$,opacity:B,showCategoryTicks:D,categoryFormat:j}=e,{width:E,height:F,enableHover:O,showGrid:z,showLegend:H,title:W,description:G,summary:q,accessibleTable:Y,categoryLabel:V,valueLabel:X}=n,U=yg(()=>u(r),[r]),K=wh({data:U,rawData:r,colorBy:h,colorScheme:p,legendInteraction:_,legendPosition:T,selection:w,linkedHover:k,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"BoxPlot",chartId:M,showLegend:H,userMargin:i,marginDefaults:n.marginDefaults,loading:P,loadingContent:I,emptyContent:R,width:E,height:F}),Q=Ed(),Z=yg(()=>new Map,[]),J=Uy({colorBy:h,colorScale:K.colorScale,color:L,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=yg(()=>wg(),[]);if(K.earlyReturn)return K.earlyReturn;const te=ph({componentName:"BoxPlot",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(te)return kg(Qd,{componentName:"BoxPlot",message:te,width:E,height:F});const ne={chartType:"boxplot",...null!=r&&{data:U},oAccessor:s,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:J,showOutliers:m,size:[E,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:V,rLabel:X,rFormat:d,...j&&{oFormat:j},showGrid:z,showCategoryTicks:D,...K.legendBehaviorProps,...$h({title:W,description:G,summary:q,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:g,defaultTooltipContent:ee}),...Bh({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 kg(oh,{componentName:"BoxPlot",width:E,height:F,children:kg(qy,{ref:o,...ne})})});Sg.displayName="BoxPlot";import{useMemo as Ag,forwardRef as Cg,useRef as Mg}from"react";import{jsx as Pg,jsxs as Ig}from"react/jsx-runtime";var Rg=e=>{const t=e?.category;return null==t?"All":t+""},_g=Cg(function(e,t){const n=Vd(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}),o=Mg(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,categoryAccessor:s=Rg,valueAccessor:c="value",bins:l=25,relative:d=!1,valueFormat:h,colorBy:p,colorScheme:m,categoryPadding:f=20,tooltip:y,annotations:g,valueExtent:b,brush:v,onBrush:x,linkedBrush:w,frameProps:k={},selection:S,linkedHover:A,onObservation:C,onClick:M,hoverHighlight:P,chartId:I,loading:R,loadingContent:_,emptyContent:T,legendInteraction:L,legendPosition:N,color:$,stroke:B,strokeWidth:D,opacity:j,showCategoryTicks:E,categoryFormat:F}=e,{width:O,height:z,enableHover:H,showGrid:W,showLegend:G,title:q,description:Y,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=n,Q=Ag(()=>u(r),[r]),Z=wh({data:Q,rawData:r,colorBy:p,colorScheme:m,legendInteraction:L,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:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"Histogram",chartId:I,showLegend:G,userMargin:i,marginDefaults:n.marginDefaults,loading:R,loadingContent:_,emptyContent:T,width:O,height:z}),J=pg({brushProp:v,onBrushProp:x,linkedBrush:w,valueAccessor:c}),ee=Ag(()=>{if(0===Q.length)return;const e="function"==typeof c?c:e=>e[c];let t=1/0,n=-1/0;for(const o of Q){const r=e(o);null!=r&&isFinite(r)&&(t>r&&(t=r),r>n&&(n=r))}return t>n?void 0:[t,n]},[Q,c]),te=Ed(),ne=Ag(()=>new Map,[]),oe=Uy({colorBy:p,colorScale:Z.colorScale,color:$,themeCategorical:te,colorScheme:m,categoryIndexMap:ne,userPieceStyle:void 0,stroke:B,strokeWidth:D,opacity:j,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),re=Ag(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return Ig("div",{className:"semiotic-tooltip",style:tc,children:[n&&Pg("div",{style:{fontWeight:"bold"},children:n+""}),null!=o&&Ig("div",{children:["Count: ",o]}),r&&2===r.length&&Ig("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]);if(Z.earlyReturn)return Z.earlyReturn;const ie=ph({componentName:"Histogram",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(ie)return Pg(Qd,{componentName:"Histogram",message:ie,width:O,height:z});const ae={chartType:"histogram",...null!=r&&{data:Q},oAccessor:s,rAccessor:c,projection:"horizontal",summaryStyle:oe,bins:l,normalize:d,...b?{rExtent:b}:ee&&{rExtent:ee},size:[O,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Z.margin,barPadding:f,enableHover:H,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:U,rLabel:K,rFormat:h,...F&&{oFormat:F},showGrid:W,showCategoryTicks:E,...Z.legendBehaviorProps,...$h({title:q,description:Y,summary:V,accessibleTable:X,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:y,defaultTooltipContent:re}),...Bh({linkedHover:A,selection:S,onObservation:C,onClick:M,hoverHighlight:P,mobileInteraction:Z.mobileInteraction,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior}),...g&&g.length>0&&{annotations:g},...J.brushStreamProps,...Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e))};return Pg(oh,{componentName:"Histogram",width:O,height:z,children:Pg(qy,{ref:o,...ae})})});_g.displayName="Histogram";import{useMemo as Tg,forwardRef as Lg,useRef as Ng}from"react";import{jsx as $g}from"react/jsx-runtime";var Bg=Lg(function(e,t){const n=Vd(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}),o=Ng(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",orientation:l="vertical",bins:d=25,curve:h="catmullRom",showIQR:p=!0,valueFormat:m,colorBy:f,colorScheme:y,categoryPadding:g=20,tooltip:b,annotations:v,valueExtent:x,brush:w,onBrush:k,linkedBrush:S,frameProps:A={},selection:C,linkedHover:M,onObservation:P,onClick:I,hoverHighlight:R,chartId:_,loading:T,loadingContent:L,emptyContent:N,legendInteraction:$,legendPosition:B,color:D,stroke:j,strokeWidth:E,opacity:F,showCategoryTicks:O,categoryFormat:z}=e,{width:H,height:W,enableHover:G,showGrid:q,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=n,J=Tg(()=>u(r),[r]),ee=wh({data:J,rawData:r,colorBy:f,colorScheme:y,legendInteraction:$,legendPosition:B,selection:C,linkedHover:M,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:P,onClick:I,hoverHighlight:R,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"ViolinPlot",chartId:_,showLegend:Y,userMargin:i,marginDefaults:n.marginDefaults,loading:T,loadingContent:L,emptyContent:N,width:H,height:W}),te=pg({brushProp:w,onBrushProp:k,linkedBrush:S,valueAccessor:c}),ne=Ed(),oe=Tg(()=>new Map,[]),re=Uy({colorBy:f,colorScale:ee.colorScale,color:D,themeCategorical:ne,colorScheme:y,categoryIndexMap:oe,userPieceStyle:void 0,stroke:j,strokeWidth:E,opacity:F,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),ie=Tg(()=>wg({valueAccessor:c}),[c]);if(ee.earlyReturn)return ee.earlyReturn;const ae=ph({componentName:"ViolinPlot",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(ae)return $g(Qd,{componentName:"ViolinPlot",message:ae,width:H,height:W});const se={chartType:"violin",...null!=r&&{data:J},oAccessor:s,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:re,bins:d,showIQR:p,size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ee.margin,barPadding:g,enableHover:G,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:Q,rLabel:Z,rFormat:m,...z&&{oFormat:z},showGrid:q,showCategoryTicks:O,...ee.legendBehaviorProps,...$h({title:V,description:X,summary:U,accessibleTable:K,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:b,defaultTooltipContent:ie}),...Bh({linkedHover:M,selection:C,onObservation:P,onClick:I,hoverHighlight:R,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 $g(oh,{componentName:"ViolinPlot",width:H,height:W,children:$g(qy,{ref:o,...se})})});Bg.displayName="ViolinPlot";import{useMemo as Dg,forwardRef as jg,useRef as Eg}from"react";import{jsx as Fg}from"react/jsx-runtime";var Og=jg(function(e,t){const n=Vd(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}),o=Eg(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",orientation:l="horizontal",valueFormat:d,colorBy:h,colorScheme:p,sort:m="auto",dotRadius:f=5,categoryPadding:y=10,tooltip:g,annotations:b,regression:v,valueExtent:x,frameProps:w={},selection:k,linkedHover:S,onObservation:A,onClick:C,hoverHighlight:M,chartId:P,loading:I,loadingContent:R,emptyContent:_,legendInteraction:T,legendPosition:L,color:N,stroke:$,strokeWidth:B,opacity:D,categoryFormat:j}=e,{width:E,height:F,enableHover:O,showGrid:z,showLegend:H,title:W,description:G,summary:q,accessibleTable:Y,categoryLabel:V,valueLabel:X}=n,U=Dg(()=>u(r),[r]),K=wh({data:U,rawData:r,colorBy:h,colorScheme:p,legendInteraction:T,legendPosition:L,selection:k,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"DotPlot",chartId:P,showLegend:H,userMargin:i,marginDefaults:n.marginDefaults,loading:I,loadingContent:R,emptyContent:_,width:E,height:F}),Q=zd(U,m,c),Z=Ed(),J=Dg(()=>new Map,[]),ee=Uy({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=Dg(()=>jl({categoryAccessor:s,valueAccessor:c,valueFormat:d}),[s,c,d]);if(K.earlyReturn)return K.earlyReturn;const ne=ph({componentName:"DotPlot",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(ne)return Fg(Qd,{componentName:"DotPlot",message:ne,width:E,height:F});const oe=Tp(v),re=oe?[oe,...b||[]]:b,ie={chartType:"point",...null!=r&&{data:Q},oAccessor:s,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:ee,size:[E,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:V,rLabel:X,rFormat:d,...j&&{oFormat:j},showGrid:z,oSort:m,...K.legendBehaviorProps,...$h({title:W,description:G,summary:q,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:g,defaultTooltipContent:te}),...Bh({linkedHover:S,selection:k,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior}),...re&&re.length>0&&{annotations:re},...x&&{rExtent:x},...Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e))};return Fg(oh,{componentName:"DotPlot",width:E,height:F,children:Fg(qy,{ref:o,...ie})})});Og.displayName="DotPlot";import{useMemo as zg,forwardRef as Hg,useRef as Wg}from"react";import{jsx as Gg}from"react/jsx-runtime";var qg=Hg(function(e,t){const n=Vd(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}),o=Wg(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",orientation:l="horizontal",bins:d=20,amplitude:h=1.5,valueFormat:p,colorBy:m,colorScheme:f,categoryPadding:y=5,tooltip:g,annotations:b,valueExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:P,loadingContent:I,emptyContent:R,legendInteraction:_,legendPosition:T,color:L,stroke:N,strokeWidth:$,opacity:B,showCategoryTicks:D,categoryFormat:j}=e,{width:E,height:F,enableHover:O,showGrid:z,showLegend:H,title:W,description:G,summary:q,accessibleTable:Y,categoryLabel:V,valueLabel:X}=n,U=zg(()=>u(r),[r]),K=wh({data:U,rawData:r,colorBy:m,colorScheme:f,legendInteraction:_,legendPosition:T,selection:w,linkedHover:k,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof s?s:""],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"RidgelinePlot",chartId:M,showLegend:H,userMargin:i,marginDefaults:n.marginDefaults,loading:P,loadingContent:I,emptyContent:R,width:E,height:F}),Q=Ed(),Z=zg(()=>new Map,[]),J=Uy({colorBy:m,colorScale:K.colorScale,color:L,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=zg(()=>wg(),[]);if(K.earlyReturn)return K.earlyReturn;const te=ph({componentName:"RidgelinePlot",data:r,accessors:{categoryAccessor:s,valueAccessor:c}});if(te)return Gg(Qd,{componentName:"RidgelinePlot",message:te,width:E,height:F});const ne={chartType:"ridgeline",...null!=r&&{data:U},oAccessor:s,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:J,bins:d,size:[E,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:V,rLabel:X,rFormat:p,...j&&{oFormat:j},showGrid:z,showCategoryTicks:D,oSort:!1,amplitude:h,...K.legendBehaviorProps,...$h({title:W,description:G,summary:q,accessibleTable:Y,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:g,defaultTooltipContent:ee}),...Bh({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 Gg(oh,{componentName:"RidgelinePlot",width:E,height:F,children:Gg(qy,{ref:o,...ne})})});qg.displayName="RidgelinePlot";import{useMemo as Yg,forwardRef as Vg,useRef as Xg}from"react";import{jsx as Ug}from"react/jsx-runtime";var Kg=Vg(function(e,t){const n=Vd(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}),o=Xg(null),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",colorBy:l,colorScheme:d,startAngle:h=0,cornerRadius:p,tooltip:m,annotations:f,frameProps:y={},selection:g,linkedHover:b,onObservation:v,onClick:x,hoverHighlight:w,chartId:k,loading:S,loadingContent:A,emptyContent:C,legendInteraction:M,legendPosition:P,color:I,stroke:R,strokeWidth:_,opacity:T}=e,{width:L,height:N,enableHover:$,showLegend:B,title:D,description:j,summary:E,accessibleTable:F}=n,O=Yg(()=>u(r),[r]),z=l||s,H=wh({data:O,rawData:r,colorBy:z,colorScheme:d,legendInteraction:M,legendPosition:P,selection:g,linkedHover:b,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:v,onClick:x,hoverHighlight:w,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"PieChart",chartId:k,showLegend:B,userMargin:i,marginDefaults:n.marginDefaults,loading:S,loadingContent:A,emptyContent:C,width:L,height:N}),W=Ed(),G=Yg(()=>new Map,[]),q=Uy({colorBy:z,colorScale:H.colorScale,color:I,themeCategorical:W,colorScheme:d,categoryIndexMap:G,userPieceStyle:y?.pieceStyle,stroke:R,strokeWidth:_,opacity:T,effectiveSelectionHook:H.effectiveSelectionHook,resolvedSelection:H.resolvedSelection,cycleByCategory:!0}),Y=Yg(()=>jl({categoryAccessor:s,valueAccessor:c,groupAccessor:l&&l!==s?l:void 0,groupLabel:"string"==typeof l?l:"group",pieData:!0}),[s,c,l]),V=ph({componentName:"PieChart",data:r,accessors:{categoryAccessor:s,valueAccessor:c}}),{effectiveLegendProps:X,effectiveMargin:U}=Vy({ref:t,frameRef:o,setup:H});if(H.earlyReturn)return H.earlyReturn;const K={chartType:"pie",...null!=r&&{data:O},oAccessor:s,rAccessor:c,projection:"radial",pieceStyle:q,startAngle:h,...null!=p&&{cornerRadius:p},size:[L,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U,enableHover:$,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...X,...$h({title:D,description:j,summary:E,accessibleTable:F,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:m,defaultTooltipContent:Y}),...Bh({linkedHover:b,selection:g,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(y).filter(([e])=>"pieceStyle"!==e))};return V?Ug(Qd,{componentName:"PieChart",message:V,width:L,height:N}):Ug(oh,{componentName:"PieChart",width:L,height:N,children:Ug(qy,{ref:o,...K})})});Kg.displayName="PieChart";import{useMemo as Qg,forwardRef as Zg,useRef as Jg}from"react";import{jsx as eb}from"react/jsx-runtime";var tb=Zg(function(e,t){const n=Vd(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}),o=Jg(null),{data:r,margin:i,className:a,categoryAccessor:s="category",valueAccessor:c="value",innerRadius:l,centerContent:d,colorBy:h,colorScheme:p,startAngle:m=0,cornerRadius:f,tooltip:y,annotations:g,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:R,color:_,stroke:T,strokeWidth:L,opacity:N}=e,{width:$,height:B,enableHover:D,showLegend:j,title:E,description:F,summary:O,accessibleTable:z}=n,H=Qg(()=>u(r),[r]),W=h||s,G=wh({data:H,rawData:r,colorBy:W,colorScheme:p,legendInteraction:I,legendPosition:R,selection:v,linkedHover:x,fallbackFields:W?["string"==typeof W?W:""]:[],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"DonutChart",chartId:A,showLegend:j,userMargin:i,marginDefaults:n.marginDefaults,loading:C,loadingContent:M,emptyContent:P,width:$,height:B}),q=l??Math.max(2,.15*Math.min($,B)),Y=Ed(),V=Qg(()=>new Map,[]),X=Uy({colorBy:W,colorScale:G.colorScale,color:_,themeCategorical:Y,colorScheme:p,categoryIndexMap:V,userPieceStyle:b?.pieceStyle,stroke:T,strokeWidth:L,opacity:N,effectiveSelectionHook:G.effectiveSelectionHook,resolvedSelection:G.resolvedSelection,cycleByCategory:!0}),U=Qg(()=>jl({categoryAccessor:s,valueAccessor:c,groupAccessor:h&&h!==s?h:void 0,groupLabel:"string"==typeof h?h:"group",pieData:!0}),[s,c,h]),K=ph({componentName:"DonutChart",data:r,accessors:{categoryAccessor:s,valueAccessor:c}}),{effectiveLegendProps:Q,effectiveMargin:Z}=Vy({ref:t,frameRef:o,setup:G});if(G.earlyReturn)return G.earlyReturn;const J={chartType:"donut",...null!=r&&{data:H},oAccessor:s,rAccessor:c,projection:"radial",pieceStyle:X,innerRadius:q,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,...$h({title:E,description:F,summary:O,accessibleTable:z,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:y,defaultTooltipContent:U}),...Bh({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior}),...g&&g.length>0&&{annotations:g},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return K?eb(Qd,{componentName:"DonutChart",message:K,width:$,height:B}):eb(oh,{componentName:"DonutChart",width:$,height:B,children:eb(qy,{ref:o,...J})})});tb.displayName="DonutChart";import{useMemo as nb,forwardRef as ob,useRef as rb}from"react";function ib(e=240){const t=360-e,n=180+t/2,o=n*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:n,startAngleRad:o,offsetRad:-Math.PI/2+o}}function ab(e){return Math.max(0,Math.min(1,e))}function sb(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 n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function cb(e,t,n){const o=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function lb(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:ab(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=ab(t);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1];if(t.offset>o||o>r.offset)continue;const i=r.offset-t.offset,a=i>0?(o-t.offset)/i:0,s=sb(t.color),c=sb(r.color);if(!s||!c)return.5>a?t.color:r.color;const[l,u,d]=s,[h,p,m]=c;return cb(l+(h-l)*a,u+(p-u)*a,d+(m-d)*a)}return n[n.length-1].color}function ub(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}import{jsx as db,jsxs as hb}from"react/jsx-runtime";var pb=ob(function(e,t){const o=Vd(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}),r=rb(null),i="context"===e.mode,{compactMode:a}=o,{value:s,min:c=0,max:l=100,thresholds:u,gradientFill:d,color:h,backgroundColor:p="var(--semiotic-grid, #e0e0e0)",arcWidth:m=.3,cornerRadius:f,showNeedle:y=!0,needleColor:g="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:R}=e,{width:_,height:T,title:L,description:N,summary:$,accessibleTable:B}=o,D=d&&"object"==typeof d?d:void 0,j=Math.max(c,Math.min(l,s)),E=l-c||1,F=(j-c)/E,{gaugeData:O,pieceStyle:z,gaugeAnnotations:H}=nb(()=>function(e){const{min:t,max:n,value:o,thresholds:r,fillColor:i,backgroundColor:a,fillZones:s,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,o))-t)/d;let p=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:i||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>p[p.length-1].value&&p.push({value:n,color:p[p.length-1].color});const m=!!l&&l.colorStops.length>=2,f=[],y=new Map,g=[];if(m){const e=s?h:1,t=ub("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:a,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),o=[];for(let t=0;n>t;t++)o.push(lb(l.colorStops,e*(t+.5)/n));const r=ub("fill",0);f.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),y.set(r,{fill:o[0]||a})}}else{let e=t;for(let n=0;p.length>n;n++){const o=p[n],r=(o.value-e)/d,i=(e-t)/d,c=(o.value-t)/d,l=Math.max(0,(s?Math.min(h,c):c)-i),u=s?Math.max(0,r-l):0;if(l>0){const e=ub("fill",n);f.push({category:e,value:l,_zone:o.label||"Zone "+(n+1),_isFill:!0}),y.set(e,{fill:o.color})}if(u>0){const e=ub("bg",n);f.push({category:e,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),y.set(e,{fill:a,opacity:.4})}e=o.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&g.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:a},gaugeAnnotations:g}}({min:c,max:l,value:s,thresholds:u,fillColor:h,backgroundColor:p,fillZones:k,showScaleLabels:x,gradientFill:D}),[s,c,l,u,h,p,x,k,D]),W=nb(()=>Sh(z,{stroke:P,strokeWidth:I,opacity:R}),[z,P,I,R]),{sweepRad:G,startAngleDeg:q}=ib(w),Y=function(e=240){const{sweepRad:t,offsetRad:o}=ib(e),r=[[Math.cos(o),Math.sin(o)],[Math.cos(o+t),Math.sin(o+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-o)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||r.push([Math.cos(e),Math.sin(e)]);const i=r.map(e=>e[0]),a=r.map(e=>e[1]),[s,c]=n(i),[l,u]=n(a);return{minX:s,maxX:c,minY:l,maxY:u,width:c-s,height:u-l,cx:(s+c)/2,cy:(l+u)/2}}(w),V=Math.min(10,Math.max(1,Math.min(_,T)/12)),X=Y.cx,U=Y.cy,K=Math.max(4,Math.min((_-2*V)/Y.width,(T-2*V)/Y.height)-2),Q=Math.max(0,Math.min(K-1.5,K*(1-m))),Z=_/2-X*K,J=T/2-U*K,ee=2*(K+4),te=nb(()=>{if(a&&null==b)return null;if(null!=b)return"function"==typeof b?b(j,c,l):b;const e=v?v(j):Math.round(j)+"";return hb("div",{style:{textAlign:"center",lineHeight:1.2},children:[db("div",{style:{fontSize:Math.max(16,.3*K),fontWeight:700,color:"var(--semiotic-text, #333)"},children:e}),x&&hb("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",l]})]})},[b,j,c,l,v,x,K,a]),ne=nb(()=>i&&null==b?{type:"gauge-value",text:v?v(j):Math.round(j)+""}:null,[i,b,j,v]),oe=nb(()=>{if(!y)return null;const e=-Math.PI/2+q*Math.PI/180+F*G,t=Q>20?Q-8:K-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:g}},[y,q,F,G,Q,K,g]),re=nb(()=>(e,t,n)=>{if("gauge-needle"===e.type){const o=(n.width||_)/2,r=(n.height||T)/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 hb("g",{transform:`translate(${o},${r})`,children:[db("line",{x1:0,y1:0,x2:e.tipX,y2:e.tipY,stroke:e.color,strokeWidth:a,strokeLinecap:"round"}),db("circle",{cx:0,cy:0,r:s,fill:e.color})]},"gauge-needle-"+t)}if("gauge-label"===e.type){const o=-Math.PI/2+q*Math.PI/180+(e.value-c)/E*G,r=(n.width||_)/2,i=(n.height||T)/2,a=Q-1,s=K+1,l=Math.cos(o)*a,u=Math.sin(o)*a,d=Math.cos(o)*s,h=Math.sin(o)*s,p=K+10,m=Math.cos(o)*p,f=Math.sin(o)*p,y=((o+Math.PI/2)/(2*Math.PI)*12+12)%12;let g,b;return y>=11||1>y?(g="middle",b="auto"):y>=1&&5>y?(g="start",b="middle"):y>=5&&7>y?(g="middle",b="hanging"):(g="end",b="middle"),hb("g",{transform:`translate(${r},${i})`,children:[db("line",{x1:l,y1:u,x2:d,y2:h,stroke:"var(--semiotic-border)",strokeWidth:2,strokeLinecap:"round"}),db("text",{x:m,y:f,textAnchor:g,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?db("text",{x:(n.width||_)/2,y:(n.height||T)/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},[_,T,c,E,q,G,Q,K]),ie=nb(()=>{const e=[...H,...A||[]];return oe&&e.push(oe),ne&&e.push(ne),e},[H,A,oe,ne]),ae=nb(()=>e=>{const t=e?.data?.[0]||e?.data||e,n=t?._zone||"",o=t?._isFill;return hb("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:[db("div",{style:{fontWeight:600},children:n}),db("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:o?"Current: "+Math.round(j):"Remaining"})]})},[j]);if(0===O.length)return db(Qd,{componentName:"GaugeChart",message:"No data to display",width:_,height:T});const se={chartType:"donut",data:O,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:W,innerRadius:Q,startAngle:q,sweepAngle:w,...null!=f&&{cornerRadius:f},centerContent:te,size:[_,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:{top:J-ee/2,bottom:T-J-ee/2,left:Z-ee/2,right:_-Z-ee/2},enableHover:o.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===S?()=>null:sc(S)||ae,svgAnnotationRules:re,...ie.length>0&&{annotations:ie},...L&&{title:L},...N&&{description:N},...$&&{summary:$},...void 0!==B&&{accessibleTable:B},...M&&{className:M},...null!=e.animate&&{animate:e.animate},...C};return db(oh,{componentName:"GaugeChart",width:_,height:T,children:db(qy,{ref:r,...se})})});pb.displayName="GaugeChart";import{useMemo as mb,forwardRef as fb,useRef as yb}from"react";import{jsx as gb,jsxs as bb}from"react/jsx-runtime";var vb=fb(function(e,t){const n=Vd(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}),o=yb(null);Nh(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:a,stepAccessor:s="step",valueAccessor:c="value",categoryAccessor:l,colorBy:d,colorScheme:h,orientation:p="horizontal",connectorOpacity:m=.3,showLabels:f=!0,tooltip:y,annotations:g,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,loading:C,loadingContent:M,emptyContent:P,legendInteraction:I,legendPosition:R,color:_,stroke:T,strokeWidth:L,opacity:N,categoryFormat:$}=e,B="vertical"===p,{width:D,height:j,enableHover:E,showLegend:F,title:O,description:z,summary:H,accessibleTable:W}=n,G=B?{top:O?60:40,right:20,bottom:60,left:60}:{top:O?40:10,right:10,bottom:10,left:10},q=mb(()=>u(r),[r]),Y=d||l,V=!Y,X=wh({data:q,rawData:r,colorBy:Y,colorScheme:h,legendInteraction:I,legendPosition:R,selection:v,linkedHover:x,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"FunnelChart",chartId:A,showLegend:F,userMargin:i,marginDefaults:G,loading:C,loadingContent:M,emptyContent:P,width:D,height:j});ch("FunnelChart",q,"stepAccessor",s),ch("FunnelChart",q,"valueAccessor",c);const U=Ed(),K=mb(()=>new Map,[]),Q=mb(()=>{if(V)return _||(U?.[0]?U[0]:Array.isArray(h)&&h[0]?h[0]:"#4e79a7")},[V,_,U,h]),Z=Uy({colorBy:Q?void 0:Y,colorScale:X.colorScale,color:Q??_,themeCategorical:U,colorScheme:h,categoryIndexMap:K,userPieceStyle:b?.pieceStyle,stroke:T,strokeWidth:L,opacity:N,effectiveSelectionHook:X.effectiveSelectionHook,resolvedSelection:X.resolvedSelection}),J=mb(()=>e=>{const t=e?.data||e,n=t?.__funnelStep||t?.__barFunnelStep||t?.step||"",o=t?.__funnelValue??t?.__barFunnelValue??t?.value??"",r=t?.__funnelPercent??t?.__barFunnelPercent,i=t?.__funnelIsFirstStep??t?.__barFunnelIsFirstStep,a=t?.__barFunnelIsDropoff,s=t?.__barFunnelCategory??t?.category,c=null==r||i?"":` (${.05>Math.abs(r-Math.round(r))?Math.round(r)+"%":r.toFixed(1)+"%"})`;return bb("div",{className:"semiotic-tooltip",style:tc,children:[n&&gb("div",{style:{fontWeight:"bold"},children:n+""}),s&&s!==n&&gb("div",{style:{marginTop:2,opacity:.8},children:s+""}),a&&gb("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),bb("div",{style:{marginTop:4},children:[o+"",c]})]})},[]);if(X.earlyReturn)return X.earlyReturn;const ee=ph({componentName:"FunnelChart",data:r,accessors:{stepAccessor:s,valueAccessor:c}});if(ee)return gb(Qd,{componentName:"FunnelChart",message:ee,width:D,height:j});const te={chartType:B?"bar-funnel":"funnel",...null!=r&&{data:q},oAccessor:s,rAccessor:c,...l&&{stackBy:l},projection:B?"vertical":"horizontal",barPadding:B?40:0,pieceStyle:Z,size:[D,j],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,...O&&{title:O},...z&&{description:z},...H&&{summary:H},...void 0!==W&&{accessibleTable:W},...a&&{className:a},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===y?()=>null:!0===y||null==y?J:sc(y)||J,...Bh({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:X.mobileInteraction,customHoverBehavior:X.customHoverBehavior,customClickBehavior:X.customClickBehavior}),...g&&g.length>0&&{annotations:g},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return gb(oh,{componentName:"FunnelChart",width:D,height:j,children:gb(qy,{ref:o,...te})})});vb.displayName="FunnelChart";import*as xb from"react";import{useMemo as wb,useCallback as kb,forwardRef as Sb,useRef as Ab,useImperativeHandle as Cb}from"react";import{useRef as Mb,useState as Pb,useCallback as Ib,useMemo as Rb}from"react";import{useMemo as _b,useCallback as Tb,useRef as Lb}from"react";var Nb={RdBu:_e,PiYG:Te,PRGn:Le,BrBG:Ne,RdYlBu:$e,RdYlGn:Be,Spectral:De},$b="__likert_neutral_neg",Bb="__likert_neutral_pos";function Db(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function jb(e,t,n,o,r,i){const a=new Map,s=new Set(t);for(const c of e){const e=n(c);a.has(e)||a.set(e,new Map);const l=a.get(e);if(o){const e=o(c);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 n=e-1;if(0>n||n>=t.length)continue;const r=t[n];l.set(r,(l.get(r)||0)+1)}else if(r&&i){const e=r(c),t=i(c);if(!s.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,n]of a){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let r=0;t.length>r;r++){const i=t[r],a=n.get(i)||0;c.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:a,__likertPct:a/o*100,__likertLevelIndex:r})}}return c}function Eb(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===r){const e=t.__likertPct/2;i.push({...t,__likertLevel:$b,__likertPct:-e}),i.push({...t,__likertLevel:Bb,__likertPct:e})}else i.push(r>e?{...t,__likertPct:-t.__likertPct}:t)}return i}function Fb(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/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 n of e)n.__likertLevel===$b?i=n:n.__likertLevel===Bb?s=n:t.set(n.__likertLevelIndex,n);o&&i&&a.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&a.push(n)}o&&s&&a.push(s);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&a.push(n)}}return a}var Ob=["Very Low","Low","Neutral","High","Very High"];import{jsx as zb}from"react/jsx-runtime";var Hb=new Map,Wb=Sb(function(e,t){const n=Vd(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}),o=Ab(null),{data:r,margin:i,className:a,categoryAccessor:s="question",valueAccessor:c,levelAccessor:l,countAccessor:u="count",levels:d=Ob,orientation:h="horizontal",colorScheme:p,barPadding:m=20,tooltip:f,annotations:y,valueExtent:g,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,valueFormat:C,loading:M,loadingContent:P,emptyContent:I,legendInteraction:R,legendPosition:_,categoryFormat:T,stroke:L,strokeWidth:N,opacity:$}=e,{width:B,height:D,enableHover:j,showGrid:E,showLegend:F,title:O,description:z,summary:H,accessibleTable:W,categoryLabel:G,valueLabel:q}=n,Y="horizontal"===h,V=void 0===r,X=!l,U=function(){const e=Pd();return e?.colors?.diverging||void 0}(),K=wb(()=>p&&Array.isArray(p)&&p.length>=d.length?p:function(e,t){if(0>=e)return[];if(t){const n=Nb[t];if(n){if(1===e)return[n(.5)];const t=[];for(let o=0;e>o;o++)t.push(n(o/(e-1)));return t}}const n=["#da1e28","#ff8389","#ffb3b8"],o=["#a6c8ff","#4589ff","#0043ce"],r="#a8a8a8";if(1===e)return[r];const i=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;a>e;e++)s.push(n[Math.min(Math.floor(e*n.length/a),n.length-1)]);i&&s.push(r);for(let e=0;a>e;e++)s.push(o[Math.min(Math.floor(e*o.length/a),o.length-1)]);return s}(d.length,U),[p,d.length,U]),Q=wb(()=>{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:n,valueAccessor:o,levelAccessor:r,countAccessor:i,isDiverging:a,frameRef:s}){const c=!r,l=_b(()=>Db(n,"question"),[n]),u=_b(()=>c?Db(o,"score"):null,[c,o]),d=_b(()=>c?null:Db(r,"level"),[c,r]),h=_b(()=>c?null:Db(i,"count"),[c,i]),p=Lb([]);return{processedData:_b(()=>{const n=e||[];if(0===n.length)return[];let o=jb(n,t,l,u,d,h);return a&&(o=Eb(o,t),o=Fb(o,t)),o},[e,t,l,u,d,h,a]),reAggregate:Tb(e=>{let n=jb(e,t,l,u,d,h);a&&(n=Eb(n,t),n=Fb(n,t)),s.current?.replace(n)},[t,l,u,d,h,a,s]),accumulatorRef:p}}({data:r,levels:d,categoryAccessor:s,valueAccessor:c,levelAccessor:l,countAccessor:u,isDiverging:Y,frameRef:o}),te="__likertLevelLabel",ne=function({isPushMode:e,colorBy:t,colorScheme:n,showLegend:o,legendPosition:r="right"}){const i=Mb(new Set),a=Mb([]),[s,c]=Pb(0),l=Cu(),u=Ed(),d=Ib(e=>{if(!t)return null;const n="function"==typeof t?t(e):e[t];return null!=n?n+"":null},[t]),h=Ib(n=>{if(!e||!t)return;let o=!1;for(const e of n){if(!e||"object"!=typeof e)continue;const t=d(e);null==t||i.current.has(t)||(i.current.add(t),a.current.push(t),o=!0)}o&&c(e=>e+1)},[e,t,d]),p=Ib(n=>{if(!e||!t)return;const o=Array.from(new Set(n.map(String))),r=a.current;r.length===o.length&&r.every((e,t)=>e===o[t])||(i.current=new Set(o),a.current=o,c(e=>e+1))},[e,t]),m=Ib(e=>t=>{h([t]),e(t)},[h]),f=Ib(e=>t=>{h(t),e(t)},[h]),y=Ib(()=>{i.current=new Set,a.current=[],c(e=>e+1)},[]);cd(e&&t?a.current:[]);const g=Rb(()=>{if(!e||!t||!1===o)return;const r=a.current;if(0===r.length)return;const i=Array.isArray(n)&&n.length>0||"string"==typeof n&&n.length>0?n:u&&u.length>0?u:Fe,s="string"==typeof t?t:"__streamCat",c=r.map(e=>({[s]:e})),d=Ge(c,s,i);return pd({data:c,colorBy:s,colorScale:e=>l?.[e]||d(e)||"#999",getColor:He})},[e,t,o,n,l,u,s]),b=Rb(()=>{if(g)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[g,r]);return{wrapPush:m,wrapPushMany:f,resetCategories:y,categories:a.current,categoryDomainProps:e&&t?{legendCategoryAccessor:t,onCategoriesChange:p}:{},streamingLegend:g,streamingMarginAdjust:b}}({isPushMode:V,colorBy:te,colorScheme:K,showLegend:F,legendPosition:_}),{wrapPush:oe,wrapPushMany:re}=ne,ie=kb(e=>oe(e=>{ee.current.push(e),J(ee.current)})(e),[oe,J,ee]),ae=kb(e=>re(e=>{ee.current.push(...e),J(ee.current)})(e),[re,J,ee]);Cb(t,()=>({push:ie,pushMany:ae,remove:e=>o.current?.remove(e)??[],update:(e,t)=>o.current?.update(e,t)??[],clear:()=>{ee.current=[],ne.resetCategories(),o.current?.clear()},getData:()=>o.current?.getData()??[],getScales:()=>o.current?.getScales()??null}),[ie,ae,ee,ne]);const se=wh({data:Z,rawData:r,colorBy:te,colorScheme:K,legendInteraction:R,legendPosition:_,selection:v,linkedHover:x,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"LikertChart",chartId:A,showLegend:F,userMargin:i,marginDefaults:n.marginDefaults,loading:M,loadingContent:P,emptyContent:I,width:B,height:D}),ce=wb(()=>{const e=d.length;return e%2!=0&&Q.get(d[Math.floor(e/2)])||"#888"},[d,Q]),le=Uy({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:Hb,userPieceStyle:b?.pieceStyle,stroke:L,strokeWidth:N,opacity:$,effectiveSelectionHook:se.effectiveSelectionHook,resolvedSelection:se.resolvedSelection,baseStyleExtras:e=>{const t=e.__likertLevelLabel||e.data?.__likertLevelLabel,n=e.__likertLevel||e.data?.__likertLevel;if(n===$b||n===Bb)return{fill:ce};const o=t||n;return o&&Q.has(o)?{fill:Q.get(o)}:{fill:"#888"}}}),ue=wb(()=>{const e=d.length;return e%2!=0?d[Math.floor(e/2)]:""},[d]),de=wb(()=>e=>{const t=e.data||e,n=t.__likertLevel||"Unknown",o=n===$b||n===Bb?ue:n,r=t.__likertCategory||"",i=Math.abs(t.__likertPct||0),a=n===$b||n===Bb?2*i:i,s=t.__likertCount||0;return xb.createElement("div",{className:"semiotic-tooltip",style:tc},xb.createElement("div",{style:{fontWeight:"bold"}},r),xb.createElement("div",{style:{marginTop:4}},`${o}: ${a.toFixed(1)}% (n=${s})`))},[ue]),he=wb(()=>{if(!d||2>d.length)return"LikertChart requires `levels` with at least 2 entries.";if(c&&l)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(l&&!u)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==r&&0===r.length)return null;const e={categoryAccessor:s};return X?c&&(e.valueAccessor=c):(l&&(e.levelAccessor=l),u&&(e.countAccessor=u)),ph({componentName:"LikertChart",data:r,accessors:e,requiredProps:{levels:d}})},[r,s,c,l,u,d,X]),pe=wb(()=>[{styleFn:e=>({fill:Q.get(e.label)||"#888"}),items:d.map(e=>({label:e})),label:""}],[d,Q]),me=wb(()=>!1!==F?{...se.legendBehaviorProps,legend:{legendGroups:pe},legendPosition:_||se.legendPosition||"bottom"}:se.legendBehaviorProps,[se.legendBehaviorProps,se.legendPosition,_,F,pe]),fe=wb(()=>{const e={...se.margin};if(V&&!1!==F){const t=_||"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(ne.streamingMarginAdjust)for(const[t,n]of Object.entries(ne.streamingMarginAdjust))n>e[t]&&(e[t]=n);return Y&&100>e.left&&(e.left=100),e},[se.margin,ne.streamingMarginAdjust,Y,V,F,_]),ye=wb(()=>C||(Y?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[Y,C]);if(se.earlyReturn)return se.earlyReturn;const ge={chartType:"bar",...null!=r&&{data:Z},oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:Y?"horizontal":"vertical",pieceStyle:le,size:[B,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:fe,barPadding:m,enableHover:j,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:G,rLabel:q||(Y?void 0:"Percentage"),rFormat:ye,...T&&{oFormat:T},showGrid:E,...me,...O&&{title:O},...z&&{description:z},...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?de:sc(f)||de,...Bh({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:se.mobileInteraction,customHoverBehavior:se.customHoverBehavior,customClickBehavior:se.customClickBehavior}),...y&&y.length>0&&{annotations:y},...g&&{rExtent:g},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return he?zb(Qd,{componentName:"LikertChart",message:he,width:B,height:D}):zb(oh,{componentName:"LikertChart",width:B,height:D,children:zb(qy,{ref:o,...ge})})});Wb.displayName="LikertChart";import{useMemo as Gb,forwardRef as qb,useRef as Yb}from"react";import{jsx as Vb}from"react/jsx-runtime";var Xb=qb(function(e,t){const n=Vd(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}),o=Yb(null),{data:r,margin:i,className:a,categoryAccessor:s="category",subcategoryAccessor:c,valueAccessor:l="value",orientation:d="horizontal",valueFormat:h,colorBy:p,colorScheme:m,barPadding:f,tooltip:y,annotations:g,brush:b,onBrush:v,linkedBrush:x,frameProps:w={},selection:k,linkedHover:S,onObservation:A,onClick:C,hoverHighlight:M,chartId:P,loading:I,loadingContent:R,emptyContent:_,legendInteraction:T,legendPosition:L,color:N,stroke:$,strokeWidth:B,opacity:D,categoryFormat:j,rTickValues:E,tickLabelEdgeAlign:F,showCategoryTicks:O,gradientFill:z,trackFill:H,roundedTop:W,valueExtent:G}=e,{width:q,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=n,ne=Gb(()=>u(r),[r]),oe=p||c,re=Gb(()=>{if(null!=f)return f;if("sparkline"!==e.mode)return 40;const t=new Set(ne.map(e=>"function"==typeof s?s(e):e[s])),n=Math.max(1,t.size);return n>1?Math.max(0,Math.min(1,(("horizontal"===d?Y:q)-2*n)/(n-1))):1},[f,e.mode,ne,s,d,q,Y]),ie=wh({data:ne,rawData:r,colorBy:oe,colorScheme:m,legendInteraction:T,legendPosition:L,selection:k,linkedHover:S,fallbackFields:oe?["string"==typeof oe?oe:""]:[],unwrapData:!0,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"SwimlaneChart",chartId:P,showLegend:U,userMargin:i,marginDefaults:n.marginDefaults,loading:I,loadingContent:R,emptyContent:_,width:q,height:Y}),ae=pg({brushProp:b,onBrushProp:v,linkedBrush:x,valueAccessor:l}),se=Ed(),ce=Gb(()=>new Map,[]),le=Uy({colorBy:oe,colorScale:ie.colorScale,color:N,themeCategorical:se,colorScheme:m,categoryIndexMap:ce,userPieceStyle:w?.pieceStyle,stroke:$,strokeWidth:B,opacity:D,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection,cycleByCategory:!0}),ue=Gb(()=>jl({categoryAccessor:c,valueAccessor:l,groupAccessor:s,valueFormat:h}),[c,s,l,h]),de=ph({componentName:"SwimlaneChart",data:r,accessors:{categoryAccessor:s,valueAccessor:l,subcategoryAccessor:c},requiredProps:{subcategoryAccessor:c}}),{effectiveLegendProps:he,effectiveMargin:pe}=Vy({ref:t,frameRef:o,setup:ie});if(ie.earlyReturn)return ie.earlyReturn;const me={chartType:"swimlane",...null!=r&&{data:ne},oAccessor:s,rAccessor:l,stackBy:c,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:pe,barPadding:re,enableHover:V,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:!1===O?void 0:ee,rLabel:te,rFormat:h,...E&&{rTickValues:E},...null!=F&&{tickLabelEdgeAlign:F},...j&&{oFormat:j},...void 0!==O&&{showCategoryTicks:O},showGrid:X,...he,...$h({title:K,description:Q,summary:Z,accessibleTable:J,className:a,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Dh({tooltip:y,defaultTooltipContent:ue}),...Bh({linkedHover:S,selection:k,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:ie.mobileInteraction,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior}),...g&&g.length>0&&{annotations:g},...z&&{gradientFill:!0===z?{topOpacity:.8,bottomOpacity:.05}:z},...null!=H&&{trackFill:H},...null!=W&&{roundedTop:W},...G&&{rExtent:G},...ae.brushStreamProps,...Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e))};return de?Vb(Qd,{componentName:"SwimlaneChart",message:de,width:q,height:Y}):Vb(oh,{componentName:"SwimlaneChart",width:q,height:Y,children:Vb(qy,{ref:o,...me})})});Xb.displayName="SwimlaneChart";import{useMemo as Ub,forwardRef as Kb,useRef as Qb}from"react";import{useRef as Zb,useState as Jb,useEffect as ev,useMemo as tv,useCallback as nv,useImperativeHandle as ov,forwardRef as rv,memo as iv}from"react";var av={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},sv={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},cv=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,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const o=this.particles[n];return o.active=!0,o.t=0,o.offset=t()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const i=this.particles[r];if(!i.active)continue;const a=n[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(o?o[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?lv(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(r))):(i.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;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 n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function lv(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),c=a-s,[l,u,d,h]=e[s];uv(l,u,d,h,c,r);const p=h.x-l.x,m=h.y-l.y,f=Math.sqrt(p*p+m*m);if(f>.001){const e=p/f;r.x+=-m/f*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,i,a,s]=e.points;uv(r,i,a,s,t,o);const c=s.x-r.x,l=s.y-r.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;o.x+=-l/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function uv(e,t,n,o,r,i){const a=1-r,s=a*a,c=s*a,l=r*r,u=l*r;i.x=c*e.x+3*s*r*t.x+3*a*l*n.x+u*o.x,i.y=c*e.y+3*s*r*t.y+3*a*l*n.y+u*o.y}function dv(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function hv(e,t){var n,o=[],r=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=l(o));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[o=s[e][t]];h||(a[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):o.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)n[c]=-1,o[c]=0,r[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function p(t){var c=[t],l=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;l.length>0;){var p=e[t=l[l.length-1]];if(p.length>i[t]){for(var m=i[t];p.length>m;++m){var f=p[m];if(0>n[f]){n[f]=o[f]=u,r[f]=!0,u+=1,c.push(f),l.push(f);break}r[f]&&(o[t]=0|Math.min(o[t],o[f])),0>a[f]||s[t].push(a[f])}i[t]=m}else{if(o[t]===n[t]){var y=[],g=[],b=0;for(m=c.length-1;m>=0;--m){var v=c[m];if(r[v]=!1,y.push(v),g.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){c.length=m;break}}d.push(y);var x=Array(b);for(m=0;g.length>m;m++)for(var w=0;g[m].length>w;w++)x[--b]=g[m][w];h.push(x)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&p(c);for(c=0;h.length>c;c++){var m=h[c];if(0!==m.length){m.sort(function(e,t){return e-t}),l=[m[0]];for(var f=1;m.length>f;f++)m[f]!==m[f-1]&&l.push(m[f]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var c=r[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var p=d(n);if(n=p.leastVertex,s=p.adjList){for(var m=0;s.length>m;m++)for(var f=0;s[m].length>f;f++){var y=s[m][f];i[+y]=!1,a[y]={}}l(n),n+=1}else n=h}return t?void 0:o}function pv(e){return e.y0-e.y1>0?"up":"down"}function mv(e,t){return t(e.source)==t(e.target)}function fv(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function yv(e){return e.target.x0-e.source.x1}function gv(e,t){var n=vv(e),o=yv(t)/Math.tan(n);return"up"==pv(e)?e.y1-o:e.y1+o}function bv(e,t){var n=vv(e),o=yv(t)/Math.tan(n);return"up"==pv(e)?e.y1+o:e.y1-o}function vv(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function xv(e,t){return t(e)}function wv(e){return Sv(e.source)}function kv(e){return Sv(e.target)}function Sv(e){return(e.y0+e.y1)/2}function Av(e){return e.virtual?0:e.value}function Cv(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!mv(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!mv(e,t)?o+1:o}),n+o}function Mv(e){return e.target.depth}function Pv(e,t){return e.sourceLinks.length?e.depth:t-1}function Iv(e,t){return e.y0-t.y0}function Rv(e,t){return t.y0-e.y0}function _v(e,t){return e.y1-t.y1}function Tv(e,t){return t.y1-e.y1}function Lv(e,t){return $v(e.source,t.source)||e.index-t.index}function Nv(e,t){return $v(e.target,t.target)||e.index-t.index}function $v(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Bv(e,t){return Dv(e)==Dv(t)?"bottom"==e.circularLinkType?Rv(e,t):Iv(e,t):Dv(t)-Dv(e)}function Dv(e){return e.target.column-e.source.column}function jv(e,t){return Ev(e)==Ev(t)}function Ev(e){return e.y0-e.y1>0?"up":"down"}import{min as Fv}from"d3-array";function Ov(e,t,n,o,r){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=Fv(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),zv(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),zv(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,mv(e,t)&&fv(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+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-r-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,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?Rv:Iv);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(l=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Tv:_v),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+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-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function zv(e,t,n){e.sort(Bv);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(mv(e,t)&&fv(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Hv(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Hv(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as Wv,max as Gv,sum as qv,mean as Yv,group as Vv,groups as Xv}from"d3-array";function Uv(e){return function(){return e}}function Kv(e){return e.index}function Qv(e){return e.nodes}function Zv(e){return e.links}function Jv(e,t,n){var o=Xv(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Sv(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Sv(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.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(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Cv(t,n)-Cv(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==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==Cv(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function ex(e,t,n,o,r,i){var a=Xv(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,c=i;c>0;--c)l(s*=.99,n),u();function l(t,n){var o=a.length;a.forEach(function(r){var i=r.length,a=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Cv(r,n)>0){var c=Yv(r.sourceLinks,kv),l=Yv(r.targetLinks,wv),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-Sv(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(a==o-1&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)s=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+s;else{var h=Yv(r.sourceLinks,kv),p=Yv(r.targetLinks,wv),m=((h&&p?(h+p)/2:h||p)-Sv(r))*t;r.y0+=m,r.y1+=m}})})}function u(){a.forEach(function(n){var i,a,s,c=e.y0,l=n.length;for(n.sort(t||$v),s=0;l>s;++s)(a=c-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+o;if((a=c-o-e.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=n[s]).y1+r-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function tx(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Nv),e.targetLinks.sort(Lv)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function nx(){var e=0,t=0,n=1,o=1,r=24,i=8,a=null,s=Kv,c=Pv,l=void 0,u=32,d=2,h=Qv,p=Zv;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=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return Vv(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=dv(n,o)),"object"!=typeof r&&(r=e.target=dv(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var c=hv(o);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||l[o]&&l[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,l),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){xv(e,t)!=xv(r.source,t)&&xv(e,t)!=xv(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),mv(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(qv(e.sourceLinks,Av),qv(e.targetLinks,Av)),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,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,l,c);var p=i;if(null!==a){var m=Xv(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),f=Gv(m,function(e){return e.length});f>1&&(p=Math.max(1,(o-t)*a/(f-1)))}(function(e,t,n){var o=Xv(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 r=Wv(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/qv(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=Gv(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,p,r),Jv(h,l,s),ex(h,l,s,p,p,u),tx(h),Ov(h,s,d,10,8),Jv(h,l,s),ex(h,l,s,p,p,u),tx(h),Ov(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return xv(n.source,t)==xv(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!jv(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=gv(t,e);return e.y1-n}if(t.target.column>e.target.column)return gv(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return xv(n.target,t)==xv(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!jv(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=bv(t,e);return e.y0-n}if(t.source.column>e.source.column)return bv(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){let o=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=Wv(t,function(e){return e.y0}),a=Gv(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1)}),n.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=o(e.y0)-e.y0;e.y0=o(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),Ov(h,s,d,10,8)}(m),m}return m.update=function(e){return tx(e),Ov(e,s,d,10,8),e},m.nodeWidth=function(e){return arguments.length?(r=+e,m):r},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:Uv(e),m):h},m.links=function(e){return arguments.length?(p="function"==typeof e?e:Uv(e),m):p},m.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Uv(e),m):s},m.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Uv(e),m):c},m.nodeSort=function(e){return arguments.length?(l=e,m):l},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(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],m):[[e,t],[n,o]]},m.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],m):[n-e,o-t]},m}import{interpolateNumber as ox}from"d3-interpolate";import{line as rx,curveLinearClosed as ix}from"d3-shape";function ax(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:a,cp1X:s,cp2X:c}=e,l=(n+o)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${c},${i} ${r},${i}`,`L${r},${a}`,`C${c},${a} ${s},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:s,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}var sx=e=>{let t,n,o,r,i,a,s,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=ox(i,a),c=s(.5),l=s(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${a}L${o},${a}C${o},${l} ${r},${c} ${r},${i}Z`;const u=e.sankeyWidth/2,d=ox(e.source.x1,e.target.x0),{pathD:h}=ax({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 cx(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const n=o.sourceX,r=o.sourceY,i=o.targetX,a=o.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*(o.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${n},${r-t}L${n+s},${r-t}L${n+s},${r+t}L${n},${r+t}ZM${i},${a-t}L${i-c},${a-t}L${i-c},${a+t}L${i},${a+t}Z`}const r=o.sourceX,i=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${i-d*t}L${c},${i-d*t}L${c+n},${i-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${s-d*t+d*h}L${l-n+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${l+n},${s+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${i+d*t}L${r},${i+d*t}Z`}var lx=new Set,ux=new WeakMap;function dx(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=ux.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,ux.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;lx.has(e)||(lx.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}var hx={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(Mv))-1:0},justify:Pv};function px(e){return"string"==typeof e?e:e.id}var mx={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,c=n.iterations??100,l=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"===r?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const h=nx().extent(d).links(u).nodes(l).nodeAlign(hx[i]||Pv).nodeId(e=>e.id).nodeWidth(a).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of l)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(o._circularWidth??o.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,s=o[0],c=o[1];if(i>0&&a>0&&(0>e||0>n||t>s||r>c)){const t=Math.min(s/i,c/a),o=-e*t+(s-i*t)/2,r=-n*t+(c-a*t)/2;for(const e of l)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of l){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=px(e.source),n=px(e.target),o=m.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=e.width??0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=r;const i=p.get(t),a=p.get(n);i&&(o.source=i),a&&(o.target=a)}}},buildScene(e,t,n,o){const r="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:fe,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],p=[],m=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=i?i(dx(t,"nodeStyle")):{},a={fill:o.fill||u.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};m.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,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,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?m.get(o.id)||u.get(o.id)||r:m.get(t.id)||u.get(t.id)||r;const i=a?a(dx(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,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 l;(l=e.circular&&e.circularPathData?cx(e):sx(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||r,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(y=n.nodeLabel)?"function"==typeof y?y:e=>e[y]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,c,l;"down"===r?(s=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),c=n.y0+i/2),p.push({x:s,y:c,text:a+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var y;return{sceneNodes:d,sceneEdges:h,labels:p}}};import{forceSimulation as fx,forceCenter as yx,forceX as gx,forceY as bx,forceLink as vx,forceManyBody as xx,forceCollide as wx}from"d3-force";import{scaleLinear as kx}from"d3-scale";var Sx={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r=n.forceStrength??.1,i=o[0]/2,a=o[1]/2,s=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=s?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const o=Ax(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=Cx(e.id),i=r%360*(Math.PI/180),a=10+r%20;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=Cx(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=i+o*Math.cos(n),e.y=a+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),r=n*t;o.x=i+e*Math.cos(r),o.y=a+e*Math.sin(r)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=Mx(n.nodeSize,n.nodeSizeRange,e),p=e=>h(e);if(d>0){const o=new Map,s=new Map;for(const t of e)o.set(t.id,0),s.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;o.set(t,(o.get(t)??0)+1),o.set(n,(o.get(n)??0)+1)}const c=vx().strength(e=>{const t=e.weight,n="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(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*i))}).distance(e=>{const t="string"==typeof e.source?s.get(e.source):e.source,n="string"==typeof e.target?s.get(e.target):e.target,o=(t?p(t):0)+(n?p(n):0)+12;return Math.max(40,o)}).id(e=>e.id),l=fx();if(void 0===n.random&&void 0===n.seed||l.randomSource(n.random??Cc(n.seed)),l.force("charge",xx().strength(e=>{const t=o.get(e.id)??0;return-15*p(e)*Math.sqrt(t+1)})).force("collide",wx(e=>p(e)+3).strength(.9).iterations(2)).force("center",yx(i,a).strength(.8)).force("x",gx(i).strength(.06)).force("y",bx(a).strength(.06)),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}));c.links(e),l.force("link",c)}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(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[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,n,o){const r=n.nodeStyle,i=n.edgeStyle,a=Mx(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:fe,c=new Map;e.forEach((e,t)=>{c.set(e.id,s[t%s.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(dx(t,"nodeSize")),o=r?r(dx(t,"nodeStyle")):{},i={fill:o.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.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),o="object"==typeof e.target?e.target:h.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=i?i(dx(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(p=n.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=a(dx(n,"nodeSize"));d.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var p;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Ax(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function Cx(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Mx(e,t,o){if(o.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 r=t||[5,20],i=[];for(const t of o){const n=t.data?.[e];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>r[0];const[a,s]=n(i);if(a===s)return()=>(r[0]+r[1])/2;const c=kx().domain([a,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:c(n)}}import{chord as Px,ribbon as Ix}from"d3-chord";import{arc as Rx}from"d3-shape";var _x=fe,Tx={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,c=s-i,l=o[0]/2,u=o[1]/2,d=(h=n.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,n=p.get("string"==typeof e.source?e.source:e.source.id),o=p.get(t);if(void 0===n||void 0===o)continue;const r=d(e);f[n][o]=r}const y=Px().padAngle(r);a&&y.sortGroups(a);const g=y(f),b=g.groups,v=Rx().innerRadius(c).outerRadius(s);for(const t of b){const n=e[t.index],o=v.centroid({innerRadius:c,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+l,n.y=o[1]+u,n.__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,n=x.get("string"==typeof e.source?e.source:e.source.id),o=x.get(t);n&&(e.source=n),o&&(e.target=o)}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 g){const n=e[t.source.index].id,o=e[t.target.index].id,r=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){const{groupWidth:r=20,edgeOpacity:i=.5}=n,a=Math.min(o[0],o[1])/2,s=a-r,c=o[0]/2,l=o[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:_x,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const f=Ix().radius(s),y=[],g=[],b=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let r;r=u?u(dx(n,"nodeStyle")).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const i=u?u(dx(n,"nodeStyle")):{};y.push({type:"arc",cx:c,cy:l,innerR:s,outerR:a,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:r,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=f(t);if(!o)continue;const r=Lx(o,c,l);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)a=d(dx(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?a=m.get(n.id)||a:t&&(a=m.get(t.id)||a)}const s=d?d(dx(e,"edgeStyle")):{};g.push({type:"ribbon",pathD:r,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,o=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:c+Math.cos(a)*o,y:l+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:y,sceneEdges:g,labels:b}}};function Lx(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}import{hierarchy as Nx,tree as $x,cluster as Bx,treemap as Dx,pack as jx,partition as Ex,treemapBinary as Fx}from"d3-hierarchy";var Ox=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function zx(e){const[t,n,o]=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*n+.114*o>150?"#222":"#fff"}function Hx(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Wx(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 Gx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ox}function qx(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 Yx(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}var Vx={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;if(!r)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,l=Nx(r,a);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=o;switch(i){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=$x();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=Bx();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,o){const r=t.padding??4,i=t.paddingTop??0,a=Dx().size([n,o]).tile(Fx).padding(r);i>0&&a.paddingTop(i),a(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,o){const r=t.padding??4;jx().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){Ex().size([n,o]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;h.length>t;t++){const o=h[t],r={id:Hx(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===i||"cluster"===i?Xx(r,o,n):"treemap"===i||"partition"===i?Ux(r,o):"circlepack"===i&&Kx(r,o),r.__hierarchyNode=o,e.push(r),p.set(o,r)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=p.get(e.parent),o=p.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){const a=[],s=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=o[0]/2,h=o[1]/2,p="number"==typeof(m=n.nodeSize)?m:5;var m;for(const t of e){let e=t.x,o=t.y;u&&(e+=d,o+=h);const i=r(dx(t,"nodeStyle"));let s=i.fill||qx(n);if(n.colorByDepth&&void 0!==t.depth){const e=Gx(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:o,r:p,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const f=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,a=t.y,c=o.x,p=o.y;u&&(r+=d,a+=h,c+=d,p+=h);const m=Yx(r,a,c,p,l),y=i(dx(e,"edgeStyle"));s.push({type:"curved",pathD:m,style:{fill:"none",stroke:y.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:y.strokeWidth??1.5,opacity:y.opacity??f},datum:e})}if(!1!==n.showLabels){const t=Wx(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(o=a-p-6,i="end"):(o=a+p+6,i="start"),r=s):(o=a,r=s+p+14,i="middle");c.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:c}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=o(dx(n,"nodeStyle"));let s=a.fill||qx(t);if(t.colorByDepth&&void 0!==n.depth){const e=Gx(t);s=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Wx(t.nodeLabel),r=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const l=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(s):s.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=o(dx(s,"nodeStyle")).fill||qx(t);if(t.colorByDepth&&void 0!==s.depth){const e=Gx(t);d=e[s.depth%e.length]}const h="string"==typeof d?zx(d):t.themeSemantic?.text??"#000";i.push(l?{x:s.x0+e/2,y:s.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/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:r,sceneEdges:[],labels:i}}(e,n,0,r);case"circlepack":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=o(dx(n,"nodeStyle"));let a=i.fill||qx(t);if(t.colorByDepth&&void 0!==n.depth){const e=Gx(t);a=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Wx(t.nodeLabel);for(const r of e){const e=r.__radius??5,a=n?n(r):r.id;if(!a)continue;if(15>e)continue;const s=!(r.data?.children&&r.data.children.length>0);let c=o(dx(r,"nodeStyle")).fill||qx(t);if(t.colorByDepth&&void 0!==r.depth){const e=Gx(t);c=e[r.depth%e.length]}if(s){const n="string"==typeof c?zx(c):t.themeSemantic?.text??"#000";i.push({x:r.x,y:r.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:r.x,y:r.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:r,sceneEdges:[],labels:i}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Xx(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ux(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 Kx(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}import{pie as Qx}from"d3-shape";function Zx(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Jx={sankey:mx,force:Sx,chord:Tx,tree:Vx,cluster:Vx,treemap:Vx,circlepack:Vx,partition:Vx,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=Zx(n);h.metaMap.clear(),o.length=0,r.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,y=t[1]/2,g=Math.min(t[0],t[1])/2*.85,b=m(a(e));o.push({id:b,x:f,y:y,x0:f,x1:f,y0:y,y1:y,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:g,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,p,f,y){const g=i(t);if(!g?.length)return;const b=g.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=g.slice(k,k+x);if(!w.length)break;const S=(b+1)/v,A={id:n,depth:f,data:t,parentId:n},C=y?p/u(A)*S:p*S,M=Qx().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=c+C*Math.sin(i),p=l+C*Math.cos(i)*P;o.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:n,eccentricity:P}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,p,C,f+1,!0)}k+=x}}(e,b,f,y,g,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=Zx(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{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:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(dx(t,"nodeSize")),o=r?r(dx(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:o.fill||n.themeSemantic?.primary||"#6366f1",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.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),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=a(dx(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:c,labels:l}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=Zx(t),o=t.orbitSpeed??.25,r=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())-n.startTime)/1e3,a=o*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=s.get(e.parentId);if(!o)continue;const c=e.angle+i*a*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(c),t.y=o.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function ew(e){return Jx[e]}import{quadtree as tw}from"d3-quadtree";function nw(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 ow(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(!rw(e))return!1;return!0}return rw(t.points)}function rw(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 iw}from"d3-interpolate";var aw="rgba(34, 197, 94, 0.7)",sw=2e3,cw=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],lw=["scene-style","data-paint","accessibility","evidence"],uw=(e,t)=>({retainedData:e,invalidations:t}),dw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hw=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pw=["scene-geometry","data-paint","overlay","accessibility","evidence"],mw=["scene-style","data-paint","accessibility","evidence"],fw=["scene-geometry","data-paint","overlay","accessibility","evidence"],yw=[],gw={chartType:uw("rebuild",dw),nodeIDAccessor:uw("rebuild",dw),sourceAccessor:uw("rebuild",dw),targetAccessor:uw("rebuild",dw),valueAccessor:uw("rebuild",dw),edgeIdAccessor:uw("rebuild",dw),childrenAccessor:uw("rebuild",dw),hierarchySum:uw("rebuild",dw),orientation:uw("preserve",hw),nodeAlign:uw("preserve",hw),nodePaddingRatio:uw("preserve",hw),nodeWidth:uw("preserve",hw),edgeSort:uw("preserve",hw),iterations:uw("preserve",hw),forceStrength:uw("preserve",hw),padAngle:uw("preserve",hw),groupWidth:uw("preserve",hw),sortGroups:uw("preserve",hw),treeOrientation:uw("preserve",hw),edgeType:uw("preserve",hw),padding:uw("preserve",hw),paddingTop:uw("preserve",hw),orbitMode:uw("preserve",hw),orbitSize:uw("preserve",hw),orbitSpeed:uw("preserve",hw),orbitRevolution:uw("preserve",hw),orbitRevolutionStyle:uw("preserve",hw),orbitEccentricity:uw("preserve",hw),orbitShowRings:uw("preserve",hw),orbitAnimated:uw("preserve",hw),customNetworkLayout:uw("preserve",hw),layoutConfig:uw("preserve",hw),nodeSize:uw("preserve",pw),nodeSizeRange:uw("preserve",pw),colorByDepth:uw("preserve",pw),nodeLabel:uw("preserve",fw),showLabels:uw("preserve",fw),labelMode:uw("preserve",fw),nodeStyle:uw("preserve",mw),edgeStyle:uw("preserve",mw),colorBy:uw("preserve",mw),colorScheme:uw("preserve",mw),themeCategorical:uw("preserve",mw),themeSemantic:uw("preserve",mw),edgeColorBy:uw("preserve",mw),edgeOpacity:uw("preserve",mw),showParticles:uw("preserve",mw),particleStyle:uw("preserve",mw),decay:uw("preserve",mw),pulse:uw("preserve",mw),thresholds:uw("preserve",mw),staleness:uw("preserve",mw),layoutSelection:uw("preserve",mw),clock:uw("preserve",yw),random:uw("preserve",yw),seed:uw("preserve",yw),tensionConfig:uw("preserve",yw),transition:uw("preserve",yw),introAnimation:uw("preserve",yw),onLayoutError:uw("preserve",yw),__skipForceSimulation:uw("preserve",yw),__hierarchyRoot:uw("preserve",yw),__orbitState:uw("preserve",yw),__previousPositions:uw("preserve",yw)},bw=uw("preserve",hw),vw=class{constructor(){this.tracker=new ln}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},cw)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},lw):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=gw[o]??bw;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},xw=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.updateResults=new vw,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.config=e,this.tensionConfig={...av,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new cv(2e3))}currentTime(){return this.config.clock?.()??Ue()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const o=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...av,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new cv(2e3)),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}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,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,o){const{nodeIDAccessor:r="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,c="function"==typeof r?r:e=>e[r],l="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=c(t)+"";this.nodes.set(e,{...nw(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=u(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(o)||this.nodes.set(o,{...nw(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...nw(r),data:n});const c=`${o}\0${r}\0${e}`,h={source:o,target:r,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&ow(n.bezier)&&(h.bezier=n.bezier),this.edges.set(c,h)}o?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,o){return this.ingestBounded(e,t,n,o),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.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:n,value:o}=e,r=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,nw(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,nw(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),c=this.edges.get(s);let l=!1;c?(c.value+=o,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=r||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=ew(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)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,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,o,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;o.length>e;e++){const t=o[e],n=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=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const r=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||r.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=r,this.saveTargetPositions();const i=n.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&&n.length>0&&a>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),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=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:o,baseStyles:r,selection:i}){const a=!(!n&&!o);if(n)for(const t of e){const e=r.get(t)??t.style,o=n(t,i);t.style=o?{...e,...o}:e}if(o)for(const e of t){const t=r.get(e)??e.style,n=o(e,i);e.style=n?{...t,...n}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:o,edges:r,previousResult:i,revision:a}){const s=Pf(e.colorScheme,e.themeCategorical,fe),c={nodes:o,edges:r,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...s]},resolveColor:If(s,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==i,o=Et("network",t,n,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:o,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(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++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void Bt({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=ew(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:r,sceneEdges:i,labels:a}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const o=Array(t);let r=0;for(const e of this.sceneNodes)"circle"===e.type&&(o[r++]=e);this._nodeQuadtree=tw().x(e=>e.cx).y(e=>e.cy).addAll(o)}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=ew(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=ew(this.config.chartType);if(!n?.tick)return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,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),n=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,n),e.x1=Xe(e._prevX1,e._targetX1,n),e.y0=Xe(e._prevY0,e._targetY0,n),e.y1=Xe(e._prevY1,e._targetY1,n));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,n),e.y1=Xe(e._prevY1,e._targetY1,n),e.sankeyWidth=Xe(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.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 n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.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,n=.5){const o="string"==typeof e.source?t.get(e.source):e.source,r="string"==typeof e.target?t.get(e.target):e.target;!o||!r||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],i=n.x-t.x,a=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:r,halfWidth:t}}(e):function(e,t,n,o=.5){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=iw(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(o)},{x:e.y1,y:s(1-o)},{x:e.y1,y:a}],halfWidth:r}}const i=t.x1,a=n.x0,s=iw(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(o),y:e.y0},{x:s(1-o),y:e.y1},{x:a,y:e.y1}],halfWidth:r}}(e,o,r,n))}(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 n=t.duration??500,o=t.color??"rgba(255,255,255,0.6)",r=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 c=i-s;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=o,t._pulseGlowRadius=r)}for(const t of e.sceneEdges){const r=t.datum;if(!r)continue;const a="object"==typeof r.source?r.source?.id:r.source,s="object"==typeof r.target?r.target?.id:r.target;if(!a||!s)continue;const c=e.edgeTimestamps.get(`${a}\0${s}`);if(!c)continue;const l=i-c;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=o)}}({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 n=e.nodeTimestamps.size;if(1>=n)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 n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const o=e.cache.ageMap;for(const r of e.sceneNodes){const e=r.id;if(!e)continue;const i=o.get(e);if(void 0===i)continue;const a=Ze(t,i,n);r.style={...r.style,opacity:(r.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===aw&&(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>=sw)return;const n=1-t/sw;for(const t of e.sceneNodes){const o=t.id;o&&e.addedNodes.has(o)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=aw,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&sw>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",o=t.criticalColor??"#ef4444",r=!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 c=t.metric(s);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=n):l=o,l&&(i.style={...i.style,fill:l},r&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,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 n of e){const e=t.metric(n);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 n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-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 n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const o=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),o}updateEdge(e,t,n){const o=this.config.valueAccessor,r="function"==typeof o?o:o?e=>e[o]:e=>e.value,i=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){i.push(o.data?{...o.data}:{}),o.data=n(o.data??{});const e=r(o.data);null!=e&&(o.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];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 o="function"==typeof t?t:e=>e?.[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.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(),this.updateResults.recordData("clear")}};xw.QUADTREE_THRESHOLD=500;var ww=xw;rn(ww);import*as kw from"react";import{Fragment as Sw,jsx as Aw,jsxs as Cw}from"react/jsx-runtime";function Mw(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p="right",legendLayout:m,foregroundGraphics:f,sceneNodes:y,annotations:g,onAnnotationActivate:b,onObservation:v,chartId:x,chartType:w,autoPlaceAnnotations:k,svgAnnotationRules:S}=e,A=bi({onAnnotationActivate:b,onObservation:v,chartId:x,chartType:w}),C=kw.useMemo(()=>{const e=(y||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const o=so(e.glyph,e.size);return{x:t+o.centerDx,y:n+o.centerDy,r:Math.max(1,o.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,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,Lt(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=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:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:y}},[n,y,t]),M=kw.useMemo(()=>g&&k?Zi({annotations:g,context:C,..."object"==typeof k?k:{}}):g,[g,k,C]),P=kw.useMemo(()=>_i(),[]),I=M?Ri(M.filter(e=>"widget"!==e.type),P,S,C):null,R=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Cw(Sw,{children:[R&&Aw("style",{children:ui},"annotation-widget-disclosure-style"),Cw("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Aw("title",{children:"string"==typeof s?s:"Network Chart"}),Aw("desc",{children:"string"==typeof s?s+" — network data visualization":"Network data visualization"}),Cw("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>Aw("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)),I,f]}),s&&"string"==typeof s?Aw("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?Aw("foreignObject",{x:0,y:0,width:o,height:i.top,children:s}):null,Mr({legend:c,totalWidth:o,totalHeight:r,margin:i,legendPosition:p,title:s,legendLayout:m,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&y).map((e,t)=>{const n=!0===e._annotationDeferred,o=y.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!o)return null;const r=i.left+(o.cx??(null!=o.x&&null!=o.w?o.x+o.w/2:o.x??0)),a=i.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),s=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,d=e.content??Aw("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return Aw("div",{...xi(e,A),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+s-l/2,top:a+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}Mw.displayName="NetworkSVGOverlay";import*as Pw from"react";import{jsx as Iw}from"react/jsx-runtime";var Rw={position:"absolute",top:0,left:0,pointerEvents:"none"};function _w({marks:e,margin:t,selection:n=null,overscan:o=400}){const r=Pw.useRef(null),i=function(e,t,n){const[o,r]=Pw.useState(null);return Pw.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:o}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const i=()=>{o=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();r(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===o&&(o=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",a),s.disconnect()}},[t,e,n]),Pw.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:i}=o,a=t.left-n,s=t.right+n,c=t.top-n,l=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=i+e.y;return!(a>t+e.width||t>s||c>n+e.height||n>l)})},[e,o,n])}(e,r,o);if(!e||0===e.length)return null;const a=Iw("div",{className:"semiotic-network-html-marks",ref:r,style:{...Rw,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>Iw("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!=n?Iw(Wn,{value:n,children:a}):a}import{jsx as Tw,jsxs as Lw}from"react/jsx-runtime";function Nw({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:i,adjustedHeight:a,resolvedBackground:s,resolvedForeground:c}){const{chartType:l,nodes:d,edges:h,data:p,className:m,description:f,title:y,responsiveWidth:g,responsiveHeight:b,summary:v,background:x,renderMode:w,legend:k,legendPosition:S,legendLayout:A,legendHoverBehavior:C,legendClickBehavior:M,legendHighlightedCategory:P,legendIsolatedCategories:I,layoutSelection:R,annotations:_,onAnnotationActivate:T,annotationObservationCallback:L,onObservation:N,chartId:$,autoPlaceAnnotations:B,svgAnnotationRules:D}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?p||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[i,a]),t.buildScene([i,a]);else{const e=u(d),n=Array.isArray(h)?u(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,a]),t.buildScene([i,a]))}}const j=t?.sceneNodes??[],E=t?.sceneEdges??[],F=t?.labels??[];return Lw("div",{ref:n,className:"stream-network-frame"+(m?" "+m:""),role:"img","aria-label":f||("string"==typeof y?y:"Network chart"),style:{position:"relative",width:g?"100%":o[0],height:b?"100%":o[1]},children:[Tw(Es,{summary:v}),Lw("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[s&&Tw("g",{transform:`translate(${r.left},${r.top})`,children:s}),Lw("g",{transform:`translate(${r.left},${r.top})`,children:[x&&Tw("rect",{x:0,y:0,width:i,height:a,fill:x}),E.map((e,t)=>Pl({node:e,index:t,renderMode:w,fallback:()=>function(e,t){switch(e.type){case"line":return _a("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 n=e;return _a("path",{d:n.pathD,fill:Na(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return _a("path",{d:n.pathD,fill:Na(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return _a("path",{d:n.pathD,fill:Na(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),j.map((e,t)=>Pl({node:e,index:t,renderMode:w,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,o=So(n.style.fill)?Mo(n.style.fill,`net-circle-${t}-hatch`):void 0;return Ta(Sa.Fragment,{children:[o&&_a("defs",{children:o}),_a("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:o?`url(#net-circle-${t}-hatch)`:Na(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,o=So(n.style.fill)?Mo(n.style.fill,`net-rect-${t}-hatch`):void 0;return Ta(Sa.Fragment,{children:[o&&_a("defs",{children:o}),_a("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:o?`url(#net-rect-${t}-hatch)`:Na(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,o=Aa().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(La)||"",r=So(n.style.fill)?Mo(n.style.fill,`net-arc-${t}-hatch`):void 0;return Ta(Sa.Fragment,{children:[r&&_a("defs",{children:r}),_a("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:r?`url(#net-arc-${t}-hatch)`:Na(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,o=Tt(n.symbolType,n.size,n.path);return _a("path",{d:o,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Na(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return Ba(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),F.map((e,t)=>function(e,t){return _a("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)]})]}),Tw(Mw,{width:i,height:a,totalWidth:o[0],totalHeight:o[1],margin:r,labels:F,sceneNodes:j,title:y,legend:k,legendPosition:S,legendLayout:A,legendHoverBehavior:C,legendClickBehavior:M,legendHighlightedCategory:P,legendIsolatedCategories:I,foregroundGraphics:Fn(c,Gn(t?.customLayoutOverlays,R??null)),annotations:_,onAnnotationActivate:T,onObservation:L??N,chartId:$,chartType:"StreamNetworkFrame",autoPlaceAnnotations:B,svgAnnotationRules:D,annotationFrame:0}),Tw(_w,{marks:t?.customLayoutHtmlMarks,margin:r,selection:R??null})]})}function $w(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}function Bw(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Dw(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var jw=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):$w("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,n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n?this.pending.delete(n):this.pending.clear(),o.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 o.reject(e)}o.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(Dw());const n=this.nextRequestId;this.nextRequestId+=1;const o={requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),r(Dw())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(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()}},Ew=null;import{jsx as Fw,jsxs as Ow}from"react/jsx-runtime";var zw=/^(value|amount|total|count|weight|score)$/i;function Hw({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?Ow("div",{className:"semiotic-tooltip",style:tc,children:[Ow("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&&Ow("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 n=t.__hierarchyNode;if(n){const e=[];let o=n;for(;o;){const n=o.data?.name??o.data?.id??t.id;null!=n&&e.unshift(n+""),o=o.parent}e.length>1&&e.shift();const r=e.length-1;return Ow("div",{className:"semiotic-tooltip",style:tc,children:[Fw("div",{children:e.map((e,t)=>Ow("span",{children:[t>0&&Fw("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?Fw("strong",{children:e}):Fw("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&Fw("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const o=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),r=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=Zs(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>zw.test(e.key));return Ow("div",{className:"semiotic-tooltip",style:tc,children:[Fw("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>Ow("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",Ll(e.value)]},e.key)),!s&&null!=t.value&&t.value>0&&Ow("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&Ow("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function Ww(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Gw(e,t){if(!t.pathD)return;e.save();const n=Ww(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,0,o.x1,0),r=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=go(e,i)||i;n.addColorStop(0,1===o.from?a:"transparent"),n.addColorStop(1,1===o.to?a:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=Eo(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}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(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function qw(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=go(e,n)||n,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 Yw(e,t){if(!t.pathD)return;e.save();const n=Ww(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Eo(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),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(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function Vw(e,t){if(!t.pathD)return;e.save();const n=Ww(t),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),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Eo(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}Hw.ownsChrome=!0;var Xw=new Map;function Uw(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Xw.get(t);return n||(n=new Path2D(Tt(e.symbolType,e.size)),Xw.size>256&&Xw.clear(),Xw.set(t,n)),n}catch{return null}}function Kw(e){const{sceneNodes:t,nodes:n,nodeColorMap:o,colorScheme:r}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&o.set(e.id,e.style.fill);const i=Array.isArray(r)?r:Ee,a=Array.from(n);for(let e=0;a.length>e;e++){const t=a[e];o.has(t.id)||o.set(t.id,i[e%i.length])}return a.length}function Qw(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i);return a>Kn(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"rect":return function(e,t,n){const o=Un(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,r=n-e.cy,i=Math.sqrt(o*o+r*r);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Jn(Math.atan2(r,o)),s=Jn(e.startAngle),c=Jn(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,a=Math.sqrt(r*r+i*i);return a>Kn(Lt(e.size),o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,o);case"glyph":return function(e,t,n,o=30){if(null==e.datum)return null;const r=so(e.glyph,e.size),i=e.cx+r.centerDx,a=e.cy+r.centerDy,s=t-i,c=n-a,l=Math.sqrt(s*s+c*c);return l>Kn(r.radius,o)?null:{type:"node",datum:e.datum,x:i,y:a,distance:l}}(e,t,n,o);default:return null}}var Zw=null,Jw=null;function ek(){return Jw||((Zw=document.createElement("canvas")).width=1,Zw.height=1,Jw=Zw.getContext("2d")),Jw}function tk(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 nk(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=tk(e),r=ek();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,i=o*o+r*r;if(0===i)return null;let a=((t-e.x1)*o+(n-e.y1)*r)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*o,c=e.y1+a*r,l=Math.sqrt((t-s)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=tk(e),r=ek();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=r.lineWidth;r.lineWidth=10;const a=r.isPointInStroke(o,t,n);if(r.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function ok(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:u,hitRadius:d=30}=e,h=t-o.left-r.left,p=n-o.top-r.top;if(0>h||h>i||0>p||p>a)return{kind:"miss-outside"};const m=function(e,t,n,o,r=30,i,a=0){let s=null,c=r,l=1/0;if(i){const e=lo(i,n,o,r,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},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Qw(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(s=e,l=n)}else c>e.distance&&(s=e,c=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=nk(e,n,o);t&&c>t.distance&&(s=t,c=t.distance)}return s}(s,c,h,p,d,l,u);return m?{kind:"hit",hover:Ys(m.datum||{},m.x,m.y,{nodeOrEdge:m.type})}:{kind:"miss"}}import{useCallback as rk}from"react";var ik="StreamNetworkFrame";import{jsx as ak,jsxs as sk}from"react/jsx-runtime";var ck={top:20,right:80,bottom:20,left:80},lk={top:40,right:40,bottom:40,left:40},uk=new Set(["chord","force","circlepack","orbit"]),dk=[800,600],hk=iv(rv(function(e,t){const{chartType:n,nodes:o,edges:r,data:i,initialEdges:a,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:d="value",edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f="horizontal",nodeAlign:y="justify",nodePaddingRatio:g=.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:R="curve",padding:_,paddingTop:T,tensionConfig:L,showParticles:N=!1,particleStyle:$,renderMode:B,nodeStyle:D,edgeStyle:j,colorBy:E,colorScheme:F="category10",edgeColorBy:O="source",edgeOpacity:z=.5,colorByDepth:H=!1,nodeSize:W=8,nodeSizeRange:G=[5,20],nodeLabel:q,showLabels:V=!0,labelMode:X,size:U=dk,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:oe,customClickBehavior:re,onObservation:ie,annotationObservationCallback:ae,chartId:se,onTopologyChange:ce,annotations:le,onAnnotationActivate:ue,autoPlaceAnnotations:de,svgAnnotationRules:he,legend:pe,legendPosition:me,legendLayout:fe,legendHoverBehavior:ye,legendClickBehavior:ge,legendHighlightedCategory:be,legendIsolatedCategories:ve,title:xe,foregroundGraphics:we,backgroundGraphics:ke,decay:Se,pulse:Ae,transition:Ce,animate:Me,staleness:Pe,frameScheduler:Ie,clock:Re,random:_e,seed:Te,paused:Le=!1,suspendWhenHidden:Ne=!0,thresholds:$e,accessibleTable:Be=!0,description:De,summary:je,orbitMode:Fe,orbitSize:Oe,orbitSpeed:ze,orbitRevolution:He,orbitRevolutionStyle:We,orbitEccentricity:Ge,orbitShowRings:qe,orbitAnimated:Ye,customNetworkLayout:Ve,onLayoutError:Xe,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=uk.has(n)?lk:ck,Ze=Zb(!0),Je=Tc({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:xe,legend:pe,legendPosition:me,foregroundGraphics:we,backgroundGraphics:ke,animate:Me,transitionProp:Ce,frameScheduler:Ie,clock:Re,random:_e,seed:Te,paused:Le,suspendWhenHidden:Ne,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:ot,adjustedWidth:rt,adjustedHeight:it,resolvedForeground:at,resolvedBackground:st,transition:ct,introEnabled:lt,tableId:ut,rafRef:dt,renderFnRef:ht,scheduleRender:pt,frameRuntime:mt,currentTheme:ft}=Je,yt=qa(),gt=Ua(),bt=tv(()=>u(o),[o]),vt=tv(()=>Array.isArray(r)?u(r):r,[r]),xt=tv(()=>({...av,...L}),[L]),wt=tv(()=>({...sv,...$}),[$]),kt=tv(()=>{return{chartType:(e={chartType:n,clock:mt.now,random:_e,seed:Te,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:l,valueAccessor:d,edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f,nodeAlign:y,nodePaddingRatio:g,nodeWidth:b,iterations:v,forceStrength:x,padAngle:A,groupWidth:C,sortGroups:M,edgeSort:P,treeOrientation:I,edgeType:R,padding:_,paddingTop:T,tensionConfig:xt,showParticles:N,particleStyle:wt,nodeStyle:D,edgeStyle:j,nodeLabel:q,showLabels:V,labelMode:X,colorBy:E,colorScheme:F,edgeColorBy:O,edgeOpacity:z,colorByDepth:H,nodeSize:W,nodeSizeRange:G,decay:Se,pulse:Ae,transition:ct,introAnimation:lt,staleness:Pe,thresholds:$e,orbitMode:Fe,orbitSize:Oe,orbitSpeed:ze,orbitRevolution:He,orbitRevolutionStyle:We,orbitEccentricity:Ge,orbitShowRings:qe,orbitAnimated:Ye,customNetworkLayout:Ve,onLayoutError:Xe,layoutConfig:Ue,currentTheme:ft}).chartType,clock:e.clock,random:e.random,seed:e.seed,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},[n,mt.now,_e,Te,s,c,l,d,h,p,m,f,y,g,b,v,x,A,C,M,P,I,R,_,T,xt,N,wt,D,j,q,V,X,E,F,O,z,H,W,G,Se,Ae,ct,lt,Pe,$e,Fe,Oe,ze,He,We,Ge,qe,Ye,Ve,Xe,Ue,ft]),St=Qa(kt),At=Qa({chartType:(Ct={chartType:n,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:l,valueAccessor:d,edgeIdAccessor:h,childrenAccessor:p,hierarchySum:m,orientation:f,nodeAlign:y,nodePaddingRatio:g,nodeWidth:b,iterations:v,forceStrength:x,padAngle:A,groupWidth:C,sortGroups:M,edgeSort:P,treeOrientation:I,edgeType:R,padding:_,paddingTop:T,random:_e,seed:Te,tensionConfig:xt,customNetworkLayout:Ve,orbitMode:Fe,orbitSize:Oe,orbitEccentricity:Ge}).chartType,nodeIDAccessor:Ct.nodeIDAccessor,sourceAccessor:Ct.sourceAccessor,targetAccessor:Ct.targetAccessor,valueAccessor:Ct.valueAccessor,edgeIdAccessor:Ct.edgeIdAccessor,childrenAccessor:Ct.childrenAccessor,hierarchySum:Ct.hierarchySum,orientation:Ct.orientation,nodeAlign:Ct.nodeAlign,nodePaddingRatio:Ct.nodePaddingRatio,nodeWidth:Ct.nodeWidth,iterations:Ct.iterations,forceStrength:Ct.forceStrength,padAngle:Ct.padAngle,groupWidth:Ct.groupWidth,sortGroups:Ct.sortGroups,edgeSort:Ct.edgeSort,treeOrientation:Ct.treeOrientation,edgeType:Ct.edgeType,padding:Ct.padding,paddingTop:Ct.paddingTop,random:Ct.random,seed:Ct.seed,tensionConfig:Ct.tensionConfig,customNetworkLayout:Ct.customNetworkLayout,orbitMode:Ct.orbitMode,orbitSize:Ct.orbitSize,orbitEccentricity:Ct.orbitEccentricity});var Ct;const Mt=Zb(0),Pt=Zb(0),It=Zb(!1),Rt=Zb(null);Rt.current||(Rt.current=new ww(St));const _t=Dn("StreamNetworkFrame"),Tt=nv((e,t,n=!1)=>function(e,t,n,o=!1,r=!1){const i=e.beforeCompute(t.getLastUpdateResult(),o);n(),e.afterCompute(i,!0,r)}(_t.current,e,()=>e.buildScene(t),n),[_t]),[Lt,Nt]=Jb(null),[$t,Bt]=Jb(0),[Dt,jt]=Jb(0),[Et,Ft]=Jb(!1),[Ot,zt]=Jb(!1),Ht=Zb(0),Wt=Zb(null),Gt=Zb(!1),qt=Zb(S);qt.current=S;const Yt=Zb(St);Yt.current=St;const Vt=Zb(null),Xt=Zb(new Map),Ut=Zb(0),Kt=nv(e=>function(e){const{node:t,colorBy:n,colorScheme:o,nodeColorMap:r,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!r.has(e+"")){const t=Array.isArray(o)?o:Ee;r.set(e+"",t[i.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const a=Array.isArray(o)?o:Ee,s=n?a[i.current++%a.length]:a[0];return r.set(t.id,s),s}({node:e,colorBy:E,colorScheme:F,nodeColorMap:Xt.current,colorIndexRef:Ut}),[E,F]),Qt=(Zt=ft,Zt?.colors?.border||Zt?.colors?.secondary||Zt?.colors?.primary||"#999");var Zt;const Jt=nv(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Rt.current?.nodes),[]),en=nv(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:i}=e;if("function"==typeof n)return n(t);const a=r(t.source),s=r(t.target);return"target"===n&&s?o(s):a?o(a):i}({edge:e,edgeColorBy:O,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[O,Kt,Qt,Jt]),tn=nv(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:c}=e;if("function"==typeof n){const e=s(t.source);return e?n(t,e):c}if(!r)return i(t);const l=o,u=s(t.source),d=s(t.target);return"target"===l&&d?a(d):u?a(u):c}({edge:e,particleStyleColor:wt.color,particleColorBy:wt.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:en,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[$?.colorBy,wt.color,wt.colorBy,Kt,en,Qt,Jt]),nn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Ve,N,!!Ae,Rt.current?.isAnimating??!1);Vn(Rt,St,Ze,pt),Xn(Rt,Ke,Ze,pt),ev(()=>{const e=Rt.current;e&&(Tt(e,[rt,it]),Ut.current=Kw({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:F}),Ze.current=!0,pt())},[ft,rt,it,Tt,pt,F]);const on=nv(()=>{const e=Rt.current;if(e&&(e.runLayout([rt,it]),Tt(e,[rt,it]),Ze.current=!0,Ut.current=Kw({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:F}),Bt(e.layoutVersion),ce)){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[rt,it,Tt,ce,F]),rn=nv(e=>{if(null==e||"object"!=typeof e)return;const t=Rt.current;t&&(t.ingestEdge(e)&&on(),pt())},[on,pt]),an=nv(e=>{const t=Rt.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&on(),pt()},[on,pt]),sn=nv(()=>{Rt.current?.clear(),Xt.current.clear(),Ut.current=0,Bt(Rt.current?.layoutVersion??0),Nt(null),Vt.current=null,Ze.current=!0,pt()},[pt]),cn=nv(()=>{const e=Rt.current;e&&(e.tension+=999,on(),pt())},[on,pt]);ov(t,()=>({push:rn,pushMany:an,removeNode:e=>{const t=Rt.current?.removeNode(e)??!1;if(t){const t=Vt.current?.data?"function"==typeof s?s(Vt.current.data):Vt.current.data[s]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Nt(null)),Xt.current.delete(e),on(),Ze.current=!0,pt()}return t},removeEdge:(e,t)=>{const n=Rt.current?.removeEdge(e,t)??!1;if(n){if(Vt.current&&"edge"===Vt.current.nodeOrEdge){const n=Vt.current.data;let o;o=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,o&&(Vt.current=null,Nt(null))}on(),Ze.current=!0,pt()}return n},updateNode:(e,t)=>{const n=Rt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,pt()),n},updateEdge:(e,t,n)=>{const o=Rt.current?.updateEdge(e,t,n)??[];return o.length>0&&(on(),Ze.current=!0,pt()),o},clear:sn,getTopology:()=>Rt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Rt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Rt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Rt.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:cn,getTension:()=>Rt.current?.tension??0}),[rn,an,sn,cn,s,on,pt,h]);const ln=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),un=ln?i||(Array.isArray(r)?void 0:r):void 0;ev(()=>{const e=Rt.current;if(!e)return;const t=++Ht.current;if(Wt.current?.abort(),Wt.current=null,ln&&un)e.ingestHierarchy(un,[rt,it]),Tt(e,[rt,it]),zt(!1),qt.current?.("ready"),Ze.current=!0,pt();else{const i=bt,a=Array.isArray(vt)?vt:[];if(0===i.length&&0===a.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||sn(),zt(!1),void qt.current?.("ready");const s=[rt,it],c="force"===n&&!Ve&&Bw()&&!_e&&function(e,t,n,o,r=4e4){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(w,i.length,a.length,v);if(c&&gt&&!Gt.current&&e.sceneNodes.length>0)return Gt.current=!0,zt(!1),qt.current?.("ready"),Ze.current=!0,void pt();if(c){const n=new AbortController;Wt.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(i,a,s,{deferLayout:!0});const r=e.getLayoutData(),c=function(e,t,n,o,r){const i=Mx(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=r?.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,n="string"==typeof e.target?e.target:e.target.id,o=e.data?.weight,r="number"==typeof o&&Number.isFinite(o)?o:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:r}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:o}}(r.nodes,r.edges,Yt.current,s,o);return zt(!0),qt.current?.("pending"),function(e,t){return Bw()?t?.aborted?Promise.reject(Dw()):(Ew&&!Ew.isDead||(Ew=new jw),Ew).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Ht.current&&(e.applyForceLayoutPositions(n,s),Tt(e,s),Ut.current=Kw({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:F}),zt(!1),qt.current?.("ready"),Bt(e.layoutVersion),Ze.current=!0,pt())}).catch(n=>{"AbortError"!==n.name&&t===Ht.current&&(e.runLayout(s),Tt(e,s),Ut.current=Kw({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:F}),zt(!1),qt.current?.("error"),Bt(e.layoutVersion),Ze.current=!0,pt())}),()=>n.abort()}e.ingestBounded(i,a,s),Tt(e,s),zt(!1),qt.current?.("ready"),Ut.current=Kw({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:F}),Ze.current=!0,pt()}},[bt,vt,o,r,i,un,ln,rt,it,At,w,v,gt,n,Ve,_e,pt,sn,F,Tt]),ev(()=>{a&&a.length>0&&an(a)},[a,an]);const{customHoverBehavior:dn,customClickBehavior:hn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:rk((t,r)=>{e?.(t,r),Gl({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:ik,chartId:o,context:r})},[e,n,o]),customClickBehavior:rk((e,r)=>{t?.(e,r),ql({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:ik,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:oe,customClickBehavior:re,onObservation:ie,chartId:se}),{hoverHandlerRef:pn,hoverLeaveRef:mn,onPointerMove:fn,onPointerLeave:yn}=Je,gn=()=>!Ve||(Rt.current?.hasCustomRestyle??!1);pn.current=e=>{if(!te)return;const t=gn(),n=Cn.current;if(!n)return;const o=Rt.current;if(!o)return;const r=ok({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:ot,adjustedWidth:rt,adjustedHeight:it,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Vt.current=r.hover,Nt(r.hover),dn&&(dn(r.hover),t&&(Ze.current=!0)),t&&pt()):Vt.current&&(Vt.current=null,Nt(null),dn&&(dn(null),t&&(Ze.current=!0)),t&&pt())},mn.current=()=>{if(Vt.current){const e=gn();Vt.current=null,Nt(null),dn&&(dn(null),e&&(Ze.current=!0)),e&&pt()}};const bn=Zb(()=>{});bn.current=e=>{if(wi(e.target))return;if(!re&&!ie)return;const t=Cn.current;if(!t)return;const n=Rt.current;if(!n)return;const o=ok({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:ot,adjustedWidth:rt,adjustedHeight:it,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?hn(o.hover,{type:"activate",inputType:Hl(e.nativeEvent.pointerType)}):"miss"===o.kind&&hn(null)};const vn=nv(e=>bn.current(e),[]),xn=Zb(-1),wn=Zb(null),kn=Zb(-1),Sn=nv(e=>{if(Wl(e))return;const t=Rt.current;if(!t)return;const n=()=>{xn.current=-1,wn.current=null,kn.current=-1,Vt.current=null,Nt(null),dn&&(dn(null),Ze.current=!0),pt()},o=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=so(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return void(0>xn.current||n());const r=Kl(o);let i=xn.current;if(r.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=r.flat[i];return void hn(Ys(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),xn.current=0,kn.current=-1;const t=r.flat[0];wn.current={shape:t.shape,w:t.w,h:t.h};const n=Ys(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=n,Nt(n),dn&&(dn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void pt()}const a=Ql(r,i),s=function(e,t,n,o,r){const i=n.flat[t.flatIndex];if(!i)return Zl(e,t,n);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=function(e,t,n){let o=null,r=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,c=a.y-t.y;let l=!1;switch(n){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;r>u&&(r=u,o=i)}return o}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=nu(t.source),i=nu(t.target),a=null!=r,s=null!=i;a&&r+""===n&&s?o.push(i+""):s&&i+""===n&&a&&o.push(r+"")}return o}(a,o);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(r.current+1)%e.length])??-1;return 0>i?t.flatIndex:(r.current=-1,i)}default:{const o=Zl(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,a,r,t.sceneEdges??[],kn);if(null===s)return;if(e.preventDefault(),0>s)return void n();xn.current=s;const c=r.flat[s];wn.current={shape:c.shape,w:c.w,h:c.h};const l={data:c.datum||{},x:c.x,y:c.y,__semioticHoverData:!0,nodeOrEdge:"node"};Vt.current=l,Nt(l),dn&&(dn(l,{type:"focus",inputType:"keyboard"}),Ze.current=!0),pt()},[hn,dn,pt]),An=nv(e=>{xn.current=-1,wn.current=null,fn(e)},[fn]);ht.current=()=>{if(dt.current=null,!mt.isActive)return;const e=Cn.current;if(!e)return;const t=Rt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:i,adjustedWidth:a,adjustedHeight:s,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:p,random:m,reducedMotion:f,showParticles:y,isContinuous:g,animate:b,decay:v,pulse:x,thresholds:w,staleness:k,particleStyle:S,getParticleColor:A,pendingAnnotationFrameRef:C,lastAnnotationFrameTimeRef:M,setAnnotationFrame:P,scheduleNextFrame:I}=e,R=t.getContext("2d");if(!R)return;const _=h.current?Math.min((p-h.current)/1e3,.1):.016;h.current=p;const T=n.advanceTransition(f?p+1e6:p),L=!f&&T,N=!f&&n.tickAnimation([a,s],_),$=d.current,B=o?.beforeCompute(n.getLastUpdateResult(),L),D=T||$||N;D&&n.buildScene([a,s]),B&&o?.afterCompute(B,D,!1);const j=y&&!f&&!!n.particlePool,E=ns({dirtyOrRebuilt:$,transitioning:L,animationTicked:N,continuous:j||g,liveEncoding:!!v||!!x||!!w||!1!==b&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}),F=!!k&&n.lastIngestTime>0&&p-n.lastIngestTime>(k?.threshold??5e3);if(E){const e=Oc();if(!Fc(t,r,i,e))return;if(R.clearRect(-i.left,-i.top,r[0],r[1]),ts(R,{background:c,hasBackgroundGraphics:u,width:a,height:s}),v&&n.applyDecay(),x&&n.applyPulse(p),w&&n.applyThresholds(p),!1!==b&&n.applyTopologyDiff(p),F&&(R.globalAlpha=k?.dimOpacity??.5),Ml({context:R,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Gw(e,n);break;case"line":qw(e,n);break;case"ribbon":Yw(e,n);break;case"curved":Vw(e,n)}}(R,e)}),Ml({context:R,nodes:n.sceneNodes,renderMode:l,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=Eo(e,t.style.fill,"#007bff"),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)),tl(e,t),e.restore())}}(R,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;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=Eo(e,t.style.fill,"#007bff"),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()),nl(e,t),e.restore())}}(R,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;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=Eo(e,t.style.fill,"#007bff"),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()}}(R,t),function(e,t){const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Uw(t);if(!r)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=n*i*(t.style.fillOpacity??1),e.fillStyle=Eo(e,t.style.fill,"#007bff"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=go(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&hl(e,o,o.cx,o.cy,n);e.globalAlpha=n}(R,t)}}),j&&!F){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const i=o.spawnRate??.1,a=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const s=t[o];if(!s.bezier)continue;if(e.countForEdge(o)>=a)continue;const c=s.value*i*n*(s.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let d=l;r()<u&&d++;for(let t=0;d>t&&e.countForEdge(o)<a;t++)e.spawn(o,r)}}(n.particlePool,e,_,S,m);const t=.5*(S.speedMultiplier??1);let o;if(S.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(_,t,e,o),function(e,t,n,o,r){const i=o.radius??3;e.globalAlpha=o.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const c=n[s.edgeIndex];if(!c)continue;let l;l="string"==typeof o.color&&"inherit"!==o.color?o.color:r(c),e.fillStyle=go(e,l)||l,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(R,n.particlePool,e,S,A)}}F&&(R.globalAlpha=1)}d.current=!1,($||L||N)&&t.setAttribute("aria-label",ks(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const O=$||L||N||C.current;O&&p-M.current>=33?(P(e=>e+1),M.current=p,C.current=!1):C.current=!!O,(g||L||null!=n.transition||N||n.hasActivePulses||n.hasActiveThresholds||!1!==b&&n.hasActiveTopologyDiff||C.current)&&I()}({canvas:e,store:t,sceneRevisionDiagnostics:_t.current,size:nt,margin:ot,adjustedWidth:rt,adjustedHeight:it,background:ee,renderMode:B,hasBackgroundGraphics:!!ke,dirtyRef:Ze,lastFrameTimeRef:Mt,now:mt.now(),random:mt.random,reducedMotion:!!et.current,showParticles:N,isContinuous:nn,animate:Me,decay:Se,pulse:Ae,thresholds:$e,staleness:Pe,particleStyle:wt,getParticleColor:tn,pendingAnnotationFrameRef:It,lastAnnotationFrameTimeRef:Pt,setAnnotationFrame:jt,scheduleNextFrame:()=>{pt()}})};const{canvasRef:Cn}=Bc(Je,{hydrated:yt,wasHydratingFromSSR:gt,storeRef:Rt,dirtyRef:Ze,canvasPaintDependencies:[n,rt,it,ee,ke,B,pt]});cr(Pe,Rt,Ze,pt,Et,Ft);const Mn=te&&Lt?ak(lc,{x:Lt.x,y:Lt.y,containerWidth:rt,containerHeight:it,margin:ot,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Lt):ak(Hw,{data:Lt})}):null;if(Ea||!yt&&gt)return ak(Nw,{props:e,store:Rt.current,responsiveRef:tt,size:nt,margin:ot,adjustedWidth:rt,adjustedHeight:it,resolvedBackground:st,resolvedForeground:at});const Pn=Rt.current;return sk("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":De||("string"==typeof xe?xe:"Network chart"),tabIndex:0,"aria-busy":Ot||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Sn,children:["production"!==process.env.NODE_ENV&&Rt.current&&ak(jn,{store:Rt.current,diagnostics:_t.current}),Be&&ak(Fs,{tableId:ut}),Be&&ak(js,{nodes:Pn?.sceneNodes??[],edges:Pn?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof xe?xe:void 0}),ak(Es,{summary:je}),ak(ms,{hoverPoint:Lt}),sk("div",{role:"img","aria-label":De||("string"==typeof xe?xe:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?An:void 0,onMouseLeave:te?yn:void 0,onClick:re||ie?vn:void 0,children:[Ot&&!1!==k&&ak("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:sh(!0,nt[0],nt[1],k)}),ak(Dc,{size:nt,margin:ot,overflowVisible:!0,children:st}),ak("canvas",{ref:Cn,"aria-label":ks(Pn?.sceneNodes?.length??0,Pn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),ak(Mw,{width:rt,height:it,totalWidth:nt[0],totalHeight:nt[1],margin:ot,labels:Pn?.labels||[],sceneNodes:Pn?.sceneNodes,title:xe,legend:pe,legendPosition:me,legendLayout:fe,legendHoverBehavior:ye,legendClickBehavior:ge,legendHighlightedCategory:be,legendIsolatedCategories:ve,foregroundGraphics:Fn(at,Gn(Rt.current?.customLayoutOverlays,Ke??null)),annotations:le,onAnnotationActivate:ue,onObservation:ae??ie,chartId:se,chartType:"StreamNetworkFrame",autoPlaceAnnotations:de,svgAnnotationRules:he,annotationFrame:Dt}),ak(_w,{marks:Pn?.customLayoutHtmlMarks,margin:ot,selection:Ke??null}),ak(Hs,{active:xn.current>=0,hoverPoint:Lt,margin:ot,size:nt,shape:wn.current?.shape,width:wn.current?.w,height:wn.current?.h}),Mn,Pe?.showBadge&&ak(ur,{isStale:Et,position:Pe.badgePosition})]})]})}));hk.displayName="StreamNetworkFrame";var pk=hk;import{useMemo as mk}from"react";function fk(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function yk(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function gk(e){return"function"==typeof e?e:t=>t[e]||1}function bk({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s={fillOpacity:r,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=He(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=He(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function vk(e){const{nodes:t,edges:n,inferNodes:o=!0,sourceAccessor:r="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:c,legendPosition:l,legendInteraction:d,selection:h,linkedHover:p,onObservation:m,onClick:f,mobileInteraction:y,mobileSemantics:g,chartType:b,chartId:v,marginDefaults:x,userMargin:w,width:k,height:S,loading:A,loadingContent:C,emptyContent:M,emptyDataKey:P="edges"}=e,I=mk(()=>u(n),[n]),R=mk(()=>u(t),[t]),_=sh(A,k,S,C),T=_?null:ah("nodes"===P?void 0===t?void 0:R:void 0===n?void 0:I,k,S,M),L=mk(()=>o?yk(R,I,r,i):R,[o,R,I,r,i]),N=Od(L,a,s),$=Ed(),B=mk(()=>{if(Array.isArray(s))return s;if($&&$.length>0)return $;if("string"==typeof s){const e=je[s];if(Array.isArray(e)&&e.length>0)return e}return Ee},[s,$]),D=mk(()=>{if(!a)return[];const e=new Set;for(const t of L){const n="function"==typeof a?a(t):t[a];null!=n&&e.add(n+"")}return Array.from(e)},[L,a]),j=qd(d,a,D),{legend:E,margin:F,legendPosition:O}=Gd({data:L,colorBy:a,colorScale:N,showLegend:c,legendPosition:l,userMargin:w,defaults:x,categories:D}),z=mk(()=>jd(y,{width:k,mobileSemantics:g}),[y,k,g]),H=Hd({selection:h,linkedHover:p,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:m,onClick:f,mobileInteraction:z,chartType:b,chartId:v}),{customHoverBehavior:W,customClickBehavior:G,activeSelectionHook:q,hoverSelectionHook:Y,crosshairSourceId:V}=H;return{safeNodes:L,safeEdges:I,colorScale:N,effectivePalette:B,themeCategorical:$,allCategories:D,legendState:j,legend:E,margin:F,legendPosition:O,mobileInteraction:z,customHoverBehavior:W,customClickBehavior:G,activeSelectionHook:q,hoverSelectionHook:Y,crosshairSourceId:V,loadingEl:_,emptyEl:T}}import{jsx as xk}from"react/jsx-runtime";var wk=Kb(function(e,t){const n=Qb(null);Nh(t,{variant:"network",frameRef:n});const o=Vd(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:r,edges:i,margin:a,className:s,nodeIdAccessor:c,nodeIDAccessor:l,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:p,colorScheme:m,styleRules:f,nodeSize:y=8,nodeSizeRange:g=[5,20],edgeWidth:b=1,edgeColor:v="#999",edgeOpacity:x=.6,iterations:w=300,forceStrength:k=.1,layoutExecution:S="auto",layoutLoadingContent:A,onLayoutStateChange:C,tooltip:M,frameProps:P={},onObservation:I,onClick:R,chartId:_,selection:T,linkedHover:L,loading:N,loadingContent:$,emptyContent:B,legendInteraction:D,legendPosition:j,stroke:E,strokeWidth:F,opacity:O}=e,z=c??l??"id",{width:H,height:W,enableHover:G,showLegend:q,showLabels:Y=!1,title:V,description:X,summary:U,accessibleTable:K}=o,Q=vk({nodes:r,edges:i,inferNodes:!1,nodeIdAccessor:z,sourceAccessor:u,targetAccessor:d,colorBy:p,colorScheme:m,showLegend:q,legendPosition:j,legendInteraction:D,selection:T,linkedHover:L,onObservation:I,onClick:R,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ForceDirectedGraph",chartId:_,marginDefaults:o.marginDefaults,userMargin:a,width:H,height:W,loading:N,loadingContent:$,emptyContent:B,emptyDataKey:"nodes"}),Z=Ub(()=>new Map,[]),J=Ub(()=>e=>{const t={};return t.fill=p?He(e.data||e,p,Q.colorScale):Fd(void 0,Q.themeCategorical,m,void 0,Z),"number"==typeof y&&(t.r=y),t},[p,Q.colorScale,y,Q.themeCategorical,m,Z]),ee=Ub(()=>Mh(p,"number"==typeof y?void 0:y),[p,y]),te=Ub(()=>Sh(_h(J,f,ee,e=>e.data||e),{stroke:E,strokeWidth:F,opacity:O}),[J,f,ee,E,F,O]),ne=Ub(()=>e=>{const t=e.data||e;let n;if("number"==typeof b)n=b;else if("function"==typeof b)n=b(t);else{const e=t[b],o="number"==typeof e?e:Number(e);n=Number.isFinite(o)&&o>0?o:1}return{stroke:v,strokeWidth:n,opacity:x}},[b,v,x]),oe=Ub(()=>Sh(ne,{stroke:E,strokeWidth:F,opacity:O}),[ne,E,F,O]),re=Ub(()=>{if(Y&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[Y,h]),ie=fh({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:z}});return ie?xk(Qd,{componentName:"ForceDirectedGraph",message:ie,width:H,height:W}):Q.loadingEl?Q.loadingEl:Q.emptyEl?Q.emptyEl:xk(oh,{componentName:"ForceDirectedGraph",width:H,height:W,children:xk(pk,{ref:n,chartType:"force",...null!=r&&{nodes:Q.safeNodes},...null!=i&&{edges:Q.safeEdges},size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Q.margin,nodeIDAccessor:z,sourceAccessor:u,targetAccessor:d,iterations:w,forceStrength:k,layoutExecution:S,layoutLoadingContent:A,onLayoutStateChange:C,nodeStyle:te,edgeStyle:oe,colorBy:p,colorScheme:Q.effectivePalette,nodeSize:y,nodeSizeRange:g,nodeLabel:re,showLabels:Y,enableHover:G,tooltipContent:!1===M?()=>null:sc(M)||void 0,...Bh({linkedHover:L,selection:T,onObservation:I,onClick:R,mobileInteraction:Q.mobileInteraction,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:Q.legend,legendPosition:Q.legendPosition,...D&&"none"!==D&&{legendHoverBehavior:Q.legendState.onLegendHover,legendClickBehavior:Q.legendState.onLegendClick,legendHighlightedCategory:Q.legendState.highlightedCategory,legendIsolatedCategories:Q.legendState.isolatedCategories},className:s,title:V,description:X,summary:U,accessibleTable:K,...null!=e.animate&&{animate:e.animate},...P})})});wk.displayName="ForceDirectedGraph";import{useMemo as kk,forwardRef as Sk,useRef as Ak}from"react";import{jsx as Ck}from"react/jsx-runtime";var Mk=Sk(function(e,t){const n=Ak(null);Nh(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=Vd(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:r,edges:i,margin:a,className:s,sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,styleRules:m,edgeColorBy:f="source",padAngle:y=.01,groupWidth:g=20,sortGroups:b,nodeLabel:v,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:S,onClick:A,chartId:C,selection:M,linkedHover:P,loading:I,loadingContent:R,emptyContent:_,legendInteraction:T,stroke:L,strokeWidth:N,opacity:$}=e,{width:B,height:D,enableHover:j,showLabels:E=!0,title:F,description:O,summary:z,accessibleTable:H}=o,W=vk({nodes:r,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,showLegend:!1,legendInteraction:T,selection:M,linkedHover:P,onObservation:S,onClick:A,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ChordDiagram",chartId:C,marginDefaults:o.marginDefaults,userMargin:a,width:B,height:D,loading:I,loadingContent:R,emptyContent:_}),G=kk(()=>new Map,[]),q=W.safeNodes.length>0,Y=kk(()=>{if(q)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=He(e.data||e,h,W.colorScale);else{const o=Array.isArray(p)?p:je[p]||Ee,r=Array.isArray(o)?o:Ee;n.fill=r[(e.index??t??0)%r.length]}return n}},[q,h,W.colorScale,p]),V=kk(()=>Mh(h),[h]),X=kk(()=>{if(Y||m&&m.length>0)return Sh(_h(Y,m,V,e=>e.data||e),{stroke:L,strokeWidth:N,opacity:$})},[Y,m,V,L,N,$]),U=kk(()=>{if(q)return bk({edgeColorBy:f,colorBy:h,colorScale:W.colorScale,nodeStyleFn:X||(e=>({fill:Fd(void 0,W.themeCategorical,p,void 0,G)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[q,f,h,W.colorScale,X,x,W.themeCategorical,p,G]),K=kk(()=>U?Sh(U,{stroke:L,strokeWidth:N,opacity:$}):void 0,[U,L,N,$]),Q=kk(()=>{if(!E)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[E,v,d]),Z=fh({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return Z?Ck(Qd,{componentName:"ChordDiagram",message:Z,width:B,height:D}):W.loadingEl?W.loadingEl:W.emptyEl?W.emptyEl:Ck(oh,{componentName:"ChordDiagram",width:B,height:D,children:Ck(pk,{ref:n,chartType:"chord",...W.safeNodes.length>0&&{nodes:W.safeNodes},...null!=i&&{edges:W.safeEdges},size:[B,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:W.margin,nodeIDAccessor:d,sourceAccessor:c,targetAccessor:l,valueAccessor:u,padAngle:y,groupWidth:g,sortGroups:b,nodeStyle:X,edgeStyle:K,colorBy:h,colorScheme:W.effectivePalette,edgeColorBy:f,edgeOpacity:x,nodeLabel:Q,showLabels:E,enableHover:j,tooltipContent:!1===w?()=>null:sc(w)||void 0,...Bh({linkedHover:P,selection:M,onObservation:S,onClick:A,mobileInteraction:W.mobileInteraction,customHoverBehavior:W.customHoverBehavior,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...T&&"none"!==T&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:s,title:F,description:O,summary:z,accessibleTable:H,...null!=e.animate&&{animate:e.animate},...k})})});Mk.displayName="ChordDiagram";import{useMemo as Pk,forwardRef as Ik,useRef as Rk}from"react";import{jsx as _k}from"react/jsx-runtime";var Tk=Ik(function(e,t){const n=Rk(null);Nh(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=Vd(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:r,edges:i,margin:a,className:s,sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,styleRules:m,edgeColorBy:f="source",orientation:y="horizontal",nodeAlign:g="justify",nodePaddingRatio:b=.05,nodeWidth:v=15,nodeLabel:x,edgeOpacity:w=.5,edgeSort:k,tooltip:S,frameProps:A={},onObservation:C,onClick:M,chartId:P,selection:I,linkedHover:R,loading:_,loadingContent:T,emptyContent:L,showLegend:N,legendPosition:$,legendInteraction:B,stroke:D,strokeWidth:j,opacity:E}=e,{width:F,height:O,enableHover:z,showLabels:H=!0,title:W,description:G,summary:q,accessibleTable:Y}=o,V=vk({nodes:r,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,showLegend:N,legendPosition:$,legendInteraction:B,selection:I,linkedHover:R,onObservation:C,onClick:M,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"SankeyDiagram",chartId:P,marginDefaults:o.marginDefaults,userMargin:a,width:F,height:O,loading:_,loadingContent:T,emptyContent:L}),X=Pk(()=>new Map,[]),U=Pk(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?He(e.data||e,h,V.colorScale):Fd(void 0,V.themeCategorical,p,void 0,X),t},[h,V.colorScale,V.themeCategorical,p,X]),K=Pk(()=>Mh(h,u),[h,u]),Q=Pk(()=>Sh(_h(U,m,K,e=>e.data||e),{stroke:D,strokeWidth:j,opacity:E}),[U,m,K,D,j,E]),Z=Pk(()=>bk({edgeColorBy:f,colorBy:h,colorScale:V.colorScale,nodeStyleFn:Q,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[f,h,V.colorScale,Q,w]),J=Pk(()=>Sh(Z,{stroke:D,strokeWidth:j,opacity:E}),[Z,D,j,E]),ee=Pk(()=>{if(!H)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[H,x,d]),te=fh({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?_k(Qd,{componentName:"SankeyDiagram",message:te,width:F,height:O}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:_k(oh,{componentName:"SankeyDiagram",width:F,height:O,children:_k(pk,{ref:n,chartType:"sankey",...V.safeNodes.length>0&&{nodes:V.safeNodes},...null!=i&&{edges:V.safeEdges},size:[F,O],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:V.margin,nodeIDAccessor:d,sourceAccessor:c,targetAccessor:l,valueAccessor:u,orientation:y,nodeAlign:g,nodePaddingRatio:b,nodeWidth:v,nodeStyle:Q,edgeStyle:J,colorBy:h,colorScheme:V.effectivePalette,edgeColorBy:f,edgeOpacity:w,edgeSort:k,nodeLabel:ee,showLabels:H,enableHover:z,tooltipContent:!1===S?()=>null:sc(S)||void 0,...Bh({linkedHover:R,selection:I,onObservation:C,onClick:M,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:V.legend,legendPosition:V.legendPosition,...B&&"none"!==B&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},className:s,title:W,description:G,summary:q,accessibleTable:Y,...null!=e.animate&&{animate:e.animate},...A})})});Tk.displayName="SankeyDiagram";import{useMemo as Lk,useState as Nk,useRef as $k,useCallback as Bk}from"react";import{scaleTime as Dk}from"d3-scale";import{forwardRef as jk}from"react";function Ek(e,n,o){const r=n.incoming[e.id],i=n.outgoing[e.id],a=[];for(const e of r)a.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)a.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{a.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},l=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!=l&&Number.isFinite(l)?l-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};c();const f=[];let y=0,g=0;for(const e of a)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:g);if(o>0){const r=m(e.time);f.push({time:r,delta:-o,kind:"transfer-out",side:t}),f.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:g-=o,"top"===e.side?y+=o:g+=o,n-=o}n>0&&null!==d&&(f.push({time:d,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}a.push(...f),c();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 R=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===R||e.systemOutTime>R)&&(R=e.systemOutTime);if(C.length>0){const e=C[C.length-1],t=Math.max(null!=P?P:-1/0,null!=R?R:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&C.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=C[0],o=Math.min(null!=u?u:1/0,null!=I?I:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&C.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:C,peak:x,topPeak:w,botPeak:k,localAttachments:A}}function Fk(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ok(e,t){return e.map(e=>({t:Fk(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function zk(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function Hk(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],a=t[r];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]&&n++)}return n}function Wk(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function Gk(e,t){return 1e3*Hk(e,t)+Wk(e,t)}function qk(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Yk(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=qk(e,t),a=Gk(t,n);for(let s=0;o>s;s++){const o=Array(r).fill(0),s=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),s[n]+=e.value||1,o[r]+=n*(e.value||1),s[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(s[e]>0?o[e]/s[e]:e)-(s[t]>0?o[t]/s[t]:t)),l=c.map(t=>e[t]),u=new Map;c.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 l)e.push(t);const d=Gk(t,n);if(a>d)a=d,i=qk(e,t);else if(d===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=Gk(t,n);for(let a=0;o>a;a++){let o=!1;for(let a=0;r-1>a;a++){const r=e[a];e[a]=e[a+1],e[a+1]=r;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const s=Gk(t,n);if(i>s)i=s,o=!0;else{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)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r={...t},i=Object.keys(r),a=Array.from({length:o},(e,t)=>t),s=a.slice(),c={...r};let l=a.slice(),u=1/0;const d=()=>{for(const e of i)c[e]=s[r[e]];const e=Gk(c,n);u>e&&(u=e,l=a.slice())},h=(e,t)=>{const n=a[e],o=a[t];a[e]=o,a[t]=n,s[n]=t,s[o]=e};d();const p=Array(o).fill(0);let m=0;for(;o>m;)m>p[m]?(h(m%2==0?0:p[m],m),d(),p[m]++,m=0):(p[m]=0,m++);const f=l.map(t=>e[t]),y=new Map;l.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,n)}function Vk(e,t,n,o,r){const{plotH:i,padding:a,valueScale:s,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const p="half"===u,m={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=p?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=p?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=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(r)?r:null,end:Number.isFinite(i)?i:null}}const f={},y=[];if("reuse"===c){const n=new Map;for(const t of e)n.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(r.get(e.target)??0)+1);const i=[];for(const t of e)0===(r.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of o.outgoing[e]??[]){const o=(n.get(e)??0)+1;o>(n.get(t.target)??0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&i.push(t.target)}}const a=[...e].filter(e=>null!==m[e.id].start).sort((e,t)=>{const o=n.get(e.id)??0,r=n.get(t.id)??0;return o!==r?o-r: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 n=-1;for(let e=0;y.length>e;e++){const o=y[e].occupants[y[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(y.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=y.length-1),y[n].occupants.push({id:e.id,end:t?.end??-1/0}),y[n].peak.topPeak=Math.max(y[n].peak.topPeak,d[e.id]),y[n].peak.botPeak=Math.max(y[n].peak.botPeak,h[e.id]),f[e.id]=n}}else e.forEach((e,t)=>{y.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 g=null,b=null,v=null,x=null;const w=()=>{g=Hk(f,t),v=Wk(f,t)},k=()=>{b=Hk(f,t),x=Wk(f,t)};"crossing-min"===l?(w(),Yk(y,f,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=r[0].idx;let s=a-1,c=a+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>s?i[c++]=r[e].idx:i[s--]=r[e].idx;const l=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 l)e.push(t)}(y,f),k()):"crossing-min+inside-out"===l&&(w(),Yk(y,f,t),function(e,t,n){const o=e.length;if(1>=o)return;const r=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((o-1)/2);let a=Gk(t,n);for(const{slot:s}of r){const r=e.indexOf(s);if(0>r)continue;const c=i;if(r===c)continue;const l=e[r];e.splice(r,1),e.splice(c,0,l);const u=new Map;for(let e=0;o>e;e++)u.set(e,e);if(c>r){for(let e=r+1;c>=e;e++)u.set(e,e-1);u.set(r,c)}else{for(let e=c;r>e;e++)u.set(e,e+1);u.set(r,c)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Gk(t,n);if(d>a){const n=e[c];e.splice(c,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)i.set(e,e-1);i.set(c,r)}else{for(let e=r;c>e;e++)i.set(e,e+1);i.set(c,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=d}}(y,f,t),k());const S=y.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},C=[];for(let e=0;y.length-1>e;e++){const t=S[e],n=S[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=A(t,e),i=A(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}C.push(r)}const M=[];let P=a+(y[0]?.peak.topPeak??0)*s;y.length>0&&M.push(P);for(let e=1;y.length>e;e++)P+=C[e-1]*s+a,M.push(P);if(y.length>0&&(P+=y[y.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===y.length?0:y[0].peak.topPeak+C.reduce((e,t)=>e+t,0)+y[y.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=M[f[t.id]];return{effectiveSlotsHeight:I,centerlines:R,laneLifetime:m,slots:y,slotByNode:f,slotCenter:M,crossingsBefore:g,crossingsAfter:b,lengthBefore:v,lengthAfter:x}}var Xk=e=>{const{bands:t=[],ribbons:n=[],showLabels:o=!0}=e.config,r=[];for(const e of n)r.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 n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)r.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=o?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:r,labels:i}};function Uk(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Kk,jsx as Qk,jsxs as Zk}from"react/jsx-runtime";function Jk(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function eS(e,t){return"function"==typeof e?e(t):t[e]}var tS=jk(function(e,t){const{nodes:n,edges:o,domain:r,axisTicks:i=[],nodeIdAccessor:a="id",sourceAccessor:s="source",targetAccessor:c="target",valueAccessor:l="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:m,xExtentAccessor:f="xExtent",edgeIdAccessor:y="id",colorBy:g,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:R=600,height:_=400,margin:T,title:L,description:N,summary:$,accessibleTable:B,responsiveWidth:D,responsiveHeight:j,loading:E,loadingContent:F,emptyContent:O,edgeOpacity:z=.35,timeFormat:H,valueFormat:W,tooltip:G,enableHover:q=!0,onObservation:Y,onClick:V,showParticles:X=!1,particleStyle:U,chartId:K,frameProps:Q={}}=e,[Z,J]=Nk([]),[ee,te]=Nk([]),ne=$k(Z),oe=$k(ee);ne.current=Z,oe.current=ee;const re=Bk(e=>{ne.current=e,J(e)},[]),ie=Bk(e=>{oe.current=e,te(e)},[]),ae=void 0!==o,se=u(ae?o:Z),ce=Lk(()=>{const e=u(n??[]),t=ee;if(0===e.length&&0===t.length)return yk([],se,s,c);const o=new Set,r=[];for(const t of e){const e=eS(a,t)+"";o.has(e)||(o.add(e),r.push(t))}for(const e of t){const t=eS(a,e)+"";o.has(t)||(o.add(t),r.push(e))}const i=yk([],se,s,c);for(const e of i)o.has(e.id)||(o.add(e.id),r.push(e));return r},[n,ee,se,a,s,c]),le=$k(null),ue=Bk((e,t)=>{const n=eS(y,e);return null!=n?n+"":`${eS(s,e)}-${eS(c,e)}-${t}`},[y,s,c]),de=Bk(e=>{if(null==e)return!1;const t=e;return null!=eS(s,t)&&null!=eS(c,t)},[s,c]);Nh(t,{variant:"network",frameRef:le,overrides:{push(e){if(de(e)){if(ae)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");re([...ne.current,e])}else ie([...oe.current,e])},pushMany(e){const t=[],n=[];for(const o of e)de(o)?t.push(o):n.push(o);t.length>0&&(ae?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):re([...ne.current,...t])),n.length>0&&ie([...oe.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ae){const e=ne.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(ue(i,r))?n.push(i):o.push(i)}o.length!==e.length&&re(o)}const o=oe.current,r=[];for(const e of o){const o=eS(a,e)+"";t.has(o)?n.push(e):r.push(e)}return r.length!==o.length&&ie(r),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!ae){let e=!1;const r=ne.current.map((r,i)=>n.has(ue(r,i))?(o.push(r),e=!0,t(r)):r);e&&re(r)}let r=!1;const i=oe.current.map(e=>{const i=eS(a,e)+"";return n.has(i)?(o.push(e),r=!0,t(e)):e});return r&&ie(i),o},clear(){ae||re([]),ie([]),le.current?.clear()},getData:()=>se??[],getScales:()=>null}});const he=ue,pe=Bk(e=>eS(a,e)+"",[a]),{nodes:me,edges:fe,domain:ye,rawNodeById:ge,rawEdgeById:be}=Lk(()=>{const e=(ce??[]).map(e=>{const t={id:pe(e),__raw:e},n=f?eS(f,e):null;if(Array.isArray(n)&&2===n.length){const e=Jk(n[0]),o=Jk(n[1]);Number.isFinite(e)&&Number.isFinite(o)&&(t.xExtent=[e,o])}return t}),t=(se??[]).map((e,t)=>{const n={id:he(e,t),source:eS(s,e)+"",target:eS(c,e)+"",value:Number(eS(l,e)),startTime:Jk(eS(d,e)),endTime:Jk(eS(h,e)),__raw:e};if(p){const t=Jk(eS(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(m){const t=Jk(eS(m,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Jk(r[0]),Jk(r[1])],o=new Map;for(const t of e)null!=t.__raw&&o.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:n,rawNodeById:o,rawEdgeById:i}},[ce,se,r,pe,he,f,s,c,l,d,h,p,m]),ve=vk({nodes:ce,edges:se,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:s,targetAccessor:c,colorBy:g,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:T,width:R,height:_,loading:E,loadingContent:F,emptyContent:O}),xe=(v??!!g)&&!!g,we=Bk(e=>null!=T&&("number"==typeof T||null!=T[e]),[T]),ke=Lk(()=>{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=R-ke.left-ke.right,Ae=_-ke.top-ke.bottom,Ce=Lk(()=>function(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||o.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]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.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||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}(me,fe,ye),[me,fe,ye]),Me=Lk(()=>Ce.length>0?null:function(e,t,n){const{plotH:o,pairing:r="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),l=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(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 n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const a=[...n.values()];a.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:r);return a};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(o,"source"),n=s(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=o}}}return a}(e,t,c,r);let u={};for(const t of e)u[t.id]=Ek(t,c,l);const d=Vk(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=l.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(h.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,a="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=a)return!1;const s=Math.min(i,a),c=n.filter(t=>!h.has(t.id)&&l.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=Ek(t,c,l);const p=Vk(e,t,u,c,{plotH:o,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*o/Math.max(p.slots.length+1,1)),y=m>0?Math.max(0,(o-f*(p.slots.length+1))/m):1,g=Vk(e,t,u,c,{plotH:o,padding:f,valueScale:y,packing:i,laneOrder:a,lifetimeMode:s});return{nodeData:u,sides:l,valueScale:y,padding:f,compressedPadding:12>f,centerlines:g.centerlines,laneLifetime:g.laneLifetime,slots:g.slots,slotByNode:g.slotByNode,crossingsBefore:g.crossingsBefore,crossingsAfter:g.crossingsAfter,lengthBefore:g.lengthBefore,lengthAfter:g.lengthAfter}}(me,fe,{plotH:Ae,pairing:w,packing:k,laneOrder:S,lifetimeMode:C}),[Ce,me,fe,Ae,w,k,S,C]),Pe=Lk(()=>Dk().domain(ye).range([0,Se]),[ye,Se]),Ie=Bk((e,t)=>{if(g&&ce){const t=ge.get(e);if(t)return He(t,g,ve.colorScale)}return ve.effectivePalette[t%ve.effectivePalette.length]||"#475569"},[g,ce,ge,ve.colorScale,ve.effectivePalette]),Re=Lk(()=>{const e=new Map;return me.forEach((t,n)=>e.set(t.id,n)),e},[me]),_e=Lk(()=>{if(!Me)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Me,o=[],r=[];return me.forEach((r,i)=>{const a=t[r.id];if(!a||0===a.samples.length)return;const s=function(e,t,n,o,r){if(0===e.length)return null;const i=Ok(e,r),a=e=>t-i[e].topMass*n,s=e=>t+i[e].botMass*n;let c=`M${o(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)c+=` L${o(i[e].t)},${a(e)}`;c+=` L${o(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)c+=` L${o(i[e].t)},${s(e)}`;return c+" Z"}(a.samples,e[r.id],n,Pe,ye);if(!s)return;const c=Ok(a.samples,ye),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=e[r.id]+(l.botMass-l.topMass)*n/2,d=Ie(r.id,i),h=ge.get(r.id)??r,p=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,s=n.centerlines[e],c=Ok(i.samples,r),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=o(l.t),h=o(u.t),p=e=>o(Fk(e,r)),m=[],f=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=p(n.systemInTime),o=p(n.startTime),r=t-20,i=Math.max(d,r);if(o>i){const[n,c]=zk(e,s,a);m.push({pathD:f(i,n,o,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=p(n.systemOutTime),o=p(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,c]=zk(e,s,a);m.push({pathD:f(o,n,i,c),x0:t,x1:r,from:1,to:0})}}}}return m}(r.id,fe,Me,Pe,ye);o.push({id:r.id,pathD:s,fill:d,stroke:d,strokeWidth:.5,...p.length>0&&{gradientStubs:p},rawDatum:h,labelX:Pe(l.t)-4,labelY:u,labelText:r.id})}),fe.forEach(o=>{const i=t[o.source]?.localAttachments.get(o.id),a=t[o.target]?.localAttachments.get(o.id);if(!i||!a)return;const s=Re.get(o.source)??0,c=Ie(o.source,s),l=function(e,t,n,o,r,i,a,s){const c=r,l=e=>s?Math.max(s[0],Math.min(s[1],e)):e,u=i(l(e.time)),d=i(l(n.time)),h=e.value*c,p=n.value*c,m=e.sideMassBefore*c,f=n.sideMassAfter*c;let y,g,b,v;"top"===e.side?(y=t-m,g=y+h):(g=t+m,y=g-h),"top"===n.side?(b=o-f,v=b+p):(v=o+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:y,sBot:g,tx:d,tTop:b,tBot:v,cp1X:x,cp2X:x}}(i,e[o.source],a,e[o.target],n,Pe,A,ye),{pathD:u,bezier:d}=ax(l),h=be.get(o.id)??o;r.push({id:o.id,pathD:u,fill:c,opacity:z,rawDatum:h,bezier:d})}),{bands:o,ribbons:r}},[Me,me,fe,Pe,ye,Ie,ge,be,A,z,Re]),Te=Lk(()=>({bands:_e.bands,ribbons:_e.ribbons,showLabels:I}),[_e,I]),Le=Lk(()=>{if(!xe||!g)return;const e=new Map;(ce??[]).forEach((t,n)=>{const o=eS(g,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:Ie(pe(t),n)})});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,g,ce,Ie,pe]),Ne=Lk(()=>!1!==G&&q?void 0===G||!0===G?null:sc(G)||null:null,[G,q]),$e=Bk(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=Bk(e=>W?W(e):e+"",[W]),De=Bk(e=>{if(!e||!e.data)return null;const t=e.data;if(!Uk(t))return null;const n=t.data;if(Ne)return Ne(n);if("band"===t.__kind){const e=t.id,n=Me?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,r=`${o.t}:${e}`;t.has(r)||(t.add(r),n.push({t:o.t,total:e}))}return n}(Me.nodeData[e]):[],o=5,r=n.length>o?n.length:null,i=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,r=[{...n[0],mark:"min"},{...n[Math.floor(.25*o)],mark:"q25"},{...n[Math.floor(.5*o)],mark:"median"},{...n[Math.floor(.75*o)],mark:"q75"},{...n[o],mark:"max"}],i=new Set,a=[];for(const e of r)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,o);return Zk("div",{style:{minWidth:160},children:[Qk("div",{style:{fontWeight:600,marginBottom:4},children:e}),i.length>0&&Zk("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Qk("thead",{children:Zk("tr",{style:{opacity:.6},children:[Qk("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Qk("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=r&&Qk("th",{})]})}),Qk("tbody",{children:i.map((e,t)=>Zk("tr",{children:[Qk("td",{style:{paddingRight:8},children:$e(e.t)}),Qk("td",{style:{textAlign:"right"},children:Be(e.total)}),null!=r&&Qk("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=r&&Zk("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",i.length," of ",r," samples"]})]})}const o=n,r=eS(s,o),i=eS(c,o),a=eS(l,o),u=eS(d,o),p=eS(h,o);return Zk("div",{style:{minWidth:160},children:[Zk("div",{style:{fontWeight:600,marginBottom:4},children:[r+""," → ",i+""]}),Zk("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&Zk(Kk,{children:[Qk("span",{style:{opacity:.6},children:"value"}),Qk("span",{style:{textAlign:"right"},children:Be(Number(a))})]}),null!=u&&Zk(Kk,{children:[Qk("span",{style:{opacity:.6},children:"start"}),Qk("span",{style:{textAlign:"right"},children:$e(Jk(u))})]}),null!=p&&Zk(Kk,{children:[Qk("span",{style:{opacity:.6},children:"end"}),Qk("span",{style:{textAlign:"right"},children:$e(Jk(p))})]})]})]})},[Me,Ne,$e,Be,s,c,l,d,h]),je=Lk(()=>{if(!Me)return null;const{centerlines:e,laneLifetime:t,nodeData:n,valueScale:o,compressedPadding:r,crossingsBefore:a,crossingsAfter:s,lengthBefore:c,lengthAfter:l}=Me;let u=null,d=null;for(const e of me){const n=t[e.id];if(!n||null===n.start||null===n.end)continue;const o=Pe(n.start),r=Pe(n.end);(null===u||u>o)&&(u=o),(null===d||r>d)&&(d=r)}const h=e=>Math.max(0,Math.min(Se,e)),p=h(u??0),m=Math.max(p,h(d??Se));return Zk("g",{children:[P&&null!==(s??null)&&Zk("text",{x:Se,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(c)," → ",Math.round(l)]}),r&&Qk("text",{x:Se,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),i.map((e,t)=>{const n=Pe(Jk(e.date));return p-.5>n||n>m+.5?null:Qk("line",{x1:n,y1:0,x2:n,y2:Ae,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),M&&me.map((r,i)=>{const a=t[r.id];if(!a||null===a.start)return null;const s=n[r.id],c=s?{topPeak:s.topPeak,botPeak:s.botPeak}:{topPeak:0,botPeak:0},l=e[r.id]+(c.botPeak-c.topPeak)*o/2,u=Pe(a.start),d=Pe(a.end),h=Ie(r.id,i);return Zk("g",{children:[Qk("line",{x1:u,y1:l,x2:d,y2:l,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Qk("line",{x1:u,y1:l-4,x2:u,y2:l+4,stroke:h,strokeOpacity:.5}),Qk("line",{x1:d,y1:l-4,x2:d,y2:l+4,stroke:h,strokeOpacity:.5})]},"lane-"+r.id)}),Qk("line",{x1:p,y1:Ae+4,x2:m,y2:Ae+4,stroke:"#94a3b8"}),i.map((e,t)=>{const n=Jk(e.date),o=Pe(n);if(p-.5>o||o>m+.5)return null;const r=null!=e.label?e.label:H?H(new Date(n)):"";return Zk("g",{transform:`translate(${o},${Ae+4})`,children:[Qk("line",{y2:6,stroke:"#94a3b8"}),Qk("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:r})]},t)})]})},[Me,i,Pe,Se,Ae,M,me,Ie,P,H]),Ee=Lk(()=>(ce??[]).map(e=>({id:pe(e),data:e})),[ce,pe]),Fe=Lk(()=>{const e=new Map;for(const t of _e.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[_e]),Oe=Lk(()=>(se??[]).map((e,t)=>{const n=he(e,t),o=Number(eS(l,e));return{id:n,source:eS(s,e)+"",target:eS(c,e)+"",value:Number.isFinite(o)?o:0,bezier:Fe.get(n),data:e}}),[se,he,s,c,l,Fe]),ze=ve.loadingEl,We=ve.emptyEl;return Ce.length>0?Zk("svg",{width:R,height:_,role:"img","aria-label":L??"Process Sankey validation failed",children:[Qk("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ce.map((e,t)=>{return Qk("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+(n=e,"invalid-node-time"===n.kind?`node ${n.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===n.kind?`edge ${n.id} has an invalid startTime or endTime`:"invalid-domain"===n.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===n.kind?`edge ${n.id} must have a positive finite value`:"missing-node"===n.kind?`edge ${n.id} references missing ${n.endpoint} node "${n.nodeId}"`:"backward-edge"===n.kind?`edge ${n.id} (${n.source}->${n.target}) ends before it starts`:n.kind)},t);var n})]}):ze||We||Qk(pk,{ref:le,chartType:"force",nodes:Ee,edges:Oe,customNetworkLayout:Xk,layoutConfig:Te,size:[R,_],responsiveWidth:D,responsiveHeight:j,margin:ke,title:L,description:N??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:$,accessibleTable:B,enableHover:q,tooltipContent:!1===G?()=>null:De,backgroundGraphics:je,showParticles:X,particleStyle:U,legend:Le,legendPosition:x,onObservation:Y,...V&&{customClickBehavior:e=>{if(!e||!e.data||!V)return;const t=e.data;Uk(t)&&V(t.data,{x:e.x,y:e.y})}},chartId:K,colorScheme:Array.isArray(b)?b:void 0,...Q})});tS.displayName="ProcessSankey";import{useMemo as nS}from"react";import{jsx as oS}from"react/jsx-runtime";function rS(e){const t=Vd(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:n,margin:o,className:r,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:f=5,tooltip:y,frameProps:g={},onObservation:b,onClick:v,chartId:x,selection:w,linkedHover:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:P,opacity:I}=e,{width:R,height:_,enableHover:T,showLabels:L=!0,title:N,description:$,summary:B,accessibleTable:D}=t,j=vk({nodes:nS(()=>fk(n??null,s),[n,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:o,width:R,height:_,loading:S,loadingContent:A}),E=nS(()=>new Map,[]),F=nS(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Oe[(e.depth||0)%Oe.length]:u?He(e.data||e,u,j.colorScale):Fd(void 0,j.themeCategorical,d,void 0,E),t},[u,h,j.colorScale,j.themeCategorical,d,E]),O=nS(()=>Sh(F,{stroke:M,strokeWidth:P,opacity:I}),[F,M,P,I]),z=nS(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=nS(()=>Sh(z,{stroke:M,strokeWidth:P,opacity:I}),[z,M,P,I]),W=nS(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return gk(c)},[i,c]),G=mh({componentName:"TreeDiagram",data:n});return G?oS(Qd,{componentName:"TreeDiagram",message:G,width:R,height:_}):j.loadingEl?j.loadingEl:oS(oh,{componentName:"TreeDiagram",width:R,height:_,children:oS(pk,{chartType:i,...null!=n&&{data:n},size:[R,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:j.margin,nodeIDAccessor:l,childrenAccessor:s,hierarchySum:W,treeOrientation:a,edgeType:p,nodeStyle:O,edgeStyle:H,colorBy:u,colorScheme:j.effectivePalette,colorByDepth:h,nodeSize:f,nodeLabel:L?m||l:void 0,showLabels:L,enableHover:T,tooltipContent:!1===y?()=>null:sc(y)||void 0,...Bh({linkedHover:k,selection:w,onObservation:b,onClick:v,mobileInteraction:j.mobileInteraction,customHoverBehavior:j.customHoverBehavior,customClickBehavior:j.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&"none"!==C&&{legendHoverBehavior:j.legendState.onLegendHover,legendClickBehavior:j.legendState.onLegendClick,legendHighlightedCategory:j.legendState.highlightedCategory,legendIsolatedCategories:j.legendState.isolatedCategories},className:r,title:N,description:$,summary:B,accessibleTable:D,...null!=e.animate&&{animate:e.animate},...g})})}rS.displayName="TreeDiagram";import{useMemo as iS,useCallback as aS}from"react";import{jsx as sS}from"react/jsx-runtime";function cS(e){const t=Vd(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:n,margin:o,className:r,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:c,colorScheme:l,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:p=4,paddingTop:m,nodeStyle:f,tooltip:y,frameProps:g={},selection:b,linkedHover:v,onObservation:x,onClick:w,chartId:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:P,opacity:I}=e,{nodeStyle:R,..._}=g,{width:T,height:L,enableHover:N,showLabels:$=!0,title:B,description:D,summary:j,accessibleTable:E}=t,F=vk({nodes:iS(()=>fk(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:c,colorScheme:l,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:o,width:T,height:L,loading:S,loadingContent:A}),O=xh(b),z=F.customHoverBehavior,H=aS(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),W=iS(()=>new Map,[]),G=iS(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Oe[(e.depth||0)%Oe.length]:c?He(e.data||e,c,F.colorScale):Fd(void 0,F.themeCategorical,l,void 0,W),t},[c,u,F.colorScale,F.themeCategorical,l,W]),q=iS(()=>f||R?e=>({...G(e),...R?R(e)??{}:{},...f?f(e)??{}:{}}):G,[G,f,R]),Y=iS(()=>Sh(q,{stroke:M,strokeWidth:P,opacity:I}),[q,M,P,I]),V=iS(()=>F.activeSelectionHook?e=>{const t={...Y(e)};if(F.activeSelectionHook.isActive)if(F.activeSelectionHook.predicate(e.data||e))O?.selectedStyle&&Object.assign(t,O.selectedStyle);else{const e=O?.unselectedOpacity??.5;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,O?.unselectedStyle&&Object.assign(t,O.unselectedStyle)}return t}:Y,[Y,F.activeSelectionHook,O]),X=iS(()=>gk(a),[a]),U=void 0!==m?m:!$||"parent"!==d&&"all"!==d?void 0:18,K=mh({componentName:"Treemap",data:n});return K?sS(Qd,{componentName:"Treemap",message:K,width:T,height:L}):F.loadingEl?F.loadingEl:sS(oh,{componentName:"Treemap",width:T,height:L,children:sS(pk,{chartType:"treemap",...null!=n&&{data:n},size:[T,L],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:F.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:X,padding:p,paddingTop:U,nodeStyle:V,colorBy:c,colorScheme:F.effectivePalette,colorByDepth:u,nodeLabel:$?h||s:void 0,showLabels:$,labelMode:d,enableHover:N,tooltipContent:!1===y?()=>null:sc(y)||void 0,...Bh({linkedHover:v,selection:b,onObservation:x,onClick:w,mobileInteraction:F.mobileInteraction,customHoverBehavior:H,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:r,title:B,description:D,summary:j,accessibleTable:E,...null!=e.animate&&{animate:e.animate},..._})})}cS.displayName="Treemap";import{useMemo as lS}from"react";import{jsx as uS}from"react/jsx-runtime";function dS(e){const t=Vd(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:n,margin:o,className:r,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:c,colorScheme:l,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:p=4,tooltip:m,frameProps:f={},onObservation:y,onClick:g,chartId:b,selection:v,linkedHover:x,loading:w,loadingContent:k,legendInteraction:S,stroke:A,strokeWidth:C,opacity:M}=e,{width:P,height:I,enableHover:R,showLabels:_=!0,title:T,description:L,summary:N,accessibleTable:$}=t,B=vk({nodes:lS(()=>fk(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:c,colorScheme:l,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:y,onClick:g,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:o,width:P,height:I,loading:w,loadingContent:k}),D=lS(()=>new Map,[]),j=lS(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Oe[(e.depth||0)%Oe.length]:c?He(e.data||e,c,B.colorScale):Fd(void 0,B.themeCategorical,l,void 0,D),t},[c,u,B.colorScale,h,B.themeCategorical,l,D]),E=lS(()=>Sh(j,{stroke:A,strokeWidth:C,opacity:M}),[j,A,C,M]),F=lS(()=>gk(a),[a]),O=mh({componentName:"CirclePack",data:n});return O?uS(Qd,{componentName:"CirclePack",message:O,width:P,height:I}):B.loadingEl?B.loadingEl:uS(oh,{componentName:"CirclePack",width:P,height:I,children:uS(pk,{chartType:"circlepack",...null!=n&&{data:n},size:[P,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:F,padding:p,nodeStyle:E,colorBy:c,colorScheme:B.effectivePalette,colorByDepth:u,nodeLabel:_?d||s:void 0,showLabels:_,enableHover:R,tooltipContent:!1===m?()=>null:sc(m)||void 0,...Bh({linkedHover:x,selection:v,onObservation:y,onClick:g,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:r,title:T,description:L,summary:N,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...f})})}dS.displayName="CirclePack";import{useMemo as hS}from"react";import{jsx as pS}from"react/jsx-runtime";var mS=Oe;function fS(e){const t=Vd(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:n,margin:o,className:r,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:c,colorByDepth:l=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:p,revolutionStyle:m,eccentricity:f=1,showRings:y=!0,nodeRadius:g=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:R,loadingContent:_,stroke:T,strokeWidth:L,opacity:N}=e,{width:$,height:B,enableHover:D,title:j,description:E,summary:F,accessibleTable:O}=t,z=vk({nodes:hS(()=>fk(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:l?void 0:s,colorScheme:c,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:o,width:$,height:B,loading:R,loadingContent:_}),H=hS(()=>new Map,[]),{colorScale:W,customClickBehavior:G,customHoverBehavior:q,themeCategorical:Y}=z,V=hS(()=>{if(Array.isArray(c))return c;const e=je[c];return Array.isArray(e)?e:Ee},[c]),X=hS(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=l?n?V[0]:mS[(e.depth||0)%mS.length]:s?He(e.data||e,s,W):Fd(void 0,Y,c,void 0,H),t.opacity=n?1:.85,t},[s,l,W,V,Y,c,H]),U=hS(()=>Sh(X,{stroke:T,strokeWidth:L,opacity:N}),[X,T,L,N]),K=hS(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=hS(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),Z=hS(()=>e=>{G(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[G]),J=mh({componentName:"OrbitDiagram",data:n});return J?pS(Qd,{componentName:"OrbitDiagram",message:J,width:$,height:B}):z.loadingEl?z.loadingEl:pS(oh,{componentName:"OrbitDiagram",width:$,height:B,children:pS(pk,{chartType:"orbit",...null!=n&&{data:n},size:[$,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:U,edgeStyle:K,colorBy:s,colorScheme:z.effectivePalette,colorByDepth:l,nodeSize:g,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&D,tooltipContent:v?void 0:!1===x?()=>null:sc(x)||void 0,...Bh({linkedHover:I,selection:P,onObservation:A,onClick:C,mobileInteraction:z.mobileInteraction,customHoverBehavior:Q,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:w,annotations:k,className:r,title:j,description:E,summary:F,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:p,orbitRevolutionStyle:m,orbitEccentricity:f,orbitShowRings:y,orbitAnimated:v,accessibleTable:O,...null!=e.animate&&{animate:e.animate},...S})})}fS.displayName="OrbitDiagram";import{useRef as yS,useImperativeHandle as gS,forwardRef as bS,useCallback as vS,useState as xS,useEffect as wS}from"react";import{jsx as kS,jsxs as SS}from"react/jsx-runtime";var AS={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"},CS={opacity:.7,marginRight:4};function MS(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function PS(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function IS(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const i=e?.data??null,a=MS(i,t,"time"),s=MS(i,n,"value");return SS("div",{className:"semiotic-tooltip",style:AS,children:[SS("div",{children:[SS("span",{style:CS,children:[o,":"]}),PS(a)]}),SS("div",{children:[SS("span",{style:CS,children:[r,":"]}),PS(s)]})]})}}function RS(e,t){return null!=e?e:Math.max(t?.length??0,200)}var _S=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,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*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}},TS=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 n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new _S,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new _S;o.push(t);let r=e,i=e;const a=[],s={start:r,end:i,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?a.push(t):(s.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>i&&(i=t.end));s.start=r,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 n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const o=t+this.size;e.push(this.row(t,o,n,o>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,n,o){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:o}}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 LS(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 NS={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},$S=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function BS(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;$S.lastIndex=0;let n,o=0,r=0;for(;null!==(n=$S.exec(t));){const e=parseFloat(n[1]),t=NS[n[2]];if(null==t||!Number.isFinite(e))return null;o+=e*t,r+=n[0].length}return r!==t.length?null:o>0?o:null}var DS="time",jS="value",ES="__aggLower",FS="__aggUpper",OS="__aggPartial",zS="count",HS="__aggStart",WS="__aggEnd";function GS(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[DS]:(e.start+e.end)/2,[jS]:LS(e,n),[zS]:e.count,[OS]:e.partial,[HS]:e.start,[WS]:e.end},i=function(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=LS(e,n),i=e.stddev*o;return[r-i,r+i]}(e,o,n,r);return i&&(t[ES]=i[0],t[FS]=i[1]),t})}var qS=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 n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const o of this.held)this.getTime(o)>e?n.push(o):t.push(o);return this.held=n,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 YS}from"react/jsx-runtime";function VS(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();const r=Number(o);return Number.isFinite(r)?r:null}var XS=bS(function(e,t){const n=Vd(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:o,margin:r,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,stroke:f="#007bff",strokeWidth:y=2,strokeDasharray:g,opacity:b,background:v,tooltipContent:x,tooltip:w,onHover:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:R,staleness:_,transition:T,linkedHover:L,selection:N,onObservation:$,chartId:B,loading:D,loadingContent:j,emptyContent:E,emphasis:F,legendPosition:O,aggregate:z,eventTime:H}=e,W=n.showAxes,G=n.enableHover,q=r??n.marginDefaults,Y=o??[n.width,n.height],V=x??w??IS({timeAccessor:u,valueAccessor:d}),X=yS(null),{customHoverBehavior:U}=Hd({selection:N,linkedHover:L,unwrapData:!0,onObservation:$,chartType:"RealtimeLineChart",chartId:B}),K=vS(e=>{k&&k(e),U(e)},[k,U]),Q=null!=z,[Z,J]=xS([]),ee=yS(null),te=yS(z);te.current=z;const ne=yS(Q);ne.current=Q;const oe=yS(Z);oe.current=Z;const re=yS({timeAccessor:u,valueAccessor:d});re.current={timeAccessor:u,valueAccessor:d},wS(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=BS("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?BS(e.hop):void 0,r=null!=e.gap?BS(e.gap):void 0;return new TS({window:t,size:n,hop:o??void 0,gap:r??void 0,retain:e.retain})}(e);if(ee.current=t,t&&l){const{timeAccessor:e,valueAccessor:n}=re.current;for(const o of l){const r=VS(o,e,"time"),i=VS(o,n,"value");null!=r&&null!=i&&t.push(r,i)}}J(t?GS(t,e):[])},[Q?[z.window??"tumbling",z.size,z.hop??"",z.gap??"",z.retain??""].join("|"):"",Q,l]),wS(()=>{Q&&ee.current&&J(GS(ee.current,te.current))},[z?.stat,z?.band,z?.sigma]);const ie=vS(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:o,valueAccessor:r}=re.current;for(const n of e){const e=VS(n,o,"time"),i=VS(n,r,"value");null!=e&&null!=i&&t.push(e,i)}J(GS(t,n))},[]),ae=null!=H,se=yS(null),ce=yS(H);ce.current=H;const le=yS(ae);le.current=ae;const ue=yS($);ue.current=$;const de=yS(B);de.current=B,wS(()=>{se.current=ae?function(e){const t=BS(e.lateness);return null==t?null:new qS({lateness:t,getTime:e=>VS(e,re.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[ae?`${H.lateness}|${H.latePolicy??"drop"}`:"",ae]);const he=vS(e=>{0!==e.length&&(ne.current?ie(e):X.current?.pushMany(e))},[ie]),pe=vS(e=>{const t=se.current;if(!le.current||!t)return void he(e);const n=[];for(const o of e){const e=t.push(o);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:o}=re.current,r=ce.current?.latePolicy??"drop";for(const i of e.late)n({type:"late-data",datum:i,eventTime:VS(i,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:de.current})}}}he(n)},[he]);gS(t,()=>({push:e=>pe([e]),pushMany:e=>pe(e),remove:e=>ne.current?[]:X.current?.remove(e)??[],update:(e,t)=>ne.current?[]:X.current?.update(e,t)??[],clear:()=>{se.current?.clear(),ne.current?(ee.current?.clear(),J([])):X.current?.clear()},getData:()=>ne.current?oe.current:X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[pe]);const me=sh(D,Y[0],Y[1],j),fe=me?null:ah(Q?void 0:l,Y[0],Y[1],E),ye={stroke:f,strokeWidth:y,strokeDasharray:g};null!=b&&(ye.opacity=b);const ge=RS(c,l),be=Q?Z:l,ve=Q?DS:u,xe=Q?jS:d,we=Q&&z&&"none"!==(z.band??"none")?{y0Accessor:ES,y1Accessor:FS,perSeries:!1}:void 0;return me||fe||YS(hu,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,margin:q,className:F?`${i||""} semiotic-emphasis-${F}`.trim():i,arrowOfTime:a,windowMode:Q?"growing":s,windowSize:Q?Math.max(1,z?.retain??Math.max(Z.length,600)):ge,data:be,timeAccessor:ve,valueAccessor:xe,xExtent:h,yExtent:p,extentPadding:m,band:we,lineStyle:ye,showAxes:W,background:v,hoverAnnotation:G,tooltipContent:V,...Bh({linkedHover:L,selection:N,onObservation:$,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:R,staleness:_,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:O})});XS.displayName="RealtimeLineChart";import{useRef as US,useImperativeHandle as KS,forwardRef as QS,useCallback as ZS,useMemo as JS}from"react";import{jsx as eA}from"react/jsx-runtime";function tA(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var nA=QS(function(e,t){const n=Vd(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:o,size:r,margin:i,className:a,arrowOfTime:s="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:d,valueAccessor:h,direction:p="up",timeExtent:m,valueExtent:f,extentPadding:y,categoryAccessor:g,colors:b,fill:v,stroke:x,strokeWidth:w,opacity:k,gap:S,background:A,tooltipContent:C,tooltip:M,onHover:P,annotations:I,autoPlaceAnnotations:R,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:L,linkedHover:N,selection:$,decay:B,pulse:D,staleness:j,transition:E,onObservation:F,chartId:O,loading:z,loadingContent:H,emptyContent:W,emphasis:G,legendPosition:q,brush:Y,onBrush:V,linkedBrush:X}=e,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=r??[n.width,n.height],J=C??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null;if(null==o?.binStart||null==o?.binEnd){const e=MS(o,t,"time"),r=MS(o,n,"value");return SS("div",{className:"semiotic-tooltip",style:AS,children:[SS("div",{children:[kS("span",{style:CS,children:"x:"}),PS(e)]}),SS("div",{children:[kS("span",{style:CS,children:"y:"}),PS(r)]})]})}return SS("div",{className:"semiotic-tooltip",style:AS,children:[SS("div",{children:[kS("span",{style:CS,children:"range:"}),PS(o.binStart),"–",PS(o.binEnd)]}),null!=o.total&&SS("div",{children:[kS("span",{style:CS,children:"count:"}),PS(o.total)]}),null!=o.category&&SS("div",{children:[kS("span",{style:CS,children:"category:"}),PS(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ee=US(null),{customHoverBehavior:te}=Hd({selection:$,linkedHover:N,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:O}),ne=ZS(e=>{P&&P(e),te(e)},[P,te]),oe=!0===Y?{dimension:"x",snap:"bin"}:"x"===Y?{dimension:"x"}:"object"==typeof Y?Y:void 0,re=md(X),ie="string"==typeof d?d:"time",ae=Xu({name:re?.name||"__unused_hist_brush__",xField:re?.xField||ie,...re?.yField?{yField:re.yField}:{}}),se=US(ae.brushInteraction);se.current=ae.brushInteraction;const ce=ZS(e=>{if(V&&V(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}),re){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,F,O,re]);KS(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 le=sh(z,Z[0],Z[1],H),ue=le?null:ah(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=G?`${a||""} semiotic-emphasis-${G}`.trim():a,pe=RS(l,u),me=JS(()=>"down"!==p?f:function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,valueExtent:r,extentPadding:i}){if(r)return[r[1],r[0]];if(!e||0===e.length)return;const a=new Map;for(const r of e){const e=tA(r,n,"time"),i=tA(r,t,"value");if(null==e||null==i)continue;const s=Math.floor(e/o)*o;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:o,valueExtent:f,extentPadding:y}),[p,u,h,d,o,f,y]);return le||ue||eA(hu,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:he,arrowOfTime:s,windowMode:c,windowSize:pe,data:u,timeAccessor:d,valueAccessor:h,xExtent:m,yExtent:me,extentPadding:y,binSize:o,categoryAccessor:g,barColors:b,barStyle:de,showAxes:U,background:A,hoverAnnotation:K,tooltipContent:J,...Bh({linkedHover:N,selection:$,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:I,autoPlaceAnnotations:R,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:L,decay:B,pulse:D,staleness:j,transition:E,pointIdAccessor:e.pointIdAccessor,legendPosition:q,brush:oe||(X?{dimension:"x"}:void 0),onBrush:oe||X?ce:void 0})});function oA(e){return eA(nA,{...e,windowMode:"growing"})}nA.displayName="RealtimeHistogram",oA.displayName="TemporalHistogram";import{useRef as rA,useImperativeHandle as iA,forwardRef as aA,useCallback as sA}from"react";import{jsx as cA}from"react/jsx-runtime";var lA=aA(function(e,t){const n=Vd(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:o,margin:r,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,yScaleType:m,extentPadding:f,categoryAccessor:y,colors:g,radius:b,fill:v,opacity:x,stroke:w,strokeWidth:k,pointStyle:S,background:A,tooltipContent:C,tooltip:M,onHover:P,annotations:I,autoPlaceAnnotations:R,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:L,linkedHover:N,selection:$,onObservation:B,chartId:D,loading:j,loadingContent:E,emptyContent:F,emphasis:O,legendPosition:z}=e,H=n.showAxes,W=n.enableHover,G=r??n.marginDefaults,q=o??[n.width,n.height],Y=C??M??IS({timeAccessor:u,valueAccessor:d}),V=rA(null),{customHoverBehavior:X}=Hd({selection:$,linkedHover:N,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:D}),U=sA(e=>{P&&P(e),X(e)},[P,X]);iA(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=sh(j,q[0],q[1],E),Q=K?null:ah(l,q[0],q[1],F),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=O?`${i||""} semiotic-emphasis-${O}`.trim():i,te=RS(c,l);return K||Q||cA(hu,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:q,margin:G,className:ee,arrowOfTime:a,windowMode:s,windowSize:te,data:l,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,yScaleType:m,extentPadding:f,categoryAccessor:y,barColors:g,swarmStyle:Z,pointStyle:J,showAxes:H,background:A,hoverAnnotation:W,tooltipContent:Y,...Bh({linkedHover:N,selection:$,onObservation:B,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:I,autoPlaceAnnotations:R,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:L,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});lA.displayName="RealtimeSwarmChart";import{useRef as uA,useImperativeHandle as dA,forwardRef as hA,useCallback as pA}from"react";import{jsx as mA}from"react/jsx-runtime";var fA=hA(function(e,t){const n=Vd(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:o,margin:r,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,positiveColor:f,negativeColor:y,connectorStroke:g,connectorWidth:b,gap:v,stroke:x,strokeWidth:w,opacity:k,background:S,tooltipContent:A,tooltip:C,onHover:M,annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:_,tickFormatValue:T,linkedHover:L,selection:N,onObservation:$,chartId:B,loading:D,loadingContent:j,emptyContent:E,emphasis:F,legendPosition:O}=e,z=n.showAxes,H=n.enableHover,W=r??n.marginDefaults,G=o??[n.width,n.height],q=A??C??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=MS(o,t,"time"),i=o?.delta??MS(o,n,"value"),a=o?.cumEnd,s="number"==typeof i?0>i?PS(i):"+"+PS(i):PS(i);return SS("div",{className:"semiotic-tooltip",style:AS,children:[SS("div",{children:[kS("span",{style:CS,children:"x:"}),PS(r)]}),SS("div",{children:[kS("span",{style:CS,children:"Δ:"}),s]}),null!=a&&SS("div",{children:[kS("span",{style:CS,children:"total:"}),PS(a)]})]})}}({timeAccessor:u,valueAccessor:d}),Y=uA(null),{customHoverBehavior:V}=Hd({selection:N,linkedHover:L,unwrapData:!0,onObservation:$,chartType:"RealtimeWaterfallChart",chartId:B}),X=pA(e=>{M&&M(e),V(e)},[M,V]);dA(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=sh(D,G[0],G[1],j),K=U?null:ah(l,G[0],G[1],E),Q={};null!=f&&(Q.positiveColor=f),null!=y&&(Q.negativeColor=y),null!=g&&(Q.connectorStroke=g),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=F?`${i||""} semiotic-emphasis-${F}`.trim():i,J=RS(c,l);return U||K||mA(hu,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:G,margin:W,className:Z,arrowOfTime:a,windowMode:s,windowSize:J,data:l,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,extentPadding:m,waterfallStyle:Q,showAxes:z,background:S,hoverAnnotation:H,tooltipContent:q,...Bh({linkedHover:L,selection:N,onObservation:$,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:X}),annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:_,tickFormatValue:T,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});fA.displayName="RealtimeWaterfallChart";import{useRef as yA,useImperativeHandle as gA,forwardRef as bA,useCallback as vA}from"react";import{jsx as xA}from"react/jsx-runtime";var wA=bA(function(e,t){const n=Vd(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:o,margin:r,className:i,arrowOfTime:a="right",windowMode:s="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:p,valueExtent:m,extentPadding:f,heatmapXBins:y=20,heatmapYBins:g=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:R,staleness:_,linkedHover:T,selection:L,onObservation:N,chartId:$,loading:B,loadingContent:D,emptyContent:j,emphasis:E,legendPosition:F}=e,O=n.showAxes,z=n.enableHover,H=r??n.marginDefaults,W=o??[n.width,n.height],G=x??w??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const i=e?.data??null,a=i?.xCenter??MS(i,t,"time"),s=i?.yCenter??MS(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,d=i?.agg??"count";return SS("div",{className:"semiotic-tooltip",style:AS,children:[SS("div",{children:[SS("span",{style:CS,children:[o,":"]}),PS(a)]}),SS("div",{children:[SS("span",{style:CS,children:[r,":"]}),PS(s)]}),null!=c&&SS("div",{children:[kS("span",{style:CS,children:"count:"}),PS(c)]}),"sum"===d&&null!=l&&SS("div",{children:[kS("span",{style:CS,children:"sum:"}),PS(l)]}),"mean"===d&&null!=u&&SS("div",{children:[kS("span",{style:CS,children:"mean:"}),PS(u)]})]})}}({timeAccessor:u,valueAccessor:d}),q=yA(null),{customHoverBehavior:Y}=Hd({selection:L,linkedHover:T,unwrapData:!0,onObservation:N,chartType:"RealtimeHeatmap",chartId:$}),V=vA(e=>{k&&k(e),Y(e)},[k,Y]);gA(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const X=sh(B,W[0],W[1],D),U=X?null:ah(l,W[0],W[1],j),K=E?`${i||""} semiotic-emphasis-${E}`.trim():i,Q=RS(c,l);return X||U||xA(hu,{ref:q,chartType:"heatmap",runtimeMode:"streaming",size:W,margin:H,className:K,arrowOfTime:a,windowMode:s,windowSize:Q,data:l,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:p,yExtent:m,extentPadding:f,heatmapXBins:y,heatmapYBins:g,heatmapAggregation:b,showAxes:O,background:v,hoverAnnotation:z,tooltipContent:G,...Bh({linkedHover:T,selection:L,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:P,decay:I,pulse:R,staleness:_,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});wA.displayName="RealtimeHeatmap";import{forwardRef as kA,useCallback as SA,useMemo as AA,useRef as CA}from"react";import*as MA from"react";import{forwardRef as PA,memo as IA,useCallback as RA,useEffect as _A,useImperativeHandle as TA,useId as LA,useRef as NA}from"react";var $A={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},BA={names:["--semiotic-border","--surface-3"],fallback:"#334155"},DA={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},jA={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},EA={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},FA={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},OA={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},zA={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},HA={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},WA={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function GA(e,t){const n=e.canvas;if("function"!=typeof getComputedStyle||!n)return t.fallback;const o=getComputedStyle(n);for(const n of t.names){const t=o.getPropertyValue(n).trim();if(t)return go(e,t)??t}return t.fallback}function qA(e,t){const n=Math.max(0,Math.min(1,t)),o=e.trim(),r=o.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i);if(r){const[,e,t,o]=r;return qA(`#${e}${e}${t}${t}${o}${o}`,n)}const i=o.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i){const[,e,t,o]=i;return`rgba(${parseInt(e,16)}, ${parseInt(t,16)}, ${parseInt(o,16)}, ${n})`}const a=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(a)return`rgba(${a[1]}, ${n})`;const s=o.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return s?`rgba(${s[1]}, ${n})`:o}import*as YA from"react";import{scaleLinear as VA}from"d3-scale";import{Fragment as XA,jsx as UA,jsxs as KA}from"react/jsx-runtime";function QA(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function ZA(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,title:a,legend:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:p,pointNodes:m=[],annotations:f,onAnnotationActivate:y,onObservation:g,chartId:b,chartType:v,autoPlaceAnnotations:x,svgAnnotationRules:w,children:k}=e,S=bi({onAnnotationActivate:y,onObservation:g,chartId:b,chartType:v}),A=YA.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(f),[f]),C=YA.useMemo(()=>function(e){const{width:t,height:n,pointNodes:o=[],data:r}=e;return{scales:{x:VA().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:VA().domain([0,Math.max(1,n)]).range([0,Math.max(1,n)])},width:t,height:n,frameType:"network",pointNodes:o,data:r,xAccessor:"x",yAccessor:"y"}}({width:t,height:n,pointNodes:m}),[n,m,t]),M=YA.useMemo(()=>A&&x?Zi({annotations:A,context:C,..."object"==typeof x?x:{}}):A,[C,x,A]),P=YA.useMemo(()=>_i(0,S),[S]),I=M?Ri(M,P,w,C):null,R=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return KA(XA,{children:[R?UA("style",{children:ui},"physics-annotation-disclosure-style"):null,KA("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[KA("g",{transform:`translate(${i.left},${i.top})`,children:[I,k]}),a&&"string"==typeof a?UA("text",{x:o/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?UA("foreignObject",{x:0,y:0,width:o,height:Math.max(i.top,28),children:a}):null,s?Mr({legend:s,totalWidth:o,totalHeight:r,margin:i,legendPosition:h,legendLayout:p,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}function JA(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function eC(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,JA(e.thickness)??JA(n)??JA(t.thickness)??4)}var tC=2500;function nC(e){return"function"==typeof e}function oC(e){return void 0===e||!1===e||!nC(e.binAccessor)&&!nC(e.labelAccessor)&&!nC(e.valueAccessor)}function rC(e){if(void 0!==e){if(!1===e)return!1;if(!oC(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 iC(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function aC(e){return function(e){return!nC(e?.timeAccessor)}(e)}function sC(e={}){if(e.engine)throw new TypeError("Physics workers use the built-in kernel adapter");const{engine:t,observation:n,sediment:o,...r}=e;return{...r,observation:iC(n),sediment:rC(o)}}function cC(){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 lC=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./physicsWorker.js",import.meta.url):$w("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,n=this.pending.get(t.requestId);n&&(this.pending.delete(t.requestId),n.cleanup(),t.ok?n.resolve(t.payload):n.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(cC());const n=this.nextRequestId;this.nextRequestId+=1;const o={command:e,requestId:n};return new Promise((e,r)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),r(cC())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(e)}})}async init(e,t,n,o){if(!aC(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:sC(e),initialSpawns:t,initialSpawnPacing:n},o);if("frame"!==r.type)throw Error("Physics worker returned a non-frame init response");return r.frame}async restore(e,t){const n=await this.request({type:"restore",snapshot:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame restore response");return n.frame}async initFromSnapshot(e,t,n){const o=await this.request({type:"init",config:sC(e),snapshot:t},n);if("frame"!==o.type)throw Error("Physics worker returned a non-frame init response");return o.frame}async enqueue(e,t,n){if(!aC(t))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const o=await this.request({type:"enqueue",spawns:e,pacing:t},n);if("frame"!==o.type)throw Error("Physics worker returned a non-frame enqueue response");return o.frame}async tick(e,t){const n=await this.request({type:"tick",deltaSeconds:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame tick response");return n.frame}async settle(e,t){const n=await this.request({type:"settle",maxSteps:e},t);if("frame"!==n.type)throw Error("Physics worker returned a non-frame settle response");return n.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 n=await this.request({type:"remove",ids:e},t);if("removed"!==n.type)throw Error("Physics worker returned a non-remove response");return{frame:n.frame,removed:n.removed}}terminate(){this.rejectAll(Error("Physics worker terminated")),this.worker.terminate()}rejectAll(e){for(const[t,n]of this.pending)this.pending.delete(t),n.cleanup(),n.reject(e)}};function uC(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 dC={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},hC=1e-9,pC=.005;function mC(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function fC(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 yC(e,t,n){return Math.max(t,Math.min(n,e))}function gC(e){return 0>e?-1:1}function bC(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,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function vC(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function xC(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function wC(e,t,n,o,r,i,a,s){const c=r-e,l=(n+a)/2-Math.abs(c);if(0>=l)return null;const u=i-t,d=(o+s)/2-Math.abs(u);return d>0?d>l?{nx:gC(c),ny:0,penetration:l}:{nx:0,ny:gC(u),penetration:d}:null}function kC(e,t,n,o,r,i,a){const s=i/2,c=a/2;let l=e-yC(e,o-s,o+s),u=t-yC(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(hC>=d){const i=Math.abs(e-(o-s)),a=Math.abs(e-(o+s)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),p=Math.min(i,a,d,h);return p===i?(l=-1,u=0,{nx:l,ny:u,penetration:n+i}):p===a?(l=1,u=0,{nx:l,ny:u,penetration:n+a}):p===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function SC(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,o,r,i){const a=o-e,s=r-t,c=n+i,l=a*a+s*s;if(l>=c*c)return null;if(hC>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:a/u,ny:s/u,penetration:c-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 wC(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 n=kC(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?kC(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function AC(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?kC(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):wC(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,o,r,i,a,s=0){const c=i-o,l=a-r,u=c*c+l*l,d=u>hC?yC(((e-o)*c+(t-r)*l)/u,0,1):0,h=n+s/2,p=e-(o+c*d),m=t-(r+l*d),f=p*p+m*m;if(f>=h*h)return null;if(hC>=f){const e=Math.sqrt(u);return e>hC?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const y=Math.sqrt(f);return{nx:p/y,ny:m/y,penetration:h-y}}(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,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function CC(e,t){return`${e}\0${t}`}function MC(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function PC(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:mC(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function IC(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 RC(e){return{id:e.id,shape:fC(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:IC(e.bodyFilter),index:e.index}}function _C(e,t){return!!t?.some(t=>Object.is(e,t))}function TC(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const o=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(o,n.equals)||"notEquals"in n&&Object.is(o,n.notEquals)||n.oneOf&&!_C(o,n.oneOf)||n.notOneOf&&_C(o,n.notOneOf))}var LC=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={...dC,...e},this.random=uC(this.options.seed)}init(e={}){this.options={...dC,...e},this.random=uC(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(hC,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:mC(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))MC(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:fC(t.shape),bodyFilter:IC(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,n){const o=this.bodies.get(e);o&&(o.vx+=t/o.mass,o.vy+=n/o.mass,this.wake(o))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const o=this.options.maxVelocity;for(const e of n)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,o>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>o){const n=o/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),i=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,i,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}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:mC(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(MC)}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(PC),colliders:this.sortedColliders().map(RC),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=uC(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=PC(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=RC(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 n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const o="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!o)continue;const r=o.x-n.x,i=o.y-n.y,a=Math.sqrt(r*r+i*i);if(hC>=a)continue;const s=r/a,c=i/a,l=(a-t.restLength)*t.stiffness+((("vx"in o?o.vx:0)-n.vx)*s+(("vy"in o?o.vy:0)-n.vy)*c)*t.damping;n.vx+=l*s*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const o of t){const[t,r]=o.split(":").map(Number),i=e[t],a=e[r];if(!i||!a)continue;const s=SC(i,a);s&&(this.resolveDynamicCollision(i,a,s),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:a.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let o=0;e.length>o;o+=1){if(!1===e[o].bodyCollisions)continue;const r=bC(e[o]),i=Math.floor(r.minX/t),a=Math.floor(r.maxX/t),s=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=i;a>=e;e+=1)for(let t=s;c>=t;t+=1){const r=`${e}:${t}`,i=n.get(r);i?i.push(o):n.set(r,[o])}}const o=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const i=r[t],a=r[n];!1!==e[i].bodyCollisions&&!1!==e[a].bodyCollisions&&xC(bC(e[i]),bC(e[a]))&&o.add(`${i}:${a}`)}}return Array.from(o).sort((e,t)=>{const[n,o]=e.split(":").map(Number),[r,i]=t.split(":").map(Number);return n===r?o-i:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const o=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,i=o+r;if(hC>=i)return;const a=Math.max(0,n.penetration-pC)/i;e.x-=n.nx*a*o,e.y-=n.ny*a*o,t.x+=n.nx*a*r,t.y+=n.ny*a*r;const s=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(s>0)return;const c=Math.abs(s),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*s/i,u=l*n.nx,d=l*n.ny;e.vx-=u*o,e.vy-=d*o,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,o,r,i){const a=-n.ny,s=n.nx,c=(t.vx-e.vx)*a+(t.vy-e.vy)*s,l=r+i;if(hC>=Math.abs(c)||hC>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=yC(-c/l,-o*u,o*u),h=d*a,p=d*s;e.vx-=h*r,e.vy-=p*r,t.vx+=h*i,t.vy+=p*i}resolveColliders(e,t,n){for(const o of e)for(const e of t){if(!TC(e,o))continue;if(!xC(bC(o),vC(e)))continue;const t=AC(o,e);t&&(this.resolveStaticCollision(o,e,t),this.supportedThisStep.add(o.id),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-pC),e.y+=n.ny*Math.max(0,n.penetration-pC);const o=e.vx*n.nx+e.vy*n.ny;if(0>o){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*o*n.nx,e.vy-=(1+r)*o*n.ny;const i=-n.ny,a=n.nx,s=e.vx*i+e.vy*a,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=s*i*c,e.vy-=s*a*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const o of e){const e=bC(o);for(const r of n){if(!TC(r,o))continue;if(!xC(e,vC(r)))continue;if(!AC(o,r))continue;const n=CC(r.id,o.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:o}=MC(e);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of e)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=t,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},NC=class{constructor(e={}){this.id="builtin",this.capabilities={...(new LC).capabilities,engine:"builtin"},this.world=new LC(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,n){this.world.applyImpulse(e,t,n)}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 $C(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new NC(e)}(t)}var BC=["binId","targetBin","category","windowIndex","lane","group"];function DC(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 n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function jC(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 EC(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 FC(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function OC(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?FC(t,e):void 0}function zC(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function HC(e){const t=jC(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:jC(e.x),y:jC(e.y),value:t}}var WC=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 n=zC(OC(this.config.binAccessor,e,t))??function(e){for(const t of BC){const n=zC(FC(e,t));if(n)return n}return"sediment"}(e),o=zC(OC(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const o="function"==typeof e?e(t,n):"string"==typeof e?FC(t,e):1,r="number"==typeof o?o:Number(o);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),i=Math.max(0,Math.floor(this.config.retainBodyIds??12));let a=this.bins.get(n);return a||(a={id:n,label:o,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(n,a)),a.label=o,a.lastBodyId=e.id,a.lastDatum=e.datum,DC(a.x,e.x),DC(a.y,e.y),DC(a.value,r),i>0&&(a.bodyIds.push(e.id),a.bodyIds.length>i&&(a.bodyIds=a.bodyIds.slice(a.bodyIds.length-i))),HC(a)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(HC)}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:EC(t.x),y:EC(t.y),value:EC(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 GC(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var qC={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},YC={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function VC(e={},t=YC){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 XC(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function UC(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 KC(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function QC(e){return{...XC(e),sequence:e.sequence,spawnAt:e.spawnAt}}function ZC(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 JC(e){return!1!==e&&{...e}}function eM(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function tM(e){return{...e,gravity:{...e.gravity}}}function nM(e,t,n,o){if("circle"===e.shape.type){const r=e.x-t,i=e.y-n,a=e.shape.radius+o,s=r*r+i*i;return s>a*a?null:s}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),i=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),a=r*r+i*i;return a>o*o?null:a}function oM(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function rM(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:c=s}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*s,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*s,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*c}}),a&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*c}}),l}function iM(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:a,yBottom:s,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:p=Math.max(2,c)}=e,m=[],f=a+(s-a)/2,y=Math.abs(s-a),g=l?n:n-1;if(u||l)for(let e=l?0:1;g>=e;e+=1){if(!u&&e>0&&n>e)continue;const a=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:f,width:c,height:y}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,a=n+r;if(a>=d)continue;const s=i(n),l=i(a);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,l)+c/2,y1:h,x2:Math.max(s,l)-c/2,y2:h,thickness:p}})}return m}import{quadtree as aM}from"d3-quadtree";var sM=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,o,r,i=0){const a=this.ensure(e,t);if(!a)return null;let s=null,c=1/0;const l=Math.max(0,i)+this.maxSearchRadius,u=o-l,d=o+l,h=r-l,p=r+l;return a.visit((e,t,a,l,m)=>{if(u>l||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=nM(e,o,r,Math.max(0,i));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(s?.id??""))&&(s=e,c=t)}f=f.next}return!1}),s}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.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=aM().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},cM=["data","scene-geometry","data-paint","accessibility","evidence"],lM=["scene-geometry","data-paint","accessibility","evidence"],uM=["overlay","accessibility","evidence"],dM=(e,t)=>({retainedData:e,invalidations:t}),hM=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pM=["scene-geometry","data-paint","accessibility","evidence"],mM=[],fM={engine:dM("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:dM("preserve",pM),colliders:dM("preserve",pM),sediment:dM("preserve",pM),bodyBudget:dM("preserve",hM),bodyLimit:dM("preserve",hM),eviction:dM("preserve",hM),fixedDt:dM("preserve",mM),maxDeltaSeconds:dM("preserve",mM),maxSubsteps:dM("preserve",mM),settleStepLimit:dM("preserve",mM),timeScale:dM("preserve",mM),observation:dM("preserve",mM)},yM=dM("preserve",hM);function gM(e){let t="preserve";const n=new Set;for(const o of e){const e=fM[o]??yM;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var bM=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function vM(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&bM.every(n=>e[n]===t[n])}function xM(e,t,n,o){return e||!t?"paused":n||!o?"running":"settled"}var wM=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new sM,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new ln,this.simulationState="settled",this.visible=!0;const{bodyBudget:t,colliders:n,engine:o,kernel:r,observation:i,sediment:a,...s}=e;this.config={...qC,...s},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=o,this.observation=VC(i),this.sediment=new WC(a??!1),this.world=$C(o,{fixedDt:this.config.fixedDt,...r}),n&&this.world.setColliders(ZC(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!vM(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:o,engine:r,kernel:i,observation:a,sediment:s,...c}=e;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=$C(r,e.options),this.world.restore(e),this.revision+=1}if(i&&!vM(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=VC(a,this.observation)),this.sediment.updateConfig(s),n&&(this.world.setColliders(ZC(n)),this.revision+=1),this.configInput={...this.configInput,...e};const l=gM(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(ZC(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},gM(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],o=t?function(e,t={}){const n=UC(t.startAt)??0,o=t.pacing??"immediate";if("arrival"===o){const o=e.map((e,n)=>function(e,t,n){return"function"==typeof n?UC(n(e,t)):"string"==typeof n?UC(KC(e,n)):UC(e.spawnAt)??UC(KC(e,"arrivalTime"))??UC(KC(e,"timestamp"))??UC(KC(e,"time"))??UC(KC(e,"eventTime"))}(e,n,t.timeAccessor)),r=o.filter(e=>null!=e),i=r.length>0?Math.min(...r):0,a=UC(t.timeScale)??1,s=a>0?a:1;return e.map((e,t)=>{const r=o[t],a=null==r?0:Math.max(0,r-i);return{...XC(e),spawnAt:n+a/s}})}if("object"==typeof o){const t=UC(o.ratePerSec);if(t&&t>0)return e.map((e,o)=>({...XC(e),spawnAt:n+o/t}))}return e.map(e=>({...XC(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of o)this.queue.push({...XC(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(eM),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?cM:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(XC(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},cM)}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"},cM)}tick(e){const t=this.revision,n=[],o=[],r=[],i=[],a=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,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(n,a);const c=this.observeBodyBudget(a),l=this.evictOverflow(a);o.push(...l.evicted),r.push(...l.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||n.length>0||o.length>0||r.length>0||i.length>0)&&(this.revision+=1);const d=this.result(u,n,o,r,i,a,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||o.length||r.length?cM:lM:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const n=this.world.settle(e,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==t?lM:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],o=[],r=[],i=[],a=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,i,a,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,a);const s=this.observeBodyBudget(a),c=this.evictOverflow(a);o.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(a);let l=0;for(;e>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,a),this.observeSensorTransitions(a),l+=1}(l>0||n.length>0||o.length>0||r.length>0||i.length>0)&&(this.revision+=1);const u=this.result(l,n,o,r,i,a,void 0,s);return this.updateResults.record({kind:"settle",count:l},this.revision!==t?n.length||o.length||r.length?cM:lM:[]),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:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:a="count",x:s}=t,c=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{const l=Math.max(0,e[a]/c*i),u=s?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}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:n,chartId:o,...r}=e,i={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(i),this.updateResults.record({kind:"update",count:1},["evidence"]),i}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?uM:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?uM:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),o=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 r=e.filter(e=>n.has(e)||o.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?cM:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},lM),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},lM)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},lM)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,o)=>e.applyImpulse(t,n,o),clear:()=>e.clear(),hitTest:(t,n,o)=>e.hitTest(t,n,o),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),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:JC(this.bodyBudget),config:{...this.config,kernel:tM(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(QC),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:JC(e.bodyBudget??{}),kernel:tM(e.world.options)},this.bodyBudget=JC(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(QC).sort(eM),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??xM(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"},cM)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.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 n=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:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,o,r,i,a,s=this.evaluateBodyBudget()){this.syncSimulationState(i);const c=this.world.allSleeping();return{budget:s,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:a??(this.queue.length>0||!c),sleeping:c,sedimented:o,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const o=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=o.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.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,n){const o=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===o.size&&0===t.size)return o;const r=new Map(e.readState().map(e=>[e.id,e])),i=(e,t)=>{const{sensorId:o,bodyId:i}=oM(t),a=n.observation.sensors[o],s=r.get(i);n.emit({type:"enter"===e?a?.enterType??"physics-bin-enter":a?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:i,datum:s?.datum,x:s?.x,y:s?.y,sensorId:o,binId:a?.binId??o})};for(const e of Array.from(o).sort())t.has(e)||i("enter",e);for(const e of Array.from(t).sort())o.has(e)||i("exit",e);return o}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(oM(n).bodyId)&&e.delete(n)}(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)),n=Math.max(0,Math.floor(e.queuedBodies??0)),o=t+n,r=GC(e.bodyLimit),i=GC(e.engineMaxBodiesHint),a=function(e,t,n){if(!1===n)return;const o=GC(n?.warnAt);return null!=o?o:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,i,e.options),s=null==r?0:Math.max(0,t-r),c=s>0?"overflow":null==a||a>o?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:i,liveBodies:t,overflow:s,projectedBodies:o,queuedBodies:n,state:c,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 n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,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=xM(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,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 n=this.liveBodyOrder.length-t;if(0>=n)return{evicted:[],sedimented:[]};const o=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,n);if(0===o.length)return{evicted:[],sedimented:[]};const r=this.absorbSediment(o,e);this.world.remove(o);const i=new Set(o);return this.liveBodyOrder=this.liveBodyOrder.filter(e=>!i.has(e)),this.removeActiveSensorPairsForBodies(i),{evicted:o,sedimented:r}}absorbSediment(e,t){const n=new Map(this.world.readState().map(e=>[e.id,e])),o=[];for(const r of e){const e=n.get(r);if(!e)continue;const i=this.sediment.add(e);i&&(o.push(r),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:r,datum:e.datum,x:e.x,y:e.y,binId:i.id,count:i.count,total:i.total},t))}return o}sleepingFirstEvictionOrder(){const e=new Map(this.world.readState().map(e=>[e.id,e.sleeping])),t=[],n=[];for(const o of this.liveBodyOrder)e.get(o)?t.push(o):n.push(o);return[...t,...n]}};function kM(e,t,n){const o=new wM(e);return t?.length&&o.enqueue(t,n),o}function SM(){return"undefined"!=typeof performance?performance.now():Date.now()}import*as AM from"react-dom/server";function CM(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 MM={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function PM(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 IM(e,t){const n="function"==typeof t?t(e):t;return{...MM,...n??{}}}function RM(e,t={}){const n=e.settle(t.maxSteps),o=e.readBodies(),r=e.snapshot(),i=function(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??PM(e)},r={style:IM(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:o,_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,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}(o,t),a=function(e,t={}){const n=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),o=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:o,settled:"settled"===e.simulationState&&0===e.queue.length&&o===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:CM(t.projectionRows)}}(r,{bodies:o,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:r,bodies:o,sceneNodes:i,evidence:a,stepsRun:n}}import{jsx as _M,jsxs as TM}from"react/jsx-runtime";function LM(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function NM(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=BM(e.datum,t),o=BM(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function $M(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function BM(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function DM(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=BM(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function jM(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),o=e.queueLayout??"lane",r=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),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,p=new Map,m=new Map,f=new Map,y=new Map,g=[];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,R=0,_=0,T=0,L=0,N=0,$=0,B=0,D=0,j=-1,E=!1;function F(e,n){const o=n(e);return!!o&&o.activeRegionIds.includes(t)}function O(){D+=1}function z(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function H(n,o,r,i){const a={bodyId:n.id,jobId:o.jobId,visitId:o.visitId,visit:o.visit,remaining:o.work,total:o.work,queuedAt:o.queuedAt,sequence:i};return u.set(o.jobId,a),y.delete(n.id),f.set(n.id,o.jobId),M+=1,P+=o.work,O(),function(n,o,r){const i=z(o);e.onQueued?.(n,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:o.total,jobId:o.jobId,visitId:o.visitId,visit:o.visit,queuedAt:o.queuedAt,queueDepth:u.size})}(n,a,r),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 n of t){if(u.size>=a)break;const t=m.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),y.delete(n.bodyId),H(t,n,e,n.sequence)):d.delete(n.jobId)}}function G(){let e=0;for(const t of u.values())e+=t.remaining;return e}function q(){N=Math.max(N,u.size),$=Math.max($,G())}function Y(){const e=S-s,t=Math.max(0,Math.min(s,S-(A??S)));let o=0,r=0,i=0,a=0,c=0;for(const t of g){if(e>t.end)continue;o+=t.arrivals,r+=t.arrivalWork,i+=t.completions,a+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:o,arrivalWork:r,completions:i,completedWork:a,processedWork:c,arrivalsPerSecond:t>0?o/t:0,throughputPerSecond:t>0?i/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:o=>{const r=o.controls.readBodies(),i=new Map,M=new Map;for(const t of r){if(i.set(t.id,t),!F(t.id,o.getRegionState))continue;if(!DM(t,e.bodyFilter))continue;const n=NM(t,e.jobKey),r=M.get(n)??[];r.push(t),M.set(n,r)}const P=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!E){const e=Number.isFinite(o.elapsed)?Math.max(0,o.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},G=new Map;for(const[e,t]of M){const n=h.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];G.set(e,o),m.set(e,o)}for(const[n,r]of h){if(G.has(n))continue;const a=u.get(n),s=i.get(r.bodyId)??m.get(n);if(a){u.delete(n),f.delete(a.bodyId),T+=1,L+=a.remaining,O();const i={...z(a),abandonedAt:S,remainingWork:a.remaining,queueSeconds:Math.max(0,S-a.queuedAt)};s&&e.onAbandoned?.(s,i),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:t,work:a.total,remainingWork:a.remaining,jobId:n,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:S,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(n),y.delete(r.bodyId),h.delete(n),m.delete(n)}for(const[n,r]of G){if(h.has(n))continue;const i=(p.get(n)??0)+1;p.set(n,i);const s=LM(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${i}`,visit:i,regionId:t,work:s,queuedAt:S};h.set(n,c),C+=1,D.arrivals+=1,D.arrivalWork+=s;const l=b++;if(a>u.size)H(r,c,o,l);else{const a={...c,blockedAt:S,sequence:l};d.set(n,a),y.set(r.id,n),_+=1,O(),e.onBlocked?.(r,a),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:s,jobId:n,visitId:c.visitId,visit:i,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}W(o),q();const Y=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let V=n*P;for(const n of Y){if(0>=V)break;const r=Math.min(n.remaining,V);if(n.remaining-=r,V-=r,I+=r,D.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),f.delete(n.bodyId),k+=1,R+=n.total,D.completions+=1,D.completedWork+=n.total;const a=Math.max(0,S-n.queuedAt);B+=a,O();const s=i.get(n.bodyId);if(!s)continue;o.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...z(n),completedAt:S,queueSeconds:a};e.onProcessed?.(s,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:a,queueDepth:u.size})}W(o),q(),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)&&g.push(e);const t=S-s;for(;g.length>0&&t>g[0].end;)g.shift()}(D);const X=Math.floor(S/c);X!==j&&(j=X,O())},getSnapshot:()=>{const e=G(),o=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=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:r,processedCount:k,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+o,blockedDepth:d.size,blockedWork:o,arrivalCount:C,admittedCount:M,admittedWork:P,processedWork:I,completedWork:R,blockedCount:_,abandonedCount:T,abandonedWork:L,peakQueueDepth:N,peakRemainingWork:$,queueAge:{count:i.length,meanSeconds:i.length>0?a/i.length:0,p50Seconds:$M(i,.5),p95Seconds:$M(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:k>0?B/k:0,window:Y(),simulatedAt:S,metricRevision:D}},bodyForce:e=>{if("none"===o)return null;const n=f.get(e.body.id),a=y.get(e.body.id),s=n?u.get(n):void 0,c=a?d.get(a):void 0;if(!s&&!c)return null;const l=s?v.get(e.body.id):x.get(e.body.id);if(null==l)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:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*i,y:(h.y-(l-((c?d.size:w)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:w))-e.body.y)*i*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function EM(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}import{useEffect as FM,useRef as OM}from"react";function zM(){return"undefined"==typeof document||!document.hidden}function HM(e,t,n){const o=Fo(e,n.fill)??"#4e79a7",r=n.stroke,i=n.strokeWidth??0,a=n.opacity??1,s=n.fillOpacity??1,c=function(e,t){const n=t.mark;if(n)return n;const o=e.datum,r=o?.__physicsMark??o?.mark;return"circle"===r||"halo"===r||"faceted"===r||"pill"===r||"diamond"===r||"square"===r?r:"circle"===e.shape.type?"circle":"square"}(t,n),l="circle"===t.shape.type?n.r??t.shape.radius:Math.max(t.shape.width,t.shape.height)/2;if(e.save(),e.globalAlpha*=a,e.beginPath(),"pill"===c||"square"===c||"aabb"===t.shape.type){const n="pill"===c?2.4*l:"aabb"===t.shape.type?t.shape.width:1.7*l,o="pill"===c?1.35*l:"aabb"===t.shape.type?t.shape.height:1.7*l,r=t.x-n/2,i=t.y-o/2,a="pill"===c?o/2:Math.min(4,n/4);e.moveTo(r+a,i),e.arcTo(r+n,i,r+n,i+o,a),e.arcTo(r+n,i+o,r,i+o,a),e.arcTo(r,i+o,r,i,a),e.arcTo(r,i,r+n,i,a),e.closePath()}else if("diamond"===c)e.moveTo(t.x,t.y-l),e.lineTo(t.x+l,t.y),e.lineTo(t.x,t.y+l),e.lineTo(t.x-l,t.y),e.closePath();else if("faceted"===c){const n=6;for(let o=0;n>o;o+=1){const r=2*Math.PI*o/n-Math.PI/2,i=t.x+Math.cos(r)*l,a=t.y+Math.sin(r)*l;0===o?e.moveTo(i,a):e.lineTo(i,a)}e.closePath()}else e.arc(t.x,t.y,l,0,2*Math.PI);o&&(e.save(),e.globalAlpha*=s,e.fillStyle=o,e.fill(),e.restore()),"halo"===c&&(e.beginPath(),e.arc(t.x,t.y,1.35*l,0,2*Math.PI),e.strokeStyle=r??o,e.lineWidth=Math.max(1.5,i||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),r&&i>0&&(e.strokeStyle=r,e.lineWidth=i,n.strokeDasharray&&e.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function WM(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function GM(e){return e.sensorId??"stream-region-"+e.id}function qM(e){const t=GM(e),n={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){const o=e.colliderThickness??8,r=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[{...n,id:t+"-top",shape:{type:"segment",x1:r,y1:a,x2:i,y2:a,thickness:o}},{...n,id:t+"-right",shape:{type:"segment",x1:i,y1:a,x2:i,y2:s,thickness:o}},{...n,id:t+"-bottom",shape:{type:"segment",x1:i,y1:s,x2:r,y2:s,thickness:o}},{...n,id:t+"-left",shape:{type:"segment",x1:r,y1:s,x2:r,y2:a,thickness:o}}]}return e.collider?[{...n,id:t+"-collider",shape:e.shape}]:[]}function YM(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function VM(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const o=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(o)||Number.isFinite(r)?{x:Number.isFinite(o)?o:0,y:Number.isFinite(r)?r:0}:null}function XM(e){if(!1===e.semanticItem)return null;const t=e.shape,n=e.semanticItem??{},o="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{...o,...n,id:n.id??o.id}}function UM(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function KM(e,t){const n="function"==typeof e?e(t):e;if(!n)return null;const o=Number(n.x??0),r=Number(n.y??0);return Number.isFinite(o)||Number.isFinite(r)?{x:Number.isFinite(o)?o:0,y:Number.isFinite(r)?r:0}:null}var QM=[];function ZM(e){const t=e.store.controls(),n=e.store.snapshot(),o=Math.max(0,e.result.steps*(n.config.fixedDt||1/60)),r=function(e,t,n,o){const r=Number.isFinite(o)?Math.max(0,o):0;if(0>=r||!UM(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 o=n.get(t.id);if(!o||!o.activeRegionIds.size)continue;const a=YM(o);if(a)for(const n of o.activeRegionIds){const o=i.get(n);if(!o)continue;const c=VM(o.force,{body:t,region:o,regionState:a}),l=Number(o.damping??0),u=(c?.x??0)*r-(Number.isFinite(l)?t.vx*l*r:0),d=(c?.y??0)*r-(Number.isFinite(l)?t.vy*l*r:0);(u||d)&&(e.applyImpulse(t.id,u,d),s=!0)}}return s}(t,e.regionEffects,e.regionState,o),i=function(e,t,n,o,r,i){const a=Number.isFinite(i)?Math.max(0,i):0;if(0>=a||!t)return!1;const s=new Map(n.map(e=>[e.id,e])),c=e.readBodies();let l=!1;for(let n=0;c.length>n;n+=1){const i=c[n],u=o.get(i.id),d=YM(u);let h=QM;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const n=s.get(t);n&&e.push(n)}h=e}const p=KM(t,{body:i,bodies:c,index:n,regionState:d,regions:h,simulationState:r});if(!p)continue;const m=(p.x??0)*a,f=(p.y??0)*a;(m||f)&&(e.applyImpulse(i.id,m,f),l=!0)}return l}(t,e.bodyForces,e.regionEffects,e.regionState,n.simulationState,o);return e.composed&&e.composed.onTick(e.result,t,{dt:o,elapsed:e.result.elapsedSeconds,getRegionState:t=>YM(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:i,snapshot:n}}function JM(e,t,n,o,r,i,a,s,c,l){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,r),d={selected:u,simulationState:t,regionState:i,regions:a},h="function"==typeof n?n(e,d):n,p=a.reduce((t,n)=>n.bodyStyle?{...t,..."function"==typeof n.bodyStyle?n.bodyStyle(e,d):n.bodyStyle}:t,{}),m=u?"function"==typeof o?o(e,d):o:void 0;return{fill:l?.color??s,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...p,...m}}import{useCallback as eP}from"react";import*as tP from"react";import{jsx as nP,jsxs as oP}from"react/jsx-runtime";var rP={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},iP="semiotic-accessible-data-table",aP=iP+" semiotic-accessible-data-table-hidden",sP=iP+" semiotic-accessible-data-table-visible",cP={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"},lP={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},uP={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)"},dP={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},hP={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))"},pP={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},mP={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},fP={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 yP(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function gP(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function bP(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 vP(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 xP(e){const t=wP(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function wP(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=yP(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function kP({hover:e}){const t=wP(e.data);return oP("div",{className:"semiotic-tooltip",style:tc,children:[nP("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>oP("div",{children:[oP("span",{style:{opacity:.72},children:[e,": "]}),nP("span",{children:t})]},e))]})}function SP(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=yP(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function AP(e){const t=[`${e.length} semantic item${1===e.length?"":"s"}.`],n=new Map;for(const t of e)t.group&&n.set(t.group,(n.get(t.group)??0)+1);return n.size&&t.push(Array.from(n).map(([e,t])=>`${e}: ${t}`).join(", ")),t.join(" ")}function CP(e){const{chartTitle:t,items:n,tableId:o}=e,[r,i]=tP.useState(!1),[a,s]=tP.useState(5),c=ds(),l=c?.visible??!1,u=r||l,d=tP.useRef(null),h="Data summary for "+(t??"physics chart");tP.useEffect(()=>{u||s(5)},[u]);const p=tP.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),m=tP.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!n.length)return nP("span",{id:o,tabIndex:-1,style:rP});if(!u)return nP("div",{id:o,className:aP,role:"region","aria-label":h,tabIndex:-1,style:rP,onFocus:p,children:oP("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",n.length," semantic items)"]})});const f=Math.min(a,n.length),y=n.slice(0,f),g=n.length-f;return oP("div",{ref:d,id:o,className:sP,role:"region","aria-label":h,tabIndex:-1,onBlur:m,style:cP,children:[nP("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},style:uP,children:"×"}),nP("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:lP,children:AP(n)}),oP("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:dP,children:[nP("caption",{className:"semiotic-accessible-data-table-caption",style:mP,children:g>0?`First ${f} of ${n.length} semantic items`:`All ${n.length} semantic items`}),nP("thead",{children:oP("tr",{children:[nP("th",{scope:"col",style:hP,children:"Item"}),nP("th",{scope:"col",style:hP,children:"Description"}),nP("th",{scope:"col",style:hP,children:"Group"}),nP("th",{scope:"col",style:hP,children:"Position"}),nP("th",{scope:"col",style:hP,children:"Data"})]})}),nP("tbody",{children:y.map((e,t)=>oP("tr",{children:[nP("th",{scope:"row",style:pP,children:e.label}),nP("td",{style:pP,children:e.description??e.label}),nP("td",{style:pP,children:e.group??""}),oP("td",{style:pP,children:[Math.round(e.x),", ",Math.round(e.y)]}),nP("td",{style:pP,children:SP(e)})]},e.id??`${e.label}-${t}`))})]}),g>0?oP("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:fP,children:["Show ",Math.min(25,g)," more"," ",1===g?"row":"rows"," (",g," remaining)"]}):null]})}kP.ownsChrome=!0;import{jsx as MP,jsxs as PP}from"react/jsx-runtime";var IP=[640,360],RP={top:0,right:0,bottom:0,left:0},_P=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),TP="StreamPhysicsFrame",LP=IA(PA(function(e,t){const{accessibleTable:n=!0,annotations:o,onAnnotationActivate:r,autoPlaceAnnotations:i,background:a,backgroundGraphics:s,bodySemanticItemLimit:c=200,bodySemanticItems:l=!1,bodySemanticUpdateMs:u=200,bodyForces:d,bodyStyle:h,chartId:p,className:m,frameScheduler:f,clock:y,random:g,seed:b,color:v,config:x,controllers:w,continuous:k=!1,description:S,emphasis:A,chartMode:C,enableHover:M=!0,foregroundGraphics:P,hoverRadius:I=16,initialSpawns:R,initialSpawnPacing:_,legend:T,legendClickBehavior:L,legendHighlightedCategory:N,legendHoverBehavior:$,legendIsolatedCategories:B,legendLayout:D,legendPosition:j,margin:E,onClick:F,onObservation:O,onRegionEvent:z,onSimulationExecutionChange:H,onBodyHover:W,onBodyPointerDown:G,onSemanticItemActivate:q,onSemanticItemFocus:Y,onTick:V,opacity:X,paused:U=!1,regionEffects:K=[],responsiveHeight:Q,responsiveWidth:Z,selectedBodyStyle:J={stroke:"#111827",strokeWidth:2,opacity:1},selection:ee,semanticItems:te=[],simulationExecution:ne="auto",size:oe=IP,stroke:re,strokeWidth:ie,summary:ae,suspendWhenHidden:se=!0,svgAnnotationRules:ce,title:le,tooltipContent:ue,workerBodyThreshold:de=tC,renderBody:he,beforePaint:pe,afterPaint:me}=e,fe=MA.useMemo(()=>({color:v,stroke:re,strokeWidth:ie,opacity:X}),[v,X,re,ie]),ye=NA(O);ye.current=O;const ge=NA(p);ge.current=p;const be=NA(new Map),ve=NA(K);ve.current=K;const xe=NA(d);xe.current=d;const we=NA(V);we.current=V;const ke=MA.useMemo(()=>function(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=EM(n,o.bodyForce(e)));return n}}}(w),[w]),Se=NA(ke);Se.current=ke;const Ae=k||!!ke?.continuous,Ce=NA(Ae);Ce.current=Ae;const Me=MA.useMemo(()=>{if(!d&&!ke?.bodyForce)return d;if(!ke?.bodyForce)return d;if(!d)return ke.bodyForce;const e=ke.bodyForce;return t=>{const n="function"==typeof d?d(t):d,o="function"==typeof e?e(t):e;return n||o?{x:(n?.x??0)+(o?.x??0),y:(n?.y??0)+(o?.y??0)}:null}},[d,ke]);xe.current=Me;const Pe=MA.useMemo(()=>new Map(K.map(e=>[GM(e),e])),[K]),Ie=MA.useMemo(()=>new Map(K.map(e=>[e.id,e])),[K]),Re=MA.useMemo(()=>K.map(XM).filter(e=>null!=e),[K]),[_e,Te]=MA.useState([]),Le=MA.useMemo(()=>_e.length||Re.length?[...te,..._e,...Re]:te,[_e,Re,te]),Ne=MA.useMemo(()=>UM(K),[K]),$e=!!Me,Be=NA(null),De=NA(y??SM);De.current=y??SM;const je=RA((e,t,n)=>{const o=Be.current;if(!o||!n)return!1;const r=o.readBodies().find(t=>t.id===e),i=YM(be.current.get(e));if(!r||!i)return!1;const a=VM(n,{body:r,region:t,regionState:i});return!(!a||!a.x&&!a.y||(o.applyImpulse(e,a.x??0,a.y??0),0))},[]),Ee=RA((e,t,n)=>{if(!n.bodyId)return;const o=YM(be.current.get(n.bodyId));if(!o)return;const r={bodyId:n.bodyId,datum:n.datum,observation:n,region:t,regionState:o,type:e};"region-enter"===e?t.onEnter?.(r):t.onExit?.(r),z?.(r)},[z]),Fe=RA(e=>{const t=e.sensorId?Pe.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const n=function(e,t){let n=e.get(t);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,n)),n}(be.current,e.bodyId),o=Be.current?.readBodies().find(t=>t.id===e.bodyId),r=YM(n),i=o&&r?{body:o,region:t,regionState:r}:null;if("physics-proximity-enter"===e.type){if(n.activeRegionIds.add(t.id),n.regionIds.add(t.id),n.energy+=t.energyDelta??0,i){!function(e,t,n){const o="function"==typeof e.attributes?e.attributes(t):e.attributes;o&&(n.attributes={...n.attributes,...o})}(t,i,n);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&&(n.charges[t.id]=e)}je(e.bodyId,t,t.impulseOnEnter),Ee("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),je(e.bodyId,t,t.impulseOnExit),Ee("region-exit",t,e))},[je,Ee,Pe]),Oe=MA.useMemo(()=>{if(!o?.length)return[];const e=o.filter(e=>"barrier"===e.physics||"sensor"===e.physics);return e.length?function(e=[],t={}){const n=t.idPrefix?t.idPrefix+"-":"",o=[];for(const r of e){if("barrier"!==r.physics&&"sensor"!==r.physics)continue;const e=r.axis??t.defaultAxis??"x",i=eC(r,t),a=r.colliderId??`${n}${r.id}`;let s;if("x"===e){const e=JA(r.x),n=JA(r.y1)??JA(t.plotBounds?.y)??JA(r.y),o=JA(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??JA(r.y);if(null==e||null==n||null==o)continue;s={type:"segment",x1:e,y1:n,x2:e,y2:o,thickness:i}}else{const e=JA(r.y),n=JA(r.x1)??JA(t.plotBounds?.x)??JA(r.x),o=JA(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??JA(r.x);if(null==e||null==n||null==o)continue;s={type:"segment",x1:n,y1:e,x2:o,y2:e,thickness:i}}o.push({id:a,shape:s,sensor:"sensor"===r.physics,..."barrier"!==r.physics||null==r.restitution&&null==t.barrierRestitution?{}:{restitution:JA(r.restitution)??JA(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:JA(r.friction)??JA(t.barrierFriction)}})}return o}(e,{idPrefix:p?p+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:oe?.[0]??IP[0],height:oe?.[1]??IP[1]}}):[]},[o,p,oe]),ze=MA.useMemo(()=>{const e=void 0===b||void 0!==x?.kernel?.seed?x:{...x,kernel:{...x?.kernel,seed:b}},t=K.flatMap(e=>[{id:GM(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...qM(e)]),n=Object.fromEntries(K.map(e=>[GM(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),o=e?.observation,r=K.length>0;return r||t.length>0||Oe.length>0||null!=p||o?{...e,colliders:[...e?.colliders??[],...t,...Oe],observation:{...o,chartId:p??o?.chartId,chartType:o?.chartType??TP,sensors:{...o?.sensors??{},...n},onObservation:e=>{r&&Fe(e),o?.onObservation?.(e)}}}:e},[Oe,p,x,Fe,K,b]);if(!Be.current){const e=kM(ze,R,_);e.setPaused(U),se&&e.setVisible(zM()),Be.current=e}const He=NA(-1),We=NA(null),Ge=NA(!0),qe=Dn("StreamPhysicsFrame"),Ye=NA(""),Ve=LA().replace(/:/g,""),Xe=NA(!1),Ue=NA(!1),Ke=NA(0),Qe=NA(!1),Ze=NA(null),Je=NA(!1),et=Tc({sizeProp:oe,responsiveWidth:Z,responsiveHeight:Q,userMargin:E,marginDefault:RP,foregroundGraphics:P,backgroundGraphics:s,frameScheduler:f,clock:y,random:g,seed:b,paused:U,suspendWhenHidden:se}),{margin:tt,rafRef:nt,reducedMotionRef:ot,renderFnRef:rt,cancelRender:it,resolvedBackground:at,resolvedForeground:st,responsiveRef:ct,scheduleRender:lt,size:ut,frameRuntime:dt}=et,ht=NA(dt.now);ht.current=dt.now;const pt=qa(),mt=Ua(),[ft,yt]=MA.useState(null),[gt,bt]=MA.useState(null),vt=NA(null),xt=NA(0),wt=NA(new Map),kt=Ve+"-physics-live",St=RA((e,t,n=!1)=>{if(!l)return void Te(e=>e.length?[]:e);const o=ht.current();if(!n&&u>0&&u>o-xt.current)return;xt.current=o;const r=function(e,t,n,o){if(!n)return[];const r=Math.max(0,Math.floor(o));if(!r)return[];const i=[];for(let o=0;e.length>o&&r>i.length;o+=1){const r=e[o],a="function"==typeof n?n(r,{index:o,simulationState:t}):void 0;if(!1===a)continue;const s=bP(r);i.push({datum:r.datum??r,description:xP(r),group:"body",label:vP(r),...s,...a??{},bodyId:a?.bodyId??r.id,id:a?.id??"body:"+r.id,x:a?.x??r.x,y:a?.y??r.y})}return i}(e,t,l,c);Te(e=>function(e,t){if(e.length!==t.length)return!0;for(let n=0;e.length>n;n+=1){const o=e[n],r=t[n];if(o.id!==r.id||o.label!==r.label||o.description!==r.description||o.group!==r.group||o.bodyId!==r.bodyId||Math.round(o.x)!==Math.round(r.x)||Math.round(o.y)!==Math.round(r.y))return!0}return!1}(e,r)?r:e)},[c,l,u]),At=RA(e=>{if(!Le.length)return;const t=Math.max(0,Math.min(e,Le.length-1));He.current=t;const n=Le[t];if(vt.current=n.bodyId??null,yt(n),Y?.(n),n.bodyId&&Be.current){const e=Be.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=gP(e);bt(t),W?.(e,t)}}},[Le,W,Y]),Ct=RA(()=>{He.current=-1,vt.current=null,yt(null),Y?.(null)},[Y]),Mt=function({onObservationRef:e,chartIdRef:t,wallClockRef:n}){return eP((o,r)=>{const i=e.current;if(!i)return;const a={timestamp:n.current(),chartType:"StreamPhysicsFrame",chartId:t.current};i("hover"===o||"click"===o?{...a,type:o,datum:r?.datum??{},x:r?.x??0,y:r?.y??0}:"focus"===o?{...a,type:o,datum:r?.datum??{},inputType:"touch"===r?.inputType?"pointer":r?.inputType??"keyboard"}:"activate"===o?{...a,type:o,datum:r?.datum??{},inputType:r?.inputType??"keyboard"}:{...a,type:o})},[t,e,n])}({onObservationRef:ye,chartIdRef:ge,wallClockRef:De}),Pt=RA(()=>{bt(e=>e?(W?.(null,null),Mt("hover-end"),null):e)},[Mt,W]),It=RA(e=>{if(!M||!Be.current)return;const t=e.currentTarget.getBoundingClientRect(),n=Be.current.hitTest(e.clientX-t.left,e.clientY-t.top,I);if(!n)return void Pt();const o=gP(n);bt(e=>e&&e.id===o.id&&e.x===o.x&&e.y===o.y?e:(W?.(n,o),Mt("hover",{datum:n.datum,x:n.x,y:n.y}),o))},[Pt,Mt,M,I,W]),Rt=RA(e=>{Ct();const t=Be.current,n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left,r=e.clientY-n.top,i=t?t.hitTest(o,r,Math.max(16,I)):null;G?.(i,e),i?(Mt("click",{datum:i.datum,x:i.x,y:i.y}),Mt("activate",{datum:i.datum,inputType:"touch"===e.pointerType?"touch":"pointer"}),F?.(i.datum??null,{x:i.x,y:i.y,body:i})):(Mt("click-end"),F?.(null,{x:o,y:r,body:null}),Pt())},[Pt,Ct,Mt,I,G,F]);_A(()=>{if(!Le.length)return void Ct();const e=He.current;if(Le.length>e){if(e>=0){const t=Le[e];if(vt.current=t.bodyId??null,yt(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&&Be.current){const e=Be.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=gP(e);bt(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else At(Le.length-1)},[Le,Ct,At]),_A(()=>{M||Pt()},[Pt,M]);const _t=RA(e=>{if(Wl(e))return;if(!Le.length)return;if("Escape"===e.key)return e.preventDefault(),void Ct();if(("Enter"===e.key||" "===e.key)&&He.current>=0){e.preventDefault();const t=Le[He.current];return Mt("activate",{datum:t.datum??{id:t.id,label:t.label},inputType:"keyboard"}),void q?.(t)}if(!_P.has(e.key))return;e.preventDefault();const t=He.current;if(0>t){At(0);const e=Le[0];return void Mt("focus",{datum:e.datum??{id:e.id,label:e.label},inputType:"keyboard"})}const n=Math.max(1,Math.floor(.1*Le.length));let o=t;if("Home"===e.key?o=0:"End"===e.key?o=Le.length-1:"PageDown"===e.key?o=Math.min(Le.length-1,t+n):"PageUp"===e.key?o=Math.max(0,t-n):"ArrowRight"===e.key||"ArrowDown"===e.key?o=Math.min(Le.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(o=Math.max(0,t-1)),At(o),o!==t){const e=Le[o];Mt("focus",{datum:e.datum??{id:e.id,label:e.label},inputType:"keyboard"})}},[Ct,Mt,At,q,Le]),[Tt,Lt]=MA.useState([]),Nt=NA(0),$t=!!o?.length&&o.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),{canvasRef:Bt}=Bc(et,{hydrated:pt,wasHydratingFromSSR:mt,storeRef:Be,dirtyRef:Ge,manageFrameRuntime:!1,skipInitialCanvasPaintInvalidation:!0,canvasPaintDependencies:[a,s,lt]}),Dt=RA(()=>{const e=Bt.current,t=Be.current;if(!e||!t)return;const n=qe.current.beforeCompute(t.getLastUpdateResult(),!1),o=Oc(),r=Fc(e,ut,tt,o);if(!r)return void qe.current.afterCompute(n,!1,!1);const i=function(e){const t=GA(e,FA),n=GA(e,DA),o=GA(e,WA),r=GA(e,OA),i=GA(e,BA),a=GA(e,$A),s=GA(e,zA),c=GA(e,HA),l=GA(e,jA),u=GA(e,EA);return{annotationBackground:qA(a,.94),annotationStroke:i,annotationText:s,background:a,border:i,closedWindowFill:qA(n,.08),closedWindowStroke:qA(n,.55),danger:n,focus:l,grid:u,gutterFill:qA(c,.14),lateFill:o,openWindowFill:qA(t,.07),openWindowStroke:qA(t,.3),primary:t,selectedFill:o,selectedStroke:l,success:r,text:s,textSecondary:c,warning:o}}(r);r.clearRect(-tt.left,-tt.top,ut[0],ut[1]),s||"transparent"===a||(r.fillStyle=a??i.background,r.fillRect(-tt.left,-tt.top,ut[0],ut[1]));const c=t.snapshot(),l=t.readBodies();if(St(l,c.simulationState),$t){const e=ht.current();if(e-Nt.current>=100){Nt.current=e;const t=function(e){return e.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,QA(e))}))}(l);Lt(e=>e.length===t.length&&e.every((e,n)=>e.pointId===t[n].pointId&&Math.round(e.x)===Math.round(t[n].x)&&Math.round(e.y)===Math.round(t[n].y))?e:t)}}pe&&(r.save(),pe(r,l),r.restore());for(const e of l){const t=be.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Ie.get(e)).filter(e=>null!=e):[],o=JM(e,c.simulationState,h,J,ee,YM(t),n,i.primary,i.text,fe);he?(r.save(),he(r,e,o),r.restore()):HM(r,e,o)}me&&(r.save(),me(r,l),r.restore()),function(e,t,n){let o=!1;for(const[r,i]of t){const a=Math.min(1,Math.max(0,(n-i.startedAt)/i.durationMs));if(a>=1){t.delete(r);continue}o=!0;const s=1-Math.pow(1-a,3),{body:c}=i,l=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(c.x,c.y,l,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(c.x,c.y,.52*l,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 n=t*(Math.PI/4)+1.4*a,o=i.radius+5+12*s,r=i.radius+12+34*s;e.beginPath(),e.moveTo(c.x+Math.cos(n)*o,c.y+Math.sin(n)*o),e.lineTo(c.x+Math.cos(n)*r,c.y+Math.sin(n)*r),e.stroke()}e.restore()}}(r,wt.current,ht.current()),qe.current.afterCompute(n,!0,!1),Ge.current=!1},[Bt,qe,ut,tt,s,a,St,$t,pe,me,h,J,ee,fe,he,Ie]),jt=RA((e,t)=>{const n=Be.current,o=`${ne}:${e}:${t??""}`;Ye.current!==o&&(Ye.current=o,H?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:ne}))},[H,ne]),Et=RA((e,t=!0)=>{Ke.current+=1,Xe.current=!1,Qe.current=!1,Je.current=!1,Ze.current?.terminate(),Ze.current=null,t&&jt("sync",e)},[jt]),Ft=RA(()=>pt?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Ne?"runtime region effects require sync":$e?"body forces require sync":ke?"physics controllers require sync":function(e){return!e||!e.engine&&oC(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(ze??{})?aC(_)?Ue.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[ze,ke,$e,Ne,pt,_]),Ot=RA(()=>{const e=Be.current,t=Ft();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),o=e.queueSize(),r=function(e,t,n=0,o=tC){return"sync"!==e&&("worker"===e||t+n>=o)}(ne,n,o,de);return{reason:r?"worker"===ne?"forced worker":"body threshold":"below threshold",useWorker:r}},[ne,de,Ft]),zt=RA(e=>{const t=Be.current;return t&&e.snapshot?(t.restore(e.snapshot),Ge.current=!0,t):t},[]),Ht=RA((e,t=!0)=>{const n=zt(e);if(!n)return;t&&V?.(e.result,n.controls()),Dt();const o=n.snapshot();!e.result.shouldContinue&&wt.current.size<=0||o.paused||!o.visible||ot.current||lt()},[zt,V,Dt,ot,lt]),Wt=RA(e=>{Ue.current=!0,Et("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Et]),Gt=RA(()=>{const e=Be.current;if(!e)return!1;const t=Ot();if(!t.useWorker)return Xe.current||Je.current?Et(t.reason??"sync fallback"):jt("sync",t.reason??"sync"),!1;if(Xe.current||Je.current)return!0;const n=Ze.current??new lC;Ze.current=n,Je.current=!0;const o=Ke.current+1;return Ke.current=o,n.initFromSnapshot(ze??{},e.snapshot()).then(e=>{if(Ke.current!==o)return;Je.current=!1,Xe.current=!0,Ue.current=!1,zt(e),jt("worker",t.reason??"worker"),Dt();const n=Be.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!ot.current&&(We.current=null,lt())}).catch(e=>{Ke.current===o&&Wt(e)}),!0},[zt,ze,Wt,Dt,ot,jt,lt,Et,Ot]),qt=RA(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Yt=RA((e,t=!0)=>{const n=Ze.current;if(!n||!Xe.current)return;const o=Ke.current;n.request(e).then(e=>{if(Ke.current!==o)return;const n=qt(e);n&&Ht(n,t)}).catch(Wt)},[Ht,qt,Wt]),Vt=RA(()=>{const e=Be.current;if(!e)return;const t=Gt(),n=e.snapshot(),o=Ae||$e||Ne||!!ke;n.paused||!n.visible||!e.hasPendingWork()&&!o||ot.current?rt.current():t&&Je.current||(We.current=null,lt())},[ke,Ae,$e,Ne,ot,rt,lt,Gt]),Xt=RA(()=>{it(),nt.current=null;const e=Be.current;if(!e)return;if(Xe.current&&Ze.current){if(Qe.current)return;let t=0;if(!ot.current){const e=ht.current();t=null!==We.current?(e-We.current)/1e3:0,We.current=e}const n=Ze.current,o=Ke.current;return Qe.current=!0,void(ot.current?n.settle():n.tick(t)).then(e=>{Qe.current=!1,Ke.current===o&&Ht(e)}).catch(n=>{if(Qe.current=!1,Ke.current!==o)return;Wt(n);const r=ot.current?e.settleWithObservations():e.tick(t);ZM({store:e,result:r,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,composed:Se.current,onTick:we.current}),Dt()})}let t;if(ot.current)t=e.settleWithObservations();else{const n=ht.current(),o=null!==We.current?(n-We.current)/1e3:0;We.current=n,t=e.tick(o)}const n=Se.current,{regionEffectsApplied:o,bodyForcesApplied:r,snapshot:i}=ZM({store:e,result:t,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,composed:n,onTick:we.current});Dt(),(Ce.current||t.shouldContinue||o||r||n||wt.current.size>0)&&!i.paused&&i.visible&&!ot.current&&lt()},[Ht,Wt,Dt,it,lt,ot,nt]);rt.current=Xt,_A(()=>{Ue.current=!1,(Xe.current||Je.current)&&Et("config changed",!1),Be.current?.updateConfig(ze??{}),Vt()},[ze,Et]),_A(()=>{Ue.current=!1,Vt()},[pt,ne,de]),function({cancelRender:e,frameRuntime:t,lastFrameTimeRef:n,paused:o,postWorkerCommand:r,requestRender:i,storeRef:a,suspendWhenHidden:s}){const c=OM(r);c.current=r;const l=OM(i);l.current=i,FM(()=>{const r=a.current;r&&(t.setPaused(o),r.setPaused(o),o&&(n.current=null,e()),c.current({type:"setPaused",paused:o},!1),l.current())},[e,t,o]),FM(()=>{if(!s){const e=a.current;return t.setVisible(!0),void(e&&!e.snapshot().visible&&(e.setVisible(!0),c.current({type:"setVisible",visible:!0},!1),l.current()))}if("undefined"==typeof document)return;const o=()=>{const o=a.current;if(!o)return;const r=zM();t.setVisible(r),o.setVisible(r),r||(n.current=null,e()),c.current({type:"setVisible",visible:r},!1),l.current()};return o(),document.addEventListener("visibilitychange",o),()=>document.removeEventListener("visibilitychange",o)},[e,t,s])}({cancelRender:it,frameRuntime:dt,lastFrameTimeRef:We,paused:U,postWorkerCommand:Yt,requestRender:Vt,storeRef:Be,suspendWhenHidden:se}),_A(()=>()=>Et("unmount",!1),[Et]),_A(()=>{Dt()},[Dt]),TA(t,()=>({...Be.current.controls(),applyImpulse:(e,t,n)=>{Be.current.applyImpulse(e,t,n),Yt({type:"applyImpulse",id:e,ix:t,iy:n}),Vt()},clear:()=>{Be.current.clear(),be.current.clear(),wt.current.clear(),Yt({type:"clear"}),Vt()},clearRegionState:e=>{e?be.current.delete(e):be.current.clear(),Vt()},getData:()=>Be.current.readBodies(),getRegionState:e=>e?YM(be.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const o=YM(e);o&&(t[n]=o)}),t}(be.current),getStore:()=>Be.current,pause:()=>{dt.setPaused(!0),We.current=null,it(),Be.current.setPaused(!0),Yt({type:"setPaused",paused:!0},!1),Vt()},push:(e,t)=>{Be.current.enqueue(e,t),aC(t)?Yt({type:"enqueue",spawns:[e],pacing:t}):(Xe.current||Je.current)&&Et("spawn pacing is not worker-cloneable"),Vt()},pushMany:(e,t)=>{Be.current.enqueue(e,t),aC(t)?Yt({type:"enqueue",spawns:e,pacing:t}):(Xe.current||Je.current)&&Et("spawn pacing is not worker-cloneable"),Vt()},popBodies:(e,t={})=>{const n=Be.current,o=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),i=ht.current();for(const e of r){const n=o.get(e);n&&(be.current.delete(e),wt.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??WM(n),startedAt:i}),vt.current===e&&(vt.current=null,yt(null)),bt(t=>t?.id===e?null:t))}return r.length&&(Yt({type:"remove",ids:r}),Vt()),r},remove:e=>{const t=Be.current.remove(e);for(const t of e)be.current.delete(t);return Yt({type:"remove",ids:e}),Vt(),t},restore:e=>{Be.current.restore(e),be.current.clear(),wt.current.clear(),Yt({type:"restore",snapshot:e},!1),Vt()},resume:()=>{dt.setPaused(!1),We.current=null,Be.current.setPaused(!1),Yt({type:"setPaused",paused:!1},!1),Vt()},settle:e=>{const t=Be.current.settle(e);return Yt({type:"settle",maxSteps:e}),Vt(),t},settleWithObservations:e=>{const t=Be.current.settleWithObservations(e);return Yt({type:"settle",maxSteps:e}),Vt(),t},step:e=>{const t=Be.current,n=t.tick(e);return ZM({store:t,result:n,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,composed:Se.current,onTick:we.current}),Yt({type:"tick",deltaSeconds:e}),Dt(),n}}),[it,dt,Dt,Yt,Vt,Et]);const Ut=Ea||!pt&&mt,Kt=["stream-physics-frame",C?"stream-physics-frame--mode-"+C:null,A?"stream-physics-frame--emphasis-"+A:null,m].filter(Boolean).join(" "),Qt=S??("string"==typeof le?le:void 0)??"Physics chart",Zt=Ve+"-physics-table",Jt=Math.max(1,ut[0]-tt.left-tt.right),en=Math.max(1,ut[1]-tt.top-tt.bottom),tn=M&&gt?ue?ue(gt):MP(kP,{hover:gt}):null,nn=tn&&gt?MP(lc,{x:gt.x-tt.left,y:gt.y-tt.top,containerWidth:Math.max(1,ut[0]-tt.left-tt.right),containerHeight:Math.max(1,ut[1]-tt.top-tt.bottom),margin:tt,className:"stream-physics-tooltip",children:tn}):null;if(Ut){const e=Be.current??kM(ze,R,_),t="string"==typeof le?le:void 0,{svg:n}=function(e,t={}){const{width:n=640,height:o=360,title:r,description:i,background:a,className:s,idPrefix:c="physics",...l}=t,u=RM(e,l),d=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(c),h=r?d+"-title":void 0,p=i?d+"-desc":void 0,m=[h,p].filter(Boolean).join(" ")||void 0;return{svg:AM.renderToStaticMarkup(TM("svg",{xmlns:"http://www.w3.org/2000/svg",className:s??"stream-physics-frame",width:n,height:o,viewBox:`0 0 ${n} ${o}`,role:"img","aria-labelledby":m,children:[r&&_M("title",{id:h,children:r}),i&&_M("desc",{id:p,children:i}),a&&"transparent"!==a?_M("rect",{x:0,y:0,width:n,height:o,fill:a}):null,_M("g",{id:d+"-data-area",children:u.sceneNodes.map((e,t)=>ja(e,t,d))})]})),scene:u,evidence:u.evidence}}(e,{width:ut[0],height:ut[1],title:t,description:S,background:"transparent"===a?void 0:a,className:"stream-physics-frame__svg",idPrefix:"physics-"+Ve});return PP("div",{ref:ct,className:Kt,"data-semiotic-mode":C,role:"img","aria-label":Qt,style:{width:ut[0],height:ut[1]},children:[MP(Es,{summary:ae}),MP("div",{dangerouslySetInnerHTML:{__html:n}})]})}return PP("div",{ref:ct,className:Kt,"data-semiotic-mode":C,role:"group","aria-label":Qt,"aria-describedby":ft?kt:void 0,tabIndex:0,style:{position:"relative",width:ut[0],height:ut[1]},onKeyDown:_t,children:["production"!==process.env.NODE_ENV&&Be.current&&MP(jn,{store:Be.current,diagnostics:qe.current}),n?MP(Fs,{tableId:Zt}):null,n?MP(CP,{chartTitle:"string"==typeof le?le:Qt,items:Le,tableId:Zt}):null,MP(Es,{summary:ae}),MP(ms,{hoverPoint:gt}),MP("div",{id:kt,"aria-live":"polite","aria-atomic":"true",style:rP,children:ft?ft.description??ft.label:""}),PP("div",{role:"img","aria-label":Qt,style:{position:"relative",width:"100%",height:"100%"},children:[MP(Dc,{size:ut,margin:tt,children:at}),MP("canvas",{ref:Bt,width:ut[0],height:ut[1],"aria-hidden":"true",onPointerDown:Rt,onPointerMove:M?It:void 0,onPointerLeave:M?Pt:void 0}),st,MP(ZA,{width:Jt,height:en,totalWidth:ut[0],totalHeight:ut[1],margin:tt,title:le,legend:T,legendPosition:j,legendLayout:D,legendHoverBehavior:$,legendClickBehavior:L,legendHighlightedCategory:N,legendIsolatedCategories:B,pointNodes:Tt,annotations:o,onAnnotationActivate:r,onObservation:O,chartId:p,chartType:TP,autoPlaceAnnotations:i,svgAnnotationRules:ce}),MP(Hs,{active:null!=ft,hoverPoint:ft?{x:ft.x,y:ft.y}:null,margin:tt,size:ut,shape:ft?.shape,width:ft?.width,height:ft?.height,pathData:ft?.pathData}),nn]})]})}));LP.displayName="StreamPhysicsFrame";var NP=LP;function $P(e){const[t,n]=e;return{width:t,height:n,plot:{x:32,y:24,width:Math.max(80,t-64),height:Math.max(80,n-58)}}}function BP(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let e=0;t.length>e;e+=1)o=31*o+t.charCodeAt(e)>>>0;return n[o%n.length]}function DP(e,t="#4e79a7",n){const o=n?.styleRules,r=!!o&&o.length>0,i=r?Ah(n?.valueAccessor):void 0;return n=>{const a=n.datum,s=a&&e?"function"==typeof e?e(a,0):a[e]:void 0,c={fill:null==s?t:BP(s),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&a&&Object.assign(c,Rh(a,o,{value:i?i(a):void 0,category:null==s?void 0:s+""})),c}}function jP(e,t,n,o){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function EP(e,t,n){if(!e.length)return[];const o=$P(t),r=o.plot.width/Math.max(1,e.length),i=Math.max(1,...e.map(e=>e.value)),a=.62*o.plot.height,s=o.plot.y+o.plot.height;return e.map((e,t)=>{const c=Math.max(8,e.value/i*a),l=`${n} ${e.label}: ${e.value}${null==e.secondary?"":`, ${e.secondary} secondary`}`;return{id:`${n}-${e.label}`,label:l,description:l,datum:e,x:o.plot.x+(t+.5)*r,y:s-c/2,shape:"rect",width:Math.max(12,.58*r),height:c,group:n}})}function FP(e,t,n){return"function"==typeof n?n(e,t):e[n]}function OP(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 zP(e,t,n){return Math.max(t,Math.min(n,e))}function HP(e,t){const n=OP(e);return null!=n&&n>0?n:t}function WP(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function GP(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 qP}from"d3-scale";function YP(e){const{data:t,valueAccessor:n,bins:o,ballRadius:r,seed:i,size:a,valueExtent:s}=e,c=$P(a),l=t.map((e,t)=>OP(FP(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=OP(e[0]),n=OP(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(s),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),p=h===d?1:h-d,m=qP().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),f=Array.from({length:o},()=>0),y=[];t.forEach((e,t)=>{const i=OP(FP(e,t,n));if(null==i)return;const a=Math.max(0,Math.min(o-1,Math.floor((i-d)/p*o)));f[a]+=1,y.push({id:(e.id??"galton-"+t)+"",x:m(a+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:i,bin:a}})});const g=c.plot.y+c.plot.height;return{config:jP(i,[...rM({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...iM({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:m,yTop:c.plot.y-400,yBottom:g,wallThickness:6})],"GaltonBoardChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:f.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[d,h]}}}import{scaleLinear as VP}from"d3-scale";function XP(e){const{count:t,idPrefix:n,wallThickness:o,xScale:r,yBottom:i,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(i-1,s?.(t)??a),l=Math.max(1,i-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:o,height:l}}})}function UP(e,t,n){const o=e.width/Math.max(1,t),r=Math.max(2,2*n),i=Math.min(.7*o,Math.max(3.2*r,r+8)),a=Math.max(1,Math.floor(i/r));return{laneWidth:o,tubeWidth:i,ballDiameter:r,perRow:a,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/a)*r}}function KP(e){const{data:t,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:i,seed:a,size:s}=e,c=HP(r,1),l=$P(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((FP(e,t,n)??"unknown")+"")});const f=Math.max(1,u.length),y=UP(l.plot,f,i),g=Math.max(0,y.tubeWidth/2-i-1),b=u.map(()=>[]);t.forEach((e,t)=>{const r=(FP(e,t,n)??"unknown")+"",a=m(r),s=o?OP(FP(e,t,o)):1,u=Math.max(0,Math.round((s??0)/c)),d=y.centerX(a);for(let n=0;u>n;n+=1){const o=h.get(r)??0,s=y.perRow>1?((y.perRow>1?o%y.perRow:0)/(y.perRow-1)*2-1)*g:0;h.set(r,o+1),b[a].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+s,y:l.plot.y+i+2,vx:(n%3-1)*i/2,vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...e,category:r,unitIndex:n}})}});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=l.plot.y+l.plot.height,w=[...rM({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;f>e;e+=1){const t=y.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*y.tubeWidth/2,y:(k+x)/2,width:6,height:x-k}})}return{config:jP(a,w,"PhysicsPileChart"),initialSpawns:p,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}import{scaleLinear as QP}from"d3-scale";function ZP(e){const{data:t,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:i,seed:a,size:s,xExtent:c,collisionIterations:l,settle:u}=e,d=$P(s),h=GP(a),p=[],m=[],f=new Map;t.forEach((e,t)=>{const a=OP(FP(e,t,n));if(null==a)return;const s=o?(FP(e,t,o)??"All")+"":"All",c=r?OP(FP(e,t,r)):null,l=zP(null!=c&&c>0?c: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:l})});const y=p.map(e=>e.value),g=c?OP(c[0]):null,b=c?OP(c[1]):null,v=y.length?Math.min(...y):0,x=y.length?Math.max(...y):1;let w=g??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=QP().domain([w,k]).range([A,C]),P=Math.max(1,m.length),I=d.plot.y+Math.max(28,3*S),R=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-I),_=e=>{const t=f.get(e)??0;return 1===P?d.plot.y+.54*d.plot.height:I+t/(P-1)*R},T=new Map,L=p.map((e,t)=>{T.set(e.group,(T.get(e.group)??0)+1);const n=M(e.value),o=_(e.group),r=(h()-.5)*e.radius*1.6,i=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:zP(n+(t%9-4)*e.radius*2.5,A,C),y:u?o+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:n,targetY:o},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:jP(a,rM({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(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:L,projectionRows:m.map(e=>({label:e,value:T.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,C],groups:m.map(e=>({label:e,y:_(e),count:T.get(e)??0})),plot:d.plot}}}function JP(e){if(Array.isArray(e)&&e.length>=2){const t=OP(e[0]),n=OP(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=OP(t.x),o=OP(t.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function eI(e){return Array.isArray(e)?e.map(JP).filter(e=>null!=e):[]}function tI(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:zP(e.x,t.plot.x,t.plot.x+t.plot.width),y:zP(e.y,t.plot.y,t.plot.y+t.plot.height)}}function nI(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function oI(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=zP(t,0,1)*nI(e);let o=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],i=e[t],a=Math.hypot(i.x-r.x,i.y-r.y);if(a>0){if(o+a>=n){const e=(n-o)/a;return{x:r.x+(i.x-r.x)*e,y:r.y+(i.y-r.y)*e}}o+=a}}return{...e[e.length-1]}}function rI(e,t){const n=oI(e,Math.max(0,t-.02)),o=oI(e,Math.min(1,t+.02)),r=o.x-n.x,i=o.y-n.y,a=Math.hypot(r,i)||1;return{x:r/a,y:i/a}}function iI(e){const{coordinateMode:t,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:i,nodeXAccessor:a,nodeYAccessor:s,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:p,seed:m,size:f,sourceAccessor:y,targetAccessor:g,throughputAccessor:b}=e,v=$P(f),x=GP(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")+""}c.forEach((e,t)=>{const n=(FP(e,t,i)??e.id??t)+"",o=OP(FP(e,t,a)),r=OP(FP(e,t,s));if(null!=o&&null!=r){const e={x:o,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const C=[];o.forEach((e,t)=>{const n=A(FP(e,t,y)),o=A(FP(e,t,g)),r=Math.max(0,OP(FP(e,t,b))??0),i=eI(d?FP(e,t,d):void 0),a=i.length?i:eI(e.path??e.points??e.route);a.forEach(e=>S.push(e)),C.push({id:(e.id??`physical-flow-${n}-${o}-${t}`)+"",link:e,index:t,source:n,target:o,throughput:r,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 R=new Map;for(const[e,t]of w)R.set(e,tI(t,v,M));const _=[];for(const e of C){let t=e.rawPath.map(e=>tI(e,v,M));if(2>t.length){const n=R.get(e.source),o=R.get(e.target);n&&o&&(t=[n,o])}else R.has(e.source)||R.set(e.source,t[0]),R.has(e.target)||R.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),_.push({...e,path:t,packetCount:0}))}const T=HP(u,.12),L=Math.max(1,Math.round(r)),N=_.map(e=>Math.max(1,Math.round(e.throughput*T))),$=N.reduce((e,t)=>e+t,0),B=$>L?L/$:1;_.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(N[t]*B))});let D=_.reduce((e,t)=>e+t.packetCount,0);for(;D>L;){const e=_.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>_[e].packetCount)?n:e,-1);if(-1===e)break;_[e].packetCount-=1,D-=1}const j=new Map,E=new Map,F=[],O=HP(n,90),z=HP(l,4);_.forEach((e,t)=>{j.set(e.target,(j.get(e.target)??0)+e.throughput),E.set(e.source,(E.get(e.source)??0)+e.throughput);const n=nI(e.path);for(let o=0;e.packetCount>o;o+=1){const r=(o+.5)/e.packetCount,i=p?r:zP(.12+.84*r+.04*(x()-.5),.04,.98),a=p?i:Math.max(0,i-(.18+.12*x())),s=oI(e.path,a),c=oI(e.path,i),l=rI(e.path,a),u={x:-l.y,y:l.x},d=(x()-.5)*z*1.5;F.push({id:`${e.id}-packet-${o}`,x:s.x+u.x*d,y:s.y+u.y*d,vx:p?0:l.x*O+10*(x()-.5),vy:p?0:l.y*O+10*(x()-.5),mass:.8,spawnAt:p?0:.04*t+o/32,shape:{type:"circle",radius:z},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:o,packetCount:e.packetCount,routeProgress:i,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:O,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&p?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*z,stiffness:26,damping:4.25}]:void 0})}});const H=Math.max(18,5*z),W=Array.from(R,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+WP(e),point:t})),G=W.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:H,height:H}})),q=Object.fromEntries(W.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),Y=jP(m,[...rM({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...G],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*z),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});Y.bodyLimit=L,Y.eviction="oldest",Y.observation={...Y.observation,sensors:q};const V=Array.from(R,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+WP(e),incoming:j.get(e)??0,outgoing:E.get(e)??0})),X=_.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:F,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:F.length,totalThroughput:_.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:X}}}function aI(e,t,n){return Math.max(t,Math.min(n,e))}function sI(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function cI(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),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,n,o,r}function lI(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...cI({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function uI(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 dI(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,o=$P(n),r=zP(e.ballRadius??6,2,18),i=e.seed??1,a=GP(i),s=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,p=e.groupCompletion??(l?"allAbsorbed":"none"),m=e.springStiffness??.28,f=e.springDamping??.72,y=!0===e.settle,g=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",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,a=r,s=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=aI(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,f=aI(d*h+m,.06*d,.5*d),y=f/2,g=u-y,b=u+y,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=aI(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 n=P,o=t===S.length-1?s:P+(e.share??1)/C*M;return P=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),R=I[A],_=R.x0,T=R.x1,L=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=aI((e-a)/Math.max(1,s-a),0,1);return"top"===n?c+(g-c)*t:l+(b-l)*t}if(_>=e){const t=aI((e-a)/Math.max(1,_-a),0,1);return"top"===n?c+(g-c)*t:l+(b-l)*t}if(T>=e)return"top"===n?g:b;const o=aI((e-T)/Math.max(1,s-T),0,1);return"top"===n?g+(c-g)*o:b+(l-b)*o},N=I.map(e=>{const t=Math.min(L(e.x0,"top"),L(e.x1,"top")),n=Math.max(L(e.x0,"bottom"),L(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:x,restitution:w},B=[];"lane"===t?B.push(sI(v+"-top",a,c,s,c,$),sI(v+"-bottom",a,l,s,l,$),sI(v+"-left",a,c,a,l,{...$,thickness:Math.max(6,k-2)}),sI(v+"-right",s,c,s,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?B.push(sI(v+"-top",a,c,s,g,$),sI(v+"-bottom",a,l,s,b,$),sI(v+"-left",a,c,a,l,{...$,thickness:Math.max(6,k-2)}),sI(v+"-right",s,g,s,b,{...$,thickness:Math.max(6,k)})):B.push(sI(v+"-left-top",a,c,_,g,$),sI(v+"-left-bottom",a,l,_,b,$),sI(v+"-center-top",_,g,T,g,$),sI(v+"-center-bottom",_,b,T,b,$),sI(v+"-right-top",T,g,s,c,$),sI(v+"-right-bottom",T,b,s,l,$),sI(v+"-left",a,c,a,l,{...$,thickness:Math.max(6,k-2)}),sI(v+"-right",s,c,s,l,{...$,thickness:Math.max(6,k)}));const D=e.membraneDampingScale??.5,j=a,E=Math.max(1,("bowtie"===t?_:s)-j),F=(e.membranes??[]).map(e=>{const t=j+aI(e.offset,0,1)*E,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),O=!1===e.includeMembraneRegions?[]:F.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=aI(e.cost,0,2);return{...cI({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}({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:n,height:o,padX:r,padY:i,left:a,right:s,topY:c,bottomY:l,midY:u,centerLeft:_,centerRight:T,pinchHeight:f,pinchTop:g,pinchBottom:b,stages:N,membranes:F,colliders:B,regionEffects:O,boundaryY:L}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:g,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 n={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{...cI({...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"}}({...n,kind:e.kind??"sink",force:uI(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return o={...n,kind:e.kind??"force-field",force:uI(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...cI({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;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{...cI({...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}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:uI(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.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,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...cI({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}({...n,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:uI(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?lI({...n,kind:e.kind??"force-field",force:uI(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...cI({...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}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:b.midY,width:t.width,height:b.bottomY-b.topY})});A.unshift(lI({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 n=(s?FP(e,t,s)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",o=(FP(e,t,c)??w)+"",i=v.has(o)?o:w;C.set(i,(C.get(i)??0)+1);const a=l?(FP(e,t,l)??"")+"":void 0,p=a&&u?(FP(e,t,u)??a)+"":a,m=d?OP(FP(e,t,d))??1:1,f=h?OP(FP(e,t,h)):null,y=zP(null!=f&&f>0?f:r,2,18);M.push({datum:e,id:n,stageId:i,groupId:a||void 0,groupLabel:p||void 0,work:m,radius:y,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 R=zP(e.groupAnchorAlong??.55,.15,.9),_=b.left+(b.right-b.left)*R,T=Array.from(P.keys()),L=T.map((e,n)=>{const o=P.get(e)??[],r=T.length>1?b.topY+28+n/Math.max(1,T.length-1)*(b.bottomY-b.topY-56):b.midY;return function(e){const t=e.x??e.anchor?.x??0,n=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:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:I.get(e)??e,bodyIds:o,anchor:{x:_,y:r},x:_,y:r,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 n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.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},c=t.reduce((e,t)=>e+s(t),0),l=t.reduce((e,t)=>e+(n.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}(L,M.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(L.map(e=>[e.id,e])),B=M.map((e,t)=>{const n=x.get(e.stageId)??k,o=n.x+(a()-.5)*Math.min(24,.2*n.width),r=b.boundaryY(o,"top")+e.radius+10,i=b.boundaryY(o,"bottom")-e.radius-10,s=i>r?r+a()*Math.max(1,i-r):b.midY,c=y?o:b.left+18+t%7*4,l=y?s:b.midY+(a()-.5)*(b.bottomY-b.topY)*.35,u=[{target:{type:"point",x:o,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:c,y:l,vx:y?0:40+40*a(),vy:y?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:y?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},j=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:y?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:j,metadata:{kind:"process-flow",plot:o.plot,volume:b,stages:E,groups:L,groupCompletion:N,regionEffects:A}}}import{useImperativeHandle as hI,useRef as pI}from"react";function mI(e,t){if(!t?.length)return[e];const n=t.filter(t=>{if(t.id===e||t.id.startsWith(e+"-"))return!0;const n=t.datum;return!(!n||"object"!=typeof n||null==n.id)&&n.id+""===e}).map(e=>e.id);return n.length?n:[e]}function fI(e,t,n){if("function"==typeof n)return n(e,t)+"";if("string"==typeof n){const t=e[n];if(null!=t)return t+""}return null!=e&&"object"==typeof e&&"id"in e&&null!=e.id?e.id+"":"physics-row-"+t}function yI(e,t){const n=e?.getData().find(e=>e.id===t),o=n?.datum;if(o&&"object"==typeof o)return o}function gI(e,t){const{frameRef:n,spawnDatum:o,seedRows:r,idAccessor:i,bodyIdsForSeed:a,seedSpawns:s}=t,c=pI(new Map),l=pI(new Map),u=pI(""),d=r?r.map((e,t)=>fI(e,t,i)).join("\0"):"";if(d!==u.current&&(u.current=d,r))for(let e=0;r.length>e;e+=1){const t=r[e],n=fI(t,e,i);c.current.set(n,t),l.current.set(n,a?.(t,n,e)??mI(n,s))}hI(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=o(e,t);return{datumId:n.datumId||fI(e,t,i),spawns:n.spawns.map(e=>({...e,spawnAt:void 0}))}}function a(o){const r=[];for(const{datum:n,result:i}of o)e.set(i.datumId,n),t.set(i.datumId,i.spawns.map(e=>e.id)),r.push(...i.spawns);if(!r.length)return;const i=n.current;i?(i.pushMany(r),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(o){const r=e.get(o);if(r)return r;const i=t.get(o)??[o];for(const r of i){const i=yI(n.current,r);if(i)return e.set(o,i),t.has(o)||t.set(o,[r]),i}}return{push:t=>{a([{datum:t,result:r(t,e.size)}])},pushMany:t=>{const n=e.size;a(t.map((e,t)=>({datum:e,result:r(e,n+t)})))},remove:o=>{const r=Array.isArray(o)?o:[o],i=[],a=[];for(const n of r){const o=s(n);o&&i.push(o),e.delete(n),a.push(...t.get(n)??[n]),t.delete(n)}return a.length&&n.current?.remove(a),i},update:(o,i)=>{const c=Array.isArray(o)?o:[o],l=[];for(const o of c){const c=s(o);if(!c)continue;l.push(c);const u=t.get(o)??[o];n.current?.remove(u),e.delete(o),t.delete(o);const d=i(c);a([{datum:d,result:r(d,e.size)}])}return l},clear:()=>{e.clear(),t.clear(),u.current="",n.current?.clear()},getData:()=>{const t=n.current;if(!t)return Array.from(e.values());const o=t.getData().map(e=>e.datum).filter(e=>!!e&&"object"==typeof e);return o.length?o:Array.from(e.values())},getScales:()=>null,getCustomLayout:()=>n.current?.snapshot()??null,popBodies:(e,t)=>n.current?.popBodies(e,t)??[]}},[n,i,o])}import{useMemo as bI}from"react";import{Fragment as vI,jsx as xI,jsxs as wI}from"react/jsx-runtime";var kI=new Set(["sample","mechanical"]);function SI(e,t,n){const o=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&kI.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"},r=Vd(o.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],c=t[1],l=bI(()=>{return e=[s,c],(null!=i&&null!=a?[i,a]:void 0)??[r.width??e[0],r.height??e[1]];var e},[c,s,r.height,r.width,a,i]),u=r.compactMode?"sparkline"===o.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??!r.compactMode,h=e.showChrome??!r.compactMode,p=PI(e.tooltip,void 0),m=void 0!==p.enableHover?p.enableHover:r.enableHover,f=r.compactMode?r.title:r.title??e.title,y=[e.className,o.chartMode&&"primary"!==o.chartMode?"semiotic-physics--"+o.chartMode:null].filter(Boolean).join(" ")||void 0;return{chartMode:o.chartMode,simulationMode:o.simulationMode,resolved:r,chartSize:l,margin:u,showProjection:d,showChrome:h,enableHover:m,title:f,description:r.description??e.description,summary:r.summary??e.summary,accessibleTable:r.accessibleTable??e.accessibleTable,className:y,compactMode:r.compactMode,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics}}function AI(e){const[t,n]=e.size;return sh(e.loading,t,n,e.loadingContent)||ah(e.data,t,n,e.emptyContent)}function CI(e,t,n){return xI(oh,{componentName:e,width:t[0],height:t[1],children:n})}function MI(e,t){return e?t?n=>wI(vI,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function PI(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:sc(e)||t?.tooltipContent}}function II(e,t,n,o){return{accessibleTable:o?.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:o?.chartMode??t?.chartMode,className:o?.className??e.className??t?.className,color:e.color??t?.color,description:o?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:o?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:o?.margin??t?.margin,onClick:null!=e.onClick?(t,n)=>{t&&e.onClick?.(t,{x:n.x,y:n.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,onAnnotationActivate:t?.onAnnotationActivate,opacity:e.opacity??t?.opacity,semanticItems:t?.semanticItems??n,stroke:e.stroke??t?.stroke,strokeWidth:e.strokeWidth??t?.strokeWidth,summary:o?.summary??e.summary??t?.summary,svgAnnotationRules:e.svgAnnotationRules??t?.svgAnnotationRules,title:o?.title??e.title??t?.title}}import{Fragment as RI,jsx as _I,jsxs as TI}from"react/jsx-runtime";var LI=kA(function(e,t){const{data:n,valueAccessor:o="value",styleRules:r,bins:i=21,ballRadius:a=6,colorBy:s,branchProbability:c=.5,emptyContent:l,frameProps:u,loading:d,loadingContent:h,mechanicalCount:p,paused:m,pegRows:f,referenceLines:y,responsiveHeight:g,responsiveWidth:b,seed:v=1,valueExtent:x}=e,w=SI(e,[700,420],{hasSimulationMode:!0}),{chartSize:k,simulationMode:S,showProjection:A,className:C,title:M,chartMode:P,margin:I,enableHover:R,description:_,summary:T,accessibleTable:L}=w,N=CA(null),$=Math.max(1,Math.round(f??i-1)),B=AA(()=>"mechanical"===S?[0,$]:function(e){if(!e)return;const t=Number(e[0]),n=Number(e[1]);return Number.isFinite(t)&&Number.isFinite(n)?t>n?[n,t]:[t,n]:void 0}(x),[$,S,x]),D=AA(()=>"mechanical"===S?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),o=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=zP(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=GP(e.seed??1),a=e.idPrefix??"mechanical";return Array.from({length:o},(e,t)=>{let o=0;for(let e=0;n>e;e+=1)i()<r&&(o+=1);const s=n/2;return{id:`${a}-${t}`,value:o,mechanical:!0,pegRows:n,branchProbability:r,pathRights:o,side:s>o?"left":o>s?"right":"center"}})}({bins:i,branchProbability:c,count:p,pegRows:$,seed:v}):n??[],[i,c,n,p,$,v,S]),j=AA(()=>YP({data:D,valueAccessor:o,bins:i,ballRadius:a,seed:v,size:k,valueExtent:B}),[a,i,D,k,B,v,o]);gI(t,{frameRef:N,spawnDatum:SA((e,t)=>{const n=YP({data:[e],valueAccessor:o,bins:i,ballRadius:a,seed:v+t+1,size:k,valueExtent:B}).initialSpawns[0]??{id:(e.id??"galton-push-"+t)+"",x:$P(k).plot.x,y:$P(k).plot.y,mass:1,shape:{type:"circle",radius:a},datum:e};return{datumId:(e.id??n.id)+"",spawns:[n]}},[a,i,k,B,v,o]),seedRows:D,seedSpawns:j.initialSpawns});const E="mechanical"===S&&null==s?"side":s,F=AA(()=>DP(E,"#4e79a7",{styleRules:r,valueAccessor:o}),[E,r,o]),O=AA(()=>EP(j.projectionRows,k,"bin"),[k,j.projectionRows]),z=AI({data:"mechanical"===S?D:n,emptyContent:l,loading:d,loadingContent:h,size:k});if(z)return z;const H=function(e,t,n,o,r){const i=Array.isArray(r)?r:r?[r]:[];if(!1!==n||0!==i.length)return({size:r})=>{const a=[Number(r[0])||700,Number(r[1])||420],s=$P(a),c=Math.max(2,Math.round(t)),l=s.plot.width/c,u=s.plot.y+s.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==n,[p,m]=o?.valueExtent??[0,c],f=m===p?1:m-p,y=e.map((e,t)=>{const n=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${(s.plot.x+(t+.5)*l).toFixed(1)} ${n.toFixed(1)}`}).join(" ");return TI("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?TI(RI,{children:[Array.from({length:c+1},(e,t)=>{const n=s.plot.x+t*l;return _I("line",{"data-testid":"galton-board-bin-wall",x1:n,x2:n,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),_I("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),_I("path",{d:y,fill:"none",stroke:"var(--semiotic-accent, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?_I("text",{x:s.plot.x+(t+.5)*l,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 n=Number(e.value);if(!Number.isFinite(n))return null;const o=s.plot.x+Math.max(0,Math.min(1,(n-p)/f))*s.plot.width,r=e.color??"var(--semiotic-warning, #f28e2b)",i="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;return TI("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[_I("line",{x1:o,x2:o,y1:s.plot.y+8,y2:u-4,stroke:r,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:_I("text",{x:Math.min(s.plot.x+s.plot.width-4,o+6),y:i,fill:r,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${n}`)})]})}}(j.projectionRows,i,A,j.metadata,y),W=PI(e.tooltip,u),G=II(e,u,O,{chartMode:P,className:C,title:M,description:_,summary:T,accessibleTable:L,enableHover:R,margin:I});return CI("GaltonBoardChart",k,_I(NP,{...u,...W,...G,ref:N,config:j.config,foregroundGraphics:MI(H,u?.foregroundGraphics),initialSpawns:j.initialSpawns,initialSpawnPacing:j.initialSpawnPacing,paused:m,responsiveHeight:g,responsiveWidth:b,size:k,bodyStyle:F}))});import{forwardRef as NI,useCallback as $I,useMemo as BI,useRef as DI}from"react";import{jsx as jI,jsxs as EI}from"react/jsx-runtime";var FI=NI(function(e,t){const{arrivalAccessor:n="arrivalTime",ballRadius:o=7,colorBy:r,styleRules:i,data:a,emptyContent:s,frameProps:c,loading:l,loadingContent:u,paused:d,responsiveHeight:h,responsiveWidth:p,seed:m=1,timeAccessor:f="time",timeExtent:y,timeScale:g=1,watermark:b,windows:v={size:10}}=e,x=SI(e,[760,360]),{chartSize:w,showProjection:k,className:S,title:A,chartMode:C,margin:M,enableHover:P,description:I,summary:R,accessibleTable:_}=x,T=DI(null),L=BI(()=>a??[],[a]),N=BI(()=>function(e){const{data:t,timeAccessor:n,arrivalAccessor:o,windows:r,watermark:i,ballRadius:a,seed:s,size:c,timeExtent:l,timeScale:u=1}=e,d=$P(c),h=t.map((e,t)=>OP(FP(e,t,n))).filter(e=>null!=e),p=OP(l?.[0]),m=OP(l?.[1]),f=h.length?Math.min(...h):0,y=h.length?Math.max(...h):f+r.size,g=Math.min(p??f,f),b=Math.max(m??y,y),v=Math.floor(g/r.size)*r.size,x=Math.max(1,Math.ceil((b-v+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof i?i(w):OP(i?.value)??w-(i?.delay??r.size),S=Math.max(0,Math.min(x,Array.from({length:x},(e,t)=>t).reduce((e,t)=>v+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,a),C=v+x*r.size,M=VP().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=OP(FP(e,t,n));if(null==i)return;const s=OP(FP(e,t,o))??i,c=Math.max(0,Math.min(x-1,Math.floor((i-v)/r.size))),l=k>=v+(c+1)*r.size;P[c].value+=l?0:1,P[c].secondary+=l?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:c,late:l}})});const R=d.plot.y+d.plot.height,_=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const o=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,i=VP().domain([o,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=i(e.windowStart+n*e.windowSize),s=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),l=e=>a===s?t:c+(e-s)/(a-s)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,o=n+e.windowSize,r=i(n),a=i(o);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:a,y2:l(a)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:x,windowPlot:A.windowPlot,windowSize:r.size,windowStart:v},d.plot.y+.28*d.plot.height);return{config:jP(s,[...rM({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...XP({idPrefix:"eventdrop-window",count:x,xScale:e=>M(v+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?_[0]?.y1:_[e-1]?.y2??_[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*a},yBottom:R,wallThickness:6}),..._.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*r.size}-${v+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:_,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:x,windowSize:r.size,windowStart:v}}}({data:L,timeAccessor:f,arrivalAccessor:n,windows:v,watermark:b,ballRadius:o,seed:m,size:w,timeExtent:y,timeScale:g}),[n,o,w,L,m,f,y,g,b,v]),$=N.metadata;gI(t,{frameRef:T,spawnDatum:$I((e,t)=>{const r=$?function(e,t,n,o){const r=OP(FP(e,t,o.timeAccessor));if(null==r)return null;const i=OP(FP(e,t,o.arrivalAccessor))??r,{windowPlot:a,windowStart:s,windowCount:c,windowSize:l,watermarkValue:u}=n,d=s+c*l,h=VP().domain([s,d]).range([a.x,a.x+a.width]),p=Math.max(0,Math.min(c-1,Math.floor((r-s)/l))),m=u>=s+(p+1)*l,{ballRadius:f}=o;return{id:(e.id??"event-push-"+t)+"",x:Math.max(a.x+f,Math.min(a.x+a.width-f,h(r))),y:a.y+f+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,shape:{type:"circle",radius:f},datum:{...e,eventTime:r,arrivalTime:i,windowIndex:p,late:m}}}(e,t,$,{timeAccessor:f,arrivalAccessor:n,ballRadius:o}):null,i=r??{id:(e.id??"event-push-"+t)+"",x:$P(w).plot.x,y:$P(w).plot.y,mass:1,shape:{type:"circle",radius:o},datum:e};return{datumId:(e.id??i.id)+"",spawns:[i]}},[n,o,w,$,f]),seedRows:L,seedSpawns:N.initialSpawns});const B=BI(()=>DP(r,"#4e79a7",{styleRules:i,valueAccessor:f}),[r,i,f]),D=BI(()=>function(e,t,n){if(!t)return EP(e,n,"window");const o=t.windowPlot.width/Math.max(1,e.length),r=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,n)=>{const s=Math.max(8,(e.value+(e.secondary??0))/r*i),c=`window ${e.label}: ${e.value} on time${e.secondary?`, ${e.secondary} late`:""}`;return{id:"window-"+e.label,label:c,description:c,datum:e,x:t.windowPlot.x+(n+.5)*o,y:a-s/2,shape:"rect",width:Math.max(12,.58*o),height:s,group:"window"}})}(N.projectionRows,$,w),[w,N.projectionRows,$]),j=AI({data:a,emptyContent:s,loading:l,loadingContent:u,size:w});if(j)return j;const E=function(e,t,n){if(!1!==n&&t)return({size:n})=>{const o=[Number(n[0])||760,Number(n[1])||360],r=$P(o),i=Math.max(1,t.windowCount),a=t.plot??r.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},c=t.windowPlot??a,l=c.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=c.x+Math.max(0,Math.min(1,m===p?0:(t.watermarkValue-p)/(m-p)))*c.width;return EI("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[jI("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?EI("g",{children:[jI("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}),jI("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},(n,r)=>{const i=e[r],a=c.x+r*l,s=t.closedWindowCount>r,h=i?.secondary??0;return EI("g",{children:[jI("rect",{x:a,y:d,width:l,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===r).map(e=>jI("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,EI("text",{x:a+l/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:[i?.value??0,h?` / ${h} late`:""]}),jI("text",{x:a+l/2,y:Math.min(o[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:i?.label??""})]},"window-"+r)}),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>jI("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)),jI("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),jI("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}),EI("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?EI("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]})}}(N.projectionRows,N.metadata,k),F=PI(e.tooltip,c),O=II(e,c,D,{chartMode:C,className:S,title:A,description:I,summary:R,accessibleTable:_,enableHover:P,margin:M});return CI("EventDropChart",w,jI(NP,{...c,...F,...O,ref:T,config:N.config,foregroundGraphics:MI(E,c?.foregroundGraphics),initialSpawns:N.initialSpawns,initialSpawnPacing:N.initialSpawnPacing,paused:d,responsiveHeight:h,responsiveWidth:p,size:w,bodyStyle:B}))});import{forwardRef as OI,useCallback as zI,useMemo as HI,useRef as WI}from"react";import{scaleLinear as GI}from"d3-scale";function qI(e,t){const n=t.config??{},o=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...o],i=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...i.length>0&&{colliders:i}}}function YI(e){const t=function(e,t,n){const o=e?.observation;return{...e,observation:{...o,chartId:t??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:n??o?.onObservation}}}(e.config,e.chartId,e.onObservation),n=Pf(e.colorScheme,e.themeCategorical,fe),o=$P(e.size),r={data:e.data,scales:{x:GI().domain(e.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:GI().domain(e.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:If(n,e.colorScheme),config:e.layoutConfig??{},world:new wM(t)},i=e.skipLayout?{}:e.layout(r)??{},a=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...o}=e,r=n.get(t)??[];r.push(o),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...i.initialSpawns??i.bodies??[]],i.constraints);return{config:qI(t,i),context:r,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:a,result:i}}import{jsx as VI}from"react/jsx-runtime";var XI=OI(function(e,t){const{chartId:n,color:o,colorBy:r,colorScheme:i,config:a,controllers:s,data:c,emptyContent:l,frameProps:d={},layout:h,layoutConfig:p,loading:m,loadingContent:f,onObservation:y,opacity:g,paused:b,spawnDatum:v,stroke:x,strokeWidth:w,title:k,xExtent:S,yExtent:A}=e,C=SI(e,[700,380]),{chartSize:M,className:P,title:I,chartMode:R,margin:_,enableHover:T,description:L,summary:N,accessibleTable:$}=C,B=WI(null),D=WI(null),j=WI(""),E=AI({data:c,emptyContent:l,loading:m,loadingContent:f,size:M}),F=null!=E,O=HI(()=>u(c??[]),[c]),z=ee(e=>e.theme),H=HI(()=>Y(z)??{},[z]),W=z?.colors?.categorical??U.colors.categorical,G=HI(()=>[M[0],M[1],O.length,O.map((e,t)=>(e.id??t)+"").join("|"),S?.join(",")??"",A?.join(",")??""].join("::"),[M,O,S,A]),q=HI(()=>YI({chartId:n,colorScheme:i,config:a,data:O,layout:h,layoutConfig:p,onObservation:y,semantic:H,skipLayout:F,size:M,themeCategorical:W,xExtent:S,yExtent:A}),[n,M,i,a,h,p,y,O,H,F,W,S,A]);j.current===G&&null!=D.current||(j.current=G,D.current=q.initialSpawns);const V=D.current,X=HI(()=>{const e=[...q.result.controllers??[],...s??[],...d.controllers??[]];return e.length?e:void 0},[d.controllers,s,q.result.controllers]),K=HI(()=>{const e=[...q.result.regionEffects??[],...d.regionEffects??[]];return e.length?e:void 0},[d.regionEffects,q.result.regionEffects]),Q=zI(e=>{const t=e.datum,n=t&&r?function(e,t,n){return"function"==typeof n?n(e,0):e[n]}(t,0,r)+"":e.id;return{fill:o??q.context.resolveColor(n,t),stroke:x??"#111827",strokeWidth:w??1,opacity:g??.9}},[o,r,g,q.context,x,w]);gI(t,{frameRef:B,spawnDatum:zI((e,t)=>{const o=e;if(v)return function(e,t,n){return Array.isArray(n)?{datumId:(e.id??n[0]?.id??"physics-custom-"+t)+"",spawns:n}:"spawns"in n?n:{datumId:(e.id??n.id??"physics-custom-"+t)+"",spawns:[n]}}(e,t,v(o,t,q.context));const r=YI({chartId:n,colorScheme:i,config:a,data:[o],layout:h,layoutConfig:p,onObservation:y,semantic:H,size:M,themeCategorical:W,xExtent:S,yExtent:A}),s=r.initialSpawns.length?r.initialSpawns:[{id:(e.id??"physics-custom-"+t)+"",x:r.context.dimensions.plot.x+r.context.dimensions.plot.width/2,y:r.context.dimensions.plot.y+12,mass:1,shape:{type:"circle",radius:5},datum:e}];return{datumId:(e.id??s[0].id)+"",spawns:s}},[n,M,i,a,v,h,p,y,q.context,H,W,S,A]),seedRows:O,seedSpawns:V});const Z=zI((e,t)=>{d.onBodyPointerDown?.(e,t)},[d]);if(E)return E;const J=PI(e.tooltip,d),te=II(e,d,q.result.semanticItems,{chartMode:R,className:P,title:I??k,description:L,summary:N,accessibleTable:$,enableHover:T,margin:_});return CI("PhysicsCustomChart",M,VI(NP,{...d,...J,...te,ref:B,backgroundGraphics:MI(d.backgroundGraphics,q.result.backgroundOverlays),bodyForces:q.result.bodyForces??d.bodyForces,bodyStyle:q.result.bodyStyle??d.bodyStyle??Q,config:q.config,controllers:X,foregroundGraphics:MI(d.foregroundGraphics,q.result.overlays),initialSpawnPacing:q.initialSpawnPacing,initialSpawns:V,onBodyPointerDown:Z,paused:b,regionEffects:K,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:q.result.selectedBodyStyle??d.selectedBodyStyle,size:M}))});XI.displayName="PhysicsCustomChart";import{forwardRef as UI,useCallback as KI,useMemo as QI,useRef as ZI}from"react";import{jsx as JI,jsxs as eR}from"react/jsx-runtime";var tR=UI(function(e,t){const{ballRadius:n=8,categoryAccessor:o="category",colorBy:r,data:i,emptyContent:a,frameProps:s,loading:c,loadingContent:l,mechanicalCategories:u,mechanicalCount:d,paused:h,responsiveHeight:p,responsiveWidth:m,seed:f=1,unitValue:y=1,valueAccessor:g,styleRules:b}=e,v=SI(e,[700,380],{hasSimulationMode:!0}),{chartSize:x,simulationMode:w,showProjection:k,className:S,title:A,chartMode:C,margin:M,enableHover:P,description:I,summary:R,accessibleTable:_}=v,T=ZI(null),L="mechanical"===w&&null==g?"value":g,N=QI(()=>"mechanical"===w?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],o=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=HP(e.unitValue,1),i=GP(e.seed??1),a=e.idPrefix??"mechanical-pile",s=n.map(()=>.65+.9*i()),c=s.reduce((e,t)=>e+t,0)||1,l=o-n.length,u=s.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=o-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 n.map((e,t)=>({id:`${a}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/o}))}({categories:u,count:d,seed:f,unitValue:y}):i??[],[i,u,d,f,w,y]),$=QI(()=>KP({data:N,categoryAccessor:o,valueAccessor:L,unitValue:y,ballRadius:n,seed:f,size:x}),[n,o,x,N,L,f,y]);gI(t,{frameRef:T,spawnDatum:KI((e,t)=>{const r=KP({data:[e],categoryAccessor:o,valueAccessor:L,unitValue:y,ballRadius:n,seed:f+t+1,size:x}),i={id:(e.id??"pile-push-"+t)+"",x:$P(x).plot.x,y:$P(x).plot.y,mass:1,shape:{type:"circle",radius:n},datum:e},a=r.initialSpawns.length?r.initialSpawns:[i];return{datumId:(e.id??a[0].id)+"",spawns:a}},[n,o,x,L,f,y]),seedRows:N,seedSpawns:$.initialSpawns});const B="mechanical"===w&&null==r?"category":r,D=QI(()=>DP(B,"#4e79a7",{styleRules:b,valueAccessor:g}),[B,b,g]),j=QI(()=>EP($.projectionRows,x,"category"),[x,$.projectionRows]),E=AI({data:"mechanical"===w?N:i,emptyContent:a,loading:c,loadingContent:l,size:x});if(E)return E;const F=function(e,t,n){if(!1!==n&&0!==e.length)return({size:n})=>{const o=[Number(n[0])||700,Number(n[1])||380],r=$P(o),i=UP(r.plot,e.length,t),a=r.plot.y+r.plot.height;return eR("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[JI("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:a,y2:a,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{const n=Math.min(r.plot.height,i.pileHeight(e.value)),s=i.tubeWidth,c=i.centerX(t),l=a-n;return eR("g",{children:[JI("rect",{x:c-s/2,y:l,width:s,height:n,rx:3,fill:"var(--semiotic-accent, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-accent, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),JI("text",{x:c,y:Math.max(r.plot.y+12,l-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),JI("text",{x:c,y:Math.min(o[1]-8,a+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)})]})}}($.projectionRows,n,k),O=PI(e.tooltip,s),z=II(e,s,j,{chartMode:C,className:S,title:A,description:I,summary:R,accessibleTable:_,enableHover:P,margin:M});return CI("PhysicsPileChart",x,JI(NP,{...s,...O,...z,ref:T,config:$.config,foregroundGraphics:MI(F,s?.foregroundGraphics),initialSpawns:$.initialSpawns,initialSpawnPacing:$.initialSpawnPacing,paused:h,responsiveHeight:p,responsiveWidth:m,size:x,bodyStyle:D}))});import{forwardRef as nR,useCallback as oR,useMemo as rR,useRef as iR}from"react";import{jsx as aR,jsxs as sR}from"react/jsx-runtime";function cR(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}var lR=nR(function(e,t){const{colorBy:n,styleRules:o,collisionIterations:r,data:i,emptyContent:a,frameProps:s,groupAccessor:c,loading:l,loadingContent:u,paused:d,pointRadius:h=5,radiusAccessor:p,responsiveHeight:m,responsiveWidth:f,seed:y=1,settle:g,xAccessor:b="x",xExtent:v}=e,x=SI(e,[700,360]),{chartSize:w,showProjection:k,className:S,title:A,chartMode:C,margin:M,enableHover:P,description:I,summary:R,accessibleTable:_}=x,T=iR(null),L=rR(()=>i??[],[i]),N=rR(()=>ZP({data:L,xAccessor:b,groupAccessor:c,radiusAccessor:p,pointRadius:h,seed:y,size:w,xExtent:v,collisionIterations:r,settle:g}),[L,w,r,c,h,p,y,g,b,v]);gI(t,{frameRef:T,spawnDatum:oR((e,t)=>{const n=ZP({data:[e],xAccessor:b,groupAccessor:c,radiusAccessor:p,pointRadius:h,seed:y+t+1,size:w,xExtent:v,collisionIterations:r,settle:g}).initialSpawns[0]??{id:(e.id??"collision-swarm-push-"+t)+"",x:$P(w).plot.x,y:$P(w).plot.y,mass:1,shape:{type:"circle",radius:h},datum:e};return{datumId:(e.id??n.id)+"",spawns:[n]}},[w,r,c,h,p,y,g,b,v]),seedRows:L,seedSpawns:N.initialSpawns});const $=n??c,B=rR(()=>DP($,"#4e79a7",{styleRules:o,valueAccessor:b}),[$,o,b]),D=AI({data:i,emptyContent:a,loading:l,loadingContent:u,size:w});if(D)return D;const j=function(e,t){if(!1!==t&&e)return({size:t})=>{const n=[Number(t[0])||700,Number(t[1])||360],o=$P(n),r=o.plot.y+o.plot.height,[i,a]=e.xExtent,s=i+(a-i)/2,c=[{label:cR(i),x:e.xRange[0]},{label:cR(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:cR(a),x:e.xRange[1]}];return sR("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.map(e=>sR("g",{children:[aR("line",{x1:o.plot.x,x2:o.plot.x+o.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),aR("text",{x:o.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),sR("text",{x:o.plot.x+o.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count]})]},e.label)),aR("line",{x1:e.xRange[0],x2:e.xRange[1],y1:r,y2:r,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),c.map(e=>sR("g",{children:[aR("line",{x1:e.x,x2:e.x,y1:r,y2:r+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),aR("text",{x:e.x,y:Math.min(n[1]-8,r+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}(N.metadata,k),E=function(e){if(!e)return[];const t=Math.max(24,e.xRange[1]-e.xRange[0]),n=e.xRange[0]+t/2;return e.groups.map(e=>{const o=`${e.label} lane: ${e.count} points`;return{id:"collision-swarm-"+e.label,label:o,description:o,datum:e,x:n,y:e.y,shape:"rect",width:t,height:28,group:"lane"}})}(N.metadata),F=PI(e.tooltip,s),O=II(e,s,E,{chartMode:C,className:S,title:A,description:I,summary:R,accessibleTable:_,enableHover:P,margin:M});return CI("CollisionSwarmChart",w,aR(NP,{...s,...F,...O,ref:T,config:N.config,foregroundGraphics:MI(j,s?.foregroundGraphics),initialSpawns:N.initialSpawns,paused:d,responsiveHeight:m,responsiveWidth:f,size:w,bodyStyle:B}))});import{forwardRef as uR,useCallback as dR,useMemo as hR,useRef as pR}from"react";import{jsx as mR,jsxs as fR}from"react/jsx-runtime";function yR(e){return e.toLocaleString(void 0,1e3>Math.abs(e)?{maximumFractionDigits:1}:{maximumFractionDigits:0})}function gR(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function bR(e){if(!e||"object"!=typeof e)return null;const t=e,n=Number(t.x),o=Number(t.y);return Number.isFinite(n)&&Number.isFinite(o)?{x:n,y:o}:null}function vR(e){if(!e||"object"!=typeof e)return[];const t=e.flowPath;return Array.isArray(t)?t.map(bR).filter(e=>null!=e):[]}function xR(e,t){if(2>t.length)return null;let n=0;const o=[];for(let e=1;t.length>e;e+=1){const r=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);o.push(r),n+=r}if(0>=n)return null;let r=null,i=0;for(let a=1;t.length>a;a+=1){const s=t[a-1],c=t[a],l=o[a-1];if(0>=l)continue;const u=c.x-s.x,d=c.y-s.y,h=Math.max(0,Math.min(1,((e.x-s.x)*u+(e.y-s.y)*d)/(l*l))),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*l)/n,tangent:{x:u/l,y:d/l},totalLength:n};r&&m.distance>=r.distance||(r=m),i+=l}return r}function wR(e,t,n){if(0===e.length)return{x:0,y:0};if(1===e.length||0>=n)return{...e[0]};let o=0;const r=Math.max(0,Math.min(1,t))*n;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(o+a>=r){const e=(r-o)/a;return{x:n.x+(i.x-n.x)*e,y:n.y+(i.y-n.y)*e}}o+=a}}return{...e[e.length-1]}}function kR(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function SR(e,t,n){const o=Math.hypot(e,t);if(n>=o||0>=o)return[e,t];const r=n/o;return[e*r,t*r]}function AR(e,t,n){const o=xR({...e,x:t[0].x,y:t[0].y},t),r=o?.tangent??{x:t[1].x-t[0].x,y:t[1].y-t[0].y},i=Math.hypot(r.x,r.y)||1,a=r.x/i,s=r.y/i,c=kR(e),l=function(e,t){let n=0;for(let t=0;e.length>t;t+=1)n=31*n+e.charCodeAt(t)>>>0;return(n%1e3/1e3-.5)*t*1.4}(e.id,c);return{id:e.id,x:t[0].x+-s*l,y:t[0].y+a*l,vx:a*n,vy:s*n,mass:e.mass,shape:e.shape,datum:{...e.datum&&"object"==typeof e.datum?e.datum:{},routeProgress:0}}}var CR=uR(function(e,t){const{chartId:n,colorBy:o,coordinateMode:r="auto",data:i,edges:a,emptyContent:s,flowSpeed:c=90,frameProps:l,links:u,loading:d,loadingContent:h,maxParticles:p=180,nodeIdAccessor:m="id",nodeXAccessor:f="x",nodeYAccessor:y="y",nodes:g,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:R=!1,showStaticFlow:_=!0,sourceAccessor:T="source",targetAccessor:L="target",throughputAccessor:N="value"}=e,$=SI(e,[760,420]),{chartSize:B,className:D,title:j,chartMode:E,margin:F,enableHover:O,description:z,summary:H,accessibleTable:W}=$,G=pR(null),q=hR(()=>g??[],[g]),Y=hR(()=>u??a??i??[],[i,a,u]),V=hR(()=>iI({nodes:q,links:Y,nodeIdAccessor:m,nodeXAccessor:f,nodeYAccessor:y,sourceAccessor:T,targetAccessor:L,throughputAccessor:N,pathAccessor:w,coordinateMode:r,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:c,pathConstraint:k,reducedMotion:A,seed:P,size:B}),[Y,q,B,r,c,p,m,f,y,v,x,w,k,A,P,T,L,N]);gI(t,{frameRef:G,spawnDatum:dR((e,t)=>{const n=iI({nodes:q,links:[e],nodeIdAccessor:m,nodeXAccessor:f,nodeYAccessor:y,sourceAccessor:T,targetAccessor:L,throughputAccessor:N,pathAccessor:w,coordinateMode:r,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:c,pathConstraint:k,reducedMotion:A,seed:P+t+1,size:B}),o={id:(e.id??"physical-flow-push-"+t)+"",x:$P(B).plot.x,y:$P(B).plot.y,mass:1,shape:{type:"circle",radius:v},datum:e},i=n.initialSpawns.length?n.initialSpawns:[o];return{datumId:(e.id??i[0].id)+"",spawns:i}},[q,B,r,c,p,m,f,y,v,x,w,k,A,P,T,L,N]),seedRows:Y,seedSpawns:V.initialSpawns});const X=o??"source",U=hR(()=>DP(X,"#2563eb"),[X]),K=hR(()=>function(e,t,n){return{...e,observation:{...e.observation,chartId:t??e.observation?.chartId??"physical-flow",chartType:"PhysicalFlowChart",onObservation:n??e.observation?.onObservation}}}(V.config,n,b),[n,V.config,b]),Q=pR(l?.onTick);Q.current=l?.onTick;const Z=dR((e,t)=>{A||"none"===k||function(e,t){const n=e.readBodies(),o=[],r=[];for(const i of n){const n=vR(i.datum);if(2>n.length)continue;const a=xR(i,n);if(!a)continue;const s=i.datum,c=Number(s?.flowSpeed),l=Number.isFinite(c)&&c>0?c:t;if(a.progress>=.985||a.distance>Math.max(90,14*kR(i))){o.push(i.id),r.push(AR(i,n,l));continue}const u=wR(n,Math.min(1,a.progress+Math.max(.035,Math.min(.12,l/a.totalLength*.16))),a.totalLength),d=a.tangent,h=(d.x*l-i.vx)*i.mass*.16+(u.x-i.x)*i.mass*.045+(a.point.x-i.x)*i.mass*.08,p=(d.y*l-i.vy)*i.mass*.16+(u.y-i.y)*i.mass*.045+(a.point.y-i.y)*i.mass*.08,[m,f]=SR(h,p,i.mass*l*.35);e.applyImpulse(i.id,m,f)}o.length&&e.remove(o),r.length&&e.pushMany(r)}(t,c),Q.current?.(e,t)},[c,k,A]),J=AI({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:n,showSensors:o,showStaticFlow:r}=t;if(e&&(r||o))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 fR("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:[r?e.links.map(e=>{const t=3+e.throughput/a*16,n=e.path[Math.floor(e.path.length/2)];return fR("g",{children:[mR("path",{d:gR(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),mR("path",{d:gR(e.path),fill:"none",stroke:"var(--semiotic-accent, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),n?mR("text",{x:n.x,y:n.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:yR(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>fR("g",{children:[o&&s.has(e.sensorId)?mR("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,r?mR("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,n?mR("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:R,showStaticFlow:_}),te=(ne=V.metadata)?ne.links.map(e=>{const t=e.path[Math.floor(e.path.length/2)]??e.path[0],n=`${e.sourceLabel} to ${e.targetLabel}: ${yR(e.throughput)} throughput, ${e.packetCount} packets`;return{id:e.id,label:n,description:n,datum:e,x:t?.x??0,y:t?.y??0,shape:"path",pathData:gR(e.path),group:"flow"}}):[];var ne;const oe=PI(e.tooltip,l),re=II(e,l,te,{chartMode:E,className:D,title:j,description:z,summary:H,accessibleTable:W,enableHover:O,margin:F});return CI("PhysicalFlowChart",B,mR(NP,{...l,...oe,...re,ref:G,config:K,continuous:!A&&"none"!==k,foregroundGraphics:MI(ee,l?.foregroundGraphics),initialSpawns:V.initialSpawns,onTick:Z,paused:S||A,responsiveHeight:C,responsiveWidth:M,simulationExecution:"none"===k?l?.simulationExecution:"sync",size:B,bodyStyle:U,workerBodyThreshold:l?.workerBodyThreshold??1/0}))});CR.displayName="PhysicalFlowChart";import{forwardRef as MR,useCallback as PR,useEffect as IR,useMemo as RR,useRef as _R,useState as TR}from"react";import{Fragment as LR,jsx as NR,jsxs as $R}from"react/jsx-runtime";var BR={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 DR(e,t,n){return Math.max(t,Math.min(n,e))}function jR(e){return 6.2*e.length}function ER(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function FR(e,t,n="auto"){const o=Math.max(1,Math.floor(t/6.2)),r="compact"===n?ER(e,o):"full"===n?e:jR(e)>t?ER(e,o):e;return{text:r,textLength:jR(r)>t?Math.max(4,t):void 0}}function OR(e){return e.flatMap(e=>{if(!1===e.semanticItem)return[];const t=e.semanticItem??{},n={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[{...n,...t,id:t.id??n.id}]})}import{jsx as zR}from"react/jsx-runtime";var HR=MR(function(e,t){const{ballRadius:n=6,chromeOptions:o,colorBy:r,data:i,emptyContent:a,frameProps:s={},groupAnchorAlong:c,groupBy:l,groupCompletion:d,groupLabelAccessor:h,gravityX:p,gravityY:m,idAccessor:f,initialSpawnPacing:y,liveCapacity:g=!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:R=1,settle:_,springDamping:T,springStiffness:L,stageAccessor:N="stage",stages:$,workAccessor:B}=e,D=SI(e,[900,420]),{chartSize:j,showProjection:E,showChrome:F,className:O,title:z,chartMode:H,margin:W,enableHover:G,description:q,summary:Y,accessibleTable:V}=D,X=_R(null),U=RR(()=>u(i??[]),[i]),K=RR(()=>({data:U,stages:$,size:j,idAccessor:f,stageAccessor:N,groupBy:l,groupLabelAccessor:h,workAccessor:B,radiusAccessor:C,ballRadius:n,seed:R,route:I,groupCompletion:d,groupAnchorAlong:c,springStiffness:L,springDamping:T,gravityX:p,gravityY:m,settle:_}),[n,j,p,m,c,l,d,h,f,C,I,U,R,_,T,L,N,$,B]),Q=RR(()=>dI(K),[K]),Z=Q.metadata;gI(t,{frameRef:X,spawnDatum:PR((e,t)=>{const o=dI({...K,data:[e],seed:R+t+1,settle:!0}).initialSpawns[0]??{id:(e.id??"process-flow-push-"+t)+"",x:$P(j).plot.x,y:$P(j).plot.y,mass:1,shape:{type:"circle",radius:n},datum:e};return{datumId:(e.id??o.id)+"",spawns:[o]}},[n,K,j,R]),seedRows:U,seedSpawns:Q.initialSpawns});const J=RR(()=>DP(r),[r]),ee=RR(()=>{if(!g)return s.controllers;const e=[...$.filter(e=>e.capacity&&e.capacity.unitsPerSecond>0).map(e=>{const t=e.capacity.unitsPerSecond;return jM({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,g,$,B]),[te,ne]=TR({}),oe=_R(ee);oe.current=ee;const re=_R(s.onTick);re.current=s.onTick;const ie=!1!==F||null!=b;IR(()=>{if(!b)return;const e=Object.values(te);e.length&&b(e)},[te,b]);const ae=PR((e,t)=>{if(re.current?.(e,t),!ie)return;const n=oe.current;if(!n?.length)return;const o={};for(const e of n){const t=e.getSnapshot?.();t&&"string"==typeof t.regionId&&(o[t.regionId]=t)}ne(e=>function(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){const n=e[o],r=t[o];if(!r)return!1;if(n.queueDepth!==r.queueDepth||n.blockedDepth!==r.blockedDepth||n.processedCount!==r.processedCount||n.unitsPerSecond!==r.unitsPerSecond||n.regionId!==r.regionId||n.metricRevision!==r.metricRevision)return!1}return!0}(e,o)?e:o)},[ie]),se=RR(()=>{const e=J,t=s.bodyStyle;return w||t?(n,o)=>{const r="function"==typeof t?t(n,o):t;return{..."function"==typeof e?e(n):e,...r,mark:r?.mark??n.datum?.__physicsMark??n.datum?.mark??w}}:e},[w,J,s.bodyStyle]),ce=AI({data:i,emptyContent:a,loading:k,loadingContent:S,size:j});if(ce)return ce;if(!$?.length)return CI("ProcessFlowChart",j,zR("div",{role:"status",style:{width:j[0],height:j[1],display:"grid",placeItems:"center",color:"var(--semiotic-text-secondary, #64748b)"},children:"ProcessFlowChart requires a non-empty stages array."}));const le=function(e,t,n={},o){if(!1===t||!e)return;const{volume:r,stages:i,groups:a,groupCompletion:s}=e,c=new Map(r.stages.map(e=>[e.id,e])),l=new Map(s.map(e=>[e.id,e]));return({size:e})=>{const t=Number(e[0])||r.width,s=Number(e[1])||r.height,u=i.map(e=>{const t=c.get(e.id),o=n["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:o?.queueDepth,processed:o?.processedCount}}),d=a.map(e=>{const t=l.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:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:p,bottomY:m,midY:f,stages:y,groups:g=[]}=e,b=m-p;return $R("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[NR("defs",{children:$R("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[NR("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),NR("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),NR("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),NR("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}),n?NR("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,y.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=BR[n],c=Math.max(12,e.width-8),l=DR(c-8,22,88),d=FR(e.label,Math.max(8,l-10),a),h="none"!==a&&c-8>=22,g=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=FR(g,Math.max(16,c-10),"auto"),x=r&&!1!==e.showBadge&&c>=32,w=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",k=FR(w,Math.max(16,c-8),"auto"),S=Math.max(30,p-15),A=S-13;return $R("g",{"data-stage":e.id,"data-role":n,children:[NR("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:c,height:b-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),y.length-1>t?NR("polygon",{points:`${e.x1-2},${f-7} ${e.x1+8},${f} ${e.x1-2},${f+7}`,fill:i.accent,opacity:.85}):null,h?$R(LR,{children:[NR("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:A,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),$R("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:[NR("title",{children:e.label}),d.text]})]}):null,x?$R("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:[NR("title",{children:g}),v.text]}):null,o&&null!=e.count?$R("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:[NR("title",{children:w}),k.text]}):null]},e.id)}),i?g.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=DR(Math.max(54,jR(e.label)+18,jR(c)+16),54,104),u=FR(e.label,l-12,"auto"),d=FR(c,l-12,"auto");return $R("g",{"data-group":e.id,children:[NR("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),$R("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:[NR("title",{children:e.label}),u.text]}),$R("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:[NR("title",{children:c}),d.text]})]},e.id)}):null]})}({width:t,height:s,left:r.left,right:r.right,topY:r.topY,bottomY:r.bottomY,midY:r.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...o})}}(Z,F,te,o),ue=function(e,t,n){if(!1===n||!t||0===e.length)return;const o=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:n})=>{const r=[Number(n[0])||t.volume.width,Number(n[1])||t.volume.height],i=$P(r),a=Math.max(1,...e.map(e=>e.value)),s=Math.min(48,.18*i.plot.height),c=i.plot.y+6;return zR("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,n)=>{const r=e[n];if(!r)return null;const i=o.get(t.id);if(!i)return null;const l=Math.max(2,r.value/a*s),u=Math.max(8,.35*i.width);return zR("rect",{x:i.x-u/2,y:c,width:u,height:l,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=[...EP(Q.projectionRows,j,"stage"),...OR(Z?.groups??[])],he=PI(e.tooltip,s),pe=II(e,s,de,{chartMode:H,className:O,title:z,description:q,summary:Y,accessibleTable:V,enableHover:G,margin:W}),me=[...Z?.regionEffects??[],...s.regionEffects??[]];return CI("ProcessFlowChart",j,zR(NP,{...s,...he,...pe,ref:X,controllers:ee,regionEffects:me,selection:v??s.selection,backgroundGraphics:MI(le,s.backgroundGraphics),foregroundGraphics:MI(ue,s.foregroundGraphics),initialSpawns:Q.initialSpawns,initialSpawnPacing:y??Q.initialSpawnPacing,onTick:ae,paused:A,responsiveHeight:M,responsiveWidth:P,size:j,bodyStyle:se,config:{...Q.config,...null!=x?{bodyLimit:x,eviction:"oldest"}:{},...s.config}}))});HR.displayName="ProcessFlowChart";import{forwardRef as WR,useCallback as GR,useEffect as qR,useImperativeHandle as YR,useMemo as VR,useRef as XR,useState as UR}from"react";var KR="gauntlet-core",QR="gauntlet-positive",ZR="gauntlet-negative";function JR(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 e_(e,t,n,o){return n?"function"==typeof n?n(e,t):e[n]??o:o}function t_(e){return e?.label??e?.id??"property"}function n_(e){return`gauntlet:${e}:core`}function o_(e,t){return`gauntlet:${e}:positive:${t}`}function r_(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}function i_(e,t,n,o){const r=Math.max(2,n+2),i=80+r,a=o.floorY-r;return{x:Math.max(32+r,Math.min(o.width-30-4-r,e)),y:Math.max(i,Math.min(a,t))}}function a_(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 s_(e,t,n,o){const r=a_(n),i=o?.(e,t,n)??{};return{...r,...i,startY:i.startY??i.routeY??r.startY,socketY:i.socketY??i.routeY??r.socketY,graveyardY:i.graveyardY??r.graveyardY}}function c_(e,t){const n=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?o/(n.length-1):.5)*Math.PI*.64,index:o,radius:48+o%2*6}}function l_(e,t,n){const o=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,i=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*i-1.2*e.delay-5*r))}function u_(e,t,n,o,r){const i=e_(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",a=o.map(e=>e.id),s=[...e_(e,t,n.positiveAccessor,a)],c=[...e_(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:i,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...e_(e,t,n.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(e_(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:e_(e,t,n.initialViability,100)}}function d_(e,t,n,o,r,i,a){const s=o.startX,c=o.startY+(o.startY===n.routeY?38*t:0),l=a?.(e,t,n,o)??{},u={__gauntlet:!0,kind:KR,projectId:e.id,sourceDatum:e.datum},d=[{...l,id:n_(e.id),x:l.x??s,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:u}],h=i_(s,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,n);d[0].x=h.x,d[0].y=h.y;for(const t of e.activePositiveIds){const o=r.get(t);if(!o)continue;const i=c_(e.activePositiveIds,t),a=o.radius??10,s=i_(h.x+Math.cos(i.angle)*i.radius,h.y+Math.sin(i.angle)*i.radius,a,n);d.push({id:o_(e.id,t),x:s.x,y:s.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:QR,projectId:e.id,property:o,sourceDatum:e.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:n_(e.id)},stiffness:.56,damping:.9,restLength:52+i.index%2*4,...o.spring??{}}]})}return e.negativeIds.forEach((t,o)=>{const r=i.get(t);r&&d.push(h_(e,r,o,h.x,h.y,n,l.spawnAt??e.startedAt))}),d}function h_(e,t,n,o,r,i,a){const s=t.radius??7.2,c=i_(o-12+n%4*12,r+54+12*Math.floor(n/4),s,i);return{id:r_(e.id,t.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:a,datum:{__gauntlet:!0,kind:ZR,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:n_(e.id)},stiffness:.62,damping:.92,restLength:52+n%4*3,...t.spring??{}}]}}function p_(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 m_(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 f_(e,t){return m_(e.activePositiveIds,t.popPositive)}function y_(e,t){const n=m_(e.negativeIds,t.popNegative);if(!n.length)return[];const o=new Map;for(const e of n)o.set(e,(o.get(e)??0)+1);const r=[];return e.negativeIds.forEach((e,t)=>{const n=o.get(e)??0;n>0&&(r.push({propertyId:e,index:t}),o.set(e,n-1))}),r}function g_(e,t,n){if(t.when&&!t.when(n))return e;let o={...e};const r=f_(o,t);r.length&&(o={...o,activePositiveIds:o.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...o.poppedPositiveIds,...r]))});const i=y_(o,t);if(i.length){const e=new Set(i.map(e=>e.index));o={...o,negativeIds:o.negativeIds.filter((t,n)=>!e.has(n)),poppedNegativeIds:[...o.poppedNegativeIds,...i.map(e=>e.propertyId)]}}const a=p_(t.addPositive);a.length&&(o={...o,activePositiveIds:Array.from(new Set([...o.activePositiveIds,...a])),missingPositiveIds:o.missingPositiveIds.filter(e=>!a.includes(e))});const s=p_(t.addNegative);if(s.length&&(o={...o,negativeIds:[...o.negativeIds,...s]}),t.delayDelta&&(o={...o,delay:o.delay+t.delayDelta}),t.metricsDelta){const e={...o.metrics};for(const[n,o]of Object.entries(t.metricsDelta))e[n]=Number(e[n]??0)+o;o={...o,metrics:e}}return t.viabilityDelta&&(o={...o,viability:o.viability+t.viabilityDelta}),t.stage&&(o={...o,stage:t.stage}),t.outcome&&(o={...o,outcome:t.outcome}),o}function b_(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function v_(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 x_(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==ZR)}function w_(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}import{jsx as k_,jsxs as S_}from"react/jsx-runtime";function A_(e){const t=e.data;return t?.__gauntlet?S_("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:[k_("strong",{children:t.kind===KR?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:t_(t.property)}),k_("div",{children:t.kind===QR?"Positive property":t.kind===ZR?"Negative property":"Project core"})]}):null}function C_(e,t,n){const o=t.datum;if(!o?.__gauntlet)return;const r="circle"===t.shape.type?t.shape.radius:8;if(e.save(),e.translate(t.x,t.y),o.kind===KR)e.fillStyle=M_(e,n.fill,"#0f766e"),e.strokeStyle=M_(e,n.stroke,"#f8fafc"),e.lineWidth=2.4,e.beginPath(),e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke();else{const t=o.property;e.fillStyle=M_(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=M_(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),o.kind===ZR?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=M_(e,"var(--semiotic-background, #07111f)","#07111f"),e.font=`900 ${o.kind===ZR?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 M_(e,t,n){if("string"!=typeof t)return n;if("function"!=typeof getComputedStyle||!e.canvas)return t||n;const o=t.startsWith("var(")?t.match(/var\((--[^,\s)]+)/)?.[1]:t.startsWith("--")?t:null;return o?getComputedStyle(e.canvas).getPropertyValue(o).trim()||n:t||n}function P_({layout:e,states:t}){return S_("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[k_("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}),k_("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}),k_("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=>S_("g",{children:[k_("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}),k_("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)),S_("g",{children:[k_("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}),k_("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),S_("g",{children:[k_("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}),k_("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-negative, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),k_("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 I_(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===KR?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${t_(t.property)} ${t.kind===QR?"positive":"negative"} property`,group:t.kind===QR?"positive property":"negative property",description:`${t_(t.property)} attached to ${t.projectId}.`})}function R_({states:e,layout:t}){const n=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(!n.length)return null;const o=Math.max(1,...n.map(e=>e.value)),r=Math.max(40,(t.width-80)/n.length);return S_("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:[k_("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),n.map((e,t)=>{const n=40+t*r,i=Math.max(2,e.value/o*28),a=/kill|crash|block|grave/i.test(e.outcome);return S_("g",{children:[k_("rect",{x:n+.18*r,y:28-i+22,width:Math.max(10,.45*r),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}),k_("text",{x:n+.4*r,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}import{jsx as __}from"react/jsx-runtime";import{createElement as T_}from"react";var L_=[],N_=WR(function(e,t){const{bodyGroups:n,coreBody:o,coreForceMode:r="route",crashDetection:i=!0,crashOffset:a=30,data:s,emptyContent:c,events:l,frameProps:d={},gates:h,initialSpawnPacing:p,loading:m,loadingContent:f,negativeProperties:y,onCapacityChange:g,onClick:b,onStateChange:v,outcome:x,paused:w,positiveProperties:k=L_,projectPlacement:S,responsiveHeight:A,responsiveWidth:C,showTethers:M=!0,terminalBehavior:P="outcome",viability:I}=e,R=XR(null),_=VR(()=>({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]),T=SI(e,[900,520]),{chartSize:L,showProjection:N,showChrome:$,className:B,title:D,chartMode:j,margin:E,enableHover:F,description:O,summary:z,accessibleTable:H}=T,W=AI({data:s,emptyContent:c,loading:m,loadingContent:f,size:L}),G=VR(()=>u(s??[]),[s]),q=VR(()=>G.map((e,t)=>e_(e,t,_.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[G,_.idAccessor]),Y=VR(()=>new Map(k.map(e=>[e.id,e])),[k]),V=VR(()=>new Map(y.map(e=>[e.id,e])),[y]),X=VR(()=>function(e,t,n){const[o,r]=e,i=Math.round(.48*r),a=r-36,s=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,s.length),l=.22*o,u=c>1?(.78*o-l)/(c-1):0,d=Math.max(Math.round(.14*o),110);return{crashY:a-n,floorY:a,gates:s.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*u),width:e.width??Math.max(54,Math.round(.07*o))})),graveyardX:Math.round(.84*o),graveyardY:a-4,height:r,routeY:i,socketX:Math.round(.92*o),startX:d,width:o}}(L,h,a),[L,a,h]),U=VR(()=>new Map(X.gates.map(e=>[e.id,e])),[X.gates]),K=VR(()=>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:KR}: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]=UR(()=>G.map((e,t)=>{const n=u_(e,t,_,k,V);return{...n,viability:I?.(n,{negativeProperties:V,positiveProperties:Y})??l_(n,Y,V)}})),J=XR(Q),ee=XR(0),te=XR(new Map),ne=XR([]),oe=XR(g);oe.current=g;const re=VR(()=>function(e){const{dataKey:t,gates:n,statesRef:o,processedGateVisitsRef:r}=e;return n.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[jM({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:KR},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 n=t.datum,r=n?.sourceDatum,i=e.capacity?.unitAccessor,a=o.current.find(e=>e.id===n?.projectId);let s;"function"==typeof i?s=a?i(a):void 0:i&&(s=r?.[i]);const c=Number(s??r?.reviewWork??r?.work??a?.metrics.reviewWork??r?.points);return Number.isFinite(c)&&c>0?c:1},onProcessed:t=>{const n=t.datum;if(!n?.projectId)return;const o=`${n.projectId}:${e.id}`;r.current.set(o,(r.current.get(o)??0)+1)}})]:[])}({dataKey:q,gates:X.gates,statesRef:J,processedGateVisitsRef:te}),[q,X.gates]),ie=VR(()=>[...re,...d.controllers??[]],[re,d.controllers]),ae=XR(G);ae.current=G;const se=XR(v);se.current=v;const ce=XR({negativeById:V,positiveById:Y,positiveProperties:k,stateAccessors:_,viability:I});ce.current={negativeById:V,positiveById:Y,positiveProperties:k,stateAccessors:_,viability:I};const le=GR((e,t,n=0)=>{const o=ce.current,r=u_(e,t,o.stateAccessors,o.positiveProperties,o.negativeById);return o.stateAccessors.startTimeAccessor||(r.startedAt=Math.max(0,n)),{...r,viability:o.viability?.(r,{negativeProperties:o.negativeById,positiveProperties:o.positiveById})??l_(r,o.positiveById,o.negativeById)}},[]);qR(()=>{te.current.clear(),ne.current=[];const e=ae.current.map((e,t)=>le(e,t));J.current=e,Z(e)},[le,q]),qR(()=>{J.current=Q,se.current?.(Q)},[Q]);const ue=GR(e=>[...("function"==typeof l?l(e,X):l)??[]].sort((e,t)=>e.time-t.time),[l,X]),de=GR((e,t,n)=>{if(!t.gateId||!U.get(t.gateId)?.capacity)return!0;const o=Number(t.gateVisit),r=Number.isFinite(o)&&o>0?Math.floor(o):n.filter(e=>e.gateId===t.gateId).findIndex(e=>e.id===t.id)+1;return r>0&&(te.current.get(`${e.id}:${t.gateId}`)??0)>=r},[U]),he=GR(()=>{if(!re.length)return;const e=re.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,n;(t=ne.current).length===(n=e).length&&t.every((e,t)=>{const o=n[t];return!!o&&e.regionId===o.regionId&&e.queueDepth===o.queueDepth&&e.blockedDepth===o.blockedDepth&&e.processedCount===o.processedCount&&e.metricRevision===o.metricRevision})||(ne.current=e,oe.current?.(e))},[re]),pe=VR(()=>Q.flatMap((e,t)=>{const n=s_(e,t,X,S);return d_(e,t,X,n,Y,V,o)}),[o,X,V,Y,S,Q]),me=GR((e,t)=>{let n=!1;const o=J.current.map(o=>{if(o.id!==e)return o;const r=t(o);return n=n||r!==o,r});n&&(J.current=o,Z(o))},[]);YR(t,()=>function(e){const{statesRef:t,setStates:n,elapsedRef:o,frameRef:r,layout:i,projectPlacement:a,positiveById:s,negativeById:c,coreBody:l,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,o.current),h=s_(d,t.current.length,i,a),p=d_(d,t.current.length,i,h,s,c,l),m=[...t.current,d];t.current=m,n(m),r.current?.pushMany(p),r.current?.step(0)},pushMany:e=>{const d=[...t.current],h=[],p=o.current;e.forEach(e=>{const t=u(e,d.length,p),n=s_(t,d.length,i,a);h.push(...d_(t,d.length,i,n,s,c,l)),d.push(t)}),t.current=d,n(d),h.length&&r.current?.pushMany(h),r.current?.step(0)},remove:e=>{const o=Array.isArray(e)?e:[e],i=[],a=[];for(const e of o){const n=t.current.find(t=>t.id===e);n&&(i.push(n.datum),a.push(n_(n.id),...n.activePositiveIds.map(e=>o_(n.id,e))),n.negativeIds.forEach((e,t)=>{a.push(r_(n.id,e,t))}))}return t.current=t.current.filter(e=>!o.includes(e.id)),n(t.current),r.current?.remove(a),i},update:(e,d)=>{const h=Array.isArray(e)?e:[e],p=[];for(const e of h){const n=t.current.find(t=>t.id===e);if(!n)continue;const h=t.current.findIndex(t=>t.id===e);p.push(n.datum);const m=d(n.datum),f=u(m,0>h?t.current.length:h,n.startedAt??o.current),y=s_(f,0>h?t.current.length:h,i,a);r.current?.remove([n_(n.id),...n.activePositiveIds.map(e=>o_(n.id,e)),...n.negativeIds.map((e,t)=>r_(n.id,e,t))]),r.current?.pushMany(d_(f,0>h?t.current.length:h,i,y,s,c,l)),t.current=t.current.map(t=>t.id===e?f:t)}return n(t.current),p},clear:()=>{t.current=[],n([]),r.current?.clear()},getData:()=>t.current.map(e=>e.datum),getScales:()=>null,getCustomLayout:()=>r.current?.snapshot()??null,popBodies:(e,t)=>r.current?.popBodies(e,t)??[]}}({statesRef:J,setStates:Z,elapsedRef:ee,frameRef:R,layout:X,projectPlacement:S,positiveById:Y,negativeById:V,coreBody:o,createState:le}),[o,le,X,V,Y,S]);const fe=GR((e,t,n)=>{!function(e){const{project:t,effect:n,controls:o,layout:r,positiveById:i,negativeById:a,coreBody:s,popBodies:c}=e,l=o.readBodies().find(e=>e.id===n_(t.id)),u=o.readBodies(),d=l?.x??r.startX,h=l?.y??r.routeY,p=function(e,t){let n=-1;for(const o of t)x_(o,e.id)&&(n=Math.max(n,w_(o)));return Math.max(e.negativeIds.length,n+1)}(t,u),m=p_(n.addNegative).flatMap((e,n)=>{const o=a.get(e);return o?[h_(t,o,p+n,d,h,r)]:[]}),f=p_(n.addPositive).flatMap(e=>{if(!i.get(e)||t.activePositiveIds.includes(e))return[];const n={...a_(r),routeY:h,socketY:h,startX:d,startY:h};return d_({...t,activePositiveIds:[e],negativeIds:[]},0,r,n,i,a,s).filter(e=>e.id.includes(":positive:"))});(m.length||f.length)&&o.pushMany([...m,...f]);const y=f_(t,n);for(const e of y){const n=i.get(e);c([o_(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3})}const g=y_(t,n),b=function(e,t,n){const o=t.filter(t=>x_(t,e.id)).sort((e,t)=>w_(e)-w_(t)||e.id.localeCompare(t.id)),r=new Set;return n.map(t=>{const n=o.find(e=>!r.has(e.id)&&e.datum.property?.id===t.propertyId);return n?(r.add(n.id),n.id):r_(e.id,t.propertyId,t.index)})}(t,u,g);g.forEach((e,t)=>{const n=a.get(e.propertyId);c([b[t]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3})})}({project:e,effect:t,controls:n,layout:X,positiveById:Y,negativeById:V,coreBody:o,popBodies:(e,t)=>R.current?.popBodies(e,t)})},[o,X,V,Y]),ye=GR(({body:e,bodies:t})=>function(e){const{body:t,bodies:n,layout:o,states:r,projectPlacement:i,positiveById:a,negativeById:s,projectEvents:c,gateById:l,coreForceMode:u,terminalBehavior:d,elapsed:h}=e,p=t.datum;if(!p?.__gauntlet)return null;const m=r.findIndex(e=>e.id===p.projectId),f=0>m?void 0:r[m];if(!f)return null;const y=s_(f,m,o,i),g=n.find(e=>e.id===n_(f.id)),b=f.negativeIds.reduce((e,t)=>e+(s.get(t)?.load??1),0),v=f.killed?0:58;if(p.kind!==KR){if(!g)return null;let e;const r=p.property;if(r?.target){const i=n.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=r.target({body:t,bodies:n,core:g,index:a,layout:o,placement:y,project:f})??{x:g.x,y:g.y}}else if(p.kind===QR&&p.property){const t=c_(f.activePositiveIds,p.property.id);e={x:g.x+Math.cos(t.angle)*t.radius,y:g.y+Math.sin(t.angle)*t.radius-2}}else{const o=n.filter(e=>e.datum?.kind===ZR&&e.datum.projectId===f.id).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),r=Math.max(0,o.findIndex(e=>e.id===t.id)),i=Math.floor(r/4);e={x:g.x+18*(r%4-(Math.min(4,o.length-4*i)-1)/2),y:g.y+54+13*i}}const i="circle"===t.shape.type?t.shape.radius:8;e=i_(e.x,e.y,i,o);const a=i_(t.x,t.y,i,o);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!==QR||f.killed?0:3.2*(r?.buoyancy??r?.value??1),c=p.kind===ZR?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return{x:28*(e.x-t.x)-3*(t.vx-g.vx)+c.x+.01*v,y:28*(e.y-t.y)-3*(t.vy-g.vy)+c.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=c(f),w=function(e,t,n,o,r,i,a){if(t.killed)return{x:t.metrics.lastX??o.graveyardX,y:o.graveyardY};const s=r[r.length-1];if(!s)return{x:o.socketX,y:o.routeY};const c=r.find(n=>e>=n.time&&!t.eventsApplied.includes(n.id)&&!(!n.gateId||!i.get(n.gateId)?.capacity)),l=c?Math.min(e,c.time):e,u="built"===t.outcome||"built_diminished"===t.outcome;if(l>s.time+.85){if("hold-last"===a){const e=s.gateId?i.get(s.gateId):void 0;return{x:s.routeX??e?.x??o.socketX,y:s.routeY??o.routeY}}return u?{x:o.socketX,y:o.socketY}:{x:o.graveyardX,y:o.graveyardY-14}}const d=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),h=[{time:0,x:o.startX,y:o.startY},...r.map(e=>{const t=e.gateId?i.get(e.gateId):void 0;return{time:e.time,x:e.routeX??t?.x??o.startX,y:e.routeY??o.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>=l){m=h[e];break}p=h[e]}const f=Math.max(0,Math.min(1,(l-p.time)/Math.max(.1,m.time-p.time))),y=f*f*(3-2*f);return{x:p.x+(m.x-p.x)*y,y:p.y+(m.y-p.y)*y+7*Math.sin(2.6*l)}}(Math.max(0,h-(f.startedAt??0)),f,0,y,x,l,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*(y.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:r,terminalBehavior:P,elapsed:ee.current}),[r,U,X,V,Y,ue,S,P]),ge=GR((e,t)=>{!function(e,t,n){const{frameProps:o,elapsedRef:r,statesRef:i,crashDetection:a,layout:s,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:p,positiveById:m,negativeById:f,outcome:y,reportCapacity:g}=n;o.onTick?.(e,t),r.current=e.elapsedSeconds??t.snapshot().elapsedSeconds,g();for(const e of i.current){const n=t.readBodies().find(t=>t.id===n_(e.id));if(!n)continue;if(a&&!e.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=s.crashY){t.readBodies().forEach(n=>{const o=n.datum;o?.__gauntlet&&o.projectId===e.id&&t.applyImpulse(n.id,-n.vx*n.mass,0)}),h(e.id,e=>{const t={appliedAt:Math.max(0,r.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,r.current-(e.startedAt??0))};return{...e,crashX:n.x,eventHistory:[...e.eventHistory??[],t],killed:!0,lastEvent:t,metrics:{...e.metrics,lastX:n.x},outcome:"bad_design_crash",stage:"Crash Line",viability:Math.min(0,e.viability)}});continue}if(e.killed)continue;const o=Math.max(0,r.current-(e.startedAt??0)),i=c(e),g=i.filter(t=>o>=t.time&&!e.eventsApplied.includes(t.id)&&u(e,t,i));let b=e;for(const n of g){const r=n.gateId?l.get(n.gateId):void 0,i=n.effects??[];for(const e of i){const o={event:n,gate:r,negativeProperties:f,positiveProperties:m,project:b};e.when&&!e.when(o)||(d(b,e,t),b=g_(b,e,o))}const a={...b_(n,i),appliedAt:o};b=v_(b,a),h(e.id,e=>{let t=v_(e,a);if(t===e)return e;for(const e of i)t=g_(t,e,{event:n,gate:r,negativeProperties:f,positiveProperties:m,project:t});const o=p?.(t,{negativeProperties:f,positiveProperties:m})??l_(t,m,f);return t={...t,viability:o},n.final&&(t={...t,outcome:n.outcome??y?.(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=GR((e,t)=>{const n="function"==typeof d.bodyStyle?d.bodyStyle(e,t):d.bodyStyle,o=e.datum;return o?.__gauntlet?{fill:o.kind===KR?"var(--semiotic-accent, #0f766e)":o.property?.color??"var(--semiotic-accent, #38bdf8)",stroke:o.kind===KR?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[d]),ve=VR(()=>"function"==typeof n?n(Q,X):n??[],[n,X,Q]),xe=VR(()=>OR(ve),[ve]),we=VR(()=>N?function(e,t){if(!e.length)return[];const n=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const o=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:o,description:o,datum:e,x:40+(t+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(Q,X):[],[X,N,Q]),ke=VR(()=>[...we,...xe],[xe,we]),Se=GR((e,t)=>{d.onBodyPointerDown?.(e,t)},[d]),Ae=GR((e,t)=>{b&&(e&&"object"==typeof e&&e.__gauntlet?b(e.sourceDatum,{x:t.x,y:t.y}):e&&b(e,{x:t.x,y:t.y}))},[b]),Ce=GR((e,t)=>{d.beforePaint?.(e,t),M&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===KR).map(e=>[e.datum.projectId,e]));e.save(),e.lineWidth=1.1,e.setLineDash([3,4]);for(const o of t){const t=o.datum;if(!t?.__gauntlet||t.kind===KR)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===ZR?.24:.36,e.strokeStyle=t.kind===ZR?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(o.x,o.y),e.stroke())}e.restore()}(e,t)},[d,M]),Me=VR(()=>({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:[...JR(X),...d.config?.colliders??[]]}),[d.config?.colliders,d.config?.kernel,X]),Pe=VR(()=>[...K,...d.regionEffects??[]],[d.regionEffects,K]);if(W)return W;const Ie=PI(e.tooltip,d),Re=II(e,d,ke,{chartMode:j,className:B,title:D,description:O,summary:z,accessibleTable:H,enableHover:F,margin:E}),_e=N?__(R_,{states:Q,layout:X}):void 0,Te=MI($?__(P_,{layout:X,states:Q}):void 0,d.backgroundGraphics),Le=MI(_e,d.foregroundGraphics),Ne=d.renderBody??C_,$e=Ie.tooltipContent??A_;return CI("GauntletChart",L,T_(NP,{...d,...Ie,...Re,key:`${L[0]}x${L[1]}:${q}`,ref:R,accessibleTable:e.accessibleTable??d.accessibleTable,backgroundGraphics:Te,bodyForces:ye,bodySemanticItems:d.bodySemanticItems??I_,bodyStyle:be,beforePaint:Ce,onClick:b?Ae:Re.onClick,config:Me,controllers:ie,enableHover:Ie.enableHover??!0,foregroundGraphics:Le,hoverRadius:e.hoverRadius??d.hoverRadius??18,initialSpawns:pe,initialSpawnPacing:p,onBodyPointerDown:Se,onTick:ge,paused:w,regionEffects:Pe,renderBody:Ne,responsiveHeight:A,responsiveWidth:C,size:L,tooltipContent:$e}))});N_.displayName="GauntletChart";import{forwardRef as $_,useCallback as B_,useEffect as D_,useImperativeHandle as j_,useMemo as E_,useRef as F_,useState as O_}from"react";function z_(e,t={}){if("function"==typeof e)return e;const n=t.locale??"en-US";if("currency"===e){const e=t.precision??2,o=new Intl.NumberFormat(n,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>o.format(e)}if("percent"===e){const e=new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(n,{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?"-":"",n=Math.abs(e);if(1e3>n)return`${t}${Math.round(n)}ms`;const o=n/1e3;if(60>o)return`${t}${r=o,Math.round(100*r)/100+""}s`;var r;const i=o/60;if(60>i){const e=Math.floor(i),n=Math.round(o-60*e);return 0===n?`${t}${e}m`:`${t}${e}m ${n}s`}const a=i/60;if(24>a){const e=Math.floor(a),n=Math.round(i-60*e);return 0===n?`${t}${e}h`:`${t}${e}h ${n}m`}const s=Math.floor(a/24),c=Math.round(a-24*s);return 0===c?`${t}${s}d`:`${t}${s}d ${c}h`}(e);const o=new Intl.NumberFormat(n,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>o.format(e)}function H_(e,t,n){return`${t??""}${e}${n??""}`}import{useMemo as W_}from"react";import{Fragment as G_,jsx as q_,jsxs as Y_}from"react/jsx-runtime";var V_={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 X_(e,t,n){return void 0===e?n:"function"==typeof e?e(t):e}function U_(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function K_(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var Q_=$_((e,t)=>{const{value:n,label:o,caption:r,format:i,locale:a,currency:s,precision:c,prefix:l,suffix:u,unit:d,comparison:h,target:p,delta:m,deltaFormat:f,showDeltaPercent:y,direction:g,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:R,borderRadius:_,className:T,style:L,animate:N,stalenessThreshold:$,staleLabel:B,headerSlot:D,valueSlot:j,deltaSlot:E,trendSlot:F,chartSlot:O,chartSize:z,footerSlot:H,onClick:W,onObservation:G,chartId:q,description:Y,summary:V,loading:X,loadingContent:U,emptyContent:K}=e,Q=V_[w]??V_.tile,Z=k??Q.align,J=S??Q.width,ee=A??Q.height,te=vc(),ne=Ua(),[oe,re]=O_([]),[ie,ae]=O_(null),[se,ce]=O_(null),[le,ue]=O_(null),de=F_([]),he=F_(null),pe=F_(n);D_(()=>{pe.current=n},[n]);const me=F_(x);D_(()=>{me.current=x},[x]);const fe=B_(e=>{const t="number"==typeof e?{value:e,time:Date.now()}:{time:Date.now(),...e},n="number"==typeof t.time?t.time:t.time instanceof Date?t.time.getTime():Date.now();return{...t,time:n}},[]),ye=B_(e=>{if(0===e.length)return;const t=me.current,n=e.map(fe);let o=de.current.concat(n);o.length>t&&(o=o.slice(o.length-t)),de.current=o;const r=n[n.length-1];he.current=r.value,re(o),ae(r.value);for(let e=n.length-1;e>=0;e--){const t=n[e].comparison;if(null!=t){ce(t);break}}ue(r.time)},[fe]),ge=B_(e=>ye([e]),[ye]);j_(t,()=>({push:e=>ge(e),pushMany:e=>ye(e),clear:()=>{de.current=[],he.current=null,re([]),ae(null),ce(null),ue(null)},getValue:()=>he.current??(Number.isFinite(pe.current)?pe.current:null),getData:()=>de.current.slice()}),[ge,ye]);const be=ie??n,ve=null==be||"number"!=typeof be||!Number.isFinite(be),xe=E_(()=>z_(i??"number",{locale:a,currency:s,precision:c}),[i,a,s,c]),we=E_(()=>z_(f??i??"number",{locale:a,currency:s,precision:null==f&&null==i?0:c}),[f,i,a,s,c]),ke=N??!1,Se=("object"!=typeof ke||!1!==ke.intro)&&!!ke,Ae=Number.isFinite(be)?be:0,Ce=function(e,t,n,o=e){const[r,i]=O_(()=>o),a=F_(o),s=F_(null),c=F_(e),l=F_(0),u=!!t,d="object"==typeof t?t.duration:void 0,h="number"==typeof d&&Number.isFinite(d)?Math.max(0,d):300,p="object"==typeof t&&"linear"===t.easing?"linear":"ease-out",m=F_(e);return D_(()=>{const t=e=>{a.current=e,i(e)};if(!Number.isFinite(e))return void t(e);if(!u||n)return void t(e);if(0===h)return void t(e);c.current=a.current,m.current=e,l.current="undefined"!=typeof performance?performance.now():Date.now();const o="linear"===p?e=>e:e=>1-Math.pow(1-e,3),r=e=>{const n=Math.min(1,(e-l.current)/h),i=o(n);t(c.current+(m.current-c.current)*i),1>n?s.current=requestAnimationFrame(r):(s.current=null,t(m.current))};return s.current=requestAnimationFrame(r),()=>{null!=s.current&&cancelAnimationFrame(s.current),s.current=null}},[u,h,p,n,e]),r}(Ae,ke,te,F_(!Se||te||ne?Ae:0).current),Me=ke?Ce:Number.isFinite(be)?be:0,Pe=E_(()=>function(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const n=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let o=null;for(const t of n){if(t.at>e)break;o=t}return o}(Number.isFinite(be)?be:NaN,v),[be,v]),Ie=Pe?Pe.level:"neutral",Re=P??function(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}(Ie,Pe?.color),_e=se??h?.value??null,Te=null!=m?m:null!=_e&&Number.isFinite(be)?be-_e:null,Le=function(e,t,n){if(n&&"auto"!==n)return n;if(null==e||0===e||!Number.isFinite(e))return"neutral";const o=t??"higher-is-better";return"neutral"===o?"neutral":("higher-is-better"===o?e>0:0>e)?"positive":"negative"}(Te,h?.direction??p?.direction??g,b),Ne=null!=Te&&Number.isFinite(Te)?function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(Te,we):null,$e=E_(()=>new Intl.NumberFormat(a??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[a]),Be=null!=_e&&Number.isFinite(be)&&(y??1)&&0!==_e?$e.format((be-_e)/Math.abs(_e)):null,De=function({target:e,value:t,format:n,locale:o,currency:r,precision:i}){const a=W_(()=>new Intl.NumberFormat(o??"en-US",{style:"percent",maximumFractionDigits:0}),[o]),s=W_(()=>z_(e?.format??n??"number",{locale:o,currency:r,precision:i}),[e?.format,n,o,r,i]);return W_(()=>{if(!e||!Number.isFinite(e.value))return null;const n="number"==typeof t&&Number.isFinite(t)&&0!==e.value?a.format(t/e.value):null,o=s(e.value);return{label:e.label,percent:n,formattedValue:o,text:n?e.label?`${n} of ${e.label} (${o})`:`${n} of ${o}`:e.label?`target ${e.label} (${o})`:"target "+o}},[e,t,s,a])}({target:p,value:be,format:i,locale:a,currency:s,precision:c}),je=De?.percent??null,Ee=De?.text??null,Fe=function(e,t){const[n,o]=O_(!1);return D_(()=>{if(!t||null==e)return void o(!1);const n=()=>{o(Date.now()-e>=t)};n();const r=setInterval(n,Math.max(250,Math.floor(t/4)));return()=>clearInterval(r)},[e,t]),n}(le,$),Oe=Number.isFinite(Me)?H_(xe(Me),l,u):"",ze={value:ve?null:be,formattedValue:Oe,level:Ie,color:Re,delta:Te,deltaFormatted:Ne,deltaPercent:Be,sentiment:Le,isStale:Fe,pushBuffer:oe},He=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 n=e.delta,o=null!=n&&Number.isFinite(n)&&0!==n?n>0?"up":"down":"change";t.push(`${o} ${e.deltaFormatted}${e.deltaPercent?` (${e.deltaPercent})`:""}${e.comparisonLabel?" from "+e.comparisonLabel:""}`)}return e.targetText&&t.push(e.targetText),e.thresholdLabel&&t.push(e.thresholdLabel),e.stale&&t.push(e.staleLabel??"stale"),t.join(", ")}({label:o,formattedValue:Number.isFinite(be)?H_(xe(be),l,u):"",unit:d,comparisonLabel:h?.label,delta:Te,deltaFormatted:Ne,deltaPercent:Be,targetText:Ee,thresholdLabel:Pe?.label,stale:Fe,staleLabel:B}),We="number"==typeof C?{top:C,right:C,bottom:C,left:C}:{...Q.padding,...C??{}},Ge="end"===Z?"flex-end":"center"===Z?"center":"start"===Z?"flex-start":"inherit",qe={position:"relative",boxSizing:"border-box",width:J,height:ee,padding:`${We.top}px ${We.right}px ${We.bottom}px ${We.left}px`,background:I??Q.background,border:Q.border?"1px solid "+(R??"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof _?_+"px":_??"var(--semiotic-border-radius, 8px)",display:"inline"===w?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===Ge?void 0:Ge,textAlign:Z,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:Fe?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===M?"span 2":void 0,cursor:W?"pointer":void 0,...L},Ye=B_(e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top,r={value:ve?NaN:be,level:Ie,delta:Te};W&&W(r,{x:n,y:o}),G&&G({type:"click",datum:r,x:n,y:o,chartType:"BigNumber",chartId:q,timestamp:Date.now()})},[W,G,q,ve,be,Ie,Te]),Ve="inline"===w?"span":"div",Xe=["semiotic-bignumber","semiotic-bignumber--mode-"+w,"semiotic-bignumber--level-"+Ie,"semiotic-bignumber--sentiment-"+Le,Fe?"semiotic-bignumber--stale":null,T].filter(Boolean).join(" "),Ue="positive"===Le?"up":"negative"===Le?"down":"flat";if(X){const e="number"==typeof J?J:280,t="number"==typeof ee?ee:160;return q_(Ve,{role:"status","aria-live":"polite","aria-busy":"true",className:Xe+" semiotic-bignumber--loading",style:{...qe,opacity:1},children:U??q_(J_,{width:e,height:t,mode:w})})}return ve?!1===K?null:q_(Ve,{role:"status","aria-label":o?o+": no value":"no value",className:Xe+" semiotic-bignumber--empty",style:{...qe,color:"var(--semiotic-text-secondary, #666)",fontSize:13,alignItems:"center",justifyContent:"center"},children:K??"—"}):q_(oh,{componentName:"BigNumber",width:"number"==typeof J?J:280,height:"number"==typeof ee?ee:160,children:Y_(Ve,{role:"group","aria-label":He,"data-chart":"BigNumber","data-mode":w,"data-level":Ie,"data-stale":Fe?"true":void 0,"data-sentiment":Le,className:Xe,style:qe,onClick:W||G?Ye:void 0,children:[Q.showHeader&&(o||r||D)?q_("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:Q.showChart&&null!=O?(z??Q.chartSize)+8:0},children:X_(D,ze,Y_(G_,{children:[o?q_("span",{className:"semiotic-bignumber__label",style:{fontSize:Q.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:o}):null,r?q_("span",{className:"semiotic-bignumber__caption",style:{fontSize:Q.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:r}):null]}))}):null,X_(j,ze,Y_(Ve,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Ie,style:{display:"inline"===w?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Re,fontSize:Q.valueSize||void 0,lineHeight:1.05},children:[q_("span",{className:"semiotic-bignumber__value-text",children:Oe}),d?q_("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&&(Ne||De||h)?q_(Ve,{className:"semiotic-bignumber__delta semiotic-bignumber__delta--"+Ue,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:X_(E,ze,Y_(G_,{children:[Ne?Y_("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+Ue,style:{display:"inline-flex",alignItems:"center",gap:4,color:U_(Le),fontWeight:600},children:[q_("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+Ue,children:K_(Le)}),q_("span",{className:"semiotic-bignumber__delta-amount",children:Ne}),Be?Y_("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",Be,")"]}):null]}):null,h?.label?q_("span",{className:"semiotic-bignumber__comparison-label",children:h.label}):null,De?Y_("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[Ne||h?.label?q_("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,q_("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:je}),Y_("span",{className:"semiotic-bignumber__target-value",children:["of ",De.formattedValue,De.label?" "+De.label:""]})]}):null]}))}):null,Q.showChart&&null!=O?q_("div",{className:"semiotic-bignumber__chart",style:{position:"absolute",top:We.top,right:We.right,width:z??Q.chartSize,height:z??Q.chartSize,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:q_("div",{style:{pointerEvents:"auto",lineHeight:0},children:X_(O,ze,null)})}):null,Q.showTrend&&null!=F?q_("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:We.left,right:We.right,bottom:We.bottom+(null!=H?28:0)},children:X_(F,ze,null)}):null,null!=H?q_(Ve,{className:"semiotic-bignumber__footer",style:{position:"absolute",left:We.left,right:We.right,bottom:We.bottom,fontSize:Q.deltaSize||void 0,color:"var(--semiotic-text-secondary, #9ca3af)"},children:X_(H,ze,null)}):null,V?q_("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]})})});Q_.displayName="BigNumber";var Z_=Q_;function J_(e){const t=Math.floor(.45*e.width),n=Math.floor(.6*e.width),o=(e,t)=>q_("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return Y_("div",{style:{display:"flex",flexDirection:"column",gap:10,justifyContent:"center",width:"100%",height:"100%"},children:["thumbnail"!==e.mode&&"inline"!==e.mode?o(t,10):null,o(n,"presentation"===e.mode?48:28),"tile"===e.mode||"presentation"===e.mode?o(Math.floor(.35*e.width),8):null]})}var[eT,tT]=G(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));async function nT(e,t){const{format:n="png",filename:o="chart",scale:r=2,background:i="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),c=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",c.width+""),s.getAttribute("height")||s.setAttribute("height",c.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),oT(a,s),"svg"===n){const e=(new XMLSerializer).serializeToString(s);rT(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=c.width*r,n=c.height*r,a=document.createElement("canvas");a.width=t,a.height=n;const l=a.getContext("2d");l.fillStyle=i,l.fillRect(0,0,t,n),l.scale(r,r);const u=e.querySelector("canvas");u&&l.drawImage(u,0,0,c.width,c.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=c.width,m.height=c.height,await new Promise((e,t)=>{m.onload=()=>{l.drawImage(m,0,0),a.toBlob(n=>{n?(rT(n,o+".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 oT(e,t){const n=e.children,o=t.children,r=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 n=r.getPropertyValue(e);n&&"none"!==n&&""!==n&&t.style?.setProperty(e,n)}for(let e=0;Math.min(n.length,o.length)>e;e++)oT(n[e],o[e])}function rT(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}import*as iT from"react";var aT=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","BubbleChart","Heatmap","QuadrantChart","MultiAxisLineChart","CandlestickChart","ConnectedScatterplot","ScatterplotMatrix","MinimapChart","ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram","TreeDiagram","Treemap","CirclePack","OrbitDiagram","ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram","RealtimeLineChart","RealtimeHistogram","TemporalHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","GauntletChart","ProcessFlowChart","PhysicalFlowChart","BigNumber"],sT=new Set(aT);function cT(e){return sT.has(e)}var lT=["value","threshold","partition-boundary","time-window","range-boundary"];function uT(e,t,n,o,r){return{id:e,...t?{controlId:t}:{},status:n,message:o,...r?{remediation:r}:{}}}function dT({controls:e=[],minimumTargetSize:t=24}){const n=[],o=new Set;for(const r of e){const e=r?.id,i="controls."+(e||"unknown"),a=r?.domain,s=Array.isArray(a)&&2===a.length&&Number.isFinite(a[0])&&Number.isFinite(a[1])&&a[1]>a[0],c=lT.includes(r?.type),l="string"==typeof r?.target&&r.target.trim().length>0,u=["slider","buttons","native-range"].includes(r?.keyboard??""),d=r?.minimumTargetSize;n.push(uT(i+".semantic-type",e,c?"pass":"fail",c?`Control uses the semantic type "${r.type}".`:"Control has no recognized semantic type.","Use one of VISUALIZATION_CONTROL_TYPES.")),n.push(uT(i+".state-binding",e,l?"pass":"fail",l?`Control is bound to "${r.target}".`:"Control has no declarative state binding.","Declare the controlled state key with target.")),n.push(uT(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].")),n.push(uT(i+".keyboard",e,u?"pass":"fail",u?`Control declares a ${r.keyboard} keyboard path.`:"Control does not declare a keyboard path.","Declare slider, buttons, or native-range keyboard interaction.")),n.push(uT(i+".value-text",e,"string"==typeof r?.valueText&&r.valueText.trim().length>0?"pass":"fail","string"==typeof r?.valueText&&r.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.")),n.push(uT(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!=r?.step&&n.push(uT(i+".step",e,Number.isFinite(r.step)&&r.step>0?"pass":"fail",Number.isFinite(r.step)&&r.step>0?"Control has a positive quantization step.":"Control step must be a positive finite number.","Use a positive finite step.")),r?.observations?.length&&n.push(uT(i+".observations",e,r.observations.includes("control-change")?"pass":"warn",r.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&&!o.has(e)||n.push(uT(i+".identity",e,"fail",e?"Control id is duplicated.":"Control id is missing.","Use a unique stable control id.")),e&&o.add(e)}return{ok:n.every(e=>"fail"!==e.status),findings:n}}function hT(e){return pT(e),e}function pT(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=dT({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(!mT(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(!fT(t))throw Error(`Portable chart recipe "${e.id}" has a layout config schema that is not JSON-safe.`)}}function mT(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function fT(e,t=new Set){if(null===e)return!0;const n=typeof e;if("string"===n||"boolean"===n)return!0;if("number"===n)return Number.isFinite(e);if("object"!==n)return!1;if(t.has(e))return!1;t.add(e);const o=Array.isArray(e)?e.every(e=>fT(e,t)):Object.entries(e).every(([,e])=>fT(e,t));return t.delete(e),o}function yT(e){return"string"==typeof e?e:e.id??e.name}function gT(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 bT(e){const t=new Set(e.intents.map(yT));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 vT(e){const t=Object.values(e.audience?.familiarity??{}),n=t.find(e=>"number"==typeof e);if(void 0!==n)return Math.max(1,Math.min(5,Math.round(n)));const o=t.filter(e=>"string"==typeof e);return o.includes("high")?4:o.includes("medium")?3:o.includes("low")?2:e.reception?.memorableForm?3:2}function xT(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 wT(e,t,n){return xT(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,n))}function kT(e,t,n){if(t.field&&wT(n,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&&wT(n,t,e))return e}switch(t.semanticType){case"quantitative":return n.primary.y??n.primary.size??n.primary.x;case"temporal":return n.primary.time??n.primary.x;case"nominal":case"ordinal":return n.primary.category??n.primary.series;case"identifier":{const e=xT(n,t.source);return["id","key","name"].find(t=>e.some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,t)))}case"geographic":return n.hasGeo?t.field:void 0;default:return t.field}}function ST(e){const t={},n=[];for(const o of e.intents){const e=yT(o);e&&(t[e]=gT(o),"string"!=typeof o&&o.rationale&&n.push(o.rationale))}n.push(...(e.reception?.strengths??[]).map(e=>"Reception strength: "+e));const o=e.reception?.risks??[],r=e.designContract.misuse??[],i=[...e.designContract.caveats??[],...e.caveats??[]];return{component:e.id,displayName:e.name,candidateKind:"recipe",family:bT(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:vT(e),accuracy:4,precision:o.some(e=>/precis|comparison/i.test(e))?2:3},fits:t=>function(e,t){for(const n of e.dataRoles)if(!1!==n.required&&!kT(0,n,t))return`needs data role "${n.role}" (${n.semanticType})`;const n=e.audit?.maxCategories;return"number"==typeof n&&"number"==typeof t.categoryCount&&t.categoryCount>n?`${t.categoryCount} categories exceeds this recipe's declared maximum of ${n}`:null}(e,t),intentScores:t,caveats:()=>[...o,...r,...i],buildProps:t=>function(e,t){const n={};for(const o of e.dataRoles){const e=kT(0,o,t);e&&o.accessor&&(n[o.accessor]=e)}const o={recipeId:e.id,layoutConfig:n};e.frameFamily.startsWith("Network")?(o.nodes=t.network?.nodes??t.data,o.edges=t.network?.edges??[]):e.frameFamily.startsWith("Geo")?(o.areas=t.geo?.features??[],o.points=t.geo?.points??t.data,o.lines=t.geo?.flows??[]):o.data=t.data;const r=e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0);return r&&(o.mobileSemantics=r),o}(e,t),mobile:e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0),recipe:e,positiveRationale:n,whyCustom:{defaultAlternative:e.designContract.defaultAlternative,reason:e.designContract.whyNotDefault??e.designContract.whyCustom,tradeoff:e.designContract.tradeoff??(o.length>0?o[0]:void 0)}}}var AT=Symbol.for("semiotic.chartRecipeRegistry");function CT(){const e=globalThis;return e[AT]||(e[AT]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[AT]}function MT(e){pT(e),CT().recipes.set(e.id,e),CT().capabilities.set(e.id,ST(e))}function PT(e){CT().recipes.delete(e),CT().capabilities.delete(e)}function IT(e){return CT().recipes.get(e)}function RT(){return Array.from(CT().recipes.values())}function _T(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.`);CT().layouts.set(e,t)}function TT(e){CT().layouts.delete(e)}function LT(e){return CT().layouts.get(e)}function NT(e){return"string"==typeof e?IT(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function $T(e){return"string"==typeof e?e:e.id??e.name}function BT(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function DT(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 jT(e,t,n){return n??NT(t.recipe)??NT(t.recipeId)??IT(e)}function ET(e,t,n=[]){const o=e.accessor?t[e.accessor]:void 0;if("string"==typeof o&&o)return o;if(e.field)return e.field;const r=n.find(e=>e&&"object"==typeof e);if(!r)return;const i=Object.entries(r).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 r):i.find(([,e])=>"string"==typeof e)?.[0]}function FT(e,t){return e.dataRoles.find(e=>e.role===t)}function OT(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function zT(e,t,n,o,r,i={}){const a={...i};if(t)for(const[e,n]of Object.entries(t))a[e]=n;for(const e of n.dataRoles){const n=ET(e,o,r),i=t&&n?t[n]:n;void 0!==i&&(a[e.role]=i)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const n=a[t];return null==n?`{${t}}`:n+""})}var HT=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"]),WT=new Set(["data","nodes","edges","points","areas","lines","flows"]);function GT(e,t){return!!WT.has(e)&&("areas"!==e||"string"!=typeof t)}var qT="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function YT(e,t,n){const o=IT(e)??NT(t.recipe)??NT(t.recipeId);if(o)return function(e,t,n){const o=function(e,t,n){const o={};for(const[r,i]of Object.entries(e))if(null!=i&&!HT.has(r)&&"recipeId"!==r&&(t||!GT(r,i)))if("function"==typeof i||i?.$$typeof){if(n)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`)}else if(fT(i))o[r]=qT(i);else if(n)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`);return o}(t,!1!==n?.includeData,"portable"===e.portability),r=e.intents.map($T).filter(e=>!!e),i={name:e.name,intents:r,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!fT(o))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:o,manifest:i,version:"1",createdAt:(new Date).toISOString(),...n?.selections?{selections:n.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:o,manifest:i,version:"1",createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(o,t,n);if(!cT(e))throw Error(`Unknown component "${e}". Known components: ${aT.join(", ")}`);const r=!1!==n?.includeData,i={};for(const[e,n]of Object.entries(t))null!=n&&(HT.has(e)||!r&&GT(e,n)||"function"!=typeof n&&(n?.$$typeof||(i[e]=qT(n))));return{component:e,props:i,version:"1",createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}function VT(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=IT(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:{...qT(e.props),recipeId:e.recipeId}}}if(!cT(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:qT(e.props)}}function XT(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function UT(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)}async function KT(e,t="json"){const n="jsx"===t?QT(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(n)}function QT(e){const{props:t}=e,n=["<"+("LocalChartRecipe"===e.component?"ChartRecipe":e.component)];e.recipeId&&n.push(` recipeId="${e.recipeId}"`);for(const[e,o]of Object.entries(t))if("string"==typeof o)n.push(` ${e}="${o}"`);else if("boolean"==typeof o&&!0===o)n.push(" "+e);else if("boolean"==typeof o&&!1===o)n.push(` ${e}={false}`);else if("number"==typeof o)n.push(` ${e}={${o}}`);else{const t=JSON.stringify(o);n.push(80>t.length?` ${e}={${t}}`:` ${e}={${JSON.stringify(o,null,2)}}`)}return n.push("/>"),n.join("\n")}var ZT=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),JT=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),eL=new Set(["PieChart","DonutChart","FunnelChart"]),tL=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function nL(e,t){return JT.has(e)||eL.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 oL(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function rL(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function iL(e,t){const n={...e};return t.provenance&&(n.provenance=t.provenance),t.lifecycle&&(n.lifecycle=t.lifecycle),n}function aL(){return(new Date).toISOString()}function sL(e,t={}){const n=e.provenance;return{...e,provenance:{...n,...t,createdAt:t.createdAt??n?.createdAt??aL()}}}function cL(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 lL(e){const t=cL(e?.now);if(null!=t)return t;const n=e?.dataExtent;if(n)if(Array.isArray(n)){const e=cL(n[n.length-1]);if(null!=e)return e}else if("max"in n){const e=cL(n.max);if(null!=e)return e}return Date.now()}function uL(e,t,n={}){const o=e?.lifecycle?.freshness,r=cL(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==r||null==i?o??"fresh":Qe(t-r,i,n)}function dL(e,t={}){const n=lL(t);return e.map(e=>{const o=uL(e,n,t.thresholds);return{...e,lifecycle:{...e.lifecycle,freshness:o}}})}var hL={fresh:null,aging:.55,stale:.35,expired:.2},pL={fresh:null,aging:null,stale:"4 4",expired:"2 4"};function mL(e,t,n){return e&&n in e?e[n]:t[n]}function fL(e,t={}){const n=lL(t),o=!0===t.showExpiredAnnotations,r=[];for(const i of e){const e=uL(i,n,t.thresholds);if("expired"===e&&!o)continue;const a=mL(t.opacity,hL,e),s=mL(t.strokeDasharray,pL,e),c=t.labelSuffix?.[e],l={...i,lifecycle:{...i.lifecycle,freshness:e}};null!=a&&null==l.opacity&&(l.opacity=a),null!=s&&null==l.strokeDasharray&&(l.strokeDasharray=s),c&&"string"==typeof l.label&&(l.label=l.label+c);const u=i.lifecycle?.anchor;u&&null==l.anchor&&(l.anchor=u),r.push(l)}return r}var yL={proposed:.7,accepted:null,disputed:.7,retracted:.25},gL={proposed:"3 3",accepted:null,disputed:"2 3",retracted:"2 4"},bL={proposed:" (proposed)",accepted:"",disputed:" (?)",retracted:""};function vL(e,t,n){return e&&n in e?e[n]:t[n]}function xL(e,t={}){const n=!0===t.showRetractedAnnotations,o=!0===t.showSupersededAnnotations,r=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&r.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&r.has(t)&&!o)})}function wL(e,t={}){const n=[];for(const o of xL(e,t)){const e=o?.lifecycle?.status;if(!e){n.push(o);continue}const r=vL(t.opacity,yL,e),i=vL(t.strokeDasharray,gL,e),a=t.labelSuffix?.[e]??bL[e],s={...o};null!=r&&(s.opacity=("number"==typeof s.opacity?s.opacity:1)*r),null!=i&&null==s.strokeDasharray&&(s.strokeDasharray=i),a&&"string"==typeof s.label&&(s.label=s.label+a),n.push(s)}return n}function kL(e,t,n={}){const o=DT(t),r=BT(t),i=n.locale??"en",a="function"==typeof e.description?e.description({data:o,config:r,locale:i}):void 0,s=a?.levels??function(e,t,n,o){const r=OT(e,["nominal","ordinal"]),i=OT(e,["quantitative"]),a=r?ET(r,n,t):void 0,s=i?ET(i,n,t):void 0,c=r?.role??a??"category",l=i?.role??s??"value",u=e.encodings??[],d=u.length?u.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${c} and ${l} 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})}}}(o),m=new Map;if(a&&s)for(const e of t){const t=(e[a]??"Uncategorized")+"",n=Number(e[s]);Number.isFinite(n)&&m.set(t,(m.get(t)??0)+n)}const f=[...m].sort((e,t)=>t[1]-e[1]),y=f.reduce((e,[,t])=>e+t,0),g=f[0],b=f[1],v=y>0?((g?.[1]??0)+(b?.[1]??0))/y:0,x=e.intents.map(e=>({id:$T(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 ${c} and ${l}. ${k=d,k?k.charAt(0).toUpperCase()+k.slice(1):k}.`,l2:f.length>0?`${f.length} categories total ${h.format(y)}. ${g[0]} accounts for ${h.format(g[1])}${y>0?` (${p.format(g[1]/y)})`:""}${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?g?g[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 ${g[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,o,r,i),c=n.levels??["l1","l2","l3","l4"],l={};for(const e of c)s[e]&&(l[e]=s[e]);const u=["l1","l2","l3","l4"].map(e=>l[e]).filter(e=>!!e).join(" "),d=n.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:u,levels:l,...d?.length?{caveats:d}:{}}}var SL={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"},AL=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),CL=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","PhysicsCustomChart"]);function ML(e){return SL[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function PL(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var IL=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),RL={"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"},_L={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},TL=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],LL={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function NL(e){return RL[e]}function $L(e,t){const n=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,n={};for(const[e,o]of Object.entries(t.intentScores))"number"==typeof o&&Number.isFinite(o)&&(n[e]=o);return{family:t.family,intentScores:Object.keys(n).length?n:void 0}}return e}}(t);if(n?.act)return n.act;if(n?.intentScores){const e=function(e){let t,n=0;for(const[o,r]of Object.entries(e))if("number"==typeof r&&r>0)if(r>n)t=o,n=r;else if(r===n&&void 0!==t){const e=TL.indexOf(o),n=TL.indexOf(t);-1===e||-1!==n&&e>=n||(t=o)}return t}(n.intentScores);if(e&&RL[e]&&(n.intentScores[e]??0)>=3)return RL[e]}return n?.family?_L[n.family]:function(e){return eL.has(e)||"StackedAreaChart"===e?"apportioning":IL.has(e)?"relating":JT.has(e)?"comparing":tL.has(e)?"characterizing":ZT.has(e)?"tracking":AL.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var BL=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),DL=new Set(["system","agent","watcher"]),jL=new Set(["ai","agent","system","computed","dbt","great-expectations"]),EL=new Set(["rule","statistical-test","llm-inference","computed"]);function FL(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||!BL.has(t.type))return!1;const n=t.provenance;return!(!n||"object"!=typeof n)&&(DL.has(n.authorKind)||jL.has(n.source)||EL.has(n.basis))})}function OL(e="en"){let t,n;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?n.format(e):t.format(e):e+""}var zL={"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 HL(e){const t=zL["string"==typeof e.type?e.type:"annotation"]||"an annotation",n=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,n=t?.authorKind??t?.source??t?.basis;return"watcher"===n?"a watcher-flagged ":"agent"===n||"ai"===n||"llm-inference"===n?"an AI-suggested ":""}(e),o=n?n+t.replace(/^an? /,""):t,r="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return r?`${o} labeled "${r}"`:o}function WL(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const n=xL(t.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return;const o=n.map(HL),r=o.slice(0,5),i=o.length-r.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]??""}(r)+(i>0?`, and ${i} more`:""),s=n.length;return`The author has marked ${1===s?"one feature":s+" features"} on this chart: ${a}.`}function GL(e,t,n={}){const o=void 0!==n.levels,r=new Set(n.levels??["l1","l2","l3"]);o||!n.capability&&!FL(t)||r.add("l4");const i=jT(e,t,n.recipe);if(i){const e=["l1","l2","l3","l4"].filter(e=>r.has(e));o||e.includes("l4")||e.push("l4");const a=kL(i,t,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),s=WL(t);return{...a,text:s?`${s} ${a.text}`.trim():a.text,...s?{annotations:s}:{}}}const a=OL(n.locale??"en"),s=ML(e),c=Array.isArray(t.data)?t.data:null,l=oL(t),u=CL.has(e)?function(e,t){const n=e.physics&&"object"==typeof e.physics?e.physics:null,o=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,r=[e.settledProjectionRows,e.projectionRows,o?.rows,n?.settledProjectionRows,n?.projectionRows,n?.settledProjection&&"object"==typeof n.settledProjection?n.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(r)?r.map((e,n)=>{if(!e||"object"!=typeof e)return null;const o=e,r=PL(o.count??o.value??o.total??o.bodies??o.events);if(null==r)return null;const i=o.label??o.id??o.name??"container "+(n+1),a=PL(o.secondary??o.secondaryCount),s=PL(o.observed??o.observedCount);return{label:rL(i,t),count:r,...null!=a?{secondary:a}:{},..."string"==typeof o.secondaryLabel&&o.secondaryLabel?{secondaryLabel:o.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(t,a):null,{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=nL(e,t),f="string"==typeof d&&d?d:h,y="string"==typeof p&&p?p:m,g={};if(CL.has(e)&&function(e,t,n,o,r,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(r.has("l1")&&(o.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)),!r.has("l2")&&!r.has("l3"))return;if(!n||0===n.length)return void(r.has("l2")&&(o.l2="No settled projection is loaded yet."));const c=n.reduce((e,t)=>e+t.count,0),l=n.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),u=l[0]??n.slice().sort((e,t)=>t.count-e.count)[0];if(!u)return;const d=n.reduce((e,t)=>e+(t.secondary??0),0),h=n.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(r.has("l2"))if(0===l.length)o.l2=`The settled projection contains ${i(c)} ${YL(c,s)} across ${n.length} ${YL(n.length,a)}; no ${YL(2,a)} are non-empty yet.`;else{const e=d>0?` ${i(d)} ${YL(d,s)} ${1===d?"is":"are"} marked ${h}.`:"";o.l2=`The settled projection contains ${i(c)} ${YL(c,s)} across ${n.length} ${YL(n.length,a)}; ${l.length} ${YL(l.length,a)} ${1===l.length?"is":"are"} non-empty. The largest ${a} is ${u.label} with ${i(u.count)} ${YL(u.count,s)}.${e}`}if(r.has("l3")&&c>0&&l.length>0){const e=l.find(e=>e!==u),t=function(e,t){if(0>=t)return"0%";const n=e/t*100;return(10>n?Math.round(10*n)/10:Math.round(n))+"%"}(u.count,c);o.l3=e?`The settled projection is most concentrated in ${u.label}, which holds ${i(u.count)} ${YL(u.count,s)} (${t}); ${e.label} follows with ${i(e.count)} ${YL(e.count,s)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${i(u.count)} ${YL(u.count,s)}.`}}(e,s,u,g,r,a),r.has("l1")&&!CL.has(e))if(ZT.has(e)||JT.has(e))g.l1=`A ${s} of ${f} by ${y}`+(l?`, split by ${l}.`:".");else if(eL.has(e))g.l1=`A ${s} showing ${f} across ${y} categories.`;else if(tL.has(e))g.l1=`A ${s} of the distribution of ${f}`+(l?` by ${l}.`:".");else if(AL.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,n=Array.isArray(t.edges)?t.edges.length:void 0,o=[null!=e?`${e} ${YL(e,"node")}`:null,null!=n?`${n} ${YL(n,"edge")}`:null].filter(Boolean);g.l1=`A ${s}${o.length?" with "+o.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:f;g.l1=`A single value${e?" for "+e:""}.`}else g.l1=`A ${s}.`;const b=ZT.has(e)||JT.has(e)||eL.has(e)||tL.has(e);let v=null;if((r.has("l2")||r.has("l3")||r.has("l4"))&&b&&c&&c.length>0&&(v=function(e,t,n,o){let r=0,i=0,a=1/0,s=-1/0,c=null,l=null,u=0,d=0,h=null,p=null,m=NaN,f=NaN;for(const n of e){const e=t(n);Number.isFinite(e)&&(0===r&&(m=e,h=n),f=e,p=n,a>e&&(a=e,c=n,u=r),e>s&&(s=e,l=n,d=r),r++,i+=e)}return 0===r?null:{count:r,min:a,max:s,mean:i/r,minLabel:rL(null!=c?n(c):null,o),maxLabel:rL(null!=l?n(l):null,o),first:m,last:f,firstLabel:rL(null!=h?n(h):null,o),lastLabel:rL(null!=p?n(p):null,o),minIndex:u,maxIndex:d}}(c,re(d,h),ie(p,m),a)),r.has("l2")&&b&&(c&&0!==c.length?v&&(g.l2=eL.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.`):g.l2="No data is loaded yet."),r.has("l3")&&v&&!l&&ZT.has(e)?g.l3=function(e,t,n){const{first:o,last:r,min:i,max:a,maxLabel:s,minLabel:c,firstLabel:l,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,m=a-i,f=r-o;if(0===m)return`${qL(t)} is constant at ${n(o)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${qL(t)} ends roughly where it started (${n(o)} at ${l} to ${n(r)} at ${u}), ranging between ${n(i)} and ${n(a)}.`;const y=h>0&&p-1>h,g=d>0&&p-1>d,b=(a-Math.max(o,r))/m,v=(Math.min(o,r)-i)/m;return y&&b>.15?`Overall ${t} climbs to a peak of ${n(a)} (${s}), then falls to ${n(r)} (${u}).`:g&&v>.15?`Overall ${t} drops to a low of ${n(i)} (${c}), then recovers to ${n(r)} (${u}).`:.05>Math.abs(f)/m?`${qL(t)} ends roughly where it started (${n(o)} at ${l} to ${n(r)} at ${u}), ranging between ${n(i)} and ${n(a)}.`:f>0?h===p-1?`Overall ${t} rises from ${n(o)} (${l}) to a peak of ${n(r)} (${u}).`:`Overall ${t} rises from ${n(o)} (${l}) to ${n(r)} (${u}), after peaking at ${n(a)} (${s}).`:d===p-1?`Overall ${t} falls from ${n(o)} (${l}) to a low of ${n(r)} (${u}).`:`Overall ${t} falls from ${n(o)} (${l}) to ${n(r)} (${u}), after dipping to ${n(i)} (${c}).`}(v,f,a):r.has("l3")&&v&&!l&&JT.has(e)&&(g.l3=`The highest ${y} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),r.has("l4")){const o=FL(t)?"alerting":$L(e,n.capability);o&&(g.l4=function(e,t,n,o,r,i,a,s){const c=LL[e],l=/^[aeiou]/i.test(c)?"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 n.label&&n.label?n.label:r} as the headline number`;break;case"tracing":u=`This is ${l} ${c} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${l} ${c} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${l} ${c} chart`,d=`read it for whether ${i} and ${r} move together`;break;default:u=`This is ${l} ${c} chart`,d=function(e,t,n,o,r,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 "+n;case"comparing":return`compare ${n} across ${o}`;case"ranking":return"read it top to bottom by "+n;case"apportioning":return`read each ${o}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+n;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,n){if(JT.has(n)||eL.has(n))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:o,last:r,min:i,max:a,minLabel:s,maxLabel:c,lastLabel:l,minIndex:u,maxIndex:d,count:h}=e,p=a-i;if(p>0){const e=d>0&&h-1>d,n=u>0&&h-1>u,m=(a-Math.max(o,r))/p,f=(Math.min(o,r)-i)/p;if(e&&m>.15)return`the peak of ${t(a)} at ${c} is the point to investigate`;if(n&&f>.15)return`the dip to ${t(i)} at ${s} is the point to investigate`;if(r>=a)return`the climb to ${t(r)} at ${l} warrants a closer look`;if(i>=r)return`the drop to ${t(r)} at ${l} warrants a closer look`}return`the extremes — ${c} (${t(a)}) and ${s} (${t(i)}) — are the points to check`}(t,r,i);case"tracking":return`read it for the trajectory of ${n}, which ${function(e){const t=e.max-e.min,n=e.last-e.first;return 0===t||.05>Math.abs(n)/t?"holds roughly steady":n>0?"rises":"falls"}(t)} from ${r(t.first)} (${t.firstLabel}) to ${r(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${n} across ${o}; ${t.maxLabel} leads at ${r(t.max)}`;case"ranking":return`read it top to bottom by ${n}; ${t.maxLabel} ranks highest at ${r(t.max)}`;case"apportioning":{const e=t.mean*t.count,n=e>0?Math.round(t.max/e*100):null;return`read each ${o}'s share of the ${r(e)} total; ${t.maxLabel} is the largest at ${r(t.max)}${null!=n?` (${n}%)`:""}`}case"characterizing":return`read it for the spread of ${n}, from ${r(t.min)} to ${r(t.max)}`;default:return"read the highlighted features"}}(e,o,r,i,a,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const n=t.familiarity?.[e];return"number"!=typeof n||n>2?"":` This ${ML(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(o,e,t,l?null:v,f,y,a,n.audience))}const x=["l1","l2","l3","l4"].filter(e=>r.has(e)&&g[e]).map(e=>g[e]).join(" "),w=WL(t);return{text:w?`${w} ${x}`.trim():x,levels:g,...w?{annotations:w}:{}}}function qL(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function YL(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function VL(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function XL(e,t,n={}){const o=DT(t),r=BT(t),i=Math.max(1,n.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:o,config:r,locale:n.locale??"en"});const a=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const c=(a?.groupByRole?FT(e,a.groupByRole):void 0)??(a?.groupBy?.[0]?FT(e,a.groupBy[0])??e.dataRoles.find(e=>e.field===a.groupBy?.[0]):void 0)??OT(e,["nominal","ordinal"]),l=c?ET(c,r,o):void 0,u=(a?.idRole?FT(e,a.idRole):void 0)??OT(e,["identifier"]),d=u?ET(u,r,o):void 0,h={id:"root",role:"chart",label:a?.summaryTemplate?zT(a.summaryTemplate,void 0,e,r,o,{count:o.length}):`${e.name}: ${o.length} ${1===o.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const m=(t,n,i)=>{const s=d?t[d]:void 0,c=a?.itemLabelTemplate?zT(a.itemLabelTemplate,t,e,r,o,{count:o.length}):function(e,t,n,o){const r=OT(t,["nominal","ordinal"]),i=t.dataRoles.filter(e=>"quantitative"===e.semanticType),a=r?ET(r,n,o):void 0,s=[];a&&null!=e[a]&&s.push(e[a]+"");for(const t of i){const r=ET(t,n,o);r&&null!=e[r]&&s.push(`${t.role}: ${e[r]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,r,o);return{id:"datum-"+VL(s??n),role:"datum",label:c,level:i,datum:t}};if(l){const e=new Map;for(const t of o){const n=(t[l]??"Uncategorized")+"",o=e.get(n);o?o.push(t):e.set(n,[t])}h.children=[...e].map(([e,t],n)=>{const o=t.slice(0,Math.max(0,i-p));p+=o.length;const r=o.map((e,t)=>m(e,1e5*n+t,3));return t.length>o.length&&r.push({id:"more-"+VL(e),role:"datum",label:`…and ${t.length-o.length} more items`,level:3}),{id:"group-"+VL(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:r}})}else{const e=o.slice(0,i);h.children=e.map((e,t)=>m(e,t,2)),o.length>e.length&&h.children.push({id:"more",role:"datum",label:`…and ${o.length-e.length} more items`,level:2})}return h}function UL(e,t,n={}){const o=n.locale??"en",r=Math.max(1,n.maxLeaves??200),i=OL(o),a=jT(e,t,n.recipe);if(a)return XL(a,t,{maxLeaves:r,locale:o});const s={id:"root",role:"chart",label:GL(e,t,{locale:o}).text||"Chart.",level:1,children:[]},c=function(e,t){const n=Array.isArray(e.annotations)?e.annotations:null;if(!n)return null;const o=xL(n.filter(e=>!!e&&"object"==typeof e));if(0===o.length)return null;let r=0;const i=o.slice(0,t).map(e=>{const t=e.lifecycle?.status,n=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+r++,role:"annotation",level:3,label:`${o=HL(e),o?o.charAt(0).toUpperCase()+o.slice(1):o}${n}.`,datum:e};var o});o.length>t&&i.push({id:"annotation-"+r++,role:"annotation",level:3,label:`…and ${o.length-t} more annotations.`});const a=o.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===a?"one marked feature":a+" marked features"}.`,children:i}}(t,r),l=Array.isArray(t.data)?t.data:null,u=ZT.has(e)||JT.has(e)||eL.has(e)||tL.has(e);if(!l||0===l.length||!u)return c&&(s.children=[c]),s;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=nL(e,t),f=re(d,h),y=ie(p,m),g="string"==typeof d&&d?d:h,b="string"==typeof p&&p?p:m,v=oL(t);let x=0;const w=e=>`${e}-${x++}`,k=(e,t)=>{const n=e.slice(0,r).map(e=>((e,t)=>{const n=f(e),o=rL(y(e),i);return{id:w("datum"),role:"datum",level:t,label:`${o}: ${Number.isFinite(n)?i(n):"—"}`,value:Number.isFinite(n)?n:void 0,datum:e}})(e,t));return e.length>r&&n.push({id:w("more"),role:"datum",level:t,label:`…and ${e.length-r} more points`}),n},S=[];if(ZT.has(e)||JT.has(e)){let t=1/0,n=-1/0,o=1/0,r=-1/0;const a=[];let s=!0;for(const e of l){const i=f(e);Number.isFinite(i)&&(t>i&&(t=i),i>n&&(n=i));const c=y(e);a.push(c),"number"==typeof c&&Number.isFinite(c)?(o>c&&(o=c),c>r&&(r=c)):s=!1}const c=new Set,u=[];for(const e of a){const t=e+"";c.has(t)||(c.add(t),u.push(e))}const d=s?`${i(o)} to ${i(r)}`:`${rL(u[0],i)} to ${rL(u[u.length-1],i)} (${JT.has(e)?u.length+" categories":l.length+" points"})`;S.push({id:w("axis"),role:"axis",level:2,label:`${JT.has(e)?"Category axis":"X axis"}: ${b}, ${d}.`}),t>n||S.push({id:w("axis"),role:"axis",level:2,label:`Value axis: ${g}, ${i(t)} to ${i(n)}.`})}if(v){const n=ie(v,v),r=new Map;for(const e of l){const t=(n(e)??"—")+"",o=r.get(t);o?o.push(e):r.set(t,[e])}const i=[];for(const[n,a]of r){const r=GL(e,{...t,data:a},{levels:["l2","l3"],locale:o}).text;i.push({id:w("series"),role:"series",level:2,label:`Series ${n}: ${r}`,children:k(a,3)})}s.children=[...S,...i]}else s.children=[...S,...k(l,2)];return c&&s.children.push(c),s}function KL(e,t){const n=[],o=e=>{if(n.push(e),e.children&&e.children.length>0&&t.has(e.id))for(const t of e.children)o(t)};return o(e),n}function QL(e){let t=1;if(e.children)for(const n of e.children)t+=QL(n);return t}import*as ZL from"react";var JL=null,eN=new Set,tN=new Set,nN=1e3;function oN(e,t,n){const o=e??t;if(!Number.isFinite(o)||0>=o)throw new RangeError(`${n} must be a positive number, got ${o+""}`);return Math.floor(o)}function rN(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function iN(e,t){try{const n=t();n&&"function"==typeof n.then&&Promise.resolve(n).catch(t=>rN(e,t))}catch(t){rN(e,t)}}function aN(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function sN(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 rN("localStorage load",e),[]}}(e.getItem(t))}catch(e){return rN("localStorage read",e),[]}}var cN=Object.freeze([]),lN=cN,uN=!1;function dN(){return uN?(lN=JL?Object.freeze(JL.buffer.slice()):cN,uN=!1,lN):lN}function hN(){uN=!0}var pN=new Set;function mN(){for(const e of pN)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function fN(e){return pN.add(e),()=>{pN.delete(e)}}function yN(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return tN.add(e),()=>{tN.delete(e)}}function gN(e={}){const t=e.key??"semiotic:conversation-arc",n=oN(e.maxEvents,nN,"createLocalStorageConversationArcSink: maxEvents");return{record(o){const r=aN(e.storage),i=sN(r,t);i.push(o),function(e,t,n,o){if(e)try{e.setItem(t,JSON.stringify(n.slice(-o)))}catch(e){rN("localStorage write",e)}}(r,t,i,n)},clear(){const n=aN(e.storage);if(n)try{n.removeItem(t)}catch(e){rN("localStorage clear",e)}},load:()=>sN(aN(e.storage),t)}}function bN(e={}){const t=e.dbName??"semiotic-conversation-arc",n=e.storeName??"events",o=oN(e.maxEvents,nN,"createIndexedDBConversationArcSink: maxEvents");let r=null;const i=()=>(r??(r=function(e,t,n){const o=function(e){if(e)return e;try{return globalThis.indexedDB??null}catch{return null}}(n);return o?new Promise(n=>{let r;try{r=o.open(e,1)}catch(e){return rN("IndexedDB open",e),void n(null)}r.onupgradeneeded=()=>{const e=r.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id",autoIncrement:!0})},r.onsuccess=()=>n(r.result),r.onerror=()=>{rN("IndexedDB open",r.error),n(null)},r.onblocked=()=>{rN("IndexedDB open",Error("upgrade blocked")),n(null)}}):Promise.resolve(null)}(t,n,e.indexedDB)),r);return{async record(e){const t=await i();t&&(await new Promise(o=>{try{const r=t.transaction(n,"readwrite");r.objectStore(n).add({event:e}),r.oncomplete=()=>o(),r.onerror=()=>{rN("IndexedDB record",r.error),o()}}catch(e){rN("IndexedDB record",e),o()}}),await function(e,t,n){return e?new Promise(o=>{try{const r=e.transaction(t,"readwrite"),i=r.objectStore(t),a=i.getAll();a.onsuccess=()=>{const e=Array.isArray(a.result)?a.result:[],t=e.length-n;if(t>0)for(const n of e.slice(0,t))null!=n.id&&i.delete(n.id)},a.onerror=()=>rN("IndexedDB trim",a.error),r.oncomplete=()=>o(),r.onerror=()=>{rN("IndexedDB trim",r.error),o()}}catch(e){rN("IndexedDB trim",e),o()}}):Promise.resolve()}(t,n,o))},async clear(){const e=await i();e&&await new Promise(t=>{try{const o=e.transaction(n,"readwrite");o.objectStore(n).clear(),o.oncomplete=()=>t(),o.onerror=()=>{rN("IndexedDB clear",o.error),t()}}catch(e){rN("IndexedDB clear",e),t()}})},load:async()=>function(e,t){return e?new Promise(n=>{try{const o=e.transaction(t,"readonly").objectStore(t).getAll();o.onsuccess=()=>{n((Array.isArray(o.result)?o.result:[]).map(e=>e.event).filter(Boolean))},o.onerror=()=>{rN("IndexedDB load",o.error),n([])}}catch(e){rN("IndexedDB load",e),n([])}}):Promise.resolve([])}(await i(),n)}}function vN(e){if(!e.url)throw new TypeError("createWebhookConversationArcSink: url is required");const t=e.method??"POST";return{record(n){const o=e.fetch??globalThis.fetch;if(!o)return;const r=e.mapEvent?e.mapEvent(n):n;return o(e.url,{method:t,headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify(r)}).then(()=>{})}}}function xN(e,t={}){const n=Array.isArray(e)?e.slice():[],o=oN(t.capacity,Math.max(JL?.capacity??nN,n.length,1),"loadConversationArc: capacity"),r=t.sessionId??n[0]?.sessionId??JL?.sessionId??AN();for(JL?(JL.enabled=t.enabled??!1,JL.sessionId=r,JL.capacity=o):JL={enabled:t.enabled??!1,sessionId:r,capacity:o,buffer:[]},t.append||(JL.buffer=[]),JL.buffer.push(...n);JL.buffer.length>JL.capacity;)JL.buffer.shift();return hN(),mN(),dN()}function wN(e,t={}){return xN(e,t)}function kN(e,t,n){return RN.record({type:"audience-set",audience:e,previous:t??void 0,...n})}function SN(e,t){return RN.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function AN(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function CN(){return JL}function MN(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(JL){if(JL.enabled=!0,e.sessionId&&(JL.sessionId=e.sessionId),null!=e.capacity){for(JL.capacity=t;JL.buffer.length>JL.capacity;)JL.buffer.shift();hN()}}else JL={enabled:!0,sessionId:e.sessionId??AN(),capacity:t,buffer:[]},hN();return mN(),RN}function PN(){JL&&(JL.enabled=!1,mN())}function IN(){return RN}var RN={get enabled(){return JL?.enabled??!1},get sessionId(){return JL?.sessionId??null},get capacity(){return JL?.capacity??0},record(e){const t=CN();if(!t||!t.enabled)return null;const n={...e,timestamp:e.timestamp??Date.now(),sessionId:e.sessionId??t.sessionId};for(t.buffer.push(n);t.buffer.length>t.capacity;)t.buffer.shift();hN(),mN();for(const e of eN)try{e(n)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of tN)t.record&&iN("sink record",()=>t.record?.(e))}(n),n},flush(){const e=CN();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],hN(),mN(),function(e){for(const t of tN)t.flush&&iN("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>dN(),subscribe:e=>(eN.add(e),()=>{eN.delete(e)}),clear(){const e=CN();e&&(e.buffer=[],hN(),mN()),function(){for(const e of tN)e.clear&&iN("sink clear",()=>e.clear?.())}()},reset(){if(eN.clear(),tN.clear(),lN=cN,uN=!1,!JL)return mN(),void pN.clear();JL.buffer=[],JL.enabled=!1,JL=null,mN(),pN.clear()}};import{jsx as _N,jsxs as TN}from"react/jsx-runtime";var LN={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function NN({tree:e,label:t,visible:n=!1,className:o,onActiveChange:r,activeId:i,chartId:a,onObservation:s,onAnnotationActivate:c}){const[l,u]=ZL.useState(()=>new Set([e.id])),[d,h]=ZL.useState(e.id),p=void 0!==i,m=p?i:d,f=ZL.useRef(null),y=ZL.useRef(new Map),g=gi(e=>e.pushObservation),b=ZL.useCallback(e=>{s?.(e),g?.(e)},[s,g]),v=ZL.useMemo(()=>function(e){const t=new Map,n=e=>{for(const o of e.children??[])t.set(o.id,e),n(o)};return n(e),t}(e),[e]),x=ZL.useMemo(()=>KL(e,l),[e,l]);ZL.useEffect(()=>{p||x.some(e=>e.id===d)||h(e.id)},[x,d,e.id,p]),ZL.useEffect(()=>{const e=[];let t=v.get(m);for(;t;)e.push(t.id),t=v.get(t.id);e.length>0&&u(t=>{if(e.every(e=>t.has(e)))return t;const n=new Set(t);for(const t of e)n.add(t);return n})},[m,v]),ZL.useEffect(()=>{f.current?.contains(document.activeElement)&&y.current.get(m)?.focus()},[m]);const w=ZL.useCallback((e,t,n)=>{const o=IN();o.enabled&&o.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:!!n})},[a]),k=ZL.useCallback(e=>{e.id!==m&&(p||h(e.id),r?.(e),w(e,"focus"),e.datum&&b({type:"focus",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a}))},[r,p,w,m,b,a]),S=ZL.useCallback(e=>{if(e.datum){if("annotation"===e.role){const t=vi(e.datum);return c?.({annotation:e.datum,annotationId:t,chartId:a,inputType:"navigation-tree"}),void(t&&b({type:"annotation-activate",annotationId:t,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a}))}b({type:"activate",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a})}},[a,b,c]),A=e=>{u(t=>new Set(t).add(e.id)),w(e,"toggle",!0)},C=e=>{u(t=>{const n=new Set(t);return n.delete(e.id),n}),w(e,"toggle",!1)},M=(e,t,o)=>{const r=!!e.children&&e.children.length>0,i=l.has(e.id);return TN("li",{role:"treeitem","aria-label":e.label,"aria-level":e.level,"aria-posinset":t,"aria-setsize":o,"aria-expanded":r?i:void 0,"aria-selected":e.id===m,tabIndex:e.id===m?0:-1,ref:t=>{y.current.set(e.id,t)},onClick:t=>{t.stopPropagation(),k(e),r?(i?C:A)(e):S(e)},style:n?{listStyle:"none",padding:"2px 6px",paddingLeft:6+16*(e.level-1),cursor:r?"pointer":"default",fontSize:13,color:"var(--semiotic-text, currentColor)",background:e.id===m?"var(--semiotic-surface, var(--semiotic-grid, var(--semiotic-bg, #f0f4f8)))":"transparent",outline:"none"}:void 0,children:[TN("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[n&&r?i?"▾ ":"▸ ":"",e.label]}),r&&i&&_N("ul",{role:"group",style:n?{margin:0,padding:0}:void 0,children:e.children.map((t,n)=>M(t,n+1,e.children.length))})]},e.id)};return _N("div",{ref:f,className:"semiotic-nav-tree"+(o?" "+o:""),style:n?void 0:LN,onKeyDown:e=>{const t=x.findIndex(e=>e.id===m);if(-1===t)return;const n=x[t],o=!!n.children&&n.children.length>0,r=l.has(n.id);let i=!0;switch(e.key){case"ArrowDown":k(x[Math.min(t+1,x.length-1)]);break;case"ArrowUp":k(x[Math.max(t-1,0)]);break;case"Home":k(x[0]);break;case"End":k(x[x.length-1]);break;case"ArrowRight":o&&!r?A(n):o&&r?k(n.children[0]):i=!1;break;case"ArrowLeft":if(o&&r)C(n);else{const e=v.get(n.id);e?k(e):i=!1}break;case"Enter":case" ":o?(r?C:A)(n):S(n);break;default:i=!1}i&&(e.preventDefault(),e.stopPropagation())},children:_N("ul",{role:"tree","aria-label":t||"Chart navigation",style:n?{margin:0,padding:0}:void 0,children:M(e,1,1)})})}import*as $N from"react";import{jsx as BN,jsxs as DN}from"react/jsx-runtime";function jN(e,t,n=0){const o=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=Math.max(o,Math.min(r,e[0])),a=Math.max(o,Math.min(r,e[1])),s=i>a?[a,i]:[i,a];if(s[1]-s[0]>=n)return s;const c=(s[0]+s[1])/2,l=n/2;return[Math.max(o,Math.min(r-n,c-l)),Math.min(r,Math.max(o+n,c+l))]}function EN(e,t,n,o=1,r=o){const i="in"===n?o:-o;return jN([e[0]+i,e[1]-i],t,r)}function FN(e){const{domain:t,initialValue:n=t,step:o=1,minSpan:r=o,label:i,formatValue:a,onChange:s}=e,[c,l]=$N.useState(()=>jN(n,t,r)),u=jN(c,t,r),d=$N.useCallback(e=>{const n=jN(e,t,r);l(n),s?.(n)},[t,r,s]),h=$N.useMemo(()=>({label:i,domain:t,value:u,step:o,formatValue:a,onChange:d,onClear:()=>d(t)}),[t,a,i,d,o,u]),p=$N.useMemo(()=>({onZoomIn:()=>d(EN(u,t,"in",o,r)),onZoomOut:()=>d(EN(u,t,"out",o,r)),onReset:()=>d(t)}),[t,r,d,o,u]);return{value:u,setValue:d,xExtent:u,brush:h,zoom:p}}var ON={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)))"},zN={fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #57606a)"};function HN(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 WN(e){return"function"==typeof e}function GN({brush:e,targetSize:t}){const n=e?.value,o=e?.domain,r=!!n&&!!o,i=!0===e?.disabled,a=e?.formatValue??(e=>e),s=!!e?.onChange&&r&&!i,c=o?.[0]??0,l=o?.[1]??1,u=n?.[0]??c,d=n?.[1]??l,h=e?.step??((l-c)/100||1);return DN("section",{style:ON,"aria-label":"Brush controls",children:[BN("div",{style:zN,children:e?.label??"Filter range"}),r?DN("div",{style:{display:"grid",gap:8},children:[DN("label",{style:{display:"grid",gap:4,fontSize:12},children:[DN("span",{children:["Start: ",a(u)]}),BN("input",{type:"range",min:c,max:l,step:h,value:u,disabled:!s,style:{minHeight:t},onChange:t=>{const n=Number(t.currentTarget.value);e?.onChange?.([Math.min(n,d),d])}})]}),DN("label",{style:{display:"grid",gap:4,fontSize:12},children:[DN("span",{children:["End: ",a(d)]}),BN("input",{type:"range",min:c,max:l,step:h,value:d,disabled:!s,style:{minHeight:t},onChange:t=>{const n=Number(t.currentTarget.value);e?.onChange?.([u,Math.max(n,u)])}})]})]}):BN("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."}),BN("button",{type:"button",disabled:i||!WN(e?.onClear),onClick:e?.onClear,style:HN(t),children:"Clear range"})]})}function qN({zoom:e,targetSize:t}){const n=!0===e?.disabled;return DN("section",{style:ON,"aria-label":"Zoom controls",children:[BN("div",{style:zN,children:e?.label??"Zoom"}),DN("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[BN("button",{type:"button","aria-label":"Zoom out",disabled:n||!WN(e?.onZoomOut),onClick:e?.onZoomOut,style:HN(t),children:"-"}),BN("button",{type:"button","aria-label":"Reset zoom",disabled:n||!WN(e?.onReset),onClick:e?.onReset,style:HN(t),children:"Reset"}),BN("button",{type:"button","aria-label":"Zoom in",disabled:n||!WN(e?.onZoomIn),onClick:e?.onZoomIn,style:HN(t),children:"+"})]})]})}function YN({legend:e,targetSize:t}){const n=!0===e?.disabled,o=e?.items??[];return DN("section",{style:ON,"aria-label":"Legend controls",children:[BN("div",{style:zN,children:e?.label??"Series"}),o.length>0&&BN("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(o=>{const r=!1!==o.active;return DN("button",{type:"button",disabled:n||o.disabled||!e?.onToggle,onClick:()=>e?.onToggle?.(o.id,!r),style:HN(t,r),"aria-pressed":r,children:[o.color&&BN("span",{"aria-hidden":"true",style:{display:"inline-block",width:9,height:9,marginRight:6,borderRadius:999,background:o.color}}),o.label??o.id]},o.id)})}),DN("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[BN("button",{type:"button",disabled:n||!WN(e?.onShowAll),onClick:e?.onShowAll,style:HN(t),children:"Show all"}),BN("button",{type:"button",disabled:n||!WN(e?.onHideAll),onClick:e?.onHideAll,style:HN(t),children:"Hide all"})]})]})}function VN({controls:e,targetSize:t=44,compact:n=!1,className:o,style:r,ariaLabel:i="Mobile chart controls",brush:a,zoom:s,legend:c}){const l=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 n=[];return t.brush&&n.push("brush"),t.zoom&&n.push("zoom"),t.legend&&n.push("legend"),n}(e,{brush:a,zoom:s,legend:c});return 0===l.length?null:DN("div",{className:o,role:"group","aria-label":i,style:{display:"grid",gridTemplateColumns:n?"1fr":"repeat(auto-fit, minmax(180px, 1fr))",gap:10,...r},children:[l.includes("brush")&&BN(GN,{brush:a,targetSize:t}),l.includes("zoom")&&BN(qN,{zoom:s,targetSize:t}),l.includes("legend")&&BN(YN,{legend:c,targetSize:t})]})}var XN=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),UN=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),KN={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function QN(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ZN(e){return"string"==typeof e&&e.trim().length>0}function JN(e){const t=QN(e.capability)?e.capability:null,n=QN(e.recipe)?e.recipe:null,o=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,n?.mobile];for(const e of o)if(QN(e))return e;return null}function e$(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 t$(e){return e$(e.size)||e$(QN(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function n$(e,t){e.push({...t,status:"pass"})}function o$(e,t){e.push({...t,status:"warn"})}function r$(e,t){e.push({...t,status:"manual"})}function i$(e,t={},n={}){const o=n.viewportWidth??390,r=n.targetSize??44,i=t$(t),a=_d(t,{width:o,height:i?.[1]}),s=[],c=t$(t=a.props),l=JN(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=JN(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===n.inChartContainer,p=ZN(t.title)||ZN(t.summary)||ZN(t.description)||!0===l?.summary||ZN(l?.summary);if(a.matches.length>0&&n$(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${a.matches.length} responsive rule(s) applied for the ${o}px mobile audit.`}),c){const[t,n]=c;t>o&&!d?o$(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${o}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."}):n$(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof l?.minViewportWidth&&l.minViewportWidth>o&&o$(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${l.minViewportWidth}px minimum, wider than the audited ${o}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const r=t/Math.max(1,n);430>=o&&r>2.4&&"BigNumber"!==e&&o$(s,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${r.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>n&&"BigNumber"!==e&&o$(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${n}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 r$(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,QN(e.frameProps)?e.frameProps.data:void 0];let n=0;for(const e of t)Array.isArray(e)&&(n+=e.length);return n}(t);m>0&&(m>("number"==typeof l?.maxMarks?l.maxMarks:XN.has(e)?1.25*o:UN.has(e)?Math.max(8,Math.floor(o/34)):o)?o$(s,{id:"density.mark-budget",category:"density",impact:XN.has(e)?"medium":"high",message:`${m} data item(s) exceed the rough mobile density budget for ${e} at ${o}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):n$(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 n=0;for(const e of t)Array.isArray(e)&&(n+=e.length);return n>0?n:null}(t),y=!1!==t.showAxes&&!1!==t.axis;if(y&&null!=f){const e=Math.max(3,Math.floor(o/58));f>e&&o$(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${f} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${o}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else y&&(XN.has(e)||UN.has(e))&&r$(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=QN(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=JN(e),n=QN(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===n?.tapToSelect||!0===n?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||ZN(t?.interaction?.hoverFallback)}(e)}(t)?n$(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):o$(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 g=function(e,t){const n=KN[e];if(!n)return null;let o=n.includes("hoverRadius")?30:null;for(const e of n){const n=t[e];"number"==typeof n&&Number.isFinite(n)&&n>0&&(o=null==o?n:Math.max(o,n))}return null==o?null:2*o}(e,t),b=QN(t.mobileInteraction)?t.mobileInteraction:null,v=g??("number"==typeof b?.targetSize?b.targetSize:!0===t.mobileInteraction?44:"number"==typeof l?.minimumHitTarget?l.minimumHitTarget:"number"==typeof l?.interaction?.targetSize?l.interaction.targetSize:null);null!=v&&(24>v?o$(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."}):r>v?o$(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}px, above 24px but below the ${r}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):n$(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${v}px, meeting the configured ${r}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 n=JN(e),o=QN(e.mobileInteraction)?e.mobileInteraction:null,r=o?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(n?.interaction?.alternatives)&&n.interaction.alternatives.length>0)||!0===r||"all"===r||t.every(e=>"brush"===e?Array.isArray(r)?r.includes("brush"):"brush"===r:"pan/zoom"===e?Array.isArray(r)?r.includes("zoom"):"zoom"===r:"legend filtering"===e&&(Array.isArray(r)?r.includes("legend"):"legend"===r))}(t,x)&&o$(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"===l?.labels?.strategy||"inline"===l?.labels?.strategy||"external"===l?.labels?.strategy||o>430||o$(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=>QN(e)):[];if(w.length>("number"==typeof l?.maxAnnotations?l.maxAnnotations:3)&&430>=o&&o$(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=>!ZN(e.mobileText)&&!ZN(e.shortText)&&!ZN(e.label));e.length>0&&r$(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||r$(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&&(l?(n$(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===l.custom?.dataBearingSceneNodes?o$(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!==l.custom?.dataBearingSceneNodes&&r$(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."})):r$(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||o$(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:o,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 a$={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},s$=["layout","density","interaction","annotation","semantics"];function c$(e){const t=[],n=e.summary,o=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${n.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${o} - ${n.warnings} warning(s) - ${n.manual} manual check(s)`);for(const n of s$){const o=e.findings.filter(e=>e.category===n&&"not-applicable"!==e.status);if(0!==o.length){t.push(""),t.push(" "+n.toUpperCase());for(const e of o)t.push(` ${a$[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 l$(){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."]}function u$(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function d$(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function h$(e){return Array.isArray(e)?e.length>0:!!e}import{Fragment as p$,jsx as m$,jsxs as f$}from"react/jsx-runtime";var y$={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function g$(){const e=function(){const e=ss.useContext(ls);return e?e.toggle:null}();return e?m$("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:P$,children:f$("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m$("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),m$("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),m$("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var b$={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)"},v$={error:4,warning:3,info:2,success:1,neutral:0};function x$({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 f$("svg",{...t,children:[m$("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),m$("path",{d:"M8 6.4v3.4"}),m$("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return f$("svg",{...t,children:[m$("circle",{cx:"8",cy:"8",r:"6.4"}),m$("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return f$("svg",{...t,children:[m$("circle",{cx:"8",cy:"8",r:"6.4"}),m$("path",{d:"M8 7.4V11"}),m$("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return f$("svg",{...t,children:[m$("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"}),m$("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function w$({notification:e,level:t,onDismiss:n}){const o=b$[t]??b$.info,r=!1!==e.dismissible;return f$("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 "+o,background:"var(--semiotic-surface, rgba(127, 127, 127, 0.08))"},children:[f$("div",{style:{flex:1,minWidth:0},children:[e.source&&m$("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&&m$("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:o},children:e.title}),m$("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),r&&m$("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:n,style:{...P$,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function k$({visible:e,onDismiss:t}){const[n,o]=iT.useState(!1),r=iT.useRef(null),i=iT.useRef(null);if(iT.useEffect(()=>{0===e.length&&n&&o(!1)},[e.length,n]),iT.useEffect(()=>{if(!n)return;const e=e=>{r.current&&!r.current.contains(e.target)&&o(!1)},t=e=>{"Escape"===e.key&&(o(!1),i.current?.focus())};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n]),0===e.length)return null;const a=e.reduce((e,t)=>v$[t.level]>v$[e]?t.level:e,e[0].level),s=b$[a]??b$.info,c=e.length,l=`${c} chart notification${1===c?"":"s"}, most severe: ${a}`;return f$("div",{ref:r,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[m$("span",{style:y$,role:"status","aria-live":"polite",children:l}),f$("button",{ref:i,className:"semiotic-chart-action semiotic-chart-notifications-toggle","aria-haspopup":"dialog","aria-expanded":n,"aria-label":`${l}. ${n?"Hide":"Show"} notifications`,title:l,onClick:()=>o(e=>!e),style:{...P$,color:s,position:"relative"},children:[m$(x$,{level:a}),m$("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:c>99?"99+":c})]}),n&&m$("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=>m$(w$,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var S$={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 A$({height:e}){return m$("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 C$({error:e}){return m$("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:m$("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var M$=iT.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:a,describe:s,navigable:c,controls:l,banner:u,notifications:d,onNotificationDismiss:h,loading:p=!1,error:m,errorBoundary:f=!1,status:y,detailsPanel:g,mobile:b,mobileAudit:v,className:x,style:w},k){const S=iT.useRef(null),A=iT.useRef(null),[C,M]=iT.useState(!1),[P,I]=iT.useState(()=>new Set);iT.useEffect(()=>{I(e=>{if(0===e.size)return e;const t=new Set((d??[]).map((e,t)=>e.id??t+""));let n=!1;const o=new Set;for(const r of e)t.has(r)?o.add(r):n=!0;return n?o:e})},[d]);const R=iT.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]),_=iT.useCallback(e=>{I(t=>new Set(t).add(e.key)),h?.(e.notification,e.index)},[h]),T=!1!==i?.export&&void 0!==i?.export,L=!1!==i?.fullscreen&&void 0!==i?.fullscreen,N=!1!==i?.copyConfig&&void 0!==i?.copyConfig&&a,$=!0===i?.dataSummary,B=iT.useMemo(()=>{if(!s||!a?.component||!a?.props)return"";const e="object"==typeof s?s.levels:void 0;try{return GL(a.component,a.props,e?{levels:e}:{}).text}catch{return""}},[s,a]),D="object"==typeof s&&!0===s.visible,j=iT.useMemo(()=>{if(!c||!a?.component||!a?.props)return null;const e="object"==typeof c?c.maxLeaves:void 0;try{return UL(a.component,a.props,e?{maxLeaves:e}:{})}catch{return null}},[c,a]),E="object"==typeof c&&!0===c.visible,F=iT.useMemo(()=>"object"==typeof i?.export?i.export:{},[i?.export]),O="object"==typeof i?.copyConfig?i.copyConfig.format:"json",z=iT.useCallback(async e=>{A.current&&await nT(A.current,{...F,...e})},[F]),H=iT.useCallback(()=>{S.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):S.current.requestFullscreen().catch(()=>{}))},[]),W=iT.useCallback(async e=>{a&&await KT({...a,version:a.version??"1",createdAt:a.createdAt??(new Date).toISOString()},e||O||"json")},[a,O]);iT.useEffect(()=>{const e=()=>{M(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),iT.useImperativeHandle(k,()=>({export:z,toggleFullscreen:H,copyConfig:W,element:S.current}),[z,H,W]);const G=!0===b?{}:b&&"object"==typeof b?b:null,q=!!b,Y=G?.breakpoint??480,V=void 0===G?.chartMode?"mobile":G.chartMode,X=G?.semantics,U=G?.mobileInteraction??(!!q||void 0),K=G?.standardControls,Q=u$(K)?K:null,Z=Q?.controls??(u$(K)?void 0:K)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(U),J=iT.useMemo(()=>function(e,t){return h$(t)?e&&"object"==typeof e?{...e,standardControls:t}:!1===e||null==e?e:{standardControls:t}:e}(U,Z),[U,Z]),ee=q&&h$(Z)?m$(VN,{controls:Z,targetSize:Q?.targetSize??d$(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=G?.summary,ne=!0===G?.allowHorizontalScroll,oe=!0===G?.hideToolbar,re=iT.useMemo(()=>{if(!v||!a?.component||!a?.props)return null;const e="object"==typeof v?v:{},t=a.props;try{return i$(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]);iT.useEffect(()=>{if(!re||re.ok)return;const e=re.findings.filter(e=>"pass"!==e.status).slice(0,5);console.warn(`[Semiotic mobile audit] ${a?.component}: ${re.summary.highRisk} high-risk mobile finding(s), ${re.summary.warnings} warning(s).`,e)},[re,a?.component]);const ie=re&&!re.ok&&"object"==typeof v&&!0===v.visible?f$("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: ",re.summary.highRisk," high-risk finding",1===re.summary.highRisk?"":"s"," and"," ",re.summary.warnings," warning",1===re.summary.warnings?"":"s"," at"," ",("object"==typeof v?v.viewportWidth:void 0)??390,"px."]}):null,ae=R.length>0,se=e||t||l||T||L||N||$||y||ae,ce=iT.useMemo(()=>{if(!q||!iT.isValidElement(n))return n;if(!function(e){const t=e.type;return"function"==typeof t||"object"==typeof t&&null!==t}(n))return n;const e=n.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?iT.cloneElement(n,t):n},[n,q,V,X,J]),le=p?m$(A$,{height:r}):m?m$(C$,{error:m}):f?m$(eh,{children:ce}):ce;return ue=f$(p$,{children:[m$("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}`}}),f$("div",{ref:S,className:"semiotic-chart-container"+(x?" "+x:""),"data-semiotic-mobile":q?"true":void 0,"data-semiotic-mobile-scroll":ne?"true":void 0,"data-semiotic-mobile-hide-toolbar":oe?"true":void 0,style:{width:o,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&&f$("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:[f$("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[e&&m$("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:e}),t&&m$("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0},children:t})]}),f$("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[l,ae&&m$(k$,{visible:R,onDismiss:_}),T&&m$("button",{className:"semiotic-chart-action",onClick:()=>z(),title:"Export chart","aria-label":"Export chart",style:P$,children:f$("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m$("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),m$("path",{d:"M2 12h10"})]})}),$&&m$(g$,{}),L&&m$("button",{className:"semiotic-chart-action",onClick:H,title:C?"Exit fullscreen":"Fullscreen","aria-label":C?"Exit fullscreen":"Enter fullscreen",style:P$,children:m$("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:f$(p$,C?{children:[m$("path",{d:"M9 1v4h4"}),m$("path",{d:"M5 13V9H1"}),m$("path",{d:"M13 5H9V1"}),m$("path",{d:"M1 9h4v4"})]}:{children:[m$("path",{d:"M1 5V1h4"}),m$("path",{d:"M13 9v4H9"}),m$("path",{d:"M9 1h4v4"}),m$("path",{d:"M5 13H1V9"})]})})}),N&&m$("button",{className:"semiotic-chart-action",onClick:()=>W(),title:"Copy config","aria-label":"Copy chart configuration",style:P$,children:f$("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[m$("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),m$("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),y&&m$("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:S$[y].bg,color:S$[y].color,lineHeight:"18px"},children:y})]})]}),u&&m$("div",{className:"semiotic-chart-banner",children:u}),ie,te&&m$("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&&m$("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&&m$("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)"}:y$,children:B}),j&&m$("div",{className:"semiotic-chart-nav",style:E?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:m$(NN,{tree:j,label:"string"==typeof e&&e?e+" — navigable structure":"Chart navigable structure",visible:E,chartId:"string"==typeof a?.props?.chartId?a.props.chartId:void 0})}),f$("div",{className:"semiotic-chart-body",ref:A,style:{position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",...C?{flex:1}:{height:r}},children:[le,g]})]})]}),$?m$(us,{children:ue}):ue;var ue}),P$={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 I$ from"react";import{jsx as R$,jsxs as _$}from"react/jsx-runtime";function T$({children:e,controls:t,mobile:n,breakpoint:o=480,chartMode:r="mobile",mobileInteraction:i=!0,mobileSemantics:a,mobileSummary:s,chips:c=[],activeChip:l,onChipChange:u,detail:d,detailTitle:h="Details",detailMode:p="sheet",initialDetailOpen:m=!1,allowHorizontalScroll:f=!1,hideToolbar:y=!1,chartDefaults:g,...b}){const[v,x]=I$.useState(()=>l??c.find(e=>!e.disabled)?.id),[w,k]=I$.useState(m);I$.useEffect(()=>{void 0===l&&(c.length?c.some(e=>e.id===v&&!e.disabled)||x(c.find(e=>!e.disabled)?.id):x(void 0))},[l,c,v]);const S=l??v,A=I$.useCallback(e=>{e.disabled||(void 0===l&&x(e.id),u?.(e))},[l,u]),C=c.length?R$("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:c.map(e=>_$("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:[R$("span",{children:e.label}),e.description&&R$("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,M=s||C?_$("div",{className:"semiotic-mobile-summary-card",children:[s&&R$("div",{className:"semiotic-mobile-summary-copy",children:s}),C]}):n?.summary,P={breakpoint:o,chartMode:r,mobileInteraction:i,semantics:a,allowHorizontalScroll:f,hideToolbar:y,...n,summary:M},I=I$.useMemo(()=>{if(!g||!I$.isValidElement(e))return e;const t=e.props,n={};for(const[e,o]of Object.entries(g))null==t[e]&&(n[e]=o);return Object.keys(n).length>0?I$.cloneElement(e,n):e},[e,g]),R=!!d&&"sheet"===p,_=!!d&&"inline"===p||R&&w,T=R?R$("button",{type:"button",className:"semiotic-mobile-detail-toggle","aria-expanded":w,onClick:()=>k(e=>!e),children:w?"Hide details":"Show details"}):null,L=t||T?_$("div",{className:"semiotic-mobile-control-stack",children:[t,T]}):void 0;return _$("div",{className:"semiotic-mobile-chart-shell",children:[R$("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: ${o}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 `}),R$(M$,{...b,controls:L,mobile:P,children:I}),_&&_$("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof h?h:"Chart details",children:[_$("div",{className:"semiotic-mobile-detail-header",children:[R$("span",{children:h}),R&&R$("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),R$("div",{className:"semiotic-mobile-detail-body",children:d})]})]})}import*as L$ from"react";import{jsx as N$,jsxs as $$}from"react/jsx-runtime";function B$(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function D$(e,t){const n="function"==typeof t?t(e):e[t];return Array.isArray(n)?n:[]}function j$(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 E$(e,t){if(!L$.isValidElement(e))return e;const n=e.props,o={};for(const[e,r]of Object.entries(t))void 0!==r&&null==n[e]&&(o[e]=r);return Object.keys(o).length>0?L$.cloneElement(e,o):e}function F$({items:e,children:t,columns:n=3,tabletColumns:o=2,mobileColumns:r=1,mobileBreakpoint:i=480,tabletBreakpoint:a=860,gap:s=12,mode:c="mobile",chartHeight:l=220,sharedExtent:u=!0,valueAccessor:d,dataAccessor:h="data",extentProps:p=["yExtent","valueExtent"],linkedHover:m,selection:f,linkedBy:y,linkProvider:g="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:R}){const _=od(),T=e||"function"==typeof t?[]:L$.Children.toArray(t),L=e??T.map((e,t)=>({id:"panel-"+(t+1)})),N=L.length,$=L$.useMemo(()=>function(e,t,n,o){if(t&&"object"==typeof t)return t;if(!1===t)return{};const r=[],i=[];for(const t of e)if(t.extent&&r.push(t.extent[0],t.extent[1]),o)for(const e of D$(t,n))i.push(B$(e,o));const a=function(e){let t=1/0,n=-1/0;for(const o of e){const e=Number(o);Number.isFinite(e)&&(t>e&&(t=e),e>n&&(n=e))}if(Number.isFinite(t)&&Number.isFinite(n))return t===n?[t-1,n+1]:[t,n]}(i.length?i:r);return a?{yExtent:a,valueExtent:a}:{}}(L,u,h,d),[L,u,h,d]),B=L$.useMemo(()=>{if(!y)return{name:void 0,fields:void 0,linkedHover:m,selection:f};const e=Array.isArray(y)?"small-multiples":y.name||"small-multiples",t=Array.isArray(y)?y:y.fields||[];return{name:e,fields:t,linkedHover:m??{name:e,fields:t},selection:f??{name:e}}},[y,m,f]),D=L$.useMemo(()=>({linkedHover:B.linkedHover,selection:B.selection}),[B.linkedHover,B.selection]),j=L$.useMemo(()=>{const e={mode:c,height:l,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:C??j$(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},[c,l,A,C,N,D,P,M,p,$]),E=$$("section",{className:["semiotic-small-multiple-chart",I].filter(Boolean).join(" "),style:R,"data-semiotic-small-multiple":"true",children:[N$("style",{children:`\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${n};\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: ${o};\n }\n }\n @media (max-width: ${i}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${r};\n }\n .semiotic-small-multiple-panel {\n border-radius: 14px;\n }\n .semiotic-small-multiple-heading {\n padding: 9px 10px 0;\n }\n }\n `}),L.map((e,n)=>{const o={...j},r="function"==typeof t?t(e,{item:e,index:n,count:N,chartProps:o,sharedExtent:$}):T[n];return $$("article",{className:"semiotic-small-multiple-panel","aria-label":"string"==typeof e.title?e.title:void 0,children:[(e.title||e.subtitle||e.summary)&&$$("header",{className:"semiotic-small-multiple-heading",children:[e.title&&N$("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&N$("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&N$("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),N$("div",{className:"semiotic-small-multiple-plot",children:E$(r,o)})]},e.id??n)})]});return!0===g||"auto"===g&&(y||m||f||b||!0===v)&&!_?N$(hd,{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 O$ from"react";import{Fragment as z$,jsx as H$,jsxs as W$}from"react/jsx-runtime";function G$({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,tabletColumns:r,mobileColumns:i=1,mobileBreakpoint:a=480,tabletBreakpoint:s=860,chartDefaults:c,className:l,style:u}){const d="semiotic-chart-grid-"+O$.useId().replace(/[^a-zA-Z0-9_-]/g,""),h="number"==typeof t?t:void 0,p="auto"===t?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${t}, 1fr)`,m=["semiotic-chart-grid",d,l].filter(Boolean).join(" ");return W$(z$,{children:[H$("style",{children:`\n ${r?`\n @media (max-width: ${s}px) {\n .${d} {\n grid-template-columns: repeat(${r}, 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 `}),H$("div",{className:m,style:{display:"grid",gridTemplateColumns:p,gap:o,width:"100%",...u},children:O$.Children.map(e,e=>{if(!O$.isValidElement(e))return e;const t=e.props,n={};if(c)for(const[e,o]of Object.entries(c))null==t[e]&&(n[e]=o);const o=Object.keys(n).length>0?O$.cloneElement(e,n):e;return"primary"!==e.props.emphasis||void 0!==h&&2>h?o:H$("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:o})})})]})}G$.displayName="ChartGrid";import*as q$ from"react";import{Fragment as Y$,jsx as V$,jsxs as X$}from"react/jsx-runtime";function U$({children:e,context:t,position:n="right",contextSize:o=250,mobilePosition:r="bottom",mobileBreakpoint:i=480,gap:a=12,className:s,style:c}){const l="semiotic-context-layout-"+q$.useId().replace(/[^a-zA-Z0-9_-]/g,""),u="left"===n||"right"===n,d="left"===n||"top"===n,h={display:"flex",flexDirection:u?d?"row-reverse":"row":d?"column-reverse":"column",gap:a,width:"100%",...c},p=u?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return X$(Y$,{children:[V$("style",{children:`\n @media (max-width: ${i}px) {\n .${l}[data-mobile-position="bottom"] {\n flex-direction: column !important;\n }\n .${l}[data-mobile-position="top"] {\n flex-direction: column-reverse !important;\n }\n .${l}[data-mobile-position="bottom"] > .semiotic-context-panel,\n .${l}[data-mobile-position="top"] > .semiotic-context-panel {\n flex: 0 0 auto !important;\n width: 100% !important;\n height: auto !important;\n }\n }\n `}),X$("div",{className:["semiotic-context-layout",l,s].filter(Boolean).join(" "),"data-mobile-position":r,style:h,children:[V$("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),V$("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}U$.displayName="ContextLayout";import{useState as K$,useEffect as Q$,useRef as Z$,useCallback as J$}from"react";import{jsx as eB,jsxs as tB}from"react/jsx-runtime";function nB({children:e,position:t="right",size:n=300,trigger:o="click",chartId:r,observation:i,dismissOnEmpty:a=!0,showClose:s=!0,onToggle:c,className:l,style:u}){const[d,h]=K$(null),[p,m]=K$(null),[f,y]=K$(!1),[g,b]=K$(!1),v=Z$(null),x=Z$(void 0),w="click"===o?["click","click-end"]:["hover","hover-end"],{latest:k}=Zu({types:w,chartId:r,limit:1}),S=void 0!==i?i:k,A=J$(()=>{b(!0),y(!1),clearTimeout(x.current),x.current=setTimeout(()=>{b(!1),h(null),m(null)},200)},[]);if(Q$(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;h(e.datum),m(e),y(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]),Q$(()=>{c?.(f)},[f,c]),Q$(()=>()=>clearTimeout(x.current),[]),!d&&!g)return null;const C=d&&p?e(d,p):null;if(null===C&&!g)return null;const M=function(e,t,n,o){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:o?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return"right"===e?{...r,top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{...r,bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{...r,top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"}}(t,n,f,g);return tB("div",{ref:v,className:`semiotic-details-panel semiotic-details-${t}${l?" "+l:""}`,style:{...M,...u},children:[s&&eB("button",{className:"semiotic-details-close",onClick:A,"aria-label":"Close details",style:oB,children:eB("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:eB("path",{d:"M2 2l8 8M10 2l-8 8"})})}),eB("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:C})]})}var oB={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};nB.displayName="DetailsPanel";var rB={BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["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"},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"},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"}}},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"},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"}}},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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"},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 iB(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function aB(e,t){const n=[];null!=t&&"object"==typeof t||(t={});const o=rB[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(rB).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);"array"!==o.dataShape||!Object.prototype.hasOwnProperty.call(o.props,"data")||o.required.includes("data")||function(e,t){return"mechanical"===t.mode&&("GaltonBoardChart"===e||"PhysicsPileChart"===e)}(e,t)||null!=t.data||n.push(`"data" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!iB(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=uh(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const a=ph({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});a&&n.push(a)}else if("object"===o.dataShape){const o=mh({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=fh({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}import{interpolateLab as sB}from"d3-interpolate";function cB(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function lB(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||function(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}(e.denominator)>100?80:100);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.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||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.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"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.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"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function uB(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 dB(e){const t=uB(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 hB(e){const t=uB(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;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:n,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:lB(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:lB(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:lB(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:n,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:lB(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 pB(e){let t=e.replace(/^#/,"");/^[a-f\d]{3}$/i.test(t)&&(t=t.split("").map(e=>e+e).join(""));const n=t.match(/^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!n)return null;const[o,r,i]=[parseInt(n[1],16)/255,parseInt(n[2],16)/255,parseInt(n[3],16)/255],a=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*a(o)+.7152*a(r)+.0722*a(i)}function mB(e,t){const n=pB(e),o=pB(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}var fB=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),yB=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),gB=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),bB=new Set(["LineChart","AreaChart","StackedAreaChart"]),vB=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]),xB=new Set(["LineChart","AreaChart","StackedAreaChart","ConnectedScatterplot"]),wB=new Set(["PieChart","DonutChart"]),kB={PieChart:"valueAccessor",DonutChart:"valueAccessor",FunnelChart:"valueAccessor"},SB=new Set(Object.keys(kB)),AB={StackedBarChart:"valueAccessor",StackedAreaChart:"yAccessor"},CB=new Set(["BigNumber"]),MB=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),PB=new Set(["StreamPhysicsFrame","GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]),IB=new Set(["OrbitDiagram",...PB]),RB=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart"]),_B=new Set(["GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","PhysicsCustomChart"]),TB=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),LB=new Set(["MultiAxisLineChart"]),NB=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),$B={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},BB=["xExtent","yExtent","rExtent"];function DB(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function jB(e,t,n){if("function"==typeof t)return t(e);const o="string"==typeof t?t:n;return e?.[o]}var EB=new Set(["category10","tableau10","set3","blues","reds","greens","oranges","purples","greys","viridis","plasma","inferno","magma","cividis","turbo"]),FB=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function OB(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function zB(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function HB(e,t){const n=zB(e.visibleTokens);if(null!=n)return n;const o=zB(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=o)return o;const r=zB(t.tokenCount),i=zB(t.maxTokens);return null!=r&&null!=i?Math.min(r,i):r??o??i}function WB(e,t){const n=[],o=aB(e,function(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,OB(t.encoding)&&delete t.encoding,t}(t));for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return rB[e]?(function(e,t,n){const o=rB[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.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"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.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,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=rB[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${a.join(", ")}.`,fix:`Change ${e} to one of: ${a.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){fB.has(e)&&Array.isArray(t.data)&&n.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,n),function(e,t,n){yB.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=rB[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const a=t.xAccessor;"string"==typeof a&&i[a]instanceof Date&&!t.xFormat&&n.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,n),function(e,t,n){t.linkedHover&&!t.selection&&n.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,n),function(e,t,n){if(!gB.has(e))return;const o=t.rExtent||t.yExtent||t.valueExtent;o&&Array.isArray(o)&&o.length>=1&&null!=o[0]&&0!==o[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${o[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, ${o[1]??"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!bB.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){const o=t.width??600,r=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);o>a||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${a}px) >= width (${o}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),r>s||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${s}px) >= height (${r}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){const o=rB[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.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(r.length,5);for(const e of i){let t=!0;for(let n=0;a>n;n++){const o=r[n]?.[e.name];if("number"==typeof o&&Number.isFinite(o)){t=!1;break}}t&&n.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,n),function(e,t,n){if(!vB.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} 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,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){if(!t.showLegend)return;if("right"!==(t.legendPosition??"right"))return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.right;"number"==typeof r&&100>r&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${r}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,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" 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,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=mB(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${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,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=mB(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.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,n),function(e,t,n){const o=t.colorScheme;if("string"!=typeof o)return;const r=rB[e];r?.props?.colorScheme?.enum||EB.has(o)||n.push({severity:"warning",code:"UNKNOWN_COLOR_SCHEME",message:`colorScheme "${o}" is not a recognized named scheme — the chart will fall back to the default palette.`,fix:`Use a known scheme name (${[...EB].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}(e,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.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,n),function(e,t,n){const o=[];for(const e of FB)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.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,n),function(e,t,n){const o=t.hoverRadius;"number"==typeof o&&o>0&&24>o&&!1!==t.enableHover&&(!1!==t.hoverAnnotation||t.tooltip||t.customHoverBehavior||t.customClickBehavior||t.onClick)&&n.push({severity:"warning",code:"TOUCH_TARGET_SMALL",message:`hoverRadius=${o}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,n),function(e,t,n){!0===t.responsiveWidth&&!0===t.responsiveHeight&&n.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,n),function(e,t,n){if(!0!==t.showParticles)return;const o=t.particleStyle&&"object"==typeof t.particleStyle?t.particleStyle:{},r="number"==typeof o.maxPerLine?o.maxPerLine:void 0,i="number"==typeof o.spawnRate?o.spawnRate:void 0;("number"==typeof r&&r>20||"number"==typeof i&&i>.08)&&n.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,n),function(e,t,n){const o=[];OB(t.tokenEncoding)&&o.push({source:"tokenEncoding",encoding:t.tokenEncoding}),OB(t.encoding)&&o.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:r}of o){const o=HB(t,r);for(const t of lB(r,{visibleTokens:o}))n.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,n),function(e,t,n){const o=Array.isArray(t.annotations)?t.annotations:null;if(o)for(const e of o){if(!e||"object"!=typeof e)continue;const t=Ni(e);if(!$i(e)||"widget"===t)continue;const o=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),r="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,i=Bi(e);!i&&o>120?n.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${r}" sits ~${Math.round(o)}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&&o>250&&n.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${r}" uses a very long connector (~${Math.round(o)}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,n),function(e,t,n){const o=Array.isArray(t.annotations)?t.annotations:null;if(!o)return;const r=o.filter($i).length;if(0===r)return;const i="number"==typeof t.width?t.width:600,a="number"==typeof t.height?t.height:400,s=ji(i,a);Number.isFinite(s)&&r>s&&n.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${r} 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,n),function(e,t,n){const o=Array.isArray(t.annotations)?t.annotations:null;if(o)for(const e of o)e&&"object"==typeof e&&"widget"===Ni(e)&&null!=e.content&&!vi(e)&&n.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,n),function(e,t,n){for(const e of BB){const o=t[e];if(!Array.isArray(o)||2>o.length)continue;const[r,i]=o;"number"==typeof r&&"number"==typeof i&&r>i&&n.push({severity:"warning",code:"INVERTED_AXIS",message:`${e}=[${r}, ${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}, ${r}]}). 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,n),function(e,t,n){if("MultiAxisLineChart"!==e)return;const o=t.series;if(!Array.isArray(o)||2!==o.length)return;const r=o.filter(e=>!e||"object"!=typeof e||"string"!=typeof e.label||0===e.label.trim().length);r.length>0&&n.push({severity:"warning",code:"DUAL_AXIS_UNLABELED",message:`Dual-axis chart with ${r.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,n),function(e,t,n){if(!bB.has(e))return;const o=t.xExtent;if(!Array.isArray(o)||2>o.length)return;const[r,i]=o;if("number"!=typeof r||"number"!=typeof i||r>=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 c=1/0,l=-1/0;for(const e of a){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 u=l-c,d=Math.max(0,Math.min(i,l)-Math.max(r,c))/u;.7>d&&n.push({severity:"warning",code:"CHERRY_PICKED_WINDOW",message:`xExtent=[${r}, ${i}] shows only ~${Math.round(100*d)}% 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,n),function(e,t,n){const o=kB[e],r=AB[e];if(!o&&!r)return;if(r&&!t.normalize)return;const i=o??r,a=t[i],s="string"==typeof a?a:"yAccessor"===i?"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&&n.push({severity:o?"error":"warning",code:"PART_TO_WHOLE_NEGATIVE",message:`${l.length} negative value(s) in "${s}" — a part-to-whole encoding cannot represent negative parts${o?"; slice angles/areas for negatives are meaningless":"; normalized shares distort when parts are negative"}.`,fix:o?"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,n),function(e,t,n){xB.has(e)&&"basis"===t.curve&&n.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,n),function(e,t,n){if("LineChart"!==e&&"AreaChart"!==e)return;if("sparkline"===t.mode)return;if(t.responsiveWidth||t.responsiveHeight)return;const o="number"==typeof t.width?t.width:600,r="number"==typeof t.height?t.height:400;if(0>=o||0>=r)return;const i=o/r;if(i>8||.25>i){const e=i>8?"flattens":"exaggerates";n.push({severity:"warning",code:"EXTREME_ASPECT_RATIO",message:`${o}×${r} (${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,n),function(e,t,n){if(!wB.has(e))return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.categoryAccessor,i="string"==typeof r?r:"category",a=new Set;for(const e of o){const t=e?.[i];null!=t&&a.add(t)}a.size>8&&n.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,n),function(e,t,n){if(_B.has(e)){if("GaltonBoardChart"===e){const e=t.bins;"number"==typeof e&&2>e&&n.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 o=DB(t.branchProbability);null!=t.branchProbability&&(null==o||0>o||o>1)&&n.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 r=DB(t.mechanicalCount);null==t.mechanicalCount||null!=r&&r>0||n.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,o=e&&"object"==typeof e?DB(e.size):null;null==o||o>0||n.push({severity:"error",code:"PHYSICS_BAD_WINDOW_SIZE",message:`windows.size=${o} 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||n.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 r=Array.isArray(t.data)?t.data:[];if(r.length>0){const e=t.timeAccessor||"time",o=t.arrivalAccessor||"arrivalTime";r.some(t=>{const n=DB(jB(t,e,"time")),r=DB(jB(t,o,"arrivalTime"));return null!=n&&null!=r&&n!==r})||n.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=DB(t.mechanicalCount);null==t.mechanicalCount||null!=e&&e>0||n.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&&n.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 o=DB(t.unitValue??1)??1;if(0>=o)return void n.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 r=t.valueAccessor||"value",i=(Array.isArray(t.data)?t.data:[]).reduce((e,t)=>{const n=DB(jB(t,r,"value"))??0;return e+Math.max(0,Math.round(n/o))},0);i>1500&&n.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((DB(t.pointRadius??5)??5)>0||n.push({severity:"error",code:"PHYSICS_BAD_POINT_RADIUS",message:`pointRadius=${t.pointRadius} cannot produce collision bodies.`,fix:"Use a positive pointRadius, for example 5."}),(DB(t.collisionIterations??6)??6)>0||n.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:[],o=DB(e[0]),r=DB(e[1]);(2>e.length||null==o||null==r)&&n.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&&n.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 o=t.groupAccessor;if(e.length>0&&o){const t=new Set;for(const n of e){const e=jB(n,o,"group");null!=e&&t.add(e)}t.size>12&&n.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)&&n.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||n.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)n.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())&&n.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 o=e.filter(e=>e?.absorb).length;t.groupBy&&0===o&&n.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)||n.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 o=Array.isArray(t.data)?t.data:[],r=DB(t.mechanicalCount)??0,i=o.length>0?o.length*("PhysicsPileChart"===e?Math.max(1,(DB(t.unitValue),1)):1):r;i>2500&&n.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,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var GB=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]);function qB(e){return"string"==typeof e&&e.trim().length>0}function YB(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 VB(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const n=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return n?n.length:1}function XB(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function UB(e,t,n={}){const o=[],r=IT(e),i=PB.has(e),a=!!rB[e]||!!r||i,s=!0===n.inChartContainer,c=!0===n.describe,l=!0===n.navigable,u=CB.has(e),d=fB.has(e),h=!1!==t.accessibleTable&&!u,p=qB(t.title),m=qB(t.description),f=qB(t.summary),y=p||m||f,g=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=XB(e),n=e.controls&&"object"==typeof e.controls?e.controls:{};return!0===e.pauseControl||!0===t.pauseControl||!0===n.pause||"function"==typeof n.pause}(t),v=i,x=function(e){const t=XB(e);return!0===e.settledProjection||!0===t.settledProjection}(t)||RB.has(e)&&h,w=function(e){const t=XB(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(o.push(function(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},n=e.colorScheme,o="string"==typeof e.background?e.background:null;if(o&&!o.startsWith("#"))return{...t,status:"manual",message:`Background "${o}" 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 r=o??"#ffffff";if(!Array.isArray(n))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 n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=mB(e,r);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 ${r}: ${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 ${r}.`}}(t)),o.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."}}),o.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."}),o.push({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0,...null!=t.pulse||IB.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){o.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,n=e?e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase()):[],r=n.length>0&&n.every(e=>GB.has(e));o.push({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1,...r?{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.'}}),o.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($i);if(e.length>0){const n=t.autoPlaceAnnotations,r="object"==typeof n&&null!==n&&!0===n.redundantCues,i=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=Ni(e),n=r&&"text"===t;return!(Bi(e)||n)});o.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."}})}}o.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&&o.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 n=$B[e];if(n&&g){const e=t[n];"number"==typeof e&&e>0&&24>2*e&&o.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${n}=${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."})}}o.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).`}),o.push({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0,...g?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."}}),o.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}.`}),o.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}),o.push({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0,...y?{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)."}}),o.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."}: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."}: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(qB).join(". "),n=e?function(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),n=e.trim().split(/\s+/).filter(Boolean);if(0===n.length||0===t.length)return null;let o=0;for(const e of n)o+=VB(e);return n.length/t.length*.39+o/n.length*11.8-15.59}(e):null;o.push({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0,...null==n?{status:"not-applicable",message:"No description/summary text to grade."}:n>9?{status:"warn",message:`Description/summary reads at ~grade ${n.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(n))} (≤ 9).`}})}if(MB.has(e)){const e=qB(t.xLabel),n=qB(t.yLabel);o.push({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1,...e&&n?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!n&&"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(LB.has(e)&&o.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(YB).length;o.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)&&o.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&&o.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}),o.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."}),o.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."}),o.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}),o.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||o.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)."}}),o.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}),o.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."}: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 n=Array.isArray(t.data)?t.data:null,r=Array.isArray(t.nodes)?t.nodes:null,i={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let a;a=SB.has(e)&&n&&n.length>7?{...i,status:"warn",message:n.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.'}:r&&r.length>200?{...i,status:"warn",message:r.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."}:n&&n.length>5e3?{...i,status:"warn",message:n.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."}:n?{...i,status:"pass",message:n.length+" data points — a reasonable density for non-visual consumption."}:r?{...i,status:"pass",message:r.length+" nodes — a reasonable density for non-visual consumption."}:{...i,status:"manual",message:"Data not provided inline (push mode); verify density at runtime."},o.push(a)}{const e=Array.isArray(t.data)?t.data:null,n=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let r=!1;if(e&&!n)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){r=!0;break}if(r)break}r&&o.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.'})}o.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()."}: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."}}),o.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."}}),o.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}),o.push({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...IB.has(e)||TB.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&&(o.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."}}),o.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."}}),o.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 n=!0===t.responsiveWidth||!0===t.responsiveHeight,r=NB.has(e)&&!0===t.zoomable;o.push({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1,...n?{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.`}:r?{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(r){const e=r.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));e&&o.push({id:"perceivable.recipe-color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,status:"warn",message:r.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"!==r.accessibility.description||qB(t.description)||o.push({id:"understandable.recipe-description",principle:"understandable",heuristic:"Features are not described",critical:!1,status:"fail",message:r.name+" requires a recipe-aware description, but none is attached.",fix:"Call describeChart with recipeId/recipe metadata and attach the returned text as description."}),r.accessibility.fallbackTable&&!1===t.accessibleTable&&o.push({id:"compromising.recipe-fallback",principle:"compromising",heuristic:"No data table is provided",critical:!0,status:"fail",message:r.name+" requires a fallback table, but accessibleTable is disabled.",fix:"Enable accessibleTable and preserve recipe-declared table fields on scene nodes."})}const C=o.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),M={criticalsPassed:C.filter(e=>"pass"===e.status).length,criticalsEvaluated:C.length,fails:o.filter(e=>"fail"===e.status).length,warnings:o.filter(e=>"warn"===e.status).length,manual:o.filter(e=>"manual"===e.status).length,passes:o.filter(e=>"pass"===e.status).length};return{component:e,ok:!C.some(e=>"fail"===e.status),summary:M,findings:o,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 KB(e,{onlyCritical:t=!1}={}){const n=[];for(const o of e.findings)"fail"!==o.status&&"warn"!==o.status||t&&!o.critical||n.push(o.message);return n}var QB={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},ZB=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function JB(e){const t=[],n=e.summary,o=e.ok?`${n.criticalsPassed}/${n.criticalsEvaluated} critical heuristics pass`:`${n.fails} blocking failure(s) — ${n.criticalsPassed}/${n.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${o} · ${n.warnings} warning(s) · ${n.manual} to verify manually`);for(const n of ZB){const o=e.findings.filter(e=>e.principle===n&&"not-applicable"!==e.status);if(0!==o.length){t.push(""),t.push(" "+n.toUpperCase());for(const e of o)t.push(` ${QB[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 eD(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t}function tD(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t}function nD(e){return"nominal"===e||"ordinal"===e}function oD(e){return"quantitative"===e||"temporal"===e}var rD={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"},iD={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"},aD={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function sD(e){e=function(e){if(!function(e){return e.usermeta?.idid}(e)||!Array.isArray(e.layer))return e;const t=e.layer.filter(e=>!function(e){return"annotation-layer"===e.usermeta?.idid?.role}(e));if(1!==t.length)return e;const{layer:n,...o}=e,{usermeta:r,...i}=t[0];return{...o,...i}}(e);const t=[],{type:o,markProps:r}=function(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};const{type:t,...n}=e;return{type:t,markProps:n}}(e.mark),i=e.encoding||{},a=i.x,s=i.y,c=i.color,l=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),c?.field&&(p.colorBy=c.field,c.scale?.scheme)){const e=rD[c.scale.scheme];e&&(p.colorScheme=e)}void 0!==d?.value&&(p.pointOpacity=d.value);const f=a?.aggregate,y=s?.aggregate;if(h&&(f||y)){const e=y?s:a,t=y?a:s,o=aD[e.aggregate];if(o&&t?.field&&e.field)h=function(e,t){const{groupBy:o,value:r,agg:i="sum"}=t,a=new Map;for(const t of e){const e=t[o]+"";a.has(e)||a.set(e,[]),a.get(e).push(Number(t[r]))}const s=[];for(const[e,t]of a){let r;switch(i){case"count":r=t.length;break;case"mean":r=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":r=n(t)[0];break;case"max":r=n(t)[1];break;default:r=t.reduce((e,t)=>e+t,0)}s.push({[o]:e,value:r})}return s}(h,{groupBy:t.field,value:e.field,agg:o});else if(("count"===o||"count"===e.aggregate)&&t?.field&&h){const e=new Map;for(const n of h){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}h=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}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 n=a?.bin||s?.bin,o="object"==typeof n?n.maxbins:void 0;return o&&(p.bins=o),lD(e,p,t)}let g;switch(o){case"bar":g=function(e,t,n,o,r,i,a){let s;return n?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(s="StackedBarChart",o.stackBy=n.field):s="BarChart",nD(e?.type)&&oD(t?.type)?(o.categoryAccessor=e.field,o.valueAccessor=a?"value":t.field,e?.axis?.title&&(o.categoryLabel=e.axis.title),t?.axis?.title&&(o.valueLabel=t.axis.title)):oD(e?.type)&&nD(t?.type)?(o.categoryAccessor=t.field,o.valueAccessor=i?"value":e.field,o.orientation="horizontal",t?.axis?.title&&(o.categoryLabel=t.axis.title),e?.axis?.title&&(o.valueLabel=e.axis.title)):(e?.field&&(o.categoryAccessor=e.field),t?.field&&(o.valueAccessor=a?"value":t.field),e?.axis?.title&&(o.categoryLabel=e.axis.title),t?.axis?.title&&(o.valueLabel=t.axis.title)),r&&(o.data=r),s}(a,s,c,p,h,f,y);break;case"line":if(g="LineChart",cD(a,s,p,f,y),c?.field&&(p.lineBy=c.field),r.interpolate){const e=iD[r.interpolate];e&&(p.curve=e)}!0===r.point&&(p.showPoints=!0),h&&(p.data=h);break;case"area":if(c?.field?(g="StackedAreaChart",p.areaBy=c.field):g="AreaChart",cD(a,s,p,f,y),r.interpolate){const e=iD[r.interpolate];e&&(p.curve=e)}void 0!==r.opacity&&(p.areaOpacity=r.opacity),h&&(p.data=h);break;case"point":case"circle":case"square":l?.field?(g="BubbleChart",p.sizeBy=l.field,l.scale?.range&&(p.sizeRange=l.scale.range)):g="Scatterplot",cD(a,s,p,f,y),h&&(p.data=h);break;case"rect":g="Heatmap",a?.field&&(p.xAccessor=a.field),s?.field&&(p.yAccessor=s.field),c?.field&&(p.valueAccessor=c.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":r.innerRadius&&r.innerRadius>0?(g="DonutChart",p.innerRadius=r.innerRadius):g="PieChart",u?.field?p.valueAccessor=u.field:s?.field&&(p.valueAccessor=y?"value":s.field),c?.field&&(p.categoryAccessor=c.field),a?.field&&!u?.field&&(p.categoryAccessor=a.field),h&&(p.data=h);break;case"tick":g="DotPlot",nD(a?.type)?(p.categoryAccessor=a.field,s?.field&&(p.valueAccessor=y?"value":s.field),a?.axis?.title&&(p.categoryLabel=a.axis.title),s?.axis?.title&&(p.valueLabel=s.axis.title)):nD(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=y?"value":s.field)),h&&(p.data=h);break;default:t.push(`Unsupported mark type "${o}". Defaulting to Scatterplot.`),g="Scatterplot",cD(a,s,p,f,y),h&&(p.data=h)}return lD(g,p,t)}function cD(e,t,n,o,r){e?.field&&(n.xAccessor=o?"value":e.field),t?.field&&(n.yAccessor=r?"value":t.field),e?.axis?.title&&(n.xLabel=e.axis.title),t?.axis?.title&&(n.yLabel=t.axis.title)}function lD(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}import{useCallback as uD,useMemo as dD,useRef as hD,useState as pD}from"react";var mD=/^\d{4}[-/]\d{2}/,fD=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function yD(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?mD.test(e)&&!Number.isNaN(Date.parse(e))?"date":fD.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function gD(e){let t=1/0,n=-1/0;for(let o=0;e.length>o;o++){const r=e[o];t>r&&(t=r),r>n&&(n=r)}return{min:t,max:n}}function bD(e){const t=e.length;if(0===t)return NaN;const n=t>>1;return t%2==0?(e[n-1]+e[n])/2:e[n]}function vD(e,t={}){const{maxDistinct:n=10,sampleSize:o=5,keyScanRows:r=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const i=new Set,a=Math.min(e.length,r);for(let t=0;a>t;t++){const n=e[t];if(n&&"object"==typeof n)for(const e of Object.keys(n))i.add(e)}const s={};for(const t of i){const o=[];for(let n=0;e.length>n;n++){const r=e[n]?.[t];null!=r&&o.push(r)}if(0===o.length){s[t]={type:"unknown"};continue}const r=yD(o[0]);if("numeric"===r){const e=[];for(let t=0;o.length>t;t++){const n=Number(o[t]);Number.isFinite(n)&&e.push(n)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:n,max:r}=gD(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:n,max:r,mean:i/e.length,median:bD(a)}}else if("date"===r){const e=[];for(let t=0;o.length>t;t++){const n=o[t],r=n instanceof Date?n.getTime():Date.parse(n);Number.isFinite(r)&&e.push(r)}if(0===e.length){s[t]={type:"unknown"};continue}const{min:n,max:r}=gD(e);s[t]={type:"date",min:new Date(n).toISOString(),max:new Date(r).toISOString()}}else if("categorical"===r){const e=new Map;for(let t=0;o.length>t;t++){const n=o[t]+"";e.set(n,(e.get(n)??0)+1)}const r=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,n).map(([e,t])=>({value:e,count:t}));s[t]={type:"categorical",distinctCount:e.size,topValues:r,distinctValues:e.size>n?void 0:r.map(e=>e.value)}}else s[t]={type:"unknown"}}return{rowCount:e.length,fields:s,sample:e.slice(0,o)}}var xD=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,wD=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,kD=/(size|magnitude|volume|weight|count|amount)/i,SD=/^(category|label|name|type|group|region|segment|kind|class)$/i,AD=/^(series|group|type|category|segment|cohort|product)$/i,CD=new Set(["numeric"]),MD=new Set(["numeric","date"]),PD=new Set(["numeric"]),ID=new Set(["date"]),RD=new Set(["categorical","boolean"]);function _D(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function TD(e,t){return t.test(e)?.2:0}function LD(e,t){let n=null;for(let o=0;e.length>o;o++){const r=e[o]?.[t];if(null==r)continue;const i=r instanceof Date?r.getTime():Number(r);if(!Number.isFinite(i))return!1;if(null!==n&&n>i)return!1;n=i}return null!==n}function ND(e,t,n,o,r={}){const i=[];for(const[a,s]of Object.entries(e)){const e=_D(s);if(!n.has(e))continue;let c,l=.5;l+=TD(a,o),"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 u={field:a,kind:e,quality:Math.max(0,Math.min(1,l)),distinctCount:c};!r.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=LD(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 $D(e,t){const n=new Set;for(let o=0;e.length>o;o++){const r=e[o]?.[t];null!=r&&n.add(r+"")}return n.size}var BD=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,DD=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,jD=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,ED=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,FD=/^(value|weight|amount|count|magnitude|volume)$/i;function OD(e,t){return e.find(e=>t.test(e))}function zD(e,t={}){const n=vD(e??[]),o=Array.isArray(e)?e:[],r=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(!r.hasNetwork&&!r.hasHierarchy&&!r.hasGeo){const e=function(e){if(3>e.length)return null;const t=e[0];if(!t||"object"!=typeof t)return null;const n=Object.keys(t),o=OD(n,BD),r=OD(n,DD);if(!o||!r||o===r)return null;const i=OD(n,jD),a=OD(n,ED),s=OD(n,FD),c=[];for(const t of e){if(!t)continue;const e=t[o],n=t[r];if(null==e||null==n)continue;const i=(e+"").trim(),a=(n+"").trim();i&&a&&i!==a&&c.push(t)}if(3>c.length)return null;const l=new Map,u=new Map,d=new Map;for(const e of c){const t=(e[o]+"").trim(),n=(e[r]+"").trim();l.has(t)||l.set(t,{id:t,label:t}),l.has(n)||l.set(n,{id:n,label:n});const c=`${t}->${n}`,h=s?Number(e[s]):1,p=Number.isFinite(h)?h:1;u.set(c,(u.get(c)??0)+p),d.has(c)||d.set(c,{source:t,target:n,...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(l.values()),edges:h}}(o);e&&(r.hasNetwork=!0,r.network=e)}const i=ND(n.fields,o,MD,xD,{computeMonotonic:!0}),a=ND(n.fields,o,PD,wD),s=ND(n.fields,o,CD,kD),c=ND(n.fields,o,RD,SD),l=ND(n.fields,o,RD,AD),u=ND(n.fields,o,ID,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let h=d,p=d?"time":"none";if(!h){const e=i.find(e=>xD.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(n.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,y="time"===p||"named"===p,g=c.map(e=>e.field);let b,v;y?(v=t.seriesField??g[0],b=g.find(e=>e!==v)):(b=g[0],v=t.seriesField??g.find(e=>e!==b));const x=b?$D(o,b):void 0,w=v?$D(o,v):void 0,k=h?$D(o,h):void 0,S=!!h&&function(e,t){const n=new Set;for(let o=0;e.length>o;o++){const r=e[o]?.[t];if(null==r)continue;const i=r+"";if(n.has(i))return!0;n.add(i)}return!1}(o,h),A=i.find(e=>e.field===h)?.monotonic??!1,C=u.length>0;return{...n,data:o,candidates:{x:i,y:a,size:s,category:c,series:l,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:r.hasHierarchy,hasNetwork:r.hasNetwork,hasGeo:r.hasGeo,xProvenance:p,network:r.network,hierarchy:r.hierarchy,geo:r.geo}}var HD={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},WD=["tiny","small","medium","large","huge"];function GD(e){return{rows:{...HD.rows,...e?.rows??{}},cardinality:{...HD.cardinality,...e?.cardinality??{}},fields:{...HD.fields,...e?.fields??{}}}}function qD(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const n=GD(t?.thresholds).rows;return e>n.tiny?e>n.small?e>n.medium?e>n.large?"huge":"large":"medium":"small":"tiny"}function YD(e,t){if(!Number.isFinite(e)||0>e)return"low";const n=GD(t?.thresholds).cardinality;return e>n.low?e>n.medium?"high":"medium":"low"}function VD(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const n=GD(t?.thresholds).fields;return e>n.narrow?e>n.typical?"wide":"typical":"narrow"}function XD(e,t){return WD.indexOf(e)-WD.indexOf(t)}function UD(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=GD(n?.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 KD(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=GD(n?.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 QD(e,t){const n=e.rowCount??0,o=t?.rows,r=UD(o,n,t),i=qD(r,t),a=Object.keys(e.fields??{}).length,s=t?.fields,c="number"==typeof s?s:"string"==typeof s?function(e,t){const n=GD(t?.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(n.narrow/2));case"typical":return Math.floor((n.narrow+n.typical)/2);case"wide":return Math.floor(2*n.typical)}}(s,t):a,l=VD(c,t),u=e.primary.category,d=KD((u?t?.cardinality?.[u]:void 0)??t?.typicalCardinality,e.categoryCount,t);return{rows:r,rowBand:i,fields:c,fieldBand:l,typicalCardinality:d,cardinalityBand:void 0!==d?YD(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==o?"declared":"measured"}}var ZD=2.5;function JD(e,t,n,o,r){const i=[],a=[];let s=0,c=!1;if(e.scaleFit){const r=e.scaleFit(t,n,o);if(r&&(s+=Math.max(-2.5,Math.min(ZD,r.delta??0)),r.reason&&i.push(r.reason),r.caveats))for(const e of r.caveats)a.push(e)}const l=o?.charts?.[e.component];if(l&&(l.minBand&&0>XD(n.rowBand,l.minBand)||l.maxBand&&XD(n.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(s+=Math.max(-3,Math.min(3,l.bias)),l.reason&&i.push(`${o?.name?o.name+": ":""}${l.reason}`)):l.reason&&i.push(`${o?.name?o.name+": ":""}${l.reason}`)),r&&e.qualityFit){const n=e.qualityFit(t,r);if(n&&(s+=Math.max(-1,Math.min(1,n.delta??0)),n.reason&&i.push(n.reason),n.caveats))for(const e of n.caveats)a.push(e)}else if(r){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const n=e[t];return"number"==typeof n?n:void 0}(r.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:c}}function ej(e){return(t,n)=>{let o=0;const r=[];let i;if(e.rows){const[t,a]=e.rows.sweetSpot;t>n.rows||n.rows>a?t>n.rows?(o-=Math.min(ZD,.8*(0===t?1:(t-n.rows)/t)),void 0===e.rows.caveatBelow||n.rows>e.rows.caveatBelow||r.push(`only ${n.rows} rows — chart may feel sparse`)):(o-=Math.min(ZD,.4*(0===a?1:(n.rows-a)/a)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>n.rows||r.push(n.rows+" rows is past this chart's comfortable density")):(o+=.6,i=n.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==n.typicalCardinality){const t=n.typicalCardinality,[i,a]=e.cardinality.sweetSpot;i>t||t>a?t>a&&(o-=Math.min(ZD,.5*(0===a?1:(t-a)/a)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||r.push(t+" distinct categories may overwhelm this chart")):o+=.4}return 0!==o||0!==r.length||i?{delta:o,reason:i,caveats:r}:null}}var tj={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 n={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(n.lineBy=e.primary.series,n.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(n.xScaleType="time"),{...n,...t?.props??{}}},scaleFit:ej({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},nj={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 n=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,o=e.primary.y,r=new Map;for(const n of e.data){const e=n[t];if(null==e||""===e)continue;const i=Number(n[o]);r.set(e,(r.get(e)??0)+(Number.isFinite(i)?i:0))}let i,a=-1/0;for(const[e,t]of r)t>a&&(a=t,i=e);null!=i&&r.size>0&&(n=e.data.filter(e=>e[t]===i))}const o={data:n,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:!0,areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(o.xScaleType="time"),{...o,...t?.props??{}}},scaleFit:ej({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},oj={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 n={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&&(n.xScaleType="time"),{...n,...t?.props??{}}},scaleFit:ej({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},rj={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,n=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&n.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 n={data:e.data},o="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,r=o?e.candidates.y.filter(e=>e.field!==o).map(e=>e.field):[];return o&&r.length>=2?(n.xAccessor=r[0],n.yAccessor=r[1]):(n.xAccessor=e.primary.x,n.yAccessor=e.primary.y,e.primary.size&&(n.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(n.colorBy=e.primary.series),{...n,...t?.props??{}}},scaleFit:ej({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},ij={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,n=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&n.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},n="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,o=n?e.candidates.y.filter(e=>e.field!==n).map(e=>e.field):[];return n&&o.length>=2?(t.xAccessor=o[0],t.yAccessor=o[1],t.orderAccessor=n):(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}},aj={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:ej({rows:{sweetSpot:[10,500],caveatAbove:1500}})},sj={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,n=e.primary.y,o=e.fields[t],r=e.fields[n],i="numeric"===o?.type?o.median:void 0,a="numeric"===r?.type?r.median:void 0;return{data:e.data,xAccessor:t,yAccessor:n,...void 0!==i?{xCenter:i}:{},...void 0!==a?{yCenter:a}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...Lm},topRight:{...Nm},bottomLeft:{...$m},bottomRight:{...Bm}}}}},cj={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,n])=>"numeric"===n.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,n])=>"numeric"===n.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},lj={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"}:{}})},uj={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,n=e.primary.y,o=e.primary.series,r=e=>null!=e&&(e+"").length>0,i=new Map;for(const t of e.data){const e=t[o];if(!r(e))continue;const a=e+"",s=Number(t[n]);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],c=a[1]?.[0],l=e=>e instanceof Date?e.getTime():e,u=new Map;for(const i of e.data){const e=i[o];if(!r(e))continue;const a=e+"";if(a!==s&&a!==c)continue;const d=i[t],h=i[n],p=l(d);let m=u.get(p);m||(m={[t]:d},u.set(p,m)),a===s?m.a=h:a===c&&(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:c}}},dj={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())),n=t.has("high"),o=t.has("low");return n&&o?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),n=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:n("high"),lowAccessor:n("low"),openAccessor:n("open"),closeAccessor:n("close")}}},hj={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 n=e.candidates.category.map(e=>e.field),o=e.primary.time??n[0],r=n.find(e=>e!==o)??n[0]??e.primary.series;return{data:e.data,xAccessor:o,yAccessor:r,valueAccessor:e.primary.y,...t?.props??{}}},scaleFit:ej({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},pj=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,mj=/^(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,fj=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,yj={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 n=t.replace(/([a-z])([A-Z])/g,"$1 $2");if(pj.test(n))return!0;const o=e.data;if(!o||0===o.length)return!1;let r=0,i=0;for(const e of o){const n=e[t];if(null==n)continue;i++;const o=(n+"").trim();(mj.test(o)||fj.test(o))&&r++}return i>0&&r/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:ej({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},gj={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})},bj={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??{}})},vj={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:ej({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},xj={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:ej({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},wj={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})},kj=/(stage|step|funnel|status|outcome|phase)/i,Sj={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=>kj.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=>kj.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},Aj={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,n=e.data[0],o=n?Number(n[t]):0,r=e.fields[t],i="numeric"===r?.type?r.max:100;return{value:Number.isFinite(o)?o:0,min:0,max:i}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},Cj=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,Mj={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=>Cj.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=>Cj.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},Pj={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})},Ij={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,n=e.candidates.y.find(e=>e.field===t);return void 0!==n?.distinctCount&&6>n.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??{}})},Rj={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})},_j={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}:{}})},Tj={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??{}})},Lj={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})},Nj={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"}}},$j={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"})},Bj={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"})},Dj={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"},n=e.network?.edges[0];return n&&(void 0===n.startTime&&void 0!==n.start&&(t.startTimeAccessor="start"),void 0===n.endTime&&void 0!==n.end&&(t.endTimeAccessor="end")),t}},jj={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 Ej(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+Ej(t),0):1}var Fj={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 n=Ej(e.hierarchy);let o=0;const r=[];let i;return 5>n?(o-=.5,r.push(`only ${n} leaves — treemap needs more cells to show structure`)):n>100?n>500&&(o-=.7,r.push(n+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(o+=.4,i=n+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(o-=.5,r.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:o,reason:i,caveats:r}}},Oj={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"})},zj={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"})},Hj={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"})},Wj={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"})},Gj={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"})},qj={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 Yj(e){return Number.isFinite("number"==typeof e?e:Number(e))}function Vj(e){return["value","throughput","traffic","rate","volume","count"].find(t=>e.some(e=>{const n=Number(e?.[t]);return Number.isFinite(n)&&n>0}))??"value"}function Xj(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var Uj=[tj,nj,oj,rj,ij,aj,sj,cj,lj,uj,dj,hj,yj,gj,bj,vj,xj,wj,Sj,Aj,Mj,Pj,Ij,Rj,_j,Tj,Lj,Nj,$j,Bj,Dj,jj,Fj,Oj,zj,Hj,Wj,Gj,qj,{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,n=(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:n,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,n=t?e.data.map(e=>Number(e?.[t])).filter(e=>Number.isFinite(e)):[],o=n.length?Math.max(...n):1;return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:t,unitValue:Math.max(1,Math.ceil(o/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=>Yj(e.x)&&Yj(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:Vj(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":Xj(e,"stage")||Xj(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=(Xj(e,"stage")?"stage":Xj(e,"status")&&"status")||e.primary.category||"stage",n=Xj(e,"id")?"id":void 0,o=(Xj(e,"featureId")?"featureId":Xj(e,"group")&&"group")||e.primary.series||void 0,r=new Set;for(const n of e.data){if(!n||"object"!=typeof n)continue;const e=n[t];null!=e&&""!==e&&r.add(e+"")}const i=r.size>0?Array.from(r):["coding","review","merged"],a=i.map((t,n)=>{const o=n===i.length-1,r=n===Math.floor(i.length/2);return{id:t,label:t,force:o?20:12,capacity:r?{unitsPerSecond:Math.max(2,Math.round(e.rowCount/8))}:void 0,pressure:r||void 0,absorb:o||void 0}});return{data:e.data,...n?{idAccessor:n}:{},stageAccessor:t,...o?{groupBy:o,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 n=e.data,o=n.length>0?n[n.length-1]:null,r=o?Number(o[t]):0,i={value:Number.isFinite(r)?r:0,label:t};if(n.length>=2){const e=Number(n[n.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}],Kj=new Map;function Qj(e){Kj.set(e.component,e)}function Zj(e){Kj.delete(e)}function Jj(){if(0===Kj.size&&0>=CT().capabilities.size)return Uj;const e=new Map;for(const t of Uj)e.set(t.component,t);for(const t of Array.from(CT().capabilities.values()))e.set(t.component,t);for(const[t,n]of Kj)e.set(t,n);return Array.from(e.values())}function eE(e){return Jj().find(t=>t.component===e)}var tE=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),nE={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function oE(e,t){if("visual"===t)return{delta:0,caveats:[]};let n=0;const o=[],r=[];for(const t of e.findings){if(!tE.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(n-=e,o.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),r.push(t.message))}return 0===o.length?{delta:0,caveats:[]}:{delta:Math.max(-3,n),reason:`Harder to receive via ${nE[t]}: ${o.slice(0,3).join("; ")}`,caveats:r}}function rE(e,t,n,o,r){if(!o)return{score:e,rubric:t};const i=o.familiarity?.[n],a=i??t.familiarity,s=o.targets?.[n];let c,l,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)),c=s.reason?`${o.name?o.name+": ":""}${s.reason}`:`${o.name?o.name+" ":""}target: ${s.direction} ${n}`);const d=o.receptionModality;return r&&d&&"visual"!==d&&(u+=r.delta,l=r.reason),{score:e+u,rubric:{...t,familiarity:a},appliedReason:c,receivabilityReason:l}}function iE(e,t,n){return n?n.familiarity?.[e]??t:t}function aE(e){return e&&2===e.exposureLevel?4:3}function sE(e,t){if(void 0===e)return 0;const n="function"==typeof e?e(t):e;return Number.isFinite(n)?Math.max(0,Math.min(5,n)):0}function cE(e,t){if(!t?.intentDeltas)return e;const n={...e};for(const[e,o]of Object.entries(t.intentDeltas))n[e]=Math.max(0,Math.min(5,(n[e]??0)+o));return n}function lE(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 uE(e,t,n,o){const r=[],i=o.map(e=>({intent:e,score:n[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)r.push(`Strong fit for ${e} (${t}/5)`);if(t.primary.x&&t.primary.y&&r.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&r.push(`${t.seriesCount} series detected on field "${t.primary.series??"series"}"`),"recipe"===e.candidateKind){for(const t of e.positiveRationale?.slice(0,2)??[])r.push(t);e.whyCustom?.reason&&r.push("Why leave the catalog: "+e.whyCustom.reason)}return r}function dE(e,t){if("recipe"!==e.candidateKind||!e.recipe)return{delta:0,reasons:[],caveats:[]};const n=e.recipe;if(t.portability&&n.portability!==t.portability)return{delta:0,reasons:[],caveats:[],excluded:`requires a ${t.portability} recipe`};let o=0;const r=[],i=[],a=t.audience?.name?.trim().toLowerCase();if(a){const e=n.audienceFit?.find(e=>e.audience.trim().toLowerCase()===a);e&&(o+={strong:.75,moderate:.25,weak:-.5,avoid:-2}[e.fit],r.push(e.rationale??`${e.fit} fit for ${t.audience?.name??e.audience}`))}const s=t.receptionChannel??t.audience?.receptionModality??"visual";n.reception?.channels?.includes(s)?(o+=.25,r.push(`Designed for ${s} reception`)):n.reception?.channels?.length&&(o-=1,i.push(`Recipe does not declare support for the ${s} reception channel.`));const c=n.reception?.risks??[];return"low"===t.riskTolerance&&c.length>0?(o-=Math.min(1.5,.35*c.length),i.push(...c)):"medium"===t.riskTolerance&&c.length>2&&(o-=.25),"local"===n.portability?i.push("Local-only recipe: cannot be rendered remotely by CLI or MCP."):r.push("Portable registered recipe"),{delta:o,reasons:r,caveats:i}}function hE(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 n=0;for(const o of t)n+=e[o]??0;return n/t.length}function pE(e,t={}){const n=t.profile??zD(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??Jj(),r=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],i=!1!==t.includeVariants,a=t.minScore??0,s=t.maxResults??10,c=t.allow?new Set(t.allow):null,l=t.deny?new Set(t.deny):null,u=t.audience?.receptionModality,d=void 0!==u&&"visual"!==u,h=QD(n,t.scale),p=void 0!==t.scale&&h.rows!==n.rowCount?{...n,rowCount:h.rows}:n,m=[];for(const e of o){if(c&&!c.has(e.component))continue;if(l&&l.has(e.component))continue;if(null!==e.fits(p))continue;const o={};for(const[t,n]of Object.entries(e.intentScores))o[t]=sE(n,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 c=cE(o,i),l=hE(c,r),f=lE(e.rubric,i),y=e.buildProps(n,i);let g;d&&(g=oE(UB(e.component,y),u));const b=rE(l,f,e.component,t.audience,g),v=JD(e,p,h,t.scale,t.quality);if(v.excluded)continue;const x=dE(e,t);if(x.excluded)continue;const w=b.score+v.delta+x.delta;if(a>w)continue;const k=uE(e,p,c,r);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,...g?.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:c,rubric:b.rubric,reasons:k,caveats:S,props:y,...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 mE(e,t={}){const n=t.profile??zD(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??Jj(),r=t.allow?new Set(t.allow):null,i=t.deny?new Set(t.deny):null,a=QD(n,t.scale),s=void 0!==t.scale&&a.rows!==n.rowCount?{...n,rowCount:a.rows}:n,c=[];for(const e of o){if(r&&!r.has(e.component))continue;if(i&&i.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:pE(e,{...t,profile:n}),rejected:c,profile:n}}function fE(e,t,n={}){const o=Jj().find(t=>t.component===e);if(!o)return{reason:`No capability registered for "${e}"`};const r=n.profile??zD(t??[]),i=o.fits(r);if(null!==i)return{reason:i};const a=n.variantKey?o.variants?.find(e=>e.key===n.variantKey):void 0,s=n.intent?Array.isArray(n.intent)?n.intent:[n.intent]:[],c={};for(const[e,t]of Object.entries(o.intentScores))c[e]=sE(t,r);const l=cE(c,a),u=hE(l,s),d=lE(o.rubric,a),h=uE(o,r,l,s),p=dE(o,n);if(p.excluded)return{reason:p.excluded};h.push(...p.reasons);const m=[...o.caveats?o.caveats(r):[],...a?.caveats??[],...p.caveats];return{component:o.component,displayName:o.displayName??o.component,candidateKind:o.candidateKind??"built-in",...o.recipe?{recipeId:o.recipe.id}:{},family:o.family,importPath:o.importPath,variant:a,score:u+p.delta,intentScores:l,rubric:d,reasons:h,caveats:m,props:o.buildProps(r,a),...o.whyCustom?{whyCustom:o.whyCustom}:{}}}function yE(e,t={}){const n=t.profile??zD(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=QD(n,t.scale),r=t.maxPerBand??t.maxResults??5,i=["tiny","small","medium","large","huge"],a={};for(const o of i){const i={...t.scale??{},rows:o};a[o]=pE(e,{...t,profile:n,scale:i,maxResults:r})}return{tiny:a.tiny??[],small:a.small??[],medium:a.medium??[],large:a.large??[],huge:a.huge??[],effective:o}}var gE=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function bE(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function vE(e){return bE(e)?e:void 0}function xE(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function wE(e){const t=xE(e);return null==t?void 0:Math.max(0,Math.floor(t))}function kE(...e){return e.map(vE).find(Boolean)}function SE(...e){return e.find(Array.isArray)}function AE(e){const t={};for(const[n,o]of Object.entries(e))void 0!==o&&(t[n]=o);return t}function CE(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function ME(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function PE(e,t,n){const o=e?.filter(e=>!0===vE(e)?.sensor).length,r=vE(t?.observation),i=vE(r?.sensors),a=SE(n?.activeSensors);return Math.max(o??0,i?Object.keys(i).length:0,a?.length??0)||void 0}function IE(e,t,n={}){const{capability:o,audience:r,locale:i}=n,a=n.levels??["l1","l2","l3"],s=!1!==n.includeStructure,c=$L(e,o),l=GL(e,t,{levels:c?[...a,"l4"]:a,locale:i,capability:o,audience:r}),{l4:u,...d}=l.levels,h=["l1","l2","l3"].map(e=>l.levels[e]).filter(Boolean).join(" "),p={levels:d,text:l.annotations?`${l.annotations} ${h}`.trim():h,...l.annotations?{annotations:l.annotations}:{}};let m;if(c&&u){const e=(f=o)?"fits"in f||"buildProps"in f?{family:f.family}:{family:f.family,intentScores:f.intentScores}:{};m={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}var f;const y=s?UL(e,t,{maxLeaves:n.maxLeaves,locale:i}):void 0,g=function(e,t,n){if(!1===n)return;const o=bE(n)?n:void 0,r=vE(t.physics),i=kE(o?.snapshot,r?.snapshot,t.physicsSnapshot,function(e){const t=vE(e);return!!t&&(bE(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),a=kE(o?.evidence,r?.evidence,t.physicsEvidence,t.settledEvidence),s=kE(o?.config,r?.config,i?.config,t.config),c=kE(vE(i?.world),vE(r?.world)),l=kE(vE(s?.kernel),vE(c?.options)),u=SE(c?.bodies),d=SE(c?.colliders,s?.colliders),h=SE(i?.queue,r?.queue),p=SE(i?.liveBodyOrder),m=SE(c?.springs),f=SE(i?.activeSensorPairs),y=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const n=vE(e);if(!n)return;const o=xE(n.count??n.value??n.total??n.bodies??n.events);if(null==o)return;const r=(n.label??n.id??n.name??"container "+(t+1))+"",i=null==n.id?void 0:n.id+"",a=xE(n.secondary??n.secondaryCount),s=xE(n.observed??n.observedCount);return AE({id:i,label:r,count:o,secondary:a,secondaryLabel:"string"==typeof n.secondaryLabel?n.secondaryLabel:void 0,observed:s})}).filter(e=>null!=e);if(0===t.length)return;const n=t.reduce((e,t)=>e+t.count,0),o=t.filter(e=>e.count>0).length,r=t.slice().sort((e,t)=>t.count-e.count)[0];return{rows:t,totalCount:n,populatedCount:o,...r?{leader:r}:{}}}(function(e,t,n,o){const r=vE(e.settledProjection),i=vE(t?.settledProjection);return SE(n?.projectionRows,n?.aggregates,e.settledProjectionRows,e.projectionRows,r?.rows,t?.settledProjectionRows,t?.projectionRows,i?.rows,o?.binCounts)}(t,r,o,a)),g=function(e,t){const n=e?.map((e,t)=>{const n=vE(e);if(!n)return;const o=xE(n.count)??0,r=xE(n.total),i={label:(n.label??n.id??"sediment "+(t+1))+"",count:o};return null!=n.id&&(i.id=n.id+""),null!=r&&(i.total=r),i}).filter(e=>null!=e),o=wE(t?.bins)??n?.length??0,r=xE(t?.count)??n?.reduce((e,t)=>e+t.count,0)??0,i=xE(t?.total)??n?.reduce((e,t)=>e+(t.total??0),0),a=n?.slice().sort((e,t)=>t.count-e.count)[0];if(0!==o||0!==r||i)return{bins:o,count:r,...null!=i&&i>0?{total:i}:{},...a?{leader:a}:{}}}(SE(o?.sediment,r?.sediment,i?.sediment),kE(o?.sedimentTotals,r?.sedimentTotals)),b=p?.length??u?.length??wE(a?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===vE(e)?.sleeping).length}(u)??wE(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=vE(l?.gravity),A=xE(S?.x),C=xE(S?.y),M=AE({state:w,settled:k,elapsedSeconds:xE(i?.elapsedSeconds),paused:"boolean"==typeof i?.paused?i.paused:void 0,visible:"boolean"==typeof i?.visible?i.visible:void 0,seed:xE(l?.seed),gravity:null!=A&&null!=C?{x:A,y:C}:void 0,fixedDt:xE(s?.fixedDt??l?.fixedDt),timeScale:xE(s?.timeScale),maxSubsteps:wE(s?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:x,bodyLimit:xE(s?.bodyLimit),eviction:"string"==typeof s?.eviction?s.eviction:void 0}),P=AE({colliders:d?.length,sensors:PE(d,s,c),springs:m?.length,activeSensorPairs:f?.length}),I=Object.keys(P).length>0,R=gE.has(e);if(!(Object.keys(M).length>0||I||y||g)||!R&&null==n)return;const _={simulation:M,...I?{geometry:P}:{},...y?{aggregates:y}:{},...g?{sediment:g}:{}},T=function(e){const t=[],n=e.simulation,o=[n.state??(n.settled?"settled":void 0),null!=n.liveBodies?`${n.liveBodies} live ${CE(n.liveBodies,"body")}`:void 0,null!=n.sleepingBodies?n.sleepingBodies+" sleeping":void 0,null!=n.queued?n.queued+" queued":void 0,null!=n.seed?"seed "+ME(n.seed):void 0,n.gravity?`gravity (${ME(n.gravity.x)}, ${ME(n.gravity.y)})`:void 0,null!=n.fixedDt?`fixed step ${ME(n.fixedDt)}s`:void 0,null!=n.timeScale?ME(n.timeScale)+"x time":void 0].filter(Boolean);o.length>0&&t.push(`Physics simulation: ${o.join("; ")}.`);const r=e.geometry;if(r){const e=[null!=r.colliders?`${r.colliders} ${CE(r.colliders,"collider")}`:void 0,null!=r.sensors?`${r.sensors} ${CE(r.sensors,"sensor")}`:void 0,null!=r.springs?`${r.springs} ${CE(r.springs,"spring")}`:void 0,null!=r.activeSensorPairs?`${r.activeSensorPairs} active sensor ${CE(r.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,n=e?` Largest is ${e.label} with ${ME(e.count)}.`:"";t.push(`Physics aggregates: ${ME(i.totalCount)} settled ${CE(i.totalCount,"body")} across ${i.rows.length} ${CE(i.rows.length,"container")}; ${i.populatedCount} populated.${n}`)}const a=e.sediment;if(a){const e=null!=a.total?", value total "+ME(a.total):"",n=a.leader?`; largest sediment bin is ${a.leader.label} with ${ME(a.leader.count)}`:"";t.push(`Physics sediment: ${a.count} retained ${CE(a.count,"body")} in ${a.bins} ${CE(a.bins,"bin")}${e}${n}.`)}return t.join(" ")}(_);return{..._,text:T}}(e,t,n.physics),b=[p.text,m?.sentence,g?.text].filter(Boolean).join(" ");return{component:e,description:p,intent:m,structure:y,physics:g,text:b}}function RE(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function _E(e){const{data:t,onQuery:n,initialAnnotations:o,componentName:r,props:i,includeProfile:a,includeSuggestions:s,suggestionsIntent:c,suggestionsMax:l,focus:u,includeGrounding:d}=e,[h,p]=pD([]),[m,f]=pD([]),[y,g]=pD(!1),[b,v]=pD(null),x=dD(()=>vD(t??[]),[t]),w=a||s,k=dD(()=>w?zD(t??[]):void 0,[w,t]),S=dD(()=>s&&k?pE(t,{profile:k,intent:c,maxResults:l??5}):void 0,[s,k,t,c,l]),A=dD(()=>{if(d&&r)return IE(r,{data:t??[],...i??{}},"object"==typeof d?d:void 0)},[d,r,i,t]),C=hD(n);C.current=n;const M=hD(r);M.current=r;const P=hD(i);P.current=i;const I=hD(t);I.current=t;const R=hD(x);R.current=x;const _=hD(k);_.current=k;const T=hD(S);T.current=S;const L=hD(u);L.current=u;const N=hD(A);N.current=A;const $=uD(async e=>{const t=e.trim();if(!t)return;g(!0),v(null),p(e=>[...e,{role:"user",text:t}]);const n="undefined"!=typeof performance?performance.now():Date.now();IN().record({type:"interrogation-asked",component:M.current,query:RE(t,500)});try{const e=await C.current(t,{data:I.current??[],summary:R.current,profile:_.current,suggestions:T.current,componentName:M.current,props:P.current,grounding:N.current,focus:L.current??void 0});p(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&f(e.annotations);const o="undefined"!=typeof performance?performance.now():Date.now();IN().record({type:"interrogation-answered",component:M.current,answer:RE(e.answer,2e3),annotationCount:e.annotations?.length,latencyMs:Math.max(0,Math.round(o-n))})}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();IN().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-n))})}finally{g(!1)}},[]),B=uD(({text:e,annotations:t})=>{const n=e.trim();n&&(p(e=>[...e,{role:"assistant",text:n}]),t&&t.length>0&&f(e=>[...e,...t]))},[]),D=uD(()=>{p([]),f([]),v(null)},[]);return{ask:$,announce:B,history:h,summary:x,annotations:dD(()=>{const e=o??[];return 0===e.length?m:0===m.length?e:[...e,...m]},[o,m]),loading:y,error:b,reset:D}}import{useMemo as TE}from"react";var LE=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function NE(e={}){const{chartId:t,types:n=LE}=e,{latest:o}=Zu({chartId:t,types:n,limit:1});return TE(()=>{if(!o)return null;if("hover-end"===o.type||"selection-end"===o.type||"brush-end"===o.type||"click-end"===o.type)return null;let e;if("selection"===o.type)e=o.selection.fields;else{if("hover"!==o.type&&"click"!==o.type)return null;e=o.datum}return e&&"object"==typeof e?{datum:e,x:o.x,y:o.y,source:o.type}:null},[o])}function $E(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function BE(e,t){return"pass"===e?t.passColor??"var(--semiotic-success)":"warn"===e?t.warnColor??"var(--semiotic-warning)":t.failColor??"var(--semiotic-danger)"}function DE(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 jE(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 EE(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 FE(e,t={}){const n=[],o=[],r=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=BE(a.status,t),s=jE(a),c={provenance:EE(a),lifecycle:i},l=e=>o.push({result:a,reason:e}),u=e=>n.push(iL(e,c));switch(a.kind){case"range":if("number"!=typeof a.min||"number"!=typeof a.max){l("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){l(a.kind+" check is missing a numeric value");break}u({type:"x"===r?"x-threshold":"y-threshold",value:t,label:s,color:e});break}case"freshness":{const t=void 0!==a.at?$E(a.at):void 0;if(void 0===t){l("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:l(`${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:n,unplaced:o}}function OE(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function zE(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function HE(e,t={}){const n=[],o=e.sources;if(o?.results){const e=o.metadata?.generated_at,t=o.metadata?.invocation_id;for(const r of o.results){const o=OE(r.status),i=zE(r.unique_id),a=DE(r.max_loaded_at);n.push({id:r.unique_id??i,name:"dbt freshness: "+i,label:"pass"===o?i+" fresh":`${i} stale${a?" since "+a:""}`,status:o,kind:"freshness",at:r.max_loaded_at,message:`freshness ${o}${r.max_loaded_at?" — last load "+r.max_loaded_at:""}`,source:"dbt",basis:"rule",createdAt:e,dataVersion:t})}}const r=e.runResults;if(r?.results){const e=r.metadata?.generated_at,o=r.metadata?.invocation_id;for(const i of r.results){const r=OE(i.status);if("pass"===r&&!t.includePassed)continue;const a=zE(i.unique_id);n.push({id:i.unique_id??a,name:"dbt test · "+a,status:r,kind:"custom",message:i.message??void 0,observedCount:"number"==typeof i.failures?i.failures:void 0,source:"dbt",basis:"rule",createdAt:e,dataVersion:o})}}return FE(n,t)}function WE(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function GE(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 qE(e,t={}){const{createdAt:n,dataVersion:o}=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),r=[];for(const[t,i]of(e.results??[]).entries()){const e=i.expectation_config??{},a=e.expectation_type??"unknown_expectation",s=e.kwargs??{},c=s.column,l=i.success?"pass":"fail",u=WE(s.min_value),d=WE(s.max_value),h=WE(s.value),p=WE(i.result?.observed_value),m=c??"value",f=GE(a),y=void 0!==p?`${m}: ${p} `:"",g={id:`ge:${a}:${c??t}`,name:`GE ${f}${c?` (${c})`:""}`,status:l,column:c,message:void 0!==p?"observed "+p:void 0,observedCount:i.result?.unexpected_count,source:"great-expectations",basis:"statistical-test",createdAt:n,dataVersion:o},b=/_to_be_between$/.test(a);r.push(b&&void 0!==u&&void 0!==d?{...g,kind:"range",min:u,max:d,label:`${y}(expected ${u}–${d})`}:b&&void 0!==u?{...g,kind:"min",value:u,label:`${y}(min ${u})`}:b&&void 0!==d?{...g,kind:"max",value:d,label:`${y}(max ${d})`}:void 0!==h?{...g,kind:"threshold",value:h,label:`${y}(target ${h})`}:{...g,kind:"custom",label:`${m} ${f}`})}return FE(r,t)}function YE(e,t,n={}){const o=n.profile??zD(t??[],{rawInput:n.rawInput}),r=eE(e),i=n.maxAlternatives??3,a=r?.recipe?function(e,t){const n=[];"required"===e.accessibility.description&&"string"!=typeof(t.props??{}).description&&n.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))&&n.push("This recipe is unfamiliar; add an orienting legend, annotation, or summary.");const o=e.encodings?.some(e=>"color"===e.channel&&(!e.redundantWith||0===e.redundantWith.length));o&&n.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&&n.push("This interactive recipe needs a static data fallback."),"local"===e.portability&&n.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?n.push("Scene audit found data-bearing marks without hit targets."):"accessibility.table-fields"===e.id?n.push("Scene audit found accessible-table field loss."):"accessibility.navigation-depth"===e.id&&n.push("The recipe navigation tree is root-only; expose groups and reachable data marks."));return[...new Set(n)]}(r.recipe,n):[];if(!r)return{status:"unknown",component:e,alternatives:pE(t,{profile:o,intent:n.intent,maxResults:i,includeVariants:!1}),profile:o};const s=r.fits(o);return null===s?{status:"ok",component:e,profile:o,...a.length?{repairs:a}:{}}:{status:"alternative",component:e,reason:s,alternatives:pE(t,{profile:o,intent:n.intent,maxResults:i,deny:[e],includeVariants:!1}),profile:o,...a.length?{repairs:a}:{}}}var VE={valid:!1,errors:[]};function XE(e,t={}){const n=e.component,o=e.props??{},r=[],i=!!rB[n];i||r.push(`Unknown component "${n}". It is not in the chart registry — pick a known chart.`);const a=i?aB(n,o):{...VE};if(!a.valid)for(const e of a.errors)r.push(e);const s=!1!==t.diagnose&&i?WB(n,o).diagnoses:[],c=s.filter(e=>"error"===e.severity),l=!1!==t.treatErrorsAsBlocking;if(l)for(const e of c)r.push(`${e.code}: ${e.message}`);let u,d,h,p,m;if((t.repair??!!t.data)&&t.data&&(u=YE(n,t.data,{intent:t.intent}),"alternative"===u.status?r.push(`${n} is a poor fit: ${u.reason}. Consider ${u.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`):"unknown"===u.status&&r.push(`${n} could not be evaluated against the data; consider ${u.alternatives.map(e=>e.component).slice(0,3).join(", ")}.`)),i&&(d=YT(n,o),h=QT(d)),t.render&&i){const e=t.render(n,o);m=e.svg,p=e.evidence,p.empty&&r.push("Rendered to an empty scene (no marks) — the data or accessors produce nothing to draw.");for(const e of p.warnings)r.push(e)}const f=i&&a.valid&&(!l||0===c.length)&&(!u||"ok"===u.status)&&(!p||!p.empty);return{ok:f,component:n,props:o,config:d,jsx:h,validation:a,diagnostics:s,repair:u,evidence:p,svg:m,reasons:f?[]:r}}function UE(e={}){const t=e.components??Object.keys(rB).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 KE(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function QE(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function ZE(e,t=!0){if(!e||"object"!=typeof e||Array.isArray(e))return!1;const n=e,o=Array.isArray(n.type)?n.type:[n.type],r=o.includes("object")||!!n.properties;if(t&&!r)return!1;if(r){if(!1!==n.additionalProperties)return!1;const e=n.properties;if(!e||"object"!=typeof e||Array.isArray(e))return!1;const t=new Set(Array.isArray(n.required)?n.required:[]);if(Object.keys(e).some(e=>!t.has(e)))return!1;if(!Object.values(e).every(e=>ZE(e,!1)))return!1}if(o.includes("array")&&(!n.items||!ZE(n.items,!1)))return!1;for(const e of["anyOf","oneOf","allOf"]){if(void 0===n[e])continue;const t=n[e];if(!Array.isArray(t)||0===t.length)return!1;if(!t.every(e=>ZE(e,!1)))return!1}return!0}function JE(e,t={}){const n=t.strict??!1;if(n&&!ZE(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:n}}function eF(e){return t=>XE(t,e?e(t):{})}import{useCallback as tF,useEffect as nF,useMemo as oF,useRef as rF,useState as iF}from"react";var aF=["hover","click","focus","activate"];function sF(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=sF(t);if(e)return e}return null}function cF(e,t){return e?t.map(t=>e[t]+"").join(""):""}function lF(e,t){if(e.id===t)return e;for(const n of e.children??[]){const e=lF(n,t);if(e)return e}return null}function uF(e){const{tree:t,chartId:n,observe:o=aF}=e,r=e.selectionName??"__semiotic-nav-sync"+(n?":"+n:""),i=oF(()=>{if(e.matchFields)return e.matchFields;const n=sF(t);return n?Object.keys(n).filter(e=>{return!e.startsWith("_")&&(null==(t=n[e])||"string"==typeof t||"number"==typeof t||"boolean"==typeof t);var t}):[]},[e.matchFields,t]),a=oF(()=>{const e=new Map,n=t=>{if("datum"===t.role&&t.datum){const n=cF(t.datum,i);e.has(n)||e.set(n,t.id)}for(const e of t.children??[])n(e)};return n(t),e},[t,i]),{selectPoints:s,clear:c}=Gu({name:r,fields:i}),l=oF(()=>[...o,"hover-end"],[o]),{latest:u}=Zu({chartId:n,types:l,limit:1}),[d,h]=iF(t.id),p=rF(d);p.current=d;const m=rF(t);nF(()=>{const e=m.current;m.current=t;const n=lF(e,p.current),o=lF(t,p.current);"datum"===n?.role&&"datum"===o?.role&&n.datum&&o.datum&&i.length>0&&cF(n.datum,i)===cF(o.datum,i)||n&&o&&"datum"!==n.role&&"datum"!==o.role||(h(t.id),c())},[t,c,i]);const f=tF(e=>{if(h(e.id),"datum"===e.role&&e.datum&&i.length>0){const t={};for(const n of i)t[n]=[e.datum[n]];s(t)}else c()},[i,s,c]),y=e.annotations,g=oF(()=>{const e=new Set;if(0===i.length||!y)return e;for(const t of y){const n=a.get(cF(t,i));n&&e.add(n)}return e},[y,a,i]),b=tF(e=>{const t="number"==typeof e?y?.[e]:e;if(!t||0===i.length)return!1;const n=a.get(cF(t,i));if(!n)return!1;h(n);const o={};for(const e of i)o[e]=[t[e]];return s(o),!0},[y,a,i,s]),v=rF(null),x=tF(e=>{if(n&&e.chartId!==n)return;if("hover-end"===e.type){if(e===v.current)return;return void(v.current=e)}if(!function(e){return"hover"===e.type||"click"===e.type||"focus"===e.type||"activate"===e.type}(e))return;if(!o.includes(e.type))return;if(e===v.current)return;if(v.current=e,0===i.length)return;const t=function(e){const t=e,n=t.data;if(!n||"object"!=typeof n||Array.isArray(n))return e;const o=e=>e.every(e=>"number"==typeof t[e]),r=o(["x0","x1","y0","y1","width","height","value"]),i=o(["y0","y1","sankeyWidth","value"])&&"source"in t&&"target"in t;return r||i?n:e}(e.datum),r=a.get(cF(t,i));r&&h(e=>e===r?e:r)},[n,o,a,i]),w=rF(null);return nF(()=>{u&&u!==w.current&&(w.current=u,x(u))},[u,x]),{activeId:d,onActiveChange:f,selection:{name:r},onObservation:x,handleObservation:x,annotatedIds:g,focusAnnotation:b}}var dF=[{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 hF(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const n of dF)for(const o of n.patterns)if(o.test(e)){const e=t.get(n.intent)??0;t.set(n.intent,Math.min(5,0===e?n.weight:e+.5));break}if(0===t.size)return null;const n=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[o,...r]=n;return{intent:o.intent,confidence:o.confidence,alternates:r}}function pF(e,t={}){const n=t.audience;if(!n)return[];const o=t.profile??zD(e??[],{rawInput:t.rawInput}),r=aE(n),i=t.scoreTolerance??1.5,a=t.maxResults??5,s=Jj(),c=new Map;for(const e of s)c.set(e.component,iE(e.component,e.rubric.familiarity,n));const l=pE(e,{profile:o,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),u=l.filter(e=>(c.get(e.component)??e.rubric.familiarity)>=4)[0],d=[];for(const e of l)(c.get(e.component)??e.rubric.familiarity)>r||("increase"===n.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 o=`${e.component}/${e.variant?.key??"base"}`;if(h.has(o))continue;h.add(o);const r=c.get(e.component)??e.rubric.familiarity,i=n.targets?.[e.component],s=i?.reason??("increase"===i?.direction?`${n.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:r}),p.length>=a)break}return p}function mF(e,t={}){const n=t.profile??zD(e??[],{rawInput:t.rawInput}),o=t.maxPanels??6,r=!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))}(n),a=[],s=[],c=[],l=new Set,u=new Set;for(const d of i){if(a.length>=o){c.push(d);continue}const i=pE(e,{profile:n,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"}`)||r&&l.has(e.family))){h=e;break}if(!h&&r)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),l.add(h.family),u.add(`${h.component}/${h.variant?.key??"base"}`)):c.push(d)}return{panels:a,intentsCovered:s,intentsMissing:c,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?pF(e,{profile:n,audience:t.audience,deny:Array.from(u).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,o)}):[],profile:n}}var fF={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},yF={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},gF={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},bF={executive:fF,analyst:yF,"data-scientist":gF},vF=[{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,n=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:n}}},{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,n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:n}}},{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,n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name,o=e.fields.find(e=>"category"===e.role||"categorical"===e.kind)?.name;return{timeAccessor:t,valueAccessor:n,categoryAccessor:o}}},{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,n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind)?.name;return{timeAccessor:t,valueAccessor:n}}},{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,n=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind)?.name,o=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role)?.name;return{timeAccessor:t,valueAccessor:n,...o?{categoryAccessor:o}:{}}}},{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,n=e.fields.find(e=>"x"===e.role||"date"===e.kind)?.name;return{timeAccessor:n,valueAccessor:t}}}],xF=new Map;function wF(e){xF.set(e.component,e)}function kF(e){xF.delete(e)}function SF(){if(0===xF.size)return vF;const e=new Map;for(const t of vF)e.set(t.component,t);for(const[t,n]of xF)e.set(t,n);return Array.from(e.values())}function AF(e,t){if(void 0===e)return 0;const n="function"==typeof e?e(t):e;return Number.isFinite(n)?Math.max(0,Math.min(5,n)):0}function CF(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 n=0;for(const o of t)n+=e[o]??0;return n/t.length}function MF(e,t,n){const o=[],r=n.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 r)o.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&o.push(`tuned for ${e.throughput} throughput`),o}function PF(e,t={}){const n=t.capabilities??SF(),o=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],r=t.minScore??0,i=t.maxResults??10,a=t.allow?new Set(t.allow):null,s=t.deny?new Set(t.deny):null,c=[];for(const t of n){if(a&&!a.has(t.component))continue;if(s&&s.has(t.component))continue;if(null!==t.fits(e))continue;const n={};for(const[o,r]of Object.entries(t.intentScores))n[o]=AF(r,e);const i=CF(n,o);if(r>i)continue;const l={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=MF(e,n,o),h=t.buildProps(e);c.push({component:t.component,family:"realtime",importPath:t.importPath,score:i,intentScores:n,rubric:l,reasons:d,caveats:u,props:h})}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,i)}var IF=["x","y","size","category","series","time"];function RF(e,t){const n=e.fields[t];return n?"numeric"===n.type?"numeric":"categorical"===n.type?"categorical":"date"===n.type?"date":"unknown":"unknown"}function _F(e){const t=new Set;for(const n of Jj())null===n.fits(e)&&t.add(n.component);return t}function TF(e,t){const n=new Set(Object.keys(e.fields)),o=new Set(Object.keys(t.fields)),r=[],i=[];for(const e of o)n.has(e)||r.push(e);for(const e of n)o.has(e)||i.push(e);r.sort(),i.sort();const a=[];for(const r of o){if(!n.has(r))continue;const o=RF(e,r),i=RF(t,r);o!==i&&a.push({field:r,from:o,to:i})}a.sort((e,t)=>e.field.localeCompare(t.field));const s=[];for(const n of IF){const o=e.primary[n],r=t.primary[n];o!==r&&s.push({role:n,from:o,to:r})}const c=_F(e),l=_F(t),u=Array.from(c).filter(e=>!l.has(e)).sort(),d=Array.from(l).filter(e=>!c.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:r,removed:i,typeChanges:a,primaryChanges:s,becameUnfit:u,becameFit:d,unchanged:0===r.length&&0===i.length&&0===a.length&&0===s.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}}function LF(e,t=Jj()){const n=new Map;for(const e of t)n.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 o=new Map,r=new Map,i=new Map,a=new Map,s=[];for(const c of e){let e,l;try{e=zD(c.data,{rawInput:c.rawInput}),l=mE(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 u=[],d=new Set;for(const e of l.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=c.expected&&c.expected.length>0?u.some(e=>c.expected.includes(e.component)):null,p=c.expected&&c.expected.length>0?u.length>0&&c.expected.includes(u[0].component):null;s.push({fixture:c.name,shape:c.shape,intent:c.intent,expected:c.expected,topPick:u[0],topThree:u,fittingCount:l.fitting.length,rejectedCount:l.rejected.length,expertAgreement:h,topPickAgreement:p,noFitHonored:!0===c.expectsNoFit?0===l.fitting.length:null});for(const e of l.fitting){const t=n.get(e.component);t&&(t.fitsOn+=1,o.set(e.component,(o.get(e.component)??0)+e.score),r.set(e.component,(r.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 l.rejected){const t=n.get(e.component);t&&(t.rejectedOn+=1)}for(const e of u){const t=n.get(e.component);t&&(t.inTopThreeOn+=1)}if(u[0]){const e=n.get(u[0].component);e&&(e.topPickOn+=1)}if(c.expected&&h)for(const e of u)if(c.expected.includes(e.component)){const t=n.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of n.values()){const t=r.get(e.component)??0;e.averageScore=0===t?0:(o.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 c=Array.from(n.values()).sort((e,t)=>{const n=e.expertAgreementCount-t.expertAgreementCount;return 0!==n?n:t.fitsOn-e.fitsOn}),l=s.filter(e=>null!==e.expertAgreement),u=0===l.length?0:l.filter(e=>!0===e.expertAgreement).length/l.length,d=0===l.length?0:l.filter(e=>!0===e.topPickAgreement).length/l.length,h=Array.from(r.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:c,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 NF=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,n)=>e.map(e=>({month:e,revenue:800+e*(200+40*n)+150*Math.sin(e),region:t})))})(),$F=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),BF=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],DF=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]})),jF=Array.from({length:80},(e,t)=>{const n=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:n,grade:Math.min(100,1.8*n+30+20*(Math.random()-.5))}}),EF=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),FF=[{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}],OF=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:NF,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:NF,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:NF,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:$F,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:BF,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:BF,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:DF,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:DF,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:jF,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:jF,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:FF,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:FF,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 n=100+1.2*t+8*Math.sin(t/4),o=n+4*(Math.random()-.5),r=n+4*(Math.random()-.5);return{day:t+1,open:o,high:Math.max(o,r)+3*Math.random(),low:Math.min(o,r)-3*Math.random(),close:r}}),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,n)=>e.map((e,o)=>({service:t,day:e,incidents:Math.round(2+9*Math.abs(Math.sin(1.7*n+o))+(5>o?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:EF,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 zF,useMemo as HF,useRef as WF,useSyncExternalStore as GF}from"react";var qF=e=>fN(e),YF=()=>IN().enabled,VF=()=>!1;function XF(e,t={}){const{intent:n,allow:o,deny:r,maxResults:i,includeVariants:a,minScore:s,rawInput:c,seriesField:l,capabilities:u,audience:d,profile:h}=t,p=HF(()=>h??zD(e??[],{rawInput:c,seriesField:l}),[h,e,c,l]),m=HF(()=>pE(e,{intent:n,allow:o,deny:r,maxResults:i,includeVariants:a,minScore:s,capabilities:u,audience:d,profile:p}),[e,n,o,r,i,a,s,u,d,p]),f=GF(qF,YF,VF),y=WF(null);return zF(()=>{if(0===m.length)return void(y.current=null);if(!f)return void(y.current=null);const e=IN(),t=d?.name??(d?"custom":void 0),o=`${n??""}|${t??""}|${m.map(e=>e.component).join(",")}`;if(o===y.current)return;const r=e.getEvents();for(let e=r.length-1;e>=0;e--){const t=r[e];if("suggestion-shown"===t.type){if(`${Array.isArray(t.intent)?t.intent.join(","):t.intent??""}|${t.audience??""}|${t.components.join(",")}`===o)return void(y.current=o);break}}y.current=o,e.record({type:"suggestion-shown",intent:n,components:m.map(e=>e.component),topScore:m[0]?.score,audience:t})},[m,n,d,f]),{suggestions:m,profile:p}}import*as UF from"react";import{forwardRef as KF,useMemo as QF}from"react";import{useMemo as ZF,useRef as JF}from"react";function eO(e){const t=JF(null);return Nh(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Vd(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}),normalizedMargin:ZF(()=>nf(e.margin),[e.margin])}}function tO(e){const t=eO(e),{resolved:n,normalizedMargin:o}=t,r=wh({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:n.showLegend,userMargin:o,marginDefaults:n.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:n.width,height:n.height});return{...t,safeData:r.data,setup:r,earlyReturn:r.earlyReturn}}import{jsx as nO}from"react/jsx-runtime";var oO=KF(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,xExtent:a,yExtent:s,showAxes:c=!1,margin:l,className:u,annotations:d,onObservation:h,onClick:p,selection:m,linkedHover:f,chartId:y,loading:g,loadingContent:b,emptyContent:v,colorBy:x,colorScheme:w,frameProps:k={}}=e,{frameRef:S,resolved:A,safeData:C,setup:M,earlyReturn:P}=tO({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:n,colorBy:x,colorScheme:w,selection:m,linkedHover:f,onObservation:h,onClick:p,chartId:y,loading:g,loadingContent:b,emptyContent:v,margin:l,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,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules,xLabel:e.xLabel,yLabel:e.yLabel}),I=M.effectiveSelectionHook,R=QF(()=>I?.isActive?{isActive:!0,predicate:I.predicate}:null,[I?.isActive,I?.predicate]);if(P)return P;const{width:_,height:T,enableHover:L,showGrid:N,title:$,description:B,summary:D,accessibleTable:j,xLabel:E,yLabel:F}=A,O={chartType:"custom",...null!=n&&{data:C},customLayout:o,layoutConfig:r,onLayoutError:i,...R&&{layoutSelection:R},xExtent:a,yExtent:s,colorAccessor:x,colorScheme:w,size:[_,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M.margin,showAxes:c,xLabel:E,yLabel:F,enableHover:L,showGrid:N,...M.legendBehaviorProps,...$h({title:$,description:B,summary:D,accessibleTable:j,className:u,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...Bh({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 nO(oh,{componentName:"XYCustomChart",width:_,height:T,children:nO(hu,{ref:S,...O})})});oO.displayName="XYCustomChart";import{forwardRef as rO,useMemo as iO}from"react";import{jsx as aO}from"react/jsx-runtime";var sO=rO(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,categoryAccessor:a="category",valueAccessor:s="value",oExtent:c,rExtent:l,projection:u="vertical",margin:d,className:h,colorBy:p,colorScheme:m,showAxes:f=!1,annotations:y,onObservation:g,onClick:b,selection:v,linkedHover:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,frameProps:C={}}=e,{frameRef:M,resolved:P,safeData:I,setup:R,earlyReturn:_}=tO({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"OrdinalCustomChart",unwrapData:!0,data:n,colorBy:p,colorScheme:m,selection:v,linkedHover:x,onObservation:g,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,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),T=R.effectiveSelectionHook,L=iO(()=>T?.isActive?{isActive:!0,predicate:T.predicate}:null,[T?.isActive,T?.predicate]);if(_)return _;const{width:N,height:$,enableHover:B,showGrid:D,title:j,description:E,summary:F,accessibleTable:O}=P,z={chartType:"custom",...null!=n&&{data:I},customLayout:o,layoutConfig:r,onLayoutError:i,...L&&{layoutSelection:L},oAccessor:a,rAccessor:s,oExtent:c,rExtent:l,projection:u,colorAccessor:p,colorScheme:m,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:R.margin,enableHover:B,showAxes:f,showGrid:D,annotations:y,...$h({title:j,description:E,summary:F,accessibleTable:O,className:h,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...Bh({linkedHover:x,selection:v,onObservation:g,onClick:b,hoverHighlight:!1,mobileInteraction:R.mobileInteraction,customHoverBehavior:R.customHoverBehavior,customClickBehavior:R.customClickBehavior}),...C};return aO(oh,{componentName:"OrdinalCustomChart",width:N,height:$,children:aO(qy,{ref:M,...z})})});sO.displayName="OrdinalCustomChart";import{forwardRef as cO,useMemo as lO}from"react";import{jsx as uO}from"react/jsx-runtime";var dO=cO(function(e,t){const{nodes:n,edges:o,layout:r,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:c="source",targetAccessor:l="target",margin:d,className:h,colorBy:p,colorScheme:m,selection:f,linkedHover:y,onObservation:g,onClick:b,chartId:v,annotations:x,autoPlaceAnnotations:w,frameProps:k={}}=e,{frameRef:S,resolved:A,normalizedMargin:C}=eO({imperativeRef:t,imperativeVariant:"network",margin:d,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),M=lO(()=>u(n),[n]),P=lO(()=>u(o),[o]),I=lO(()=>void 0===n&&void 0===o?void 0:[...M,...P],[o,n,P,M]),R=jd(e.mobileInteraction,{mode:e.mode,width:A.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:_,customClickBehavior:T,activeSelectionHook:L}=Hd({selection:f,linkedHover:y,fallbackFields:"string"==typeof p?[p]:[],onObservation:g,onClick:b,chartType:"NetworkCustomChart",chartId:v,colorByField:"string"==typeof p?p:void 0,mobileInteraction:R}),N=lO(()=>L?.isActive?{isActive:!0,predicate:L.predicate}:null,[L?.isActive,L?.predicate]),{width:$,height:B,enableHover:D,title:j,description:E,summary:F,accessibleTable:O}=A,z=sh(e.loading,$,B,e.loadingContent),H=z?null:ah(I,$,B,e.emptyContent);if(z||H)return z||H;const W={chartType:"force",...null!=n&&{nodes:M},...null!=o&&{edges:P},customNetworkLayout:r,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:c,targetAccessor:l,colorBy:p,colorScheme:m,size:[$,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:C,enableHover:D,...$h({title:j,description:E,summary:F,accessibleTable:O,className:h,animate:e.animate,autoPlaceAnnotations:w}),...Bh({linkedHover:y,selection:f,onObservation:g,onClick:b,mobileInteraction:R,customHoverBehavior:_,customClickBehavior:T,linkedHoverInClickPredicate:!1}),layoutSelection:N,...null!=x&&{annotations:x},...k};return uO(oh,{componentName:"NetworkCustomChart",width:$,height:B,children:uO(pk,{ref:S,...W})})});dO.displayName="NetworkCustomChart";import{forwardRef as hO,useMemo as pO}from"react";import{useRef as mO,useState as fO,useEffect as yO,useMemo as gO,useCallback as bO,useImperativeHandle as vO,forwardRef as xO,memo as wO}from"react";import{geoPath as kO}from"d3-geo";import{quadtree as SO}from"d3-quadtree";import{geoMercator as AO,geoEqualEarth as CO,geoAlbersUsa as MO,geoOrthographic as PO,geoNaturalEarth1 as IO,geoEquirectangular as RO}from"d3-geo";var _O={mercator:AO,equalEarth:CO,albersUsa:MO,orthographic:PO,naturalEarth:IO,equirectangular:RO};function TO(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function LO(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function NO(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function $O(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function BO(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const a=-r/i,s=o/i,c=Math.min(.3*i,80),l=(e[0]+t[0])/2+a*c,u=(e[1]+t[1])/2+s*c,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*l+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function DO(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,a;0===t?(i=e[1][0]-r[0],a=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],a=r[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;o.push([r[0]+a/s*n,r[1]+-i/s*n])}return o}function jO(e,t,n,o,r){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 c=a/s,l=-i/s,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}import{scaleLinear as EO}from"d3-scale";var FO=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],OO=["scene-style","data-paint","accessibility","evidence"],zO=(e,t)=>({retainedData:e,invalidations:t}),HO=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],WO=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],GO=["scene-geometry","data-paint","accessibility","evidence"],qO=["scene-style","data-paint","accessibility","evidence"],YO=["overlay","accessibility","evidence"],VO=[],XO={xAccessor:zO("rebuild",HO),yAccessor:zO("rebuild",HO),lineDataAccessor:zO("rebuild",HO),pointIdAccessor:zO("rebuild",GO),lineIdAccessor:zO("rebuild",GO),windowSize:zO("rebuild",HO),projection:zO("preserve",WO),projectionExtent:zO("preserve",WO),fitPadding:zO("preserve",WO),lineType:zO("preserve",WO),flowStyle:zO("preserve",WO),graticule:zO("preserve",WO),projectionTransform:zO("preserve",WO),customLayout:zO("preserve",WO),layoutConfig:zO("preserve",WO),layoutMargin:zO("preserve",WO),areaStyle:zO("preserve",qO),pointStyle:zO("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:zO("preserve",qO),colorScheme:zO("preserve",qO),themeCategorical:zO("preserve",qO),themeDiverging:zO("preserve",qO),themeSemantic:zO("preserve",qO),themeSequential:zO("preserve",qO),decay:zO("preserve",qO),pulse:zO("preserve",qO),layoutSelection:zO("preserve",qO),annotations:zO("preserve",YO),autoPlaceAnnotations:zO("preserve",YO),clock:zO("preserve",VO),transition:zO("preserve",VO),introAnimation:zO("preserve",VO),onLayoutError:zO("preserve",VO)},UO=zO("preserve",WO),KO=class{constructor(){this.tracker=new ln}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},FO)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},OO):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=XO[o]??UO;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e),o=new Set(n.invalidations);return t.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:e},o)}};import{geoDistance as QO,geoGraticule as ZO,geoInterpolate as JO}from"d3-geo";function ez(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var tz=class t{constructor(e){this.updateResults=new KO,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.config=function(e){return{...e,fitPadding:ez(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Ue()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),n=this.timestampBuffer?.toArray()??[],o=t.slice(-e),r=n.slice(-o.length),i=this.currentTime();this.pointBuffer=new te(e),this.timestampBuffer=new te(e),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??i)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:ez(e.fitPadding)}:e}(e),n=this.config,o=this.getConfiguredWindowSize(),r=Object.keys(t).filter(e=>t[e]!==n[e]);this.config={...this.config,...t};const i=this.getConfiguredWindowSize(),a=this.streaming&&i!==o;a&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:a})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],r=n.slice(-t),i=o.slice(-r.length),a=this.currentTime();this.pointBuffer=new te(t),this.timestampBuffer=new te(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(i[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();Ut(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const n of e)Ut(this.pointBuffer,n,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!o.has(n(e)+"")||(r.push(e),!1)),r.length>0?(this.version++,this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");Kt(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!o.has(n(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,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++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const n of this.scene){const o=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...o,...r}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,n=this.projection,o=this.geoPath,r=this.scales,i=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return CO();if("string"==typeof e){const t=_O[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),CO())}if("object"==typeof e&&"type"in e){const t=_O[e.type],n=t?t():CO();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=kO(this.projection),this.fitProjection(e),this.geoPath=kO(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=o,this.scales=r,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,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,o=[...this.areas],r=TO(n.xAccessor,"lon"),i=TO(n.yAccessor,"lat"),a=this.getPoints();if(a.length>0){const e=a.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const s=LO(n.lineDataAccessor);for(const e of this.lineData){const t=s(e);if(t&&t.length>0){const e=t.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==o.length){if(n.projectionExtent){const[[o,r],[i,a]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[i,r],[i,a],[o,a],[o,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const o=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*o),t.translate([e.width/2,e.height/2])}else{const r=n.fitPadding??0,i=e.width*r,a=e.height*r;t.fitExtent([[i,a],[e.width-i,e.height-a]],{type:"FeatureCollection",features:o})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),a=[...n.translate()],s=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=kO(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(a),this.currentZoom=s,this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),a=[...n.translate()],s=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=kO(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(a),this.currentZoom=s,this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;if(!n||!n.rotate)return;const o=this.geoPath,r=this.scales,i=[...n.rotate()];n.rotate(e),this.geoPath=kO(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(i),this.geoPath=o,this.scales=r):(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,n=0;for(const t of this.scene)"point"===t.type&&(n++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(o[r++]=e);this._quadtree=SO().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,o=this.geoPath;if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Pf(t.colorScheme,t.themeCategorical,Fe),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...o]},resolveColor:If(o,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,o=Et("geo",e,n,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?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 Bt({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:n,areas:o,points:r,lines:i,layout:a}){const s=TO(e.xAccessor,"lon"),c=TO(e.yAccessor,"lat"),l=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,o=ZO();t.step&&o.step(t.step);const r=n(o())||"";r&&l.push({type:"geoarea",pathData:r,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of o){const o=n(t);if(!o)continue;const r=n.centroid(t),i=n.bounds(t),a=n.area(t);l.push({type:"geoarea",pathData:o,centroid:r,bounds:i,screenArea:a,style:NO(e.areaStyle,t,u),datum:t,interactive:!0})}const p=LO(e.lineDataAccessor);for(const n of i){const o=p(n);if(!o||2>o.length)continue;let r=[];if("geo"===e.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[s(o[t]),c(o[t])];for(let n=0;e.length-1>n;n++){const o=e[n],i=e[n+1],a=QO(o,i)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),c=JO(o,i);for(let e=0;s>=e;e++){if(n>0&&0===e)continue;const o=t(c(e/s));null!=o&&r.push(o)}}}else for(let e=0;o.length>e;e++){const n=o[e],i=t([s(n),c(n)]);null!=i&&r.push(i)}if(2>r.length)continue;const i=NO(e.lineStyle,n,d),u="number"==typeof i.strokeWidth?i.strokeWidth:1;2!==o.length||2>r.length||"arc"!==e.flowStyle?2!==o.length||2>r.length||"offset"!==e.flowStyle||(r="geo"===e.lineType?DO(r,u):jO(r[0],r[r.length-1],0,0,u)):r=BO(r[0],r[r.length-1]);const h=$O(r,a.width);if(h.length>1)for(const e of h)2>e.length||l.push({type:"line",path:e,style:{...i,_edgeFade:!0},datum:n});else l.push({type:"line",path:2>r.length&&h[0]||r,style:i,datum:n})}const m=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=t.clipAngle?t.clipAngle()??0:0,y=f>0?f*Math.PI/180:null,g=t.rotate?t.rotate():[0,0,0],b="function"==typeof t.center?t.center():[0,0],v=[(b[0]??0)-g[0],(b[1]??0)-g[1]];for(const n of r){const o=s(n),r=c(n);if(null!=y&&QO([o,r],v)>y)continue;const i=t([o,r]);if(!i)continue;const a=e.pointStyle?e.pointStyle(n):{...h},u={type:"point",x:i[0],y:i[1],r:a.r||4,style:a,datum:n,pointId:m?m(n)+"":void 0};l.push(u)}return l}({config:t,projection:n,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(t,n){const o=function(t,n,o,r){const i=t.filter(e=>"point"===e.type);if(2>i.length)return null;const a=n.strength??1;if(0===a)return null;const s=n.centerAccessor?"function"==typeof n.centerAccessor?n.centerAccessor:e=>e[n.centerAccessor]:e=>e.id,c="function"==typeof n.costAccessor?n.costAccessor:e=>e[n.costAccessor],l=i.find(e=>e.datum&&s(e.datum)+""==n.center+"");if(!l)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${n.center}" not found in point data`),null;const u=l.x,d=l.y,h=i.map(e=>e.datum?c(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),p=e(h,1),m=Math.min(o.width,o.height)/2,f=EO().domain([0,p]).range([0,m]);r>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 n=t[e];"geoarea"===n.type&&n.interactive&&t.splice(e,1)}for(const e of i){if(e===l)continue;if(!e.datum)continue;const t=Math.atan2(e.y-d,e.x-u),n=Math.sqrt((e.x-u)**2+(e.y-d)**2),o=c(e.datum),r=n+((isFinite(o)?f(o):n)-n)*a;e.x=u+Math.cos(t)*r,e.y=d+Math.sin(t)*r}const y=o.width/2,g=o.height/2,b=y-l.x,v=g-l.y;if(Math.abs(b)>.5||Math.abs(v)>.5)for(const e of i)e.x+=b,e.y+=v;const x={cx:y,cy:g,maxCost:p,availableRadius:m},w=t.filter(e=>"line"===e.type);if(w.length>0&&"fractional"!==n.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 n=t.datum?.source,o=t.datum?.target;if(n&&o){const r=e.get(n+""),i=e.get(o+"");r&&i&&(t.path=[r,i])}}}return x}(this.scene,t,n,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const r=Ze(e,o,t);n[o]._decayOpacity=r,n[o].style={...n[o].style,opacity:r}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const n=this.scene.filter(e=>"point"===e.type),o=this.timestampBuffer.toArray(),r=t.color||"rgba(255,255,255,0.6)",i=t.glowRadius??4;let a=!1;for(let s=0;n.length>s&&o.length>s;s++){const c=et(t,o[s],e);a=tt(n[s],c,r,i)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&nt(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const o=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of o)if(e.pointId){const t=n.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)&&(r=!0))}for(const e of o)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Ve(e,this.activeTransition),n=Ye(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Xe(e.x,e._targetX,n),e.y=Xe(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of o)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}};tz.QUADTREE_THRESHOLD=500;var nz=tz;function oz(e,t,n,o,r,i,a=0,s=o){if(i){const e=lo(i,t,n,o,a);if(e)return e}else{let r=null,i=o;for(const a of e){if("point"!==a.type)continue;const e=a.x-t,s=a.y-n,c=Math.sqrt(e*e+s*s);Kn(a.r,o)>=c&&i>c&&(r=a,i=c)}if(r)return{node:r,distance:i}}let c=null,l=o;for(const r of e){if("glyph"!==r.type)continue;if(null==r.datum)continue;const e=so(r.glyph,r.size),i=r.x+e.centerDx-t,a=r.y+e.centerDy-n,s=Math.sqrt(i*i+a*a);Kn(e.radius,o)>=s&&l>s&&(c=r,l=s)}if(c)return{node:c,distance:l};for(let o=e.length-1;o>=0;o--){const i=e[o];if("geoarea"!==i.type)continue;const a=i;if(!1===a.interactive)continue;const[[s,c],[l,u]]=a.bounds;if(!(s>t||t>l||c>n||n>u)&&(a._cachedPath2D||(a._cachedPath2D=new Path2D(a.pathData)),r.isPointInPath(a._cachedPath2D,t,n)))return{node:a,distance:0}}let u=null,d=s;for(const o of e){if("line"!==o.type)continue;const e=o,{path:r}=e,i=Math.max((e.style.strokeWidth||2)+4,5,s);for(let o=0;r.length-1>o;o++){const[a,s]=r[o],[c,l]=r[o+1],h=rz(t,n,a,s,c,l);i>=h&&d>h&&(u=e,d=h)}}return u?{node:u,distance:d}:null}function rz(e,t,n,o,r,i){const a=r-n,s=i-o,c=a*a+s*s;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*a+(t-o)*s)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*a))**2+(t-(o+l*s))**2)}rn(nz);import{useMemo as iz,useRef as az}from"react";import{jsx as sz,jsxs as cz}from"react/jsx-runtime";function lz(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,showAxes:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p,legendLayout:m,foregroundGraphics:f,annotations:y,onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x,autoPlaceAnnotations:w,pointNodes:k}=e,S=bi({onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x}),A=az([y?.length??0,new Map]),C=y?.length??0;A.current[0]!==C&&(A.current=[C,new Map]);const M=iz(()=>{if(!y||0===y.length)return null;const e={scales:null,timeAxis:"x",width:t,height:n,frameType:"xy",pointNodes:k,stickyPositionCache:A.current[1]};return Ri(w?Zi({annotations:y,context:e,..."object"==typeof w?w:{}}):y,_i(0,S),void 0,e)},[y,w,t,n,k,S]);return a||s||c||f||M&&M.length>0?cz("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[sz("title",{children:"string"==typeof s?s:"XY Chart"}),sz("desc",{children:"string"==typeof s?s+" — XY data visualization":"XY data visualization"}),cz("g",{transform:"translate("+i.left+","+i.top+")",children:[M,f]}),s&&"string"==typeof s?sz("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?sz("foreignObject",{x:0,y:0,width:o,height:i.top,children:s}):null,Mr({legend:c,totalWidth:o,totalHeight:r,margin:i,legendPosition:p,title:s,legendLayout:m,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}):null}import{zoom as uz,zoomIdentity as dz}from"d3-zoom";import{select as hz}from"d3-selection";function pz([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t,n]}function mz(e,t,n,o,r){return"function"==typeof e?e(t,n,o,r):e.replace("{z}",t+"").replace("{x}",n+"").replace("{y}",o+"").replace("{r}",r>1?"@2x":"")}var fz=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[n,o]of this.cache)t>o.lastUsed&&(t=o.lastUsed,e=n);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 yz=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,t=Math.random){for(let n=0;this.capacity>n;n++){const o=this.particles[n];if(!o.active)return o.active=!0,o.t=0,o.offset=.6*(t()-.5),o.lineIndex=e,o.x=0,o.y=0,o}return null}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const i=this.particles[r];if(!i.active)continue;const a=n[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=gz(a),c=bz(a,i.t*s),l=(o[i.lineIndex]||2)/2;i.x=c.x+c.nx*i.offset*l*2,i.y=c.y+c.ny*i.offset*l*2}}countForLine(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}};function gz(e){let t=0;for(let n=1;e.length>n;n++){const o=e[n][0]-e[n-1][0],r=e[n][1]-e[n-1][1];t+=Math.sqrt(o*o+r*r)}return t}function bz(e,t){let n=0;for(let o=1;e.length>o;o++){const r=e[o][0]-e[o-1][0],i=e[o][1]-e[o-1][1],a=Math.sqrt(r*r+i*i);if(n+a>=t||o===e.length-1){const s=a>0?(t-n)/a:0,c=a>.001?a:1;return{x:e[o-1][0]+r*s,y:e[o-1][1]+i*s,nx:-i/c,ny:r/c}}n+=a}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}function vz(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("glyph"===n.type){const e=n,o=so(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+o.centerDx,y:e.y+o.centerDy,r:o.radius})}return t}import{jsx as xz,jsxs as wz}from"react/jsx-runtime";function kz({data:e}){if(!e)return null;if(e.properties)return xz("div",{className:"semiotic-tooltip",style:tc,children:xz("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 n=Zs(t),o=null!=n.title?n.title+"":null;return null==o&&0===n.entries.length?null:wz("div",{className:"semiotic-tooltip",style:tc,children:[null!=o&&xz("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:o}),n.entries.map(e=>wz("div",{children:[wz("span",{style:{opacity:.7},children:[e.key,": "]}),xz("span",{style:{fontWeight:600},children:Ll(e.value)})]},e.key))]})}kz.ownsChrome=!0;var Sz={top:10,right:10,bottom:10,left:10},Az=null;function Cz(){if(null!==Az)return Az;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,n="undefined"!=typeof navigator&&"number"==typeof navigator.deviceMemory&&4>=navigator.deviceMemory;return Az=e||t||n}function Mz(){return Cz()?12:30}var Pz={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 Iz(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function Rz(e){return e?e.getContext("2d"):null}import{jsx as _z,jsxs as Tz}from"react/jsx-runtime";var Lz=wO(xO(function(e,t){const{projection:n,projectionExtent:o,fitPadding:r,projectionTransform:i,areas:a,points:s,lines:c,customLayout:l,layoutConfig:d,layoutSelection:h,onLayoutError:p,xAccessor:m,yAccessor:f,lineDataAccessor:y,pointIdAccessor:g,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:R,tileCacheSize:_,size:T,width:L,height:N,responsiveWidth:$,responsiveHeight:B,margin:D,className:j,background:E,windowSize:F=500,renderMode:O,areaStyle:z,pointStyle:H,lineStyle:W,colorScheme:G,enableHover:q=!0,hoverAnnotation:V,tooltipContent:X,allowTooltipOverflow:U=!1,customClickBehavior:K,customHoverBehavior:Q,onObservation:Z,annotationObservationCallback:J,chartId:ee,annotations:te,onAnnotationActivate:ne,autoPlaceAnnotations:oe,decay:re,pulse:ie,transition:ae,animate:se,staleness:ce,frameScheduler:le,clock:ue,random:de,seed:he,paused:pe=!1,suspendWhenHidden:me=!0,backgroundGraphics:fe,foregroundGraphics:ye,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,legendCategoryAccessor:Ce,onCategoriesChange:Me,showAxes:Pe,accessibleTable:Ie=!0,description:Re,summary:_e}=e,{customHoverBehavior:Te,customClickBehavior:Le,hasClickBehavior:Ne}=Vl({customHoverBehavior:Q,customClickBehavior:K,onObservation:Z,chartId:ee,chartType:"StreamGeoFrame"}),$e=T||[L||600,N||400],Be=mO(!0),De=Tc({sizeProp:$e,responsiveWidth:$,responsiveHeight:B,userMargin:D,marginDefault:Sz,title:ge,legend:be,legendPosition:ve,foregroundGraphics:ye,backgroundGraphics:fe,animate:se,transitionProp:ae,frameScheduler:le,clock:ue,random:de,seed:he,paused:pe,suspendWhenHidden:me,themeDirtyRef:Be}),{reducedMotionRef:je,responsiveRef:Ee,size:Fe,margin:Oe,adjustedWidth:ze,adjustedHeight:He,resolvedForeground:We,resolvedBackground:Ge,transition:qe,introEnabled:Ye,tableId:Ve,frameRuntime:Xe,rafRef:Ue,renderFnRef:Ke,scheduleRender:Qe,currentTheme:Ze}=De,Je=qa(),et=Ua(),tt=gO(()=>Array.isArray(a)?u(a):a,[a]),nt=gO(()=>u(s),[s]),ot=gO(()=>u(c),[c]),rt=gO(()=>null!=C?C:"orthographic"===Iz(n),[C,n]),it=Qa(gO(()=>({projection:n,projectionExtent:o,fitPadding:r,xAccessor:m,yAccessor:f,lineDataAccessor:y,lineType:v,flowStyle:x,areaStyle:z,pointStyle:H,lineStyle:W,colorScheme:G,themeSemantic:Y(Ze),themeSequential:Ze?.colors?.sequential,themeDiverging:Ze?.colors?.diverging,themeCategorical:Ze?.colors?.categorical,graticule:w,projectionTransform:i,windowSize:F,clock:Xe.now,decay:re,pulse:ie,transition:qe,introAnimation:Ye,annotations:te,pointIdAccessor:g,lineIdAccessor:b,customLayout:l,layoutConfig:d,onLayoutError:p,layoutMargin:Oe}),[n,o,r,m,f,y,v,x,z,H,W,G,Ze,w,i,F,Xe.now,re,ie,qe,Ye,te,g,b,l,d,p,Oe])),at=mO(null);at.current||(at.current=new nz(it));const st=mO(null),ct=mO(null),lt=mO(null);I&&!lt.current&&(lt.current=new fz(_||256));const ut=mO(te),dt=mO(null),ht=mO(dz),pt=mO(!1),mt=mO(null),ft=bO(e=>{mt.current=e,Ee&&"object"==typeof Ee&&(Ee.current=e)},[Ee]),yt=mO(null),gt=mO(null),bt=mO(null),vt=mO(0);if(M&&!bt.current){const e=P?.maxPerLine??Mz();bt.current=new yz(50*e)}const xt=mO(null),wt=mO(null),kt=mO(!1),St=mO(!1),At=Dn("StreamGeoFrame"),Ct=mO(void 0),[Mt,Pt]=fO(null),[,It]=fO(0),Rt=mO(0),[_t,Tt]=fO(!1),Lt=Wc(at,Ce,Me,e=>e.getPoints());Vn(at,it,Be,Qe),Xn(at,h,Be,Qe),yO(()=>{const e=at.current;e&&(tt&&e.setAreas(tt),s&&e.setPoints(nt),c&&e.setLines(ot),Be.current=!0,Qe())},[tt,s,nt,c,ot,Qe]);const Nt=bO(e=>{null!=e&&"object"==typeof e&&(at.current?.pushPoint(e),Be.current=!0,Qe())},[Qe]),$t=bO(e=>{const t=u(e);0!==t.length&&(at.current?.pushMany(t),Be.current=!0,Qe())},[Qe]),Bt=bO(e=>{null!=e&&"object"==typeof e&&(at.current?.pushLine(e),Be.current=!0,Qe())},[Qe]),Dt=bO(e=>{const t=u(e);0!==t.length&&(at.current?.pushManyLines(t),Be.current=!0,Qe())},[Qe]),jt=bO(()=>{at.current?.clear(),Be.current=!0,Qe()},[Qe]);vO(t,()=>({push:Nt,pushMany:$t,removePoint:e=>{const t=at.current?.removePoint(e)??[];return t.length>0&&(Be.current=!0,Qe()),t},pushLine:Bt,pushManyLines:Dt,removeLine:e=>{const t=at.current?.removeLine(e)??[];return t.length>0&&(Be.current=!0,Qe()),t},getLines:()=>at.current?.getLines()??[],clear:jt,getProjection:()=>at.current?.scales?.projection??null,getGeoPath:()=>at.current?.scales?.geoPath??null,getCartogramLayout:()=>at.current?.cartogramLayout??null,getCustomLayout:()=>at.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>at.current?.lastCustomLayoutFailure??null,getZoom:()=>ht.current.k,resetZoom:()=>{const e=mt.current;e&&dt.current&&hz(e).call(dt.current.transform,dz)},getData:()=>at.current?.getPoints()??[]}),[Nt,$t,Bt,Dt,jt,Qe]);const{hoverHandlerRef:Et,onPointerMove:Ft,onPointerLeave:Ot}=De,{canvasRef:zt,interactionCanvasRef:Ht}=Bc(De,{hydrated:Je,wasHydratingFromSSR:et,storeRef:at,dirtyRef:Be,cleanup:()=>lt.current?.clear(),canvasPaintDependencies:[ze,He,E,fe,O,Qe]});yO(()=>{Et.current=e=>{if(!q)return;const t=at.current;if(!t||!t.scene.length)return;const n=zt.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Oe.left,i=e.clientY-o.top-Oe.top;if(0>r||r>ze||0>i||i>He)return xt.current=null,wt.current=null,Pt(null),Te?.(null),void Qe();ct.current||(ct.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const a=Rz(ct.current);if(!a)return;const s=Gs(30,e.pointerType),c=Gs(6,e.pointerType),l=oz(t.scene,r,i,s,a,t.quadtree,t.maxPointRadius,c);if(l){const e=l.node,t=e.datum,n=Array.isArray(t)?null:t?.properties?t:t?.data||t;let o,a;"point"===e.type?(o=e.x,a=e.y):"geoarea"===e.type?(o=e.centroid[0],a=e.centroid[1]):(o=r,a=i);const s={...n,...n?.properties||{},data:n,properties:n?.properties,__semioticHoverData:!0,x:o,y:a};xt.current=s,wt.current=e,Pt(s),Te?.(s),Qe()}else xt.current&&(xt.current=null,wt.current=null,Pt(null),Te?.(null),Qe())}},[q,ze,He,Oe,Te,Qe,Et,zt]),De.hoverLeaveRef.current=()=>{xt.current=null,wt.current=null,Pt(null),Te?.(null),Qe()};const Wt=bO(e=>{if(wi(e.target))return;if(!Le)return;const t=at.current;if(!t||!t.scene.length)return void Le(null);const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Oe.left,r=e.clientY-n.top-Oe.top;if(0>o||o>ze||0>r||r>He)return void Le(null);ct.current||(ct.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=Rz(ct.current);if(!i)return void Le(null);const a=Gs(30,Ct.current),s=Gs(6,Ct.current),c=oz(t.scene,o,r,a,i,t.quadtree,t.maxPointRadius,s);if(c){const e=c.node.datum,t=Array.isArray(e)?null:e?.properties?e:e?.data||e,n=t?.properties?{...t,...t.properties}:t;return void Le({...n,data:t,properties:t?.properties,__semioticHoverData:!0,x:o,y:r,time:o,value:r},{type:"activate",inputType:Hl(Ct.current)})}Le(null)},[He,ze,Le,Oe]),{kbFocusIndexRef:Gt,focusedNavPointRef:qt,onKeyDown:Yt}=function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:a}){const s=Ul(-1),c=Ul(null),l=Xl(l=>{if(Wl(l))return;const u=e.current;if(!u)return;const d=()=>{s.current=-1,c.current=null,t.current=null,n&&(n.current=null),o(null),r(null),a()};if(0===u.scene.length)return void(0>s.current||d());const h=function(e){const t=[];for(const n of e)if("point"===n.type&&null!=n.x)t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"});else if("glyph"===n.type){if(0>=n.size||null==n.datum)continue;const e=so(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight})}else"geoarea"===n.type&&n.centroid&&!1!==n.interactive&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"geoarea",pathData:n.pathData});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(u.scene);if(0===h.length)return void(0>s.current||d());let p=s.current;if(h.length>p||(d(),p=-1),("Enter"===l.key||" "===l.key)&&p>=0)return l.preventDefault(),void i(iu(h[p]),{type:"activate",inputType:"keyboard"});const m=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-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*n)),n-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(l.key,0>p?-1:p,h.length);if(null===m)return;if(l.preventDefault(),0>m)return void d();const f=0>p?0:m;s.current=f;const y=h[f];c.current=y;const g=iu(y);t.current=g,o(g),r(g,{type:"focus",inputType:"keyboard"}),a()},[i,r,t,n,a,o,e]);return{kbFocusIndexRef:s,focusedNavPointRef:c,onKeyDown:l}}({storeRef:at,hoverRef:xt,hoveredNodeRef:wt,setHoverPoint:Pt,customHoverBehavior:Te,customClickBehavior:Le,scheduleRender:Qe}),Vt=bO(e=>{Ct.current=e.pointerType,Gt.current=-1,qt.current=null,Ft(e)},[qt,Gt,Ft]),Xt=bO(e=>{Ct.current=e.pointerType},[]);Ke.current=()=>{if(Ue.current=null,!Xe.isActive)return;const e=zt.current,t=at.current;if(!e||!t)return;const n=Xe.now();let o=!1;const r=gt.current;let i=!1;r&&(gt.current=null,t.applyRotation(r,{width:ze,height:He}),i=!0);const a=t.advanceTransition(je.current?n+1e6:n),s=!je.current&&a,c=At.current.beforeCompute(t.getLastUpdateResult(),s);let l=!1;if(Be.current&&!a){const n={width:ze,height:He},o=rt?t.getRotation():null;t.computeScene(n);const r=ht.current,i=1!==r.k||0!==r.x||0!==r.y;rt&&o?i?(t.setRotation(o),t.applyZoomScale(r.k,n)):t.applyRotation(o,n):i&&t.applyZoomTransform(r,n),Be.current=!1,l=!0,e.setAttribute("aria-label",ws(t.scene,"Geographic chart")),Lt()}At.current.afterCompute(c,l,!1);const u=Oc(),d=M&&!je.current&&!!bt.current,h=t.consumeStylePaintPending(),p=jc(t,n,l,St),m=ns({dirtyOrRebuilt:l,transitioning:s,continuous:d,liveEncoding:p.changed,forced:i||h});if(I&&lt.current){const e=st.current;if(e&&t.scales?.projection){const n=Fc(e,Fe,Oe,u);if(n){n.clearRect(-Oe.left,-Oe.top,Fe[0],Fe[1]),n.save(),n.beginPath(),n.rect(0,0,ze,He),n.clip();const e=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:a,onTileLoad:s}=t,c=o.scale(),l=o.translate(),u=function(e){const{size:t,scale:n,translate:o,clampX:r=!0,clampY:i=!0}=e,a=Math.max(Math.log(n)/Math.LN2-8,0),s=Math.round(a),c=1<<s,l=Math.pow(2,a-s+8),u=o[0]-n/2,d=o[1]-n/2,h=Math.max(r?0:-1/0,Math.floor((0-u)/l)),p=Math.min(r?c:1/0,Math.ceil((t[0]-u)/l)),m=Math.max(i?0:-1/0,Math.floor((0-d)/l)),f=Math.min(i?c:1/0,Math.ceil((t[1]-d)/l)),y=[];for(let e=m;f>e;++e)for(let t=h;p>t;++t)y.push([t,e,s]);return{tiles:y,translate:[u/l,d/l],scale:l}}({size:[r,i],scale:2*c*Math.PI,translate:l}),d=Oc();let h=!0;for(const t of u.tiles){const[o,r,i]=pz(t),c=`${i}/${o}/${r}`;let l=a.get(c);if(!l){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:c,lastUsed:performance.now()};a.set(c,t),e.onload=()=>{t.loaded=!0,s?.()},e.onerror=()=>{t.loaded=!0},e.src=mz(n,i,o,r,d),l=t}if(!l.loaded){h=!1;continue}const p=u.scale;e.drawImage(l.img,(t[0]+u.translate[0])*p-.5,(t[1]+u.translate[1])*p-.5,p+1,p+1)}return h}(n,{tileURL:I,projection:t.scales.projection,width:ze,height:He,tileCache:lt.current,onTileLoad:()=>Qe()});n.restore(),e||(o=!0)}}}if(m){const r=Fc(e,Fe,Oe,u);if(!r)return;r.clearRect(-Oe.left,-Oe.top,Fe[0],Fe[1]),I||ts(r,{background:E,hasBackgroundGraphics:!!fe,width:ze,height:He}),r.save(),r.beginPath(),r.rect(0,0,ze,He),r.clip();const i=t.scene,a={width:ze,height:He};if(Ml({context:r,nodes:i,renderMode:O,pixelRatio:u,paintBuiltIn:e=>{!function(e,t){const n=t.filter(e=>"geoarea"===e.type);for(const t of n){if(!t.pathData)continue;t._cachedPath2D||(t._cachedPath2D=new Path2D(t.pathData));const n=t._cachedPath2D,o=Fo(e,t.style.fill)||"#e0e0e0";if("none"!==o&&(e.fillStyle=o,e.globalAlpha=(t._decayOpacity??1)*(t.style.fillOpacity??1),e.fill(n)),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 n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(n)}ol(e,t,n),e.globalAlpha=1,e.setLineDash([])}}(r,e),Jc(r,e,0,a),cl(r,e),pl(r,e)}}),d&&bt.current){const e=bt.current,t=i.filter(e=>"line"===e.type);if(t.length>0){const i=P||{},a=.3*(i.speedMultiplier??1),s=i.maxPerLine??Mz(),c=i.spawnRate??(Cz()?.06:.15),l=i.radius??2,u=i.opacity??.7,d=n/1e3,h=vt.current>0?Math.min(d-vt.current,.1):.016;vt.current=d;const p=t.map(e=>e.path),m=t.map(e=>e.style.strokeWidth||2);for(let n=0;t.length>n;n++)Xe.random()<c&&e.countForLine(n)<s&&e.spawn(n,Xe.random);e.step(h,a,p,m),r.globalAlpha=u;for(let n=0;e.particles.length>n;n++){const o=e.particles[n];if(!o.active)continue;const a=t[o.lineIndex],s="function"==typeof i.color?i.color(a?.datum??{}):"source"!==i.color&&i.color?i.color:a?.style.stroke||"#fff";r.beginPath(),r.arc(o.x,o.y,l,0,2*Math.PI),r.fillStyle=s,r.fill()}r.globalAlpha=1,o=!0}}r.restore()}const f=wt.current,y=!(!f||"geoarea"!==f.type&&"point"!==f.type),g=os(y,kt.current),b=Ht.current;if(b&&g){const e=Fc(b,Fe,Oe,u);if(e){if(e.clearRect(-Oe.left,-Oe.top,Fe[0],Fe[1]),f&&"geoarea"===f.type){const t=new Path2D(f.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(f&&"point"===f.type){const t=f,n="object"==typeof V?V:void 0,o=n?.pointColor||Il(f);e.beginPath(),e.arc(t.x,t.y,t.r+3,0,2*Math.PI),o?(e.save(),e.globalAlpha=.4,e.fillStyle=o,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=o||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}kt.current=y}const v=te!==ut.current;v&&(ut.current=te),(l||v||s&&te&&te.length>0)&&(l||v||n-Rt.current>=33)&&(It(e=>e+1),Rt.current=n),(s||null!=t.activeTransition||p.pending||o)&&Qe()},cr(ce,at,Be,Qe,_t,Tt),yO(()=>{if("production"!==process.env.NODE_ENV&&I){const e=Iz(n);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,n]),yO(()=>{const e=mt.current;if(!k||!e)return dt.current&&e&&(hz(e).on(".zoom",null),dt.current=null),void(e&&hz(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=S||[1,8],o={width:ze,height:He};if(rt){let r=ht.current.k;const i=e=>{r=Math.max(t,Math.min(n,e)),ht.current=dz.scale(r);const i=at.current;i&&(i.applyZoomScale(r,o),Be.current=!1,Qe(),i.scales?.projection&&A?.({projection:i.scales.projection,zoom:i.currentZoom}))};dt.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>i(t?.k??1)};const a=e=>{e.preventDefault(),i(r*(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*r))};e.addEventListener("wheel",a,{passive:!1}),e.addEventListener("dblclick",s);const c=.4,l=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=at.current;if(!o)return;const r=o.getRotation();yt.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=yt.current;t&&(gt.current=[t.rotation[0]+(e.clientX-t.x)*c,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*c)),t.rotation[2]],Qe())},d=t=>{if(!yt.current)return;yt.current=null,e.releasePointerCapture(t.pointerId);const n=gt.current;if(n){gt.current=null;const e=at.current;e&&(e.applyRotation(n,o),Qe())}const r=at.current;r?.scales?.projection&&A?.({projection:r.scales.projection,zoom:r.currentZoom})};return e.addEventListener("pointerdown",l),e.addEventListener("pointermove",u),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("wheel",a),e.removeEventListener("dblclick",s),e.removeEventListener("pointerdown",l),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),dt.current=null}}const r=uz().scaleExtent([t,n]).extent([[0,0],[Fe[0],Fe[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;ht.current=t,pt.current=!0;const n=at.current;n&&(n.applyZoomTransform(t,o),Be.current=!1,Qe())}).on("end",e=>{ht.current=e.transform,pt.current=!1;const t=at.current;t?.scales?.projection&&A?.({projection:t.scales.projection,zoom:t.currentZoom})});return dt.current=r,hz(e).call(r),()=>{hz(e).on(".zoom",null)}},[k,S,rt,Fe,ze,He,Oe,A,Qe]);const Ut=q&&!1!==V,Kt=Ut&&Mt?X?X(Mt):_z(kz,{data:Mt}):null,Qt=Kt?_z(lc,{x:Mt.x,y:Mt.y,containerWidth:ze,containerHeight:He,margin:Oe,className:"stream-frame-tooltip",zIndex:10,children:Kt}):null;if(Ea||!Je&&et){const e=at.current;e&&(tt||s||c)&&(tt&&e.setAreas(tt),s&&e.setPoints(nt),c&&e.setLines(ot),e.computeScene({width:ze,height:He}));const t=e?.scene??[];return Tz("div",{ref:ft,className:"stream-geo-frame"+(j?" "+j:""),role:"img","aria-label":Re||("string"==typeof ge?ge:"Geographic chart"),style:{position:"relative",width:$?"100%":Fe[0],height:B?"100%":Fe[1]},children:[_z(Es,{summary:_e}),Tz("svg",{xmlns:"http://www.w3.org/2000/svg",width:Fe[0],height:Fe[1],style:{position:"absolute",left:0,top:0},children:[_z("g",{transform:`translate(${Oe.left},${Oe.top})`,children:Ge}),Tz("g",{transform:`translate(${Oe.left},${Oe.top})`,children:[E&&_z("rect",{x:0,y:0,width:ze,height:He,fill:E}),t.map((e,t)=>Pl({node:e,index:t,renderMode:O,fallback:()=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=So(n.style.fill)?Mo(n.style.fill,`geoarea-${t}-hatch`):void 0;return Ta(Sa.Fragment,{children:[o&&_a("defs",{children:o}),_a("path",{d:n.pathData,fill:o?`url(#geoarea-${t}-hatch)`:Na(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+t)}case"point":{const n=e,o=So(n.style.fill)?Mo(n.style.fill,`geopoint-${t}-hatch`):void 0;return Ta(Sa.Fragment,{children:[o&&_a("defs",{children:o}),_a("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${t}-hatch)`:Na(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const o="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return _a("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return Ba(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)}))]})]}),_z(lz,{width:ze,height:He,totalWidth:Fe[0],totalHeight:Fe[1],margin:Oe,showAxes:!1,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,foregroundGraphics:Fn(We,Gn(at.current?.customLayoutOverlays,h??null)),annotations:te,onAnnotationActivate:ne,onObservation:J??Z,chartId:ee,chartType:"StreamGeoFrame",autoPlaceAnnotations:oe,pointNodes:vz(t)})]})}return Tz("div",{ref:ft,className:"stream-geo-frame"+(j?" "+j:""),role:"group","aria-label":Re||("string"==typeof ge?ge:"Geographic chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Fe[0],height:B?"100%":Fe[1],overflow:U?"visible":"hidden",...k?{touchAction:"none"}:{}},onKeyDown:Yt,children:["production"!==process.env.NODE_ENV&&at.current&&_z(jn,{store:at.current,diagnostics:At.current}),Ie&&_z(Fs,{tableId:Ve}),Ie&&_z(Ds,{scene:at.current?.scene??[],chartType:"Geographic chart",tableId:Ve,chartTitle:"string"==typeof ge?ge:void 0}),_z(Es,{summary:_e}),_z(ms,{hoverPoint:Mt}),Tz("div",{role:"img","aria-label":Re||("string"==typeof ge?ge:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Ut?Vt:void 0,onPointerLeave:Ut?Ot:void 0,onPointerDown:Ut||Ne?Xt:void 0,onClick:Ne?Wt:void 0,children:[_z(Dc,{size:Fe,margin:Oe,children:Ge}),I&&_z("canvas",{ref:st,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),_z("canvas",{ref:zt,"aria-label":ws(at.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),_z("canvas",{ref:Ht,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),_z(lz,{width:ze,height:He,totalWidth:Fe[0],totalHeight:Fe[1],margin:Oe,showAxes:Pe,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,foregroundGraphics:Fn(We,Gn(at.current?.customLayoutOverlays,h??null)),annotations:te,onAnnotationActivate:ne,onObservation:J??Z,chartId:ee,chartType:"StreamGeoFrame",autoPlaceAnnotations:oe,pointNodes:vz(at.current?.scene)}),ce?.showBadge&&_z(ur,{isStale:_t,position:ce.badgePosition}),k&&Tz("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Oe.bottom+8,left:Oe.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[_z("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=mt.current,n=dt.current;t&&n?.scaleBy&&n.scaleBy(hz(t),1.5)},style:Pz,children:"+"}),_z("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=mt.current,n=dt.current;t&&n?.scaleBy&&n.scaleBy(hz(t),1/1.5)},style:Pz,children:"−"})]}),R&&_z("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Oe.bottom+2,right:Oe.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:R}),_z(Hs,{active:Gt.current>=0,hoverPoint:Mt,margin:Oe,size:Fe,shape:qt.current?.shape,width:qt.current?.w,height:qt.current?.h,pathData:qt.current?.pathData}),Qt]})]})}));Lz.displayName="StreamGeoFrame";var Nz=Lz;import{jsx as $z}from"react/jsx-runtime";var Bz=hO(function(e,t){const{points:n,areas:o,lines:r,layout:i,layoutConfig:a,onLayoutError:s,projection:c="equirectangular",xAccessor:l="lon",yAccessor:d="lat",lineDataAccessor:h,colorBy:p,colorScheme:m,tooltip:f,annotations:y,margin:g,selection:b,linkedHover:v,onObservation:x,onClick:w,chartId:k,loading:S,loadingContent:A,emptyContent:C,className:M,frameProps:P={}}=e,{frameRef:I,resolved:R,normalizedMargin:_}=eO({imperativeRef:t,imperativeVariant:"geo-points",margin:g,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),T=pO(()=>u(n),[n]),L=pO(()=>u(o),[o]),N=pO(()=>u(r),[r]),$=pO(()=>[...T,...N,...L],[T,N,L]),B=wh({data:$,rawData:void 0!==n||void 0!==r||void 0!==o?$: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:_,marginDefaults:R.marginDefaults,loading:S,loadingContent:A,emptyContent:C,width:R.width,height:R.height}),D=B.effectiveSelectionHook,j=pO(()=>D?.isActive?{isActive:!0,predicate:D.predicate}:null,[D?.isActive,D?.predicate]);if(B.earlyReturn)return B.earlyReturn;const{width:E,height:F,enableHover:O,title:z,description:H,summary:W,accessibleTable:G}=R,q=sc(f),Y={projection:c,...null!=n&&{points:T},...null!=o&&{areas:L},...null!=r&&{lines:N},xAccessor:l,yAccessor:d,...null!=h&&{lineDataAccessor:h},customLayout:i,layoutConfig:a,onLayoutError:s,layoutSelection:j,colorBy:p,colorScheme:m,size:[E,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B.margin,enableHover:O,...$h({title:z,description:H,summary:W,accessibleTable:G,className:M,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations}),...!1===f?{tooltipContent:()=>null}:q?{tooltipContent:q}:{},...Bh({linkedHover:v,selection:b,onObservation:x,onClick:w,hoverHighlight:!1,mobileInteraction:B.mobileInteraction,customHoverBehavior:B.customHoverBehavior,customClickBehavior:B.customClickBehavior,linkedHoverInClickPredicate:!1}),...y&&y.length>0&&{annotations:y},...P};return $z(oh,{componentName:"GeoCustomChart",width:E,height:F,children:$z(Nz,{ref:I,...Y})})});function Dz(e){const t=NT(e.recipe)??(e.recipeId?IT(e.recipeId):void 0);if(!t)throw Error(`Unknown chart recipe "${e.recipeId??"(missing recipeId)"}". Register it before rendering.`);const n=function(e){return"function"==typeof e.layout?e.layout:mT(e.layout)?LT(e.layout.id):void 0}(t);if(!n){const e=mT(t.layout)?t.layout.id:t.id;throw Error(`No runtime layout registered for chart recipe "${t.id}" (${e}).`)}const o="semiotic-chart-recipe semiotic-chart-recipe-"+t.id.replace(/[^a-zA-Z0-9_-]+/g,"-"),r={...e,chartId:e.chartId??t.id,className:e.className?`${o} ${e.className}`:o,recipeId:t.id,recipe:t,layout:n},i="XYFrame"===t.frameFamily||"XYCustomChart"===t.frameFamily?oO:"OrdinalFrame"===t.frameFamily||"OrdinalCustomChart"===t.frameFamily?sO:"NetworkFrame"===t.frameFamily||"NetworkCustomChart"===t.frameFamily?dO:"GeoFrame"===t.frameFamily||"GeoCustomChart"===t.frameFamily?Bz:void 0;if(!i)throw Error(`Chart recipe "${t.id}" uses unsupported frame family "${t.frameFamily}".`);return UF.createElement(i,r)}function jz(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function Ez(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function Fz(e){return"number"==typeof e&&Number.isFinite(e)}function Oz(e){if(Fz(e.x)&&Fz(e.y)&&Fz(e.w)&&Fz(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(Fz(e.x)&&Fz(e.y)&&Fz(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(Fz(e.cx)&&Fz(e.cy)&&Fz(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(Fz(e.cx)&&Fz(e.cy)&&Fz(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)&&Fz(e[0])&&Fz(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 zz(e,t){const n=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)),o=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 o>0?n/o:0}function Hz(e,t,n,o,r){if(e===t)return!0;const i=n.dataRoles.map(e=>ET(e,o,r)).filter(e=>!!e).filter(n=>null!=e[n]&&null!=t[n]);return i.length>0&&i.every(n=>e[n]+""==t[n]+"")}function Wz(e,t,n,o,r,i="warn",a){return{id:e,category:t,status:n?"pass":i,message:n?o:r,...a?{evidence:a}:{}}}function Gz(e){const{recipe:t}=e,n=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(e.scene),o=e.layoutConfig??BT({layoutConfig:e.layoutConfig}),r=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},i=r.x??0,a=r.y??0,s=[],c=n.filter(e=>null!=Ez(e)),l=n.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(Wz("geometry.finite","geometry",0===l.length,"All emitted geometry is finite.",l.length+" marks contain non-finite geometry.","fail",{count:l.length}));const u=n.map(Oz),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;s.push(Wz("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+r.width||e.y1>a+r.height)).length;s.push(Wz("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(Wz("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=c.map(jz),y=f.filter(e=>!e).length,g=new Set,b=f.filter(e=>!(!e||!g.has(e)&&(g.add(e),1)));s.push(Wz("identity.stable-ids","identity",0===y,"Every data-bearing mark exposes a stable id.",y+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:y})),s.push(Wz("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 c){const n=Ez(e),r=Array.isArray(n)?n:[n];let i=!1;for(const e of r)if(e&&"object"==typeof e)for(let n=0;k.length>n;n+=1)Hz(e,k[n],t,o,k)&&(x.add(n),i=!0);i||(w+=1)}const S=Math.max(0,k.length-x.size);s.push(Wz("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(Wz("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&&c.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=c.filter(e=>!1===e.interactive).length;s.push(Wz("interaction.hit-targets","interaction",0===C&&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.":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=>!g.has(e));s.push(Wz("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=>!g.has(e));e.chart?.selectedIds&&s.push(Wz("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 R=bs(n),_=(t.accessibility.tableFields??t.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const n=e.role?t.dataRoles.find(t=>t.role===e.role):void 0;return n?ET(n,o,k):void 0}).filter(e=>!!e),T=new Set(R.flatMap(e=>Object.keys(e.values))),L=_.filter(e=>!T.has(e));s.push(Wz("accessibility.table-fields","accessibility",0===L.length,_.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${L.join(", ")}.`,"fail",{expectedFields:_,observedFields:[...T]})),new Set(k.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=T.size&&[...T].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(Wz("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,n]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])n&&s.push(Wz("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(Wz("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(Wz("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=n.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!B.startsWith("#"))return!1;const n=mB(t,B);return null!=n&&3>n}).length;s.push(Wz("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 j=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>zz(E[e],E[t])||(j+=1);j>E.length&&s.push({id:"visual.overlap-density",category:"visual",status:"warn",message:j+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const F=[["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})),O={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map($T).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},z=[...s,...F],H=s.filter(e=>"fail"===e.status).length;return{recipeId:t.id,ok:0===H,summary:{marks:n.length,passes:z.filter(e=>"pass"===e.status).length,warnings:z.filter(e=>"warn"===e.status).length,failures:H,manual:z.filter(e=>"manual"===e.status).length},declaredSemantics:O,observedSceneEvidence:s,manualATChecks:F}}Bz.displayName="GeoCustomChart";import*as qz from"react";function Yz(e){const t=e.designContract?.chartFamily??e.title??"chart",n=e.audience?.primary?" for "+e.audience.primary:"",o=e.designContract?.whyThisForm;return`${t}: ${e.intent.primary}${n}${o?". "+o:""}`}function Vz(e,t){const n=e.intents.map(e=>"string"==typeof e?e:e.id??e.name).filter(e=>!!e),o=e.intents.find(e=>"string"!=typeof e&&"primary"===e.strength),r=("object"==typeof o?o.id??o.name:void 0)??n[0]??"explanation";return{ididVersion:"0.1",chartId:t.chartId,title:t.title??e.name,intent:{primary:r,secondary:n.filter(e=>e!==r)},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 Xz,jsxs as Uz}from"react/jsx-runtime";function Kz({manifest:e,label:t="Intent Mark",className:n,showSummary:o=!0}){const[r,i]=qz.useState(!1),a=qz.useMemo(()=>JSON.stringify(e,null,2),[e]),s=qz.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(a),i(!0),window.setTimeout(()=>i(!1),1200))},[a]);return Uz("details",{className:n?"semiotic-intent-mark "+n:"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:[Uz("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),Uz("div",{style:{padding:"0 10px 10px"},children:[o&&Xz("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:Yz(e)}),Xz("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:r?"Copied":"Copy manifest"}),Xz("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 Qz=[{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"}],Zz=new Map(Qz.map(e=>[e.id,e]));function Jz(e){return Zz.get(e)}function eH(){return Array.from(Zz.values())}function tH(e){Zz.set(e.id,e)}var nH=new Set(Qz.map(e=>e.id)),oH=new Set;function rH(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function iH(e,t){return void 0===e?0:rH("function"==typeof e?e(t):e,0,5)}function aH(e){return e?Array.isArray(e)?[...e]:[e]:[]}function sH(e,t,n){const o={};for(const[n,r]of Object.entries(e.intentScores))o[n]=iH(r,t);if(n)for(const[e,t]of Object.entries(n))o[e]=rH((o[e]??0)+t,0,5);return o}function cH(e,t){if(t.length>0)return t.reduce((t,n)=>t+(e[n]??0),0)/t.length;const n=Object.values(e).filter(e=>"number"==typeof e&&e>0);return n.length?n.reduce((e,t)=>e+t,0)/n.length:0}function lH(e,t){return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:n=>e.buildProps(n,t),rationale:t.description??`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function uH(e,t,n){return e.some(e=>e.props?.[t]===n)}var dH=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var hH=(e,t,n)=>function(e,t,n){const o=new Map,r=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(o.has(t.id)||o.set(t.id,t))};r(function(e,t,n){const o=n.profile,r=n.existingVariants??t.variants??[],i=aH(n.intent),a=[];for(const e of r)a.push(lH(t,e));const s=i.includes("rank")||i.includes("compare-categories");!dH.has(e)||"categorical"!==t.family||uH(r,"orientation","horizontal")||!s&&6>(o.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 c=uH(r,"normalize",!0)||uH(r,"type","percent")||r.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!c&&(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=Jj().filter(t=>t.component!==e).filter(e=>null===e.fits(o)).map(e=>{const t=sH(e,o);return{candidate:e,fit:cH(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:n}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 (${n.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return a}(e,t,n));for(const o of oH)try{r(o(e,t,n)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(o.values())}(e,t,n),pH=(e,t,n,o={})=>{const r=eE(e.baseComponent);if(!r)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const i=r.fits(t);if(null!==i)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+i]};const a=aH(o.intent),s=sH(r,t,e.intentDeltas),c=cH(s,a),l=function(e,t){return t?{familiarity:Math.round(rH((n={familiarity:e.familiarity+(t.familiarity??0),accuracy:e.accuracy+(t.accuracy??0),precision:e.precision+(t.precision??0)}).familiarity,1,5)),accuracy:Math.round(rH(n.accuracy,1,5)),precision:Math.round(rH(n.precision,1,5))}:e;var n}(r.rubric,e.rubricDeltas);let u;const d=n?.receptionModality;if(d&&"visual"!==d){const o=e.variantKey?r.variants?.find(t=>t.key===e.variantKey):void 0,i=e.buildProps?e.buildProps(t,n):r.buildProps(t,o);u=oE(UB(e.baseComponent,i),d)}const h=rE(c,l,e.baseComponent,n,u),p=rH(h.score,0,5);let m="manual"===e.source?.15:"heuristic"===e.source?.45:.75;o.baselineComponent&&o.baselineComponent!==e.baseComponent&&(m+=.2),e.variantKey||(m+=.05),m=rH(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),l.accuracy>3||(f+=.1),3>p&&(f+=.2),f=rH(f,0,1);const y=[];if(e.rationale&&y.push(e.rationale),a.length>0){const e=a.map(e=>`${e}: ${(s[e]??0).toFixed(1)}/5`).join(", ");y.push(`Intent fit — ${e}.`)}else y.push(`Mean non-zero intent fit ${c.toFixed(1)}/5.`);return"manual"!==e.source&&y.push(e.source+" proposal; verify against domain context."),h.appliedReason&&y.push(h.appliedReason),h.receivabilityReason&&y.push(h.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&y.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:p,novelty:m,risk:f,reasons:y}};function mH(e){return oH.add(e),()=>{oH.delete(e)}}function fH(){return Array.from(oH)}function yH(){oH.clear()}import{useCallback as gH,useEffect as bH,useMemo as vH,useState as xH,useSyncExternalStore as wH}from"react";var kH={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function SH(e){if(0===e.length)return kH;const t={},n=new Set,o=[];let r;for(const i of e){t[i.type]=(t[i.type]??0)+1,i.arcId&&(r=i.arcId);const e="component"in i&&"string"==typeof i.component?i.component:void 0;if(e&&n.add(e),"from"in i&&"string"==typeof i.from&&n.add(i.from),"to"in i&&"string"==typeof i.to&&n.add(i.to),"components"in i&&Array.isArray(i.components))for(const e of i.components)"string"==typeof e&&n.add(e);"audience-set"===i.type&&"string"==typeof i.audience&&o.push(i.audience)}const i=e[0].timestamp,a=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(n),audiencesSeen:o,latestArcId:r,startedAt:i,lastAt:a,durationMs:Math.max(0,a-i)}}function AH(e={}){const{enableOnMount:t=!0,disableOnUnmount:n=!1,capacity:o,sessionId:r}=e;bH(()=>(t&&MN({capacity:o,sessionId:r}),()=>{n&&PN()}),[t,n,o,r]);const i=gH(e=>fN(e),[]),a=gH(()=>IN().getEvents(),[]),s=wH(i,a,a),[c,l]=xH(()=>IN().enabled),[u,d]=xH(()=>IN().sessionId);bH(()=>(l(IN().enabled),d(IN().sessionId),fN(()=>{const e=IN();l(e.enabled),d(e.sessionId)})),[]);const h=vH(()=>SH(s),[s]),p=gH(e=>IN().record(e),[]),m=gH(()=>IN().clear(),[]);return{history:s,summary:h,enabled:c,sessionId:u,record:p,clear:m}}import{Fragment as CH,jsx as MH,jsxs as PH}from"react/jsx-runtime";function IH({items:e,title:t="Additional notes",empty:n=null,ordered:o=!0,renderItem:r,className:i,style:a}){if(!e.length)return n?MH(CH,{children:n}):null;const s=o?"ol":"ul";return PH("section",{className:["semiotic-mobile-annotation-callouts",i].filter(Boolean).join(" "),style:a,children:[MH("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&&MH("h3",{children:t}),MH(s,{children:e.map((e,t)=>MH("li",{children:r?r(e,t):PH(CH,{children:[MH("span",{children:e.label}),(e.source||e.emphasis)&&MH("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}export{NN as AccessibleNavTree,op as AreaChart,nj as AreaChartCapability,bF as BUILT_IN_AUDIENCES,nH as BUILT_IN_INTENT_IDS,Qy as BarChart,yj as BarChartCapability,Z_ as BigNumber,Sg as BoxPlot,Rj as BoxPlotCapability,Yp as BubbleChart,aj as BubbleChartCapability,OF as CANONICAL_FIXTURES,rf as CandlestickChart,dj as CandlestickChartCapability,Au as CategoryColorProvider,M$ as ChartContainer,G$ as ChartGrid,Dz as ChartRecipe,Mk as ChordDiagram,Bj as ChordDiagramCapability,Hj as ChoroplethMapCapability,dS as CirclePack,Oj as CirclePackCapability,lR as CollisionSwarmChart,Op as ConnectedScatterplot,ij as ConnectedScatterplotCapability,U$ as ContextLayout,Ke as DEFAULT_LIFECYCLE_THRESHOLDS,HD as DEFAULT_SCALE_THRESHOLDS,nB as DetailsPanel,pp as DifferenceChart,uj as DifferenceChartCapability,qj as DistanceCartogramCapability,tb as DonutChart,wj as DonutChartCapability,Og as DotPlot,vj as DotPlotCapability,FI as EventDropChart,Gj as FlowMapCapability,wk as ForceDirectedGraph,Nj as ForceDirectedGraphCapability,vb as FunnelChart,Sj as FunnelChartCapability,LI as GaltonBoardChart,pb as GaugeChart,Aj as GaugeChartCapability,N_ as GauntletChart,sg as GroupedBarChart,gj as GroupedBarChartCapability,Zp as Heatmap,hj as HeatmapCapability,_g as Histogram,Ij as HistogramCapability,Kz as IntentMark,Wb as LikertChart,Mj as LikertChartCapability,Uh as LineChart,tj as LineChartCapability,hd as LinkedCharts,Im as MinimapChart,lj as MinimapChartCapability,IH as MobileAnnotationCalloutList,T$ as MobileChartContainer,VN as MobileStandardControls,Zm as MultiAxisLineChart,cj as MultiAxisLineChartCapability,ic as MultiLineTooltip,fS as OrbitDiagram,zj as OrbitDiagramCapability,CR as PhysicalFlowChart,XI as PhysicsCustomChart,tR as PhysicsPileChart,Kg as PieChart,xj as PieChartCapability,HR as ProcessFlowChart,tS as ProcessSankey,Dj as ProcessSankeyCapability,Wj as ProportionalSymbolMapCapability,Om as QuadrantChart,sj as QuadrantChartCapability,wA as RealtimeHeatmap,nA as RealtimeHistogram,XS as RealtimeLineChart,lA as RealtimeSwarmChart,fA as RealtimeWaterfallChart,qg as RidgelinePlot,Lj as RidgelinePlotCapability,Tk as SankeyDiagram,$j as SankeyDiagramCapability,Np as Scatterplot,rj as ScatterplotCapability,ym as ScatterplotMatrix,F$ as SmallMultipleChart,bp as StackedAreaChart,oj as StackedAreaChartCapability,ng as StackedBarChart,bj as StackedBarChartCapability,fg as SwarmPlot,_j as SwarmPlotCapability,Xb as SwimlaneChart,Pj as SwimlaneChartCapability,oA as TemporalHistogram,Md as ThemeProvider,eT as TooltipProvider,rS as TreeDiagram,jj as TreeDiagramCapability,cS as Treemap,Fj as TreemapCapability,Bg as ViolinPlot,Tj as ViolinPlotCapability,KB as accessibilityCaveats,yF as analystPersona,uL as annotationFreshnessFor,vi as annotationStableId,fL as applyAnnotationLifecycle,wL as applyAnnotationStatus,rE as applyAudienceBias,JD as applyScaleBias,UB as auditAccessibility,i$ as auditMobileVisualization,Gz as auditObservedScene,dT as auditVisualizationControls,Qe as bandFromAge,UL as buildNavigationTree,IE as buildReaderGrounding,XL as buildRecipeNavigationTree,UE as chartGenerationTool,jN as clampMobileRange,YD as classifyCardinalityBand,VD as classifyFieldBand,qD as classifyRowBand,yH as clearVariantDiscovery,NL as communicativeActForIntent,XD as compareBands,dL as computeAnnotationFreshness,QD as computeEffectiveScale,QT as configToJSX,KT as copyConfig,QL as countNodes,eF as createChartToolHandler,bN as createIndexedDBConversationArcSink,gN as createLocalStorageConversationArcSink,vN as createWebhookConversationArcSink,aL as currentTimestamp,FE as dataQualityToAnnotations,gF as dataScientistPersona,hT as defineChartRecipe,GL as describeChart,kL as describeRecipeChart,tD as deserializeSelections,WB as diagnoseConfig,lB as diagnoseTokenEncoding,TF as diffProfile,PN as disableConversationArc,iE as effectiveFamiliarity,MN as enableConversationArc,pH as evaluateVariantProposal,fF as executivePersona,mE as explainCapabilityFit,nT as exportChart,xL as filterAnnotationsByStatus,KL as flattenVisible,JB as formatAccessibilityAudit,c$ as formatMobileVisualizationAudit,VT as fromConfig,HE as fromDbtArtifacts,qE as fromGreatExpectations,UT as fromURL,sD as fromVegaLite,Jj as getCapabilities,eE as getCapability,IT as getChartRecipe,IN as getConversationArcStore,Jz as getIntent,LT as getRecipeLayout,fH as getRegisteredVariantDiscovery,SF as getStreamCapabilities,hF as inferIntent,Vz as intentManifestFromRecipe,fT as isJsonSafe,mT as isRegisteredRecipeLayout,RT as listChartRecipes,eH as listIntents,xN as loadConversationArc,l$ as mobileVisualizationCaveats,cB as normalizeTokenEncoding,XE as prepareChart,zD as profileData,hH as proposeVariant,oE as receivabilityBias,ST as recipeToChartCapability,SN as recordAnnotationStatusChange,kN as recordAudienceChange,Qj as registerChartCapability,MT as registerChartRecipe,yN as registerConversationArcSink,tH as registerIntent,_T as registerRecipeLayout,wF as registerStreamChartCapability,mH as registerVariantDiscovery,YE as repairChartConfig,wN as replayConversationArc,KD as resolveCardinalityToNumber,NT as resolveChartRecipe,$L as resolveCommunicativeAct,kT as resolveRecipeRoleField,_d as resolveResponsiveRules,UD as resolveRowsToNumber,Rd as responsiveRuleMatches,LF as runQualityScorecard,ej as scaleHints,fE as scoreChart,eD as serializeSelections,aE as stretchFamiliarityCeiling,fN as subscribeToConversationArcChange,pE as suggestCharts,yE as suggestChartsGrouped,mF as suggestDashboard,PF as suggestStreamCharts,pF as suggestStretchCharts,hB as suggestTokenEncoding,SH as summarizeArc,vD as summarizeData,Yz as summarizeIntentManifest,KE as toAnthropicTool,YT as toConfig,JE as toOpenAIResponsesTool,QE as toOpenAITool,XT as toURL,dB as tokenTaskIntentToCapabilityIntents,Zj as unregisterChartCapability,PT as unregisterChartRecipe,TT as unregisterRecipeLayout,kF as unregisterStreamChartCapability,Xu as useBrushSelection,Cu as useCategoryColors,NE as useChartFocus,_E as useChartInterrogation,Zu as useChartObserver,XF as useChartSuggestions,AH as useConversationArc,Ku as useFilteredData,od as useLinkedChartsActive,Yu as useLinkedHover,FN as useMobileRangeControls,uF as useNavigationSync,Gu as useSelection,qu as useSelectionActions,Pd as useTheme,pT as validateChartRecipe,aB as validateProps,sL as withCurrentProvenance,iL as withProvenance,EN as zoomMobileRange};