semiotic 3.8.9 → 3.9.0

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 (500) hide show
  1. package/README.md +83 -67
  2. package/agent-skill/semiotic-charts/SKILL.md +11 -2
  3. package/ai/behaviorContracts.cjs +33 -3
  4. package/ai/cli.js +53 -2
  5. package/ai/componentMetadata.cjs +15 -0
  6. package/ai/dist/mcp-server.js +1530 -611
  7. package/ai/examples.md +48 -42
  8. package/{CLAUDE.md → ai/reference.md} +43 -22
  9. package/ai/schema.json +10603 -986
  10. package/ai/surface-manifest.json +643 -2
  11. package/ai/system-prompt.md +83 -130
  12. package/dist/c-3BLJEQNG.min.js +1 -0
  13. package/dist/c-3KZD6AXJ.min.js +1 -0
  14. package/dist/c-4TWEX5HG.min.js +1 -0
  15. package/dist/c-52TEGIUJ.min.js +1 -0
  16. package/dist/c-5YCIX3VZ.min.js +1 -0
  17. package/dist/c-6FEKTA3U.min.js +1 -0
  18. package/dist/c-6O5EVOPH.min.js +1 -0
  19. package/dist/c-74HEEZGK.min.js +1 -0
  20. package/dist/c-AKAF6JAD.min.js +1 -0
  21. package/dist/c-BBKITSXB.min.js +1 -0
  22. package/dist/c-BWNB6USU.min.js +1 -0
  23. package/dist/c-C25ENHIK.min.js +1 -0
  24. package/dist/c-CDR5AO3R.min.js +1 -0
  25. package/dist/c-COHXCW3Q.min.js +1 -0
  26. package/dist/{chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js → c-DADXPJXV.min.js} +0 -1
  27. package/dist/c-E3JFRRMI.min.js +1 -0
  28. package/dist/c-EBFPQHHO.min.js +1 -0
  29. package/dist/c-G36WS6LN.min.js +1 -0
  30. package/dist/c-GIKRQI4X.min.js +1 -0
  31. package/dist/c-GPYOFETM.min.js +1 -0
  32. package/dist/c-IDUHYYSI.min.js +1 -0
  33. package/dist/{chunk-chunk-FQPKOAIH.module.min.js → c-IUHFPMHD.min.js} +0 -1
  34. package/dist/c-J5G56TUH.min.js +1 -0
  35. package/dist/c-JAZ73J32.min.js +1 -0
  36. package/dist/c-KG3NXHAL.min.js +1 -0
  37. package/dist/c-KII3PLZE.min.js +1 -0
  38. package/dist/c-LIXGXMNS.min.js +1 -0
  39. package/dist/c-LVEY6D6B.min.js +1 -0
  40. package/dist/c-M4Y3BHFR.min.js +1 -0
  41. package/dist/c-MAIICR2Z.min.js +1 -0
  42. package/dist/c-MG5DM6VE.min.js +1 -0
  43. package/dist/{chunk-minimapBrushOverlay-JU57U7NM.module.min.js → c-MNF2S4AA.min.js} +0 -1
  44. package/dist/c-MT3WBK7M.min.js +1 -0
  45. package/dist/c-NY3JWV2K.min.js +1 -0
  46. package/dist/c-O6U6K4CW.min.js +1 -0
  47. package/dist/c-OCI56QF2.min.js +1 -0
  48. package/dist/c-OQ7M4AGV.min.js +1 -0
  49. package/dist/c-OXYMVK7Q.min.js +1 -0
  50. package/dist/c-PPWDL5ZI.min.js +1 -0
  51. package/dist/c-QHF5YON3.min.js +1 -0
  52. package/dist/c-RR3GO5SW.min.js +1 -0
  53. package/dist/{chunk-chunk-J5QD4RAM.module.min.js → c-RSVIHIQ4.min.js} +0 -1
  54. package/dist/{chunk-chunk-EMO5NUGE.module.min.js → c-S2BXNNJN.min.js} +0 -1
  55. package/dist/{chunk-chunk-YCQYG6J5.module.min.js → c-SLGMUBUL.min.js} +0 -1
  56. package/dist/c-SUILCHWU.min.js +1 -0
  57. package/dist/c-TZW3JGJ5.min.js +1 -0
  58. package/dist/c-US5ZFT6E.min.js +1 -0
  59. package/dist/{chunk-chunk-RZH7VZYS.module.min.js → c-USFMFKIH.min.js} +0 -1
  60. package/dist/c-UUKVD4WB.min.js +1 -0
  61. package/dist/{chunk-chunk-SV4XAZ3Q.module.min.js → c-VGW3VG3I.min.js} +0 -1
  62. package/dist/c-W3CE4A4S.min.js +1 -0
  63. package/dist/{chunk-chunk-2NVFEB7P.module.min.js → c-WJCD5EUY.min.js} +0 -1
  64. package/dist/{chunk-chunk-2JGJ5GUG.module.min.js → c-X5UBGU2V.min.js} +0 -1
  65. package/dist/c-YDAY2WFR.min.js +1 -0
  66. package/dist/c-ZOWWU34K.min.js +1 -0
  67. package/dist/components/AccessibleNavTree.d.ts +1 -1
  68. package/dist/components/CategoryColors.d.ts +1 -1
  69. package/dist/components/GradientLegend.d.ts +14 -0
  70. package/dist/components/Legend.d.ts +2 -7
  71. package/dist/components/LinkedCharts.d.ts +1 -1
  72. package/dist/components/MobileAnnotationCalloutList.d.ts +1 -1
  73. package/dist/components/ObservationReadout.d.ts +45 -0
  74. package/dist/components/ThemeProvider.d.ts +4 -4
  75. package/dist/components/Tooltip/FlippingTooltip.d.ts +5 -7
  76. package/dist/components/Tooltip/Tooltip.d.ts +30 -5
  77. package/dist/components/Tooltip/tooltipChrome.d.ts +43 -0
  78. package/dist/components/ai/chartCapabilityTypes.d.ts +86 -2
  79. package/dist/components/ai/chartClinic.d.ts +2 -0
  80. package/dist/components/ai/deriveProfileFields.d.ts +40 -0
  81. package/dist/components/ai/evaluateChart.d.ts +85 -0
  82. package/dist/components/ai/fieldPolicy.d.ts +7 -0
  83. package/dist/components/ai/fieldRoles.d.ts +24 -0
  84. package/dist/components/ai/generativeChart.d.ts +18 -2
  85. package/dist/components/ai/inferIntent.d.ts +26 -2
  86. package/dist/components/ai/intents.d.ts +35 -0
  87. package/dist/components/ai/navigationTree.d.ts +2 -2
  88. package/dist/components/ai/observedSceneAudit.d.ts +2 -1
  89. package/dist/components/ai/profileData.d.ts +11 -0
  90. package/dist/components/ai/repairChartConfig.d.ts +2 -3
  91. package/dist/components/ai/semanticEvidence.d.ts +4 -0
  92. package/dist/components/ai/semanticViability.d.ts +11 -0
  93. package/dist/components/ai/semanticViabilityRegistry.d.ts +5 -0
  94. package/dist/components/ai/streamingTypes.d.ts +4 -0
  95. package/dist/components/ai/suggestCharts.d.ts +5 -6
  96. package/dist/components/ai/suggestDashboard.d.ts +2 -3
  97. package/dist/components/ai/suggestStreamCharts.d.ts +1 -1
  98. package/dist/components/ai/suggestStretchCharts.d.ts +2 -3
  99. package/dist/components/ai/suggestionPropContracts.d.ts +20 -0
  100. package/dist/components/ai/variantDiscovery.d.ts +3 -1
  101. package/dist/components/charts/custom/NetworkCustomChart.d.ts +3 -0
  102. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +3 -0
  103. package/dist/components/charts/custom/XYCustomChart.d.ts +1 -1
  104. package/dist/components/charts/geo/ChoroplethMap.d.ts +3 -1
  105. package/dist/components/charts/geo/DistanceCartogram.d.ts +2 -7
  106. package/dist/components/charts/geo/cartogramOverlay.d.ts +28 -0
  107. package/dist/components/charts/index.d.ts +4 -3
  108. package/dist/components/charts/network/ProcessSankey.d.ts +2 -136
  109. package/dist/components/charts/network/ProcessSankeyProps.d.ts +139 -0
  110. package/dist/components/charts/network/Treemap.d.ts +2 -1
  111. package/dist/components/charts/network/processSankey/boundaryHubOrdering.d.ts +23 -0
  112. package/dist/components/charts/network/processSankey/layoutGeometry.d.ts +2 -0
  113. package/dist/components/charts/network/processSankey/ordering.d.ts +3 -41
  114. package/dist/components/charts/network/processSankey/orderingTypes.d.ts +32 -0
  115. package/dist/components/charts/network/processSankey/packing.d.ts +1 -1
  116. package/dist/components/charts/network/processSankey/packingCache.d.ts +1 -1
  117. package/dist/components/charts/network/processSankey/packingOptimization.d.ts +72 -0
  118. package/dist/components/charts/ordinal/BarChart.d.ts +4 -3
  119. package/dist/components/charts/ordinal/FunnelChart.d.ts +2 -0
  120. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -2
  121. package/dist/components/charts/ordinal/StackedBarChart.d.ts +4 -3
  122. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +2 -2
  123. package/dist/components/charts/physics/GaltonBoardChart.d.ts +2 -9
  124. package/dist/components/charts/physics/GauntletChart.d.ts +10 -41
  125. package/dist/components/charts/physics/ProcessFlowChart.d.ts +1 -1
  126. package/dist/components/charts/physics/chainReactionAccessibleTable.d.ts +9 -0
  127. package/dist/components/charts/physics/chainReactionRuntime.d.ts +2 -1
  128. package/dist/components/charts/physics/chainReactionTypes.d.ts +5 -1
  129. package/dist/components/charts/physics/crucibleBodyRenderers.d.ts +2 -2
  130. package/dist/components/charts/physics/crucibleClone.d.ts +6 -0
  131. package/dist/components/charts/physics/crucibleEffects.d.ts +1 -2
  132. package/dist/components/charts/physics/crucibleRecord.d.ts +7 -0
  133. package/dist/components/charts/physics/gauntletChrome.d.ts +4 -4
  134. package/dist/components/charts/physics/gauntletPhysics.d.ts +1 -0
  135. package/dist/components/charts/physics/gauntletPublic.d.ts +4 -0
  136. package/dist/components/charts/physics/packetFlowOverlay.d.ts +7 -0
  137. package/dist/components/charts/physics/physicsChartLayout.d.ts +8 -0
  138. package/dist/components/charts/physics/physicsChartShared.d.ts +3 -1
  139. package/dist/components/charts/physics/physicsChartUtils.d.ts +1 -1
  140. package/dist/components/charts/physics/physicsHocUtils.d.ts +25 -12
  141. package/dist/components/charts/physics/physicsProjectionOverlays.d.ts +24 -0
  142. package/dist/components/charts/physics/processFlowOverlays.d.ts +9 -0
  143. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +15 -12
  144. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +10 -7
  145. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +35 -14
  146. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +21 -14
  147. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +20 -13
  148. package/dist/components/charts/realtime/aggregate.d.ts +4 -1
  149. package/dist/components/charts/realtime/eventTime.d.ts +4 -0
  150. package/dist/components/charts/realtime/realtimeChartRuntime.d.ts +27 -0
  151. package/dist/components/charts/realtime/realtimeChartTypes.d.ts +30 -0
  152. package/dist/components/charts/realtime/useRealtimeCategoryColors.d.ts +30 -0
  153. package/dist/components/charts/shared/FrameTextAnnotationSVG.d.ts +10 -0
  154. package/dist/components/charts/shared/annotationActivation.d.ts +3 -7
  155. package/dist/components/charts/shared/annotationBandFill.d.ts +6 -0
  156. package/dist/components/charts/shared/annotationDispatch.d.ts +31 -0
  157. package/dist/components/charts/shared/annotationIdentity.d.ts +8 -0
  158. package/dist/components/charts/shared/annotationRules.d.ts +1 -15
  159. package/dist/components/charts/shared/boundedCategoryRegistry.d.ts +8 -0
  160. package/dist/components/charts/shared/chainReactionChartSpec.d.ts +3 -0
  161. package/dist/components/charts/shared/chartMode.d.ts +3 -2
  162. package/dist/components/charts/shared/chartSpecCore.d.ts +1 -0
  163. package/dist/components/charts/shared/frameTextAnnotation.d.ts +63 -0
  164. package/dist/components/charts/shared/gradient.d.ts +16 -0
  165. package/dist/components/charts/shared/hatchFill.d.ts +15 -0
  166. package/dist/components/charts/shared/hooks.d.ts +4 -4
  167. package/dist/components/charts/shared/legendUtils.d.ts +1 -0
  168. package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -1
  169. package/dist/components/charts/shared/styleRules.d.ts +9 -2
  170. package/dist/components/charts/shared/styleRulesWireSchema.d.ts +353 -0
  171. package/dist/components/charts/shared/types.d.ts +18 -9
  172. package/dist/components/charts/shared/useChartLegend.d.ts +43 -9
  173. package/dist/components/charts/shared/useChartSetup.d.ts +3 -1
  174. package/dist/components/charts/shared/useCustomChartSetup.d.ts +5 -2
  175. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +5 -1
  176. package/dist/components/charts/shared/useOrdinalBrush.d.ts +3 -3
  177. package/dist/components/charts/shared/useStreamingLegend.d.ts +6 -1
  178. package/dist/components/charts/value/types.d.ts +1 -1
  179. package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
  180. package/dist/components/charts/xy/BumpChart.capability.d.ts +14 -1
  181. package/dist/components/charts/xy/BumpChart.d.ts +13 -73
  182. package/dist/components/charts/xy/BumpChart.semanticViability.d.ts +5 -0
  183. package/dist/components/charts/xy/CandlestickChart.d.ts +2 -2
  184. package/dist/components/charts/xy/LineChart.d.ts +2 -2
  185. package/dist/components/charts/xy/Scatterplot.d.ts +1 -1
  186. package/dist/components/charts/xy/bumpData.d.ts +44 -0
  187. package/dist/components/charts/xy/bumpIdentity.d.ts +2 -0
  188. package/dist/components/charts/xy/bumpLayout.d.ts +45 -0
  189. package/dist/components/charts/xy/bumpTooltip.d.ts +20 -0
  190. package/dist/components/legendLayout.d.ts +131 -4
  191. package/dist/components/realtime/ReorderBuffer.d.ts +2 -0
  192. package/dist/components/realtime/types.d.ts +10 -1
  193. package/dist/components/recipes/balanceSnapshotsToFlows.d.ts +42 -0
  194. package/dist/components/recipes/directedReachability.d.ts +14 -0
  195. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +6 -6
  196. package/dist/components/recipes/gridObservatory.d.ts +1 -1
  197. package/dist/components/recipes/networkAnalysis.d.ts +1 -18
  198. package/dist/components/recipes/physics.d.ts +7 -4
  199. package/dist/components/recipes/processPhysics.d.ts +0 -1
  200. package/dist/components/recipes/waffle.d.ts +7 -4
  201. package/dist/components/semiotic-ai-core.d.ts +13 -4
  202. package/dist/components/semiotic-ai-observations.d.ts +3 -0
  203. package/dist/components/semiotic-ai.d.ts +16 -9
  204. package/dist/components/semiotic-client-shared.d.ts +10 -0
  205. package/dist/components/semiotic-experimental.d.ts +1 -1
  206. package/dist/components/semiotic-geo.d.ts +4 -1
  207. package/dist/components/semiotic-network.d.ts +7 -4
  208. package/dist/components/semiotic-ordinal.d.ts +4 -1
  209. package/dist/components/semiotic-physics.d.ts +11 -4
  210. package/dist/components/semiotic-realtime-core.d.ts +11 -4
  211. package/dist/components/semiotic-realtime-react.d.ts +4 -3
  212. package/dist/components/semiotic-realtime.d.ts +3 -1
  213. package/dist/components/semiotic-recipes-core.d.ts +7 -5
  214. package/dist/components/semiotic-server-edge.d.ts +3 -2
  215. package/dist/components/semiotic-server.d.ts +3 -2
  216. package/dist/components/semiotic-themes-core.d.ts +5 -48
  217. package/dist/components/semiotic-utils-core.d.ts +10 -5
  218. package/dist/components/semiotic-utils-react.d.ts +2 -0
  219. package/dist/components/semiotic-xy.d.ts +4 -1
  220. package/dist/components/semiotic.d.ts +68 -26
  221. package/dist/components/server/animatedGif.d.ts +1 -1
  222. package/dist/components/server/renderEvidence.d.ts +25 -2
  223. package/dist/components/server/renderToStaticSVG.d.ts +15 -7
  224. package/dist/components/server/serverChartConfigShared.d.ts +8 -1
  225. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  226. package/dist/components/server/serverChartConfigsNetwork.d.ts +3 -3
  227. package/dist/components/server/serverChartConfigsNetworkChord.d.ts +2 -0
  228. package/dist/components/server/serverChartConfigsNetworkForce.d.ts +2 -0
  229. package/dist/components/server/serverChartConfigsNetworkHierarchy.d.ts +3 -0
  230. package/dist/components/server/serverChartConfigsXY.d.ts +3 -3
  231. package/dist/components/server/serverChartConfigsXYBubble.d.ts +5 -0
  232. package/dist/components/server/serverChartConfigsXYBump.d.ts +7 -0
  233. package/dist/components/server/serverChartConfigsXYScatter.d.ts +5 -0
  234. package/dist/components/server/staticAnnotationFallbacks.d.ts +10 -0
  235. package/dist/components/server/staticAnnotations.d.ts +28 -1
  236. package/dist/components/server/staticAxisTickLabel.d.ts +13 -0
  237. package/dist/components/server/staticLegend.d.ts +1 -1
  238. package/dist/components/server/staticLegendMargin.d.ts +41 -0
  239. package/dist/components/server/staticOrdinal.d.ts +8 -2
  240. package/dist/components/server/staticPhysics.d.ts +13 -1
  241. package/dist/components/server/staticPhysicsChrome.d.ts +20 -0
  242. package/dist/components/server/staticRawLegend.d.ts +15 -0
  243. package/dist/components/server/staticSVGChrome.d.ts +16 -55
  244. package/dist/components/server/staticXYAxes.d.ts +27 -0
  245. package/dist/components/server/staticXYAxisTicks.d.ts +39 -0
  246. package/dist/components/server/staticXYGrid.d.ts +11 -0
  247. package/dist/components/server/themeResolver.d.ts +5 -1
  248. package/dist/components/store/ThemeStore.d.ts +2 -98
  249. package/dist/components/store/designTokens.d.ts +1 -1
  250. package/dist/components/store/themeCSSVariables.d.ts +10 -0
  251. package/dist/components/store/themeCore.d.ts +91 -0
  252. package/dist/components/store/themePresets.d.ts +81 -0
  253. package/dist/components/store/themeSerialization.d.ts +2 -1
  254. package/dist/components/stream/AccessibleDataTable.d.ts +12 -14
  255. package/dist/components/stream/AccessibleTablePortalImpl.d.ts +6 -0
  256. package/dist/components/stream/GeoTileRenderer.d.ts +2 -0
  257. package/dist/components/stream/NetworkCanvasHitTester.d.ts +3 -1
  258. package/dist/components/stream/NetworkSSRFrame.d.ts +2 -1
  259. package/dist/components/stream/NetworkSVGOverlay.d.ts +3 -31
  260. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -0
  261. package/dist/components/stream/SVGChartTitle.d.ts +9 -0
  262. package/dist/components/stream/SVGOverlay.d.ts +1 -21
  263. package/dist/components/stream/SVGUnderlay.d.ts +24 -0
  264. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  265. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  266. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  267. package/dist/components/stream/StreamXYFrame.d.ts +1 -1
  268. package/dist/components/stream/accessibleDataRows.d.ts +11 -0
  269. package/dist/components/stream/accessibleDataTableModel.d.ts +40 -0
  270. package/dist/components/stream/accessibleTableTypes.d.ts +11 -0
  271. package/dist/components/stream/axisTickUtils.d.ts +19 -0
  272. package/dist/components/stream/canvasBackground.d.ts +10 -0
  273. package/dist/components/stream/canvasSetup.d.ts +9 -0
  274. package/dist/components/stream/frameCursorInteraction.d.ts +25 -0
  275. package/dist/components/stream/frameDefaultMargins.d.ts +37 -0
  276. package/dist/components/stream/frameGraphics.d.ts +18 -0
  277. package/dist/components/stream/frameGraphicsSubscription.d.ts +26 -0
  278. package/dist/components/stream/frameLegendOptions.d.ts +18 -0
  279. package/dist/components/stream/geoFrameCursorInteraction.d.ts +9 -0
  280. package/dist/components/stream/geoFrameHelpers.d.ts +29 -1
  281. package/dist/components/stream/geoTypes.d.ts +10 -11
  282. package/dist/components/stream/hitTarget.d.ts +61 -2
  283. package/dist/components/stream/moduleWorkerSession.d.ts +6 -0
  284. package/dist/components/stream/networkAnnotationAnchors.d.ts +37 -0
  285. package/dist/components/stream/networkCustomLayout.d.ts +2 -2
  286. package/dist/components/stream/networkFrameCursorInteraction.d.ts +12 -0
  287. package/dist/components/stream/networkFrameInteraction.d.ts +2 -0
  288. package/dist/components/stream/networkFramePaint.d.ts +7 -0
  289. package/dist/components/stream/networkPipelineConfig.d.ts +1 -1
  290. package/dist/components/stream/networkTypes.d.ts +30 -32
  291. package/dist/components/stream/normalizeXYData.d.ts +7 -0
  292. package/dist/components/stream/ordinalFrameCursorInteraction.d.ts +7 -0
  293. package/dist/components/stream/ordinalFrameInteraction.d.ts +29 -0
  294. package/dist/components/stream/ordinalSceneSVG.d.ts +10 -0
  295. package/dist/components/stream/ordinalTypes.d.ts +10 -4
  296. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +9 -1
  297. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +25 -0
  298. package/dist/components/stream/physics/PhysicsControllers.d.ts +0 -3
  299. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +4 -1
  300. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +3 -24
  301. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +9 -21
  302. package/dist/components/stream/physics/PhysicsSettledSVGElement.d.ts +37 -0
  303. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +7 -3
  304. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +1 -1
  305. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +23 -4
  306. package/dist/components/stream/physics/physicsAnnotationContext.d.ts +19 -0
  307. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +4 -0
  308. package/dist/components/stream/physics/physicsSettledChrome.d.ts +7 -0
  309. package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +32 -0
  310. package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +36 -0
  311. package/dist/components/stream/pipelineConfig.d.ts +6 -17
  312. package/dist/components/stream/pipelineDomainResolution.d.ts +1 -1
  313. package/dist/components/stream/renderBackend.d.ts +2 -0
  314. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +13 -2
  315. package/dist/components/stream/renderers/resolveCSSColor.d.ts +7 -0
  316. package/dist/components/stream/responsiveSize.d.ts +17 -0
  317. package/dist/components/stream/sceneCursor.d.ts +41 -0
  318. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +1 -1
  319. package/dist/components/stream/svgOverlayUtils.d.ts +22 -1
  320. package/dist/components/stream/types.d.ts +25 -12
  321. package/dist/components/stream/useCanvasFrameHost.d.ts +3 -1
  322. package/dist/components/stream/useFrame.d.ts +24 -1
  323. package/dist/components/stream/useResponsiveSize.d.ts +6 -1
  324. package/dist/components/stream/useStalenessCheck.d.ts +1 -1
  325. package/dist/components/stream/xyFrameAxisTypes.d.ts +15 -4
  326. package/dist/components/stream/xyFrameCursorInteraction.d.ts +6 -0
  327. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +1 -1
  328. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -26
  329. package/dist/components/types/legendTypes.d.ts +6 -0
  330. package/dist/components/types/marginType.d.ts +7 -8
  331. package/dist/controls.min.js +1 -1
  332. package/dist/controls.module.min.js +1 -1
  333. package/dist/forceLayoutWorker.js +1 -1
  334. package/dist/geo.min.js +1 -1
  335. package/dist/geo.module.min.js +1 -1
  336. package/dist/network.min.js +1 -1
  337. package/dist/network.module.min.js +1 -1
  338. package/dist/ordinal.min.js +1 -1
  339. package/dist/ordinal.module.min.js +1 -1
  340. package/dist/physics-matter.module.min.js +1 -1
  341. package/dist/physics-rapier.module.min.js +1 -1
  342. package/dist/physics.min.js +1 -1
  343. package/dist/physics.module.min.js +1 -1
  344. package/dist/physicsWorker.js +1 -1
  345. package/dist/processSankeyLayoutWorker.js +1 -1
  346. package/dist/realtime.min.js +1 -1
  347. package/dist/realtime.module.min.js +1 -1
  348. package/dist/rough.min.js +1 -1
  349. package/dist/rough.module.min.js +1 -1
  350. package/dist/semiotic-ai-core.d.ts +13 -4
  351. package/dist/semiotic-ai-core.min.js +1 -1
  352. package/dist/semiotic-ai-core.module.min.js +1 -1
  353. package/dist/semiotic-ai.d.ts +16 -9
  354. package/dist/semiotic-ai.min.js +1 -1
  355. package/dist/semiotic-ai.module.min.js +1 -1
  356. package/dist/semiotic-client-cjs-shared.min.js +1 -0
  357. package/dist/semiotic-client-glyph.module.min.js +2 -0
  358. package/dist/semiotic-client-responsive.module.min.js +2 -0
  359. package/dist/semiotic-client-shared.module.min.js +2 -0
  360. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -0
  361. package/dist/semiotic-data.min.js +1 -1
  362. package/dist/semiotic-data.module.min.js +1 -1
  363. package/dist/semiotic-experimental-auxiliary.module.min.js +2 -0
  364. package/dist/semiotic-experimental-node-auxiliary.module.min.js +2 -0
  365. package/dist/semiotic-experimental-node.module.min.js +2 -0
  366. package/dist/semiotic-experimental-react-shared.module.min.js +2 -0
  367. package/dist/semiotic-experimental-vacp.min.js +1 -1
  368. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  369. package/dist/semiotic-experimental.d.ts +1 -1
  370. package/dist/semiotic-experimental.min.js +1 -1
  371. package/dist/semiotic-experimental.module.min.js +1 -1
  372. package/dist/semiotic-geo.d.ts +4 -1
  373. package/dist/semiotic-network.d.ts +7 -4
  374. package/dist/semiotic-ordinal.d.ts +4 -1
  375. package/dist/semiotic-physics.d.ts +11 -4
  376. package/dist/semiotic-realtime-core.d.ts +11 -4
  377. package/dist/semiotic-realtime-core.min.js +2 -1
  378. package/dist/semiotic-realtime-core.module.min.js +2 -1
  379. package/dist/semiotic-realtime-react.d.ts +4 -3
  380. package/dist/semiotic-realtime-react.min.js +1 -1
  381. package/dist/semiotic-realtime-react.module.min.js +1 -1
  382. package/dist/semiotic-realtime.d.ts +3 -1
  383. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -0
  384. package/dist/semiotic-recipes-core.d.ts +7 -5
  385. package/dist/semiotic-recipes-core.min.js +9 -1
  386. package/dist/semiotic-recipes-core.module.min.js +1 -1
  387. package/dist/semiotic-recipes-geo-cjs.min.js +1 -0
  388. package/dist/semiotic-recipes-react.min.js +1 -1
  389. package/dist/semiotic-recipes-react.module.min.js +1 -1
  390. package/dist/semiotic-recipes.min.js +7 -1
  391. package/dist/semiotic-recipes.module.min.js +2 -1
  392. package/dist/semiotic-server-edge-node.module.min.js +1 -0
  393. package/dist/semiotic-server-edge.d.ts +3 -2
  394. package/dist/semiotic-server-edge.min.js +1 -1
  395. package/dist/semiotic-server-edge.module.min.js +1 -1
  396. package/dist/semiotic-server-node.min.js +1 -1
  397. package/dist/semiotic-server-node.module.min.js +1 -1
  398. package/dist/semiotic-server.d.ts +3 -2
  399. package/dist/semiotic-themes-core.d.ts +5 -48
  400. package/dist/semiotic-themes-core.min.js +1 -1
  401. package/dist/semiotic-themes-core.module.min.js +1 -1
  402. package/dist/semiotic-themes-react.min.js +1 -1
  403. package/dist/semiotic-themes-react.module.min.js +1 -1
  404. package/dist/semiotic-themes.min.js +1 -1
  405. package/dist/semiotic-themes.module.min.js +1 -1
  406. package/dist/semiotic-utils-core.d.ts +10 -5
  407. package/dist/semiotic-utils-core.min.js +1 -1
  408. package/dist/semiotic-utils-core.module.min.js +1 -1
  409. package/dist/semiotic-utils-react.d.ts +2 -0
  410. package/dist/semiotic-utils-react.min.js +1 -1
  411. package/dist/semiotic-utils-react.module.min.js +1 -1
  412. package/dist/semiotic-utils.min.js +2 -1
  413. package/dist/semiotic-utils.module.min.js +2 -1
  414. package/dist/semiotic-value.min.js +1 -1
  415. package/dist/semiotic-value.module.min.js +1 -1
  416. package/dist/semiotic-xy.d.ts +4 -1
  417. package/dist/semiotic.d.ts +68 -26
  418. package/dist/semiotic.min.js +1 -1
  419. package/dist/semiotic.module.min.js +1 -1
  420. package/dist/server.min.js +1 -1
  421. package/dist/server.module.min.js +1 -1
  422. package/dist/xy.min.js +1 -1
  423. package/dist/xy.module.min.js +1 -1
  424. package/package.json +53 -19
  425. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +0 -20
  426. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +0 -2
  427. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +0 -1
  428. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +0 -2
  429. package/dist/chunk-chartContainerDataAudit-IQ3NBN3Q.module.min.js +0 -2
  430. package/dist/chunk-chunk-2B3AIKUZ.module.min.js +0 -2
  431. package/dist/chunk-chunk-2CXCXRB4.module.min.js +0 -1
  432. package/dist/chunk-chunk-2X3FJCME.module.min.js +0 -1
  433. package/dist/chunk-chunk-2ZHHWZQM.module.min.js +0 -2
  434. package/dist/chunk-chunk-4ITOQRXM.module.min.js +0 -2
  435. package/dist/chunk-chunk-5UKL5W76.module.min.js +0 -2
  436. package/dist/chunk-chunk-5VVNW5AZ.module.min.js +0 -1
  437. package/dist/chunk-chunk-5ZON5NMV.module.min.js +0 -2
  438. package/dist/chunk-chunk-66PCWJUG.module.min.js +0 -1
  439. package/dist/chunk-chunk-6S3YGYW7.module.min.js +0 -1
  440. package/dist/chunk-chunk-6V5VQVCT.module.min.js +0 -2
  441. package/dist/chunk-chunk-7C5EDZ3Z.module.min.js +0 -2
  442. package/dist/chunk-chunk-A3I4HBD5.module.min.js +0 -1
  443. package/dist/chunk-chunk-ACLDBMRH.module.min.js +0 -2
  444. package/dist/chunk-chunk-AFQHURLO.module.min.js +0 -2
  445. package/dist/chunk-chunk-DDB4TLQG.module.min.js +0 -2
  446. package/dist/chunk-chunk-DTH3SUOU.module.min.js +0 -2
  447. package/dist/chunk-chunk-DTSNLGRK.module.min.js +0 -2
  448. package/dist/chunk-chunk-DVCWU7MT.module.min.js +0 -2
  449. package/dist/chunk-chunk-FEPXDKJP.module.min.js +0 -1
  450. package/dist/chunk-chunk-FJ76HWQZ.module.min.js +0 -1
  451. package/dist/chunk-chunk-FSIHAW6L.module.min.js +0 -2
  452. package/dist/chunk-chunk-G2RGVEYY.module.min.js +0 -2
  453. package/dist/chunk-chunk-G75OPF5N.module.min.js +0 -2
  454. package/dist/chunk-chunk-HADHLMY5.module.min.js +0 -1
  455. package/dist/chunk-chunk-HAJVODLO.module.min.js +0 -2
  456. package/dist/chunk-chunk-HBFA4NN6.module.min.js +0 -1
  457. package/dist/chunk-chunk-HIV7AW2V.module.min.js +0 -2
  458. package/dist/chunk-chunk-IY7RYD4S.module.min.js +0 -1
  459. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  460. package/dist/chunk-chunk-J3XWETBJ.module.min.js +0 -2
  461. package/dist/chunk-chunk-JZAMMSQQ.module.min.js +0 -2
  462. package/dist/chunk-chunk-KTWEBFMX.module.min.js +0 -2
  463. package/dist/chunk-chunk-LSJUXBMF.module.min.js +0 -1
  464. package/dist/chunk-chunk-MXMRXSCI.module.min.js +0 -2
  465. package/dist/chunk-chunk-MXVBXFKW.module.min.js +0 -2
  466. package/dist/chunk-chunk-NWIGA3UK.module.min.js +0 -1
  467. package/dist/chunk-chunk-OFAP623Y.module.min.js +0 -2
  468. package/dist/chunk-chunk-OHLRAEQZ.module.min.js +0 -2
  469. package/dist/chunk-chunk-OZK46A5U.module.min.js +0 -1
  470. package/dist/chunk-chunk-PMR47KRY.module.min.js +0 -2
  471. package/dist/chunk-chunk-PRNXOCYZ.module.min.js +0 -2
  472. package/dist/chunk-chunk-Q2YADC2V.module.min.js +0 -2
  473. package/dist/chunk-chunk-RLKZVJMQ.module.min.js +0 -2
  474. package/dist/chunk-chunk-ROP4HI7H.module.min.js +0 -2
  475. package/dist/chunk-chunk-SK2TQMG4.module.min.js +0 -2
  476. package/dist/chunk-chunk-SKLYXNYW.module.min.js +0 -2
  477. package/dist/chunk-chunk-TCMHJWFJ.module.min.js +0 -1
  478. package/dist/chunk-chunk-TSCFL235.module.min.js +0 -1
  479. package/dist/chunk-chunk-U4NZCU5T.module.min.js +0 -2
  480. package/dist/chunk-chunk-U66USBWU.module.min.js +0 -1
  481. package/dist/chunk-chunk-UOQRPGPK.module.min.js +0 -2
  482. package/dist/chunk-chunk-VKL6DI43.module.min.js +0 -2
  483. package/dist/chunk-chunk-W62673ZE.module.min.js +0 -1
  484. package/dist/chunk-chunk-WFHZHWT7.module.min.js +0 -1
  485. package/dist/chunk-chunk-XCC25CZZ.module.min.js +0 -2
  486. package/dist/chunk-chunk-XECNOUZY.module.min.js +0 -2
  487. package/dist/chunk-chunk-XYZDTYAF.module.min.js +0 -2
  488. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +0 -2
  489. package/dist/chunk-chunk-YWZB3KPI.module.min.js +0 -2
  490. package/dist/chunk-statisticalOverlays-HMYYSGPE.module.min.js +0 -2
  491. package/dist/components/stream/test-utils/frameScheduler.d.ts +0 -12
  492. package/dist/components/stream/test-utils/revisionConsumption.d.ts +0 -13
  493. package/dist/test-utils/canvasMock.d.ts +0 -86
  494. package/dist/test-utils/capturedFrameProps.d.ts +0 -67
  495. package/dist/test-utils/frameMock.d.ts +0 -81
  496. package/dist/test-utils/ordinalFixtures.d.ts +0 -48
  497. /package/dist/{chunk-chunk-JJ2OOIET.module.min.js → c-GGISSW5E.min.js} +0 -0
  498. /package/dist/{chunk-chunk-SIRIJ3DY.module.min.js → c-N4G2L7ID.min.js} +0 -0
  499. /package/dist/{chunk-chunk-CA3YDW6F.module.min.js → c-S6U5CGT5.min.js} +0 -0
  500. /package/dist/components/recipes/{mobileAnnotationStrategy.d.ts → mobileAnnotationBehavior.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e,t,n=Object.create,o=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,c=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[i(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},l=(e,t)=>{for(var n in t)o(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of i(t))a.call(e,c)||c===n||o(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},d=(e,t,r)=>(r=null!=e?n(s(e)):{},u(!t&&e&&e.__esModule?r:o(r,"default",{value:e,enumerable:!0}),e));function h({label:n="Data range brush",description:o=t,onAction:r}={}){const i=e.useId().replace(/:/g,""),s=e.useRef(r);return s.current=r,{description:o,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":n,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:e.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(),s.current?.(t))},[])}}}var p,m,y,f,g=c({"src/components/stream/brushAccessibility.ts"(){e=d(require("react")),t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it."}}),b={};function v(e,t,n,o){const[r,i]=[Math.min(...t),Math.max(...t)],s=(i-r)/20;let[a,c]=e;if(o)0>n?a=Math.max(r,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(r,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function x(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 w(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 k({width:e,height:t,totalWidth:n,totalHeight:o,margin:r,dimension:i,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:d,streaming:g}){const b=(0,p.useRef)(null),k=(0,p.useRef)(null),S=(0,p.useRef)(a);S.current=a;const A=(0,p.useRef)(s);A.current=s;const C=(0,p.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),M=(0,p.useRef)(C);M.current=C;const j=(0,p.useRef)(!1),P=(0,p.useRef)(null),I=h({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=A.current,n=k.current;if(!t||!n||!b.current)return;const o=(0,m.select)(b.current).select(".brush-g");if("clear"===e.type)return j.current=!0,o.call(n.move,null),j.current=!1,P.current=null,void S.current(null);const r=t.x.domain(),s=t.y.domain(),a=P.current;let c=a?.x??[r[0]+.4*(r[1]-r[0]),r[0]+.6*(r[1]-r[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==i&&(c=v(c,r,d,e.resize)),u||"x"===i||(l=v(l,s,d,e.resize)),u&&"y"===i||!u&&"x"===i)return;const h={x:c,y:l};j.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])]]),j.current=!1,P.current=h,S.current(h)}});return(0,p.useEffect)(()=>{if(!b.current)return;const n=(0,m.select)(b.current).select(".brush-g"),o="x"===i?(0,y.brushX)():"y"===i?(0,y.brushY)():(0,y.brush)();return o.extent([[0,0],[e,t]]),o.on("brush end",r=>{if(j.current)return;const s=A.current;if(!s)return;if(!r.selection)return P.current=null,void S.current(null);let a,u;if("x"===i){const[e,n]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===i){const[t,n]=r.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,o]]=r.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(o),s.y.invert(t)]}if("bin"===l&&"y"!==i&&("end"===r.type||"brush"===r.type&&d)){const e=M.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[x(e[0],t),w(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(j.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]]])}j.current=!1}const h={x:a,y:u};P.current=h,S.current(h)}),n.call(o),k.current=o,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),k.current=null}},[e,t,i,l,c,d]),(0,p.useEffect)(()=>{if(!(g&&s&&k.current&&P.current))return;if(!b.current)return;if("y"===i)return;const e=P.current,t=s.x.domain()[0],n=(0,m.select)(b.current).select(".brush-g");if(t>=e.x[1])return j.current=!0,n.call(k.current.move,null),j.current=!1,P.current=null,void S.current(null);let o=e.x[0],r=!1;if(t>e.x[0]){if(o=t,"bin"===l){const e=M.current;e&&e.length>0?o=w(t,e):c&&c>0&&(o=Math.ceil(t/c)*c)}if(o>=e.x[1])return j.current=!0,n.call(k.current.move,null),j.current=!1,P.current=null,void S.current(null);r=!0}const a=s.x(o),u=s.x(e.x[1]);if(j.current=!0,"x"===i)n.call(k.current.move,[a,u]);else{const t=s.y(e.y[1]),o=s.y(e.y[0]);n.call(k.current.move,[[a,t],[u,o]])}if(j.current=!1,r){const t={x:[o,e.x[1]],y:e.y};P.current=t,S.current(t)}},[s,g,i,l,c]),(0,f.jsxs)("svg",{ref:b,width:n,height:o,...I.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,f.jsx)("title",{children:I.svgProps["aria-label"]}),(0,f.jsx)("desc",{id:I.descriptionId,children:I.description}),(0,f.jsx)("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`})]})}l(b,{XYBrushOverlay:()=>k});var S,A=c({"src/components/stream/XYBrushOverlay.tsx"(){p=require("react"),m=require("d3-selection"),y=require("d3-brush"),g(),f=require("react/jsx-runtime")}});function C(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=S.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 M(e){return e instanceof Date?e.getTime():"string"==typeof e?C(e):+e}var j=c({"src/components/charts/shared/temporalStrings.ts"(){S=/^\d{4}-\d{1,2}$/}});function P(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}function I(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}var R,T=c({"src/components/charts/shared/minMax.ts"(){}});function _(e){const t=10**R;return Math.round(e*t)/t}function L(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 s=[];for(let n=0;r>n;n++){let o=0;for(const[r,i]of e)null!==i&&(o+=r**(t+n));s.push(o)}o.push(s)}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(_);return{points:e.map(([e])=>[_(e),_(i.reduce((t,n,o)=>t+n*e**o,0))]),equation:[...i].reverse()}}function D(e){const t=e.length;let n=0,o=0,r=0,i=0;for(const[t,s]of e)n+=t,o+=s,r+=t*t,i+=t*s;const s=t*r-n*n;if(1e-12>Math.abs(s))return null;const a=(t*i-n*o)/s,c=(o-a*n)/t;return e=>c+a*e}function N(e,t){const n=e.length,o=e.map(([e,n])=>n-t(e)).reduce((e,t)=>e+t*t,0),r=Math.sqrt(o/Math.max(n-2,1)),i=e.reduce((e,t)=>e+t[0],0)/n,s=e.reduce((e,t)=>e+(t[0]-i)**2,0);return{se:r,meanX:i,ssX:s}}function $(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}var B=c({"src/components/charts/shared/leastSquaresRegression.ts"(){R=2}});function E(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function O(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}var F,z,H=c({"src/components/charts/shared/colorManipulation.ts"(){}}),W={};function q(e,t,n,o){const r=t.uncertaintyOpacity,i=t.confidenceAccessor;if(!r&&!i)return;const s="object"==typeof r?r:{},a=s.min??.15,c=s.max??1;if(i){const t="function"==typeof i?i:e=>e[i];for(const n of e){const e=t(n);null!=e&&Number.isFinite(e)&&(n[z]=a+Math.max(0,Math.min(1,e))*(c-a))}return}const l=e.map(e=>{const t=n(e),r=o(e);return null!=t&&null!=r&&Number.isFinite(t)&&Number.isFinite(r)?Math.abs(t-r):NaN}),u=l.filter(e=>Number.isFinite(e));if(0===u.length)return;const[d,h]=P(u),p=h-d;e.forEach((e,t)=>{const n=l[t];Number.isFinite(n)&&(e[z]=c-(p>0?(n-d)/p:0)*(c-a))})}function G(e,t){return"function"==typeof t?t(e):!!e[t]}function Y(e){return[{type:"anomaly-band",threshold:e.threshold??2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:e.bandOpacity??.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:e.anomalyRadius??6,label:e.label}]}function V(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){const{isTraining:i,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:p=6,label:m}=o,y=e.map(e=>{let t="observed";return s&&G(e,s)?t="forecast":i&&G(e,i)&&(t="training"),{...e,[F]:t}}),f=o._groupBy,g=[];if(f){const e=new Map;for(const t of y){const n=t[f]??"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][F]!==n[e+1][F]&&(t.push({...n[e+1],[F]:n[e][F]}),t.push({...n[e],[F]:n[e+1][F]}));g.push(...y,...t)}else for(let e=0;y.length>e;e++)g.push(y[e]),y.length-1>e&&y[e][F]!==y[e+1][F]&&(g.push({...y[e+1],[F]:y[e][F]}),g.push({...y[e],[F]:y[e+1][F]}));if(o.trainUnderline){const e=[];for(const t of g)"training"===t[F]&&e.push({...t,[F]:"training-base"});g.unshift(...e)}const b=[];if(c&&l){const e="string"==typeof c?c:"__envUpper",t="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const n of g)"function"==typeof c&&(n[e]=c(n)),"function"==typeof l&&(n[t]=l(n));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:m})}if(o.uncertaintyOpacity||o.confidenceAccessor){const e=c?"function"==typeof c?c:e=>e[c]:()=>{},t=l?"function"==typeof l?l:e=>e[l]:()=>{};q(g.filter(e=>"forecast"===e[F]),o,e,t)}if(a){const e=o.anomalyStyle,t={type:"highlight",filter:e=>G(e,a)};e?(t.style=e,t.r=p):"function"==typeof h?(t.style=e=>{const t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=p):(t.color=h,t.r=p,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),b.push(t)}return r&&b.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label}),{processedData:g,annotations:b}}(e,0,0,o,r):function(e,t,n,o,r){const{trainEnd:i,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=o;if(null==i)return{processedData:e,annotations:[]};const d=[],h=[];for(const n of e)n[t]>i?h.push({...n,[F]:"observed"}):d.push({...n,[F]:"training"});const p=d.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],y=[];if(p.length>=3){const r=p.length,i=D(p);if(i){const{se:d,meanX:h,ssX:f}=N(p,i),g=$(a),b=I(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),v=p.length>1?(p[r-1][0]-p[0][0])/(r-1):1;for(let e=1;s>=e;e++){const o=b+e*v,s=i(o),a=d*Math.sqrt(1+1/r+(f>0?(o-h)**2/f:0))*g;y.push({[t]:o,[n]:s,[F]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}q(y,o,e=>e.__forecastUpper,e=>e.__forecastLower),m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}m.push({type:"x-threshold",x:i,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&m.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label});const f=[];if(f.push(...d),d.length>0&&h.length>0&&f.push({...d[d.length-1],[F]:"observed"}),f.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&f.push({...e,[F]:"forecast"}),f.push(...y)}return{processedData:f,annotations:m}}(e,t,n,o,r);var i}function X(e,t){const n=t.trainDasharray??"8,4",o=t.forecastDasharray??"4,4",r=t.color||"#6366f1",i=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,c=t.trainLinecap,l=t.trainUnderline;return t=>{const u=e(t),d=t[F];if("training"===d){let e=u.stroke;return"darken"===a?e=E(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:n,...c&&{strokeLinecap:c},...null!=i&&{strokeOpacity:i}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===l&&(e=O(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[z],n=null!=e?e:s;return{...u,stroke:r,strokeDasharray:o,...null!=n&&{strokeOpacity:n}}}return u}}l(W,{FORECAST_OPACITY_FIELD:()=>z,SEGMENT_FIELD:()=>F,buildAnomalyAnnotations:()=>Y,buildForecast:()=>V,createSegmentLineStyle:()=>X,darkenColor:()=>E,lightenColor:()=>O,stampForecastOpacity:()=>q});var U,K,Q,Z,J,ee=c({"src/components/charts/shared/statisticalOverlays.ts"(){T(),H(),B(),H(),F="__forecastSegment",z="__forecastOpacity"}}),te=c({"src/components/charts/xy/scatterplotMatrixInteractionTypes.ts"(){}}),ne={};function oe({frameRef:e,cellSize:t,onBrush:n}){const o=(0,U.useRef)(null),r=t-J.left-J.right,i=t-J.top-J.bottom;return(0,U.useEffect)(()=>{if(!o.current)return;const t=(0,Q.select)(o.current).select(".brush-g"),s=(0,K.brush)().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,s],[a,c]]=t.selection,l=[[o.x.invert(i),o.y.invert(s)],[o.x.invert(a),o.y.invert(c)]];n(l)});return t.call(s),t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{s.on("brush end",null)}},[r,i,e,n]),(0,Z.jsx)("svg",{ref:o,width:t,height:t,style:{position:"absolute",top:0,left:0},children:(0,Z.jsx)("g",{className:"brush-g",transform:`translate(${J.left},${J.top})`})})}l(ne,{ScatterplotMatrixBrushOverlay:()=>oe});var re,ie,se,ae,ce=c({"src/components/charts/xy/scatterplotMatrixBrushOverlay.tsx"(){U=require("react"),K=require("d3-brush"),Q=require("d3-selection"),te(),Z=require("react/jsx-runtime"),J={top:4,bottom:4,left:4,right:4}}}),le={};function ue({width:e,height:t,margin:n,scales:o,brushDirection:r,extent:i,onBrush:s}){const a=(0,re.useRef)(null),c=(0,re.useRef)(null),l=(0,re.useRef)(!1),u=e+n.left+n.right,d=t+n.top+n.bottom;return(0,re.useEffect)(()=>{if(!a.current||!o)return;const n=(0,se.select)(a.current).select(".brush-group"),i="x"===r?(0,ie.brushX)().extent([[0,0],[e,t]]):(0,ie.brushY)().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 s(null);const n=("x"===r?o.x:o.y).invert;if(!n)return;const i=[n(t[0]),n(t[1])];s(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,s]),(0,re.useEffect)(()=>{if(!c.current||!o||!a.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]),(0,ae.jsx)("svg",{ref:a,width:u,height:d,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:(0,ae.jsx)("g",{className:"brush-group",transform:`translate(${n.left},${n.top})`})})}l(le,{MinimapBrushOverlay:()=>ue});var de,he,pe,me,ye=c({"src/components/charts/xy/minimapBrushOverlay.tsx"(){re=require("react"),ie=require("d3-brush"),se=require("d3-selection"),ae=require("react/jsx-runtime")}}),fe={};function ge({width:e,height:t,totalWidth:n,totalHeight:o,margin:r,scales:i,onBrush:s}){const a=(0,de.useRef)(null),c=(0,de.useRef)(null),l=(0,de.useRef)(s);l.current=s;const u=(0,de.useRef)(i);u.current=i;const d=(0,de.useRef)(!1),p=(0,de.useRef)(null),m="horizontal"===i?.projection,y=(0,de.useRef)(m);y.current=m;const f=h({label:"Ordinal value range brush",onAction:e=>{const t=u.current,n=c.current;if(!t||!n||!a.current)return;const o=(0,he.select)(a.current).select(".brush-g");if("clear"===e.type)return d.current=!0,o.call(n.move,null),d.current=!1,p.current=null,void l.current(null);if(("left"===e.direction||"right"===e.direction)!=!!y.current)return;const r=t.r.domain(),[i,s]=[Math.min(...r),Math.max(...r)],h=(s-i)/20,m=p.current?.r??[i+.4*(s-i),i+.6*(s-i)],f="left"===e.direction||"down"===e.direction?-1:1;let[g,b]=m;if(e.resize)0>f?g=Math.max(i,g-h):b=Math.min(s,b+h);else{const e=b-g;g=Math.max(i,Math.min(s-e,g+f*h)),b=g+e}const v={r:[g,b]};d.current=!0,o.call(n.move,y.current?[t.r(g),t.r(b)]:[t.r(b),t.r(g)]),d.current=!1,p.current=v,l.current(v)}});return(0,de.useEffect)(()=>{if(!a.current)return;const n=(0,he.select)(a.current).select(".brush-g"),o=m?(0,pe.brushX)():(0,pe.brushY)();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 p.current=null,void l.current(null);const[n,o]=e.selection;let r;r=y.current?[t.r.invert(n),t.r.invert(o)]:[t.r.invert(o),t.r.invert(n)];const i={r:r};p.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,m]),(0,de.useEffect)(()=>{if(!i||!c.current||!p.current)return;if(!a.current)return;const e=p.current,t=(0,he.select)(a.current).select(".brush-g"),n=i.r(e.r[0]),o=i.r(e.r[1]);m?(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,m]),(0,me.jsxs)("svg",{ref:a,width:n,height:o,...f.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,me.jsx)("title",{children:f.svgProps["aria-label"]}),(0,me.jsx)("desc",{id:f.descriptionId,children:f.description}),(0,me.jsx)("g",{className:"brush-g",transform:`translate(${r.left},${r.top})`,style:{pointerEvents:"all"}})]})}l(fe,{OrdinalBrushOverlay:()=>ge});var be=c({"src/components/stream/OrdinalBrushOverlay.tsx"(){de=require("react"),he=require("d3-selection"),pe=require("d3-brush"),g(),me=require("react/jsx-runtime")}});function ve(e,t){const n=e.nestedDataAccessorProp?t[e.nestedDataAccessorProp]:void 0;return"string"==typeof n?n:e.defaultNestedDataAccessor}function xe(e,t,n){const o=e.dataProp??"data",r=t[o],i=n??(Array.isArray(r)?r:[]),s=ve(e,t);if(!s)return{dataProp:o,rows:i};const a=[];let c=!1;for(const e of i){const t=e?.[s];if(Array.isArray(t)){c=!0;for(const e of t)e&&"object"==typeof e&&a.push(e)}}return{dataProp:o,rows:c?a:i}}var we,ke,Se,Ae,Ce,Me,je,Pe,Ie,Re,Te,_e,Le,De,Ne,$e,Be,Ee=c({"src/components/data/dataAuditSources.ts"(){}});function Oe(){const e=globalThis;return e[Be]??(e[Be]={contracts:new Map}),e[Be]}var Fe=c({"src/components/data/numericContracts.ts"(){ke={fields:we=[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"y",accessor:"yAccessor",defaultAccessor:"y",domain:!0}]},Se=[{...we[0],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates"},{...we[1],nestedDataAccessorProp:"lineDataAccessor",defaultNestedDataAccessor:"coordinates",allowMissing:!0}],Ae={fields:Se},Ce={role:"value",accessor:"valueAccessor",defaultAccessor:"value"},Me={...Ce,domain:!0},je={fields:[{...Ce,requirements:["finite","non-negative"]}],aggregates:[{kind:"positive-total",role:"value"}]},Pe={fields:[Ce],aggregates:[{kind:"normalized-total",role:"value",groupAccessor:"categoryAccessor",defaultGroupAccessor:"category",whenProp:"normalize"}]},Ie={fields:Se,aggregates:[{kind:"normalized-total",role:"y",groupAccessor:"xAccessor",defaultGroupAccessor:"x",whenProp:"normalize"}]},Re={fields:[...we,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},Te={fields:[...we,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},_e={fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date-like",domain:!0},{role:"high",accessor:"highAccessor",defaultAccessor:"high",requirements:["finite"]},{role:"low",accessor:"lowAccessor",defaultAccessor:"low",requirements:["finite"]},{role:"open",accessor:"openAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]},{role:"close",accessor:"closeAccessor",whenProps:["openAccessor","closeAccessor"],requirements:["finite"]}]},Le={fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"x",temporalValues:"date",domain:!0},{role:"value",accessor:"seriesAAccessor",defaultAccessor:"a"},{role:"value",accessor:"seriesBAccessor",defaultAccessor:"b"}]},De={fields:[Ce]},Ne={fields:[{...Ce,dataProp:"edges",requirements:["finite","non-negative"],missingValue:1}]},$e={LineChart:Ae,AreaChart:Ae,BumpChart:Ae,Scatterplot:Te,ConnectedScatterplot:ke,QuadrantChart:Te,MinimapChart:Ae,BubbleChart:Re,StackedAreaChart:Ie,DifferenceChart:Le,CandlestickChart:_e,Heatmap:De,BarChart:{fields:[Ce]},GroupedBarChart:{fields:[Ce]},StackedBarChart:Pe,DotPlot:{fields:[Me]},Histogram:{fields:[Me]},BoxPlot:{fields:[Me]},SwarmPlot:{fields:[Me,{role:"size",accessor:"sizeBy",requirements:["finite","non-negative"]}]},ViolinPlot:{fields:[Me]},RidgelinePlot:{fields:[Me]},PieChart:je,DonutChart:je,FunnelChart:je,SankeyDiagram:Ne,ChordDiagram:Ne,ProportionalSymbolMap:{fields:[{role:"x",accessor:"xAccessor",defaultAccessor:"lon",dataProp:"points",requirements:["finite"]},{role:"y",accessor:"yAccessor",defaultAccessor:"lat",dataProp:"points",requirements:["finite"]},{role:"size",accessor:"sizeBy",dataProp:"points",requirements:["finite","non-negative"]}]}},Be=Symbol.for("semiotic.numericContractRegistry")}});function ze(e,t){const n={numbers:[],missing:0,nonFinite:0,nonNumeric:0,zero:0,negative:0,fractional:0};for(const o of e){const e=o?.[t];if(null==e||""===e){n.missing++;continue}let r;if("number"==typeof e)r=e;else if("string"==typeof e){const t=e.trim();if(""===t){n.missing++;continue}const o=Number(t);Number.isNaN(o)?/^[+-]?nan$/i.test(t)&&(r=o):r=o}void 0!==r?Number.isFinite(r)?(n.numbers.push(r),0===r&&n.zero++,0>r&&n.negative++,Number.isInteger(r)||n.fractional++):n.nonFinite++:n.nonNumeric++}return n}function He(e,t){if(0===e.length)return;const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);if(o===r)return e[o];const i=n-o;return e[o]*(1-i)+e[r]*i}function We(e,t={}){if(!Array.isArray(e)||0===e.length)return{};const n=new Set;for(const t of e)if(t&&"object"==typeof t)for(const e of Object.keys(t))n.add(e);const o={};for(const r of n){const n=ze(e,r);let i=1/0,s=-1/0;for(const e of n.numbers)i>e&&(i=e),e>s&&(s=e);const a=!1===t.quantiles?void 0:[...n.numbers].sort((e,t)=>e-t);o[r]={field:r,observedCount:e.length-n.missing,finiteCount:n.numbers.length,missingCount:n.missing,nonFiniteCount:n.nonFinite,nonNumericCount:n.nonNumeric,zeroCount:n.zero,negativeCount:n.negative,fractionalCount:n.fractional,...n.numbers.length>0?{min:i,...a?{q1:He(a,.25),median:He(a,.5),q3:He(a,.75)}:{},max:s}:{}}}return o}var qe=c({"src/components/data/numericFieldProfiler.ts"(){}});function Ge(e){const t=[`${e.component}: ${e.ok?"✓ numerically safe":"✗ numeric hazards found"}`,`${e.rowCount} rows · ${e.summary.fieldsChecked} numeric fields · ${e.summary.errors} errors · ${e.summary.warnings} warnings`];for(const n of e.diagnoses)t.push(`${"error"===n.severity?"ERROR":"WARN"} ${n.code}${n.field?` [${n.field}]`:""}: ${n.message}`),n.fix&&t.push(" Fix: "+n.fix);return t.join("\n")}function Ye(e){return e.code.toLowerCase().split("_").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function Ve(e,t={}){const n=Number.isFinite(t.max)?Math.max(0,Math.floor(t.max)):6,o=e.diagnoses.map((e,t)=>({item:e,diagnosisIndex:t})).filter(({item:e})=>!t.errorsOnly||"error"===e.severity),r=o.slice(0,n).map(({item:e,diagnosisIndex:t})=>({id:`data-audit:${e.code}:${e.role??"chart"}:${e.field??"chart"}:${t}`,level:e.severity,title:e.field?`${Ye(e)} · ${e.field}`:Ye(e),message:e.fix?`${e.message} ${e.fix}`:e.message,source:"Semiotic data audit",dismissible:!0}));return o.length>n&&r.push({id:"data-audit:overflow:chart",level:o.slice(n).some(({item:e})=>"error"===e.severity)?"error":"warning",title:`${o.length-n} more numeric finding${o.length-n===1?"":"s"}`,message:"Run auditData() or diagnoseConfig() to inspect the complete report.",source:"Semiotic data audit",dismissible:!0}),r}var Xe,Ue,Ke=c({"src/components/data/dataAuditPresentation.ts"(){}});function Qe(e,t,n){return"function"==typeof e?e(t,n):t[e]}function Ze(e,t){if("number"==typeof e)return Number.isFinite(e)?e:null;if(e instanceof Date){const n=e.getTime();return t&&Number.isFinite(n)?n:null}if("string"==typeof e){const n=e.trim(),o=Number(n);if(n&&Number.isFinite(o))return o;if("date-like"===t){const e=C(n);return Number.isFinite(e)?e:null}}return null}function Je(e){return"number"==typeof e&&!Number.isFinite(e)}function et(e,t,n,o,r){const i={field:n,numbers:[],finiteRows:[],missingRows:[],nonFiniteRows:[],nonNumericRows:[],accessorErrorRows:[],zeroRows:[],negativeRows:[],fractionalRows:[]};for(let n=0;e.length>n;n++){let s;try{s=Qe(t,e[n],n)}catch{i.accessorErrorRows.push(n);continue}if(null==s||""===s){if(void 0!==r){i.numbers.push(r),i.finiteRows.push(n),0===r&&i.zeroRows.push(n),0>r&&i.negativeRows.push(n),Number.isInteger(r)||i.fractionalRows.push(n);continue}i.missingRows.push(n);continue}const a=Ze(s,o);null!=a?(i.numbers.push(a),i.finiteRows.push(n),0===a&&i.zeroRows.push(n),0>a&&i.negativeRows.push(n),Number.isInteger(a)||i.fractionalRows.push(n)):Je(s)?i.nonFiniteRows.push(n):i.nonNumericRows.push(n)}return i}function tt(e,t){const n=new Set(e.requirements??["finite"]);return n.add("finite"),("x"===e.role&&"log"===t.xScaleType||"y"===e.role&&"log"===t.yScaleType)&&n.add("positive"),[...n]}function nt(e){return e.slice(0,Xe)}function ot(e){return{domain:"data",...e}}function rt(e,t){const n=[],{observation:o,contract:r,accessorLabel:i,requirements:s}=e,a={field:i,role:r.role},c=[...o.nonFiniteRows,...o.nonNumericRows,...o.accessorErrorRows].sort((e,t)=>e-t);if(0===o.numbers.length)return n.push(ot({severity:"error",code:"DEGENERATE_EXTENT",message:`${r.accessor}="${i}" produces no finite numeric values; the chart cannot resolve its ${r.role} input.`,fix:`Ensure ${i} contains finite numbers${"x"===r.role?" (or valid dates for a time scale)":""}.`,...a,...c.length>0?{rows:nt(c),count:c.length}:{}})),n;o.nonFiniteRows.length>0&&n.push(ot({severity:"error",code:"NON_FINITE_VALUE",message:`${i} contains ${o.nonFiniteRows.length} NaN or infinite value${1===o.nonFiniteRows.length?"":"s"}; scale and layout math require finite numbers.`,fix:`Filter or replace NaN/Infinity in ${i} before rendering.`,...a,rows:nt(o.nonFiniteRows),count:o.nonFiniteRows.length})),!r.allowMissing&&o.missingRows.length>0&&n.push(ot({severity:"error",code:"MISSING_NUMERIC_VALUE",message:`${i} is missing for ${o.missingRows.length} row${1===o.missingRows.length?"":"s"}; the ${r.role} role requires an explicit numeric value.`,fix:`Fill or filter missing ${i} values before rendering.`,...a,rows:nt(o.missingRows),count:o.missingRows.length}));const l=[...o.nonNumericRows,...o.accessorErrorRows].sort((e,t)=>e-t);if(l.length>0&&n.push(ot({severity:"error",code:"NON_NUMERIC_VALUE",message:`${i} produces ${l.length} non-numeric value${1===l.length?"":"s"} for the ${r.role} role.`,fix:`Bind ${r.accessor} to a numeric field or return finite numbers from the accessor.`,...a,rows:nt(l),count:l.length})),r.domain&&o.numbers.length>=2){const[e,t]=function(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}(o.numbers);e===t&&n.push(ot({severity:"warning",code:"ZERO_SPAN_DOMAIN",message:`${i} is constant at ${e}; its ${r.role} scale has a zero-span data domain.`,fix:`Provide varying ${r.role} values, set an explicit extent around ${e}, or use a single-value display.`,...a,rows:nt(o.finiteRows),count:o.finiteRows.length}))}if(s.includes("positive")){const t=o.numbers.map((e,t)=>({number:e,row:o.finiteRows[t]})).filter(({number:e})=>0>=e).map(({row:e})=>e);if(t.length>0){const o=e.logScale;n.push(ot({severity:"error",code:o?"LOG_NON_POSITIVE":"NON_POSITIVE_VALUE",message:`${i} contains ${t.length} non-positive value${1===t.length?"":"s"}, which ${o?"cannot be represented on a log scale":"violate the positive-value contract"}.`,fix:o?"Remove or transform values ≤ 0, or use a linear/symlog scale.":"Provide values greater than zero.",...a,rows:nt(t),count:t.length}))}}if(s.includes("non-negative")&&o.negativeRows.length>0&&n.push(ot({severity:"error",code:"size"===r.role?"NEGATIVE_SIZE":"NEGATIVE_VALUE",message:`${i} contains ${o.negativeRows.length} negative ${r.role} value${1===o.negativeRows.length?"":"s"}; the chart maps this role to non-negative geometry.`,fix:"Use a non-negative measure, clamp intentionally, or encode sign with position/color instead.",...a,rows:nt(o.negativeRows),count:o.negativeRows.length})),s.includes("integer")){const e=[...new Set([...o.negativeRows,...o.zeroRows,...o.fractionalRows])].sort((e,t)=>e-t);e.length>0&&n.push(ot({severity:"error",code:"INVALID_COUNT",message:`${i} contains ${e.length} value${1===e.length?"":"s"} that are not positive integers.`,fix:"Counts must be integers ≥ 1; aggregate, round intentionally, or use a continuous-value encoding.",...a,rows:nt(e),count:e.length}))}if(s.includes("unit-interval")){const e=o.numbers.map((e,t)=>({number:e,row:o.finiteRows[t]})).filter(({number:e})=>0>e||e>1).map(({row:e})=>e);e.length>0&&n.push(ot({severity:"error",code:"OUTSIDE_UNIT_INTERVAL",message:`${i} contains ${e.length} value${1===e.length?"":"s"} outside [0, 1].`,fix:`Normalize ${i} to [0, 1] before using it as ${r.role}.`,...a,rows:nt(e),count:e.length}))}if(t&&r.domain){const t=function(e){const t=e.observation.numbers.map((t,n)=>({value:t,row:e.observation.finiteRows[n]})).sort((e,t)=>e.value-t.value);if(8>t.length)return[];const n=t.map(e=>e.value),o=He(n,.25),r=He(n,.75),i=He(n,.5),s=r-o;if(s>0){const e=o-10*s,n=r+10*s;return t.filter(t=>e>t.value||t.value>n).map(e=>e.row)}const a=100*Math.max(1,Math.abs(i));return t.filter(e=>Math.abs(e.value-i)>a).map(e=>e.row)}(e);t.length>0&&n.push(ot({severity:"warning",code:"OUTLIER_DOMINATED_DOMAIN",message:`${i} has ${t.length} extreme value${1===t.length?"":"s"} beyond the 10×IQR guardrail; the main distribution may collapse visually.`,fix:"Verify the extreme values, then consider a log scale, robust extent, inset, or explicit annotation rather than silently clipping them.",...a,rows:nt(t),count:t.length}))}return n}function it(e,t,n){if(!e)return"__all__";try{return Qe(e,t,n)+""}catch{return"__accessor_error__"}}function st(e,t,n){if(e.whenProp&&!0!==n[e.whenProp])return[];const o=t.find(t=>t.contract.role===e.role);if(!o||0===o.observation.numbers.length)return[];const r=e.groupAccessor?n[e.groupAccessor]:void 0,i="string"==typeof r||"function"==typeof r?r:e.defaultGroupAccessor,s=new Map;for(let e=0;o.rows.length>e;e++){let t;try{t=Qe(o.accessor,o.rows[e],e)}catch{continue}const n=Ze(t,void 0);if(null==n)continue;const r=it(i,o.rows[e],e),a=s.get(r)??{sum:0,magnitude:0,positive:!1,negative:!1,rows:[],negativeRows:[]};a.sum+=n,a.magnitude+=Math.abs(n),a.positive||(a.positive=n>0),a.negative||(a.negative=0>n),a.rows.push(e),0>n&&a.negativeRows.push(e),s.set(r,a)}const a=[],c=[],l=[],u=[],d=[],h=[];for(const[t,n]of s)("positive-total"===e.kind&&0>=n.sum||"normalized-total"===e.kind&&Number.EPSILON*Math.max(1,n.magnitude)*10>=Math.abs(n.sum))&&(a.push(t),u.push(...n.rows)),"normalized-total"===e.kind&&n.positive&&n.negative&&(c.push(t),d.push(...n.rows)),"normalized-total"===e.kind&&n.negative&&(l.push(t),h.push(...n.negativeRows));const p=[];return a.length>0&&p.push(ot({severity:"error",code:"normalized-total"===e.kind?"ZERO_NORMALIZED_TOTAL":"NON_POSITIVE_TOTAL",message:"normalized-total"===e.kind?`${a.length} normalization group${1===a.length?" has":"s have"} a zero total, so division would be undefined.`:"The part-to-whole total is not positive, so meaningful shares cannot be computed.",fix:"normalized-total"===e.kind?"Remove empty/zero-sum groups or disable normalization.":"Provide at least one positive value and ensure the total is greater than zero.",field:o.accessorLabel,role:e.role,rows:nt([...new Set(u)].sort((e,t)=>e-t)),count:a.length})),l.length>0&&p.push(ot({severity:"error",code:"NEGATIVE_NORMALIZED_VALUE",message:`${l.length} normalization group${1===l.length?" contains":"s contain"} negative contributions, so conventional percentage shares are not defined.`,fix:"Use non-negative contributions, a diverging stack, or disable normalization.",field:o.accessorLabel,role:e.role,rows:nt([...new Set(h)].sort((e,t)=>e-t)),count:h.length})),c.length>0&&p.push(ot({severity:"warning",code:"MIXED_SIGN_NORMALIZATION",message:`${c.length} normalization group${1===c.length?" mixes":"s mix"} positive and negative contributions; percentage shares may be unstable or misleading.`,fix:"Separate positive and negative contributions, use diverging stacks, or disable normalization.",field:o.accessorLabel,role:e.role,rows:nt([...new Set(d)].sort((e,t)=>e-t)),count:c.length})),p}function at(e,t,n,o={}){const r=o.contracts??function(e){return Oe().contracts.get(e)??$e[e]}(e)??function(e){const t=[];for(const[n,o]of Object.entries(Ue))"string"!=typeof e[n]&&"function"!=typeof e[n]||t.push({role:o,accessor:n,..."size"===o?{requirements:["finite","non-negative"]}:{},..."x"===o||"y"===o?{domain:!0}:{}});return t.length>0?{fields:t}:void 0}(t);if(!r)return{component:e,ok:!0,rowCount:n?.length??(Array.isArray(t.data)?t.data.length:0),summary:{fieldsChecked:0,errors:0,warnings:0},contracts:[],diagnoses:[]};const i=function(e,t,n){const o=[],r=new Set;for(const i of e.fields){if(i.whenProps?.some(e=>null==t[e]))continue;const e=t[i.accessor],s="string"==typeof e||"function"==typeof e?e:i.defaultAccessor;if("string"!=typeof s&&"function"!=typeof s)continue;const{dataProp:a,rows:c}=xe(i,t,n);if(0===c.length)continue;const l="string"==typeof s?s:i.accessor+"()",u=`${a}:${i.role}:${l}`;if(r.has(u))continue;r.add(u);const d=i.temporalValues??("time"===i.role||"x"===i.role&&"time"===t.xScaleType?"date-like":void 0),h="x"===i.role&&"log"===t.xScaleType||"y"===i.role&&"log"===t.yScaleType,p=tt(i,t);o.push({contract:i,accessor:s,accessorLabel:l,dataProp:a,rows:c,requirements:p,logScale:h,observation:et(c,s,l,d,i.missingValue)})}return o}(r,t,n),s=[],a=!1!==o.checkOutliers;for(const e of function(e,t,n){const o=new Set;for(const r of e.fields){const e=r.dataProp??"data",i=n??t[e];if(!Array.isArray(i))continue;if(0===i.length){o.add(e);continue}const s=ve(r,t);if(!s)continue;const a=i.map(e=>e?.[s]).filter(Array.isArray);a.length>0&&a.every(e=>0===e.length)&&o.add(`${e}.${s}`)}return[...o]}(r,t,n))s.push(ot({severity:"error",code:"EMPTY_DATA",message:e+" is an explicitly empty array; there are no numeric inputs to render.",fix:`Provide at least one valid row, render an intentional empty state, or omit ${e} when using the ref push API.`,count:0,rows:[]}));const c=new Set(i.filter(e=>e.contract.domain&&1===e.rows.length).map(e=>e.dataProp));for(const e of c)s.push(ot({severity:"warning",code:"SINGLE_ROW_DOMAIN",message:e+" has one row; a quantitative scale cannot establish variation from a single observation.",fix:"Provide at least two observations or use a single-value display such as BigNumber.",count:1,rows:[0]}));for(const e of i)s.push(...rt(e,a));for(const e of r.aggregates??[])s.push(...st(e,i,t));const l=s.filter(e=>"error"===e.severity).length,u=s.length-l;return{component:e,ok:0===l,rowCount:i.reduce((e,t)=>Math.max(e,t.rows.length),n?.length??(Array.isArray(t.data)?t.data.length:0)),summary:{fieldsChecked:i.length,errors:l,warnings:u},contracts:i.map(e=>({role:e.contract.role,accessor:e.accessorLabel,dataProp:e.dataProp,requirements:e.requirements,allowMissing:!0===e.contract.allowMissing,...void 0!==e.contract.missingValue?{missingValue:e.contract.missingValue}:{},domain:!0===e.contract.domain})),diagnoses:s}}var ct=c({"src/components/data/auditData.ts"(){j(),Ee(),Fe(),qe(),qe(),Ke(),Xe=5,Ue={xAccessor:"x",yAccessor:"y",valueAccessor:"value",sizeBy:"size",sizeAccessor:"size",radiusAccessor:"size",countAccessor:"count",amountAccessor:"value",highAccessor:"high",lowAccessor:"low",openAccessor:"open",closeAccessor:"close",lowerAccessor:"lower",upperAccessor:"upper",positiveAccessor:"value",negativeAccessor:"value",progressAccessor:"value",confidenceAccessor:"value",costAccessor:"value",throughputAccessor:"value"}}}),lt={};function ut(e,t){if(!t||!e?.component||!e.props)return[];const n="object"==typeof t?t:{};try{return Ve(at(e.component,e.props,void 0,{checkOutliers:n.checkOutliers}),{max:n.max,errorsOnly:n.errorsOnly})}catch{return[]}}l(lt,{buildChartDataAuditNotifications:()=>ut});var dt,ht=c({"src/components/chartContainerDataAudit.ts"(){ct(),Ke()}}),pt={};l(pt,{AccessibleNavTree:()=>KD,AreaChart:()=>Ym,AreaChartCapability:()=>fE,BUILT_IN_AUDIENCES:()=>BF,BUILT_IN_INTENT_IDS:()=>zH,BarChart:()=>Bg,BarChartCapability:()=>TE,BigNumber:()=>P_,BoxPlot:()=>Jg,BoxPlotCapability:()=>qE,BubbleChart:()=>yy,BubbleChartCapability:()=>wE,BumpChart:()=>zm,BumpChartCapability:()=>gE,CANONICAL_FIXTURES:()=>iz,CandlestickChart:()=>lf,CandlestickChartCapability:()=>ME,CategoryColorProvider:()=>sh,ChainReactionChart:()=>g_,ChartContainer:()=>u$,ChartGrid:()=>A$,ChartRecipe:()=>kH,ChordDiagram:()=>Yw,ChordDiagramCapability:()=>KE,ChoroplethMapCapability:()=>oO,CirclePack:()=>eA,CirclePackCapability:()=>tO,CollisionSwarmChart:()=>uI,ConnectedScatterplot:()=>hy,ConnectedScatterplotCapability:()=>xE,ContextLayout:()=>j$,CrucibleChart:()=>UT,DEFAULT_LIFECYCLE_THRESHOLDS:()=>$n,DEFAULT_SCALE_THRESHOLDS:()=>eE,DetailsPanel:()=>T$,DifferenceChart:()=>Km,DifferenceChartCapability:()=>CE,DistanceCartogramCapability:()=>sO,DonutChart:()=>bb,DonutChartCapability:()=>$E,DotPlot:()=>lb,DotPlotCapability:()=>DE,EventDropChart:()=>KP,FlowMapCapability:()=>iO,ForceDirectedGraph:()=>Ww,ForceDirectedGraphCapability:()=>XE,FunnelChart:()=>Rb,FunnelChartCapability:()=>EE,GaltonBoardChart:()=>YP,GaugeChart:()=>jb,GaugeChartCapability:()=>OE,GauntletChart:()=>kR,GroupedBarChart:()=>Wg,GroupedBarChartCapability:()=>_E,Heatmap:()=>vy,HeatmapCapability:()=>jE,Histogram:()=>ob,HistogramCapability:()=>WE,IntentMark:()=>NH,LikertChart:()=>Gb,LikertChartCapability:()=>zE,LineChart:()=>bm,LineChartCapability:()=>yE,LinkedCharts:()=>up,MinimapChart:()=>Wy,MinimapChartCapability:()=>AE,MobileAnnotationCalloutList:()=>aW,MobileChartContainer:()=>m$,MobileStandardControls:()=>lN,MultiAxisLineChart:()=>sf,MultiAxisLineChartCapability:()=>SE,MultiLineTooltip:()=>ru,OrbitDiagram:()=>rA,OrbitDiagramCapability:()=>nO,PacketFlowChart:()=>SI,PhysicsCustomChart:()=>nI,PieChart:()=>yb,PieChartCapability:()=>NE,ProcessFlowChart:()=>LI,ProcessSankey:()=>GS,ProcessSankeyCapability:()=>QE,ProportionalSymbolMapCapability:()=>rO,QuadrantChart:()=>Qy,QuadrantChartCapability:()=>kE,RealtimeHeatmap:()=>GA,RealtimeHistogram:()=>NA,RealtimeLineChart:()=>TA,RealtimeSwarmChart:()=>OA,RealtimeWaterfallChart:()=>HA,RidgelinePlot:()=>hb,RidgelinePlotCapability:()=>VE,SankeyDiagram:()=>Uw,SankeyDiagramCapability:()=>UE,Scatterplot:()=>cy,ScatterplotCapability:()=>vE,ScatterplotMatrix:()=>Ny,SmallMultipleChart:()=>w$,StackedAreaChart:()=>Jm,StackedAreaChartCapability:()=>bE,StackedBarChart:()=>Fg,StackedBarChartCapability:()=>LE,SwarmPlot:()=>Xg,SwarmPlotCapability:()=>GE,SwimlaneChart:()=>Xb,SwimlaneChartCapability:()=>HE,TemporalHistogram:()=>$A,ThemeProvider:()=>Lh,TooltipProvider:()=>R_,TreeDiagram:()=>XS,TreeDiagramCapability:()=>ZE,Treemap:()=>QS,TreemapCapability:()=>eO,UnitPileChart:()=>sI,ViolinPlot:()=>sb,ViolinPlotCapability:()=>YE,accessibilityCaveats:()=>dB,analystPersona:()=>NF,annotationFreshnessFor:()=>La,annotationStableId:()=>Us,applyAnnotationLifecycle:()=>Ea,applyAnnotationStatus:()=>qa,applyAudienceBias:()=>wO,applyScaleBias:()=>pE,auditAccessibility:()=>uB,auditData:()=>at,auditMobileVisualization:()=>HN,auditObservedScene:()=>RH,auditVisualizationControls:()=>z_,bandFromAge:()=>Bn,buildNavigationTree:()=>uD,buildReaderGrounding:()=>VO,buildRecipeNavigationTree:()=>lD,chartGenerationTool:()=>gF,clampMobileRange:()=>JD,classifyCardinalityBand:()=>rE,classifyFieldBand:()=>iE,classifyRowBand:()=>oE,clearVariantDiscovery:()=>tW,communicativeActForIntent:()=>XL,compareBands:()=>sE,computeAnnotationFreshness:()=>Da,computeEffectiveScale:()=>lE,configToJSX:()=>IL,copyConfig:()=>PL,countNodes:()=>hD,createChartToolHandler:()=>kF,createIndexedDBConversationArcSink:()=>$D,createLocalStorageConversationArcSink:()=>ND,createWebhookConversationArcSink:()=>BD,currentTimestamp:()=>Ia,dataQualityToAnnotations:()=>aF,dataScientistPersona:()=>$F,defineChartRecipe:()=>H_,describeChart:()=>iD,describeRecipeChart:()=>BL,deserializeSelections:()=>fB,diagnoseConfig:()=>nB,diagnoseTokenEncoding:()=>O$,diffProfile:()=>KF,disableConversationArc:()=>GD,effectiveFamiliarity:()=>kO,enableConversationArc:()=>qD,evaluateVariantProposal:()=>ZH,executivePersona:()=>DF,explainCapabilityFit:()=>TO,exportChart:()=>__,filterAnnotationsByStatus:()=>Wa,flattenVisible:()=>dD,formatAccessibilityAudit:()=>mB,formatDataAudit:()=>Ge,formatMobileVisualizationAudit:()=>GN,fromConfig:()=>CL,fromDbtArtifacts:()=>uF,fromGreatExpectations:()=>pF,fromURL:()=>jL,fromVegaLite:()=>kB,getCapabilities:()=>mO,getCapability:()=>yO,getChartRecipe:()=>rL,getConversationArcStore:()=>YD,getIntent:()=>EH,getRecipeLayout:()=>cL,getRegisteredVariantDiscovery:()=>eW,getStreamCapabilities:()=>HF,inferIntent:()=>TF,intentManifestFromRecipe:()=>LH,isJsonSafe:()=>G_,isRegisteredRecipeLayout:()=>q_,listChartRecipes:()=>iL,listIntents:()=>OH,loadConversationArc:()=>ED,mobileVisualizationCaveats:()=>YN,normalizeTokenEncoding:()=>E$,prepareChart:()=>fF,profileData:()=>JB,profileNumericFields:()=>We,proposeVariant:()=>QH,rankBumpData:()=>Nm,receivabilityBias:()=>xO,recipeToChartCapability:()=>J_,recordAnnotationStatusChange:()=>zD,recordAudienceChange:()=>FD,registerChartCapability:()=>hO,registerChartRecipe:()=>nL,registerConversationArcSink:()=>DD,registerIntent:()=>FH,registerRecipeLayout:()=>sL,registerStreamChartCapability:()=>FF,registerVariantDiscovery:()=>JH,repairChartConfig:()=>mF,replayConversationArc:()=>OD,resolveCardinalityToNumber:()=>cE,resolveChartRecipe:()=>lL,resolveCommunicativeAct:()=>UL,resolveRecipeRoleField:()=>Z_,resolveResponsiveRules:()=>Bh,resolveRowsToNumber:()=>aE,responsiveRuleMatches:()=>$h,runQualityScorecard:()=>QF,scaleHints:()=>mE,scoreChart:()=>_O,serializeSelections:()=>yB,stretchFamiliarityCeiling:()=>SO,subscribeToConversationArcChange:()=>LD,suggestCharts:()=>RO,suggestChartsGrouped:()=>LO,suggestDashboard:()=>LF,suggestStreamCharts:()=>YF,suggestStretchCharts:()=>_F,suggestTokenEncoding:()=>H$,summarizeArc:()=>rW,summarizeData:()=>TB,summarizeIntentManifest:()=>_H,toAnthropicTool:()=>bF,toConfig:()=>AL,toDataAuditNotifications:()=>Ve,toOpenAIResponsesTool:()=>wF,toOpenAITool:()=>vF,toURL:()=>ML,tokenTaskIntentToCapabilityIntents:()=>z$,unregisterChartCapability:()=>pO,unregisterChartRecipe:()=>oL,unregisterRecipeLayout:()=>aL,unregisterStreamChartCapability:()=>zF,useBrushSelection:()=>kh,useCategoryColors:()=>ah,useChartFocus:()=>eF,useChartInterrogation:()=>QO,useChartObserver:()=>Qh,useChartSuggestions:()=>uz,useConversationArc:()=>iW,useFilteredData:()=>Sh,useLinkedChartsActive:()=>tp,useLinkedHover:()=>xh,useMobileRangeControls:()=>tN,useNavigationSync:()=>IF,useSelection:()=>bh,useSelectionActions:()=>vh,useTheme:()=>Dh,validateChartRecipe:()=>W_,validateProps:()=>N$,withCurrentProvenance:()=>Ra,withProvenance:()=>Pa,zoomMobileRange:()=>eN}),module.exports=(dt=pt,u(o({},"__esModule",{value:!0}),dt));var mt=require("react"),yt=Object.freeze([]);function ft(e){if(!e)return yt;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}var gt=d(require("react")),bt=require("react"),vt=d(require("react")),xt=require("react/jsx-runtime"),wt=null,kt=null;function St(e){const[t,n]=vt.useState(()=>wt);return vt.useEffect(()=>{if(t)return;let e=!1;return(wt?Promise.resolve(wt):(kt||(kt=Promise.resolve().then(()=>(A(),b)).then(e=>wt=e.XYBrushOverlay).catch(e=>{throw kt=null,e})),kt)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,xt.jsx)(t,{...e}):null}var At=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=ft(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=ft(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}},Ct=require("react"),Mt=require("react/jsx-runtime");function jt(e){let t=null;const n=()=>(t||(t=(0,Ct.createContext)(null)),t),o=Pt(e);return[function({children:t,initialState:o}){const r=(0,Ct.useRef)(o),i=(0,Ct.useMemo)(()=>Pt(e,r.current),[]),s=n();return(0,Mt.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const r=n(),i=(0,Ct.useContext)(r)??o,s=(0,Ct.useRef)(e);s.current=e;const a=(0,Ct.useRef)({hasValue:!1,value:void 0}),c=(0,Ct.useCallback)(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=(0,Ct.useCallback)(()=>s.current(i.getState()),[i]);return(0,Ct.useSyncExternalStore)(i.subscribe,c,l)}]}function Pt(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(It(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 It(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Rt(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 Tt(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:_t}}),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 _t=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Lt={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}},Dt={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}},Nt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:_t,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 $t(e,t){if("light"===t)return Lt;if("dark"===t)return Dt;if("high-contrast"===t)return Nt;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?Dt:Lt;return Tt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Tt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Bt,Et]=jt(e=>({theme:Lt,setTheme(t){e(e=>({theme:$t(e.theme,t)}))}})),Ot=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,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}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}},Ft=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 zt(e,t){return e===t}function Ht(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Wt(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function qt(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function Gt(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function Yt(e){return"string"==typeof e?e:e.id}function Vt(e){return new Set(Array.isArray(e)?e:[e])}j();var Xt=require("d3-scale");function Ut(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function Kt(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function Qt(e){const t=e.map(Ut),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return Kt(e,n,o)}if(e>=1){const[e,o,r]=t[n];return Kt(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return Kt(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(d-c)*i))}}var Zt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Jt=Qt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),en=Qt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),tn=Qt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),nn=Qt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),on=Qt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),rn=Qt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),sn=Qt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),an=Qt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),cn=Qt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),ln=Qt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),un=Qt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),dn=Qt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),hn={blues:Jt,reds:en,greens:tn,viridis:sn,oranges:nn,purples:on,greys:rn,plasma:an,inferno:cn,magma:ln,cividis:un,turbo:dn};function pn(e){return e&&hn[e]||Jt}var mn=Qt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),yn=Qt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),fn=Qt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),gn=Qt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),bn=Qt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),vn=Qt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),xn=Qt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),wn={category10:Zt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...hn},kn=Zt,Sn="#007bff";function An(e,t,n=kn){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=wn[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var Cn=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Mn=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],jn=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 Pn(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")||jn.has(t)}(o)?n(o):o}const o=e?.[t]+"";return n?n(o):kn[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))%kn.length]}function In(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 Rn(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>In(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(0,Xt.scaleOrdinal)().domain(o).range(n).unknown("#999");const i=wn[n]||wn.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:kn;return(0,Xt.scaleOrdinal)().domain(o).range(e).unknown("#999")}}function Tn(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e?.[t],!o)return r;const[i,s]=o,[a,c]=n;if(s===i)return(a+c)/2;let l=(r-i)/(s-i);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function _n(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Ln(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Dn(e,t,n){return e+(t-e)*n}function Nn(){return"undefined"!=typeof performance?performance.now():Date.now()}var $n={fresh:1,aging:1.5,stale:3};function Bn(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??$n.fresh)>e?"fresh":t*(n.aging??$n.aging)>e?"aging":t*(n.stale??$n.stale)>e?"stale":"expired":"fresh"}function En(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 On(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Fn(e,t,n){const o=e.duration??500,r=n-t;return o>r?1-r/o:0}function zn(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 Hn(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 Wn(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 qn(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Gn(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:i}}function Yn(e,t,n,o,r,i,s,a){const c=[];for(const i of e){const e=n(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):r;c.push({px:l,topY:t.y(s),botY:t.y(u),rawY:s})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length),d=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],d[e]=t.rawY}return{type:"area",topPath:l,bottomPath:u,rawValues:d,style:i,datum:e,group:s}}function Vn(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],s=e[o];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=r.get(i)??0;r.set(s,u-(c>0?a/(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 Xn(e,t,n,o,r,i,s){const a=n(e),c=o(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function Un(e,t,n,o,r,i,s,a){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:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Kn(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function Qn(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Zn(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 Jn(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 s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);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,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Zn(e,o,n,t[0]),datum:t,group:n,interactive:o.interactive}}function eo(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 to(e,t,n){const o=[];for(const r of n){const n=Jn(e,t,"__ribbon_aggregate",r);n&&o.push(n)}return o}function no(e,t,n,o){const r=[];for(const i of o){const o=Jn(e,t,n,i);o&&r.push(o)}return r}function oo(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 ro(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 s=o.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Xn(i,e.scales,e.getX,r,s,o,a);c&&n.push(c)}}}function io(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var so={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function ao(e,t=so){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function co(e){return e?ao(e):void 0}function lo(e){return ao(e)}var uo=require("d3-shape"),ho={circle:uo.symbolCircle,square:uo.symbolSquare,triangle:uo.symbolTriangle,diamond:uo.symbolDiamond,star:uo.symbolStar,cross:uo.symbolCross,wye:uo.symbolWye},po=["circle","triangle","diamond","star","square","chevron","cross","wye"];function mo(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*yo(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):(0,uo.symbol)(ho[o]??uo.symbolCircle,Math.max(1,t))()??""}function yo(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function fo(e,t){const n=new Map;let o=0;return r=>{const i=e(r)+"",s=t?.[i];if(s)return s;let a=n.get(i);return a||(a=po[o%po.length],o++,n.set(i,a)),a}}var go=new Map;function bo(e,t,n){const o=n.config.areaStyle?.(t);return o&&(e.style=o),e}function vo(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))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+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function xo(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;wo(o)&&0===n.length&&ko(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)&&ko(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 wo(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(wo))}function ko(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function So(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 Ao(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function Co(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,o=Ao(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Ht(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:Ao(e.y1Accessor,"y1"),getBottom:Ao(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var Mo=require("d3-scale");function jo(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Po(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,Mo.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,Mo.scaleSymlog)().domain(t).range(n):"time"===e?(0,Mo.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,Mo.scaleLinear)().domain(t).range(n)}function Io(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function Ro(e,t){const n=new Ot(e.capacity);return e.forEach(()=>n.push(t)),n}function To(e,t,n,o){const r=e.push(t);return n&&n.push(o),r}function _o(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 Lo=new WeakMap;function Do(){return this.updateResults.last}function No(){return this.updateResults.last}function $o(e){return this.updateResults.subscribe(e)}function Bo(e){this.config.layoutSelection=e}function Eo(){Lo.set(this,!0)}function Oo(){const e=!0===Lo.get(this);return Lo.delete(this),e}function Fo(e){Object.assign(e.prototype,{getLastUpdateResult:Do,getUpdateSnapshot:No,subscribeUpdateResult:$o,setLayoutSelection:Bo,markStylePaintPending:Eo,consumeStylePaintPending:Oo})}var zo={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 Ho(e,t){const n={...e};for(const e of t)n[zo[e]]++;return n}function Wo(e,t,n){const o=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:o,revisions:Ho(n,o)}}var qo=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=Wo({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=Wo(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Go=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yo=["scene-style","data-paint","accessibility","evidence"],Vo=(e,t)=>({retainedData:e,invalidations:t}),Xo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Uo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ko=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Zo=["scene-geometry","data-paint","accessibility","evidence"],Jo=["scene-style","data-paint","accessibility","evidence"],er=[],tr={chartType:Vo("rebuild",Xo),runtimeMode:Vo("rebuild",Xo),xAccessor:Vo("rebuild",Xo),yAccessor:Vo("rebuild",Xo),timeAccessor:Vo("rebuild",Xo),valueAccessor:Vo("rebuild",Xo),y0Accessor:Vo("rebuild",Xo),boundsAccessor:Vo("rebuild",Xo),band:Vo("rebuild",Xo),openAccessor:Vo("rebuild",Xo),highAccessor:Vo("rebuild",Xo),lowAccessor:Vo("rebuild",Xo),closeAccessor:Vo("rebuild",Xo),candlestickRangeMode:Vo("rebuild",Xo),accessorRevision:Vo("rebuild",Xo),groupAccessor:Vo("rebuild",Uo),categoryAccessor:Vo("rebuild",Uo),lineDataAccessor:Vo("rebuild",Uo),colorAccessor:Vo("rebuild",Jo),sizeAccessor:Vo("rebuild",Zo),symbolAccessor:Vo("rebuild",Zo),pointIdAccessor:Vo("rebuild",Zo),xScaleType:Vo("preserve",Ko),yScaleType:Vo("preserve",Ko),xExtent:Vo("preserve",Ko),yExtent:Vo("preserve",Ko),extentPadding:Vo("preserve",Ko),scalePadding:Vo("preserve",Ko),axisExtent:Vo("preserve",Ko),yAxisExtent:Vo("preserve",Ko),binSize:Vo("preserve",Ko),normalize:Vo("preserve",Ko),heatmapAggregation:Vo("preserve",Ko),heatmapXBins:Vo("preserve",Ko),heatmapYBins:Vo("preserve",Ko),arrowOfTime:Vo("preserve",Qo),baseline:Vo("preserve",Qo),stackOrder:Vo("preserve",Qo),sizeRange:Vo("preserve",Qo),curve:Vo("preserve",Qo),areaGroups:Vo("preserve",Qo),customLayout:Vo("preserve",Qo),layoutConfig:Vo("preserve",Qo),layoutMargin:Vo("preserve",Qo),symbolMap:Vo("preserve",Zo),showValues:Vo("preserve",Zo),heatmapValueFormat:Vo("preserve",Zo),lineStyle:Vo("preserve",Jo),pointStyle:Vo("preserve",Jo),areaStyle:Vo("preserve",Jo),barStyle:Vo("preserve",Jo),swarmStyle:Vo("preserve",Jo),waterfallStyle:Vo("preserve",Jo),candlestickStyle:Vo("preserve",Jo),boundsStyle:Vo("preserve",Jo),gradientFill:Vo("preserve",Jo),lineGradient:Vo("preserve",Jo),semanticLineStops:Vo("preserve",Jo),colorScheme:Vo("preserve",Jo),themeCategorical:Vo("preserve",Jo),themeSemantic:Vo("preserve",Jo),themeSequential:Vo("preserve",Jo),themeDiverging:Vo("preserve",Jo),barColors:Vo("preserve",Jo),decay:Vo("preserve",Jo),pulse:Vo("preserve",Jo),staleness:Vo("preserve",Jo),layoutSelection:Vo("preserve",Jo),annotations:Vo("preserve",["overlay","accessibility","evidence"]),windowSize:Vo("preserve",er),windowMode:Vo("preserve",er),maxCapacity:Vo("preserve",er),clock:Vo("preserve",er),transition:Vo("preserve",er),introAnimation:Vo("preserve",er),onLayoutError:Vo("preserve",er)},nr=Vo("preserve",Qo),or=class{constructor(){this.tracker=new qo}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}},Go)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Yo):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=tr[o]??nr;"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)}},rr=require("d3-quadtree"),ir=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=(0,rr.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},sr=class e{constructor(e){if(this.xExtent=new Ft,this.yExtent=new Ft,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 or,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 ir,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 s=e.color??"rgba(255,255,255,0.6)",a=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,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=o.get(t);if(null==s)continue;const c=Fn(e,s,i);c>r&&(r=c)}a&&(c=zn(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=o.get(t);c=zn(n,null==r?0:Fn(e,r,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new Ot(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Ht(e.timeAccessor||e.xAccessor,"time"),this.getY=Ht(e.valueAccessor||e.yAccessor,"value")):(this.getX=Ht(e.xAccessor,"x"),this.getY=Ht(e.yAccessor,"y")),this.getGroup=qt(e.groupAccessor),this.getCategory=qt(e.categoryAccessor),this.getSize=e.sizeAccessor?Ht(e.sizeAccessor,"size"):void 0,this.getColor=qt(e.colorAccessor),this.getSymbol=qt(e.symbolAccessor),this.getY0=e.y0Accessor?Ht(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Co(e),this.getPointId=qt(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Ht(e.openAccessor,"open"):void 0,this.getHigh=Ht(e.highAccessor,"high"),this.getLow=Ht(e.lowAccessor,"low"),this.getClose=n?Ht(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new Ot(e.windowSize))}currentTime(){return this.config.clock?.()??Nn()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ro(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?Ht(this.config.timeAccessor||this.config.xAccessor,"time"):Ht(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(C(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>M(t[e]):e=>M(n(e))}}Io(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)To(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=To(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(),s=this.yExtent.extent;let a=jo(this.xExtent.extent,t.xExtent),c=jo(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===(t.yAxisExtent??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.yAxisExtent??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 s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=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),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.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,y;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=Vn(e,m,(e,t)=>a.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 s=r-o,l=i?0:s>0?s*t.extentPadding:1;y=[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,s=0;for(const o of t){const t=n(o,i)||0;0>t?s+=t:e+=t}o>s&&(o=s),e>r&&(r=e)}return[o,r]}(e,m,(e,t)=>a.get(e)?.get(t)||0),r=o-n,s=i?0:r>0?r*t.extentPadding:1;y=[n-s,o+s]}else y=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({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,s){const[,a]=function(e,t,n,o,r){const i=vo(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,o,r);return[0,s?a:a+a*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),s=i-r,a=o?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(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:s}));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:a,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}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:o,yDomain:r}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,Mo.scaleLinear)().domain(o).range(e),y:Po(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Po(t.yScaleType,r,[s,n.width-s]),y:(0,Mo.scaleLinear)().domain(o).range(e)}}var a;return{x:Po(t.xScaleType,o,[s,n.width-s]),y:Po(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,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}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*n,height:e.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(),s=this.scales.y.range(),a=Po,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(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??Cn},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=So("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 s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return xo({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}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(io).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=eo(e.ribbons);if(i.length>0&&o.push(...to(e,t,i)),r.length>0)for(const t of n)o.push(...no(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Gn(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 ro(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}=eo(e.ribbons);if(i.length>0&&o.push(...to(e,t,i)),r.length>0)for(const t of n)o.push(...no(e,t.data,t.key,r))}const r=e.scales.y.domain(),i=r[0],s=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:r[0]+Math.max(0,Math.min(1,e.offset))*(r[1]-r[0]),color:e.color,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),a=s&&s.length>0?(()=>{const t=s.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),n=[{from:r[0],to:t[0].value}];for(let e=0;t.length>e;e++)n.push({from:t[e].value,to:t[e+1]?.value??r[1],color:t[e].color});return n.map(({from:t,to:n,color:o})=>{const r=e.scales.y(t),i=e.scales.y(n);return{y:Math.min(r,i),height:Math.abs(i-r),color:o}}).filter(e=>e.height>0)})():void 0,c=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Yn(t.data,e.scales,e.getX,e.getY,i,n,t.key,c),l=lo(e.config.gradientFill);l&&(r.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),s&&s.length>0&&(r.colorThresholds=s,r.strokeColorBands=a),o.push(r)}return ro(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}=eo(e.ribbons);if(i.length>0&&o.push(...to(e,t,i)),r.length>0)for(const t of n)o.push(...no(e,t.data,t.key,r))}const i=e.scales.y.domain()[0],s=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=Yn(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=lo(e.config.gradientFill);a&&(r.fillGradient=a),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=Gn(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 ro(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 s=0,a=0;for(const n of e)a>s?(o.push(n),s+=t.get(n.key)??0):(i.push(n),a+=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,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,o,r,i,s,a="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=Vn(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),p="diverging"===a&&!i,m=[],y=new Map,f=new Map,g=new Map,b=new Map;for(const e of l)f.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 a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),m.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,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?(s=g.get(n),l=s+u,g.set(n,l)):(s=b.get(n),l=s+u,b.set(n,l)):(s=f.get(n),l=s+u,f.set(n,l));const m=t.x(n);c.push([m,t.y(s)]),a.push([m,t.y(l)]),o.set(n,l)}h(),y.set(n.key,o)}return{nodes:m,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;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);ro(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 s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=c?fo(c,e.config.symbolMap):null;for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},c=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(c=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(l){const o=l(r),i=Un(r,e.scales,e.getX,e.getY,Math.PI*c*c,o,t,u);i&&n.push(i)}else{const o=Xn(r,e.scales,e.getX,e.getY,c,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",s=Ht(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/o,h=(u-l||1)/r,p=o*r;if(p>1e6)return[];const m=new Int32Array(p),y=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-a)/d),o-1),f=Math.min(Math.floor((u-l)/h),r-1);if(0>p||0>f)continue;const g=f*o+p;m[g]++;const b=s(i);y[g]+=isFinite(b)?b:0}let f=1/0,g=-1/0;for(let e=0;p>e;e++){if(0===m[e])continue;let t;switch(i){case"sum":t=y[e];break;case"mean":t=y[e]/m[e];break;default:t=m[e]}f>t&&(f=t),t>g&&(g=t)}if(!isFinite(f))return[];const b=g-f||1,v=n.width/o,x=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let t=0;r>t;t++){const n=t*o;for(let s=0;o>s;s++){const o=n+s;if(0===m[o])continue;let c;switch(i){case"sum":c=y[o];break;case"mean":c=y[o]/m[o];break;default:c=m[o]}const u=(c-f)/b,p={xi:s,yi:t,value:c,count:m[o],sum:y[o],xCenter:a+(s+.5)*d,yCenter:l+(t+.5)*h,agg:i};S.push(bo(Qn(s*v,(r-1-t)*x,v,x,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,p,w?{value:c,showValues:!0,valueFormat:k}:void 0),p,e))}}return S}(e,t,n);if(0===t.length)return[];const o=Ht(e.config.valueAccessor,"value"),r=Wt(e.config.xAccessor,"x"),i=Wt(e.config.yAccessor,"y"),s=new Map,a=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,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),p=Array.from(a.keys()),m=h.every(e=>"number"==typeof e&&!isNaN(e)),y=p.every(e=>"number"==typeof e&&!isNaN(e));if(m){h.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){p.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;p.length>e;e++)a.set(p[e],e)}const f=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=s.get(c[e]),i=a.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)),f[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 hn?e:"blues";let n=go.get(t);if(n)return n;n=Array(256);const o=pn(t);for(let e=0;256>e;e++)n[e]=o(e/255);return go.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,j=e.config.showValues,P=e.config.heatmapValueFormat,I=[];for(let t=0;x>t;t++){const n=g[t];if(!isFinite(n))continue;const o=f[t],r=o%u,i=b[t];I.push(bo(Qn(r*C,(d-1-(o-r)/u)*M,C,M,S[Math.min((n-w)*A+.5|0,255)],i,j?{value:n,showValues:!0,valueFormat:P}:void 0),i,e))}return I}(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=vo(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),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?o=e.barCategoryCache.order:(o=[...a,...s],e.barCategoryCache={key:c,order:o})}const r=[],i=e.scales,[s,a]=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,s),u=Math.min(t.end,a);if(n>=u)continue;const p=i.x(n),m=i.x(u),y=Math.abs(m-p),f=y>d+1?d:0,g=Math.min(p,m)+f/2,b=Math.max(y-f,1);if(b>0)if(o&&t.categories.size>0){let n=0;for(const s of o){const o=t.categories.get(s)||0;if(0===o)continue;const a=i.y(n),u=i.y(n+o);r.push(Kn(g,Math.min(a,u),b,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:o},s)),n+=o}}else{const e=i.y(0),n=i.y(t.total);r.push(Kn(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",s=o.opacity??.7,a=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)??{},y={type:"point",x:u,y:d,r:p??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...m},datum:o};e.getPointId&&(y.pointId=e.getPointId(o)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const o=[],r=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=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;s.length>t;t++){const m=s[t],y=e.getX(m),f=e.getY(m),g=p+f;let b;b=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const v=r.x(y),x=0!==b?r.x(y+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),j={fill:0>f?c:a,stroke:u,strokeWidth:d};null!=h&&(j.opacity=h),o.push(Kn(w,C,k,M,j,{...m,baseline:p,cumEnd:g,delta:f,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),p=g}return o}(r,t,e);case"candlestick":return function(e,t,n){if(!e.getHigh||!e.getLow||!e.scales)return[];const o=e.config.candlestickRangeMode??!1;if(!(o||e.getOpen&&e.getClose))return[];const r=[],i=e.config.candlestickStyle||{},s=i.rangeColor||"#6366f1",a=o?s:i.upColor||"#28a745",c=o?s:i.downColor||"#dc3545",l=o?s:i.wickColor||"#333",u=i.wickWidth||(o?2:1),d=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=i.bodyWidth??0;if(null==i.bodyWidth)if(d.length>1){let t=1/0;for(let n=1;d.length>n;n++){const o=Math.abs(e.scales.x(d[n])-e.scales.x(d[n-1]));o>0&&t>o&&(t=o)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const s=e.getHigh(i),d=e.getLow(i);if(null==s||Number.isNaN(s)||null==d||Number.isNaN(d))continue;const p=o?s:e.getOpen(i),m=o?d:e.getClose(i);if(!o&&[p,m].some(e=>null==e||Number.isNaN(e)))continue;const y=m>=p,f={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(m),highY:e.scales.y(s),lowY:e.scales.y(d),bodyWidth:h,upColor:a,downColor:c,wickColor:l,wickWidth:u,isUp:y,datum:i};o&&(f.isRange=!0,f.dotRadius=Math.max(2,Math.min(h/2,.12*n.height))),r.push(f)}return r}(r,t,e);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?En(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=On(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,o=On(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 s=!1;for(let n=0;t.length>n;n++){const a=o.get(t[n]);null!=a?(i[n]=En(e,a,r),1>i[n]&&(s=!0)):i[n]=1}s&&(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 s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=o.get(t[n]);null!=i?(s[n]=En(e,i,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=o.get(n);if(null!=t){const n=En(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=o.get(n.datum);if(null==t)continue;const i=En(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&&Hn(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],s=Wn(e,i,r);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:qn(i.style)}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:qn(i.style),glyph:i.glyph}):"rect"===i.type||"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:qn(i.style)}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:qn(i.style)}):"line"===i.type?o.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&o.set(s,{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=Wn(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=Nn()){if(0===o.size&&0===r.size)return n;const s=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 a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=Wn(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=r.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=qn(i.style),u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=qn(i.style),i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=qn(i.style),u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=qn(i.style),i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=qn(i.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=qn(i.style),i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=qn(i.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=qn(i.style),i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=qn(i.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=qn(i.style),i.style={...i.style||{},opacity:0},a=!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),a=!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),a=!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})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),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=Ln(e,n.activeTransition),i=_n(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=Dn(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=Dn(n.x,e._targetX,i),e.y=Dn(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Dn(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=Dn(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=Dn(n.x,e._targetX,i),e.y=Dn(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Dn(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=Dn(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=Dn(n.x,e._targetX,i),e.y=Dn(n.y,e._targetY,i),void 0!==n.w&&(e.w=Dn(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Dn(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:Dn(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=Dn(n.x,e._targetX,i),e.y=Dn(n.y,e._targetY,i),void 0!==n.w&&(e.w=Dn(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Dn(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:Dn(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=Dn(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Dn(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Dn(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Dn(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Dn(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Dn(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]=Dn(t[o][0],n[o][0],i),e.path[o][1]=Dn(t[o][1],n[o][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Dn(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]=Dn(t[n][0],o[n][0],i),e.topPath[n][1]=Dn(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]=Dn(n[t][0],r[t][0],i),e.bottomPath[t][1]=Dn(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,function(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0);else if("candlestick"===t.type)void 0!==t._targetX&&(t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0);else if("line"===t.type||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}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 s=Array.from(i).sort(),a=s.join("\0");if(r&&r.key===a){const e={...r,version:o};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||Cn,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,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 s=o(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,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:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=o.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||Cn;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(t,l),o.size>r){const e=o.keys().next().value;void 0!==e&&o.delete(e)}return{color:l,groupColorCounter:s}}({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=Vt(e),n=this.getPointId,o=e=>t.has(n(e));_o(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=Vt(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,s=e&&t.valueAccessor||t.yAccessor,a=i||!zt(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!zt(n,s);(a||c)&&(e?(this.getX=Ht(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ht(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ht(this.config.xAccessor,"x"),this.getY=Ht(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Co(this.config)),o=!0,r=!0)}if("groupAccessor"in e&&!zt(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?qt(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in e&&!zt(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?qt(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in e&&!zt(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ht(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in e&&!zt(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?qt(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in e&&!zt(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?qt(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in e&&!zt(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ht(this.config.y0Accessor,"y0"):void 0,o=!0,r=!0),("boundsAccessor"in e&&!zt(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Co(this.config),o=!0,r=!0),"pointIdAccessor"in e&&!zt(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?qt(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!zt(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!zt(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!zt(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!zt(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Ht(this.config.openAccessor,"open"):void 0,this.getHigh=Ht(this.config.highAccessor,"high"),this.getLow=Ht(this.config.lowAccessor,"low"),this.getClose=t?Ht(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}};sr.GROUP_COLOR_MAP_CAP=1e3;var ar=sr;Fo(ar);var cr=require("react"),lr={sceneGeometry:0,layout:0,domain:0};function ur(e){const{domain:t,layout:n,sceneGeometry:o}=e.revisions;return{domain:t,layout:n,sceneGeometry:o}}function dr(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 hr="production"!==process.env.NODE_ENV,pr={revisions:lr,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},mr=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=lr,this.lastObserved=lr,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){hr&&(this.lastObserved=dr(this.lastObserved,ur(e)))}beforeCompute(e,t){if(!hr)return pr;const n=dr(ur(e),this.lastObserved),o=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;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(hr){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 yr(e){return(0,cr.useRef)(new mr(e))}var fr=(0,cr.memo)(function({store:e,diagnostics:t}){return(0,cr.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),gr=d(require("react"));function br(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:gr.createElement(gr.Fragment,null,...t)}var vr=d(require("react")),xr=require("react/jsx-runtime"),wr={isActive:!1,predicate:()=>!0},kr=vr.createContext(null);function Sr({value:e,children:t}){return(0,xr.jsx)(kr.Provider,{value:e,children:t})}function Ar(e,t){return null!=e?(0,xr.jsx)(Sr,{value:t,children:e}):e}var Cr=require("react");function Mr(e,t,n,o){(0,Cr.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function jr(e,t,n,o){const r=(0,Cr.useRef)(null);(0,Cr.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;r.current!==s&&(r.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,o())},[t,o,e,n])}function Pr(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 Ir(e,t=30){return Math.max((e??4)+5,12,t)}function Rr(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Tr(e,t){const n=Rr(e);if(!n)return!1;const o=Rr(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function _r(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Lr=[40,40],Dr=[.5,.5];function Nr(e,t){const[n,o]=e.viewBox??Lr,[r,i]=e.anchor??Dr,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function $r(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}var Br=null;function Er(e){if("undefined"==typeof Path2D)return null;Br||(Br=new Map);const t=Br.get(e);if(t)return t;const n=new Path2D(e);return Br.size>1024&&Br.clear(),Br.set(e,n),n}function Or(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Lr,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Fr(e,t){const n=Nr(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 zr(e,t,n,o,r,i=e=>e){for(const s of t.parts){const t=Er(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:$r(s.fill,n,o);l&&(e.fillStyle=i(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:$r(s.stroke??"none",n,o);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function Hr(e,t,n,o,r,i=e=>e.x,s=e=>e.y,a=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,y,f)=>{if(r>u||l>y||c>h||d>f)return!0;if(!e.length){let r=e;do{const e=r.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);Ir(a(e),o)>=u&&m>u&&(p=e,m=u),r=r.next}while(r)}return!1}),p?{node:p,distance:m}:null}var Wr=new WeakMap,qr=0,Gr=!1,Yr=null,Vr=null;function Xr(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),o=n.indexOf(",");if(-1===o){const e=n.trim();return e.startsWith("--")?{name:e}:null}const r=n.slice(0,o).trim(),i=n.slice(o+1).trim();return r.startsWith("--")?{name:r,fallback:i||void 0}:null}(t);if(!n)return t;const o=()=>n.fallback?Xr(e,n.fallback):t,r=e.canvas;if(!r)return o();!function(){if(Gr)return;if("undefined"==typeof window||"undefined"==typeof document)return;Gr=!0;const e=()=>{qr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{Yr=window.matchMedia("(prefers-color-scheme: dark)"),Vr=e,"function"==typeof Yr.addEventListener?Yr.addEventListener("change",Vr):"function"==typeof Yr.addListener&&Yr.addListener(Vr)}catch{}}();let i=Wr.get(r);i&&i.version===qr||(i={version:qr,map:new Map},Wr.set(r,i));const s=i.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(n.name).trim()||o()||t;return i.map.set(t,a),a}function Ur(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]}function Kr(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Qr=null;function Zr(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45}=e,a={background:n,stroke:o,lineWidth:r,spacing:i,angle:s},c=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Qr||(Qr=document.createElement("canvas")),Qr.width=e,Qr.height=e,Qr)}(c)}catch{return Kr(a)}const u=l.getContext("2d");if(!u)return Kr(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=r,u.lineCap="square";const d=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-c;2*c>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const e=2*c;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(l,"repeat")}var Jr=require("react/jsx-runtime");function ei(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function ti(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var ni=new Map;function oi(e,t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return(0,Jr.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Jr.jsx)("rect",{width:c,height:c,fill:n}),(0,Jr.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a}),(0,Jr.jsx)("line",{x1:i,y1:0,x2:i,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a})]},t)}function ri(e,t,n="#4e79a7"){if(ei(e)){const n=function(e,t){let n=2166136261;const o=ti(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:oi(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var ii=require("d3-shape");function si(e){switch(e){case"monotoneX":return ii.curveMonotoneX;case"monotoneY":return ii.curveMonotoneY;case"cardinal":return ii.curveCardinal;case"catmullRom":return ii.curveCatmullRom;case"step":return ii.curveStep;case"stepBefore":return ii.curveStepBefore;case"stepAfter":return ii.curveStepAfter;case"basis":return ii.curveBasis;case"natural":return ii.curveNatural;default:return null}}function ai(e,t,n){if(null==t)return n;if(ei(t)){const o=function(e,t){const n=e.background??"transparent",o=e.stroke??"#000",r="transparent"===n||"none"===n?n:Xr(t,n)||n,i=Xr(t,o)||o||"#000",s="undefined"!=typeof window&&window.devicePixelRatio||1,a=`${ti(e)}|${r}|${i}@${s}`,c=ni.get(a);if(void 0!==c)return c;const l=Zr({background:r,stroke:i,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=ei(l)?null:l;return ni.set(a,u),u}(t,e);return o||t.background&&Xr(e,t.background)||n}return"string"!=typeof t?t:Xr(e,t)||n}function ci(e,t){if(null==t)return;const n=ai(e,t,"");return""===n?void 0:n}function li(e,t,n,o,r,i,s){const a=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>a.length)return null;const c=e.createLinearGradient(o,r,i,s);for(const t of a)c.addColorStop(Math.max(0,Math.min(1,t.offset)),ui(e,t,n));return c}function ui(e,t,n){const o=t.color??n,r=Xr(e,o)||o;if(null==t.opacity)return r;const i=Math.max(0,Math.min(1,t.opacity)),[s,a,c]=Ur(e,r);return`rgba(${s},${a},${c},${i})`}function di(e,t,n,o){t.fill&&(e.fillStyle=ai(e,t.fill,n),void 0!==t.fillOpacity&&(e.globalAlpha=(t.opacity??1)*t.fillOpacity),o())}function hi(e,t,n){t.stroke&&"none"!==t.stroke&&(e.strokeStyle=Xr(e,t.stroke)||t.stroke,e.lineWidth=t.strokeWidth??1,e.globalAlpha=(t.opacity??1)*(t.strokeOpacity??1),n())}var pi=require("d3-shape"),mi=new WeakMap;function yi(e,t){const n=si(t);if(!n)return e;const o=mi.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,s,a,c){if(!r)return r=[a,c],void o.push([a,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*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){r=[n,i],o.push([n,i])}};return(0,pi.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),o}(e,n);return mi.set(e,r),r}function fi(e,t,n,o=30,r,i=0){let s=null;if(r){const e=Hr(r,t,n,o,i);e&&(s={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=bi(i,t,n,o);break;case"symbol":e=vi(i,t,n,o);break;case"glyph":e=xi(i,t,n,o);break;case"line":e=wi(i,t,n,o);break;case"rect":if(null==i.datum)break;e=Si(i,t,n);break;case"heatcell":e=Ai(i,t,n);break;case"area":if(!1===i.interactive)break;e=Mi(i,t,n);break;case"candlestick":e=Ci(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function gi(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=ji(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[s,a]=e[r],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function bi(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Ir(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function vi(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Ir(yo(e.size),o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function xi(e,t,n,o=30){if(null==e.datum)return null;const r=Fr(e.glyph,e.size),i=e.x+r.centerDx,s=e.y+r.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Ir(r.radius,o)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function wi(e,t,n,o=30){if(0===e.path.length)return null;const r=ji(e.path,t);if(0>r)return null;const[i,s]=e.path[r];let a;if(e.path.length>1){let o=1/0;const i=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=i;s>=r;r++){const[i,s]=e.path[r],[a,c]=e.path[r+1],l=ki(t,n,i,s,a,c);o>l&&(o=l)}a=o}else{const e=t-i,o=n-s;a=Math.sqrt(e*e+o*o)}const c=e.style;return a>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:s,distance:a}}function ki(e,t,n,o,r,i){const s=r-n,a=i-o,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*s+(t-o)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(o+l*a))**2)}function Si(e,t,n){const o=Pr(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function Ai(e,t,n){const o=Pr(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function Ci(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,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function Mi(e,t,n){if(0===e.topPath.length)return null;const o=ji(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:c}}function ji(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}var Pi=require("react"),Ii={fresh:1,aging:.7,stale:.45,expired:.25},Ri={alpha:1,band:"fresh",isStale:!1};function Ti(e,t){if(!e||0>=t)return Ri;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=Bn(t,n,e.thresholds);return{alpha:{...Ii,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ri}function _i(e,t,n,o,r,i){const s=(0,Pi.useRef)("fresh");(0,Pi.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Ti(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&i(l.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,i,n])}var Li=require("react/jsx-runtime");function Di({isStale:e,position:t}){return(0,Li.jsx)("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"})}var Ni=require("react"),$i=d(require("react"));function Bi(...e){let t;for(const n of e)n&&(t=Ei(t)&&Ei(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}function Ei(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Oi(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Fi=16,zi=6,Hi=10,Wi=22,qi=100,Gi=10;function Yi(e){return Math.ceil(7*e.length)}function Vi(e,t){if(Ei(e)){const n=os(t),o=e.legendGroups.flatMap(e=>[e.label?Yi(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+Yi(e.label))]);return Math.max(qi,...o)}if(Oi(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),o=Math.max(Yi(n(t.domain[0])),Yi(n(t.domain[1]))),r=t.label?Yi(t.label):0;return Math.max(qi,19+o,r)}return qi}function Xi(e){return(Ei(e)||Oi(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):Gi}function Ui(e){return Math.max(0,e?.sideGutter??0)}var Ki=22,Qi=46,Zi=64;function Ji(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?Zi:Qi:Ki:0}function es(e){return{hasAxis:!1!==e.showAxes,hasAxisLabel:!!e.xLabel}}function ts(e){const t=e.projection??"vertical";return{hasAxis:!1!==e.showAxes&&"radial"!==t,hasAxisLabel:"horizontal"===t?e.hasValueLabel:e.hasCategoryLabel}}function ns(e,t,n){if(Oi(e))return e.gradient.label?34:26;if(!Ei(e))return 20;const o=os(n),r=Math.max(1,n?.maxWidth??t);let i=o.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=o.swatchSize+o.labelGap+Yi(i.label),s=0===n?t:n+o.itemGap+t;n>0&&s>r?(e+=1,n=t):n=s}t.items.length>0&&(e+=1),i=Math.max(i,e*o.rowHeight,t.label?Yi(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function os(e){const t=Math.max(1,e?.swatchSize??Fi),n=Math.max(t,e?.rowHeight??Wi);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??zi),itemGap:Math.max(0,e?.itemGap??Hi),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}var rs=require("react/jsx-runtime"),is={fill:(e,t)=>(0,rs.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,rs.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function ss(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,is[n])(o(e,t),r),i}function as({swatchSize:e}){return(0,rs.jsx)("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 cs(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var ls=(e,t,n,o,r,i,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:p}=e,m=[];let y=0;const f=!(!t&&!n),g="isolate"===l||void 0===l&&null!=r,{swatchSize:b,labelGap:v,rowHeight:x}=u;return p.forEach((e,l)=>{const u=ss(e,l,d,h,b),w=cs(e,o,r),k=r&&r.size>0&&r.has(e.label);m.push((0,rs.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:f?a===i&&l===s?0:-1:void 0,role:f?"option":void 0,"aria-selected":f&&g?k||!1:void 0,"aria-current":f&&!g&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:f?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(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:f?t=>{c(a,l),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:f?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:f?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[f&&(0,rs.jsx)("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&&(0,rs.jsx)(as,{swatchSize:b}),(0,rs.jsx)("text",{y:b/2,x:b+v,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),y+=x}),m},us=({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{const d=[],h=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:o})=>{n+=5;const r=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=o*t+8,{lineY:r,labelY:i,itemsY:s,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,p)=>{const m=h[p];d.push((0,rs.jsx)("line",{stroke:"gray",x1:0,y1:m.lineY,x2:t,y2:m.lineY},"legend-top-line legend-symbol-"+p)),e.label&&null!=m.labelY&&d.push((0,rs.jsx)("text",{y:m.labelY,className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+p)),d.push((0,rs.jsx)("g",{className:"legend-item",transform:`translate(0,${m.itemsY})`,children:ls(e,n,o,r,i,s,a,p,c,l,u)},"legend-group-"+p))}),d},ds=({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,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 y=((e,t,n,o,r,i,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:p,items:m}=e,y=[],{swatchSize:f,labelGap:g,itemGap:b,rowHeight:v,align:x}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=m.map(e=>f+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=ss(e,d,h,p,f),A=cs(e,o,r),C=r&&r.size>0&&r.has(e.label);y.push((0,rs.jsxs)("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?a===i&&d===s?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(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,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&&(0,rs.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:f+g+2+7*e.label.length,height:f+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,C&&(0,rs.jsx)(as,{swatchSize:f}),(0,rs.jsx)("text",{y:f/2,x:f+g,dominantBaseline:"central",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const j=Math.max(0,...A.map(e=>e.width)),P=A.length;return{items:y,offset:j,totalRows:P,totalHeight:P*v}})(e,o,r,i,s,a,c,t,l,u,d,d.maxWidth??n);m+=y.offset+5,p.push({label:e.label,...y,offset:m,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=m+12});const m=d.maxWidth??n;let y=h>m?0:"center"===d.align?Math.max(0,(m-h)/2):"end"===d.align?Math.max(0,m-h):0;const f=[];return p.forEach((n,o)=>{const r=e[o];r.label&&(f.push((0,rs.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),y+=16),f.push((0,rs.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+o)),y+=n.offset+5,e[o+1]&&f.push((0,rs.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),(0,rs.jsx)("g",{children:f})};function hs({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+$i.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,rs.jsx)("stop",{offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))},e))}return(0,rs.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,rs.jsx)("defs",{children:(0,rs.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&(0,rs.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,rs.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,rs.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,rs.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,rs.jsx)("stop",{offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))},e))}return(0,rs.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,rs.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,rs.jsx)("defs",{children:(0,rs.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,rs.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,rs.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,rs.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function ps(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=os(d),[p,m]=$i.useState(0),[y,f]=$i.useState(0),g=$i.useCallback((e,t)=>{m(e),f(t)},[]),b="vertical"===u?us({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:g,legendInteraction:s,metrics:h}):ds({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:p,focusedItemIndex:y,onFocusedIndexChange:g,legendInteraction:s,metrics:h}),v=!(!n&&!o);return(0,rs.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,rs.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),b]})}var ms=require("react/jsx-runtime");function ys(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",legendLayout:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,p=Math.max(0,n-r.left-r.right),m=Math.max(1,h?s?.maxWidth??p:Vi(t,s)),y=Xi(t),f=Ui(s),g=Ji(e.axisChrome,s),b=Ji(void 0,s),v=ns(t,p,s);let x,w;if("left"===i)x=r.left-f-m-y,w=r.top;else if("top"===i)x=r.left,w=r.top-b-y-v;else if("bottom"===i){x=r.left;const e=o-r.bottom;w=Math.max(e+y,Math.min(e+g+y,o-v))}else x=n-r.right+f+y,w=r.top;return(0,ms.jsx)("g",{transform:`translate(${x}, ${w})`,children:Oi(t)?(0,ms.jsx)(hs,{config:t.gradient,orientation:h?"horizontal":"vertical",width:m}):Ei(t)?(0,ms.jsx)(ps,{legendGroups:t.legendGroups,title:"",width:m,orientation:h?"horizontal":"vertical",legendLayout:s,customHoverBehavior:a,customClickBehavior:c,highlightedCategory:l,isolatedCategories:u,legendInteraction:d}):t})}var fs=require("react"),gs=require("d3-array");T();var bs=require("react/jsx-runtime");function vs(e){return"string"==typeof e?{type:e}:e}function xs({orient:e,config:t,values:n,scale:o,size:r,length:i}){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}}(t),a="top"===e||"bottom"===e,c=(0,fs.useMemo)(()=>{if(0===n.length)return null;const t=o.domain(),c=r-8;if("boxplot"===s.type){const t=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)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:r,median:i,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),p=(c-h)/2+4;if(a){const t=o(r),n=o(l),a=o(i),c=o(u),m=o(d),y="top"===e?-1:1,f=0;return(0,bs.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,bs.jsx)("line",{x1:c,y1:f+y*(p+h/2),x2:m,y2:f+y*(p+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:c,y1:f+y*p,x2:c,y2:f+y*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:m,y1:f+y*p,x2:m,y2:f+y*(p+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("rect",{x:Math.min(t,n),y:"top"===e?f-p-h:f+p,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:a,y1:"top"===e?f-p-h:f+p,x2:a,y2:"top"===e?f-p:f+p+h,stroke:s.fill,strokeWidth:2})]})}{const t=o(r),n=o(l),a=o(i),c=o(u),m=o(d),y="left"===e?-1:1,f=0;return(0,bs.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,bs.jsx)("line",{x1:f+y*(p+h/2),y1:c,x2:f+y*(p+h/2),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:f+y*p,y1:c,x2:f+y*(p+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:f+y*p,y1:m,x2:f+y*(p+h),y2:m,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,bs.jsx)("rect",{x:"left"===e?f-p-h:f+p,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,bs.jsx)("line",{x1:"left"===e?f-p-h:f+p,y1:a,x2:"left"===e?f-p:f+p+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,gs.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=I(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,bs.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,bs.jsx)("rect",{x:i,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,bs.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(i,i+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const i=r.length/u*(c/2),s=o((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let r=l.length-1;r>=0;r--){const i=l[r];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),d=o((i.x0+i.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,bs.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,bs.jsx)("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 t=[];if(a){const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${i}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return(0,bs.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,bs.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,o,s,r,i,e,a,4]);return c?(0,bs.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var ws=d(require("react")),ks=require("react/jsx-runtime");function Ss(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function As(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 Cs(e,t,n,o){if(!e)return(0,ks.jsx)("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!i)return(0,ks.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;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]:Ss(i,c):[],y=r?l?[r]:Ss(r,c):[],f="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((0,ks.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?f-c:"middle"===h?f-c/2:f,y:-16,width:c,height:Math.max(p,(m.length+y.length)*p+(i&&r?2:0))+p,style:{overflow:"visible"},children:(0,ks.jsxs)("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&&(0,ks.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),r&&(0,ks.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(m.length>0&&(b.push((0,ks.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:m.map((e,t)=>(0,ks.jsx)("tspan",{x:f,dy:0===t?0:p,children:e},t))},"annotation-note-title")),g=m.length*p),y.length>0&&b.push((0,ks.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:g,children:y.map((e,t)=>(0,ks.jsx)("tspan",{x:f,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=(0,ks.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(m.length+y.length)*p+(y.length>0?p:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=(0,ks.jsx)("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+y.length-1)*p;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+p+(y.length>0&&m.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,ks.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,ks.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:b}),x]})}function Ms(e,t,n,o,r){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,ks.jsx)("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((0,ks.jsx)("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,s=r||0;if(void 0!==t?.x){const o=(t.x||0)-e;i.push((0,ks.jsx)("line",{x1:o,y1:(t.y1||0)-s,x2:o,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const o=(t.y||0)-s;i.push((0,ks.jsx)("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((0,ks.jsx)("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((0,ks.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,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((0,ks.jsx)("path",{d:As(e,o,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,ks.jsx)("g",{className:"annotation-subject",children:i})}function js(e,t,n,o,r,i){const s=[];let a=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,s=e-r,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=i+l*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=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);a=Math.cos(o)*n,c=Math.sin(o)*n}}const l=Math.sqrt((e-a)**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-a);if(i){const o=(a+e)/2,i=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,p=(n?.curve??.25)*l,m=o+d*p,y=i+h*p;s.push((0,ks.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${m},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,m-a)}else s.push((0,ks.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,ks.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,ks.jsx)("g",{className:"annotation-connector",children:s})}function Ps(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:p,opacity:m,strokeDasharray:y,events:f={},"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!=s&&(k=s-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(0,ks.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":g,...null!=m&&{opacity:m},...y&&{strokeDasharray:y},...f,children:[!x.has("connector")&&js(w,k,c,d,S,l),!x.has("subject")&&Ms(S,l,d,b,v),!x.has("note")&&Cs(a,w,k,d)]})}function Is(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 s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return(0,ks.jsx)(Ps,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+i)});return(0,ks.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,ks.jsx)(Ps,{"data-testid":"semiotic-annotation",events:r,...t,type:o},s)}var Rs=require("d3-hierarchy"),Ts=require("d3-shape");function _s(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 Ls(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 Ds(e){return null==e?null:e+""}function Ns(e,t,n){return t.stickyPositionCache?.set(e,n),n}function $s(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 Ns(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"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}(n);return o?Ns(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Ds(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Ds(e.pointId)===o);if(r)return Ns(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Ds(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const s=_s(i,n),a=Ls(i,n);return null==s||null==a?null:Ns(t,n,{x:s,y:a})}(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=_s(e,n),i=Ls(e,n)),null!=r&&null!=i)return Ns(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Bs(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}B();var Es=require("react/jsx-runtime"),Os={secondary:0,primary:3},Fs=".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 zs(e){return!0===e?._annotationDeferred}function Hs(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Ws(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function qs(e){return Math.max(.72,.95-.06*e)}T();var Gs=d(require("react")),[Ys,Vs]=jt(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 Xs(e){const t=Vs(e=>e.pushObservation),n=Gs.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Gs.useMemo(()=>({...e,onObservation:n}),[n,e])}function Us(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}function Ks(e,t={}){const n=Us(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 Qs(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}var Zs=require("react/jsx-runtime"),Js="var(--semiotic-bg, #ffffff)";function ea(e){const{x:t,y:n,text:o,fill:r,fontSize:i=12,fontWeight:s,fontFamily:a,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=>(0,Zs.jsx)("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:r,fontSize:i,fontWeight:s,fontFamily:a,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??Js,strokeWidth:h.haloWidth??3});const m=h.padding??{x:6,y:3},y="number"==typeof m?m:m.x,f="number"==typeof m?m:m.y,g=function(e,t){return(e+"").length*t*.6}(o,i),b=i+2*f;let v,x;return v="middle"===c?t-g/2-y:"end"===c?t-g-y:t-y,x="middle"===l||"central"===l?n-b/2:"hanging"===l||"text-before-edge"===l?n-f:n-.8*i-f,(0,Zs.jsxs)("g",{className:d,children:[(0,Zs.jsx)("rect",{x:v,y:x,width:g+2*y,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Js,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),p()]})}var ta=require("react/jsx-runtime"),na={linear:Ts.curveLinear,monotoneX:Ts.curveMonotoneX,monotoneY:Ts.curveMonotoneY,step:Ts.curveStep,stepAfter:Ts.curveStepAfter,stepBefore:Ts.curveStepBefore,basis:Ts.curveBasis,cardinal:Ts.curveCardinal,catmullRom:Ts.curveCatmullRom};function oa(e,t,n,o){const r=[];return e.forEach((e,i)=>{let s;if(n){const r=n(e,i,o);s=null!=r?r:t(e,i,o)}else s=t(e,i,o);s&&r.push({node:s,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:Ws(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),o=e.some(e=>zs(e.annotation)),r=e.some(e=>null!=Hs(e.annotation)),i=e.some(e=>"layer"===Hs(e.annotation));if(!n&&!o&&!r)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Os[e.emphasis]);const a=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=zs(t.annotation);let s=t.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;s=(0,Es.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:qs(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=Hs(t.annotation);return a&&(s=(0,Es.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,Es.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return o&&a.unshift((0,Es.jsx)("style",{children:Fs},"annotation-disclosure-style")),i&&a.unshift((0,Es.jsx)("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")),a}(r)}function ra(e,t={}){return function(e,n,o){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=$s(e,n,o);if(!t)return null;const{x:r,y:i}=t;if(!Bs(r,i,o))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,ta.jsx)(Is,{noteData:{x:r,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=_s(null!=e.value?{...e,x:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(o.height||0)-4:"center"===i?(o.height||0)/2:16;const a=t>.6*(o.width||0),c=a?t-4:t+4,l=a?"end":"start";return(0,ta.jsxs)("g",{opacity:e.opacity,children:[(0,ta.jsx)("line",{x1:t,y1:0,x2:t,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ta.jsx)(ea,{x:c,y:s,text:e.label,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Ls(null!=e.value?{...e,y:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end");const l=20>(s=t)?Math.min((o.height||0)-4,s+16):s-4;return(0,ta.jsxs)("g",{opacity:e.opacity,children:[(0,ta.jsx)("line",{x1:0,y1:t,x2:o.width||0,y2:t,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ta.jsx)(ea,{x:a,y:l,text:e.label,textAnchor:c,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:_s({...e,type:"point"},o),y:Ls({...e,type:"point"},o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=(0,Rs.packEnclose)(t),i=e.padding||10;return(0,ta.jsxs)("g",{children:[(0,ta.jsx)("circle",{cx:r.x,cy:r.y,r:r.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&&(0,ta.jsx)(ea,{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:_s({...e,type:"point"},o),y:Ls({...e,type:"point"},o)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=P(i),[l,u]=P(s),d=a-r,h=c+r,p=l-r;return(0,ta.jsxs)("g",{children:[(0,ta.jsx)("rect",{x:d,y:p,width:h-d,height:u+r-p,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,ta.jsx)(ea,{x:(d+h)/2,y:p-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=o.data||[],r="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(0,ta.jsx)("g",{children:r.map((t,n)=>{const r=_s(t,o),s=Ls(t,o);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return(0,ta.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=_s(e,o),r=Ls(e,o);return(0,ta.jsx)(Is,{noteData:{x:t??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s="ordinal"===o.frameType,a="horizontal"===o.projection,c=s?r:null,l=s?i:null;let u;const d=[],h=new Map;if(s&&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[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const p=o.scales?.x??o.scales?.time,m=o.scales?.y??o.scales?.value;if(!p||!m)return null;const y=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},f=p,g=m;let b;if(s)if(a){const e=y(g);b=(t,n)=>[f(n),e(t)]}else{const e=y(f);b=(t,n)=>[e(t),g(n)]}else b=(e,t)=>[f(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]),s=Math.max(2,Math.ceil(t*n)),a=[];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(s-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){a.push([t,i[e]]);continue}const y=u*p-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*m-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===v?L(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:_((n*t[3]-t[0]*t[1])/o),i=_(t[1]/n-r*t[0]/n);return{points:e.map(([e])=>[_(e),_(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(0,ta.jsxs)("g",{children:[(0,ta.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ta.jsx)("text",{x:A+4,y:C-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=o.scales?.y??o.scales?.value,s=t?.domain?.(),a=e.y0??s?.[0],c=e.y1??s?.[1],l=null!=a&&t?t(a):0,u=null!=c&&t?t(c):o.height||0,d=ri(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,ta.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,ta.jsx)("defs",{children:d.def}),(0,ta.jsx)("rect",{x:0,y:Math.min(l,u),width:o.width||0,height:Math.abs(u-l),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,ta.jsx)(ea,{x:(o.width||0)-4,y:(r=l,i=u,Math.max(Math.min(r,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=o.scales?.x??o.scales?.time,r=t?.domain?.(),i=e.x0??r?.[0],s=e.x1??r?.[1],a=null!=i&&t?t(i):null,c=null!=s&&t?t(s):null;if(null==a||null==c)return null;const l=ri(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,ta.jsxs)("g",{opacity:e.opacity,children:[l.def&&(0,ta.jsx)("defs",{children:l.def}),(0,ta.jsx)("rect",{x:Math.min(a,c),y:0,width:Math.abs(c-a),height:o.height||0,fill:l.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,ta.jsx)(ea,{x:Math.min(a,c)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=na[o.curve||"linear"]||Ts.curveLinear,h=(0,Ts.area)().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const p=e.fill||"#6366f1";return(0,ta.jsxs)("g",{children:[(0,ta.jsx)("path",{d:h,fill:p,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,ta.jsx)("text",{x:i(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=o.data||[];if(2>t.length)return null;const r=o.yAccessor||"y",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,p=!1!==e.showBand,m=e.fill||"#6366f1",y=e.fillOpacity??.1,f=e.anomalyColor||"#ef4444",g=e.anomalyRadius??6,b=s(c+d*u),v=s(h),x=t.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,ta.jsxs)("g",{children:[p&&(0,ta.jsx)("rect",{x:0,y:Math.min(b,v),width:o.width||0,height:Math.abs(v-b),fill:m,fillOpacity:y}),x.map((e,t)=>{const n=_s(e,o),r=Ls(e,o);return null==n||null==r?null:(0,ta.jsx)("circle",{cx:n,cy:r,r:g,fill:f,fillOpacity:.7,stroke:f,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,ta.jsx)("text",{x:(o.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:m,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=o.data||[];if(3>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=L(c,e.order||2).equation;l=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=D(c);if(!e)return null;l=e}const u=c.length,{se:d,meanX:h,ssX:p}=N(c,l),m=$(e.confidence??.95),y=e.steps??5,f=c[u-1][0],g=(f-c[0][0])/Math.max(u-1,1),b=[];for(let e=1;y>=e;e++)b.push(f+e*g);const v=[];for(const e of b){const t=l(e),n=d*Math.sqrt(1+1/u+(p>0?(e-h)**2/p:0))*m;v.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const x=`M${v.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${v.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,w=v.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),k=`${s(f)},${a(l(f))}`,S=e.strokeColor||"#6366f1";return(0,ta.jsxs)("g",{children:[(0,ta.jsx)("path",{d:x,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,ta.jsx)("polyline",{points:`${k} ${w}`,fill:"none",stroke:S,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&v.length>0&&(0,ta.jsx)("text",{x:s(v[v.length-1].x)+4,y:a(v[v.length-1].yCenter)-4,fill:S,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let r,i;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const t=$s(e,n,o);if(!t)return null;r=t.x,i=t.y}if(!Bs(r,i,o))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??(0,ta.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,ta.jsx)("foreignObject",{x:r+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:(0,ta.jsx)("div",{...Ks(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=$s(e,n,o);if(!t)return null;const{x:r,y:i}=t,s=r+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,ta.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?ws.cloneElement(l,{key:"ann-text-"+n}):(0,ta.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,ta.jsx)("line",{x1:r,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),ws.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=o.scales?.o,s=o.scales?.x,a=o.scales?.y,c=r(i)?i:r(s)?s:r(a)?a: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(0,ta.jsxs)("g",(o.projection?"vertical"===o.projection:c===s)?{children:[(0,ta.jsx)("rect",{x:l,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),p&&(0,ta.jsx)(ea,{x:l+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:p,background:e.labelBackground??"none"})]}:{children:[(0,ta.jsx)("rect",{x:0,y:l,width:o.width||0,height:u,fill:d,fillOpacity:h}),p&&(0,ta.jsx)(ea,{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:p,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var r,i,s}}var ia=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),sa=new Set(["label","callout","callout-circle","callout-rect"]);function aa(e){return"string"==typeof e?.type?e.type:""}function ca(e){return!!e&&"object"==typeof e&&ia.has(aa(e))}function la(e){return sa.has(aa(e))&&!function(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}(e)}var ua=2e4;function da(e){return"primary"===e?.emphasis||!0===e?.defensive}function ha(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:ua))):1/0}function pa(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 ma=32,ya=6,fa=4,ga=8,ba=72;var va={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function xa(e){if(!wa(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 wa(e){return ca(e)}function ka(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 Sa(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function Aa(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ca(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 Ma(e,t,n,o,r,i,s,a){const c=Aa(e,s);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,a);for(const e of n)l+=12*Ca(c,e);for(const e of o)l+=4*Ca(c,e);return l}function ja(e){const{annotations:t,context:n,defaultOffset:o=ma,notePadding:r=ya,markPadding:i=fa,edgePadding:s=ga,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ba,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:m,cohesion:y,audience:f}=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(xa):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&&!y?v.cohesion:y;if(0===k.length||0>=g||0>=b)return k.slice();const j=[],P=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 I=!1;const R=k.map((e,t)=>{if(!wa(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?$s(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=[...ka("string"==typeof e.title?e.title:void 0,t),...ka("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(a&&("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 j.push(Aa(Sa(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=Ma(Sa(i.x,i.y,e.dx,e.dy,u),e,j,P,g,b,r,s);p>t&&(h=e,p=t)}if(!h)return e;const m=Aa(Sa(i.x,i.y,h.dx,h.dy,u),r);j.push(m);const y=Math.hypot(h.dx,h.dy),f=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return I=!0,{...e,dx:h.dx,dy:h.dy,...f?{connector:f}:{}}}),T=I?R:k.slice();let _=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});_=e?t:T}{let e=!1;const t=_.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?va[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});_=e?t:_}const L=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}(f),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ha(g,b,e))*t))},{deferred:o}=function(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??1),i=ha(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,ca(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>da(e.annotation)),l=a.filter(e=>!da(e.annotation)).sort((e,t)=>pa(t.annotation)-pa(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 s)!n||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:i}}({annotations:_,width:g,height:b,...n});for(const e of o)L.add(e)}if(C&&("object"==typeof C&&"number"==typeof C.minWidth?C.minWidth:480)>=g)for(const e of _)wa(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of _)!0===e?.defensive&&L.delete(e);let D;return D=0===L.size?_:A?_.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):_.filter(e=>!L.has(e)),M?function(e,t){let n=!1;const o=e.map(e=>wa(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(D,M):D}function Pa(e,t){const n={...e};return t.provenance&&(n.provenance=t.provenance),t.lifecycle&&(n.lifecycle=t.lifecycle),n}function Ia(){return(new Date).toISOString()}function Ra(e,t={}){const n=e.provenance;return{...e,provenance:{...n,...t,createdAt:t.createdAt??n?.createdAt??Ia()}}}function Ta(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 _a(e){const t=Ta(e?.now);if(null!=t)return t;const n=e?.dataExtent;if(n)if(Array.isArray(n)){const e=Ta(n[n.length-1]);if(null!=e)return e}else if("max"in n){const e=Ta(n.max);if(null!=e)return e}return Date.now()}function La(e,t,n={}){const o=e?.lifecycle?.freshness,r=Ta(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":Bn(t-r,i,n)}function Da(e,t={}){const n=_a(t);return e.map(e=>{const o=La(e,n,t.thresholds);return{...e,lifecycle:{...e.lifecycle,freshness:o}}})}var Na={fresh:null,aging:.55,stale:.35,expired:.2},$a={fresh:null,aging:null,stale:"4 4",expired:"2 4"};function Ba(e,t,n){return e&&n in e?e[n]:t[n]}function Ea(e,t={}){const n=_a(t),o=!0===t.showExpiredAnnotations,r=[];for(const i of e){const e=La(i,n,t.thresholds);if("expired"===e&&!o)continue;const s=Ba(t.opacity,Na,e),a=Ba(t.strokeDasharray,$a,e),c=t.labelSuffix?.[e],l={...i,lifecycle:{...i.lifecycle,freshness:e}};null!=s&&null==l.opacity&&(l.opacity=s),null!=a&&null==l.strokeDasharray&&(l.strokeDasharray=a),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 Oa={proposed:.7,accepted:null,disputed:.7,retracted:.25},Fa={proposed:"3 3",accepted:null,disputed:"2 3",retracted:"2 4"},za={proposed:" (proposed)",accepted:"",disputed:" (?)",retracted:""};function Ha(e,t,n){return e&&n in e?e[n]:t[n]}function Wa(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 qa(e,t={}){const n=[];for(const o of Wa(e,t)){const e=o?.lifecycle?.status;if(!e){n.push(o);continue}const r=Ha(t.opacity,Oa,e),i=Ha(t.strokeDasharray,Fa,e),s=t.labelSuffix?.[e]??za[e],a={...o};null!=r&&(a.opacity=("number"==typeof a.opacity?a.opacity:1)*r),null!=i&&null==a.strokeDasharray&&(a.strokeDasharray=i),s&&"string"==typeof a.label&&(a.label=a.label+s),n.push(a)}return n}var Ga=require("react"),Ya={positions:new Map},Va=new Set;function Xa(){for(const e of Va)e()}function Ua(e,t){const n=Ya.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Ya.positions);o.delete(e),Ya={positions:o},Xa()}function Ka(e,t){const n=Ya.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const o=new Map(Ya.positions);o.delete(e),Ya={positions:o},Xa()}function Qa(){return Ya}function Za(e){return Va.add(e),()=>Va.delete(e)}var Ja={positions:new Map};function ec(){return()=>{}}function tc(){return Ja}function nc(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,s=o instanceof Date?o.getTime():o,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function oc(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function rc(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function ic(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 sc(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function ac(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 s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}var cc=require("react/jsx-runtime");function lc(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,p=(0,Ni.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=c?.find(e=>"top"===e.orient),o=e??n,r=o?.extent??h,i=o?.tickFormat||u||uc,a=Math.max(2,Math.floor(t/70)),l=o?.ticks??5,d="exact"===r?Math.max(2,l):Math.min(l,a),p=o?.tickValues??nc(s.x,d,r),m=p.map(e=>e.valueOf()),y=p.map((e,t)=>({value:e,pixel:s.x(e),label:i(e,t,m)})),f=y.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 dc(y,Math.max(55,f+8))},[s,c,u,t,h]),m=(0,Ni.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.extent??h,o=e?.tickFormat||d||uc,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,a="exact"===t?Math.max(2,i):Math.min(i,r);return dc((e?.tickValues??nc(s.y,a,t)).map(e=>({value:e,pixel:s.y(e),label:o(e)})),22)},[s,c,d,n,h]),y=l&&s,f=a&&s;if(!y&&!f)return null;const g=c?.find(e=>"bottom"===e.orient),b=c?.find(e=>"left"===e.orient),v=f&&(!g||!1!==g.baseline),x=f&&(!b||!1!==b.baseline),w=g?.jaggedBase||!1,k=b?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,cc.jsx)("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,cc.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(()=>{const e=sc(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=sc(c?.find(e=>"left"===e.orient)?.gridStyle),r=!1!==c?.find(e=>"bottom"===e.orient)?.grid,i=!1!==c?.find(e=>"left"===e.orient)?.grid;return(0,cc.jsxs)("g",{className:"stream-grid",children:[r&&p.map((t,o)=>(0,cc.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),i&&m.map((e,n)=>(0,cc.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),v&&!w&&(0,cc.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,cc.jsx)("path",{d:ac("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),x&&!k&&(0,cc.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,cc.jsx)("path",{d:ac("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function uc(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function dc(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 hc(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:p,axisExtent:m,showGrid:y,title:f,legend:g,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:C,xValues:M,yValues:j,annotations:P,onAnnotationActivate:I,onObservation:R,chartId:T,chartType:_,autoPlaceAnnotations:L,svgAnnotationRules:D,xAccessor:N,yAccessor:$,annotationData:B,pointNodes:E,curve:O,underlayRendered:F,canvasObscuresUnderlay:z=!0,linkedCrosshairName:H,linkedCrosshairSourceId:W,children:q}=e,G=Xs({onAnnotationActivate:I,onObservation:R,chartId:T,chartType:_}),Y=Ui(S),V=g&&"left"===k&&Y>0?Y:i.left,X=g&&"right"===k&&Y>0?Y:i.right,U=(0,Ni.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=c?.find(e=>"top"===e.orient),o=e??n,r=o?.extent??m,i=o?.tickFormat||h||uc,l=Math.max(2,Math.floor(t/70)),u=o?.ticks??5,d="exact"===r?Math.max(2,u):Math.min(u,l),p=o?.tickValues??nc(s.x,d,r),y=p.map(e=>e.valueOf()),f=p.map((e,t)=>({value:e,pixel:s.x(e),label:i(e,t,y)})),g=f.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),b=o?.autoRotate?Math.max(20,Math.min(g+8,55)):Math.max(55,g+8);let v=dc(f,b);if(v.length>1&&(v=v.filter((e,t)=>0===t||e.label+""!=v[t-1].label+"")),o?.includeMax&&v.length>0&&"exact"!==r&&!o?.tickValues){const e=s.x.domain()[1],t=s.x(e),n=v[v.length-1].pixel;if(Math.abs(t-n)>1){const o=i(e,v.length,y);b>t-n&&v.length>1&&(v=v.slice(0,-1)),v.push({value:e,pixel:t,label:o})}}return v},[a,s,c,h,t,m]),K=(0,Ni.useMemo)(()=>{const e=c?.find(e=>"bottom"===e.orient);if(!e?.autoRotate||1>=U.length)return!1;const n=t/Math.max(U.length-1,1);return U.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>n},[c,U,t]),Q=(0,Ni.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.extent??m,o=e?.tickFormat||p||uc,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,l="exact"===t?Math.max(2,i):Math.min(i,r);let u=dc((e?.tickValues??nc(s.y,l,t)).map(e=>({value:e,pixel:s.y(e),label:o(e)})),22);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),e?.includeMax&&u.length>0&&"exact"!==t&&!e?.tickValues){const e=s.y.domain()[1],t=s.y(e),n=u[u.length-1].pixel;if(Math.abs(t-n)>1){const r=o(e);22>Math.abs(t-n)&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[a,s,c,p,n,m]),Z=(0,Ni.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.extent??m,o=e.tickFormat||p||uc,r=Math.max(2,Math.floor(n/30)),i=e.ticks??5;return dc((e.tickValues??nc(s.y,"exact"===t?Math.max(2,i):Math.min(i,r),t)).map(e=>({value:e,pixel:s.y(e),label:o(e)})),22)},[a,s,c,p,n,m]),J=(0,Ni.useRef)(new Map),ee=(0,Ni.useRef)(P?.length??0),te=P?.length??0;ee.current!==te&&(ee.current=te,J.current=new Map);const ne=(0,Ni.useMemo)(()=>{if(!P||0===P.length)return null;const e=Wa(P),o=ra(0,G),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:N,yAccessor:$,width:t,height:n,data:B,frameType:"xy",pointNodes:E,curve:O,stickyPositionCache:J.current};return oa(L?ja({annotations:e,context:r,..."object"==typeof L?L:{}}):e,o,D,r)},[P,L,D,t,n,N,$,B,s,E,O,G]),oe=function(e){const t=(0,Ga.useSyncExternalStore)(e?Za:ec,e?Qa:tc,e?Qa:tc);return e?t.positions.get(e)??null:null}(H);return(0,Ni.useEffect)(()=>{if(!oe?.locked||!H)return;const e=e=>{"Escape"===e.key&&Ka(H)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[oe?.locked,H]),a||f||g||A||C||ne&&ne.length>0||y||q||oe?(0,cc.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,cc.jsx)("title",{children:"string"==typeof f?f:"XY Chart"}),(0,cc.jsx)("desc",{children:"string"==typeof f?f+" (XY data visualization)":"XY data visualization"}),(0,cc.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&s&&(!F||z)&&(()=>{const e=sc(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=sc(c?.find(e=>"left"===e.orient)?.gridStyle),r=!1!==c?.find(e=>"bottom"===e.orient)?.grid,i=!1!==c?.find(e=>"left"===e.orient)?.grid;return(0,cc.jsxs)("g",{className:"stream-grid",children:[r&&U.map((t,o)=>(0,cc.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),i&&Q.map((e,n)=>(0,cc.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),o=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=!o||!1!==o.baseline,s=e?.jaggedBase||!1,a=o?.jaggedBase||!1,h=o?.landmarkTicks,p=e?.landmarkTicks,m="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",f="var(--semiotic-text, #333)",g=K,b={fontSize:"var(--semiotic-tick-font-size, 12px)"},v={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},x={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},w=o?.tickAnchor,k=e?.tickAnchor,S=ic(U),A=ic(Q);return(0,cc.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,cc.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!F||z)&&i&&!a&&(0,cc.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:m,strokeWidth:1}),(!F||z)&&a&&(0,cc.jsx)("path",{d:ac("bottom",t,n),fill:"none",stroke:m,strokeWidth:1}),U.map((e,t)=>{const o=!!h&&("function"==typeof h?h(e.value,t):Tr(e.value,t>0?U[t-1].value:void 0));return(0,cc.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,cc.jsx)("line",{y2:5,stroke:m,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,cc.jsx)("text",{y:g?12:18,textAnchor:g?"end":oc(w,e.pixel===S.min,e.pixel===S.max),fontWeight:o?600:400,fill:y,fontSize:o?13:12,className:"semiotic-axis-tick",style:{userSelect:"none",...o?v:b},transform:g?"rotate(-45)":void 0,children:e.label}):(0,cc.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,cc.jsx)("div",{style:{textAlign:"center",userSelect:"none",...b},children:e.label})})]},"xtick-"+t)}),l&&(0,cc.jsx)("text",{x:t/2,y:n+(g?58:40),textAnchor:"middle",fill:f,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...x},children:l})]}),(0,cc.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||z)&&r&&!s&&(0,cc.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:m,strokeWidth:1}),(!F||z)&&s&&(0,cc.jsx)("path",{d:ac("left",t,n),fill:"none",stroke:m,strokeWidth:1}),Q.map((e,t)=>{const n=!!p&&("function"==typeof p?p(e.value,t):Tr(e.value,t>0?Q[t-1].value:void 0));return(0,cc.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,cc.jsx)("line",{x2:-5,stroke:m,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,cc.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:rc(k,e.pixel===A.min,e.pixel===A.max),fontWeight:n?600:400,fill:y,fontSize:n?13:12,className:"semiotic-axis-tick",style:{userSelect:"none",...n?v:b},children:e.label}):(0,cc.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,cc.jsx)("div",{style:{textAlign:"right",userSelect:"none",...b},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,cc.jsx)("text",{x:15-V,y:n/2,textAnchor:"middle",fill:f,transform:`rotate(-90, ${15-V}, ${n/2})`,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...x},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===Z.length)return null;const o=!1!==e.baseline,r=e.landmarkTicks,i=e.label||d,s=e.tickAnchor,a=ic(Z);return(0,cc.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&(0,cc.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:m,strokeWidth:1}),Z.map((e,n)=>{const o=!!r&&("function"==typeof r?r(e.value,n):Tr(e.value,n>0?Z[n-1].value:void 0));return(0,cc.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,cc.jsx)("line",{x2:5,stroke:m,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,cc.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:rc(s,e.pixel===a.min,e.pixel===a.max),fontWeight:o?600:400,fill:y,fontSize:o?13:12,className:"semiotic-axis-tick",style:{userSelect:"none",...o?v:b},children:e.label}):(0,cc.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,cc.jsx)("div",{style:{textAlign:"left",userSelect:"none",...b},children:e.label})})]},"ytick-r-"+n)}),i&&(0,cc.jsx)("text",{x:t+X-15,y:n/2,textAnchor:"middle",fill:f,transform:`rotate(90, ${t+X-15}, ${n/2})`,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...x},children:i})]})})()]})})(),ne,C&&s&&M&&j&&(0,cc.jsxs)(cc.Fragment,{children:[C.top&&(0,cc.jsx)("g",{transform:"translate(0, 0)",children:(0,cc.jsx)(xs,{orient:"top",config:vs(C.top),values:M,scale:s.x,size:i.top,length:t})}),C.bottom&&(0,cc.jsx)("g",{transform:`translate(0, ${n})`,children:(0,cc.jsx)(xs,{orient:"bottom",config:vs(C.bottom),values:M,scale:s.x,size:i.bottom,length:t})}),C.left&&(0,cc.jsx)("g",{transform:"translate(0, 0)",children:(0,cc.jsx)(xs,{orient:"left",config:vs(C.left),values:j,scale:s.y,size:i.left,length:n})}),C.right&&(0,cc.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,cc.jsx)(xs,{orient:"right",config:vs(C.right),values:j,scale:s.y,size:i.right,length:n})})]}),A,oe&&oe.sourceId!==W&&s?.x&&(()=>{const e=s.x(oe.xValue);if(null==e||0>e||e>t)return null;const o=oe.locked;return(0,cc.jsx)("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"})})(),q]}),f&&"string"==typeof f?(0,cc.jsx)("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:f}):f?(0,cc.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:f}):null,ys({legend:g,totalWidth:o,totalHeight:r,margin:i,legendPosition:k,title:f,legendLayout:S,axisChrome:{hasAxis:!!a,hasAxisLabel:!!l,rotatedTicks:K},legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:x,legendIsolatedCategories:w})]}):null}var pc=d(require("react")),mc=require("d3-shape");function yc(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 fc(e,t,n,o){if(2>e.length||t.length!==e.length||0===n.length)return[];const r=[],i=(e,t,n)=>{const o=r[r.length-1];o?.color===e?o.path.push(n):r.push({color:e,path:[t,n]})};for(let r=1;e.length>r;r++){const[s,a]=e[r-1],[c,l]=e[r],u=t[r-1],d=t[r]-u,h=[0,...0===d?[]:n.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,n)=>0===t||e!==n[t-1]),1];for(let e=1;h.length>e;e++){const t=h[e-1],r=h[e];i(yc(u+d*((t+r)/2),n,o),[s+(c-s)*t,a+(l-a)*t],[s+(c-s)*r,a+(l-a)*r])}}return r}function gc(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function bc(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 vc=require("react/jsx-runtime"),xc={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function wc(e,t="#4e79a7"){return ei(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function kc(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Sc(e,t,n,o){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const i=Nr(r,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=Or(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?kc(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:$r(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:$r(n.stroke??"none",a,e.accent);return r||i?(0,vc.jsx)("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(0,vc.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,vc.jsx)("clipPath",{id:l,children:(0,vc.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,vc.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,vc.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},o)}function Ac(e,t){const n=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>n.length?null:n.map((e,t)=>(0,vc.jsx)("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function Cc(e,t,n){const o=mo(e.symbolType,e.size,e.path);return(0,vc.jsx)("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?wc(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}var Mc=d(require("react")),jc=require("d3-shape"),Pc=require("react/jsx-runtime"),Ic=d(require("react")),Rc=require("react/jsx-runtime"),Tc=d(require("react")),_c=require("d3-shape"),Lc=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function Dc(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=Lc(n,o),t=Lc(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=Lc(n,o),s=Lc(n,r),a=Lc(t,r),c=Lc(t,o),l=r-o>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return Dc({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-o,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return Dc({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const p=o+(d?a:0),m=r-(h?a:0),y=o+(d?c:0),f=r-(h?c:0),g=Lc(n,p),b=Lc(n,m),v=(n-s)*Math.cos(a),x=Lc(v,o),w=Lc(v,r),k=i?null:Lc(t,f),S=i?null:Lc(t,y),A=i?0:(t+s)*Math.cos(c),C=i?null:Lc(A,o),M=i?null:Lc(A,r),j=m-p>Math.PI?1:0,P=i?0:f-y>Math.PI?1:0;let I="";if(d)I+=`M${x.x},${x.y}`,I+=` A${s},${s} 0 0 1 ${g.x},${g.y}`;else{const e=Lc(n,o);I+=`M${e.x},${e.y}`}if(h)I+=` A${n},${n} 0 ${j} 1 ${b.x},${b.y}`,I+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=Lc(n,r);I+=` A${n},${n} 0 ${j} 1 ${e.x},${e.y}`}if(i)I+=" L0,0";else{if(h)I+=` L${M.x},${M.y}`,I+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=Lc(t,r);I+=` L${e.x},${e.y}`}if(d)I+=` A${t},${t} 0 ${P} 0 ${S.x},${S.y}`,I+=` A${s},${s} 0 0 1 ${C.x},${C.y}`;else{const e=Lc(t,o);I+=` A${t},${t} 0 ${P} 0 ${e.x},${e.y}`}}return I+=" Z",I}function Nc(e){const t=Dc({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:Dc({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:o[r]})}return{clipPath:t,slices:n}}var $c=require("react/jsx-runtime");function Bc(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 Ec(e,t){const n=e.datum;if(!n)return null;const o=[],r=n.__funnelStepLabel,i=Number(n.__funnelStepLabelX),s=Number(n.__funnelStepLabelY),a=Number(n.__funnelRowWidth);"string"!=typeof r||!Number.isFinite(i)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*r.length+16>a||o.push((0,$c.jsx)("text",{x:i,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-step"));const c=Number(n.__funnelValue),l=Number(n.__funnelValueLabelX),u=Number(n.__funnelValueLabelY),d=Number(n.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const e=Number(n.__funnelPercent);let r=!0!==n.__funnelIsFirstStep&&Number.isFinite(e)?`${Bc(c)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:Bc(c);7.8*r.length+16>d&&(r=Bc(c)),7.8*r.length+16>d||o.push((0,$c.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-value"))}return o.length?(0,$c.jsx)("g",{children:o},t+"-funnel-labels"):null}var Oc=require("react/jsx-runtime");function Fc(e,t,n,o){if(!e||2>t.length)return null;const r=Ac(e.stops,o);return r?(0,Oc.jsx)("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}function zc(e,t,n){switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r=si(o.curve),i=r?(0,mc.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.path)??"":"M"+o.path.map(([e,t])=>`${e},${t}`).join("L"),s=kc(`${n?n+"-":""}line-${t}-stroke-gradient`),a=Fc(o.strokeGradient,o.path,s,o.style.stroke||"#4e79a7");return(0,Oc.jsxs)(pc.Fragment,{children:[a&&(0,Oc.jsx)("defs",{children:a}),(0,Oc.jsx)("path",{d:i,fill:"none",stroke:a?`url(#${s})`:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})]},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=si(o.curve),i=!r||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,mc.area)().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(r)(o.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,a=ei(o.style.fill)?oi(o.style.fill,s):void 0,c=kc(`${n?n+"-":""}area-${t}-gradient`),l=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=1/0;for(const[,t]of e.topPath)o=Math.min(o,t);let r=-1/0;for(const[,t]of e.bottomPath)r=Math.max(r,t);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const i=Ac(n.stops,wc(e.style.fill));return i?(0,Oc.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:o,x2:0,y2:r,children:i}):null}(o,c),u=l?`url(#${c})`:a?`url(#${s})`:wc(o.style.fill),d=l?void 0:o.style.fillOpacity??o.style.opacity??.7,h=r?(0,mc.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=kc(`${n?n+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),y=!!o.strokeColorBands?.length,f=m||y?null:Fc(o.strokeGradient,o.topPath,p,o.style.stroke||"#4e79a7"),g=o.style.strokeWidth||2;let b=1/0,v=-1/0;for(const[e]of o.topPath)b>e&&(b=e),e>v&&(v=e);const x=y?o.strokeColorBands.map((e,o)=>kc(`${n?n+"-":""}area-${t}-stroke-band-${o}`)):[],w=y?o.strokeColorBands.map((e,t)=>(0,Oc.jsx)("clipPath",{id:x[t],children:(0,Oc.jsx)("rect",{x:b-g,y:e.y,width:v-b+2*g,height:e.height})},x[t])):null,k=o.style.stroke&&"none"!==o.style.stroke?y?o.strokeColorBands.map((e,n)=>(0,Oc.jsx)("path",{d:h,fill:"none",stroke:e.color??wc(o.style.stroke),strokeWidth:g,opacity:o.style.opacity,clipPath:`url(#${x[n]})`},`area-${t}-stroke-band-${n}`)):m?fc(o.topPath,o.rawValues,o.colorThresholds,wc(o.style.stroke)).map((e,n)=>(0,Oc.jsx)("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:g,opacity:o.style.opacity},`area-${t}-threshold-${n}`)):(0,Oc.jsx)("path",{d:h,fill:"none",stroke:f?`url(#${p})`:wc(o.style.stroke),strokeWidth:g,opacity:o.style.opacity}):null;if(o.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,Oc.jsxs)("g",{children:[(0,Oc.jsxs)("defs",{children:[l,!l&&a,f,w,(0,Oc.jsx)("clipPath",{id:e,children:(0,Oc.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,Oc.jsxs)("g",{clipPath:`url(#${e})`,children:[(0,Oc.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]})]},"area-"+t)}return(0,Oc.jsxs)(pc.Fragment,{children:[(l||a||f||w)&&(0,Oc.jsxs)("defs",{children:[l,!l&&a,f,w]}),(0,Oc.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]},"area-"+t)}case"point":{const o=e,r=`${n?n+"-":""}point-${t}-hatch`,i=ei(o.style.fill)?oi(o.style.fill,r):void 0;return(0,Oc.jsxs)(pc.Fragment,{children:[i&&(0,Oc.jsx)("defs",{children:i}),(0,Oc.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#${r})`:wc(o.style.fill),opacity:o.style.opacity??o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+t)}case"symbol":return Cc(e,t);case"glyph":return Sc(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const o=e,r=`${n?n+"-":""}xyrect-${t}-hatch`,i=ei(o.style.fill)?oi(o.style.fill,r):void 0;return(0,Oc.jsxs)(pc.Fragment,{children:[i&&(0,Oc.jsx)("defs",{children:i}),(0,Oc.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#${r})`:wc(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e,o={x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth,...null!=n.style?.opacity&&{opacity:n.style.opacity}};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),[r,i,s]=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*r+.587*i+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,Oc.jsxs)("g",{children:[(0,Oc.jsx)("rect",{...o}),(0,Oc.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+t)}return(0,Oc.jsx)("rect",{...o},"heatcell-"+t)}case"candlestick":{const n=e;if(n.isRange){const e=n.dotRadius??Math.max(2,n.bodyWidth/2);return(0,Oc.jsxs)("g",{children:[(0,Oc.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,Oc.jsx)("circle",{cx:n.x,cy:n.highY,r:e,fill:n.wickColor}),(0,Oc.jsx)("circle",{cx:n.x,cy:n.lowY,r:e,fill:n.wickColor})]},"candle-"+t)}const 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(0,Oc.jsxs)("g",{children:[(0,Oc.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,Oc.jsx)("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 Hc="undefined"==typeof window||"undefined"==typeof document,Wc=require("react"),qc="undefined"!=typeof window?Wc.useLayoutEffect:Wc.useEffect;function Gc(){const[e,t]=(0,Wc.useState)(!1);return qc(()=>{t(!0)},[]),e}var Yc=()=>()=>{},Vc=()=>!1,Xc=()=>!0;function Uc(){const e=(0,Wc.useSyncExternalStore)(Yc,Vc,Xc);return(0,Wc.useRef)(e).current}var Kc=require("react");function Qc(e){const t=(0,Kc.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Jc(e,t);if(!el(e)||!el(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(!Jc(n,r))return!1}else{if(!el(n)||!el(r))return!1;if(!Zc(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function Zc(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 Jc(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 el(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 tl(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:o=""}=e;return"transparent"===t||n?null:t||(o&&"transparent"!==o?o:"")||null}function nl(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:i=0,y:s=0,width:a,height:c}=t,l=tl({background:n,hasBackgroundGraphics:o,themeBackground:r});if(!l)return!1;const u=Xr(e,l);return!!u&&(e.fillStyle=u,e.fillRect(i,s,a,c),!0)}function ol(e){return!!(e.dirtyOrRebuilt||e.transitioning||e.animationTicked||e.continuous||e.liveEncoding||e.forced)}function rl(e,t){return e||t}var il={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 sl(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}var al=d(require("react")),cl=d(require("react")),ll=require("react/jsx-runtime"),ul=cl.createContext(null);function dl({children:e}){const[t,n]=cl.useState(!1),o=cl.useCallback(()=>n(e=>!e),[]),r=cl.useMemo(()=>({visible:t,setVisible:n,toggle:o}),[t,o]);return(0,ll.jsx)(ul.Provider,{value:r,children:e})}function hl(){return cl.useContext(ul)}var pl=require("react/jsx-runtime"),ml={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function yl({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(0,pl.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:ml,children:t})}function fl(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 gl(e){return e&&"object"==typeof e?e:{}}function bl(e){return gl(e.accessibility).tableFields??e.accessibleDatum??e.datum}function vl(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:fl(bl(o))});break;case"line":case"area":{const e=bl(o),n=Array.isArray(e)?e:[],r="line"===o.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:fl(e)});break}case"rect":{const e=bl(o),n=null!=e&&"object"==typeof e?e:{},r=n.category??o.group??"",i=n.value??n.__aggregateValue??n.total,s=fl(n);null==s.category&&""!==r&&(s.category=r+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=fl(bl(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=bl(o),n=fl(e);if(null==n.category){const t=gl(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:fl(bl(o))});break;case"arc":t.push({label:"Arc",values:fl(bl(o))});break;case"candlestick":t.push({label:"Candlestick",values:fl(bl(o))});break;case"geoarea":{const e=gl(bl(o)),n=fl(e);if(null==n.name){const t=gl(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}var xl=require("react/jsx-runtime");function wl(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"],s=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 s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}function kl(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 Sl=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Al="semiotic-accessible-data-table",Cl=Al+" semiotic-accessible-data-table-hidden",Ml=Al+" semiotic-accessible-data-table-visible",jl=Ml+" semiotic-accessible-data-table-network",Pl={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"},Il={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Rl={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)"},Tl={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},_l={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))"},Ll={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Dl={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Nl={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 $l({scene:e,chartType:t,tableId:n,chartTitle:o}){const[r,i]=al.useState(!1),[s,a]=al.useState(5),c=hl(),l=c?.visible??!1,u=r||l,d=al.useRef(null),h=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t;al.useEffect(()=>{u||a(5)},[u]);const p=al.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),m=al.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?(0,xl.jsx)("span",{id:n,tabIndex:-1,style:ml}):null;if(!u)return(0,xl.jsx)("div",{id:n,className:Cl,tabIndex:-1,onFocus:p,style:ml,role:"region","aria-label":h,children:(0,xl.jsxs)("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const y=vl(e),f=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}(y),g=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Sl(e.min)} to ${Sl(e.max)}, mean ${Sl(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(" ")}(y.length,f),b=Math.min(s,y.length),v=y.slice(0,b),x=y.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(0,xl.jsxs)("div",{ref:d,id:n,className:Ml,tabIndex:-1,onBlur:m,style:Pl,role:"region","aria-label":h,children:[(0,xl.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Rl,children:"×"}),(0,xl.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Il,children:g}),(0,xl.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Tl,children:[(0,xl.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Dl,children:x>0?`First ${b} of ${y.length} data points`:`All ${y.length} data points`}),(0,xl.jsx)("thead",{children:(0,xl.jsxs)("tr",{children:[(0,xl.jsx)("th",{style:_l,children:"type"}),k.map(e=>(0,xl.jsx)("th",{style:_l,children:e},e))]})}),(0,xl.jsx)("tbody",{children:v.map((e,t)=>(0,xl.jsxs)("tr",{children:[(0,xl.jsx)("td",{style:Ll,children:e.label}),k.map(t=>{return(0,xl.jsx)("td",{style:Ll,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Sl(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),x>0&&(0,xl.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Nl,children:["Show ",Math.min(25,x)," more"," ",1===x?"row":"rows"," (",x," remaining)"]})]})}function Bl({nodes:e,edges:t,chartType:n,tableId:o,chartTitle:r}){const[i,s]=al.useState(!1),[a,c]=al.useState(5),l=hl(),u=l?.visible??!1,d=i||u,h=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,p=al.useRef(null);al.useEffect(()=>{d||c(5)},[d]);const m=al.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),y=al.useCallback(e=>{u||p.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return o?(0,xl.jsx)("span",{id:o,tabIndex:-1,style:ml}):null;if(!d)return(0,xl.jsx)("div",{id:o,className:Cl,tabIndex:-1,onFocus:m,style:ml,role:"region","aria-label":h,children:(0,xl.jsxs)("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const f=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;f.length>e;e++){const t=f[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,s=x.get(o)??0,a=w.get(o)??0;k.push({id:o,degree:r+i,inDeg:r,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}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: ${Sl(S)}, max degree: ${A}.`);const j=Math.min(a,k.length),P=k.slice(0,j),I=k.length-j;return(0,xl.jsxs)("div",{ref:p,id:o,className:jl,tabIndex:-1,onBlur:y,style:Pl,role:"region","aria-label":h,children:[(0,xl.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Rl,children:"×"}),(0,xl.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Il,children:M.join(" ")}),(0,xl.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Tl,children:[(0,xl.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Dl,children:I>0?`Top ${j} of ${k.length} nodes by degree`:`All ${k.length} nodes by degree`}),(0,xl.jsx)("thead",{children:(0,xl.jsxs)("tr",{children:[(0,xl.jsx)("th",{style:_l,children:"id"}),(0,xl.jsx)("th",{style:_l,children:"degree"}),(0,xl.jsx)("th",{style:_l,children:"in"}),(0,xl.jsx)("th",{style:_l,children:"out"}),C&&(0,xl.jsx)("th",{style:_l,children:"w. degree"}),C&&(0,xl.jsx)("th",{style:_l,children:"w. in"}),C&&(0,xl.jsx)("th",{style:_l,children:"w. out"})]})}),(0,xl.jsx)("tbody",{children:P.map((e,t)=>(0,xl.jsxs)("tr",{children:[(0,xl.jsx)("td",{style:Ll,children:e.id}),(0,xl.jsx)("td",{style:Ll,children:e.degree}),(0,xl.jsx)("td",{style:Ll,children:e.inDeg}),(0,xl.jsx)("td",{style:Ll,children:e.outDeg}),C&&(0,xl.jsx)("td",{style:Ll,children:Sl(e.wDegree)}),C&&(0,xl.jsx)("td",{style:Ll,children:Sl(e.wInDeg)}),C&&(0,xl.jsx)("td",{style:Ll,children:Sl(e.wOutDeg)})]},t))})]}),I>0&&(0,xl.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Nl,children:["Show ",Math.min(25,I)," more"," ",1===I?"node":"nodes"," (",I," remaining)"]})]})}function El({summary:e}){return e?(0,xl.jsx)("div",{role:"note",style:ml,children:e}):null}function Ol({tableId:e}){return(0,xl.jsx)("a",{href:"#"+e,style:ml,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,ml)},children:"Skip to data table"})}var Fl=require("react/jsx-runtime"),zl="var(--semiotic-focus, #005fcc)";function Hl({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,Fl.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:zl,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Fl.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:zl,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:zl,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Fl.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Fl.jsx)("path",{d:a,fill:"none",stroke:zl,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Fl.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Wl=d(require("react"));function ql(e,t){return"touch"===t?Math.max(e,24):e}function Gl(e){return Array.isArray(e)?e[0]:e}function Yl(e,t,n,o){return{data:Gl(e),x:t,y:n,__semioticHoverData:!0,...o}}var Vl=["name","label","title"],Xl=["type","kind","category","group","class","status","role","shape"],Ul=["value","amount","total","count","weight","score"],Kl=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 Ql(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Zl(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&&Kl.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=>Vl.includes(e.lower));const s=i>=0;0>i&&(i=r.findIndex(e=>"id"===e.lower)),0>i&&(i=r.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:r[i];let c=r.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=Ql(c,Xl),u=Ql(c,Ul),d=new Set(Xl),h=new Set(Ul),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:a?.key,title:a?.value,entries:p}}var Jl=require("react/jsx-runtime"),eu={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 tu(e,t){return"function"==typeof t?t(e):e[t]}function nu(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 ou(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=tu(e,n);s=nu(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 s=tu(e,r);a.push({label:n,value:nu(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=nu(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=nu(e[t[0]],o))}}const c={...eu,...r};return(0,Jl.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:c,children:[s&&(0,Jl.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,Jl.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,Jl.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function ru(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const c=[];if(n){const t=tu(e,n);c.push({value:nu(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 a=nu(tu(e,r),i);c.push({label:s?n:void 0,value:a})});else{const t=Zl(e,{skipPositional:!1});null!=t.title&&c.push({label:void 0,value:nu(t.title,o),bold:!0}),t.entries.forEach(e=>{c.push({label:s?e.key:void 0,value:nu(e.value,o)})})}const l={...eu,...r};return Array.isArray(c)&&0!==c.length?(0,Jl.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:l,children:c.map((e,t)=>(0,Jl.jsxs)("div",{style:{marginBottom:c.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,Jl.jsxs)("strong",{children:[e.label,a]}),e.value]},t))}):null}}function iu(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&"mode"in e&&"multi"===e.mode}function su(e){const{tooltip:t,defaultTooltipContent:n,multiDefaultContent:o=au()}=e;return!1===t?{tooltipContent:()=>null}:function(e){return"multi"===e||iu(e)}(t)?{tooltipContent:(iu(t)&&"function"==typeof t.content?cu(t.content):void 0)||o,tooltipMode:"multi"}:{tooltipContent:cu(t)||n}}function au(){return e=>{const t=e.allSeries;if(!t||0===t.length)return(0,Jl.jsx)("div",{className:"semiotic-tooltip",style:eu,children:(0,Jl.jsx)("div",{children:nu(e.data?.value??e.data?.y)})});const n=e.xValue??e.data?.time??e.data?.x;return(0,Jl.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=n&&(0,Jl.jsx)("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:nu(n)}),t.map((e,t)=>(0,Jl.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[(0,Jl.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),(0,Jl.jsx)("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),(0,Jl.jsx)("span",{style:{fontWeight:500,fontSize:"0.85em"},children:nu(e.value)})]},t))]})}}function cu(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{const n=!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);let o=Gl(n?e.data??{}:e);if(!o)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof o?.x0&&"number"==typeof o?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof o?.sankeyWidth)&&o.data&&"object"==typeof o.data&&(o=o.data),!o)return null;if(n&&(void 0!==e.allSeries||void 0!==e.xValue)){const t={...o};void 0!==e.allSeries&&void 0===t.allSeries&&(t.allSeries=e.allSeries),void 0!==e.xValue&&void 0===t.xValue&&(t.xValue=e.xValue),o=t}const r=t(o);return null==r?null:(0,Jl.jsx)("div",{className:"semiotic-tooltip",style:eu,children:r})}}return!1!==e&&void 0!==e&&(iu(e)?"function"==typeof e.content?cu(e.content):("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip={{ mode: "multi" }} reached normalizeTooltip without a chart that wires tooltipMode. Prefer LineChart/AreaChart/StackedAreaChart/DifferenceChart, or pass frameProps.tooltipMode: "multi".'),au()):"object"==typeof e&&null!==e&&("fields"in e||"title"in e)?ou(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),ru()):ou())}}var lu=require("react/jsx-runtime");function uu({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=Wl.useRef(null),[u,d]=Wl.useState(null);Wl.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()},[s,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(!Wl.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:eu;return c?(0,lu.jsx)("div",{ref:l,className:p?s:(s+" semiotic-tooltip").trim(),style:{...m||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var du=d(require("react")),hu=require("react"),pu=require("react");function mu(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 yu(){const[e,t]=(0,pu.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,pu.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),mu(e,e=>t(e.matches))},[]),e}var fu=require("react");function gu(e,t,n){const o=(0,fu.useRef)(null),[r,i]=(0,fu.useState)(null);return(0,fu.useEffect)(()=>{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 bu=()=>"undefined"!=typeof performance?performance.now():Date.now();function vu(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 xu(e,t){const n=e();return Number.isFinite(n)?n:t}var wu=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??bu,this.lastWallTime=xu(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=xu(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??bu;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=xu(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:vu(n)))}},ku="undefined"==typeof window?hu.useEffect:hu.useLayoutEffect,Su={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Au(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Cu(e){const t=yu(),n=(0,hu.useRef)(t);n.current=t;const[o,r]=gu(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,hu.useMemo)(()=>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,s),[e.marginDefault,e.userMargin,i,s]),c=r[0]-a.left-a.right,l=r[1]-a.top-a.bottom,u=Au(e.foregroundGraphics,r,a),d=Au(e.backgroundGraphics,r,a),h=Et(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),y="semiotic-table-"+du.useId(),f=(0,hu.useRef)(null);if(!f.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;f.current=new wu({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const g=f.current;g.configure({clock:e.clock,random:e.random,seed:e.seed});const b=(0,hu.useRef)(null),v=(0,hu.useRef)(e.frameScheduler??Su);v.current=e.frameScheduler??Su;const x=(0,hu.useRef)(null),w=(0,hu.useRef)(!1),k=(0,hu.useRef)(()=>{}),S=(0,hu.useCallback)(()=>{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=(0,hu.useCallback)(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);ku(()=>{g.setPaused(!0===e.paused)},[g,e.paused]),(0,hu.useEffect)(()=>{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]),(0,hu.useEffect)(()=>()=>{A()},[A]);const C=(0,hu.useRef)(()=>{}),M=(0,hu.useRef)(()=>{}),j=(0,hu.useRef)(null),P=(0,hu.useRef)(null),I=(0,hu.useRef)(null),R=(0,hu.useCallback)(()=>{const e=j.current;j.current=null,e&&C.current(e)},[]),T=(0,hu.useCallback)(e=>{if(j.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,I.current=null,R()});t||(P.current=n,I.current=e)}},[R]),_=(0,hu.useCallback)(()=>{j.current=null,null!==P.current&&((I.current??v.current).cancelAnimationFrame(P.current),P.current=null,I.current=null),M.current()},[]);(0,hu.useEffect)(()=>()=>{j.current=null,null!==P.current&&((I.current??v.current).cancelAnimationFrame(P.current),P.current=null,I.current=null)},[]);const L=e.themeDirtyRef;return ku(()=>{L&&(qr++,L.current=!0,S())},[h,S,L]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:o,size:r,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:p,introEnabled:m,tableId:y,frameRuntime:g,rafRef:b,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:C,hoverLeaveRef:M,onPointerMove:T,onPointerLeave:_}}var Mu=require("react");function ju(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=Math.round(t[0]*o),s=Math.round(t[1]*o),a=i/t[0],c=s/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===s||(e.width=i,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}function Pu(e){if("undefined"==typeof window)return 1;const t=window.devicePixelRatio||1,n=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(t,"number"==typeof e&&e>0?e:n))}var Iu=require("react/jsx-runtime");function Ru(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,maxDevicePixelRatio:i,scheduleRender:s}=e,a=(0,Mu.useRef)(null),c=(0,Mu.useRef)(null),l=(0,Mu.useRef)(!1),u=(0,Mu.useRef)(!1),d=(0,Mu.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:i,cancelRender:s,cleanup:a}=e;qc(()=>{const e=o.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():r.current=!0,s?.(),i.current()},[t,n]);const c=(0,Wc.useRef)(a);c.current=a,(0,Wc.useEffect)(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,Mu.useEffect)(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,s()):t()})},[t,n,o,r,s]),(0,Mu.useEffect)(()=>function(){if("undefined"==typeof window||"function"!=typeof window.matchMedia)return()=>{};let e=null,t=!1;const n=()=>{e&&("function"==typeof e.removeEventListener?e.removeEventListener("change",r):"function"==typeof e.removeListener&&e.removeListener(r))},o=()=>{const t=`(resolution: ${window.devicePixelRatio||1}dppx)`;e=window.matchMedia(t),e.media.includes("resolution")?"function"==typeof e.addEventListener?e.addEventListener("change",r):"function"==typeof e.addListener&&e.addListener(r):e=null};function r(){t||(n(),e=null,l.current=!0,s(),queueMicrotask(()=>{t||o()}))}return o(),()=>{t=!0,n(),e=null}}(),[s]),(0,Mu.useEffect)(()=>{d.current?(l.current=!0,s()):d.current=!0},[i,s]),(0,Mu.useEffect)(()=>{!u.current&&(u.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.canvasPaintInvalidator?e.canvasPaintInvalidator():e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:c,resolutionDirtyRef:l}}function Tu(e,t){return Ru({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function _u({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?(0,Iu.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:(0,Iu.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Lu(e,t,n,o){const r=o.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!r)&&e.refreshPulse(t);return o.current=s,{changed:a,pending:s}}function Du(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}var Nu=require("react");function $u(e,t,n,o){const r=(0,Nu.useRef)({accessor:t,onChange:n,readData:o}),i=(0,Nu.useRef)([]);return r.current={accessor:t,onChange:n,readData:o},(0,Nu.useCallback)(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const s=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})(s,i.current)||(i.current=s,n(s))},[e])}function Bu(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 Eu(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 s={...n};return o&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return r?i:o}}var Ou=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Fu=3156e7;function zu(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")}`}:Fu>t?e=>{const t=new Date(e);return`${Ou[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Fu>t?e=>{const t=new Date(e);return`${Ou[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Hu(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:yo(n.size)});else if("glyph"===n.type){const e=Fr(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var Wu=require("d3-shape");function qu(e,t,n,o,r,i){if(2>t.length)return;const s=[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];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;c>o&&(i*=o/c),c>a-o&&(i*=(a-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 Gu=(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=Xr(e,r)||r,s=t.style.strokeWidth||2,a=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=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){qu(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=si(t.curve),u=a&&a.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){const n=fc(t.path,c,a,i);for(const t of n){e.beginPath(),e.strokeStyle=Xr(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?li(e,t.strokeGradient,i,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)(0,Wu.line)().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=ai(e,t.style.fill,t.style.fill),l&&!u)(0,Wu.line)().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 Yu(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Vu(e,t,n=.3){Yu(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 Xu(e,t,n=.6){if(!Yu(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 Uu(e,t,n,o=.35){Yu(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Ku=require("d3-shape");function Qu(e,t){const n=si(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=(0,Ku.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}function Zu(e,t){const n=si(t.curve);if(e.beginPath(),n)(0,Ku.line)().x(e=>e[0]).y(e=>e[1]).curve(n).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])}}var Ju=(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=ai(e,t.style.fill,"#4e79a7"),s=t._decayOpacities,a=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),c=!!t.strokeColorBands?.length;if(s&&s.length===t.topPath.length&&!a&&!c){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(s[o]+s[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=Xr(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*(s[n]+s[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 l=t.style.opacity??1;if(Qu(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&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=li(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,o);e.fillStyle=r||i,e.globalAlpha=l}else e.globalAlpha=(t.style.fillOpacity??.7)*l,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Qu(e,t),Uu(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=l;const n=Xr(e,t.style.stroke)||t.style.stroke,o=a||c||!t.strokeGradient||2>t.topPath.length?null:li(e,t.strokeGradient,n,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),c){let o=1/0,r=-1/0;for(const[e]of t.topPath)o=Math.min(o,e),r=Math.max(r,e);const i=e.lineWidth;for(const s of t.strokeColorBands){e.save(),e.beginPath(),e.rect(o-i,s.y,r-o+2*i,s.height),e.clip();const a=s.color??n;e.strokeStyle=Xr(e,a)||a,Zu(e,t),e.stroke(),e.restore()}}else if(a){const o=fc(t.topPath,t.rawValues,t.colorThresholds,n);for(const t of o){e.beginPath(),e.strokeStyle=Xr(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else e.strokeStyle=o||n,Zu(e,t),e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},ed=(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=ai(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&"none"!==n.style.stroke&&(e.strokeStyle=ai(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),Xu(e,n)}finally{e.restore()}}},td=new Map;function nd(e,t,n,o,r,i){if(0>=t.size)return;const s=function(e,t,n){try{if(n)return new Path2D(n);const o=`${e??"circle"}:${Math.round(t)}`;let r=td.get(o);return r||(r=new Path2D(mo(e,t)),td.size>256&&td.clear(),td.set(o,r)),r}catch{return null}}(t.symbolType,t.size,t.path);if(!s)return;e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation);const a=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=r*a*(t.style.fillOpacity??1),e.fillStyle=ai(e,t.style.fill,i),e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=r*a,e.strokeStyle=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(s)),e.restore()}var od=(e,t)=>{const n=e.globalAlpha;for(const o of t)"symbol"===o.type&&nd(e,o,o.x,o.y,n,"#4e79a7");e.globalAlpha=n};function rd(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=Nr(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=ai(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(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=Or(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&zr(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),zr(e,i,l,t.accent,void 0,c),e.restore()}var id=(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&rd(e,o,o.x,o.y,n);e.globalAlpha=n};function sd(e,t){const{x:n,y:o,w:r,h:i}=t,{tl:s,tr:a,br:c,bl:l}=bc(t);e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),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+s),s>0&&e.arcTo(n,o,n+s,o,s),e.closePath()}function ad(e,t){const n=ai(e,t.style.fill,Xr(e,"var(--semiotic-primary, #007bff)")),o=function(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}}}(t);return(t.fillGradient&&"string"==typeof n?li(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null)||n}function cd(e,t){return!(!t.style.stroke||"none"===t.style.stroke||(e.strokeStyle=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,0))}var ld=(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)ud(e,t);else if(t.cornerRadii&&gc(t.cornerRadii))e.fillStyle=ad(e,t),sd(e,t),e.fill(),cd(e,t)&&e.stroke();else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=ad(e,t);const n=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:o,y:r,w:i,h:s}=t;switch(t.roundedEdge){case"right":e.moveTo(o,r),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o,r+s);break;case"left":e.moveTo(o+i,r),e.lineTo(o+n,r),e.arcTo(o,r,o,r+n,n),e.lineTo(o,r+s-n),e.arcTo(o,r+s,o+n,r+s,n),e.lineTo(o+i,r+s);break;case"bottom":e.moveTo(o,r),e.lineTo(o+i,r),e.lineTo(o+i,r+s-n),e.arcTo(o+i,r+s,o+i-n,r+s,n),e.lineTo(o+n,r+s),e.arcTo(o,r+s,o,r+s-n,n);break;default:e.moveTo(o,r+s),e.lineTo(o,r+n),e.arcTo(o,r,o+n,r,n),e.lineTo(o+i-n,r),e.arcTo(o+i,r,o+i,r+n,n),e.lineTo(o+i,r+s)}e.closePath(),e.fill(),cd(e,t)&&e.stroke()}else e.fillStyle=ad(e,t),e.fillRect(t.x,t.y,t.w,t.h),cd(e,t)&&e.strokeRect(t.x,t.y,t.w,t.h);Vu(e,t),e.globalAlpha=1}};function ud(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,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function dd(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 hd(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var pd=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h);const o=Math.max(0,n?.strokeWidth??1);if(o>0&&(e.strokeStyle=Xr(e,n?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=o,e.strokeRect(t.x,t.y,t.w,t.h)),Vu(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):hd(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=dd(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}},md=(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=Xr(e,t.wickColor)||t.wickColor,s=60>o.height,a=s?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=a,e.stroke()};if(s||c(),t.isRange){const n=t.dotRadius??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=Xr(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))}s&&c(),e.restore()}},yd={line:[Ju,Gu,ed],area:[Ju,ed],stackedarea:[Ju,ed],scatter:[ed,od],bubble:[ed,od],heatmap:[pd],bar:[ld],swarm:[ed],waterfall:[(e,t,n,o)=>{ld(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const i=r[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=Xr(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],i=r[t+1],s=o.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[md],mixed:[Ju,Gu,ed],custom:[Ju,ld,pd,Gu,ed,od,id,md]},fd=new Set;function gd(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 bd(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;fd.has(n)||(fd.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function vd(e){const{context:t,nodes:n,renderMode:o,pixelRatio:r,paintBuiltIn:i}=e;if(!o||"sketchy"===o)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=gd(o,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:r})}finally{t.restore()}c||(bd(n.id,e.type??"unknown"),i([e]))}a()}function xd(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=gd(o,t);if(!i)return r();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(bd(i.id,t.type??"unknown"),r())}function wd(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}var kd=require("react/jsx-runtime");function Sd(e){return"string"==typeof e?e:"value"}function Ad(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Cd(e,t){if(!t)return Ad(e);try{const n=t(e);return null==n?Ad(e):n}catch{return Ad(e)}}function Md(e,t){return"function"==typeof t?t(e):e[t]}function jd(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 Pd(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?Cd(Md(o,t.accessor),t.format):null;return(0,kd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=r&&(0,kd.jsx)("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((e,t)=>{const n=Cd(Md(o,e.accessor),e.format);return(0,kd.jsxs)("div",{style:t>0?{marginTop:2}:void 0,children:[(0,kd.jsxs)("span",{style:{opacity:.7},children:[e.label,": "]}),(0,kd.jsx)("span",{children:n})]},t)})]})}}function Id({categoryAccessor:e,valueAccessor:t,groupAccessor:n,groupLabel:o,pieData:r=!1,valueFormat:i}){return s=>{const a=r?s.data?.[0]||s.data||s:s.data||s,c=Md(a,e),l=Md(a,t),u=n?Md(a,n):void 0;return(0,kd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,kd.jsx)("div",{style:{fontWeight:"bold"},children:Ad(c)}),(0,kd.jsx)("div",{style:{marginTop:4},children:Cd(l,i)}),null!=u&&(0,kd.jsxs)("div",{style:{marginTop:2,opacity:.8},children:[o||Sd(n),": ",Ad(u)]})]})}}var Rd=require("react/jsx-runtime");function Td(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function _d({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=Zl(t);if(null!=e.title||e.entries.length>0)return(0,Rd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=e.title&&(0,Rd.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,Rd.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,Rd.jsx)("span",{style:{fontWeight:600},children:Td(e.value)})]},e.key))]})}return(0,Rd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,Rd.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Td(n)}),(0,Rd.jsx)("div",{style:{opacity:.7,fontSize:11},children:Td(o)})]})}function Ld(e){return"touch"===e?"touch":"pointer"}function Dd(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 Nd(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function $d(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}_d.ownsChrome=!0;var Bd=require("react");function Ed({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){const i=!(!e&&!n),s=!(!t&&!n),a=(0,Bd.useCallback)((t,i)=>{e?.(t,i),Nd({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:i})},[o,r,e,n]),c=(0,Bd.useCallback)((e,i)=>{t?.(e,i),$d({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:i})},[o,r,t,n]);return{customHoverBehavior:i?a:void 0,customClickBehavior:s?c:void 0,hasClickBehavior:s}}var Od=require("react");function Fd(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 zd(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 Hd(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?Wd(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?Wd(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 Wd(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 qd(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=Fr(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 Gd(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=Fr(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 Yd(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Vd(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}function Xd({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=(0,Od.useRef)(-1),u=(0,Od.useRef)(null),d=(0,Od.useRef)(null),h=(0,Od.useCallback)(h=>{if(Dd(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),s()};if(0===p.scene.length)return void(0>l.current||m());let y;if(d.current?.version===p.version)y=d.current.graph;else{const e=a(p.scene);if(0===e.length)return void(0>l.current||m());y=Fd(e),d.current={version:p.version,graph:y}}let f=l.current;if(y.flat.length>f||(m(),f=-1),("Enter"===h.key||" "===h.key)&&f>=0)return h.preventDefault(),void i?.(c(y.flat[f],p),{type:"activate",inputType:"keyboard"});if(0>f){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=y.flat[0];u.current=e;const n=c(e,p);return t.current=n,o(n),r?.(n,{type:"focus",inputType:"keyboard"}),void s()}const g=Hd(h.key,zd(y,f),y);if(null===g)return;if(h.preventDefault(),0>g)return void m();l.current=g;const b=y.flat[g];u.current=b;const v=c(b,p);t.current=v,o(v),r?.(v,{type:"focus",inputType:"keyboard"}),s()},[i,r,a,t,n,s,o,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:h}}function Ud(e){const t=e.datum;return{...t||{},...t?.properties||{},data:t,properties:t?.properties,x:e.x,y:e.y,__semioticHoverData:!0}}var Kd=require("react/jsx-runtime"),Qd={top:20,right:20,bottom:30,left:40},Zd=il;function Jd(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var eh=(0,bt.memo)((0,bt.forwardRef)(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:i,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:p,groupAccessor:m,lineDataAccessor:y,curve:f,normalize:g,baseline:b,stackOrder:v,binSize:x,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:C,xExtent:M,yExtent:j,extentPadding:P=.1,scalePadding:I,sizeRange:R,size:T=[500,300],responsiveWidth:_,responsiveHeight:L,margin:D,className:N,background:$,maxDevicePixelRatio:B,renderMode:E,lineStyle:O,pointStyle:F,areaStyle:z,barStyle:H,waterfallStyle:W,swarmStyle:q,barColors:G,colorScheme:Y,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:Q,lineGradient:Z,semanticLineStops:J,areaGroups:ee,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,showAxes:se=!0,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:de,yFormat:he,axisExtent:pe,tickFormatTime:me,tickFormatValue:ye,hoverAnnotation:fe,tooltipContent:ge,customHoverBehavior:be,customClickBehavior:ve,onObservation:xe,annotationObservationCallback:we,chartId:ke,enableHover:Se,hoverRadius:Ae=30,tooltipMode:Ce,annotations:Me,onAnnotationActivate:je,autoPlaceAnnotations:Pe,svgAnnotationRules:Ie,showGrid:Re,legend:Te,legendHoverBehavior:_e,legendClickBehavior:Le,legendHighlightedCategory:De,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:Be,legendCategoryAccessor:Ee,onCategoriesChange:Oe,backgroundGraphics:Fe,foregroundGraphics:ze,canvasPreRenderers:He,svgPreRenderers:We,title:qe,categoryAccessor:Ge,brush:Ye,onBrush:Ve,decay:Xe,pulse:Ue,transition:Ke,animate:Qe,staleness:Ze,frameScheduler:Je,clock:et,random:tt,seed:nt,paused:ot=!1,suspendWhenHidden:rt=!0,heatmapAggregation:it,heatmapXBins:st,heatmapYBins:at,showValues:ct,heatmapValueFormat:lt,marginalGraphics:ut,pointIdAccessor:dt,xScaleType:ht,yScaleType:pt,accessibleTable:mt=!0,description:yt,summary:vt,linkedCrosshairName:xt,linkedCrosshairSourceId:wt,customLayout:kt,onLayoutError:Ct,layoutConfig:Mt,layoutSelection:jt}=e,{customHoverBehavior:Pt,customClickBehavior:It,hasClickBehavior:Tt}=Ed({customHoverBehavior:be,customClickBehavior:ve,onObservation:xe,chartId:ke,chartType:"StreamXYFrame"}),_t=(0,bt.useId)().replace(/:/g,""),Lt=(0,bt.useRef)(!1),Dt=(0,bt.useRef)({w:-1,h:-1}),Nt=(0,bt.useRef)(!1),$t=Cu({sizeProp:T,responsiveWidth:_,responsiveHeight:L,userMargin:D,marginDefault:Qd,title:qe,legend:Te,legendPosition:$e,animate:Qe,transitionProp:Ke,frameScheduler:Je,clock:et,random:tt,seed:nt,paused:ot,suspendWhenHidden:rt,themeDirtyRef:Lt}),Bt=Gc(),Et=Uc(),{reducedMotionRef:Ot,responsiveRef:Ft,size:zt,currentTheme:Ht,transition:Wt,introEnabled:qt,tableId:Gt,rafRef:Yt,renderFnRef:Vt,scheduleRender:Xt,frameRuntime:Ut}=$t;let Kt=$t.margin;if(ut){const e=60,t={...$t.margin};ut.top&&e>t.top&&(t.top=e),ut.bottom&&e>t.bottom&&(t.bottom=e),ut.left&&e>t.left&&(t.left=e),ut.right&&e>t.right&&(t.right=e),Kt=t}const Qt=zt[0]-Kt.left-Kt.right,Zt=zt[1]-Kt.top-Kt.bottom,Jt=(ae?.find(e=>"left"===e.orient)??ae?.find(e=>"right"===e.orient))?.extent??pe,en=(0,bt.useMemo)(()=>ft(r),[r]),tn=fe??Se,[nn,on]=(0,bt.useState)(0),rn=(0,bt.useRef)(0),[sn,an]=(0,bt.useState)(null),cn=Du(ze,zt,Kt,sn),ln=Du(Fe,zt,Kt,sn),un=(0,bt.useRef)(null),dn=(0,bt.useRef)(null),hn=(0,bt.useRef)(void 0),[pn,mn]=(0,bt.useState)(null),yn=(0,bt.useRef)(Zd.primary),fn=(0,bt.useRef)(function(){let e=-1,t=il;return{resolve(n){if(!n)return il;const o=qr;return o===e||(t=function(e){if(!e)return il;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(),s=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||il.axisStroke,tickText:s||il.tickText,crosshair:s?sl(s,"66"):il.crosshair,hoverFill:l?sl(l,"4D"):il.hoverFill,hoverStroke:s?sl(s,"99"):il.hoverStroke,pointRing:l||il.pointRing,primary:i||il.primary,background:l||il.background}:il}(n),e=o),t},invalidate(){e=-1}}}()),gn=(0,bt.useRef)(!1),bn=yr("StreamXYFrame"),[vn,xn]=(0,bt.useState)(!1),[wn,kn]=(0,bt.useState)([]),[Sn,An]=(0,bt.useState)([]),Cn="streaming"===o||["bar","swarm","waterfall"].includes(n),Mn=Qc((0,bt.useMemo)(()=>({chartType:n,runtimeMode:Cn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Cn?k:"right",extentPadding:P,scalePadding:I,axisExtent:pe,yAxisExtent:Jt,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Cn?C:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:p,groupAccessor:m||(y?"_lineGroup":void 0),categoryAccessor:Ge,lineDataAccessor:y,xScaleType:ht,yScaleType:pt,xExtent:M,yExtent:j,sizeRange:R,binSize:x,normalize:g,baseline:b,stackOrder:v,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:ao(Q),areaGroups:ee?new Set(ee):void 0,lineGradient:co(Z),semanticLineStops:J,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,lineStyle:O,pointStyle:F,areaStyle:z,swarmStyle:q,waterfallStyle:W,colorScheme:Y,barColors:G,barStyle:H,annotations:Me,decay:Xe,pulse:Ue,transition:Wt,introAnimation:qt,staleness:Ze,clock:Ut.now,heatmapAggregation:it,heatmapXBins:st,heatmapYBins:at,showValues:ct,heatmapValueFormat:lt,pointIdAccessor:dt,curve:f,themeCategorical:Ht?.colors?.categorical,themeSemantic:Rt(Ht),themeSequential:Ht?.colors?.sequential,themeDiverging:Ht?.colors?.diverging,customLayout:kt,onLayoutError:Ct,layoutConfig:Mt,layoutMargin:Kt}),[n,Cn,A,S,k,P,I,pe,Jt,a,c,l,C,w,u,d,h,p,m,y,Ge,ht,pt,M,j,R,x,g,b,v,V,X,U,K,Q,ee,Z,J,te,ne,oe,re,ie,O,F,z,q,W,Y,G,H,Me,Xe,Ue,Wt,qt,Ze,Ut.now,it,st,at,ct,lt,dt,f,Ht,kt,Ct,Mt,Kt])),jn=(0,bt.useRef)(null);jn.current||(jn.current=new ar(Mn));const Pn=$u(jn,Ee,Oe,e=>e.getData());Mr(jn,Mn,Lt,Xt),jr(jn,jt,Lt,Xt);const In=(0,bt.useRef)(null);In.current||(In.current=new At(e=>{const t=jn.current;t&&t.ingest(e)&&(Lt.current=!0,Xt())},{chunkThreshold:i,chunkSize:s})),(0,bt.useEffect)(()=>{In.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const Rn=(0,bt.useCallback)(e=>{In.current?.push(e)},[]),Tn=(0,bt.useCallback)(e=>{In.current?.pushMany(e)},[]),_n=(0,bt.useCallback)(()=>{In.current?.clear(),jn.current?.clear(),Lt.current=!0,Xt()},[Xt]);(0,bt.useImperativeHandle)(t,()=>({push:Rn,pushMany:Tn,remove:e=>{In.current?.flush();const t=jn.current?.remove(e)??[];return t.length>0&&(un.current&&t.some(e=>e===un.current?.data)&&(un.current=null,mn(null)),Lt.current=!0,Xt()),t},update:(e,t)=>{In.current?.flush();const n=jn.current?.update(e,t)??[];return n.length>0&&(Lt.current=!0,Xt()),n},clear:_n,getData:()=>(In.current?.flush(),jn.current?.getData()??[]),getScales:()=>jn.current?.scales??null,getExtents:()=>jn.current?.getExtents()??null,getCustomLayout:()=>jn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>jn.current?.lastCustomLayoutFailure??null}),[Rn,Tn,_n,Xt]),(0,bt.useEffect)(()=>{if(r){if(y&&en.length>0&&"object"==typeof en[0]&&null!==en[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(en[0][e])){const t=[];for(const n of en){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 In.current?.setBoundedData(t)}}In.current?.setBoundedData(en)}},[r,en,y]);const{canvasRef:Ln,interactionCanvasRef:Dn,resolutionDirtyRef:Nn}=Tu($t,{storeRef:jn,dirtyRef:Lt,hydrated:Bt,wasHydratingFromSSR:Et,cleanup:()=>In.current?.clear(),maxDevicePixelRatio:B,canvasPaintDependencies:[n,Qt,Zt,se,$,Fe,O,E,He,Xt]}),{hoverHandlerRef:$n,hoverLeaveRef:Bn,onPointerMove:En,onPointerLeave:On}=$t;$n.current=e=>{if(!tn)return;const t=Ln.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-Kt.left,i=e.clientY-o.top-Kt.top;if(0>r||r>Qt||0>i||i>Zt)return void(un.current&&(un.current=null,dn.current=null,mn(null),Pt?.(null),Xt()));const s=jn.current;if(!s||0===s.scene.length)return;const c=ql(Ae,e.pointerType),l=fi(s.scene,r,i,c,s.quadtree,s.maxPointRadius),u="multi"===Ce,d=()=>{un.current&&(un.current=null,dn.current=null,mn(null),Pt&&Pt(null),Xt())};if(!l&&!u)return void d();const h=u||!l?r:l.x,p=u||!l?i:l.y,m=l?.datum?oo(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,f="function"==typeof y?y(h):void 0;let g=Yl(m,h,p,null!=f?{xValue:f,xPx:h}:void 0);if(u&&s.scene.length>0&&s.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=gi(yi(e.path,e.curve),t,n);if(null===i)continue;const s=ji(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][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=yi(e.topPath,e.curve),s=yi(e.bottomPath,e.curve),a=gi(i,t,n);if(null===a)continue;const c=gi(s,t,n),l=ji(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:a,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}(s.scene,h,Math.max(c,Qt));if(e.length>0){const t=s.scales.y.invert,o=yn.current,r=y?y(h):h;if(l)g.xValue=r,g.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),g=Yl(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:oo(e.datum,s.resolvedRibbons)}})}}l||g.allSeries?.length?(un.current=g,dn.current=l?.node??null,mn(g),Pt?.(g),Xt()):d()},Bn.current=()=>{un.current&&(un.current=null,dn.current=null,mn(null),Pt?.(null),Xt())};const Fn=(0,bt.useRef)(()=>{});Fn.current=e=>{if(Qs(e.target))return;if(!It)return;const t=Ln.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Kt.left,r=e.clientY-n.top-Kt.top;if(0>o||o>Qt||0>r||r>Zt)return void It(null);const i=jn.current;if(!i||0===i.scene.length)return void It(null);const s=ql(Ae,hn.current),a=fi(i.scene,o,r,s,i.quadtree,i.maxPointRadius);if(!a)return void It(null);const c=a.datum||{},l=i.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;It(Yl(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Ld(hn.current)})};const zn=(0,bt.useCallback)(e=>Fn.current(e),[]),{kbFocusIndexRef:Hn,focusedNavPointRef:Wn,onKeyDown:qn}=(Gn={storeRef:jn,hoverRef:un,hoveredNodeRef:dn,setHoverPoint:mn,customHoverBehavior:Pt,customClickBehavior:It,scheduleRender:Xt},Xd({...Gn,extractPoints:qd,toHover:(e,t)=>Vd({...e,datum:oo(e.datum,t.resolvedRibbons)})}));var Gn;const Yn=(0,bt.useCallback)(e=>{hn.current=e.pointerType,Hn.current=-1,Wn.current=null,En(e)},[Wn,Hn,En]),Vn=(0,bt.useCallback)(e=>{hn.current="mouse",Hn.current=-1,Wn.current=null,En({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Wn,Hn,En]),Xn=(0,bt.useCallback)(e=>{hn.current=e.pointerType},[]);Vt.current=()=>{if(Yt.current=null,!Ut.isActive)return;const e=Ln.current,t=Dn.current;if(!e||!t)return;const o=jn.current;if(!o)return;const r=Ut.now(),i=o.advanceTransition(Ot.current?r+1e6:r),s=!Ot.current&&i,l=Dt.current.w!==Qt||Dt.current.h!==Zt,u=Nn.current,d=Lt.current||i||l,h=o.consumeStylePaintPending();let p=!1;const m=o.getLastUpdateResult(),y=bn.current.beforeCompute(m,s);!d||s&&!l||(o.computeScene({width:Qt,height:Zt}),Dt.current={w:Qt,h:Zt},p=!0,Pn()),bn.current.afterCompute(y,p,l);const f=Lu(o,r,p,Nt),g=Pu(B),b=fn.current.resolve(e);yn.current=b.primary;const v=Ti(Ze,o.lastIngestTime>0?r-o.lastIngestTime:0),x=Ze&&v.isStale;if(d||h||f.changed||u){const t=ju(e,zt,Kt,g);if(t){if(t.clearRect(-Kt.left,-Kt.top,zt[0],zt[1]),Ze&&1>v.alpha&&(t.globalAlpha=v.alpha),nl(t,{background:$,hasBackgroundGraphics:!!Fe,themeBackground:b.background,x:-Kt.left,y:-Kt.top,width:zt[0],height:zt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Qt,Zt),t.clip()),He&&o.scales)for(const e of He)t.save(),e(t,o.scene,o.scales,{width:Qt,height:Zt}),t.restore();const e=kt?yd.custom:yd[n];vd({context:t,nodes:o.scene,renderMode:E,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:Qt,height:Zt})}}),t.restore(),Ze&&1>v.alpha&&(t.globalAlpha=1)}}const w=!!(tn&&un.current&&o.scales),k=!!(dn.current&&Array.isArray(fe)&&fe.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),S=w||k;if(rl(S,gn.current)){const e=ju(t,zt,Kt,g);if(e&&(e.clearRect(-Kt.left,-Kt.top,zt[0],zt[1]),w&&un.current&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.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=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=r.pointColor||wd(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,un.current,Qt,Zt,"object"==typeof tn?tn:{},dn.current,b),k&&dn.current&&Array.isArray(fe))){const t=fe.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,dn.current,t,b)}gn.current=S}d&&e&&e.setAttribute("aria-label",wl(o.scene,n+" chart"));const A=Lt.current;if(Lt.current=A&&s&&!p,Nn.current=!1,A&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!sn||e(sn.x.domain()[0])!==e(o.scales.x.domain()[0])||e(sn.x.domain()[1])!==e(o.scales.x.domain()[1])||e(sn.y.domain()[0])!==e(o.scales.y.domain()[0])||e(sn.y.domain()[1])!==e(o.scales.y.domain()[1])||sn.x.range()[0]!==o.scales.x.range()[0]||sn.x.range()[1]!==o.scales.x.range()[1]||sn.y.range()[0]!==o.scales.y.range()[0]||sn.y.range()[1]!==o.scales.y.range()[1])&&an(o.scales),ut){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];kn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),An(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((Me&&Me.length>0||kt)&&(p||s))||!p&&33>r-rn.current||(on(e=>e+1),rn.current=r),Ze?.showBadge&&xn(!!x),(s||null!=o.activeTransition||f.pending)&&Xt()},_i(Ze,jn,Lt,Xt,vn,xn);const Un=(0,bt.useMemo)(()=>{if(de||me)return;const e=jn.current;return e?.xIsDate&&sn?zu(sn.x.domain()):void 0},[de,me,sn]),Kn=de||me||Un,Qn=tn&&pn?ge?ge(pn):(0,Kd.jsx)(_d,{hover:pn}):null,Zn=Qn?(0,Kd.jsx)(uu,{x:pn.x,y:pn.y,containerWidth:Qt,containerHeight:Zt,margin:Kt,className:"stream-frame-tooltip",children:Qn}):null,Jn=Wn.current,eo=(0,Kd.jsx)(Hl,{active:Hn.current>=0,hoverPoint:pn,margin:Kt,size:zt,shape:Jn?.shape,width:Jn?.w,height:Jn?.h}),to=Bu(a,C,"__semiotic_resolvedX","__semiotic_resolvedTime"),no=Bu(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),ro=to.key,io=no.key,so=Eu(to,no,Me&&Me.length>0||!1);if(Hc||!Bt&&Et){const e=jn.current;e&&r&&(e.ingest({inserts:en,bounded:!0}),e.computeScene({width:Qt,height:Zt}));const t=e?.scene??[],n=e?.scales??null,o=Du(ze,zt,Kt,n),i=Du(Fe,zt,Kt,n),s=Kn||(()=>{if(e?.xIsDate&&n)return zu(n.x.domain())})();return(0,Kd.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(N?" "+N:""),role:"img","aria-label":yt||("string"==typeof qe?qe:"XY chart"),style:{position:"relative",width:_?"100%":zt[0],height:L?"100%":zt[1]},children:[(0,Kd.jsx)(El,{summary:vt}),(0,Kd.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:zt[0],height:zt[1],style:{position:"absolute",left:0,top:0},children:[(0,Kd.jsx)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:i}),(0,Kd.jsxs)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:[$&&(0,Kd.jsx)("rect",{x:0,y:0,width:Qt,height:Zt,fill:$}),We&&n&&We.map((e,o)=>(0,Kd.jsx)(gt.Fragment,{children:e(t,n,{width:Qt,height:Zt})},"svgpre-"+o)),t.map((e,t)=>xd({node:e,index:t,renderMode:E,fallback:()=>zc(e,t,_t)})).filter(Boolean)]})]}),(0,Kd.jsx)(hc,{width:Qt,height:Zt,totalWidth:zt[0],totalHeight:zt[1],margin:Kt,scales:n,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:s,yFormat:he||ye,axisExtent:pe,showGrid:Re,title:qe,legend:Te,legendHoverBehavior:_e,legendClickBehavior:Le,legendHighlightedCategory:De,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:Be,foregroundGraphics:br(o,Ar(jn.current?.customLayoutOverlays,jt??null)),marginalGraphics:ut,xValues:[],yValues:[],annotations:Me,onAnnotationActivate:je,onObservation:we??xe,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:Pe,svgAnnotationRules:Ie,annotationFrame:0,xAccessor:ro,yAccessor:io,annotationData:so(jn.current?.getData()),pointNodes:Hu(jn.current?.scene),curve:"string"==typeof f?f:void 0,linkedCrosshairName:xt,linkedCrosshairSourceId:wt})]})}return(0,Kd.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(N?" "+N:""),role:"group","aria-label":yt||("string"==typeof qe?qe:"XY chart"),tabIndex:0,style:{position:"relative",width:_?"100%":zt[0],height:L?"100%":zt[1],overflow:"visible",touchAction:Jd(Ye)},onKeyDown:qn,children:["production"!==process.env.NODE_ENV&&jn.current&&(0,Kd.jsx)(fr,{store:jn.current,diagnostics:bn.current}),mt&&(0,Kd.jsx)(Ol,{tableId:Gt}),mt&&(0,Kd.jsx)($l,{scene:jn.current?.scene??[],chartType:n+" chart",tableId:Gt,chartTitle:"string"==typeof qe?qe:void 0}),(0,Kd.jsx)(El,{summary:vt}),(0,Kd.jsx)(yl,{hoverPoint:pn}),(0,Kd.jsxs)("div",{role:"img","aria-label":yt||("string"==typeof qe?qe:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:tn?Yn:void 0,onMouseMove:tn?Vn:void 0,onPointerLeave:tn?On:void 0,onMouseLeave:tn?On:void 0,onPointerDown:tn||Tt?Xn:void 0,onClick:Tt?zn:void 0,children:[(0,Kd.jsx)(_u,{size:zt,margin:Kt,children:ln}),(0,Kd.jsx)(lc,{width:Qt,height:Zt,totalWidth:zt[0],totalHeight:zt[1],margin:Kt,scales:sn,showAxes:se,axes:ae,showGrid:Re,xFormat:Kn,yFormat:he||ye,axisExtent:pe}),(0,Kd.jsx)("canvas",{ref:Ln,"aria-label":wl(jn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Kd.jsx)("canvas",{ref:Dn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Kd.jsx)(hc,{width:Qt,height:Zt,totalWidth:zt[0],totalHeight:zt[1],margin:Kt,scales:sn,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:Kn,yFormat:he||ye,axisExtent:pe,showGrid:Re,title:qe,legend:Te,legendHoverBehavior:_e,legendClickBehavior:Le,legendHighlightedCategory:De,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:Be,foregroundGraphics:br(cn,Ar(jn.current?.customLayoutOverlays,jt??null)),marginalGraphics:ut,xValues:wn,yValues:Sn,annotations:Me,onAnnotationActivate:je,onObservation:we??xe,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:Pe,svgAnnotationRules:Ie,annotationFrame:nn,xAccessor:ro,yAccessor:io,annotationData:so(jn.current?.getData()),pointNodes:Hu(jn.current?.scene),curve:"string"==typeof f?f:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!tl({background:$,hasBackgroundGraphics:!!Fe,themeBackground:Ht?.colors.background}),linkedCrosshairName:xt,linkedCrosshairSourceId:wt}),(Ye||Ve)&&(0,Kd.jsx)(St,{width:Qt,height:Zt,totalWidth:zt[0],totalHeight:zt[1],margin:Kt,dimension:Ye?.dimension??"xy",scales:sn,onBrush:Ve??(()=>{}),binSize:x,snap:Ye?.snap,binBoundaries:Ye?.binBoundaries??("bar"===n?jn.current?.getBinBoundaries():void 0),snapDuring:Ye?.snapDuring,streaming:"streaming"===o}),Ze?.showBadge&&(0,Kd.jsx)(Di,{isStale:vn,position:Ze.badgePosition}),eo,Zn]})]})}));eh.displayName="StreamXYFrame";var th=eh,nh=require("react"),oh=require("react"),rh=require("react/jsx-runtime"),ih=(0,oh.createContext)(null);function sh({colors:e,categories:t,colorScheme:n="category10",children:o}){const r=(0,oh.useMemo)(()=>{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]=In(e,n)??kn[r++%kn.length];return o}const e=Array.isArray(n)?n:wn[n]||kn,o={};for(let n=0;t.length>n;n++)o[t[n]]=e[n%e.length];return o}return{}},[e,t,n]);return(0,rh.jsx)(ih.Provider,{value:r,children:o})}function ah(){return(0,oh.useContext)(ih)}function ch(e){return e?"string"==typeof e?{name:e}:e:null}sh.displayName="CategoryColorProvider";var lh=.5;function uh(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??lh;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e}var dh=require("react");function hh(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 ph(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(hh(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function mh(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function yh(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[fh,gh]=jt(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||!yh(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),s=mh(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{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=mh(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}})}}));function bh(e){const t=(0,dh.useId)(),n=e.clientId||t,{name:o}=e,r=gh(e=>e.selections.get(o)),i=gh(e=>e.setClause),s=gh(e=>e.clearClause),a=(0,dh.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,dh.useMemo)(()=>r&&0!==r.clauses.size?ph(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,dh.useCallback)(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:(0,dh.useCallback)(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:(0,dh.useCallback)(()=>{s(o,n)},[s,o,n]),clientId:n}}function vh(e,t){const n=(0,dh.useId)(),o=t||n,r=gh(e=>e.setClause),i=gh(e=>e.clearClause);return{selectPoints:(0,dh.useCallback)(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:(0,dh.useCallback)(()=>i(e,o),[e,o,i]),clientId:o}}function xh(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=bh({name:t,fields:n});return{onHover:(0,dh.useCallback)(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}It(t)&&i(t)},[n,i,s]),predicate:o,isActive:r}}function wh(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function kh(e){const{name:t,xField:n,yField:o}=e,{predicate:r,isActive:i,selectInterval:s,clear:a}=bh({name:t,fields:[n,o].filter(Boolean)}),c=n&&o?"xyBrush":n?"xBrush":"yBrush",l=(0,dh.useCallback)(e=>{if(!e)return void a();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&&wh(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&wh(e)&&o&&(t[o]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),It(t)&&s(t)},[c,n,o,s,a]);return{brushInteraction:(0,dh.useMemo)(()=>({brush:c,during:l,end:l}),[c,l]),predicate:r,isActive:i,clear:a}}function Sh(e,t,n){const o=gh(e=>e.selections.get(t));return(0,dh.useMemo)(()=>{if(!o||0===o.clauses.size)return e;const t=ph(o,n);return e.filter(t)},[e,o,n])}var Ah=d(require("react")),Ch={light:Lt,dark:Dt,"high-contrast":Nt,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 Mh(e){return Ch[e]}var jh=require("react/jsx-runtime"),Ph=Ah.createContext(void 0),Ih="undefined"==typeof window?Ah.useEffect:Ah.useLayoutEffect;function Rh(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return Mh(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function Th({theme:e}){const t=Et(e=>e.setTheme),n=Et(e=>e.theme),o=Ah.useRef(n);o.current=n;const r=Ah.useRef(null);Ah.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===Nt?Lt:o.current,t("high-contrast")),mu(n,e=>{e.matches?(r.current=o.current===Nt?r.current??Lt:o.current,t("high-contrast")):(function(e,t){e(t===Lt?"light":t===Dt?"dark":t===Nt?"high-contrast":t)}(t,r.current??Lt),r.current=null)})},[e,t]);const i=Ah.useRef(!1);return Ih(()=>{i.current?void 0!==e&&t(Rh(e)):i.current=!0},[e,t]),null}function _h({children:e}){const t=Et(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=Ah.useContext(Ph),r={};return o&&(r["data-semiotic-theme"]=o),(0,jh.jsx)("div",{style:n,...r,children:e})}function Lh({theme:e,children:t}){const n="string"==typeof e&&Mh(e)?e:void 0,o=Ah.useMemo(()=>function(e){return void 0!==e?$t(Lt,Rh(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?Nt:Lt}(e),[e]);return(0,jh.jsx)(Bt,{initialState:{theme:o},children:(0,jh.jsxs)(Ph.Provider,{value:n,children:[(0,jh.jsx)(Th,{theme:e}),(0,jh.jsx)(_h,{children:t})]})})}function Dh(){return Et(e=>e.theme)}function Nh(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function $h(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),s=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&&s!==n.orientation)}function Bh(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=>$h(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"])Nh(e[o])&&Nh(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}}var Eh=44,Oh={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Eh,snap:"nearestDatum",brushHandleSize:Eh,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Fh(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,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!i)return Oh;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??Eh,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Eh,standardControls:a.standardControls??!1}}var zh={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}}},Hh={top:10,bottom:10,left:10,right:10};function Wh(e){return e.compactMode?e.marginDefaults:Hh}function qh(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}function Gh(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 Yh(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 Vh(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var Xh=require("react"),Uh=require("react"),Kh=require("react");function Qh(e={}){const{limit:t=50,types:n,chartId:o}=e,r=Vs(e=>e.version),i=Vs(e=>e.observations),s=Vs(e=>e.clearObservations),a=(0,Kh.useMemo)(()=>{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:a,latest:a.length>0?a[a.length-1]:null,clear:s}}var Zh=require("react/jsx-runtime"),Jh=(0,Uh.createContext)(!1),ep=(0,Uh.createContext)(!1);function tp(){return(0,Uh.useContext)(ep)}var np=(0,Uh.createContext)(null),op="undefined"==typeof window?Uh.useEffect:Uh.useLayoutEffect;function rp(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}function ip(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 sp(e){const t=(0,Uh.useContext)(np),n=(0,Uh.useId)(),o=rp(e),r=(0,Uh.useRef)([]);ip(r.current,o)||(r.current=o);const i=r.current;op(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),op(()=>{t&&t.registerCategories(n,i)},[t,n,i])}var ap="__linked-legend-isolate__",cp="__linked-legend-highlight__";function lp({categoryColors:e,interaction:t,selectionName:n,field:o}){const r=Object.entries(e),i=r.map(([e])=>e),s=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:r.map(([e,t])=>({label:e,color:t})),label:""}],{selectPoints:a,clear:c}=bh({name:n,fields:[o],clientId:ap}),{selectPoints:l,clear:u}=bh({name:n,fields:[o],clientId:cp}),d=gh(e=>e.selections.get(n)),{isolatedCategories:h,highlightedCategory:p}=(0,Uh.useMemo)(()=>{const e=new Set;let t=null;const n=d?.clauses.get(ap)?.fields[o];if("point"===n?.type)for(const t of n.values)e.add(t+"");const r=d?.clauses.get(cp)?.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=(0,Uh.useCallback)(e=>{"highlight"===t&&(e?l({[o]:[e.label]}):u())},[t,o,l,u]),y=(0,Uh.useCallback)(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():a({[o]:Array.from(n)})},[t,o,h,i.length,a,c]),[f,[g]]=gu([0,0],!0,!1),b=(0,Uh.useMemo)(()=>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:(0,Zh.jsx)("div",{ref:f,style:{width:"100%",display:"block"},children:(0,Zh.jsx)("svg",{width:"100%",height:Math.max(30,22*b+8),style:{display:"block",overflow:"visible"},children:(0,Zh.jsx)(ps,{legendGroups:s,title:!1,orientation:"horizontal",width:g,height:20,customHoverBehavior:"highlight"===t?m:void 0,customClickBehavior:"isolate"===t?y:void 0,highlightedCategory:p,isolatedCategories:h})})})}function up({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=(0,Uh.useMemo)(()=>{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=ah(),[l,u]=(0,Uh.useState)({}),d=(0,Uh.useRef)({}),h=(0,Uh.useMemo)(()=>({registerCategories:(e,t)=>{const n=rp(t);u(t=>ip(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=(0,Uh.useMemo)(()=>{const e=[];for(const t of Object.values(l))for(const n of t)e.push(n);return rp(e)},[l]),m=(0,Uh.useMemo)(()=>{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]=kn[n%kn.length],n++);const o={...e};for(const n of p)o[n]=e[n]??t[n];return o},[c,p]),y=void 0===n||n,f=Object.keys(m).length>0;return(0,Zh.jsx)(fh,{initialState:a,children:(0,Zh.jsx)(Ys,{children:(0,Zh.jsx)(ep.Provider,{value:!0,children:(0,Zh.jsx)(np.Provider,{value:h,children:(0,Zh.jsx)(sh,{colors:m,children:(0,Zh.jsxs)(Jh.Provider,{value:y&&f,children:[y&&"top"===o&&(0,Zh.jsx)(lp,{categoryColors:m,interaction:r,selectionName:i,field:s}),e,y&&"bottom"===o&&(0,Zh.jsx)(lp,{categoryColors:m,interaction:r,selectionName:i,field:s})]})})})})})})}function dp({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){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:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):Cn[i%Cn.length];return{label:r+"",color:a}}),label:""}]}}function hp(e,t){if(!t)return[];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)}function pp({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:c,chartWidth:l,legendLayout:u,hasTitle:d=!1,axisChrome:h}){const p=(0,Uh.useContext)(Jh),m=null!==(0,Uh.useContext)(np),y=void 0!==o?o:!p&&!!t,f=!!t&&(y||m),g=(0,Xh.useMemo)(()=>f?void 0!==a?a:hp(e,t):[],[a,t,e,f]);sp(m&&t?g:[]);const b=(0,Xh.useMemo)(()=>{if(!y||!t)return;const o=dp({data:e,colorBy:t,colorScale:n,getColor:Pn,categories:g});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[y,t,e,n,g]),v=(0,Xh.useMemo)(()=>Bi(b,c),[b,c]),{hasAxis:x,hasAxisLabel:w,rotatedTicks:k}=h??{},S=(0,Xh.useMemo)(()=>{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:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];if(v){const e=function(e,t){return Vi(e,t)+Xi(e)+Ui(t)}(v,u),t=void 0===x?{hasAxis:!0,hasAxisLabel:!0}:{hasAxis:x,hasAxisLabel:w,rotatedTicks:k},i=ns(v,Math.max(1,(l??600)-n.left-n.right),u)+Xi(v)+Ji("bottom"===r?t:void 0,u)+("top"===r&&d?24:0);"right"===r&&!o("right")&&e>n.right?n.right=e:"left"===r&&!o("left")&&e>n.left?n.left=e:"top"!==r||o("top")?"bottom"!==r||o("bottom")||(n.bottom=Math.max(n.bottom,80,i)):n.top=Math.max(n.top,50,i)}return n},[s,i,v,r,l,u,d,x,w,k]);return{legend:v,margin:S,legendPosition:r}}function mp(e,t,n){const[o,r]=(0,Xh.useState)(null),[i,s]=(0,Xh.useState)(new Set),a=(0,Xh.useMemo)(()=>new Set,[]),c=(0,Xh.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,Xh.useCallback)(t=>{"isolate"===e&&s(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=(0,Xh.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return("string"==typeof r?r:(r??"")+"")===o}}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return i.has("string"==typeof o?o:(o??"")+"")}}:null},[e,t,o,i]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?i:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}var yp=[];function fp(){const e=Dh(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function gp(e,t,n,o,r){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=In(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=wn[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]:Sn}function bp(e,t,n){const o=ah(),r=fp();return(0,nh.useMemo)(()=>{if(!t)return;const i=o??void 0,s=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&&Vh(i)){const e=Rn(n.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return Rn(n.map(e=>({_cat:e})),"_cat",s)}if(i&&Vh(i)){const n=Rn(e,t,s);return e=>i[e]||n(e)}return Rn(e,t,s)}if(i&&Vh(i)){const e=Rn([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,o,r])}function vp(e,t,n){return(0,nh.useMemo)(()=>{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 xp({selection:e,linkedHover:t,fallbackFields:n=yp,unwrapData:o=!1,onObservation:r,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,nh.useId)(),h=(0,nh.useMemo)(()=>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=(0,nh.useMemo)(()=>"series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n,[h,l,n]),m=bh({name:e?.name||"__unused__",fields:p}),y=xh({name:h?.name||"hover",fields:p}),f=Vs(e=>e.pushObservation),g=(0,nh.useCallback)(e=>{r?.(e),f?.(e)},[r,f]),b=e?{isActive:m.isActive,predicate:m.predicate}:null,[v,x]=(0,nh.useState)(null),w=(0,nh.useRef)(!1),k=l||n[0],S=(0,nh.useMemo)(()=>{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=(0,nh.useCallback)((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=Gh(e,t,h.xField);null!=n&&function(e,t,n){const o=Ya.positions.get(e);o?.locked||o&&o.xValue===t&&o.sourceId===n||(Ya={positions:new Map(Ya.positions).set(e,{xValue:t,sourceId:n})},Xa())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||o||Ua(h.name||"hover",d),"x-position"===h?.mode||o||y.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||f)&&Nd({onObservation:g,datum:e?Yh(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,y,h,d,r,i,s,f,g,c,k,u]),C=(0,nh.useCallback)((n=!0)=>{w.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&m.clear(),n&&c&&x(null),"x-position"===h?.mode&&(Ka(h.name||"hover",d),Ua(h.name||"hover",d))},[t,h,y,e,u,m,c,d]),M=(0,nh.useCallback)((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=Gh(n,e,h.xField);null!=t&&function(e,t,n){const o=Ya.positions.get(e);if(o?.locked){const t=new Map(Ya.positions);return t.delete(e),Ya={positions:t},Xa(),!1}Ya={positions:new Map(Ya.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Xa()}(h.name||"hover",t,d)}if(l)if(n){w.current=!0;const o=Yh(n);if(t&&"x-position"!==h?.mode&&y.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])}Vh(e)&&m.selectPoints(e)}if(c&&k){const e=o?.[k];x(null!=e?e+"":null)}}else b&&C();if(n||b){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(r||f)&&$d({onObservation:g,datum:n?Yh(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:o})}},[a,r,f,g,i,s,h,d,u,t,y,e,m,p,c,k,C]);return(0,nh.useEffect)(()=>{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]),(0,nh.useEffect)(()=>()=>{w.current&&C(!1)},[C]),(0,nh.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Ka(e,d),Ua(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:M,crosshairSourceId:d}}function wp(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 kp(e,t,n){return function(e,t,n){const o=zh[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,s=Bh({...t,mode:e},{width:t.width??r,height:t.height??i}).props,a=s.mode||e||"primary",c=zh[a],l="context"===a||"sparkline"===a,u="primary"===a&&n?.width?n.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&n?.height?n.height:c.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:qh(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Fh(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(e,t,n)}var Sp=require("react/jsx-runtime");function Ap({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return(0,Sp.jsx)("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:(0,Sp.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Sp.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Sp.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Sp.jsx)("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})]})})}var Cp=d(require("react")),Mp=require("react/jsx-runtime"),jp=class extends Cp.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:(0,Mp.jsx)(Ap,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Pp=require("react/jsx-runtime"),Ip="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function Rp({componentName:e,width:t,height:n,children:o}){return(0,Pp.jsx)(jp,{fallback:o=>(0,Pp.jsx)(Ap,{componentName:e,message:o.message,width:t,height:n}),children:o})}var Tp={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"},_p={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Lp(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Pp.jsx)("div",{style:{...Tp,width:t,height:n},children:o||"No data available"}):null}function Dp(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return(0,Pp.jsx)("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))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(i+s)-s))/2);return(0,Pp.jsx)("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)=>(0,Pp.jsx)("div",{className:"semiotic-loading-bar",style:{..._p,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Np(e,t,n,o){if(!Ip)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 $p(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 s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function Bp(e,t,n=3){let o,r=n+1;for(const n of t){const t=$p(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function Ep(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function Op(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(Bp(e,t,3)??null)}function Fp(e){return` Or use a function: ${e}={d => d.myValue}.`}function zp({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=Ep(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=Op(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`+Fp(r)}}}return null}function Hp({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 Wp({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=Ep(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=Op(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`+Fp(o)}}}return null}var qp=require("react"),Gp=require("react");function Yp(e){const t=Et(e=>e.theme.colors.selectionOpacity);return(0,Gp.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}function Vp(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:i,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:p,showLegend:m,legend:y,legendLayout:f,userMargin:g,marginDefaults:b,onClick:v,hoverHighlight:x,mobileInteraction:w,mobileSemantics:k,loading:S,loadingContent:A,emptyContent:C,width:M,height:j,hasTitle:P,axisChrome:I}=e,R=void 0===n,T=(0,qp.useMemo)(()=>ft(t),[t]),[_,L]=(0,qp.useState)([]),D=(0,qp.useCallback)(e=>{L(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),N="string"==typeof o?o:void 0,$=(0,qp.useMemo)(()=>Fh(w,{width:M,mobileSemantics:k}),[w,M,k]),{activeSelectionHook:B,hoverSelectionHook:E,customHoverBehavior:O,customClickBehavior:F,crosshairSourceId:z}=xp({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:p,onClick:v,hoverHighlight:x,colorByField:N,mobileInteraction:$}),H=wp(c,z),W=bp(T,o,r),q=(0,qp.useMemo)(()=>hp(T,o),[T,o]),G=(0,qp.useMemo)(()=>R&&_.length>0?_:q,[R,_,q]),Y=mp(i,o,G),V=(0,qp.useMemo)(()=>E||(Y.legendSelectionHook?Y.legendSelectionHook:B),[E,Y.legendSelectionHook,B]),X=Yp(a),U=fp(),K=ah(),Q=(0,qp.useMemo)(()=>{if(W)return W;if(!o||0===G.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:U&&U.length>0?U:Cn,t="__streamCat",n=Rn(G.map(e=>({[t]:e})),t,e);return e=>K?.[e]||n(e)||"#999"},[W,o,G,r,U,K]),{legend:Z,margin:J,legendPosition:ee}=pp({data:T,colorBy:o,colorScale:Q,showLegend:m,legendPosition:s,userMargin:g,defaults:b,categories:G,additionalLegend:y,chartWidth:M,legendLayout:f,hasTitle:P,axisChrome:I}),te=(0,qp.useMemo)(()=>{const e={};return Z&&(e.legend=Z,e.legendPosition=ee,f&&(e.legendLayout=f)),i&&"none"!==i&&(e.legendHoverBehavior=Y.onLegendHover,e.legendClickBehavior=Y.onLegendClick,e.legendHighlightedCategory=Y.highlightedCategory,e.legendIsolatedCategories=Y.isolatedCategories),R&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=D),e},[Z,ee,f,i,Y.onLegendHover,Y.onLegendClick,Y.highlightedCategory,Y.isolatedCategories,R,o,D]),ne=Array.isArray(n)?ft(n):n,oe=Dp(S,M,j,A),re=oe?null:Lp(ne,M,j,C);return{data:T,colorScale:W,allCategories:G,legendState:Y,effectiveSelectionHook:V,activeSelectionHook:B,customHoverBehavior:O,customClickBehavior:F,mobileInteraction:$,legend:Z,margin:J,legendPosition:ee,earlyReturn:oe||re||null,legendBehaviorProps:te,crosshairProps:H,resolvedSelection:X}}var Xp=require("react");function Up(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 Kp(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Jp(t(e))}function Qp(e,t){const n=Kp(e),o=Kp(t);return(e,t)=>{const r=o(e);return{value:r,x:n(e),y:r,category:t}}}function Zp(e,t){const n=Kp(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 Jp(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 em(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=Jp(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 tm(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!em(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function nm(e,t,n,o=e=>e){const r=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const s=o(e),a={...r(e,i)};return Object.assign(a,tm(s,t,n(s,i))),a}:r}function om(e){const{lineWidth:t=2,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:s,areaOpacity:a=.3,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,styleRules:p,ruleContext:m}=e,y=(0,Xp.useMemo)(()=>function(e){const{lineWidth:t=2,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const d={strokeWidth:t},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let p;return i?p=i(e,u):n?o&&(p=Pn(e,n,o)):p=r||Sn,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,tm(e,c,l?l(e,u):{value:void 0,category:u})),d}}({lineWidth:t,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:s,areaOpacity:a,styleRules:p,ruleContext:m}),[t,n,o,r,i,s,a,p,m]),f=(0,Xp.useMemo)(()=>Up(y,{stroke:c,strokeWidth:l,opacity:u}),[y,c,l,u]);return(0,Xp.useMemo)(()=>uh(f,d??null,h),[f,d,h])}var rm=require("react");function im(e,t){const{variant:n,frameRef:o,overrides:r}=t,i=(0,rm.useRef)(r);i.current=r,(0,rm.useImperativeHandle)(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)??[],replace:t=>e.current?.replace?.(t),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 new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}function sm(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:s,maxDevicePixelRatio:a,axisExtent:c,autoPlaceAnnotations:l}=e,u={};return t&&(u.title=t),n&&(u.description=n),o&&(u.summary=o),void 0!==r&&(u.accessibleTable=r),i&&(u.className=i),null!=s&&(u.animate=s),void 0!==a&&(u.maxDevicePixelRatio=a),void 0!==c&&(u.axisExtent=c),void 0!==l&&(u.autoPlaceAnnotations=l),u}function am(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,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(a||t||o||r||s)&&(p.customHoverBehavior=u),d&&(c||(h?o||r||t:o||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(p.customClickBehavior=d),null!=m&&(p.hoverRadius=m),p}function cm(e){const{tooltip:t,defaultTooltipContent:n}=e;return{tooltipContent:!1===t?()=>null:cu(t)||n}}var lm="__forecastSegment",um=null;async function dm(){return um||(um=await Promise.resolve().then(()=>(ee(),W))),um}var hm=require("react"),pm="__semiotic_resolvedX",mm="__semiotic_resolvedY";function ym(e){const{data:t,xAccessor:n,yAccessor:o,forecast:r,anomaly:i,groupBy:s}=e,a="string"==typeof n?n:pm,c="string"==typeof o?o:mm,l=(0,hm.useMemo)(()=>{if(!r&&!i)return t;const e="function"==typeof n,s="function"==typeof o;return e||s?t.map(t=>{const r={...t};return e&&(r[pm]=n(t)),s&&(r[mm]=o(t)),r}):t},[t,r,i,n,o]),[u,d]=(0,hm.useState)(null),[h,p]=(0,hm.useState)([]),m=(0,hm.useRef)(r),y=(0,hm.useRef)(i);return(0,hm.useEffect)(()=>{if(!r&&!i)return void((m.current||y.current)&&(d(null),p([]),m.current=r,y.current=i));let e=!1;const t=r!==m.current||i!==y.current;if(m.current=r,y.current=i,t&&(d(null),p([])),r){const t=s&&"string"==typeof s&&"object"==typeof r?{...r,_groupBy:s}:r;(async function(...e){return(await dm()).buildForecast(...e)})(l,a,c,t,i).then(t=>{e||(d(t),p(t.annotations))}).catch(()=>{e||(d(null),p([]))})}else i&&async function(...e){return(await dm()).buildAnomalyAnnotations(...e)}(i).then(t=>{e||(d(null),p(t))}).catch(()=>{e||p([])});return()=>{e=!0}},[l,r,i,a,c,s]),{effectiveData:u?u.processedData:t,statisticalAnnotations:h,hasForecast:!!u,xAccessorKey:a,yAccessorKey:c}}var fm=require("react/jsx-runtime"),gm="__lineObjectSeries",bm=(0,mt.forwardRef)(function(e,t){const n=(0,mt.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:r,margin:i,className:s,xFormat:a,yFormat:c,axisExtent:l,xAccessor:u="x",yAccessor:d="y",lineBy:h,lineDataAccessor:p="coordinates",colorBy:m,colorScheme:y,styleRules:f,curve:g="linear",showPoints:b=!1,pointRadius:v=3,fillArea:x=!1,areaOpacity:w=.3,lineWidth:k=2,lineGradient:S,tooltip:A,pointIdAccessor:C,annotations:M,directLabel:j,gapStrategy:P="break",anomaly:I,forecast:R,band:T,xExtent:_,yExtent:L,frameProps:D={},selection:N,linkedHover:$,onObservation:B,onClick:E,hoverHighlight:O,hoverRadius:F,chartId:z,loading:H,loadingContent:W,emptyContent:q,legendInteraction:G,legendPosition:Y,legend:V,xScaleType:X,yScaleType:U,color:K,stroke:Q,strokeWidth:Z,opacity:J}=e,{legend:ee,...te}=D,ne=(0,mt.useMemo)(()=>Bi(ee,V),[ee,V]),{width:oe,height:re,enableHover:ie,showGrid:se,showLegend:ae,title:ce,description:le,summary:ue,accessibleTable:de,xLabel:he,yLabel:pe}=o,me=(0,mt.useMemo)(()=>ft(r),[r]),ye=Array.isArray(me[0]?.[p])?me[0][p]:me;Np("LineChart",ye,"xAccessor",u),Np("LineChart",ye,"yAccessor",d);const{effectiveData:fe,statisticalAnnotations:ge}=ym({data:me,xAccessor:u,yAccessor:d,forecast:R,anomaly:I,groupBy:h}),be="__compoundGroup",ve=!(!R||!h),xe=ve?be:R?lm:h,we=(0,mt.useMemo)(()=>{if(!ve)return fe;const e="function"==typeof h?h:e=>e[h];return fe.map(t=>{const n={...t};return n[be]=`${e(t)}__${t[lm]||"observed"}`,n})},[fe,ve,h]),ke=ve?we:fe,Se=m||h,Ae=(0,mt.useMemo)(()=>{if(!R)return;const e=R.upperBounds,t=R.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 s=fe;for(const e of s){const t="function"==typeof d?d(e):+e[d];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},[R,fe,d]),Ce=(0,mt.useCallback)(e=>{const t="function"==typeof u?u(e):e[u],n="function"==typeof d?d(e):e[d];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[u,d]),Me=void 0!==ke[0]?.[p],je=Me?gm:xe,Pe=(0,mt.useMemo)(()=>{if(Me)return ke.map((e,t)=>{const n="function"==typeof h?h(e):"string"==typeof h?e[h]:void 0,o=null==n?"line-"+t:n+"",r=Array.isArray(e[p])?e[p]:[];return{...e,[gm]:o,[p]:r.map(t=>({...t,[gm]:o,parentLine:e,..."string"==typeof h&&void 0!==e[h]?{[h]:e[h]}:{}}))}});if(xe){const e=ke.reduce((e,t)=>{const n="function"==typeof xe?xe(t):t[xe];if(!e[n]){const o={[p]:[]};"string"==typeof xe&&(o[xe]=n),ve&&(o[lm]=t[lm],"string"==typeof h&&(o[h]=t[h])),e[n]=o}return e[n][p].push(t),e},{});return Object.values(e)}return[{[p]:ke}]},[Me,xe,p,ke,h,ve]),{gapProcessedLineData:Ie,hasGaps:Re}=(0,mt.useMemo)(()=>{if("interpolate"===P){let e=!1;const t=[];for(const n of Pe){const o=(n[p]||[]).filter(t=>!Ce(t)||(e=!0,!1));o.length>0&&t.push({...n,[p]:o})}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const n of Pe){const o=n[p]||[];let r=[],i=0;const s=je&&"string"==typeof je?n[je]:void 0;for(const a of o)if(Ce(a))e=!0,r.length>0&&(t.push({...n,[p]:r}),r=[],i++);else{const e=null!=s?`${s}__seg${i}`:"__seg"+i;r.push({...a,_gapSegment:e})}r.length>0&&t.push({...n,[p]:r})}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof d?d:"y",n=[];for(const o of Pe){const r=o[p]||[],i=[];for(const n of r)Ce(n)?(e=!0,i.push({...n,[t]:0})):i.push(n);n.push({...o,[p]:i})}return{gapProcessedLineData:n,hasGaps:e}}return{gapProcessedLineData:Pe,hasGaps:!1}},[Pe,P,p,Ce,je,d]),Te="object"==typeof j?j:{},_e=Te.position||"end",Le=Te.fontSize||11,De=(0,mt.useMemo)(()=>{if(!j||!Se)return[];const e="function"==typeof Se?Se:e=>e[Se],t=new Set;for(const n of Ie){const o=n[p]||[];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)},[j,Se,Ie,p,_e]),Ne=(0,mt.useMemo)(()=>{if(!j)return o.marginDefaults;const e=De.reduce((e,t)=>Math.max(e,t.length*(.6*Le)),0)+10,t="end"===_e?"right":"left";return{...o.marginDefaults,[t]:Math.max(o.marginDefaults[t]||0,e)}},[j,De,Le,_e,o.marginDefaults]),$e=Vp({data:fe,rawData:r,colorBy:Se,colorScheme:y,legendInteraction:G,legendPosition:Y,selection:N,linkedHover:$,fallbackFields:Se?["string"==typeof Se?Se:""]:[],unwrapData:!1,onObservation:B,onClick:E,hoverHighlight:O,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"LineChart",chartId:z,showLegend:(!j||void 0!==ae)&&ae,legend:ne,userMargin:i,marginDefaults:Ne,loading:H,loadingContent:W,emptyContent:q,width:oe,height:re,hasTitle:!!ce,axisChrome:es({showAxes:o.showAxes,xLabel:he})}),Be=$e.colorScale,Ee=$e.effectiveSelectionHook,Oe=$e.resolvedSelection,Fe=$e.customHoverBehavior,ze=$e.customClickBehavior,He=$e.crosshairProps,We=(0,mt.useMemo)(()=>{if(Se)return Me?e=>{const t=e.parentLine||e;return"function"==typeof Se?Se(t):t[Se]}:Se},[Se,Me]),qe=(0,mt.useMemo)(()=>Qp(u,d),[u,d]),Ge=om({lineWidth:k,colorBy:We,colorScale:Be,color:K,fillArea:x,areaOpacity:w,stroke:Q,strokeWidth:Z,opacity:J,effectiveSelectionHook:Ee,resolvedSelection:Oe,styleRules:f,ruleContext:qe}),[Ye,Ve]=(0,mt.useState)(null);(0,mt.useEffect)(()=>{if(!R)return void Ve(null);let e=!1;return async function(...e){return(await dm()).createSegmentLineStyle(...e)}(Ge,R).then(t=>{e||Ve(()=>t)}).catch(()=>{e||Ve(null)}),()=>{e=!0}},[Ge,R]);const Xe=Ye||Ge,Ue=(0,mt.useMemo)(()=>{if(b)return e=>{const t={r:v,fillOpacity:1};return Se?Be&&(t.fill=Pn(e.parentLine||e,Se,Be)):t.fill=K||Sn,t}},[b,v,Se,Be,K]),Ke=Array.isArray(x)?"mixed":x?"area":"line",Qe=(0,mt.useMemo)(()=>{if(!j||!Se)return[];const e="function"==typeof u?u:e=>e[u],t="function"==typeof d?d:e=>e[d],n="function"==typeof Se?Se:e=>e[Se],o=new Map;for(const e of Ie){const t=e[p]||[];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 s=i+"";""===s||o.has(s)||o.set(s,r)}const r=Array.from(o.entries()).map(([n,o])=>({type:"text",label:n,["string"==typeof u?u:"x"]:e(o),["string"==typeof d?d:"y"]:t(o),dx:"end"===_e?6:-6,dy:0,color:Be?Be(n):Sn,fontSize:Le}));r.sort((e,t)=>{const n="string"==typeof d?d:"y";return e[n]-t[n]});for(let e=1;r.length>e;e++){const t="string"==typeof d?d:"y",n=r[e-1],o=r[e];Le+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Le+2)}return r},[j,Se,Be,Ie,p,u,d,_e,Le]),Ze=$e.margin,Je=h||m,et=(0,mt.useMemo)(()=>Pd([{label:he||Sd(u),accessor:u,role:"x",format:a},{label:pe||Sd(d),accessor:d,role:"y",format:c},...Je?[{label:Sd(Je),accessor:Je,role:"group"}]:[],...jd(T,c)]),[u,d,he,pe,Je,a,c,T]),tt=zp({componentName:"LineChart",data:Me?fe[0]?.[p]||[]:r,accessors:{xAccessor:u,yAccessor:d}}),nt=(0,mt.useMemo)(()=>Me||je||Re?Ie.flatMap(e=>{const t=e[p]||[];return je&&"string"==typeof je?t.map(t=>({...t,[je]:t[je]??e[je]})):t}):ke,[Ie,p,Me,je,ke,Re]),ot=co(S),rt={chartType:Ke,...Array.isArray(x)&&{areaGroups:x},...ot&&{lineGradient:ot},...null!=r&&{data:nt},xAccessor:u,yAccessor:d,xScaleType:X,yScaleType:U,..._&&{xExtent:_},...!L||null==L[0]&&null==L[1]?Ae?{yExtent:Ae}:{}:{yExtent:L},groupAccessor:"break"===P&&Re?"_gapSegment":je||void 0,...T&&{band:T},curve:g,lineStyle:Xe,...b&&{pointStyle:Ue},size:[oe,re],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:Ze,showAxes:o.showAxes,xLabel:he,yLabel:pe,xFormat:a,yFormat:c,...void 0!==l&&{axisExtent:l},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},enableHover:ie,showGrid:se,...$e.legendBehaviorProps,...ce&&{title:ce},...le&&{description:le},...ue&&{summary:ue},...void 0!==de&&{accessibleTable:de},...s&&{className:s},...null!=e.animate&&{animate:e.animate},...su({tooltip:A,defaultTooltipContent:et,multiDefaultContent:au()}),...am({linkedHover:$,selection:N,onObservation:B,onClick:E,hoverRadius:F,hoverHighlight:O,mobileInteraction:$e.mobileInteraction,customHoverBehavior:Fe,customClickBehavior:ze}),...C&&{pointIdAccessor:C},...(M?.length||ge.length||Qe.length)&&{annotations:[...M||[],...ge,...Qe]},...He,...te};return $e.earlyReturn?$e.earlyReturn:tt?(0,fm.jsx)(Ap,{componentName:"LineChart",message:tt,width:oe,height:re}):(0,fm.jsx)(Rp,{componentName:"LineChart",width:oe,height:re,children:(0,fm.jsx)(th,{ref:n,...rt})})});bm.displayName="LineChart";var vm=require("react"),xm=require("react"),wm=require("react");function km(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}function Sm(e){const t=(0,wm.useRef)(null);return im(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:kp(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:(0,wm.useMemo)(()=>km(e.margin),[e.margin])}}function Am(e){const t=Sm(e),{resolved:n,normalizedMargin:o}=t,r=Vp({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,selection:e.selection,linkedHover:e.linkedHover,hoverHighlight:e.hoverHighlight,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,legend:e.legend,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}}var Cm=require("react/jsx-runtime"),Mm=(0,xm.forwardRef)(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,xExtent:s,yExtent:a,showAxes:c=!1,margin:l,className:u,annotations:d,onObservation:h,onClick:p,selection:m,linkedHover:y,hoverHighlight:f,chartId:g,loading:b,loadingContent:v,emptyContent:x,colorBy:w,colorScheme:k,legend:S,legendInteraction:A,legendPosition:C,frameProps:M={}}=e,{legend:j,...P}=M,I=(0,xm.useMemo)(()=>Bi(j,S),[j,S]),{frameRef:R,resolved:T,safeData:_,setup:L,earlyReturn:D}=Am({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:n,colorBy:w,colorScheme:k,legend:I,legendInteraction:A,legendPosition:C,selection:m,linkedHover:y,hoverHighlight:f,onObservation:h,onClick:p,chartId:g,loading:b,loadingContent:v,emptyContent:x,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}),N=L.effectiveSelectionHook,$=(0,xm.useMemo)(()=>N?.isActive?{isActive:!0,predicate:N.predicate}:null,[N?.isActive,N?.predicate]);if(D)return D;const{width:B,height:E,enableHover:O,showGrid:F,title:z,description:H,summary:W,accessibleTable:q,xLabel:G,yLabel:Y}=T,V={chartType:"custom",...null!=n&&{data:_},customLayout:o,layoutConfig:r,onLayoutError:i,...$&&{layoutSelection:$},xExtent:s,yExtent:a,colorAccessor:w,colorScheme:k,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:L.margin,showAxes:c,xLabel:G,yLabel:Y,enableHover:O,showGrid:F,...L.legendBehaviorProps,...sm({title:z,description:H,summary:W,accessibleTable:q,className:u,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...am({linkedHover:y,selection:m,onObservation:h,onClick:p,hoverRadius:e.hoverRadius,hoverHighlight:f,mobileInteraction:L.mobileInteraction,customHoverBehavior:L.customHoverBehavior,customClickBehavior:L.customClickBehavior}),...d&&d.length>0&&{annotations:d},...L.crosshairProps,...P};return(0,Cm.jsx)(Rp,{componentName:"XYCustomChart",width:B,height:E,children:(0,Cm.jsx)(th,{ref:R,...V})})});function jm(e,t,n,o,r){const i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*n+r*r*r*o}function Pm(e,t,n,o,r){const i=1-r;return 3*i*i*(t-e)+6*i*r*(n-t)+3*r*r*(o-n)}function Im(e,t,n,o,r){const i=[],s=(e.x+t.x)/2;for(let a=0;r>=a;a++){const c=a/r;let l,u,d,h;"linear"===o?(l=e.x+(t.x-e.x)*c,u=e.y+(t.y-e.y)*c,d=t.x-e.x,h=t.y-e.y):(l=jm(e.x,s,s,t.x,c),u=jm(e.y,e.y,t.y,t.y,c),d=Pm(e.x,s,s,t.x,c),h=Pm(e.y,e.y,t.y,t.y,c)),i.push({x:l,y:u,dx:d,dy:h,radius:e.radius+(t.radius-e.radius)*c,datumIndex:.5>c?n:n+1})}return i}function Rm(e,t={}){const n=[],o=[],r=[];if(2>e.length)return{topPath:n,bottomPath:o,datumIndices:r};const i=t.curve??"smooth",s=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){const a=Im(e[t],e[t+1],t,i,s);for(let e=0===t?0:1;a.length>e;e++){const t=a[e],i=Math.hypot(t.dx,t.dy)||1,s=-t.dy/i,c=t.dx/i,l=Math.max(0,t.radius);n.push([t.x+s*l,t.y+c*l]),o.push([t.x-s*l,t.y-c*l]),r.push(t.datumIndex)}}return{topPath:n,bottomPath:o,datumIndices:r}}Mm.displayName="XYCustomChart";var Tm=require("react/jsx-runtime"),_m="Other";function Lm(e,t,n){return"function"==typeof e?e(t,n):t[e]}function Dm(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Nm(e,t={}){const n=t.xAccessor??"x",o=t.yAccessor??"y",r=t.lineBy??"series",i=t.rankDirection??"descending",s=[],a=new Map,c=new Map,l=[],u=new Map;let d=1/0,h=-1/0;e.forEach((e,t)=>{const i=Lm(n,e,t),p=Dm(i);let m=a.get(p);null==m&&(m=s.length,a.set(p,m),s.push(i),c.set(m,[]));const y=Lm(r,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const f=Number(Lm(o,e,t));Number.isFinite(f)&&(d=Math.min(d,f),h=Math.max(h,f),c.get(m)?.push({datum:e,inputIndex:t,series:y,value:f}))});const p=[],m=new Map,y=new Map;for(let e=0;s.length>e;e++){const t=c.get(e)??[];t.sort((e,t)=>("descending"===i?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,n)=>{const o=n+1;p.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:o}),m.set(t.series,(m.get(t.series)??0)+o),y.set(t.series,(y.get(t.series)??0)+1)})}const f=l.length+1,g=[...l].sort((e,t)=>{const n=y.get(e)??0,o=y.get(t)??0;return((m.get(e)??0)+(s.length-n)*f)/Math.max(1,s.length)-((m.get(t)??0)+(s.length-o)*f)/Math.max(1,s.length)||(u.get(e)??0)-(u.get(t)??0)}),b=new Set(g.slice(0,null==t.highlightTop?g.length:Math.max(0,Math.floor(t.highlightTop))));return{data:p.map(e=>{const t=b.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:_m,__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:s,seriesOrder:l,overallOrder:g,valueExtent:d===1/0?[0,0]:[d,h]}}function $m({datum:e,x:t,y:n,side:o,color:r,highlighted:i,labelStyle:s}){const a=vr.useContext(kr)??wr,c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;return(0,Tm.jsx)("text",{className:"semiotic-bump-label",x:t+("end"===o?8:-8),y:n,dy:"0.35em",textAnchor:"end"===o?"start":"end",fill:r,fillOpacity:c?.16:1,fontWeight:i?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...l},children:e.__bumpSeries})}function Bm(e,t,n){const[o,r]=t,[i,s]=n;return r===o?(i+s)/2:i+(s-i)*Math.max(0,Math.min(1,(e-o)/(r-o)))}function Em(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:void 0}function Om(e){return{value:e.__bumpValue,x:Em(e.__bumpXValue),y:e.__bumpValue,category:e.__bumpSeries}}function Fm(e){const t=e.config,n=new Map;for(const t of e.data){const e=n.get(t.__bumpSeries)??[];e.push(t),n.set(t.__bumpSeries,e)}const o=t.seriesOrder.filter(e=>n.has(e)).sort((e,o)=>(n.get(e)?.[0]?.__bumpHighlighted?1:0)-(n.get(o)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(o)),r=[],i=[];for(const s of o){const o=(n.get(s)??[]).sort((e,t)=>e.x-t.x);if(2>o.length)continue;const a=o[0].__bumpHighlighted,c=e.resolveColor(o[0].__bumpSeries,o[0]),l=t.color??(a?c:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??c),u=o.map(n=>({x:e.scales.x(n.x),y:e.scales.y(n.y),radius:t.ribbon?Bm(n.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Rm(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h=d.datumIndices.map(e=>o[e]),p={fill:l,fillOpacity:1,opacity:a?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(p,tm(o[0].__bumpRaw,t.styleRules,Om(o[0]))),t.areaStyle&&Object.assign(p,t.areaStyle(o[0].__bumpRaw)??{}),void 0!==t.stroke&&(p.stroke=t.stroke),void 0!==t.strokeWidth&&(p.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(p.opacity=t.opacity),r.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:p,datum:h,accessibleDatum:o.map(e=>e.__bumpRaw),accessibility:{label:s+" ranking trajectory",tableFields:o.map(e=>e.__bumpRaw)},group:s,interactive:!0}),t.showPoints&&o.forEach((e,n)=>{const o={fill:l,stroke:"none",opacity:a?1:.75};t.styleRules?.length&&Object.assign(o,tm(e.__bumpRaw,t.styleRules,Om(e))),t.pointStyle&&Object.assign(o,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),r.push({type:"point",x:u[n].x,y:u[n].y,r:o.r??t.pointRadius,style:o,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${s}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${s}:${e.x}`})});const m=!0===t.showLabels?"end":t.showLabels,y=(e,n,o)=>{i.push((0,Tm.jsx)($m,{datum:e,x:u[n].x,y:u[n].y,side:o,color:"string"==typeof p.fill?p.fill:l,highlighted:a,labelStyle:t.labelStyle},`${s}-${o}`))};"start"!==m&&"both"!==m||y(o[0],0,"start"),"end"!==m&&"both"!==m||y(o.at(-1),o.length-1,"end")}return{nodes:r,overlays:i.length?(0,Tm.jsx)("g",{className:"semiotic-bump-labels",children:i}):void 0,restyle:(e,t)=>{const n=function(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&n&&!t.predicate(n))return{opacity:.14}}}}var zm=(0,vm.forwardRef)(function(e,t){const n=fp(),o=Dh(),{data:r,xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c="descending",ribbon:l=!1,curve:u="smooth",ribbonSizeRange:d=[4,28],samplesPerSegment:h=12,lineWidth:p=3,highlightTop:m,neutralColor:y,styleRules:f,labelStyle:g,colorScheme:b,ribbonOpacity:v=.82,lineOpacity:x=.9,showPoints:w=!1,pointRadius:k=3,showLabels:S=!0,showAxes:A=!0,showGrid:C=!0,showLegend:M=!1,enableHover:j=!0,hoverHighlight:P=!0,tooltip:I,frameProps:R={},xFormat:T,yFormat:_,onClick:L}=e,D=(0,vm.useMemo)(()=>Nm(r,{xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c,highlightTop:m}),[r,i,s,a,c,m]),{axes:N,areaStyle:$,pointStyle:B,...E}=R,O=(0,vm.useMemo)(()=>function(e){const{seriesOrder:t,overallOrder:n,highlightTop:o,color:r,colorScheme:i,neutralColor:s,themeCategorical:a,themeNeutral:c}=e;if(null==o&&null==r)return i;const l=new Set(n.slice(0,null==o?n.length:Math.max(0,Math.floor(o)))),u=new Map,d={};for(const e of t)d[e]=r??(l.has(e)?gp(void 0,a,i,e,u):s??c??"#b8bec8");return d}({seriesOrder:D.seriesOrder,overallOrder:D.overallOrder,highlightTop:m,color:e.color,colorScheme:b,neutralColor:y,themeCategorical:n,themeNeutral:o.colors.textSecondary}),[D.seriesOrder,D.overallOrder,m,e.color,b,y,n,o.colors.textSecondary]),F=(0,vm.useMemo)(()=>({ribbon:l,curve:u,samplesPerSegment:h,ribbonSizeRange:d,valueExtent:D.valueExtent,seriesOrder:D.seriesOrder,lineWidth:p,ribbonOpacity:v,lineOpacity:x,neutralColor:y,color:e.color,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity,styleRules:f,areaStyle:$,pointStyle:B,labelStyle:g,showPoints:w,pointRadius:k,showLabels:S}),[l,u,h,d,D.valueExtent,D.seriesOrder,p,v,x,y,e.color,e.stroke,e.strokeWidth,e.opacity,f,$,B,g,w,k,S]),z=(0,vm.useCallback)((e,t)=>{if(0===D.xValues.length)return"";const n=D.xValues[Math.max(0,Math.min(D.xValues.length-1,Math.round(Number(e))))];return T?T(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},[D.xValues,T]),H=(0,vm.useCallback)(e=>_?_(e):e.toLocaleString(),[_]),W=(0,vm.useMemo)(()=>"multi"===I?void 0:cu(I),[I]),q=(0,vm.useCallback)(e=>{const t=e?.data??e;return t?!1===I?null:W?W({...e,data:t.__bumpRaw,__semioticHoverData:!0}):(0,Tm.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,Tm.jsx)("div",{style:{fontWeight:700},children:t.__bumpSeries}),(0,Tm.jsxs)("div",{children:[z(t.x)," · Rank ",t.__bumpRank]}),(0,Tm.jsxs)("div",{children:["Value: ",H(t.__bumpValue)]})]}):null},[H,z,W,I]),G=(0,vm.useMemo)(()=>{if(L)return(e,t)=>{L(e.__bumpRaw??e,t)}},[L]),Y=Math.max(1,D.seriesOrder.length),V=D.xValues.map((e,t)=>t),X=Array.from({length:Y},(e,t)=>t+1),U=N??[{orient:"left",tickValues:X,tickFormat:e=>e+"",label:e.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:V,tickFormat:z,label:e.xLabel,tickAnchor:"edges"}],K=(0,vm.useMemo)(()=>function(e,t){if(!e?.length)return;const n=new Map(t.map((e,t)=>[Dm(e),t]));return e.map(e=>{const t={...e},o=o=>{if(!(o in e))return;const r=n.get(Dm(e[o]));void 0!==r&&(t[o]=r)};return o("x"),o("x0"),o("x1"),"string"!=typeof e.type||"x-threshold"!==e.type&&"x"!==e.type||o("value"),t})}(e.annotations,D.xValues),[e.annotations,D.xValues]);return(0,Tm.jsx)(Mm,{ref:t,data:D.data,layout:Fm,layoutConfig:F,xExtent:[0,Math.max(1,D.xValues.length-1)],yExtent:[Y+.5,.5],showAxes:A,showGrid:C,showLegend:M,enableHover:j,hoverHighlight:P,colorBy:"__bumpSeries",colorScheme:O,tooltip:q,onClick:G,hoverRadius:e.hoverRadius,width:e.width,height:e.height,responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,responsiveRules:e.responsiveRules,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,mode:e.mode,margin:e.margin??{top:20,right:S?110:24,bottom:48,left:48},className:e.className,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,selection:e.selection,linkedHover:e.linkedHover,legend:e.legend,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,onObservation:e.onObservation,chartId:e.chartId,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations,annotations:K,xLabel:e.xLabel,yLabel:e.yLabel??"Rank",frameProps:{axes:U,axisExtent:"exact",...E}})});zm.displayName="BumpChart";var Hm=require("react"),Wm=require("react");function qm(e){const{safeData:t,data:n,areaBy:o,lineDataAccessor:r,colorBy:i,colorScale:s,color:a,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,areaOpacity:p,showLine:m,lineWidth:y,showPoints:f,pointRadius:g,xAccessor:b,yAccessor:v,xLabel:x,yLabel:w,xFormat:k,yFormat:S,groupField:A,styleRules:C,ruleContext:M}=e,j=(0,Wm.useMemo)(()=>function({data:e,safeData:t,areaBy:n,lineDataAccessor:o}){if(null==e)return[];const r=void 0!==t[0]?.[o];if(!r&&!n)return t;let i;if(r)i=t;else{const e=t.reduce((e,t)=>{const r="function"==typeof n?n(t):t[n],i=r+"";if(!e[i]){const t={[o]:[]};"string"==typeof n&&(t[n]=r),e[i]=t}return e[i][o].push(t),e},{});i=Object.values(e)}return i.flatMap(e=>{const t=Array.isArray(e[o])?e[o]:[];return"string"==typeof n?t.map(t=>({...t,[n]:t[n]??e[n]})):t})}({data:n,safeData:t,areaBy:o,lineDataAccessor:r}),[n,t,o,r]),P=(0,Wm.useMemo)(()=>e=>{const t={};if(i){if(s){const n=Pn(e,i,s);t.fill=n,m?(t.stroke=n,t.strokeWidth=y):t.stroke="none"}}else{const e=a||Sn;t.fill=e,m?(t.stroke=e,t.strokeWidth=y):t.stroke="none"}return t.fillOpacity=p,C&&C.length>0&&Object.assign(t,tm(e,C,M?M(e):{value:void 0})),t},[i,s,a,p,m,y,C,M]),I=(0,Wm.useMemo)(()=>Up(P,{stroke:c,strokeWidth:l,opacity:u}),[P,c,l,u]);return{flattenedData:j,lineStyle:(0,Wm.useMemo)(()=>uh(I,d??null,h),[I,d,h]),pointStyle:(0,Wm.useMemo)(()=>{if(f)return e=>{const t={r:g,fillOpacity:1};return i?s&&(t.fill=Pn(e.parentLine||e,i,s)):t.fill=a||Sn,t}},[f,g,i,s,a]),defaultTooltipContent:(0,Wm.useMemo)(()=>Pd([{label:x||Sd(b),accessor:b,role:"x",format:k},{label:w||Sd(v),accessor:v,role:"y",format:S},...A?[{label:Sd(A),accessor:A,role:"group"}]:[],...jd(e.band,S)]),[b,v,x,w,A,k,S,e.band])}}var Gm=require("react/jsx-runtime"),Ym=(0,Hm.forwardRef)(function(e,t){const n=(0,Hm.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",areaBy:d,y0Accessor:h,gradientFill:p=!1,semanticGradient:m,semanticLine:y=!0,lineDataAccessor:f="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:j,annotations:P,forecast:I,anomaly:R,band:T,xExtent:_,yExtent:L,frameProps:D={},selection:N,linkedHover:$,onObservation:B,onClick:E,hoverHighlight:O,chartId:F,loading:z,loadingContent:H,emptyContent:W,legendInteraction:q,legendPosition:G,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:se}=o,ae=(0,Hm.useMemo)(()=>ft(r),[r]),ce=g||d,le=(0,Hm.useMemo)(()=>function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:n})=>({offset:e/100,color:t,...null!=n&&{opacity:n}}))}:Array.isArray(e.stops)?e:void 0}(m),[m]),ue=(0,Hm.useMemo)(()=>le?.stops.length?{stops:le.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:ao(p),[le,p]),de=(0,Hm.useMemo)(()=>co(k),[k]),he=(0,Hm.useMemo)(()=>y&&le?.stops.length?le.stops.flatMap(({offset:e,color:t})=>t?[{offset:e,color:t}]:[]):void 0,[le,y]);Np("AreaChart",ae,"xAccessor",l),Np("AreaChart",ae,"yAccessor",u);const pe=Vp({data:ae,rawData:r,colorBy:ce,colorScheme:b,legendInteraction:q,legendPosition:G,selection:N,linkedHover:$,fallbackFields:ce?["string"==typeof ce?ce:""]:[],unwrapData:!1,onObservation:B,onClick:E,hoverHighlight:O,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"AreaChart",chartId:F,showLegend:ee,userMargin:i,marginDefaults:o.marginDefaults,loading:z,loadingContent:H,emptyContent:W,width:K,height:Q,hasTitle:!!te,axisChrome:es({showAxes:o.showAxes,xLabel:ie})}),{effectiveData:me,statisticalAnnotations:ye}=ym({data:ae,xAccessor:l,yAccessor:u,forecast:I,anomaly:R,groupBy:d}),fe=(0,Hm.useMemo)(()=>Qp(l,u),[l,u]),{flattenedData:ge,lineStyle:be,pointStyle:ve,defaultTooltipContent:xe}=qm({safeData:me,data:r,areaBy:d,lineDataAccessor:f,colorBy:ce,colorScale:pe.colorScale,color:Y,stroke:V,strokeWidth:X,opacity:U,effectiveSelectionHook:pe.effectiveSelectionHook,resolvedSelection:pe.resolvedSelection,areaOpacity:w,showLine:S,lineWidth:A,showPoints:C,pointRadius:M,xAccessor:l,yAccessor:u,xLabel:ie,yLabel:se,xFormat:a,yFormat:c,groupField:d||g,band:T,styleRules:v,ruleContext:fe}),we=zp({componentName:"AreaChart",data:r,accessors:{xAccessor:l,yAccessor:u}}),ke={chartType:"area",...null!=r&&{data:ge},xAccessor:l,yAccessor:u,groupAccessor:d||void 0,...h&&{y0Accessor:h},...T&&{band:T},...ue&&{gradientFill:ue},...de&&{lineGradient:de},...he&&{semanticLineStops:he},curve:x,lineStyle:be,...C&&ve&&{pointStyle:ve},size:[K,Q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:pe.margin,showAxes:o.showAxes,xLabel:ie,yLabel:se,xFormat:a,yFormat:c,enableHover:Z,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:J,...pe.legendBehaviorProps,...sm({title:te,description:ne,summary:oe,accessibleTable:re,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...su({tooltip:j,defaultTooltipContent:xe,multiDefaultContent:au()}),...am({linkedHover:$,selection:N,onObservation:B,onClick:E,hoverHighlight:O,mobileInteraction:pe.mobileInteraction,customHoverBehavior:pe.customHoverBehavior,customClickBehavior:pe.customClickBehavior}),...(P&&P.length>0||ye.length>0)&&{annotations:[...P||[],...ye]},..._&&{xExtent:_},...L&&{yExtent:L},...pe.crosshairProps,...D};return pe.earlyReturn?pe.earlyReturn:we?(0,Gm.jsx)(Ap,{componentName:"AreaChart",message:we,width:K,height:Q}):(0,Gm.jsx)(Rp,{componentName:"AreaChart",width:K,height:Q,children:(0,Gm.jsx)(th,{ref:n,...ke})})});Ym.displayName="AreaChart";var Vm=require("react"),Xm=require("react/jsx-runtime");function Um(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 Km=(0,Vm.forwardRef)(function(e,t){const n=(0,Vm.useRef)(null),o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",seriesAAccessor:u="a",seriesBAccessor:d="b",seriesALabel:h="A",seriesBLabel:p="B",seriesAColor:m="var(--semiotic-danger, #dc2626)",seriesBColor:y="var(--semiotic-info, #2563eb)",showLines:f=!0,lineWidth:g=1.5,showPoints:b=!1,pointRadius:v=3,curve:x="linear",areaOpacity:w=.6,gradientFill:k,tooltip:S,annotations:A,xExtent:C,yExtent:M,frameProps:j={},selection:P,linkedHover:I,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:D,loadingContent:N,emptyContent:$,legendInteraction:B,legendPosition:E,pointIdAccessor:O,windowSize:F}=e,{width:z,height:H,enableHover:W,showGrid:q,showLegend:G,title:Y,description:V,summary:X,accessibleTable:U,xLabel:K,yLabel:Q}=o,Z=(0,Vm.useMemo)(()=>"function"==typeof l?e=>Um(l(e)):e=>Um(e[l]),[l]),J=(0,Vm.useMemo)(()=>"function"==typeof u?e=>Um(u(e)):e=>Um(e[u]),[u]),ee=(0,Vm.useMemo)(()=>"function"==typeof d?e=>Um(d(e)):e=>Um(e[d]),[d]),[te,ne]=(0,Vm.useState)([]),oe=(0,Vm.useRef)([]),re=null==r,ie=(0,Vm.useMemo)(()=>ft(re?te:r),[re,te,r]),se=(0,Vm.useMemo)(()=>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 s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${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),y=n(i),f=o(i);if(!Number.isFinite(m)||!Number.isFinite(y)||!Number.isFinite(f))continue;const g=u(y,f);if(null!==g)if(null!=a){if(c&&c.w!==g){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const n=y-c.a-(f-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*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=g,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)p(l[e],a)}else for(const e of l)p(e,a);l=[],h({__x:m,__y:f>y?f:y,__y0:f>y?y:f,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:f,__sourceDatum:i}),c={x:m,a:y,b:f,w:g}}else{a=g;for(const e of l)p(e,a);l=[],h({__x:m,__y:f>y?f:y,__y0:f>y?y:f,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:f,__sourceDatum:i}),c={x:m,a:y,b:f,w:g}}else l.push({x:m,y:y,datum:i})}for(const e of l)p(e,a??"A");return i}(ie,Z,J,ee),[ie,Z,J,ee]),ae=(0,Vm.useMemo)(()=>f?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),s=n(e),a=o(e);Number.isFinite(s)&&i.push({__x:r,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&i.push({__x:r,__y:a,__diffSegment:"line-B"})}return i}(ie,Z,J,ee):[],[f,ie,Z,J,ee]),ce=(0,Vm.useMemo)(()=>[...se,...ae],[se,ae]),le=(0,Vm.useMemo)(()=>{const e=new Set;for(const t of se)e.add(t.__diffSegment);return Array.from(e)},[se]);(0,Vm.useImperativeHandle)(t,()=>{const e=e=>{const t=F&&e.length>F?e.slice(e.length-F):e;oe.current=t,ne(t)},t=O?"function"==typeof O?O:e=>e[O]:null;return{push:t=>e([...oe.current,t]),pushMany:t=>e([...oe.current,...t]),remove:n=>{if(!t)return[];const o=Array.isArray(n)?n:[n],r=[],i=[];for(const e of oe.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=[],s=oe.current.map(e=>{if(r.includes(t(e))){const t=o(e);return i.push(t),t}return e});return e(s),i},clear:()=>e([]),getData:()=>re?oe.current:ie,getScales:()=>n.current?.getScales()??null}},[re,ie,O,F]);const ue=Vp({data:ie,rawData:r,colorBy:"__diffWinner",colorScheme:[m,y],legendInteraction:B,legendPosition:E,selection:P,linkedHover:I,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"DifferenceChart",chartId:L,showLegend:G,userMargin:i,marginDefaults:o.marginDefaults,loading:D,loadingContent:N,emptyContent:$,width:z,height:H,hasTitle:!!Y,axisChrome:es({showAxes:o.showAxes,xLabel:K})}),de=(0,Vm.useMemo)(()=>{if(!1!==G)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:h,color:m},{label:p,color:y}]}]}},[G,h,p,m,y]),he=(0,Vm.useCallback)(e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?m:y,stroke:"none",fillOpacity:w}},[m,y,w]),pe=(0,Vm.useCallback)(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?m:y,strokeWidth:g,fill:"none"}),[m,y,g]),me=(0,Vm.useCallback)(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?m:y,r:v}),[m,y,v]),ye=(0,Vm.useCallback)(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=ie.find(e=>Z(e)===o);e&&(null==r&&(r=J(e)),null==i&&(i=ee(e)))}const s=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",c=a&&null!=o?a(o):null!=o?o+"":"";return(0,Xm.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[c&&(0,Xm.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:c}),(0,Xm.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Xm.jsx)("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),(0,Xm.jsxs)("span",{children:[h,": ",s(r)]})]}),(0,Xm.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Xm.jsx)("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),(0,Xm.jsxs)("span",{children:[p,": ",s(i)]})]}),null!=r&&null!=i&&Number.isFinite(r)&&Number.isFinite(i)&&(0,Xm.jsxs)("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(r-i)]})]})},[ie,Z,J,ee,a,m,y,h,p]),{tooltipContent:fe,tooltipMode:ge}=(0,Vm.useMemo)(()=>su({tooltip:S,defaultTooltipContent:ye,multiDefaultContent:ye}),[S,ye]),be=(0,Vm.useMemo)(()=>ao(k,{stops:[{offset:0,opacity:.85},{offset:1,opacity:.15}]}),[k]);if(ue.earlyReturn)return ue.earlyReturn;const ve={chartType:"mixed",data:ce,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:le,curve:x,areaStyle:he,lineStyle:pe,...b&&{pointStyle:me},size:[z,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ue.margin,showAxes:o.showAxes,xLabel:K,yLabel:Q,xFormat:a,yFormat:c,enableHover:W,showGrid:q,...be&&{gradientFill:be},...de&&{legend:de,legendPosition:ue.legendPosition},...sm({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:fe,..."multi"===ge&&{tooltipMode:"multi"},...am({linkedHover:I,selection:P,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:ue.mobileInteraction,customHoverBehavior:ue.customHoverBehavior,customClickBehavior:ue.customClickBehavior}),...A&&A.length>0&&{annotations:A},...C&&{xExtent:C},...M&&{yExtent:M},...ue.crosshairProps,...j};return(0,Xm.jsx)(Rp,{componentName:"DifferenceChart",width:z,height:H,children:(0,Xm.jsx)(th,{ref:n,...ve})})});"function"==typeof Km&&(Km.displayName="DifferenceChart");var Qm=require("react"),Zm=require("react/jsx-runtime"),Jm=(0,Qm.forwardRef)(function(e,t){const n=(0,Qm.useRef)(null),o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",areaBy:d,lineDataAccessor:h="coordinates",colorBy:p,colorScheme:m,styleRules:y,curve:f="monotoneX",areaOpacity:g=.7,showLine:b=!0,lineWidth:v=2,showPoints:x=!1,pointRadius:w=3,normalize:k=!1,baseline:S="zero",stackOrder:A,tooltip:C,annotations:M,xExtent:j,yExtent:P,frameProps:I={},selection:R,linkedHover:T,onObservation:_,onClick:L,hoverHighlight:D,chartId:N,loading:$,loadingContent:B,emptyContent:E,legendInteraction:O,legendPosition:F,color:z,stroke:H,strokeWidth:W,opacity:q}=e,{width:G,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=o,ne=(0,Qm.useMemo)(()=>ft(r),[r]),oe=p||d;im(t,{variant:"xy",frameRef:n});const re=Vp({data:ne,rawData:r,colorBy:oe,colorScheme:m,legendInteraction:O,legendPosition:F,selection:R,linkedHover:T,fallbackFields:oe?["string"==typeof oe?oe:""]:[],unwrapData:!1,onObservation:_,onClick:L,hoverHighlight:D,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"StackedAreaChart",chartId:N,showLegend:U,userMargin:i,marginDefaults:o.marginDefaults,loading:$,loadingContent:B,emptyContent:E,width:G,height:Y,hasTitle:!!K,axisChrome:es({showAxes:o.showAxes,xLabel:ee})}),ie=(0,Qm.useMemo)(()=>Qp(l,u),[l,u]),{flattenedData:se,lineStyle:ae,pointStyle:ce,defaultTooltipContent:le}=qm({safeData:ne,data:r,areaBy:d,lineDataAccessor:h,colorBy:oe,colorScale:re.colorScale,color:z,stroke:H,strokeWidth:W,opacity:q,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection,areaOpacity:g,showLine:b,lineWidth:v,showPoints:x,pointRadius:w,xAccessor:l,yAccessor:u,xLabel:ee,yLabel:te,xFormat:a,yFormat:c,groupField:d||p,styleRules:y,ruleContext:ie}),ue=zp({componentName:"StackedAreaChart",data:r,accessors:{xAccessor:l,yAccessor:u}}),de={chartType:"stackedarea",...null!=r&&{data:se},xAccessor:l,yAccessor:u,groupAccessor:d||void 0,curve:f,normalize:k,baseline:k?"zero":S,stackOrder:A,lineStyle:ae,...x&&ce&&{pointStyle:ce},size:[G,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:re.margin,showAxes:o.showAxes,xLabel:ee,yLabel:te,xFormat:a,yFormat:c,enableHover:V,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:X,...re.legendBehaviorProps,...sm({title:K,description:Q,summary:Z,accessibleTable:J,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...su({tooltip:C,defaultTooltipContent:le,multiDefaultContent:au()}),...am({linkedHover:T,selection:R,onObservation:_,onClick:L,hoverHighlight:D,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...M&&M.length>0&&{annotations:M},...j&&{xExtent:j},...P&&{yExtent:P},...re.crosshairProps,...I};return re.earlyReturn?re.earlyReturn:ue?(0,Zm.jsx)(Ap,{componentName:"StackedAreaChart",message:ue,width:G,height:Y}):(0,Zm.jsx)(Rp,{componentName:"StackedAreaChart",width:G,height:Y,children:(0,Zm.jsx)(th,{ref:n,...de})})});Jm.displayName="StackedAreaChart";var ey=d(require("react")),ty=require("react"),ny=require("react");function oy(e){const{colorBy:t,colorScale:n,color:o,pointRadius:r=5,radiusFn:i,fillOpacity:s=1,fallbackFill:a,baseStyleExtras:c,stroke:l,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:p,colorDatumAccessor:m,styleRules:y,ruleContext:f}=e,g=(0,ny.useMemo)(()=>e=>{const l="function"==typeof c?c(e):c,u=l?{...l}:{};if(void 0===u.fillOpacity&&(u.fillOpacity=s),void 0===u.fill)if(t){if(n){const o=m?m(e):e;u.fill=Pn(o,t,n)}}else u.fill=a?a(e):o||Sn;return void 0===u.r&&(u.r=i?i(e):r),y&&y.length>0&&Object.assign(u,tm(e,y,f?f(e):{value:void 0})),u},[t,n,o,r,i,s,a,c,m,y,f]),b=(0,ny.useMemo)(()=>Up(g,{stroke:l,strokeWidth:u,opacity:d}),[g,l,u,d]);return(0,ny.useMemo)(()=>uh(b,h??null,p),[b,h,p])}var ry=require("react");function iy(e){const{accessor:t,data:n,isPushMode:o}=e,r=(0,ry.useRef)(null),[i,s]=(0,ry.useState)(0),a=(0,ry.useCallback)(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&&s(e=>e+1)},[o,t]),c=(0,ry.useCallback)(()=>{o&&(r.current=null,s(e=>e+1))},[o]);return{domain:(0,ry.useMemo)(()=>{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,s=-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>s&&(s=o))}return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:void 0},[n,t,o,i]),trackPushed:a,reset:c}}function sy(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}}}var ay=require("react/jsx-runtime"),cy=(0,ty.forwardRef)(function(e,t){const n=(0,ty.useRef)(null),o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",xScaleType:d,yScaleType:h,colorBy:p,colorScheme:m,styleRules:y,sizeBy:f,sizeRange:g=[3,15],symbolBy:b,symbolMap:v,pointRadius:x=5,pointOpacity:w=.8,tooltip:k,marginalGraphics:S,pointIdAccessor:A,annotations:C,regression:M,forecast:j,anomaly:P,xExtent:I,yExtent:R,frameProps:T={},selection:_,linkedHover:L,linkedBrush:D,onObservation:N,onClick:$,hoverHighlight:B,chartId:E,loading:O,loadingContent:F,emptyContent:z,legendInteraction:H,legendPosition:W,color:q,stroke:G,strokeWidth:Y,opacity:V}=e,{width:X,height:U,enableHover:K,showGrid:Q,showLegend:Z,title:J,description:ee,summary:te,accessibleTable:ne,xLabel:oe,yLabel:re}=o,ie=(0,ty.useMemo)(()=>ft(r),[r]),se=void 0===r,{domain:ae,trackPushed:ce,reset:le}=iy({accessor:f,data:ie,isPushMode:se}),ue=(0,ty.useCallback)(e=>{ce([e]),n.current?.push(e)},[ce]),de=(0,ty.useCallback)(e=>{ce(e),n.current?.pushMany(e)},[ce]);im(t,{variant:"xy",frameRef:n,overrides:{push:ue,pushMany:de,clear:()=>{le(),n.current?.clear()}}});const he=Vp({data:ie,rawData:r,colorBy:p,colorScheme:m,legendInteraction:H,legendPosition:W,selection:_,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:N,onClick:$,hoverHighlight:B,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"Scatterplot",chartId:E,showLegend:Z,userMargin:i,marginDefaults:o.marginDefaults,loading:O,loadingContent:F,emptyContent:z,width:X,height:U,hasTitle:!!J,axisChrome:es({showAxes:o.showAxes,xLabel:oe})}),pe=ch(D),me=kh({name:pe?.name||"__unused_brush__",xField:pe?.xField||("string"==typeof l?l:void 0),yField:pe?.yField||("string"==typeof u?u:void 0)}),ye=pe?"xyBrush"===me.brushInteraction.brush?"xy":"xBrush"===me.brushInteraction.brush?"x":"y":void 0,fe=ey.useRef(me.brushInteraction);fe.current=me.brushInteraction;const ge=(0,ty.useCallback)(e=>{const t=fe.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)},[]);Np("Scatterplot",ie,"xAccessor",l),Np("Scatterplot",ie,"yAccessor",u);const be=(0,ty.useMemo)(()=>f?ae??[0,1]:void 0,[f,ae]),ve=(0,ty.useMemo)(()=>f?e=>Tn(e,f,g,be):void 0,[f,g,be]),xe=(0,ty.useMemo)(()=>Qp(l,u),[l,u]),we=oy({colorBy:p,colorScale:he.colorScale,color:q,pointRadius:x,fillOpacity:w,radiusFn:ve,stroke:G,strokeWidth:Y,opacity:V,styleRules:y,ruleContext:xe,effectiveSelectionHook:he.effectiveSelectionHook,resolvedSelection:he.resolvedSelection}),ke=(0,ty.useMemo)(()=>Pd([{label:oe||Sd(l),accessor:l,role:"x",format:a},{label:re||Sd(u),accessor:u,role:"y",format:c},...p?[{label:Sd(p),accessor:p,role:"color"}]:[],...f?[{label:Sd(f),accessor:f,role:"size"}]:[]]),[l,u,oe,re,p,f,a,c]),{effectiveData:Se,statisticalAnnotations:Ae}=ym({data:ie,xAccessor:l,yAccessor:u,forecast:j,anomaly:P}),Ce=(0,ty.useMemo)(()=>{const e=sy(M);return e||0!==Ae.length?[...e?[e]:[],...C||[],...Ae]:C},[M,C,Ae]);if(he.earlyReturn)return he.earlyReturn;const Me=zp({componentName:"Scatterplot",data:r,accessors:{xAccessor:l,yAccessor:u}});if(Me)return(0,ay.jsx)(Ap,{componentName:"Scatterplot",message:Me,width:X,height:U});const je={chartType:"scatter",...null!=r&&{data:Se},xAccessor:l,yAccessor:u,xScaleType:d,yScaleType:h,colorAccessor:p||void 0,sizeAccessor:f||void 0,...b&&{symbolAccessor:b},...v&&{symbolMap:v},sizeRange:g,pointStyle:we,colorScheme:m,size:[X,U],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:he.margin,showAxes:o.showAxes,xLabel:oe,yLabel:re,xFormat:a,yFormat:c,enableHover:K,showGrid:Q,...he.legendBehaviorProps,...sm({title:J,description:ee,summary:te,accessibleTable:ne,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:k,defaultTooltipContent:ke}),...am({linkedHover:L,selection:_,onObservation:N,onClick:$,hoverHighlight:B,mobileInteraction:he.mobileInteraction,customHoverBehavior:he.customHoverBehavior,customClickBehavior:he.customClickBehavior}),...S&&{marginalGraphics:S},...A&&{pointIdAccessor:A},...Ce&&Ce.length>0&&{annotations:Ce},...I&&{xExtent:I},...R&&{yExtent:R},...pe&&{brush:{dimension:ye},onBrush:ge},...he.crosshairProps,...T};return(0,ay.jsx)(Rp,{componentName:"Scatterplot",width:X,height:U,children:(0,ay.jsx)(th,{ref:n,...je})})});cy.displayName="Scatterplot";var ly=require("react"),uy=require("react/jsx-runtime");function dy(e,t){return sn(1===t?.5:e/(t-1))}var hy=(0,ly.forwardRef)(function(e,t){const n=(0,ly.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",orderAccessor:d,orderLabel:h,styleRules:p,pointRadius:m=4,tooltip:y,pointIdAccessor:f,annotations:g,regression:b,forecast:v,anomaly:x,xExtent:w,yExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:j,hoverHighlight:P,chartId:I,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,stroke:D,strokeWidth:N,opacity:$}=e,{width:B,height:E,enableHover:O,showGrid:F,title:z,description:H,summary:W,accessibleTable:q,xLabel:G,yLabel:Y}=o,{safeData:V,orderMap:X}=(0,ly.useMemo)(()=>{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 s=0;for(const e of o){const o=t(e),r=n(e);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&s++}let a=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:a++,total:s})}return{safeData:o,orderMap:i}},[r,d,l,u]);Np("ConnectedScatterplot",V,"xAccessor",l),Np("ConnectedScatterplot",V,"yAccessor",u);const U=Vp({data:V,rawData:r,colorBy:void 0,colorScheme:void 0,legendInteraction:L,selection:A,linkedHover:C,fallbackFields:[],unwrapData:!1,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ConnectedScatterplot",chartId:I,showLegend:void 0,userMargin:i,marginDefaults:o.marginDefaults,loading:R,loadingContent:T,emptyContent:_,width:B,height:E,hasTitle:!!z,axisChrome:es({showAxes:o.showAxes,xLabel:G})}),K=U.resolvedSelection?.unselectedOpacity??lh,Q=(0,ly.useMemo)(()=>(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,s=n.length;e.lineCap="round";for(let t=0;s-1>t;t++){const a=n[t],c=n[t+1],l=dy(t,s),u=!o||!r||r(a.datum??a)||r(c.datum??c),d=o?u?1:K:1;i&&(e.beginPath(),e.moveTo(a.x,a.y),e.lineTo(c.x,c.y),e.strokeStyle="white",e.lineWidth=m+2,e.globalAlpha=.5*d,e.stroke()),e.beginPath(),e.moveTo(a.x,a.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=(0,ly.useMemo)(()=>[Q],[Q]),J=(0,ly.useMemo)(()=>(e,t,n)=>{const o=e.filter(e=>"point"===e.type);if(2>o.length)return null;const r=o.length,i=100>r,s=[];for(let e=0;r-1>e;e++){const t=o[e],n=o[e+1],a=dy(e,r),c=Math.min("number"==typeof t.style?.opacity?t.style.opacity:1,"number"==typeof n.style?.opacity?n.style.opacity:1);i&&s.push((0,uy.jsx)("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)),s.push((0,uy.jsx)("line",{x1:t.x,y1:t.y,x2:n.x,y2:n.y,stroke:a,strokeWidth:m,strokeLinecap:"round",opacity:c},"seg-"+e))}return(0,uy.jsx)(uy.Fragment,{children:s})},[m]),ee=(0,ly.useMemo)(()=>[J],[J]),te=oy({colorScale:void 0,baseStyleExtras:(0,ly.useMemo)(()=>e=>{const t=X.get(e),n=t?.idx??0,o=t?.total??1;return{fill:o>0?dy(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,X]),stroke:D,strokeWidth:N,opacity:$,styleRules:p,ruleContext:(0,ly.useMemo)(()=>Qp(l,u),[l,u]),effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection}),ne=h||("string"==typeof d?d:"Order"),oe=(0,ly.useMemo)(()=>Pd([{label:G||Sd(l),accessor:l,role:"x",format:a},{label:Y||Sd(u),accessor:u,role:"y",format:c},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[l,u,G,Y,d,ne,a,c]),re=zp({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:l,yAccessor:u}}),{effectiveData:ie,statisticalAnnotations:se}=ym({data:V,xAccessor:l,yAccessor:u,forecast:v,anomaly:x});if(U.earlyReturn)return U.earlyReturn;const ae=sy(b),ce=ae||se.length>0?[...ae?[ae]:[],...g||[],...se]:g,le={chartType:"scatter",...null!=r&&{data:ie},xAccessor:l,yAccessor:u,pointStyle:te,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,showAxes:o.showAxes,xLabel:G,yLabel:Y,xFormat:a,yFormat:c,enableHover:O,showGrid:F,...sm({title:z,description:H,summary:W,accessibleTable:q,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:y,defaultTooltipContent:oe}),...am({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...f&&{pointIdAccessor:f},canvasPreRenderers:Z,svgPreRenderers:ee,...ce&&ce.length>0&&{annotations:ce},...w&&{xExtent:w},...k&&{yExtent:k},...U.crosshairProps,...S};return re?(0,uy.jsx)(Ap,{componentName:"ConnectedScatterplot",message:re,width:B,height:E}):(0,uy.jsx)(Rp,{componentName:"ConnectedScatterplot",width:B,height:E,children:(0,uy.jsx)(th,{ref:n,...le})})});hy.displayName="ConnectedScatterplot";var py=require("react"),my=require("react/jsx-runtime"),yy=(0,py.forwardRef)(function(e,t){const n=(0,py.useRef)(null),o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",sizeBy:d,sizeRange:h=[5,40],colorBy:p,colorScheme:m,styleRules:y,bubbleOpacity:f=.6,bubbleStrokeWidth:g=1,bubbleStrokeColor:b="white",tooltip:v,marginalGraphics:x,pointIdAccessor:w,annotations:k,regression:S,xExtent:A,yExtent:C,frameProps:M={},selection:j,linkedHover:P,linkedBrush:I,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:D,loadingContent:N,emptyContent:$,legendInteraction:B,legendPosition:E,color:O,stroke:F,strokeWidth:z,opacity:H}=e,{width:W,height:q,enableHover:G,showGrid:Y,showLegend:V,title:X,description:U,summary:K,accessibleTable:Q,xLabel:Z,yLabel:J}=o,ee=(0,py.useMemo)(()=>ft(r),[r]),te=void 0===r,ne=Vp({data:ee,rawData:r,colorBy:p,colorScheme:m,legendInteraction:B,legendPosition:E,selection:j,linkedHover:P,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"BubbleChart",chartId:L,showLegend:V,userMargin:i,marginDefaults:o.marginDefaults,loading:D,loadingContent:N,emptyContent:$,width:W,height:q,hasTitle:!!X,axisChrome:es({showAxes:o.showAxes,xLabel:Z})}),{domain:oe,trackPushed:re,reset:ie}=iy({accessor:d,data:ee,isPushMode:te}),se=(0,py.useCallback)(e=>{re([e]),n.current?.push(e)},[re]),ae=(0,py.useCallback)(e=>{re(e),n.current?.pushMany(e)},[re]);im(t,{variant:"xy",frameRef:n,overrides:{push:se,pushMany:ae,clear:()=>{ie(),n.current?.clear()}}});const ce=ch(I),le=(kh({name:ce?.name||"__unused_brush__",xField:ce?.xField||("string"==typeof l?l:void 0),yField:ce?.yField||("string"==typeof u?u:void 0)}),(0,py.useMemo)(()=>({stroke:b,strokeWidth:g}),[b,g])),ue=(0,py.useMemo)(()=>oe??[0,1],[oe]),de=(0,py.useCallback)(e=>Tn(e,d,h,ue),[d,h,ue]),he=(0,py.useMemo)(()=>Qp(l,u),[l,u]),pe=oy({colorBy:p,colorScale:ne.colorScale,color:O,fillOpacity:f,radiusFn:de,baseStyleExtras:le,stroke:F,strokeWidth:z,opacity:H,styleRules:y,ruleContext:he,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection}),me=(0,py.useMemo)(()=>Pd([{label:Z||Sd(l),accessor:l,role:"x",format:a},{label:J||Sd(u),accessor:u,role:"y",format:c},{label:Sd(d),accessor:d,role:"size"},...p?[{label:Sd(p),accessor:p,role:"color"}]:[]]),[l,u,Z,J,d,p,a,c]);if(ne.earlyReturn)return ne.earlyReturn;const ye=zp({componentName:"BubbleChart",data:r,accessors:{xAccessor:l,yAccessor:u},requiredProps:{sizeBy:d}});if(ye)return(0,my.jsx)(Ap,{componentName:"BubbleChart",message:ye,width:W,height:q});const fe=sy(S),ge=fe?[fe,...k||[]]:k,be={chartType:"bubble",...null!=r&&{data:ee},xAccessor:l,yAccessor:u,colorAccessor:p||void 0,sizeAccessor:d,sizeRange:h,pointStyle:pe,colorScheme:m,size:[W,q],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ne.margin,showAxes:o.showAxes,xLabel:Z,yLabel:J,xFormat:a,yFormat:c,enableHover:G,showGrid:Y,...ne.legendBehaviorProps,...sm({title:X,description:U,summary:K,accessibleTable:Q,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:v,defaultTooltipContent:me}),...am({linkedHover:P,selection:j,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:ne.mobileInteraction,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior}),...x&&{marginalGraphics:x},...w&&{pointIdAccessor:w},...ge&&ge.length>0&&{annotations:ge},...A&&{xExtent:A},...C&&{yExtent:C},...ne.crosshairProps,...M};return(0,my.jsx)(Rp,{componentName:"BubbleChart",width:W,height:q,children:(0,my.jsx)(th,{ref:n,...be})})});yy.displayName="BubbleChart";var fy=require("react"),gy=require("d3-scale");T();var by=require("react/jsx-runtime"),vy=(0,fy.forwardRef)(function(e,t){const n=(0,fy.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:r,margin:i,className:s,xAccessor:a="x",yAccessor:c="y",valueAccessor:l="value",xFormat:u,yFormat:d,colorScheme:h,customColorScale:p,showValues:m=!1,valueFormat:y,cellBorderColor:f="#fff",cellBorderWidth:g=1,tooltip:b,annotations:v,xExtent:x,yExtent:w,frameProps:k={},selection:S,linkedHover:A,onObservation:C,onClick:M,hoverHighlight:j,chartId:I,loading:R,loadingContent:T,emptyContent:_,showLegend:L,legendPosition:D,legend:N,legendInteraction:$}=e,{width:B,height:E,enableHover:O,title:F,description:z,summary:H,accessibleTable:W,xLabel:q,yLabel:G}=o,Y=Dp(R,B,E,T),V=Y?null:Lp(r,B,E,_),X=(0,fy.useMemo)(()=>ft(r),[r]),U=function(){const e=Dh();return e?.colors?.sequential||void 0}(),K=h??U??"blues",Q=L??!1,Z=D??"right",{customHoverBehavior:J,customClickBehavior:ee,crosshairSourceId:te}=xp({selection:S,linkedHover:A,fallbackFields:[],onObservation:C,onClick:M,chartType:"Heatmap",chartId:I,hoverHighlight:j,colorByField:void 0,mobileInteraction:o.mobileInteraction});Yp(S);const ne=wp(A,te);mp($,void 0,[]);const oe=(0,fy.useMemo)(()=>"function"==typeof l?e=>l(e):e=>e[l],[l]),re=(0,fy.useMemo)(()=>P(X.map(oe)),[X,oe]),ie=(0,fy.useMemo)(()=>{if("custom"===K&&p)return p;const e=pn(K);return(0,gy.scaleSequential)(e).domain(re)},[K,p,re]),se=(0,fy.useMemo)(()=>{const e=Number.isFinite(g)?Math.max(0,g):1;return()=>({stroke:f,strokeWidth:e})},[f,g]),ae=(0,fy.useMemo)(()=>Pd([{label:q||Sd(a),accessor:a,role:"x",format:u},{label:G||Sd(c),accessor:c,role:"y",format:d},{label:Sd(l),accessor:l,role:"value",format:y}]),[a,c,q,G,l,u,d,y]),ce=zp({componentName:"Heatmap",data:r,accessors:{xAccessor:a,yAccessor:c,valueAccessor:l}}),le=(0,fy.useMemo)(()=>{if(Q)return{gradient:{colorFn:e=>ie(e),domain:re,label:"string"==typeof l?l:"value",format:y},legendDistance:N?.legendDistance}},[Q,ie,re,l,y,N?.legendDistance]),{margin:ue}=pp({data:[],colorBy:void 0,colorScale:void 0,showLegend:!1,legendPosition:Z,userMargin:i,defaults:o.marginDefaults,additionalLegend:le,chartWidth:B,legendLayout:k.legendLayout,hasTitle:!!F,axisChrome:{hasAxis:!1!==o.showAxes,hasAxisLabel:!!q}}),de={chartType:"heatmap",...null!=r&&{data:X},xAccessor:a,yAccessor:c,valueAccessor:l,colorScheme:"custom"!==K?K:void 0,areaStyle:se,showValues:m,heatmapValueFormat:y,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ue,showAxes:o.showAxes,xLabel:q,yLabel:G,xFormat:u,yFormat:d,enableHover:O,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...le&&{legend:le,legendPosition:Z},...sm({title:F,description:z,summary:H,accessibleTable:W,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:b,defaultTooltipContent:ae}),...am({linkedHover:A,selection:S,onObservation:C,onClick:M,hoverHighlight:j,mobileInteraction:o.mobileInteraction,customHoverBehavior:J,customClickBehavior:ee}),...v&&v.length>0&&{annotations:v},...x&&{xExtent:x},...w&&{yExtent:w},...ne,...k};return Y||V||(ce?(0,by.jsx)(Ap,{componentName:"Heatmap",message:ce,width:B,height:E}):(0,by.jsx)(Rp,{componentName:"Heatmap",width:B,height:E,children:(0,by.jsx)(th,{ref:n,...de})}))});vy.displayName="Heatmap";var xy=d(require("react")),wy=require("react");T();var ky=d(require("react")),Sy=require("react/jsx-runtime"),Ay=null,Cy=null;function My(e){const[t,n]=ky.useState(()=>Ay);return ky.useEffect(()=>{if(t)return;let e=!1;return(Ay?Promise.resolve(Ay):(Cy||(Cy=Promise.resolve().then(()=>(ce(),ne)).then(e=>Ay=e.ScatterplotMatrixBrushOverlay).catch(e=>{throw Cy=null,e})),Cy)).then(t=>{e||n(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?(0,Sy.jsx)(t,{...e}):null}var jy=require("react/jsx-runtime"),Py="__splomIdx",Iy="splom-hover-source",Ry={top:4,bottom:4,left:4,right:4};function Ty({data:e,xField:t,yField:n,cellSize:o,pointRadius:r,pointOpacity:i,colorBy:s,colorScale:a,brushSelectionName:c,hoverSelectionName:l,unselectedOpacity:u,maxDevicePixelRatio:d,mobileInteraction:h,mode:p,onPointHover:m,onPointClick:y}){const f=(0,wy.useRef)(null),g=bh({name:c,clientId:`splom-${t}-${n}`,fields:[t,n]}),b=kh({name:c,xField:t,yField:n}),v=bh({name:l,clientId:Iy,fields:[Py]}),x=v.selectPoints,w=(0,wy.useCallback)(e=>{e?b.brushInteraction.during(e):b.brushInteraction.end(null)},[b.brushInteraction]),k=(0,wy.useCallback)(e=>{if(!e)return void m?.(null);const t=e.data,n=t?.[Py];void 0!==n&&(x({[Py]:[n]}),m?.(t,e.x+Ry.left,e.y+Ry.top))},[x,m]),S=(0,wy.useCallback)(e=>{if(!e)return void y?.(null);const t=e.data;t&&y?.(t,e.x+Ry.left,e.y+Ry.top)},[y]),A=(0,wy.useCallback)(e=>{const t={opacity:i,r:r};return t.fill=s?Pn(e,s,a):Sn,"hover"===p?v.isActive&&v.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):v.isActive&&(t.opacity=.6*i):g.isActive&&!g.predicate(e)&&(t.opacity=u),t},[i,r,s,p,a,v,g,u]);return(0,jy.jsxs)("div",{style:{position:"relative",width:o,height:o},children:[(0,jy.jsx)(th,{ref:f,chartType:"scatter",data:e,size:[o,o],xAccessor:t,yAccessor:n,pointStyle:A,margin:Ry,showAxes:!1,maxDevicePixelRatio:d,enableHover:"hover"===p,...am({forceHoverBehavior:"hover"===p,forceClickBehavior:!!y,mobileInteraction:h,customHoverBehavior:k,customClickBehavior:S}),tooltipContent:"hover"===p?()=>null:void 0}),"brush"===p&&(0,jy.jsx)(My,{frameRef:f,cellSize:o,onBrush:w})]})}function _y({data:e,field:t,label:n,cellSize:o,bins:r,colorBy:i,colorScale:s,brushSelectionName:a,hoverSelectionName:c,mode:l}){const u=bh({name:a,clientId:"splom-diag-"+t,fields:[t]}),d=bh({name:c,clientId:`splom-diag-${t}-hover`,fields:[Py]}),h="hover"===l?d:u,p=h.isActive,m=h.predicate,y=(0,wy.useMemo)(()=>{const n="string"==typeof i?i:null,s=[],a=new Set;for(const o of e){const e=o[t];if(null==e||isNaN(e)||s.push(Number(e)),n){const e=o[n];null!=e&&a.add(e+"")}}if(0===s.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const[c,l]=P(s),u=(l-c)/r||1,d=Array.from(a),h=new Map(d.map((e,t)=>[e,t])),y=Array(r).fill(0),f=Array(r).fill(0),g=Array.from({length:r},()=>Array(d.length).fill(0)),b=Array.from({length:r},()=>Array(d.length).fill(0));for(const o of e){const e=o[t];if(null==e||isNaN(e))continue;const i=Math.min(Math.floor((e-c)/u),r-1);if(y[i]++,p&&!m(o)||f[i]++,n){const e=h.get(o[n]+"");void 0!==e&&(g[i][e]++,p&&!m(o)||b[i][e]++)}}const v=I(y,1),x=g.map((e,t)=>{let n=0;return e.map((e,i)=>{const s=e/v*(o-24),a={x:t/r*o,w:o/r-1,h:s,y0:n,category:d[i]};return n+=s,a})}),w=b.map((e,t)=>{let n=0;return e.map((e,i)=>{const s=e/v*(o-24),a={x:t/r*o,w:o/r-1,h:s,y0:n,category:d[i]};return n+=s,a})});return{bars:y.map((e,t)=>({x:t/r*o,w:o/r-1,h:e/v*(o-24),count:e})),selectedBars:f.map((e,t)=>({x:t/r*o,w:o/r-1,h:e/v*(o-24),count:e})),categoryBars:x,selectedCategoryBars:w,max:v,categories:d}},[e,t,r,o,p,m,i]);return(0,jy.jsxs)("svg",{width:o,height:o,style:{overflow:"hidden"},children:[(0,jy.jsx)("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:n}),y.categories.length>0?y.categoryBars.map((e,t)=>e.map((e,n)=>(0,jy.jsx)("rect",{x:e.x,y:o-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Sn,opacity:p?.3:.6},`bg-${t}-${n}`))):y.bars.map((e,t)=>(0,jy.jsx)("rect",{x:e.x,y:o-e.h,width:Math.max(e.w,1),height:e.h,fill:Sn,opacity:p?.3:.6},"bg-"+t)),p&&(y.categories.length>0?y.selectedCategoryBars.map((e,t)=>e.map((e,n)=>(0,jy.jsx)("rect",{x:e.x,y:o-e.y0-e.h,width:Math.max(e.w,1),height:e.h,fill:s?s(e.category):Sn,opacity:.7},`sel-${t}-${n}`))):y.selectedBars.map((e,t)=>(0,jy.jsx)("rect",{x:e.x,y:o-e.h,width:Math.max(e.w,1),height:e.h,fill:Sn,opacity:.7},"sel-"+t)))]})}function Ly({label:e,cellSize:t}){return(0,jy.jsx)("svg",{width:t,height:t,children:(0,jy.jsx)("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:e})})}function Dy(e){const{data:t,fields:n,fieldLabels:o={},colorBy:r,colorScheme:i,cellSize:s=150,cellGap:a=4,pointRadius:c=2,pointOpacity:l=.5,diagonal:u="histogram",histogramBins:d=20,brushMode:h="crossfilter",hoverMode:p=!0,unselectedOpacity:m=.1,showGrid:y=!1,maxDevicePixelRatio:f,tooltip:g,showLegend:b,idAccessor:v,width:x,className:w,onObservation:k,onClick:S,chartId:A}=e,C="splom",M="splom-hover",j=Fh(e.mobileInteraction,{mode:e.mode,width:x??n.length*s,mobileSemantics:e.mobileSemantics}),P=p?"hover":h?"brush":"hover",I=gh(e=>e.clearSelection),[R,T]=(0,wy.useState)(null),_=(0,wy.useCallback)(()=>{I(M),T(null)},[I,M]),L=(0,wy.useMemo)(()=>(t||[]).map((e,t)=>void 0!==e[Py]?e:{...e,[Py]:t}),[t]),D=bp(L,r,i),N=(0,wy.useCallback)((e,t,n,o)=>[40+e*(s+a)+(n??0),t*(s+a)+(o??0)],[40,s,a]),$=void 0!==b?b:!!r,B=(0,wy.useMemo)(()=>{if(!$||!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:D?D(e+""):Sn})):null},[$,r,L,D]),E=(0,wy.useMemo)(()=>({display:"grid",gridTemplateColumns:"40px "+n.map(()=>s+"px").join(" "),gridTemplateRows:n.map(()=>s+"px").join(" ")+" 40px",gap:a+"px",width:"fit-content"}),[n,s,a,40]);return(0,jy.jsxs)("div",{className:w,style:{position:"relative"},children:[B&&(0,jy.jsx)("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:B.map(e=>(0,jy.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,jy.jsx)("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),(0,jy.jsx)("span",{style:{fontSize:11},children:e.label})]},e.label))}),(0,jy.jsxs)("div",{style:E,onMouseLeave:"hover"===P?_:void 0,children:[n.map((e,t)=>(0,jy.jsxs)(xy.Fragment,{children:[(0,jy.jsx)("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?(0,jy.jsx)(Ly,{label:o[e]||e,cellSize:s},"diag-"+e):(0,jy.jsx)(_y,{data:L,field:e,label:o[e]||e,cellSize:s,bins:d,colorBy:r,colorScale:D,brushSelectionName:C,hoverSelectionName:M,unselectedOpacity:m,mode:P},"diag-"+e):(0,jy.jsx)(Ty,{data:L,xField:n,yField:e,fieldLabels:o,cellSize:s,pointRadius:c,pointOpacity:l,colorBy:r,colorScale:D,brushSelectionName:C,hoverSelectionName:M,unselectedOpacity:m,showGrid:y,maxDevicePixelRatio:f,tooltip:g,mobileInteraction:j,mode:P,onPointHover:"hover"===P?(o,r,s)=>{if(o){if(T({datum:o,xField:n,yField:e,colIndex:i,rowIndex:t,px:r??0,py:s??0}),k){const[e,n]=N(i,t,r,s);k({type:"hover",datum:o,x:e,y:n,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})}}else T(null),k&&k({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})}:void 0,onPointClick:S||k?(e,n,o)=>{if(!e)return;const[r,s]=N(i,t,n,o);S&&S(e,{x:r,y:s}),k&&k({type:"click",datum:e,x:r,y:s,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})}:void 0},`cell-${e}-${n}`))]},"row-"+e)),(0,jy.jsx)("div",{})," ",n.map(e=>(0,jy.jsx)("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=v?"function"==typeof v?v(e):e[v]:"Row "+e[Py];return(0,jy.jsxs)("div",{style:{position:"absolute",left:40+R.colIndex*(s+a)+R.px,top:R.rowIndex*(s+a)+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:[(0,jy.jsx)("div",{style:{fontWeight:"bold",marginBottom:2},children:c+""}),(0,jy.jsxs)("div",{children:[t,": ",null!=e[R.xField]?Number(e[R.xField]).toFixed(1):"–"]}),(0,jy.jsxs)("div",{children:[n,": ",null!=e[R.yField]?Number(e[R.yField]).toFixed(1):"–"]}),null!=i&&(0,jy.jsxs)("div",{style:{opacity:.8},children:["string"==typeof r?r:"group",": ",i+""]})]})})()]})}function Ny(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),(0,jy.jsx)(up,{selections:o,children:(0,jy.jsx)(Dy,{...e})})}Ny.displayName="ScatterplotMatrix";var $y=require("react"),By=d(require("react")),Ey=require("react/jsx-runtime"),Oy=null,Fy=null;function zy(e){const[t,n]=By.useState(()=>Oy);return By.useEffect(()=>{if(t)return;let e=!1;return(Oy?Promise.resolve(Oy):(Fy||(Fy=Promise.resolve().then(()=>(ye(),le)).then(e=>Oy=e.MinimapBrushOverlay).catch(e=>{throw Fy=null,e})),Fy)).then(t=>{e||n(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?(0,Ey.jsx)(t,{...e}):null}var Hy=require("react/jsx-runtime");function Wy(e){const{data:t,width:n=600,height:o=400,margin:r,className:i,title:s,description:a,summary:c,xLabel:l,yLabel:u,xFormat:d,yFormat:h,xAccessor:p="x",yAccessor:m="y",lineBy:y,lineDataAccessor:f="coordinates",colorBy:g,colorScheme:b,curve:v="linear",lineWidth:x=2,fillArea:w=!1,areaOpacity:k=.3,showPoints:S=!1,pointRadius:A=3,enableHover:C=!0,showGrid:M=!1,showLegend:j,legendPosition:P,tooltip:I,minimap:R={},renderBefore:T=!1,onBrush:_,brushExtent:L,yExtent:D,frameProps:N={},loading:$,loadingContent:B,emptyContent:E}=e,O=Dp($,n,o,B),F=O?null:Lp(t,n,o,E),z=(0,$y.useMemo)(()=>ft(t),[t]),[H,W]=(0,$y.useState)(null),q=L??H,G=(0,$y.useCallback)(e=>{L||W(e),_?.(e)},[L,_]),Y=(0,$y.useRef)(null),[V,X]=(0,$y.useState)(null);(0,$y.useEffect)(()=>{let e=0,t=!1;const n=()=>{if(t)return;const o=Y.current?.getScales?.();o?X(o):e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{t=!0,e&&cancelAnimationFrame(e)}},[t]);const U=void 0!==z[0]?.[f],K=(0,$y.useMemo)(()=>{if(U)return z;if(y){const e=z.reduce((e,t)=>{const n="function"==typeof y?y(t):t[y];if(!e[n]){const t={[f]:[]};"string"==typeof y&&(t[y]=n),e[n]=t}return e[n][f].push(t),e},{});return Object.values(e)}return[{[f]:z}]},[z,y,f,U]),Q=(0,$y.useMemo)(()=>U||y?K.flatMap(e=>{const t=e[f]||[];return y&&"string"==typeof y?t.map(t=>({...t,[y]:e[y]})):t}):z,[K,f,U,y,z]),Z=bp(z,g,b),J=om({lineWidth:x,colorBy:g,colorScale:Z,fillArea:w,areaOpacity:k}),ee=(0,$y.useMemo)(()=>{if(R.lineStyle)return R.lineStyle},[R.lineStyle]),te=om({lineWidth:1,colorBy:g,colorScale:Z}),ne=ee??te,oe=(0,$y.useMemo)(()=>{if(S)return e=>{const t={r:A,fillOpacity:1};return t.fill=g?Pn(e.parentLine||e,g,Z):Sn,t}},[S,A,g,Z]),{legend:re,margin:ie,legendPosition:se}=pp({data:K,colorBy:g,colorScale:Z,showLegend:j,legendPosition:P,userMargin:r,chartWidth:n,hasTitle:!!s,axisChrome:{hasAxis:!0,hasAxisLabel:!!l}}),ae=R.height||60,ce=(0,$y.useMemo)(()=>({top:R.margin?.top??0,bottom:R.margin?.bottom??20,left:R.margin?.left??ie.left,right:R.margin?.right??ie.right}),[R.margin,ie]),le=R.brushDirection||"x",ue=(0,$y.useMemo)(()=>Pd([{label:l||Sd(p),accessor:p,role:"x",format:d},{label:u||Sd(m),accessor:m,role:"y",format:h}]),[p,m,l,u,d,h]),de=zp({componentName:"MinimapChart",data:t,accessors:{xAccessor:p,yAccessor:m}});if(de)return(0,Hy.jsx)(Ap,{componentName:"MinimapChart",message:de,width:n,height:o});const he=w?"area":"line",pe={chartType:he,data:Q,xAccessor:p,yAccessor:m,groupAccessor:y||void 0,curve:v,lineStyle:J,...S&&{pointStyle:oe},size:[n,o],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:ie,showAxes:!0,xLabel:l,yLabel:u,xFormat:d,yFormat:h,enableHover:C,showGrid:M,...re&&{legend:re,legendPosition:se},...s&&{title:s},...a&&{description:a},...c&&{summary:c},tooltipContent:!1===I?()=>null:cu(I)||ue,...q&&{xExtent:q},...D&&{yExtent:D},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...N},me={chartType:he,data:Q,xAccessor:p,yAccessor:m,groupAccessor:y||void 0,curve:v,lineStyle:ne,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},size:[n,ae+ce.top+ce.bottom],margin:ce,showAxes:R.showAxes??!1,background:R.background,enableHover:!1,...D&&{yExtent:D}},ye=(0,Hy.jsxs)("div",{style:{position:"relative",width:n,overflow:"hidden"},children:[(0,Hy.jsx)(th,{ref:Y,...me}),(0,Hy.jsx)(zy,{width:n-ce.left-ce.right,height:ae,margin:ce,scales:V,brushDirection:le,extent:q,onBrush:G})]},"minimap"),fe=(0,Hy.jsx)("div",{style:{overflow:"hidden"},children:(0,Hy.jsx)(th,{...pe})},"main");return O||F||(0,Hy.jsx)(Rp,{componentName:"MinimapChart",width:n,height:o,children:(0,Hy.jsxs)("div",{className:"minimap-chart"+(i?" "+i:""),children:[T?ye:fe,T?fe:ye]})})}Wy.displayName="MinimapChart";var qy=require("react"),Gy={label:"Low / High",color:"#E9C46A",opacity:.08},Yy={label:"High / High",color:"#2A9D8F",opacity:.08},Vy={label:"Low / Low",color:"#E76F51",opacity:.08},Xy={label:"High / Low",color:"#86BBD8",opacity:.08};T();var Uy=require("react/jsx-runtime");function Ky(e,t){return{label:t?.label??e.label,color:t?.color??e.color,opacity:t?.opacity??e.opacity}}var Qy=(0,qy.forwardRef)(function(e,t){const n=(0,qy.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",xCenter:d,yCenter:h,quadrants:p,centerlineStyle:m={},showQuadrantLabels:y=!0,quadrantLabelSize:f=12,colorBy:g,colorScheme:b,styleRules:v,sizeBy:x,sizeRange:w=[3,15],pointRadius:k=5,pointOpacity:S=.8,tooltip:A,pointIdAccessor:C,annotations:M,frameProps:j={},selection:I,linkedHover:R,onObservation:T,onClick:_,hoverHighlight:L,chartId:D,loading:N,loadingContent:$,emptyContent:B,legendInteraction:E,legendPosition:O,color:F,stroke:z,strokeWidth:H,opacity:W}=e,{width:q,height:G,enableHover:Y,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=o,te=(0,qy.useMemo)(()=>({topLeft:Ky(Gy,p?.topLeft),topRight:Ky(Yy,p?.topRight),bottomLeft:Ky(Vy,p?.bottomLeft),bottomRight:Ky(Xy,p?.bottomRight)}),[p]),ne=(0,qy.useMemo)(()=>ft(r),[r]),oe=Vp({data:ne,rawData:r,colorBy:g,colorScheme:b,legendInteraction:E,legendPosition:O,selection:I,linkedHover:R,fallbackFields:"string"==typeof g?[g]:[],unwrapData:!1,onObservation:T,onClick:_,hoverHighlight:L,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"QuadrantChart",chartId:D,showLegend:X,userMargin:i,marginDefaults:o.marginDefaults,loading:N,loadingContent:$,emptyContent:B,width:q,height:G,hasTitle:!!U,axisChrome:es({showAxes:o.showAxes,xLabel:J})});Np("QuadrantChart",ne,"xAccessor",l),Np("QuadrantChart",ne,"yAccessor",u);const re=(0,qy.useMemo)(()=>{if(!ne.length)return;const e="function"==typeof l?l:e=>+e[l],t="function"==typeof u?u:e=>+e[u];let n=1/0,o=-1/0,r=1/0,i=-1/0;for(const s of ne){const a=e(s),c=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(c)&&(r>c&&(r=c),c>i&&(i=c))}if(null!=d&&isFinite(d)&&(n>d&&(n=d),d>o&&(o=d)),null!=h&&isFinite(h)&&(r>h&&(r=h),h>i&&(i=h)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(i-r)||1;return{xExtent:[n-s,o+s],yExtent:[r-a,i+a]}},[ne,l,u,d,h]),ie=(0,qy.useMemo)(()=>{if(!x||0===ne.length)return;const e=ne.map(e=>"function"==typeof x?x(e):e[x]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?P(e):void 0},[ne,x]),se=(0,qy.useMemo)(()=>"function"==typeof l?l:e=>+e[l],[l]),ae=(0,qy.useMemo)(()=>"function"==typeof u?u:e=>+e[u],[u]),ce=(0,qy.useMemo)(()=>e=>{const t=se(e),n=ae(e),o=null!=d?t>=d:void 0,r=null!=h?n>=h:void 0;return void 0===r||void 0===o?F||Sn:r&&o?te.topRight.color:r&&!o?te.topLeft.color:!r&&o?te.bottomRight.color:te.bottomLeft.color},[se,ae,d,h,te,F]),le=(0,qy.useMemo)(()=>x?e=>Tn(e,x,w,ie):void 0,[x,w,ie]),ue=(0,qy.useMemo)(()=>Qp(l,u),[l,u]),de=oy({colorBy:g,colorScale:oe.colorScale,color:F,pointRadius:k,fillOpacity:S,radiusFn:le,fallbackFill:ce,stroke:z,strokeWidth:H,opacity:W,styleRules:v,ruleContext:ue,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection}),he=(0,qy.useMemo)(()=>{if(!ne.length)return;const e=new Set;"string"==typeof l&&e.add(l),"string"==typeof u&&e.add(u),"string"==typeof g&&e.add(g),"string"==typeof x&&e.add(x);const t=ne[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[ne,l,u,g,x]),pe=(0,qy.useMemo)(()=>Pd([...he?[{label:he,accessor:he,role:"title"}]:[],{label:J||Sd(l),accessor:l,role:"x",format:a},{label:ee||Sd(u),accessor:u,role:"y",format:c},...g?[{label:Sd(g),accessor:g,role:"color"}]:[],...x?[{label:Sd(x),accessor:x,role:"size"}]:[]]),[he,l,u,J,ee,g,x,a,c]),me=zp({componentName:"QuadrantChart",data:r,accessors:{xAccessor:l,yAccessor:u}}),ye=(0,qy.useMemo)(()=>{const e={stroke:m.stroke||"#999",strokeWidth:m.strokeWidth??1,dashArray:m.strokeDasharray||[]};return[(t,n,o,r)=>{if(!o?.x||!o?.y)return;const i=r.width,s=r.height,a=null!=d?o.x(d):i/2,c=null!=h?o.y(h):s/2;if(null!=d&&!isFinite(a))return;if(null!=h&&!isFinite(c))return;const l=Math.max(0,Math.min(i,a)),u=Math.max(0,Math.min(s,c)),p=[{config:te.topLeft,x:0,y:0,w:l,h:u},{config:te.topRight,x:l,y:0,w:i-l,h:u},{config:te.bottomLeft,x:0,y:u,w:l,h:s-u},{config:te.bottomRight,x:l,y:u,w:i-l,h:s-u}];for(const e of p)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,s),t.stroke(),t.beginPath(),t.moveTo(0,u),t.lineTo(i,u),t.stroke(),t.setLineDash([])}]},[d,h,te,m]),fe=(0,qy.useMemo)(()=>y?[...ye,(e,t,n,o)=>{if(!n?.x||!n?.y)return;const r=o.width,i=o.height,s=null!=d?n.x(d):r/2,a=null!=h?n.y(h):i/2;(null==d||isFinite(s))&&(null==h||isFinite(a))&&(e.font=`600 ${f}px sans-serif`,e.globalAlpha=.5,e.fillStyle=te.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(te.topLeft.label,8,8),e.fillStyle=te.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(te.topRight.label,r-8,8),e.fillStyle=te.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(te.bottomLeft.label,8,i-8),e.fillStyle=te.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(te.bottomRight.label,r-8,i-8),e.globalAlpha=1)}]:ye,[ye,y,f,te,d,h]),ge=(0,qy.useMemo)(()=>{const e=j.canvasPreRenderers||[];return[...fe,...e]},[fe,j.canvasPreRenderers]),be=(0,qy.useMemo)(()=>{const e={stroke:m.stroke||"#999",strokeWidth:m.strokeWidth??1,dashArray:m.strokeDasharray?Array.isArray(m.strokeDasharray)?m.strokeDasharray.join(","):m.strokeDasharray:void 0};return[(t,n,o)=>{if(!n?.x||!n?.y)return null;const r=o.width,i=o.height,s=null!=d?n.x(d):r/2,a=null!=h?n.y(h):i/2;if(null!=d&&!isFinite(s))return null;if(null!=h&&!isFinite(a))return null;const c=Math.max(0,Math.min(r,s)),l=Math.max(0,Math.min(i,a));return(0,Uy.jsxs)(Uy.Fragment,{children:[[{config:te.topLeft,x:0,y:0,w:c,h:l},{config:te.topRight,x:c,y:0,w:r-c,h:l},{config:te.bottomLeft,x:0,y:l,w:c,h:i-l},{config:te.bottomRight,x:c,y:l,w:r-c,h:i-l}].map((e,t)=>e.w>0&&e.h>0?(0,Uy.jsx)("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),(0,Uy.jsx)("line",{x1:c,y1:0,x2:c,y2:i,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),(0,Uy.jsx)("line",{x1:0,y1:l,x2:r,y2:l,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),y&&(0,Uy.jsxs)(Uy.Fragment,{children:[(0,Uy.jsx)("text",{x:8,y:8+f,fill:te.topLeft.color,fontWeight:600,fontSize:f,opacity:.5,children:te.topLeft.label}),(0,Uy.jsx)("text",{x:r-8,y:8+f,fill:te.topRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end",children:te.topRight.label}),(0,Uy.jsx)("text",{x:8,y:i-8,fill:te.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5,children:te.bottomLeft.label}),(0,Uy.jsx)("text",{x:r-8,y:i-8,fill:te.bottomRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end",children:te.bottomRight.label})]})]})}]},[d,h,te,m,y,f]);if(oe.earlyReturn)return oe.earlyReturn;const ve={chartType:"scatter",...null!=r&&{data:ne},xAccessor:l,yAccessor:u,colorAccessor:g||void 0,sizeAccessor:x||void 0,sizeRange:w,pointStyle:de,colorScheme:b,size:[q,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:oe.margin,showAxes:o.showAxes,xLabel:J,yLabel:ee,xFormat:a,yFormat:c,enableHover:Y,showGrid:V,...re&&{xExtent:re.xExtent,yExtent:re.yExtent},...oe.legendBehaviorProps,...U&&{title:U},...K&&{description:K},...Q&&{summary:Q},...void 0!==Z&&{accessibleTable:Z},...s&&{className:s},...null!=e.animate&&{animate:e.animate},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},tooltipContent:!1===A?()=>null:!0===A||void 0===A?pe:cu(A)||pe,...am({linkedHover:R,selection:I,onObservation:T,onClick:_,hoverHighlight:L,mobileInteraction:oe.mobileInteraction,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior}),...C&&{pointIdAccessor:C},...M&&M.length>0&&{annotations:M},canvasPreRenderers:ge,...oe.crosshairProps,...j,...ge.length>0&&{canvasPreRenderers:ge},svgPreRenderers:be};return me?(0,Uy.jsx)(Ap,{componentName:"QuadrantChart",message:me,width:q,height:G}):(0,Uy.jsx)(Rp,{componentName:"QuadrantChart",width:q,height:G,children:(0,Uy.jsx)(th,{ref:n,...ve})})});Qy.displayName="QuadrantChart";var Zy=d(require("react")),Jy=require("react"),ef=require("react/jsx-runtime"),tf="__ma_unitized",nf="__ma_series";function of(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function rf(e,t){return t[0]+e*(t[1]-t[0])}var sf=(0,Jy.forwardRef)(function(e,t){const n=(0,Jy.useRef)(null),o=(0,Jy.useRef)([]),r=(0,Jy.useRef)(e.series);r.current=e.series,(0,Jy.useImperativeHandle)(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],s=t.extent||o.current[e];if(!s)continue;const a=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(i);null!=a&&isFinite(a)&&n.current.push({...i,[tf]:of(a,s),[nf]: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],s=n.extent||o.current[t];if(!s)continue;const a=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=a&&isFinite(a)&&i.push({...e,[tf]:of(a,s),[nf]: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=kp(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:s,margin:a,className:c,xFormat:l,xAccessor:u="x",series:d,colorScheme:h,curve:p="monotoneX",lineWidth:m=2,tooltip:y,annotations:f,frameProps:g={},selection:b,linkedHover:v,onObservation:x,onClick:w,hoverHighlight:k,chartId:S,loading:A,loadingContent:C,emptyContent:M,legendInteraction:j,legendPosition:P,stroke:I,strokeWidth:R,opacity:T}=e,{width:_,height:L,enableHover:D,showGrid:N,showLegend:$=!0,title:B,description:E,summary:O,accessibleTable:F,xLabel:z}=i,H=(0,Jy.useMemo)(()=>ft(s),[s]),W=(0,Jy.useMemo)(()=>ft(d),[d]),q=W,G=2===W.length,Y=(0,Jy.useMemo)(()=>G?{...g.legendLayout,sideGutter:g.legendLayout?.sideGutter??70}:g.legendLayout,[g.legendLayout,G]);"undefined"==typeof process||"production"===process.env?.NODE_ENV||G||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${W.length}. Rendering as a standard multi-line chart.`);const V=Dp(A,_,L,C),X=V?null:Lp(s,_,L,M),U=fp(),K=(0,Jy.useMemo)(()=>{let e;if(Array.isArray(h))e=h;else if(U&&U.length>0)e=U;else{const t=wn[h];e=Array.isArray(t)?t:kn}return q.map((t,n)=>t.color||e[n%e.length])},[q,h,U]),Q=(0,Jy.useMemo)(()=>W.map((e,t)=>e.label||"Series "+(t+1)),[W]),{unitizedData:Z,extents:J}=(0,Jy.useMemo)(()=>{if(0===H.length){const e=W.map(e=>e.extent||null).filter(Boolean);return e.length===W.length&&(o.current=e),{unitizedData:[],extents:e.length===W.length?e:[]}}const e=W.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]}(H,e.yAccessor));if(o.current=e,!G){const t=[];for(const e of H)for(let n=0;W.length>n;n++){const o=W[n],r=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=r&&t.push({...e,[tf]:r,[nf]:Q[n]})}return{unitizedData:t,extents:e}}const t=[];for(const n of H)for(let o=0;2>o;o++){const r=W[o],i=("function"==typeof r.yAccessor?r.yAccessor:e=>e[r.yAccessor])(n);null!=i&&t.push({...n,[tf]:of(i,e[o]),[nf]:Q[o]})}return{unitizedData:t,extents:e}},[H,W,G,Q]),ee=(0,Jy.useMemo)(()=>{if(G&&J.length>=2)return[{orient:"left",label:Q[0],tickFormat:W[0].format||(e=>{const t=rf(e,J[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:Q[1],tickFormat:W[1].format||(e=>{const t=rf(e,J[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[G,J,W,Q]),te=Vp({data:(0,Jy.useMemo)(()=>Z.length>0?Z:Q.map(e=>({[nf]:e})),[Z,Q]),rawData:s,colorBy:nf,colorScheme:K,legendInteraction:j,legendPosition:P,selection:b,linkedHover:v,fallbackFields:[nf],unwrapData:!1,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"MultiAxisLineChart",chartId:S,showLegend:$,legendLayout:Y,userMargin:a,marginDefaults:G?{...i.marginDefaults,left:70,right:70}:i.marginDefaults,loading:A,loadingContent:C,emptyContent:M,width:_,height:L,hasTitle:!!B,axisChrome:es({showAxes:i.showAxes,xLabel:z})}),ne=(0,Jy.useMemo)(()=>{const e=new Map;return Q.forEach((t,n)=>e.set(t,K[n])),e},[Q,K]),oe=om({lineWidth:m,resolveStroke:(0,Jy.useCallback)(e=>ne.get(e[nf])||K[0],[ne,K]),stroke:I,strokeWidth:R,opacity:T,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=(0,Jy.useMemo)(()=>{if(!1===y)return()=>null;return cu(y)||(e=>{const t=e.data||e,n=t[nf],o=Q.indexOf(n),r=t[tf],i=G&&o>=0&&J[o]?rf(r,J[o]):r,s=o>=0&&W[o]?.format?W[o].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),a="function"==typeof u?u(t):t[u];return Zy.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},Zy.createElement("div",{style:{fontWeight:600,marginBottom:4,color:K[o]||"inherit"}},n),Zy.createElement("div",null,`${"string"==typeof u?u:"x"}: ${a}`),Zy.createElement("div",null,`${n}: ${s(i)}`))})},[y,Q,K,J,G,W,u]);if(te.earlyReturn)return te.earlyReturn;const ie=zp({componentName:"MultiAxisLineChart",data:s,accessors:{xAccessor:u}}),se=G?[0,1]:void 0,ae={chartType:"line",...null!=s&&{data:Z},xAccessor:u,yAccessor:tf,groupAccessor:nf,lineStyle:oe,colorScheme:K,size:[_,L],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,...void 0!==e.maxDevicePixelRatio&&{maxDevicePixelRatio:e.maxDevicePixelRatio},margin:te.margin,showAxes:i.showAxes,...ee&&{axes:ee},xLabel:z,...G?{}:{yLabel:Q[0]},xFormat:l,...G&&se&&{yExtent:se},enableHover:D,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:N,curve:p,...te.legendBehaviorProps,...B&&{title:B},...E&&{description:E},...O&&{summary:O},...void 0!==F&&{accessibleTable:F},...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,...f&&{annotations:f},...am({linkedHover:v,selection:b,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:te.mobileInteraction,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior}),...te.crosshairProps,...g,...Y&&{legendLayout:Y}};return V||X||(ie?(0,ef.jsx)(Ap,{componentName:"MultiAxisLineChart",message:ie,width:_,height:L}):(0,ef.jsx)(Rp,{componentName:"MultiAxisLineChart",width:_,height:L,children:(0,ef.jsx)(th,{ref:n,...ae})}))});sf.displayName="MultiAxisLineChart";var af=require("react"),cf=require("react/jsx-runtime"),lf=(0,af.forwardRef)(function(e,t){const n=(0,af.useRef)(null);im(t,{variant:"xy",frameRef:n});const o=kp(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:s,xFormat:a,yFormat:c,xAccessor:l="x",highAccessor:u="high",lowAccessor:d="low",openAccessor:h,closeAccessor:p,candlestickStyle:m,tooltip:y,annotations:f,xExtent:g,yExtent:b,frameProps:v={},selection:x,linkedHover:w,onObservation:k,onClick:S,chartId:A,loading:C,loadingContent:M,emptyContent:j}=e,{width:P,height:I,enableHover:R,showGrid:T,title:_,description:L,summary:D,accessibleTable:N,xLabel:$,yLabel:B}=o,E=Dp(C,P,I,M),O=E?null:Lp(r,P,I,j),F=(0,af.useMemo)(()=>ft(r),[r]),z=null==h||null==p;Np("CandlestickChart",F,"xAccessor",l),Np("CandlestickChart",F,"highAccessor",u),Np("CandlestickChart",F,"lowAccessor",d),z||(Np("CandlestickChart",F,"openAccessor",h),Np("CandlestickChart",F,"closeAccessor",p));const{customHoverBehavior:H,customClickBehavior:W,crosshairSourceId:q}=xp({selection:x,linkedHover:w,onObservation:k,onClick:S,chartType:"CandlestickChart",chartId:A,mobileInteraction:o.mobileInteraction}),G=wp(w,q),Y=(0,af.useMemo)(()=>{const e=o.marginDefaults,t="sparkline"===o.mode?{...e,top:0,bottom:0}:e;return null==i?t:{...t,...km(i)}},[i,o.marginDefaults,o.mode]),V=(0,af.useMemo)(()=>{const e=[{label:$||Sd(l),accessor:l,role:"x",format:a}];return z?(e.push({label:"High",accessor:u,role:"y",format:c}),e.push({label:"Low",accessor:d,format:c})):(e.push({label:"Open",accessor:h,format:c}),e.push({label:"High",accessor:u,format:c}),e.push({label:"Low",accessor:d,format:c}),e.push({label:"Close",accessor:p,format:c})),Pd(e)},[l,$,a,c,u,d,h,p,z]),X=zp({componentName:"CandlestickChart",data:r,accessors:{xAccessor:l,highAccessor:u,lowAccessor:d,...!z&&{openAccessor:h,closeAccessor:p}}}),U={chartType:"candlestick",...null!=r&&{data:F},xAccessor:l,yAccessor:u,highAccessor:u,lowAccessor:d,...!z&&{openAccessor:h,closeAccessor:p},...m&&{candlestickStyle:m},scalePadding:Math.max(2,Math.min(12,Math.round(P/40))),extentPadding:P>200?.1:.02,size:[P,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Y,showAxes:o.showAxes,xLabel:$,yLabel:B,xFormat:a,yFormat:c,enableHover:R,showGrid:T,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...sm({title:_,description:L,summary:D,accessibleTable:N,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:y,defaultTooltipContent:V}),...am({linkedHover:w,selection:x,onObservation:k,onClick:S,mobileInteraction:o.mobileInteraction,customHoverBehavior:H,customClickBehavior:W}),...f&&f.length>0&&{annotations:f},...g&&{xExtent:g},...b&&{yExtent:b},...G,...v};return E||O||(X?(0,cf.jsx)(Ap,{componentName:"CandlestickChart",message:X,width:P,height:I}):(0,cf.jsx)(Rp,{componentName:"CandlestickChart",width:P,height:I,children:(0,cf.jsx)(th,{ref:n,...U})}))});lf.displayName="CandlestickChart";var uf=require("react"),df=require("react"),hf=require("d3-scale"),pf=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||Cn,r=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,r),r}};function mf(e){const t=e.getSymbol;return t?fo(t,e.config.symbolMap):null}function yf(e,t,n,o,r,i,s){e.push(t?{type:"symbol",x:o,y:r,size:Math.PI*i*i,symbolType:t(n),style:s,datum:n}:{type:"point",x:o,y:r,r:i,style:s,datum:n})}function ff(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],s=Math.min(t.width,t.height)/2-4,a="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,y=r(t.pieceData[0],t.name),f=0===e,g=e===d.length-1,b={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:m,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?b.roundedEnds=n._roundedEnds:p&&(b.roundedEnds={start:f,end:g}),n?._gradientBand&&(b._gradientBand=n._gradientBand),i.push(b)}return i}var gf=require("d3-array");function bf(e){const t=e.length,n=e[0],o=e[t-1];return{n:t,min:n,q1:(0,gf.quantile)(e,.25)??n,median:(0,gf.quantile)(e,.5)??(n+o)/2,q3:(0,gf.quantile)(e,.75)??o,max:o,mean:e.reduce((e,t)=>e+t,0)/t}}T();var vf=require("d3-scale"),xf={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,p=r.normalize,m=[];if(s){const e=new Set;for(const t of Object.values(o))for(const n of t.pieceData){const t=s(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=s?s(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 y=a(l.pieces[0],s?i:e.name),f={...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(Kn(e.x,t,e.width,Math.abs(n),y,f,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(Kn(t,e.x,Math.abs(n),e.width,y,f,i)),0>m?r+=m:o+=m}}}const y="vertical"===l,f=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=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(f>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(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=f),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=f)}}return u},clusterbar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getGroup:s,resolvePieceStyle:a}=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=s?s(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=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=i(r),p=a(r,h[s]);if(d){const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Kn(i,Math.min(a,d),o,Math.abs(a-d),p,r,h[s]))}else{const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Kn(Math.min(a,d),i,Math.abs(d-a),o,p,r,h[s]))}}}}const y=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);y>0&&(e.roundedTop=y),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:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=i.length>0,p=mf(e),m=2*Math.PI,y=-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]||a,f=s(t,e.name),g=f.r||5;let b,v;if(d){const t=y+(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);yf(l,p,t,b,v,g,f)}return l},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=mf(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],a=r(o),d=i(o,e.name),h=d.r||4,p=(7919*n%100/100-.5)*t*.8;yf(c,u,o,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:ff,donut:ff,boxplot:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,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=(0,gf.quantile)(n,.25)??o,h=(0,gf.quantile)(n,.5)??(o+r)/2,p=(0,gf.quantile)(n,.75)??r,m=p-c,y=c-1.5*m,f=p+1.5*m,g=n.find(e=>e>=y)??o,b=[...n].reverse().find(e=>f>=e)??r,v=s(t.pieceData[0],t.name),x=[];if(d)for(const e of t.pieceData){const n=i(e);if(y>n||n>f){const o=u?t.middle:a(n),r=u?a(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:a(g),q1Pos:a(c),medianPos:a(h),q3Pos:a(p),maxPos:a(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(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const p=I(c,1),m=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const o=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/p*m} ${o}`}y+=` L ${e.middle} ${a(o)}`;for(let t=d-1;t>=0;t--){const o=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/p*m} ${o}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/p*m}`;y+=` L ${a(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/p*m}`;y+=" Z"}const f=s(e.pieceData[0],e.name);let g;if(h&&t.length>=4){const r=(0,gf.quantile)(t,.25)??n,i=(0,gf.quantile)(t,.5)??(n+o)/2,s=(0,gf.quantile)(t,.75)??o;g={q1Pos:a(r),medianPos:a(i),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const b=u?{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))}:{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:b,iqrLine:g,stats:bf(t),style:f,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,p=d?+d[1]:void 0;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,o]=P(t),r=null!=h&&isFinite(h)?h:n,d=null!=p&&isFinite(p)?p:o,m=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/m),l-1)]++;const f=t.length,g=I(y,1),b=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/f:y[t]/g)*e.width*.9,o=a(r+t*m),i=a(r+(t+1)*m);c.push(Kn(Math.min(o,i),e.x+e.width-n,Math.abs(i-o),n,b,{bin:t,count:y[t],range:[r+t*m,r+(t+1)*m],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>o||c[Math.min(Math.floor((e-n)/r),u-1)]++;const p=I(c,1),m=s(e.pieceData[0],e.name),y=e.width*h;let f;if(d){const t=e.x+e.width;f=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)f+=` L ${a(n+(e+.5)*r)} ${t-c[e]/p*y}`;f+=` L ${a(o)} ${t} Z`}else{const t=e.x;f=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const o=a(n+(e+.5)*r);f+=` L ${t+c[e]/p*y} ${o}`}f+=` L ${t} ${a(o)} Z`}const g=d?{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))};l.push({type:"violin",pathString:f,translateX:0,translateY:0,bounds:g,stats:bf(t),style:{...m,fillOpacity:m.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,a]=n,u=i(t,e.name);if(l){const n=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Kn(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Kn(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,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;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 s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}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 s;const y=new Map;for(const e of u){const t=p[0].groups.get(e);y.set(e,t?.total??0)}const f=p[0].stepTotal,g=h?.95*a:.9*t.width,b=(0,vf.scaleLinear)().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=a,l=a;for(let h=0;u.length>h;h++){const p=u[h],f=n.groups.get(p);if(!f)continue;const v=b(f.total),x=h%2==0,w=x?t:l-v;x?t+=v:l-=v;const k=i(f.pieces[0],p),S=y.get(p)??f.total,A={...f.pieces[0],__funnelValue:f.total,__funnelPercent:S>0?f.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:f.total,__pieceCount:f.pieces.length,category:p};c&&(0===h&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=m,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+v/2,A.__funnelValueLabelY=m,A.__funnelBarW=v),s.push(Kn(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=a-t/2,h=u[0],p="_default"!==h,y=n.groups.get(h)?.pieces[0]??o.pieceData[0],v=p?h:o.name,x=i(y,v),w=f>0?e/f*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,category:p?h:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=m,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=m,k.__funnelBarW=t),s.push(Kn(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),a=g.get(r);if(!t||!a)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],[a.x+a.w,a.y],[a.x,a.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};s.push(l)}}x=g}return s},"bar-funnel":function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i,scales:s}=e,a=[],c=s.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return a;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 s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}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=s.r,y=d?l.length:1,f=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,s=n.width/y,c=s*f,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const f=y.total,g=p.get(h)??f,b=g>0?f/g*100:0,v=r?.groups.get(h),x=o?0:Math.max(0,(v?.total??f)-f),w=n.x+e*s+c/2,k=m(f),S=m(0)-k,A=i(y.pieces[0],d?h:n.name),C={...y.pieces[0],__barFunnelValue:f,__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(f+x)};if(a.push(Kn(w,k,u,S,A,C,d?h:n.name)),x>0){const e=m(f+x),t=k-e,o={...A},r={...y.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};a.push(Kn(w,e,u,t,o,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:s}=e,{r:a,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]=a.range(),i=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(o)){const o={fill:e,opacity:t},r=u?Kn(i,n.x,s,n.width,o,null,"__track__"):Kn(n.x,i,n.width,s,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=s(n,c);let m;if(u){const r=a(t),i=a(t+o);m=Kn(r,e.x,i-r,e.width,p,n,c)}else{const r=a(t+o),i=a(t);m=Kn(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 wf(e,t,n){return An(e,t,n)}function kf(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&In(n,e)||"#4e79a7":t=>{if(n){const e=In(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 Sf=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Af=["scene-style","data-paint","accessibility","evidence"],Cf=(e,t)=>({retainedData:e,invalidations:t}),Mf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pf=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],If=["scene-geometry","data-paint","accessibility","evidence"],Rf=["scene-style","data-paint","accessibility","evidence"],Tf=[],_f={chartType:Cf("rebuild",Mf),runtimeMode:Cf("rebuild",Mf),categoryAccessor:Cf("rebuild",Mf),valueAccessor:Cf("rebuild",Mf),oAccessor:Cf("rebuild",Mf),rAccessor:Cf("rebuild",Mf),stackBy:Cf("rebuild",Mf),groupBy:Cf("rebuild",Mf),timeAccessor:Cf("rebuild",Mf),accessorRevision:Cf("rebuild",Mf),colorAccessor:Cf("rebuild",Rf),symbolAccessor:Cf("rebuild",If),connectorAccessor:Cf("rebuild",If),dataIdAccessor:Cf("rebuild",If),projection:Cf("preserve",jf),extentPadding:Cf("preserve",jf),axisExtent:Cf("preserve",jf),rExtent:Cf("preserve",jf),oExtent:Cf("preserve",jf),multiAxis:Cf("preserve",jf),normalize:Cf("preserve",jf),bins:Cf("preserve",jf),oSort:Cf("preserve",Pf),barPadding:Cf("preserve",Pf),roundedTop:Cf("preserve",Pf),baselinePadding:Cf("preserve",Pf),innerRadius:Cf("preserve",Pf),cornerRadius:Cf("preserve",Pf),startAngle:Cf("preserve",Pf),sweepAngle:Cf("preserve",Pf),trackFill:Cf("preserve",Pf),showOutliers:Cf("preserve",Pf),showIQR:Cf("preserve",Pf),amplitude:Cf("preserve",Pf),connectorOpacity:Cf("preserve",Pf),showLabels:Cf("preserve",Pf),dynamicColumnWidth:Cf("rebuild",Pf),customLayout:Cf("preserve",Pf),layoutConfig:Cf("preserve",Pf),layoutMargin:Cf("preserve",Pf),symbolMap:Cf("preserve",If),pieceStyle:Cf("preserve",Rf),summaryStyle:Cf("preserve",Rf),connectorStyle:Cf("preserve",Rf),gradientFill:Cf("preserve",Rf),colorScheme:Cf("preserve",Rf),themeCategorical:Cf("preserve",Rf),themeSemantic:Cf("preserve",Rf),themeSequential:Cf("preserve",Rf),themeDiverging:Cf("preserve",Rf),barColors:Cf("preserve",Rf),decay:Cf("preserve",Rf),pulse:Cf("preserve",Rf),staleness:Cf("preserve",Rf),layoutSelection:Cf("preserve",Rf),windowSize:Cf("preserve",Tf),windowMode:Cf("preserve",Tf),clock:Cf("preserve",Tf),transition:Cf("preserve",Tf),introAnimation:Cf("preserve",Tf),onLayoutError:Cf("preserve",Tf)},Lf=Cf("preserve",Pf),Df=class{constructor(){this.tracker=new qo}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}},Sf)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Af):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=_f[o]??Lf;"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)}},Nf=require("d3-quadtree"),$f=class{constructor(e){this.rExtent=new Ft,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Df,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new pf,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 Ot(e.windowSize),this.getO=qt(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Ht(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Ft)):(this.getR=Ht(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=qt(e.stackBy),this.getGroup=qt(e.groupBy),this.getColor=qt(e.colorAccessor),this.getSymbol=qt(e.symbolAccessor),this.getConnector=qt(e.connectorAccessor),this.getDataId=qt(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Ot(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:Ro(t,o):null)}currentTime(){return this.config.clock?.()??Nn()}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(),Io(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)To(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=To(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 s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let p,m;if(d){p=(0,hf.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;m=(0,hf.scaleLinear)().domain(l).range([o,n])}else u?(p=(0,hf.scaleBand)().domain(c).range([0,e.height]).padding(h),m=(0,hf.scaleLinear)().domain(l).range([0,e.width])):(p=(0,hf.scaleBand)().domain(c).range([0,e.width]).padding(h),m=(0,hf.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:p,r:m,projection:a},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[s,a]=i.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,hf.scaleLinear)().domain([s,a]).range([0,e.width]):(0,hf.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,p,a,e),this._customLayoutFailedThisBuild=!1;const f=this.buildSceneNodes(y,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=f,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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 s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return i.sort("asc"===o?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:o,normalize:r,rExtent:i,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,p=s;if("radial"===o&&("pie"===n||"donut"===n))return[0,1];let m=0,y=0;if("bar"===n&&d&&r)m=0,y=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>y&&(y=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>y&&(y=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>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),m>t&&(m=t)}else{const e=h[0],t=h[1];e!==1/0&&(m=e),t!==-1/0&&(y=t)}i&&(null!=i[0]&&(m=i[0]),null!=i[1]&&(y=i[1]));const f="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(f&&null==i?.[0]&&null==i?.[1]&&(m>0&&(m=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-m,t=e>0?e*p:1,o=f&&!a&&0===m,r=f&&!a&&0===y||"swimlane"===n;null!=i?.[0]||o||(m-=t),null!=i?.[1]||r||(y+=t)}return[m,y]}({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:s,getO:a,getR:c}=e,l={},u=new Map;for(const e of t){const t=a(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(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let o;o="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(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,s;h?(i=m,s=h.get(e)||o.bandwidth(),m+=s+o.padding()*o.step()):(i=o(e)??0,s=o.bandwidth()),l[e]={name:e,x:i,y:0,width:s,middle:i+s/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=So("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 xo({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=xf[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 s=[],{projection:a}=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,s;"point"===e.type?(o=e.x,s=e.y):(o=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:o,y:s,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],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:i.x,y2:i.y,style:a,datum:r.datum,group:t})}}return s}(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=wf(n.colorScheme,n.themeCategorical,Cn),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:kf(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?En(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=On(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 s=e[i],a=n?t(s):s[o],c=r.get(a);c?c.push(i):r.set(a,[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:(0,Nf.quadtree)().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 s=e.color??"rgba(255,255,255,0.6)",a=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 s of r(t)??[]){const t=n.get(s);null!=t&&(o=Math.max(o,Fn(e,t,i)))}c=zn(l,o,s)||c;continue}if(null==l.datum)continue;const t=o.get(l.datum);if(null==t)continue;const u=n.get(t);c=zn(l,null==u?0:Fn(e,u,i),s,a)||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&&Hn(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],s=this.getNodeKey(i,e);s&&("rect"===i.type?this.prevPositionMap.set(s,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(s,{x:i.x,y:i.y,r:0,opacity:0}):"wedge"===i.type&&(void 0===o&&(o=i.startAngle),this.prevPositionMap.set(s,{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}`}if("rect"===e.type){const n=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",o=`r:${e.group||""}:${n}`,r=t.get(o)||0;return t.set(o,r+1),0===r?o:`${o}:${r}`}return"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??n.style.fillOpacity}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity??n.style.fillOpacity}):"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 s=this.prevPositionMap.get(i);if("point"===r.type)s?(n.add(i),r._targetOpacity=r.style.opacity??r.style.fillOpacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.r),t=!0)):(r._targetOpacity=r.style.opacity??r.style.fillOpacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)s?(n.add(i),r._targetOpacity=r.style.opacity??r.style.fillOpacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??r.style.fillOpacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(s)n.add(i),r._targetOpacity=r.style.opacity??r.style.fillOpacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??r.style.fillOpacity??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=Ln(e,this.activeTransition),n=_n(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=Dn(o?o.opacity??1:0,e._targetOpacity,n)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Dn(o.x,e._targetX,n),e.y=Dn(o.y,e._targetY,n)),void 0!==e._targetR&&void 0!==o?.r&&(e.r=Dn(o.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style.opacity=Dn(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=Dn(o.x,e._targetX,n),e.y=Dn(o.y,e._targetY,n),void 0!==o.w&&(e.w=Dn(o.w,e._targetW,n),e.h=Dn(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:Dn(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=Dn(o.startAngle,e._targetStartAngle,n),e.endAngle=Dn(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,function(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?void 0!==t._targetX?(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}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=Vt(e),n=this.getDataId,o=e=>t.has(n(e));_o(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=Vt(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&&!zt(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!zt(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!zt(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)&&(zt(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=qt(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)=>!zt(e,i[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Ht(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Ft)):(this.getR=Ht(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!zt(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?qt(this.config.stackBy):void 0),"groupBy"in e&&!zt(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?qt(this.config.groupBy):void 0),"colorAccessor"in e&&!zt(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?qt(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!zt(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?qt(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!zt(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?qt(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 Bf(e,t,n,o=30,r,i=0){let s=null;if(r){const e=Hr(r,t,n,o,i);e&&(s={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=Ef(i,t,n);break;case"point":if(r)break;e=Of(i,t,n,o);break;case"symbol":e=Ff(i,t,n,o);break;case"glyph":e=zf(i,t,n,o);break;case"wedge":if(null===i.datum)break;e=Hf(i,t,n);break;case"boxplot":e=Wf(i,t,n);break;case"violin":e=qf(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function Ef(e,t,n){const o=Pr(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function Of(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Ir(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function Ff(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Ir(yo(e.size),o)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function zf(e,t,n,o=30){if(null==e.datum)return null;const r=Fr(e.glyph,e.size),i=e.x+r.centerDx,s=e.y+r.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Ir(r.radius,o)?null:{datum:e.datum,x:i,y:s,distance:l}}function Hf(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 s=_r(Math.atan2(r,o)),a=_r(e.startAngle),c=_r(e.endAngle);if(!(a>c?s>=a||c>=s:s>=a&&c>=s))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 Wf(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 qf(e,t,n){if(!e.bounds)return null;const{x:o,y:r,width:i,height:s}=e.bounds;return o>t||t>o+i||r>n||n>r+s?null:{datum:e.datum,x:o+i/2,y:r+s/2,distance:0,category:e.category,stats:e.stats}}Fo($f);var Gf=require("react"),Yf=require("react/jsx-runtime");function Vf(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,showGrid:c,rFormat:l}=e,{rTickValues:u,axisExtent:d}=e,h="radial"===s?.projection,p="horizontal"===s?.projection,m=(0,Gf.useMemo)(()=>!s||h?[]:(u||nc(s.r,5,d)).map(e=>({value:e,pixel:s.r(e),label:(l||Xf)(e)})),[s,l,h,u,d]),y=c&&s&&!h,f=a&&s&&!h;return y||f?(0,Yf.jsx)("svg",{width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:(0,Yf.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(0,Yf.jsx)("g",{className:"ordinal-grid",children:m.map((e,o)=>(0,Yf.jsx)("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))}),f&&(0,Yf.jsx)(Yf.Fragment,{children:(0,Yf.jsxs)(Yf.Fragment,p?{children:[(0,Yf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Yf.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[(0,Yf.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Yf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function Xf(e){return Math.round(100*e)/100+""}function Uf(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,showCategoryTicks:c,oLabel:l,rLabel:u,oFormat:d,rFormat:h,showGrid:p,title:m,legend:y,legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:b,legendIsolatedCategories:v,legendPosition:x="right",legendLayout:w,foregroundGraphics:k,annotations:S,onAnnotationActivate:A,onObservation:C,chartId:M,chartType:j,autoPlaceAnnotations:P,svgAnnotationRules:I,xAccessor:R,yAccessor:T,annotationData:_,underlayRendered:L,canvasObscuresUnderlay:D=!0,children:N}=e,$=Xs({onAnnotationActivate:A,onObservation:C,chartId:M,chartType:j}),B="radial"===s?.projection,E="horizontal"===s?.projection,O=!1!==c,F=!L||D,z=(0,Gf.useMemo)(()=>{if(!a||!O||!s||B)return[];const e=s.o.bandwidth(),t=s.o.domain().map((t,n)=>({value:t,pixel:(s.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)},[a,O,s,d,B,E]),H=e.rTickValues,W=e.tickLabelEdgeAlign,q=e.axisExtent,G=(0,Gf.useMemo)(()=>a&&s&&!B?(H||nc(s.r,5,q)).map(e=>({value:e,pixel:s.r(e),label:(h||Xf)(e)})):[],[a,s,h,B,H,q]),Y=(0,Gf.useRef)(new Map),V=(0,Gf.useRef)(S?.length??0),X=S?.length??0;V.current!==X&&(V.current=X,Y.current=new Map);const U=(0,Gf.useMemo)(()=>{if(!S||0===S.length)return null;const e=Wa(S),o=ra(0,$),r="horizontal"===s?.projection,i=s?.o?e=>(s.o(e)??0)+s.o.bandwidth()/2:null,a={scales:s?{x:r?s.r:i||s.r,y:r&&i||s.r,time:s.r,value:s.r,o:s.o}:null,timeAxis:"x",xAccessor:R,yAccessor:T,width:t,height:n,data:_,frameType:"ordinal",projection:r?"horizontal":"vertical",stickyPositionCache:Y.current};return oa(P?ja({annotations:e,context:a,..."object"==typeof P?P:{}}):e,o,I,a)},[S,P,I,t,n,s,R,T,_,$]);return a||m||y||k||U&&U.length>0||p||N?(0,Yf.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Yf.jsx)("title",{children:"string"==typeof m?m:"Ordinal Chart"}),(0,Yf.jsx)("desc",{children:"string"==typeof m?m+" (ordinal data visualization)":"Ordinal data visualization"}),(0,Yf.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&!B&&F&&(0,Yf.jsx)("g",{className:"ordinal-grid",children:G.map((e,o)=>(0,Yf.jsx)("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))}),a&&s&&!B&&(()=>{const e={fontSize:"var(--semiotic-tick-font-size, 12px)"},o={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return(0,Yf.jsx)("g",{className:"ordinal-axes",children:(0,Yf.jsxs)(Yf.Fragment,E?{children:[(0,Yf.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[F&&(0,Yf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),z.map((t,n)=>(0,Yf.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Yf.jsx)("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?(0,Yf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",fontSize:12,className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):(0,Yf.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Yf.jsx)("div",{style:{textAlign:"right",userSelect:"none",...e},children:t.label})})]},"cat-"+n)),l&&(0,Yf.jsx)("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${n/2})`,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:l})]}),(0,Yf.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[F&&(0,Yf.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),F&&s?.r&&(()=>{const e=s.r(0);return e>1&&t-1>e?(0,Yf.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),G.map((t,o)=>{const r=W?0===o?"start":o===G.length-1?"end":"middle":"middle";return(0,Yf.jsxs)("g",{transform:`translate(${t.pixel},${n})`,children:[(0,Yf.jsx)("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Yf.jsx)("text",{y:18,textAnchor:r,fill:"var(--semiotic-text-secondary, #666)",fontSize:12,className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label})]},"val-"+o)}),u&&(0,Yf.jsx)("text",{x:t/2,y:n+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:u})]})]}:{children:[(0,Yf.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[F&&(()=>{const e=s?.r?s.r(0):n,o=0>e||e>n?n:e;return(0,Yf.jsx)("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),z.map((t,o)=>(0,Yf.jsxs)("g",{transform:`translate(${t.pixel},${n})`,children:[(0,Yf.jsx)("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?(0,Yf.jsx)("text",{y:18,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #666)",fontSize:12,className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label}):(0,Yf.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Yf.jsx)("div",{style:{textAlign:"center",userSelect:"none",...e},children:t.label})})]},"cat-"+o)),l&&(0,Yf.jsx)("text",{x:t/2,y:n+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:l})]}),(0,Yf.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[F&&(0,Yf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),G.map((t,n)=>(0,Yf.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Yf.jsx)("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Yf.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",fontSize:12,className:"semiotic-axis-tick",style:{userSelect:"none",...e},children:t.label})]},"val-"+n)),u&&(0,Yf.jsx)("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-i.left}, ${n/2})`,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...o},children:u})]})]})})})(),U,k,N]}),m&&"string"==typeof m?(0,Yf.jsx)("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?(0,Yf.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:m}):null,ys({legend:y,totalWidth:o,totalHeight:r,margin:i,legendPosition:x,title:m,legendLayout:w,axisChrome:{hasAxis:!!a&&!B,hasAxisLabel:E?!!u:!!l},legendHoverBehavior:f,legendClickBehavior:g,legendHighlightedCategory:b,legendIsolatedCategories:v})]}):null}var Kf=d(require("react")),Qf=require("react/jsx-runtime"),Zf=null,Jf=null;function eg(e){const[t,n]=Kf.useState(()=>Zf);return Kf.useEffect(()=>{if(t)return;let e=!1;return(Zf?Promise.resolve(Zf):(Jf||(Jf=Promise.resolve().then(()=>(be(),fe)).then(e=>Zf=e.OrdinalBrushOverlay).catch(e=>{throw Jf=null,e})),Jf)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,Qf.jsx)(t,{...e}):null}var tg=require("d3-shape");function ng(e,t){const n=t._gradientBand.colors;if(0===n.length)return;const{clipPath:o,slices:r}=Nc({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=Xr(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=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(i),e.restore())}function og(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 rg(e,t){const n={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},o=(0,tg.arc)().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 ig=(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)ng(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(og(e,t),Uu(e,t)),e.globalAlpha=1;else{if(e.fillStyle=ai(e,t.style.fill,"#007bff"),t.roundedEnds){t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1);const n=Dc({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=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),rg(e,t)):(og(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()));t._pulseIntensity&&t._pulseIntensity>0&&(og(e,t),Uu(e,t)),e.globalAlpha=1}},sg=(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=Xr(e,"var(--semiotic-primary, #007bff)"),i=Xr(e,"var(--semiotic-text, #333)"),s=ai(e,t.style.fill,r),a=t.style.stroke,c="string"==typeof a?Xr(e,a)||a: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=s,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()}},ag=(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=ai(e,t.style.fill,"#007bff"),e.fill(n),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xr(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()}},cg=(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=ci(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=Xr(e,n.style.stroke)||ai(e,n.style.fill,"")||Xr(e,"var(--semiotic-border, #999)"),e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=n.style.opacity??.5,e.stroke(),e.globalAlpha=1}},lg=(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=ci(e,t.style?.fill)||"#999",e.fill(),t.style?.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Xr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}};function ug(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 dg(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}var hg=new Map;function pg(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=hg.get(n);if(void 0!==o)return o;const r=Zr({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t),i=ei(r)?null:r;return hg.set(n,i),i}function mg(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 yg(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 fg(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}function gg(e){return"rect"===e.type||"point"===e.type||"symbol"===e.type||"glyph"===e.type}function bg(e){return(t,n,o,r)=>{e(t,n.filter(gg),{x:o.r,y:o.r},r)}}var vg=bg(ld),xg=bg(ed),wg=bg(od),kg=bg(id),Sg=e=>[cg,...e],Ag={bar:Sg([vg]),clusterbar:Sg([vg]),point:Sg([xg,wg]),swarm:Sg([xg,wg]),pie:[ig],donut:[ig],boxplot:Sg([sg,xg]),violin:Sg([ag]),histogram:Sg([vg]),ridgeline:Sg([ag]),timeline:Sg([vg]),funnel:[vg,lg,(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,s=!0===n.__funnelIsFirstStep;let a;if(a=s?ug(r):null!=i?`${ug(r)} (${dg(i)})`:ug(r),e.measureText(a).width+16>o){if(s||null==i)continue;if(a=ug(r),e.measureText(a).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(a,c,l),e.fillStyle="#fff",e.fillText(a,c,l)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[vg,(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)||Xr(e,"var(--semiotic-border, #999)"),o=pg(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]=Ur(e,t);return(.2126*n+.7152*o+.0722*r)/255>.6}(e,Xr(e,"var(--semiotic-text, #333)")),s=i?"#1f2937":"#ffffff",a=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?fg(r):"",d=yg(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,y=i?32:17,f=n.__barFunnelLabelX,g=f-m/2,b=n.__barFunnelLabelY-y-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=s,e.beginPath(),mg(e,g,b,m,y,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),mg(e,g,b,m,y,4),e.stroke(),e.textAlign="center",e.textBaseline="top",i?(e.font="bold 13px sans-serif",e.fillStyle=c,e.fillText(u,f,b+3),e.font="11px sans-serif",e.fillStyle=l,e.fillText(d,f,b+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=c,e.fillText(d,f,b+3))}e.lineWidth=1}],swimlane:Sg([vg]),custom:Sg([vg,xg,wg,kg,ig,sg,ag,lg])},Cg=require("react/jsx-runtime");function Mg(e){const t=Zl(e,{skipPositional:!1});return null==t.title&&0===t.entries.length?null:(0,Cg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=t.title&&(0,Cg.jsx)("div",{style:{fontWeight:"bold"},children:t.title+""}),t.entries.map(e=>(0,Cg.jsxs)("div",{children:[(0,Cg.jsxs)("span",{style:{opacity:.7},children:[e.key,":"]})," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]},e.key))]})}function jg({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(0,Cg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[e&&(0,Cg.jsx)("div",{style:{fontWeight:"bold"},children:e+""}),(0,Cg.jsxs)("div",{children:["n = ",n.n]}),(0,Cg.jsxs)("div",{children:["Min: ",n.min.toLocaleString()]}),(0,Cg.jsxs)("div",{children:["Q1: ",n.q1.toLocaleString()]}),(0,Cg.jsxs)("div",{children:["Median: ",n.median.toLocaleString()]}),(0,Cg.jsxs)("div",{children:["Q3: ",n.q3.toLocaleString()]}),(0,Cg.jsxs)("div",{children:["Max: ",n.max.toLocaleString()]}),(0,Cg.jsxs)("div",{style:{opacity:.8},children:["Mean: ",n.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const r=t.length;return(0,Cg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[e&&(0,Cg.jsx)("div",{style:{fontWeight:"bold"},children:e+""}),(0,Cg.jsxs)("div",{children:[r," items"]})]})}if(null!=t.bin&&null!=t.count){const e=t.range||[];return(0,Cg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[t.category&&(0,Cg.jsx)("div",{style:{fontWeight:"bold"},children:t.category+""}),(0,Cg.jsxs)("div",{children:["Count: ",t.count]}),2===e.length&&(0,Cg.jsxs)("div",{style:{opacity:.8},children:[Number(e[0]).toFixed(1)," – ",Number(e[1]).toFixed(1)]})]})}const r=e.__oAccessor,i=e.__rAccessor,s=e.__chartType;if("swarm"===s||"point"===s)return Mg(t);const a=(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 a||""!==c?(0,Cg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[a&&(0,Cg.jsx)("div",{style:{fontWeight:"bold"},children:a+""}),""!==c&&(0,Cg.jsx)("div",{children:"number"==typeof c?c.toLocaleString():c+""})]}):Mg(t)}jg.ownsChrome=!0;var Pg=require("react/jsx-runtime"),Ig={top:50,right:40,bottom:60,left:70},Rg=(0,df.memo)((0,df.forwardRef)(function(e,t){const{chartType:n,runtimeMode:o,data:r,oAccessor:i="category",rAccessor:s="value",colorAccessor:a,symbolAccessor:c,symbolMap:l,stackBy:u,groupBy:d,multiAxis:h,timeAccessor:p,valueAccessor:m,categoryAccessor:y,accessorRevision:f,projection:g="vertical",size:b=[600,400],responsiveWidth:v,responsiveHeight:x,margin:w,maxDevicePixelRatio:k,barPadding:S,roundedTop:A,gradientFill:C,trackFill:M,baselinePadding:j,innerRadius:P,cornerRadius:I,normalize:R,startAngle:T,sweepAngle:_,dynamicColumnWidth:L,bins:D,showOutliers:N,showIQR:$,amplitude:B,connectorOpacity:E,showLabels:O,connectorAccessor:F,connectorStyle:z,dataIdAccessor:H,rExtent:W,oExtent:q,extentPadding:G=.05,oSort:Y,windowMode:V="sliding",windowSize:X=200,pieceStyle:U,summaryStyle:K,renderMode:Q,colorScheme:Z,barColors:J,showAxes:ee=!0,showCategoryTicks:te,categoryLabel:ne,valueLabel:oe,categoryFormat:re,valueFormat:ie,oLabel:se,rLabel:ae,oFormat:ce,rFormat:le,rTickValues:ue,tickLabelEdgeAlign:de,axisExtent:he,enableHover:pe=!0,hoverAnnotation:me,tooltipContent:ye,customHoverBehavior:fe,customClickBehavior:ge,onObservation:be,annotationObservationCallback:ve,chartId:xe,annotations:we,onAnnotationActivate:ke,autoPlaceAnnotations:Se,svgAnnotationRules:Ae,showGrid:Ce=!1,legend:Me,legendHoverBehavior:je,legendClickBehavior:Pe,legendHighlightedCategory:Ie,legendIsolatedCategories:Re,legendPosition:Te,legendLayout:_e,legendCategoryAccessor:Le,onCategoriesChange:De,backgroundGraphics:Ne,foregroundGraphics:$e,title:Be,className:Ee,background:Oe,centerContent:Fe,decay:ze,pulse:He,transition:We,animate:qe,staleness:Ge,frameScheduler:Ye,clock:Ve,random:Xe,seed:Ue,paused:Ke=!1,suspendWhenHidden:Qe=!0,brush:Ze,onBrush:Je,accessibleTable:et=!0,description:tt,summary:nt,customLayout:ot,onLayoutError:rt,layoutConfig:it,layoutSelection:st}=e,{customHoverBehavior:at,customClickBehavior:ct,hasClickBehavior:lt}=Ed({customHoverBehavior:fe,customClickBehavior:ge,onObservation:be,chartId:xe,chartType:"StreamOrdinalFrame"}),ut=y??i,dt=m??s,ht=(0,df.useRef)(!0),pt=Cu({sizeProp:b,responsiveWidth:v,responsiveHeight:x,userMargin:w,marginDefault:Ig,title:Be,legend:Me,legendPosition:Te,animate:qe,transitionProp:We,frameScheduler:Ye,clock:Ve,random:Xe,seed:Ue,paused:Ke,suspendWhenHidden:Qe,themeDirtyRef:ht}),{reducedMotionRef:mt,responsiveRef:yt,size:gt,margin:bt,adjustedWidth:vt,adjustedHeight:xt,currentTheme:wt,transition:kt,introEnabled:St,tableId:Ct,rafRef:Mt,renderFnRef:jt,scheduleRender:Pt,frameRuntime:It}=pt,Tt=Gc(),_t=Uc(),Lt=(0,df.useMemo)(()=>ft(r),[r]),Dt=ne??se,Nt=oe??ae,$t=re??ce,Bt=ie??le,Et=(0,df.useRef)(null),[Ot,Ft]=(0,df.useState)(null),[zt,Ht]=(0,df.useState)(null),Wt=Du($e,gt,bt,zt),qt=Du(Ne,gt,bt,zt),Gt=Ne||"transparent"===Oe?null:(0,Pg.jsx)("rect",{className:"semiotic-canvas-background","data-semiotic-layer":"canvas-background",x:-bt.left,y:-bt.top,width:gt[0],height:gt[1],fill:Oe||"var(--semiotic-bg, transparent)"}),[Yt,Vt]=(0,df.useState)(0),Xt=(0,df.useRef)(0),[Ut,Kt]=(0,df.useState)(!1),Qt=(0,df.useRef)({w:-1,h:-1}),Zt=(0,df.useRef)(!1),Jt=yr("StreamOrdinalFrame"),en=pe||me,tn="streaming"===o,nn=Qc((0,df.useMemo)(()=>({chartType:n,runtimeMode:tn?"streaming":"bounded",windowSize:X,windowMode:V,extentPadding:G,projection:g,oAccessor:tn?void 0:ut,rAccessor:tn?void 0:dt,accessorRevision:f,colorAccessor:a,symbolAccessor:c,symbolMap:l,stackBy:u,groupBy:d,multiAxis:h,timeAccessor:tn?p:void 0,valueAccessor:tn?m||("string"==typeof dt||"function"==typeof dt?dt:void 0):void 0,categoryAccessor:tn?ut:void 0,rExtent:W,oExtent:q,axisExtent:he,barPadding:S,roundedTop:A,gradientFill:ao(C),trackFill:M,baselinePadding:j,innerRadius:P,cornerRadius:I,normalize:R,startAngle:T,sweepAngle:_,dynamicColumnWidth:L,bins:D,showOutliers:N,showIQR:$,amplitude:B,connectorOpacity:E,showLabels:O,connectorAccessor:F,connectorStyle:z,dataIdAccessor:H,oSort:Y,pieceStyle:U,summaryStyle:K,colorScheme:Z,themeCategorical:wt?.colors?.categorical,themeSemantic:Rt(wt),themeSequential:wt?.colors?.sequential,themeDiverging:wt?.colors?.diverging,barColors:J,decay:ze,pulse:He,transition:kt,introAnimation:St,staleness:Ge,clock:It.now,customLayout:ot,onLayoutError:rt,layoutConfig:it,layoutMargin:bt}),[n,tn,X,V,G,g,ut,dt,f,a,c,l,u,d,h,p,m,W,q,he,S,A,C,M,j,P,I,R,T,_,L,D,N,$,B,E,O,F,z,H,Y,U,K,Z,wt,J,ze,He,kt,St,Ge,It.now,ot,rt,it,bt])),on=(0,df.useRef)(null);on.current||(on.current=new $f(nn));const rn=$u(on,Le,De,e=>e.getData());Mr(on,nn,ht,Pt),jr(on,st,ht,Pt);const sn=(0,df.useRef)(null);sn.current||(sn.current=new At(e=>{const t=on.current;t&&t.ingest(e)&&(ht.current=!0,Pt())}));const an=(0,df.useCallback)(e=>{sn.current?.push(e)},[]),cn=(0,df.useCallback)(e=>{sn.current?.pushMany(e)},[]),ln=(0,df.useCallback)(()=>{sn.current?.clear(),on.current?.clear(),ht.current=!0,Pt()},[Pt]),un=(0,df.useCallback)(e=>{sn.current?.clearLastData(),sn.current?.setReplacementData(e)},[]);(0,df.useImperativeHandle)(t,()=>({push:an,pushMany:cn,replace:un,remove:e=>{sn.current?.flush();const t=on.current?.remove(e)??[];if(t.length>0){const e=Et.current?.data;!!Et.current&&t.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Et.current=null,Ft(null)),ht.current=!0,Pt()}return t},update:(e,t)=>{sn.current?.flush();const n=on.current?.update(e,t)??[];return n.length>0&&(ht.current=!0,Pt()),n},clear:ln,getData:()=>(sn.current?.flush(),on.current?.getData()??[]),getScales:()=>on.current?.scales??null,getCustomLayout:()=>on.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>on.current?.lastCustomLayoutFailure??null}),[an,cn,un,ln,Pt]),(0,df.useEffect)(()=>{r&&sn.current?.setBoundedData(Lt)},[r,Lt]);const{canvasRef:dn,resolutionDirtyRef:hn}=Tu(pt,{storeRef:on,dirtyRef:ht,hydrated:Tt,wasHydratingFromSSR:_t,cleanup:()=>sn.current?.clear(),maxDevicePixelRatio:k,canvasPaintDependencies:[n,vt,xt,ee,Oe,Ne,Q,Pt]}),{hoverHandlerRef:pn,hoverLeaveRef:mn,onPointerMove:yn,onPointerLeave:fn}=pt;pn.current=e=>{if(!en)return;const t=dn.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-bt.left,i=e.clientY-o.top-bt.top;if(0>r||r>vt||0>i||i>xt)return void(Et.current&&(Et.current=null,Ft(null),at&&at(null),Pt()));const s=on.current;if(!s||0===s.scene.length)return;const a="radial"===g,c=Bf(s.scene,a?r-vt/2:r,a?i-xt/2:i,30,s.pointQuadtree,s.maxPointRadius);if(!c)return void(Et.current&&(Et.current=null,Ft(null),at&&at(null),Pt()));const l=Yl(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof ut?ut:void 0,__rAccessor:"string"==typeof dt?dt:void 0,__chartType:n});Et.current=l,Ft(l),at?.(l),Pt()},mn.current=()=>{Et.current&&(Et.current=null,Ft(null),at?.(null),Pt())};const gn=(0,df.useCallback)(e=>{if(Qs(e.target))return;if(!ct)return;const t=dn.current;if(!t)return ct(null),void Pt();const o=t.getBoundingClientRect(),r=e.clientX-o.left-bt.left,i=e.clientY-o.top-bt.top;if(0>r||r>vt||0>i||i>xt)return ct(null),void Pt();const s=on.current;if(!s||0===s.scene.length)return ct(null),void Pt();const a="radial"===g,c=Bf(s.scene,a?r-vt/2:r,a?i-xt/2:i,30,s.pointQuadtree,s.maxPointRadius);if(!c)return ct(null),void Pt();ct(Yl(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof ut?ut:void 0,__rAccessor:"string"==typeof dt?dt:void 0,__chartType:n}),{type:"activate",inputType:Ld(e.nativeEvent.pointerType)}),Pt()},[ct,dn,bt.left,bt.top,vt,xt,g,ut,dt,n,Pt]),{kbFocusIndexRef:bn,focusedNavPointRef:vn,onKeyDown:xn}=function({chartType:e,oAccessor:t,rAccessor:n,...o}){return Xd({...o,extractPoints:Gd,toHover:o=>({...Vd(o),__oAccessor:"string"==typeof t?t:void 0,__rAccessor:"string"==typeof n?n:void 0,__chartType:e})})}({storeRef:on,hoverRef:Et,setHoverPoint:Ft,customHoverBehavior:at,customClickBehavior:ct,scheduleRender:Pt,chartType:n,oAccessor:ut,rAccessor:dt}),wn=(0,df.useCallback)(e=>{bn.current=-1,vn.current=null,yn(e)},[vn,bn,yn]);jt.current=()=>{if(Mt.current=null,!It.isActive)return;const e=dn.current;if(!e)return;const t=e.getContext("2d");if(!t)return;const o=on.current;if(!o)return;const r=It.now(),i=o.advanceTransition(mt.current?r+1e6:r),s=!mt.current&&i,a=Qt.current.w!==vt||Qt.current.h!==xt,c=ht.current;let l=!1;const u=Jt.current.beforeCompute(o.getLastUpdateResult(),s);!c&&!a||s&&!a||(o.computeScene({width:vt,height:xt}),Qt.current={w:vt,h:xt},l=!0,rn()),Jt.current.afterCompute(u,l,a),ht.current=c&&s&&!l,hn.current=!1;const d=Lu(o,r,l,Zt);(l||s)&&e.setAttribute("aria-label",wl(o.scene,n+" chart"));const h=Pu(k),p=gt[0]*h,m=gt[1]*h;e.width===p&&e.height===m||(e.width=p,e.height=m,e.style.width=gt[0]+"px",e.style.height=gt[1]+"px"),t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,gt[0],gt[1]);const y=Ge&&o.lastIngestTime>0&&r-o.lastIngestTime>(Ge?.threshold??5e3);y&&(t.globalAlpha=Ge?.dimOpacity??.5);const f="radial"===g;t.save(),t.beginPath(),t.rect(bt.left,bt.top,vt,xt),t.clip(),f?(t.save(),t.translate(bt.left+vt/2,bt.top+xt/2)):t.translate(bt.left,bt.top);const b=ot?Ag.custom:Ag[n]||[],v={width:vt,height:xt},x=o.scales;x&&vd({context:t,nodes:o.scene,renderMode:Q,pixelRatio:h,paintBuiltIn:e=>{for(const n of b)n(t,e,x,v)}}),f&&t.restore(),t.restore(),y&&(t.globalAlpha=1),l&&o.scales?(Ht(o.scales),Vt(e=>e+1),Xt.current=r):s&&o.scales&&r-Xt.current>=33&&(Vt(e=>e+1),Xt.current=r),Ge?.showBadge&&Kt(!!y),(s||null!=o.activeTransition||d.pending)&&Pt()},_i(Ge,on,ht,Pt,Ut,Kt);const kn=en&&Ot?ye?ye(Ot):(0,Pg.jsx)(jg,{hover:Ot}):null,Sn="radial"===g,An=kn?(0,Pg.jsx)(uu,{x:Ot?Sn?Ot.x+vt/2:Ot.x:0,y:Ot?Sn?Ot.y+xt/2:Ot.y:0,containerWidth:vt,containerHeight:xt,margin:bt,className:"stream-ordinal-tooltip",children:kn}):null,Cn="horizontal"===g?ut:dt,Mn=Bu("horizontal"===g?dt:ut,void 0,"__semiotic_resolvedO",""),jn=Bu(Cn,void 0,"__semiotic_resolvedR",""),Pn=Mn.key,In=jn.key,Rn=Eu(Mn,jn,we&&we.length>0||!1);if(Hc||!Tt&&_t){const e=on.current;e&&r&&(e.ingest({inserts:Lt,bounded:!0}),e.computeScene({width:vt,height:xt}));const t=e?.scene??[],n=e?.scales??null,o=Du($e,gt,bt,n),i=Du(Ne,gt,bt,n),s="radial"===g,a=s?bt.left+vt/2:bt.left,c=s?bt.top+xt/2:bt.top;return(0,Pg.jsxs)("div",{ref:yt,className:"stream-ordinal-frame"+(Ee?" "+Ee:""),role:"img","aria-label":tt||("string"==typeof Be?Be:"Ordinal chart"),style:{position:"relative",width:v?"100%":gt[0],height:x?"100%":gt[1]},children:[(0,Pg.jsx)(El,{summary:nt}),(0,Pg.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:gt[0],height:gt[1],style:{position:"absolute",left:0,top:0},children:[i&&(0,Pg.jsx)("g",{transform:`translate(${bt.left},${bt.top})`,children:i}),(0,Pg.jsxs)("g",{transform:`translate(${a},${c})`,children:[Oe&&(0,Pg.jsx)("rect",{x:0,y:0,width:vt,height:xt,fill:Oe}),t.map((e,t)=>xd({node:e,index:t,renderMode:Q,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=kc(i)+"-grad",o=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=e.x,r=e.y,i=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(o=e.x+e.w,r=e.y,i=e.x,s=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,i=e.x+e.w,s=e.y);const a=Ac(n.stops,wc(e.style.fill));return a?(0,vc.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:i,y2:s,children:a}):null}(t,n);let r,s;if(o)s=`url(#${n})`;else if(ei(t.style.fill)){const e=kc(i)+"-hatch";r=oi(t.style.fill,e),s=`url(#${e})`}else s=wc(t.style.fill);const a=o||r?(0,$c.jsxs)("defs",{children:[o,r]}):null;if(t.cornerRadii&&gc(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:o,h:r}=e,{tl:i,tr:s,br:a,bl:c}=bc(e);let l=`M${t+i},${n}`;return l+=` L${t+o-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+o},${n+s}`),l+=` L${t+o},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+o-a},${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(0,$c.jsxs)(Tc.Fragment,{children:[a,(0,$c.jsx)("path",{d:e,fill:s,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(0,$c.jsxs)(Tc.Fragment,{children:[a,(0,$c.jsx)("path",{d:l,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return(0,$c.jsxs)(Tc.Fragment,{children:[a,(0,$c.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth}),Ec(t,i)]},i)}case"point":{const t=e;return(0,$c.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:wc(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return Cc(e,t,n);case"glyph":return Sc(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=kc(`${n?n+"-":""}gauge-grad-${o.category||i}-${t}`),{clipPath:r,slices:s}=Nc({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(0,$c.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,$c.jsx)("defs",{children:(0,$c.jsx)("clipPath",{id:e,children:(0,$c.jsx)("path",{d:r})})}),(0,$c.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,$c.jsx)("path",{d:e.d,fill:wc(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&(0,$c.jsx)("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},i)}let r;if(o.roundedEnds)r=Dc({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=(0,_c.arc)().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(xc)||""}return(0,$c.jsx)("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:wc(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(0,$c.jsxs)("g","vertical"===t.projection?{children:[(0,$c.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:wc(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,$c.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("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:[(0,$c.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:wc(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,$c.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,$c.jsx)("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=[(0,$c.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:wc(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;t.iqrLine.isVertical?n.push((0,$c.jsx)("line",{x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,$c.jsx)("circle",{cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,$c.jsx)("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,$c.jsx)("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,$c.jsx)("g",{children:n},i)}case"connector":return(0,$c.jsx)("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(0,$c.jsx)("polygon",{points:n,fill:wc(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)]})]}),(0,Pg.jsx)(Uf,{width:vt,height:xt,totalWidth:gt[0],totalHeight:gt[1],margin:bt,scales:n,showAxes:ee,showCategoryTicks:te,oLabel:Dt,rLabel:Nt,oFormat:$t,rFormat:Bt,rTickValues:ue,tickLabelEdgeAlign:de,axisExtent:he,showGrid:Ce,title:Be,legend:Me,legendHoverBehavior:je,legendClickBehavior:Pe,legendHighlightedCategory:Ie,legendIsolatedCategories:Re,legendPosition:Te,legendLayout:_e,foregroundGraphics:br(o,Ar(on.current?.customLayoutOverlays,st??null)),annotations:we,onAnnotationActivate:ke,onObservation:ve??be,chartId:xe,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:Se,svgAnnotationRules:Ae,annotationFrame:0,xAccessor:Pn,yAccessor:In,annotationData:Rn(e?.getData())}),Fe&&"radial"===g&&(0,Pg.jsx)("div",{style:{position:"absolute",left:bt.left+vt/2,top:bt.top+xt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Fe})]})}return(0,Pg.jsxs)("div",{ref:yt,className:"stream-ordinal-frame"+(Ee?" "+Ee:""),role:"group","aria-label":tt||("string"==typeof Be?Be:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:v?"100%":gt[0],height:x?"100%":gt[1],overflow:"visible"},onKeyDown:xn,children:["production"!==process.env.NODE_ENV&&on.current&&(0,Pg.jsx)(fr,{store:on.current,diagnostics:Jt.current}),et&&(0,Pg.jsx)(Ol,{tableId:Ct}),et&&(0,Pg.jsx)($l,{scene:on.current?.scene??[],chartType:n+" chart",tableId:Ct,chartTitle:"string"==typeof Be?Be:void 0}),(0,Pg.jsx)(El,{summary:nt}),(0,Pg.jsx)(yl,{hoverPoint:Ot}),(0,Pg.jsxs)("div",{role:"img","aria-label":tt||("string"==typeof Be?Be:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:en?wn:void 0,onMouseLeave:en?fn:void 0,onClick:lt?gn:void 0,children:[(0,Pg.jsxs)(_u,{size:gt,margin:bt,children:[Gt,qt]}),(0,Pg.jsx)(Vf,{width:vt,height:xt,totalWidth:gt[0],totalHeight:gt[1],margin:bt,scales:zt,showAxes:ee,showGrid:Ce,rFormat:Bt,rTickValues:ue,axisExtent:he}),(0,Pg.jsx)("canvas",{ref:dn,"aria-label":wl(on.current?.scene??[],n+" chart"),style:{position:"absolute",top:0,left:0,width:gt[0],height:gt[1]}}),(0,Pg.jsx)(Uf,{width:vt,height:xt,totalWidth:gt[0],totalHeight:gt[1],margin:bt,scales:zt,showAxes:ee,showCategoryTicks:te,oLabel:Dt,rLabel:Nt,oFormat:$t,rFormat:Bt,rTickValues:ue,axisExtent:he,showGrid:Ce,title:Be,legend:Me,legendHoverBehavior:je,legendClickBehavior:Pe,legendHighlightedCategory:Ie,legendIsolatedCategories:Re,legendPosition:Te,legendLayout:_e,foregroundGraphics:br(Wt,Ar(on.current?.customLayoutOverlays,st??null)),annotations:we,onAnnotationActivate:ke,onObservation:ve??be,chartId:xe,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:Se,svgAnnotationRules:Ae,annotationFrame:Yt,xAccessor:Pn,yAccessor:In,annotationData:Rn(on.current?.getData()),underlayRendered:!0,canvasObscuresUnderlay:!1}),(Ze||Je)&&"radial"!==g&&(0,Pg.jsx)(eg,{width:vt,height:xt,totalWidth:gt[0],totalHeight:gt[1],margin:bt,scales:zt,onBrush:Je||(()=>{})}),Fe&&"radial"===g&&(0,Pg.jsx)("div",{style:{position:"absolute",left:bt.left+vt/2,top:bt.top+xt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Fe}),Ge?.showBadge&&(0,Pg.jsx)(Di,{isStale:Ut,position:Ge.badgePosition}),(0,Pg.jsx)(Hl,{active:bn.current>=0,hoverPoint:Ot,margin:bt,size:gt,shape:vn.current?.shape,width:vn.current?.w,height:vn.current?.h}),An]})]})}));Rg.displayName="StreamOrdinalFrame";var Tg=Rg,_g=require("react");function Lg({ref:e,frameRef:t,setup:n}){return(0,_g.useImperativeHandle)(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)??[],replace:e=>t.current?.replace(e),clear:()=>t.current?.clear(),getData:()=>t.current?.getData()??[],getScales:()=>t.current?.getScales()??null}),[t]),{effectiveLegendProps:n.legendBehaviorProps,effectiveMargin:n.margin}}var Dg=require("react");function Ng(e){const{colorBy:t,colorScale:n,color:o,themeCategorical:r,colorScheme:i,categoryIndexMap:s,userPieceStyle:a,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:d,resolvedSelection:h,cycleByCategory:p=!1,baseStyleExtras:m,linkStrokeToFill:y=!1,styleRules:f,resolveRuleValue:g}=e,b=(0,Dg.useMemo)(()=>(e,a)=>{const c="function"==typeof m?m(e,a):m,l=c?{...c}:{};if(void 0===l.fill)if(t){if(!n)return l;l.fill=Pn(e,t,n)}else l.fill=gp(o,r,i,p?a:void 0,s);if(f&&f.length>0){const t=tm(e,f,{value:g?g(e):void 0,category:a});Object.assign(l,t)}return y&&void 0===l.stroke&&void 0!==l.fill&&(l.stroke=l.fill),l},[t,n,o,r,i,s,p,m,y,f,g]),v=(0,Dg.useMemo)(()=>Up(a?"function"==typeof a?(e,t)=>({...b(e,t),...a(e,t)||{}}):(e,t)=>({...b(e,t),...a}):b,{stroke:c,strokeWidth:l,opacity:u}),[b,a,c,l,u]);return(0,Dg.useMemo)(()=>uh(v,d??null,h),[v,d,h])}var $g=require("react/jsx-runtime"),Bg=(0,uf.forwardRef)(function(e,t){const n=kp(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=(0,uf.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="vertical",valueFormat:u,colorBy:d,colorScheme:h,sort:p=!1,barPadding:m=40,roundedTop:y,gradientFill:f=!1,styleRules:g,baselinePadding:b=!1,tooltip:v,annotations:x,regression:w,valueExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:j,hoverHighlight:P,chartId:I,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:D,color:N,stroke:$,strokeWidth:B,opacity:E,showCategoryTicks:O,categoryFormat:F,dataIdAccessor:z}=e,{width:H,height:W,enableHover:q,showGrid:G,showLegend:Y,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=n,J=(0,uf.useMemo)(()=>ft(r),[r]),ee=Vp({data:J,rawData:r,colorBy:d,colorScheme:h,legendInteraction:L,legendPosition:D,selection:A,linkedHover:C,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"BarChart",chartId:I,showLegend:Y,userMargin:i,marginDefaults:n.marginDefaults,loading:R,loadingContent:T,emptyContent:_,width:H,height:W,hasTitle:!!V,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Q,hasValueLabel:!!Z})}),{effectiveLegendProps:te,effectiveMargin:ne}=Lg({ref:t,frameRef:o,setup:ee});Np("BarChart",J,"categoryAccessor",a),Np("BarChart",J,"valueAccessor",c);const oe=vp(J,p,c),re=fp(),ie=(0,uf.useMemo)(()=>new Map,[]),se=(0,uf.useMemo)(()=>Kp(c),[c]),ae=Ng({colorBy:d,colorScale:ee.colorScale,color:N,themeCategorical:re,colorScheme:h,categoryIndexMap:ie,userPieceStyle:S?.pieceStyle,stroke:$,strokeWidth:B,opacity:E,styleRules:g,resolveRuleValue:se,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ce=(0,uf.useMemo)(()=>Id({categoryAccessor:a,valueAccessor:c,groupAccessor:d&&d!==a?d:void 0,groupLabel:"string"==typeof d?d:"group",valueFormat:u}),[a,c,d,u]),le=(0,uf.useMemo)(()=>ao(f),[f]);if(ee.earlyReturn)return ee.earlyReturn;const ue=zp({componentName:"BarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ue)return(0,$g.jsx)(Ap,{componentName:"BarChart",message:ue,width:H,height:W});const de=sy(w),he=de?[de,...x||[]]:x,pe={chartType:"bar",...null!=r&&{data:oe},oAccessor:a,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:ae,size:[H,W],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ne,barPadding:m,...null!=y&&{roundedTop:y},...le&&{gradientFill:le},...z&&{dataIdAccessor:z},baselinePadding:b,enableHover:q,showAxes:n.showAxes,oLabel:Q,rLabel:Z,rFormat:u,...F&&{oFormat:F},showGrid:G,showCategoryTicks:O,oSort:p,...te,...sm({title:V,description:X,summary:U,accessibleTable:K,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:v,defaultTooltipContent:ce}),...am({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:ee.mobileInteraction,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior}),...he&&he.length>0&&{annotations:he},...k&&{rExtent:k},...Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e))};return(0,$g.jsx)(Rp,{componentName:"BarChart",width:H,height:W,children:(0,$g.jsx)(Tg,{ref:o,...pe})})});Bg.displayName="BarChart";var Eg=require("react"),Og=require("react/jsx-runtime"),Fg=(0,Eg.forwardRef)(function(e,t){const n=kp(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=(0,Eg.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",stackBy:c,valueAccessor:l="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:p,normalize:m=!1,sort:y=!1,barPadding:f=40,roundedTop:g,gradientFill:b,styleRules:v,baselinePadding:x=!1,tooltip:w,annotations:k,valueExtent:S,frameProps:A={},selection:C,linkedHover:M,onObservation:j,onClick:P,hoverHighlight:I,chartId:R,loading:T,loadingContent:_,emptyContent:L,legendInteraction:D,legendPosition:N,color:$,stroke:B,strokeWidth:E,opacity:O,categoryFormat:F}=e,{width:z,height:H,enableHover:W,showGrid:q,showLegend:G,title:Y,description:V,summary:X,accessibleTable:U,categoryLabel:K,valueLabel:Q}=n,Z=(0,Eg.useMemo)(()=>ft(r),[r]),J=h||c,ee=Vp({data:Z,rawData:r,colorBy:J,colorScheme:p,legendInteraction:D,legendPosition:N,selection:C,linkedHover:M,fallbackFields:J?["string"==typeof J?J:""]:[],unwrapData:!0,onObservation:j,onClick:P,hoverHighlight:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"StackedBarChart",chartId:R,showLegend:G,userMargin:i,marginDefaults:n.marginDefaults,loading:T,loadingContent:_,emptyContent:L,width:z,height:H,hasTitle:!!Y,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===u?"horizontal":"vertical",hasCategoryLabel:!!K,hasValueLabel:!!Q})}),te=fp(),ne=(0,Eg.useMemo)(()=>new Map,[]),oe=(0,Eg.useMemo)(()=>Kp(l),[l]),re=Ng({colorBy:J,colorScale:ee.colorScale,color:$,themeCategorical:te,colorScheme:p,categoryIndexMap:ne,userPieceStyle:A?.pieceStyle,stroke:B,strokeWidth:E,opacity:O,styleRules:v,resolveRuleValue:oe,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ie=(0,Eg.useMemo)(()=>Id({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),se=zp({componentName:"StackedBarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:c}}),{effectiveLegendProps:ae,effectiveMargin:ce}=Lg({ref:t,frameRef:o,setup:ee}),le=(0,Eg.useMemo)(()=>ao(b),[b]);if(ee.earlyReturn)return ee.earlyReturn;const ue={chartType:"bar",...null!=r&&{data:Z},oAccessor:a,rAccessor:l,stackBy:c,normalize:m,oSort:y,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:re,size:[z,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ce,barPadding:f,...null!=g&&{roundedTop:g},...le&&{gradientFill:le},baselinePadding:x,enableHover:W,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:K,rLabel:Q,rFormat:d,...F&&{oFormat:F},showGrid:q,...ae,...sm({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:w,defaultTooltipContent:ie}),...am({linkedHover:M,selection:C,onObservation:j,onClick:P,hoverHighlight:I,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 se?(0,Og.jsx)(Ap,{componentName:"StackedBarChart",message:se,width:z,height:H}):(0,Og.jsx)(Rp,{componentName:"StackedBarChart",width:z,height:H,children:(0,Og.jsx)(Tg,{ref:o,...ue})})});Fg.displayName="StackedBarChart";var zg=require("react"),Hg=require("react/jsx-runtime"),Wg=(0,zg.forwardRef)(function(e,t){const n=kp(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=(0,zg.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",groupBy:c,valueAccessor:l="value",orientation:u="vertical",valueFormat:d,colorBy:h,colorScheme:p,sort:m=!1,barPadding:y=60,roundedTop:f,gradientFill:g,styleRules:b,baselinePadding:v=!1,tooltip:x,annotations:w,valueExtent:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:j,hoverHighlight:P,chartId:I,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:D,color:N,stroke:$,strokeWidth:B,opacity:E,categoryFormat:O}=e,{width:F,height:z,enableHover:H,showGrid:W,showLegend:q,title:G,description:Y,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=n,Q=(0,zg.useMemo)(()=>ft(r),[r]),Z=h||c,J=Vp({data:Q,rawData:r,colorBy:Z,colorScheme:p,legendInteraction:L,legendPosition:D,selection:A,linkedHover:C,fallbackFields:Z?["string"==typeof Z?Z:""]:[],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"GroupedBarChart",chartId:I,showLegend:q,userMargin:i,marginDefaults:n.marginDefaults,loading:R,loadingContent:T,emptyContent:_,width:F,height:z,hasTitle:!!G,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===u?"horizontal":"vertical",hasCategoryLabel:!!U,hasValueLabel:!!K})}),ee=fp(),te=(0,zg.useMemo)(()=>new Map,[]),ne=(0,zg.useMemo)(()=>Kp(l),[l]),oe=Ng({colorBy:Z,colorScale:J.colorScale,color:N,themeCategorical:ee,colorScheme:p,categoryIndexMap:te,userPieceStyle:S.pieceStyle,stroke:$,strokeWidth:B,opacity:E,styleRules:b,resolveRuleValue:ne,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),re=(0,zg.useMemo)(()=>Id({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),ie=zp({componentName:"GroupedBarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:c}}),{effectiveLegendProps:se,effectiveMargin:ae}=Lg({ref:t,frameRef:o,setup:J}),ce=(0,zg.useMemo)(()=>ao(g),[g]);if(J.earlyReturn)return J.earlyReturn;const le={chartType:"clusterbar",...null!=r&&{data:Q},oAccessor:a,rAccessor:l,groupBy:c,oSort:m,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:oe,size:[F,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:ae,barPadding:y,...null!=f&&{roundedTop:f},...ce&&{gradientFill:ce},baselinePadding:v,enableHover:H,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:U,rLabel:K,rFormat:d,...O&&{oFormat:O},showGrid:W,...se,...sm({title:G,description:Y,summary:V,accessibleTable:X,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:x,defaultTooltipContent:re}),...am({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:P,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?(0,Hg.jsx)(Ap,{componentName:"GroupedBarChart",message:ie,width:F,height:z}):(0,Hg.jsx)(Rp,{componentName:"GroupedBarChart",width:F,height:z,children:(0,Hg.jsx)(Tg,{ref:o,...le})})});Wg.displayName="GroupedBarChart";var qg=require("react"),Gg=require("react");function Yg({brushProp:e,onBrushProp:t,linkedBrush:n,valueAccessor:o}){const r=(0,Gg.useMemo)(()=>ch("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),[n]),i="string"==typeof o?o:"value",s=kh({name:r?.name||"__unused_ordinal_brush__",xField:r?.xField||i}),a=(0,Gg.useRef)(s.brushInteraction);a.current=s.brushInteraction;const c=(0,Gg.useCallback)(e=>{if(r){a.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}:{}}}T();var Vg=require("react/jsx-runtime"),Xg=(0,qg.forwardRef)(function(e,t){const n=kp(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=(0,qg.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="vertical",valueFormat:u,colorBy:d,colorScheme:h,sizeBy:p,sizeRange:m=[3,8],symbolBy:y,symbolMap:f,pointRadius:g=4,pointOpacity:b=.7,categoryPadding:v=20,tooltip:x,annotations:w,valueExtent:k,brush:S,onBrush:A,linkedBrush:C,frameProps:M={},selection:j,linkedHover:I,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:D,loadingContent:N,emptyContent:$,legendInteraction:B,legendPosition:E,color:O,stroke:F,strokeWidth:z,opacity:H,showCategoryTicks:W,categoryFormat:q}=e,{width:G,height:Y,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=n,ne=(0,qg.useMemo)(()=>ft(r),[r]),oe=Vp({data:ne,rawData:r,colorBy:d,colorScheme:h,legendInteraction:B,legendPosition:E,selection:j,linkedHover:I,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"SwarmPlot",chartId:L,showLegend:U,userMargin:i,marginDefaults:n.marginDefaults,loading:D,loadingContent:N,emptyContent:$,width:G,height:Y,hasTitle:!!K,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!ee,hasValueLabel:!!te})}),re=Yg({brushProp:S,onBrushProp:A,linkedBrush:C,valueAccessor:c}),ie=(0,qg.useMemo)(()=>{if(p)return P(ne.map(e=>"function"==typeof p?p(e):e[p]))},[ne,p]),se=fp(),ae=(0,qg.useMemo)(()=>new Map,[]),ce=Ng({colorBy:d,colorScale:oe.colorScale,color:O,themeCategorical:se,colorScheme:h,categoryIndexMap:ae,userPieceStyle:M?.pieceStyle,stroke:F,strokeWidth:z,opacity:H,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection,baseStyleExtras:e=>({fillOpacity:b,r:p?Tn(e,p,m,ie):g})}),le=(0,qg.useMemo)(()=>Id({categoryAccessor:a,valueAccessor:c,groupAccessor:d||void 0,valueFormat:u}),[a,c,d,u]);if(oe.earlyReturn)return oe.earlyReturn;const ue=zp({componentName:"SwarmPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ue)return(0,Vg.jsx)(Ap,{componentName:"SwarmPlot",message:ue,width:G,height:Y});const de={chartType:"swarm",...null!=r&&{data:ne},oAccessor:a,rAccessor:c,...y&&{symbolAccessor:y},...f&&{symbolMap:f},projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:ce,size:[G,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:oe.margin,barPadding:v,enableHover:V,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:ee,rLabel:te,rFormat:u,...q&&{oFormat:q},showGrid:X,showCategoryTicks:W,...oe.legendBehaviorProps,...sm({title:K,description:Q,summary:Z,accessibleTable:J,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:x,defaultTooltipContent:le}),...am({linkedHover:I,selection:j,onObservation:R,onClick:T,hoverHighlight:_,mobileInteraction:oe.mobileInteraction,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior}),...w&&w.length>0&&{annotations:w},...k&&{rExtent:k},...re.brushStreamProps,...Object.fromEntries(Object.entries(M).filter(([e])=>"pieceStyle"!==e))};return(0,Vg.jsx)(Rp,{componentName:"SwarmPlot",width:G,height:Y,children:(0,Vg.jsx)(Tg,{ref:o,...de})})});Xg.displayName="SwarmPlot";var Ug=require("react"),Kg=require("react/jsx-runtime");function Qg(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(0,Kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Kg.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),null!=o.n&&(0,Kg.jsxs)("div",{children:["n = ",o.n]}),null!=o.min&&(0,Kg.jsxs)("div",{children:["Min: ",o.min.toLocaleString()]}),null!=o.q1&&(0,Kg.jsxs)("div",{children:["Q1: ",o.q1.toLocaleString()]}),(0,Kg.jsxs)("div",{children:["Median: ",o.median.toLocaleString()]}),null!=o.q3&&(0,Kg.jsxs)("div",{children:["Q3: ",o.q3.toLocaleString()]}),null!=o.max&&(0,Kg.jsxs)("div",{children:["Max: ",o.max.toLocaleString()]}),null!=o.mean&&(0,Kg.jsxs)("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,s=i>0?i%2!=0?r[Math.floor(i/2)]:(r[i/2-1]+r[i/2])/2:null;return(0,Kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Kg.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),i>0&&(0,Kg.jsxs)("div",{children:["n = ",i]}),null!=s&&(0,Kg.jsxs)("div",{children:["Median: ",s.toLocaleString()]})]})}return(0,Kg.jsx)("div",{className:"semiotic-tooltip",style:eu,children:(0,Kg.jsx)("div",{style:{fontWeight:"bold"},children:n+""})})}}var Zg=require("react/jsx-runtime"),Jg=(0,Ug.forwardRef)(function(e,t){const n=kp(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=(0,Ug.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="vertical",valueFormat:u,colorBy:d,colorScheme:h,showOutliers:p=!0,outlierRadius:m=3,categoryPadding:y=20,tooltip:f,annotations:g,valueExtent:b,frameProps:v={},selection:x,linkedHover:w,onObservation:k,onClick:S,hoverHighlight:A,chartId:C,loading:M,loadingContent:j,emptyContent:P,legendInteraction:I,legendPosition:R,color:T,stroke:_,strokeWidth:L,opacity:D,showCategoryTicks:N,categoryFormat:$}=e,{width:B,height:E,enableHover:O,showGrid:F,showLegend:z,title:H,description:W,summary:q,accessibleTable:G,categoryLabel:Y,valueLabel:V}=n,X=(0,Ug.useMemo)(()=>ft(r),[r]),U=Vp({data:X,rawData:r,colorBy:d,colorScheme:h,legendInteraction:I,legendPosition:R,selection:x,linkedHover:w,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,onClick:S,hoverHighlight:A,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"BoxPlot",chartId:C,showLegend:z,userMargin:i,marginDefaults:n.marginDefaults,loading:M,loadingContent:j,emptyContent:P,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=fp(),Q=(0,Ug.useMemo)(()=>new Map,[]),Z=Ng({colorBy:d,colorScale:U.colorScale,color:T,themeCategorical:K,colorScheme:h,categoryIndexMap:Q,userPieceStyle:void 0,stroke:_,strokeWidth:L,opacity:D,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),J=(0,Ug.useMemo)(()=>Qg(),[]);if(U.earlyReturn)return U.earlyReturn;const ee=zp({componentName:"BoxPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ee)return(0,Zg.jsx)(Ap,{componentName:"BoxPlot",message:ee,width:B,height:E});const te={chartType:"boxplot",...null!=r&&{data:X},oAccessor:a,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:Z,showOutliers:p,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:Y,rLabel:V,rFormat:u,...$&&{oFormat:$},showGrid:F,showCategoryTicks:N,...U.legendBehaviorProps,...sm({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:f,defaultTooltipContent:J}),...am({linkedHover:w,selection:x,onObservation:k,onClick:S,hoverHighlight:A,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...g&&g.length>0&&{annotations:g},...b&&{rExtent:b},...Object.fromEntries(Object.entries(v).filter(([e])=>"pieceStyle"!==e))};return(0,Zg.jsx)(Rp,{componentName:"BoxPlot",width:B,height:E,children:(0,Zg.jsx)(Tg,{ref:o,...te})})});Jg.displayName="BoxPlot";var eb=require("react"),tb=require("react/jsx-runtime"),nb=e=>{const t=e?.category;return null==t?"All":t+""},ob=(0,eb.forwardRef)(function(e,t){const n=kp(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=(0,eb.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a=nb,valueAccessor:c="value",bins:l=25,relative:u=!1,valueFormat:d,colorBy:h,colorScheme:p,categoryPadding:m=("sparkline"===n.mode?0:20),tooltip:y,annotations:f,valueExtent:g,brush:b,onBrush:v,linkedBrush:x,frameProps:w={},selection:k,linkedHover:S,onObservation:A,onClick:C,hoverHighlight:M,chartId:j,loading:P,loadingContent:I,emptyContent:R,legendInteraction:T,legendPosition:_,color:L,stroke:D,strokeWidth:N,opacity:$,showCategoryTicks:B,categoryFormat:E}=e,{width:O,height:F,enableHover:z,showGrid:H,showLegend:W,title:q,description:G,summary:Y,accessibleTable:V,categoryLabel:X,valueLabel:U}=n,K=(0,eb.useMemo)(()=>ft(r),[r]),Q=Vp({data:K,rawData:r,colorBy:h,colorScheme:p,legendInteraction:T,legendPosition:_,selection:k,linkedHover:S,fallbackFields:h?["string"==typeof h?h:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"Histogram",chartId:j,showLegend:W,userMargin:i,marginDefaults:n.marginDefaults,loading:P,loadingContent:I,emptyContent:R,width:O,height:F,hasTitle:!!q,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal",hasCategoryLabel:!!X,hasValueLabel:!!U})}),Z=Yg({brushProp:b,onBrushProp:v,linkedBrush:x,valueAccessor:c}),J=(0,eb.useMemo)(()=>{if(0===K.length)return;const e="function"==typeof c?c:e=>e[c];let t=1/0,n=-1/0;for(const o of K){const r=e(o);null!=r&&isFinite(r)&&(t>r&&(t=r),r>n&&(n=r))}return t>n?void 0:[t,n]},[K,c]),ee=fp(),te=(0,eb.useMemo)(()=>new Map,[]),ne=Ng({colorBy:h,colorScale:Q.colorScale,color:L,themeCategorical:ee,colorScheme:p,categoryIndexMap:te,userPieceStyle:void 0,stroke:D,strokeWidth:N,opacity:$,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),oe=(0,eb.useMemo)(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return(0,tb.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,tb.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),null!=o&&(0,tb.jsxs)("div",{children:["Count: ",o]}),r&&2===r.length&&(0,tb.jsxs)("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]);if(Q.earlyReturn)return Q.earlyReturn;const re=zp({componentName:"Histogram",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(re)return(0,tb.jsx)(Ap,{componentName:"Histogram",message:re,width:O,height:F});const ie={chartType:"histogram",...null!=r&&{data:K},oAccessor:a,rAccessor:c,projection:"horizontal",summaryStyle:ne,bins:l,normalize:u,...g?{rExtent:g}:J&&{rExtent:J},size:[O,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Q.margin,barPadding:m,enableHover:z,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:X,rLabel:U,rFormat:d,...E&&{oFormat:E},showGrid:H,showCategoryTicks:B,...Q.legendBehaviorProps,...sm({title:q,description:G,summary:Y,accessibleTable:V,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:y,defaultTooltipContent:oe}),...am({linkedHover:S,selection:k,onObservation:A,onClick:C,hoverHighlight:M,mobileInteraction:Q.mobileInteraction,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior}),...f&&f.length>0&&{annotations:f},...Z.brushStreamProps,...Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e))};return(0,tb.jsx)(Rp,{componentName:"Histogram",width:O,height:F,children:(0,tb.jsx)(Tg,{ref:o,...ie})})});ob.displayName="Histogram";var rb=require("react"),ib=require("react/jsx-runtime"),sb=(0,rb.forwardRef)(function(e,t){const n=kp(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=(0,rb.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="vertical",bins:u=25,curve:d="catmullRom",showIQR:h=!0,valueFormat:p,colorBy:m,colorScheme:y,categoryPadding:f=20,tooltip:g,annotations:b,valueExtent:v,brush:x,onBrush:w,linkedBrush:k,frameProps:S={},selection:A,linkedHover:C,onObservation:M,onClick:j,hoverHighlight:P,chartId:I,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:D,color:N,stroke:$,strokeWidth:B,opacity:E,showCategoryTicks:O,categoryFormat:F}=e,{width:z,height:H,enableHover:W,showGrid:q,showLegend:G,title:Y,description:V,summary:X,accessibleTable:U,categoryLabel:K,valueLabel:Q}=n,Z=(0,rb.useMemo)(()=>ft(r),[r]),J=Vp({data:Z,rawData:r,colorBy:m,colorScheme:y,legendInteraction:L,legendPosition:D,selection:A,linkedHover:C,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"ViolinPlot",chartId:I,showLegend:G,userMargin:i,marginDefaults:n.marginDefaults,loading:R,loadingContent:T,emptyContent:_,width:z,height:H,hasTitle:!!Y,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!K,hasValueLabel:!!Q})}),ee=Yg({brushProp:x,onBrushProp:w,linkedBrush:k,valueAccessor:c}),te=fp(),ne=(0,rb.useMemo)(()=>new Map,[]),oe=Ng({colorBy:m,colorScale:J.colorScale,color:N,themeCategorical:te,colorScheme:y,categoryIndexMap:ne,userPieceStyle:void 0,stroke:$,strokeWidth:B,opacity:E,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),re=(0,rb.useMemo)(()=>Qg({valueAccessor:c}),[c]);if(J.earlyReturn)return J.earlyReturn;const ie=zp({componentName:"ViolinPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ie)return(0,ib.jsx)(Ap,{componentName:"ViolinPlot",message:ie,width:z,height:H});const se={chartType:"violin",...null!=r&&{data:Z},oAccessor:a,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:oe,bins:u,showIQR:h,size:[z,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J.margin,barPadding:f,enableHover:W,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:K,rLabel:Q,rFormat:p,...F&&{oFormat:F},showGrid:q,showCategoryTicks:O,...J.legendBehaviorProps,...sm({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:g,defaultTooltipContent:re}),...am({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:P,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior}),...b&&b.length>0&&{annotations:b},...v&&{rExtent:v},...ee.brushStreamProps,...Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e))};return(0,ib.jsx)(Rp,{componentName:"ViolinPlot",width:z,height:H,children:(0,ib.jsx)(Tg,{ref:o,...se})})});sb.displayName="ViolinPlot";var ab=require("react"),cb=require("react/jsx-runtime"),lb=(0,ab.forwardRef)(function(e,t){const n=kp(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=(0,ab.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="horizontal",valueFormat:u,colorBy:d,colorScheme:h,sort:p="auto",dotRadius:m=5,categoryPadding:y=10,tooltip:f,annotations:g,regression:b,valueExtent:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:j,loadingContent:P,emptyContent:I,legendInteraction:R,legendPosition:T,color:_,stroke:L,strokeWidth:D,opacity:N,categoryFormat:$}=e,{width:B,height:E,enableHover:O,showGrid:F,showLegend:z,title:H,description:W,summary:q,accessibleTable:G,categoryLabel:Y,valueLabel:V}=n,X=(0,ab.useMemo)(()=>ft(r),[r]),U=Vp({data:X,rawData:r,colorBy:d,colorScheme:h,legendInteraction:R,legendPosition:T,selection:w,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"DotPlot",chartId:M,showLegend:z,userMargin:i,marginDefaults:n.marginDefaults,loading:j,loadingContent:P,emptyContent:I,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=vp(X,p,c),Q=fp(),Z=(0,ab.useMemo)(()=>new Map,[]),J=Ng({colorBy:d,colorScale:U.colorScale,color:_,themeCategorical:Q,colorScheme:h,categoryIndexMap:Z,userPieceStyle:x?.pieceStyle,stroke:L,strokeWidth:D,opacity:N,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{r:m,fillOpacity:.8}}),ee=(0,ab.useMemo)(()=>Id({categoryAccessor:a,valueAccessor:c,valueFormat:u}),[a,c,u]);if(U.earlyReturn)return U.earlyReturn;const te=zp({componentName:"DotPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(te)return(0,cb.jsx)(Ap,{componentName:"DotPlot",message:te,width:B,height:E});const ne=sy(b),oe=ne?[ne,...g||[]]:g,re={chartType:"point",...null!=r&&{data:K},oAccessor:a,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",pieceStyle:J,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:Y,rLabel:V,rFormat:u,...$&&{oFormat:$},showGrid:F,oSort:p,...U.legendBehaviorProps,...sm({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:f,defaultTooltipContent:ee}),...am({linkedHover:k,selection:w,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...oe&&oe.length>0&&{annotations:oe},...v&&{rExtent:v},...Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e))};return(0,cb.jsx)(Rp,{componentName:"DotPlot",width:B,height:E,children:(0,cb.jsx)(Tg,{ref:o,...re})})});lb.displayName="DotPlot";var ub=require("react"),db=require("react/jsx-runtime"),hb=(0,ub.forwardRef)(function(e,t){const n=kp(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=(0,ub.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",orientation:l="horizontal",bins:u=20,amplitude:d=1.5,valueFormat:h,colorBy:p,colorScheme:m,categoryPadding:y=5,tooltip:f,annotations:g,valueExtent:b,frameProps:v={},selection:x,linkedHover:w,onObservation:k,onClick:S,hoverHighlight:A,chartId:C,loading:M,loadingContent:j,emptyContent:P,legendInteraction:I,legendPosition:R,color:T,stroke:_,strokeWidth:L,opacity:D,showCategoryTicks:N,categoryFormat:$}=e,{width:B,height:E,enableHover:O,showGrid:F,showLegend:z,title:H,description:W,summary:q,accessibleTable:G,categoryLabel:Y,valueLabel:V}=n,X=(0,ub.useMemo)(()=>ft(r),[r]),U=Vp({data:X,rawData:r,colorBy:p,colorScheme:m,legendInteraction:I,legendPosition:R,selection:x,linkedHover:w,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:k,onClick:S,hoverHighlight:A,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"RidgelinePlot",chartId:C,showLegend:z,userMargin:i,marginDefaults:n.marginDefaults,loading:M,loadingContent:j,emptyContent:P,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=fp(),Q=(0,ub.useMemo)(()=>new Map,[]),Z=Ng({colorBy:p,colorScale:U.colorScale,color:T,themeCategorical:K,colorScheme:m,categoryIndexMap:Q,userPieceStyle:void 0,stroke:_,strokeWidth:L,opacity:D,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),J=(0,ub.useMemo)(()=>Qg(),[]);if(U.earlyReturn)return U.earlyReturn;const ee=zp({componentName:"RidgelinePlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ee)return(0,db.jsx)(Ap,{componentName:"RidgelinePlot",message:ee,width:B,height:E});const te={chartType:"ridgeline",...null!=r&&{data:X},oAccessor:a,rAccessor:c,projection:"horizontal"===l?"horizontal":"vertical",summaryStyle:Z,bins:u,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,barPadding:y,enableHover:O,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:Y,rLabel:V,rFormat:h,...$&&{oFormat:$},showGrid:F,showCategoryTicks:N,oSort:!1,amplitude:d,...U.legendBehaviorProps,...sm({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:f,defaultTooltipContent:J}),...am({linkedHover:w,selection:x,onObservation:k,onClick:S,hoverHighlight:A,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior}),...g&&g.length>0&&{annotations:g},...b&&{rExtent:b},...Object.fromEntries(Object.entries(v).filter(([e])=>"pieceStyle"!==e))};return(0,db.jsx)(Rp,{componentName:"RidgelinePlot",width:B,height:E,children:(0,db.jsx)(Tg,{ref:o,...te})})});hb.displayName="RidgelinePlot";var pb=require("react"),mb=require("react/jsx-runtime"),yb=(0,pb.forwardRef)(function(e,t){const n=kp(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=(0,pb.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",colorBy:l,colorScheme:u,startAngle:d=0,cornerRadius:h,tooltip:p,annotations:m,frameProps:y={},selection:f,linkedHover:g,onObservation:b,onClick:v,hoverHighlight:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,legendInteraction:C,legendPosition:M,color:j,stroke:P,strokeWidth:I,opacity:R}=e,{width:T,height:_,enableHover:L,showLegend:D,title:N,description:$,summary:B,accessibleTable:E}=n,O=(0,pb.useMemo)(()=>ft(r),[r]),F=l||a,z=Vp({data:O,rawData:r,colorBy:F,colorScheme:u,legendInteraction:C,legendPosition:M,selection:f,linkedHover:g,fallbackFields:F?["string"==typeof F?F:""]:[],unwrapData:!0,onObservation:b,onClick:v,hoverHighlight:x,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"PieChart",chartId:w,showLegend:D,userMargin:i,marginDefaults:n.marginDefaults,loading:k,loadingContent:S,emptyContent:A,width:T,height:_,hasTitle:!!N,axisChrome:{hasAxis:!1}}),H=fp(),W=(0,pb.useMemo)(()=>new Map,[]),q=Ng({colorBy:F,colorScale:z.colorScale,color:j,themeCategorical:H,colorScheme:u,categoryIndexMap:W,userPieceStyle:y?.pieceStyle,stroke:P,strokeWidth:I,opacity:R,effectiveSelectionHook:z.effectiveSelectionHook,resolvedSelection:z.resolvedSelection,cycleByCategory:!0}),G=(0,pb.useMemo)(()=>Id({categoryAccessor:a,valueAccessor:c,groupAccessor:l&&l!==a?l:void 0,groupLabel:"string"==typeof l?l:"group",pieData:!0}),[a,c,l]),Y=zp({componentName:"PieChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}}),{effectiveLegendProps:V,effectiveMargin:X}=Lg({ref:t,frameRef:o,setup:z});if(z.earlyReturn)return z.earlyReturn;const U={chartType:"pie",...null!=r&&{data:O},oAccessor:a,rAccessor:c,projection:"radial",pieceStyle:q,startAngle:d,...null!=h&&{cornerRadius:h},size:[T,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:X,enableHover:L,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...V,...sm({title:N,description:$,summary:B,accessibleTable:E,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:p,defaultTooltipContent:G}),...am({linkedHover:g,selection:f,onObservation:b,onClick:v,hoverHighlight:x,mobileInteraction:z.mobileInteraction,customHoverBehavior:z.customHoverBehavior,customClickBehavior:z.customClickBehavior}),...m&&m.length>0&&{annotations:m},...Object.fromEntries(Object.entries(y).filter(([e])=>"pieceStyle"!==e))};return Y?(0,mb.jsx)(Ap,{componentName:"PieChart",message:Y,width:T,height:_}):(0,mb.jsx)(Rp,{componentName:"PieChart",width:T,height:_,children:(0,mb.jsx)(Tg,{ref:o,...U})})});yb.displayName="PieChart";var fb=require("react"),gb=require("react/jsx-runtime"),bb=(0,fb.forwardRef)(function(e,t){const n=kp(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=(0,fb.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",valueAccessor:c="value",innerRadius:l,centerContent:u,colorBy:d,colorScheme:h,startAngle:p=0,cornerRadius:m,tooltip:y,annotations:f,frameProps:g={},selection:b,linkedHover:v,onObservation:x,onClick:w,hoverHighlight:k,chartId:S,loading:A,loadingContent:C,emptyContent:M,legendInteraction:j,legendPosition:P,color:I,stroke:R,strokeWidth:T,opacity:_}=e,{width:L,height:D,enableHover:N,showLegend:$,title:B,description:E,summary:O,accessibleTable:F}=n,z=(0,fb.useMemo)(()=>ft(r),[r]),H=d||a,W=Vp({data:z,rawData:r,colorBy:H,colorScheme:h,legendInteraction:j,legendPosition:P,selection:b,linkedHover:v,fallbackFields:H?["string"==typeof H?H:""]:[],unwrapData:!0,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"DonutChart",chartId:S,showLegend:$,userMargin:i,marginDefaults:n.marginDefaults,loading:A,loadingContent:C,emptyContent:M,width:L,height:D,hasTitle:!!B,axisChrome:{hasAxis:!1}}),q=l??Math.max(2,.15*Math.min(L,D)),G=fp(),Y=(0,fb.useMemo)(()=>new Map,[]),V=Ng({colorBy:H,colorScale:W.colorScale,color:I,themeCategorical:G,colorScheme:h,categoryIndexMap:Y,userPieceStyle:g?.pieceStyle,stroke:R,strokeWidth:T,opacity:_,effectiveSelectionHook:W.effectiveSelectionHook,resolvedSelection:W.resolvedSelection,cycleByCategory:!0}),X=(0,fb.useMemo)(()=>Id({categoryAccessor:a,valueAccessor:c,groupAccessor:d&&d!==a?d:void 0,groupLabel:"string"==typeof d?d:"group",pieData:!0}),[a,c,d]),U=zp({componentName:"DonutChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}}),{effectiveLegendProps:K,effectiveMargin:Q}=Lg({ref:t,frameRef:o,setup:W});if(W.earlyReturn)return W.earlyReturn;const Z={chartType:"donut",...null!=r&&{data:z},oAccessor:a,rAccessor:c,projection:"radial",pieceStyle:V,innerRadius:q,startAngle:p,...null!=m&&{cornerRadius:m},centerContent:u,size:[L,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Q,enableHover:N,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...K,...sm({title:B,description:E,summary:O,accessibleTable:F,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:y,defaultTooltipContent:X}),...am({linkedHover:v,selection:b,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:W.mobileInteraction,customHoverBehavior:W.customHoverBehavior,customClickBehavior:W.customClickBehavior}),...f&&f.length>0&&{annotations:f},...Object.fromEntries(Object.entries(g).filter(([e])=>"pieceStyle"!==e))};return U?(0,gb.jsx)(Ap,{componentName:"DonutChart",message:U,width:L,height:D}):(0,gb.jsx)(Rp,{componentName:"DonutChart",width:L,height:D,children:(0,gb.jsx)(Tg,{ref:o,...Z})})});bb.displayName="DonutChart";var vb=require("react");function xb(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 wb(e){return Math.max(0,Math.min(1,e))}function kb(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 Sb(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 Ab(e,t,n){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:wb(e.offset),color:e.color??n,opacity:null==e.opacity?1:wb(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";const r=e=>{if(1===e.opacity)return e.color;const t=kb(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===o.length)return r(o[0]);const i=wb(t);if(o[0].offset>=i)return r(o[0]);if(i>=o[o.length-1].offset)return r(o[o.length-1]);for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1];if(t.offset>i||i>n.offset)continue;const s=n.offset-t.offset,a=s>0?(i-t.offset)/s:0,c=kb(t.color),l=kb(n.color);if(!c||!l)return r(.5>a?t:n);const[u,d,h]=c,[p,m,y]=l,f=u+(p-u)*a,g=d+(m-d)*a,b=h+(y-h)*a,v=t.opacity+(n.opacity-t.opacity)*a;return 1===v?Sb(f,g,b):`rgba(${Math.round(f)},${Math.round(g)},${Math.round(b)},${v})`}return r(o[o.length-1])}function Cb(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}T();var Mb=require("react/jsx-runtime"),jb=(0,vb.forwardRef)(function(e,t){const n=kp(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}),o=(0,vb.useRef)(null),r="context"===n.mode,{compactMode:i}=n,{value:s,min:a=0,max:c=100,thresholds:l,gradientFill:u,color:d,backgroundColor:h="var(--semiotic-grid, #e0e0e0)",arcWidth:p=.3,cornerRadius:m,showNeedle:y=!0,needleColor:f="var(--semiotic-text, #333)",centerContent:g,valueFormat:b,showScaleLabels:v=!i,sweep:x=240,fillZones:w=!0,tooltip:k,annotations:S,frameProps:A={},className:C,stroke:M,strokeWidth:j,opacity:I}=e,{width:R,height:T,title:_,description:L,summary:D,accessibleTable:N}=n,$=co(u),B=Math.max(a,Math.min(c,s)),E=c-a||1,O=(B-a)/E,{gaugeData:F,pieceStyle:z,gaugeAnnotations:H}=(0,vb.useMemo)(()=>function(e){const{min:t,max:n,value:o,thresholds:r,fillColor:i,backgroundColor:s,fillZones:a,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.stops.length>=2,y=[],f=new Map,g=[];if(m){const e=a?h:1,t=Cb("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),f.set(t,{fill:s,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(Ab(l.stops,e*(t+.5)/n,i||p[0]?.color||"#007bff"));const r=Cb("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),f.set(r,{fill:o[0]||s})}}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,(a?Math.min(h,c):c)-i),u=a?Math.max(0,r-l):0;if(l>0){const e=Cb("fill",n);y.push({category:e,value:l,_zone:o.label||"Zone "+(n+1),_isFill:!0}),f.set(e,{fill:o.color})}if(u>0){const e=Cb("bg",n);y.push({category:e,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),f.set(e,{fill:s,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:y,pieceStyle:(e,t)=>f.get(t||e.category)||{fill:s},gaugeAnnotations:g}}({min:a,max:c,value:s,thresholds:l,fillColor:d,backgroundColor:h,fillZones:w,showScaleLabels:v,gradientFill:$}),[s,a,c,l,d,h,v,w,$]),W=(0,vb.useMemo)(()=>Up(z,{stroke:M,strokeWidth:j,opacity:I}),[z,M,j,I]),{sweepRad:q,startAngleDeg:G}=xb(x),Y=function(e=240){const{sweepRad:t,offsetRad:n}=xb(e),o=[[Math.cos(n),Math.sin(n)],[Math.cos(n+t),Math.sin(n+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-n)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||o.push([Math.cos(e),Math.sin(e)]);const r=o.map(e=>e[0]),i=o.map(e=>e[1]),[s,a]=P(r),[c,l]=P(i);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}(x),V=Math.min(10,Math.max(1,Math.min(R,T)/12)),X=Y.cx,U=Y.cy,K=Math.max(4,Math.min((R-2*V)/Y.width,(T-2*V)/Y.height)-2),Q=Math.max(0,Math.min(K-1.5,K*(1-p))),Z=R/2-X*K,J=T/2-U*K,ee=2*(K+4),te=(0,vb.useMemo)(()=>{if(i&&null==g)return null;if(null!=g)return"function"==typeof g?g(B,a,c):g;const e=b?b(B):Math.round(B)+"";return(0,Mb.jsxs)("div",{style:{textAlign:"center",lineHeight:1.2},children:[(0,Mb.jsx)("div",{style:{fontSize:Math.max(16,.3*K),fontWeight:700,color:"var(--semiotic-text, #333)"},children:e}),v&&(0,Mb.jsxs)("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[a," – ",c]})]})},[g,B,a,c,b,v,K,i]),ne=(0,vb.useMemo)(()=>r&&null==g?{type:"gauge-value",text:b?b(B):Math.round(B)+""}:null,[r,g,B,b]),oe=(0,vb.useMemo)(()=>{if(!y)return null;const e=-Math.PI/2+G*Math.PI/180+O*q,t=Q>20?Q-8:K-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:f}},[y,G,O,q,Q,K,f]),re=(0,vb.useMemo)(()=>(e,t,n)=>{if("gauge-needle"===e.type){const o=(n.width||R)/2,r=(n.height||T)/2,i=Math.max(1,K-Q),s=Math.max(1,Math.min(2.5,.4*i)),a=Math.max(1,Math.min(5,.6*i));return(0,Mb.jsxs)("g",{transform:`translate(${o},${r})`,children:[(0,Mb.jsx)("line",{x1:0,y1:0,x2:e.tipX,y2:e.tipY,stroke:e.color,strokeWidth:s,strokeLinecap:"round"}),(0,Mb.jsx)("circle",{cx:0,cy:0,r:a,fill:e.color})]},"gauge-needle-"+t)}if("gauge-label"===e.type){const o=-Math.PI/2+G*Math.PI/180+(e.value-a)/E*q,r=(n.width||R)/2,i=(n.height||T)/2,s=Q-1,c=K+1,l=Math.cos(o)*s,u=Math.sin(o)*s,d=Math.cos(o)*c,h=Math.sin(o)*c,p=K+10,m=Math.cos(o)*p,y=Math.sin(o)*p,f=((o+Math.PI/2)/(2*Math.PI)*12+12)%12;let g,b;return f>=11||1>f?(g="middle",b="auto"):f>=1&&5>f?(g="start",b="middle"):f>=5&&7>f?(g="middle",b="hanging"):(g="end",b="middle"),(0,Mb.jsxs)("g",{transform:`translate(${r},${i})`,children:[(0,Mb.jsx)("line",{x1:l,y1:u,x2:d,y2:h,stroke:"var(--semiotic-border, #ccc)",strokeWidth:2,strokeLinecap:"round"}),(0,Mb.jsx)("text",{x:m,y:y,textAnchor:g,dominantBaseline:b,fill:"var(--semiotic-text-secondary, #666)",fontSize:10,style:{userSelect:"none",fontSize:"var(--semiotic-gauge-label-font-size, 10px)"},children:e.label})]},"gauge-label-"+t)}return"gauge-value"===e.type?(0,Mb.jsx)("text",{x:(n.width||R)/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},[R,T,a,E,G,q,Q,K]),ie=(0,vb.useMemo)(()=>{const e=[...H,...S||[]];return oe&&e.push(oe),ne&&e.push(ne),e},[H,S,oe,ne]),se=(0,vb.useMemo)(()=>e=>{const t=e?.data?.[0]||e?.data||e,n=t?._zone||"",o=t?._isFill;return(0,Mb.jsxs)("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:[(0,Mb.jsx)("div",{style:{fontWeight:600},children:n}),(0,Mb.jsx)("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:o?"Current: "+Math.round(B):"Remaining"})]})},[B]);if(0===F.length)return(0,Mb.jsx)(Ap,{componentName:"GaugeChart",message:"No data to display",width:R,height:T});const ae={chartType:"donut",data:F,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:W,innerRadius:Q,startAngle:G,sweepAngle:x,...null!=m&&{cornerRadius:m},centerContent:te,size:[R,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:{top:J-ee/2,bottom:T-J-ee/2,left:Z-ee/2,right:R-Z-ee/2},enableHover:n.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===k?()=>null:cu(k)||se,svgAnnotationRules:re,...ie.length>0&&{annotations:ie},..._&&{title:_},...L&&{description:L},...D&&{summary:D},...void 0!==N&&{accessibleTable:N},...C&&{className:C},...null!=e.animate&&{animate:e.animate},...A};return(0,Mb.jsx)(Rp,{componentName:"GaugeChart",width:R,height:T,children:(0,Mb.jsx)(Tg,{ref:o,...ae})})});jb.displayName="GaugeChart";var Pb=require("react"),Ib=require("react/jsx-runtime"),Rb=(0,Pb.forwardRef)(function(e,t){const n=kp(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=(0,Pb.useRef)(null);im(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,stepAccessor:a="step",valueAccessor:c="value",categoryAccessor:l,colorBy:u,colorScheme:d,orientation:h="horizontal",connectorOpacity:p=.3,showLabels:m=!0,tooltip:y,annotations:f,frameProps:g={},selection:b,linkedHover:v,onObservation:x,onClick:w,hoverHighlight:k,chartId:S,loading:A,loadingContent:C,emptyContent:M,legendInteraction:j,legendPosition:P,color:I,stroke:R,strokeWidth:T,opacity:_,categoryFormat:L}=e,D="vertical"===h,{width:N,height:$,enableHover:B,showLegend:E,title:O,description:F,summary:z,accessibleTable:H}=n,W=D?{top:O?60:40,right:20,bottom:60,left:60}:{top:O?40:10,right:10,bottom:10,left:10},q=(0,Pb.useMemo)(()=>ft(r),[r]),G=u||l,Y=!G,V=Vp({data:q,rawData:r,colorBy:G,colorScheme:d,legendInteraction:j,legendPosition:P,selection:b,linkedHover:v,fallbackFields:G?["string"==typeof G?G:""]:[],unwrapData:!0,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"FunnelChart",chartId:S,showLegend:E,userMargin:i,marginDefaults:W,loading:A,loadingContent:C,emptyContent:M,width:N,height:$,hasTitle:!!O,axisChrome:ts({showAxes:D,projection:D?"vertical":"horizontal",hasCategoryLabel:!1,hasValueLabel:!1})});Np("FunnelChart",q,"stepAccessor",a),Np("FunnelChart",q,"valueAccessor",c);const X=fp(),U=(0,Pb.useMemo)(()=>new Map,[]),K=(0,Pb.useMemo)(()=>{if(Y)return I||(X?.[0]?X[0]:Array.isArray(d)&&d[0]?d[0]:"#4e79a7")},[Y,I,X,d]),Q=Ng({colorBy:K?void 0:G,colorScale:V.colorScale,color:K??I,themeCategorical:X,colorScheme:d,categoryIndexMap:U,userPieceStyle:g?.pieceStyle,stroke:R,strokeWidth:T,opacity:_,effectiveSelectionHook:V.effectiveSelectionHook,resolvedSelection:V.resolvedSelection}),Z=(0,Pb.useMemo)(()=>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,s=t?.__barFunnelIsDropoff,a=t?.__barFunnelCategory??t?.category,c=null==r||i?"":` (${.05>Math.abs(r-Math.round(r))?Math.round(r)+"%":r.toFixed(1)+"%"})`;return(0,Ib.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Ib.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),a&&a!==n&&(0,Ib.jsx)("div",{style:{marginTop:2,opacity:.8},children:a+""}),s&&(0,Ib.jsx)("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),(0,Ib.jsxs)("div",{style:{marginTop:4},children:[o+"",c]})]})},[]);if(V.earlyReturn)return V.earlyReturn;const J=zp({componentName:"FunnelChart",data:r,accessors:{stepAccessor:a,valueAccessor:c}});if(J)return(0,Ib.jsx)(Ap,{componentName:"FunnelChart",message:J,width:N,height:$});const ee={chartType:D?"bar-funnel":"funnel",...null!=r&&{data:q},oAccessor:a,rAccessor:c,...l&&{stackBy:l},projection:D?"vertical":"horizontal",barPadding:D?40:0,pieceStyle:Q,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:V.margin,enableHover:B,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:D,showCategoryTicks:D,...L&&{oFormat:L},showGrid:D,...!D&&{connectorOpacity:p},showLabels:m,...V.legendBehaviorProps,...O&&{title:O},...F&&{description:F},...z&&{summary:z},...void 0!==H&&{accessibleTable:H},...s&&{className:s},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===y?()=>null:!0===y||null==y?Z:cu(y)||Z,...am({linkedHover:v,selection:b,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior}),...f&&f.length>0&&{annotations:f},...Object.fromEntries(Object.entries(g).filter(([e])=>"pieceStyle"!==e))};return(0,Ib.jsx)(Rp,{componentName:"FunnelChart",width:N,height:$,children:(0,Ib.jsx)(Tg,{ref:o,...ee})})});Rb.displayName="FunnelChart";var Tb=d(require("react")),_b=require("react"),Lb=require("react"),Db=require("react"),Nb={RdBu:mn,PiYG:yn,PRGn:fn,BrBG:gn,RdYlBu:bn,RdYlGn:vn,Spectral:xn},$b="__likert_neutral_neg",Bb="__likert_neutral_pos";function Eb(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Ob(e,t,n,o,r,i){const s=new Map,a=new Set(t);for(const c of e){const e=n(c);s.has(e)||s.set(e,new Map);const l=s.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(!a.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,n]of s){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],s=n.get(i)||0;c.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:r})}}return c}function Fb(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 zb(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 s=[];for(const[,e]of i){const t=new Map;let i,a;for(const n of e)n.__likertLevel===$b?i=n:n.__likertLevel===Bb?a=n:t.set(n.__likertLevelIndex,n);o&&i&&s.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&s.push(n)}o&&a&&s.push(a);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&s.push(n)}}return s}var Hb=["Very Low","Low","Neutral","High","Very High"],Wb=require("react/jsx-runtime"),qb=new Map,Gb=(0,_b.forwardRef)(function(e,t){const n=kp(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=(0,_b.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="question",valueAccessor:c,levelAccessor:l,countAccessor:u="count",levels:d=Hb,orientation:h="horizontal",colorScheme:p,barPadding:m=20,tooltip:y,annotations:f,valueExtent:g,frameProps:b={},selection:v,linkedHover:x,onObservation:w,onClick:k,hoverHighlight:S,chartId:A,valueFormat:C,loading:M,loadingContent:j,emptyContent:P,legendInteraction:I,legendPosition:R,categoryFormat:T,stroke:_,strokeWidth:L,opacity:D}=e,{width:N,height:$,enableHover:B,showGrid:E,showLegend:O,title:F,description:z,summary:H,accessibleTable:W,categoryLabel:q,valueLabel:G}=n,Y="horizontal"===h,V=void 0===r,X=!l,U=function(){const e=Dh();return e?.colors?.diverging||void 0}(),K=(0,_b.useMemo)(()=>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,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);i&&a.push(r);for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);return a}(d.length,U),[p,d.length,U]),Q=(0,_b.useMemo)(()=>{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:s,frameRef:a}){const c=!r,l=(0,Db.useMemo)(()=>Eb(n,"question"),[n]),u=(0,Db.useMemo)(()=>c?Eb(o,"score"):null,[c,o]),d=(0,Db.useMemo)(()=>c?null:Eb(r,"level"),[c,r]),h=(0,Db.useMemo)(()=>c?null:Eb(i,"count"),[c,i]),p=(0,Db.useRef)([]);return{processedData:(0,Db.useMemo)(()=>{const n=e||[];if(0===n.length)return[];let o=Ob(n,t,l,u,d,h);return s&&(o=Fb(o,t),o=zb(o,t)),o},[e,t,l,u,d,h,s]),reAggregate:(0,Db.useCallback)(e=>{let n=Ob(e,t,l,u,d,h);s&&(n=Fb(n,t),n=zb(n,t)),a.current?.replace(n)},[t,l,u,d,h,s,a]),accumulatorRef:p}}({data:r,levels:d,categoryAccessor:a,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=(0,Lb.useRef)(new Set),s=(0,Lb.useRef)([]),[a,c]=(0,Lb.useState)(0),l=ah(),u=fp(),d=(0,Lb.useCallback)(e=>{if(!t)return null;const n="function"==typeof t?t(e):e[t];return null!=n?n+"":null},[t]),h=(0,Lb.useCallback)(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),s.current.push(t),o=!0)}o&&c(e=>e+1)},[e,t,d]),p=(0,Lb.useCallback)(n=>{if(!e||!t)return;const o=Array.from(new Set(n.map(String))),r=s.current;r.length===o.length&&r.every((e,t)=>e===o[t])||(i.current=new Set(o),s.current=o,c(e=>e+1))},[e,t]),m=(0,Lb.useCallback)(e=>t=>{h([t]),e(t)},[h]),y=(0,Lb.useCallback)(e=>t=>{h(t),e(t)},[h]),f=(0,Lb.useCallback)(()=>{i.current=new Set,s.current=[],c(e=>e+1)},[]);sp(e&&t?s.current:[]);const g=(0,Lb.useMemo)(()=>{if(!e||!t||!1===o)return;const r=s.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:Cn,a="string"==typeof t?t:"__streamCat",c=r.map(e=>({[a]:e})),d=Rn(c,a,i);return dp({data:c,colorBy:a,colorScale:e=>l?.[e]||d(e)||"#999",getColor:Pn})},[e,t,o,n,l,u,a]),b=(0,Lb.useMemo)(()=>{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:y,resetCategories:f,categories:s.current,categoryDomainProps:e&&t?{legendCategoryAccessor:t,onCategoriesChange:p}:{},streamingLegend:g,streamingMarginAdjust:b}}({isPushMode:V,colorBy:te,colorScheme:K,showLegend:O,legendPosition:R}),{wrapPush:oe,wrapPushMany:re}=ne,ie=(0,_b.useCallback)(e=>oe(e=>{ee.current.push(e),J(ee.current)})(e),[oe,J,ee]),se=(0,_b.useCallback)(e=>re(e=>{ee.current.push(...e),J(ee.current)})(e),[re,J,ee]);(0,_b.useImperativeHandle)(t,()=>({push:ie,pushMany:se,remove:e=>o.current?.remove(e)??[],update:(e,t)=>o.current?.update(e,t)??[],replace:e=>o.current?.replace(e),clear:()=>{ee.current=[],ne.resetCategories(),o.current?.clear()},getData:()=>o.current?.getData()??[],getScales:()=>o.current?.getScales()??null}),[ie,se,ee,ne]);const ae=Vp({data:Z,rawData:r,colorBy:te,colorScheme:K,legendInteraction:I,legendPosition:R,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:O,userMargin:i,marginDefaults:n.marginDefaults,loading:M,loadingContent:j,emptyContent:P,width:N,height:$,hasTitle:!!F,axisChrome:{hasAxis:!1!==n.showAxes,hasAxisLabel:Y?!!G:!!q}}),ce=(0,_b.useMemo)(()=>{const e=d.length;return e%2!=0&&Q.get(d[Math.floor(e/2)])||"#888"},[d,Q]),le=Ng({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:qb,userPieceStyle:b?.pieceStyle,stroke:_,strokeWidth:L,opacity:D,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.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=(0,_b.useMemo)(()=>{const e=d.length;return e%2!=0?d[Math.floor(e/2)]:""},[d]),de=(0,_b.useMemo)(()=>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),s=n===$b||n===Bb?2*i:i,a=t.__likertCount||0;return Tb.createElement("div",{className:"semiotic-tooltip",style:eu},Tb.createElement("div",{style:{fontWeight:"bold"}},r),Tb.createElement("div",{style:{marginTop:4}},`${o}: ${s.toFixed(1)}% (n=${a})`))},[ue]),he=(0,_b.useMemo)(()=>{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:a};return X?c&&(e.valueAccessor=c):(l&&(e.levelAccessor=l),u&&(e.countAccessor=u)),zp({componentName:"LikertChart",data:r,accessors:e,requiredProps:{levels:d}})},[r,a,c,l,u,d,X]),pe=(0,_b.useMemo)(()=>[{styleFn:e=>({fill:Q.get(e.label)||"#888"}),items:d.map(e=>({label:e})),label:""}],[d,Q]),me=(0,_b.useMemo)(()=>!1!==O?{...ae.legendBehaviorProps,legend:{legendGroups:pe},legendPosition:R||ae.legendPosition||"bottom"}:ae.legendBehaviorProps,[ae.legendBehaviorProps,ae.legendPosition,R,O,pe]),ye=(0,_b.useMemo)(()=>{const e={...ae.margin};if(V&&!1!==O){const t=R||"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},[ae.margin,ne.streamingMarginAdjust,Y,V,O,R]),fe=(0,_b.useMemo)(()=>C||(Y?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[Y,C]);if(ae.earlyReturn)return ae.earlyReturn;const ge={chartType:"bar",...null!=r&&{data:Z},oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:Y?"horizontal":"vertical",pieceStyle:le,size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ye,barPadding:m,enableHover:B,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:q,rLabel:G||(Y?void 0:"Percentage"),rFormat:fe,...T&&{oFormat:T},showGrid:E,...me,...F&&{title:F},...z&&{description:z},...H&&{summary:H},...void 0!==W&&{accessibleTable:W},...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===y?()=>null:!0===y?de:cu(y)||de,...am({linkedHover:x,selection:v,onObservation:w,onClick:k,hoverHighlight:S,mobileInteraction:ae.mobileInteraction,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior}),...f&&f.length>0&&{annotations:f},...g&&{rExtent:g},...Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e))};return he?(0,Wb.jsx)(Ap,{componentName:"LikertChart",message:he,width:N,height:$}):(0,Wb.jsx)(Rp,{componentName:"LikertChart",width:N,height:$,children:(0,Wb.jsx)(Tg,{ref:o,...ge})})});Gb.displayName="LikertChart";var Yb=require("react"),Vb=require("react/jsx-runtime"),Xb=(0,Yb.forwardRef)(function(e,t){const n=kp(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=(0,Yb.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="category",subcategoryAccessor:c,valueAccessor:l="value",orientation:u="horizontal",valueFormat:d,colorBy:h,colorScheme:p,barPadding:m,tooltip:y,annotations:f,brush:g,onBrush:b,linkedBrush:v,frameProps:x={},selection:w,linkedHover:k,onObservation:S,onClick:A,hoverHighlight:C,chartId:M,loading:j,loadingContent:P,emptyContent:I,legendInteraction:R,legendPosition:T,color:_,stroke:L,strokeWidth:D,opacity:N,categoryFormat:$,rTickValues:B,tickLabelEdgeAlign:E,showCategoryTicks:O,gradientFill:F,trackFill:z,roundedTop:H,valueExtent:W}=e,{width:q,height:G,enableHover:Y,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,categoryLabel:J,valueLabel:ee}=n,te=(0,Yb.useMemo)(()=>ft(r),[r]),ne=h||c,oe=(0,Yb.useMemo)(()=>{if(null!=m)return m;if("sparkline"!==n.mode)return 40;const e=new Set(te.map(e=>"function"==typeof a?a(e):e[a])),t=Math.max(1,e.size);return t>1?Math.max(0,Math.min(1,(("horizontal"===u?G:q)-2*t)/(t-1))):1},[m,n.mode,te,a,u,q,G]),re=Vp({data:te,rawData:r,colorBy:ne,colorScheme:p,legendInteraction:R,legendPosition:T,selection:w,linkedHover:k,fallbackFields:ne?["string"==typeof ne?ne:""]:[],unwrapData:!0,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"SwimlaneChart",chartId:M,showLegend:X,userMargin:i,marginDefaults:n.marginDefaults,loading:j,loadingContent:P,emptyContent:I,width:q,height:G,hasTitle:!!U,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===u?"horizontal":"vertical",hasCategoryLabel:!1!==O&&!!J,hasValueLabel:!!ee})}),ie=Yg({brushProp:g,onBrushProp:b,linkedBrush:v,valueAccessor:l}),se=fp(),ae=(0,Yb.useMemo)(()=>new Map,[]),ce=Ng({colorBy:ne,colorScale:re.colorScale,color:_,themeCategorical:se,colorScheme:p,categoryIndexMap:ae,userPieceStyle:x?.pieceStyle,stroke:L,strokeWidth:D,opacity:N,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection,cycleByCategory:!0}),le=(0,Yb.useMemo)(()=>Id({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),ue=zp({componentName:"SwimlaneChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l,subcategoryAccessor:c},requiredProps:{subcategoryAccessor:c}}),{effectiveLegendProps:de,effectiveMargin:he}=Lg({ref:t,frameRef:o,setup:re}),pe=(0,Yb.useMemo)(()=>ao(F),[F]);if(re.earlyReturn)return re.earlyReturn;const me={chartType:"swimlane",...null!=r&&{data:te},oAccessor:a,rAccessor:l,stackBy:c,projection:"horizontal"===u?"horizontal":"vertical",pieceStyle:ce,size:[q,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:he,barPadding:oe,enableHover:Y,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:n.showAxes,oLabel:!1===O?void 0:J,rLabel:ee,rFormat:d,...B&&{rTickValues:B},...null!=E&&{tickLabelEdgeAlign:E},...$&&{oFormat:$},...void 0!==O&&{showCategoryTicks:O},showGrid:V,...de,...sm({title:U,description:K,summary:Q,accessibleTable:Z,className:s,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...cm({tooltip:y,defaultTooltipContent:le}),...am({linkedHover:k,selection:w,onObservation:S,onClick:A,hoverHighlight:C,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...f&&f.length>0&&{annotations:f},...pe&&{gradientFill:pe},...null!=z&&{trackFill:z},...null!=H&&{roundedTop:H},...W&&{rExtent:W},...ie.brushStreamProps,...Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e))};return ue?(0,Vb.jsx)(Ap,{componentName:"SwimlaneChart",message:ue,width:q,height:G}):(0,Vb.jsx)(Rp,{componentName:"SwimlaneChart",width:q,height:G,children:(0,Vb.jsx)(Tg,{ref:o,...me})})});Xb.displayName="SwimlaneChart";var Ub=require("react"),Kb=d(require("react")),Qb=require("react"),Zb={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Jb={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},ev=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 s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(o?o[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?tv(s.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 tv(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),c=s-a,[l,u,d,h]=e[a];nv(l,u,d,h,c,r);const p=h.x-l.x,m=h.y-l.y,y=Math.sqrt(p*p+m*m);if(y>.001){const e=p/y;r.x+=-m/y*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,s,a]=e.points;nv(r,i,s,a,t,o);const c=a.x-r.x,l=a.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 nv(e,t,n,o,r,i){const s=1-r,a=s*s,c=a*s,l=r*r,u=l*r;i.x=c*e.x+3*a*r*t.x+3*s*l*n.x+u*o.x,i.y=c*e.y+3*a*r*t.y+3*s*l*n.y+u*o.y}function ov(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function rv(e,t){var n,o=[],r=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;a[e].length>t;t++)(o=a[e][t])===n?(u(n,r),d=!0):i[o]||(d=l(o));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[o=a[e][t]];h||(s[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),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,o[c]=0,r[c]=!1,i[c]=0,s[c]=-1,a[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 y=p[m];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>s[y]||a[t].push(s[y])}i[t]=m}else{if(o[t]===n[t]){var f=[],g=[],b=0;for(m=c.length-1;m>=0;--m){var v=c[m];if(r[v]=!1,f.push(v),g.push(a[v]),b+=a[v].length,s[v]=d.length,v===t){c.length=m;break}}d.push(f);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 y=1;m.length>y;y++)m[y]!==m[y-1]&&l.push(m[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)i>r[s][a]&&(i=r[s][a],n=s);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,a=p.adjList){for(var m=0;a.length>m;m++)for(var y=0;a[m].length>y;y++){var f=a[m][y];i[+f]=!1,s[f]={}}l(n),n+=1}else n=h}return t?void 0:o}function iv(e){return e.y0-e.y1>0?"up":"down"}function sv(e,t){return t(e.source)==t(e.target)}function av(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 cv(e){return e.target.x0-e.source.x1}function lv(e,t){var n=dv(e),o=cv(t)/Math.tan(n);return"up"==iv(e)?e.y1-o:e.y1+o}function uv(e,t){var n=dv(e),o=cv(t)/Math.tan(n);return"up"==iv(e)?e.y1+o:e.y1-o}function dv(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function hv(e,t){return t(e)}function pv(e){return yv(e.source)}function mv(e){return yv(e.target)}function yv(e){return(e.y0+e.y1)/2}function fv(e){return e.virtual?0:e.value}function gv(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!sv(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!sv(e,t)?o+1:o}),n+o}function bv(e){return e.target.depth}function vv(e,t){return e.sourceLinks.length?e.depth:t-1}function xv(e,t){return e.y0-t.y0}function wv(e,t){return t.y0-e.y0}function kv(e,t){return e.y1-t.y1}function Sv(e,t){return t.y1-e.y1}function Av(e,t){return Mv(e.source,t.source)||e.index-t.index}function Cv(e,t){return Mv(e.target,t.target)||e.index-t.index}function Mv(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function jv(e,t){return Pv(e)==Pv(t)?"bottom"==e.circularLinkType?wv(e,t):xv(e,t):Pv(t)-Pv(e)}function Pv(e){return e.target.column-e.source.column}function Iv(e,t){return Rv(e)==Rv(t)}function Rv(e){return e.y0-e.y1>0?"up":"down"}var Tv=require("d3-array");function _v(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,Tv.min)(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}),Lv(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Lv(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,sv(e,t)&&av(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 s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?wv:xv);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}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Sv:kv),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=a-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 Lv(e,t,n){e.sort(jv);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(sv(e,t)&&av(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Dv(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Dv(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Nv=require("d3-array");function $v(e){return function(){return e}}function Bv(e){return e.index}function Ev(e){return e.nodes}function Ov(e){return e.links}function Fv(e,t,n){var o=(0,Nv.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var s=r.length;if(t)r.sort(t);else if(i>0){var a=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+=yv(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=yv(e.target)*t,o+=t}}),o>0?r/o:NaN);a.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=a.get(e),o=a.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?gv(t,n)-gv(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==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==gv(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)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function zv(e,t,n,o,r,i){var s=(0,Nv.groups)(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 a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&gv(r,n)>0){var c=(0,Nv.mean)(r.sourceLinks,mv),l=(0,Nv.mean)(r.targetLinks,pv),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-yv(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,Nv.mean)(r.sourceLinks,mv),p=(0,Nv.mean)(r.targetLinks,pv),m=((h&&p?(h+p)/2:h||p)-yv(r))*t;r.y0+=m,r.y1+=m}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||Mv),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+o;if((s=c-o-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+r-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function Hv(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Cv),e.targetLinks.sort(Av)}),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 Wv(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,a=Bv,c=vv,l=void 0,u=32,d=2,h=Ev,p=Ov;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(0,Nv.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=ov(n,o)),"object"!=typeof r&&(r=e.target=ov(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],s=i.source.index,a=i.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=rv(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){hv(e,t)!=hv(r.source,t)&&hv(e,t)!=hv(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),sv(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Nv.sum)(e.sourceLinks,fv),(0,Nv.sum)(e.targetLinks,fv)),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 s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}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!==s){var m=(0,Nv.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Nv.max)(m,function(e){return e.length});y>1&&(p=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=(0,Nv.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=(0,Nv.min)(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Nv.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,Nv.max)(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),Fv(h,l,a),zv(h,l,a,p,p,u),Hv(h),_v(h,a,d,10,8),Fv(h,l,a),zv(h,l,a,p,p,u),Hv(h),_v(h,a,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 hv(n.source,t)==hv(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(!Iv(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=lv(t,e);return e.y1-n}if(t.target.column>e.target.column)return lv(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,s=0;r>i;i++)s+=o[i].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return hv(n.target,t)==hv(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(!Iv(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=uv(t,e);return e.y0-n}if(t.source.column>e.source.column)return uv(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,s=0;r>i;i++)s+=o[i].width;t.y1=e.y1-s-t.width/2}})})}(h,a),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)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,Nv.min)(t,function(e){return e.y0}),s=(0,Nv.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(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*a})):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),_v(h,a,d,10,8)}(m),m}return m.update=function(e){return Hv(e),_v(e,a,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?(s=+e,m):s},m.nodes=function(e){return arguments.length?(h="function"==typeof e?e:$v(e),m):h},m.links=function(e){return arguments.length?(p="function"==typeof e?e:$v(e),m):p},m.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:$v(e),m):a},m.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:$v(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}var qv=require("d3-interpolate");function Gv(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+o)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${r},${i}`,`L${r},${s}`,`C${c},${s} ${a},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}require("d3-shape");var Yv=e=>{let t,n,o,r,i,s,a,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,s=e.target.x0,a=(0,qv.interpolateNumber)(i,s),c=a(.5),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${i}Z`;const u=e.sankeyWidth/2,d=(0,qv.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=Gv({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 Vv(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,s=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=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+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const r=o.sourceX,i=o.sourceY,s=o.targetX,a=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},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+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 Xv=new Set,Uv=new WeakMap;function Kv(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Uv.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Uv.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}`;Xv.has(e)||(Xv.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 Qv={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(bv))-1:0},justify:vv},Zv={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",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:Yt(e.source),target:Yt(e.target),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=Wv().extent(d).links(u).nodes(l).nodeAlign(Qv[i]||vv).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),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,s=(o._circularWidth??o.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>r&&(r=i.verticalFullExtent+s)}const i=t-e,s=r-n,a=o[0],c=o[1];if(i>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/i,c/s),o=-e*t+(a-i*t)/2,r=-n*t+(c-s*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)if(e._edgeKey)m.set(e._edgeKey,e);else{const t=Yt(e.source),n=Yt(e.target);m.set(`${t}\0${n}`,e)}for(const e of u){const t=Yt(e.source),n=Yt(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),s=p.get(n);i&&(o.source=i),s&&(o.target=s)}}},buildScene(e,t,n,o){const r="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Zt,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(Kv(t,"nodeStyle")):{},s={fill:o.fill||u.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};m.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){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=s?s(Kv(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))),s=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??a,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-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Vv(e):Yv(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||r,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=Gt(n.nodeLabel);for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),p.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:p}}},Jv=require("d3-force"),ex=require("d3-scale");T();var tx={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r=n.forceStrength??.1,i=o[0]/2,s=o[1]/2,a=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=l?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const o=nx(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=ox(e.id),i=r%360*(Math.PI/180),s=(10+r%20)*a;e.x=t/o.length+s*Math.cos(i),e.y=n/o.length+s*Math.sin(i)}else{const t=ox(e.id),n=t%360*(Math.PI/180),o=(15+t%30)*a;e.x=i+o*Math.cos(n),e.y=s+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)*a,r=n*t;o.x=i+e*Math.cos(r),o.y=s+e*Math.sin(r)}}}const p=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),m=rx(n.nodeSize,n.nodeSizeRange,e),y=e=>m(e);if(p>0){const l=new Map,u=new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t=Yt(e.source),n=Yt(e.target);l.set(t,(l.get(t)??0)+1),l.set(n,(l.get(n)??0)+1)}const d=(0,Jv.forceLink)().strength(e=>{const t=e.weight,n=Yt(e.source),o=Yt(e.target),i=Math.max(1,Math.min(l.get(n)??1,l.get(o)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*i))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,o=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,o)}).id(e=>e.id),m=(0,Jv.forceSimulation)();if(void 0===n.random&&void 0===n.seed||m.randomSource(n.random??vu(n.seed)),m.force("charge",(0,Jv.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,Jv.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,Jv.forceCenter)(i,s).strength(.8)).force("x",(0,Jv.forceX)(i).strength(c)).force("y",(0,Jv.forceY)(s).strength(c)).force("bounds",function(e,t,n=2,o=.6){let r=[];const i=i=>{const s=o*Math.max(i,.2);for(const o of r){const r=o.x??e[0]/2,i=o.y??e[1]/2,a=o.vx??0,c=o.vy??0,l=t(o)+n,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),p=Math.max(e[1]/2,e[1]-l),m=r+a,y=i+c;u>m?o.vx=a+(u-m)*s:m>d&&(o.vx=a+(d-m)*s),h>y?o.vy=c+(h-y)*s:y>p&&(o.vy=c+(p-y)*s)}};return i.initialize=e=>{r=e},i}(o,y)),m.nodes(e),t.length>0){const e=t.map(e=>({...e,source:Yt(e.source),target:Yt(e.target)}));d.links(e),m.force("link",d)}h?m.alpha(.3):.1>m.alpha()&&m.alpha(1),m.stop();for(let e=0;p>e;++e)m.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=p>0?2:0,r=Math.min(o[0]/2,e+n),i=Math.min(o[1]/2,e+n);t.x=Math.max(r,Math.min(o[0]-r,t.x)),t.y=Math.max(i,Math.min(o[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=f.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=f.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.edgeStyle,s=rx(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Zt,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Kv(t,"nodeSize")),o=r?r(Kv(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(Kv(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=Gt(n.nodeLabel);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=s(Kv(n,"nodeSize"));d.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:d}}};function nx(e,t,n){const o=[];for(const r of t){const t=Yt(r.source),i=Yt(r.target);let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function ox(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 rx(e,t,n){if(n.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 o=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[i,s]=P(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,ex.scaleLinear)().domain([i,s]).range(o).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?o[0]:a(n)}}var ix=require("d3-chord"),sx=require("d3-shape"),ax=Zt,cx={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,c=a-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,y=Array.from({length:m},()=>Array.from({length:m},()=>0));for(const e of t){const t=Yt(e.source),n=Yt(e.target),o=p.get(t),r=p.get(n);if(void 0===o||void 0===r)continue;const i=d(e);y[o][r]=i}const f=(0,ix.chord)().padAngle(r);s&&f.sortGroups(s);const g=f(y),b=g.groups,v=(0,sx.arc)().innerRadius(c).outerRadius(a);for(const t of b){const n=e[t.index],o=v.centroid({innerRadius:c,outerRadius:a,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=Yt(e.source),n=Yt(e.target),o=x.get(t),r=x.get(n);o&&(e.source=o),r&&(e.target=r)}const w=new Map;for(const e of t){const t=Yt(e.source),n=Yt(e.target);w.set(`${t}\0${n}`,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,s=Math.min(o[0],o[1])/2,a=s-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:ax,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const y=(0,ix.ribbon)().radius(a),f=[],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(Kv(n,"nodeStyle")).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const i=u?u(Kv(n,"nodeStyle")):{};f.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,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=y(t);if(!o)continue;const r=lx(o,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Kv(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=m.get(n.id)||s:t&&(s=m.get(t.id)||s)}const a=d?d(Kv(e,"edgeStyle")):{};g.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=Gt(n.nodeLabel),o=s+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,s=i-Math.PI/2;b.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:f,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(" ")}var ux=require("d3-hierarchy"),dx=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function hx(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 px(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 mx(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 yx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:dx}function fx(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 gx(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 bx={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;if(!r)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,ux.hierarchy)(r,s);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=(0,ux.tree)();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=(0,ux.cluster)();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,s=(0,ux.treemap)().size([n,o]).tile(ux.treemapBinary).padding(r);i>0&&s.paddingTop(i),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,o){const r=t.padding??4;(0,ux.pack)().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){(0,ux.partition)().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:px(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?vx(r,o,n):"treemap"===i||"partition"===i?xx(r,o):"circlepack"===i&&wx(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 s=[],a=[],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(Kv(t,"nodeStyle"));let a=i.fill||fx(n);if(n.colorByDepth&&void 0!==t.depth){const e=yx(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:o,r:p,style:{fill:a,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 y=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,s=t.y,c=o.x,p=o.y;u&&(r+=d,s+=h,c+=d,p+=h);const m=gx(r,s,c,p,l),f=i(Kv(e,"edgeStyle"));a.push({type:"curved",pathD:m,style:{fill:"none",stroke:f.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:f.strokeWidth??1.5,opacity:f.opacity??y},datum:e})}if(!1!==n.showLabels){const t=mx(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(o=s+e/n*10,r=a+t/n*10,i=0>e?"end":"start"):(o=s,r=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(o=s-p-6,i="end"):(o=s+p+6,i="start"),r=a):(o=s,r=a+p+14,i="middle");c.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,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 s=o(Kv(n,"nodeStyle"));let a=s.fill||fx(t);if(t.colorByDepth&&void 0!==n.depth){const e=yx(t);a=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity,fillOpacity:s.fillOpacity,strokeOpacity:s.strokeOpacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=mx(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=o(Kv(a,"nodeStyle")).fill||fx(t);if(t.colorByDepth&&void 0!==a.depth){const e=yx(t);d=e[a.depth%e.length]}const h="string"==typeof d?hx(d):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.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(Kv(n,"nodeStyle"));let s=i.fill||fx(t);if(t.colorByDepth&&void 0!==n.depth){const e=yx(t);s=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,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=mx(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=o(Kv(r,"nodeStyle")).fill||fx(t);if(t.colorByDepth&&void 0!==r.depth){const e=yx(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?hx(c):t.themeSemantic?.text??"#000";i.push({x:r.x,y:r.y,text:s+"",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:s+"",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 vx(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 xx(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 wx(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}var kx=require("d3-shape");function Sx(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Ax={sankey:Zv,force:tx,chord:cx,tree:bx,cluster:bx,treemap:bx,circlepack:bx,partition:bx,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),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=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=Sx(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 y=t[0]/2,f=t[1]/2,g=Math.min(t[0],t[1])/2*.85,b=m(s(e));o.push({id:b,x:y,y:f,x0:y,x1:y,y0:f,y1:f,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,y,f){const g=i(t);if(!g?.length)return;const b=g.length;let v=0,x=0,w=0;for(;b>x;)x+=a[Math.min(w,a.length-1)],w++,v++;let k=0;for(let b=0;v>b;b++){const x=a[Math.min(b,a.length-1)],w=g.slice(k,k+x);if(!w.length)break;const S=(b+1)/v,A={id:n,depth:y,data:t,parentId:n},C=f?p/u(A)*S:p*S,M=(0,kx.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(w),j=d(A);for(let t=0;w.length>t;t++){const i=(M[t].startAngle+M[t].endAngle)/2,a=w[t],u=m(s(a)),d=c+C*Math.sin(i),p=l+C*Math.cos(i)*j;o.push({id:u,x:d,y:p,x0:d,x1:d,y0:p,y1:p,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:C,angle:i,depth:y,parentId:n,eccentricity:j}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,p,C,y+1,!0)}k+=x}}(e,b,y,f,g,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=Sx(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,s={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 a=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Kv(t,"nodeSize")),o=r?r(Kv(t,"nodeStyle")):{};a.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=s(Kv(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:a,sceneEdges:c,labels:l}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=Sx(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,s=o*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=a.get(e.parentId);if(!o)continue;const c=e.angle+i*s*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 Cx(e){return Ax[e]}var Mx=require("d3-quadtree");function jx(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 Px(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(!Ix(e))return!1;return!0}return Ix(t.points)}function Ix(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}var Rx=require("d3-interpolate");var Tx="rgba(34, 197, 94, 0.7)",_x=2e3,Lx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Dx=["scene-style","data-paint","accessibility","evidence"],Nx=(e,t)=>({retainedData:e,invalidations:t}),$x=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bx=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ex=["scene-geometry","data-paint","overlay","accessibility","evidence"],Ox=["scene-style","data-paint","accessibility","evidence"],Fx=["scene-geometry","data-paint","overlay","accessibility","evidence"],zx=[],Hx={chartType:Nx("rebuild",$x),nodeIDAccessor:Nx("rebuild",$x),sourceAccessor:Nx("rebuild",$x),targetAccessor:Nx("rebuild",$x),valueAccessor:Nx("rebuild",$x),edgeIdAccessor:Nx("rebuild",$x),childrenAccessor:Nx("rebuild",$x),hierarchySum:Nx("rebuild",$x),orientation:Nx("preserve",Bx),nodeAlign:Nx("preserve",Bx),nodePaddingRatio:Nx("preserve",Bx),nodeWidth:Nx("preserve",Bx),edgeSort:Nx("preserve",Bx),iterations:Nx("preserve",Bx),forceStrength:Nx("preserve",Bx),padAngle:Nx("preserve",Bx),groupWidth:Nx("preserve",Bx),sortGroups:Nx("preserve",Bx),treeOrientation:Nx("preserve",Bx),edgeType:Nx("preserve",Bx),padding:Nx("preserve",Bx),paddingTop:Nx("preserve",Bx),orbitMode:Nx("preserve",Bx),orbitSize:Nx("preserve",Bx),orbitSpeed:Nx("preserve",Bx),orbitRevolution:Nx("preserve",Bx),orbitRevolutionStyle:Nx("preserve",Bx),orbitEccentricity:Nx("preserve",Bx),orbitShowRings:Nx("preserve",Bx),orbitAnimated:Nx("preserve",Bx),customNetworkLayout:Nx("preserve",Bx),layoutConfig:Nx("preserve",Bx),nodeSize:Nx("preserve",Ex),nodeSizeRange:Nx("preserve",Ex),colorByDepth:Nx("preserve",Ex),nodeLabel:Nx("preserve",Fx),showLabels:Nx("preserve",Fx),labelMode:Nx("preserve",Fx),nodeStyle:Nx("preserve",Ox),edgeStyle:Nx("preserve",Ox),colorBy:Nx("preserve",Ox),colorScheme:Nx("preserve",Ox),themeCategorical:Nx("preserve",Ox),themeSemantic:Nx("preserve",Ox),edgeColorBy:Nx("preserve",Ox),edgeOpacity:Nx("preserve",Ox),showParticles:Nx("preserve",Ox),particleStyle:Nx("preserve",Ox),decay:Nx("preserve",Ox),pulse:Nx("preserve",Ox),thresholds:Nx("preserve",Ox),staleness:Nx("preserve",Ox),layoutSelection:Nx("preserve",Ox),clock:Nx("preserve",zx),random:Nx("preserve",zx),seed:Nx("preserve",zx),tensionConfig:Nx("preserve",zx),transition:Nx("preserve",zx),introAnimation:Nx("preserve",zx),onLayoutError:Nx("preserve",zx),__skipForceSimulation:Nx("preserve",zx),__hierarchyRoot:Nx("preserve",zx),__orbitState:Nx("preserve",zx),__previousPositions:Nx("preserve",zx)},Wx=Nx("preserve",Bx),qx=class{constructor(){this.tracker=new qo}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}},Lx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Dx):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Hx[o]??Wx;"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)}},Gx=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 qx,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={...Zb,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new ev(2e3))}currentTime(){return this.config.clock?.()??Nn()}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={...Zb,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new ev(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:s="target",valueAccessor:a="value"}=this.config,c="function"==typeof r?r:e=>e[r],l="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],d="function"==typeof a?a:e=>e[a]??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,{...jx(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",r=u(n)+"",i=d(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(o)||this.nodes.set(o,{...jx(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...jx(r),data:n});const c=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&Px(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 s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,jx(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,jx(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),c=this.edges.get(a);let l=!1;c?(c.value+=o,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),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=Cx(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)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>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:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});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 s=!(!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 s}({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:s}){const a=wf(e.colorScheme,e.themeCategorical,Zt),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:[...a]},resolveColor:kf(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==i,o=So("network",t,n,s);"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 xo({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=Cx(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:s}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=i,this.labels=s,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=(0,Mx.quadtree)().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=Cx(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Cx(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=Ln(e,this.transition),n=_n(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Dn(e._prevX0,e._targetX0,n),e.x1=Dn(e._prevX1,e._targetX1,n),e.y0=Dn(e._prevY0,e._targetY0,n),e.y1=Dn(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=Dn(e._prevY0,e._targetY0,n),e.y1=Dn(e._prevY1,e._targetY1,n),e.sankeyWidth=Dn(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,s=n.y-t.y;r.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},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,s=n.x0,a=(0,Rx.interpolateNumber)(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(o)},{x:e.y1,y:a(1-o)},{x:e.y1,y:s}],halfWidth:r}}const i=t.x1,s=n.x0,a=(0,Rx.interpolateNumber)(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(o),y:e.y0},{x:a(1-o),y:e.y1},{x:s,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 s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const c=i-a;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 s="object"==typeof r.source?r.source?.id:r.source,a="object"==typeof r.target?r.target?.id:r.target;if(!s||!a)continue;const c=e.edgeTimestamps.get(`${s}\0${a}`);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 s=En(t,i,n);r.style={...r.style,opacity:(r.style?.opacity??1)*s}}}({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===Tx&&(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>=_x)return;const n=1-t/_x;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=Tx,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&&_x>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 s=i.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const c=t.metric(a);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")}};Gx.QUADTREE_THRESHOLD=500;var Yx=Gx;Fo(Yx);var Vx=d(require("react")),Xx=require("react/jsx-runtime");function Ux(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,labels:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p="right",legendLayout:m,foregroundGraphics:y,sceneNodes:f,annotations:g,onAnnotationActivate:b,onObservation:v,chartId:x,chartType:w,autoPlaceAnnotations:k,svgAnnotationRules:S}=e,A=Xs({onAnnotationActivate:b,onObservation:v,chartId:x,chartType:w}),C=Vx.useMemo(()=>{const e=(f||[]).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=Fr(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,yo(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:f}},[n,f,t]),M=Vx.useMemo(()=>{if(!g)return g;const e=Wa(g);return k?ja({annotations:e,context:C,..."object"==typeof k?k:{}}):e},[g,k,C]),j=Vx.useMemo(()=>ra(),[]),P=M?oa(M.filter(e=>"widget"!==e.type),j,S,C):null,I=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,Xx.jsxs)(Xx.Fragment,{children:[I&&(0,Xx.jsx)("style",{children:Fs},"annotation-widget-disclosure-style"),(0,Xx.jsxs)("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,Xx.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,Xx.jsx)("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),(0,Xx.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>(0,Xx.jsx)("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)),P,y]}),a&&"string"==typeof a?(0,Xx.jsx)("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",fontSize:14,className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,Xx.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:a}):null,ys({legend:c,totalWidth:o,totalHeight:r,margin:i,legendPosition:p,title:a,legendLayout:m,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&f).map((e,t)=>{const n=!0===e._annotationDeferred,o=f.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)),s=i.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),a=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,d=e.content??(0,Xx.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,Xx.jsx)("div",{...Ks(e,A),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+a-l/2,top:s+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}Ux.displayName="NetworkSVGOverlay";var Kx=d(require("react")),Qx=require("react/jsx-runtime"),Zx={position:"absolute",top:0,left:0,pointerEvents:"none"};function Jx({marks:e,margin:t,selection:n=null,overscan:o=400}){const r=Kx.useRef(null),i=function(e,t,n){const[o,r]=Kx.useState(null);return Kx.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)},s=()=>{0===o&&(o=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Kx.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:i}=o,s=t.left-n,a=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!(s>t+e.width||t>a||c>n+e.height||n>l)})},[e,o,n])}(e,r,o);if(!e||0===e.length)return null;const s=(0,Qx.jsx)("div",{className:"semiotic-network-html-marks",ref:r,style:{...Zx,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,Qx.jsx)("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?(0,Qx.jsx)(Sr,{value:n,children:s}):s}var ew=require("react/jsx-runtime");function tw({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:c}){const{chartType:l,nodes:u,edges:d,data:h,className:p,description:m,title:y,responsiveWidth:f,responsiveHeight:g,summary:b,background:v,renderMode:x,legend:w,legendPosition:k,legendLayout:S,legendHoverBehavior:A,legendClickBehavior:C,legendHighlightedCategory:M,legendIsolatedCategories:j,layoutSelection:P,annotations:I,onAnnotationActivate:R,annotationObservationCallback:T,onObservation:_,chartId:L,autoPlaceAnnotations:D,svgAnnotationRules:N}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?h||(Array.isArray(d)?void 0:d):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=ft(u),n=Array.isArray(d)?ft(d):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const $=t?.sceneNodes??[],B=t?.sceneEdges??[],E=t?.labels??[];return(0,ew.jsxs)("div",{ref:n,className:"stream-network-frame"+(p?" "+p:""),role:"img","aria-label":m||("string"==typeof y?y:"Network chart"),style:{position:"relative",width:f?"100%":o[0],height:g?"100%":o[1]},children:[(0,ew.jsx)(El,{summary:b}),(0,ew.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[a&&(0,ew.jsx)("g",{transform:`translate(${r.left},${r.top})`,children:a}),(0,ew.jsxs)("g",{transform:`translate(${r.left},${r.top})`,children:[v&&(0,ew.jsx)("rect",{x:0,y:0,width:i,height:s,fill:v}),B.map((e,t)=>xd({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Pc.jsx)("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,o=`net-bezier-${t}-hatch`,r=ei(n.style.fill)?oi(n.style.fill,o):void 0;return(0,Pc.jsxs)(Mc.Fragment,{children:[r&&(0,Pc.jsx)("defs",{children:r}),(0,Pc.jsx)("path",{d:n.pathD,fill:r?`url(#${o})`:wc(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,o=`net-ribbon-${t}-hatch`,r=ei(n.style.fill)?oi(n.style.fill,o):void 0;return(0,Pc.jsxs)(Mc.Fragment,{children:[r&&(0,Pc.jsx)("defs",{children:r}),(0,Pc.jsx)("path",{d:n.pathD,fill:r?`url(#${o})`:wc(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(0,Pc.jsx)("path",{d:n.pathD,fill:wc(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),$.map((e,t)=>xd({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,o=ei(n.style.fill)?oi(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,Pc.jsxs)(Mc.Fragment,{children:[o&&(0,Pc.jsx)("defs",{children:o}),(0,Pc.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:o?`url(#net-circle-${t}-hatch)`:wc(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,o=ei(n.style.fill)?oi(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,Pc.jsxs)(Mc.Fragment,{children:[o&&(0,Pc.jsx)("defs",{children:o}),(0,Pc.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:o?`url(#net-rect-${t}-hatch)`:wc(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,o=(0,jc.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(xc)||"",r=ei(n.style.fill)?oi(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,Pc.jsxs)(Mc.Fragment,{children:[r&&(0,Pc.jsx)("defs",{children:r}),(0,Pc.jsx)("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:r?`url(#net-arc-${t}-hatch)`:wc(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,o=mo(n.symbolType,n.size,n.path);return(0,Pc.jsx)("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?wc(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,fillOpacity:n.style.fillOpacity,strokeOpacity:n.style.strokeOpacity,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return Sc(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),E.map((e,t)=>function(e,t){return(0,Pc.jsx)("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)]})]}),(0,ew.jsx)(Ux,{width:i,height:s,totalWidth:o[0],totalHeight:o[1],margin:r,labels:E,sceneNodes:$,title:y,legend:w,legendPosition:k,legendLayout:S,legendHoverBehavior:A,legendClickBehavior:C,legendHighlightedCategory:M,legendIsolatedCategories:j,foregroundGraphics:br(c,Ar(t?.customLayoutOverlays,P??null)),annotations:I,onAnnotationActivate:R,onObservation:T??_,chartId:L,chartType:"StreamNetworkFrame",autoPlaceAnnotations:D,svgAnnotationRules:N,annotationFrame:0}),(0,ew.jsx)(Jx,{marks:t?.customLayoutHtmlMarks,margin:r,selection:P??null})]})}function nw(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 ow(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function rw(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function iw(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}var sw=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(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);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(ow(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),r(ow(this.options.name))},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}};function aw(e){let t=null;return{get:()=>(t&&!t.isDead||(t=e()),t),resetForTest:()=>{if(t){try{t.terminate()}catch{}t=null}}}}var cw={};function lw(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}var uw=class{constructor(e=function(){const e="string"==typeof cw.url&&cw.url?new URL("./forceLayoutWorker.js",cw.url):nw("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new sw({name:"Force layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:o}=iw(t);return o?{requestId:n,ok:!1,error:rw(o)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},dw=aw(()=>new uw),hw=require("react/jsx-runtime"),pw=/^(value|amount|total|count|weight|score)$/i;function mw({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,hw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,hw.jsxs)("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&&(0,hw.jsxs)("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(0,hw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,hw.jsx)("div",{children:e.map((e,t)=>(0,hw.jsxs)("span",{children:[t>0&&(0,hw.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?(0,hw.jsx)("strong",{children:e}):(0,hw.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,hw.jsx)("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=Zl(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>pw.test(e.key));return(0,hw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,hw.jsx)("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>(0,hw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",Ad(e.value)]},e.key)),!a&&null!=t.value&&t.value>0&&(0,hw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&(0,hw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function yw(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function fw(e,t){if(!t.pathD)return;e.save();const n=yw(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,o.y0??0,o.x1,o.y1??0),r=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=Xr(e,i)||i;n.addColorStop(0,1===o.from?s:"transparent"),n.addColorStop(1,1===o.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=ai(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=Xr(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 gw(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Xr(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 bw(e,t){if(!t.pathD)return;e.save();const n=yw(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ai(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=Xr(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=yw(t),o=t.style.stroke||"#999";e.strokeStyle=Xr(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=ai(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function xw(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,s=Math.sqrt(r*r+i*i);return s>Ir(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,o);case"rect":return function(e,t,n){const o=Pr(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 s=_r(Math.atan2(r,o)),a=_r(e.startAngle),c=_r(e.endAngle);if(a>c?s>=a||c>=s:s>=a&&c>=s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,o=30){const r=t-e.cx,i=n-e.cy,s=Math.sqrt(r*r+i*i);return s>Ir(yo(e.size),o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,o);case"glyph":return function(e,t,n,o=30){if(null==e.datum)return null;const r=Fr(e.glyph,e.size),i=e.cx+r.centerDx,s=e.cy+r.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Ir(r.radius,o)?null:{type:"node",datum:e.datum,x:i,y:s,distance:l}}(e,t,n,o);default:return null}}mw.ownsChrome=!0;var ww=null,kw=null;function Sw(){return kw||((ww=document.createElement("canvas")).width=1,ww.height=1,kw=ww.getContext("2d")),kw}function Aw(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 Cw(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Aw(e),r=Sw();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 s=r.isPointInStroke(o,t,n);if(r.lineWidth=i,s)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 s=((t-e.x1)*o+(n-e.y1)*r)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*o,c=e.y1+s*r,l=Math.sqrt((t-a)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:a,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Aw(e),r=Sw();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 s=r.isPointInStroke(o,t,n);if(r.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Mw(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,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>s)return{kind:"miss-outside"};const m=function(e,t,n,o,r=30,i,s=0){let a=null,c=r,l=1/0;if(i){const e=Hr(i,n,o,r,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={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=xw(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(a=e,l=n)}else c>e.distance&&(a=e,c=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Cw(e,n,o);t&&c>t.distance&&(a=t,c=t.distance)}return a}(a,c,h,p,d,l,u);return m?{kind:"hit",hover:Yl(m.datum||{},m.x,m.y,{nodeOrEdge:m.type})}:{kind:"miss"}}var jw=require("react"),Pw="StreamNetworkFrame",Iw=require("react/jsx-runtime"),Rw={top:20,right:80,bottom:20,left:80},Tw={top:40,right:40,bottom:40,left:40},_w=new Set(["chord","force","circlepack","orbit"]),Lw=[800,600],Dw=(0,Qb.memo)((0,Qb.forwardRef)(function(e,t){const{chartType:n,nodes:o,edges:r,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",edgeIdAccessor:d,childrenAccessor:h,hierarchySum:p,orientation:m="horizontal",nodeAlign:y="justify",nodePaddingRatio:f=.05,nodeWidth:g=15,iterations:b=300,forceStrength:v=.1,layoutExecution:x="auto",layoutLoadingContent:w,onLayoutStateChange:k,padAngle:S=.01,groupWidth:A=20,sortGroups:C,edgeSort:M,treeOrientation:j="vertical",edgeType:P="curve",padding:I,paddingTop:R,tensionConfig:T,showParticles:_=!1,particleStyle:L,renderMode:D,nodeStyle:N,edgeStyle:$,colorBy:B,colorScheme:E="category10",edgeColorBy:O="source",edgeOpacity:F=.5,colorByDepth:z=!1,nodeSize:H=8,nodeSizeRange:W=[5,20],nodeLabel:q,showLabels:G=!0,labelMode:Y,size:V=Lw,responsiveWidth:X,responsiveHeight:U,margin:K,className:Q,background:Z,maxDevicePixelRatio:J,enableHover:ee=!0,tooltipContent:te,customHoverBehavior:ne,customClickBehavior:oe,onObservation:re,annotationObservationCallback:ie,chartId:se,onTopologyChange:ae,annotations:ce,onAnnotationActivate:le,autoPlaceAnnotations:ue,svgAnnotationRules:de,legend:he,legendPosition:pe,legendLayout:me,legendHoverBehavior:ye,legendClickBehavior:fe,legendHighlightedCategory:ge,legendIsolatedCategories:be,title:ve,foregroundGraphics:xe,backgroundGraphics:we,decay:ke,pulse:Se,transition:Ae,animate:Ce,staleness:Me,frameScheduler:je,clock:Pe,random:Ie,seed:Re,paused:Te=!1,suspendWhenHidden:_e=!0,thresholds:Le,accessibleTable:De=!0,description:Ne,summary:$e,orbitMode:Be,orbitSize:Ee,orbitSpeed:Oe,orbitRevolution:Fe,orbitRevolutionStyle:ze,orbitEccentricity:He,orbitShowRings:We,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ye,layoutConfig:Ve,layoutSelection:Xe}=e,Ue=_w.has(n)?Tw:Rw,Ke=(0,Qb.useRef)(!0),Qe=Cu({sizeProp:V,responsiveWidth:X,responsiveHeight:U,userMargin:K,marginDefault:Ue,title:ve,legend:he,legendPosition:pe,foregroundGraphics:xe,backgroundGraphics:we,animate:Ce,transitionProp:Ae,frameScheduler:je,clock:Pe,random:Ie,seed:Re,paused:Te,suspendWhenHidden:_e,themeDirtyRef:Ke}),{reducedMotionRef:Ze,responsiveRef:Je,size:et,margin:tt,adjustedWidth:nt,adjustedHeight:ot,resolvedForeground:rt,resolvedBackground:it,transition:st,introEnabled:at,tableId:ct,rafRef:lt,renderFnRef:ut,scheduleRender:dt,frameRuntime:ht,currentTheme:pt}=Qe,mt=Gc(),yt=Uc(),gt=(0,Qb.useMemo)(()=>ft(o),[o]),bt=(0,Qb.useMemo)(()=>Array.isArray(r)?ft(r):r,[r]),vt=(0,Qb.useMemo)(()=>({...Zb,...T}),[T]),xt=(0,Qb.useMemo)(()=>({...Jb,...L}),[L]),wt=(0,Qb.useMemo)(()=>{return{chartType:(e={chartType:n,clock:ht.now,random:Ie,seed:Re,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:d,childrenAccessor:h,hierarchySum:p,orientation:m,nodeAlign:y,nodePaddingRatio:f,nodeWidth:g,iterations:b,forceStrength:v,padAngle:S,groupWidth:A,sortGroups:C,edgeSort:M,treeOrientation:j,edgeType:P,padding:I,paddingTop:R,tensionConfig:vt,showParticles:_,particleStyle:xt,nodeStyle:N,edgeStyle:$,nodeLabel:q,showLabels:G,labelMode:Y,colorBy:B,colorScheme:E,edgeColorBy:O,edgeOpacity:F,colorByDepth:z,nodeSize:H,nodeSizeRange:W,decay:ke,pulse:Se,transition:st,introAnimation:at,staleness:Me,thresholds:Le,orbitMode:Be,orbitSize:Ee,orbitSpeed:Oe,orbitRevolution:Fe,orbitRevolutionStyle:ze,orbitEccentricity:He,orbitShowRings:We,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ye,layoutConfig:Ve,currentTheme:pt}).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:Rt(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,ht.now,Ie,Re,a,c,l,u,d,h,p,m,y,f,g,b,v,S,A,C,M,j,P,I,R,vt,_,xt,N,$,q,G,Y,B,E,O,F,z,H,W,ke,Se,st,at,Me,Le,Be,Ee,Oe,Fe,ze,He,We,qe,Ge,Ye,Ve,pt]),kt=Qc(wt),St=Qc({chartType:(At={chartType:n,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:d,childrenAccessor:h,hierarchySum:p,orientation:m,nodeAlign:y,nodePaddingRatio:f,nodeWidth:g,iterations:b,forceStrength:v,padAngle:S,groupWidth:A,sortGroups:C,edgeSort:M,treeOrientation:j,edgeType:P,padding:I,paddingTop:R,random:Ie,seed:Re,tensionConfig:vt,customNetworkLayout:Ge,orbitMode:Be,orbitSize:Ee,orbitEccentricity:He}).chartType,nodeIDAccessor:At.nodeIDAccessor,sourceAccessor:At.sourceAccessor,targetAccessor:At.targetAccessor,valueAccessor:At.valueAccessor,edgeIdAccessor:At.edgeIdAccessor,childrenAccessor:At.childrenAccessor,hierarchySum:At.hierarchySum,orientation:At.orientation,nodeAlign:At.nodeAlign,nodePaddingRatio:At.nodePaddingRatio,nodeWidth:At.nodeWidth,iterations:At.iterations,forceStrength:At.forceStrength,padAngle:At.padAngle,groupWidth:At.groupWidth,sortGroups:At.sortGroups,edgeSort:At.edgeSort,treeOrientation:At.treeOrientation,edgeType:At.edgeType,padding:At.padding,paddingTop:At.paddingTop,random:At.random,seed:At.seed,tensionConfig:At.tensionConfig,customNetworkLayout:At.customNetworkLayout,orbitMode:At.orbitMode,orbitSize:At.orbitSize,orbitEccentricity:At.orbitEccentricity});var At;const Ct=(0,Qb.useRef)(0),Mt=(0,Qb.useRef)(0),jt=(0,Qb.useRef)(!1),Pt=(0,Qb.useRef)(null);Pt.current||(Pt.current=new Yx(kt));const It=yr("StreamNetworkFrame"),Tt=(0,Qb.useCallback)((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)}(It.current,e,()=>e.buildScene(t),n),[It]),[_t,Lt]=(0,Qb.useState)(null),[Dt,Nt]=(0,Qb.useState)(0),[$t,Bt]=(0,Qb.useState)(0),[Et,Ot]=(0,Qb.useState)(!1),[Ft,zt]=(0,Qb.useState)(!1),Ht=(0,Qb.useRef)(0),Wt=(0,Qb.useRef)(null),qt=(0,Qb.useRef)(!1),Gt=(0,Qb.useRef)(k);Gt.current=k;const Yt=(0,Qb.useRef)(kt);Yt.current=kt;const Vt=(0,Qb.useRef)(null),Xt=(0,Qb.useRef)(new Map),Ut=(0,Qb.useRef)(0),Kt=(0,Qb.useCallback)(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:kn;r.set(e+"",t[i.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const s=Array.isArray(o)?o:kn,a=n?s[i.current++%s.length]:s[0];return r.set(t.id,a),a}({node:e,colorBy:B,colorScheme:E,nodeColorMap:Xt.current,colorIndexRef:Ut}),[B,E]),Qt=(0,Qb.useCallback)(e=>{Ut.current=function(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:kn,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];o.has(t.id)||o.set(t.id,i[e%i.length])}return s.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Xt.current,colorScheme:E})},[E]),Zt=(0,Qb.useCallback)((e,t)=>{Tt(e,t),Qt(e),Ke.current=!1,e.markStylePaintPending()},[Tt,Qt]),Jt=(0,Qb.useCallback)(()=>{Pt.current?.markStylePaintPending()},[]),en=(tn=pt,tn?.colors?.border||tn?.colors?.secondary||tn?.colors?.primary||"#999");var tn;const nn=(0,Qb.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Pt.current?.nodes),[]),on=(0,Qb.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:i}=e;if("function"==typeof n)return n(t);const s=r(t.source),a=r(t.target);return"target"===n&&a?o(a):s?o(s):i}({edge:e,edgeColorBy:O,getNodeColor:Kt,resolveEndpoint:nn,fallback:en}),[O,Kt,en,nn]),rn=(0,Qb.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:c}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):c}if(!r)return i(t);const l=o,u=a(t.source),d=a(t.target);return"target"===l&&d?s(d):u?s(u):c}({edge:e,particleStyleColor:xt.color,particleColorBy:xt.colorBy,hasExplicitParticleColorBy:!!L?.colorBy,getEdgeColor:on,getNodeColor:Kt,resolveEndpoint:nn,fallback:en}),[L?.colorBy,xt.color,xt.colorBy,Kt,on,en,nn]),sn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Ge,_,!!Se,Pt.current?.isAnimating??!1);Mr(Pt,kt,Ke,dt),jr(Pt,Xe,Ke,dt),(0,Qb.useEffect)(()=>{const e=Pt.current;e&&(Zt(e,[nt,ot]),Nt(e=>e+1),dt())},[pt,nt,ot,Zt,dt]);const an=(0,Qb.useCallback)(()=>{const e=Pt.current;if(e&&(e.runLayout([nt,ot]),Zt(e,[nt,ot]),Nt(e.layoutVersion),ae)){const{nodes:t,edges:n}=e.getLayoutData();ae(t,n)}},[nt,ot,Zt,ae]),cn=(0,Qb.useRef)(!1),ln=(0,Qb.useCallback)((e=!1)=>!(!e&&!cn.current||(cn.current=!1,an(),0)),[an]),un=(0,Qb.useCallback)(()=>ln(!1),[ln]),dn=(0,Qb.useCallback)(e=>{const t=Pt.current;if(!t)return!1;let n=!1,o=cn.current;for(const r of e)null!=r&&"object"==typeof r&&(n=!0,t.ingestEdge(r)&&(o=!0));const r=ln(o);return n||r},[ln]),hn=(0,Qb.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=Pt.current;t&&(t.ingestEdge(e)&&(cn.current=!0),ht.isActive?dt():un())},[un,ht,dt]),pn=(0,Qb.useCallback)(e=>{dn(e)&&dt()},[dn,dt]);(0,Qb.useEffect)(()=>ht.subscribe(()=>{ht.isActive||un()}),[un,ht]);const mn=(0,Qb.useCallback)(()=>{cn.current=!1,Pt.current?.clear(),Xt.current.clear(),Ut.current=0,Nt(Pt.current?.layoutVersion??0),Lt(null),Vt.current=null,Ke.current=!0,dt()},[dt]),yn=(0,Qb.useCallback)(()=>{const e=Pt.current;e&&(e.tension+=999,ln(!0),dt())},[ln,dt]);(0,Qb.useImperativeHandle)(t,()=>({push:hn,pushMany:pn,removeNode:e=>{const t=Pt.current?.removeNode(e)??!1;if(t){const t=Vt.current?.data?"function"==typeof a?a(Vt.current.data):Vt.current.data[a]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Lt(null)),Xt.current.delete(e)}return ln(t)&&(Ke.current=!0,dt()),t},removeEdge:(e,t)=>{const n=Pt.current?.removeEdge(e,t)??!1;if(n&&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:!d||!n||("function"==typeof d?d:e=>e?.[d])(n)===e,o&&(Vt.current=null,Lt(null))}return ln(n)&&(Ke.current=!0,dt()),n},updateNode:(e,t)=>{const n=Pt.current?.updateNode(e,t)??null;return ln(null!==n)&&(Ke.current=!0,dt()),n},updateEdge:(e,t,n)=>{const o=Pt.current?.updateEdge(e,t,n)??[];return ln(o.length>0)&&(Ke.current=!0,dt()),o},clear:mn,getTopology:()=>(un(),Pt.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(un(),Pt.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(un(),Pt.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{un();const e=Pt.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:yn,getTension:()=>(un(),Pt.current?.tension??0)}),[hn,pn,mn,yn,un,ln,a,dt,d]);const fn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),gn=fn?i||(Array.isArray(r)?void 0:r):void 0;(0,Qb.useEffect)(()=>{const e=Pt.current;if(!e)return;const t=++Ht.current;if(Wt.current?.abort(),Wt.current=null,fn&&gn)cn.current=!1,e.ingestHierarchy(gn,[nt,ot]),Zt(e,[nt,ot]),Nt(e.layoutVersion),zt(!1),Gt.current?.("ready"),dt();else{const i=gt,s=Array.isArray(bt)?bt:[];if(null==o&&null==r||(cn.current=!1),0===i.length&&0===s.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||mn(),zt(!1),void Gt.current?.("ready");const a=[nt,ot],c="force"===n&&!Ge&&lw()&&!Ie&&function(e,t,n,o,r=4e4){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(x,i.length,s.length,b);if(c&&yt&&!qt.current&&e.sceneNodes.length>0)return qt.current=!0,zt(!1),Gt.current?.("ready"),Ke.current=!0,void dt();if(c){const n=new AbortController;Wt.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const r=e.getLayoutData(),c=function(e,t,n,o,r){const i=rx(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,a,o);return zt(!0),Gt.current?.("pending"),function(e,t){return lw()?dw.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Ht.current&&(e.applyForceLayoutPositions(n,a),Zt(e,a),zt(!1),Gt.current?.("ready"),Nt(e.layoutVersion),dt())}).catch(n=>{"AbortError"!==n.name&&t===Ht.current&&(e.runLayout(a),Zt(e,a),zt(!1),Gt.current?.("error"),Nt(e.layoutVersion),dt())}),()=>n.abort()}e.ingestBounded(i,s,a),Zt(e,a),Nt(e.layoutVersion),zt(!1),Gt.current?.("ready"),dt()}},[gt,bt,o,r,i,gn,fn,nt,ot,St,x,b,yt,n,Ge,Ie,dt,mn,Zt]);const bn=Kb.useRef(!1);(0,Qb.useEffect)(()=>{bn.current||s&&s.length>0&&(bn.current=!0,pn(s))},[s,pn]);const{customHoverBehavior:vn,customClickBehavior:xn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:(0,jw.useCallback)((t,r)=>{e?.(t,r),Nd({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Pw,chartId:o,context:r})},[e,n,o]),customClickBehavior:(0,jw.useCallback)((e,r)=>{t?.(e,r),$d({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Pw,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:ne,customClickBehavior:oe,onObservation:re,chartId:se}),{hoverHandlerRef:wn,hoverLeaveRef:Sn,onPointerMove:An,onPointerLeave:Cn}=Qe,Mn=()=>!Ge||(Pt.current?.hasCustomRestyle??!1);wn.current=e=>{if(!ee)return;const t=Mn(),n=Dn.current;if(!n)return;const o=Pt.current;if(!o)return;const r=Mw({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:tt,adjustedWidth:nt,adjustedHeight:ot,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Vt.current=r.hover,Lt(r.hover),vn?.(r.hover),t&&dt()):Vt.current&&(Vt.current=null,Lt(null),vn?.(null),t&&dt())},Sn.current=()=>{if(Vt.current){const e=Mn();Vt.current=null,Lt(null),vn?.(null),e&&dt()}};const jn=(0,Qb.useRef)(()=>{});jn.current=e=>{if(Qs(e.target))return;if(!oe&&!re)return;const t=Dn.current;if(!t)return;const n=Pt.current;if(!n)return;const o=Mw({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:tt,adjustedWidth:nt,adjustedHeight:ot,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?xn(o.hover,{type:"activate",inputType:Ld(e.nativeEvent.pointerType)}):"miss"===o.kind&&xn(null)};const Pn=(0,Qb.useCallback)(e=>jn.current(e),[]),In=(0,Qb.useRef)(-1),Rn=(0,Qb.useRef)(null),Tn=(0,Qb.useRef)(-1),_n=(0,Qb.useCallback)(e=>{if(Dd(e))return;const t=Pt.current;if(!t)return;const n=()=>{In.current=-1,Rn.current=null,Tn.current=-1,Vt.current=null,Lt(null),vn?.(null),dt()},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=Fr(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>In.current||n());const r=Fd(o);let i=In.current;if(r.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=r.flat[i];return void xn?.(Yl(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(),In.current=0,Tn.current=-1;const t=r.flat[0];Rn.current={shape:t.shape,w:t.w,h:t.h};const n=Yl(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=n,Lt(n),vn?.(n,{type:"focus",inputType:"keyboard"}),void dt()}const s=zd(r,i),a=function(e,t,n,o,r){const i=n.flat[t.flatIndex];if(!i)return Hd(e,t,n);const s=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 s=e.flat[i];if(s===t)continue;const a=s.x-t.x,c=s.y-t.y;let l=!1;switch(n){case"right":l=a>0&&Math.abs(a)>=Math.abs(c);break;case"left":l=0>a&&Math.abs(a)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(a);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(a)}if(!l)continue;const u=a*a+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==s)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=Yd(t.source),i=Yd(t.target),s=null!=r,a=null!=i;s&&r+""===n&&a?o.push(i+""):a&&i+""===n&&s&&o.push(r+"")}return o}(s,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=Hd(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,s,r,t.sceneEdges??[],Tn);if(null===a)return;if(e.preventDefault(),0>a)return void n();In.current=a;const c=r.flat[a];Rn.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,Lt(l),vn?.(l,{type:"focus",inputType:"keyboard"}),dt()},[xn,vn,dt]),Ln=(0,Qb.useCallback)(e=>{In.current=-1,Rn.current=null,An(e)},[An]);ut.current=()=>{if(lt.current=null,un(),!ht.isActive)return;const e=Dn.current;if(!e)return;const t=Pt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:i,adjustedWidth:s,adjustedHeight:a,background:c,maxDevicePixelRatio:l,renderMode:u,hasBackgroundGraphics:d=!1,dirtyRef:h,resolutionDirtyRef:p,lastFrameTimeRef:m,now:y,random:f,reducedMotion:g,showParticles:b,isContinuous:v,animate:x,decay:w,pulse:k,thresholds:S,staleness:A,particleStyle:C,getParticleColor:M,pendingAnnotationFrameRef:j,lastAnnotationFrameTimeRef:P,setAnnotationFrame:I,scheduleNextFrame:R,syncColorMap:T}=e,_=t.getContext("2d");if(!_)return;const L=m.current?Math.min((y-m.current)/1e3,.1):.016;m.current=y;const D=n.advanceTransition(g?y+1e6:y),N=!g&&D,$=!g&&n.tickAnimation([s,a],L),B=h.current,E=o?.beforeCompute(n.getLastUpdateResult(),N),O=D||B||$;O&&(n.buildScene([s,a]),B&&T?.()),E&&o?.afterCompute(E,O,!1);const F=b&&!g&&!!n.particlePool,z=ol({dirtyOrRebuilt:B,transitioning:N,animationTicked:$,continuous:F||v,liveEncoding:!!w||!!k||!!S||!1!==x&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()||!0===p?.current});p&&(p.current=!1);const H=!!A&&n.lastIngestTime>0&&y-n.lastIngestTime>(A?.threshold??5e3);if(z){const e=Pu(l);if(!ju(t,r,i,e))return;if(_.clearRect(-i.left,-i.top,r[0],r[1]),nl(_,{background:c,hasBackgroundGraphics:d,width:s,height:a}),w&&n.applyDecay(),k&&n.applyPulse(y),S&&n.applyThresholds(y),!1!==x&&n.applyTopologyDiff(y),H&&(_.globalAlpha=A?.dimOpacity??.5),vd({context:_,nodes:n.sceneEdges,renderMode:u,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":fw(e,n);break;case"line":gw(e,n);break;case"ribbon":bw(e,n);break;case"curved":vw(e,n)}}(_,e)}),vd({context:_,nodes:n.sceneNodes,renderMode:u,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),di(e,t.style,"#007bff",()=>e.fillRect(t.x,t.y,t.w,t.h)),hi(e,t.style,()=>e.strokeRect(t.x,t.y,t.w,t.h)),Vu(e,t),e.restore())}}(_,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),di(e,t.style,"#007bff",()=>e.fill()),hi(e,t.style,()=>e.stroke()),Xu(e,t),e.restore())}}(_,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(),di(e,t.style,"#007bff",()=>e.fill()),hi(e,t.style,()=>e.stroke()),e.restore()}}(_,t),function(e,t){const n=e.globalAlpha;for(const o of t)"symbol"===o.type&&nd(e,o,o.cx,o.cy,n,"#007bff");e.globalAlpha=n}(_,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&rd(e,o,o.cx,o.cy,n);e.globalAlpha=n}(_,t)}}),F&&!H){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const i=o.spawnRate??.1,s=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const a=t[o];if(!a.bezier)continue;if(e.countForEdge(o)>=s)continue;const c=a.value*i*n*(a.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)<s;t++)e.spawn(o,r)}}(n.particlePool,e,L,C,f);const t=.5*(C.speedMultiplier??1);let o;if(C.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(L,t,e,o),function(e,t,n,o,r){const i=o.radius??3;e.globalAlpha=o.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const c=n[a.edgeIndex];if(!c)continue;let l;l="string"==typeof o.color&&"inherit"!==o.color?o.color:r(c),e.fillStyle=Xr(e,l)||l,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(_,n.particlePool,e,C,M)}}H&&(_.globalAlpha=1)}h.current=!1,(B||N||$)&&t.setAttribute("aria-label",kl(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const W=B||N||$||j.current;W&&y-P.current>=33?(I(e=>e+1),P.current=y,j.current=!1):j.current=!!W,(v||N||null!=n.transition||$||n.hasActivePulses||n.hasActiveThresholds||!1!==x&&n.hasActiveTopologyDiff||j.current)&&R()}({canvas:e,store:t,sceneRevisionDiagnostics:It.current,size:et,margin:tt,adjustedWidth:nt,adjustedHeight:ot,background:Z,maxDevicePixelRatio:J,renderMode:D,hasBackgroundGraphics:!!we,dirtyRef:Ke,resolutionDirtyRef:Nn,lastFrameTimeRef:Ct,now:ht.now(),random:ht.random,reducedMotion:!!Ze.current,showParticles:_,isContinuous:sn,animate:Ce,decay:ke,pulse:Se,thresholds:Le,staleness:Me,particleStyle:xt,getParticleColor:rn,pendingAnnotationFrameRef:jt,lastAnnotationFrameTimeRef:Mt,setAnnotationFrame:Bt,scheduleNextFrame:()=>{dt()},syncColorMap:()=>Qt(t)})};const{canvasRef:Dn,resolutionDirtyRef:Nn}=Tu(Qe,{hydrated:mt,wasHydratingFromSSR:yt,storeRef:Pt,dirtyRef:Ke,skipInitialCanvasPaintInvalidation:!0,canvasPaintInvalidator:Jt,maxDevicePixelRatio:J,canvasPaintDependencies:[n,nt,ot,Z,we,D,dt]});_i(Me,Pt,Ke,dt,Et,Ot);const $n=ee&&_t?(0,Iw.jsx)(uu,{x:_t.x,y:_t.y,containerWidth:nt,containerHeight:ot,margin:tt,className:"stream-network-tooltip",zIndex:2,children:te?te(_t):(0,Iw.jsx)(mw,{data:_t})}):null;if(Hc||!mt&&yt)return(0,Iw.jsx)(tw,{props:e,store:Pt.current,responsiveRef:Je,size:et,margin:tt,adjustedWidth:nt,adjustedHeight:ot,resolvedBackground:it,resolvedForeground:rt});const Bn=Pt.current;return(0,Iw.jsxs)("div",{ref:Je,className:"stream-network-frame"+(Q?" "+Q:""),role:"group","aria-label":Ne||("string"==typeof ve?ve:"Network chart"),tabIndex:0,"aria-busy":Ft||void 0,style:{position:"relative",width:X?"100%":et[0],height:U?"100%":et[1],overflow:"visible"},onKeyDown:_n,children:["production"!==process.env.NODE_ENV&&Pt.current&&(0,Iw.jsx)(fr,{store:Pt.current,diagnostics:It.current}),De&&(0,Iw.jsx)(Ol,{tableId:ct}),De&&(0,Iw.jsx)(Bl,{nodes:Bn?.sceneNodes??[],edges:Bn?.sceneEdges??[],chartType:"Network chart",tableId:ct,chartTitle:"string"==typeof ve?ve:void 0}),(0,Iw.jsx)(El,{summary:$e}),(0,Iw.jsx)(yl,{hoverPoint:_t}),(0,Iw.jsxs)("div",{role:"img","aria-label":Ne||("string"==typeof ve?ve:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ee?Ln:void 0,onMouseLeave:ee?Cn:void 0,onClick:oe||re?Pn:void 0,children:[Ft&&!1!==w&&(0,Iw.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Dp(!0,et[0],et[1],w)}),(0,Iw.jsx)(_u,{size:et,margin:tt,overflowVisible:!0,children:it}),(0,Iw.jsx)("canvas",{ref:Dn,"aria-label":kl(Bn?.sceneNodes?.length??0,Bn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,Iw.jsx)(Ux,{width:nt,height:ot,totalWidth:et[0],totalHeight:et[1],margin:tt,labels:Bn?.labels||[],sceneNodes:Bn?.sceneNodes,title:ve,legend:he,legendPosition:pe,legendLayout:me,legendHoverBehavior:ye,legendClickBehavior:fe,legendHighlightedCategory:ge,legendIsolatedCategories:be,foregroundGraphics:br(rt,Ar(Pt.current?.customLayoutOverlays,Xe??null)),annotations:ce,onAnnotationActivate:le,onObservation:ie??re,chartId:se,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ue,svgAnnotationRules:de,annotationFrame:$t}),(0,Iw.jsx)(Jx,{marks:Bn?.customLayoutHtmlMarks,margin:tt,selection:Xe??null}),(0,Iw.jsx)(Hl,{active:In.current>=0,hoverPoint:_t,margin:tt,size:et,shape:Rn.current?.shape,width:Rn.current?.w,height:Rn.current?.h}),$n,Me?.showBadge&&(0,Iw.jsx)(Di,{isStale:Et,position:Me.badgePosition})]})]})}));Dw.displayName="StreamNetworkFrame";var Nw=Dw,$w=require("react");function Bw(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 Ew(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 Ow(e){return"function"==typeof e?e:t=>t[e]||1}function Fw({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return s=>{const a={fillOpacity:r,...i};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=Pn(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=Pn(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*r);return a}}function zw(e){const{nodes:t,edges:n,inferNodes:o=!0,sourceAccessor:r="source",targetAccessor:i="target",colorBy:s,colorScheme:a,showLegend:c,legendPosition:l,legendInteraction:u,selection:d,linkedHover:h,onObservation:p,onClick:m,mobileInteraction:y,mobileSemantics:f,chartType:g,chartId:b,marginDefaults:v,userMargin:x,width:w,height:k,hasTitle:S,loading:A,loadingContent:C,emptyContent:M,emptyDataKey:j="edges"}=e,P=(0,$w.useMemo)(()=>ft(n),[n]),I=(0,$w.useMemo)(()=>ft(t),[t]),R=Dp(A,w,k,C),T=R?null:Lp("nodes"===j?void 0===t?void 0:I:void 0===n?void 0:P,w,k,M),_=(0,$w.useMemo)(()=>o?Ew(I,P,r,i):I,[o,I,P,r,i]),L=bp(_,s,a),D=fp(),N=(0,$w.useMemo)(()=>Array.isArray(a)&&a.length>0?a:[...An(a,D,kn)],[a,D]),$=(0,$w.useMemo)(()=>hp(_,s),[_,s]),B=mp(u,s,$),{legend:E,margin:O,legendPosition:F}=pp({data:_,colorBy:s,colorScale:L,showLegend:c,legendPosition:l,userMargin:x,defaults:v,categories:$,chartWidth:w,hasTitle:S}),z=(0,$w.useMemo)(()=>Fh(y,{width:w,mobileSemantics:f}),[y,w,f]),H=xp({selection:d,linkedHover:h,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:p,onClick:m,mobileInteraction:z,chartType:g,chartId:b}),{customHoverBehavior:W,customClickBehavior:q,activeSelectionHook:G,hoverSelectionHook:Y,crosshairSourceId:V}=H;return{safeNodes:_,safeEdges:P,colorScale:L,effectivePalette:N,themeCategorical:D,allCategories:$,legendState:B,legend:E,margin:O,legendPosition:F,mobileInteraction:z,customHoverBehavior:W,customClickBehavior:q,activeSelectionHook:G,hoverSelectionHook:Y,crosshairSourceId:V,loadingEl:R,emptyEl:T}}var Hw=require("react/jsx-runtime"),Ww=(0,Ub.forwardRef)(function(e,t){const n=(0,Ub.useRef)(null);im(t,{variant:"network",frameRef:n});const o=kp(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:s,className:a,nodeIdAccessor:c,nodeIDAccessor:l,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:p,colorScheme:m,styleRules:y,nodeSize:f=8,nodeSizeRange:g=[5,20],nodeStroke:b,nodeStrokeWidth:v,edgeWidth:x,edgeColor:w,edgeOpacity:k,iterations:S=300,forceStrength:A=.1,layoutExecution:C="auto",layoutLoadingContent:M,onLayoutStateChange:j,tooltip:P,frameProps:I={},onObservation:R,onClick:T,chartId:_,selection:L,linkedHover:D,loading:N,loadingContent:$,emptyContent:B,legendInteraction:E,legendPosition:O,stroke:F,strokeWidth:z,opacity:H}=e,W=c??l??"id",{width:q,height:G,enableHover:Y,showLegend:V,showLabels:X=!1,title:U,description:K,summary:Q,accessibleTable:Z}=o,J=zw({nodes:r,edges:i,inferNodes:!1,nodeIdAccessor:W,sourceAccessor:u,targetAccessor:d,colorBy:p,colorScheme:m,showLegend:V,legendPosition:O,legendInteraction:E,selection:L,linkedHover:D,onObservation:R,onClick:T,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ForceDirectedGraph",chartId:_,marginDefaults:o.marginDefaults,userMargin:s,width:q,height:G,hasTitle:!!U,loading:N,loadingContent:$,emptyContent:B,emptyDataKey:"nodes"}),ee=(0,Ub.useMemo)(()=>new Map,[]),te=(0,Ub.useMemo)(()=>e=>{const t={};return t.fill=p?Pn(e.data||e,p,J.colorScale):gp(void 0,J.themeCategorical,m,void 0,ee),"number"==typeof f&&(t.r=f),t},[p,J.colorScale,f,J.themeCategorical,m,ee]),ne=(0,Ub.useMemo)(()=>Zp(p,"number"==typeof f?void 0:f),[p,f]),oe=(0,Ub.useMemo)(()=>Up(nm(te,y,ne,e=>e.data||e),{stroke:b??F,strokeWidth:v??z,opacity:H}),[te,y,ne,b,F,v,z,H]),re=w??F??"#999",ie=k??H??.6,se=z??1,ae=(0,Ub.useMemo)(()=>e=>{const t=e.data||e;let n;if(void 0===x)n=se;else if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],o="number"==typeof e?e:Number(e);n=Number.isFinite(o)&&o>0?o:se}return{stroke:re,strokeWidth:n,opacity:ie}},[x,re,ie,se]),ce=(0,Ub.useMemo)(()=>{if(X&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[X,h]),le=Wp({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:W}});return le?(0,Hw.jsx)(Ap,{componentName:"ForceDirectedGraph",message:le,width:q,height:G}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,Hw.jsx)(Rp,{componentName:"ForceDirectedGraph",width:q,height:G,children:(0,Hw.jsx)(Nw,{ref:n,chartType:"force",...null!=r&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:J.margin,nodeIDAccessor:W,sourceAccessor:u,targetAccessor:d,iterations:S,forceStrength:A,layoutExecution:C,layoutLoadingContent:M,onLayoutStateChange:j,nodeStyle:oe,edgeStyle:ae,colorBy:p,colorScheme:J.effectivePalette,nodeSize:f,nodeSizeRange:g,nodeLabel:ce,showLabels:X,enableHover:Y,tooltipContent:!1===P?()=>null:cu(P)||void 0,...am({linkedHover:D,selection:L,onObservation:R,onClick:T,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...E&&"none"!==E&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:a,title:U,description:K,summary:Q,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...I})})});Ww.displayName="ForceDirectedGraph";var qw=require("react"),Gw=require("react/jsx-runtime"),Yw=(0,qw.forwardRef)(function(e,t){const n=(0,qw.useRef)(null);im(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=kp(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:s,className:a,sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,styleRules:m,edgeColorBy:y="source",padAngle:f=.01,groupWidth:g=20,sortGroups:b,nodeLabel:v,edgeOpacity:x=.5,tooltip:w,frameProps:k={},onObservation:S,onClick:A,chartId:C,selection:M,linkedHover:j,loading:P,loadingContent:I,emptyContent:R,legendInteraction:T,stroke:_,strokeWidth:L,opacity:D}=e,{width:N,height:$,enableHover:B,showLabels:E=!0,title:O,description:F,summary:z,accessibleTable:H}=o,W=zw({nodes:r,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,showLegend:!1,legendInteraction:T,selection:M,linkedHover:j,onObservation:S,onClick:A,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ChordDiagram",chartId:C,marginDefaults:o.marginDefaults,userMargin:s,width:N,height:$,hasTitle:!!O,loading:P,loadingContent:I,emptyContent:R}),q=(0,qw.useMemo)(()=>new Map,[]),G=(0,qw.useMemo)(()=>new Map,[]),Y=W.safeNodes.length>0,V=(0,qw.useMemo)(()=>{if(Y)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=Pn(e.data||e,h,W.colorScale);else{const o=Array.isArray(p)?p:wn[p]||kn,r=Array.isArray(o)?o:kn,i=(e.id??e.data?.[d]??"")+"";G.has(i)||G.set(i,G.size);const s=e.index??t??G.get(i);n.fill=r[s%r.length]}return n}},[Y,h,W.colorScale,p,d,G]),X=(0,qw.useMemo)(()=>Zp(h),[h]),U=(0,qw.useMemo)(()=>{if(V||m&&m.length>0)return Up(nm(V,m,X,e=>e.data||e),{stroke:_,strokeWidth:L,opacity:D})},[V,m,X,_,L,D]),K=(0,qw.useMemo)(()=>{if(Y)return Fw({edgeColorBy:y,colorBy:h,colorScale:W.colorScale,nodeStyleFn:U||(e=>({fill:gp(void 0,W.themeCategorical,p,void 0,q)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[Y,y,h,W.colorScale,U,x,W.themeCategorical,p,q]),Q=(0,qw.useMemo)(()=>K?Up(K,{stroke:_,strokeWidth:L,opacity:D}):void 0,[K,_,L,D]),Z=(0,qw.useMemo)(()=>{if(!E)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[E,v,d]),J=Wp({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,Gw.jsx)(Ap,{componentName:"ChordDiagram",message:J,width:N,height:$}):W.loadingEl?W.loadingEl:W.emptyEl?W.emptyEl:(0,Gw.jsx)(Rp,{componentName:"ChordDiagram",width:N,height:$,children:(0,Gw.jsx)(Nw,{ref:n,chartType:"chord",...W.safeNodes.length>0&&{nodes:W.safeNodes},...null!=i&&{edges:W.safeEdges},size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:W.margin,nodeIDAccessor:d,sourceAccessor:c,targetAccessor:l,valueAccessor:u,padAngle:f,groupWidth:g,sortGroups:b,nodeStyle:U,edgeStyle:Q,colorBy:h,colorScheme:W.effectivePalette,edgeColorBy:y,edgeOpacity:x,nodeLabel:Z,showLabels:E,enableHover:B,tooltipContent:!1===w?()=>null:cu(w)||void 0,...am({linkedHover:j,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:a,title:O,description:F,summary:z,accessibleTable:H,...null!=e.animate&&{animate:e.animate},...k})})});Yw.displayName="ChordDiagram";var Vw=require("react"),Xw=require("react/jsx-runtime"),Uw=(0,Vw.forwardRef)(function(e,t){const n=(0,Vw.useRef)(null);im(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=kp(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:s,className:a,sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:p,styleRules:m,edgeColorBy:y="source",orientation:f="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:j,selection:P,linkedHover:I,loading:R,loadingContent:T,emptyContent:_,showLegend:L,legendPosition:D,legendInteraction:N,stroke:$,strokeWidth:B,opacity:E}=e,{width:O,height:F,enableHover:z,showLabels:H=!0,title:W,description:q,summary:G,accessibleTable:Y}=o,V=zw({nodes:r,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,showLegend:L,legendPosition:D,legendInteraction:N,selection:P,linkedHover:I,onObservation:C,onClick:M,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"SankeyDiagram",chartId:j,marginDefaults:o.marginDefaults,userMargin:s,width:O,height:F,hasTitle:!!W,loading:R,loadingContent:T,emptyContent:_}),X=(0,Vw.useMemo)(()=>new Map,[]),U=(0,Vw.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Pn(e.data||e,h,V.colorScale):gp(void 0,V.themeCategorical,p,void 0,X),t},[h,V.colorScale,V.themeCategorical,p,X]),K=(0,Vw.useMemo)(()=>Zp(h,u),[h,u]),Q=(0,Vw.useMemo)(()=>Up(nm(U,m,K,e=>e.data||e),{stroke:$,strokeWidth:B,opacity:E}),[U,m,K,$,B,E]),Z=(0,Vw.useMemo)(()=>Fw({edgeColorBy:y,colorBy:h,colorScale:V.colorScale,nodeStyleFn:Q,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,V.colorScale,Q,w]),J=(0,Vw.useMemo)(()=>Up(Z,{stroke:$,strokeWidth:B,opacity:E}),[Z,$,B,E]),ee=(0,Vw.useMemo)(()=>{if(!H)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[H,x,d]),te=Wp({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Xw.jsx)(Ap,{componentName:"SankeyDiagram",message:te,width:O,height:F}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:(0,Xw.jsx)(Rp,{componentName:"SankeyDiagram",width:O,height:F,children:(0,Xw.jsx)(Nw,{ref:n,chartType:"sankey",...V.safeNodes.length>0&&{nodes:V.safeNodes},...null!=i&&{edges:V.safeEdges},size:[O,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:V.margin,nodeIDAccessor:d,sourceAccessor:c,targetAccessor:l,valueAccessor:u,orientation:f,nodeAlign:g,nodePaddingRatio:b,nodeWidth:v,nodeStyle:Q,edgeStyle:J,colorBy:h,colorScheme:V.effectivePalette,edgeColorBy:y,edgeOpacity:w,edgeSort:k,nodeLabel:ee,showLabels:H,enableHover:z,tooltipContent:!1===S?()=>null:cu(S)||void 0,...am({linkedHover:I,selection:P,onObservation:C,onClick:M,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:V.legend,legendPosition:V.legendPosition,...N&&"none"!==N&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},className:a,title:W,description:q,summary:G,accessibleTable:Y,...null!=e.animate&&{animate:e.animate},...A})})});Uw.displayName="SankeyDiagram";var Kw=require("react"),Qw={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Zw(e="static"){return Qw[e]??Qw.static}var Jw=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function ek(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Jw.has(e.kind)?"fatal":"warn"}function tk(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function nk(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=a>c?a:c,u=Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function ok(e,t){let n=0,o=e.length-1,r=-1;for(;o>=n;){const i=n+o>>>1;e[i].at>t?o=i-1:(r=i,n=i+1)}return 0>r?{at:t,before:0,after:0}:e[r]}function rk(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],s=e[r+1],a=[...new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=ok(i,e),n=ok(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function ik(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>a;e++){const e=new Map(r.map((e,t)=>[e,t])),c=new Map,l=new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,s>u)s=u,i=[...r];else if(u===s)break}return i}function sk(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,c>e&&(c=e,a=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>s;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function ak(e,t){return t>e?-1:e>t?1:0}function ck(e){return e.occupants.map(e=>e.id).sort(ak).join("\0")}function lk(e,t,n=0){return e.slice(0,-1).map((o,r)=>null!=o.group&&o.group===e[r+1].group?n:t)}function uk(e,t){return e.map(e=>{const n=new Map;for(const o of e.occupants){const e=t[o.id];if(e)for(const t of e.samples){const e=n.get(t.t)??{before:0,after:0},o=t.boundaryOffset??0;n.set(t.t,{before:Math.max(e.before,t.topMass-o),after:Math.max(e.after,t.botMass+o)})}}return[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function dk(e,t,n){if(0===e.length)return[];const{padding:o,plotH:r,valueScale:i}=n,s=n.stackValueScale??i,a=lk(e,o,n.groupPadding??0),c=[o+e[0].peak.topPeak*s];for(let n=1;e.length>n;n++)c.push(c[n-1]+t[n-1]*s+a[n-1]);const l=c[c.length-1]+e[e.length-1].peak.botPeak*s+o;if(l>r&&l>0){const e=r/l;for(let t=0;c.length>t;t++)c[t]*=e}return c}function hk(e,t){const n=(e.boundaryOffset??0)*t,o=e.value*t;if("out"===e.kind){const r=e.sideMassBefore*t;return n+("top"===e.side?o/2-r:r-o/2)}const r=e.sideMassAfter*t;return n+("top"===e.side?o/2-r:r-o/2)}function pk(e,t,n,o,r,i){const s=i.adjacentClearance?[...i.adjacentClearance]:rk(uk(o,n)).adjacentClearance,a=dk(o,s,i);let c="hug"===i.lanePlacement?function(e,t,n,o,r,i,s){const a=e.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=lk(e,c,s.groupPadding??0),h=r.map((e,t)=>e*u+d[t]),p=c+e[0].peak.topPeak*u,m=l-c-e[a-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=m-p)return dk(e,r,s);let y=1===a?[(p+m)/2]:[...i];for(let e=0;12>e;e++){const e=Array(a).fill(0),r=Array(a).fill(0);for(const i of n){const n=t[i.source],s=t[i.target];if(null==n||null==s||n===s)continue;const a=o[i.source]?.localAttachments.get(i.id),c=o[i.target]?.localAttachments.get(i.id);if(!a||!c)continue;const l=i.value>0&&Number.isFinite(i.value)?i.value:1,d=hk(a,u),h=hk(c,u);e[n]+=(y[s]+h-d)*l,r[n]+=l,e[s]+=(y[n]+d-h)*l,r[s]+=l}const i=nk({desired:y.map((t,n)=>0===r[n]?t:.45*t+e[n]/r[n]*.55),minGaps:h,weights:r.map(e=>Math.max(1,e)),min:p,max:m});let s=0;for(let e=0;a>e;e++)s=Math.max(s,Math.abs(i[e]-y[e]));if(y=i,.01>s)break}return y}(o,r,t,n,s,a,i):[...a];if("hug"===i.lanePlacement){const n=t=>{const n={};for(const o of e)n[o.id]=t[r[o.id]];return n};mk(n(c),t)>mk(n(a),t)+1e-6&&(c=[...a])}const l={};for(const t of e)l[t.id]=c[r[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=l[t.id],o=n[t.id];Number.isFinite(e)&&o&&(u=Math.min(u,e-o.topPeak*i.valueScale),d=Math.max(d,e+o.botPeak*i.valueScale))}return{adjacentClearance:s,centerlines:l,slotCenter:c,stackCenter:a,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&i.plotH>0?Math.max(0,Math.min(1,(d-u)/i.plotH)):0}}function mk(e,t){let n=0;for(const o of t){const t=e[o.source],r=e[o.target];Number.isFinite(t)&&Number.isFinite(r)&&(n+=Math.abs(t-r)*(o.value>0?o.value:1))}return n}function yk(e,t){const n=e?.samples;if(!n||0===n.length||n[0].t>t)return{top:0,bot:0};let o=0,r=n.length-1,i=0;for(;r>=o;){const e=o+r>>>1;n[e].t>t?r=e-1:(i=e,o=e+1)}const s=n[i].boundaryOffset??0;return{top:n[i].topMass-s,bot:n[i].botMass+s}}function fk(e,t,n,o,r){const i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*n+r*r*r*o}function gk(e,t){let n=0,o=1;for(let r=0;28>r;r++){const r=(n+o)/2;e>fk(0,t,t,1,r)?n=r:o=r}return(n+o)/2}function bk(e,t,n){const o=t+hk(e,n),r=e.value*n/2;return[o-r,o+r]}function vk(e,t,n,o){return Math.max(0,Math.min(t,o)-Math.max(e,n))/Math.max(1e-9,t-e)}function xk(e,t,n,o,r,i,s){const{valueScale:a,domain:c,mode:l="quality"}=s,u="source"===s.ribbonLane?.85:"target"===s.ribbonLane?.15:.5;let d=0;for(const s of e){const e=o[s.source],h=o[s.target];if(null==e||null==h||2>Math.abs(e-h))continue;const p=t[s.source]?.localAttachments.get(s.id),m=t[s.target]?.localAttachments.get(s.id);if(!p||!m)continue;const y=Math.max(s.startTime,c?.[0]??-1/0),f=Math.min(s.endTime,c?.[1]??1/0);if(y>=f)continue;const[g,b]=bk(p,r[s.source],a),[v,x]=bk(m,r[s.target],a),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){const o=n[e];if(!o)continue;const c=[y,f];if("quality"===l)for(const e of o.occupants)for(const n of t[e.id]?.samples??[])n.t>y&&f>n.t&&c.push(n.t);const h=e=>{const n=gk((e-y)/(f-y),u),c=fk(g,g,v,v,n),l=fk(b,b,x,x,n);let d=0;for(const n of o.occupants){if(n.id===s.source||n.id===s.target)continue;const o=i[n.id];if(null!=o?.start&&o.start>e)continue;if(null!=o?.end&&e>o.end)continue;const u=yk(t[n.id],e),h=r[n.id];d=Math.max(d,vk(c,l,h-u.top*a,h+u.bot*a))}return d},p=[...new Set(c)].sort((e,t)=>e-t);let m=0;for(let e=0;p.length-1>e;e++){const t=p[e],n=p[e+1]-t;m+=(h(t+.25*n)+h(t+.5*n)+h(t+.75*n))/3*n}d+=m/(f-y)*(s.value>0?s.value:1)}}return d}function wk(e,t,n,o,r,i,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:mk(s,n),transitOcclusion:xk(n,o,r,i,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function kk(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Sk(e,t){return e.map(e=>({t:kk(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Ak(e,t,n){const o=t+(e.boundaryOffset??0)*n,r=e.value*n;if("out"===e.kind){const t=e.sideMassBefore*n;if("top"===e.side){const e=o-t;return[e,e+r]}const i=o+t;return[i-r,i]}const i=e.sideMassAfter*n;if("top"===e.side){const e=o-i;return[e,e+r]}const s=o+i;return[s-r,s]}function Ck(e,t,n,o,r="temporal"){const i=t.incoming[e.id],s=t.outgoing[e.id],a=[];for(const e of i)a.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of s)a.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{a.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(c[e.kind]??99)-(c[t.kind]??99)||((e,t)=>{if(!o||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const n=o.get(e.edge.id)?.target,r=o.get(t.edge.id)?.target;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof r&&Number.isFinite(r)&&n!==r?"top"===e.side?n-r:r-n:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const n=o.get(e.edge.id)?.source,r=o.get(t.edge.id)?.source;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof r&&Number.isFinite(r)&&n!==r?"top"===e.side?r-n:n-r:0}return 0})(e,t)||ak(e.edge?.id??"",t.edge?.id??"")||ak(e.side,t.side)||e.delta-t.delta)},u=a.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(a.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;l();let p=null,m=0;for(const e of a)e.time!==p&&(p=e.time,m=0),e.sequence=m++;const y=e=>({time:e.time,phase:0,sequence:e.sequence??0}),f=[];let g=0,b=0;for(const e of a)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?g:b);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?g:b);if(o>0){const r=y(e);f.push({...r,delta:-o,kind:"transfer-out",side:t}),f.push({...r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?g-=o:b-=o,"top"===e.side?g+=o:b+=o,n-=o}n>0&&null!==h&&(f.push({time:h,delta:+n,kind:"create",side:e.side}),"top"===e.side?g+=n:b+=n)}"top"===e.side?g-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?g+=t:b+=t}a.push(...f),l();let v=0,x=0,w=0,k=0,S=0,A=0;const C=[],M=new Map,j=e=>{C.push({t:e,topMass:v,botMass:x,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},P=()=>{k=Math.max(k,v+x),S=Math.max(S,v-w),A=Math.max(A,x+w)};for(const e of a){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&j(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:x;M.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===e.side?v+=e.delta:x+=e.delta,"transfer-in"===e.kind?(w+="top"===e.side?e.delta:-e.delta,P(),j(e.time)):"transfer-out"!==e.kind&&(P(),"out"!==e.kind||v+x>1e-12||(w=0),j(e.time))}const I=[];let R=0;for(;C.length>R;){let e=R;for(;C.length>e+1&&C[e+1].t===C[R].t;)e++;I.push(C[R]);for(let t=R+1;e>=t;t++){const e=I[I.length-1];C[t].topMass===e.topMass&&C[t].botMass===e.botMass&&(C[t].boundaryOffset??0)===(e.boundaryOffset??0)||I.push(C[t])}R=e+1}const T=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let _=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===_||_>e.systemInTime)&&(_=e.systemInTime);let L=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===L||e.systemOutTime>L)&&(L=e.systemOutTime);if(I.length>0){const e=I[I.length-1],t=Math.max(null!=T?T:-1/0,null!=L?L:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const n=I[0],o=I.find(e=>e.topMass+e.botMass>0);let r,i=1/0;null!=d&&Number.isFinite(d)&&n.t>d&&n.topMass+n.botMass>0&&(i=d,r=n),o&&null!=_&&Number.isFinite(_)&&o.t>_&&i>_&&(i=_,r=o),r&&Number.isFinite(i)&&I.unshift({t:i,topMass:r.topMass,botMass:r.botMass,...null!=r.boundaryOffset&&{boundaryOffset:r.boundaryOffset}})}let D=I;if("max"===r&&null!=d&&null!=T&&T>d){let e,t=0;for(const n of I){const o=n.topMass+n.botMass;o>t&&(t=o,e=n)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};D=[...I.filter(e=>d>e.t),{t:d,...t},{t:T,...t},...I.filter(e=>e.t>T)]}}return{samples:D,peak:k,topPeak:S,botPeak:A,localAttachments:M}}function Mk(e){const t={};return e.forEach((e,n)=>{for(const o of e.occupants)t[o.id]=n}),t}function jk(e,t,n){e.splice(0,e.length,...n);const o=Mk(n);for(const e of Object.keys(t))delete t[e];Object.assign(t,o)}function Pk(e){const t=new Map,n=[];e.forEach((e,o)=>{if(!e.group)return void n.push({anchor:o,stableId:ck(e),slots:[e]});const r=t.get(e.group)??{indexes:[],slots:[]};r.indexes.push(o),r.slots.push(e),t.set(e.group,r)});for(const[e,o]of t)n.push({anchor:o.indexes.reduce((e,t)=>e+t,0)/o.indexes.length,stableId:`${e}\0${o.slots.map(ck).join("\0")}`,slots:o.slots});return n.sort((e,t)=>e.anchor-t.anchor||ak(e.stableId,t.stableId))}function Ik(e){return e.some(e=>e.group)?Pk(e).flatMap(e=>e.slots):[...e]}function Rk(e){return e.flatMap(e=>e.slots)}function Tk(e,t,n){const o=new Map;return e.forEach((e,t)=>{for(const n of e.slots)o.set(n,t)}),e.map((e,r)=>{if(1>=e.slots.length)return e;const i=new Map;for(const t of e.slots)i.set(t,0);for(const e of t){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n)continue;const s=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===r&&n!==r){const t=n>r?1:-1;i.set(e.source,(i.get(e.source)??0)+s*t)}else if(n===r&&t!==r){const n=t>r?1:-1;i.set(e.target,(i.get(e.target)??0)+s*n)}}const s=[...e.slots].sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||n(e,t));return{...e,slots:s}})}function _k(e,t){e.some(e=>e.group)&&jk(e,t,Ik(e))}function Lk(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Dk(e,t){return function(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,s]=t(e[r]);for(let a=r+1;e.length>a;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);0>(i-c)*(s-l)&&o++}}return o}(t,t=>[e[t.source],e[t.target]],Lk)}function Nk(e,t){let n=0;for(const o of t){const t=e[o.source],r=e[o.target];null!=t&&null!=r&&(n+=Math.abs(t-r)*(o.value>0?o.value:1))}return n}function $k(e,t,n){const[o,r]=n.get(e.first),[i,s]=n.get(e.second);return 0>(t.get(o)-t.get(i))*(t.get(r)-t.get(s))?1:0}T();var Bk=e=>{let t=1;for(let n=2;e>=n;n++)t*=n;return t},Ek=828*Bk(8),Ok=3e3;function Fk(e,t,n,o,r,i,s){const a=[...r],c=new Map(r.map(e=>[e,ck(e)])),l=new Map;for(const e of r)for(const t of e.occupants)l.set(t.id,e);const u=new Map,d=[];for(const e of t){const t=l.get(e.source),n=l.get(e.target);t&&n&&(u.set(e,[t,n]),t!==n&&d.push({source:t,target:n,weight:e.value}))}const h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let n=e+1;t.length>n;n++){if(!u.has(t[n])||!Lk(t[e],t[n]))continue;const o=new Set([...u.get(t[e]),...u.get(t[n])]);h.push({index:h.length,first:t[e],second:t[n],involvedSlots:o})}const p=new Map;for(const e of r)p.set(e,[]);for(const e of h)for(const t of e.involvedSlots)p.get(t)?.push(e);const m=new Uint32Array(h.length);let y=0;const f=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),g=s.plotH/Math.max(1,r.length),b=r.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,f)*(Math.max(1,s.plotH)+g*Math.max(b,r.length)+1e-6*Math.max(1,r.length-1))+1,x=4*g,w={fullCrossing:0,localCrossing:0},k=new Map,S=(e,t)=>{let o=k.get(e);o||(o=new Map,k.set(e,o));const r=o.get(t);if(null!=r)return r;const i=function(e,t,n){return rk(uk([e,t],n)).adjacentClearance[0]??0}(e,t,n);return o.set(t,i),i},A=new Map(r.map((e,t)=>[e,t])),C=t.flatMap(e=>{const t=u.get(e);return t?[{source:A.get(t[0]),target:A.get(t[1]),weight:e.value>0?e.value:1}]:[]}),M=new Map;for(const e of t){const t=u.get(e);t&&M.set(e,{source:A.get(t[0]),target:A.get(t[1])})}const j=new Map,P=new Map;for(const e of t)j.has(e.source)||j.set(e.source,new Set),P.has(e.target)||P.set(e.target,new Set),j.get(e.source).add(e.target),P.get(e.target).add(e.source);const I=t.flatMap(e=>{if(!(e=>{const t=new Set([...j.get(e.source)??[],...P.get(e.source)??[]]),n=new Set([...j.get(e.target)??[],...P.get(e.target)??[]]);return 1===j.get(e.source)?.size&&j.get(e.source).has(e.target)||1===t.size&&t.has(e.target)||1===n.size&&n.has(e.source)})(e))return[];const t=M.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),R=e=>{let t=0;for(const n of I)t+=Math.max(0,Math.abs(e[n.source]-e[n.target])-1)*n.weight;return t*x},T=e=>{const t=new Int16Array(r.length);for(let n=0;e.length>n;n++)t[A.get(e[n])]=n;return R(t)},_=h.map(e=>{const t=M.get(e.first),n=M.get(e.second);return[t.source,t.target,n.source,n.target]}),L=new Int16Array(r.length),D=new Float64Array(r.length),N=new Float64Array(r.length+1),$=e=>{for(let t=0;e.length>t;t++)L[A.get(e[t])]=t;let t=0;for(const[e,n,o,r]of _)0>(L[e]-L[o])*(L[n]-L[r])&&t++;if(e.length>0){const t=A.get(e[0]);D[t]=s.padding+e[0].peak.topPeak*s.valueScale;for(let t=1;e.length>t;t++){const n=A.get(e[t-1]),o=A.get(e[t]);D[o]=D[n]+S(e[t-1],e[t])*s.valueScale+s.padding}const n=A.get(e[e.length-1]),o=D[n]+e[e.length-1].peak.botPeak*s.valueScale+s.padding;if(o>s.plotH&&o>0){const e=s.plotH/o;for(let t=0;D.length>t;t++)D[t]*=e}}N[0]=0;for(let t=0;e.length>t;t++)N[t+1]=N[t]+e[t].peak.topPeak+e[t].peak.botPeak;let n=0,o=0,r=0;for(const e of C){const t=L[e.source],i=L[e.target];if(n+=Math.abs(t-i)*e.weight,o+=Math.abs(D[e.source]-D[e.target])*e.weight,Math.abs(t-i)>=2){const n=Math.min(t,i)+1;r+=(N[Math.max(t,i)]-N[n])*e.weight}}return t*v+o+r*g+R(L)+1e-6*n},B=(e,n)=>{const o=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)o[t+1]=o[t]+e[t].peak.topPeak+e[t].peak.botPeak;let r=0;for(const e of t){const t=n[e.source],i=n[e.target];if(null==t||null==i||2>Math.abs(t-i))continue;const s=Math.min(t,i)+1;r+=(o[Math.max(t,i)]-o[s])*(e.value>0?e.value:1)}return r},E=o=>{const r=Mk(o),i=o.slice(0,-1).map((e,t)=>S(e,o[t+1])),a=pk(e,t,n,o,r,{plotH:s.plotH,padding:s.padding,valueScale:s.valueScale,lanePlacement:s.lanePlacement??"stack",groupPadding:s.groupPadding,adjacentClearance:i});return{map:r,geometry:a,weightedLength:Nk(r,t),pixelLength:mk(a.centerlines,t),transitOcclusion:B(o,r)}},O=(e,t,n)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*g+T(n)+1e-6*t.weightedLength}),F=(e,t)=>{let n=t;if(null==n){const t=new Map(e.map((e,t)=>[e,t]));n=h.reduce((e,n)=>e+$k(n,t,u),0),w.fullCrossing++}return O(n,E(e),e)},z=(e,r,i="quality")=>{let a=r;if(null==a){const t=new Map(e.map((e,t)=>[e,t]));a=h.reduce((e,n)=>e+$k(n,t,u),0),w.fullCrossing++}const c=E(e);return O(a,{...c,transitOcclusion:xk(t,n,e,c.map,c.geometry.centerlines,o,{valueScale:s.valueScale,ribbonLane:s.ribbonLane,domain:s.domain,mode:i})},e)};let H=[...a];const W=(e,t)=>ak(c.get(e),c.get(t)),q=function(e){const t=new Set;for(const n of e)if(n.group){if(t.has(n.group))return!0;t.add(n.group)}return!1}(H),G=e=>{const t=(e=>{const t=ik(e,d,e=>F(e).cost,{passes:6,compare:W,maxEvaluations:Ok});let n=F(t),o=Ok;for(let e=0;6>e&&o>0;e++){let r=!1;const i=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&i.reverse();for(const e of i){if(0>=o--)break;const i=t[e],s=t[e+1],a=new Map(t.map((e,t)=>[e,t]));let c=0;const l=[];y++;for(const e of[...p.get(i)??[],...p.get(s)??[]])m[e.index]!==y&&(m[e.index]=y,l.push(e),c+=$k(e,a,u));[t[e],t[e+1]]=[s,i];const d=new Map(a);d.set(i,e+1),d.set(s,e);let h=0;for(const e of l)h+=$k(e,d,u);w.localCrossing+=l.length;const f=F(t,n.crossings-c+h);n.cost>f.cost?(n=f,r=!0):[t[e],t[e+1]]=[i,s]}if(!r)break}return t})(e);if((e.length>8?1/0:Bk(e.length)*(e.length+C.length+_.length))>Ek)return t;const n=sk(e,$,{maxItems:8,maxEvaluations:5e4}),o=z(n),r=z(t);return o.crossings!==r.crossings&&r.crossings>o.crossings?n:t},Y="geometry-refine"===s.mode;if(Y||"crossing-min"!==s.laneOrder&&"crossing-min+inside-out"!==s.laneOrder){if(!Y&&"inside-out"===s.laneOrder)if(q){const e=Pk(H),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,n)=>t(n)-t(e)||ak(e.stableId,n.stableId)),o=Array(n.length);let r=Math.floor((n.length-1)/2)-1,i=Math.floor((n.length-1)/2)+1;n.length>0&&(o[Math.floor((n.length-1)/2)]=n[0]);for(let e=1;n.length>e;e++)e%2==1&&n.length>i||0>r?o[i++]=n[e]:o[r--]=n[e];H=Rk(o)}else{const e=[...H].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||W(e,t)),t=Array(e.length);let n=Math.floor((e.length-1)/2)-1,o=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let r=1;e.length>r;r++)r%2==1&&e.length>o||0>n?t[o++]=e[r]:t[n--]=e[r];H=t}}else H=q?(e=>{let t=Pk(e);if(1>=t.length)return Rk(t);const n=e=>F(Rk(e)).cost;t=Pk(G(e)),t=Tk(t,d,W);const o=function(e,t){const n=new Map;for(const t of e)for(const e of t.slots)n.set(e,t);const o=new Map;for(const e of t){const t=n.get(e.source),r=n.get(e.target);if(!t||!r||t===r)continue;const i=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,s=r.stableId>t.stableId?`${t.stableId}\0${r.stableId}`:`${r.stableId}\0${t.stableId}`,a=o.get(s);a?a.weight=(a.weight??0)+i:o.set(s,{source:t,target:r,weight:i})}return[...o.values()]}(t,d);t=ik(t,o,n,{passes:6,compare:(e,t)=>ak(e.stableId,t.stableId),maxEvaluations:Ok}),t=function(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;s>e&&a>i;e++){let e=!1;for(let n=0;o.length-1>n&&a>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,r>s?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}(t,n,{passes:8,maxEvaluations:Ok});const r=t.length>8?1/0:Bk(t.length)*(t.length+C.length+_.length);if(Ek>=r){const e=sk(t,e=>$(Rk(e)),{maxItems:8,maxEvaluations:5e4}),n=Rk(e),o=Rk(t),r=z(n),i=z(o);r.crossings!==i.crossings?t=i.crossings>r.crossings?e:t:i.cost>r.cost&&(t=e)}return t=Tk(t,d,W),Rk(t)})(H):G(H);if(!Y&&"crossing-min+inside-out"===s.laneOrder&&H.length>1)if(q){const e=Pk(H);let t=F(Rk(e)),n=Rk(e),o=t;const r=Math.floor((e.length-1)/2),i=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),s=[...e].sort((e,t)=>i(t)-i(e)||ak(e.stableId,t.stableId));for(const i of s){const s=e.indexOf(i);if(s===r)continue;e.splice(s,1),e.splice(r,0,i);const a=Rk(e),c=F(a);c.cost>t.cost?(e.splice(r,1),e.splice(s,0,i)):(t=c,o.cost>c.cost&&(n=a,o=c))}H=n}else{let e=F(H),t=[...H],n=e;const o=Math.floor((H.length-1)/2),r=[...H].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||W(e,t));for(const i of r){const r=H.indexOf(i);if(r===o)continue;H.splice(r,1),H.splice(o,0,i);const s=F(H);s.cost>e.cost?(H.splice(o,1),H.splice(r,0,i)):(e=s,n.cost>s.cost&&(t=[...H],n=s))}H=t}if((Y||"crossing-min"===s.laneOrder||"crossing-min+inside-out"===s.laneOrder)&&H.length>1)if(q){let e=Pk(H),t=z(Rk(e),void 0,"score");for(let n=0;6>n&&e.length>1;n++){let n=!1;for(let o=0;e.length-1>o;o++){[e[o],e[o+1]]=[e[o+1],e[o]];const r=Rk(e),i=z(r,void 0,"score");t.cost>i.cost?(H=r,t=i,n=!0):[e[o],e[o+1]]=[e[o+1],e[o]]}if(!n)break}e=Tk(Pk(H),d,W),H=Rk(e)}else{let e=z(H,void 0,"score");for(let t=0;H.length-1>t;t++){const n=H[t],o=H[t+1],r=new Map(H.map((e,t)=>[e,t]));let i=0;const s=[];y++;for(const e of[...p.get(n)??[],...p.get(o)??[]])m[e.index]!==y&&(m[e.index]=y,s.push(e),i+=$k(e,r,u));[H[t],H[t+1]]=[o,n];const a=new Map(r);a.set(n,t+1),a.set(o,t);let c=0;for(const e of s)c+=$k(e,a,u);w.localCrossing+=s.length;const l=z(H,e.crossings-i+c,"score");e.cost>l.cost?e=l:[H[t],H[t+1]]=[n,o]}}const V=Ik(a);H=Ik(H);let X=z(H);const U=z(V);if(Y){const e=T(V),t=T(H);(X.crossings>U.crossings||X.crossings===U.crossings&&t>e+1e-9||X.cost>U.cost)&&(H=V,X=U)}else X.cost>U.cost&&(H=V,X=U);return jk(r,i,H),{before:U,after:X,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function zk(e,t,n){const o=e.map(e=>{const o=e.occupants.map(e=>({id:e.id,end:n[e.id]?.end??e.end}));let r=0,i=0;for(const e of o){const n=t[e.id];r=Math.max(r,n?.topPeak||0),i=Math.max(i,n?.botPeak||0)}return{occupants:o,peak:{topPeak:r,botPeak:i},...null!=e.group?{group:e.group}:{}}}),r={};return o.forEach((e,t)=>{for(const n of e.occupants)r[n.id]=t}),{slots:o,slotByNode:r}}var Hk=new Map,Wk=1e-9,qk=1e5;function Gk(e,t){let n=1/0,o=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>Wk&&(n=Math.min(n,t.t),o=Math.max(o,t.t));return Number.isFinite(n)&&Number.isFinite(o)?(null!=t.start&&(n=Math.max(n,t.start)),null!=t.end&&(o=Math.min(o,t.end)),n>o?{start:null,end:null}:{start:n,end:o}):{start:null,end:null}}function Yk(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function Vk(e,t){return ak(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Xk(e){const t=new Map,n=new Map;for(const o of e)n.has(o.source)||n.set(o.source,new Set),t.has(o.target)||t.set(o.target,new Set),n.get(o.source).add(o.target),t.get(o.target).add(o.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...n].map(([e,t])=>[e,t.size]))}}function Uk(e){const t=new Map,n=new Map,o=(e,t,n,o)=>{let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,(r.get(n)??0)+o)};for(const r of e){const e=r.value>0&&Number.isFinite(r.value)?r.value:1;o(t,r.source,r.target,e),o(n,r.target,r.source,e)}const r=new Map,i=e=>{if(r.has(e))return;const o=t.get(e),i=n.get(e);if(o&&1===o.size&&(!i||0===i.size)){const[t,n]=[...o][0];return void r.set(e,{partner:t,weight:n})}const s=new Map;for(const[e,t]of o??[])s.set(e,(s.get(e)??0)+t);for(const[e,t]of i??[])s.set(e,(s.get(e)??0)+t);if(1===s.size){const[t,n]=[...s][0];r.set(e,{partner:t,weight:n})}};for(const t of e)i(t.source),i(t.target);return r}function Kk(e,t,n){const o=n.get(e),r=n.get(t);return!o||!r||o.partner===r.partner||o.partner===t||r.partner===e}function Qk(e,t,n){return!!n.has(e)&&t.some(t=>!Kk(e,t,n))}function Zk(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function Jk(e,t,n,o){if(12>=e.length||1>=o.slotCount)return o.assignment;const r=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Map),s=Xk(n);for(const e of n){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n||t===n)continue;const o=Zk(e,s);i[t].set(n,(i[t].get(n)??0)+o),i[n].set(t,(i[n].get(t)??0)+o)}const a=Uk(n),c=e.map(e=>a.get(e)?.weight??0),l=Array.from({length:e.length},()=>new Map);let u=0;for(let n=0;e.length-1>n&&5e4>u;n++)if(a.has(e[n]))for(let o=n+1;e.length>o;o++){if(!a.has(e[o]))continue;if(t.conflicts(e[n],e[o]))continue;u++;const r=Math.min(c[n],c[o])||Math.max(c[n],c[o]),i=Kk(e[n],e[o],a)?r:-r;if(Math.abs(i)>Wk&&(l[n].set(o,i),l[o].set(n,i),u>=5e4))break}const d=[...o.assignment],h=Array.from({length:o.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));const p=(e,t,n)=>{const o=d[t],r=d[n];let i=0;const s=new Set;for(const a of[t,n])for(const[c,l]of e[a]){const e=c>a?`${a}:${c}`:`${c}:${a}`;if(s.has(e))continue;s.add(e);const u=(a===t?r:o)===(c===t?r:c===n?o:d[c]);d[a]===d[c]!==u&&(i+=u?l:-l)}return i},m=(e,t,n)=>{let o=0;for(const[r,i]of e[t]){const e=n===d[r];d[t]===d[r]!==e&&(o+=e?i:-i)}return o},y=(e,t)=>e>Wk||Wk>=Math.abs(e)&&t>Wk,f=(e,t,n,o)=>e>n+Wk||Wk>=Math.abs(e-n)&&t>o+Wk;let g=0;for(let n=0;32>n&&qk>g;n++){let n=null,o=-1,r=-1,s=-1,a=-1/0,c=-1/0;for(let u=0;e.length>u;u++){for(let p=0;h.length>p&&g++<qk;p++){if(p===d[u])continue;if(!h[p].every(n=>!t.conflicts(e[u],e[n])))continue;const g=m(i,u,p),b=m(l,u,p);y(g,b)&&f(g,b,a,c)&&(n="move",o=u,r=-1,s=p,a=g,c=b)}if(g>=qk)break}for(let u=0;e.length-1>u;u++){for(let m=u+1;e.length>m&&g++<qk;m++){const g=d[u],b=d[m];if(g===b)continue;if(!h[b].every(n=>n===m||!t.conflicts(e[u],e[n])))continue;if(!h[g].every(n=>n===u||!t.conflicts(e[m],e[n])))continue;const v=p(i,u,m),x=p(l,u,m);y(v,x)&&f(v,x,a,c)&&(n="swap",o=u,r=m,s=-1,a=v,c=x)}if(g>=qk)break}if(null==n||-1===o)break;if("move"===n){const e=d[o];h[e].splice(h[e].indexOf(o),1),h[s].push(o),d[o]=s;continue}const u=d[o],b=d[r];h[u].splice(h[u].indexOf(o),1,r),h[b].splice(h[b].indexOf(r),1,o),d[o]=b,d[r]=u}return d}function eS(e,t,n,o){const r=function(e,t,n,o){return`${e.map(e=>{const t=n[e.id],r=o[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,r?.start??"",r?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,n,o),i=Hk.get(r);if(i)return zk(i.slots,n,o);const s={};for(const t of e)s[t.id]=Gk(n[t.id],o[t.id]);const a=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,n)=>t[e.id].start-t[n.id].start||t[e.id].end-t[n.id].end||ak(e.id,n.id)).map(e=>e.id)}(e,s),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=function(e,t,n,o,r){const i=new Set,s=new Map(e.map(e=>[e,new Set])),a=new Map(e.map(e=>[e,new Set]));for(const e of o)i.add(Vk(e.source,e.target)),s.get(e.target)?.add(e.source),a.get(e.source)?.add(e.target);const c=new Map,l=new Set,u=(e,t)=>{for(let n=0;e.length>n;n++)for(let o=n+1;e.length>o;o++){const r=Vk(e[n],e[o]);t instanceof Map?t.set(r,[e[n],e[o]]):t.add(r)}};for(const e of a.values())u([...e],c);for(const e of s.values())u([...e],l);const d=new Set;for(const[e,[o,r]]of c)l.has(e)&&(Yk(t[o],t[r])||Yk(n[o],n[r])&&(d.add(o),d.add(r)));return{conflicts:(e,n)=>{const o=r.get(e),s=r.get(n);return null!=o&&null!=s&&o!==s||null!=o!=(null!=s)&&!i.has(Vk(e,n))||!!Yk(t[e],t[n])||!(!d.has(e)&&!d.has(n))&&!i.has(Vk(e,n))}}}(a,s,o,t,l),d=function(e,t,n=new Map){const o=[],r=[];for(const i of e){let e=o.findIndex(e=>e.every(e=>!t.conflicts(i,e))&&!Qk(i,e,n));-1!==e||n.has(i)||(e=o.findIndex(e=>e.every(e=>!t.conflicts(i,e)))),-1===e&&(e=o.length,o.push([])),o[e].push(i),r.push(e)}return{assignment:r,slotCount:o.length}}(a,u,Uk(t)),h=function(e,t,n,o){if(0===e.length||e.length>12||1>=o.slotCount)return o.assignment;const r=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Float64Array(e.length)),s=Array.from({length:e.length},()=>new Map),a=Array.from({length:e.length},()=>new Map),c=Xk(n);for(const e of n){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n||t===n)continue;const o=Zk(e,c);i[t][n]+=o,i[n][t]+=o,a[t].set(n,(a[t].get(n)??0)+o),s[n].set(t,(s[n].get(t)??0)+o)}const l=Uk(n),u=e.map(e=>l.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let n=t+1;e.length>n;n++){for(const[e,o]of s[t])d[t][n]+=Math.min(o,s[n].get(e)??0);for(const[e,o]of a[t])d[t][n]+=Math.min(o,a[n].get(e)??0);if(l.has(e[t])&&l.has(e[n])){const o=Math.min(u[t],u[n])||Math.max(u[t],u[n]);d[t][n]+=Kk(e[t],e[n],l)?o:-o}d[n][t]=d[t][n]}let h=[...o.assignment],p=(t=>{let n=0,o=0;for(let r=0;e.length>r;r++)for(let s=r+1;e.length>s;s++)t[r]===t[s]&&(n+=i[r][s],o+=d[r][s]);return{flow:n,affinity:o}})(h),m=0;const y=Array(e.length).fill(-1),f=Array.from({length:o.slotCount},()=>[]),g=(n,r,s,a)=>{if(m>=75e3)return;if(n===e.length)return m++,void((s>p.flow||s===p.flow&&a>p.affinity||s===p.flow&&a===p.affinity&&function(e,t){for(let n=0;Math.min(e.length,t.length)>n;n++)if(e[n]!==t[n])return t[n]>e[n];return t.length>e.length}(y,h))&&(h=[...y],p={flow:s,affinity:a}));const c=Math.min(r+1,o.slotCount-1);for(let o=0;c>=o;o++){if(f[o].some(o=>t.conflicts(e[n],e[o])))continue;let c=0,l=0;for(const e of f[o])c+=i[n][e],l+=d[n][e];if(y[n]=o,f[o].push(n),g(n+1,Math.max(r,o),s+c,a+l),f[o].pop(),y[n]=-1,m>=75e3)return}};return y[0]=0,f[0].push(0),g(1,0,0,0),h}(a,u,t,{...d,assignment:Jk(a,u,t,d)}),p=new Map,m=h.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),y=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),f={};a.forEach((e,t)=>{const n=m[t],o=y[n];o.occupants.push({id:e,end:s[e].end??-1/0});const r=c.get(e)?.group;r&&(o.group=r),f[e]=n});for(const t of[...e].sort((e,t)=>ak(e.id,t.id)))null==f[t.id]&&(y[0].occupants.push({id:t.id,end:-1/0}),f[t.id]=0);for(const e of y){e.occupants.sort((e,t)=>(s[e.id].start??1/0)-(s[t.id].start??1/0)||ak(e.id,t.id));for(const t of e.occupants){const o=n[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,o?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,o?.botPeak||0)}}const g={slots:y,slotByNode:f};return function(e,t){for(Hk.has(e)&&Hk.delete(e),Hk.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:{...t.slotByNode}});Hk.size>12;){const e=Hk.keys().next().value;if(null==e)break;Hk.delete(e)}}(r,g),g}function tS(e){return e.topMass+e.botMass}function nS(e,t){const n=e.samples.filter(e=>e.t===t);if(n.length>0)return n.reduce((e,t)=>tS(t)<tS(e)?e:t,n[0]);let o=null;for(const n of e.samples){if(n.t>t)break;o=n}return o}function oS(e,t,n,o,r,i,s=0){const a=new Map;for(const n of e){if(!n.group||!t[n.id])continue;const e=a.get(n.group)??[];e.push(n),a.set(n.group,e)}if(0===a.size||0>=i)return t;const c=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,l]of a){const a=n.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===a.length)continue;const u=a[0].slot,d=a.at(-1).slot,h=r[u.occupants[0]?.id],p=r[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(p))continue;const m=(h-u.peak.topPeak*i+(p+d.peak.botPeak*i))/2,y=[...new Set(l.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),f=new Map;for(const e of l)f.set(e.id,new Map);for(const e of y){const n=new Map;for(const r of l){const i=nS(t[r.id],e);if(!i||1e-9>=tS(i))continue;const s=o[r.id];if(null==s)continue;const a=n.get(s)??[];a.push({node:r,sample:i}),n.set(s,a)}const a=[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>tS(e)))}));if(0===a.length)continue;let c=m-(a.reduce((e,t)=>e+t.mass,0)*i+Math.max(0,s)*Math.max(0,a.length-1))/2;for(const t of a){for(const{node:n,sample:o}of t.active){const t=(c-r[n.id])/i+o.topMass-(o.boundaryOffset??0);f.get(n.id).set(e,t)}c+=t.mass*i+Math.max(0,s)}}for(const e of l){const n=t[e.id],o=c[e.id],r=f.get(e.id),i=[];for(const e of y){const t=r.get(e),o=n.samples.filter(t=>t.t===e);if(o.length>0){i.push(...o.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}})));continue}const s=nS(n,e);null!=t&&s&&tS(s)>1e-9&&i.push({...s,t:e,boundaryOffset:(s.boundaryOffset??0)+t})}o.samples=i,o.localAttachments=new Map([...n.localAttachments].map(([e,t])=>{const n=r.get(t.time);return[e,{...t,...null!=n?{boundaryOffset:(t.boundaryOffset??0)+n}:{}}]}))}}return c}function rS(e,t,n,o,r){const{plotH:i,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:p="both",domain:m}=r,y={},f={};for(const t of e)y[t.id]=n[t.id].topPeak||0,f[t.id]=n[t.id].botPeak||0;const g="half"===u,b={};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=g?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=g?(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)}b[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}let v={},x=[],w=[];if(r.frozenSlots){const e=zk(r.frozenSlots,n,b);x=e.slots,v=e.slotByNode,w=x.map(ck)}else if("reuse"===c){const o=eS(e,t,n,b);x=o.slots,v=o.slotByNode}else e.forEach((e,t)=>{x.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:f[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});_k(x,v),0===w.length&&(w=x.map(ck));let k=null;r.frozenSlots||(r.fixedSlotOrder?function(e,t,n){const o=new Map(n.map((e,t)=>[e,t]));jk(e,t,[...e].sort((e,t)=>(o.get(ck(e))??1/0)-(o.get(ck(t))??1/0)||ak(ck(e),ck(t))))}(x,v,r.fixedSlotOrder):r.runOrdering&&l&&"insertion"!==l&&(k=Fk(e,t,n,b,x,v,{plotH:i,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:m}))),_k(x,v);const S=pk(e,t,n,x,v,{plotH:i,padding:s,valueScale:a,stackValueScale:r.stackValueScale,lanePlacement:d,groupPadding:h}),A=0===x.length?0:x[0].peak.topPeak+S.adjacentClearance.reduce((e,t)=>e+t,0)+x[x.length-1].peak.botPeak,C=k?.before.crossings??null,M=k?.after.crossings??null,j=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:A,centerlines:S.centerlines,laneLifetime:b,slots:x,slotByNode:v,slotCenter:S.slotCenter,stackCenter:S.stackCenter,verticalUtilization:S.verticalUtilization,selectedSlotOrder:x.map(ck),initialSlotOrder:w,ordering:k,crossingsBefore:C,crossingsAfter:M,lengthBefore:j,lengthAfter:P}}function iS(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function sS(e,t,n,o="horizontal"){return"vertical"===o?{top:e?38:t?28:16,right:24,bottom:24,left:n?72:24}:{top:e?30:t?24:8,right:80,bottom:n?28:8,left:80}}var aS=require("react/jsx-runtime"),cS="var(--semiotic-grid, #94a3b8)",lS="var(--semiotic-text-secondary, #475569)",uS="var(--semiotic-text-secondary, #94a3b8)",dS=require("react"),hS=require("d3-scale"),pS=require("d3-scale");function mS(e,t,n,o,r,i,s,a,c={}){const l=r,u=e=>a?Math.max(a[0],Math.min(a[1],e)):e;let d=i(u(e.time));const h=i(u(n.time)),p=e.value*l,m=n.value*l,y=t+(e.boundaryOffset??0)*l,f=o+(n.boundaryOffset??0)*l,g=e.sideMassBefore*l,b=n.sideMassAfter*l;let v,x,w,k;"top"===e.side?(v=y-g,x=v+p):(x=y+g,v=x-p),"top"===n.side?(w=f-b,k=w+m):(k=f+b,w=k-m);const S=c.sourceRunwayStart,A=c.minRun,C=Math.abs((w+k)/2-(v+x)/2),M=h-d,j="number"==typeof S&&Number.isFinite(S),P="number"==typeof A&&Number.isFinite(A)&&A>0;if(j&&C>1e-9&&M>0&&("auto"===A||P)){const t="source"===s?.85:"target"===s?.15:.5,n="auto"===A?Math.min(144,Math.sqrt(8*C/(1.5*Math.min(t*t,(1-t)*(1-t))))):A;if(n>M){const t=i(u(Math.min(S,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),h-n)))}}const I="source"===s?d+.85*(h-d):"target"===s?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:v,sBot:x,tx:h,tTop:w,tBot:k,cp1X:I,cp2X:I}}function yS(e){return Math.max(18,11*e.length*.58)}function fS(e){const t=1.22*yS(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function gS(e,t){const n=e.labelX-yS(e.labelText),o=t.labelX-yS(t.labelText);return t.labelX+3>=n&&e.labelX+3>=o}var bS=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function vS(e){return e.replace(bS,(e,t,n)=>`${n},${t}`)}function xS(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function wS(e){return{...e,pathD:vS(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function kS(e){const{nodes:t,edges:n,domain:o,plotW:r,plotH:i,ribbonLane:s,ribbonMinRun:a=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:p,maxLabels:m,selectionDatum:y="raw",styleRules:f,colorBy:g,valueAccessor:b,usageMode:v="static"}=e,x="vertical"===d?i:r,w="vertical"===d?r:i,k=function(e,t,n,o={}){const r=Zw(o.usageMode??"static"),i=[],s=new Set;for(const t of e)s.has(t.id)&&i.push({kind:"duplicate-node",id:t.id,severity:r.duplicateIds}),s.add(t.id);const a=new Set,c=Array.isArray(n)&&2===n.length,l=c&&Number.isFinite(n[0])&&Number.isFinite(n[1]);c&&l&&l&&n[1]>=n[0]||i.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]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)a.has(e.id)&&i.push({kind:"duplicate-edge",id:e.id,severity:r.duplicateIds}),a.add(e.id),s.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),s.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&i.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&i.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,n,o,{usageMode:v}),{fatal:S,warnings:A}=function(e){const t=[],n=[];for(const o of e)"fatal"===ek(o)?t.push(o):n.push(o);return{fatal:t,warnings:n}}(k),C=function(e,t,n="static"){if("strip"!==Zw(n).invalidSystemTime)return e;const o=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===o.size?e:e.map(e=>{if(!o.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}(n,k,v),M=(0,pS.scaleTime)().domain(o).range([0,x]);if(S.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:S,warnings:A,xScale:M};const j=function(e,t,n){const{plotH:o,pairing:r="temporal",packing:i="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:p}=n,m=Number.isFinite(d)?Math.max(0,d):0,y=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),f=function(e,t,n,o="temporal"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime||ak(e.id,t.id):(e,t)=>t.value-e.value||ak(e.id,t.id),i="temporal"===o?(e,t)=>e.startTime-t.startTime||ak(e.id,t.id):(e,t)=>t.value-e.value||ak(e.id,t.id),s=new Map;for(const e of t)s.set(e.id,{});const a=(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 s=[...n.values()];s.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart||ak(e.partner,n.partner):e.latestEnd-n.latestEnd||ak(e.partner,n.partner):(e,t)=>t.total-e.total||ak(e.partner,t.partner));for(const e of s)e.edges.sort("target"===t?i:r);return s};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(o,"source"),n=a(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)s.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=o}}}return s}(e,t,y,r);let g={};for(const t of e)g[t.id]=Ck(t,y,f,void 0,u);const b=rS(e,t,g,y,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a,runOrdering:!0,lanePlacement:"stack",groupPadding:m,ribbonLane:h,domain:p}),v=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),x=new Set;for(const e of t){const t=b.slotByNode[e.source],n=b.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=f.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(x.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=y.outgoing[t.id],n=y.incoming[t.id],o=new Set(e.map(e=>f.get(e.id).sourceSide)),r=new Set(n.map(e=>f.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)b.slotByNode[t.source]===b.slotByNode[t.target]&&(f.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)b.slotByNode[n.source]===b.slotByNode[n.target]&&(f.get(n.id).sourceSide=t)}}!function(e,t,n){const o=new Map,r=[];for(const t of e)r.push({time:t.startTime,kind:"out",edge:t}),r.push({time:t.endTime,kind:"in",edge:t});r.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||ak(e.edge.id,t.edge.id));const i=e=>{let t=o.get(e);return t||(t={top:0,bot:0},o.set(e,t)),t},s=(e,t,n)=>{const o="top"===t?"bot":"top",r=Math.min(n,e[t]);e[t]-=r;const i=n-r;i>0&&(e[o]=Math.max(0,e[o]-i))};for(const e of r){const{edge:o}=e;if("in"===e.kind){const e=t.get(o.id)?.targetSide??"bot";i(o.target)[e]+=o.value;continue}const r=i(o.source),a=t.get(o.id);let c=a.sourceSide??"bot";if(n[o.source]===n[o.target]){const e=r.top>=o.value,t=r.bot>=o.value;e!==t?c=e?"top":"bot":e||t||r.top===r.bot||(c=r.top>r.bot?"top":"bot"),a.sourceSide=c,a.targetSide=c}s(r,c,o.value)}}(t,f,b.slotByNode),function(e,t,n,o){for(const r of e){const e=t.incoming[r.id],i=t.outgoing[r.id];if(0===e.length||0===i.length)continue;const s=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===n.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of i)"top"===n.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},a=(e,t)=>{const r=s(),a="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,c="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=a||0>=c)return!1;const l=Math.min(a,c),u=i.filter(t=>!o.has(t.id)&&n.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value||ak(e.id,t.id));return 0!==u.length&&(n.get(u[0].id).sourceSide=t,!0)};let c=i.length+1;for(;c-- >0&&(a("top","bot")||a("bot","top")););}}(e,y,f,x),g={};for(const t of e)g[t.id]=Ck(t,y,f,void 0,u);const w=rS(e,t,g,y,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:v,lanePlacement:"stack",groupPadding:m,ribbonLane:h,domain:p}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),S=w.slots.slice(0,-1).reduce((e,t,n)=>e+(null!=t.group&&t.group===w.slots[n+1].group?1:0),0),A=Math.max(1,w.slots.length+1-S),C=Math.min(12,Math.max(0,.35*o-S*m)/A),M=2*C+lk(w.slots,C,m).reduce((e,t)=>e+t,0),j=k>0?Math.max(0,(o-M)/k):1,P=Number.isFinite(c)&&c>0?Math.min(j,c):j;let I=rS(e,t,g,y,{plotH:o,padding:C,valueScale:P,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:v,lanePlacement:l,groupPadding:m,ribbonLane:h,domain:p,stackValueScale:j});const R=Number.isFinite(c)&&c>0&&j>c+1e-12;if("insertion"!==s&&("hug"===l||R)&&I.slots.length>1&&(Fk(e,t,g,I.laneLifetime,I.slots,I.slotByNode,{plotH:o,padding:C,valueScale:P,groupPadding:m,laneOrder:s,ribbonLane:h,domain:p,lanePlacement:l,mode:"geometry-refine"}),I=rS(e,t,g,y,{plotH:o,padding:C,valueScale:P,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:I.slots,fixedSlotOrder:I.slots.map(ck),lanePlacement:l,groupPadding:m,ribbonLane:h,domain:p,stackValueScale:j})),function(e,t){const n=(e,n)=>{for(const o of e){const e=new Map;for(const r of o){const o=`${("out"===n?t.get(r.id)?.sourceSide:t.get(r.id)?.targetSide)??""}\0${"out"===n?r.startTime:r.endTime}`,i="out"===n?`${r.target}\0${r.endTime}`:`${r.source}\0${r.startTime}`,s=e.get(o);if(null!=s&&s!==i)return!0;e.set(o,i)}}return!1};return n(Object.values(e.outgoing),"out")||n(Object.values(e.incoming),"in")}(y,f)){const n=function(e,t,n,o){const r=new Map;for(const i of e){const e=t[i.source]?.localAttachments.get(i.id),s=t[i.target]?.localAttachments.get(i.id),a=n[i.source],c=n[i.target];if(!(e&&s&&Number.isFinite(a)&&Number.isFinite(c)))continue;const l=Ak(e,a,o),u=Ak(s,c,o);r.set(i.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return r}(t,g,I.centerlines,P);g={};for(const t of e)g[t.id]=Ck(t,y,f,n,u);I=rS(e,t,g,y,{plotH:o,padding:C,valueScale:P,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:I.slots,fixedSlotOrder:I.slots.map(ck),lanePlacement:l,groupPadding:m,ribbonLane:h,domain:p,stackValueScale:j})}const T=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),_=[...I.slots].sort((e,t)=>(T.get(ck(e))??1/0)-(T.get(ck(t))??1/0)||ak(ck(e),ck(t))),L={};_.forEach((e,t)=>{for(const n of e.occupants)L[n.id]=t});const D=pk(e,t,g,_,L,{plotH:o,padding:C,valueScale:P,stackValueScale:j,lanePlacement:"stack",groupPadding:m}),N=oS(e,g,_,L,D.centerlines,P,m),$=wk(Dk(L,t),Nk(L,t),t,N,_,L,D.centerlines,I.laneLifetime,P,D.verticalUtilization,h,p);g=oS(e,g,I.slots,I.slotByNode,I.centerlines,P,m);const B=wk(Dk(I.slotByNode,t),Nk(I.slotByNode,t),t,g,I.slots,I.slotByNode,I.centerlines,I.laneLifetime,P,I.verticalUtilization,h,p);return{nodeData:g,sides:f,valueScale:P,padding:C,compressedPadding:12>C,centerlines:I.centerlines,laneLifetime:I.laneLifetime,slots:I.slots,slotByNode:I.slotByNode,crossingsBefore:"insertion"===s?null:$.crossings,crossingsAfter:"insertion"===s?null:B.crossings,lengthBefore:"insertion"===s?null:$.weightedLength,lengthAfter:"insertion"===s?null:B.weightedLength,layoutQualityBefore:$,layoutQuality:B}}(t,C,{plotH:w,...u,ribbonLane:s,domain:o}),{centerlines:P,nodeData:I,valueScale:R}=j,T=Zp(g,b),_=[],L=[],D=0===a?new Map:function(e,t,n){const o=new Set(t.map(e=>e.target)),r=new Map(e.map(e=>[e.id,e])),i=new Map;for(const e of t){if(o.has(e.source))continue;const t=i.get(e.source)??[];t.push(e),i.set(e.source,t)}const s=new Map;for(const t of e){if(!t.group)continue;const e=s.get(t.group)??[];e.push(t),s.set(t.group,e)}const a=new Set;for(const[e,t]of s){const n=t.flatMap(e=>i.get(e.id)??[]),r=new Set(n.map(e=>e.startTime));n.length>0&&1===r.size&&t.every(e=>{const t=e.xExtent?.[0],r=n[0].startTime;return!o.has(e.id)&&(i.get(e.id)?.length??0)>0&&Number.isFinite(t)&&r>t})&&a.add(e)}const c=new Map;for(const[e,t]of i){const o=r.get(e);if(o?.group&&!a.has(o.group))continue;const i=o?.xExtent?.[0],s=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),l=s[0]?.startTime-1;let u=null;for(let e=0;s.length>e;){const t=s[e].startTime;let o=e+1;for(;s.length>o&&s[o].startTime===t;)o++;for(let t=e;o>t;t++){const e=s[t],o=Number.isFinite(i)&&e.startTime>i,r=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!o&&!r)continue;let a=n[0];o&&(a=Math.max(a,i)),r&&(a=Math.max(a,e.systemInTime)),!o&&r&&Number.isFinite(l)&&(a=Math.max(a,l)),null!=u&&(a=Math.max(a,u)),e.startTime>a&&c.set(e.id,a)}u=t,e=o}}for(const[e,t]of s){if(!a.has(e))continue;const n=t.flatMap(e=>i.get(e.id)??[]);if(!n.every(e=>c.has(e.id))){for(const e of n)c.delete(e.id);continue}const o=Math.max(...n.map(e=>c.get(e.id)));for(const e of n)c.set(e.id,o)}return c}(t,C,o),N=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),$=new Map;for(const e of C){const t=I[e.source]?.localAttachments.get(e.id),n=I[e.target]?.localAttachments.get(e.id);t&&n&&$.set(e.id,mS(t,P[e.source],n,P[e.target],R,M,s,o,{minRun:a,sourceRunwayStart:D.get(e.id)}))}const B=function(e,t,n,o,r,i){const s=new Map(t),a=new Map;for(const t of e){const e=i?.get(t.source),n=null==e?"node:"+t.source:"group:"+e,o=a.get(n)??new Map,r=o.get(t.startTime)??[];r.push(t),o.set(t.startTime,r),a.set(n,o)}for(const e of a.values())for(const[i,a]of e){if(!a.some(e=>n.has(e.id)))continue;const e=a.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const c=o(i),l=Math.min(...e.map(e=>e.sx));if(l>=c-1e-9)continue;const u=Math.max(...a.map(e=>{const t=n.get(e.id);return null==t?c:Math.min(c,o(t))})),d=Math.min(c,Math.max(l,u));for(const e of a){const n=t.get(e.id),o=d+(n.tx-d)*("source"===r?.85:"target"===r?.15:.5);s.set(e.id,{...n,sx:d,cp1X:o,cp2X:o})}}return s}(C,$,D,M,s,N),E=function(e,t,n,o,r){const i=new Map;for(const s of e){if(!n.has(s.id))continue;const e=t.get(s.id);if(!e||e.sx>=o(s.startTime)-1e-9)continue;const a=r(e.sx);Number.isFinite(a)&&s.startTime>a&&i.set(s.id,a)}return i}(C,B,D,M,e=>o[0]+e/x*(o[1]-o[0])),O=function(e,t,n){const o=new Map,r=new Map;for(const[e,t]of n??[]){const n=r.get(t)??[];n.push(e),r.set(t,n)}for(const i of e){const e=t.get(i.id);if(null==e||!Number.isFinite(e)||e>=i.startTime)continue;const s=n?.get(i.source),a=null==s?[i.source]:r.get(s)??[i.source];for(const t of a){const n=o.get(t)??new Map,r=n.get(i.startTime);n.set(i.startTime,null==r?e:Math.min(r,e)),o.set(t,n)}}return o}(C,E,N);t.forEach((e,t)=>{const n=I[e.id];if(!n||0===n.samples.length)return;const r=(i=n.samples,(s=O.get(e.id))&&0!==s.size?i.map(e=>{const t=s.get(e.t);return null==t?e:{...e,t:t}}):i);var i,s;const a=function(e,t,n,o,r){if(0===e.length)return null;const i=Sk(e,r),s=e=>t+(i[e].boundaryOffset??0)*n,a=e=>s(e)-i[e].topMass*n,c=e=>s(e)+i[e].botMass*n;let l=`M${o(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${o(i[e].t)},${a(e)}`;l+=` L${o(i[i.length-1].t)},${c(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${o(i[e].t)},${c(e)}`;return l+" Z"}(r,P[e.id],R,M,o);if(!a)return;const c=Sk(r,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],h=P[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*R/2;let p,m,y=l(e.id,t),g=y,b=.5;const v=e.__raw??e;if(f&&f.length>0){const e=tm(v,f,T(v));"string"==typeof e.fill?y=e.fill:null!=e.fill&&ei(e.fill)&&(m=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(g=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(p=e.fillOpacity),"number"==typeof e.opacity&&null==p&&(p=e.opacity)}const x=function(e,t,n,o,r,i){const s=n.nodeData[e];if(!s||0===s.samples.length)return[];const a=n.valueScale,c=n.centerlines[e],l=Sk(s.samples,r),u=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],h=o(u.t),p=o(d.t),m=e=>o(kk(e,r)),y=[],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=s.localAttachments.get(n.id),t=i?.get(n.id)??n.startTime;if(e&&"out"===e.kind&&t>n.systemInTime){const o=m(n.systemInTime),i=m(t),s=null!=r&&r[0]>n.systemInTime,l=s?o:o-20,u=s?Math.min(i,o+20):o,d=Math.max(h,l);if(i>d){const[t,n]=Ak(e,c,a);y.push({pathD:f(d,t,i,n),x0:l,x1:u,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=s.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=m(n.systemOutTime),o=m(n.endTime),r=t+20,i=Math.min(p,r);if(i>o){const[n,s]=Ak(e,c,a);y.push({pathD:f(o,n,i,s),x0:t,x1:r,from:1,to:0})}}}}return y}(e.id,C,j,M,o,E);_.push({id:e.id,pathD:a,fill:y,stroke:g,strokeWidth:b,...null!=p&&{fillOpacity:p},...m&&{hatchFill:m},...x.length>0&&{gradientStubs:x},rawDatum:v,labelX:M("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});const F=new Map;t.forEach((e,t)=>F.set(e.id,t)),C.forEach(e=>{const t=B.get(e.id);if(!t)return;const n=F.get(e.source)??0,o=l(e.source,n),{pathD:r,bezier:i}=Gv(t),s=e.__raw??e,a="function"==typeof c?Number(c(s)):c,u=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.35;L.push({id:e.id,pathD:r,fill:o,opacity:u,rawDatum:s,bezier:i})});const z=function(e,t,n){const o=e.map(e=>({...e})),r=new Map;for(const e of o){const n=t[e.id];if(null==n)continue;const o=r.get(n)??[];o.push(e),r.set(n,o)}const i=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,o=(e.length-1)/2;e.forEach((e,r)=>{e.labelY=Math.max(8,Math.min(n-8,t+16*(r-o)))})};for(const e of r.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],n=-1/0;for(const o of e){const e=o.labelX-yS(o.labelText);t.length>0&&e>n+3&&(i(t),t=[],n=-1/0),t.push(o),n=Math.max(n,o.labelX)}i(t)}return function(e,t){const n=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;n.length>e;e+=1){let t=8;for(let o=0;e>o;o+=1)gS(n[e],n[o])&&(t=Math.max(t,n[o].labelY+16));n[e].labelY=Math.max(n[e].labelY,t)}for(let e=n.length-1;e>=0;e-=1){let o=t-8;for(let t=e+1;n.length>t;t+=1)gS(n[e],n[t])&&(o=Math.min(o,n[t].labelY-16));n[e].labelY=Math.min(n[e].labelY,o)}}}(o,n),o}(_,j.slotByNode,w).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:vS(e.pathD),gradientStubs:e.gradientStubs?.map(wS),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),H="vertical"===d?function(e,t,n){const o=e.map(e=>({...e}));for(const e of o){const n=1.22*yS(e.labelText)+4;e.labelX=t-4>n?Math.max(n/2+2,Math.min(t-n/2-2,e.labelX)):t/2}const r=[],i=[...o].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of i){const t=r[r.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?r.push([e]):t.push(e)}for(const e of r){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],o=new Map;for(const n of e){const[e,r]=fS(n);let i=t.findIndex(t=>e>t+8);-1===i&&(i=t.length),t[i]=r,o.set(n,i)}const r=e.reduce((e,t)=>e+t.labelY,0)/e.length,i=14*t.length+8>r;for(const t of e){const e=o.get(t)??0;t.labelY=i?Math.min(n-8,12+14*e):Math.max(8,r-14*e)}}return o}(z,r,i):z,W=new Map;if(null!=p)for(const e of t){const t=e.__raw??e,n="function"==typeof p?p(t):Number(t[p]);Number.isFinite(n)&&W.set(e.id,n)}const q=function(e,t,n,o,r={}){if(!1===o)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===o)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let i=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*n)/14e3)));Number.isFinite(r.maxLabels)&&r.maxLabels>=0&&(i=Math.min(i,Math.floor(r.maxLabels)));const s=e.map((e,t)=>{const n=r.priorityById?.get(e.id),o=Math.abs(e.labelY);return{band:e,index:t,score:null!=n&&Number.isFinite(n)?1e6*n+yS(e.labelText):yS(e.labelText)+.01*o}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),a=new Set(s.slice(0,i).map(e=>e.band.id));return e.map(e=>a.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(H,r,i,h,{...W.size>0&&{priorityById:W},...null!=m&&{maxLabels:m}});return{layout:j,layoutConfig:{bands:q,ribbons:L.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:vS(e.pathD),bezier:xS(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:A,xScale:M}}var SS=require("d3-scale"),AS={};function CS(e,t,n,o="reuse",r="crossing-min",i=5e4){return"sync"!==e&&("worker"===e||function(e,t,n="reuse",o="crossing-min"){return e*e*("reuse"===n?80:1)+t*t*(o&&"insertion"!==o?40:1)+10*(e+t)}(t,n,o,r)>=i)}function MS(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function jS(e){if(!e)return null;const t=e.sides,n=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:n}}var PS=class{constructor(e=function(){const e="string"==typeof AS.url&&AS.url?new URL("./processSankeyLayoutWorker.js",AS.url):nw("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new sw({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:o}=iw(t);return o?{requestId:n,ok:!1,error:rw(o)}:{requestId:n,ok:!0,payload:{layout:jS(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},IS=aw(()=>new PS);function RS(e){if(function(e){if(!e||0===e.length)return!1;for(const t of e){if("function"==typeof t.when)return!0;if("function"==typeof t.style)return!0}return!1}(e.styleRules))return!0;if("function"==typeof e.edgeOpacity)return!0;if("function"==typeof e.labelPriorityAccessor)return!0;if(e.styleRules&&e.styleRules.length>0){if("function"==typeof e.colorBy)return!0;if("function"==typeof e.valueAccessor)return!0}return!1}function TS(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function _S(e){const t=TS(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function LS(e){const t=TS(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}var DS=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:(0,hS.scaleTime)().domain(e).range([0,t])});function NS(e,t){const n=Uc(),{execution:o="auto",workerThreshold:r,colorById:i,fallbackPalette:s,rawNodeById:a,rawEdgeById:c}=t,l=(0,dS.useMemo)(()=>Object.keys(i).sort().map(e=>`${e}:${i[e]}`).join("|"),[i]),u=(0,dS.useMemo)(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,l]:"null",[e,l]),d=!!e&&!n&&function(e,t,n){return"undefined"!=typeof window&&!!MS()&&!RS(e)&&CS(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",n)}(e,o,r),h=(0,dS.useMemo)(()=>e?d?null:kS(e):DS([0,1],1),[u,d,e]),p=(0,dS.useRef)(n),[m,y]=(0,dS.useState)(()=>e?n?{...kS(e),status:"ready",error:null}:d?{...DS(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...kS(e),status:"ready",error:null}:{...DS([0,1],1),status:"ready",error:null});return(0,dS.useEffect)(()=>{if(p.current)return void(p.current=!1);if(!e||!d)return;const t=new AbortController;return y(e=>({...e,status:"pending",error:null})),async function(e,t){const{execution:n="auto",workerThreshold:o,signal:r,colorById:i,fallbackPalette:s=["#475569"],rawNodeById:a=new Map,rawEdgeById:c=new Map}=t,l=e.layoutOpts.packing??"reuse",u=e.layoutOpts.laneOrder??"crossing-min";if(!MS()||RS(e)||!CS(n,e.nodes.length,e.edges.length,l,u,o))return kS(e);try{const t=await function(e,t){return MS()?IS.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,n){return{input:{nodes:e.nodes.map(_S),edges:e.edges.map(LS),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:n}}(e,i,s),r);return function(e,t,n){const o=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),r=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:n.get(e.id)??{id:e.id}})),i=(0,SS.scaleTime)().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:o,ribbons:r,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:i}}(t,a,c)}catch(t){if("AbortError"===t?.name)throw t;return kS(e)}}(e,{execution:o,workerThreshold:r,signal:t.signal,colorById:i,fallbackPalette:s,rawNodeById:a,rawEdgeById:c}).then(e=>{y({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&y(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[u,d,o,r,s,a,c]),h?{...h,status:"ready",error:null}:m}var $S=require("react");function BS(e,t){return"function"==typeof e?e(t):t[e]}var ES=require("react"),OS=.22;function FS(e,t,n){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,n))}var zS=e=>{const{bands:t=[],ribbons:n=[],showLabels:o=!0,selectionDatum:r="raw"}=e.config,i=e.selection??null,s=[];for(const e of n){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},n=!FS(t,i,r);s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:n?Math.min(e.opacity,OS):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!FS({__kind:"band",data:e.rawDatum,id:e.id},i,r);for(let n=0;e.gradientStubs.length>n;n++){const o=e.gradientStubs[n];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?OS:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,...null!=o.y0&&{y0:o.y0},...null!=o.y1&&{y1:o.y1},from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${n}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),n={__kind:"band",data:e.rawDatum,id:e.id},o=!FS(n,i,r);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:o?OS:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...o&&t?{opacity:OS}:{}},datum:n})}const a=o?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),n=e.labelText.trim().length>0,o=t&&i?.isActive&&FS({__kind:"band",data:e.rawDatum,id:e.id},i,r),s=n?e.labelText:o?e.labelFullText:"";return s.trim()?[{x:e.labelX,y:e.labelY,text:s,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"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:s,labels:a}};function HS(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var WS=require("react/jsx-runtime");var qS=require("react/jsx-runtime"),GS=(0,Kw.forwardRef)(function(e,t){const{nodes:n,edges:o,domain:r,axisTicks:i=[],nodeIdAccessor:s="id",nodeLabel:a,sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",startTimeAccessor:d="startTime",endTimeAccessor:h="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:m,xExtentAccessor:y="xExtent",groupBy:f,edgeIdAccessor:g="id",colorBy:b,colorScheme:v,showLegend:x,legendPosition:w="right",orientation:k="horizontal",pairing:S="temporal",packing:A="reuse",laneOrder:C="crossing-min",maxValueScale:M,lanePlacement:j="stack",nodeSizing:P="temporal",groupPadding:I=0,ribbonLane:R="both",ribbonMinRun:T=0,lifetimeMode:_="half",showLaneRails:L=!1,showQualityReadout:D=!1,showLabels:N=!0,labelPriorityAccessor:$,maxLabels:B,selectionDatum:E="raw",styleRules:O,layoutExecution:F="auto",layoutWorkerThreshold:z,layoutLoadingContent:H,onLayoutStateChange:W,width:q=600,height:G=400,margin:Y,title:V,description:X,summary:U,accessibleTable:K,responsiveWidth:Q,responsiveHeight:Z,loading:J,loadingContent:ee,emptyContent:te,edgeOpacity:ne=.35,timeFormat:oe,valueFormat:re,tooltip:ie,enableHover:se=!0,onObservation:ae,onClick:ce,selection:le,linkedHover:ue,showParticles:de=!1,particleStyle:he,chartId:pe,frameProps:me={}}=e,ye=(0,Kw.useRef)(null),fe=(0,Kw.useRef)(null),{rawNodes:ge,rawEdges:be,frameRef:ve,getNodeId:xe,getEdgeId:we}=function(e){const{ref:t,rawNodesProp:n,rawEdgesProp:o,nodeIdAccessor:r,edgeIdAccessor:i,sourceAccessor:s,targetAccessor:a,scalesRef:c,layoutSnapshotRef:l}=e,[u,d]=(0,$S.useState)([]),[h,p]=(0,$S.useState)([]),m=(0,$S.useRef)(u),y=(0,$S.useRef)(h);m.current=u,y.current=h;const f=(0,$S.useCallback)(e=>{m.current=e,d(e)},[]),g=(0,$S.useCallback)(e=>{y.current=e,p(e)},[]),b=void 0!==o,v=ft(b?o:u),x=(0,$S.useMemo)(()=>{const e=ft(n??[]),t=h;if(0===e.length&&0===t.length)return Ew([],v,s,a);const o=new Set,i=[];for(const t of e){const e=BS(r,t)+"";o.has(e)||(o.add(e),i.push(t))}for(const e of t){const t=BS(r,e)+"";o.has(t)||(o.add(t),i.push(e))}const c=Ew([],v,s,a);for(const e of c)o.has(e.id)||(o.add(e.id),i.push(e));return i},[n,h,v,r,s,a]),w=(0,$S.useRef)(null),k=(0,$S.useCallback)((e,t)=>{const n=BS(i,e);return null!=n?n+"":`${BS(s,e)}-${BS(a,e)}-${t}`},[i,s,a]),S=(0,$S.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=BS(s,t)&&null!=BS(a,t)},[s,a]),A=(0,$S.useCallback)(e=>BS(r,e)+"",[r]);return im(t,{variant:"network",frameRef:w,overrides:{push(e){if(S(e)){if(b)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");f([...m.current,e])}else g([...y.current,e])},pushMany(e){const t=[],n=[];for(const o of e)S(o)?t.push(o):n.push(o);t.length>0&&(b?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):f([...m.current,...t])),n.length>0&&g([...y.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!b){const e=m.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(k(i,r))?n.push(i):o.push(i)}o.length!==e.length&&f(o)}const o=y.current,i=[];for(const e of o){const o=BS(r,e)+"";t.has(o)?n.push(e):i.push(e)}return i.length!==o.length&&g(i),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!b){let e=!1;const r=m.current.map((r,i)=>n.has(k(r,i))?(o.push(r),e=!0,t(r)):r);e&&f(r)}let i=!1;const s=y.current.map(e=>{const s=BS(r,e)+"";return n.has(s)?(o.push(e),i=!0,t(e)):e});return i&&g(s),o},clear(){b||f([]),g([]),w.current?.clear()},getData:()=>v??[],getScales:()=>c.current,getCustomLayout:()=>l.current}}),{rawNodes:x,rawEdges:v,frameRef:w,getNodeId:A,getEdgeId:k,isControlled:b}}({ref:t,rawNodesProp:n,rawEdgesProp:o,nodeIdAccessor:s,edgeIdAccessor:g,sourceAccessor:c,targetAccessor:l,scalesRef:ye,layoutSnapshotRef:fe}),{nodes:ke,edges:Se,domain:Ae,rawNodeById:Ce,rawEdgeById:Me}=(0,Kw.useMemo)(()=>{const e=(ge??[]).map(e=>{const t=xe(e),n=a?BS(a,e):t,o={id:t,label:null==n?t:n+"",__raw:e},r=f?BS(f,e):null;null!=r&&r+""!=""&&(o.group=r+"");const i=y?BS(y,e):null;if(Array.isArray(i)&&2===i.length){const e=iS(i[0]),t=iS(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),t=(be??[]).map((e,t)=>{const n={id:we(e,t),source:BS(c,e)+"",target:BS(l,e)+"",value:Number(BS(u,e)),startTime:iS(BS(d,e)),endTime:iS(BS(h,e)),__raw:e};if(p){const t=iS(BS(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(m){const t=iS(BS(m,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[iS(r[0]),iS(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}},[ge,be,r,xe,we,a,y,f,c,l,u,d,h,p,m]),je=zw({nodes:ge,edges:be,inferNodes:!1,nodeIdAccessor:s,sourceAccessor:c,targetAccessor:l,colorBy:b,colorScheme:v,showLegend:!1,legendPosition:w,selection:le,linkedHover:ue,onObservation:ae,onClick:ce?(e,t)=>{HS(e)?ce(e.data,t):ce(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:pe,marginDefaults:sS(!!V,D,i.length>0,k),userMargin:Y,width:q,height:G,hasTitle:!!V,loading:J,loadingContent:ee,emptyContent:te}),Pe=(x??!!b)&&!!b,Ie=(0,Kw.useCallback)(e=>null!=Y&&("number"==typeof Y||null!=Y[e]),[Y]),Re=(0,Kw.useMemo)(()=>{const e={...je.margin};return Pe&&("right"===w&&!Ie("right")&&140>e.right?e.right=140:"bottom"===w&&!Ie("bottom")&&80>e.bottom&&(e.bottom=80)),e},[je.margin,Pe,w,Ie]),Te=q-Re.left-Re.right,_e=G-Re.top-Re.bottom,Le="vertical"===k?_e:Te,De=(0,Kw.useCallback)((e,t)=>{if(b&&ge){const t=Ce.get(e);if(t)return Pn(t,b,je.colorScale)}return je.effectivePalette[t%je.effectivePalette.length]||"#475569"},[b,ge,Ce,je.colorScale,je.effectivePalette]),Ne=NS((0,Kw.useMemo)(()=>Te>0&&_e>0?{nodes:ke,edges:Se,domain:Ae,plotW:Te,plotH:_e,orientation:k,ribbonLane:R,ribbonMinRun:T,edgeOpacity:"function"==typeof ne?e=>ne(e):ne,colorOf:De,showLabels:N,labelPriorityAccessor:$,maxLabels:B,selectionDatum:E,styleRules:O,usageMode:"push",colorBy:b,valueAccessor:u,layoutOpts:{pairing:S,packing:A,laneOrder:C,lifetimeMode:_,maxValueScale:M,lanePlacement:j,nodeSizing:P,groupPadding:I}}:null,[ke,Se,Ae,Te,_e,k,R,T,ne,De,N,$,B,E,O,b,u,S,A,C,_,M,j,P,I]),{execution:F,workerThreshold:z,colorById:(0,Kw.useMemo)(()=>{const e={};return ke.forEach((t,n)=>{e[t.id]=De(t.id,n)}),e},[ke,De]),fallbackPalette:je.effectivePalette,rawNodeById:Ce,rawEdgeById:Me}),{issues:$e,warnings:Be,layout:Ee,xScale:Oe}=Ne,Fe=Ne.layoutConfig,ze=Ne.status;ye.current=Ee?{time:Oe,centerlines:Ee.centerlines}:{time:Oe},fe.current=Ee?{layout:Ee,nodes:ke,edges:Se,bands:Fe.bands,ribbons:Fe.ribbons,warnings:Be,status:ze}:null;const He=(0,Kw.useRef)(W);He.current=W,(0,Kw.useEffect)(()=>{He.current?.(ze)},[ze]),(0,Kw.useEffect)(()=>{0!==Be.length&&console.warn("ProcessSankey warnings:",Be.map(tk).join("; "))},[Be]);const We=(0,Kw.useMemo)(()=>{if(!Pe||!b)return;const e=new Map;(ge??[]).forEach((t,n)=>{const o=BS(b,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:De(xe(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},[Pe,b,ge,De,xe]),qe=function(e){const{tooltip:t,enableHover:n,layout:o,timeFormat:r,valueFormat:i,sourceAccessor:s,targetAccessor:a,valueAccessor:c,startTimeAccessor:l,endTimeAccessor:u}=e,d=(0,ES.useMemo)(()=>!1!==t&&n?void 0===t||!0===t?null:cu(t)||null:null,[t,n]),h=(0,ES.useCallback)(e=>r?r(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[r]),p=(0,ES.useCallback)(e=>i?i(e):e+"",[i]);return(0,ES.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!HS(t))return null;const n=t.data;if(d)return d(n);if("band"===t.__kind){const e=t.id,n=o?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}(o.nodeData[e]):[],r=5,i=n.length>r?n.length:null,s=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,s=[];for(const e of r)i.has(e.t)||(i.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(n,r);return(0,WS.jsxs)("div",{style:{minWidth:160},children:[(0,WS.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),s.length>0&&(0,WS.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,WS.jsx)("thead",{children:(0,WS.jsxs)("tr",{style:{opacity:.6},children:[(0,WS.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,WS.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&(0,WS.jsx)("th",{})]})}),(0,WS.jsx)("tbody",{children:s.map((e,t)=>(0,WS.jsxs)("tr",{children:[(0,WS.jsx)("td",{style:{paddingRight:8},children:h(e.t)}),(0,WS.jsx)("td",{style:{textAlign:"right"},children:p(e.total)}),null!=i&&(0,WS.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&(0,WS.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",s.length," of ",i," samples"]})]})}const r=n,i=BS(s,r),m=BS(a,r),y=BS(c,r),f=BS(l,r),g=BS(u,r);return(0,WS.jsxs)("div",{style:{minWidth:160},children:[(0,WS.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",m+""]}),(0,WS.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=y&&(0,WS.jsxs)(WS.Fragment,{children:[(0,WS.jsx)("span",{style:{opacity:.6},children:"value"}),(0,WS.jsx)("span",{style:{textAlign:"right"},children:p(Number(y))})]}),null!=f&&(0,WS.jsxs)(WS.Fragment,{children:[(0,WS.jsx)("span",{style:{opacity:.6},children:"start"}),(0,WS.jsx)("span",{style:{textAlign:"right"},children:h(iS(f))})]}),null!=g&&(0,WS.jsxs)(WS.Fragment,{children:[(0,WS.jsx)("span",{style:{opacity:.6},children:"end"}),(0,WS.jsx)("span",{style:{textAlign:"right"},children:h(iS(g))})]})]})]})},[o,d,h,p,s,a,c,l,u])}({tooltip:ie,enableHover:se,layout:Ee,timeFormat:oe,valueFormat:re,sourceAccessor:c,targetAccessor:l,valueAccessor:u,startTimeAccessor:d,endTimeAccessor:h}),Ge=(0,Kw.useMemo)(()=>{if(!Ee)return null;const e=Be.map(e=>tk(e));return function(e){const t=e.layout,n=e.nodes,o=e.orientation,r=e.plotW,i=e.plotH,s=e.timelineExtent,a=e.axisTicks,c=e.showQualityReadout??!1,l=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,p=e.toTime,m=e.xScale,{centerlines:y,laneLifetime:f,nodeData:g,valueScale:b,compressedPadding:v,crossingsBefore:x,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:S}=t;let A=null,C=null;for(const e of n){const t=f[e.id];if(!t||null===t.start||null===t.end)continue;const n=m(t.start),o=m(t.end);(null===A||A>n)&&(A=n),(null===C||o>C)&&(C=o)}const M=e=>Math.max(0,Math.min(s,e)),j=M(A??0),P=Math.max(j,M(C??s)),I=a.map((e,t)=>({tick:e,index:t,coordinate:m(p(e.date))})).filter(({coordinate:e})=>e>=j-.5&&P+.5>=e),R=null!==(w??null)&&null!=k&&null!=S,T=c&&(R||u.length>0)?(0,aS.jsxs)("g",{fill:uS,fontSize:10,textAnchor:"end",children:[R&&(0,aS.jsxs)(aS.Fragment,{children:[(0,aS.jsxs)("text",{x:r,y:-14,children:["crossings: ",x," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(S.pixelLength)]}),(0,aS.jsxs)("text",{x:r,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",S.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*S.verticalUtilization),"%"]})]}),u.map((e,t)=>(0,aS.jsxs)("text",{x:r,y:R?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,_=v?(0,aS.jsx)("text",{x:r,y:"vertical"===o?-3:2,fontSize:10,fill:uS,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,L=(e,t)=>h?h(e,t):cS;return(0,aS.jsxs)("g","vertical"===o?{children:[T,_,I.map(({index:e,coordinate:t})=>(0,aS.jsx)("line",{x1:0,y1:t,x2:r,y2:t,stroke:cS,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),l&&n.map((e,t)=>{const n=f[e.id];if(!n||null===n.start)return null;const o=g[e.id],r=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},i=y[e.id]+(r.botPeak-r.topPeak)*b/2,s=m(n.start),a=m(n.end),c=L(e.id,t);return(0,aS.jsxs)("g",{children:[(0,aS.jsx)("line",{x1:i,y1:s,x2:i,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,aS.jsx)("line",{x1:i-4,y1:s,x2:i+4,y2:s,stroke:c,strokeOpacity:.5}),(0,aS.jsx)("line",{x1:i-4,y1:a,x2:i+4,y2:a,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),(0,aS.jsx)("line",{x1:-4,y1:j,x2:-4,y2:P,stroke:cS}),I.map(({tick:e,index:t,coordinate:n})=>{const o=p(e.date),r=null!=e.label?e.label:d?d(new Date(o)):"";return(0,aS.jsxs)("g",{transform:`translate(-4,${n})`,children:[(0,aS.jsx)("line",{x2:-6,stroke:cS}),(0,aS.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:lS,children:r})]},t)})]}:{children:[T,_,I.map(({index:e,coordinate:t})=>(0,aS.jsx)("line",{x1:t,y1:0,x2:t,y2:i,stroke:cS,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),l&&n.map((e,t)=>{const n=f[e.id];if(!n||null===n.start)return null;const o=g[e.id],r=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},i=y[e.id]+(r.botPeak-r.topPeak)*b/2,s=m(n.start),a=m(n.end),c=L(e.id,t);return(0,aS.jsxs)("g",{children:[(0,aS.jsx)("line",{x1:s,y1:i,x2:a,y2:i,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,aS.jsx)("line",{x1:s,y1:i-4,x2:s,y2:i+4,stroke:c,strokeOpacity:.5}),(0,aS.jsx)("line",{x1:a,y1:i-4,x2:a,y2:i+4,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),(0,aS.jsx)("line",{x1:j,y1:i+4,x2:P,y2:i+4,stroke:cS}),I.map(({tick:e,index:t,coordinate:n})=>{const o=p(e.date),r=null!=e.label?e.label:d?d(new Date(o)):"";return(0,aS.jsxs)("g",{transform:`translate(${n},${i+4})`,children:[(0,aS.jsx)("line",{y2:6,stroke:cS}),(0,aS.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:lS,children:r})]},t)})]})}({layout:Ee,nodes:ke,orientation:k,plotW:Te,plotH:_e,timelineExtent:Le,axisTicks:i,showQualityReadout:D,showLaneRails:L,warnings:e,timeFormat:oe?e=>oe(e):void 0,colorOf:De,toTime:iS,xScale:e=>Number(Oe(e))})},[Ee,ke,k,Te,_e,Le,i,D,L,Be,oe,De,Oe]),Ye=(0,Kw.useMemo)(()=>(ge??[]).map(e=>({id:xe(e),data:e})),[ge,xe]),Ve=(0,Kw.useMemo)(()=>{const e=new Map;for(const t of Fe.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Fe]),Xe=(0,Kw.useMemo)(()=>(be??[]).map((e,t)=>{const n=we(e,t),o=Number(BS(u,e));return{id:n,source:BS(c,e)+"",target:BS(l,e)+"",value:Number.isFinite(o)?o:0,bezier:Ve.get(n),data:e}}),[be,we,c,l,u,Ve]);return $e.length>0?(0,qS.jsxs)("svg",{width:q,height:G,role:"img","aria-label":V??"Process Sankey validation failed",children:[(0,qS.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),$e.map((e,t)=>(0,qS.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+tk(e)},t))]}):je.loadingEl?je.loadingEl:je.emptyEl?je.emptyEl:(0,qS.jsxs)("div",{style:{position:"relative",width:q,height:G},children:["pending"===ze&&!1!==H&&!Ee&&(0,qS.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Dp(!0,q,G,H)}),(0,qS.jsx)(Nw,{ref:ve,chartType:"force",nodes:Ye,edges:Xe,customNetworkLayout:zS,layoutConfig:Fe,size:[q,G],responsiveWidth:Q,responsiveHeight:Z,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Re,title:V,description:X??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:U,accessibleTable:K,enableHover:se,tooltipContent:!1===ie?()=>null:qe,backgroundGraphics:Ge,showParticles:de,particleStyle:he,legend:We,legendPosition:w,...am({linkedHover:ue,selection:le,onObservation:ae,onClick:ce,mobileInteraction:je.mobileInteraction,customHoverBehavior:je.customHoverBehavior,customClickBehavior:je.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:pe,colorScheme:Array.isArray(v)?v:void 0,layoutSelection:je.activeSelectionHook,...me})]})});GS.displayName="ProcessSankey";var YS=require("react"),VS=require("react/jsx-runtime");function XS(e){const t=kp(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:s="vertical",childrenAccessor:a="children",valueAccessor:c="value",nodeIdAccessor:l="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:p="curve",nodeLabel:m,nodeSize:y=5,tooltip:f,frameProps:g={},onObservation:b,onClick:v,chartId:x,selection:w,linkedHover:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:j,opacity:P}=e,{width:I,height:R,enableHover:T,showLabels:_=!0,title:L,description:D,summary:N,accessibleTable:$}=t,B=zw({nodes:(0,YS.useMemo)(()=>Bw(n??null,a),[n,a]),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:I,height:R,hasTitle:!!L,loading:S,loadingContent:A}),E=(0,YS.useMemo)(()=>new Map,[]),O=(0,YS.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Mn[(e.depth||0)%Mn.length]:u?Pn(e.data||e,u,B.colorScale):gp(void 0,B.themeCategorical,d,void 0,E),t},[u,h,B.colorScale,B.themeCategorical,d,E]),F=(0,YS.useMemo)(()=>Up(O,{stroke:M,strokeWidth:j,opacity:P}),[O,M,j,P]),z=(0,YS.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=(0,YS.useMemo)(()=>Up(z,{stroke:M,strokeWidth:j,opacity:P}),[z,M,j,P]),W=(0,YS.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return Ow(c)},[i,c]),q=Hp({componentName:"TreeDiagram",data:n});return q?(0,VS.jsx)(Ap,{componentName:"TreeDiagram",message:q,width:I,height:R}):B.loadingEl?B.loadingEl:(0,VS.jsx)(Rp,{componentName:"TreeDiagram",width:I,height:R,children:(0,VS.jsx)(Nw,{chartType:i,...null!=n&&{data:n},size:[I,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:B.margin,nodeIDAccessor:l,childrenAccessor:a,hierarchySum:W,treeOrientation:s,edgeType:p,nodeStyle:F,edgeStyle:H,colorBy:u,colorScheme:B.effectivePalette,colorByDepth:h,nodeSize:y,nodeLabel:_?m||l:void 0,showLabels:_,enableHover:T,tooltipContent:!1===f?()=>null:cu(f)||void 0,...am({linkedHover:k,selection:w,onObservation:b,onClick:v,mobileInteraction:B.mobileInteraction,customHoverBehavior:B.customHoverBehavior,customClickBehavior:B.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&"none"!==C&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},className:r,title:L,description:D,summary:N,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...g})})}XS.displayName="TreeDiagram";var US=require("react"),KS=require("react/jsx-runtime");function QS(e){const t=kp(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:s="value",nodeIdAccessor:a="name",colorBy:c,colorScheme:l,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:p=4,paddingTop:m,nodeStyle:y,tooltip:f,frameProps:g={},selection:b,linkedHover:v,onObservation:x,onClick:w,chartId:k,loading:S,loadingContent:A,legendInteraction:C,stroke:M,strokeWidth:j,opacity:P}=e,{nodeStyle:I,...R}=g,{width:T,height:_,enableHover:L,showLabels:D=!0,title:N,description:$,summary:B,accessibleTable:E}=t,O=zw({nodes:(0,US.useMemo)(()=>Bw(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:_,hasTitle:!!N,loading:S,loadingContent:A}),F=Yp(b),z=O.customHoverBehavior,H=(0,US.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),W=(0,US.useMemo)(()=>new Map,[]),q=(0,US.useMemo)(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Mn[(e.depth||0)%Mn.length]:c?Pn(e.data||e,c,O.colorScale):gp(void 0,O.themeCategorical,l,void 0,W),t},[c,u,O.colorScale,O.themeCategorical,l,W]),G=(0,US.useMemo)(()=>y||I?e=>({...q(e),...I?I(e)??{}:{},...y?y(e)??{}:{}}):q,[q,y,I]),Y=(0,US.useMemo)(()=>Up(G,{stroke:M,strokeWidth:j,opacity:P}),[G,M,j,P]),V=(0,US.useMemo)(()=>O.activeSelectionHook?e=>{const t={...Y(e)};if(O.activeSelectionHook.isActive)if(O.activeSelectionHook.predicate(e.data||e))F?.selectedStyle&&Object.assign(t,F.selectedStyle);else{const e=F?.unselectedOpacity??lh;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,F?.unselectedStyle&&Object.assign(t,F.unselectedStyle)}return t}:Y,[Y,O.activeSelectionHook,F]),X=(0,US.useMemo)(()=>Ow(s),[s]),U=void 0!==m?m:!D||"parent"!==d&&"all"!==d?void 0:18,K=Hp({componentName:"Treemap",data:n});return K?(0,KS.jsx)(Ap,{componentName:"Treemap",message:K,width:T,height:_}):O.loadingEl?O.loadingEl:(0,KS.jsx)(Rp,{componentName:"Treemap",width:T,height:_,children:(0,KS.jsx)(Nw,{chartType:"treemap",...null!=n&&{data:n},size:[T,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:O.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:X,padding:p,paddingTop:U,nodeStyle:V,colorBy:c,colorScheme:O.effectivePalette,colorByDepth:u,nodeLabel:D?h||a:void 0,showLabels:D,labelMode:d,enableHover:L,tooltipContent:!1===f?()=>null:cu(f)||void 0,...am({linkedHover:v,selection:b,onObservation:x,onClick:w,mobileInteraction:O.mobileInteraction,customHoverBehavior:H,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...C&&"none"!==C&&{legendHoverBehavior:O.legendState.onLegendHover,legendClickBehavior:O.legendState.onLegendClick,legendHighlightedCategory:O.legendState.highlightedCategory,legendIsolatedCategories:O.legendState.isolatedCategories},className:r,title:N,description:$,summary:B,accessibleTable:E,...null!=e.animate&&{animate:e.animate},...R})})}QS.displayName="Treemap";var ZS=require("react"),JS=require("react/jsx-runtime");function eA(e){const t=kp(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:s="value",nodeIdAccessor:a="name",colorBy:c,colorScheme:l,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:p=4,tooltip:m,frameProps:y={},onObservation:f,onClick:g,chartId:b,selection:v,linkedHover:x,loading:w,loadingContent:k,legendInteraction:S,stroke:A,strokeWidth:C,opacity:M}=e,{width:j,height:P,enableHover:I,showLabels:R=!0,title:T,description:_,summary:L,accessibleTable:D}=t,N=zw({nodes:(0,ZS.useMemo)(()=>Bw(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:f,onClick:g,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:o,width:j,height:P,hasTitle:!!T,loading:w,loadingContent:k}),$=(0,ZS.useMemo)(()=>new Map,[]),B=(0,ZS.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Mn[(e.depth||0)%Mn.length]:c?Pn(e.data||e,c,N.colorScale):gp(void 0,N.themeCategorical,l,void 0,$),t},[c,u,N.colorScale,h,N.themeCategorical,l,$]),E=(0,ZS.useMemo)(()=>Up(B,{stroke:A,strokeWidth:C,opacity:M}),[B,A,C,M]),O=(0,ZS.useMemo)(()=>Ow(s),[s]),F=Hp({componentName:"CirclePack",data:n});return F?(0,JS.jsx)(Ap,{componentName:"CirclePack",message:F,width:j,height:P}):N.loadingEl?N.loadingEl:(0,JS.jsx)(Rp,{componentName:"CirclePack",width:j,height:P,children:(0,JS.jsx)(Nw,{chartType:"circlepack",...null!=n&&{data:n},size:[j,P],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:N.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:O,padding:p,nodeStyle:E,colorBy:c,colorScheme:N.effectivePalette,colorByDepth:u,nodeLabel:R?d||a:void 0,showLabels:R,enableHover:I,tooltipContent:!1===m?()=>null:cu(m)||void 0,...am({linkedHover:x,selection:v,onObservation:f,onClick:g,mobileInteraction:N.mobileInteraction,customHoverBehavior:N.customHoverBehavior,customClickBehavior:N.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:N.legendState.onLegendHover,legendClickBehavior:N.legendState.onLegendClick,legendHighlightedCategory:N.legendState.highlightedCategory,legendIsolatedCategories:N.legendState.isolatedCategories},className:r,title:T,description:_,summary:L,accessibleTable:D,...null!=e.animate&&{animate:e.animate},...y})})}eA.displayName="CirclePack";var tA=require("react"),nA=require("react/jsx-runtime"),oA=Mn;function rA(e){const t=kp(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:s="name",colorBy:a,colorScheme:c,colorByDepth:l=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:p,revolutionStyle:m,eccentricity:y=1,showRings:f=!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:j,linkedHover:P,loading:I,loadingContent:R,stroke:T,strokeWidth:_,opacity:L}=e,{width:D,height:N,enableHover:$,title:B,description:E,summary:O,accessibleTable:F}=t,z=zw({nodes:(0,tA.useMemo)(()=>Bw(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:l?void 0:a,colorScheme:c,showLegend:!1,legendInteraction:void 0,selection:j,linkedHover:P,onObservation:A,onClick:C,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:M,marginDefaults:Wh(t),userMargin:o,width:D,height:N,hasTitle:!!B,loading:I,loadingContent:R}),H=(0,tA.useMemo)(()=>new Map,[]),{colorScale:W,customClickBehavior:q,customHoverBehavior:G,themeCategorical:Y}=z,V=(0,tA.useMemo)(()=>{if(Array.isArray(c))return c;const e=wn[c];return Array.isArray(e)?e:kn},[c]),X=(0,tA.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=l?n?V[0]:oA[(e.depth||0)%oA.length]:a?Pn(e.data||e,a,W):gp(void 0,Y,c,void 0,H),t.opacity=n?1:.85,t},[a,l,W,V,Y,c,H]),U=(0,tA.useMemo)(()=>Up(X,{stroke:T,strokeWidth:_,opacity:L}),[X,T,_,L]),K=(0,tA.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=(0,tA.useMemo)(()=>e=>{G(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[G]),Z=(0,tA.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=Hp({componentName:"OrbitDiagram",data:n});return J?(0,nA.jsx)(Ap,{componentName:"OrbitDiagram",message:J,width:D,height:N}):z.loadingEl?z.loadingEl:(0,nA.jsx)(Rp,{componentName:"OrbitDiagram",width:D,height:N,children:(0,nA.jsx)(Nw,{chartType:"orbit",...null!=n&&{data:n},size:[D,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:z.margin,nodeIDAccessor:s,childrenAccessor:i,nodeStyle:U,edgeStyle:K,colorBy:a,colorScheme:z.effectivePalette,colorByDepth:l,nodeSize:g,nodeLabel:b?s:void 0,showLabels:b,enableHover:!v&&$,tooltipContent:v?void 0:!1===x?()=>null:cu(x)||void 0,...am({linkedHover:P,selection:j,onObservation:A,onClick:C,mobileInteraction:z.mobileInteraction,customHoverBehavior:Q,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:w,annotations:k,className:r,title:B,description:E,summary:O,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:p,orbitRevolutionStyle:m,orbitEccentricity:y,orbitShowRings:f,orbitAnimated:v,accessibleTable:F,...null!=e.animate&&{animate:e.animate},...S})})}rA.displayName="OrbitDiagram";var iA=require("react"),sA=require("react/jsx-runtime"),aA={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"},cA={opacity:.7,marginRight:4};function lA(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function uA(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function dA(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const i=e?.data??null,s=lA(i,t,"time"),a=lA(i,n,"value");return(0,sA.jsxs)("div",{className:"semiotic-tooltip",style:aA,children:[(0,sA.jsxs)("div",{children:[(0,sA.jsxs)("span",{style:cA,children:[o,":"]}),uA(s)]}),(0,sA.jsxs)("div",{children:[(0,sA.jsxs)("span",{style:cA,children:[r,":"]}),uA(a)]})]})}}function hA(e,t){return null!=e?e:Math.max(t?.length??0,200)}var pA=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}},mA=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 pA,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new pA;o.push(t);let r=e,i=e;const s=[],a={start:r,end:i,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>i&&(i=t.end));a.start=r,a.end=i,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}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 yA(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 fA={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},gA=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function bA(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;gA.lastIndex=0;let n,o=0,r=0;for(;null!==(n=gA.exec(t));){const e=parseFloat(n[1]),t=fA[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 vA="time",xA="value",wA="__aggLower",kA="__aggUpper",SA="__aggPartial",AA="count",CA="__aggStart",MA="__aggEnd";function jA(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[vA]:(e.start+e.end)/2,[xA]:yA(e,n),[AA]:e.count,[SA]:e.partial,[CA]:e.start,[MA]:e.end},i=function(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=yA(e,n),i=e.stddev*o;return[r-i,r+i]}(e,o,n,r);return i&&(t[wA]=i[0],t[kA]=i[1]),t})}var PA=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}},IA=require("react/jsx-runtime");function RA(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 TA=(0,iA.forwardRef)(function(e,t){const n=kp(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:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,stroke:y="#007bff",strokeWidth:f=2,strokeDasharray:g,opacity:b,background:v,tooltipContent:x,tooltip:w,onHover:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:P,pulse:I,staleness:R,transition:T,linkedHover:_,selection:L,onObservation:D,chartId:N,loading:$,loadingContent:B,emptyContent:E,emphasis:O,legendPosition:F,aggregate:z,eventTime:H}=e,W=n.showAxes,q=n.enableHover,G=r??n.marginDefaults,Y=o??[n.width,n.height],V=x??w??dA({timeAccessor:u,valueAccessor:d}),X=(0,iA.useRef)(null),{customHoverBehavior:U}=xp({selection:L,linkedHover:_,unwrapData:!0,onObservation:D,chartType:"RealtimeLineChart",chartId:N}),K=(0,iA.useCallback)(e=>{k&&k(e),U(e)},[k,U]),Q=null!=z,[Z,J]=(0,iA.useState)([]),ee=(0,iA.useRef)(null),te=(0,iA.useRef)(z);te.current=z;const ne=(0,iA.useRef)(Q);ne.current=Q;const oe=(0,iA.useRef)(Z);oe.current=Z;const re=(0,iA.useRef)({timeAccessor:u,valueAccessor:d});re.current={timeAccessor:u,valueAccessor:d},(0,iA.useEffect)(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=bA("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?bA(e.hop):void 0,r=null!=e.gap?bA(e.gap):void 0;return new mA({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=RA(o,e,"time"),i=RA(o,n,"value");null!=r&&null!=i&&t.push(r,i)}}J(t?jA(t,e):[])},[Q?[z.window??"tumbling",z.size,z.hop??"",z.gap??"",z.retain??""].join("|"):"",Q,l]),(0,iA.useEffect)(()=>{Q&&ee.current&&J(jA(ee.current,te.current))},[z?.stat,z?.band,z?.sigma]);const ie=(0,iA.useCallback)(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=RA(n,o,"time"),i=RA(n,r,"value");null!=e&&null!=i&&t.push(e,i)}J(jA(t,n))},[]),se=null!=H,ae=(0,iA.useRef)(null),ce=(0,iA.useRef)(H);ce.current=H;const le=(0,iA.useRef)(se);le.current=se;const ue=(0,iA.useRef)(D);ue.current=D;const de=(0,iA.useRef)(N);de.current=N,(0,iA.useEffect)(()=>{ae.current=se?function(e){const t=bA(e.lateness);return null==t?null:new PA({lateness:t,getTime:e=>RA(e,re.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${H.lateness}|${H.latePolicy??"drop"}`:"",se]);const he=(0,iA.useCallback)(e=>{0!==e.length&&(ne.current?ie(e):X.current?.pushMany(e))},[ie]),pe=(0,iA.useCallback)(e=>{const t=ae.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:RA(i,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:de.current})}}}he(n)},[he]);(0,iA.useImperativeHandle)(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:()=>{ae.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=Dp($,Y[0],Y[1],B),ye=me?null:Lp(Q?void 0:l,Y[0],Y[1],E),fe={stroke:y,strokeWidth:f,strokeDasharray:g};null!=b&&(fe.opacity=b);const ge=hA(c,l),be=Q?Z:l,ve=Q?vA:u,xe=Q?xA:d,we=Q&&z&&"none"!==(z.band??"none")?{y0Accessor:wA,y1Accessor:kA,perSeries:!1}:void 0;return me||ye||(0,IA.jsx)(th,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:G,className:O?`${i||""} semiotic-emphasis-${O}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,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:fe,showAxes:W,background:v,hoverAnnotation:q,tooltipContent:V,...am({linkedHover:_,selection:L,onObservation:D,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:P,pulse:I,staleness:R,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});TA.displayName="RealtimeLineChart";var _A=require("react");function LA(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 DA=require("react/jsx-runtime"),NA=(0,_A.forwardRef)(function(e,t){const n=kp(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,showLegend:e.showLegend,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:s,arrowOfTime:a="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:d,valueAccessor:h,direction:p="up",timeExtent:m,valueExtent:y,extentPadding:f,categoryAccessor:g,colors:b,fill:v,stroke:x,strokeWidth:w,opacity:k,gap:S,background:A,tooltipContent:C,tooltip:M,onHover:j,annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,linkedHover:L,selection:D,decay:N,pulse:$,staleness:B,transition:E,onObservation:O,chartId:F,loading:z,loadingContent:H,emptyContent:W,emphasis:q,legendPosition:G,legend:Y,brush:V,onBrush:X,linkedBrush:U}=e,K=n.showAxes,Q=n.enableHover,Z=r??[n.width,n.height],J=(0,_A.useMemo)(()=>b?e=>b[e]??v??"#999":void 0,[b,v]),{legend:ee,margin:te,legendPosition:ne}=pp({data:u??[],colorBy:g,colorScale:J,showLegend:n.showLegend,legendPosition:G,userMargin:i,defaults:n.marginDefaults,additionalLegend:Y,chartWidth:Z[0],axisChrome:{hasAxis:!1!==n.showAxes}}),oe=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=lA(o,t,"time"),r=lA(o,n,"value");return(0,sA.jsxs)("div",{className:"semiotic-tooltip",style:aA,children:[(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"x:"}),uA(e)]}),(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"y:"}),uA(r)]})]})}return(0,sA.jsxs)("div",{className:"semiotic-tooltip",style:aA,children:[(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"range:"}),uA(o.binStart),"–",uA(o.binEnd)]}),null!=o.total&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"count:"}),uA(o.total)]}),null!=o.category&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"category:"}),uA(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),re=(0,_A.useRef)(null),{customHoverBehavior:ie}=xp({selection:D,linkedHover:L,unwrapData:!0,onObservation:O,chartType:"RealtimeHistogram",chartId:F}),se=(0,_A.useCallback)(e=>{j&&j(e),ie(e)},[j,ie]),ae=!0===V?{dimension:"x",snap:"bin"}:"x"===V?{dimension:"x"}:"object"==typeof V?V:void 0,ce=ch(U),le="string"==typeof d?d:"time",ue=kh({name:ce?.name||"__unused_hist_brush__",xField:ce?.xField||le,...ce?.yField?{yField:ce.yField}:{}}),de=(0,_A.useRef)(ue.brushInteraction);de.current=ue.brushInteraction;const he=(0,_A.useCallback)(e=>{if(X&&X(e),O&&O(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}),ce){const t=de.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)}},[X,O,F,ce]);(0,_A.useImperativeHandle)(t,()=>({push:e=>re.current?.push(e),pushMany:e=>re.current?.pushMany(e),remove:e=>re.current?.remove(e)??[],update:(e,t)=>re.current?.update(e,t)??[],clear:()=>re.current?.clear(),getData:()=>re.current?.getData()??[],getScales:()=>re.current?.getScales()??null}),[]);const pe=Dp(z,Z[0],Z[1],H),me=pe?null:Lp(u,Z[0],Z[1],W),ye={};null!=v&&(ye.fill=v),null!=x&&(ye.stroke=x),null!=w&&(ye.strokeWidth=w),null!=k&&(ye.opacity=k),null!=S&&(ye.gap=S);const fe=q?`${s||""} semiotic-emphasis-${q}`.trim():s,ge=hA(l,u),be=(0,_A.useMemo)(()=>"down"!==p?y: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 s=new Map;for(const r of e){const e=LA(r,n,"time"),i=LA(r,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/o)*o;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())a=Math.max(a,e);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:h,timeAccessor:d,binSize:o,valueExtent:y,extentPadding:f}),[p,u,h,d,o,y,f]);return pe||me||(0,DA.jsx)(th,{ref:re,chartType:"bar",runtimeMode:"streaming",size:Z,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:te,className:fe,arrowOfTime:a,windowMode:c,windowSize:ge,data:u,timeAccessor:d,valueAccessor:h,xExtent:m,yExtent:be,extentPadding:f,binSize:o,categoryAccessor:g,barColors:b,barStyle:ye,showAxes:K,background:A,hoverAnnotation:Q,tooltipContent:oe,...am({linkedHover:L,selection:D,onObservation:O,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:se}),annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,decay:N,pulse:$,staleness:B,transition:E,pointIdAccessor:e.pointIdAccessor,legend:ee,legendPosition:ne,brush:ae||(U?{dimension:"x"}:void 0),onBrush:ae||U?he:void 0})});function $A(e){return(0,DA.jsx)(NA,{...e,windowMode:"growing"})}NA.displayName="RealtimeHistogram",$A.displayName="TemporalHistogram";var BA=require("react"),EA=require("react/jsx-runtime"),OA=(0,BA.forwardRef)(function(e,t){const n=kp(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:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,yScaleType:m,extentPadding:y,categoryAccessor:f,colors:g,radius:b,fill:v,opacity:x,stroke:w,strokeWidth:k,pointStyle:S,background:A,tooltipContent:C,tooltip:M,onHover:j,annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,linkedHover:L,selection:D,onObservation:N,chartId:$,loading:B,loadingContent:E,emptyContent:O,emphasis:F,legendPosition:z}=e,H=n.showAxes,W=n.enableHover,q=r??n.marginDefaults,G=o??[n.width,n.height],Y=C??M??dA({timeAccessor:u,valueAccessor:d}),V=(0,BA.useRef)(null),{customHoverBehavior:X}=xp({selection:D,linkedHover:L,unwrapData:!0,onObservation:N,chartType:"RealtimeSwarmChart",chartId:$}),U=(0,BA.useCallback)(e=>{j&&j(e),X(e)},[j,X]);(0,BA.useImperativeHandle)(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=Dp(B,G[0],G[1],E),Q=K?null:Lp(l,G[0],G[1],O),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=F?`${i||""} semiotic-emphasis-${F}`.trim():i,te=hA(c,l);return K||Q||(0,EA.jsx)(th,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:G,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:q,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:l,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,yScaleType:m,extentPadding:y,categoryAccessor:f,barColors:g,swarmStyle:Z,pointStyle:J,showAxes:H,background:A,hoverAnnotation:W,tooltipContent:Y,...am({linkedHover:L,selection:D,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:I,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});OA.displayName="RealtimeSwarmChart";var FA=require("react"),zA=require("react/jsx-runtime"),HA=(0,FA.forwardRef)(function(e,t){const n=kp(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:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:m,positiveColor:y,negativeColor:f,connectorStroke:g,connectorWidth:b,gap:v,stroke:x,strokeWidth:w,opacity:k,background:S,tooltipContent:A,tooltip:C,onHover:M,annotations:j,autoPlaceAnnotations:P,svgAnnotationRules:I,tickFormatTime:R,tickFormatValue:T,linkedHover:_,selection:L,onObservation:D,chartId:N,loading:$,loadingContent:B,emptyContent:E,emphasis:O,legendPosition:F}=e,z=n.showAxes,H=n.enableHover,W=r??n.marginDefaults,q=o??[n.width,n.height],G=A??C??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=lA(o,t,"time"),i=o?.delta??lA(o,n,"value"),s=o?.cumEnd,a="number"==typeof i?0>i?uA(i):"+"+uA(i):uA(i);return(0,sA.jsxs)("div",{className:"semiotic-tooltip",style:aA,children:[(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"x:"}),uA(r)]}),(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"Δ:"}),a]}),null!=s&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"total:"}),uA(s)]})]})}}({timeAccessor:u,valueAccessor:d}),Y=(0,FA.useRef)(null),{customHoverBehavior:V}=xp({selection:L,linkedHover:_,unwrapData:!0,onObservation:D,chartType:"RealtimeWaterfallChart",chartId:N}),X=(0,FA.useCallback)(e=>{M&&M(e),V(e)},[M,V]);(0,FA.useImperativeHandle)(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=Dp($,q[0],q[1],B),K=U?null:Lp(l,q[0],q[1],E),Q={};null!=y&&(Q.positiveColor=y),null!=f&&(Q.negativeColor=f),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=O?`${i||""} semiotic-emphasis-${O}`.trim():i,J=hA(c,l);return U||K||(0,zA.jsx)(th,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:q,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:W,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:l,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,extentPadding:m,waterfallStyle:Q,showAxes:z,background:S,hoverAnnotation:H,tooltipContent:G,...am({linkedHover:_,selection:L,onObservation:D,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:X}),annotations:j,autoPlaceAnnotations:P,svgAnnotationRules:I,tickFormatTime:R,tickFormatValue:T,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});HA.displayName="RealtimeWaterfallChart";var WA=require("react"),qA=require("react/jsx-runtime"),GA=(0,WA.forwardRef)(function(e,t){const n=kp(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:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:p,valueExtent:m,extentPadding:y,heatmapXBins:f=20,heatmapYBins:g=20,aggregation:b="count",background:v,tooltipContent:x,tooltip:w,onHover:k,annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:P,pulse:I,staleness:R,linkedHover:T,selection:_,onObservation:L,chartId:D,loading:N,loadingContent:$,emptyContent:B,emphasis:E,legendPosition:O}=e,F=n.showAxes,z=n.enableHover,H=r??n.marginDefaults,W=o??[n.width,n.height],q=x??w??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const i=e?.data??null,s=i?.xCenter??lA(i,t,"time"),a=i?.yCenter??lA(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,d=i?.agg??"count";return(0,sA.jsxs)("div",{className:"semiotic-tooltip",style:aA,children:[(0,sA.jsxs)("div",{children:[(0,sA.jsxs)("span",{style:cA,children:[o,":"]}),uA(s)]}),(0,sA.jsxs)("div",{children:[(0,sA.jsxs)("span",{style:cA,children:[r,":"]}),uA(a)]}),null!=c&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"count:"}),uA(c)]}),"sum"===d&&null!=l&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"sum:"}),uA(l)]}),"mean"===d&&null!=u&&(0,sA.jsxs)("div",{children:[(0,sA.jsx)("span",{style:cA,children:"mean:"}),uA(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=(0,WA.useRef)(null),{customHoverBehavior:Y}=xp({selection:_,linkedHover:T,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:D}),V=(0,WA.useCallback)(e=>{k&&k(e),Y(e)},[k,Y]);(0,WA.useImperativeHandle)(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const X=Dp(N,W[0],W[1],$),U=X?null:Lp(l,W[0],W[1],B),K=E?`${i||""} semiotic-emphasis-${E}`.trim():i,Q=hA(c,l);return X||U||(0,qA.jsx)(th,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:W,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:H,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:l,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:p,yExtent:m,extentPadding:y,heatmapXBins:f,heatmapYBins:g,heatmapAggregation:b,showAxes:F,background:v,hoverAnnotation:z,tooltipContent:q,...am({linkedHover:T,selection:_,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:P,pulse:I,staleness:R,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});GA.displayName="RealtimeHeatmap";var YA=require("react"),VA=d(require("react")),XA=require("react"),UA={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},KA={names:["--semiotic-border","--surface-3"],fallback:"#334155"},QA={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},ZA={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},JA={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},eC={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},tC={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},nC={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},oC={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},rC={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function iC(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 Xr(e,t)??t}return t.fallback}function sC(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 sC(`#${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 s=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);if(s)return`rgba(${s[1]}, ${n})`;const a=o.match(/^rgba\s*\(\s*([^,]+,\s*[^,]+,\s*[^,]+),\s*[^)]+\)$/i);return a?`rgba(${a[1]}, ${n})`:o}var aC=d(require("react")),cC=require("d3-scale"),lC=require("react/jsx-runtime");function uC(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function dC(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,title:s,legend:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d,legendPosition:h="right",legendLayout:p,pointNodes:m=[],annotations:y,onAnnotationActivate:f,onObservation:g,chartId:b,chartType:v,autoPlaceAnnotations:x,svgAnnotationRules:w,children:k}=e,S=Xs({onAnnotationActivate:f,onObservation:g,chartId:b,chartType:v}),A=aC.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(y),[y]),C=aC.useMemo(()=>function(e){const{width:t,height:n,pointNodes:o=[],data:r}=e;return{scales:{x:(0,cC.scaleLinear)().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:(0,cC.scaleLinear)().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=aC.useMemo(()=>A&&x?ja({annotations:A,context:C,..."object"==typeof x?x:{}}):A,[C,x,A]),j=aC.useMemo(()=>ra(0,S),[S]),P=M?oa(M,j,w,C):null,I=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,lC.jsxs)(lC.Fragment,{children:[I?(0,lC.jsx)("style",{children:Fs},"physics-annotation-disclosure-style"):null,(0,lC.jsxs)("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:[(0,lC.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[P,k]}),s&&"string"==typeof s?(0,lC.jsx)("text",{x:o/2,y:16,textAnchor:"middle",fontWeight:600,fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,lC.jsx)("foreignObject",{x:0,y:0,width:o,height:Math.max(i.top,28),children:s}):null,a?ys({legend:a,totalWidth:o,totalHeight:r,margin:i,legendPosition:h,legendLayout:p,title:s,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:d}):null]})]})}var hC=2500;function pC(e){return"function"==typeof e}function mC(e){return void 0===e||!1===e||!pC(e.binAccessor)&&!pC(e.labelAccessor)&&!pC(e.valueAccessor)}function yC(e){if(void 0!==e){if(!1===e)return!1;if(!mC(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 fC(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function gC(e){return function(e){return!pC(e?.timeAccessor)}(e)}function bC(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:fC(n),sediment:yC(o)}}var vC={};function xC(){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 wC=class{constructor(e=function(){const e="string"==typeof vC.url&&vC.url?new URL("./physicsWorker.js",vC.url):nw("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(xC());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(xC())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e)}})}async init(e,t,n,o){if(!gC(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:bC(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:bC(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(!gC(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 kC(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 SC={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},AC=1e-9,CC=.005;function MC(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function jC(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 PC(e,t,n){return Math.max(t,Math.min(n,e))}function IC(e,t,n){return Math.min(e??n,t??n)}function RC(e,t,n){return PC(Math.max(e??n,t??n),0,1)}function TC(e){return 0>e?-1:1}function _C(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 LC(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 DC(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function NC(e,t,n,o,r,i,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=i-t,d=(o+a)/2-Math.abs(u);return d>0?d>l?{nx:TC(c),ny:0,penetration:l}:{nx:0,ny:TC(u),penetration:d}:null}function $C(e,t,n,o,r,i,s){const a=i/2,c=s/2,l=e-PC(e,o-a,o+a),u=t-PC(t,r-c,r+c),d=l*l+u*u;if(d>n*n)return null;if(AC>=d){const i=Math.abs(e-(o-a)),s=Math.abs(e-(o+a)),l=Math.abs(t-(r-c)),u=Math.abs(t-(r+c)),d=Math.min(i,s,l,u);return d===i?{nx:-1,ny:0,penetration:n+i}:d===s?{nx:1,ny:0,penetration:n+s}:d===l?{nx:0,ny:-1,penetration:n+l}:{nx:0,ny:1,penetration:n+u}}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function BC(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,o,r,i){const s=o-e,a=r-t,c=n+i,l=s*s+a*a;if(l>=c*c)return null;if(AC>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/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 NC(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=$C(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?$C(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function EC(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?$C(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):NC(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,s,a=0){const c=i-o,l=s-r,u=c*c+l*l,d=u>AC?PC(((e-o)*c+(t-r)*l)/u,0,1):0,h=n+a/2,p=e-(o+c*d),m=t-(r+l*d),y=p*p+m*m;if(y>=h*h)return null;if(AC>=y){const e=Math.sqrt(u);return e>AC?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const f=Math.sqrt(y);return{nx:p/f,ny:m/f,penetration:h-f}}(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 OC(e,t){return`${e}\0${t}`}function FC(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function zC(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 HC(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 WC(e){return{id:e.id,shape:jC(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:HC(e.bodyFilter),index:e.index}}function qC(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 GC(e,t){return!!t?.some(t=>Object.is(e,t))}function YC(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=qC(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!GC(n,t.oneOf)||t.notOneOf&&GC(n,t.notOneOf))}function VC(e,t){return YC(t,e.bodyFilter)}var XC=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={...SC,...e},this.random=kC(this.options.seed)}init(e={}){this.options={...SC,...e},this.random=kC(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(AC,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))FC(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:jC(t.shape),bodyFilter:HC(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(FC)}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(zC),colliders:this.sortedColliders().map(WC),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=kC(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=zC(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=WC(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,s=Math.sqrt(r*r+i*i);if(AC>=s)continue;const a=r/s,c=i/s,l=(s-t.restLength)*t.stiffness+((("vx"in o?o.vx:0)-n.vx)*a+(("vy"in o?o.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*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],s=e[r];if(!i||!s)continue;const a=BC(i,s);a&&(this.resolveDynamicCollision(i,s,a),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:s.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=_C(e[o]),i=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=i;s>=e;e+=1)for(let t=a;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],s=r[n];!1!==e[i].bodyCollisions&&!1!==e[s].bodyCollisions&&DC(_C(e[i]),_C(e[s]))&&o.add(`${i}:${s}`)}}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.contactOpposesGravity(n.nx,n.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-n.nx,-n.ny)&&this.supportedThisStep.add(e.id);const o=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,i=o+r;if(AC>=i)return;const s=Math.max(0,n.penetration-CC)/i;e.x-=n.nx*s*o,e.y-=n.ny*s*o,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+IC(e.restitution,t.restitution,this.options.restitution))*a/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 s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+i;if(AC>=Math.abs(c)||AC>=l)return;const u=RC(e.friction,t.friction,this.options.friction),d=PC(-c/l,-o*u,o*u),h=d*s,p=d*a;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(!VC(e,o))continue;if(!DC(_C(o),LC(e)))continue;const t=EC(o,e);t&&(this.resolveStaticCollision(o,e,t),this.contactOpposesGravity(t.nx,t.ny)&&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-CC),e.y+=n.ny*Math.max(0,n.penetration-CC);const o=e.vx*n.nx+e.vy*n.ny;if(0>o){const r=IC(e.restitution,t.restitution,this.options.restitution);e.vx-=(1+r)*o*n.nx,e.vy-=(1+r)*o*n.ny;const i=-n.ny,s=n.nx,a=e.vx*i+e.vy*s,c=RC(e.friction,t.friction,this.options.friction);e.vx-=a*i*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const o of e){const e=_C(o);for(const r of n){if(!VC(r,o))continue;if(!DC(e,LC(r)))continue;if(!EC(o,r))continue;const n=OC(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}=FC(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})))}contactOpposesGravity(e,t){const{x:n,y:o}=this.options.gravity,r=Math.hypot(n,o);return 1e-9>=r||-.2>(e*n+t*o)/r}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},UC=class{constructor(e={}){this.id="builtin",this.capabilities={...(new XC).capabilities,engine:"builtin"},this.world=new XC(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 KC(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new UC(e)}(t)}var QC=["binId","targetBin","category","windowIndex","lane","group"];function ZC(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 eM(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 tM(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function nM(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?tM(t,e):void 0}function oM(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function rM(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 iM=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=oM(nM(this.config.binAccessor,e,t))??function(e){for(const t of QC){const n=oM(tM(e,t));if(n)return n}return"sediment"}(e),o=oM(nM(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?tM(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 s=this.bins.get(n);return s||(s={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,s)),s.label=o,s.lastBodyId=e.id,s.lastDatum=e.datum,ZC(s.x,e.x),ZC(s.y,e.y),ZC(s.value,r),i>0&&(s.bodyIds.push(e.id),s.bodyIds.length>i&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-i))),rM(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(rM)}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:eM(t.x),y:eM(t.y),value:eM(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 sM(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var aM={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},cM={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function lM(e={},t=cM){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 uM(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function dM(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 hM(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function pM(e){return{...uM(e),sequence:e.sequence,spawnAt:e.spawnAt}}function mM(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 yM(e){return!1!==e&&{...e}}function fM(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function gM(e){return{...e,gravity:{...e.gravity}}}function bM(e,t,n,o){if("circle"===e.shape.type){const r=e.x-t,i=e.y-n,s=e.shape.radius+o,a=r*r+i*i;return a>s*s?null:a}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),s=r*r+i*i;return s>o*o?null:s}function vM(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function xM(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=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*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function wM(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:p=Math.max(2,c)}=e,m=[],y=s+(a-s)/2,f=Math.abs(a-s),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 s=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:f}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:p}})}return m}var kM=require("d3-quadtree"),SM=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,o,r,i=0){const s=this.ensure(e,t);if(!s)return null;let a=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 s.visit((e,t,s,l,m)=>{if(u>l||t>d||h>m||s>p)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=bM(e,o,r,Math.max(0,i));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}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=(0,kM.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},AM=["data","scene-geometry","data-paint","accessibility","evidence"],CM=["scene-geometry","data-paint","accessibility","evidence"],MM=["overlay","accessibility","evidence"],jM=(e,t)=>({retainedData:e,invalidations:t}),PM=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],IM=["scene-geometry","data-paint","accessibility","evidence"],RM=[],TM={engine:jM("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:jM("preserve",IM),colliders:jM("preserve",IM),sediment:jM("preserve",IM),bodyBudget:jM("preserve",PM),bodyLimit:jM("preserve",PM),eviction:jM("preserve",PM),fixedDt:jM("preserve",RM),maxDeltaSeconds:jM("preserve",RM),maxSubsteps:jM("preserve",RM),settleStepLimit:jM("preserve",RM),timeScale:jM("preserve",RM),observation:jM("preserve",RM)},_M=jM("preserve",PM);function LM(e){let t="preserve";const n=new Set;for(const o of e){const e=TM[o]??_M;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var DM=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function NM(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&DM.every(n=>e[n]===t[n])}function $M(e,t,n,o){return e||!t?"paused":n||!o?"running":"settled"}var BM=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,n){if(n>0)return void(this.seconds=0);const o=e.readState(this.scratch),r=this.speed*this.speed;let i=!0;for(const e of o)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=r){i=!1;break}this.seconds=i?this.seconds+Math.max(0,t):0}},EM=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 qo,this.simulationState="settled",this.visible=!0,this.quiescence=new BM;const{bodyBudget:t,colliders:n,engine:o,kernel:r,observation:i,sediment:s,...a}=e;this.config={...aM,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=o,this.observation=lM(i),this.sediment=new iM(s??!1),this.world=KC(o,{fixedDt:this.config.fixedDt,...r}),this.quiescence.setKernelOptions(r),n&&this.world.setColliders(mM(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!NM(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:o,engine:r,kernel:i,observation:s,sediment:a,...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=KC(r,e.options),this.world.restore(e),this.revision+=1}if(i&&!NM(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.quiescence.setKernelOptions(t),this.revision+=1}s&&(this.observation=lM(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(mM(n)),this.revision+=1),this.configInput={...this.configInput,...e};const l=LM(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(mM(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},LM(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],o=t?function(e,t={}){const n=dM(t.startAt)??0,o=t.pacing??"immediate";if("arrival"===o){const o=e.map((e,n)=>function(e,t,n){return"function"==typeof n?dM(n(e,t)):"string"==typeof n?dM(hM(e,n)):dM(e.spawnAt)??dM(hM(e,"arrivalTime"))??dM(hM(e,"timestamp"))??dM(hM(e,"time"))??dM(hM(e,"eventTime"))}(e,n,t.timeAccessor)),r=o.filter(e=>null!=e),i=r.length>0?Math.min(...r):0,s=dM(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=o[t],s=null==r?0:Math.max(0,r-i);return{...uM(e),spawnAt:n+s/a}})}if("object"==typeof o){const t=dM(o.ratePerSec);if(t&&t>0)return e.map((e,o)=>({...uM(e),spawnAt:n+o/t}))}return e.map(e=>({...uM(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of o)this.queue.push({...uM(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(fM),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?AM:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(uM(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},AM)}materializeDueSpawns(){const e=this.revision,t=[],n=[];return this.spawnDue(t,n),0===t.length||(this.observeBodyBudget(n),this.evictOverflow(n),this.syncSimulationState(n),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?AM:[])),t}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.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},AM)}tick(e){const t=this.revision,n=[],o=[],r=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,i,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;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,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,n.length),(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,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||o.length||r.length?AM:CM:[]),d}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit){return this.runSettle(e,!0)}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t){const n=this.revision,o=[],r=[],i=[],s=[],a=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,o,r,i,s,a??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,a);const c=this.observeBodyBudget(a),l=this.evictOverflow(a);r.push(...l.evicted),i.push(...l.sedimented),this.syncSimulationState(a),o.length>0&&this.quiescence.reset();const u=t?{spawned:o,evicted:r,sedimented:i,events:s,observations:a}:{spawned:o},{steps:d,budget:h}=function(e,t,n){let o,r=0;for(;t>r&&(e.queueSize()>0||!e.atRest());){e.advanceTime(e.fixedDt);const t=[];if(e.spawnDue(t,n.observations),t.length>0){n.spawned.push(...t),o=e.observeBodyBudget(n.observations);const r=e.evictOverflow(n.observations);n.evicted?.push(...r.evicted),n.sedimented?.push(...r.sedimented)}e.step(e.fixedDt);const i=e.drainEvents();n.events&&(n.events.push(...i),e.observeKernelEvents(i,n.observations),e.observeSensorTransitions(n.observations)),r+=1,e.refreshQuiescence(e.fixedDt,t.length)}return{steps:r,budget:o}}(this.settleHost(),e,u),p=o.length+r.length+i.length>0;(d>0||p||s.length>0)&&(this.revision+=1);const m=this.result(d,o,r,i,s,a??[],void 0,h??c);return this.updateResults.record({kind:"settle",count:d},this.revision===n?[]:p?AM:CM),m}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:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(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()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}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?MM:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?MM:[])}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?AM:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},CM),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},CM)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},CM)}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:yM(this.bodyBudget),config:{...this.config,kernel:gM(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(pM),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:yM(e.bodyBudget??{}),kernel:gM(e.world.options)},this.bodyBudget=yM(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(pM).sort(fM),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??$M(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"},AM)}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,s,a=this.evaluateBodyBudget()){this.syncSimulationState(i);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),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}=vM(t),s=n.observation.sensors[o],a=r.get(i);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:i,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.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(vM(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=sM(e.bodyLimit),i=sM(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const o=sM(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),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:i,liveBodies:t,overflow:a,projectedBodies:o,queuedBodies:n,state:c,warnAt:s}}({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=$M(this.paused,this.visible,this.queue.length>0,this.atRest());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){const{evicted:t,sedimented:n,liveBodyOrder:o}=function(e,t,n,o,r,i){const s={evicted:[],sedimented:[],liveBodyOrder:r};if(!1===n)return s;const a=Math.max(0,Math.floor(o));if(!Number.isFinite(a))return s;const c=r.length-a;if(0>=c)return s;const l=function(e,t,n){if("sleeping-first"!==t)return n.slice();const o=new Map(e.readState().map(e=>[e.id,e.sleeping])),r=[],i=[];for(const e of n)o.get(e)?r.push(e):i.push(e);return[...r,...i]}(e,n,r),u=l.slice(0,c);if(0===u.length)return s;const d=function(e,t,n,o){const r=new Map(e.readState().map(e=>[e.id,e])),i=[];for(const e of n){const n=r.get(e);if(!n)continue;const s=t.add(n);s&&(i.push(e),o.emit({type:"physics-sediment",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:e,datum:n.datum,x:n.x,y:n.y,binId:s.id,count:s.count,total:s.total}))}return i}(e,t,u,i);e.remove(u);const h=new Set(u);return{evicted:u,sedimented:d,liveBodyOrder:r.filter(e=>!h.has(e))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=o,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:n}}};function OM(e,t,n){const o=new EM(e);return t?.length&&(o.enqueue(t,n),o.materializeDueSpawns()),o}function FM(){return"undefined"!=typeof performance?performance.now():Date.now()}var zM=d(require("react-dom/server"));function HM(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 WM={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function qM(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 GM(e,t){const n="function"==typeof t?t(e):t;return{...WM,...n??{}}}function YM(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)??qM(e)},r={style:GM(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),s=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,r=e.queue.length,i=e.sediment.reduce((e,t)=>e+t.count,0),s="settled"===e.simulationState&&0===r&&o===n.length,a=[];r>0&&a.push("PHYSICS_QUEUE_UNDRAINED");const c=null!=t.charge&&Number.isFinite(t.charge)?function(e,t,n,o){const r=e-(t+n+o);return{charge:e,live:t,queued:n,sedimented:o,unaccounted:r,balanced:0===r}}(t.charge,n.length,r,i):void 0;return c&&!c.balanced&&a.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:n.length,sleepingCount:o,settled:s,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:HM(t.projectionRows),queuedCount:r,sedimentedCount:i,...c?{ledger:c}:{},warnings:a}}(r,{bodies:o,projectionRows:t.projectionRows,stepsRun:n,charge:t.charge});return{snapshot:r,bodies:o,sceneNodes:i,evidence:s,stepsRun:n}}var VM=require("react/jsx-runtime"),XM={top:0,right:0,bottom:0,left:0};function UM(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function KM(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 QM(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=qC(e.datum,t),o=qC(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function ZM(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 JM(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),o=e.queueLayout??"lane",r=e.queueSlotSpacing??14,i=e.queueStiffness??.35,s=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,a=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,y=new Map,f=new Map,g=[];let b=0,v=new Map,x=new Map,w=0,k=0,S=0,A=null,C=0,M=0,j=0,P=0,I=0,R=0,T=0,_=0,L=0,D=0,N=0,$=0,B=-1,E=!1;function O(e,n){const o=n(e);return!!o&&o.activeRegionIds.includes(t)}function F(){$+=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 s={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,s),f.delete(n.id),y.set(n.id,o.jobId),M+=1,j+=o.work,F(),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,s,r),s}function W(e){if(u.size>=s||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>=s)break;const t=m.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),f.delete(n.bodyId),H(t,n,e,n.sequence)):d.delete(n.jobId)}}function q(){let e=0;for(const t of u.values())e+=t.remaining;return e}function G(){L=Math.max(L,u.size),D=Math.max(D,q())}function Y(){const e=S-a,t=Math.max(0,Math.min(a,S-(A??S)));let o=0,r=0,i=0,s=0,c=0;for(const t of g){if(e>t.end)continue;o+=t.arrivals,r+=t.arrivalWork,i+=t.completions,s+=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:s,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),!O(t.id,o.getRegionState))continue;if(!YC(t,e.bodyFilter))continue;const n=QM(t,e.jobKey),r=M.get(n)??[];r.push(t),M.set(n,r)}const j=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!E){const e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):j;S=Math.max(0,e-j),E=!0}const L=S,D=L+j;S=D,A=null==A?L:Math.min(A,L);const $={start:L,end:D,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},q=new Map;for(const[e,t]of M){const n=h.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];q.set(e,o),m.set(e,o)}for(const[n,r]of h){if(q.has(n))continue;const s=u.get(n),a=i.get(r.bodyId)??m.get(n);if(s){u.delete(n),y.delete(s.bodyId),T+=1,_+=s.remaining,F();const i={...z(s),abandonedAt:S,remainingWork:s.remaining,queueSeconds:Math.max(0,S-s.queuedAt)};a&&e.onAbandoned?.(a,i),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:t,work:s.total,remainingWork:s.remaining,jobId:n,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:S,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(n),f.delete(r.bodyId),h.delete(n),m.delete(n)}for(const[n,r]of q){if(h.has(n))continue;const i=(p.get(n)??0)+1;p.set(n,i);const a=KM(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${i}`,visit:i,regionId:t,work:a,queuedAt:S};h.set(n,c),C+=1,$.arrivals+=1,$.arrivalWork+=a;const l=b++;if(s>u.size)H(r,c,o,l);else{const s={...c,blockedAt:S,sequence:l};d.set(n,s),f.set(r.id,n),R+=1,F(),e.onBlocked?.(r,s),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:a,jobId:n,visitId:c.visitId,visit:i,queuedAt:S,blockedAt:S,queueDepth:u.size,blockedDepth:d.size})}}W(o),G();const Y=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let V=n*j;for(const n of Y){if(0>=V)break;const r=Math.min(n.remaining,V);if(n.remaining-=r,V-=r,P+=r,$.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,I+=n.total,$.completions+=1,$.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);N+=s,F();const a=i.get(n.bodyId);if(!a)continue;o.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...z(n),completedAt:S,queueSeconds:s};e.onProcessed?.(a,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:S,queueSeconds:s,queueDepth:u.size})}W(o),G(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);v=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);x=new Map(t.map((e,t)=>[e.bodyId,t])),w=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&g.push(e);const t=S-a;for(;g.length>0&&t>g[0].end;)g.shift()}($);const X=Math.floor(S/c);X!==B&&(B=X,F())},getSnapshot:()=>{const e=q(),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),s=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:j,processedWork:P,completedWork:I,blockedCount:R,abandonedCount:T,abandonedWork:_,peakQueueDepth:L,peakRemainingWork:D,queueAge:{count:i.length,meanSeconds:i.length>0?s/i.length:0,p50Seconds:ZM(i,.5),p95Seconds:ZM(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:k>0?N/k:0,window:Y(),simulatedAt:S,metricRevision:$}},bodyForce:e=>{if("none"===o)return null;const n=y.get(e.body.id),s=f.get(e.body.id),a=n?u.get(n):void 0,c=s?d.get(s):void 0;if(!a&&!c)return null;const l=a?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 ej(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}var tj=require("react");function nj(){return"undefined"==typeof document||!document.hidden}function oj(e,t,n){const o=ci(e,n.fill)??"#4e79a7",r=ci(e,n.stroke),i="none"!==r?r:void 0,s=n.strokeWidth??0,a=n.opacity??1,c=n.fillOpacity??1,l=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),u="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"===l||"square"===l||"aabb"===t.shape.type){const n="pill"===l?2.4*u:"aabb"===t.shape.type?t.shape.width:1.7*u,o="pill"===l?1.35*u:"aabb"===t.shape.type?t.shape.height:1.7*u,r=t.x-n/2,i=t.y-o/2,s="pill"===l?o/2:Math.min(4,n/4);e.moveTo(r+s,i),e.arcTo(r+n,i,r+n,i+o,s),e.arcTo(r+n,i+o,r,i+o,s),e.arcTo(r,i+o,r,i,s),e.arcTo(r,i,r+n,i,s),e.closePath()}else if("diamond"===l)e.moveTo(t.x,t.y-u),e.lineTo(t.x+u,t.y),e.lineTo(t.x,t.y+u),e.lineTo(t.x-u,t.y),e.closePath();else if("faceted"===l){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)*u,s=t.y+Math.sin(r)*u;0===o?e.moveTo(i,s):e.lineTo(i,s)}e.closePath()}else e.arc(t.x,t.y,u,0,2*Math.PI);o&&(e.save(),e.globalAlpha*=c,e.fillStyle=o,e.fill(),e.restore()),"halo"===l&&(e.beginPath(),e.arc(t.x,t.y,1.35*u,0,2*Math.PI),e.strokeStyle=i??o,e.lineWidth=Math.max(1.5,s||1.5),e.globalAlpha*=.55,e.stroke(),e.globalAlpha/=.55),i&&s>0&&(e.strokeStyle=i,e.lineWidth=s,n.strokeDasharray&&e.setLineDash(n.strokeDasharray.split(/[,\s]+/).map(e=>Number(e)).filter(e=>Number.isFinite(e))),e.stroke()),e.restore()}function rj(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function ij(e){return e.sensorId??"stream-region-"+e.id}function sj(e){const t=ij(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,s=e.shape.y-e.shape.height/2,a=e.shape.y+e.shape.height/2;return[{...n,id:t+"-top",shape:{type:"segment",x1:r,y1:s,x2:i,y2:s,thickness:o}},{...n,id:t+"-right",shape:{type:"segment",x1:i,y1:s,x2:i,y2:a,thickness:o}},{...n,id:t+"-bottom",shape:{type:"segment",x1:i,y1:a,x2:r,y2:a,thickness:o}},{...n,id:t+"-left",shape:{type:"segment",x1:r,y1:a,x2:r,y2:s,thickness:o}}]}return e.collider?[{...n,id:t+"-collider",shape:e.shape}]:[]}function aj(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function cj(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 lj(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 uj(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}function dj(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 hj=[];function pj(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||!uj(t))return!1;const i=new Map(t.map(e=>[e.id,e])),s=e.readBodies();let a=!1;for(const t of s){const o=n.get(t.id);if(!o||!o.activeRegionIds.size)continue;const s=aj(o);if(s)for(const n of o.activeRegionIds){const o=i.get(n);if(!o)continue;const c=cj(o.force,{body:t,region:o,regionState:s}),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),a=!0)}}return a}(t,e.regionEffects,e.regionState,o),i=function(e,t,n,o,r,i){const s=Number.isFinite(i)?Math.max(0,i):0;if(0>=s||!t)return!1;const a=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=aj(u);let h=hj;if(u&&u.activeRegionIds.size>0){const e=[];for(const t of u.activeRegionIds){const n=a.get(t);n&&e.push(n)}h=e}const p=dj(t,{body:i,bodies:c,index:n,regionState:d,regions:h,simulationState:r});if(!p)continue;const m=(p.x??0)*s,y=(p.y??0)*s;(m||y)&&(e.applyImpulse(i.id,m,y),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=>aj(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:i,snapshot:n}}function mj(e,t,n,o,r,i,s,a,c,l){const u=function(e,t){return!!t?.isActive&&(t.predicate?.(e)??!0)}(e,r),d={selected:u,simulationState:t,regionState:i,regions:s},h="function"==typeof n?n(e,d):n,p=s.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??a,stroke:l?.stroke??c,strokeWidth:l?.strokeWidth??1,opacity:l?.opacity??.9,...h,...p,...m}}var yj=require("react");function fj(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function gj(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,fj(e.thickness)??fj(n)??fj(t.thickness)??4)}var bj=d(require("react")),vj=require("react/jsx-runtime"),xj={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},wj="semiotic-accessible-data-table",kj=wj+" semiotic-accessible-data-table-hidden",Sj=wj+" semiotic-accessible-data-table-visible",Aj={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"},Cj={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Mj={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)"},jj={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Pj={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))"},Ij={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Rj={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Tj={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 _j(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function Lj(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function Dj(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 Nj(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 $j(e){const t=Bj(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function Bj(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=_j(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function Ej({hover:e}){const t=Bj(e.data);return(0,vj.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,vj.jsx)("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>(0,vj.jsxs)("div",{children:[(0,vj.jsxs)("span",{style:{opacity:.72},children:[e,": "]}),(0,vj.jsx)("span",{children:t})]},e))]})}function Oj(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=_j(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function Fj(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 zj(e){const{chartTitle:t,items:n,tableId:o}=e,[r,i]=bj.useState(!1),[s,a]=bj.useState(5),c=hl(),l=c?.visible??!1,u=r||l,d=bj.useRef(null),h="Data summary for "+(t??"physics chart");bj.useEffect(()=>{u||a(5)},[u]);const p=bj.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),m=bj.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!n.length)return(0,vj.jsx)("span",{id:o,tabIndex:-1,style:xj});if(!u)return(0,vj.jsx)("div",{id:o,className:kj,role:"region","aria-label":h,tabIndex:-1,style:xj,onFocus:p,children:(0,vj.jsxs)("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",n.length," semantic items)"]})});const y=Math.min(s,n.length),f=n.slice(0,y),g=n.length-y;return(0,vj.jsxs)("div",{ref:d,id:o,className:Sj,role:"region","aria-label":h,tabIndex:-1,onBlur:m,style:Aj,children:[(0,vj.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},style:Mj,children:"×"}),(0,vj.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Cj,children:Fj(n)}),(0,vj.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:jj,children:[(0,vj.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Rj,children:g>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),(0,vj.jsx)("thead",{children:(0,vj.jsxs)("tr",{children:[(0,vj.jsx)("th",{scope:"col",style:Pj,children:"Item"}),(0,vj.jsx)("th",{scope:"col",style:Pj,children:"Description"}),(0,vj.jsx)("th",{scope:"col",style:Pj,children:"Group"}),(0,vj.jsx)("th",{scope:"col",style:Pj,children:"Position"}),(0,vj.jsx)("th",{scope:"col",style:Pj,children:"Data"})]})}),(0,vj.jsx)("tbody",{children:f.map((e,t)=>(0,vj.jsxs)("tr",{children:[(0,vj.jsx)("th",{scope:"row",style:Ij,children:e.label}),(0,vj.jsx)("td",{style:Ij,children:e.description??e.label}),(0,vj.jsx)("td",{style:Ij,children:e.group??""}),(0,vj.jsxs)("td",{style:Ij,children:[Math.round(e.x),", ",Math.round(e.y)]}),(0,vj.jsx)("td",{style:Ij,children:Oj(e)})]},e.id??`${e.label}-${t}`))})]}),g>0?(0,vj.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Tj,children:["Show ",Math.min(25,g)," more"," ",1===g?"row":"rows"," (",g," remaining)"]}):null]})}Ej.ownsChrome=!0;var Hj=require("react/jsx-runtime"),Wj=[640,360],qj={top:0,right:0,bottom:0,left:0},Gj=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Yj="StreamPhysicsFrame",Vj=(0,XA.memo)((0,XA.forwardRef)(function(e,t){const{accessibleTable:n=!0,annotations:o,onAnnotationActivate:r,autoPlaceAnnotations:i,background:s,backgroundGraphics:a,maxDevicePixelRatio:c,bodySemanticItemLimit:l=200,bodySemanticItems:u=!1,bodySemanticUpdateMs:d=200,bodyForces:h,bodyStyle:p,chartId:m,className:y,frameScheduler:f,clock:g,random:b,seed:v,color:x,config:w,controllers:k,continuous:S=!1,description:A,emphasis:C,chartMode:M,enableHover:j=!0,foregroundGraphics:P,hoverRadius:I=16,initialSpawns:R,initialSpawnPacing:T,legend:_,legendClickBehavior:L,legendHighlightedCategory:D,legendHoverBehavior:N,legendIsolatedCategories:$,legendLayout:B,legendPosition:E,margin:O,onClick:F,onObservation:z,onRegionEvent:H,onSimulationExecutionChange:W,onBodyHover:q,onBodyPointerDown:G,onSemanticItemActivate:Y,onSemanticItemFocus:V,onTick:X,opacity:U,paused:K=!1,regionEffects:Q=[],responsiveHeight:Z,responsiveWidth:J,selectedBodyStyle:ee={stroke:"#111827",strokeWidth:2,opacity:1},selection:te,semanticItems:ne=[],simulationExecution:oe="auto",size:re=Wj,stroke:ie,strokeWidth:se,summary:ae,suspendWhenHidden:ce=!0,svgAnnotationRules:le,title:ue,tooltipContent:de,workerBodyThreshold:he=hC,renderBody:pe,beforePaint:me,afterPaint:ye}=e,fe=VA.useMemo(()=>({color:x,stroke:ie,strokeWidth:se,opacity:U}),[x,U,ie,se]),ge=(0,XA.useRef)(z);ge.current=z;const be=(0,XA.useRef)(m);be.current=m;const ve=(0,XA.useRef)(new Map),xe=(0,XA.useRef)(Q);xe.current=Q;const we=(0,XA.useRef)(h),ke=(0,XA.useRef)(X);ke.current=X;const Se=VA.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=ej(n,o.bodyForce(e)));return n}}}(k),[k]),Ae=(0,XA.useRef)(Se);Ae.current=Se;const Ce=S||!!Se?.continuous,Me=(0,XA.useRef)(Ce);Me.current=Ce;const je=VA.useMemo(()=>{if(!h&&!Se?.bodyForce)return h;if(!Se?.bodyForce)return h;if(!h)return Se.bodyForce;const e=Se.bodyForce;return t=>{const n="function"==typeof h?h(t):h,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}},[h,Se]);we.current=je;const Pe=VA.useMemo(()=>new Map(Q.map(e=>[ij(e),e])),[Q]),Ie=VA.useMemo(()=>new Map(Q.map(e=>[e.id,e])),[Q]),Re=VA.useMemo(()=>Q.map(lj).filter(e=>null!=e),[Q]),[Te,_e]=VA.useState([]),Le=VA.useMemo(()=>Te.length||Re.length?[...ne,...Te,...Re]:ne,[Te,Re,ne]),De=VA.useMemo(()=>uj(Q),[Q]),Ne=!!je,$e=(0,XA.useRef)(null),Be=(0,XA.useRef)(g??FM);Be.current=g??FM;const Ee=(0,XA.useCallback)((e,t,n)=>{const o=$e.current;if(!o||!n)return!1;const r=o.readBodies().find(t=>t.id===e),i=aj(ve.current.get(e));if(!r||!i)return!1;const s=cj(n,{body:r,region:t,regionState:i});return!(!s||!s.x&&!s.y||(o.applyImpulse(e,s.x??0,s.y??0),0))},[]),Oe=(0,XA.useCallback)((e,t,n)=>{if(!n.bodyId)return;const o=aj(ve.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),H?.(r)},[H]),Fe=(0,XA.useCallback)(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}(ve.current,e.bodyId),o=$e.current?.readBodies().find(t=>t.id===e.bodyId),r=aj(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)}Ee(e.bodyId,t,t.impulseOnEnter),Oe("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),Ee(e.bodyId,t,t.impulseOnExit),Oe("region-exit",t,e))},[Ee,Oe,Pe]),ze=VA.useMemo(()=>function({annotations:e,chartId:t,chartType:n,config:o,onRegionObservation:r,regionEffects:i,seed:s,size:a}){const c=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=gj(r,t),s=r.colliderId??`${n}${r.id}`;let a;if("x"===e){const e=fj(r.x),n=fj(r.y1)??fj(t.plotBounds?.y)??fj(r.y),o=fj(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??fj(r.y);if(null==e||null==n||null==o)continue;a={type:"segment",x1:e,y1:n,x2:e,y2:o,thickness:i}}else{const e=fj(r.y),n=fj(r.x1)??fj(t.plotBounds?.x)??fj(r.x),o=fj(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??fj(r.x);if(null==e||null==n||null==o)continue;a={type:"segment",x1:n,y1:e,x2:o,y2:e,thickness:i}}o.push({id:s,shape:a,sensor:"sensor"===r.physics,..."barrier"!==r.physics||null==r.restitution&&null==t.barrierRestitution?{}:{restitution:fj(r.restitution)??fj(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:fj(r.friction)??fj(t.barrierFriction)}})}return o}((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?t+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:a[0],height:a[1]}}),l=void 0===s||void 0!==o?.kernel?.seed?o:{...o,kernel:{...o?.kernel,seed:s}},u=i.flatMap(e=>[{id:ij(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...sj(e)]),d=Object.fromEntries(i.map(e=>[ij(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=l?.observation,p=i.length>0;return p||u.length>0||c.length>0||null!=t||h?{...l,colliders:[...l?.colliders??[],...u,...c],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??n,sensors:{...h?.sensors??{},...d},onObservation:e=>{p&&r(e),h?.onObservation?.(e)}}}:l}({annotations:o,chartId:m,chartType:Yj,config:w,onRegionObservation:Fe,regionEffects:Q,seed:v,size:re}),[o,m,w,Fe,Q,v,re]);if(!$e.current){const e=OM(ze,R,T);e.setPaused(K),ce&&e.setVisible(nj()),$e.current=e}const He=(0,XA.useRef)(-1),We=(0,XA.useRef)(null),qe=(0,XA.useRef)(!0),Ge=yr("StreamPhysicsFrame"),Ye=(0,XA.useRef)(""),Ve=(0,XA.useId)().replace(/:/g,""),Xe=(0,XA.useRef)(!1),Ue=(0,XA.useRef)(!1),Ke=(0,XA.useRef)(0),Qe=(0,XA.useRef)(!1),Ze=(0,XA.useRef)(!1),Je=(0,XA.useRef)(null),et=(0,XA.useRef)(!1),tt=Cu({sizeProp:re,responsiveWidth:J,responsiveHeight:Z,userMargin:O,marginDefault:qj,foregroundGraphics:P,backgroundGraphics:a,frameScheduler:f,clock:g,random:b,seed:v,paused:K,suspendWhenHidden:ce}),{margin:nt,rafRef:ot,reducedMotion:rt,reducedMotionRef:it,renderFnRef:st,cancelRender:at,resolvedBackground:ct,resolvedForeground:lt,responsiveRef:ut,scheduleRender:dt,size:ht,frameRuntime:pt}=tt,mt=(0,XA.useRef)(pt.now);mt.current=pt.now;const yt=Gc(),ft=Uc(),[gt,bt]=VA.useState(null),[vt,xt]=VA.useState(null),wt=(0,XA.useRef)(null),kt=(0,XA.useRef)(0),St=(0,XA.useRef)(new Map),At=Ve+"-physics-live",Ct=(0,XA.useCallback)((e,t,n=!1)=>{if(!u)return void _e(e=>e.length?[]:e);const o=mt.current();if(!n&&d>0&&d>o-kt.current)return;kt.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],s="function"==typeof n?n(r,{index:o,simulationState:t}):void 0;if(!1===s)continue;const a=Dj(r);i.push({datum:r.datum??r,description:$j(r),group:"body",label:Nj(r),...a,...s??{},bodyId:s?.bodyId??r.id,id:s?.id??"body:"+r.id,x:s?.x??r.x,y:s?.y??r.y})}return i}(e,t,u,l);_e(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)},[l,u,d]),Mt=(0,XA.useCallback)(e=>{if(!Le.length)return;const t=Math.max(0,Math.min(e,Le.length-1));He.current=t;const n=Le[t];if(wt.current=n.bodyId??null,bt(n),V?.(n),n.bodyId&&$e.current){const e=$e.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=Lj(e);xt(t),q?.(e,t)}}},[Le,q,V]),jt=(0,XA.useCallback)(()=>{He.current=-1,wt.current=null,bt(null),V?.(null)},[V]),Pt=function({onObservationRef:e,chartIdRef:t,wallClockRef:n}){return(0,yj.useCallback)((o,r)=>{const i=e.current;if(!i)return;const s={timestamp:n.current(),chartType:"StreamPhysicsFrame",chartId:t.current};i("hover"===o||"click"===o?{...s,type:o,datum:r?.datum??{},x:r?.x??0,y:r?.y??0}:"focus"===o?{...s,type:o,datum:r?.datum??{},inputType:"touch"===r?.inputType?"pointer":r?.inputType??"keyboard"}:"activate"===o?{...s,type:o,datum:r?.datum??{},inputType:r?.inputType??"keyboard"}:{...s,type:o})},[t,e,n])}({onObservationRef:ge,chartIdRef:be,wallClockRef:Be}),It=(0,XA.useCallback)(()=>{xt(e=>e?(q?.(null,null),Pt("hover-end"),null):e)},[Pt,q]),Rt=(0,XA.useCallback)(e=>{if(!j||!$e.current)return;const t=e.currentTarget.getBoundingClientRect(),n=$e.current.hitTest(e.clientX-t.left,e.clientY-t.top,I);if(!n)return void It();const o=Lj(n);xt(e=>e&&e.id===o.id&&e.x===o.x&&e.y===o.y?e:(q?.(n,o),Pt("hover",{datum:n.datum,x:n.x,y:n.y}),o))},[It,Pt,j,I,q]),Tt=(0,XA.useCallback)(e=>{jt();const t=$e.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?(Pt("click",{datum:i.datum,x:i.x,y:i.y}),Pt("activate",{datum:i.datum,inputType:"touch"===e.pointerType?"touch":"pointer"}),F?.(i.datum??null,{x:i.x,y:i.y,body:i})):(Pt("click-end"),F?.(null,{x:o,y:r,body:null}),It())},[It,jt,Pt,I,G,F]);(0,XA.useEffect)(()=>{if(!Le.length)return void jt();const e=He.current;if(Le.length>e){if(e>=0){const t=Le[e];if(wt.current=t.bodyId??null,bt(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&&$e.current){const e=$e.current.readBodies().find(e=>e.id===t.bodyId);if(e){const t=Lj(e);xt(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else Mt(Le.length-1)},[Le,jt,Mt]),(0,XA.useEffect)(()=>{j||It()},[It,j]);const _t=(0,XA.useCallback)(e=>{if(Dd(e))return;if(!Le.length)return;if("Escape"===e.key)return e.preventDefault(),void jt();if(("Enter"===e.key||" "===e.key)&&He.current>=0){e.preventDefault();const t=Le[He.current];return Pt("activate",{datum:t.datum??{id:t.id,label:t.label},inputType:"keyboard"}),void Y?.(t)}if(!Gj.has(e.key))return;e.preventDefault();const t=He.current;if(0>t){Mt(0);const e=Le[0];return void Pt("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)),Mt(o),o!==t){const e=Le[o];Pt("focus",{datum:e.datum??{id:e.id,label:e.label},inputType:"keyboard"})}},[jt,Pt,Mt,Y,Le]),[Lt,Dt]=VA.useState([]),Nt=(0,XA.useRef)(0),$t=!!o?.length&&o.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),{canvasRef:Bt,resolutionDirtyRef:Et}=Tu(tt,{hydrated:yt,wasHydratingFromSSR:ft,storeRef:$e,dirtyRef:qe,manageFrameRuntime:!1,skipInitialCanvasPaintInvalidation:!0,maxDevicePixelRatio:c,canvasPaintDependencies:[s,a,dt]}),Ot=(0,XA.useCallback)(()=>{const e=Bt.current,t=$e.current;if(!e||!t)return;const n=Ge.current.beforeCompute(t.getLastUpdateResult(),!1);Et.current=!1;const o=Pu(c),r=ju(e,ht,nt,o);if(!r)return void Ge.current.afterCompute(n,!1,!1);const i=function(e){const t=iC(e,eC),n=iC(e,QA),o=iC(e,rC),r=iC(e,tC),i=iC(e,KA),s=iC(e,UA),a=iC(e,nC),c=iC(e,oC),l=iC(e,ZA),u=iC(e,JA);return{annotationBackground:sC(s,.94),annotationStroke:i,annotationText:a,background:s,border:i,closedWindowFill:sC(n,.08),closedWindowStroke:sC(n,.55),danger:n,focus:l,grid:u,gutterFill:sC(c,.14),lateFill:o,openWindowFill:sC(t,.07),openWindowStroke:sC(t,.3),primary:t,selectedFill:o,selectedStroke:l,success:r,text:a,textSecondary:c,warning:o}}(r);r.clearRect(-nt.left,-nt.top,ht[0],ht[1]),a||"transparent"===s||(r.fillStyle=s??i.background,r.fillRect(-nt.left,-nt.top,ht[0],ht[1]));const l=t.snapshot(),u=t.readBodies();if(Ct(u,l.simulationState),$t){const e=mt.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,uC(e))}))}(u);Dt(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)}}me&&(r.save(),me(r,u),r.restore());for(const e of u){const t=ve.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Ie.get(e)).filter(e=>null!=e):[],o=mj(e,l.simulationState,p,ee,te,aj(t),n,i.primary,i.text,fe);pe?(r.save(),pe(r,e,o),r.restore()):oj(r,e,o)}ye&&(r.save(),ye(r,u),r.restore()),function(e,t,n){let o=!1;for(const[r,i]of t){const s=Math.min(1,Math.max(0,(n-i.startedAt)/i.durationMs));if(s>=1){t.delete(r);continue}o=!0;const a=1-Math.pow(1-s,3),{body:c}=i,l=i.scale>0?i.scale:1,u=(i.radius+28*a)*l,d=1-s;e.save(),e.globalAlpha*=d,e.strokeStyle=i.color,e.fillStyle=i.color,e.lineWidth=Math.max(.5,(2.4*d+.4)*l),e.beginPath(),e.arc(c.x,c.y,u,0,2*Math.PI),e.stroke(),e.globalAlpha*=.18,e.beginPath(),e.arc(c.x,c.y,.52*u,0,2*Math.PI),e.fill(),e.restore(),e.save(),e.globalAlpha*=d,e.strokeStyle=i.color,e.lineWidth=Math.max(.5,1.8*l);for(let t=0;8>t;t+=1){const n=t*(Math.PI/4)+1.4*s,o=(i.radius+5+12*a)*l,r=(i.radius+12+34*a)*l;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,St.current,mt.current()),Ge.current.afterCompute(n,!0,!1),qe.current=!1},[Bt,Et,Ge,ht,nt,a,s,c,Ct,$t,me,ye,p,ee,te,fe,pe,Ie]),Ft=(0,XA.useCallback)((e,t)=>{const n=$e.current,o=`${oe}:${e}:${t??""}`;Ye.current!==o&&(Ye.current=o,W?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:oe}))},[W,oe]),zt=(0,XA.useCallback)((e,t=!0)=>{Ke.current+=1,Xe.current=!1,Qe.current=!1,Ze.current=!1,et.current=!1,Je.current?.terminate(),Je.current=null,t&&Ft("sync",e)},[Ft]),Ht=(0,XA.useCallback)(()=>yt?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":De?"runtime region effects require sync":Ne?"body forces require sync":Se?"physics controllers require sync":function(e){return!e||!e.engine&&mC(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(ze??{})?gC(T)?Ue.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[ze,Se,Ne,De,yt,T]),Wt=(0,XA.useCallback)(()=>{const e=$e.current,t=Ht();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),o=e.queueSize(),r=function(e,t,n=0,o=hC){return"sync"!==e&&("worker"===e||t+n>=o)}(oe,n,o,he);return{reason:r?"worker"===oe?"forced worker":"body threshold":"below threshold",useWorker:r}},[oe,he,Ht]),qt=(0,XA.useCallback)(e=>{const t=$e.current;return t&&e.snapshot?(t.restore(e.snapshot),qe.current=!0,t):t},[]),Gt=(0,XA.useCallback)((e,t=!0)=>{const n=qt(e);if(!n)return;t&&X?.(e.result,n.controls()),Ot();const o=n.snapshot();!e.result.shouldContinue&&St.current.size<=0||o.paused||!o.visible||it.current||dt()},[qt,X,Ot,it,dt]),Yt=(0,XA.useCallback)(e=>{Ue.current=!0,zt("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[zt]),Vt=(0,XA.useCallback)(()=>{const e=$e.current;if(!e)return!1;const t=Wt();if(!t.useWorker)return Xe.current||et.current?zt(t.reason??"sync fallback"):Ft("sync",t.reason??"sync"),!1;if(Xe.current||et.current)return!0;const n=Je.current??new wC;Je.current=n,et.current=!0;const o=Ke.current+1;return Ke.current=o,n.initFromSnapshot(ze??{},e.snapshot()).then(e=>{if(Ke.current!==o)return;et.current=!1,Xe.current=!0,Ue.current=!1,qt(e),Ft("worker",t.reason??"worker"),Ot();const n=$e.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!it.current&&(We.current=null,dt())}).catch(e=>{Ke.current===o&&Yt(e)}),!0},[qt,ze,Yt,Ot,it,Ft,dt,zt,Wt]),Xt=(0,XA.useCallback)(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Ut=(0,XA.useCallback)((e,t=!0)=>{const n=Je.current;if(!n||!Xe.current)return;const o=Ke.current;n.request(e).then(e=>{if(Ke.current!==o)return;const n=Xt(e);n&&Gt(n,t)}).catch(Yt)},[Gt,Xt,Yt]),Kt=(0,XA.useCallback)(()=>{const e=$e.current;if(!e)return;const t=Vt(),n=e.snapshot(),o=Ce||Ne||De||!!Se;n.paused||!n.visible||!e.hasPendingWork()&&!o||it.current?st.current():t&&et.current||dt()},[Se,Ce,Ne,De,it,st,dt,Vt]),Qt=(0,XA.useCallback)(()=>{at(),ot.current=null;const e=$e.current;if(!e)return;const t=it.current;if(t&&(We.current=null),Xe.current&&Je.current){if(Qe.current)return void(Ze.current=!0);let n=0;if(!t){const e=mt.current();n=null!==We.current?(e-We.current)/1e3:0,We.current=e}const o=Je.current,r=Ke.current;return Qe.current=!0,void(t?o.settle():o.tick(n)).then(e=>{Qe.current=!1;const t=Ze.current;Ze.current=!1,Ke.current===r&&(Gt(e),t&&Kt())}).catch(o=>{Qe.current=!1;const i=Ze.current;if(Ze.current=!1,Ke.current!==r)return;Yt(o);const s=t?e.settleWithObservations():e.tick(n);pj({store:e,result:s,regionEffects:xe.current,regionState:ve.current,bodyForces:we.current,composed:Ae.current,onTick:ke.current}),Ot(),i&&Kt()})}const n=Ae.current,o=t=>pj({store:e,result:t,composed:n,regionEffects:xe.current,regionState:ve.current,bodyForces:we.current,onTick:ke.current});let r;if(t)r=function(e,t,n=4){let o,r=!1,i=!1,s=0;do{const n=e.settleWithObservations(),a=t(n);r=r||a.regionEffectsApplied,i=i||a.bodyForcesApplied,o={...a,regionEffectsApplied:r,bodyForcesApplied:i,result:n},s+=1}while(n>s&&e.hasPendingWork());return o}(e,o);else{const t=mt.current(),n=We.current;We.current=t;const i=e.tick(null===n?0:(t-n)/1e3);r={...o(i),result:i}}const{result:i,regionEffectsApplied:s,bodyForcesApplied:a,snapshot:c}=r;Ot(),(Me.current||i.shouldContinue||s||a||n||St.current.size>0)&&!c.paused&&c.visible&&!it.current&&dt()},[Gt,Yt,Ot,at,Kt,dt,it,ot]);st.current=Qt,(0,XA.useEffect)(()=>{Ue.current=!1,(Xe.current||et.current)&&zt("config changed",!1),$e.current?.updateConfig(ze??{}),Kt()},[ze,zt]),(0,XA.useEffect)(()=>{Ue.current=!1,Kt()},[yt,oe,he]),(0,XA.useEffect)(()=>{Kt()},[rt,Kt]),function({cancelRender:e,frameRuntime:t,lastFrameTimeRef:n,paused:o,postWorkerCommand:r,requestRender:i,storeRef:s,suspendWhenHidden:a}){const c=(0,tj.useRef)(r);c.current=r;const l=(0,tj.useRef)(i);l.current=i,(0,tj.useEffect)(()=>{const r=s.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]),(0,tj.useEffect)(()=>{if(!a){const e=s.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=s.current;if(!o)return;const r=nj();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,a])}({cancelRender:at,frameRuntime:pt,lastFrameTimeRef:We,paused:K,postWorkerCommand:Ut,requestRender:Kt,storeRef:$e,suspendWhenHidden:ce}),(0,XA.useEffect)(()=>()=>zt("unmount",!1),[zt]),(0,XA.useEffect)(()=>{Ot()},[Ot]),(0,XA.useImperativeHandle)(t,()=>({...$e.current.controls(),applyImpulse:(e,t,n)=>{$e.current.applyImpulse(e,t,n),Ut({type:"applyImpulse",id:e,ix:t,iy:n}),Kt()},clear:()=>{$e.current.clear(),ve.current.clear(),St.current.clear(),Ut({type:"clear"}),Kt()},clearRegionState:e=>{e?ve.current.delete(e):ve.current.clear(),Kt()},getData:()=>$e.current.readBodies(),getRegionState:e=>e?aj(ve.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const o=aj(e);o&&(t[n]=o)}),t}(ve.current),getStore:()=>$e.current,pause:()=>{pt.setPaused(!0),We.current=null,at(),$e.current.setPaused(!0),Ut({type:"setPaused",paused:!0},!1),Kt()},push:(e,t)=>{$e.current.enqueue(e,t),gC(t)?Ut({type:"enqueue",spawns:[e],pacing:t}):(Xe.current||et.current)&&zt("spawn pacing is not worker-cloneable"),Kt()},pushMany:(e,t)=>{$e.current.enqueue(e,t),gC(t)?Ut({type:"enqueue",spawns:e,pacing:t}):(Xe.current||et.current)&&zt("spawn pacing is not worker-cloneable"),Kt()},popBodies:(e,t={})=>{const n=$e.current,o=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),i=mt.current();for(const e of r){const n=o.get(e);n&&(ve.current.delete(e),St.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??rj(n),scale:null!=t.scale&&t.scale>0?t.scale:1,startedAt:i}),wt.current===e&&(wt.current=null,bt(null)),xt(t=>t?.id===e?null:t))}return r.length&&(Ut({type:"remove",ids:r}),Kt()),r},remove:e=>{const t=$e.current.remove(e);for(const t of e)ve.current.delete(t);return Ut({type:"remove",ids:e}),Kt(),t},restore:e=>{$e.current.restore(e),ve.current.clear(),St.current.clear(),Ut({type:"restore",snapshot:e},!1),Kt()},resume:()=>{pt.setPaused(!1),We.current=null,$e.current.setPaused(!1),Ut({type:"setPaused",paused:!1},!1),Kt()},settle:e=>{const t=$e.current.settle(e);return Ut({type:"settle",maxSteps:e}),Kt(),t},settleWithObservations:e=>{const t=$e.current.settleWithObservations(e);return Ut({type:"settle",maxSteps:e}),Kt(),t},step:e=>{const t=$e.current,n=t.tick(e);return pj({store:t,result:n,regionEffects:xe.current,regionState:ve.current,bodyForces:we.current,composed:Ae.current,onTick:ke.current}),Ut({type:"tick",deltaSeconds:e}),Ot(),n}}),[at,pt,Ot,Ut,Kt,zt]);const Zt=Hc||!yt&&ft,Jt=["stream-physics-frame",M?"stream-physics-frame--mode-"+M:null,C?"stream-physics-frame--emphasis-"+C:null,y].filter(Boolean).join(" "),en=A??("string"==typeof ue?ue:void 0)??"Physics chart",tn=Ve+"-physics-table",nn=Math.max(1,ht[0]-nt.left-nt.right),on=Math.max(1,ht[1]-nt.top-nt.bottom),rn=j&&vt?de?de(vt):(0,Hj.jsx)(Ej,{hover:vt}):null,sn=rn&&vt?(0,Hj.jsx)(uu,{x:vt.x-nt.left,y:vt.y-nt.top,containerWidth:nn,containerHeight:on,margin:nt,className:"stream-physics-tooltip",children:rn}):null;if(Zt){const e=$e.current??OM(ze,R,T),t="string"==typeof ue?ue:void 0,{svg:n}=function(e,t={}){const{width:n=640,height:o=360,title:r,description:i,background:s,backgroundGraphics:a,className:c,foregroundGraphics:l,idPrefix:u="physics",margin:d,renderBodySVG:h,...p}=t,m=YM(e,p),y={...XM,...d},f=[n,o],g=UM(a,f,y),b=UM(l,f,y),v=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(u),x=r?v+"-title":void 0,w=i?v+"-desc":void 0,k=[x,w].filter(Boolean).join(" ")||void 0;return{svg:zM.renderToStaticMarkup((0,VM.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:n,height:o,viewBox:`0 0 ${n} ${o}`,role:"img","aria-labelledby":k,children:[r&&(0,VM.jsx)("title",{id:x,children:r}),i&&(0,VM.jsx)("desc",{id:w,children:i}),!a&&s&&"transparent"!==s?(0,VM.jsx)("rect",{x:0,y:0,width:n,height:o,fill:s}):null,g,(0,VM.jsx)("g",{id:v+"-data-area",children:m.sceneNodes.map((e,t)=>{const n=m.bodies[t];return(n&&h?h(n,e.style??{},t,v):void 0)??zc(e,t,v)})}),b]})),scene:m,evidence:m.evidence}}(e,{width:ht[0],height:ht[1],title:t,description:A,background:a||"transparent"===s?void 0:s,backgroundGraphics:ct,className:"stream-physics-frame__svg",foregroundGraphics:lt,idPrefix:"physics-"+Ve,margin:nt});return(0,Hj.jsxs)("div",{ref:ut,className:Jt,"data-semiotic-mode":M,role:"img","aria-label":en,style:{width:ht[0],height:ht[1]},children:[(0,Hj.jsx)(El,{summary:ae}),(0,Hj.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}return(0,Hj.jsxs)("div",{ref:ut,className:Jt,"data-semiotic-mode":M,role:"group","aria-label":en,"aria-describedby":gt?At:void 0,tabIndex:0,style:{position:"relative",width:ht[0],height:ht[1]},onKeyDown:_t,children:["production"!==process.env.NODE_ENV&&$e.current&&(0,Hj.jsx)(fr,{store:$e.current,diagnostics:Ge.current}),n?(0,Hj.jsx)(Ol,{tableId:tn}):null,n?(0,Hj.jsx)(zj,{chartTitle:"string"==typeof ue?ue:en,items:Le,tableId:tn}):null,(0,Hj.jsx)(El,{summary:ae}),(0,Hj.jsx)(yl,{hoverPoint:vt}),(0,Hj.jsx)("div",{id:At,"aria-live":"polite","aria-atomic":"true",style:xj,children:gt?gt.description??gt.label:""}),(0,Hj.jsxs)("div",{role:"img","aria-label":en,style:{position:"relative",width:"100%",height:"100%"},children:[(0,Hj.jsx)(_u,{size:ht,margin:nt,children:ct}),(0,Hj.jsx)("canvas",{ref:Bt,width:ht[0],height:ht[1],"aria-hidden":"true",style:{position:"absolute",left:0,top:0,display:"block"},onPointerDown:Tt,onPointerMove:j?Rt:void 0,onPointerLeave:j?It:void 0}),lt,(0,Hj.jsx)(dC,{width:nn,height:on,totalWidth:ht[0],totalHeight:ht[1],margin:nt,title:ue,legend:_,legendPosition:E,legendLayout:B,legendHoverBehavior:N,legendClickBehavior:L,legendHighlightedCategory:D,legendIsolatedCategories:$,pointNodes:Lt,annotations:o,onAnnotationActivate:r,onObservation:z,chartId:m,chartType:Yj,autoPlaceAnnotations:i,svgAnnotationRules:le}),(0,Hj.jsx)(Hl,{active:null!=gt,hoverPoint:gt?{x:gt.x,y:gt.y}:null,margin:nt,size:ht,shape:gt?.shape,width:gt?.width,height:gt?.height,pathData:gt?.pathData}),sn]})]})}));Vj.displayName="StreamPhysicsFrame";var Xj=Vj;function Uj(e){const[t,n]=e,o=160>t||116>n,r=o?Math.min(12,Math.max(2,.08*t)):32,i=o?Math.min(8,Math.max(2,.12*n)):24,s=o?i:34;return{width:t,height:n,plot:{x:r,y:i,width:Math.max(1,t-2*r),height:Math.max(1,n-i-s)}}}function Kj(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 Qj(e,t="#4e79a7",n){const o=n?.styleRules,r=!!o&&o.length>0,i=r?Kp(n?.valueAccessor):void 0;return n=>{const s=n.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,c={fill:null==a?t:Kj(a),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&s&&Object.assign(c,tm(s,o,{value:i?i(s):void 0,category:null==a?void 0:a+""})),c}}function Zj(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 Jj(e,t,n){if(!e.length)return[];const o=Uj(t),r=o.plot.width/Math.max(1,e.length),i=Math.max(1,...e.map(e=>e.value)),s=.62*o.plot.height,a=o.plot.y+o.plot.height;return e.map((e,t)=>{const c=Math.max(8,e.value/i*s),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:a-c/2,shape:"rect",width:Math.max(12,.58*r),height:c,group:n}})}function eP(e,t,n){return"function"==typeof n?n(e,t):e[n]}function tP(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 nP(e,t,n){return Math.max(t,Math.min(n,e))}function oP(e,t){const n=tP(e);return null!=n&&n>0?n:t}function rP(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function iP(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}}var sP=require("d3-scale");function aP(e){const{data:t,valueAccessor:n,bins:o,ballRadius:r,seed:i,size:s,valueExtent:a}=e,c=Uj(s),l=t.map((e,t)=>tP(eP(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=tP(e[0]),n=tP(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),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=(0,sP.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),f=[];t.forEach((e,t)=>{const i=tP(eP(e,t,n));if(null==i)return;const s=Math.max(0,Math.min(o-1,Math.floor((i-d)/p*o)));y[s]+=1,f.push({id:(e.id??"galton-"+t)+"",x:m(s+.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:s}})});const g=c.plot.y+c.plot.height;return{config:Zj(i,[...xM({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...wM({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:m,yTop:c.plot.y-400,yBottom:g,wallThickness:6})],"GaltonBoardChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[d,h]}}}var cP=require("d3-scale");function lP(e){const{count:t,idPrefix:n,wallThickness:o,xScale:r,yBottom:i,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(i-1,a?.(t)??s),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)),s=Math.max(1,Math.floor(i/r));return{laneWidth:o,tubeWidth:i,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}function dP(e){const{data:t,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:i,seed:s,size:a}=e,c=oP(r,1),l=Uj(a),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((eP(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),f=uP(l.plot,y,i),g=Math.max(0,f.tubeWidth/2-i-1),b=u.map(()=>[]);t.forEach((e,t)=>{const r=(eP(e,t,n)??"unknown")+"",s=m(r),a=o?tP(eP(e,t,o)):1,u=Math.max(0,Math.round((a??0)/c)),d=f.centerX(s);for(let n=0;u>n;n+=1){const o=h.get(r)??0,a=f.perRow>1?((f.perRow>1?o%f.perRow:0)/(f.perRow-1)*2-1)*g:0;h.set(r,o+1),b[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,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=[...xM({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;y>e;e+=1){const t=f.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*f.tubeWidth/2,y:(k+x)/2,width:6,height:x-k}})}return{config:Zj(s,w,"UnitPileChart"),initialSpawns:p,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}var hP=require("d3-scale");function pP(e){const{data:t,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:i,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=Uj(a),h=iP(s),p=[],m=[],y=new Map;t.forEach((e,t)=>{const s=tP(eP(e,t,n));if(null==s)return;const a=o?(eP(e,t,o)??"All")+"":"All",c=r?tP(eP(e,t,r)):null,l=nP(null!=c&&c>0?c:i,2,18);!function(e){let t=y.get(e);null==t&&(t=m.length,m.push(e),y.set(e,t))}(a),p.push({datum:e,index:t,value:s,group:a,radius:l})});const f=p.map(e=>e.value),g=c?tP(c[0]):null,b=c?tP(c[1]):null,v=f.length?Math.min(...f):0,x=f.length?Math.max(...f):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=(0,hP.scaleLinear)().domain([w,k]).range([A,C]),j=Math.max(1,m.length),P=Math.min(Math.max(28,3*S),d.plot.height/4),I=d.plot.y+P,R=Math.max(0,d.plot.y+d.plot.height-P-I),T=e=>{const t=y.get(e)??0;return 1===j?d.plot.y+.54*d.plot.height:I+t/(j-1)*R},_=new Map,L=p.map((e,t)=>{_.set(e.group,(_.get(e.group)??0)+1);const n=M(e.value),o=T(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:nP(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:Zj(s,xM({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:_.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,C],groups:m.map(e=>({label:e,y:T(e),count:_.get(e)??0})),plot:d.plot}}}function mP(e){if(Array.isArray(e)&&e.length>=2){const t=tP(e[0]),n=tP(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=tP(t.x),o=tP(t.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function yP(e){return Array.isArray(e)?e.map(mP).filter(e=>null!=e):[]}function fP(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:nP(e.x,t.plot.x,t.plot.x+t.plot.width),y:nP(e.y,t.plot.y,t.plot.y+t.plot.height)}}function gP(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 bP(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=nP(t,0,1)*gP(e);let o=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],i=e[t],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>0){if(o+s>=n){const e=(n-o)/s;return{x:r.x+(i.x-r.x)*e,y:r.y+(i.y-r.y)*e}}o+=s}}return{...e[e.length-1]}}function vP(e,t){const n=bP(e,Math.max(0,t-.02)),o=bP(e,Math.min(1,t+.02)),r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i)||1;return{x:r/s,y:i/s}}function xP(e){const{coordinateMode:t,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:i,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:p,seed:m,size:y,sourceAccessor:f,targetAccessor:g,throughputAccessor:b}=e,v=Uj(y),x=iP(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=(eP(e,t,i)??e.id??t)+"",o=tP(eP(e,t,s)),r=tP(eP(e,t,a));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(eP(e,t,f)),o=A(eP(e,t,g)),r=Math.max(0,tP(eP(e,t,b))??0),i=yP(d?eP(e,t,d):void 0),s=i.length?i:yP(e.path??e.points??e.route);s.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:s})});const M=(P=S,"normalized"===(j=t)||"pixels"===j?j:P.length>0&&P.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var j,P;const I=new Map;for(const[e,t]of w)I.set(e,fP(t,v,M));const R=[];for(const e of C){let t=e.rawPath.map(e=>fP(e,v,M));if(2>t.length){const n=I.get(e.source),o=I.get(e.target);n&&o&&(t=[n,o])}else I.has(e.source)||I.set(e.source,t[0]),I.has(e.target)||I.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),R.push({...e,path:t,packetCount:0}))}const T=oP(u,.12),_=Math.max(1,Math.round(r)),L=R.map(e=>Math.max(1,Math.round(e.throughput*T))),D=L.reduce((e,t)=>e+t,0),N=D>_?_/D:1;R.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(L[t]*N))});let $=R.reduce((e,t)=>e+t.packetCount,0);for(;$>_;){const e=R.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>R[e].packetCount)?n:e,-1);if(-1===e)break;R[e].packetCount-=1,$-=1}const B=new Map,E=new Map,O=[],F=oP(n,90),z=oP(l,4);R.forEach((e,t)=>{B.set(e.target,(B.get(e.target)??0)+e.throughput),E.set(e.source,(E.get(e.source)??0)+e.throughput);const n=gP(e.path);for(let o=0;e.packetCount>o;o+=1){const r=(o+.5)/e.packetCount,i=p?r:nP(.12+.84*r+.04*(x()-.5),.04,.98),s=p?i:Math.max(0,i-(.18+.12*x())),a=bP(e.path,s),c=bP(e.path,i),l=vP(e.path,s),u={x:-l.y,y:l.x},d=(x()-.5)*z*1.5;O.push({id:`${e.id}-packet-${o}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:p?0:l.x*F+10*(x()-.5),vy:p?0:l.y*F+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:F,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(I,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+rP(e),point:t})),q=W.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:H,height:H}})),G=Object.fromEntries(W.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),Y=Zj(m,[...xM({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{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=_,Y.eviction="oldest",Y.observation={...Y.observation,sensors:G};const V=Array.from(I,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+rP(e),incoming:B.get(e)??0,outgoing:E.get(e)??0})),X=R.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:O,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:O.length,totalThroughput:R.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:X}}}function wP(e,t,n){return Math.max(t,Math.min(n,e))}function kP(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 SP(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 AP(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...SP({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function CP(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 MP(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,o=Uj(n),r=nP(e.ballRadius??6,2,18),i=e.seed??1,s=iP(i),a=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,y=e.springDamping??.72,f=!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,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=wP(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,y=wP(d*h+m,.06*d,.5*d),f=y/2,g=u-f,b=u+f,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=wP(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=a-s;let j=s;const P=S.map((e,t)=>{const n=j,o=t===S.length-1?a:j+(e.share??1)/C*M;return j=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}}),I=P[A],R=I.x0,T=I.x1,_=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=wP((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(g-c)*t:l+(b-l)*t}if(R>=e){const t=wP((e-s)/Math.max(1,R-s),0,1);return"top"===n?c+(g-c)*t:l+(b-l)*t}if(T>=e)return"top"===n?g:b;const o=wP((e-T)/Math.max(1,a-T),0,1);return"top"===n?g+(c-g)*o:b+(l-b)*o},L=P.map(e=>{const t=Math.min(_(e.x0,"top"),_(e.x1,"top")),n=Math.max(_(e.x0,"bottom"),_(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),D={thickness:k,friction:x,restitution:w},N=[];"lane"===t?N.push(kP(v+"-top",s,c,a,c,D),kP(v+"-bottom",s,l,a,l,D),kP(v+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),kP(v+"-right",a,c,a,l,{...D,thickness:Math.max(6,k)})):"funnel"===t?N.push(kP(v+"-top",s,c,a,g,D),kP(v+"-bottom",s,l,a,b,D),kP(v+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),kP(v+"-right",a,g,a,b,{...D,thickness:Math.max(6,k)})):N.push(kP(v+"-left-top",s,c,R,g,D),kP(v+"-left-bottom",s,l,R,b,D),kP(v+"-center-top",R,g,T,g,D),kP(v+"-center-bottom",R,b,T,b,D),kP(v+"-right-top",T,g,a,c,D),kP(v+"-right-bottom",T,b,a,l,D),kP(v+"-left",s,c,s,l,{...D,thickness:Math.max(6,k-2)}),kP(v+"-right",a,c,a,l,{...D,thickness:Math.max(6,k)}));const $=e.membraneDampingScale??.5,B=s,E=Math.max(1,("bowtie"===t?R:a)-B),O=(e.membranes??[]).map(e=>{const t=B+wP(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}}),F=!1===e.includeMembraneRegions?[]:O.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=wP(e.cost,0,2);return{...SP({...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??$,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:R,centerRight:T,pinchHeight:y,pinchTop:g,pinchBottom:b,stages:L,membranes:O,colliders:N,regionEffects:F,boundaryY:_}}({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{...SP({...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:CP(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:CP(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...SP({...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{...SP({...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:CP(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{...SP({...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:CP(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?AP({...n,kind:e.kind??"force-field",force:CP(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...SP({...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(AP({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=(a?eP(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",o=(eP(e,t,c)??w)+"",i=v.has(o)?o:w;C.set(i,(C.get(i)??0)+1);const s=l?(eP(e,t,l)??"")+"":void 0,p=s&&u?(eP(e,t,u)??s)+"":s,m=d?tP(eP(e,t,d))??1:1,y=h?tP(eP(e,t,h)):null,f=nP(null!=y&&y>0?y:r,2,18);M.push({datum:e,id:n,stageId:i,groupId:s||void 0,groupLabel:p||void 0,work:m,radius:f,index:t})});const j=new Map,P=new Map;for(const e of M){if(!e.groupId)continue;const t=j.get(e.groupId)??[];t.push(e.id),j.set(e.groupId,t),e.groupLabel&&P.set(e.groupId,e.groupLabel)}const I=nP(e.groupAnchorAlong??.55,.15,.9),R=b.left+(b.right-b.left)*I,T=Array.from(j.keys()),_=T.map((e,n)=>{const o=j.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:P.get(e)??e,bodyIds:o,anchor:{x:R,y:r},x:R,y:r,completion:"allAbsorbed"===p?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),L=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",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(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}})}(_,M.filter(e=>S.has(e.stageId)).map(e=>e.id)),D=new Map(_.map(e=>[e.id,e])),N=M.map((e,t)=>{const n=x.get(e.stageId)??k,o=n.x+(s()-.5)*Math.min(24,.2*n.width),r=b.boundaryY(o,"top")+e.radius+10,i=b.boundaryY(o,"bottom")-e.radius-10,a=i>r?r+s()*Math.max(1,i-r):b.midY,c=f?o:b.left+18+t%7*4,l=f?a:b.midY+(s()-.5)*(b.bottomY-b.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*e.radius,stiffness:m,damping:y}];if(e.groupId){const t=D.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:f?0:40+40*s(),vy:f?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:f?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}}}),$={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},B=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:$,initialSpawns:N,initialSpawnPacing:f?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:B,metadata:{kind:"process-flow",plot:o.plot,volume:b,stages:E,groups:_,groupCompletion:L,regionEffects:A}}}var jP=require("react");function PP(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 IP(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 RP(e,t){const n=e?.getData().find(e=>e.id===t),o=n?.datum;if(o&&"object"==typeof o)return o}function TP(e,t){const{frameRef:n,spawnDatum:o,seedRows:r,idAccessor:i,bodyIdsForSeed:s,seedSpawns:a}=t,c=(0,jP.useRef)(new Map),l=(0,jP.useRef)(new Map),u=(0,jP.useRef)(""),d=r?r.map((e,t)=>IP(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=IP(t,e,i);c.current.set(n,t),l.current.set(n,s?.(t,n,e)??PP(n,a))}(0,jP.useImperativeHandle)(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=o(e,t);return{datumId:n.datumId||IP(e,t,i),spawns:n.spawns.map(e=>({...e,spawnAt:void 0}))}}function s(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 a(o){const r=e.get(o);if(r)return r;const i=t.get(o)??[o];for(const r of i){const i=RP(n.current,r);if(i)return e.set(o,i),t.has(o)||t.set(o,[r]),i}}return{push:t=>{s([{datum:t,result:r(t,e.size)}])},pushMany:t=>{const n=e.size;s(t.map((e,t)=>({datum:e,result:r(e,n+t)})))},remove:o=>{const r=Array.isArray(o)?o:[o],i=[],s=[];for(const n of r){const o=a(n);o&&i.push(o),e.delete(n),s.push(...t.get(n)??[n]),t.delete(n)}return s.length&&n.current?.remove(s),i},update:(o,i)=>{const c=Array.isArray(o)?o:[o],l=[];for(const o of c){const c=a(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);s([{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])}var _P=require("react"),LP=require("react/jsx-runtime");function DP(e){return!!e&&"string"==typeof e.name}function NP(e,t=!1){if(!e?.datum)return null;const n=e.datum,o=n.sourceDatum;return t&&o&&"object"==typeof o?o:n}function $P(e){const{selection:t,linkedHover:n,colorBy:o,chartType:r,chartId:i,onBodyHover:s,fallbackFields:a,unwrapSourceDatum:c}=e,l="string"==typeof o?o:void 0,u=DP(t)?t:void 0,{activeSelectionHook:d,customHoverBehavior:h}=xp({selection:u,linkedHover:n,fallbackFields:l?[l]:a,onObservation:e.onObservation,onClick:e.onClick,chartType:r,chartId:i,colorByField:l}),p=DP(t)?null:t??null,m=(0,_P.useMemo)(()=>{if(p)return p;if(!d?.isActive)return null;const e=d.predicate;return{isActive:!0,predicate:t=>{const n=NP(t,c);return null!=n&&e(n)}}},[d?.isActive,d?.predicate,p,c]),y=(0,_P.useMemo)(()=>{if(n||s)return(e,t)=>{if(s?.(e,t),!n)return;const o=NP(e,c);h(o&&t?{...t,data:o}:null)}},[h,s,n,c]);return(0,_P.useMemo)(()=>({selection:m,onBodyHover:y}),[y,m])}var BP=new Set(["sample","mechanical"]);function EP(e,t,n,o){const[r,i]=(0,_P.useState)(0),s=(0,_P.useRef)(null),a=(0,_P.useRef)(!1),c=function(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:null}(t),l=(0,_P.useRef)(c),u=(0,_P.useRef)(!!n),d=(0,_P.useRef)(o);l.current=c,u.current=!!n,d.current=o;const h=(0,_P.useCallback)(()=>{null!=s.current&&(clearTimeout(s.current),s.current=null)},[]),p=(0,_P.useCallback)(()=>{h();const e=l.current;null!=e&&!u.current&&a.current&&(s.current=setTimeout(()=>{s.current=null,a.current=!1,d.current?.(),i(e=>e+1)},e))},[h]);(0,_P.useEffect)(()=>{null==c||n?h():a.current&&p()},[h,c,n,p]),(0,_P.useEffect)(()=>h,[h]);const m=e?.observation?.onSimulationStateChange,y=(0,_P.useCallback)((e,t)=>{if(m?.(e,t),"running"===e)return a.current=!1,void h();"settled"===e&&"running"===t&&(a.current=!0,p())},[h,m,p]);return{config:(0,_P.useMemo)(()=>null==c?e:{...e,observation:{...e?.observation,onSimulationStateChange:y}},[e,c,y]),rerunKey:r}}function OP(e,t,n){const o=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&BP.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=kp(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],s=e.size?.[1],a=t[0],c=t[1],l=(0,_P.useMemo)(()=>{return e=[a,c],(null!=i&&null!=s?[i,s]:void 0)??[r.width??e[0],r.height??e[1]];var e},[c,a,r.height,r.width,s,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=WP(e.tooltip,void 0),m=void 0!==p.enableHover?p.enableHover:r.enableHover,y=r.compactMode?r.title:r.title??e.title,f=[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:y,description:r.description??e.description,summary:r.summary??e.summary,accessibleTable:r.accessibleTable??e.accessibleTable,className:f,compactMode:r.compactMode,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics}}function FP(e){const[t,n]=e.size;return Dp(e.loading,t,n,e.loadingContent)||Lp(e.data,t,n,e.emptyContent)}function zP(e,t,n){return(0,LP.jsx)(Rp,{componentName:e,width:t[0],height:t[1],children:n})}function HP(e,t){return e?t?n=>(0,LP.jsxs)(LP.Fragment,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function WP(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:cu(e)||t?.tooltipContent}}function qP(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,maxDevicePixelRatio:e.maxDevicePixelRatio??t?.maxDevicePixelRatio,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,selection:o?.selection??t?.selection,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}}var GP=require("react/jsx-runtime"),YP=(0,YA.forwardRef)(function(e,t){const{data:n,valueAccessor:o="value",styleRules:r,bins:i=21,ballRadius:s,colorBy:a,branchProbability:c=.5,emptyContent:l,frameProps:u,loading:d,loadingContent:h,mechanicalCount:p,paused:m,pegRows:y,referenceLines:f,rerunMS:g,responsiveHeight:b,responsiveWidth:v,seed:x=1,valueExtent:w}=e,k=OP(e,[700,420],{hasSimulationMode:!0}),{chartSize:S,simulationMode:A,showProjection:C,className:M,title:j,chartMode:P,margin:I,enableHover:R,description:T,summary:_,accessibleTable:L}=k,D=s??("sparkline"===P?1.5:"context"===P?4:6),N=(0,YA.useRef)(null),$=Math.max(1,Math.round(y??i-1)),B=(0,YA.useMemo)(()=>"mechanical"===A?[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}(w),[$,A,w]),E=(0,YA.useMemo)(()=>"mechanical"===A?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=nP(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=iP(e.seed??1),s=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 a=n/2;return{id:`${s}-${t}`,value:o,mechanical:!0,pegRows:n,branchProbability:r,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:i,branchProbability:c,count:p,pegRows:$,seed:x}):n??[],[i,c,n,p,$,x,A]),O=(0,YA.useMemo)(()=>aP({data:E,valueAccessor:o,bins:i,ballRadius:D,seed:x,size:S,valueExtent:B}),[i,E,S,D,B,x,o]),F=EP(O.config,g,m);TP(t,{frameRef:N,spawnDatum:(0,YA.useCallback)((e,t)=>{const n=aP({data:[e],valueAccessor:o,bins:i,ballRadius:D,seed:x+t+1,size:S,valueExtent:B}).initialSpawns[0]??{id:(e.id??"galton-push-"+t)+"",x:Uj(S).plot.x,y:Uj(S).plot.y,mass:1,shape:{type:"circle",radius:D},datum:e};return{datumId:(e.id??n.id)+"",spawns:[n]}},[i,S,D,B,x,o]),seedRows:E,seedSpawns:O.initialSpawns});const z="mechanical"===A&&null==a?"side":a,H=(0,YA.useMemo)(()=>Qj(z,"#4e79a7",{styleRules:r,valueAccessor:o}),[z,r,o]),W=(0,YA.useMemo)(()=>Jj(O.projectionRows,S,"bin"),[S,O.projectionRows]),{selection:q,onBodyHover:G}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:a,chartType:"GaltonBoardChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:u?.onBodyHover,fallbackFields:"string"==typeof o?[o]:void 0}),Y=FP({data:"mechanical"===A?E:n,emptyContent:l,loading:d,loadingContent:h,size:S});if(Y)return Y;const V=function(e,t,n,o,r){const i=Array.isArray(r)?r:r?[r]:[];if(!1!==n||0!==i.length)return({size:r})=>{const s=[Number(r[0])||700,Number(r[1])||420],a=Uj(s),c=Math.max(2,Math.round(t)),l=a.plot.width/c,u=a.plot.y+a.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==n,[p,m]=o?.valueExtent??[0,c],y=m===p?1:m-p,f=e.map((e,t)=>{const n=u-e.value/d*a.plot.height*.9;return`${0===t?"M":"L"} ${(a.plot.x+(t+.5)*l).toFixed(1)} ${n.toFixed(1)}`}).join(" ");return(0,GP.jsxs)("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:s[0],height:s[1],viewBox:`0 0 ${s[0]} ${s[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?(0,GP.jsxs)(GP.Fragment,{children:[Array.from({length:c+1},(e,t)=>{const n=a.plot.x+t*l;return(0,GP.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:n,x2:n,y1:a.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),(0,GP.jsx)("line",{x1:a.plot.x,x2:a.plot.x+a.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,GP.jsx)("path",{d:f,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?(0,GP.jsx)("text",{x:a.plot.x+(t+.5)*l,y:Math.max(a.plot.y+10,u-e.value/d*a.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=a.plot.x+Math.max(0,Math.min(1,(n-p)/y))*a.plot.width,r=e.color??"var(--semiotic-warning, #f28e2b)",i="bottom"===e.labelPosition?Math.min(s[1]-8,u+16):a.plot.y+16;return(0,GP.jsxs)("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[(0,GP.jsx)("line",{x1:o,x2:o,y1:a.plot.y+8,y2:u-4,stroke:r,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:(0,GP.jsx)("text",{x:Math.min(a.plot.x+a.plot.width-4,o+6),y:i,fill:r,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${n}`)})]})}}(O.projectionRows,i,C,O.metadata,f),X=WP(e.tooltip,u),U=qP(e,u,W,{selection:q,chartMode:P,className:M,title:j,description:T,summary:_,accessibleTable:L,enableHover:R,margin:I});return zP("GaltonBoardChart",S,(0,GP.jsx)(Xj,{...u,...X,...U,ref:N,onBodyHover:G,config:F.config,foregroundGraphics:HP(V,u?.foregroundGraphics),initialSpawns:O.initialSpawns,initialSpawnPacing:O.initialSpawnPacing,paused:m,responsiveHeight:b,responsiveWidth:v,size:S,bodyStyle:H},F.rerunKey))}),VP=require("react"),XP=require("react/jsx-runtime"),UP=require("react"),KP=(0,VP.forwardRef)(function(e,t){const{arrivalAccessor:n="arrivalTime",ballRadius:o=7,colorBy:r,styleRules:i,data:s,emptyContent:a,frameProps:c,loading:l,loadingContent:u,paused:d,rerunMS:h,responsiveHeight:p,responsiveWidth:m,seed:y=1,timeAccessor:f="time",timeExtent:g,timeScale:b=1,watermark:v,windows:x={size:10}}=e,w=OP(e,[760,360]),{chartSize:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:P,description:I,summary:R,accessibleTable:T}=w,_=(0,VP.useRef)(null),L=(0,VP.useMemo)(()=>s??[],[s]),D=(0,VP.useMemo)(()=>function(e){const{data:t,timeAccessor:n,arrivalAccessor:o,windows:r,watermark:i,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=Uj(c),h=t.map((e,t)=>tP(eP(e,t,n))).filter(e=>null!=e),p=tP(l?.[0]),m=tP(l?.[1]),y=h.length?Math.min(...h):0,f=h.length?Math.max(...h):y+r.size,g=Math.min(p??y,y),b=Math.max(m??f,f),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):tP(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,s),C=v+x*r.size,M=(0,cP.scaleLinear)().domain([v,C]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),j=Array.from({length:x},()=>({value:0,secondary:0})),P=[];t.forEach((e,t)=>{const i=tP(eP(e,t,n));if(null==i)return;const a=tP(eP(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;j[c].value+=l?0:1,j[c].secondary+=l?1:0,P.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,M(i))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:a,windowIndex:c,late:l}})});const I=d.plot.y+d.plot.height,R=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=(0,cP.scaleLinear)().domain([o,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=i(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(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),s=i(o);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}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:Zj(a,[...xM({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...lP({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?R[0]?.y1:R[e-1]?.y2??R[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:I,wallThickness:6}),...R.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*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:P,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:j.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:R,lateCount:j.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:x,watermark:v,ballRadius:o,seed:y,size:k,timeExtent:g,timeScale:b}),[n,o,k,L,y,f,g,b,v,x]),N=EP(D.config,h,d),$=D.metadata;TP(t,{frameRef:_,spawnDatum:(0,VP.useCallback)((e,t)=>{const r=$?function(e,t,n,o){const r=tP(eP(e,t,o.timeAccessor));if(null==r)return null;const i=tP(eP(e,t,o.arrivalAccessor))??r,{windowPlot:s,windowStart:a,windowCount:c,windowSize:l,watermarkValue:u}=n,d=a+c*l,h=(0,cP.scaleLinear)().domain([a,d]).range([s.x,s.x+s.width]),p=Math.max(0,Math.min(c-1,Math.floor((r-a)/l))),m=u>=a+(p+1)*l,{ballRadius:y}=o;return{id:(e.id??"event-push-"+t)+"",x:Math.max(s.x+y,Math.min(s.x+s.width-y,h(r))),y:s.y+y+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,shape:{type:"circle",radius:y},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:Uj(k).plot.x,y:Uj(k).plot.y,mass:1,shape:{type:"circle",radius:o},datum:e};return{datumId:(e.id??i.id)+"",spawns:[i]}},[n,o,k,$,f]),seedRows:L,seedSpawns:D.initialSpawns});const B=(0,VP.useMemo)(()=>Qj(r,"#4e79a7",{styleRules:i,valueAccessor:f}),[r,i,f]),E=(0,VP.useMemo)(()=>function(e,t,n){if(!t)return Jj(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,s=t.windowPlot.y+t.windowPlot.height;return e.map((e,n)=>{const a=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:s-a/2,shape:"rect",width:Math.max(12,.58*o),height:a,group:"window"}})}(D.projectionRows,$,k),[k,D.projectionRows,$]),{selection:O,onBodyHover:F}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:r,chartType:"EventDropChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:c?.onBodyHover,fallbackFields:"string"==typeof f?[f]:void 0}),z=FP({data:s,emptyContent:a,loading:l,loadingContent:u,size:k});if(z)return z;const H=function(e,t,n){if(!1!==n&&t)return({size:n})=>{const o=[Number(n[0])||760,Number(n[1])||360],r=Uj(o),i=Math.max(1,t.windowCount),s=t.plot??r.plot,a=t.gutter??{x:s.x,y:s.y,width:0,height:s.height},c=t.windowPlot??s,l=c.width/i,u=s.y+s.height,d=s.y+.48*s.height,h=t.lidSegments[0]?.y1??d,p=t.windowStart,m=t.windowStart+i*t.windowSize,y=c.x+Math.max(0,Math.min(1,m===p?0:(t.watermarkValue-p)/(m-p)))*c.width;return(0,XP.jsxs)("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:[(0,XP.jsx)("rect",{x:s.x,y:s.y,width:s.width,height:s.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),a.width>0?(0,XP.jsxs)("g",{children:[(0,XP.jsx)("rect",{x:a.x,y:h,width:a.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.55,strokeWidth:1}),(0,XP.jsx)("text",{x:a.x+a.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:"gutter"})]}):null,Array.from({length:i},(n,r)=>{const i=e[r],s=c.x+r*l,a=t.closedWindowCount>r,h=i?.secondary??0;return(0,XP.jsxs)("g",{children:[(0,XP.jsx)("rect",{x:s,y:d,width:l,height:u-d,fill:a?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:a?.08:.06,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.68,strokeWidth:1}),a?t.lidSegments.filter(e=>e.windowIndex===r).map(e=>(0,XP.jsx)("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,(0,XP.jsxs)("text",{x:s+l/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:[i?.value??0,h?` / ${h} late`:""]}),(0,XP.jsx)("text",{x:s+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=>(0,XP.jsx)("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),(0,XP.jsx)("line",{x1:s.x,x2:s.x+s.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,XP.jsx)("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:s.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),(0,XP.jsxs)("text",{x:Math.min(s.x+s.width-4,y+6),y:s.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]}),t.lateCount>0?(0,XP.jsxs)("text",{x:a.x+a.width/2,y:s.y+32,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]}):null]})}}(D.projectionRows,D.metadata,S),W=WP(e.tooltip,c),q=qP(e,c,E,{selection:O,chartMode:M,className:A,title:C,description:I,summary:R,accessibleTable:T,enableHover:P,margin:j});return zP("EventDropChart",k,(0,UP.createElement)(Xj,{...c,...W,...q,ref:_,onBodyHover:F,key:N.rerunKey,config:N.config,foregroundGraphics:HP(H,c?.foregroundGraphics),initialSpawns:D.initialSpawns,initialSpawnPacing:D.initialSpawnPacing,paused:d,responsiveHeight:p,responsiveWidth:m,size:k,bodyStyle:B}))}),QP=require("react"),ZP=require("d3-scale");function JP(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 eI(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=wf(e.colorScheme,e.themeCategorical,Zt),o=Uj(e.size),r={data:e.data,scales:{x:(0,ZP.scaleLinear)().domain(e.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,ZP.scaleLinear)().domain(e.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:kf(n,e.colorScheme),config:e.layoutConfig??{},world:new EM(t)},i=e.skipLayout?{}:e.layout(r)??{},s=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:JP(t,i),context:r,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:s,result:i}}var tI=require("react/jsx-runtime"),nI=(0,QP.forwardRef)(function(e,t){const{chartId:n,color:o,colorBy:r,colorScheme:i,config:s,controllers:a,data:c,emptyContent:l,frameProps:u={},layout:d,layoutConfig:h,loading:p,loadingContent:m,onObservation:y,opacity:f,paused:g,spawnDatum:b,stroke:v,strokeWidth:x,title:w,xExtent:k,yExtent:S}=e,A=OP(e,[700,380]),{chartSize:C,className:M,title:j,chartMode:P,margin:I,enableHover:R,description:T,summary:_,accessibleTable:L}=A,D=(0,QP.useRef)(null),N=(0,QP.useRef)(null),$=(0,QP.useRef)(""),{selection:B,onBodyHover:E}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:r,chartType:"PhysicsCustomChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:u?.onBodyHover}),O=FP({data:c,emptyContent:l,loading:p,loadingContent:m,size:C}),F=null!=O,z=(0,QP.useMemo)(()=>ft(c??[]),[c]),H=Et(e=>e.theme),W=(0,QP.useMemo)(()=>Rt(H)??{},[H]),q=H?.colors?.categorical??Lt.colors.categorical,G=(0,QP.useMemo)(()=>[C[0],C[1],z.length,z.map((e,t)=>(e.id??t)+"").join("|"),k?.join(",")??"",S?.join(",")??""].join("::"),[C,z,k,S]),Y=(0,QP.useMemo)(()=>eI({chartId:n,colorScheme:i,config:s,data:z,layout:d,layoutConfig:h,onObservation:y,semantic:W,skipLayout:F,size:C,themeCategorical:q,xExtent:k,yExtent:S}),[n,C,i,s,d,h,y,z,W,F,q,k,S]);$.current===G&&null!=N.current||($.current=G,N.current=Y.initialSpawns);const V=N.current,X=(0,QP.useMemo)(()=>{const e=[...Y.result.controllers??[],...a??[],...u.controllers??[]];return e.length?e:void 0},[u.controllers,a,Y.result.controllers]),U=(0,QP.useMemo)(()=>{const e=[...Y.result.regionEffects??[],...u.regionEffects??[]];return e.length?e:void 0},[u.regionEffects,Y.result.regionEffects]),K=(0,QP.useCallback)(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??Y.context.resolveColor(n,t),stroke:v??"#111827",strokeWidth:x??1,opacity:f??.9}},[o,r,f,Y.context,v,x]);TP(t,{frameRef:D,spawnDatum:(0,QP.useCallback)((e,t)=>{const o=e;if(b)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,b(o,t,Y.context));const r=eI({chartId:n,colorScheme:i,config:s,data:[o],layout:d,layoutConfig:h,onObservation:y,semantic:W,size:C,themeCategorical:q,xExtent:k,yExtent:S}),a=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??a[0].id)+"",spawns:a}},[n,C,i,s,b,d,h,y,Y.context,W,q,k,S]),seedRows:z,seedSpawns:V});const Q=(0,QP.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]);if(O)return O;const Z=WP(e.tooltip,u),J=qP(e,u,Y.result.semanticItems,{selection:B,chartMode:P,className:M,title:j??w,description:T,summary:_,accessibleTable:L,enableHover:R,margin:I});return zP("PhysicsCustomChart",C,(0,tI.jsx)(Xj,{...u,...Z,...J,ref:D,onBodyHover:E,backgroundGraphics:HP(u.backgroundGraphics,Y.result.backgroundOverlays),bodyForces:Y.result.bodyForces??u.bodyForces,bodyStyle:Y.result.bodyStyle??u.bodyStyle??K,config:Y.config,controllers:X,foregroundGraphics:HP(u.foregroundGraphics,Y.result.overlays),initialSpawnPacing:Y.initialSpawnPacing,initialSpawns:V,onBodyPointerDown:Q,paused:g,regionEffects:U,responsiveHeight:e.responsiveHeight,responsiveWidth:e.responsiveWidth,selectedBodyStyle:Y.result.selectedBodyStyle??u.selectedBodyStyle,size:C}))});nI.displayName="PhysicsCustomChart";var oI=require("react"),rI=require("react/jsx-runtime"),iI=require("react"),sI=(0,oI.forwardRef)(function(e,t){const{ballRadius:n=8,categoryAccessor:o="category",colorBy:r,data:i,emptyContent:s,frameProps:a,loading:c,loadingContent:l,mechanicalCategories:u,mechanicalCount:d,paused:h,rerunMS:p,responsiveHeight:m,responsiveWidth:y,seed:f=1,unitValue:g=1,valueAccessor:b,styleRules:v}=e,x=OP(e,[700,380],{hasSimulationMode:!0}),{chartSize:w,simulationMode:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:P,description:I,summary:R,accessibleTable:T}=x,_=(0,oI.useRef)(null),L="mechanical"===k&&null==b?"value":b,D=(0,oI.useMemo)(()=>"mechanical"===k?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=oP(e.unitValue,1),i=iP(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*i()),c=a.reduce((e,t)=>e+t,0)||1,l=o-n.length,u=a.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:`${s}-${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:g}):i??[],[i,u,d,f,k,g]),N=(0,oI.useMemo)(()=>dP({data:D,categoryAccessor:o,valueAccessor:L,unitValue:g,ballRadius:n,seed:f,size:w}),[n,o,w,D,L,f,g]),$=EP(N.config,p,h);TP(t,{frameRef:_,spawnDatum:(0,oI.useCallback)((e,t)=>{const r=dP({data:[e],categoryAccessor:o,valueAccessor:L,unitValue:g,ballRadius:n,seed:f+t+1,size:w}),i={id:(e.id??"pile-push-"+t)+"",x:Uj(w).plot.x,y:Uj(w).plot.y,mass:1,shape:{type:"circle",radius:n},datum:e},s=r.initialSpawns.length?r.initialSpawns:[i];return{datumId:(e.id??s[0].id)+"",spawns:s}},[n,o,w,L,f,g]),seedRows:D,seedSpawns:N.initialSpawns});const B="mechanical"===k&&null==r?"category":r,E=(0,oI.useMemo)(()=>Qj(B,"#4e79a7",{styleRules:v,valueAccessor:b}),[B,v,b]),O=(0,oI.useMemo)(()=>Jj(N.projectionRows,w,"category"),[w,N.projectionRows]),{selection:F,onBodyHover:z}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:r,chartType:"UnitPileChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:a?.onBodyHover,fallbackFields:"string"==typeof o?[o]:void 0}),H=FP({data:"mechanical"===k?D:i,emptyContent:s,loading:c,loadingContent:l,size:w});if(H)return H;const W=function(e,t,n){if(!1!==n&&0!==e.length)return({size:n})=>{const o=[Number(n[0])||700,Number(n[1])||380],r=Uj(o),i=uP(r.plot,e.length,t),s=r.plot.y+r.plot.height;return(0,rI.jsxs)("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:[(0,rI.jsx)("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{const n=Math.min(r.plot.height,i.pileHeight(e.value)),a=i.tubeWidth,c=i.centerX(t),l=s-n;return(0,rI.jsxs)("g",{children:[(0,rI.jsx)("rect",{x:c-a/2,y:l,width:a,height:n,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),(0,rI.jsx)("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}),(0,rI.jsx)("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)})]})}}(N.projectionRows,n,S),q=WP(e.tooltip,a),G=qP(e,a,O,{selection:F,chartMode:M,className:A,title:C,description:I,summary:R,accessibleTable:T,enableHover:P,margin:j});return zP("UnitPileChart",w,(0,iI.createElement)(Xj,{...a,...q,...G,ref:_,onBodyHover:z,key:$.rerunKey,config:$.config,foregroundGraphics:HP(W,a?.foregroundGraphics),initialSpawns:N.initialSpawns,initialSpawnPacing:N.initialSpawnPacing,paused:h,responsiveHeight:m,responsiveWidth:y,size:w,bodyStyle:E}))}),aI=require("react"),cI=require("react/jsx-runtime");function lI(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}var uI=(0,aI.forwardRef)(function(e,t){const{colorBy:n,styleRules:o,collisionIterations:r,data:i,emptyContent:s,frameProps:a,groupAccessor:c,loading:l,loadingContent:u,paused:d,pointRadius:h,radiusAccessor:p,rerunMS:m,responsiveHeight:y,responsiveWidth:f,seed:g=1,settle:b,xAccessor:v="x",xExtent:x}=e,w=OP(e,[700,360]),{chartSize:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:P,description:I,summary:R,accessibleTable:T}=w,_=h??("sparkline"===M?2:"context"===M?4:5),L=(0,aI.useRef)(null),D=(0,aI.useMemo)(()=>i??[],[i]),N=(0,aI.useMemo)(()=>pP({data:D,xAccessor:v,groupAccessor:c,radiusAccessor:p,pointRadius:_,seed:g,size:k,xExtent:x,collisionIterations:r,settle:b}),[D,k,r,c,_,p,g,b,v,x]),$=EP(N.config,m,d);TP(t,{frameRef:L,spawnDatum:(0,aI.useCallback)((e,t)=>{const n=pP({data:[e],xAccessor:v,groupAccessor:c,radiusAccessor:p,pointRadius:_,seed:g+t+1,size:k,xExtent:x,collisionIterations:r,settle:b}).initialSpawns[0]??{id:(e.id??"collision-swarm-push-"+t)+"",x:Uj(k).plot.x,y:Uj(k).plot.y,mass:1,shape:{type:"circle",radius:_},datum:e};return{datumId:(e.id??n.id)+"",spawns:[n]}},[k,r,c,_,p,g,b,v,x]),seedRows:D,seedSpawns:N.initialSpawns});const B=n??c,E=(0,aI.useMemo)(()=>Qj(B,"#4e79a7",{styleRules:o,valueAccessor:v}),[B,o,v]),{selection:O,onBodyHover:F}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:B,chartType:"CollisionSwarmChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:a?.onBodyHover,fallbackFields:"string"==typeof v?[v]:void 0}),z=FP({data:i,emptyContent:s,loading:l,loadingContent:u,size:k});if(z)return z;const H=function(e,t){if(!1!==t&&e)return({size:t})=>{const n=[Number(t[0])||700,Number(t[1])||360],o=Uj(n),r=o.plot.y+o.plot.height,[i,s]=e.xExtent,a=i+(s-i)/2,c=[{label:lI(i),x:e.xRange[0]},{label:lI(a),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:lI(s),x:e.xRange[1]}];return(0,cI.jsxs)("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=>(0,cI.jsxs)("g",{children:[(0,cI.jsx)("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}),(0,cI.jsx)("text",{x:o.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),(0,cI.jsxs)("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)),(0,cI.jsx)("line",{x1:e.xRange[0],x2:e.xRange[1],y1:r,y2:r,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),c.map(e=>(0,cI.jsxs)("g",{children:[(0,cI.jsx)("line",{x1:e.x,x2:e.x,y1:r,y2:r+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),(0,cI.jsx)("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,S),W=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),q=WP(e.tooltip,a),G=qP(e,a,W,{selection:O,chartMode:M,className:A,title:C,description:I,summary:R,accessibleTable:T,enableHover:P,margin:j});return zP("CollisionSwarmChart",k,(0,cI.jsx)(Xj,{...a,...q,...G,ref:L,onBodyHover:F,config:$.config,foregroundGraphics:HP(H,a?.foregroundGraphics),initialSpawns:N.initialSpawns,paused:d,responsiveHeight:y,responsiveWidth:f,size:k,bodyStyle:E},$.rerunKey))}),dI=require("react");function hI(e){return e.toLocaleString(void 0,1e3>Math.abs(e)?{maximumFractionDigits:1}:{maximumFractionDigits:0})}function pI(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}var mI=require("react/jsx-runtime"),yI=require("react");function fI(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 gI(e){if(!e||"object"!=typeof e)return[];const t=e.flowPath;return Array.isArray(t)?t.map(fI).filter(e=>null!=e):[]}function bI(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 s=1;t.length>s;s+=1){const a=t[s-1],c=t[s],l=o[s-1];if(0>=l)continue;const u=c.x-a.x,d=c.y-a.y,h=Math.max(0,Math.min(1,((e.x-a.x)*u+(e.y-a.y)*d)/(l*l))),p={x:a.x+u*h,y:a.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 vI(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],s=Math.hypot(i.x-n.x,i.y-n.y);if(s>0){if(o+s>=r){const e=(r-o)/s;return{x:n.x+(i.x-n.x)*e,y:n.y+(i.y-n.y)*e}}o+=s}}return{...e[e.length-1]}}function xI(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function wI(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 kI(e,t,n){const o=bI({...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,s=r.x/i,a=r.y/i,c=xI(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+-a*l,y:t[0].y+s*l,vx:s*n,vy:a*n,mass:e.mass,shape:e.shape,datum:{...e.datum&&"object"==typeof e.datum?e.datum:{},routeProgress:0}}}var SI=(0,dI.forwardRef)(function(e,t){const{chartId:n,colorBy:o,coordinateMode:r="auto",data:i,edges:s,emptyContent:a,flowSpeed:c=90,frameProps:l,links:u,loading:d,loadingContent:h,maxParticles:p=180,nodeIdAccessor:m="id",nodeXAccessor:y="x",nodeYAccessor:f="y",nodes:g,onObservation:b,particleRadius:v=4,particleRate:x=.16,pathAccessor:w="path",pathConstraint:k="path",paused:S,reducedMotion:A=!1,rerunMS:C,responsiveHeight:M,responsiveWidth:j,seed:P=1,showNodeLabels:I=!0,showSensors:R=!1,showStaticFlow:T=!0,sourceAccessor:_="source",styleRules:L,targetAccessor:D="target",throughputAccessor:N="value"}=e,$=OP(e,[760,420]),{chartSize:B,className:E,title:O,chartMode:F,margin:z,enableHover:H,description:W,summary:q,accessibleTable:G}=$,Y=(0,dI.useRef)(null),V=(0,dI.useMemo)(()=>g??[],[g]),X=(0,dI.useMemo)(()=>u??s??i??[],[i,s,u]),U=(0,dI.useMemo)(()=>xP({nodes:V,links:X,nodeIdAccessor:m,nodeXAccessor:y,nodeYAccessor:f,sourceAccessor:_,targetAccessor:D,throughputAccessor:N,pathAccessor:w,coordinateMode:r,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:c,pathConstraint:k,reducedMotion:A,seed:P,size:B}),[X,V,B,r,c,p,m,y,f,v,x,w,k,A,P,_,D,N]);TP(t,{frameRef:Y,spawnDatum:(0,dI.useCallback)((e,t)=>{const n=xP({nodes:V,links:[e],nodeIdAccessor:m,nodeXAccessor:y,nodeYAccessor:f,sourceAccessor:_,targetAccessor:D,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:Uj(B).plot.x,y:Uj(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}},[V,B,r,c,p,m,y,f,v,x,w,k,A,P,_,D,N]),seedRows:X,seedSpawns:U.initialSpawns});const K=o??"source",Q=(0,dI.useMemo)(()=>Qj(K,"#2563eb",{styleRules:L,valueAccessor:N}),[K,L,N]),Z=EP((0,dI.useMemo)(()=>function(e,t,n){return{...e,observation:{...e.observation,chartId:t??e.observation?.chartId??"physical-flow",chartType:"PacketFlowChart",onObservation:n??e.observation?.onObservation}}}(U.config,n,b),[n,U.config,b]),C,S),J=(0,dI.useRef)(l?.onTick);J.current=l?.onTick;const ee=(0,dI.useCallback)((e,t)=>{A||"none"===k||function(e,t){const n=e.readBodies(),o=[],r=[];for(const i of n){const n=gI(i.datum);if(2>n.length)continue;const s=bI(i,n);if(!s)continue;const a=i.datum,c=Number(a?.flowSpeed),l=Number.isFinite(c)&&c>0?c:t;if(s.progress>=.985||s.distance>Math.max(90,14*xI(i))){o.push(i.id),r.push(kI(i,n,l));continue}const u=vI(n,Math.min(1,s.progress+Math.max(.035,Math.min(.12,l/s.totalLength*.16))),s.totalLength),d=s.tangent,h=(d.x*l-i.vx)*i.mass*.16+(u.x-i.x)*i.mass*.045+(s.point.x-i.x)*i.mass*.08,p=(d.y*l-i.vy)*i.mass*.16+(u.y-i.y)*i.mass*.045+(s.point.y-i.y)*i.mass*.08,[m,y]=wI(h,p,i.mass*l*.35);e.applyImpulse(i.id,m,y)}o.length&&e.remove(o),r.length&&e.pushMany(r)}(t,c),J.current?.(e,t)},[c,k,A]),{selection:te,onBodyHover:ne}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:o,chartType:"PacketFlowChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:l?.onBodyHover,fallbackFields:"string"==typeof _?[_]:void 0}),oe=FP({data:null==u&&null==s&&null==i?void 0:X,emptyContent:a,loading:d,loadingContent:h,size:B});if(oe)return oe;const re=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],s=Math.max(1,...e.links.map(e=>e.throughput)),a=new Set(e.nodes.map(e=>e.sensorId));return(0,mI.jsxs)("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/s*16,n=e.path[Math.floor(e.path.length/2)];return(0,mI.jsxs)("g",{children:[(0,mI.jsx)("path",{d:pI(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),(0,mI.jsx)("path",{d:pI(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),n?(0,mI.jsx)("text",{x:n.x,y:n.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:hI(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>(0,mI.jsxs)("g",{children:[o&&a.has(e.sensorId)?(0,mI.jsx)("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?(0,mI.jsx)("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?(0,mI.jsx)("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}(U.metadata,{showNodeLabels:I,showSensors:R,showStaticFlow:T}),ie=(se=U.metadata)?se.links.map(e=>{const t=e.path[Math.floor(e.path.length/2)]??e.path[0],n=`${e.sourceLabel} to ${e.targetLabel}: ${hI(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:pI(e.path),group:"flow"}}):[];var se;const ae=WP(e.tooltip,l),ce=qP(e,l,ie,{selection:te,chartMode:F,className:E,title:O,description:W,summary:q,accessibleTable:G,enableHover:H,margin:z});return zP("PacketFlowChart",B,(0,yI.createElement)(Xj,{...l,...ae,...ce,key:Z.rerunKey,ref:Y,onBodyHover:ne,config:Z.config,continuous:!A&&"none"!==k,foregroundGraphics:HP(re,l?.foregroundGraphics),initialSpawns:U.initialSpawns,onTick:ee,paused:S||A,responsiveHeight:M,responsiveWidth:j,simulationExecution:"none"===k?l?.simulationExecution:"sync",size:B,bodyStyle:Q,workerBodyThreshold:l?.workerBodyThreshold??1/0}))});SI.displayName="PacketFlowChart";var AI=require("react"),CI=require("react/jsx-runtime"),MI={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 jI(e,t,n){return Math.max(t,Math.min(n,e))}function PI(e){return 6.2*e.length}function II(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 RI(e,t,n="auto"){const o=Math.max(1,Math.floor(t/6.2)),r="compact"===n?II(e,o):"full"===n?e:PI(e)>t?II(e,o):e;return{text:r,textLength:PI(r)>t?Math.max(4,t):void 0}}function TI(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}]})}var _I=require("react/jsx-runtime"),LI=(0,AI.forwardRef)(function(e,t){const{ballRadius:n=6,chromeOptions:o,colorBy:r,data:i,emptyContent:s,frameProps:a={},groupAnchorAlong:c,groupBy:l,groupCompletion:u,groupLabelAccessor:d,gravityX:h,gravityY:p,idAccessor:m,initialSpawnPacing:y,liveCapacity:f=!0,onCapacityChange:g,selection:b,bodyLimit:v,bodyMark:x,loading:w,loadingContent:k,paused:S,radiusAccessor:A,rerunMS:C,responsiveHeight:M,responsiveWidth:j,route:P="horizontal",seed:I=1,settle:R,springDamping:T,springStiffness:_,stageAccessor:L="stage",stages:D,workAccessor:N}=e,$=OP(e,[900,420]),{chartSize:B,showProjection:E,showChrome:O,className:F,title:z,chartMode:H,margin:W,enableHover:q,description:G,summary:Y,accessibleTable:V}=$,X=(0,AI.useRef)(null),U=(0,AI.useMemo)(()=>ft(i??[]),[i]),K=(0,AI.useMemo)(()=>({data:U,stages:D,size:B,idAccessor:m,stageAccessor:L,groupBy:l,groupLabelAccessor:d,workAccessor:N,radiusAccessor:A,ballRadius:n,seed:I,route:P,groupCompletion:u,groupAnchorAlong:c,springStiffness:_,springDamping:T,gravityX:h,gravityY:p,settle:R}),[n,B,h,p,c,l,u,d,m,A,P,U,I,R,T,_,L,D,N]),Q=(0,AI.useMemo)(()=>MP(K),[K]),Z=Q.metadata;TP(t,{frameRef:X,spawnDatum:(0,AI.useCallback)((e,t)=>{const o=MP({...K,data:[e],seed:I+t+1,settle:!0}).initialSpawns[0]??{id:(e.id??"process-flow-push-"+t)+"",x:Uj(B).plot.x,y:Uj(B).plot.y,mass:1,shape:{type:"circle",radius:n},datum:e};return{datumId:(e.id??o.id)+"",spawns:[o]}},[n,K,B,I]),seedRows:U,seedSpawns:Q.initialSpawns});const J=(0,AI.useMemo)(()=>Qj(r),[r]),ee=(0,AI.useMemo)(()=>{if(!f)return a.controllers;const e=[...D.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??(N?"string"==typeof N?N:e=>{const t=e.datum;if(!t)return 1;try{return Number(N(t,0))||1}catch{return 1}}:"work"),releaseImpulse:{x:70+Math.min(40,2*t),y:0},queueLayout:"lane",continuous:!0})}),...a.controllers??[]];return e.length?e:void 0},[a.controllers,f,D,N]),[te,ne]=(0,AI.useState)({}),oe=(0,AI.useRef)(ee);oe.current=ee;const re=(0,AI.useRef)(a.onTick);re.current=a.onTick;const ie=!1!==O||null!=g;(0,AI.useEffect)(()=>{if(!g)return;const e=Object.values(te);e.length&&g(e)},[te,g]);const se=(0,AI.useCallback)((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]),ae=(0,AI.useMemo)(()=>{const e=J,t=a.bodyStyle;return x||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??x}}:e},[x,J,a.bodyStyle]),ce=EP((0,AI.useMemo)(()=>({...Q.config,...null!=v?{bodyLimit:v,eviction:"oldest"}:{},...a.config}),[v,a.config,Q.config]),C,S),{selection:le,onBodyHover:ue}=$P({selection:b,linkedHover:e.linkedHover,colorBy:r,chartType:"ProcessFlowChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:a?.onBodyHover,fallbackFields:"string"==typeof L?[L]:void 0}),de=FP({data:i,emptyContent:s,loading:w,loadingContent:k,size:B});if(de)return de;if(!D?.length)return zP("ProcessFlowChart",B,(0,_I.jsx)("div",{role:"status",style:{width:B[0],height:B[1],display:"grid",placeItems:"center",color:"var(--semiotic-text-secondary, #64748b)"},children:"ProcessFlowChart requires a non-empty stages array."}));const he=function(e,t,n={},o){if(!1===t||!e)return;const{volume:r,stages:i,groups:s,groupCompletion:a}=e,c=new Map(r.stages.map(e=>[e.id,e])),l=new Map(a.map(e=>[e.id,e]));return({size:e})=>{const t=Number(e[0])||r.width,a=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=s.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:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:p,bottomY:m,midY:y,stages:f,groups:g=[]}=e,b=m-p;return(0,CI.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,CI.jsx)("defs",{children:(0,CI.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,CI.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,CI.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,CI.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,CI.jsx)("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?(0,CI.jsx)("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,f.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=MI[n],c=Math.max(12,e.width-8),l=jI(c-8,22,88),d=RI(e.label,Math.max(8,l-10),s),h="none"!==s&&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=RI(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=RI(w,Math.max(16,c-8),"auto"),S=Math.max(30,p-15),A=S-13;return(0,CI.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,CI.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:c,height:b-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),f.length-1>t?(0,CI.jsx)("polygon",{points:`${e.x1-2},${y-7} ${e.x1+8},${y} ${e.x1-2},${y+7}`,fill:i.accent,opacity:.85}):null,h?(0,CI.jsxs)(CI.Fragment,{children:[(0,CI.jsx)("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}),(0,CI.jsxs)("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:[(0,CI.jsx)("title",{children:e.label}),d.text]})]}):null,x?(0,CI.jsxs)("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:[(0,CI.jsx)("title",{children:g}),v.text]}):null,o&&null!=e.count?(0,CI.jsxs)("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:[(0,CI.jsx)("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,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=jI(Math.max(54,PI(e.label)+18,PI(c)+16),54,104),u=RI(e.label,l-12,"auto"),d=RI(c,l-12,"auto");return(0,CI.jsxs)("g",{"data-group":e.id,children:[(0,CI.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),(0,CI.jsxs)("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:[(0,CI.jsx)("title",{children:e.label}),u.text]}),(0,CI.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,CI.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}({width:t,height:a,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,O,te,o),pe=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=Uj(r),s=Math.max(1,...e.map(e=>e.value)),a=Math.min(48,.18*i.plot.height),c=i.plot.y+6;return(0,_I.jsx)("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/s*a),u=Math.max(8,.35*i.width);return(0,_I.jsx)("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),me=[...Jj(Q.projectionRows,B,"stage"),...TI(Z?.groups??[])],ye=WP(e.tooltip,a),fe=qP(e,a,me,{chartMode:H,className:F,title:z,description:G,summary:Y,accessibleTable:V,enableHover:q,margin:W}),ge=[...Z?.regionEffects??[],...a.regionEffects??[]];return zP("ProcessFlowChart",B,(0,_I.jsx)(Xj,{...a,...ye,...fe,ref:X,onBodyHover:ue,controllers:ee,regionEffects:ge,selection:le??a.selection,backgroundGraphics:HP(he,a.backgroundGraphics),foregroundGraphics:HP(pe,a.foregroundGraphics),initialSpawns:Q.initialSpawns,initialSpawnPacing:y??Q.initialSpawnPacing,onTick:se,paused:S,responsiveHeight:M,responsiveWidth:j,size:B,bodyStyle:ae,config:ce.config}))});LI.displayName="ProcessFlowChart";var DI=require("react"),NI="gauntlet-core",$I="gauntlet-positive",BI="gauntlet-negative";function EI(e){const t=GI(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function OI(e,t,n,o){return n?"function"==typeof n?n(e,t):e[n]??o:o}function FI(e){return e?.label??e?.id??"property"}function zI(e){return`gauntlet:${e}:core`}function HI(e,t){return`gauntlet:${e}:positive:${t}`}function WI(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}var qI={left:28,top:76,rightInset:30,thickness:8};function GI(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return qI;const n=Math.max(1,Math.min(e.width,t)),o=Math.max(2,.04*e.width);return{left:o,top:Math.max(2,.08*t),rightInset:o,thickness:Math.max(1,Math.min(4,.04*n))}}function YI(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function VI(e,t,n,o){const r=GI(o),i=Math.max(2,n+2),s=r.top+r.thickness/2+i,a=o.floorY-i,c=(e,t,n)=>t>n?(t+n)/2:Math.max(t,Math.min(n,e));return{x:c(e,r.left+r.thickness/2+i,o.width-r.rightInset-r.thickness/2-i),y:c(t,s,a)}}function XI(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 UI(e,t,n,o){const r=XI(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 KI(e,t,n=1){const o=[...e].sort((e,t)=>e.localeCompare(t)),r=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?r/(o.length-1):.5)*Math.PI*.64,index:r,radius:(48+r%2*6)*n}}function QI(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 ZI(e,t,n,o,r){const i=OI(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=o.map(e=>e.id),a=[...OI(e,t,n.positiveAccessor,s)],c=[...OI(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:i,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...OI(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(OI(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:OI(e,t,n.initialViability,100)}}function JI(e,t,n,o,r,i,s){const a=YI(n),c=Math.max(3,28*a),l=o.startX,u=o.startY+(o.startY===n.routeY?38*t*a:0),d=s?.(e,t,n,o)??{},h=d.x??l,p=d.y??u,m={__gauntlet:!0,kind:NI,projectId:e.id,sourceDatum:e.datum},y=[{...d,id:zI(e.id),x:h,y:p,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??e.startedAt,datum:m}],f=VI(h,p,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,n);y[0].x=f.x,y[0].y=f.y;for(const t of e.activePositiveIds){const o=r.get(t);if(!o)continue;const i=KI(e.activePositiveIds,t,a),s=o.radius??Math.max(2,10*a),c=VI(f.x+Math.cos(i.angle)*i.radius,f.y+Math.sin(i.angle)*i.radius,s,n);y.push({id:HI(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:$I,projectId:e.id,property:o,sourceDatum:e.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:zI(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+i.index%2*4)*a),...o.spring??{}}]})}return e.negativeIds.forEach((t,o)=>{const r=i.get(t);r&&y.push(eR(e,r,o,f.x,f.y,n,d.spawnAt??e.startedAt))}),y}function eR(e,t,n,o,r,i,s){const a=YI(i),c=t.radius??Math.max(2,7.2*a),l=VI(o+(n%4*12-12)*a,r+(54+12*Math.floor(n/4))*a,c,i);return{id:WI(e.id,t.id,n),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:BI,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:zI(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...t.spring??{}}]}}function tR(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 nR(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 oR(e,t){return nR(e.activePositiveIds,t.popPositive)}function rR(e,t){const n=nR(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 iR(e,t,n){if(t.when&&!t.when(n))return e;let o={...e};const r=oR(o,t);r.length&&(o={...o,activePositiveIds:o.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...o.poppedPositiveIds,...r]))});const i=rR(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 s=tR(t.addPositive);s.length&&(o={...o,activePositiveIds:Array.from(new Set([...o.activePositiveIds,...s])),missingPositiveIds:o.missingPositiveIds.filter(e=>!s.includes(e))});const a=tR(t.addNegative);if(a.length&&(o={...o,negativeIds:[...o.negativeIds,...a]}),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 sR(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function aR(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 cR(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==BI)}function lR(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}function uR(e,t){return 2>Math.hypot(e.vx,e.vy)&&4>Math.hypot(t.x,t.y)?null:t}var dR=require("react/jsx-runtime");function hR(e){const t=e.data;return t?.__gauntlet?(0,dR.jsxs)("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:[(0,dR.jsx)("strong",{children:t.kind===NI?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:FI(t.property)}),(0,dR.jsx)("div",{children:t.kind===$I?"Positive property":t.kind===BI?"Negative property":"Project core"})]}):null}function pR(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===NI)e.fillStyle=mR(e,n.fill,"#0f766e"),e.strokeStyle=mR(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=mR(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=mR(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),o.kind===BI?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=mR(e,"var(--semiotic-bg, #07111f)","#07111f"),e.font=`900 ${o.kind===BI?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 mR(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 yR({layout:e,compact:t,showLabels:n}){const o=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),r=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);return(0,dR.jsx)(dR.Fragment,{children:e.gates.map(i=>(0,dR.jsxs)("g",{children:[(0,dR.jsx)("rect",{x:i.x-i.width/2,y:o,width:i.width,height:r,rx:t?2:12,fill:i.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:i.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),n?(0,dR.jsx)("text",{x:i.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:i.label??i.id}):null]},i.id))})}function fR({layout:e,states:t,compact:n=!1}){return n?(0,dR.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,dR.jsx)(yR,{layout:e,compact:!0,showLabels:!1})}):(0,dR.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,dR.jsx)("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-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),(0,dR.jsx)("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),(0,dR.jsx)("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),(0,dR.jsx)(yR,{layout:e,compact:!1,showLabels:!0}),(0,dR.jsxs)("g",{children:[(0,dR.jsx)("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),(0,dR.jsx)("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,dR.jsxs)("g",{children:[(0,dR.jsx)("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),(0,dR.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,dR.jsx)("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 gR(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===NI?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${FI(t.property)} ${t.kind===$I?"positive":"negative"} property`,group:t.kind===$I?"positive property":"negative property",description:`${FI(t.property)} attached to ${t.projectId}.`})}function bR({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(0,dR.jsxs)("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:[(0,dR.jsx)("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),s=/kill|crash|block|grave/i.test(e.outcome);return(0,dR.jsxs)("g",{children:[(0,dR.jsx)("rect",{x:n+.18*r,y:28-i+22,width:Math.max(10,.45*r),height:i,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),(0,dR.jsx)("text",{x:n+.4*r,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}var vR=require("react/jsx-runtime"),xR=require("react"),wR=[],kR=(0,DI.forwardRef)(function(e,t){const{bodyGroups:n,coreBody:o,coreForceMode:r="route",crashDetection:i=!0,crashOffset:s=30,data:a,emptyContent:c,events:l,frameProps:u={},gates:d,initialSpawnPacing:h,loading:p,loadingContent:m,negativeProperties:y,onCapacityChange:f,onClick:g,onStateChange:b,outcome:v,paused:x,positiveProperties:w=wR,projectPlacement:k,rerunMS:S,responsiveHeight:A,responsiveWidth:C,seed:M,showTethers:j=!0,terminalBehavior:P="outcome",viability:I}=e,R=(0,DI.useRef)(null),T=(0,DI.useMemo)(()=>({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]),_=OP(e,[900,520]),{chartSize:L,showProjection:D,showChrome:N,className:$,title:B,chartMode:E,margin:O,enableHover:F,description:z,summary:H,accessibleTable:W}=_,{selection:q,onBodyHover:G}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:void 0,chartType:"GauntletChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:u?.onBodyHover,fallbackFields:"string"==typeof e.idAccessor?[e.idAccessor]:["id"],unwrapSourceDatum:!0}),Y=FP({data:a,emptyContent:c,loading:p,loadingContent:m,size:L}),V=(0,DI.useMemo)(()=>ft(a??[]),[a]),X=(0,DI.useMemo)(()=>V.map((e,t)=>OI(e,t,T.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[V,T.idAccessor]),U=(0,DI.useMemo)(()=>new Map(w.map(e=>[e.id,e])),[w]),K=(0,DI.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),Q=(0,DI.useMemo)(()=>function(e,t,n){const[o,r]=e,i=220>o||160>r,s=Math.round(.48*r),a=i?r-Math.max(3,Math.min(12,.1*r)):r-36,c=(t??[]).filter(e=>!1!==e.enabled),l=Math.max(1,c.length),u=.22*o,d=l>1?(.78*o-u)/(l-1):0,h=i?Math.max(Math.round(.12*o),.08*o+6):Math.max(Math.round(.14*o),110);return{crashY:a-(i?Math.min(n,Math.max(3,.22*r)):n),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(i?8:54,Math.round(.07*o))})),graveyardX:Math.round(o*(i?.72:.84)),graveyardY:a-4,height:r,routeY:s,socketX:Math.round(o*(i?.82:.92)),startX:h,width:o}}(L,d,s),[L,s,d]),Z=(0,DI.useMemo)(()=>new Map(Q.gates.map(e=>[e.id,e])),[Q.gates]),J=(0,DI.useMemo)(()=>Q.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:NI}:e.regionEffect?.bodyFilter,shape:{type:"aabb",x:e.x,y:Q.routeY,width:e.capacity?e.capacity.sensorWidth??Math.max(220>Q.width?12:96,e.width*(220>Q.width?2:6)):Math.max(e.width,220>Q.width?10:54),height:Math.max(4,Math.min(360,Q.height-(160>Q.height?8:170)))}})),[Q.gates,Q.height,Q.routeY,Q.width]),[ee,te]=(0,DI.useState)(()=>V.map((e,t)=>{const n=ZI(e,t,T,w,K);return{...n,viability:I?.(n,{negativeProperties:K,positiveProperties:U})??QI(n,U,K)}})),ne=(0,DI.useRef)(ee),oe=(0,DI.useRef)(0),re=(0,DI.useRef)(new Map),ie=(0,DI.useRef)([]),se=(0,DI.useRef)(f);se.current=f;const ae=(0,DI.useRef)(V);ae.current=V;const ce=(0,DI.useRef)(b);ce.current=b;const le=(0,DI.useRef)({negativeById:K,positiveById:U,positiveProperties:w,stateAccessors:T,viability:I});le.current={negativeById:K,positiveById:U,positiveProperties:w,stateAccessors:T,viability:I};const ue=(0,DI.useCallback)((e,t,n=0)=>{const o=le.current,r=ZI(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})??QI(r,o.positiveById,o.negativeById)}},[]),de=(0,DI.useCallback)(()=>{re.current.clear(),ie.current=[],oe.current=0;const e=ae.current.map((e,t)=>ue(e,t));ne.current=e,te(e)},[ue]),he=EP((0,DI.useMemo)(()=>({fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7,...null!=M&&{seed:M},...u.config?.kernel??{}},colliders:[...EI(Q),...u.config?.colliders??[]]}),[u.config?.colliders,u.config?.kernel,Q,M]),S,x,de),pe=(0,DI.useMemo)(()=>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:NI},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,s=o.current.find(e=>e.id===n?.projectId);let a;"function"==typeof i?a=s?i(s):void 0:i&&(a=r?.[i]);const c=Number(a??r?.reviewWork??r?.work??s?.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:`${X}:${he.rerunKey}`,gates:Q.gates,statesRef:ne,processedGateVisitsRef:re}),[X,Q.gates,he.rerunKey]),me=(0,DI.useMemo)(()=>[...pe,...u.controllers??[]],[pe,u.controllers]);(0,DI.useEffect)(()=>{re.current.clear(),ie.current=[],oe.current=0;const e=ae.current.map((e,t)=>ue(e,t));ne.current=e,te(e)},[ue,X]),(0,DI.useEffect)(()=>{ne.current=ee,ce.current?.(ee)},[ee]);const ye=(0,DI.useCallback)(e=>[...("function"==typeof l?l(e,Q):l)??[]].sort((e,t)=>e.time-t.time),[l,Q]),fe=(0,DI.useCallback)((e,t,n)=>{if(!t.gateId||!Z.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&&(re.current.get(`${e.id}:${t.gateId}`)??0)>=r},[Z]),ge=(0,DI.useCallback)(()=>{if(!pe.length)return;const e=pe.flatMap(e=>{const t=e.getSnapshot?.();return t?[t]:[]});var t,n;(t=ie.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})||(ie.current=e,se.current?.(e))},[pe]),be=(0,DI.useMemo)(()=>ee.flatMap((e,t)=>{const n=UI(e,t,Q,k);return JI(e,t,Q,n,U,K,o)}),[o,Q,K,U,k,ee]),ve=(0,DI.useCallback)((e,t)=>{let n=!1;const o=ne.current.map(o=>{if(o.id!==e)return o;const r=t(o);return n=n||r!==o,r});n&&(ne.current=o,te(o))},[]);(0,DI.useImperativeHandle)(t,()=>function(e){const{statesRef:t,setStates:n,elapsedRef:o,frameRef:r,layout:i,projectPlacement:s,positiveById:a,negativeById:c,coreBody:l,createState:u}=e;return{push:e=>{const d=u(e,t.current.length,o.current),h=UI(d,t.current.length,i,s),p=JI(d,t.current.length,i,h,a,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=UI(t,d.length,i,s);h.push(...JI(t,d.length,i,n,a,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=[],s=[];for(const e of o){const n=t.current.find(t=>t.id===e);n&&(i.push(n.datum),s.push(zI(n.id),...n.activePositiveIds.map(e=>HI(n.id,e))),n.negativeIds.forEach((e,t)=>{s.push(WI(n.id,e,t))}))}return t.current=t.current.filter(e=>!o.includes(e.id)),n(t.current),r.current?.remove(s),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),y=u(m,0>h?t.current.length:h,n.startedAt??o.current),f=UI(y,0>h?t.current.length:h,i,s);r.current?.remove([zI(n.id),...n.activePositiveIds.map(e=>HI(n.id,e)),...n.negativeIds.map((e,t)=>WI(n.id,e,t))]),r.current?.pushMany(JI(y,0>h?t.current.length:h,i,f,a,c,l)),t.current=t.current.map(t=>t.id===e?y: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:ne,setStates:te,elapsedRef:oe,frameRef:R,layout:Q,projectPlacement:k,positiveById:U,negativeById:K,coreBody:o,createState:ue}),[o,ue,Q,K,U,k]);const xe="sparkline"===E?.22:"mobile"===E?.55:1,we=(0,DI.useCallback)((e,t,n)=>{!function(e){const{project:t,effect:n,controls:o,layout:r,positiveById:i,negativeById:s,coreBody:a,popBodies:c,popScale:l}=e,u=o.readBodies().find(e=>e.id===zI(t.id)),d=o.readBodies(),h=u?.x??r.startX,p=u?.y??r.routeY,m=function(e,t){let n=-1;for(const o of t)cR(o,e.id)&&(n=Math.max(n,lR(o)));return Math.max(e.negativeIds.length,n+1)}(t,d),y=tR(n.addNegative).flatMap((e,n)=>{const o=s.get(e);return o?[eR(t,o,m+n,h,p,r)]:[]}),f=tR(n.addPositive).flatMap(e=>{if(!i.get(e)||t.activePositiveIds.includes(e))return[];const n={...XI(r),routeY:p,socketY:p,startX:h,startY:p};return JI({...t,activePositiveIds:[e],negativeIds:[]},0,r,n,i,s,a).filter(e=>e.id.includes(":positive:"))});(y.length||f.length)&&o.pushMany([...y,...f]);const g=oR(t,n);for(const e of g){const n=i.get(e);c([HI(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3,scale:l})}const b=rR(t,n),v=function(e,t,n){const o=t.filter(t=>cR(t,e.id)).sort((e,t)=>lR(e)-lR(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):WI(e.id,t.propertyId,t.index)})}(t,d,b);b.forEach((e,t)=>{const n=s.get(e.propertyId);c([v[t]],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??7)+3,scale:l})})}({project:e,effect:t,controls:n,layout:Q,positiveById:U,negativeById:K,coreBody:o,popBodies:(e,t)=>R.current?.popBodies(e,t),popScale:xe})},[o,Q,K,U,xe]),ke=(0,DI.useCallback)(({body:e,bodies:t})=>function(e){const{body:t,bodies:n,layout:o,states:r,projectPlacement:i,positiveById:s,negativeById:a,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),y=0>m?void 0:r[m];if(!y)return null;const f=UI(y,m,o,i),g=n.find(e=>e.id===zI(y.id)),b=YI(o),v=y.negativeIds.reduce((e,t)=>e+(a.get(t)?.load??1),0),x=y.killed?0:58*Math.max(.25,b);if(p.kind!==NI){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===y.id&&t.kind===p.kind}).sort((e,t)=>(e.id+"").localeCompare(t.id+"")),s=Math.max(0,i.findIndex(e=>e.id===t.id));e=r.target({body:t,bodies:n,core:g,index:s,layout:o,placement:f,project:y})??{x:g.x,y:g.y}}else if(p.kind===$I&&p.property){const t=KI(y.activePositiveIds,p.property.id,b);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===BI&&e.datum.projectId===y.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)*b,y:g.y+(54+13*i)*b}}const i="circle"===t.shape.type?t.shape.radius:8;e=VI(e.x,e.y,i,o);const s=VI(t.x,t.y,i,o);if(Math.abs(s.x-t.x)>.5||Math.abs(s.y-t.y)>.5)return{x:48*(s.x-t.x)-6*t.vx,y:48*(s.y-t.y)-6*t.vy};const a=p.kind!==$I||y.killed?0:3.2*(r?.buoyancy??r?.value??1),c=p.kind===BI?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return uR(t,{x:28*(e.x-t.x)-3*(t.vx-g.vx)+c.x+.01*x,y:28*(e.y-t.y)-3*(t.vy-g.vy)+c.y-a})}if(y.killed)return uR(t,{x:44*((y.crashX??y.metrics.lastX??t.x)-t.x)-9*t.vx,y:(160+12*v)*b-1.6*t.vy});const w=c(y),k=function(e,t,n,o,r,i,s){const a=YI(n);if(t.killed)return{x:t.metrics.lastX??o.graveyardX,y:o.graveyardY};const c=r[r.length-1];if(!c)return{x:o.socketX,y:o.routeY};const l=r.find(n=>e>=n.time&&!t.eventsApplied.includes(n.id)&&!(!n.gateId||!i.get(n.gateId)?.capacity)),u=l?Math.min(e,l.time):e,d="built"===t.outcome||"built_diminished"===t.outcome;if(u>c.time+.85){if("hold-last"===s){const e=c.gateId?i.get(c.gateId):void 0;return{x:c.routeX??e?.x??o.socketX,y:c.routeY??o.routeY}}return d?{x:o.socketX,y:o.socketY}:{x:o.graveyardX,y:o.graveyardY-14}}const h=.85*t.delay+12*t.negativeIds.length+8*(t.poppedPositiveIds.length+t.missingPositiveIds.length),p=[{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,h)*a}})].sort((e,t)=>e.time-t.time);let m=p[0],y=p[p.length-1];for(let e=1;p.length>e;e+=1){if(p[e].time>=u){y=p[e];break}m=p[e]}const f=Math.max(0,Math.min(1,(u-m.time)/Math.max(.1,y.time-m.time))),g=f*f*(3-2*f);return{x:m.x+(y.x-m.x)*g,y:m.y+(y.y-m.y)*g+7*Math.sin(2.6*u)*a}}(Math.max(0,h-(y.startedAt??0)),y,o,f,w,l,d),S=y.activePositiveIds.reduce((e,t)=>e+(s.get(t)?.buoyancy??s.get(t)?.value??1),0);return uR(t,"net"===u?{x:15*(k.x-t.x)-1.8*t.vx+.18*x,y:1.25*(f.routeY-t.y)-1.4*t.vy+32*(v-S)}:{x:15*(k.x-t.x)-1.8*t.vx+.18*x,y:15*(k.y-t.y)-1.8*t.vy+13*v-2.2*S})}({body:e,bodies:t,layout:Q,states:ne.current,projectPlacement:k,positiveById:U,negativeById:K,projectEvents:ye,gateById:Z,coreForceMode:r,terminalBehavior:P,elapsed:oe.current}),[r,Z,Q,K,U,ye,k,P]),Se=(0,DI.useCallback)((e,t)=>{!function(e,t,n){const{frameProps:o,elapsedRef:r,statesRef:i,crashDetection:s,layout:a,projectEvents:c,gateById:l,capacityEventReady:u,addBodiesForEffect:d,updateProjectState:h,viability:p,positiveById:m,negativeById:y,outcome:f,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===zI(e.id));if(!n)continue;if(s&&!e.killed&&n.y+("circle"===n.shape.type?n.shape.radius:28)>=a.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:y,positiveProperties:m,project:b};e.when&&!e.when(o)||(d(b,e,t),b=iR(b,e,o))}const s={...sR(n,i),appliedAt:o};b=aR(b,s),h(e.id,e=>{let t=aR(e,s);if(t===e)return e;for(const e of i)t=iR(t,e,{event:n,gate:r,negativeProperties:y,positiveProperties:m,project:t});const o=p?.(t,{negativeProperties:y,positiveProperties:m})??QI(t,m,y);return t={...t,viability:o},n.final&&(t={...t,outcome:n.outcome??f?.(t,{layout:a,negativeProperties:y,positiveProperties:m})??(t.viability>20?"built":"approved_not_built")}),t})}}}(e,t,{frameProps:u,elapsedRef:oe,statesRef:ne,crashDetection:i,layout:Q,projectEvents:ye,gateById:Z,capacityEventReady:fe,addBodiesForEffect:we,updateProjectState:ve,viability:I,positiveById:U,negativeById:K,outcome:v,reportCapacity:ge})},[we,fe,i,u,Z,Q,K,v,U,ye,ge,ve,I]),Ae=(0,DI.useCallback)((e,t)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(e,t):u.bodyStyle,o=e.datum;return o?.__gauntlet?{fill:o.kind===NI?"var(--semiotic-primary, #0f766e)":o.property?.color??"var(--semiotic-primary, #38bdf8)",stroke:o.kind===NI?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),Ce=(0,DI.useMemo)(()=>"function"==typeof n?n(ee,Q):n??[],[n,Q,ee]),Me=(0,DI.useMemo)(()=>TI(Ce),[Ce]),je=(0,DI.useMemo)(()=>D?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"}})}(ee,Q):[],[Q,D,ee]),Pe=(0,DI.useMemo)(()=>[...je,...Me],[Me,je]),Ie=(0,DI.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]),Re=(0,DI.useCallback)((e,t)=>{g&&(e&&"object"==typeof e&&e.__gauntlet?g(e.sourceDatum,{x:t.x,y:t.y}):e&&g(e,{x:t.x,y:t.y}))},[g]),Te=(0,DI.useCallback)((e,t)=>{u.beforePaint?.(e,t),j&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===NI).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===NI)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===BI?.24:.36,e.strokeStyle=t.kind===BI?"#d94a45":"#7a8794",e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(o.x,o.y),e.stroke())}e.restore()}(e,t)},[u,j]),_e=(0,DI.useMemo)(()=>[...J,...u.regionEffects??[]],[u.regionEffects,J]);if(Y)return Y;const Le=WP(e.tooltip,u),De=qP(e,u,Pe,{selection:q,chartMode:E,className:$,title:B,description:z,summary:H,accessibleTable:W,enableHover:F,margin:O}),Ne=D?(0,vR.jsx)(bR,{states:ee,layout:Q}):void 0,$e=HP(N?(0,vR.jsx)(fR,{layout:Q,states:ee,compact:_.resolved.compactMode}):void 0,u.backgroundGraphics),Be=HP(Ne,u.foregroundGraphics),Ee=u.renderBody??pR,Oe=Le.tooltipContent??hR;return zP("GauntletChart",L,(0,xR.createElement)(Xj,{...u,...Le,...De,key:`${L[0]}x${L[1]}:${X}:${he.rerunKey}`,ref:R,onBodyHover:G,accessibleTable:e.accessibleTable??u.accessibleTable,backgroundGraphics:$e,bodyForces:ke,bodySemanticItems:u.bodySemanticItems??gR,bodyStyle:Ae,beforePaint:Te,onClick:g?Re:De.onClick,config:he.config,controllers:me,enableHover:Le.enableHover??!0,foregroundGraphics:Be,hoverRadius:e.hoverRadius??u.hoverRadius??18,initialSpawns:be,initialSpawnPacing:h,onBodyPointerDown:Ie,onTick:Se,paused:x,regionEffects:_e,renderBody:Ee,responsiveHeight:A,responsiveWidth:C,size:L,tooltipContent:Oe}))});kR.displayName="GauntletChart";var SR=require("react"),AR=1e-9;function CR(e,t){return t>e?-1:e>t?1:0}function MR(e){return{...e}}function jR(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function PR(e){const t=Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:MR(t.initialMetrics),metrics:MR(t.metrics),productIds:[...t.productIds],history:jR(t.history)}])),n=Object.fromEntries(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:MR(t.metrics),sourceIds:[...t.sourceIds],history:jR(t.history)}])),o=Object.fromEntries(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?MR(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:n,relations:o,input:{amount:e.input.amount,metrics:MR(e.input.metrics)},metrics:MR(e.metrics),loss:{amount:e.loss.amount,metrics:MR(e.loss.metrics)},history:jR(e.history)}}function IR(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function RR(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(CR)}function TR(e,t){return e?Object.entries(e).flatMap(([e,n])=>Number.isFinite(n)?[]:[IR("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function _R(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}function LR(e,t,n="selector"){const o=[],r=Object.values(e.components),i=new Set(r.map(e=>e.id)),s=(t.ids??[]).filter(e=>!i.has(e));if(s.length&&o.push(IR("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,n+".ids",s)),void 0===t.count||Number.isInteger(t.count)&&t.count>=0||o.push(IR("error","invalid-selector-count","Selector count must be a non-negative integer.",n+".count")),o.some(e=>"error"===e.severity))return{ids:[],diagnostics:o};const a=t.ids?new Set(t.ids):null,c=t.categories?new Set(t.categories):null,l=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null;let d=r.filter(e=>!a||a.has(e.id)).filter(e=>!c||c.has(e.category)).filter(e=>!l||l.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(CR);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||o.push(IR("warning","empty-selector","Selector matched no source components.",n)),{ids:d,diagnostics:o}}function DR(e,t,n={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...n}}function NR(e,t){const n={...t,eventId:e.event.id};e.materializations.push(n),e.observations.push({...n,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function $R(e,t,n){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(IR("error","unknown-outlet",`Unknown outlet "${t}".`,n,[t])),1))}function BR(e,t,n){const o=RR(t);t.length||e.diagnostics.push(IR("error","empty-source-list","A product requires at least one source component.",n)),o.length&&e.diagnostics.push(IR("error","duplicate-source",`Source ids may appear only once: ${o.join(", ")}.`,n,o));const r=t.filter(t=>!e.state.components[t]);r.length&&e.diagnostics.push(IR("error","unknown-component",`Unknown source component id${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r));const i=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);i.length&&e.diagnostics.push(IR("error","source-already-assigned",`Source component${1===i.length?" is":"s are"} already assigned: ${i.join(", ")}.`,n,i));const s=t.filter(t=>"consumed"===e.state.components[t]?.status&&!i.includes(t));return s.length&&e.diagnostics.push(IR("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,n,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function ER(e,t,n,o,r){const i=o?.amount??0;(!Number.isFinite(i)||0>i||i>t+AR)&&e.diagnostics.push(IR("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",r+".amount")),e.diagnostics.push(...TR(o?.metrics,r+".metrics"));for(const[t,i]of Object.entries(o?.metrics??{}))(0>i||i>Number(n[t]??0)+AR)&&e.diagnostics.push(IR("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${r}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function OR(e,t,n,o,r,i,s){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:i&&void 0!==e.amount?e.amount:n,metrics:i&&e.metrics?{...o,...e.metrics}:o,status:i?"complete":"forming",sourceIds:[...t],outletId:i?e.outletId??(r.outletIds.has("product")?"product":void 0):void 0,createdByEventId:r.event.id,createdAt:r.context.appliedAt,completedByEventId:i?r.event.id:void 0,completedAt:i?r.context.appliedAt:void 0,history:[s]}}function FR(e,t,n,o){void 0!==t.amount&&Math.abs(t.amount-n)>AR&&e.diagnostics.push(IR("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${n}.`,o,[t.id]))}function zR(e,t,n){const o=`events.${e.event.id}.effects.${n}`,r=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(IR("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,o+".state")),e.diagnostics.push(...TR(t.metricsDelta,o+".metricsDelta")),$R(e,t.outletId,o+".outletId");const n=LR(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(IR("error","source-already-assigned",`Assigned source components cannot be retargeted: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=DR(e,t,{sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0});for(const e of n.ids){const n=r.components[e];n.status=t.state,n.outletId=t.outletId,n.reason=t.reason,t.metricsDelta&&_R(n.metrics,t.metricsDelta),n.history.push(s)}return r.history.push(s),void(n.ids.length&&NR(e,{type:"retarget-component",sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){const{relation:n}=t;n.id&&!r.relations[n.id]||e.diagnostics.push(IR("error","duplicate-relation",`Relation id "${n.id}" is missing or already active.`,o+".relation.id",[n.id]));const i=function(e,t,n){const o=RR(t),r=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(IR("error","insufficient-relation-sources","A relation requires at least two source components.",n)),o.length&&e.diagnostics.push(IR("error","duplicate-source",`Relation source ids must be unique: ${o.join(", ")}.`,n,o)),r.length&&e.diagnostics.push(IR("error","unknown-component",`Relation references unknown source component${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,n.sourceIds,o+".relation.sourceIds");if(e.diagnostics.push(...TR(n.metrics,o+".relation.metrics")),!i||e.diagnostics.some(e=>"error"===e.severity))return;r.relations[n.id]={...n,sourceIds:[...n.sourceIds],metrics:n.metrics?{...n.metrics}:void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=DR(e,t,{sourceIds:[...n.sourceIds],relationIds:[n.id]});return r.history.push(s),void NR(e,{type:"activate-relation",sourceIds:[...n.sourceIds],relationIds:[n.id]})}if("resolve-relation"===t.type){const n=RR(t.relationIds),i=t.relationIds.filter(e=>!r.relations[e]),s=t.relationIds.filter(e=>"resolved"===r.relations[e]?.status);if(n.length&&e.diagnostics.push(IR("error","duplicate-relation","Relation ids must be unique.",o+".relationIds",n)),i.length&&e.diagnostics.push(IR("error","unknown-relation",`Unknown relation: ${i.join(", ")}.`,o+".relationIds",i)),s.length&&e.diagnostics.push(IR("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,o+".relationIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const n of t.relationIds){const o=r.relations[n];o.status="resolved",o.resolution=t.resolution,o.resolvedByEventId=e.event.id,o.resolvedAt=e.context.appliedAt,o.reason=t.reason}const a=DR(e,t,{relationIds:[...t.relationIds]});return r.history.push(a),void NR(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){const n=e.productDefinitions.get(t.productId);n||e.diagnostics.push(IR("error","unknown-product",`Product "${t.productId}" has no declared mold.`,o+".productId",[t.productId]));const i=r.products[t.productId];"combine"===t.type&&i&&e.diagnostics.push(IR("error","duplicate-product",`Product "${t.productId}" has already been formed.`,o+".productId",[t.productId])),"contribute"!==t.type||i&&"forming"===i.status||e.diagnostics.push(IR("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,o+".productId",[t.productId]));const s=BR(e,t.sourceIds,o+".sourceIds"),a="contribute"===t.type&&i?[...i.sourceIds,...t.sourceIds]:t.sourceIds,c=function(e,t,n,o){if(!t?.length)return[];const r=RR(t),i=t.filter(t=>!e.state.relations[t]),s=t.filter(t=>"resolved"===e.state.relations[t]?.status),a=new Set(n),c=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!a.has(e)));return r.length&&e.diagnostics.push(IR("error","duplicate-relation","Basis relations must be unique.",o,r)),i.length&&e.diagnostics.push(IR("error","unknown-relation",`Unknown basis relation: ${i.join(", ")}.`,o,i)),s.length&&e.diagnostics.push(IR("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,o,s)),c.length&&e.diagnostics.push(IR("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,o,c)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,a,o+".basisRelationIds");if(!s||!c||!n||e.diagnostics.some(e=>"error"===e.severity))return;const l=s.reduce((e,t)=>e+t.amount,0),u=function(e){const t={};for(const n of e)_R(t,n.metrics);return t}(s);if(!ER(e,l,u,t.loss,o+".loss"))return;const d=l-(t.loss?.amount??0);!function(e,t,n){e.state.loss.amount+=n?.amount??0;for(const[o,r]of Object.entries(n?.metrics??{}))t[o]=Number(t[o]??0)-r,e.state.loss.metrics[o]=Number(e.state.loss.metrics[o]??0)+r}(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,p=DR(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let m;if("combine"===t.type){if(h&&FR(e,n,d,o+".productId"),m=OR(n,t.sourceIds,d,u,e,h,p),h&&!$R(e,m.outletId,o+".productId"))return;r.products[t.productId]=m}else m=i,m.sourceIds.push(...t.sourceIds),m.amount+=d,_R(m.metrics,u),m.history.push(p);for(const e of s)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return r.history.push(p),function(e,t){if(t.length){for(const n of t)n.status="resolved",n.resolution="combined",n.resolvedByEventId=e.event.id,n.resolvedAt=e.context.appliedAt;NR(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,c),NR(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:m.outletId?[m.outletId]:void 0}),void(h&&NR(e,{type:"complete-product",sourceIds:[...m.sourceIds],productIds:[m.id],outletIds:m.outletId?[m.outletId]:void 0}))}if("complete-product"===t.type){const n=r.products[t.productId];return n?void function(e,t,n,o,r,i){const s=e.productDefinitions.get(t.id),a=n??s?.outletId??(e.outletIds.has("product")?"product":void 0);if(!$R(e,a,i+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(IR("error","product-already-complete",`Product "${t.id}" is already complete.`,i,[t.id]));s&&(FR(e,s,t.amount,i+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics={...t.metrics,...s.metrics})),t.status="complete",t.outletId=a,t.reason=o,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;const c=DR(e,r,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),NR(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}(e,n,t.outletId,t.reason,t,o):void e.diagnostics.push(IR("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,o+".productId",[t.productId]))}if("split"===t.type){const n=BR(e,[t.sourceId],o+".sourceId");t.products.length||e.diagnostics.push(IR("error","empty-split","A split requires at least one product allocation.",o+".products"));const i=t.products.map(e=>e.productId),s=RR(i);s.length&&e.diagnostics.push(IR("error","duplicate-product","Split product ids must be unique.",o+".products",s));const a=i.map(t=>e.productDefinitions.get(t)),c=i.filter((e,t)=>!a[t]),l=i.filter(e=>r.products[e]);c.length&&e.diagnostics.push(IR("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,o+".products",c)),l.length&&e.diagnostics.push(IR("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,o+".products",l));for(const[n,r]of t.products.entries())void 0===r.amount||Number.isFinite(r.amount)&&r.amount>=0||e.diagnostics.push(IR("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${o}.products.${n}.amount`)),e.diagnostics.push(...TR(r.metrics,`${o}.products.${n}.metrics`));if(!n?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=n[0];if(!ER(e,u.amount,u.metrics,t.loss,o+".loss"))return;const d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??a[t]?.amount),p=h.filter(e=>void 0!==e).length;if(0!==p&&p!==h.length)return void e.diagnostics.push(IR("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",o+".products"));const m=p?h:t.products.map(()=>d/t.products.length),y=m.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>AR)return void e.diagnostics.push(IR("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,o+".products"));const f={...u.metrics};for(const[e,n]of Object.entries(t.loss?.metrics??{}))f[e]=Number(f[e]??0)-n;const g=DR(e,t,{sourceIds:[u.id],productIds:i});if(t.products.forEach((n,i)=>{const s=a[i],c=d>AR?m[i]/d:1/t.products.length,l=Object.fromEntries(Object.entries(f).map(([e,t])=>[e,t*c])),h=n.metrics??s.metrics??l,p=OR({...s,amount:m[i],metrics:h},[u.id],m[i],{...h},e,!0,g);$R(e,p.outletId,`${o}.products.${i}.productId`)&&(r.products[p.id]=p)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=i,u.status="consumed",u.outletId=void 0,u.history.push(g),r.loss.amount+=t.loss?.amount??0;for(const[e,n]of Object.entries(t.loss?.metrics??{}))r.loss.metrics[e]=Number(r.loss.metrics[e]??0)+n;r.history.push(g),NR(e,{type:"split-source",sourceIds:[u.id],productIds:i});for(const t of i)NR(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:r.products[t].outletId?[r.products[t].outletId]:void 0});return}if("eject"===t.type){$R(e,t.outletId,o+".outletId");const n=LR(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(IR("error","source-already-assigned",`Assigned source components cannot be ejected: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=DR(e,t,{sourceIds:n.ids,outletIds:[t.outletId]});for(const e of n.ids){const n=r.components[e];n.status=t.state??"ejected",n.outletId=t.outletId,n.reason=t.reason,n.history.push(s)}return r.history.push(s),void(n.ids.length&&NR(e,{type:"retarget-component",sourceIds:n.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...TR(t.metricsDelta,o+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let n,i;if("run"===t.target)_R(r.metrics,t.metricsDelta);else if("components"in t.target){const i=LR(r,t.target.components,o+".target.components");if(e.diagnostics.push(...i.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;n=i.ids;for(const e of i.ids)_R(r.components[e].metrics,t.metricsDelta)}else{i=[...t.target.productIds];const n=RR(i),s=i.filter(e=>!r.products[e]);if(n.length&&e.diagnostics.push(IR("error","duplicate-product","Metric target product ids must be unique.",o+".target.productIds",n)),s.length&&e.diagnostics.push(IR("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,o+".target.productIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const e of i)_R(r.products[e].metrics,t.metricsDelta)}return void r.history.push(DR(e,t,{sourceIds:n,productIds:i}))}t.outcome.trim()?(r.outcome=t.outcome,r.summary=t.summary,r.history.push(DR(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(IR("error","invalid-outcome","Outcome must be a non-empty string.",o+".outcome"))}function HR(e,t,n){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[IR("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const o=PR(e),r={state:o,event:t,context:n,productDefinitions:new Map(n.products.map(e=>[e.id,e])),outletIds:new Set(n.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(const[n,o]of t.effects.entries())if(zR(r,o,n),r.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:r.diagnostics};return o.elapsed=Math.max(o.elapsed,n.appliedAt),o.phaseId=n.phaseId,o.eventsApplied.push(t.id),r.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:n.phaseId,authoredAt:n.authoredAt,appliedAt:n.appliedAt}),{applied:!0,state:o,materializations:r.materializations,observations:r.observations,diagnostics:r.diagnostics}}var WR=[900,520],qR=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],GR=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),YR=1e-9;function VR(e,t){return t>e?-1:e>t?1:0}function XR(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function UR(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(VR)}function KR(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function QR(e,t,n,o,r,i){if(!n)return o;try{return("function"==typeof n?n(e,t):e[n])??o}catch(e){return r.push(XR("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,i)),o}}function ZR(e,t,n){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(XR("error","invalid-metrics","Metrics must be a numeric object.",n)),{};const o={};for(const[r,i]of Object.entries(e)){const e=KR(i);null!=e?o[r]=e:t.push(XR("error","invalid-metric",`Metric "${r}" must be finite.`,`${n}.${r}`))}return o}function JR(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function eT(e){const{id:t,orientation:n,fixed:o,start:r,end:i,openings:s,thickness:a,friction:c,restitution:l}=e,u=function(e,t,n){const o=n.map(([n,o])=>[Math.max(e,Math.min(n,o)),Math.min(t,Math.max(n,o))]).filter(([e,t])=>t>e+YR).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),r=[];let i=e;for(const[e,t]of o)e>i+YR&&r.push([i,e]),i=Math.max(i,t);return t>i+YR&&r.push([i,t]),r}(r,i,s);return u.map(([e,r],i)=>({id:1===u.length?t:`${t}:${i}`,friction:c,restitution:l,shape:"horizontal"===n?{type:"segment",x1:e,y1:o,x2:r,y2:o,thickness:a}:{type:"segment",x1:o,y1:e,x2:o,y2:r,thickness:a}}))}function tT(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function nT(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?tT(e):1}function oT(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:nT(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function rT(e){return"crucible:component:"+encodeURIComponent(e)}function iT(e,t,n,o){if(void 0!==n&&Number.isFinite(n)&&n>0)return n;const r=Math.min(...t,e),i=Math.max(...t,e);return i-r>YR?o[0]+(o[1]-o[0])*Math.sqrt(Math.max(0,e-r)/(i-r)):(o[0]+o[1])/2}function sT(e,t){const n=Math.max(.25,Math.min(1,t.width/900,t.height/520)),o=e?.[0]??7*n,r=e?.[1]??18*n,i=Math.max(1,Math.min(o,r));return[i,Math.max(i,Math.max(o,r))]}function aT(e,t){if(!e)return[];const n=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),o=Math.max(1,Math.ceil(e/n));return Array.from({length:e},(e,r)=>({x:t.x+t.width/n*(r%n+.5),y:t.y+(Math.floor(r/n)+.5)*(t.height/o)}))}function cT(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function lT(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function uT(e,t,n={}){const o=Object.values(e.products).sort((e,t)=>VR(e.id,t.id)),r=Object.values(e.components).sort((e,t)=>VR(e.id,t.id)),i=[...r.map(e=>e.amount),...o.map(e=>e.amount)],s=sT(n.radiusRange,t),a=function(e,t){const n=new Map;for(const t of e){const e=t.outletId??"__chamber__",o=n.get(e)??[];o.push(t),n.set(e,o)}const o=new Map;for(const[e,r]of n){r.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||VR(e.id,t.id));const n=aT(r.length,lT(t,"__chamber__"===e?void 0:e));r.forEach((e,t)=>o.set(e.id,n[t]))}return o}(o,t),c=o.map(e=>{const o=a.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},r=1.28*iT(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(l=e.id,"crucible:product:"+encodeURIComponent(l)),x:o.x,y:o.y,mass:Math.max(.25,r*r*.018),bodyCollisions:!1,shape:{type:"circle",radius:r},datum:c};var l}),l=new Map;for(const e of r.filter(e=>!e.productIds.length)){const t=cT(e)??"__chamber__",n=l.get(t)??[];n.push(e),l.set(t,n)}const u=new Map;for(const[e,n]of l){const o=aT(n.length,lT(t,"__chamber__"===e?void 0:e));n.forEach((e,t)=>u.set(e.id,o[t]))}return[...r.map(e=>{let o=u.get(e.id);if(e.productIds.length){const n=e.productIds.map(e=>a.get(e)).filter(e=>!!e);if(n.length){o={x:n.reduce((e,t)=>e+t.x,0)/n.length,y:n.reduce((e,t)=>e+t.y,0)/n.length};const r=tT(e.id)/4294967295*Math.PI*2,i=Math.min(20,Math.max(4,.012*t.width));o={x:o.x+Math.cos(r)*i,y:o.y+Math.sin(r)*i}}}o??(o={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});const r=iT(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:rT(e.id),x:o.x,y:o.y,mass:Math.max(.25,r*r*.015),shape:{type:"circle",radius:r},datum:c}}),...c]}var dT=uT;function hT(e){return Array.isArray(e)?e.map(hT):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>VR(e,t)).map(([e,t])=>[e,hT(t)])):e}function pT(e,t=e.duration){const n=function(e,t){const n=KR(t)??0,o=Math.max(0,Math.min(e.duration,n));if(!e.phases.length)return{elapsed:o,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const r=o>=e.duration-YR,i=r?e.phases[e.phases.length-1]:e.phases.find(e=>o>=e.start&&e.end>o)??e.phases[0];return{elapsed:o,phaseId:i.id,phaseIndex:i.index,phaseElapsed:r?i.duration:Math.max(0,o-i.start),complete:r}}(e,t);let o=PR(e.initialState);const r=[],i=[],s=[];for(const t of e.events){if(t.authoredAt>n.elapsed+YR)break;const a=HR(o,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});r.push(...a.diagnostics),i.push(...a.materializations),s.push(...a.observations),a.applied&&(o=a.state)}return o.elapsed=n.elapsed,o.phaseId=n.phaseId,o.phaseIndex=n.phaseIndex,o.phaseElapsed=n.phaseElapsed,o.complete=n.complete,n.complete&&"in_process"===o.outcome&&(o.outcome="complete"),o.playing=!1,{state:o,diagnostics:r,materializations:i,observations:s}}function mT(e){const t=function(e){const t=[];e.length||t.push(XR("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const n=UR(e.map(e=>e.id));n.length&&t.push(XR("error","duplicate-phase-id",`Phase ids must be unique: ${n.join(", ")}.`,"phases",n));let o=0;return{phases:e.map((e,n)=>{const r=KR(e.duration),i=null!=r&&r>0?r:0;e.id.trim()||t.push(XR("error","invalid-phase-id","Phase ids may not be empty.",`phases.${n}.id`)),null!=r&&r>0||t.push(XR("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${n}.duration`,[e.id])),void 0===e.intensity||Number.isFinite(e.intensity)||t.push(XR("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${n}.intensity`,[e.id]));const s={...e,duration:i,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:n,start:o,end:o+i};return o=s.end,s}),diagnostics:t}}(e.phases),n=t.phases.at(-1)?.end??0,o=JR(e.outlets??qR),r=(e.products??[]).map(e=>({...e,metrics:e.metrics?{...e.metrics}:void 0})),i=function(e,t,n){const o=[],r=UR(e.map(e=>e.id));r.length&&o.push(XR("error","duplicate-event-id",`Event ids must be unique: ${r.join(", ")}.`,"events",r));const i=[];return e.forEach((e,r)=>{let s,a,c;if(e.id.trim()||o.push(XR("error","invalid-event-id","Event ids may not be empty.",`events.${r}.id`)),"time"in e.at&&void 0!==e.at.time){const i=KR(e.at.time);if(null==i||0>i||i>n+YR)return void o.push(XR("error","event-time-out-of-range",`Event time must fall between 0 and ${n}.`,`events.${r}.at.time`,[e.id]));s=Math.max(0,Math.min(n,i));const l=function(e,t,n){const o=e.find(e=>YR>=Math.abs(e.start-n));if(o)return{phase:o,boundaryRank:1};const r=e.find(e=>n>=e.start&&e.end>n);return r?{phase:r,boundaryRank:0}:YR>=Math.abs(n-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,n,s);a=l.phase,c=l.boundaryRank}else{if(a=t.find(t=>t.id===e.at.phaseId),!a)return void o.push(XR("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${r}.at.phaseId`,[e.id,e.at.phaseId]));const n=e.at.progress??0;if(!Number.isFinite(n)||0>n||n>1)return void o.push(XR("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${r}.at.progress`,[e.id]));s=a.start+a.duration*n,c=0===n?1:0}a?i.push({...e,index:r,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):o.push(XR("error","event-without-phase","Event could not be assigned to a phase.",`events.${r}.at`,[e.id]))}),i.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:i,diagnostics:o}}(e.events??[],t.phases,n),s=function(e){const t=[],n={},o=[];let r=0;const i={};e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((QR(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(XR("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));o.push(l);const u=KR(QR(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(XR("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=ZR(QR(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=QR(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),m=GR.has(p)?p:"active";GR.has(p)||t.push(XR("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=QR(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",f=QR(s,a,e.categoryAccessor,"component",t,`data.${a}.category`)+"";n[l]||(n[l]={id:l,label:y,category:f,datum:s,status:m,initialAmount:d,amount:d,initialMetrics:{...h},metrics:{...h},productIds:[],history:[]},r+=d,function(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}(i,h))});const s=UR(o);s.length&&t.push(XR("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=ZR(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:n,products:{},relations:{},input:{amount:r,metrics:i},metrics:a,loss:{amount:0,metrics:{}},history:[]},diagnostics:t}}(e),a=function(e=WR,t=qR){const n=Math.max(1,KR(e[0])??900),o=Math.max(1,KR(e[1])??520),r=360>n||260>o,i=r?Math.max(4,.035*Math.min(n,o)):20,s=r?Math.max(10,.075*o):34,a={x:i,y:i,width:Math.max(1,n-2*i),height:s},c=r?Math.max(16,.14*o):Math.min(78,.16*o),l={x:i,y:o-i-c,width:Math.max(1,n-2*i),height:c},u=r?Math.max(12,.08*n):Math.min(150,.17*n),d=a.y+a.height+(r?12:38),h=l.y-(r?10:34),p={x:u,y:d,width:Math.max(24,n-2*u),height:Math.max(24,h-d)},m=Math.max(18,Math.min(.32*p.width,r?84:180)),y={x:p.x+(p.width-m)/2,y:p.y-(r?10:24),width:m,height:r?12:28},f=JR(t),g={left:f.filter(e=>"left"===(e.side??"bottom")),right:f.filter(e=>"right"===e.side),bottom:f.filter(e=>"bottom"===(e.side??"bottom"))},b=[],v=(e,t)=>{const o=Math.max(8,u-1.5*i),s=p.height/Math.max(1,t.length);t.forEach((t,a)=>{b.push({...t,side:e,x:"left"===e?i:n-i-o,y:p.y+a*s,width:o,height:Math.max(8,s-(r?2:8))})})};v("left",g.left),v("right",g.right);const x=p.width/Math.max(1,g.bottom.length);return g.bottom.forEach((e,t)=>{b.push({...e,side:"bottom",x:p.x+t*x,y:p.y+p.height+(r?2:7),width:Math.max(8,x-(r?2:8)),height:Math.max(8,l.y-p.y-p.height-(r?4:12))})}),b.sort((e,t)=>f.findIndex(t=>t.id===e.id)-f.findIndex(e=>e.id===t.id)),{width:n,height:o,phaseRail:a,chamber:p,mouth:y,projection:l,outlets:b}}(e.size??WR,o),c=function(e){const{chamber:t,mouth:n}=e,o=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),r=Math.max(t.x,n.x),i=Math.min(t.x+t.width,n.x+n.width),s={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:r,y2:t.y,thickness:o}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:i,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:o}}];a.push(...eT({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:s.left.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...eT({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:s.right.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...eT({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:s.bottom.map(e=>[e.x,e.x+e.width]),thickness:o,friction:.5,restitution:.08}));for(const t of e.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return a}(a),l=function(e,t){const n=[],o=new Set(t.map(e=>e.id)),r=UR(t.map(e=>e.id)),i=UR(e.map(e=>e.id));return r.length&&n.push(XR("error","duplicate-outlet-id",`Outlet ids must be unique: ${r.join(", ")}.`,"outlets",r)),i.length&&n.push(XR("error","duplicate-product-id",`Product ids must be unique: ${i.join(", ")}.`,"products",i)),t.forEach((e,t)=>{e.id.trim()||n.push(XR("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||n.push(XR("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||n.push(XR("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0===e.amount||Number.isFinite(e.amount)&&e.amount>=0||n.push(XR("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0===e.outletId||o.has(e.outletId)||n.push(XR("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),ZR(e.metrics??{},n,`products.${t}.metrics`)}),n}(r,o),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>VR(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})=>({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})),products:r,outlets:o,events:i.events.map(({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a})=>({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a}))},JSON.stringify(hT(d)));var d;const h=function(e,t,n={}){const o=Object.values(e.components).sort((e,t)=>VR(e.id,t.id)),r=o.map(e=>e.amount),i=sT(n.radiusRange,t),s=function(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}}(nT(n.seed)),a=t.mouth.x+t.mouth.width/2,c=t.chamber.y+Math.max(18,.18*t.chamber.height),l=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return o.map((e,t)=>{const d=t/Math.max(1,o.length)*Math.PI*2+.18*(s()-.5),h=iT(e.amount,r,n.bodyRadius,i),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:rT(e.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:p}})}(s.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p=[...t.diagnostics,...i.diagnostics,...s.diagnostics,...l],m={phases:t.phases,events:i.events,products:r,outlets:o,duration:n,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:oT(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=pT(m),f=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),g=f.length?[XR("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${f.join(", ")}.`,"events",f)]:[];return m.terminalState=y.state,m.terminalSpawns=dT(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),m.diagnostics=[...p,...y.diagnostics,...g],m}function yT(e,t){return e.playing=t&&!e.complete,e}function fT(e,t,n=!1){const o=pT(e,t);return{...o,state:yT(o.state,n)}}function gT(e,t,n,o=t.playing){const r=fT(e,n,o),i=new Set(t.eventsApplied);return{...r,observations:r.observations.filter(e=>!i.has(e.eventId)),materializations:r.materializations.filter(e=>!i.has(e.eventId))}}function bT(e,t,n={}){return uT(t,e.layout,n)}function vT(e,t){return function(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}(`${t}:${e}`)/4294967295}function xT(e,t){return e.phases[t.phaseIndex]??e.phases.find(e=>e.id===t.phaseId)}function wT(e,t,n={}){return new Map(bT(e,t,n).flatMap(e=>{const t=e.datum;return t?.__crucible?[[`${t.kind}:${t.semanticId}`,{x:e.x,y:e.y}]]:[]}))}function kT(e,t){const n=Object.values(e.terminalState.products).map(e=>e.id).sort(),o=Math.max(0,n.indexOf(t))/Math.max(1,n.length)*Math.PI*2-Math.PI/2,r=Math.min(58,.19*e.layout.chamber.width),i=Math.min(38,.16*e.layout.chamber.height);return{x:e.layout.chamber.x+e.layout.chamber.width/2+Math.cos(o)*r,y:e.layout.chamber.y+.52*e.layout.chamber.height+Math.sin(o)*i}}function ST(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 AT(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function CT(e){const t=e.productIds.length?` Contributes to ${e.productIds.join(", ")}.`:e.outletId?` Routed to ${e.outletId}.`:"",n=e.reason?` ${e.reason}.`:"";return`${AT(e.amount)} amount; ${e.status}.${t}${n}`}function MT(e){const t=e.outletId?` Routed to ${e.outletId}.`:"";return`${e.status} product with ${e.sourceIds.length} source${1===e.sourceIds.length?"":"s"} and ${AT(e.amount)} amount.${t}`}function jT(e,t,n){const o=t.datum;if(!o?.__crucible)return;const r="circle"===t.shape.type?t.shape.radius:8,i=ST(e,n.fill,"product"===o.kind?"#b8792d":"#356b63"),s=ST(e,n.stroke,"#26323a");if(e.save(),e.translate(t.x,t.y),e.globalAlpha="number"==typeof n.opacity?n.opacity:.96,e.fillStyle=i,e.strokeStyle=s,e.lineWidth="number"==typeof n.strokeWidth?n.strokeWidth:1.25,"product"===o.kind){e.shadowColor=i,e.shadowBlur=10,e.beginPath();for(let t=0;6>t;t+=1){const n=-Math.PI/2+t/6*Math.PI*2,o=Math.cos(n)*r,i=Math.sin(n)*r;0===t?e.moveTo(o,i):e.lineTo(o,i)}e.closePath(),e.fill(),e.shadowBlur=0,e.stroke(),e.beginPath(),e.arc(0,0,Math.max(2,.36*r),0,2*Math.PI),e.strokeStyle=ST(e,"var(--semiotic-bg, #fffaf0)","#fffaf0"),e.globalAlpha*=.72,e.stroke()}else e.beginPath(),e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.beginPath(),e.arc(.25*-r,.28*-r,Math.max(1,.18*r),0,2*Math.PI),e.fillStyle="rgba(255,255,255,0.34)",e.fill();e.restore()}d(require("react")),require("react/jsx-runtime");var PT=require("react/jsx-runtime"),IT="var(--semiotic-text, #26323a)",RT="var(--semiotic-text-secondary, #6c7377)",TT="var(--semiotic-primary, #b8792d)",_T="var(--semiotic-danger, #9f3d35)",LT="var(--semiotic-success, #356b63)";function DT(e){const{x:t,y:n,width:o,height:r}=e.chamber,i=Math.min(.14*o,48),s=n+r;return[`M ${t} ${n}`,`L ${t+i} ${s-.16*r}`,`Q ${t+o/2} ${s+.1*r} ${t+o-i} ${s-.16*r}`,`L ${t+o} ${n}`].join(" ")}function NT({layout:e,phases:t,state:n,compact:o=!1}){const r=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return(0,PT.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[(0,PT.jsxs)("defs",{children:[(0,PT.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,PT.jsx)("stop",{offset:"0",stopColor:TT,stopOpacity:"0.03"}),(0,PT.jsx)("stop",{offset:"0.66",stopColor:TT,stopOpacity:"0.1"}),(0,PT.jsx)("stop",{offset:"1",stopColor:_T,stopOpacity:"0.18"})]}),(0,PT.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,PT.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:IT,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,PT.jsx)("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:IT,strokeOpacity:"0.52",strokeWidth:o?1:2.2}),(0,PT.jsx)("path",{d:DT(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,PT.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:IT,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:o?2:5}),o?null:(0,PT.jsx)("g",{"data-testid":"crucible-phase-rail",children:t.map((o,i)=>{const s=t.slice(0,i).reduce((e,t)=>e+Math.max(0,t.duration),0),a=e.phaseRail.x+s/r*e.phaseRail.width,c=Math.max(0,o.duration)/r*e.phaseRail.width,l=o.id===n.phaseId,u=n.phaseIndex>i||n.complete;return(0,PT.jsxs)("g",{children:[(0,PT.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?o.color??TT:u?LT:IT,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,PT.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?IT:RT,fontFamily:"system-ui, sans-serif",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(o.label??o.id).toUpperCase()})]},o.id)})}),e.outlets.map(e=>(0,PT.jsxs)("g",{children:[(0,PT.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?_T:LT),fillOpacity:"0.1",stroke:e.color??("left"===e.side?_T:LT),strokeDasharray:"3 3",strokeOpacity:"0.62"}),o?null:(0,PT.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:RT,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function $T(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function BT({rows:e,layout:t,projection:n,amountLabel:o}){if(!e.length)return null;const r=n.measure??"count",i=e.map(e=>Math.max(0,$T(e,r))),s=Math.max(1,...i),a=t.projection.width/Math.max(1,e.length),c=t.projection.height>48?21:4,l=Math.max(5,t.projection.height-c-5);return(0,PT.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,n)=>{const u=i[n],d=Math.max(u>0?2:0,u/s*l),h=t.projection.x+n*a+.18*a;return(0,PT.jsxs)("g",{children:[(0,PT.jsx)("rect",{x:h,y:t.projection.y+l-d,width:Math.max(3,.64*a),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?_T:"complete"===e.status?TT:LT,fillOpacity:"0.68"}),c>4&&a>=34?(0,PT.jsxs)(PT.Fragment,{children:[(0,PT.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:RT,fontFamily:"system-ui, sans-serif",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),(0,PT.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:IT,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:850,textAnchor:"middle",children:[AT(u),"amount"===r&&o?" "+o:""]})]}):null]},e.key)})})}function ET({controls:e,duration:t,elapsed:n,phaseLabel:o,playing:r,complete:i,playbackRate:s,disabled:a,onPlayPause:c,onReset:l,onStepPhase:u,onPlaybackRateChange:d}){const h=t>0?Math.min(1,Math.max(0,n/t)):1;return(0,PT.jsxs)("div",{"aria-label":"Crucible replay controls",className:"semiotic-crucible-controls",style:{alignItems:"center",color:IT,display:"flex",flexWrap:"wrap",fontFamily:"system-ui, sans-serif",fontSize:11,gap:6,marginBottom:7},children:[e.playPause?(0,PT.jsx)("button",{type:"button",disabled:a,onClick:c,"aria-pressed":r,children:r?"Pause":i?"Replay":"Play"}):null,e.stepPhase?(0,PT.jsx)("button",{type:"button",disabled:a,onClick:u,children:"Next phase"}):null,e.reset?(0,PT.jsx)("button",{type:"button",disabled:a,onClick:l,children:"Reset"}):null,e.timeline?(0,PT.jsxs)("div",{style:{alignItems:"center",display:"flex",flex:"1 1 150px",gap:7,minWidth:130},children:[(0,PT.jsx)("span",{style:{fontWeight:750,whiteSpace:"nowrap"},children:o}),(0,PT.jsx)("span",{"aria-hidden":"true",style:{background:"rgba(38,50,58,0.14)",borderRadius:2,flex:1,height:4,overflow:"hidden"},children:(0,PT.jsx)("span",{style:{background:TT,display:"block",height:"100%",transform:`scaleX(${h})`,transformOrigin:"left center"}})}),(0,PT.jsxs)("span",{style:{color:RT,fontVariantNumeric:"tabular-nums"},children:[n.toFixed(1),"s"]})]}):null,e.speed?(0,PT.jsxs)("label",{style:{alignItems:"center",display:"flex",gap:4},children:["Speed",(0,PT.jsxs)("select",{disabled:a,value:s,onChange:e=>d(Number(e.currentTarget.value)),children:[(0,PT.jsx)("option",{value:.25,children:"¼×"}),(0,PT.jsx)("option",{value:.5,children:"½×"}),(0,PT.jsx)("option",{value:1,children:"1×"}),(0,PT.jsx)("option",{value:2,children:"2×"})]})]}):null]})}function OT(e,t,n,o){const r="function"==typeof o?o(t,n):o,i=t.datum;return{fill:e,stroke:"product"===i?.kind?"var(--semiotic-bg, #fffaf0)":IT,strokeWidth:"product"===i?.kind?1.8:1.1,opacity:.96,...r}}var FT=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function zT(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function HT(e){return"number"==typeof e&&Number.isFinite(e)?e:zT((e??"crucible")+"")}function WT(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.max(.05,Math.min(8,t)):1}function qT(e,t,n){return"category"===t?e.category:"status"===t?e.status:"outlet"===t?e.outletId??"in chamber":"product"===t?e.productIds[0]??"unalloyed":function(e,t,n){return(("function"==typeof e?e(t,n):t[e])??"unassigned")+""}(t,e.datum,n)}function GT(e){return FT[zT(e)%FT.length]}function YT(e,t){const n=Object.keys(e.components).length,o=Object.keys(e.products).length,r=Object.values(e.products).reduce((e,t)=>e+t.amount,0),i=t?" "+t:" amount",s=e.outcome?` Outcome: ${e.outcome}.`:"";return`${n} source component${1===n?"":"s"}; ${o} product${1===o?"":"s"}; ${r.toLocaleString()}${i} in products.${s}`}var VT=require("react/jsx-runtime"),XT=require("react"),UT=(0,SR.forwardRef)(function(e,t){const{amountAccessor:n,amountLabel:o,bodyRadius:r,categoryAccessor:i,colorBy:s="category",conservation:a,controls:c,data:l,emptyContent:u,events:d,frameProps:h={},idAccessor:p,initialStateAccessor:m,initialSpawnPacing:y,labelAccessor:f,loading:g,loadingContent:b,metrics:v,metricsAccessor:x,onClick:w,onConservation:k,onCrucibleObservation:S,onDiagnostic:A,onStateChange:C,outlets:M,paused:j,phases:P,playback:I="replay",playbackRate:R=1,products:T,projection:_,radiusRange:L,rerunMS:D,responsiveHeight:N,responsiveWidth:$,seed:B,showBonds:E=!0,snapshotAt:O}=e,F=(0,SR.useRef)(null),z=(0,SR.useRef)(j);z.current=j;const H=yu(),W=Uc(),q=OP(e,WR),{chartMode:G,chartSize:Y,showChrome:V,showProjection:X,className:U,title:K,description:Q,summary:Z,accessibleTable:J,enableHover:ee,margin:te}=q,[ne,oe]=gu(Y,$,!1),re=$?Math.max(1,oe[0]):Y[0],ie=Y[1],se=(0,SR.useMemo)(()=>[re,ie],[ie,re]),ae=(0,SR.useMemo)(()=>ft(l??[]),[l]),ce=(0,SR.useMemo)(()=>mT({data:ae,phases:P,products:T,outlets:M,events:d,idAccessor:p,labelAccessor:f,categoryAccessor:i,amountAccessor:n,metricsAccessor:x,initialStateAccessor:m,metrics:v,size:se,seed:B,bodyRadius:r,radiusRange:L}),[n,r,i,d,p,m,f,v,x,M,P,T,L,se,ae,B]),le=Object.values(ce.initialState.components).map((e,t)=>qT(e,s,t)).join("\0"),ue=`${ce.semanticKey}:${se[0]}x${se[1]}:${(r??"auto")+""}:${L?.join(",")??"auto"}:${le}`,de=(0,SR.useRef)(ce),he=(0,SR.useRef)(ue);he.current!==ue&&(he.current=ue,de.current=ce);const pe=de.current,me="snapshot"===I||H||W,ye=me?function(e,t){return function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,KR(t)??0));const n=e.phases.find(e=>e.id===t.phaseId);if(!n)return e.duration;const o=Math.max(0,Math.min(1,KR(t.progress??0)??0));return n.start+n.duration*o}(e,t)}(pe,O):0,fe=!me,ge=(0,SR.useMemo)(()=>fT(pe,ye,fe&&!j),[he.current,ye,fe]),[be,ve]=(0,SR.useState)(ge),xe=(0,SR.useRef)(be),[we,ke]=(0,SR.useState)(fe),Se=(0,SR.useRef)(we),[Ae,Ce]=(0,SR.useState)(0),[Me,je]=(0,SR.useState)(()=>WT(R)),Pe=(0,SR.useRef)(wT(pe,ge.state,{seed:B,bodyRadius:r,radiusRange:L})),Ie=(0,SR.useRef)(""),Re=(0,SR.useRef)(C),Te=(0,SR.useRef)(S),_e=(0,SR.useRef)(A),Le=(0,SR.useRef)(k);Re.current=C,Te.current=S,_e.current=A,Le.current=k;const De=(0,SR.useRef)({seed:B,bodyRadius:r,radiusRange:L});De.current={seed:B,bodyRadius:r,radiusRange:L};const Ne=(0,SR.useCallback)((e,t=!1)=>{if(xe.current=e,Pe.current=wT(de.current,e.state,De.current),ve(e),t)for(const t of e.observations)Te.current?.(t)},[]);(0,SR.useEffect)(()=>{je(WT(R))},[R]),(0,SR.useEffect)(()=>{const e=!me,t=fT(pe,me?ye:0,e&&!z.current);Se.current=e,ke(e),Ne(t)},[Ne,pe,ye,me,ue]),(0,SR.useEffect)(()=>{const e=xe.current,t=Se.current&&!j&&!e.state.complete;if(e.state.playing===t)return;const n={...e,state:PR(e.state)};n.state.playing=t,Ne(n)},[Ne,j]),(0,SR.useEffect)(()=>{for(const e of pe.diagnostics)_e.current?.(e)},[ue,pe.diagnostics]),(0,SR.useEffect)(()=>{if(Re.current?.(be.state),a){const e=!0===a?{}:a;Le.current?.(function(e,t={}){const n=t.field??"amount",o=e=>"amount"===n?e.amount:Number(e.metrics[n]??0),r="amount"===n?e.input.amount:Number(e.input.metrics[n]??0),i=Object.values(e.products).reduce((e,t)=>e+o(t),0),s=Object.values(e.components).filter(e=>!e.productIds.length&&"consumed"!==e.status).reduce((e,t)=>e+o(t),0),a="amount"===n?e.loss.amount:Number(e.loss.metrics[n]??0),c=i+s+a,l=c-r;return{field:n,input:r,products:i,unassigned:s,loss:a,output:c,delta:l,conserved:Math.max(0,t.tolerance??1e-6)>=Math.abs(l)}}(be.state,e))}},[a,be.state]);const $e=(0,SR.useCallback)(()=>{Ie.current="";const e=!me,t=fT(de.current,0,e&&!j);Se.current=e,ke(e),Ne(t)},[Ne,j,me]),Be=(0,SR.useMemo)(()=>({...pe.config,...h.config,fixedDt:h.config?.fixedDt??pe.config.fixedDt,maxSubsteps:h.config?.maxSubsteps??pe.config.maxSubsteps,settleStepLimit:h.config?.settleStepLimit??pe.config.settleStepLimit,timeScale:Me,colliders:[...pe.config.colliders??[],...h.config?.colliders??[]],kernel:{...pe.config.kernel,...h.config?.kernel,gravity:h.config?.kernel?.gravity??pe.config.kernel?.gravity??{x:0,y:0}},observation:{...pe.config.observation,...h.config?.observation,chartType:"CrucibleChart"}}),[h.config,Me,pe.config]),Ee=me||!!j||!we&&!be.state.complete,Oe=EP(Be,D,Ee,$e),Fe=(0,SR.useCallback)(()=>{if("number"!=typeof D||!Number.isFinite(D)||0>D)return;const e=`${ue}:${Ae}:${Oe.rerunKey}`;Ie.current!==e&&(Ie.current=e,Oe.config?.observation?.onSimulationStateChange?.("settled","running"))},[Oe.config,Oe.rerunKey,D,Ae,ue]),ze=(0,SR.useCallback)(()=>{const e=fT(de.current,0,!1);Se.current=!1,ke(!1),Ne(e),Ce(e=>e+1)},[Ne]),He=(0,SR.useCallback)(()=>{const e=de.current,t=gT(e,xe.current.state,e.duration,!1);Se.current=!1,ke(!1),Ne(t,!0);const n=bT(e,t.state,De.current),o=F.current;o&&(o.clear(),o.pushMany(n),o.step(0),o.settle()),Fe()},[Ne,Fe]),We=(0,SR.useCallback)(()=>{Se.current=!1,ke(!1);const e={...xe.current,state:PR(xe.current.state)};e.state.playing=!1,Ne(e)},[Ne]),qe=(0,SR.useCallback)(()=>{if(Ie.current="",me){const e=fT(de.current,ye,!1);return Se.current=!1,ke(!1),Ne(e),void Ce(e=>e+1)}const e=fT(de.current,0,!j);Se.current=!0,ke(!0),Ne(e),Ce(e=>e+1)},[Ne,j,ye,me]),Ge=(0,SR.useCallback)(()=>{if(me)return void qe();if(xe.current.state.complete)return void qe();Se.current=!0,ke(!0);const e={...xe.current,state:PR(xe.current.state)};e.state.playing=!j,Ne(e)},[Ne,j,qe,me]),Ye=(0,SR.useCallback)(()=>{const e=de.current,t=function(e,t){const n=e.phases.find(e=>e.end>t+1e-7);return n?.end??e.duration}(e,xe.current.state.elapsed),n=gT(e,xe.current.state,t,!1);Se.current=!1,ke(!1),Ne(n,!0);const o=F.current;o&&(o.clear(),o.pushMany(bT(e,n.state,De.current)),o.step(0))},[Ne]);(0,SR.useImperativeHandle)(t,()=>({play:Ge,pause:We,reset:ze,replay:qe,stepPhase:Ye,settle:He,getCrucibleState:()=>PR(xe.current.state)}),[We,Ge,qe,ze,He,Ye]);const Ve=(0,SR.useCallback)((e,t)=>{if(h.onTick?.(e,t),me||j||!Se.current)return;const n=xe.current.state,o=Math.min(de.current.duration,e.elapsedSeconds);if(n.elapsed+.045>=o&&de.current.duration>o)return;const r=gT(de.current,n,o,de.current.duration>o),i=r.state.eventsApplied.length!==n.eventsApplied.length;if(i&&function(e,t){const n=new Set(e.readBodies().map(e=>e.id)),o=t.filter(e=>!n.has(e.id));o.length&&e.pushMany([...o]),o.map(e=>e.id)}(t,bT(de.current,r.state,De.current)),r.state.complete){Se.current=!1,ke(!1);const e=bT(de.current,r.state,De.current);t.clear(),t.pushMany(e),t.step(0),t.settle()}Ne(r,i),r.state.complete&&Fe()},[Ne,h,j,Fe,me]),Xe=(0,SR.useCallback)(({body:e})=>function(e){const t=function(e){const{body:t,plan:n,state:o,targets:r}=e,i=t.datum;if(!i?.__crucible)return null;let s=r.get(`${i.kind}:${i.semanticId}`);if(!s)return null;const a=xT(n,o),c=Math.max(0,Math.min(2,Number(a?.intensity??.5))),l=a?.motion??"hold",u=o.elapsed;if("product"===i.kind){const e=o.products[i.semanticId];"forming"===e?.status&&(s=kT(n,e.id))}else{const e=o.components[i.semanticId],t=e?.productIds.map(e=>o.products[e]).find(e=>"forming"===e?.status);if(t){const o=kT(n,t.id),r=vT(e.id,17)*Math.PI*2,i=Math.max(5,Math.min(18,.026*n.layout.width));s={x:o.x+Math.cos(r)*i,y:o.y+Math.sin(r)*i}}}const d=i.semanticId,h=vT(d,23)*Math.PI*2;if(!o.complete&&!(n.layout.chamber.x>s.x||s.x>n.layout.chamber.x+n.layout.chamber.width||n.layout.chamber.y>s.y||s.y>n.layout.chamber.y+n.layout.chamber.height))if("mix"===l){const e=Math.min(34,.1*n.layout.chamber.width)*c,t=Math.min(24,.09*n.layout.chamber.height)*c;s={x:s.x+Math.cos(u*(1.4+vT(d,29))+h)*e,y:s.y+Math.sin(u*(1.8+vT(d,31))+h)*t}}else if("press"===l){const e=n.layout.chamber.x+n.layout.chamber.width/2,t=n.layout.chamber.y+.56*n.layout.chamber.height;s={x:e+(s.x-e)*Math.max(.3,1-.32*c),y:t+(s.y-t)*Math.max(.35,1-.26*c)}}else if("separate"===l){const e=.5>vT(d,41)?-1:1;s={x:s.x+e*Math.min(28,.075*n.layout.chamber.width)*c,y:s.y}}else if("bind"===l){const e=n.layout.chamber.x+n.layout.chamber.width/2,t=n.layout.chamber.y+.5*n.layout.chamber.height;s={x:e+.72*(s.x-e),y:t+.72*(s.y-t)}}else"charge"===l?s={x:s.x,y:s.y+4*Math.sin(2*u+h)*c}:"quench"===l&&(s={x:s.x+2*Math.sin(h)*c,y:s.y});return s}(e);if(!t)return null;const{body:n,state:o}=e,r=t.x-n.x,i=t.y-n.y,s=Math.hypot(r,i),a=Math.hypot(n.vx,n.vy);if(o.complete&&.7>s&&.45>a)return null;const c=!o.complete&&"pour"===xT(e.plan,o)?.motion,l=o.complete?.68:c?.72:.5,u=o.complete?.22:c?.18:.14,d=o.complete?42:c?72:56;return{x:Math.max(-d,Math.min(d,r*l-n.vx*u)),y:Math.max(-d,Math.min(d,i*l-n.vy*u))}}({body:e,plan:de.current,state:xe.current.state,targets:Pe.current}),[]),Ue=(0,SR.useMemo)(()=>new Map(Object.keys(pe.initialState.components).map((e,t)=>[e,t])),[pe.initialState.components]),Ke=(0,SR.useCallback)(t=>{if(e.color)return e.color;const n=t.datum;if(!n?.__crucible)return"var(--semiotic-primary, #b8792d)";if("product"===n.kind){const e=xe.current.state.products[n.semanticId];return e?.color??GT(e?.id??n.semanticId)}const o=xe.current.state.components[n.semanticId];return o?GT(qT(o,s,Ue.get(o.id)??0)):"var(--semiotic-primary, #356b63)"},[s,Ue,e.color]),Qe=(0,SR.useCallback)((t,n)=>({...OT(Ke(t),t,n,h.bodyStyle),...void 0!==e.stroke?{stroke:e.stroke}:null,...void 0!==e.strokeWidth?{strokeWidth:e.strokeWidth}:null,...void 0!==e.opacity?{opacity:e.opacity}:null}),[Ke,h.bodyStyle,e.opacity,e.stroke,e.strokeWidth]),Ze=(0,SR.useCallback)((e,t)=>("function"==typeof h.bodySemanticItems?h.bodySemanticItems(e,t):void 0)??function(e,t){const n=e.datum;if(!n?.__crucible)return!1;if("component"===n.kind){const e=t.components[n.semanticId];return!!e&&{id:"crucible-component-"+e.id,label:e.label,description:CT(e),group:"source component · "+e.status,datum:e}}const o=t.products[n.semanticId];return!!o&&{id:"crucible-product-"+o.id,label:o.label,description:MT(o),group:"derived product · "+o.status,datum:o}}(e,xe.current.state),[h]),Je=(0,SR.useCallback)(e=>{if(!w||!e||"object"!=typeof e)return;if(!e.__crucible)return;const t=xe.current.state,n="component"===e.kind?t.components[e.semanticId]:t.products[e.semanticId];n&&w(n)},[w]),et=(0,SR.useCallback)((e,t)=>{h.beforePaint?.(e,t),E&&function(e,t,n){const o=new Map;for(const e of t){const t=e.datum;t?.__crucible&&o.set(`${t.kind}:${t.semanticId}`,e)}e.save(),e.lineCap="round";for(const t of Object.values(n.relations)){if("active"!==t.status)continue;const n=t.sourceIds.map(e=>o.get("component:"+e)).filter(e=>!!e);2>n.length||(e.strokeStyle="rejected"===t.category?"#9f3d35":"#b8792d",e.globalAlpha=.4,e.lineWidth=Math.max(.8,1.3*Number(t.strength??1)),e.setLineDash([3,4]),e.beginPath(),n.forEach((t,n)=>{0===n?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)}),e.stroke())}e.setLineDash([]);for(const t of Object.values(n.products)){const n=o.get("product:"+t.id);if(n)for(const r of t.sourceIds){const i=o.get("component:"+r);i&&(e.strokeStyle=t.color??"#b8792d",e.globalAlpha="complete"===t.status?.5:.28,e.lineWidth="complete"===t.status?1.6:1,e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(n.x,n.y),e.stroke())}}e.restore()}(e,t,xe.current.state)},[h,E]),tt=(0,SR.useMemo)(()=>_??{groupBy:"outlet",measure:"count"},[_]),nt=(0,SR.useMemo)(()=>function(e,t={}){const n=t.groupBy??"outlet",o=new Map,r=e=>{const t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},n),r=o.get(t);if(r)return r.count+=1,r.amount+=e.amount,void _R(r.metrics,e.metrics);o.set(t,{key:t,label:"product"===n&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:{...e.metrics},status:"status"===n?e.status:void 0,outletId:"outlet"===n?e.outletId:void 0,category:"category"===n?e.category:void 0,productId:"product"===n&&"product"===e.kind?e.id:void 0})};for(const t of Object.values(e.components))t.productIds.length||"consumed"===t.status||r({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(const t of Object.values(e.products))r({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});const i=new Map((t.order??[]).map((e,t)=>[e,t]));return[...o.values()].sort((e,t)=>(i.get(e.key)??Number.MAX_SAFE_INTEGER)-(i.get(t.key)??Number.MAX_SAFE_INTEGER)||CR(e.key,t.key))}(be.state,tt),[tt,be.state]),ot=(0,SR.useMemo)(()=>X?function(e,t,n,o){if(!e.length)return[];const r=n.measure??"count",i=t.projection.width/Math.max(1,e.length);return e.map((e,n)=>{const s=$T(e,r),a="amount"===r&&o?`${AT(s)} ${o}`:`${AT(s)} ${r}`;return{id:"crucible-projection-"+e.key,label:`${e.label}: ${a}`,description:`${e.count} source component${1===e.count?"":"s"}; ${AT(e.amount)} amount.`,datum:e,group:"settled composition",x:t.projection.x+(n+.5)*i,y:t.projection.y+t.projection.height/2,shape:"rect",width:Math.max(12,.62*i),height:Math.max(8,t.projection.height-8)}})}(nt,pe.layout,tt,o):[],[o,pe.layout,tt,nt,X]),rt=WP(e.tooltip,h),{selection:it,onBodyHover:st}=$P({selection:e.selection,linkedHover:e.linkedHover,colorBy:s,chartType:"CrucibleChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:h?.onBodyHover}),at=qP({...e,onClick:void 0},h,ot,{selection:it,chartMode:G,className:U,title:K??"Crucible",description:Q??"A bounded inventory is transformed by an authored phase and event tape; physics explains the motion but does not determine the outcome.",summary:Z??YT(be.state,o),accessibleTable:J,enableHover:ee,margin:te}),ct=HP(V?(0,VT.jsx)(NT,{layout:pe.layout,phases:pe.phases,state:be.state,compact:q.compactMode||360>se[0]||260>se[1]}):void 0,h.backgroundGraphics),lt=HP(X?(0,VT.jsx)(BT,{rows:nt,layout:pe.layout,projection:tt,amountLabel:o}):void 0,h.foregroundGraphics),ut=(0,SR.useCallback)(e=>function(e,t){const n=e.data;if(!n?.__crucible)return null;const o="component"===n.kind?t.components[n.semanticId]:t.products[n.semanticId];if(!o)return null;const r="product"===n.kind;return(0,PT.jsxs)("div",{className:"semiotic-tooltip semiotic-crucible-tooltip",style:{background:"var(--semiotic-tooltip-bg, rgba(38, 50, 58, 0.96))",border:"1px solid rgba(255,255,255,0.2)",borderRadius:3,boxShadow:"0 8px 24px rgba(0,0,0,0.28)",color:"var(--semiotic-tooltip-text, #fffaf0)",maxWidth:290,padding:"9px 12px"},children:[(0,PT.jsx)("strong",{children:o.label}),(0,PT.jsx)("div",{style:{opacity:.78,fontSize:11,letterSpacing:"0.06em",textTransform:"uppercase"},children:r?"Product · "+o.status:"Source · "+o.status}),(0,PT.jsx)("div",{style:{marginTop:4},children:r?MT(o):CT(o)})]})}(e,xe.current.state),[]),dt=me?bT(pe,be.state,De.current):pe.initialSpawns,ht=function(e){return e?!0===e?{playPause:!0,reset:!0,stepPhase:!0,timeline:!0,speed:!0}:{playPause:e.playPause??!0,reset:e.reset??!0,stepPhase:e.stepPhase??!0,timeline:e.timeline??!0,speed:e.speed??!1}:{playPause:!1,reset:!1,stepPhase:!1,timeline:!1,speed:!1}}(c),pt=Object.values(ht).some(Boolean),mt=pe.phases[be.state.phaseIndex],yt=FP({data:l,emptyContent:u,loading:g,loadingContent:b,size:se});if(yt)return yt;const gt=pe.diagnostics.filter(e=>"error"===e.severity);return gt.length?(0,VT.jsxs)("div",{className:U,role:"alert",style:{maxWidth:"100%",width:se[0]},children:[(0,VT.jsx)("strong",{children:"CrucibleChart could not compile this treatment tape."}),(0,VT.jsx)("ul",{children:gt.map((e,t)=>(0,VT.jsx)("li",{children:e.message},`${e.code}-${t}`))})]}):zP("CrucibleChart",se,(0,VT.jsxs)("div",{ref:ne,className:"semiotic-crucible-chart",style:{maxWidth:"100%",overflow:"hidden",position:"relative",width:$?"100%":se[0]},children:[pt?(0,VT.jsx)(ET,{controls:ht,duration:pe.duration,elapsed:be.state.elapsed,phaseLabel:mt?.label??mt?.id??"Complete",playing:we&&!j,complete:be.state.complete,playbackRate:Me,disabled:me,onPlayPause:we?We:Ge,onReset:ze,onStepPhase:Ye,onPlaybackRateChange:je}):null,(0,XT.createElement)(Xj,{...h,...rt,...at,key:`${ue}:${Ae}:${Oe.rerunKey}:${me?ye:"replay"}`,ref:F,onBodyHover:st,accessibleTable:e.accessibleTable??h.accessibleTable,backgroundGraphics:ct,bodyForces:Xe,bodySemanticItems:Ze,bodyStyle:Qe,beforePaint:et,config:Oe.config,continuous:!me&&we&&!j&&!be.state.complete,enableHover:rt.enableHover??ee,foregroundGraphics:lt,hoverRadius:e.hoverRadius??h.hoverRadius??18,initialSpawns:dt,initialSpawnPacing:y,onClick:w?Je:at.onClick,onTick:Ve,paused:Ee,renderBody:h.renderBody??jT,responsiveHeight:N,responsiveWidth:!1,seed:HT(B),size:se,tooltipContent:rt.tooltipContent??ut})]}))});UT.displayName="CrucibleChart";var KT=require("react");function QT(e,t,n={}){const o=new Set,r=[...e.get(t)??[]];let i=0;for(;r.length>i;){const t=r[i];if(i+=1,!o.has(t)){o.add(t);for(const n of e.get(t)??[])r.push(n)}}return n.includeStart&&o.add(t),o}function ZT(e,t,n){return function(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}(n,e,t)}function JT(e,t){return t>e?-1:e>t?1:0}function e_(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function t_(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function n_(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function o_(e,t,n={}){const o=new Set(n.completedTaskIDs??[]),r=[...QT(function(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target);return n}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(n.isComplete?n.isComplete(e):o.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),i=Array.from(new Set(r.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:r.length,affectedLaneCount:i.length,downstreamTaskIDs:r.map(e=>e.id),affectedLanes:i}}var r_=[];function i_(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function s_(e){if(null==e.completionTime)return null;const t=i_(e.completionTime,NaN);return Number.isFinite(t)?t:null}function a_(e,t,n,o){const r=new Set;for(const i of e.nodes){const s=e.incoming.get(i.id)??[];(o.has(i.id)||!n.has(i.id)&&s.every(e=>t.has(e.id)))&&r.add(i.id)}return r}function c_(e,t,n,o){const r=e.nodes.map(s_).filter(e=>null!=e),i=r.length?Math.min(...r)-1:0,s="replay"!==t||o?n:i,a=new Set,c=new Map;for(const n of e.nodes){const e=s_(n);(null!=e&&s>=e||"done"===n.status&&"replay"!==t)&&a.add(n.id),n.blockerReason&&!a.has(n.id)&&c.set(n.id,n.blockerReason)}const l=new Set;if("replay"!==t||o)for(const t of e.edges)a.has(t.sourceID)&&l.add(t.id);return{currentTime:s,playing:!1,completed:a,delivered:l,inFlight:new Set,armed:a_(e,l,c,a),blockers:c,previewTaskID:null}}function l_(e){return{...e,completed:new Set(e.completed),delivered:new Set(e.delivered),inFlight:new Set(e.inFlight),armed:new Set(e.armed),blockers:new Map(e.blockers)}}function u_(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function d_(e){const t=u_(e.body);if(!t||2>t.route.length)return null;const n=function(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}(t.route),o=function(e,t){let n=1/0,o=0,r=0;for(let i=1;t.length>i;i+=1){const s=t[i-1],a=t[i],c=a.x-s.x,l=a.y-s.y,u=c*c+l*l,d=Math.sqrt(u);if(0>=d)continue;const h=Math.max(0,Math.min(1,((e.x-s.x)*c+(e.y-s.y)*l)/u)),p=Math.hypot(e.x-(s.x+c*h),e.y-(s.y+l*h));n>p&&(n=p,o=r+h*d),r+=d}return o}(e.body,t.route),r=function(e,t){if(2>e.length)return{point:e[0]??{x:0,y:0},tangent:{x:0,y:1}};let n=0;for(let o=1;e.length>o;o+=1){const r=e[o-1],i=e[o],s=i.x-r.x,a=i.y-r.y,c=Math.hypot(s,a);if(c>0){if(n+c>=t){const e=Math.max(0,Math.min(1,(t-n)/c));return{point:{x:r.x+s*e,y:r.y+a*e},tangent:{x:s/c,y:a/c}}}n+=c}}const o=e[e.length-2],r=e[e.length-1],i=r.x-o.x,s=r.y-o.y,a=Math.hypot(i,s)||1;return{point:r,tangent:{x:i/a,y:s/a}}}(t.route,Math.min(n,o+22));return{x:2.5*(78*r.tangent.x-e.body.vx)+8*(r.point.x-e.body.x),y:2.5*(78*r.tangent.y-e.body.vy)+8*(r.point.y-e.body.y)}}function h_(e,t){const n=t.points[0]??{x:0,y:0},o=t.points[1]??n,r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i)||1;return{id:"dependency-ball:"+e.id,x:n.x,y:n.y,vx:r/s*42,vy:i/s*42,mass:.7,restitution:.02,friction:.12,bodyCollisions:!1,shape:{type:"circle",radius:5},datum:{kind:"dependency-ball",edgeID:e.id,sourceID:e.sourceID,targetID:e.targetID,route:t.points}}}var p_=require("react/jsx-runtime");function m_({machine:e,layout:t,runtime:n,downstreamSet:o,selectedSet:r,width:i,height:s,seed:a,reduced:c,onSelectTask:l}){const u=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);return(0,p_.jsxs)("svg",{"aria-hidden":"true",width:i,height:s,viewBox:`0 0 ${i} ${s}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[(0,p_.jsx)("defs",{children:(0,p_.jsx)("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:(0,p_.jsx)("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,n)=>{const o=t.tasks.filter(e=>e.laneIndex===n),r=o[0]?.x??0;return(0,p_.jsxs)("g",{children:[(0,p_.jsx)("line",{x1:r,x2:r,y1:h,y2:s-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),(0,p_.jsx)("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{const t=n.delivered.has(e.edgeID),r=n.inFlight.has(e.edgeID),i=o.has(e.targetID)||o.has(e.sourceID),s=e.points.map(e=>`${e.x},${e.y}`).join(" ");return(0,p_.jsx)("polyline",{points:s,fill:"none",stroke:i?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:i?4:r?3:2,strokeOpacity:t||r||i?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{const t=n.delivered.has(e.edgeID);return(0,p_.jsxs)("g",{children:[(0,p_.jsx)("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&(0,p_.jsx)("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{const i=t.taskByID.get(e.id);if(!i)return null;const s=n.completed.has(e.id),u=n.blockers.has(e.id),d=n.previewTaskID===e.id,h=r.has(e.id)||d,p=o.has(e.id),m=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(e,n),y=i.x-i.width/2,f=i.y-i.height/2,g=Math.max(2,i.height*e.progress);return(0,p_.jsxs)("g",{children:[(0,p_.jsxs)("g",{style:{transform:`rotate(${s?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:c?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+a+")"},children:[(0,p_.jsx)("rect",{x:y,y:f,width:i.width,height:i.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||p?"var(--semiotic-selection-color, #e08a1e)":m,strokeWidth:h?4:p?3:2}),(0,p_.jsx)("rect",{x:y+3,y:f+i.height-g+1,width:i.width-6,height:Math.max(0,g-4),rx:2,fill:m,opacity:s?.86:.46})]}),u&&(0,p_.jsxs)("g",{opacity:d?.28:1,children:[(0,p_.jsx)("line",{x1:y-8,x2:y+14,y1:i.y+9,y2:i.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),(0,p_.jsx)("circle",{cx:y-8,cy:i.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),(0,p_.jsxs)("g",{onPointerDown:()=>l(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[(0,p_.jsx)("rect",{x:y,y:f,width:i.width,height:i.height,fill:"transparent"}),(0,p_.jsx)("text",{x:i.x,y:i.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),(0,p_.jsxs)("text",{x:i.x,y:i.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",s?"done":u?"blocked":n.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}var y_=require("react/jsx-runtime"),f_={border:0,clip:"rect(0 0 0 0)",clipPath:"inset(50%)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},g_=(0,KT.forwardRef)(function(e,t){const{data:n,taskIDAccessor:o,labelAccessor:r,laneAccessor:i,dependencyAccessor:s,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:u,completionTimeAccessor:d,blockerAccessor:h,milestoneAccessor:p,mode:m="snapshot",insight:y="blocker-amplification",currentTime:f,controls:g=!1,selectedTaskIDs:b,onSelectionChange:v,onObservation:x,reducedMotion:w,seed:k=31,width:S=920,height:A=620,responsiveWidth:C,responsiveHeight:M,title:j="Dependency chain reaction",description:P,className:I,accessibleTable:R=!0,enableHover:T=!0}=e,_=(0,KT.useRef)(null),[L,D]=(0,KT.useState)([]),N=b?Array.from(b):L,$=(0,KT.useMemo)(()=>new Set(N),[N]),B=i_(f,1/0),E="settle"===w,O=(0,KT.useMemo)(()=>function(e){const t=[],n=new Map,o=[],r=new Set;e.data.forEach((i,s)=>{const a=(ZT(i,s,e.taskIDAccessor)??"")+"";if(!a)return void t.push({code:"duplicate-task-id",message:`Task row ${s} has an empty id.`,taskIDs:[]});if(n.has(a))return void t.push({code:"duplicate-task-id",message:`Task id "${a}" occurs more than once.`,taskIDs:[a]});const c=(ZT(i,s,e.laneAccessor)??"Unassigned")+"";r.has(c)||(r.add(c),o.push(c));const l=ZT(i,s,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,e=>e+""))).sort(JT),d=ZT(i,s,e.blockerAccessor),h=ZT(i,s,e.statusAccessor)??(d?"blocked":"waiting");n.set(a,{id:a,label:(ZT(i,s,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:i,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:ZT(i,s,e.startAccessor),end:ZT(i,s,e.endAccessor),progress:n_(ZT(i,s,e.progressAccessor)),status:h,completionTime:ZT(i,s,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!ZT(i,s,e.milestoneAccessor)})});const i=e.laneOrder?[...e.laneOrder,...o.filter(t=>!e.laneOrder?.includes(t))]:o,s=new Map(i.map((e,t)=>[e,t]));for(const e of n.values())e.laneIndex=s.get(e.lane)??0;const a=new Map,c=new Map;for(const e of n.keys())a.set(e,[]),c.set(e,[]);const l=[],u=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of u)e.dependencyIDs.forEach((o,r)=>{const i=n.get(o);if(!i)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${o}".`,taskIDs:[e.id,o]});const s={id:e_(o,e.id),sourceID:o,targetID:e.id,sourceIndex:i.index,targetIndex:e.index,socketID:t_(e.id,r),socketIndex:r};l.push(s),a.get(e.id)?.push(s),c.get(o)?.push(s),e.incomingEdgeIDs.push(s.id),e.socketIDs.push(s.socketID),i.outgoingEdgeIDs.push(s.id)});for(const e of a.values())e.sort((e,t)=>JT(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=t_(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>JT(e.targetID,t.targetID));for(const e of n.values()){const t=a.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(c.get(e.id)??[]).map(e=>e.id)}const d=new Map,h=new Map;for(const e of n.keys())d.set(e,a.get(e)?.length??0),h.set(e,0);const p=[...n.keys()].filter(e=>0===d.get(e)).sort(JT);let m=0;for(;p.length;){const e=p.shift();m+=1;for(const t of c.get(e)??[]){const n=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,n);const o=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,o),0===o){const e=p.findIndex(e=>e>t.targetID);0>e?p.push(t.targetID):p.splice(e,0,t.targetID)}}}if(m!==n.size){const e=[...n.keys()].filter(e=>(d.get(e)??0)>0).sort(JT);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let y=0;const f=[...n.values()].sort((e,t)=>e.index-t.index);for(const e of f)e.level=h.get(e.id)??0,y=Math.max(y,e.level);return{nodes:f,edges:l,byID:n,incoming:a,outgoing:c,lanes:i,maxLevel:y,diagnostics:t,valid:0===t.length}}({data:n,taskIDAccessor:o,labelAccessor:r,laneAccessor:i,dependencyAccessor:s,startAccessor:a,endAccessor:c,progressAccessor:l,statusAccessor:u,completionTimeAccessor:d,blockerAccessor:h,milestoneAccessor:p}),[n,o,r,i,s,a,c,l,u,d,h,p]),F=(0,KT.useMemo)(()=>function(e,t,n={}){const o=Math.max(240,t.width),r=Math.max(220,t.height),i=t.paddingX??48,s=t.paddingTop??48,a=t.paddingBottom??44,c=Math.max(70,(o-2*i)/Math.max(1,e.lanes.length)),l=Math.max(76,(r-s-a)/Math.max(1,e.maxLevel+1)),u=Math.min(n.taskWidth??112,Math.max(58,.78*c)),d=Math.min(n.taskHeight??58,.64*l),h=n.socketRadius??5,p=Math.max(1,Math.round(n.gutterCount??3)),m=new Map;for(const t of e.nodes){const e=`${t.laneIndex}:${t.level}`,n=m.get(e)??[];n.push(t),m.set(e,n)}for(const e of m.values())e.sort((e,t)=>JT(e.id,t.id));const y=.86*l,f=e.nodes.map(e=>{const t=m.get(`${e.laneIndex}:${e.level}`)??[e],n=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,o=(r=t.length)>1?Math.max(22,Math.min(d,(y-4*(r-1))/r)):d;var r;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:i+c*(e.laneIndex+.5),y:s+l*(e.level+.5)+n*(o+4),width:u,height:o}}),g=new Map(f.map(e=>[e.taskID,e])),b=[],v=[];e.edges.forEach((t,n)=>{const o=g.get(t.sourceID),r=g.get(t.targetID);if(!o||!r)return;const i=e.incoming.get(t.targetID)??[],s=Math.min(.72*r.width,14*Math.max(1,i.length-1)),a=i.length>1?r.x-s/2+s*t.socketIndex/(i.length-1):r.x,c=r.y-r.height/2-h-2;b.push({id:t.socketID,edgeID:t.id,taskID:r.taskID,index:t.socketIndex,x:a,y:c,radius:h});const l={x:o.x,y:o.y+o.height/2+3},u=Math.min(c-10,l.y+.48*Math.max(18,c-l.y)+7*(n%p-(p-1)/2));var d;v.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(d=[l,{x:l.x,y:u},{x:a,y:u},{x:a,y:c}],d.filter((e,t)=>{const n=d[t-1];return!n||n.x!==e.x||n.y!==e.y}))})});const x=new Map(b.map(e=>[e.id,e])),w=new Map(v.map(e=>[e.edgeID,e]));return{tasks:f,sockets:b,routes:v,taskByID:g,socketByID:x,routeByEdgeID:w}}(O,{width:S,height:A}),[O,S,A]),[z,H]=(0,KT.useState)(()=>c_(O,m,B,E)),W=(0,KT.useRef)(z),q=(0,KT.useCallback)(e=>{W.current=e,H(e)},[]),G=(0,KT.useCallback)(e=>x?.(e),[x]);(0,KT.useEffect)(()=>{const e=c_(O,m,B,E);_.current?.clear(),W.current=e,H(e)},[O,m,B,E]);const Y=(0,KT.useCallback)(e=>{const t=$.has(e)?N.filter(t=>t!==e):[e];b||D(t),v?.(t)},[b,v,$,N]),V=(0,KT.useCallback)(e=>{if(E)return;const t=l_(W.current),n=[];for(const o of O.outgoing.get(e)??[]){if(t.delivered.has(o.id)||t.inFlight.has(o.id))continue;const e=F.routeByEdgeID.get(o.id);e&&(t.inFlight.add(o.id),n.push(h_(o,e)))}n.length&&(q(t),_.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[q,F,O,E]),X=(0,KT.useCallback)((e,t)=>{const n=O.byID.get(e),o=W.current;if(!n||o.completed.has(e))return;const r=l_(o);r.completed.add(e),r.blockers.delete(e),r.armed.add(e),null!=t&&(r.currentTime=t),q(r),G({type:"task-completed",taskID:e,datum:n.datum}),V(e)},[q,G,O,V]),U=(0,KT.useCallback)(e=>{const t=l_(W.current),n=[],o=[];for(const o of e){if(t.delivered.has(o))continue;const e=O.edges.find(e=>e.id===o);e&&(t.delivered.add(o),t.inFlight.delete(o),n.push(e))}for(const e of n){const n=O.byID.get(e.targetID);!n||t.blockers.has(n.id)||t.armed.has(n.id)||(O.incoming.get(n.id)??[]).every(e=>t.delivered.has(e.id))&&(t.armed.add(n.id),o.push(n.id))}if(n.length){q(t);for(const e of n)G({type:"dependency-delivered",sourceID:e.sourceID,targetID:e.targetID});for(const e of o)G({type:"task-armed",taskID:e})}},[q,G,O]),K=(0,KT.useCallback)((e,t)=>{const n=[],o=[];for(const e of t.readBodies()){const t=u_(e);if(!t||W.current.delivered.has(t.edgeID))continue;const r=t.route[t.route.length-1];r&&9>=Math.hypot(e.x-r.x,e.y-r.y)&&(n.push(t.edgeID),o.push(e.id))}o.length&&t.remove(o),n.length&&U(n)},[U]),Q=(0,KT.useCallback)(()=>{const e=l_(W.current);for(const t of O.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=a_(O,e.delivered,e.blockers,e.completed),e.playing=!1,_.current?.settle(),q(e),G({type:"machine-settled"})},[q,G,O]),Z=(0,KT.useCallback)(()=>{const e=l_(W.current);e.playing=!1,q(e)},[q]),J=(0,KT.useCallback)(()=>{const e=W.current,t=O.nodes.map(e=>({node:e,time:s_(e)})).filter(t=>null!=t.time&&t.time>e.currentTime&&!e.completed.has(t.node.id)).sort((e,t)=>e.time-t.time||e.node.index-t.node.index)[0];if(t)return void X(t.node.id,t.time);Z();const n=[...e.blockers.keys()].map(t=>o_(O,t,{completedTaskIDs:e.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);n[0]&&G({type:"machine-stalled",blockerID:n[0].blockerID,downstreamTaskCount:n[0].downstreamTaskCount,affectedLaneCount:n[0].affectedLaneCount})},[G,O,Z,X]),ee=(0,KT.useCallback)(()=>{if(E)return void Q();const e=l_(W.current);e.playing=!0,q(e)},[q,E,Q]);(0,KT.useEffect)(()=>{if(!z.playing||"replay"!==m||E)return;const e=window.setInterval(J,760);return()=>window.clearInterval(e)},[m,E,z.playing,J]);const te=(0,KT.useCallback)(()=>{_.current?.clear(),q(c_(O,m,B,E))},[q,O,m,B,E]),ne=(0,KT.useCallback)(e=>{if(!O.byID.has(e))return;const t=l_(W.current);t.previewTaskID=e,q(t);const n=o_(O,e,{completedTaskIDs:t.completed});G({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[q,G,O]),oe=(0,KT.useCallback)(()=>{const e=l_(W.current);e.previewTaskID=null,q(e)},[q]),re=(0,KT.useCallback)((e,t)=>{if(!O.byID.has(e))return;const n=l_(W.current);n.blockers.set(e,t),n.armed.delete(e),q(n)},[q,O]),ie=(0,KT.useCallback)(e=>{if(!O.byID.has(e))return;const t=l_(W.current);t.blockers.delete(e),(O.incoming.get(e)??[]).every(e=>t.delivered.has(e.id))&&t.armed.add(e),q(t)},[q,O]),se=(0,KT.useCallback)(e=>o_(O,e,{completedTaskIDs:W.current.completed}),[O]),ae=(0,KT.useCallback)(()=>{const e=W.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...N],tasks:O.nodes.map(t=>({taskID:t.id,completed:e.completed.has(t.id),armed:e.armed.has(t.id),blocked:e.blockers.has(t.id),blockerReason:e.blockers.get(t.id)})),dependencies:O.edges.map(t=>({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,state:e.delivered.has(t.id)?"delivered":e.inFlight.has(t.id)?"in-flight":"waiting"}))}},[O,N]);(0,KT.useImperativeHandle)(t,()=>({play:ee,pause:Z,step:J,reset:te,settle:Q,previewResolve:ne,clearPreview:oe,completeTask:X,blockTask:re,unblockTask:ie,getAmplification:se,getMachineState:ae}),[re,oe,se,ae,Z,X,ee,ne,te,Q,J,ie]);const ce=z.previewTaskID??N[0]??null,le=ce?o_(O,ce,{completedTaskIDs:z.completed}):null,ue=(0,KT.useMemo)(()=>new Set(le?.downstreamTaskIDs??[]),[le?.downstreamTaskIDs]),de=(0,KT.useMemo)(()=>function(e,t,n){return e.nodes.flatMap(o=>{const r=t.taskByID.get(o.id);if(!r)return[];const i=e.incoming.get(o.id)??[],s=i.filter(e=>n.delivered.has(e.id)).length,a=n.blockers.get(o.id),c=n.completed.has(o.id)?"completed":a?"blocked: "+a:n.armed.has(o.id)?"armed":"waiting";return[{id:o.id,label:`${o.label}, ${o.lane}, ${Math.round(100*o.progress)}%, ${c}`,description:`${s} of ${i.length} prerequisites delivered.`,datum:o.datum,x:r.x,y:r.y,width:r.width,height:r.height,shape:"rect",group:o.lane}]})}(O,F,z),[F,O,z]),he=(0,KT.useMemo)(()=>(0,y_.jsx)(m_,{machine:O,layout:F,runtime:z,downstreamSet:ue,selectedSet:$,width:S,height:A,seed:k,reduced:E,onSelectTask:Y}),[ue,A,F,O,E,z,k,Y,$,S]),pe=(0,KT.useMemo)(()=>{const e=[...z.blockers.keys()].map(e=>o_(O,e,{completedTaskIDs:z.completed})).sort((e,t)=>t.affectedLaneCount-e.affectedLaneCount||t.downstreamTaskCount-e.downstreamTaskCount);return e.length?e.map(e=>`${O.byID.get(e.blockerID)?.label??e.blockerID} affects ${e.downstreamTaskCount} unfinished tasks across ${e.affectedLaneCount} lanes.`).join(" "):"No explicit blockers are active."},[O,z.blockers,z.completed]),me=(0,KT.useMemo)(()=>[{id:"chain-left",shape:{type:"segment",x1:2,y1:0,x2:2,y2:A,thickness:4}},{id:"chain-right",shape:{type:"segment",x1:S-2,y1:0,x2:S-2,y2:A,thickness:4}},{id:"chain-top",shape:{type:"segment",x1:0,y1:2,x2:S,y2:2,thickness:4}},{id:"chain-bottom",shape:{type:"segment",x1:0,y1:A-2,x2:S,y2:A-2,thickness:4}}],[A,S]),ye=!0===g?["play","pause","step","reset","settle"]:g||[];return(0,y_.jsxs)("div",O.valid?{className:I,style:{width:S,maxWidth:"100%",position:"relative"},children:[ye.length>0&&(0,y_.jsx)("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:ye.map(e=>(0,y_.jsx)("button",{type:"button",onClick:"play"===e?ee:"pause"===e?Z:"step"===e?J:"reset"===e?te:Q,"aria-pressed":"play"===e?z.playing:void 0,children:e[0].toUpperCase()+e.slice(1)},e))}),(0,y_.jsx)(Xj,{ref:_,size:[S,A],responsiveWidth:C,responsiveHeight:M,maxDevicePixelRatio:e.maxDevicePixelRatio,title:j,description:P??"Tasks are arranged by workstream and dependency depth. Balls represent satisfied prerequisites; task completion remains an explicit data event.",summary:`${pe}${le&&"blocker-amplification"===y?` Selected task reaches ${le.downstreamTaskCount} unfinished tasks across ${le.affectedLaneCount} lanes.`:""}`,accessibleTable:!1,enableHover:T,initialSpawns:r_,bodyForces:d_,bodyStyle:{fill:"var(--semiotic-primary, #f0a329)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.25},bodySemanticItems:!1,semanticItems:de,onSemanticItemActivate:e=>e.id&&Y(e.id),foregroundGraphics:()=>he,paused:E,continuous:z.inFlight.size>0,onTick:K,config:{bodyLimit:Math.max(16,O.edges.length+4),colliders:me,settleStepLimit:2200,kernel:{seed:k,gravity:{x:0,y:7},fixedDt:1/60,cellSize:28,collisionIterations:2,velocityDamping:.992,restitution:.02,friction:.12,maxVelocity:150,sleepSpeed:1.1,sleepAfter:.8},observation:{chartType:"ChainReactionChart"}}}),R&&(0,y_.jsxs)("table",{style:f_,children:[(0,y_.jsx)("caption",{children:pe}),(0,y_.jsx)("thead",{children:(0,y_.jsxs)("tr",{children:[(0,y_.jsx)("th",{children:"Task"}),(0,y_.jsx)("th",{children:"Lane"}),(0,y_.jsx)("th",{children:"Progress"}),(0,y_.jsx)("th",{children:"State"}),(0,y_.jsx)("th",{children:"Waiting on"}),(0,y_.jsx)("th",{children:"Downstream reach"})]})}),(0,y_.jsx)("tbody",{children:O.nodes.map(e=>{const t=o_(O,e.id,{completedTaskIDs:z.completed});return(0,y_.jsxs)("tr",{children:[(0,y_.jsx)("th",{scope:"row",children:e.label}),(0,y_.jsx)("td",{children:e.lane}),(0,y_.jsxs)("td",{children:[Math.round(100*e.progress),"%"]}),(0,y_.jsx)("td",{children:z.completed.has(e.id)?"Completed":z.blockers.has(e.id)?"Blocked":z.armed.has(e.id)?"Armed":"Waiting"}),(0,y_.jsx)("td",{children:z.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!z.completed.has(e)).join(", ")||"None")}),(0,y_.jsxs)("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:I,role:"alert",style:{width:S,maxWidth:"100%"},children:[(0,y_.jsx)("strong",{children:"ChainReactionChart could not compile this dependency graph."}),(0,y_.jsx)("ul",{children:O.diagnostics.map((e,t)=>(0,y_.jsx)("li",{children:e.message},`${e.code}-${t}`))})]})});g_.displayName="ChainReactionChart";var b_=require("react");function v_(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 s=i/60;if(24>s){const e=Math.floor(s),n=Math.round(i-60*e);return 0===n?`${t}${e}h`:`${t}${e}h ${n}m`}const a=Math.floor(s/24),c=Math.round(s-24*a);return 0===c?`${t}${a}d`:`${t}${a}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 x_(e,t,n){return`${t??""}${e}${n??""}`}var w_=require("react"),k_=require("react/jsx-runtime"),S_={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 A_(e,t,n){return void 0===e?n:"function"==typeof e?e(t):e}function C_(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function M_(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var j_=(0,b_.forwardRef)((e,t)=>{const{value:n,label:o,caption:r,format:i,locale:s,currency:a,precision:c,prefix:l,suffix:u,unit:d,comparison:h,target:p,delta:m,deltaFormat:y,showDeltaPercent:f,direction:g,sentiment:b,thresholds:v,windowSize:x=60,mode:w="tile",align:k,width:S,height:A,padding:C,emphasis:M,color:j,background:P,borderColor:I,borderRadius:R,className:T,style:_,animate:L,stalenessThreshold:D,staleLabel:N,headerSlot:$,valueSlot:B,deltaSlot:E,trendSlot:O,chartSlot:F,chartSize:z,footerSlot:H,onClick:W,onObservation:q,chartId:G,description:Y,summary:V,loading:X,loadingContent:U,emptyContent:K}=e,Q=S_[w]??S_.tile,Z=k??Q.align,J=S??Q.width,ee=A??Q.height,te=yu(),ne=Uc(),[oe,re]=(0,b_.useState)([]),[ie,se]=(0,b_.useState)(null),[ae,ce]=(0,b_.useState)(null),[le,ue]=(0,b_.useState)(null),de=(0,b_.useRef)([]),he=(0,b_.useRef)(null),pe=(0,b_.useRef)(n);(0,b_.useEffect)(()=>{pe.current=n},[n]);const me=(0,b_.useRef)(x);(0,b_.useEffect)(()=>{me.current=x},[x]);const ye=(0,b_.useCallback)(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}},[]),fe=(0,b_.useCallback)(e=>{if(0===e.length)return;const t=me.current,n=e.map(ye);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),se(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)},[ye]),ge=(0,b_.useCallback)(e=>fe([e]),[fe]);(0,b_.useImperativeHandle)(t,()=>({push:e=>ge(e),pushMany:e=>fe(e),clear:()=>{de.current=[],he.current=null,re([]),se(null),ce(null),ue(null)},getValue:()=>he.current??(Number.isFinite(pe.current)?pe.current:null),getData:()=>de.current.slice()}),[ge,fe]);const be=ie??n,ve=null==be||"number"!=typeof be||!Number.isFinite(be),xe=(0,b_.useMemo)(()=>v_(i??"number",{locale:s,currency:a,precision:c}),[i,s,a,c]),we=(0,b_.useMemo)(()=>v_(y??i??"number",{locale:s,currency:a,precision:null==y&&null==i?0:c}),[y,i,s,a,c]),ke=L??!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]=(0,b_.useState)(()=>o),s=(0,b_.useRef)(o),a=(0,b_.useRef)(null),c=(0,b_.useRef)(e),l=(0,b_.useRef)(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=(0,b_.useRef)(e);return(0,b_.useEffect)(()=>{const t=e=>{s.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=s.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?a.current=requestAnimationFrame(r):(a.current=null,t(m.current))};return a.current=requestAnimationFrame(r),()=>{null!=a.current&&cancelAnimationFrame(a.current),a.current=null}},[u,h,p,n,e]),r}(Ae,ke,te,(0,b_.useRef)(!Se||te||ne?Ae:0).current),Me=ke?Ce:Number.isFinite(be)?be:0,je=(0,b_.useMemo)(()=>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]),Pe=je?je.level:"neutral",Ie=j??function(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}(Pe,je?.color),Re=ae??h?.value??null,Te=null!=m?m:null!=Re&&Number.isFinite(be)?be-Re:null,_e=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),Le=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,De=(0,b_.useMemo)(()=>new Intl.NumberFormat(s??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[s]),Ne=null!=Re&&Number.isFinite(be)&&(f??1)&&0!==Re?De.format((be-Re)/Math.abs(Re)):null,$e=function({target:e,value:t,format:n,locale:o,currency:r,precision:i}){const s=(0,w_.useMemo)(()=>new Intl.NumberFormat(o??"en-US",{style:"percent",maximumFractionDigits:0}),[o]),a=(0,w_.useMemo)(()=>v_(e?.format??n??"number",{locale:o,currency:r,precision:i}),[e?.format,n,o,r,i]);return(0,w_.useMemo)(()=>{if(!e||!Number.isFinite(e.value))return null;const n="number"==typeof t&&Number.isFinite(t)&&0!==e.value?s.format(t/e.value):null,o=a(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,a,s])}({target:p,value:be,format:i,locale:s,currency:a,precision:c}),Be=$e?.percent??null,Ee=$e?.text??null,Oe=function(e,t){const[n,o]=(0,b_.useState)(!1);return(0,b_.useEffect)(()=>{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,D),Fe=Number.isFinite(Me)?x_(xe(Me),l,u):"",ze={value:ve?null:be,formattedValue:Fe,level:Pe,color:Ie,delta:Te,deltaFormatted:Le,deltaPercent:Ne,sentiment:_e,isStale:Oe,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)?x_(xe(be),l,u):"",unit:d,comparisonLabel:h?.label,delta:Te,deltaFormatted:Le,deltaPercent:Ne,targetText:Ee,thresholdLabel:je?.label,stale:Oe,staleLabel:N}),We="number"==typeof C?{top:C,right:C,bottom:C,left:C}:{...Q.padding,...C??{}},qe="end"===Z?"flex-end":"center"===Z?"center":"start"===Z?"flex-start":"inherit",Ge={position:"relative",boxSizing:"border-box",width:J,height:ee,padding:`${We.top}px ${We.right}px ${We.bottom}px ${We.left}px`,background:P??Q.background,border:Q.border?"1px solid "+(I??"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof R?R+"px":R??"var(--semiotic-border-radius, 8px)",display:"inline"===w?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===qe?void 0:qe,textAlign:Z,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:Oe?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===M?"span 2":void 0,cursor:W?"pointer":void 0,..._},Ye=(0,b_.useCallback)(e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top,r={value:ve?NaN:be,level:Pe,delta:Te};W&&W(r,{x:n,y:o}),q&&q({type:"click",datum:r,x:n,y:o,chartType:"BigNumber",chartId:G,timestamp:Date.now()})},[W,q,G,ve,be,Pe,Te]),Ve="inline"===w?"span":"div",Xe=["semiotic-bignumber","semiotic-bignumber--mode-"+w,"semiotic-bignumber--level-"+Pe,"semiotic-bignumber--sentiment-"+_e,Oe?"semiotic-bignumber--stale":null,T].filter(Boolean).join(" "),Ue="positive"===_e?"up":"negative"===_e?"down":"flat";if(X){const e="number"==typeof J?J:280,t="number"==typeof ee?ee:160;return(0,k_.jsx)(Ve,{role:"status","aria-live":"polite","aria-busy":"true",className:Xe+" semiotic-bignumber--loading",style:{...Ge,opacity:1},children:U??(0,k_.jsx)(I_,{width:e,height:t,mode:w})})}return ve?!1===K?null:(0,k_.jsx)(Ve,{role:"status","aria-label":o?o+": no value":"no value",className:Xe+" semiotic-bignumber--empty",style:{...Ge,color:"var(--semiotic-text-secondary, #666)",fontSize:13,alignItems:"center",justifyContent:"center"},children:K??"—"}):(0,k_.jsx)(Rp,{componentName:"BigNumber",width:"number"==typeof J?J:280,height:"number"==typeof ee?ee:160,children:(0,k_.jsxs)(Ve,{role:"group","aria-label":He,"data-chart":"BigNumber","data-mode":w,"data-level":Pe,"data-stale":Oe?"true":void 0,"data-sentiment":_e,className:Xe,style:Ge,onClick:W||q?Ye:void 0,children:[Q.showHeader&&(o||r||$)?(0,k_.jsx)("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:Q.showChart&&null!=F?(z??Q.chartSize)+8:0},children:A_($,ze,(0,k_.jsxs)(k_.Fragment,{children:[o?(0,k_.jsx)("span",{className:"semiotic-bignumber__label",style:{fontSize:Q.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:o}):null,r?(0,k_.jsx)("span",{className:"semiotic-bignumber__caption",style:{fontSize:Q.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:r}):null]}))}):null,A_(B,ze,(0,k_.jsxs)(Ve,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Pe,style:{display:"inline"===w?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Ie,fontSize:Q.valueSize||void 0,lineHeight:1.05},children:[(0,k_.jsx)("span",{className:"semiotic-bignumber__value-text",children:Fe}),d?(0,k_.jsx)("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&&(Le||$e||h)?(0,k_.jsx)(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:A_(E,ze,(0,k_.jsxs)(k_.Fragment,{children:[Le?(0,k_.jsxs)("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+Ue,style:{display:"inline-flex",alignItems:"center",gap:4,color:C_(_e),fontWeight:600},children:[(0,k_.jsx)("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+Ue,children:M_(_e)}),(0,k_.jsx)("span",{className:"semiotic-bignumber__delta-amount",children:Le}),Ne?(0,k_.jsxs)("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",Ne,")"]}):null]}):null,h?.label?(0,k_.jsx)("span",{className:"semiotic-bignumber__comparison-label",children:h.label}):null,$e?(0,k_.jsxs)("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[Le||h?.label?(0,k_.jsx)("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,(0,k_.jsx)("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:Be}),(0,k_.jsxs)("span",{className:"semiotic-bignumber__target-value",children:["of ",$e.formattedValue,$e.label?" "+$e.label:""]})]}):null]}))}):null,Q.showChart&&null!=F?(0,k_.jsx)("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:(0,k_.jsx)("div",{style:{pointerEvents:"auto",lineHeight:0},children:A_(F,ze,null)})}):null,Q.showTrend&&null!=O?(0,k_.jsx)("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:We.left,right:We.right,bottom:We.bottom+(null!=H?28:0)},children:A_(O,ze,null)}):null,null!=H?(0,k_.jsx)(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:A_(H,ze,null)}):null,V?(0,k_.jsx)("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]})})});j_.displayName="BigNumber";var P_=j_;function I_(e){const t=Math.floor(.45*e.width),n=Math.floor(.6*e.width),o=(e,t)=>(0,k_.jsx)("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return(0,k_.jsxs)("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[R_,T_]=jt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));async function __(e,t){const{format:n="png",filename:o="chart",scale:r=2,background:i="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),c=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",c.width+""),a.getAttribute("height")||a.setAttribute("height",c.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),L_(s,a),"svg"===n){const e=(new XMLSerializer).serializeToString(a);D_(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=c.width*r,n=c.height*r,s=document.createElement("canvas");s.width=t,s.height=n;const l=s.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(a),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),s.toBlob(n=>{n?(D_(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 L_(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++)L_(n[e],o[e])}function D_(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)}var N_=d(require("react")),$_=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","BumpChart","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","UnitPileChart","CollisionSwarmChart","GauntletChart","CrucibleChart","ProcessFlowChart","PacketFlowChart","ChainReactionChart","BigNumber"],B_=new Set($_);function E_(e){return B_.has(e)}var O_=["value","threshold","partition-boundary","time-window","range-boundary"];function F_(e,t,n,o,r){return{id:e,...t?{controlId:t}:{},status:n,message:o,...r?{remediation:r}:{}}}function z_({controls:e=[],minimumTargetSize:t=24}){const n=[],o=new Set;for(const r of e){const e=r?.id,i="controls."+(e||"unknown"),s=r?.domain,a=Array.isArray(s)&&2===s.length&&Number.isFinite(s[0])&&Number.isFinite(s[1])&&s[1]>s[0],c=O_.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(F_(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(F_(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(F_(i+".domain",e,a?"pass":"fail",a?"Control has a finite ordered value domain.":"Control has no finite ordered value domain.","Declare domain as [minimum, maximum].")),n.push(F_(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(F_(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(F_(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(F_(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(F_(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(F_(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 H_(e){return W_(e),e}function W_(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=z_({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(!q_(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(!G_(t))throw Error(`Portable chart recipe "${e.id}" has a layout config schema that is not JSON-safe.`)}}function q_(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function G_(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=>G_(e,t)):Object.entries(e).every(([,e])=>G_(e,t));return t.delete(e),o}function Y_(e){return"string"==typeof e?e:e.id??e.name}function V_(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 X_(e){const t=new Set(e.intents.map(Y_));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 U_(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 K_(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 Q_(e,t,n){return K_(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,n))}function Z_(e,t,n){if(t.field&&Q_(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&&Q_(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=K_(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 J_(e){const t={},n=[];for(const o of e.intents){const e=Y_(o);e&&(t[e]=V_(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:X_(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:U_(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&&!Z_(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=Z_(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 eL=Symbol.for("semiotic.chartRecipeRegistry");function tL(){const e=globalThis;return e[eL]||(e[eL]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[eL]}function nL(e){W_(e),tL().recipes.set(e.id,e),tL().capabilities.set(e.id,J_(e))}function oL(e){tL().recipes.delete(e),tL().capabilities.delete(e)}function rL(e){return tL().recipes.get(e)}function iL(){return Array.from(tL().recipes.values())}function sL(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.`);tL().layouts.set(e,t)}function aL(e){tL().layouts.delete(e)}function cL(e){return tL().layouts.get(e)}function lL(e){return"string"==typeof e?rL(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function uL(e){return"string"==typeof e?e:e.id??e.name}function dL(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function hL(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 pL(e,t,n){return n??lL(t.recipe)??lL(t.recipeId)??rL(e)}function mL(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 yL(e,t){return e.dataRoles.find(e=>e.role===t)}function fL(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function gL(e,t,n,o,r,i={}){const s={...i};if(t)for(const[e,n]of Object.entries(t))s[e]=n;for(const e of n.dataRoles){const n=mL(e,o,r),i=t&&n?t[n]:n;void 0!==i&&(s[e.role]=i)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const n=s[t];return null==n?`{${t}}`:n+""})}var bL="1",vL=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"]),xL=new Set(["data","nodes","edges","points","areas","lines","flows"]);function wL(e){if(null==e)return e;if("function"==typeof e)return;if("object"!=typeof e)return e;if(e.$$typeof)return;if(Array.isArray(e))return e.map(wL).filter(e=>void 0!==e);if(e instanceof Date)return e;const t={};for(const[n,o]of Object.entries(e)){if("function"==typeof o)continue;if(o&&"object"==typeof o&&o.$$typeof)continue;const e=wL(o);void 0!==e&&(t[n]=e)}return t}function kL(e,t){return!!xL.has(e)&&("areas"!==e||"string"!=typeof t)}var SL="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function AL(e,t,n){const o=rL(e)??lL(t.recipe)??lL(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&&!vL.has(r)&&"recipeId"!==r&&(t||!kL(r,i)))if("function"==typeof i||i?.$$typeof){if(n)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`)}else if(G_(i))o[r]=SL(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(uL).filter(e=>!!e),i={name:e.name,intents:r,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!G_(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:bL,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:bL,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(o,t,n);if(!E_(e))throw Error(`Unknown component "${e}". Known components: ${$_.join(", ")}`);const r=!1!==n?.includeData,i={};for(const[e,n]of Object.entries(t))if(null!=n&&!vL.has(e)&&(r||!kL(e,n))&&"function"!=typeof n&&!n?.$$typeof)try{i[e]=SL(wL(n))}catch{}return{component:e,props:i,version:bL,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}function CL(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=rL(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:{...SL(e.props),recipeId:e.recipeId}}}if(!E_(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:SL(e.props)}}function ML(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function jL(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 PL(e,t="json"){const n="jsx"===t?IL(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 IL(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 RL=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),TL=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),_L=new Set(["PieChart","DonutChart","FunnelChart"]),LL=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function DL(e,t){return TL.has(e)||_L.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 NL(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function $L(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function BL(e,t,n={}){const o=hL(t),r=dL(t),i=n.locale??"en",s="function"==typeof e.description?e.description({data:o,config:r,locale:i}):void 0,a=s?.levels??function(e,t,n,o){const r=fL(e,["nominal","ordinal"]),i=fL(e,["quantitative"]),s=r?mL(r,n,t):void 0,a=i?mL(i,n,t):void 0,c=r?.role??s??"category",l=i?.role??a??"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(s&&a)for(const e of t){const t=(e[s]??"Uncategorized")+"",n=Number(e[a]);Number.isFinite(n)&&m.set(t,(m.get(t)??0)+n)}const y=[...m].sort((e,t)=>t[1]-e[1]),f=y.reduce((e,[,t])=>e+t,0),g=y[0],b=y[1],v=f>0?((g?.[1]??0)+(b?.[1]??0))/f:0,x=e.intents.map(e=>({id:uL(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:y.length>0?`${y.length} categories total ${h.format(f)}. ${g[0]} accounts for ${h.format(g[1])}${f>0?` (${p.format(g[1]/f)})`:""}${b?`, followed by ${b[0]} at ${h.format(b[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>y.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 ${y.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)a[e]&&(l[e]=a[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 EL={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",UnitPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PacketFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",CrucibleChart:"crucible physics chart",PhysicsCustomChart:"custom physics chart"},OL=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),FL=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function zL(e){return EL[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function HL(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var WL=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),qL={"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"},GL={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},YL=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],VL={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function XL(e){return qL[e]}function UL(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=YL.indexOf(o),n=YL.indexOf(t);-1===e||-1!==n&&e>=n||(t=o)}return t}(n.intentScores);if(e&&qL[e]&&(n.intentScores[e]??0)>=3)return qL[e]}return n?.family?GL[n.family]:function(e){return _L.has(e)||"StackedAreaChart"===e?"apportioning":WL.has(e)?"relating":TL.has(e)?"comparing":LL.has(e)?"characterizing":RL.has(e)?"tracking":OL.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var KL=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),QL=new Set(["system","agent","watcher"]),ZL=new Set(["ai","agent","system","computed","dbt","great-expectations"]),JL=new Set(["rule","statistical-test","llm-inference","computed"]);function eD(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||!KL.has(t.type))return!1;const n=t.provenance;return!(!n||"object"!=typeof n)&&(QL.has(n.authorKind)||ZL.has(n.source)||JL.has(n.basis))})}function tD(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 nD={"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 oD(e){const t=nD["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 rD(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const n=Wa(t.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return;const o=n.map(oD),r=o.slice(0,5),i=o.length-r.length,s=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`:""),a=n.length;return`The author has marked ${1===a?"one feature":a+" features"} on this chart: ${s}.`}function iD(e,t,n={}){const o=void 0!==n.levels,r=new Set(n.levels??["l1","l2","l3"]);o||!n.capability&&!eD(t)||r.add("l4");const i=pL(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 s=BL(i,t,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),a=rD(t);return{...s,text:a?`${a} ${s.text}`.trim():s.text,...a?{annotations:a}:{}}}const s=tD(n.locale??"en"),a=zL(e),c=Array.isArray(t.data)?t.data:null,l=NL(t),u=FL.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=HL(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),s=HL(o.secondary??o.secondaryCount),a=HL(o.observed??o.observedCount);return{label:$L(i,t),count:r,...null!=s?{secondary:s}:{},..."string"==typeof o.secondaryLabel&&o.secondaryLabel?{secondaryLabel:o.secondaryLabel}:{},...null!=a?{observed:a}:{}}}).filter(e=>null!=e):null}(t,s):null,{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=DL(e,t),y="string"==typeof d&&d?d:h,f="string"==typeof p&&p?p:m,g={};if(FL.has(e)&&function(e,t,n,o,r,i){const s=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PacketFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}(e),a=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PacketFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"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.":"UnitPileChart"===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.":"PacketFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":"CrucibleChart"===e?"A crucible physics chart that replays authored phases and events into declared products and outlets; the settled ledger, not collisions, determines the result.":`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)} ${aD(c,a)} across ${n.length} ${aD(n.length,s)}; no ${aD(2,s)} are non-empty yet.`;else{const e=d>0?` ${i(d)} ${aD(d,a)} ${1===d?"is":"are"} marked ${h}.`:"";o.l2=`The settled projection contains ${i(c)} ${aD(c,a)} across ${n.length} ${aD(n.length,s)}; ${l.length} ${aD(l.length,s)} ${1===l.length?"is":"are"} non-empty. The largest ${s} is ${u.label} with ${i(u.count)} ${aD(u.count,a)}.${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)} ${aD(u.count,a)} (${t}); ${e.label} follows with ${i(e.count)} ${aD(e.count,a)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${i(u.count)} ${aD(u.count,a)}.`}}(e,a,u,g,r,s),r.has("l1")&&!FL.has(e))if(RL.has(e)||TL.has(e))g.l1=`A ${a} of ${y} by ${f}`+(l?`, split by ${l}.`:".");else if(_L.has(e))g.l1=`A ${a} showing ${y} across ${f} categories.`;else if(LL.has(e))g.l1=`A ${a} of the distribution of ${y}`+(l?` by ${l}.`:".");else if(OL.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} ${aD(e,"node")}`:null,null!=n?`${n} ${aD(n,"edge")}`:null].filter(Boolean);g.l1=`A ${a}${o.length?" with "+o.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:y;g.l1=`A single value${e?" for "+e:""}.`}else g.l1=`A ${a}.`;const b=RL.has(e)||TL.has(e)||_L.has(e)||LL.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,s=1/0,a=-1/0,c=null,l=null,u=0,d=0,h=null,p=null,m=NaN,y=NaN;for(const n of e){const e=t(n);Number.isFinite(e)&&(0===r&&(m=e,h=n),y=e,p=n,s>e&&(s=e,c=n,u=r),e>a&&(a=e,l=n,d=r),r++,i+=e)}return 0===r?null:{count:r,min:s,max:a,mean:i/r,minLabel:$L(null!=c?n(c):null,o),maxLabel:$L(null!=l?n(l):null,o),first:m,last:y,firstLabel:$L(null!=h?n(h):null,o),lastLabel:$L(null!=p?n(p):null,o),minIndex:u,maxIndex:d}}(c,Ht(d,h),Wt(p,m),s)),r.has("l2")&&b&&(c&&0!==c.length?v&&(g.l2=_L.has(e)?`${v.count} segments totaling ${s(function(e){return e.mean*e.count}(v))}. Largest is ${v.maxLabel} at ${s(v.max)}; smallest is ${v.minLabel} at ${s(v.min)}.`:`${y} ranges from ${s(v.min)} (${v.minLabel}) to ${s(v.max)} (${v.maxLabel}), with a mean of ${s(v.mean)} across ${v.count} points.`):g.l2="No data is loaded yet."),r.has("l3")&&v&&!l&&RL.has(e)?g.l3=function(e,t,n){const{first:o,last:r,min:i,max:s,maxLabel:a,minLabel:c,firstLabel:l,lastLabel:u,minIndex:d,maxIndex:h,count:p}=e,m=s-i,y=r-o;if(0===m)return`${sD(t)} is constant at ${n(o)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${sD(t)} ends roughly where it started (${n(o)} at ${l} to ${n(r)} at ${u}), ranging between ${n(i)} and ${n(s)}.`;const f=h>0&&p-1>h,g=d>0&&p-1>d,b=(s-Math.max(o,r))/m,v=(Math.min(o,r)-i)/m;return f&&b>.15?`Overall ${t} climbs to a peak of ${n(s)} (${a}), 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(y)/m?`${sD(t)} ends roughly where it started (${n(o)} at ${l} to ${n(r)} at ${u}), ranging between ${n(i)} and ${n(s)}.`:y>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(s)} (${a}).`: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,y,s):r.has("l3")&&v&&!l&&TL.has(e)&&(g.l3=`The highest ${f} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),r.has("l4")){const o=eD(t)?"alerting":UL(e,n.capability);o&&(g.l4=function(e,t,n,o,r,i,s,a){const c=VL[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(TL.has(n)||_L.has(n))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:o,last:r,min:i,max:s,minLabel:a,maxLabel:c,lastLabel:l,minIndex:u,maxIndex:d,count:h}=e,p=s-i;if(p>0){const e=d>0&&h-1>d,n=u>0&&h-1>u,m=(s-Math.max(o,r))/p,y=(Math.min(o,r)-i)/p;if(e&&m>.15)return`the peak of ${t(s)} at ${c} is the point to investigate`;if(n&&y>.15)return`the dip to ${t(i)} at ${a} is the point to investigate`;if(r>=s)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(s)}) and ${a} (${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,s,t)}return`${u}; ${d}.${function(e,t){if(!t)return"";const n=t.familiarity?.[e];return"number"!=typeof n||n>2?"":` This ${zL(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,a)}`}(o,e,t,l?null:v,y,f,s,n.audience))}const x=["l1","l2","l3","l4"].filter(e=>r.has(e)&&g[e]).map(e=>g[e]).join(" "),w=rD(t);return{text:w?`${w} ${x}`.trim():x,levels:g,...w?{annotations:w}:{}}}function sD(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function aD(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function cD(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function lD(e,t,n={}){const o=hL(t),r=dL(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 s=(a=e.navigation)&&"object"==typeof a?e.navigation:void 0;var a;const c=(s?.groupByRole?yL(e,s.groupByRole):void 0)??(s?.groupBy?.[0]?yL(e,s.groupBy[0])??e.dataRoles.find(e=>e.field===s.groupBy?.[0]):void 0)??fL(e,["nominal","ordinal"]),l=c?mL(c,r,o):void 0,u=(s?.idRole?yL(e,s.idRole):void 0)??fL(e,["identifier"]),d=u?mL(u,r,o):void 0,h={id:"root",role:"chart",label:s?.summaryTemplate?gL(s.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 a=d?t[d]:void 0,c=s?.itemLabelTemplate?gL(s.itemLabelTemplate,t,e,r,o,{count:o.length}):function(e,t,n,o){const r=fL(t,["nominal","ordinal"]),i=t.dataRoles.filter(e=>"quantitative"===e.semanticType),s=r?mL(r,n,o):void 0,a=[];s&&null!=e[s]&&a.push(e[s]+"");for(const t of i){const r=mL(t,n,o);r&&null!=e[r]&&a.push(`${t.role}: ${e[r]+""}`)}return a.length>0?a.join(", "):"Data item"}(t,e,r,o);return{id:"datum-"+cD(a??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-"+cD(e),role:"datum",label:`…and ${t.length-o.length} more items`,level:3}),{id:"group-"+cD(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 uD(e,t,n={}){const o=n.locale??"en",r=Math.max(1,n.maxLeaves??200),i=tD(o),s=pL(e,t,n.recipe);if(s)return lD(s,t,{maxLeaves:r,locale:o});const a={id:"root",role:"chart",label:iD(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=Wa(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=oD(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 s=o.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===s?"one marked feature":s+" marked features"}.`,children:i}}(t,r),l=Array.isArray(t.data)?t.data:null,u=RL.has(e)||TL.has(e)||_L.has(e)||LL.has(e);if(!l||0===l.length||!u)return c&&(a.children=[c]),a;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=DL(e,t),y=Ht(d,h),f=Wt(p,m),g="string"==typeof d&&d?d:h,b="string"==typeof p&&p?p:m,v=NL(t);let x=0;const w=e=>`${e}-${x++}`,k=(e,t)=>{const n=e.slice(0,r).map(e=>((e,t)=>{const n=y(e),o=$L(f(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(RL.has(e)||TL.has(e)){let t=1/0,n=-1/0,o=1/0,r=-1/0;const s=[];let a=!0;for(const e of l){const i=y(e);Number.isFinite(i)&&(t>i&&(t=i),i>n&&(n=i));const c=f(e);s.push(c),"number"==typeof c&&Number.isFinite(c)?(o>c&&(o=c),c>r&&(r=c)):a=!1}const c=new Set,u=[];for(const e of s){const t=e+"";c.has(t)||(c.add(t),u.push(e))}const d=a?`${i(o)} to ${i(r)}`:`${$L(u[0],i)} to ${$L(u[u.length-1],i)} (${TL.has(e)?u.length+" categories":l.length+" points"})`;S.push({id:w("axis"),role:"axis",level:2,label:`${TL.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=Wt(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,s]of r){const r=iD(e,{...t,data:s},{levels:["l2","l3"],locale:o}).text;i.push({id:w("series"),role:"series",level:2,label:`Series ${n}: ${r}`,children:k(s,3)})}a.children=[...S,...i]}else a.children=[...S,...k(l,2)];return c&&a.children.push(c),a}function dD(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 hD(e){let t=1;if(e.children)for(const n of e.children)t+=hD(n);return t}var pD=d(require("react")),mD=null,yD=new Set,fD=new Set,gD="semiotic:conversation-arc",bD="semiotic-conversation-arc",vD="events",xD=1e3;function wD(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 kD(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function SD(e,t){try{const n=t();n&&"function"==typeof n.then&&Promise.resolve(n).catch(t=>kD(e,t))}catch(t){kD(e,t)}}function AD(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function CD(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 kD("localStorage load",e),[]}}(e.getItem(t))}catch(e){return kD("localStorage read",e),[]}}var MD=Object.freeze([]),jD=MD,PD=!1;function ID(){return PD?(jD=mD?Object.freeze(mD.buffer.slice()):MD,PD=!1,jD):jD}function RD(){PD=!0}var TD=new Set;function _D(){for(const e of TD)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function LD(e){return TD.add(e),()=>{TD.delete(e)}}function DD(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return fD.add(e),()=>{fD.delete(e)}}function ND(e={}){const t=e.key??gD,n=wD(e.maxEvents,xD,"createLocalStorageConversationArcSink: maxEvents");return{record(o){const r=AD(e.storage),i=CD(r,t);i.push(o),function(e,t,n,o){if(e)try{e.setItem(t,JSON.stringify(n.slice(-o)))}catch(e){kD("localStorage write",e)}}(r,t,i,n)},clear(){const n=AD(e.storage);if(n)try{n.removeItem(t)}catch(e){kD("localStorage clear",e)}},load:()=>CD(AD(e.storage),t)}}function $D(e={}){const t=e.dbName??bD,n=e.storeName??vD,o=wD(e.maxEvents,xD,"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 kD("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=()=>{kD("IndexedDB open",r.error),n(null)},r.onblocked=()=>{kD("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=()=>{kD("IndexedDB record",r.error),o()}}catch(e){kD("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),s=i.getAll();s.onsuccess=()=>{const e=Array.isArray(s.result)?s.result:[],t=e.length-n;if(t>0)for(const n of e.slice(0,t))null!=n.id&&i.delete(n.id)},s.onerror=()=>kD("IndexedDB trim",s.error),r.oncomplete=()=>o(),r.onerror=()=>{kD("IndexedDB trim",r.error),o()}}catch(e){kD("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=()=>{kD("IndexedDB clear",o.error),t()}}catch(e){kD("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=()=>{kD("IndexedDB load",o.error),n([])}}catch(e){kD("IndexedDB load",e),n([])}}):Promise.resolve([])}(await i(),n)}}function BD(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 ED(e,t={}){const n=Array.isArray(e)?e.slice():[],o=wD(t.capacity,Math.max(mD?.capacity??xD,n.length,1),"loadConversationArc: capacity"),r=t.sessionId??n[0]?.sessionId??mD?.sessionId??HD();for(mD?(mD.enabled=t.enabled??!1,mD.sessionId=r,mD.capacity=o):mD={enabled:t.enabled??!1,sessionId:r,capacity:o,buffer:[]},t.append||(mD.buffer=[]),mD.buffer.push(...n);mD.buffer.length>mD.capacity;)mD.buffer.shift();return RD(),_D(),ID()}function OD(e,t={}){return ED(e,t)}function FD(e,t,n){return VD.record({type:"audience-set",audience:e,previous:t??void 0,...n})}function zD(e,t){return VD.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function HD(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function WD(){return mD}function qD(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(mD){if(mD.enabled=!0,e.sessionId&&(mD.sessionId=e.sessionId),null!=e.capacity){for(mD.capacity=t;mD.buffer.length>mD.capacity;)mD.buffer.shift();RD()}}else mD={enabled:!0,sessionId:e.sessionId??HD(),capacity:t,buffer:[]},RD();return _D(),VD}function GD(){mD&&(mD.enabled=!1,_D())}function YD(){return VD}var VD={get enabled(){return mD?.enabled??!1},get sessionId(){return mD?.sessionId??null},get capacity(){return mD?.capacity??0},record(e){const t=WD();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();RD(),_D();for(const e of yD)try{e(n)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of fD)t.record&&SD("sink record",()=>t.record?.(e))}(n),n},flush(){const e=WD();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],RD(),_D(),function(e){for(const t of fD)t.flush&&SD("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>ID(),subscribe:e=>(yD.add(e),()=>{yD.delete(e)}),clear(){const e=WD();e&&(e.buffer=[],RD(),_D()),function(){for(const e of fD)e.clear&&SD("sink clear",()=>e.clear?.())}()},reset(){if(yD.clear(),fD.clear(),jD=MD,PD=!1,!mD)return _D(),void TD.clear();mD.buffer=[],mD.enabled=!1,mD=null,_D(),TD.clear()}},XD=require("react/jsx-runtime"),UD={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function KD({tree:e,label:t,visible:n=!1,className:o,onActiveChange:r,activeId:i,chartId:s,onObservation:a,onAnnotationActivate:c}){const[l,u]=pD.useState(()=>new Set([e.id])),[d,h]=pD.useState(e.id),p=void 0!==i,m=p?i:d,y=pD.useRef(null),f=pD.useRef(new Map),g=Vs(e=>e.pushObservation),b=pD.useCallback(e=>{a?.(e),g?.(e)},[a,g]),v=pD.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=pD.useMemo(()=>dD(e,l),[e,l]);pD.useEffect(()=>{p||x.some(e=>e.id===d)||h(e.id)},[x,d,e.id,p]),pD.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]),pD.useEffect(()=>{y.current?.contains(document.activeElement)&&f.current.get(m)?.focus()},[m]);const w=pD.useCallback((e,t,n)=>{const o=YD();o.enabled&&o.record("focus"===t?{type:"nav-node-focused",chartId:s,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:s,nodeId:e.id,role:e.role,level:e.level,expanded:!!n})},[s]),k=pD.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:s}))},[r,p,w,m,b,s]),S=pD.useCallback(e=>{if(e.datum){if("annotation"===e.role){const t=Us(e.datum);return c?.({annotation:e.datum,annotationId:t,chartId:s,inputType:"navigation-tree"}),void(t&&b({type:"annotation-activate",annotationId:t,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:s}))}b({type:"activate",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:s})}},[s,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(0,XD.jsxs)("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=>{f.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:[(0,XD.jsxs)("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[n&&r?i?"▾ ":"▸ ":"",e.label]}),r&&i&&(0,XD.jsx)("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(0,XD.jsx)("div",{ref:y,className:"semiotic-nav-tree"+(o?" "+o:""),style:n?void 0:UD,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:(0,XD.jsx)("ul",{role:"tree","aria-label":t||"Chart navigation",style:n?{margin:0,padding:0}:void 0,children:M(e,1,1)})})}var QD=d(require("react")),ZD=require("react/jsx-runtime");function JD(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])),s=Math.max(o,Math.min(r,e[1])),a=i>s?[s,i]:[i,s];if(a[1]-a[0]>=n)return a;const c=(a[0]+a[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 JD([e[0]+i,e[1]-i],t,r)}function tN(e){const{domain:t,initialValue:n=t,step:o=1,minSpan:r=o,label:i,formatValue:s,onChange:a}=e,[c,l]=QD.useState(()=>JD(n,t,r)),u=JD(c,t,r),d=QD.useCallback(e=>{const n=JD(e,t,r);l(n),a?.(n)},[t,r,a]),h=QD.useMemo(()=>({label:i,domain:t,value:u,step:o,formatValue:s,onChange:d,onClear:()=>d(t)}),[t,s,i,d,o,u]),p=QD.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 nN={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)))"},oN={fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #57606a)"};function rN(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-bg, #fff)":"var(--semiotic-text, #24292f)",fontSize:13,fontWeight:650,touchAction:"manipulation"}}function iN(e){return"function"==typeof e}function sN({brush:e,targetSize:t}){const n=e?.value,o=e?.domain,r=!!n&&!!o,i=!0===e?.disabled,s=e?.formatValue??(e=>e),a=!!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(0,ZD.jsxs)("section",{style:nN,"aria-label":"Brush controls",children:[(0,ZD.jsx)("div",{style:oN,children:e?.label??"Filter range"}),r?(0,ZD.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,ZD.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12},children:[(0,ZD.jsxs)("span",{children:["Start: ",s(u)]}),(0,ZD.jsx)("input",{type:"range",min:c,max:l,step:h,value:u,disabled:!a,style:{minHeight:t},onChange:t=>{const n=Number(t.currentTarget.value);e?.onChange?.([Math.min(n,d),d])}})]}),(0,ZD.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12},children:[(0,ZD.jsxs)("span",{children:["End: ",s(d)]}),(0,ZD.jsx)("input",{type:"range",min:c,max:l,step:h,value:d,disabled:!a,style:{minHeight:t},onChange:t=>{const n=Number(t.currentTarget.value);e?.onChange?.([u,Math.max(n,u)])}})]})]}):(0,ZD.jsx)("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."}),(0,ZD.jsx)("button",{type:"button",disabled:i||!iN(e?.onClear),onClick:e?.onClear,style:rN(t),children:"Clear range"})]})}function aN({zoom:e,targetSize:t}){const n=!0===e?.disabled;return(0,ZD.jsxs)("section",{style:nN,"aria-label":"Zoom controls",children:[(0,ZD.jsx)("div",{style:oN,children:e?.label??"Zoom"}),(0,ZD.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,ZD.jsx)("button",{type:"button","aria-label":"Zoom out",disabled:n||!iN(e?.onZoomOut),onClick:e?.onZoomOut,style:rN(t),children:"-"}),(0,ZD.jsx)("button",{type:"button","aria-label":"Reset zoom",disabled:n||!iN(e?.onReset),onClick:e?.onReset,style:rN(t),children:"Reset"}),(0,ZD.jsx)("button",{type:"button","aria-label":"Zoom in",disabled:n||!iN(e?.onZoomIn),onClick:e?.onZoomIn,style:rN(t),children:"+"})]})]})}function cN({legend:e,targetSize:t}){const n=!0===e?.disabled,o=e?.items??[];return(0,ZD.jsxs)("section",{style:nN,"aria-label":"Legend controls",children:[(0,ZD.jsx)("div",{style:oN,children:e?.label??"Series"}),o.length>0&&(0,ZD.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(o=>{const r=!1!==o.active;return(0,ZD.jsxs)("button",{type:"button",disabled:n||o.disabled||!e?.onToggle,onClick:()=>e?.onToggle?.(o.id,!r),style:rN(t,r),"aria-pressed":r,children:[o.color&&(0,ZD.jsx)("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)})}),(0,ZD.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,ZD.jsx)("button",{type:"button",disabled:n||!iN(e?.onShowAll),onClick:e?.onShowAll,style:rN(t),children:"Show all"}),(0,ZD.jsx)("button",{type:"button",disabled:n||!iN(e?.onHideAll),onClick:e?.onHideAll,style:rN(t),children:"Hide all"})]})]})}function lN({controls:e,targetSize:t=44,compact:n=!1,className:o,style:r,ariaLabel:i="Mobile chart controls",brush:s,zoom:a,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:s,zoom:a,legend:c});return 0===l.length?null:(0,ZD.jsxs)("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")&&(0,ZD.jsx)(sN,{brush:s,targetSize:t}),l.includes("zoom")&&(0,ZD.jsx)(aN,{zoom:a,targetSize:t}),l.includes("legend")&&(0,ZD.jsx)(cN,{legend:c,targetSize:t})]})}var uN=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),dN=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),hN=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),pN=new Set(["LineChart","AreaChart","StackedAreaChart"]),mN=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]),yN=new Set(["LineChart","AreaChart","StackedAreaChart","ConnectedScatterplot"]),fN=new Set(["PieChart","DonutChart"]),gN={PieChart:"valueAccessor",DonutChart:"valueAccessor",FunnelChart:"valueAccessor"},bN=new Set(Object.keys(gN)),vN={StackedBarChart:"valueAccessor",StackedAreaChart:"yAccessor"},xN=new Set(["BigNumber"]),wN=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),kN=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),SN=new Set(["StreamPhysicsFrame","GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]),AN=new Set(["OrbitDiagram",...SN]),CN=new Set(["GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart"]),MN=new Set(["GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]),jN=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),PN=new Set(["MultiAxisLineChart"]),IN=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),RN={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},TN="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.",_N=new Set([...wN,"RealtimeLineChart","RealtimeHeatmap"]),LN=Object.fromEntries(Object.entries(RN).map(([e,t])=>[e,[t,"hoverRadius"]]));function DN(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function NN(e){return"string"==typeof e&&e.trim().length>0}function $N(e){const t=DN(e.capability)?e.capability:null,n=DN(e.recipe)?e.recipe:null,o=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,n?.mobile];for(const e of o)if(DN(e))return e;return null}function BN(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 EN(e){return BN(e.size)||BN(DN(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function ON(e,t){e.push({...t,status:"pass"})}function FN(e,t){e.push({...t,status:"warn"})}function zN(e,t){e.push({...t,status:"manual"})}function HN(e,t={},n={}){const o=n.viewportWidth??390,r=n.targetSize??44,i=EN(t),s=Bh(t,{width:o,height:i?.[1]}),a=[],c=EN(t=s.props),l=$N(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=$N(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=NN(t.title)||NN(t.summary)||NN(t.description)||!0===l?.summary||NN(l?.summary);if(s.matches.length>0&&ON(a,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${s.matches.length} responsive rule(s) applied for the ${o}px mobile audit.`}),c){const[t,n]=c;t>o&&!d?FN(a,{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."}):ON(a,{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&&FN(a,{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&&FN(a,{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&&FN(a,{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 zN(a,{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,DN(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:_N.has(e)?1.25*o:kN.has(e)?Math.max(8,Math.floor(o/34)):o)?FN(a,{id:"density.mark-budget",category:"density",impact:_N.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."}):ON(a,{id:"density.mark-budget",category:"density",impact:"medium",message:m+" data item(s) are within the rough mobile density budget for this component."}));const y=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),f=!1!==t.showAxes&&!1!==t.axis;if(f&&null!=y){const e=Math.max(3,Math.floor(o/58));y>e&&FN(a,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${y} 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 f&&(_N.has(e)||kN.has(e))&&zN(a,{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=DN(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=$N(e),n=DN(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||NN(t?.interaction?.hoverFallback)}(e)}(t)?ON(a,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):FN(a,{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=LN[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=DN(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?FN(a,{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?FN(a,{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."}):ON(a,{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=$N(e),o=DN(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)&&FN(a,{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||FN(a,{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=>DN(e)):[];if(w.length>("number"==typeof l?.maxAnnotations?l.maxAnnotations:3)&&430>=o&&FN(a,{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=>!NN(e.mobileText)&&!NN(e.shortText)&&!NN(e.label));e.length>0&&zN(a,{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||zN(a,{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?(ON(a,{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?FN(a,{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&&zN(a,{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."})):zN(a,{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||FN(a,{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=a.filter(e=>"warn"===e.status),S={highRisk:k.filter(e=>"high"===e.impact).length,warnings:k.length,manual:a.filter(e=>"manual"===e.status).length,passes:a.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:o,ok:0===S.highRisk,summary:S,findings:a,reference:TN}}var WN={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},qN=["layout","density","interaction","annotation","semantics"];function GN(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 qN){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(` ${WN[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 YN(){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."]}var VN,XN=d(require("react")),UN=[];function KN(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function QN(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function ZN(e){return Array.isArray(e)?e.length>0:!!e}var JN=require("react/jsx-runtime"),e$={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function t$(){const e=function(){const e=cl.useContext(ul);return e?e.toggle:null}();return e?(0,JN.jsx)("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:d$,children:(0,JN.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,JN.jsx)("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),(0,JN.jsx)("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),(0,JN.jsx)("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var n$={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)"},o$={error:4,warning:3,info:2,success:1,neutral:0};function r$({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(0,JN.jsxs)("svg",{...t,children:[(0,JN.jsx)("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),(0,JN.jsx)("path",{d:"M8 6.4v3.4"}),(0,JN.jsx)("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return(0,JN.jsxs)("svg",{...t,children:[(0,JN.jsx)("circle",{cx:"8",cy:"8",r:"6.4"}),(0,JN.jsx)("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return(0,JN.jsxs)("svg",{...t,children:[(0,JN.jsx)("circle",{cx:"8",cy:"8",r:"6.4"}),(0,JN.jsx)("path",{d:"M8 7.4V11"}),(0,JN.jsx)("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return(0,JN.jsxs)("svg",{...t,children:[(0,JN.jsx)("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"}),(0,JN.jsx)("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function i$({notification:e,level:t,onDismiss:n}){const o=n$[t]??n$.info,r=!1!==e.dismissible;return(0,JN.jsxs)("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:[(0,JN.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.source&&(0,JN.jsx)("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&&(0,JN.jsx)("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:o},children:e.title}),(0,JN.jsx)("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),r&&(0,JN.jsx)("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:n,style:{...d$,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function s$({visible:e,onDismiss:t}){const[n,o]=N_.useState(!1),r=N_.useRef(null),i=N_.useRef(null);if(N_.useEffect(()=>{0===e.length&&n&&o(!1)},[e.length,n]),N_.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 s=e.reduce((e,t)=>o$[t.level]>o$[e]?t.level:e,e[0].level),a=n$[s]??n$.info,c=e.length,l=`${c} chart notification${1===c?"":"s"}, most severe: ${s}`;return(0,JN.jsxs)("div",{ref:r,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[(0,JN.jsx)("span",{style:e$,role:"status","aria-live":"polite",children:l}),(0,JN.jsxs)("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:{...d$,color:a,position:"relative"},children:[(0,JN.jsx)(r$,{level:s}),(0,JN.jsx)("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:a,color:"#fff",fontSize:9,fontWeight:700,lineHeight:"15px",textAlign:"center"},children:c>99?"99+":c})]}),n&&(0,JN.jsx)("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=>(0,JN.jsx)(i$,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var a$={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 c$({height:e}){return(0,JN.jsx)("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 l$({error:e}){return(0,JN.jsx)("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:(0,JN.jsx)("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var u$=N_.forwardRef(function({title:e,subtitle:t,children:n,width:o="100%",height:r=400,actions:i,chartConfig:s,describe:a,navigable:c,controls:l,banner:u,notifications:d,dataAudit:h,onNotificationDismiss:p,loading:m=!1,error:y,errorBoundary:f=!1,status:g,detailsPanel:b,mobile:v,mobileAudit:x,className:w,style:k},S){const A=N_.useRef(null),C=N_.useRef(null),[M,j]=N_.useState(!1),P=function(e,t){const[n,o]=XN.useState(UN),r=e?.component,i=e?.props,s=!!t,a="object"==typeof t?t.checkOutliers:void 0,c="object"==typeof t?t.errorsOnly:void 0,l="object"==typeof t?t.max:void 0;return XN.useEffect(()=>{let e=!0;return s&&r&&i?((VN??(VN=Promise.resolve().then(()=>(ht(),lt)).catch(e=>{throw VN=void 0,e})),VN).then(({buildChartDataAuditNotifications:t})=>{e&&o(t({component:r,props:i},{checkOutliers:a,errorsOnly:c,max:l}))}).catch(()=>{e&&o(UN)}),()=>{e=!1}):(o(e=>0===e.length?e:UN),()=>{e=!1})},[a,r,s,c,l,i]),n}(s,h),I=N_.useMemo(()=>[...d??[],...P],[d,P]),[R,T]=N_.useState(()=>new Set);N_.useEffect(()=>{T(e=>{if(0===e.size)return e;const t=new Set(I.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})},[I]);const _=N_.useMemo(()=>I.map((e,t)=>({notification:e,index:t,key:e.id??t+"",level:e.level??"info"})).filter(({key:e})=>!R.has(e)),[I,R]),L=N_.useCallback(e=>{T(t=>new Set(t).add(e.key)),p?.(e.notification,e.index)},[p]),D=!1!==i?.export&&void 0!==i?.export,N=!1!==i?.fullscreen&&void 0!==i?.fullscreen,$=!1!==i?.copyConfig&&void 0!==i?.copyConfig&&s,B=!0===i?.dataSummary,E=N_.useMemo(()=>{if(!a||!s?.component||!s?.props)return"";const e="object"==typeof a?a.levels:void 0;try{return iD(s.component,s.props,e?{levels:e}:{}).text}catch{return""}},[a,s]),O="object"==typeof a&&!0===a.visible,F=N_.useMemo(()=>{if(!c||!s?.component||!s?.props)return null;const e="object"==typeof c?c.maxLeaves:void 0;try{return uD(s.component,s.props,e?{maxLeaves:e}:{})}catch{return null}},[c,s]),z="object"==typeof c&&!0===c.visible,H=N_.useMemo(()=>"object"==typeof i?.export?i.export:{},[i?.export]),W="object"==typeof i?.copyConfig?i.copyConfig.format:"json",q=N_.useCallback(async e=>{C.current&&await __(C.current,{...H,...e})},[H]),G=N_.useCallback(()=>{A.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):A.current.requestFullscreen().catch(()=>{}))},[]),Y=N_.useCallback(async e=>{s&&await PL({...s,version:s.version??"1",createdAt:s.createdAt??(new Date).toISOString()},e||W||"json")},[s,W]);N_.useEffect(()=>{const e=()=>{j(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),N_.useImperativeHandle(S,()=>({export:q,toggleFullscreen:G,copyConfig:Y,element:A.current}),[q,G,Y]);const V=!0===v?{}:v&&"object"==typeof v?v:null,X=!!v,U=V?.breakpoint??480,K=void 0===V?.chartMode?"mobile":V.chartMode,Q=V?.semantics,Z=V?.mobileInteraction??(!!X||void 0),J=V?.standardControls,ee=KN(J)?J:null,te=ee?.controls??(KN(J)?void 0:J)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(Z),ne=N_.useMemo(()=>function(e,t){return ZN(t)?e&&"object"==typeof e?{...e,standardControls:t}:!1===e||null==e?e:{standardControls:t}:e}(Z,te),[Z,te]),oe=X&&ZN(te)?(0,JN.jsx)(lN,{controls:te,targetSize:ee?.targetSize??QN(Z)??44,compact:ee?.compact??!0,className:ee?.className,style:ee?.style,ariaLabel:ee?.ariaLabel,brush:ee?.brush,zoom:ee?.zoom,legend:ee?.legend}):null,re=V?.summary,ie=!0===V?.allowHorizontalScroll,se=!0===V?.hideToolbar,ae=N_.useMemo(()=>{if(!x||!s?.component||!s?.props)return null;const e="object"==typeof x?x:{},t=s.props;try{return HN(s.component,{...t,mobileSemantics:t.mobileSemantics??Q,mobileInteraction:t.mobileInteraction??ne},{viewportWidth:e.viewportWidth??390,targetSize:e.targetSize??44,inChartContainer:!0})}catch{return null}},[x,s,Q,ne]);N_.useEffect(()=>{if(!ae||ae.ok)return;const e=ae.findings.filter(e=>"pass"!==e.status).slice(0,5);console.warn(`[Semiotic mobile audit] ${s?.component}: ${ae.summary.highRisk} high-risk mobile finding(s), ${ae.summary.warnings} warning(s).`,e)},[ae,s?.component]);const ce=ae&&!ae.ok&&"object"==typeof x&&!0===x.visible?(0,JN.jsxs)("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: ",ae.summary.highRisk," high-risk finding",1===ae.summary.highRisk?"":"s"," and"," ",ae.summary.warnings," warning",1===ae.summary.warnings?"":"s"," at"," ",("object"==typeof x?x.viewportWidth:void 0)??390,"px."]}):null,le=_.length>0,ue=e||t||l||D||N||$||B||g||le,de=N_.useMemo(()=>{if(!X||!N_.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 K&&null==e.mode&&(t.mode=K),Q&&null==e.mobileSemantics&&(t.mobileSemantics=Q),void 0!==ne&&null==e.mobileInteraction&&(t.mobileInteraction=ne),Object.keys(t).length>0?N_.cloneElement(n,t):n},[n,X,K,Q,ne]),he=m?(0,JN.jsx)(c$,{height:r}):y?(0,JN.jsx)(l$,{error:y}):f?(0,JN.jsx)(jp,{children:de}):de;return pe=(0,JN.jsxs)(JN.Fragment,{children:[(0,JN.jsx)("style",{dangerouslySetInnerHTML:{__html:`@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n@media (max-width: ${U}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}`}}),(0,JN.jsxs)("div",{ref:A,className:"semiotic-chart-container"+(w?" "+w:""),"data-semiotic-mobile":X?"true":void 0,"data-semiotic-mobile-scroll":ie?"true":void 0,"data-semiotic-mobile-hide-toolbar":se?"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",...M?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{},...k},children:[ue&&(0,JN.jsxs)("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:[(0,JN.jsxs)("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[e&&(0,JN.jsx)("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:e}),t&&(0,JN.jsx)("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0},children:t})]}),(0,JN.jsxs)("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[l,le&&(0,JN.jsx)(s$,{visible:_,onDismiss:L}),D&&(0,JN.jsx)("button",{className:"semiotic-chart-action",onClick:()=>q(),title:"Export chart","aria-label":"Export chart",style:d$,children:(0,JN.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,JN.jsx)("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),(0,JN.jsx)("path",{d:"M2 12h10"})]})}),B&&(0,JN.jsx)(t$,{}),N&&(0,JN.jsx)("button",{className:"semiotic-chart-action",onClick:G,title:M?"Exit fullscreen":"Fullscreen","aria-label":M?"Exit fullscreen":"Enter fullscreen",style:d$,children:(0,JN.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,JN.jsxs)(JN.Fragment,M?{children:[(0,JN.jsx)("path",{d:"M9 1v4h4"}),(0,JN.jsx)("path",{d:"M5 13V9H1"}),(0,JN.jsx)("path",{d:"M13 5H9V1"}),(0,JN.jsx)("path",{d:"M1 9h4v4"})]}:{children:[(0,JN.jsx)("path",{d:"M1 5V1h4"}),(0,JN.jsx)("path",{d:"M13 9v4H9"}),(0,JN.jsx)("path",{d:"M9 1h4v4"}),(0,JN.jsx)("path",{d:"M5 13H1V9"})]})})}),$&&(0,JN.jsx)("button",{className:"semiotic-chart-action",onClick:()=>Y(),title:"Copy config","aria-label":"Copy chart configuration",style:d$,children:(0,JN.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,JN.jsx)("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),(0,JN.jsx)("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),g&&(0,JN.jsx)("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:a$[g].bg,color:a$[g].color,lineHeight:"18px"},children:g})]})]}),u&&(0,JN.jsx)("div",{className:"semiotic-chart-banner",children:u}),ce,re&&(0,JN.jsx)("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:re}),oe&&(0,JN.jsx)("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:oe}),E&&(0,JN.jsx)("div",{className:"semiotic-chart-description",role:"note",style:O?{padding:"8px 16px",fontSize:12,lineHeight:1.5,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}:e$,children:E}),F&&(0,JN.jsx)("div",{className:"semiotic-chart-nav",style:z?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:(0,JN.jsx)(KD,{tree:F,label:"string"==typeof e&&e?e+" — navigable structure":"Chart navigable structure",visible:z,chartId:"string"==typeof s?.props?.chartId?s.props.chartId:void 0})}),(0,JN.jsxs)("div",{className:"semiotic-chart-body",ref:C,style:{position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",...M?{flex:1}:{height:r}},children:[he,b]})]})]}),B?(0,JN.jsx)(dl,{children:pe}):pe;var pe}),d$={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},h$=d(require("react")),p$=require("react/jsx-runtime");function m$({children:e,controls:t,mobile:n,breakpoint:o=480,chartMode:r="mobile",mobileInteraction:i=!0,mobileSemantics:s,mobileSummary:a,chips:c=[],activeChip:l,onChipChange:u,detail:d,detailTitle:h="Details",detailMode:p="sheet",initialDetailOpen:m=!1,allowHorizontalScroll:y=!1,hideToolbar:f=!1,chartDefaults:g,...b}){const[v,x]=h$.useState(()=>l??c.find(e=>!e.disabled)?.id),[w,k]=h$.useState(m);h$.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=h$.useCallback(e=>{e.disabled||(void 0===l&&x(e.id),u?.(e))},[l,u]),C=c.length?(0,p$.jsx)("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:c.map(e=>(0,p$.jsxs)("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:[(0,p$.jsx)("span",{children:e.label}),e.description&&(0,p$.jsx)("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,M=a||C?(0,p$.jsxs)("div",{className:"semiotic-mobile-summary-card",children:[a&&(0,p$.jsx)("div",{className:"semiotic-mobile-summary-copy",children:a}),C]}):n?.summary,j={breakpoint:o,chartMode:r,mobileInteraction:i,semantics:s,allowHorizontalScroll:y,hideToolbar:f,...n,summary:M},P=h$.useMemo(()=>{if(!g||!h$.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?h$.cloneElement(e,n):e},[e,g]),I=!!d&&"sheet"===p,R=!!d&&"inline"===p||I&&w,T=I?(0,p$.jsx)("button",{type:"button",className:"semiotic-mobile-detail-toggle","aria-expanded":w,onClick:()=>k(e=>!e),children:w?"Hide details":"Show details"}):null,_=t||T?(0,p$.jsxs)("div",{className:"semiotic-mobile-control-stack",children:[t,T]}):void 0;return(0,p$.jsxs)("div",{className:"semiotic-mobile-chart-shell",children:[(0,p$.jsx)("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-primary, #1f7a6d);\n background: color-mix(in srgb, var(--semiotic-primary, #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 `}),(0,p$.jsx)(u$,{...b,controls:_,mobile:j,children:P}),R&&(0,p$.jsxs)("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof h?h:"Chart details",children:[(0,p$.jsxs)("div",{className:"semiotic-mobile-detail-header",children:[(0,p$.jsx)("span",{children:h}),I&&(0,p$.jsx)("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),(0,p$.jsx)("div",{className:"semiotic-mobile-detail-body",children:d})]})]})}var y$=d(require("react")),f$=require("react/jsx-runtime");function g$(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function b$(e,t){const n="function"==typeof t?t(e):e[t];return Array.isArray(n)?n:[]}function v$(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 x$(e,t){if(!y$.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?y$.cloneElement(e,o):e}function w$({items:e,children:t,columns:n=3,tabletColumns:o=2,mobileColumns:r=1,mobileBreakpoint:i=480,tabletBreakpoint:s=860,gap:a=12,mode:c="mobile",chartHeight:l=220,sharedExtent:u=!0,valueAccessor:d,dataAccessor:h="data",extentProps:p=["yExtent","valueExtent"],linkedHover:m,selection:y,linkedBy:f,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:j,className:P,style:I}){const R=tp(),T=e||"function"==typeof t?[]:y$.Children.toArray(t),_=e??T.map((e,t)=>({id:"panel-"+(t+1)})),L=_.length,D=y$.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 b$(t,n))i.push(g$(e,o));const s=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 s?{yExtent:s,valueExtent:s}:{}}(_,u,h,d),[_,u,h,d]),N=y$.useMemo(()=>{if(!f)return{name:void 0,fields:void 0,linkedHover:m,selection:y};const e=Array.isArray(f)?"small-multiples":f.name||"small-multiples",t=Array.isArray(f)?f:f.fields||[];return{name:e,fields:t,linkedHover:m??{name:e,fields:t},selection:y??{name:e}}},[f,m,y]),$=y$.useMemo(()=>({linkedHover:N.linkedHover,selection:N.selection}),[N.linkedHover,N.selection]),B=y$.useMemo(()=>{const e={mode:c,height:l,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:C??v$(L),...$,...j};"legend"!==M&&(e.showLegend=!1),"direct"===M&&(e.directLabel=!0);for(const t of p)t in D&&(e[t]=D[t]);return e},[c,l,A,C,L,$,j,M,p,D]),E=(0,f$.jsxs)("section",{className:["semiotic-small-multiple-chart",P].filter(Boolean).join(" "),style:I,"data-semiotic-small-multiple":"true",children:[(0,f$.jsx)("style",{children:`\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${n};\n --semiotic-small-multiple-gap: ${a}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: ${s}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 `}),_.map((e,n)=>{const o={...B},r="function"==typeof t?t(e,{item:e,index:n,count:L,chartProps:o,sharedExtent:D}):T[n];return(0,f$.jsxs)("article",{className:"semiotic-small-multiple-panel","aria-label":"string"==typeof e.title?e.title:void 0,children:[(e.title||e.subtitle||e.summary)&&(0,f$.jsxs)("header",{className:"semiotic-small-multiple-heading",children:[e.title&&(0,f$.jsx)("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&(0,f$.jsx)("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&(0,f$.jsx)("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),(0,f$.jsx)("div",{className:"semiotic-small-multiple-plot",children:x$(r,o)})]},e.id??n)})]});return!0===g||"auto"===g&&(f||m||y||b||!0===v)&&!R?(0,f$.jsx)(up,{selections:b,showLegend:v,legendPosition:x,legendInteraction:w,legendSelectionName:k??N.name??"small-multiples",legendField:S??N.fields?.[0]??"category",children:E}):E}var k$=d(require("react")),S$=require("react/jsx-runtime");function A$({children:e,columns:t="auto",minCellWidth:n=300,gap:o=16,tabletColumns:r,mobileColumns:i=1,mobileBreakpoint:s=480,tabletBreakpoint:a=860,chartDefaults:c,className:l,style:u}){const d="semiotic-chart-grid-"+k$.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(0,S$.jsxs)(S$.Fragment,{children:[(0,S$.jsx)("style",{children:`\n ${r?`\n @media (max-width: ${a}px) {\n .${d} {\n grid-template-columns: repeat(${r}, minmax(0, 1fr)) !important;\n }\n }`:""}\n @media (max-width: ${s}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 `}),(0,S$.jsx)("div",{className:m,style:{display:"grid",gridTemplateColumns:p,gap:o,width:"100%",...u},children:k$.Children.map(e,e=>{if(!k$.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?k$.cloneElement(e,n):e;return"primary"!==e.props.emphasis||void 0!==h&&2>h?o:(0,S$.jsx)("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:o})})})]})}A$.displayName="ChartGrid";var C$=d(require("react")),M$=require("react/jsx-runtime");function j$({children:e,context:t,position:n="right",contextSize:o=250,mobilePosition:r="bottom",mobileBreakpoint:i=480,gap:s=12,className:a,style:c}){const l="semiotic-context-layout-"+C$.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:s,width:"100%",...c},p=u?{flex:`0 0 ${o}px`,width:o,minHeight:0}:{flex:`0 0 ${o}px`,height:o,minWidth:0};return(0,M$.jsxs)(M$.Fragment,{children:[(0,M$.jsx)("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 `}),(0,M$.jsxs)("div",{className:["semiotic-context-layout",l,a].filter(Boolean).join(" "),"data-mobile-position":r,style:h,children:[(0,M$.jsx)("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),(0,M$.jsx)("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}j$.displayName="ContextLayout";var P$=require("react"),I$=require("react/jsx-runtime"),R$=200;function T$({children:e,position:t="right",size:n=300,trigger:o="click",chartId:r,observation:i,dismissOnEmpty:s=!0,showClose:a=!0,onToggle:c,className:l,style:u}){const[d,h]=(0,P$.useState)(null),[p,m]=(0,P$.useState)(null),[y,f]=(0,P$.useState)(!1),[g,b]=(0,P$.useState)(!1),v=(0,P$.useRef)(null),x=(0,P$.useRef)(void 0),w="click"===o?["click","click-end"]:["hover","hover-end"],{latest:k}=Qh({types:w,chartId:r,limit:1}),S=void 0!==i?i:k,A=(0,P$.useCallback)(()=>{b(!0),f(!1),clearTimeout(x.current),x.current=setTimeout(()=>{b(!1),h(null),m(null)},R$)},[]);if((0,P$.useEffect)(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;h(e.datum),m(e),f(e=>(e||(b(!0),clearTimeout(x.current),x.current=setTimeout(()=>b(!1),R$)),!0))}else!s||"click-end"!==S.type&&"hover-end"!==S.type||A()},[s,A,S]),(0,P$.useEffect)(()=>{c?.(y)},[y,c]),(0,P$.useEffect)(()=>()=>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 ${R$}ms ease-out, opacity ${R$}ms 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,y,g);return(0,I$.jsxs)("div",{ref:v,className:`semiotic-details-panel semiotic-details-${t}${l?" "+l:""}`,style:{...M,...u},children:[a&&(0,I$.jsx)("button",{className:"semiotic-details-close",onClick:A,"aria-label":"Close details",style:_$,children:(0,I$.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:(0,I$.jsx)("path",{d:"M2 2l8 8M10 2l-8 8"})})}),(0,I$.jsx)("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:C})]})}var _$={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};T$.displayName="DetailsPanel";var L$={BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},valueFormat:{type:"function"},categoryFormat:{type:"function"},data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["vertical","horizontal"]},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},valueExtent:{type:"array"},styleRules:{type:"array"},gradientFill:{type:"object"},regression:{type:["boolean","string","object"]}}},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},styleRules:{type:"array"},gradientFill:{type:"object"}}},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},styleRules:{type:"array"},gradientFill:{type:"object"}}},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"}}},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"}}},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},regression:{type:["boolean","string","object"]}}},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},valueFormat:{type:"function"},centerContent:{type:["object","string","number","function"]},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}}},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"}}},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"},trackFill:{type:["string","object"]},gradientFill:{type:"object"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}}},LikertChart:{required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},categoryLabel:{type:"string"},valueLabel:{type:"string"},showCategoryTicks:{type:"boolean"},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"},valueExtent:{type:"array"}}},LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]},fillArea:{type:"boolean"},areaOpacity:{type:"number"},lineGradient:{type:"object"},directLabel:{type:["boolean","object"]},gapStrategy:{type:"string",enum:["break","interpolate","zero"]},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]},xExtent:{type:"array"},yExtent:{type:"array"}}},BumpChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:["boolean","string"],enum:["series"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"},lineBy:{type:["string","function"]},rankDirection:{type:"string",enum:["descending","ascending"]},ribbon:{type:"boolean"},curve:{type:"string",enum:["smooth","linear"]},ribbonSizeRange:{type:"array"},samplesPerSegment:{type:"number"},lineWidth:{type:"number"},highlightTop:{type:"number"},neutralColor:{type:"string"},ribbonOpacity:{type:"number"},lineOpacity:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},showLabels:{type:["boolean","string"],enum:["start","end","both"]},showAxes:{type:"boolean"},styleRules:{type:"array"},labelStyle:{type:["object","function"]}}},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"]},y0Accessor:{type:["string","function"]},gradientFill:{type:"object"},semanticGradient:{type:"object"},semanticLine:{type:"boolean"},lineGradient:{type:"object"},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]},xExtent:{type:"array"},yExtent:{type:"array"}}},DifferenceChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","seriesAAccessor","seriesBAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:"object"},xExtent:{type:"array"},yExtent:{type:"array"},pointIdAccessor:{type:["string","function"]},windowSize:{type:"number"}}},StackedAreaChart:{required:["data","areaBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},showPoints:{type:"boolean"},pointRadius:{type:"number"},normalize:{type:"boolean"},baseline:{type:"string",enum:["zero","wiggle","silhouette","diverging"]},stackOrder:{type:"string",enum:["key","input","insideOut","asc","desc"]},pointIdAccessor:{type:["string","function"]},xExtent:{type:"array"},yExtent:{type:"array"}}},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]},marginalGraphics:{type:["object","function"]},xExtent:{type:"array"},yExtent:{type:"array"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}}},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]},marginalGraphics:{type:["object","function"]},xExtent:{type:"array"},yExtent:{type:"array"},regression:{type:["boolean","string","object"]}}},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]},xExtent:{type:"array"},yExtent:{type:"array"}}},QuadrantChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]}}},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"},pointIdAccessor:{type:["string","function"]},xExtent:{type:"array"},yExtent:{type:"array"}}},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"]},xExtent:{type:"array"},yExtent:{type:"array"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"},fields:{type:"array"}}},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},data:{type:"array"}}},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIdAccessor","sourceAccessor","targetAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},nodes:{type:"array"},edges:{type:"array"},nodeIdAccessor:{type:["string","function"]},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"},nodeStroke:{type:"string"},nodeStrokeWidth:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},layoutExecution:{type:"string",enum:["auto","worker","sync"]},layoutLoadingContent:{type:["boolean","object"]},onLayoutStateChange:{type:"function"},showLabels:{type:"boolean"}}},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"]},nodeLabel:{type:["string","function"]},startTimeAccessor:{type:["string","function"]},endTimeAccessor:{type:["string","function"]},systemInTimeAccessor:{type:["string","function"]},systemOutTimeAccessor:{type:["string","function"]},xExtentAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},edgeIdAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},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"]},maxValueScale:{type:"number"},lanePlacement:{type:"string",enum:["stack","hug"]},showLabels:{type:["boolean","string"],enum:["auto"]},labelPriorityAccessor:{type:"string"},maxLabels:{type:"number"},selectionDatum:{type:"string",enum:["raw","scene"]},groupPadding:{type:"number"},ribbonLane:{type:"string",enum:["source","target","both"]},ribbonMinRun:{type:["number","string"]},lifetimeMode:{type:"string",enum:["full","half"]},showLaneRails:{type:"boolean"},showQualityReadout:{type:"boolean"},edgeOpacity:{type:"number"},styleRules:{type:"array"},layoutExecution:{type:"string",enum:["auto","worker","sync"]},layoutWorkerThreshold:{type:"number"},layoutLoadingContent:{type:["boolean","object"]},onLayoutStateChange:{type:"function"},timeFormat:{type:"function"},valueFormat:{type:"function"},showParticles:{type:"boolean"},particleStyle:{type:"object"}}},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},areas:{type:["array","string"]}}},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]},lineIdAccessor:{type:["string","function"]},pointRadius:{type:"number"}}},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},frameProps:{type:"object"},onClick:{type:"function"},styleRules:{type:"array"},points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]},showRingLabels:{type:"boolean"},cartogramLayout:{type:"string",enum:["radial","strip"]}}},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{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"},maxDevicePixelRatio:{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"},maxDevicePixelRatio:{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"},maxDevicePixelRatio:{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"},maxDevicePixelRatio:{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"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"]},rerunMS:{type:["number","null"]},showProjection:{type:"boolean"}}},EventDropChart:{required:["data"],dataShape:"array",dataAccessors:["timeAccessor","arrivalAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"}}},UnitPileChart:{required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"},rerunMS:{type:["number","null"]},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"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"},rerunMS:{type:["number","null"]},showChrome:{type:"boolean"},showProjection:{type:"boolean"},showTethers:{type:"boolean"},coreForceMode:{type:"string",enum:["route","net"]},terminalBehavior:{type:"string",enum:["outcome","hold-last"]}}},CrucibleChart:{required:["data","phases"],dataShape:"array",dataAccessors:["idAccessor","labelAccessor","categoryAccessor","amountAccessor","metricsAccessor","initialStateAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},colorBy:{type:["string","function"]},seed:{type:["number","string"]},ballRadius:{type:"number"},hoverRadius:{type:"number"},paused:{type:"boolean"},tooltip:{type:["boolean","function","object"]},frameProps:{type:"object"},phases:{type:"array"},products:{type:"array"},events:{type:"array"},outlets:{type:"array"},idAccessor:{type:["string","function"]},labelAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},amountAccessor:{type:["string","function"]},metricsAccessor:{type:["string","function"]},initialStateAccessor:{type:["string","function"]},metrics:{type:"object"},amountLabel:{type:"string"},conservation:{type:["boolean","object"]},projection:{type:"object"},playback:{type:"string",enum:["replay","snapshot"]},snapshotAt:{type:["number","object"]},controls:{type:["boolean","object"]},playbackRate:{type:"number"},rerunMS:{type:["number","null"]},bodyRadius:{type:"number"},radiusRange:{type:"array"},showBonds:{type:"boolean"},showChrome:{type:"boolean"},showProjection:{type:"boolean"},initialSpawnPacing:{type:"object"},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},onStateChange:{type:"function"},onCrucibleObservation:{type:"function"},onDiagnostic:{type:"function"},onConservation:{type:"function"},onClick:{type:"function"}}},ProcessFlowChart:{required:["stages"],dataShape:"array",dataAccessors:["idAccessor","stageAccessor","groupBy","workAccessor","radiusAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"}}},PacketFlowChart:{required:[],dataShape:"network",dataAccessors:["nodeIdAccessor","nodeXAccessor","nodeYAccessor","sourceAccessor","targetAccessor","throughputAccessor","pathAccessor"],props:{mode:{type:"string",enum:["primary","context","sparkline","mobile"]},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:"boolean"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},legendInteraction:{type:"string",enum:["highlight","isolate","none"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},legend:{type:["array","object"]},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array","object"]},tooltip:{type:["boolean","function","object","string"]},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},maxDevicePixelRatio:{type:"number"},axisExtent:{type:"string",enum:["nice","exact"]},animate:{type:["boolean","object"]},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},hoverHighlight:{type:"boolean"},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},responsiveWidth:{type:"boolean"},responsiveHeight:{type:"boolean"},color:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},opacity:{type:"number"},onObservation:{type:"function"},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"}}},ChainReactionChart:{required:["data","taskIDAccessor","labelAccessor","laneAccessor","dependencyAccessor"],dataShape:"array",dataAccessors:["taskIDAccessor","labelAccessor","laneAccessor","dependencyAccessor","startAccessor","endAccessor","progressAccessor","statusAccessor","completionTimeAccessor","blockerAccessor","milestoneAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},maxDevicePixelRatio:{type:"number"},className:{type:"string"},title:{type:"string"},description:{type:"string"},summary:{type:"string"},accessibleTable:{type:["boolean","object"]},chartId:{type:"string"},emphasis:{type:"string",enum:["primary","secondary"]},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"},taskIDAccessor:{type:["string","function"]},labelAccessor:{type:["string","function"]},laneAccessor:{type:["string","function"]},dependencyAccessor:{type:["string","function"]},startAccessor:{type:["string","function"]},endAccessor:{type:["string","function"]},progressAccessor:{type:["string","function"]},statusAccessor:{type:["string","function"]},completionTimeAccessor:{type:["string","function"]},blockerAccessor:{type:["string","function"]},milestoneAccessor:{type:["string","function"]},mode:{type:"string",enum:["snapshot","replay","mechanical"]},insight:{type:"string",enum:["none","blocker-amplification"]},currentTime:{type:["number","object"]},controls:{type:["boolean","array"]},mechanism:{type:"string",enum:["domino-ball"]},orientation:{type:"string",enum:["vertical"]},reducedMotion:{type:"string",enum:["settle"]},selectedTaskIDs:{type:"array"},onSelectionChange:{type:"function"},onObservation:{type:"function"}}},BigNumber:{required:[],dataShape:"none",dataAccessors:[],props:{width:{type:["number","string"]},height:{type:["number","string"]},className:{type:"string"},chartId:{type:"string"},description:{type:"string"},summary:{type:"string"},loading:{type:"boolean"},loadingContent:{type:["boolean","object"]},emptyContent:{type:["boolean","object"]},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 D$(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function N$(e,t){const n=[];null!=t&&"object"==typeof t||(t={});const o=L$[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(L$).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||"UnitPileChart"===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(!D$(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=Bp(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 s=zp({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=Hp({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=t.nodeIdAccessor??t.nodeIDAccessor??"id",i="string"==typeof r?{nodeIdAccessor:r}:void 0,s=Wp({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges"),accessors:i});s&&n.push(s)}return"GaugeChart"===e&&n.push(...function(e){if(!Array.isArray(e.thresholds))return[];const t=[];return 0===e.thresholds.length&&t.push('"thresholds" for GaugeChart must contain at least one { value, color, label? } object.'),e.thresholds.forEach((e,n)=>{if(!e||"object"!=typeof e||Array.isArray(e))return void t.push(`"thresholds[${n}]" for GaugeChart should be an object with numeric "value" and string "color".`);const o=e;"number"==typeof o.value&&Number.isFinite(o.value)||t.push(`"thresholds[${n}].value" is required for GaugeChart and must be a finite number. BigNumber's "at" threshold key is not supported here.`),"string"==typeof o.color&&0!==o.color.length||t.push(`"thresholds[${n}].color" is required for GaugeChart and must be a non-empty string.`),void 0!==o.label&&"string"!=typeof o.label&&t.push(`"thresholds[${n}].label" for GaugeChart should be a string.`);const r=Object.keys(o).filter(e=>"value"!==e&&"color"!==e&&"label"!==e);r.length>0&&t.push(`"thresholds[${n}]" has unsupported GaugeChart key(s): ${r.join(", ")}. Use { value, color, label? }; { at, level } belongs to BigNumber.`)}),t}(t)),{valid:0===n.length,errors:n}}require("d3-interpolate");var $$=80,B$=100;function E$(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function O$(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)>B$?$$:B$);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 F$(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 z$(e){const t=F$(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 H$(e){const t=F$(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:O$(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:O$(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:O$(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:O$(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 W$(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],s=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*s(o)+.7152*s(r)+.0722*s(i)}function q$(e,t){const n=W$(e),o=W$(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}var G$=120,Y$=250,V$=["xExtent","yExtent","rExtent"],X$=8;function U$(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function K$(e,t,n){if("function"==typeof t)return t(e);const o="string"==typeof t?t:n;return e?.[o]}ct();var Q$=new Set(["category10","tableau10","set3","blues","reds","greens","oranges","purples","greys","viridis","plasma","inferno","magma","cividis","turbo"]),Z$=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIdAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function J$(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function eB(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function tB(e,t){const n=eB(e.visibleTokens);if(null!=n)return n;const o=eB(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=o)return o;const r=eB(t.tokenCount),i=eB(t.maxTokens);return null!=r&&null!=i?Math.min(r,i):r??o??i}function nB(e,t){const n=[],o=N$(e,function(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,J$(t.encoding)&&delete t.encoding,t}(t));for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});if(!L$[e])return{ok:0===n.length,diagnoses:n};!function(e,t,n){const o=L$[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=L$[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 s=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: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}, or use a function: ${e}={d => d.myValue}.`}))}}(e,t,n),function(e,t,n){uN.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){dN.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=L$[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 s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" 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(!hN.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(!pN.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 s=(i.left||0)+(i.right||0),a=(i.top||0)+(i.bottom||0);o>s||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${s}px) >= width (${o}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),r>a||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${a}px) >= height (${r}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n);const r=at(e,t,void 0,{checkOutliers:!1}).diagnoses;for(const e of r)"EMPTY_DATA"===e.code&&n.some(e=>"EMPTY_DATA"===e.code||"EMPTY_EDGES"===e.code)||n.push(e);if(function(e,t,n){if(!mN.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" uses the authoritative margin.bottom=${r}px — the legend may be clipped or overlap axis labels.`,fix:'Use margin={{ ...margin, bottom: "auto" }} or provide enough bottom margin for the legend, its legendDistance, and any desired outer padding.'})}(0,t,n),function(e,t,n){if(!t.showLegend)return;const o=t.legendPosition??"right";if("right"!==o&&"left"!==o)return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r[o];"number"==typeof i&&110>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="${o}" and authoritative margin.${o}=${i}px — the legend may be clipped.`,fix:`Use margin={{ ...margin, ${o}: "auto" }} or provide enough ${o} margin for the measured legend width, its legendDistance, and any desired outer padding.`})}(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=q$(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=q$(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=L$[e];r?.props?.colorScheme?.enum||Q$.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 (${[...Q$].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}(e,t,n),function(e,t,n){const o=L$[e]?.props,r=e=>!!o?.[e]&&"string"==typeof t[e]&&t[e].trim().length>0,i=r("title"),s=r("description"),a=r("summary");i||s||a||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.'})}(e,t,n),function(e,t,n){const o=[];for(const e of Z$)"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=[];J$(t.tokenEncoding)&&o.push({source:"tokenEncoding",encoding:t.tokenEncoding}),J$(t.encoding)&&o.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:r}of o){const o=tB(t,r);for(const t of O$(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=aa(e);if(!ca(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=la(e);!i&&o>G$?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>Y$&&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(ca).length;if(0===r)return;const i="number"==typeof t.width?t.width:600,s="number"==typeof t.height?t.height:400,a=ha(i,s);Number.isFinite(a)&&r>a&&n.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${r} note annotations on a ${i}×${s} chart exceed the ~${a} 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"===aa(e)&&null!=e.content&&!Us(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 V$){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(!pN.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 s=t.data;if(!s||!Array.isArray(s)||4>s.length)return;const a=t.xAccessor??"x";if("string"!=typeof a)return;let c=1/0,l=-1/0;for(const e of s){const t=e?.[a];"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),n.some(e=>"NEGATIVE_VALUE"===e.code||"NEGATIVE_NORMALIZED_VALUE"===e.code)||function(e,t,n){const o=gN[e],r=vN[e];if(!o&&!r)return;if(r&&!t.normalize)return;const i=o??r,s=t[i],a="string"==typeof s?s:"yAccessor"===i?"y":"value",c=t.data;if(!c||!Array.isArray(c)||0===c.length)return;const l=c.filter(e=>{const t=e?.[a];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 "${a}" — 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){yN.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(!fN.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",s=new Set;for(const e of o){const t=e?.[i];null!=t&&s.add(t)}s.size>X$&&n.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:`${s.size} slices — angle judgments degrade rapidly past ~${X$} categories (Cleveland & McGill), and thin slices become unreadable and unlabelable.`,fix:`Use a BarChart or DotPlot for ${s.size} categories, or group the long tail into an "Other" slice before charting.`})}(e,t,n),function(e,t,n){if(MN.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=U$(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=U$(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?U$(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=U$(K$(t,e,"time")),r=U$(K$(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("UnitPileChart"===e){const e=U$(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=U$(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=U$(K$(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:`UnitPileChart 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((U$(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."}),(U$(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=U$(e[0]),r=U$(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=K$(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&&"UnitPileChart"!==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."}),"UnitPileChart"!==e&&"GaltonBoardChart"!==e&&"CollisionSwarmChart"!==e&&"ProcessFlowChart"!==e&&"CrucibleChart"!==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 [].'})),"CrucibleChart"===e){const e=Array.isArray(t.phases)?t.phases:[],o=Array.isArray(t.products)?t.products:[],r=Array.isArray(t.events)?t.events:[],i=Array.isArray(t.outlets)?t.outlets:[];0===e.length?n.push({severity:"error",code:"CRUCIBLE_MISSING_PHASES",message:"CrucibleChart requires an authored, non-empty phases array; a treatment program cannot be inferred from flat data.",fix:'Provide phases={[{ id: "charge", label: "Charge", duration: 1, motion: "charge" }]}.'}):e.some(e=>!e||null==e.id||""===(e.id+"").trim()||null==U$(e.duration)||0>=Number(e.duration))&&n.push({severity:"error",code:"CRUCIBLE_BAD_PHASE",message:"Every CrucibleChart phase needs a stable id and a positive finite duration.",fix:'Use phases like { id: "assay", label: "Assay", duration: 2, motion: "mix" }.'}),0===o.length&&n.push({severity:"warning",code:"CRUCIBLE_NO_PRODUCTS",message:"CrucibleChart has no declared product molds. Products are never discovered from collisions or source fields.",fix:'Declare products={[{ id: "accepted", label: "Accepted", outletId: "product" }]} when the treatment forms an output.'}),0===r.length&&n.push({severity:"warning",code:"CRUCIBLE_NO_EVENTS",message:"CrucibleChart has no authored events, so its phases cannot transform, combine, split, or route the charge.",fix:"Supply an explicit events array; do not ask the chart or an AI layer to infer a treatment from the rows."}),Array.isArray(t.outlets)||n.push({severity:"warning",code:"CRUCIBLE_IMPLICIT_OUTLETS",message:"CrucibleChart is using generic default outlets rather than domain-specific destinations.",fix:"Provide reason-labelled outlets and reference their ids from products, complete-product, and eject effects."});const s=new Set(o.map(e=>e?.id).filter(e=>null!=e).map(String)),a=new Set(["product","retained","residue","failed","recovered",...i.map(e=>e?.id).filter(e=>null!=e).map(String)]),c=new Set,l=new Set;for(const e of r)if(e&&Array.isArray(e.effects))for(const t of e.effects){if(!t||"object"!=typeof t)continue;const e=t.type;if("combine"!==e&&"contribute"!==e&&"complete-product"!==e||null==t.productId||s.has(t.productId+"")||c.add(t.productId+""),"split"===e&&Array.isArray(t.products))for(const e of t.products)null==e?.productId||s.has(e.productId+"")||c.add(e.productId+"");null==t.outletId||a.has(t.outletId+"")||l.add(t.outletId+"")}c.size>0&&n.push({severity:"error",code:"CRUCIBLE_UNKNOWN_PRODUCT",message:`CrucibleChart events reference undeclared product molds: ${[...c].sort().join(", ")}.`,fix:"Declare every referenced product id in products; do not create product definitions implicitly inside events."}),l.size>0&&n.push({severity:"error",code:"CRUCIBLE_UNKNOWN_OUTLET",message:`CrucibleChart events reference undeclared outlets: ${[...l].sort().join(", ")}.`,fix:"Declare every domain outlet in outlets and reuse its stable id in authored effects."});const u=U$(t.playbackRate);null==t.playbackRate||null!=u&&u>0||n.push({severity:"error",code:"CRUCIBLE_BAD_PLAYBACK_RATE",message:`playbackRate=${t.playbackRate+""} cannot advance the authored CrucibleChart tape.`,fix:"Use a positive playbackRate such as 0.5 for half speed or 2 for double speed."});const d=U$(t.rerunMS);null==t.rerunMS||null!=d&&d>=0||n.push({severity:"error",code:"CRUCIBLE_BAD_RERUN_MS",message:`rerunMS=${t.rerunMS+""} must be a finite non-negative delay or null.`,fix:"Use rerunMS={3000}, rerunMS={0}, or omit the prop for a single run."})}if("GaltonBoardChart"===e||"CollisionSwarmChart"===e||"ProcessFlowChart"===e||"EventDropChart"===e||"CrucibleChart"===e){const o=Array.isArray(t.data)?t.data:[],r=U$(t.mechanicalCount)??0,i=o.length>0?o.length: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),"ProcessSankey"===e)for(const e of function(e){const t=[],n=e.domain;null==n?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(n)&&2===n.length&&Number.isFinite(Number(n[0]))&&Number.isFinite(Number(n[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const o=e.edges;if(Array.isArray(o)&&o.length>0){const e=o[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const r=e.nodes,i=Array.isArray(r)?r.length:0;return!0!==e.showLabels||24>i||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(o)?o.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}(t))n.push(e);return{ok:n.every(e=>"warning"===e.severity),diagnoses:n}}var oB=["title","description","summary"];function rB(e){return"string"==typeof e&&e.trim().length>0}var iB=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]),sB="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 aB(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 cB(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 lB(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function uB(e,t,n={}){const o=[],r=rL(e),i=SN.has(e),s=!!L$[e]||!!r||i,a=!0===n.inChartContainer,c=!0===n.describe,l=!0===n.navigable,u=xN.has(e),d=uN.has(e),{hasTitle:h,hasDescription:p,hasSummary:m,unsupportedFinding:y}=function(e,t){const n=L$[e]?.props,o=e=>!!n?.[e],r=oB.filter(e=>rB(t[e])&&!o(e));return{hasTitle:o("title")&&rB(t.title),hasDescription:o("description")&&rB(t.description),hasSummary:o("summary")&&rB(t.summary),unsupportedFinding:r.length>0?{id:"understandable.unsupported-description-prop",principle:"understandable",heuristic:"Descriptive text is connected to the rendered chart",critical:!0,status:"warn",message:`Useful ${r.join(" and ")} text was supplied, but ${1===r.length?"that prop is":"those props are"} not supported by ${e}'s declared chart API and cannot be credited as rendered accessibility text.`,fix:"Use the component's declared title, description, and summary props when available; for richer generated description or navigation, use ChartContainer with chartConfig plus describe and/or navigable."}:void 0}}(e,t),f=!1!==t.accessibleTable&&!u,g=h||p||m,b=function(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}(t),v=function(e){const t=lB(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),x=i,w=function(e){const t=lB(e);return!0===e.settledProjection||!0===t.settledProjection}(t)||CN.has(e)&&f,k=function(e){const t=lB(e);return!0===e.reducedMotionSettle||"settle"===e.reducedMotion||!0===t.reducedMotionSettle||"settle"===t.reducedMotion}(t)||x,S=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],A=s?"pass":"manual",C=s?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(y&&o.push(y),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 s=0;for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=q$(e,r);null!=t&&(s++,3>t&&i.push(`${e} (${t.toFixed(1)}:1)`))}return 0===s?{...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 ${s} 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."}:f?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:p&&m?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."}}),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||AN.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){const e=!0===t.directLabel||!0===t.showLabels,n=function(e){return!!Array.isArray(e.styleRules)&&e.styleRules.some(e=>{if("object"!=typeof e||null===e)return!1;const t=e.style;if("object"!=typeof t||null===t||Array.isArray(t))return!1;const n=t.fill;return"object"==typeof n&&null!==n&&"hatch"===n.type})}(t);o.push({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1,...e?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:n?"Categories use colorBy and this config authors a HatchFill through styleRules, but a static audit cannot prove those rules give every category a distinct non-color cue. Semiotic does not automatically assign per-category textures.":"Categories are encoded by color (colorBy) with no declared redundant channel. Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor and there is no automatic per-category texture assignment.",fix:n?"Verify every category remains distinguishable with color removed; add direct labels where hatching is incomplete, keep categories ≤ ~7, and use a CVD-safe palette.":"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy) or category-targeted styleRules with distinct HatchFill descriptors; keep categories ≤ ~7 and use a CVD-safe palette."}});const r=function(e){if(!Array.isArray(e))return!1;const t=e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase());return t.length>0&&t.every(e=>iB.has(e))}(t.colorScheme);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:n?"This config uses an author-supplied HatchFill through styleRules, but Semiotic has no automatic, theme-aware per-category texture channel or user-facing texture toggle.":"Semiotic supports author-supplied HatchFill patterns through styleRules, but this config has no statically visible HatchFill descriptor; there is no automatic, theme-aware per-category texture channel or user-facing texture toggle.",fix:n?"Verify the authored hatches cover every meaningful category and remain legible in the active theme; pair them with direct labels and a CVD-safe palette.":"Use category-targeted styleRules with distinct HatchFill descriptors or direct labels so the encoding survives color removal. Contrast itself is themeable via CSS variables."})}{const e=S.filter(ca);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=aa(e),n=r&&"text"===t;return!(la(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,...s?{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=RN[e];if(n&&b){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:A,message:`The chart takes a single tab stop and navigates data with arrow keys${C} — 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,...b?m||p?{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:A,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${C}.`}),o.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:A,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${C}.`,fix:s?"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,...g?{status:"pass",message:`Provided: ${[h&&"title",p&&"description",m&&"summary"].filter(Boolean).join(", ")}.`}:a?{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,...p||m?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:c?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:h?{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(rB).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+=cB(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(wN.has(e)){const e=rB(t.xLabel),n=rB(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(PN.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."}),S.length>1){const e=S.filter(aB).length;o.push({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,...e===S.length?{status:"pass",message:`All ${S.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:S.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:`${S.length-e} of ${S.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:A,message:`Transitions animate with object constancy and data changes are mirrored to the live region${C}.`,fix:s?"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:A,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${C}.`,fix:s?"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."}:f?{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,...a?{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:s?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${s?"":C}.`,fix:s?"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?d?{status:"pass",message:"ChartContainer's navigable option mounts a structured navigation tree. For hierarchical/network charts the tree is currently shallow (root/topology summary + annotations branch), not a full descent of every node."}:{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:A,message:`Keyboard navigation steps through points and switches series/groups${C}.`,fix:s?"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 s;s=bN.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(s)}{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()."}:m?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."}}),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."}:f?{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:A,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${C}.`,fix:s?"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,...AN.has(e)||jN.has(e)?v?{status:"pass",message:e+" animates continuously and declares an in-chart pause/stop control."}:{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:A,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${C}.`}}),i&&(o.push({id:"flexible.sim-pause-control",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1,...v?{status:"pass",message:"Physics simulation exposes a pause/stop control for users who need to stop motion."}:{status:"warn",message:"Physics simulation has no declared pause/stop control.",fix:"Provide a visible pause control and set physics.pauseControl=true (or pauseControl=true) so the contract is auditable."}}),o.push({id:"flexible.settled-projection",principle:"flexible",heuristic:"User style change not respected",critical:!1,...w?{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,...k?{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=IN.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||rB(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 M=o.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),j={criticalsPassed:M.filter(e=>"pass"===e.status).length,criticalsEvaluated:M.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:!M.some(e=>"fail"===e.status),summary:j,findings:o,reference:sB}}function dB(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 hB={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},pB=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function mB(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 pB){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(` ${hB[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 yB(e){const t=Object.create(null);for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n=Object.create(null);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 fB(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=Object.create(null);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 gB(e){return"nominal"===e||"ordinal"===e}function bB(e){return"quantitative"===e||"temporal"===e}T();var vB={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"},xB={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"},wB={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function kB(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:n,markProps:o}=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),r=e.encoding||{},i=r.x,s=r.y,a=r.color,c=r.size,l=r.theta,u=r.opacity;let d;e.data?.values?d=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||r.facet||r.row||r.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 h={};e.width&&(h.width=e.width),e.height&&(h.height=e.height);const p=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(p&&(h.title=p),a?.field&&(h.colorBy=a.field,a.scale?.scheme)){const e=vB[a.scale.scheme];e&&(h.colorScheme=e)}void 0!==u?.value&&(h.pointOpacity=u.value);const m=i?.aggregate,y=s?.aggregate;if(d&&(m||y)){const e=y?s:i,t=y?i:s,n=wB[e.aggregate];if(n&&t?.field&&e.field)d=function(e,t){const{groupBy:n,value:o,agg:r="sum"}=t,i=new Map;for(const t of e){const e=t[n]+"";i.has(e)||i.set(e,[]),i.get(e).push(Number(t[o]))}const s=[];for(const[e,t]of i){let o;switch(r){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=P(t)[0];break;case"max":o=P(t)[1];break;default:o=t.reduce((e,t)=>e+t,0)}s.push({[n]:e,value:o})}return s}(d,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&t?.field&&d){const e=new Map;for(const n of d){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}d=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}if(i?.bin||s?.bin){const e="Histogram";d&&(h.data=d),i?.bin?(h.valueAccessor=i.field,s?.field&&(h.categoryAccessor=s.field),i.axis?.title&&(h.valueLabel=i.axis.title)):s?.bin&&(h.valueAccessor=s.field,i?.field&&(h.categoryAccessor=i.field),s.axis?.title&&(h.valueLabel=s.axis.title));const n=i?.bin||s?.bin,o="object"==typeof n?n.maxbins:void 0;return o&&(h.bins=o),AB(e,h,t)}let f;switch(n){case"bar":f=function(e,t,n,o,r,i,s){let a;return n?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(a="StackedBarChart",o.stackBy=n.field):a="BarChart",gB(e?.type)&&bB(t?.type)?(o.categoryAccessor=e.field,o.valueAccessor=s?"value":t.field,e?.axis?.title&&(o.categoryLabel=e.axis.title),t?.axis?.title&&(o.valueLabel=t.axis.title)):bB(e?.type)&&gB(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=s?"value":t.field),e?.axis?.title&&(o.categoryLabel=e.axis.title),t?.axis?.title&&(o.valueLabel=t.axis.title)),r&&(o.data=r),a}(i,s,a,h,d,m,y);break;case"line":if(f="LineChart",SB(i,s,h,m,y),a?.field&&(h.lineBy=a.field),o.interpolate){const e=xB[o.interpolate];e&&(h.curve=e)}!0===o.point&&(h.showPoints=!0),d&&(h.data=d);break;case"area":if(a?.field?(f="StackedAreaChart",h.areaBy=a.field):f="AreaChart",SB(i,s,h,m,y),o.interpolate){const e=xB[o.interpolate];e&&(h.curve=e)}void 0!==o.opacity&&(h.areaOpacity=o.opacity),d&&(h.data=d);break;case"point":case"circle":case"square":c?.field?(f="BubbleChart",h.sizeBy=c.field,c.scale?.range&&(h.sizeRange=c.scale.range)):f="Scatterplot",SB(i,s,h,m,y),d&&(h.data=d);break;case"rect":f="Heatmap",i?.field&&(h.xAccessor=i.field),s?.field&&(h.yAccessor=s.field),a?.field&&(h.valueAccessor=a.field,delete h.colorBy),i?.axis?.title&&(h.xLabel=i.axis.title),s?.axis?.title&&(h.yLabel=s.axis.title),d&&(h.data=d);break;case"arc":o.innerRadius&&o.innerRadius>0?(f="DonutChart",h.innerRadius=o.innerRadius):f="PieChart",l?.field?h.valueAccessor=l.field:s?.field&&(h.valueAccessor=y?"value":s.field),a?.field&&(h.categoryAccessor=a.field),i?.field&&!l?.field&&(h.categoryAccessor=i.field),d&&(h.data=d);break;case"tick":f="DotPlot",gB(i?.type)?(h.categoryAccessor=i.field,s?.field&&(h.valueAccessor=y?"value":s.field),i?.axis?.title&&(h.categoryLabel=i.axis.title),s?.axis?.title&&(h.valueLabel=s.axis.title)):gB(s?.type)?(h.categoryAccessor=s.field,i?.field&&(h.valueAccessor=m?"value":i.field),h.orientation="horizontal",s?.axis?.title&&(h.categoryLabel=s.axis.title),i?.axis?.title&&(h.valueLabel=i.axis.title)):(i?.field&&(h.categoryAccessor=i.field),s?.field&&(h.valueAccessor=y?"value":s.field)),d&&(h.data=d);break;default:t.push(`Unsupported mark type "${n}". Defaulting to Scatterplot.`),f="Scatterplot",SB(i,s,h,m,y),d&&(h.data=d)}return AB(f,h,t)}function SB(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 AB(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}var CB=require("react"),MB=/^\d{4}[-/]\d{2}/,jB=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function PB(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?MB.test(e)&&!Number.isNaN(Date.parse(e))?"date":jB.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function IB(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 RB(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 TB(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,s=Math.min(e.length,r);for(let t=0;s>t;t++){const n=e[t];if(n&&"object"==typeof n)for(const e of Object.keys(n))i.add(e)}const a={};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){a[t]={type:"unknown"};continue}const r=PB(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){a[t]={type:"unknown"};continue}const{min:n,max:r}=IB(e);let i=0;for(let t=0;e.length>t;t++)i+=e[t];const s=[...e].sort((e,t)=>e-t);a[t]={type:"numeric",min:n,max:r,mean:i/e.length,median:RB(s)}}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){a[t]={type:"unknown"};continue}const{min:n,max:r}=IB(e);a[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}));a[t]={type:"categorical",distinctCount:e.size,topValues:r,distinctValues:e.size>n?void 0:r.map(e=>e.value)}}else a[t]={type:"unknown"}}return{rowCount:e.length,fields:a,sample:e.slice(0,o)}}ct();var _B=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,LB=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,DB=/(size|magnitude|volume|weight|count|amount)/i,NB=/^(category|label|name|type|group|region|segment|kind|class)$/i,$B=/^(series|group|type|category|segment|cohort|product)$/i,BB=new Set(["numeric"]),EB=new Set(["numeric","date"]),OB=new Set(["numeric"]),FB=new Set(["date"]),zB=new Set(["categorical","boolean"]);function HB(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function WB(e,t){return t.test(e)?.2:0}function qB(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 GB(e,t,n,o,r={}){const i=[];for(const[s,a]of Object.entries(e)){const e=HB(a);if(!n.has(e))continue;let c,l=.5;l+=WB(s,o),"categorical"===a.type&&(c=a.distinctCount,!c||2>c||c>12||(l+=.2),c&&c>50&&(l-=.2)),"numeric"===a.type&&Number.isFinite(a.min)&&Number.isFinite(a.max)&&a.max>a.min&&(l+=.1);const u={field:s,kind:e,quality:Math.max(0,Math.min(1,l)),distinctCount:c};!r.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=qB(t,s),u.monotonic&&(u.quality=Math.min(1,u.quality+.2))),i.push(u)}return i.sort((e,t)=>t.quality-e.quality),i}function YB(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 VB=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,XB=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,UB=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,KB=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,QB=/^(value|weight|amount|count|magnitude|volume)$/i;function ZB(e,t){return e.find(e=>t.test(e))}function JB(e,t={}){const n=TB(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=ZB(n,VB),r=ZB(n,XB);if(!o||!r||o===r)return null;const i=ZB(n,UB),s=ZB(n,KB),a=ZB(n,QB),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(),s=(n+"").trim();i&&s&&i!==s&&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=a?Number(e[a]):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]}:{},...s?{endTime:e[s]}:{}})}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=GB(n.fields,o,EB,_B,{computeMonotonic:!0}),s=GB(n.fields,o,OB,LB),a=GB(n.fields,o,BB,DB),c=GB(n.fields,o,zB,NB),l=GB(n.fields,o,zB,$B),u=GB(n.fields,o,FB,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let h=d,p=d?"time":"none";if(!h){const e=i.find(e=>_B.test(e.field)&&"numeric"===e.kind);e&&(h=e.field,p="named")}const m=s.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 y=a.find(e=>e.field!==h&&e.field!==m)?.field,f="time"===p||"named"===p,g=c.map(e=>e.field);let b,v;f?(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?YB(o,b):void 0,w=v?YB(o,v):void 0,k=h?YB(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,numericFields:We(o,{quantiles:!1}),candidates:{x:i,y:s,size:a,category:c,series:l,time:u},primary:{x:h,y:m,size:y,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}}Fe();var eE={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},tE=["tiny","small","medium","large","huge"];function nE(e){return{rows:{...eE.rows,...e?.rows??{}},cardinality:{...eE.cardinality,...e?.cardinality??{}},fields:{...eE.fields,...e?.fields??{}}}}function oE(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const n=nE(t?.thresholds).rows;return e>n.tiny?e>n.small?e>n.medium?e>n.large?"huge":"large":"medium":"small":"tiny"}function rE(e,t){if(!Number.isFinite(e)||0>e)return"low";const n=nE(t?.thresholds).cardinality;return e>n.low?e>n.medium?"high":"medium":"low"}function iE(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const n=nE(t?.thresholds).fields;return e>n.narrow?e>n.typical?"wide":"typical":"narrow"}function sE(e,t){return tE.indexOf(e)-tE.indexOf(t)}function aE(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=nE(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 cE(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=nE(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 lE(e,t){const n=e.rowCount??0,o=t?.rows,r=aE(o,n,t),i=oE(r,t),s=Object.keys(e.fields??{}).length,a=t?.fields,c="number"==typeof a?a:"string"==typeof a?function(e,t){const n=nE(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)}}(a,t):s,l=iE(c,t),u=e.primary.category,d=cE((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?rE(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==o?"declared":"measured"}}var uE=2.5,dE=1,hE=3;function pE(e,t,n,o,r){const i=[],s=[];let a=0,c=!1;if(e.scaleFit){const r=e.scaleFit(t,n,o);if(r&&(a+=Math.max(-uE,Math.min(uE,r.delta??0)),r.reason&&i.push(r.reason),r.caveats))for(const e of r.caveats)s.push(e)}const l=o?.charts?.[e.component];if(l&&(l.minBand&&0>sE(n.rowBand,l.minBand)||l.maxBand&&sE(n.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(a+=Math.max(-hE,Math.min(hE,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&&(a+=Math.max(-dE,Math.min(dE,n.delta??0)),n.reason&&i.push(n.reason),n.caveats))for(const e of n.caveats)s.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&&s.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:a,reasons:i,caveats:s,excluded:c}}function mE(e){return(t,n)=>{let o=0;const r=[];let i;if(e.rows){const[t,s]=e.rows.sweetSpot;t>n.rows||n.rows>s?t>n.rows?(o-=Math.min(uE,.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(uE,.4*(0===s?1:(n.rows-s)/s)),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,s]=e.cardinality.sweetSpot;i>t||t>s?t>s&&(o-=Math.min(uE,.5*(0===s?1:(t-s)/s)),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}}Fe();var yE={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},numericContracts:$e.LineChart,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:mE({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})};Fe();var fE={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:$e.AreaChart,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,s=-1/0;for(const[e,t]of r)t>s&&(s=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:{stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(o.xScaleType="time"),{...o,...t?.props??{}}},scaleFit:mE({rows:{sweetSpot:[6,200],caveatAbove:2e3}})};Fe();var gE={component:"BumpChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:$e.BumpChart,fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.series||2>(e.seriesCount??0))return"needs a series field with at least 2 series to rank against each other";if(!e.primary.y)return"needs a numeric value to rank by";const t=!(!e.primary.x&&!e.primary.time);return t||e.primary.category?2>(t?e.uniqueXCount??0:e.categoryCount??0)?"needs at least 2 ranking columns to show rank movement":null:"needs an ordered x (time or sequence) or a categorical ranking column"},intentScores:{rank:e=>{if(!e.seriesCount||2>e.seriesCount)return 1;const t=!(!e.primary.x&&!e.primary.time);return 2>(t?e.uniqueXCount??0:e.categoryCount??0)?2:e.seriesCount>12?3:t?5:4},"compare-series":e=>e.seriesCount&&e.seriesCount>=2?2:1,"change-detection":e=>(e.primary.x||e.primary.time)&&e.seriesCount&&e.seriesCount>=2?3:1,trend:e=>e.primary.time||e.primary.x&&("scatter"!==e.xProvenance||e.monotonicX)?2:0},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>12&&t.push(e.seriesCount+" series will cross into a hard-to-follow tangle — use highlightTop to foreground the leaders"),t.push("rank position hides absolute magnitude — use ribbon to also encode value, or pair with a value chart"),t},variants:[{key:"ribbon",label:"Magnitude ribbons",description:"Encodes the ranked value as ribbon width, so the chart shows both order and magnitude instead of order alone.",props:{ribbon:!0},tags:["ribbon","magnitude"],rubricDeltas:{precision:1}}],buildProps:(e,t)=>{const n={data:e.data,xAccessor:e.primary.x??e.primary.time??e.primary.category,yAccessor:e.primary.y,lineBy:e.primary.series};return e.seriesCount&&e.seriesCount>6&&(n.highlightTop=5),{...n,...t?.props??{}}},scaleFit:mE({rows:{sweetSpot:[8,200],caveatBelow:4,caveatAbove:1500}})};Fe();var bE={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",numericContracts:$e.StackedAreaChart,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:mE({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})};Fe();var vE={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},numericContracts:$e.Scatterplot,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:mE({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})};Fe();var xE={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:$e.ConnectedScatterplot,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}};Fe();var wE={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:$e.BubbleChart,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:mE({rows:{sweetSpot:[10,500],caveatAbove:1500}})};Fe();var kE={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:$e.QuadrantChart,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,s="numeric"===r?.type?r.median:void 0;return{data:e.data,xAccessor:t,yAccessor:n,...void 0!==i?{xCenter:i}:{},...void 0!==s?{yCenter:s}:{},...e.primary.series&&6>=(e.seriesCount??0)?{colorBy:e.primary.series}:{},quadrants:{topLeft:{...Gy},topRight:{...Yy},bottomLeft:{...Vy},bottomRight:{...Xy}}}}},SE={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}}};Fe();var AE={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},numericContracts:$e.MinimapChart,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"}:{}})};Fe();var CE={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:$e.DifferenceChart,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 s=e+"",a=Number(t[n]);i.set(s,(i.get(s)??0)+(Number.isFinite(a)?a:0))}const s=[...i.entries()].sort((e,t)=>t[1]-e[1]),a=s[0]?.[0],c=s[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 s=e+"";if(s!==a&&s!==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)),s===a?m.a=h:s===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:a,seriesBLabel:c}}};Fe();var ME={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:$e.CandlestickChart,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")}}};Fe();var jE={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:$e.Heatmap,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:mE({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})};Fe();var PE=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,IE=/^(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,RE=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,TE={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},numericContracts:$e.BarChart,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(PE.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();(IE.test(o)||RE.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:mE({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})};Fe();var _E={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},numericContracts:$e.GroupedBarChart,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})};Fe();var LE={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:$e.StackedBarChart,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??{}})};Fe();var DE={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},numericContracts:$e.DotPlot,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:mE({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})};Fe();var NE={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},numericContracts:$e.PieChart,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"]}],buildProps:(e,t)=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,...t?.props??{}}),scaleFit:mE({cardinality:{sweetSpot:[2,5],caveatAbove:6}})};Fe();var $E={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},numericContracts:$e.DonutChart,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})};Fe();var BE=/(stage|step|funnel|status|outcome|phase)/i,EE={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:$e.FunnelChart,fits:e=>e.primary.y?Object.keys(e.fields).find(e=>BE.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=>BE.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},OE={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},FE=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,zE={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=>FE.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=>FE.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},HE={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})};Fe();var WE={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:$e.Histogram,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??{}})};Fe();var qE={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:$e.BoxPlot,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})};Fe();var GE={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:$e.SwarmPlot,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}:{}})};Fe();var YE={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:$e.ViolinPlot,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??{}})};Fe();var VE={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},numericContracts:$e.RidgelinePlot,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})},XE={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"}}};Fe();var UE={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:$e.SankeyDiagram,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"})};Fe();var KE={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},numericContracts:$e.ChordDiagram,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"})},QE={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=e.network?.edges??[],n={nodes:e.network?.nodes??[],edges:t,pairing:"temporal",laneOrder:"crossing-min"},o=t[0],r=o&&void 0===o.startTime&&void 0!==o.start?"start":"startTime",i=o&&void 0===o.endTime&&void 0!==o.end?"end":"endTime";o&&("start"===r&&(n.startTimeAccessor="start"),"end"===i&&(n.endTimeAccessor="end"));let s=1/0,a=-1/0;for(const e of t){const t=e?.[r],n=e?.[i],o=t instanceof Date?t.getTime():"number"==typeof t?t:null!=t?new Date(t).getTime():NaN,c=n instanceof Date?n.getTime():"number"==typeof n?n:null!=n?new Date(n).getTime():NaN;Number.isFinite(o)&&(s=Math.min(s,o),a=Math.max(a,o)),Number.isFinite(c)&&(s=Math.min(s,c),a=Math.max(a,c))}return Number.isFinite(s)&&Number.isFinite(a)&&a>=s&&(n.domain=[s,a===s?s+1:a]),n}},ZE={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 JE(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+JE(t),0):1}var eO={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=JE(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}}},tO={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"})},nO={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"})},oO={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"})};Fe();var rO={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",numericContracts:$e.ProportionalSymbolMap,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"})},iO={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"})},sO={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 aO(e){return Number.isFinite("number"==typeof e?e:Number(e))}function cO(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 lO(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var uO=[yE,fE,gE,bE,vE,xE,wE,kE,SE,AE,CE,ME,jE,TE,_E,LE,DE,NE,$E,EE,OE,zE,HE,WE,qE,GE,YE,VE,XE,UE,KE,QE,ZE,eO,tO,nO,oO,rO,iO,sO,{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},variants:[{key:"observed",label:"Observed samples",description:"Drop the supplied rows through the board and read the settled bins.",props:{simulationMode:"sample"},tags:["observed"]},{key:"mechanical",label:"Mechanical demonstration",description:"Seeded Bernoulli draws with no input data — explains where a bell curve comes from rather than reporting one.",props:{simulationMode:"mechanical"},tags:["explainer","no-data"],intentDeltas:{distribution:-2,"outlier-detection":-1},rubricDeltas:{accuracy:-2,precision:-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:"UnitPileChart",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},variants:[{key:"projected",label:"Piles with stated totals",description:"Countable units plus the exact per-category total, so accumulation is dramatized without losing precision.",props:{showProjection:!0},tags:["observed"]},{key:"units-only",label:"Units only",description:"Piles without the totals overlay — reads as texture, and the reader must count.",props:{showProjection:!1},tags:["narrative"],intentDeltas:{"compare-categories":-1,"part-to-whole":-1},rubricDeltas:{precision:-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:"PacketFlowChart",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=>aO(e.x)&&aO(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:()=>["PacketFlowChart 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:cO(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":lO(e,"stage")||lO(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=(lO(e,"stage")?"stage":lO(e,"status")&&"status")||e.primary.category||"stage",n=lO(e,"id")?"id":void 0,o=(lO(e,"featureId")?"featureId":lO(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"],s=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:s,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:"CrucibleChart",family:"flow",importPath:"semiotic/physics",rubric:{familiarity:1,accuracy:4,precision:3},fits:()=>"requires authored phases, product molds, events, and outlets; these cannot be inferred from flat data",intentScores:{flow:4,"change-detection":3,"compare-categories":1},caveats:()=>["CrucibleChart presents an authored treatment and its accounting; collisions never discover products, affinity, failure, or causality.","Supply stable source ids plus explicit phases, products, events, and reason-labelled outlets. Use the settled projection for the exact reading.","buildCrucibleProductEvents can serialize an explicit form → contribute → complete lifecycle, but the caller must still author every member, relation, event position, and outlet."],buildProps:e=>({data:e.data})},{component:"ChainReactionChart",family:"hierarchy",importPath:"semiotic/physics",rubric:{familiarity:2,accuracy:4,precision:3},fits:()=>"requires an authored dependency graph (stable task ids plus an explicit array of prerequisite ids per task); edges cannot be inferred from flat data",intentScores:{flow:3,hierarchy:3,"change-detection":3,"outlier-detection":2},caveats:()=>["The settled projection is the chart: task state (completed / blocked / armed / waiting) plus each blocker's downstream reach. Ball motion shows prerequisites being delivered and never decides whether a task is done.","Task completion is an explicit data event, not something the simulation discovers. Supply completionTimeAccessor or statusAccessor.","Blocker amplification counts unfinished downstream tasks and affected lanes; it is a graph reachability result, not a schedule forecast."],buildProps:e=>({data:e.data})},{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}],dO=new Map;function hO(e){var t,n;dO.set(e.component,e),t=e.component,(n=e.numericContracts)?Oe().contracts.set(t,n):Oe().contracts.delete(t)}function pO(e){dO.delete(e),function(e){Oe().contracts.delete(e)}(e)}function mO(){if(0===dO.size&&0>=tL().capabilities.size)return uO;const e=new Map;for(const t of uO)e.set(t.component,t);for(const t of Array.from(tL().capabilities.values()))e.set(t.component,t);for(const[t,n]of dO)e.set(t,n);return Array.from(e.values())}function yO(e){return mO().find(t=>t.component===e)}var fO=.5,gO=1,bO=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),vO={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function xO(e,t){if("visual"===t)return{delta:0,caveats:[]};let n=0;const o=[],r=[];for(const t of e.findings){if(!bO.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 ${vO[t]}: ${o.slice(0,3).join("; ")}`,caveats:r}}function wO(e,t,n,o,r){if(!o)return{score:e,rubric:t};const i=o.familiarity?.[n],s=i??t.familiarity,a=o.targets?.[n];let c,l,u=0;void 0!==i&&(u+=(i-3)*fO),a&&(u+=("increase"===a.direction?1:-1)*gO*Math.max(1,Math.min(3,a.weight??1)),c=a.reason?`${o.name?o.name+": ":""}${a.reason}`:`${o.name?o.name+" ":""}target: ${a.direction} ${n}`);const d=o.receptionModality;return r&&d&&"visual"!==d&&(u+=r.delta,l=r.reason),{score:e+u,rubric:{...t,familiarity:s},appliedReason:c,receivabilityReason:l}}function kO(e,t,n){return n?n.familiarity?.[e]??t:t}function SO(e){return e&&2===e.exposureLevel?4:3}function AO(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 CO(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 MO(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 jO(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 PO(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=[],s=t.audience?.name?.trim().toLowerCase();if(s){const e=n.audienceFit?.find(e=>e.audience.trim().toLowerCase()===s);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 a=t.receptionChannel??t.audience?.receptionModality??"visual";n.reception?.channels?.includes(a)?(o+=.25,r.push(`Designed for ${a} reception`)):n.reception?.channels?.length&&(o-=1,i.push(`Recipe does not declare support for the ${a} 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 IO(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 RO(e,t={}){const n=t.profile??JB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??mO(),r=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],i=!1!==t.includeVariants,s=t.minScore??0,a=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=lE(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]=AO(n,p);const a=e.caveats?Array.from(e.caveats(p)):[],y=i&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const i of y){const c=CO(o,i),l=IO(c,r),y=MO(e.rubric,i),f=e.buildProps(n,i);let g;d&&(g=xO(uB(e.component,f),u));const b=wO(l,y,e.component,t.audience,g),v=pE(e,p,h,t.scale,t.quality);if(v.excluded)continue;const x=PO(e,t);if(x.excluded)continue;const w=b.score+v.delta+x.delta;if(s>w)continue;const k=jO(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=[...a,...i?.caveats??[],...v.caveats,...g?.caveats.slice(0,3)??[],...x.caveats],A={band:h.rowBand,cardinalityBand:h.cardinalityBand,rows:h.rows,rowsSource:h.rowsSource},C=i?.component??e.component;m.push({component:C,displayName:e.displayName??C,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:f,...e.whyCustom?{whyCustom:e.whyCustom}:{},scaleRange:A})}}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 y=new Set;return m.filter(e=>{const t=`${e.component}:${e.score.toFixed(4)}`;return!y.has(t)&&(y.add(t),!0)}).slice(0,a)}function TO(e,t={}){const n=t.profile??JB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??mO(),r=t.allow?new Set(t.allow):null,i=t.deny?new Set(t.deny):null,s=lE(n,t.scale),a=void 0!==t.scale&&s.rows!==n.rowCount?{...n,rowCount:s.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(a);null!==t&&c.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:RO(e,{...t,profile:n}),rejected:c,profile:n}}function _O(e,t,n={}){const o=mO().find(t=>t.component===e);if(!o)return{reason:`No capability registered for "${e}"`};const r=n.profile??JB(t??[]),i=o.fits(r);if(null!==i)return{reason:i};const s=n.variantKey?o.variants?.find(e=>e.key===n.variantKey):void 0,a=n.intent?Array.isArray(n.intent)?n.intent:[n.intent]:[],c={};for(const[e,t]of Object.entries(o.intentScores))c[e]=AO(t,r);const l=CO(c,s),u=IO(l,a),d=MO(o.rubric,s),h=jO(o,r,l,a),p=PO(o,n);if(p.excluded)return{reason:p.excluded};h.push(...p.reasons);const m=[...o.caveats?o.caveats(r):[],...s?.caveats??[],...p.caveats],y=s?.component??o.component;return{component:y,displayName:o.displayName??y,candidateKind:o.candidateKind??"built-in",...o.recipe?{recipeId:o.recipe.id}:{},family:o.family,importPath:o.importPath,variant:s,score:u+p.delta,intentScores:l,rubric:d,reasons:h,caveats:m,props:o.buildProps(r,s),...o.whyCustom?{whyCustom:o.whyCustom}:{}}}function LO(e,t={}){const n=t.profile??JB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=lE(n,t.scale),r=t.maxPerBand??t.maxResults??5,i=["tiny","small","medium","large","huge"],s={};for(const o of i){const i={...t.scale??{},rows:o};s[o]=RO(e,{...t,profile:n,scale:i,maxResults:r})}return{tiny:s.tiny??[],small:s.small??[],medium:s.medium??[],large:s.large??[],huge:s.huge??[],effective:o}}var DO=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function NO(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function $O(e){return NO(e)?e:void 0}function BO(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function EO(e){const t=BO(e);return null==t?void 0:Math.max(0,Math.floor(t))}function OO(...e){return e.map($O).find(Boolean)}function FO(...e){return e.find(Array.isArray)}function zO(e){const t={};for(const[n,o]of Object.entries(e))void 0!==o&&(t[n]=o);return t}function HO(e,t,n){return e["string"==typeof t&&t?t:n]}function WO(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function qO(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function GO(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function YO(e,t,n){const o=e?.filter(e=>!0===$O(e)?.sensor).length,r=$O(t?.observation),i=$O(r?.sensors),s=FO(n?.activeSensors);return Math.max(o??0,i?Object.keys(i).length:0,s?.length??0)||void 0}function VO(e,t,n={}){const{capability:o,audience:r,locale:i}=n,s=n.levels??["l1","l2","l3"],a=!1!==n.includeStructure,c=UL(e,o),l=iD(e,t,{levels:c?[...s,"l4"]:s,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=(y=o)?"fits"in y||"buildProps"in y?{family:y.family}:{family:y.family,intentScores:y.intentScores}:{};m={act:c,sentence:u,family:e.family,intentScores:e.intentScores}}var y;const f=a?uD(e,t,{maxLeaves:n.maxLeaves,locale:i}):void 0,g=function(e,t,n){if(!1===n)return;const o=NO(n)?n:void 0,r=$O(t.physics),i=OO(o?.snapshot,r?.snapshot,t.physicsSnapshot,function(e){const t=$O(e);return!!t&&(NO(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),s=OO(o?.evidence,r?.evidence,t.physicsEvidence,t.settledEvidence),a=OO(o?.config,r?.config,i?.config,t.config),c=OO($O(i?.world),$O(r?.world)),l=OO($O(a?.kernel),$O(c?.options)),u=FO(c?.bodies),d=FO(c?.colliders,a?.colliders),h=FO(i?.queue,r?.queue),p=FO(i?.liveBodyOrder),m=FO(c?.springs),y=FO(i?.activeSensorPairs),f=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const n=$O(e);if(!n)return;const o=BO(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+"",s=BO(n.secondary??n.secondaryCount),a=BO(n.observed??n.observedCount);return zO({id:i,label:r,count:o,secondary:s,secondaryLabel:"string"==typeof n.secondaryLabel?n.secondaryLabel:void 0,observed:a})}).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=$O(e.settledProjection),i=$O(t?.settledProjection);return FO(n?.projectionRows,n?.aggregates,e.settledProjectionRows,e.projectionRows,r?.rows,t?.settledProjectionRows,t?.projectionRows,i?.rows,o?.binCounts)}(t,r,o,s)),g=function(e,t){const n=e?.map((e,t)=>{const n=$O(e);if(!n)return;const o=BO(n.count)??0,r=BO(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=EO(t?.bins)??n?.length??0,r=BO(t?.count)??n?.reduce((e,t)=>e+t.count,0)??0,i=BO(t?.total)??n?.reduce((e,t)=>e+(t.total??0),0),s=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}:{},...s?{leader:s}:{}}}(FO(o?.sediment,r?.sediment,i?.sediment),OO(o?.sedimentTotals,r?.sedimentTotals)),b=p?.length??u?.length??EO(s?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===$O(e)?.sleeping).length}(u)??EO(s?.sleepingCount),x=h?.length,w="string"==typeof i?.simulationState?i.simulationState:void 0,k="boolean"==typeof s?.settled?s.settled:w?"settled"===w:null!=b||null!=v||null!=x?null!=b&&v===b&&0===(x??0):void 0,S=$O(l?.gravity),A=BO(S?.x),C=BO(S?.y),M=zO({state:w,settled:k,elapsedSeconds:BO(i?.elapsedSeconds),paused:"boolean"==typeof i?.paused?i.paused:void 0,visible:"boolean"==typeof i?.visible?i.visible:void 0,seed:BO(l?.seed),gravity:null!=A&&null!=C?{x:A,y:C}:void 0,fixedDt:BO(a?.fixedDt??l?.fixedDt),timeScale:BO(a?.timeScale),maxSubsteps:EO(a?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:x,bodyLimit:BO(a?.bodyLimit),eviction:"string"==typeof a?.eviction?a.eviction:void 0}),j=zO({colliders:d?.length,sensors:YO(d,a,c),springs:m?.length,activeSensorPairs:y?.length}),P=Object.keys(j).length>0,I=DO.has(e);if(!(Object.keys(M).length>0||P||f||g)||!I&&null==n)return;const R={simulation:M,...P?{geometry:j}:{},...f?{aggregates:f}:{},...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 ${qO(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 "+GO(n.seed):void 0,n.gravity?`gravity (${GO(n.gravity.x)}, ${GO(n.gravity.y)})`:void 0,null!=n.fixedDt?`fixed step ${GO(n.fixedDt)}s`:void 0,null!=n.timeScale?GO(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} ${qO(r.colliders,"collider")}`:void 0,null!=r.sensors?`${r.sensors} ${qO(r.sensors,"sensor")}`:void 0,null!=r.springs?`${r.springs} ${qO(r.springs,"spring")}`:void 0,null!=r.activeSensorPairs?`${r.activeSensorPairs} active sensor ${qO(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 ${GO(e.count)}.`:"";t.push(`Physics aggregates: ${GO(i.totalCount)} settled ${qO(i.totalCount,"body")} across ${i.rows.length} ${qO(i.rows.length,"container")}; ${i.populatedCount} populated.${n}`)}const s=e.sediment;if(s){const e=null!=s.total?", value total "+GO(s.total):"",n=s.leader?`; largest sediment bin is ${s.leader.label} with ${GO(s.leader.count)}`:"";t.push(`Physics sediment: ${s.count} retained ${qO(s.count,"body")} in ${s.bins} ${qO(s.bins,"bin")}${e}${n}.`)}return t.join(" ")}(R);return{...R,text:T}}(e,t,n.physics),b=function(e,t,n){const o=[];if("GaugeChart"===e){"number"==typeof t.value&&Number.isFinite(t.value)&&o.push(`Current value is ${WO(t.value)}.`);const e="number"==typeof t.min&&Number.isFinite(t.min)?t.min:0,n="number"==typeof t.max&&Number.isFinite(t.max)?t.max:100;o.push(`The gauge scale runs from ${WO(e)} to ${WO(n)}.`)}if("SankeyDiagram"===e||"ProcessSankey"===e){const r=Array.isArray(t.edges)?t.edges:[];if("ProcessSankey"===e&&Array.isArray(t.domain)&&2===t.domain.length&&o.push(`The ProcessSankey time domain runs from ${WO(t.domain[0])} to ${WO(t.domain[1])}.`),r.length>0){o.push(`${r.length} source flow${1===r.length?"":"s"} are supplied.`);for(const i of r.slice(0,n)){const n=HO(i,t.sourceAccessor,"source"),r=HO(i,t.targetAccessor,"target"),s=HO(i,t.valueAccessor,"value");o.push("ProcessSankey"!==e||null==i.startTime&&null==i.endTime?`${WO(n)} to ${WO(r)} has value ${WO(s)}.`:`${WO(n)} to ${WO(r)} has value ${WO(s)} over ${WO(i.startTime)}–${WO(i.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=$O(t.data),r="string"==typeof t.childrenAccessor&&t.childrenAccessor?t.childrenAccessor:"children",i="string"==typeof t.valueAccessor&&t.valueAccessor?t.valueAccessor:"value",s="string"==typeof t.nodeIdAccessor&&t.nodeIdAccessor?t.nodeIdAccessor:"string"==typeof t.nodeIDAccessor&&t.nodeIDAccessor?t.nodeIDAccessor:"name",a=[],c=e=>{const t=Array.isArray(e[r])?e[r]:[];if(0!==t.length)for(const e of t){const t=$O(e);t&&c(t)}else a.push(e)};if(e&&c(e),a.length>0){o.push(a.length+" hierarchy leaves are supplied.");for(const e of a.slice(0,n))o.push(`${WO(e[s])} has value ${WO(e[i])}.`)}}if(DO.has(e)&&Array.isArray(t.data)){const n=t.data;o.push(`${n.length} observed source row${1===n.length?"":"s"} are supplied.`);const r="CollisionSwarmChart"===e?t.xAccessor:t.valueAccessor,i="CollisionSwarmChart"===e?"x":"value",s=n.map(e=>BO(HO(e,r,i))).filter(e=>null!=e);s.length>0&&o.push(`Observed ${"string"==typeof r?r:i} ranges from ${WO(Math.min(...s))} to ${WO(Math.max(...s))}.`)}if(0!==o.length)return{source:"chart-props",statements:o,text:"Exact chart-prop facts: "+o.join(" ")}}(e,t,Math.max(1,n.maxLeaves??200)),v=[p.text,m?.sentence,g?.text,b?.text].filter(Boolean).join(" ");return{component:e,description:p,intent:m,structure:f,physics:g,facts:b,text:v}}var XO=500,UO=2e3;function KO(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function QO(e){const{data:t,onQuery:n,initialAnnotations:o,componentName:r,props:i,includeProfile:s,includeSuggestions:a,suggestionsIntent:c,suggestionsMax:l,focus:u,includeGrounding:d}=e,[h,p]=(0,CB.useState)([]),[m,y]=(0,CB.useState)([]),[f,g]=(0,CB.useState)(!1),[b,v]=(0,CB.useState)(null),x=(0,CB.useMemo)(()=>TB(t??[]),[t]),w=s||a,k=(0,CB.useMemo)(()=>w?JB(t??[]):void 0,[w,t]),S=(0,CB.useMemo)(()=>a&&k?RO(t,{profile:k,intent:c,maxResults:l??5}):void 0,[a,k,t,c,l]),A=(0,CB.useMemo)(()=>{if(d&&r)return VO(r,{data:t??[],...i??{}},"object"==typeof d?d:void 0)},[d,r,i,t]),C=(0,CB.useRef)(n);C.current=n;const M=(0,CB.useRef)(r);M.current=r;const j=(0,CB.useRef)(i);j.current=i;const P=(0,CB.useRef)(t);P.current=t;const I=(0,CB.useRef)(x);I.current=x;const R=(0,CB.useRef)(k);R.current=k;const T=(0,CB.useRef)(S);T.current=S;const _=(0,CB.useRef)(u);_.current=u;const L=(0,CB.useRef)(A);L.current=A;const D=(0,CB.useCallback)(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();YD().record({type:"interrogation-asked",component:M.current,query:KO(t,XO)});try{const e=await C.current(t,{data:P.current??[],summary:I.current,profile:R.current,suggestions:T.current,componentName:M.current,props:j.current,grounding:L.current,focus:_.current??void 0});p(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&y(e.annotations);const o="undefined"!=typeof performance?performance.now():Date.now();YD().record({type:"interrogation-answered",component:M.current,answer:KO(e.answer,UO),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();YD().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-n))})}finally{g(!1)}},[]),N=(0,CB.useCallback)(({text:e,annotations:t})=>{const n=e.trim();n&&(p(e=>[...e,{role:"assistant",text:n}]),t&&t.length>0&&y(e=>[...e,...t]))},[]),$=(0,CB.useCallback)(()=>{p([]),y([]),v(null)},[]);return{ask:D,announce:N,history:h,summary:x,annotations:(0,CB.useMemo)(()=>{const e=o??[];return 0===e.length?m:0===m.length?e:[...e,...m]},[o,m]),loading:f,error:b,reset:$}}var ZO=require("react"),JO=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function eF(e={}){const{chartId:t,types:n=JO}=e,{latest:o}=Qh({chartId:t,types:n,limit:1});return(0,ZO.useMemo)(()=>{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])}var tF={failColor:"var(--semiotic-danger)",warnColor:"var(--semiotic-warning)",passColor:"var(--semiotic-success)"};function nF(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function oF(e,t){return"pass"===e?t.passColor??tF.passColor:"warn"===e?t.warnColor??tF.warnColor:t.failColor??tF.failColor}function rF(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 iF(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 sF(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 aF(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 s of e){if("pass"===s.status&&!t.includePassed)continue;const e=oF(s.status,t),a=iF(s),c={provenance:sF(s),lifecycle:i},l=e=>o.push({result:s,reason:e}),u=e=>n.push(Pa(e,c));switch(s.kind){case"range":if("number"!=typeof s.min||"number"!=typeof s.max){l("range check is missing numeric min/max bounds");break}u({type:"band",y0:s.min,y1:s.max,fill:e,fillOpacity:.12,color:e,label:a});break;case"min":case"max":case"threshold":{const t=s.value??("min"===s.kind?s.min:s.max);if("number"!=typeof t){l(s.kind+" check is missing a numeric value");break}u({type:"x"===r?"x-threshold":"y-threshold",value:t,label:a,color:e});break}case"freshness":{const t=void 0!==s.at?nF(s.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:a,color:e});break}default:l(`${s.kind} check on "${s.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 cF(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function lF(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function uF(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=cF(r.status),i=lF(r.unique_id),s=rF(r.max_loaded_at);n.push({id:r.unique_id??i,name:"dbt freshness: "+i,label:"pass"===o?i+" fresh":`${i} stale${s?" since "+s:""}`,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=cF(i.status);if("pass"===r&&!t.includePassed)continue;const s=lF(i.unique_id);n.push({id:i.unique_id??s,name:"dbt test · "+s,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 aF(n,t)}function dF(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function hF(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 pF(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??{},s=e.expectation_type??"unknown_expectation",a=e.kwargs??{},c=a.column,l=i.success?"pass":"fail",u=dF(a.min_value),d=dF(a.max_value),h=dF(a.value),p=dF(i.result?.observed_value),m=c??"value",y=hF(s),f=void 0!==p?`${m}: ${p} `:"",g={id:`ge:${s}:${c??t}`,name:`GE ${y}${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(s);r.push(b&&void 0!==u&&void 0!==d?{...g,kind:"range",min:u,max:d,label:`${f}(expected ${u}–${d})`}:b&&void 0!==u?{...g,kind:"min",value:u,label:`${f}(min ${u})`}:b&&void 0!==d?{...g,kind:"max",value:d,label:`${f}(max ${d})`}:void 0!==h?{...g,kind:"threshold",value:h,label:`${f}(target ${h})`}:{...g,kind:"custom",label:`${m} ${y}`})}return aF(r,t)}function mF(e,t,n={}){const o=n.profile??JB(t??[],{rawInput:n.rawInput}),r=yO(e),i=n.maxAlternatives??3,s=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:RO(t,{profile:o,intent:n.intent,maxResults:i,includeVariants:!1}),profile:o};const a=r.fits(o);return null===a?{status:"ok",component:e,profile:o,...s.length?{repairs:s}:{}}:{status:"alternative",component:e,reason:a,alternatives:RO(t,{profile:o,intent:n.intent,maxResults:i,deny:[e],includeVariants:!1}),profile:o,...s.length?{repairs:s}:{}}}var yF={valid:!1,errors:[]};function fF(e,t={}){const n=e.component,o=e.props??{},r=[],i=!!L$[n];i||r.push(`Unknown component "${n}". It is not in the chart registry — pick a known chart.`);const s=i?N$(n,o):{...yF};if(!s.valid)for(const e of s.errors)r.push(e);const a=!1!==t.diagnose&&i?nB(n,o).diagnoses:[],c=a.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=mF(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=AL(n,o),h=IL(d)),t.render&&i&&s.valid&&(!l||0===c.length)){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 y=i&&s.valid&&(!l||0===c.length)&&(!u||"ok"===u.status)&&(!p||!p.empty);return{ok:y,component:n,props:o,config:d,jsx:h,validation:s,diagnostics:a,repair:u,evidence:p,svg:m,reasons:y?[]:r}}function gF(e={}){const t=e.components??Object.keys(L$).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 bF(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function vF(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function xF(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=>xF(e,!1)))return!1}if(o.includes("array")&&(!n.items||!xF(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=>xF(e,!1)))return!1}return!0}function wF(e,t={}){const n=t.strict??!1;if(n&&!xF(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 kF(e){return t=>fF(t,e?e(t):{})}var SF=require("react"),AF="",CF=["hover","click","focus","activate"];function MF(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=MF(t);if(e)return e}return null}function jF(e,t){return e?t.map(t=>e[t]+"").join(AF):""}function PF(e,t){if(e.id===t)return e;for(const n of e.children??[]){const e=PF(n,t);if(e)return e}return null}function IF(e){const{tree:t,chartId:n,observe:o=CF}=e,r=e.selectionName??"__semiotic-nav-sync"+(n?":"+n:""),i=(0,SF.useMemo)(()=>{if(e.matchFields)return e.matchFields;const n=MF(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]),s=(0,SF.useMemo)(()=>{const e=new Map,n=t=>{if("datum"===t.role&&t.datum){const n=jF(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:a,clear:c}=bh({name:r,fields:i}),l=(0,SF.useMemo)(()=>[...o,"hover-end"],[o]),{latest:u}=Qh({chartId:n,types:l,limit:1}),[d,h]=(0,SF.useState)(t.id),p=(0,SF.useRef)(d);p.current=d;const m=(0,SF.useRef)(t);(0,SF.useEffect)(()=>{const e=m.current;m.current=t;const n=PF(e,p.current),o=PF(t,p.current);"datum"===n?.role&&"datum"===o?.role&&n.datum&&o.datum&&i.length>0&&jF(n.datum,i)===jF(o.datum,i)||n&&o&&"datum"!==n.role&&"datum"!==o.role||(h(t.id),c())},[t,c,i]);const y=(0,SF.useCallback)(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]];a(t)}else c()},[i,a,c]),f=e.annotations,g=(0,SF.useMemo)(()=>{const e=new Set;if(0===i.length||!f)return e;for(const t of f){const n=s.get(jF(t,i));n&&e.add(n)}return e},[f,s,i]),b=(0,SF.useCallback)(e=>{const t="number"==typeof e?f?.[e]:e;if(!t||0===i.length)return!1;const n=s.get(jF(t,i));if(!n)return!1;h(n);const o={};for(const e of i)o[e]=[t[e]];return a(o),!0},[f,s,i,a]),v=(0,SF.useRef)(null),x=(0,SF.useCallback)(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=s.get(jF(t,i));r&&h(e=>e===r?e:r)},[n,o,s,i]),w=(0,SF.useRef)(null);return(0,SF.useEffect)(()=>{u&&u!==w.current&&(w.current=u,x(u))},[u,x]),{activeId:d,onActiveChange:y,selection:{name:r},onObservation:x,handleObservation:x,annotatedIds:g,focusAnnotation:b}}ct();var RF=[{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 TF(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const n of RF)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 _F(e,t={}){const n=t.audience;if(!n)return[];const o=t.profile??JB(e??[],{rawInput:t.rawInput}),r=SO(n),i=t.scoreTolerance??1.5,s=t.maxResults??5,a=mO(),c=new Map;for(const e of a)c.set(e.component,kO(e.component,e.rubric.familiarity,n));const l=RO(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],a=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:a,familiarity:r}),p.length>=s)break}return p}function LF(e,t={}){const n=t.profile??JB(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),s=[],a=[],c=[],l=new Set,u=new Set;for(const d of i){if(s.length>=o){c.push(d);continue}const i=RO(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?(s.push({intent:d,suggestion:h}),a.push(d),l.add(h.family),u.add(`${h.component}/${h.variant?.key??"base"}`)):c.push(d)}return{panels:s,intentsCovered:a,intentsMissing:c,stretchPanels:t.audience&&(t.audience.exposureLevel??1)>0?_F(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 DF={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},NF={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},$F={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:DF,analyst:NF,"data-scientist":$F},EF=[{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}}}],OF=new Map;function FF(e){OF.set(e.component,e)}function zF(e){OF.delete(e)}function HF(){if(0===OF.size)return EF;const e=new Map;for(const t of EF)e.set(t.component,t);for(const[t,n]of OF)e.set(t,n);return Array.from(e.values())}function WF(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 qF(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 GF(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 YF(e,t={}){const n=t.capabilities??HF(),o=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],r=t.minScore??0,i=t.maxResults??10,s=t.allow?new Set(t.allow):null,a=t.deny?new Set(t.deny):null,c=[];for(const t of n){if(s&&!s.has(t.component))continue;if(a&&a.has(t.component))continue;if(null!==t.fits(e))continue;const n={};for(const[o,r]of Object.entries(t.intentScores))n[o]=WF(r,e);const i=qF(n,o);if(r>i)continue;const l={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=GF(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 VF=["x","y","size","category","series","time"];function XF(e,t){const n=e.fields[t];return n?"numeric"===n.type?"numeric":"categorical"===n.type?"categorical":"date"===n.type?"date":"unknown":"unknown"}function UF(e){const t=new Set;for(const n of mO())null===n.fits(e)&&t.add(n.component);return t}function KF(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 s=[];for(const r of o){if(!n.has(r))continue;const o=XF(e,r),i=XF(t,r);o!==i&&s.push({field:r,from:o,to:i})}s.sort((e,t)=>e.field.localeCompare(t.field));const a=[];for(const n of VF){const o=e.primary[n],r=t.primary[n];o!==r&&a.push({role:n,from:o,to:r})}const c=UF(e),l=UF(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:s,primaryChanges:a,becameUnfit:u,becameFit:d,unchanged:0===r.length&&0===i.length&&0===s.length&&0===a.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}}function QF(e,t=mO()){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,s=new Map,a=[];for(const c of e){let e,l;try{e=JB(c.data,{rawInput:c.rawInput}),l=TO(c.data,{profile:e,intent:c.intent,capabilities:t,maxResults:40})}catch{const e=!!c.expected&&c.expected.length>0;a.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;a.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&&s.set(e.component,(s.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:(s.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=a.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(s.values()).reduce((e,t)=>e+t,0);return{perCapability:c,perFixture:a,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:u,top1AgreementRate:d,overallCaveatCoverage:0===h?0:p/h,overallVariantUtilization:0===h?0:m/h}}}var ZF=(()=>{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})))})(),JF=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),ez=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],tz=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]})),nz=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))}}),oz=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),rz=[{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}],iz=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:ZF,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:ZF,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:ZF,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:JF,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:ez,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:ez,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:tz,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:tz,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:nz,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:nz,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:rz,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:rz,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:oz,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"]}],sz=require("react"),az=e=>LD(e),cz=()=>YD().enabled,lz=()=>!1;function uz(e,t={}){const{intent:n,allow:o,deny:r,maxResults:i,includeVariants:s,minScore:a,rawInput:c,seriesField:l,capabilities:u,audience:d,profile:h}=t,p=(0,sz.useMemo)(()=>h??JB(e??[],{rawInput:c,seriesField:l}),[h,e,c,l]),m=(0,sz.useMemo)(()=>RO(e,{intent:n,allow:o,deny:r,maxResults:i,includeVariants:s,minScore:a,capabilities:u,audience:d,profile:p}),[e,n,o,r,i,s,a,u,d,p]),y=(0,sz.useSyncExternalStore)(az,cz,lz),f=(0,sz.useRef)(null);return(0,sz.useEffect)(()=>{if(0===m.length)return void(f.current=null);if(!y)return void(f.current=null);const e=YD(),t=d?.name??(d?"custom":void 0),o=`${n??""}|${t??""}|${m.map(e=>e.component).join(",")}`;if(o===f.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(f.current=o);break}}f.current=o,e.record({type:"suggestion-shown",intent:n,components:m.map(e=>e.component),topScore:m[0]?.score,audience:t})},[m,n,d,y]),{suggestions:m,profile:p}}var dz=d(require("react")),hz=require("react"),pz=require("react/jsx-runtime"),mz=(0,hz.forwardRef)(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,categoryAccessor:s="category",valueAccessor:a="value",oExtent:c,rExtent:l,projection:u="vertical",margin:d,className:h,colorBy:p,colorScheme:m,showAxes:y=!1,annotations:f,onObservation:g,onClick:b,selection:v,linkedHover:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,frameProps:C={}}=e,{frameRef:M,resolved:j,safeData:P,setup:I,earlyReturn:R}=Am({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=I.effectiveSelectionHook,_=(0,hz.useMemo)(()=>T?.isActive?{isActive:!0,predicate:T.predicate}:null,[T?.isActive,T?.predicate]);if(R)return R;const{width:L,height:D,enableHover:N,showGrid:$,title:B,description:E,summary:O,accessibleTable:F}=j,z={chartType:"custom",...null!=n&&{data:P},customLayout:o,layoutConfig:r,onLayoutError:i,..._&&{layoutSelection:_},oAccessor:s,rAccessor:a,oExtent:c,rExtent:l,projection:u,colorAccessor:p,colorScheme:m,size:[L,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:I.margin,enableHover:N,showAxes:y,showGrid:$,annotations:f,...sm({title:B,description:E,summary:O,accessibleTable:F,className:h,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...am({linkedHover:x,selection:v,onObservation:g,onClick:b,hoverHighlight:!1,mobileInteraction:I.mobileInteraction,customHoverBehavior:I.customHoverBehavior,customClickBehavior:I.customClickBehavior}),...C};return(0,pz.jsx)(Rp,{componentName:"OrdinalCustomChart",width:L,height:D,children:(0,pz.jsx)(Tg,{ref:M,...z})})});mz.displayName="OrdinalCustomChart";var yz=require("react"),fz=require("react/jsx-runtime"),gz=(0,yz.forwardRef)(function(e,t){const{nodes:n,edges:o,layout:r,layoutConfig:i,onLayoutError:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",margin:u,className:d,colorBy:h,colorScheme:p,selection:m,linkedHover:y,onObservation:f,onClick:g,chartId:b,annotations:v,autoPlaceAnnotations:x,frameProps:w={}}=e,{frameRef:k,resolved:S,normalizedMargin:A}=Sm({imperativeRef:t,imperativeVariant:"network",margin:u,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}),C=(0,yz.useMemo)(()=>ft(n),[n]),M=(0,yz.useMemo)(()=>ft(o),[o]),j=(0,yz.useMemo)(()=>void 0===n&&void 0===o?void 0:[...C,...M],[o,n,M,C]),P=Fh(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:I,customClickBehavior:R,activeSelectionHook:T}=xp({selection:m,linkedHover:y,fallbackFields:"string"==typeof h?[h]:[],onObservation:f,onClick:g,chartType:"NetworkCustomChart",chartId:b,colorByField:"string"==typeof h?h:void 0,mobileInteraction:P}),_=(0,yz.useMemo)(()=>T?.isActive?{isActive:!0,predicate:T.predicate}:null,[T?.isActive,T?.predicate]),{width:L,height:D,enableHover:N,title:$,description:B,summary:E,accessibleTable:O}=S,F=Dp(e.loading,L,D,e.loadingContent),z=F?null:Lp(j,L,D,e.emptyContent);if(F||z)return F||z;const H={chartType:"force",...null!=n&&{nodes:C},...null!=o&&{edges:M},customNetworkLayout:r,layoutConfig:i,onLayoutError:s,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,size:[L,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:A,enableHover:N,...sm({title:$,description:B,summary:E,accessibleTable:O,className:d,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:x}),...am({linkedHover:y,selection:m,onObservation:f,onClick:g,mobileInteraction:P,customHoverBehavior:I,customClickBehavior:R,linkedHoverInClickPredicate:!1}),layoutSelection:_,...null!=v&&{annotations:v},...w};return(0,fz.jsx)(Rp,{componentName:"NetworkCustomChart",width:L,height:D,children:(0,fz.jsx)(Nw,{ref:k,...H})})});gz.displayName="NetworkCustomChart";var bz=require("react"),vz=require("react"),xz=require("d3-geo"),wz=require("d3-quadtree"),kz=require("d3-geo"),Sz={mercator:kz.geoMercator,equalEarth:kz.geoEqualEarth,albersUsa:kz.geoAlbersUsa,orthographic:kz.geoOrthographic,naturalEarth:kz.geoNaturalEarth1,equirectangular:kz.geoEquirectangular};function Az(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Cz(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Mz(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function jz(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 Pz(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 s=-r/i,a=o/i,c=Math.min(.3*i,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*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 Iz(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,s;0===t?(i=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(i*i+s*s)||1;o.push([r[0]+s/a*n,r[1]+-i/a*n])}return o}function Rz(e,t,n,o,r){const i=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(i*i+s*s);if(0===a)return[e,t];const c=s/a,l=-i/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var Tz=require("d3-scale");T();var _z=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lz=["scene-style","data-paint","accessibility","evidence"],Dz=(e,t)=>({retainedData:e,invalidations:t}),Nz=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$z=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bz=["scene-geometry","data-paint","accessibility","evidence"],Ez=["scene-style","data-paint","accessibility","evidence"],Oz=["overlay","accessibility","evidence"],Fz=[],zz={xAccessor:Dz("rebuild",Nz),yAccessor:Dz("rebuild",Nz),lineDataAccessor:Dz("rebuild",Nz),pointIdAccessor:Dz("rebuild",Bz),lineIdAccessor:Dz("rebuild",Bz),windowSize:Dz("rebuild",Nz),projection:Dz("preserve",$z),projectionExtent:Dz("preserve",$z),fitPadding:Dz("preserve",$z),lineType:Dz("preserve",$z),flowStyle:Dz("preserve",$z),graticule:Dz("preserve",$z),projectionTransform:Dz("preserve",$z),customLayout:Dz("preserve",$z),layoutConfig:Dz("preserve",$z),layoutMargin:Dz("preserve",$z),areaStyle:Dz("preserve",Ez),pointStyle:Dz("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Dz("preserve",Ez),colorScheme:Dz("preserve",Ez),themeCategorical:Dz("preserve",Ez),themeDiverging:Dz("preserve",Ez),themeSemantic:Dz("preserve",Ez),themeSequential:Dz("preserve",Ez),decay:Dz("preserve",Ez),pulse:Dz("preserve",Ez),layoutSelection:Dz("preserve",Ez),annotations:Dz("preserve",Oz),autoPlaceAnnotations:Dz("preserve",Oz),clock:Dz("preserve",Fz),transition:Dz("preserve",Fz),introAnimation:Dz("preserve",Fz),onLayoutError:Dz("preserve",Fz)},Hz=Dz("preserve",$z),Wz=class{constructor(){this.tracker=new qo}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}},_z)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Lz):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=zz[o]??Hz;"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)}},qz=require("d3-geo");function Gz(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 Yz=class e{constructor(e){this.updateResults=new Wz,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:Gz(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Nn()}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 Ot(e),this.timestampBuffer=new Ot(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:Gz(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(),s=this.streaming&&i!==o;s&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:s})}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),s=this.currentTime();this.pointBuffer=new Ot(t),this.timestampBuffer=new Ot(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(i[t]??s)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();To(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)To(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)+"");_o(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,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,kz.geoEqualEarth)();if("string"==typeof e){const t=Sz[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,kz.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Sz[e.type],n=t?t():(0,kz.geoEqualEarth)();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=(0,xz.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,xz.geoPath)(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=s,this.baseRotation=a):(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=Az(n.xAccessor,"lon"),i=Az(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Cz(n.lineDataAccessor);for(const e of this.lineData){const t=a(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,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[o,s],[i,s],[i,r],[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,s=e.height*r;t.fitExtent([[i,s],[e.width-i,e.height-s]],{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(),s=[...n.translate()],a=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=(0,xz.geoPath)(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(s),this.currentZoom=a,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(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,xz.geoPath)(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(s),this.currentZoom=a,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=(0,xz.geoPath)(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 s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(i),this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,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)}hasProjection(){return null!=this.projection}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 t=0,n=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(o[r++]=e);this._quadtree=(0,wz.quadtree)().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=wf(t.colorScheme,t.themeCategorical,Cn),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:kf(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=So("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 s=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 s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return xo({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}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:s}){const a=Az(e.xAccessor,"lon"),c=Az(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=(0,qz.geoGraticule)();t.step&&o.step(t.step);const r=n(o())||"";r&&l.push({type:"geoarea",pathData:r,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.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),s=n.area(t);l.push({type:"geoarea",pathData:o,centroid:r,bounds:i,screenArea:s,style:Mz(e.areaStyle,t,u),datum:t,interactive:!0})}const p=Cz(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]=[a(o[t]),c(o[t])];for(let n=0;e.length-1>n;n++){const o=e[n],i=e[n+1],s=(0,qz.geoDistance)(o,i)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,qz.geoInterpolate)(o,i);for(let e=0;a>=e;e++){if(n>0&&0===e)continue;const o=t(c(e/a));null!=o&&r.push(o)}}}else for(let e=0;o.length>e;e++){const n=o[e],i=t([a(n),c(n)]);null!=i&&r.push(i)}if(2>r.length)continue;const i=Mz(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?Iz(r,u):Rz(r[0],r[r.length-1],0,0,u)):r=Pz(r[0],r[r.length-1]);const h=jz(r,s.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,y=t.clipAngle?t.clipAngle()??0:0,f=y>0?y*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=a(n),r=c(n);if(null!=f&&(0,qz.geoDistance)([o,r],v)>f)continue;const i=t([o,r]);if(!i)continue;const s=e.pointStyle?e.pointStyle(n):{...h},u={type:"point",x:i[0],y:i[1],r:s.r||4,style:s,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(e,t){const n=function(e,t,n,o){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const i=t.strength??1,s=Number.isFinite(i)?Math.max(0,Math.min(1,i)):1,a="strip"===t.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=r.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const d=I(r.map(e=>e.datum?Number(l(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);o>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 t=e.length-1;t>=0;t--){const n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}const h="strip"===a?function(e,t,n,o,r){const i=Math.max(3,Math.min(8,.35*r.height)),s=Math.max(1,r.width-2*i),a=r.height/2,c=(0,Tz.scaleLinear)().domain([0,o]).range([0,s]);t.x=i,t.y=a;const l=[];for(const r of e){if(r===t)continue;if(!r.datum){r.x=i,r.y=a;continue}const e=Number(n(r.datum)),s=i+(isFinite(e)&&e>=0&&o>0?c(e):0);r.x=s,r.y=a,l.push({node:r,x:s})}l.sort((e,t)=>e.x-t.x);const u=Math.max(0,Math.min(r.height/2-1,6));let d=0;for(;l.length>d;){let e=d+1;for(;l.length>e&&3>Math.abs(l[e].x-l[d].x);)e++;const t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)l[d+e].node.y=a+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:i,cy:a,maxCost:o,availableRadius:s,layout:"strip"}}(r,u,l,d,n):function(e,t,n,o,r,i){const s=t.x,a=t.y,c=i.width/2,l=i.height/2,u=Math.min(i.width,i.height)/2,d=(0,Tz.scaleLinear)().domain([0,o]).range([0,u]);for(const i of e){if(i===t)continue;if(!i.datum)continue;const e=i.x,u=i.y,h=Math.atan2(u-a,e-s),p=Math.hypot(e-s,u-a),m=Number(n(i.datum)),y=isFinite(m)&&m>=0?o>0?d(m):0:p,f=c+Math.cos(h)*y,g=l+Math.sin(h)*y;i.x=e+(f-e)*r,i.y=u+(g-u)*r}return t.x=s+(c-s)*r,t.y=a+(l-a)*r,{cx:t.x,cy:t.y,maxCost:o,availableRadius:u,layout:"radial"}}(r,u,l,d,s,n),p=e.filter(e=>"line"===e.type);if(p.length>0){const e=new Map;for(const t of r)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(const n of p){const o=n.datum?.source,r=n.datum?.target;if(null!=o&&null!=r){const i=e.get(o+""),s=e.get(r+"");if(i&&s)if("fractional"===t.lineMode&&n.path.length>2){const e=n.path[0],t=n.path[n.path.length-1],o=[i[0]-e[0],i[1]-e[1]],r=[s[0]-t[0],s[1]-t[1]],a=[0];for(let e=1;n.path.length>e;e++)a.push(a[e-1]+Math.hypot(n.path[e][0]-n.path[e-1][0],n.path[e][1]-n.path[e-1][1]));const c=a[a.length-1];n.path=n.path.map((e,t)=>{const i=c>0?a[t]/c:t/(n.path.length-1);return[e[0]+o[0]*(1-i)+r[0]*i,e[1]+o[1]*(1-i)+r[1]*i]})}else n.path=[i,s]}}}return h}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}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=En(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 s=!1;for(let a=0;n.length>a&&o.length>a;a++){const c=Fn(t,o[a],e);s=zn(n[a],c,r,i)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Hn(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??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(const e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;const t=Ln(e,this.activeTransition),n=_n(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=Dn(e.x,e._targetX,n),e.y=Dn(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}};Yz.QUADTREE_THRESHOLD=500;var Vz=Yz;function Xz(e,t,n,o,r,i,s=0,a=o){if(i){const e=Hr(i,t,n,o,s);if(e)return e}else{let r=null,i=o;for(const s of e){if("point"!==s.type)continue;if(!1===s.interactive)continue;const e=s.x-t,a=s.y-n,c=Math.sqrt(e*e+a*a);Ir(s.r,o)>=c&&i>c&&(r=s,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=Fr(r.glyph,r.size),i=r.x+e.centerDx-t,s=r.y+e.centerDy-n,a=Math.sqrt(i*i+s*s);Ir(e.radius,o)>=a&&l>a&&(c=r,l=a)}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 s=i;if(!1===s.interactive)continue;const[[a,c],[l,u]]=s.bounds;if(!(a>t||t>l||c>n||n>u)&&(s._cachedPath2D||(s._cachedPath2D=new Path2D(s.pathData)),r.isPointInPath(s._cachedPath2D,t,n)))return{node:s,distance:0}}let u=null,d=a;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,a);for(let o=0;r.length-1>o;o++){const[s,a]=r[o],[c,l]=r[o+1],h=Uz(t,n,s,a,c,l);i>=h&&d>h&&(u=e,d=h)}}return u?{node:u,distance:d}:null}function Uz(e,t,n,o,r,i){const s=r-n,a=i-o,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*s+(t-o)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(o+l*a))**2)}Fo(Vz);var Kz=require("react"),Qz=require("react/jsx-runtime");function Zz(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,showAxes:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p,legendLayout:m,foregroundGraphics:y,annotations:f,onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x,autoPlaceAnnotations:w,svgAnnotationRules:k,pointNodes:S,geoProjection:A}=e,C=Xs({onAnnotationActivate:g,onObservation:b,chartId:v,chartType:x}),M=(0,Kz.useRef)([f?.length??0,new Map]),j=f?.length??0;M.current[0]!==j&&(M.current=[j,new Map]);const P=(0,Kz.useMemo)(()=>{if(!f||0===f.length)return null;const e=Wa(f),o=A?e.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;const t=A(Number(e.coordinates[0]),Number(e.coordinates[1]));return t?{...e,x:t[0],y:t[1]}:e}):e,r={scales:{x:e=>Number(e),y:e=>Number(e)},timeAxis:"x",width:t,height:n,frameType:"xy",pointNodes:S,stickyPositionCache:M.current[1]};return oa(w?ja({annotations:o,context:r,..."object"==typeof w?w:{}}):o,ra(0,C),k,r)},[f,w,k,t,n,S,C,A]);return s||a||c||y||P&&P.length>0?(0,Qz.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Qz.jsx)("title",{children:"string"==typeof a?a:"XY Chart"}),(0,Qz.jsx)("desc",{children:"string"==typeof a?a+" (XY data visualization)":"XY data visualization"}),(0,Qz.jsxs)("g",{transform:"translate("+i.left+","+i.top+")",children:[P,y]}),a&&"string"==typeof a?(0,Qz.jsx)("text",{x:o/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,Qz.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:a}):null,ys({legend:c,totalWidth:o,totalHeight:r,margin:i,legendPosition:p,title:a,legendLayout:m,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}):null}var Jz=require("d3-zoom"),eH=require("d3-selection");function tH([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t,n]}function nH(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 oH=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 rH=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 s=n[i.lineIndex];if(!s||2>s.length){i.active=!1;continue}if(i.t+=e*t,i.t>=1){i.active=!1;continue}const a=iH(s),c=sH(s,i.t*a),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 iH(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 sH(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],s=Math.sqrt(r*r+i*i);if(n+s>=t||o===e.length-1){const a=s>0?(t-n)/s:0,c=s>.001?s:1;return{x:e[o-1][0]+r*a,y:e[o-1][1]+i*a,nx:-i/c,ny:r/c}}n+=s}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}function aH(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=Fr(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+o.centerDx,y:e.y+o.centerDy,r:o.radius})}return t}var cH=require("react/jsx-runtime");function lH({data:e}){if(!e)return null;if(e.properties)return(0,cH.jsx)("div",{className:"semiotic-tooltip",style:eu,children:(0,cH.jsx)("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=Zl(t),o=null!=n.title?n.title+"":null;return null==o&&0===n.entries.length?null:(0,cH.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=o&&(0,cH.jsx)("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:o}),n.entries.map(e=>(0,cH.jsxs)("div",{children:[(0,cH.jsxs)("span",{style:{opacity:.7},children:[e.key,": "]}),(0,cH.jsx)("span",{style:{fontWeight:600},children:Ad(e.value)})]},e.key))]})}lH.ownsChrome=!0;var uH={top:10,right:10,bottom:10,left:10},dH=null;function hH(){if(null!==dH)return dH;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 dH=e||t||n}function pH(){return hH()?12:30}var mH={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 yH(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function fH(e){return e?e.getContext("2d"):null}var gH=require("react/jsx-runtime"),bH=(0,vz.memo)((0,vz.forwardRef)(function(e,t){const{projection:n,projectionExtent:o,fitPadding:r,projectionTransform:i,areas:s,points:a,lines:c,customLayout:l,layoutConfig:u,layoutSelection:d,onLayoutError:h,xAccessor:p,yAccessor:m,lineDataAccessor:y,pointIdAccessor:f,lineIdAccessor:g,lineType:b="geo",flowStyle:v="basic",graticule:x,zoomable:w,zoomExtent:k,onZoom:S,dragRotate:A,showParticles:C,particleStyle:M,tileURL:j,tileAttribution:P,tileCacheSize:I,size:R,width:T,height:_,responsiveWidth:L,responsiveHeight:D,margin:N,className:$,background:B,maxDevicePixelRatio:E,windowSize:O=500,renderMode:F,areaStyle:z,pointStyle:H,lineStyle:W,colorScheme:q,enableHover:G=!0,hoverAnnotation:Y,tooltipContent:V,allowTooltipOverflow:X=!1,customClickBehavior:U,customHoverBehavior:K,onObservation:Q,annotationObservationCallback:Z,chartId:J,annotations:ee,onAnnotationActivate:te,autoPlaceAnnotations:ne,svgAnnotationRules:oe,decay:re,pulse:ie,transition:se,animate:ae,staleness:ce,frameScheduler:le,clock:ue,random:de,seed:he,paused:pe=!1,suspendWhenHidden:me=!0,backgroundGraphics:ye,foregroundGraphics:fe,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,legendCategoryAccessor:Ce,onCategoriesChange:Me,showAxes:je,accessibleTable:Pe=!0,description:Ie,summary:Re}=e,{customHoverBehavior:Te,customClickBehavior:_e,hasClickBehavior:Le}=Ed({customHoverBehavior:K,customClickBehavior:U,onObservation:Q,chartId:J,chartType:"StreamGeoFrame"}),De=R||[T||600,_||400],Ne=(0,vz.useRef)(!0),$e=Cu({sizeProp:De,responsiveWidth:L,responsiveHeight:D,userMargin:N,marginDefault:uH,title:ge,legend:be,legendPosition:ve,foregroundGraphics:fe,backgroundGraphics:ye,animate:ae,transitionProp:se,frameScheduler:le,clock:ue,random:de,seed:he,paused:pe,suspendWhenHidden:me,themeDirtyRef:Ne}),{reducedMotionRef:Be,responsiveRef:Ee,size:Oe,margin:Fe,adjustedWidth:ze,adjustedHeight:He,resolvedForeground:We,resolvedBackground:qe,transition:Ge,introEnabled:Ye,tableId:Ve,frameRuntime:Xe,rafRef:Ue,renderFnRef:Ke,scheduleRender:Qe,currentTheme:Ze}=$e,Je=Gc(),et=Uc(),tt=(0,vz.useMemo)(()=>Array.isArray(s)?ft(s):s,[s]),nt=(0,vz.useMemo)(()=>ft(a),[a]),ot=(0,vz.useMemo)(()=>ft(c),[c]),rt=(0,vz.useMemo)(()=>null!=A?A:"orthographic"===yH(n),[A,n]),it=Qc((0,vz.useMemo)(()=>({projection:n,projectionExtent:o,fitPadding:r,xAccessor:p,yAccessor:m,lineDataAccessor:y,lineType:b,flowStyle:v,areaStyle:z,pointStyle:H,lineStyle:W,colorScheme:q,themeSemantic:Rt(Ze),themeSequential:Ze?.colors?.sequential,themeDiverging:Ze?.colors?.diverging,themeCategorical:Ze?.colors?.categorical,graticule:x,projectionTransform:i,windowSize:O,clock:Xe.now,decay:re,pulse:ie,transition:Ge,introAnimation:Ye,annotations:ee,pointIdAccessor:f,lineIdAccessor:g,customLayout:l,layoutConfig:u,onLayoutError:h,layoutMargin:Fe}),[n,o,r,p,m,y,b,v,z,H,W,q,Ze,x,i,O,Xe.now,re,ie,Ge,Ye,ee,f,g,l,u,h,Fe])),st=(0,vz.useRef)(null);st.current||(st.current=new Vz(it));const at=(0,vz.useRef)(null),ct=(0,vz.useRef)(null),lt=(0,vz.useRef)(null);j&&!lt.current&&(lt.current=new oH(I||256));const ut=(0,vz.useRef)(ee),dt=(0,vz.useRef)(null),ht=(0,vz.useRef)(Jz.zoomIdentity),pt=(0,vz.useRef)(!1),mt=(0,vz.useRef)(null),yt=(0,vz.useCallback)(e=>{mt.current=e,Ee&&"object"==typeof Ee&&(Ee.current=e)},[Ee]),gt=(0,vz.useRef)(null),bt=(0,vz.useRef)(null),vt=(0,vz.useRef)(null),xt=(0,vz.useRef)(0);if(C&&!vt.current){const e=M?.maxPerLine??pH();vt.current=new rH(50*e)}const wt=(0,vz.useRef)(null),kt=(0,vz.useRef)(null),St=(0,vz.useRef)(!1),At=(0,vz.useRef)(!1),Ct=yr("StreamGeoFrame"),Mt=(0,vz.useRef)(void 0),[jt,Pt]=(0,vz.useState)(null),[,It]=(0,vz.useState)(0),Tt=(0,vz.useRef)(0),[_t,Lt]=(0,vz.useState)(!1),Dt=$u(st,Ce,Me,e=>e.getPoints());Mr(st,it,Ne,Qe),jr(st,d,Ne,Qe),(0,vz.useEffect)(()=>{const e=st.current;e&&(tt&&e.setAreas(tt),a&&e.setPoints(nt),c&&e.setLines(ot),Ne.current=!0,Qe())},[tt,a,nt,c,ot,Qe]);const Nt=(0,vz.useCallback)(e=>{null!=e&&"object"==typeof e&&(st.current?.pushPoint(e),Ne.current=!0,Qe())},[Qe]),$t=(0,vz.useCallback)(e=>{const t=ft(e);0!==t.length&&(st.current?.pushMany(t),Ne.current=!0,Qe())},[Qe]),Bt=(0,vz.useCallback)(e=>{null!=e&&"object"==typeof e&&(st.current?.pushLine(e),Ne.current=!0,Qe())},[Qe]),Et=(0,vz.useCallback)(e=>{const t=ft(e);0!==t.length&&(st.current?.pushManyLines(t),Ne.current=!0,Qe())},[Qe]),Ot=(0,vz.useCallback)(()=>{st.current?.clear(),Ne.current=!0,Qe()},[Qe]);(0,vz.useImperativeHandle)(t,()=>({push:Nt,pushMany:$t,removePoint:e=>{const t=st.current?.removePoint(e)??[];return t.length>0&&(Ne.current=!0,Qe()),t},pushLine:Bt,pushManyLines:Et,removeLine:e=>{const t=st.current?.removeLine(e)??[];return t.length>0&&(Ne.current=!0,Qe()),t},getLines:()=>st.current?.getLines()??[],clear:Ot,getProjection:()=>st.current?.scales?.projection??null,getGeoPath:()=>st.current?.scales?.geoPath??null,getCartogramLayout:()=>st.current?.cartogramLayout??null,getCustomLayout:()=>st.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>st.current?.lastCustomLayoutFailure??null,getZoom:()=>ht.current.k,resetZoom:()=>{const e=mt.current;e&&dt.current&&(0,eH.select)(e).call(dt.current.transform,Jz.zoomIdentity)},getData:()=>st.current?.getPoints()??[]}),[Nt,$t,Bt,Et,Ot,Qe]);const{hoverHandlerRef:Ft,onPointerMove:zt,onPointerLeave:Ht}=$e,{canvasRef:Wt,interactionCanvasRef:qt,resolutionDirtyRef:Gt}=Tu($e,{hydrated:Je,wasHydratingFromSSR:et,storeRef:st,dirtyRef:Ne,cleanup:()=>lt.current?.clear(),maxDevicePixelRatio:E,canvasPaintDependencies:[ze,He,B,ye,F,Qe]});(0,vz.useEffect)(()=>{Ft.current=e=>{if(!G)return;const t=st.current;if(!t||!t.scene.length)return;const n=Wt.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Fe.left,i=e.clientY-o.top-Fe.top;if(0>r||r>ze||0>i||i>He)return wt.current=null,kt.current=null,Pt(null),Te?.(null),void Qe();ct.current||(ct.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const s=fH(ct.current);if(!s)return;const a=ql(30,e.pointerType),c=ql(6,e.pointerType),l=Xz(t.scene,r,i,a,s,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,s;"point"===e.type?(o=e.x,s=e.y):"geoarea"===e.type?(o=e.centroid[0],s=e.centroid[1]):(o=r,s=i);const a={...n,...n?.properties||{},data:n,properties:n?.properties,__semioticHoverData:!0,x:o,y:s};wt.current=a,kt.current=e,Pt(a),Te?.(a),Qe()}else wt.current&&(wt.current=null,kt.current=null,Pt(null),Te?.(null),Qe())}},[G,ze,He,Fe,Te,Qe,Ft,Wt]),$e.hoverLeaveRef.current=()=>{wt.current=null,kt.current=null,Pt(null),Te?.(null),Qe()};const Yt=(0,vz.useCallback)(e=>{if(Qs(e.target))return;if(!_e)return;const t=st.current;if(!t||!t.scene.length)return void _e(null);const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Fe.left,r=e.clientY-n.top-Fe.top;if(0>o||o>ze||0>r||r>He)return void _e(null);ct.current||(ct.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=fH(ct.current);if(!i)return void _e(null);const s=ql(30,Mt.current),a=ql(6,Mt.current),c=Xz(t.scene,o,r,s,i,t.quadtree,t.maxPointRadius,a);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 _e({...n,data:t,properties:t?.properties,__semioticHoverData:!0,x:o,y:r,time:o,value:r},{type:"activate",inputType:Ld(Mt.current)})}_e(null)},[He,ze,_e,Fe]),{kbFocusIndexRef:Vt,focusedNavPointRef:Xt,onKeyDown:Ut}=function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s}){const a=(0,Od.useRef)(-1),c=(0,Od.useRef)(null),l=(0,Od.useCallback)(l=>{if(Dd(l))return;const u=e.current;if(!u)return;const d=()=>{a.current=-1,c.current=null,t.current=null,n&&(n.current=null),o(null),r?.(null),s()};if(0===u.scene.length)return void(0>a.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=Fr(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>a.current||d());let p=a.current;if(h.length>p||(d(),p=-1),("Enter"===l.key||" "===l.key)&&p>=0)return l.preventDefault(),void i?.(Ud(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 y=0>p?0:m;a.current=y;const f=h[y];c.current=f;const g=Ud(f);t.current=g,o(g),r?.(g,{type:"focus",inputType:"keyboard"}),s()},[i,r,t,n,s,o,e]);return{kbFocusIndexRef:a,focusedNavPointRef:c,onKeyDown:l}}({storeRef:st,hoverRef:wt,hoveredNodeRef:kt,setHoverPoint:Pt,customHoverBehavior:Te,customClickBehavior:_e,scheduleRender:Qe}),Kt=(0,vz.useCallback)(e=>{Mt.current=e.pointerType,Vt.current=-1,Xt.current=null,zt(e)},[Xt,Vt,zt]),Qt=(0,vz.useCallback)(e=>{Mt.current=e.pointerType},[]);Ke.current=()=>{if(Ue.current=null,!Xe.isActive)return;const e=Wt.current,t=st.current;if(!e||!t)return;const n=Xe.now();let o=!1;const r=bt.current;let i=!1;r&&(bt.current=null,t.applyRotation(r,{width:ze,height:He}),i=!0);const s=t.advanceTransition(Be.current?n+1e6:n),a=!Be.current&&s,c=Ct.current.beforeCompute(t.getLastUpdateResult(),a);let l=!1;if(Ne.current&&!s){const n={width:ze,height:He},o=t.hasProjection(),r=rt&&o?t.getRotation():null;t.computeScene(n);const i=ht.current,s=1!==i.k||0!==i.x||0!==i.y;rt&&r?s?(t.setRotation(r),t.applyZoomScale(i.k,n)):t.applyRotation(r,n):s&&t.applyZoomTransform(i,n),Ne.current=!1,l=!0,e.setAttribute("aria-label",wl(t.scene,"Geographic chart")),Dt()}Ct.current.afterCompute(c,l,!1);const u=Pu(E),d=C&&!Be.current&&!!vt.current,h=t.consumeStylePaintPending(),p=Lu(t,n,l,At),m=ol({dirtyOrRebuilt:l,transitioning:a,continuous:d,liveEncoding:p.changed,forced:i||h||Gt.current});if(Gt.current=!1,j&&lt.current){const e=at.current;if(e&&t.scales?.projection){const n=ju(e,Oe,Fe,u);if(n){n.clearRect(-Fe.left,-Fe.top,Oe[0],Oe[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:s,onTileLoad:a,maxDevicePixelRatio:c}=t,l=o.scale(),u=o.translate(),d=function(e){const{size:t,scale:n,translate:o,clampX:r=!0,clampY:i=!0}=e,s=Math.max(Math.log(n)/Math.LN2-8,0),a=Math.round(s),c=1<<a,l=Math.pow(2,s-a+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)),y=Math.min(i?c:1/0,Math.ceil((t[1]-d)/l)),f=[];for(let e=m;y>e;++e)for(let t=h;p>t;++t)f.push([t,e,a]);return{tiles:f,translate:[u/l,d/l],scale:l}}({size:[r,i],scale:2*l*Math.PI,translate:u}),h=Pu(c);let p=!0;for(const t of d.tiles){const[o,r,i]=tH(t),c=`${i}/${o}/${r}`;let l=s.get(c);if(!l){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:c,lastUsed:performance.now()};s.set(c,t),e.onload=()=>{t.loaded=!0,a?.()},e.onerror=()=>{t.loaded=!0},e.src=nH(n,i,o,r,h),l=t}if(!l.loaded){p=!1;continue}const u=d.scale;e.drawImage(l.img,(t[0]+d.translate[0])*u-.5,(t[1]+d.translate[1])*u-.5,u+1,u+1)}return p}(n,{tileURL:j,projection:t.scales.projection,width:ze,height:He,tileCache:lt.current,maxDevicePixelRatio:E,onTileLoad:()=>Qe()});n.restore(),e||(o=!0)}}}if(m){const r=ju(e,Oe,Fe,u);if(!r)return;r.clearRect(-Fe.left,-Fe.top,Oe[0],Oe[1]),j||nl(r,{background:B,hasBackgroundGraphics:!!ye,width:ze,height:He}),r.save(),r.beginPath(),r.rect(0,0,ze,He),r.clip();const i=t.scene,s={width:ze,height:He};if(vd({context:r,nodes:i,renderMode:F,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=ci(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=Xr(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)}Uu(e,t,n),e.globalAlpha=1,e.setLineDash([])}}(r,e),Gu(r,e,0,s),ed(r,e),id(r,e)}}),d&&vt.current){const e=vt.current,t=i.filter(e=>"line"===e.type);if(t.length>0){const i=M||{},s=.3*(i.speedMultiplier??1),a=i.maxPerLine??pH(),c=i.spawnRate??(hH()?.06:.15),l=i.radius??2,u=i.opacity??.7,d=n/1e3,h=xt.current>0?Math.min(d-xt.current,.1):.016;xt.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)<a&&e.spawn(n,Xe.random);e.step(h,s,p,m),r.globalAlpha=u;for(let n=0;e.particles.length>n;n++){const o=e.particles[n];if(!o.active)continue;const s=t[o.lineIndex],a="function"==typeof i.color?i.color(s?.datum??{}):"source"!==i.color&&i.color?i.color:s?.style.stroke||"#fff";r.beginPath(),r.arc(o.x,o.y,l,0,2*Math.PI),r.fillStyle=a,r.fill()}r.globalAlpha=1,o=!0}}r.restore()}const y=kt.current,f=!(!y||"geoarea"!==y.type&&"point"!==y.type),g=rl(f,St.current),b=qt.current;if(b&&g){const e=ju(b,Oe,Fe,u);if(e){if(e.clearRect(-Fe.left,-Fe.top,Oe[0],Oe[1]),y&&"geoarea"===y.type){const t=new Path2D(y.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(y&&"point"===y.type){const t=y,n="object"==typeof Y?Y:void 0,o=n?.pointColor||wd(y);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()}}St.current=f}const v=ee!==ut.current;v&&(ut.current=ee),(l||v||a&&ee&&ee.length>0)&&(l||v||n-Tt.current>=33)&&(It(e=>e+1),Tt.current=n),(a||null!=t.activeTransition||p.pending||o)&&Qe()},_i(ce,st,Ne,Qe,_t,Lt),(0,vz.useEffect)(()=>{if("production"!==process.env.NODE_ENV&&j){const e=yH(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.`)}},[j,n]),(0,vz.useEffect)(()=>{const e=mt.current;if(!w||!e)return dt.current&&e&&((0,eH.select)(e).on(".zoom",null),dt.current=null),void(e&&(0,eH.select)(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=k||[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=Jz.zoomIdentity.scale(r);const i=st.current;i&&(i.applyZoomScale(r,o),Ne.current=!1,Qe(),i.scales?.projection&&S?.({projection:i.scales.projection,zoom:i.currentZoom}))};dt.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>i(t?.k??1)};const s=e=>{e.preventDefault(),i(r*(0>e.deltaY?1.1:1/1.1))},a=e=>{const t=e.target;t&&(t.closest("button")||t.closest(".stream-geo-zoom-controls"))||(e.preventDefault(),i(1.5*r))};e.addEventListener("wheel",s,{passive:!1}),e.addEventListener("dblclick",a);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=st.current;if(!o)return;const r=o.getRotation();gt.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=gt.current;t&&(bt.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(!gt.current)return;gt.current=null,e.releasePointerCapture(t.pointerId);const n=bt.current;if(n){bt.current=null;const e=st.current;e&&(e.applyRotation(n,o),Qe())}const r=st.current;r?.scales?.projection&&S?.({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",s),e.removeEventListener("dblclick",a),e.removeEventListener("pointerdown",l),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),dt.current=null}}const r=(0,Jz.zoom)().scaleExtent([t,n]).extent([[0,0],[Oe[0],Oe[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=st.current;n&&(n.applyZoomTransform(t,o),Ne.current=!1,Qe())}).on("end",e=>{ht.current=e.transform,pt.current=!1;const t=st.current;t?.scales?.projection&&S?.({projection:t.scales.projection,zoom:t.currentZoom})});return dt.current=r,(0,eH.select)(e).call(r),()=>{(0,eH.select)(e).on(".zoom",null)}},[w,k,rt,Oe,ze,He,Fe,S,Qe]);const Zt=G&&!1!==Y,Jt=Zt&&jt?V?V(jt):(0,gH.jsx)(lH,{data:jt}):null,en=Jt?(0,gH.jsx)(uu,{x:jt.x,y:jt.y,containerWidth:ze,containerHeight:He,margin:Fe,className:"stream-frame-tooltip",zIndex:10,children:Jt}):null;if(Hc||!Je&&et){const e=st.current;e&&(tt||a||c)&&(tt&&e.setAreas(tt),a&&e.setPoints(nt),c&&e.setLines(ot),e.computeScene({width:ze,height:He}));const t=e?.scene??[];return(0,gH.jsxs)("div",{ref:yt,className:"stream-geo-frame"+($?" "+$:""),role:"img","aria-label":Ie||("string"==typeof ge?ge:"Geographic chart"),style:{position:"relative",width:L?"100%":Oe[0],height:D?"100%":Oe[1]},children:[(0,gH.jsx)(El,{summary:Re}),(0,gH.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Oe[0],height:Oe[1],style:{position:"absolute",left:0,top:0},children:[(0,gH.jsx)("g",{transform:`translate(${Fe.left},${Fe.top})`,children:qe}),(0,gH.jsxs)("g",{transform:`translate(${Fe.left},${Fe.top})`,children:[B&&(0,gH.jsx)("rect",{x:0,y:0,width:ze,height:He,fill:B}),t.map((e,t)=>xd({node:e,index:t,renderMode:F,fallback:()=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=ei(n.style.fill)?oi(n.style.fill,`geoarea-${t}-hatch`):void 0;return(0,Rc.jsxs)(Ic.Fragment,{children:[o&&(0,Rc.jsx)("defs",{children:o}),(0,Rc.jsx)("path",{d:n.pathData,fill:o?`url(#geoarea-${t}-hatch)`:wc(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=ei(n.style.fill)?oi(n.style.fill,`geopoint-${t}-hatch`):void 0;return(0,Rc.jsxs)(Ic.Fragment,{children:[o&&(0,Rc.jsx)("defs",{children:o}),(0,Rc.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${t}-hatch)`:wc(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(0,Rc.jsx)("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 Sc(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)}))]})]}),(0,gH.jsx)(Zz,{width:ze,height:He,totalWidth:Oe[0],totalHeight:Oe[1],margin:Fe,showAxes:!1,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,foregroundGraphics:br(We,Ar(st.current?.customLayoutOverlays,d??null)),annotations:ee,onAnnotationActivate:te,onObservation:Z??Q,chartId:J,chartType:"StreamGeoFrame",autoPlaceAnnotations:ne,svgAnnotationRules:oe,pointNodes:aH(t),geoProjection:st.current?.scales?.projectedPoint})]})}return(0,gH.jsxs)("div",{ref:yt,className:"stream-geo-frame"+($?" "+$:""),role:"group","aria-label":Ie||("string"==typeof ge?ge:"Geographic chart"),tabIndex:0,style:{position:"relative",width:L?"100%":Oe[0],height:D?"100%":Oe[1],overflow:X?"visible":"hidden",...w?{touchAction:"none"}:{}},onKeyDown:Ut,children:["production"!==process.env.NODE_ENV&&st.current&&(0,gH.jsx)(fr,{store:st.current,diagnostics:Ct.current}),Pe&&(0,gH.jsx)(Ol,{tableId:Ve}),Pe&&(0,gH.jsx)($l,{scene:st.current?.scene??[],chartType:"Geographic chart",tableId:Ve,chartTitle:"string"==typeof ge?ge:void 0}),(0,gH.jsx)(El,{summary:Re}),(0,gH.jsx)(yl,{hoverPoint:jt}),(0,gH.jsxs)("div",{role:"img","aria-label":Ie||("string"==typeof ge?ge:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Zt?Kt:void 0,onPointerLeave:Zt?Ht:void 0,onPointerDown:Zt||Le?Qt:void 0,onClick:Le?Yt:void 0,children:[(0,gH.jsx)(_u,{size:Oe,margin:Fe,children:qe}),j&&(0,gH.jsx)("canvas",{ref:at,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,gH.jsx)("canvas",{ref:Wt,"aria-label":wl(st.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),(0,gH.jsx)("canvas",{ref:qt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,gH.jsx)(Zz,{width:ze,height:He,totalWidth:Oe[0],totalHeight:Oe[1],margin:Fe,showAxes:je,title:ge,legend:be,legendPosition:ve,legendLayout:xe,legendHoverBehavior:we,legendClickBehavior:ke,legendHighlightedCategory:Se,legendIsolatedCategories:Ae,foregroundGraphics:br(We,Ar(st.current?.customLayoutOverlays,d??null)),annotations:ee,onAnnotationActivate:te,onObservation:Z??Q,chartId:J,chartType:"StreamGeoFrame",autoPlaceAnnotations:ne,svgAnnotationRules:oe,pointNodes:aH(st.current?.scene),geoProjection:st.current?.scales?.projectedPoint}),ce?.showBadge&&(0,gH.jsx)(Di,{isStale:_t,position:ce.badgePosition}),w&&(0,gH.jsxs)("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Fe.bottom+8,left:Fe.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[(0,gH.jsx)("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=mt.current,n=dt.current;t&&n?.scaleBy&&n.scaleBy((0,eH.select)(t),1.5)},style:mH,children:"+"}),(0,gH.jsx)("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=mt.current,n=dt.current;t&&n?.scaleBy&&n.scaleBy((0,eH.select)(t),1/1.5)},style:mH,children:"−"})]}),P&&(0,gH.jsx)("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Fe.bottom+2,right:Fe.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:P}),(0,gH.jsx)(Hl,{active:Vt.current>=0,hoverPoint:jt,margin:Fe,size:Oe,shape:Xt.current?.shape,width:Xt.current?.w,height:Xt.current?.h,pathData:Xt.current?.pathData}),en]})]})}));bH.displayName="StreamGeoFrame";var vH=bH,xH=require("react/jsx-runtime"),wH=(0,bz.forwardRef)(function(e,t){const{points:n,areas:o,lines:r,layout:i,layoutConfig:s,onLayoutError:a,projection:c="equirectangular",xAccessor:l="lon",yAccessor:u="lat",lineDataAccessor:d,colorBy:h,colorScheme:p,tooltip:m,annotations:y,margin:f,selection:g,linkedHover:b,onObservation:v,onClick:x,chartId:w,loading:k,loadingContent:S,emptyContent:A,className:C,frameProps:M={}}=e,{frameRef:j,resolved:P,normalizedMargin:I}=Sm({imperativeRef:t,imperativeVariant:"geo-points",margin:f,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}),R=(0,bz.useMemo)(()=>ft(n),[n]),T=(0,bz.useMemo)(()=>ft(o),[o]),_=(0,bz.useMemo)(()=>ft(r),[r]),L=(0,bz.useMemo)(()=>[...R,..._,...T],[R,_,T]),D=Vp({data:L,rawData:void 0!==n||void 0!==r||void 0!==o?L:void 0,colorBy:h,colorScheme:p,legendInteraction:void 0,selection:g,linkedHover:b,fallbackFields:"string"==typeof h?[h]:[],unwrapData:!1,onObservation:v,onClick:x,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"GeoCustomChart",chartId:w,showLegend:!1,userMargin:I,marginDefaults:P.marginDefaults,loading:k,loadingContent:S,emptyContent:A,width:P.width,height:P.height,hasTitle:!!P.title}),N=D.effectiveSelectionHook,$=(0,bz.useMemo)(()=>N?.isActive?{isActive:!0,predicate:N.predicate}:null,[N?.isActive,N?.predicate]);if(D.earlyReturn)return D.earlyReturn;const{width:B,height:E,enableHover:O,title:F,description:z,summary:H,accessibleTable:W}=P,q=cu(m),G={projection:c,...null!=n&&{points:R},...null!=o&&{areas:T},...null!=r&&{lines:_},xAccessor:l,yAccessor:u,...null!=d&&{lineDataAccessor:d},customLayout:i,layoutConfig:s,onLayoutError:a,layoutSelection:$,colorBy:h,colorScheme:p,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:D.margin,enableHover:O,...sm({title:F,description:z,summary:H,accessibleTable:W,className:C,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:e.autoPlaceAnnotations}),...!1===m?{tooltipContent:()=>null}:q?{tooltipContent:q}:{},...am({linkedHover:b,selection:g,onObservation:v,onClick:x,hoverHighlight:!1,mobileInteraction:D.mobileInteraction,customHoverBehavior:D.customHoverBehavior,customClickBehavior:D.customClickBehavior,linkedHoverInClickPredicate:!1}),...y&&y.length>0&&{annotations:y},...M};return(0,xH.jsx)(Rp,{componentName:"GeoCustomChart",width:B,height:E,children:(0,xH.jsx)(vH,{ref:j,...G})})});function kH(e){const t=lL(e.recipe)??(e.recipeId?rL(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:q_(e.layout)?cL(e.layout.id):void 0}(t);if(!n){const e=q_(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?Mm:"OrdinalFrame"===t.frameFamily||"OrdinalCustomChart"===t.frameFamily?mz:"NetworkFrame"===t.frameFamily||"NetworkCustomChart"===t.frameFamily?gz:"GeoFrame"===t.frameFamily||"GeoCustomChart"===t.frameFamily?wH:void 0;if(!i)throw Error(`Chart recipe "${t.id}" uses unsupported frame family "${t.frameFamily}".`);return dz.createElement(i,r)}function SH(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function AH(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function CH(e){return"number"==typeof e&&Number.isFinite(e)}function MH(e){if(CH(e.x)&&CH(e.y)&&CH(e.w)&&CH(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(CH(e.x)&&CH(e.y)&&CH(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(CH(e.cx)&&CH(e.cy)&&CH(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(CH(e.cx)&&CH(e.cy)&&CH(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)&&CH(e[0])&&CH(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 jH(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 PH(e,t,n,o,r){if(e===t)return!0;const i=n.dataRoles.map(e=>mL(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 IH(e,t,n,o,r,i="warn",s){return{id:e,category:t,status:n?"pass":i,message:n?o:r,...s?{evidence:s}:{}}}function RH(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??dL({layoutConfig:e.layoutConfig}),r=e.dimensions.plot??{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},i=r.x??0,s=r.y??0,a=[],c=n.filter(e=>null!=AH(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)));a.push(IH("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(MH),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;a.push(IH("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||s>e.y0||e.x1>i+r.width||e.y1>s+r.height)).length;a.push(IH("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;a.push(IH("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 y=c.map(SH),f=y.filter(e=>!e).length,g=new Set,b=y.filter(e=>!(!e||!g.has(e)&&(g.add(e),1)));a.push(IH("identity.stable-ids","identity",0===f,"Every data-bearing mark exposes a stable id.",f+" data-bearing marks have no pointId, id, or transition key.",t.audit?.requireStableIds?"fail":"warn",{missing:f})),a.push(IH("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=y.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;v>0&&a.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=AH(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)PH(e,k[n],t,o,k)&&(x.add(n),i=!0);i||(w+=1)}const S=Math.max(0,k.length-x.size);a.push(IH("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})),a.push(IH("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&&a.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;a.push(IH("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),j=M.filter(e=>!g.has(e));a.push(IH("coverage.annotation-anchors","coverage",0===j.length,M.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",j.length+" annotations point to missing scene ids.","fail",{unresolved:j}));const P=(e.chart?.selectedIds??[]).filter(e=>!g.has(e));e.chart?.selectedIds&&a.push(IH("interaction.selection-reachability","interaction",0===P.length,"Selected/highlighted states resolve to observed marks.",P.length+" selected ids are not reachable in the scene.","fail",{missing:P}));const I=vl(n),R=(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?mL(n,o,k):void 0}).filter(e=>!!e),T=new Set(I.flatMap(e=>Object.keys(e.values))),_=R.filter(e=>!T.has(e));a.push(IH("accessibility.table-fields","accessibility",0===_.length,R.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${_.join(", ")}.`,"fail",{expectedFields:R,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)&&a.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 L=(t.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);a.push(IH("accessibility.color-only","accessibility",0===L.length,"Every declared color encoding names a redundant cue.",L.length+" color encodings have no declared redundant cue.","warn"));const D=e.chart;if(D){for(const[e,n]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])n&&a.push(IH("accessibility."+e,"accessibility","string"==typeof D[e]&&D[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)&&a.push(IH("accessibility.fallback-table","accessibility",!1!==D.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),D.navigationTree&&a.push(IH("accessibility.navigation-depth","accessibility",(D.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const N=e.theme?.background??"#ffffff",$=n.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!N.startsWith("#"))return!1;const n=q$(t,N);return null!=n&&3>n}).length;a.push(IH("visual.contrast","visual",0===$,"All statically checkable mark fills meet 3:1 contrast.",$+" marks have fill contrast below 3:1.","warn",{background:N}));let B=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>jH(E[e],E[t])||(B+=1);B>E.length&&a.push({id:"visual.overlap-density",category:"visual",status:"warn",message:B+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const O=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),F={dataRoles:t.dataRoles.map(e=>e.role),intents:t.intents.map(uL).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=[...a,...O],H=a.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:F,observedSceneEvidence:a,manualATChecks:O}}wH.displayName="GeoCustomChart";var TH=d(require("react"));function _H(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 LH(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}}var DH=require("react/jsx-runtime");function NH({manifest:e,label:t="Intent Mark",className:n,showSummary:o=!0}){const[r,i]=TH.useState(!1),s=TH.useMemo(()=>JSON.stringify(e,null,2),[e]),a=TH.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(s),i(!0),window.setTimeout(()=>i(!1),1200))},[s]);return(0,DH.jsxs)("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:[(0,DH.jsxs)("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),(0,DH.jsxs)("div",{style:{padding:"0 10px 10px"},children:[o&&(0,DH.jsx)("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:_H(e)}),(0,DH.jsx)("button",{type:"button",onClick:a,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"}),(0,DH.jsx)("pre",{style:{maxHeight:280,overflow:"auto",margin:"10px 0 0",padding:10,background:"var(--semiotic-bg, #f5f5f5)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap"},children:s})]})]})}var $H=[{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"}],BH=new Map($H.map(e=>[e.id,e]));function EH(e){return BH.get(e)}function OH(){return Array.from(BH.values())}function FH(e){BH.set(e.id,e)}var zH=new Set($H.map(e=>e.id)),HH=new Set;function WH(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function qH(e,t){return void 0===e?0:WH("function"==typeof e?e(t):e,0,5)}function GH(e){return e?Array.isArray(e)?[...e]:[e]:[]}function YH(e,t,n){const o={};for(const[n,r]of Object.entries(e.intentScores))o[n]=qH(r,t);if(n)for(const[e,t]of Object.entries(n))o[e]=WH((o[e]??0)+t,0,5);return o}function VH(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 XH(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 KH=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var QH=(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=GH(n.intent),s=[];for(const e of r)s.push(XH(t,e));const a=i.includes("rank")||i.includes("compare-categories");!KH.has(e)||"categorical"!==t.family||UH(r,"orientation","horizontal")||!a&&6>(o.categoryCount??0)||s.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"))&&s.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=mO().filter(t=>t.component!==e).filter(e=>null===e.fits(o)).map(e=>{const t=YH(e,o);return{candidate:e,fit:VH(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)s.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 s}(e,t,n));for(const o of HH)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),ZH=(e,t,n,o={})=>{const r=yO(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 s=GH(o.intent),a=YH(r,t,e.intentDeltas),c=VH(a,s),l=function(e,t){return t?{familiarity:Math.round(WH((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(WH(n.accuracy,1,5)),precision:Math.round(WH(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=xO(uB(e.baseComponent,i),d)}const h=wO(c,l,e.baseComponent,n,u),p=WH(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=WH(m,0,1);let y="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(e.rubricDeltas?.accuracy??0)&&(y+=.15),0>(e.rubricDeltas?.precision??0)&&(y+=.1),l.accuracy>3||(y+=.1),3>p&&(y+=.2),y=WH(y,0,1);const f=[];if(e.rationale&&f.push(e.rationale),s.length>0){const e=s.map(e=>`${e}: ${(a[e]??0).toFixed(1)}/5`).join(", ");f.push(`Intent fit — ${e}.`)}else f.push(`Mean non-zero intent fit ${c.toFixed(1)}/5.`);return"manual"!==e.source&&f.push(e.source+" proposal; verify against domain context."),h.appliedReason&&f.push(h.appliedReason),h.receivabilityReason&&f.push(h.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(e??0))&&f.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:p,novelty:m,risk:y,reasons:f}};function JH(e){return HH.add(e),()=>{HH.delete(e)}}function eW(){return Array.from(HH)}function tW(){HH.clear()}var nW=require("react"),oW={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function rW(e){if(0===e.length)return oW;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,s=e[e.length-1].timestamp;return{total:e.length,byType:t,componentsSeen:Array.from(n),audiencesSeen:o,latestArcId:r,startedAt:i,lastAt:s,durationMs:Math.max(0,s-i)}}function iW(e={}){const{enableOnMount:t=!0,disableOnUnmount:n=!1,capacity:o,sessionId:r}=e;(0,nW.useEffect)(()=>(t&&qD({capacity:o,sessionId:r}),()=>{n&&GD()}),[t,n,o,r]);const i=(0,nW.useCallback)(e=>LD(e),[]),s=(0,nW.useCallback)(()=>YD().getEvents(),[]),a=(0,nW.useSyncExternalStore)(i,s,s),[c,l]=(0,nW.useState)(()=>YD().enabled),[u,d]=(0,nW.useState)(()=>YD().sessionId);(0,nW.useEffect)(()=>(l(YD().enabled),d(YD().sessionId),LD(()=>{const e=YD();l(e.enabled),d(e.sessionId)})),[]);const h=(0,nW.useMemo)(()=>rW(a),[a]),p=(0,nW.useCallback)(e=>YD().record(e),[]),m=(0,nW.useCallback)(()=>YD().clear(),[]);return{history:a,summary:h,enabled:c,sessionId:u,record:p,clear:m}}var sW=require("react/jsx-runtime");function aW({items:e,title:t="Additional notes",empty:n=null,ordered:o=!0,renderItem:r,className:i,style:s}){if(!e.length)return n?(0,sW.jsx)(sW.Fragment,{children:n}):null;const a=o?"ol":"ul";return(0,sW.jsxs)("section",{className:["semiotic-mobile-annotation-callouts",i].filter(Boolean).join(" "),style:s,children:[(0,sW.jsx)("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&&(0,sW.jsx)("h3",{children:t}),(0,sW.jsx)(a,{children:e.map((e,t)=>(0,sW.jsx)("li",{children:r?r(e,t):(0,sW.jsxs)(sW.Fragment,{children:[(0,sW.jsx)("span",{children:e.label}),(e.source||e.emphasis)&&(0,sW.jsx)("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}
2
+ module.exports=require("./semiotic-client-cjs-shared.min.js").ai;