semiotic 3.8.8 → 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 (501) hide show
  1. package/README.md +82 -66
  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} +46 -24
  9. package/ai/schema.json +10704 -825
  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 +83 -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 +6 -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 +26 -13
  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 +17 -12
  144. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +12 -7
  145. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +37 -14
  146. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +23 -14
  147. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +22 -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/formatUtils.d.ts +40 -9
  164. package/dist/components/charts/shared/frameTextAnnotation.d.ts +63 -0
  165. package/dist/components/charts/shared/gradient.d.ts +16 -0
  166. package/dist/components/charts/shared/hatchFill.d.ts +15 -0
  167. package/dist/components/charts/shared/hooks.d.ts +4 -4
  168. package/dist/components/charts/shared/legendUtils.d.ts +1 -0
  169. package/dist/components/charts/shared/streamPropsHelpers.d.ts +3 -1
  170. package/dist/components/charts/shared/styleRules.d.ts +9 -2
  171. package/dist/components/charts/shared/styleRulesWireSchema.d.ts +353 -0
  172. package/dist/components/charts/shared/types.d.ts +26 -10
  173. package/dist/components/charts/shared/useChartLegend.d.ts +43 -9
  174. package/dist/components/charts/shared/useChartSetup.d.ts +3 -1
  175. package/dist/components/charts/shared/useCustomChartSetup.d.ts +5 -2
  176. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +5 -1
  177. package/dist/components/charts/shared/useOrdinalBrush.d.ts +3 -3
  178. package/dist/components/charts/shared/useStreamingLegend.d.ts +6 -1
  179. package/dist/components/charts/value/types.d.ts +1 -1
  180. package/dist/components/charts/xy/BubbleChart.d.ts +1 -1
  181. package/dist/components/charts/xy/BumpChart.capability.d.ts +14 -1
  182. package/dist/components/charts/xy/BumpChart.d.ts +13 -73
  183. package/dist/components/charts/xy/BumpChart.semanticViability.d.ts +5 -0
  184. package/dist/components/charts/xy/CandlestickChart.d.ts +2 -2
  185. package/dist/components/charts/xy/LineChart.d.ts +2 -2
  186. package/dist/components/charts/xy/Scatterplot.d.ts +1 -1
  187. package/dist/components/charts/xy/bumpData.d.ts +44 -0
  188. package/dist/components/charts/xy/bumpIdentity.d.ts +2 -0
  189. package/dist/components/charts/xy/bumpLayout.d.ts +45 -0
  190. package/dist/components/charts/xy/bumpTooltip.d.ts +20 -0
  191. package/dist/components/legendLayout.d.ts +131 -4
  192. package/dist/components/realtime/ReorderBuffer.d.ts +2 -0
  193. package/dist/components/realtime/types.d.ts +10 -1
  194. package/dist/components/recipes/balanceSnapshotsToFlows.d.ts +42 -0
  195. package/dist/components/recipes/directedReachability.d.ts +14 -0
  196. package/dist/components/recipes/gofishDisplayListFixtures.generated.d.ts +6 -6
  197. package/dist/components/recipes/gridObservatory.d.ts +1 -1
  198. package/dist/components/recipes/networkAnalysis.d.ts +1 -18
  199. package/dist/components/recipes/physics.d.ts +7 -4
  200. package/dist/components/recipes/processPhysics.d.ts +0 -1
  201. package/dist/components/recipes/waffle.d.ts +7 -4
  202. package/dist/components/semiotic-ai-core.d.ts +13 -4
  203. package/dist/components/semiotic-ai-observations.d.ts +3 -0
  204. package/dist/components/semiotic-ai.d.ts +16 -9
  205. package/dist/components/semiotic-client-shared.d.ts +10 -0
  206. package/dist/components/semiotic-experimental.d.ts +1 -1
  207. package/dist/components/semiotic-geo.d.ts +4 -1
  208. package/dist/components/semiotic-network.d.ts +7 -4
  209. package/dist/components/semiotic-ordinal.d.ts +4 -1
  210. package/dist/components/semiotic-physics.d.ts +11 -4
  211. package/dist/components/semiotic-realtime-core.d.ts +11 -4
  212. package/dist/components/semiotic-realtime-react.d.ts +4 -3
  213. package/dist/components/semiotic-realtime.d.ts +3 -1
  214. package/dist/components/semiotic-recipes-core.d.ts +7 -5
  215. package/dist/components/semiotic-server-edge.d.ts +3 -2
  216. package/dist/components/semiotic-server.d.ts +3 -2
  217. package/dist/components/semiotic-themes-core.d.ts +5 -48
  218. package/dist/components/semiotic-utils-core.d.ts +11 -5
  219. package/dist/components/semiotic-utils-react.d.ts +2 -0
  220. package/dist/components/semiotic-xy.d.ts +4 -1
  221. package/dist/components/semiotic.d.ts +68 -25
  222. package/dist/components/server/animatedGif.d.ts +1 -1
  223. package/dist/components/server/renderEvidence.d.ts +25 -2
  224. package/dist/components/server/renderToStaticSVG.d.ts +15 -7
  225. package/dist/components/server/serverChartConfigShared.d.ts +8 -1
  226. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  227. package/dist/components/server/serverChartConfigsNetwork.d.ts +3 -3
  228. package/dist/components/server/serverChartConfigsNetworkChord.d.ts +2 -0
  229. package/dist/components/server/serverChartConfigsNetworkForce.d.ts +2 -0
  230. package/dist/components/server/serverChartConfigsNetworkHierarchy.d.ts +3 -0
  231. package/dist/components/server/serverChartConfigsXY.d.ts +3 -3
  232. package/dist/components/server/serverChartConfigsXYBubble.d.ts +5 -0
  233. package/dist/components/server/serverChartConfigsXYBump.d.ts +7 -0
  234. package/dist/components/server/serverChartConfigsXYScatter.d.ts +5 -0
  235. package/dist/components/server/staticAnnotationFallbacks.d.ts +10 -0
  236. package/dist/components/server/staticAnnotations.d.ts +28 -1
  237. package/dist/components/server/staticAxisTickLabel.d.ts +13 -0
  238. package/dist/components/server/staticLegend.d.ts +1 -1
  239. package/dist/components/server/staticLegendMargin.d.ts +41 -0
  240. package/dist/components/server/staticOrdinal.d.ts +8 -2
  241. package/dist/components/server/staticPhysics.d.ts +13 -1
  242. package/dist/components/server/staticPhysicsChrome.d.ts +20 -0
  243. package/dist/components/server/staticRawLegend.d.ts +15 -0
  244. package/dist/components/server/staticSVGChrome.d.ts +16 -55
  245. package/dist/components/server/staticXYAxes.d.ts +27 -0
  246. package/dist/components/server/staticXYAxisTicks.d.ts +39 -0
  247. package/dist/components/server/staticXYGrid.d.ts +11 -0
  248. package/dist/components/server/themeResolver.d.ts +5 -1
  249. package/dist/components/store/ThemeStore.d.ts +2 -98
  250. package/dist/components/store/designTokens.d.ts +1 -1
  251. package/dist/components/store/themeCSSVariables.d.ts +10 -0
  252. package/dist/components/store/themeCore.d.ts +91 -0
  253. package/dist/components/store/themePresets.d.ts +81 -0
  254. package/dist/components/store/themeSerialization.d.ts +2 -1
  255. package/dist/components/stream/AccessibleDataTable.d.ts +12 -14
  256. package/dist/components/stream/AccessibleTablePortalImpl.d.ts +6 -0
  257. package/dist/components/stream/GeoTileRenderer.d.ts +3 -0
  258. package/dist/components/stream/NetworkCanvasHitTester.d.ts +3 -1
  259. package/dist/components/stream/NetworkSSRFrame.d.ts +2 -1
  260. package/dist/components/stream/NetworkSVGOverlay.d.ts +3 -31
  261. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -0
  262. package/dist/components/stream/SVGChartTitle.d.ts +9 -0
  263. package/dist/components/stream/SVGOverlay.d.ts +1 -21
  264. package/dist/components/stream/SVGUnderlay.d.ts +24 -0
  265. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  266. package/dist/components/stream/StreamGeoFrame.d.ts +1 -1
  267. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -1
  268. package/dist/components/stream/StreamXYFrame.d.ts +1 -1
  269. package/dist/components/stream/accessibleDataRows.d.ts +11 -0
  270. package/dist/components/stream/accessibleDataTableModel.d.ts +40 -0
  271. package/dist/components/stream/accessibleTableTypes.d.ts +11 -0
  272. package/dist/components/stream/axisTickUtils.d.ts +19 -0
  273. package/dist/components/stream/canvasBackground.d.ts +10 -0
  274. package/dist/components/stream/canvasSetup.d.ts +24 -4
  275. package/dist/components/stream/frameCursorInteraction.d.ts +25 -0
  276. package/dist/components/stream/frameDefaultMargins.d.ts +37 -0
  277. package/dist/components/stream/frameGraphics.d.ts +18 -0
  278. package/dist/components/stream/frameGraphicsSubscription.d.ts +26 -0
  279. package/dist/components/stream/frameLegendOptions.d.ts +18 -0
  280. package/dist/components/stream/geoFrameCursorInteraction.d.ts +9 -0
  281. package/dist/components/stream/geoFrameHelpers.d.ts +29 -1
  282. package/dist/components/stream/geoTypes.d.ts +12 -11
  283. package/dist/components/stream/hitTarget.d.ts +61 -2
  284. package/dist/components/stream/moduleWorkerSession.d.ts +6 -0
  285. package/dist/components/stream/networkAnnotationAnchors.d.ts +37 -0
  286. package/dist/components/stream/networkCustomLayout.d.ts +2 -2
  287. package/dist/components/stream/networkFrameCursorInteraction.d.ts +12 -0
  288. package/dist/components/stream/networkFrameInteraction.d.ts +2 -0
  289. package/dist/components/stream/networkFramePaint.d.ts +15 -0
  290. package/dist/components/stream/networkPipelineConfig.d.ts +1 -1
  291. package/dist/components/stream/networkTypes.d.ts +32 -32
  292. package/dist/components/stream/normalizeXYData.d.ts +7 -0
  293. package/dist/components/stream/ordinalFrameCursorInteraction.d.ts +7 -0
  294. package/dist/components/stream/ordinalFrameInteraction.d.ts +29 -0
  295. package/dist/components/stream/ordinalSceneSVG.d.ts +10 -0
  296. package/dist/components/stream/ordinalTypes.d.ts +12 -4
  297. package/dist/components/stream/physics/PhysicsBodySpatialIndex.d.ts +9 -1
  298. package/dist/components/stream/physics/PhysicsCanvasTheme.d.ts +25 -0
  299. package/dist/components/stream/physics/PhysicsControllers.d.ts +0 -3
  300. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +4 -1
  301. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +3 -24
  302. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +9 -21
  303. package/dist/components/stream/physics/PhysicsSettledSVGElement.d.ts +37 -0
  304. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +7 -3
  305. package/dist/components/stream/physics/StreamPhysicsFrame.d.ts +1 -1
  306. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +25 -4
  307. package/dist/components/stream/physics/physicsAnnotationContext.d.ts +19 -0
  308. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +4 -0
  309. package/dist/components/stream/physics/physicsSettledChrome.d.ts +7 -0
  310. package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +32 -0
  311. package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +36 -0
  312. package/dist/components/stream/pipelineConfig.d.ts +8 -17
  313. package/dist/components/stream/pipelineDomainResolution.d.ts +2 -2
  314. package/dist/components/stream/renderBackend.d.ts +2 -0
  315. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +13 -2
  316. package/dist/components/stream/renderers/resolveCSSColor.d.ts +7 -0
  317. package/dist/components/stream/responsiveSize.d.ts +17 -0
  318. package/dist/components/stream/sceneCursor.d.ts +41 -0
  319. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +1 -1
  320. package/dist/components/stream/svgOverlayUtils.d.ts +22 -1
  321. package/dist/components/stream/types.d.ts +33 -13
  322. package/dist/components/stream/useCanvasFrameHost.d.ts +12 -1
  323. package/dist/components/stream/useFrame.d.ts +24 -1
  324. package/dist/components/stream/useResponsiveSize.d.ts +6 -1
  325. package/dist/components/stream/useStalenessCheck.d.ts +1 -1
  326. package/dist/components/stream/xyFrameAxisTypes.d.ts +20 -4
  327. package/dist/components/stream/xyFrameCursorInteraction.d.ts +6 -0
  328. package/dist/components/stream/xySceneBuilders/swarmScene.d.ts +1 -1
  329. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -26
  330. package/dist/components/types/legendTypes.d.ts +6 -0
  331. package/dist/components/types/marginType.d.ts +7 -8
  332. package/dist/controls.min.js +1 -1
  333. package/dist/controls.module.min.js +1 -1
  334. package/dist/forceLayoutWorker.js +1 -1
  335. package/dist/geo.min.js +1 -1
  336. package/dist/geo.module.min.js +1 -1
  337. package/dist/network.min.js +1 -1
  338. package/dist/network.module.min.js +1 -1
  339. package/dist/ordinal.min.js +1 -1
  340. package/dist/ordinal.module.min.js +1 -1
  341. package/dist/physics-matter.module.min.js +1 -1
  342. package/dist/physics-rapier.module.min.js +1 -1
  343. package/dist/physics.min.js +1 -1
  344. package/dist/physics.module.min.js +1 -1
  345. package/dist/physicsWorker.js +1 -1
  346. package/dist/processSankeyLayoutWorker.js +1 -1
  347. package/dist/realtime.min.js +1 -1
  348. package/dist/realtime.module.min.js +1 -1
  349. package/dist/rough.min.js +1 -1
  350. package/dist/rough.module.min.js +1 -1
  351. package/dist/semiotic-ai-core.d.ts +13 -4
  352. package/dist/semiotic-ai-core.min.js +1 -1
  353. package/dist/semiotic-ai-core.module.min.js +1 -1
  354. package/dist/semiotic-ai.d.ts +16 -9
  355. package/dist/semiotic-ai.min.js +1 -1
  356. package/dist/semiotic-ai.module.min.js +1 -1
  357. package/dist/semiotic-client-cjs-shared.min.js +1 -0
  358. package/dist/semiotic-client-glyph.module.min.js +2 -0
  359. package/dist/semiotic-client-responsive.module.min.js +2 -0
  360. package/dist/semiotic-client-shared.module.min.js +2 -0
  361. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -0
  362. package/dist/semiotic-data.min.js +1 -1
  363. package/dist/semiotic-data.module.min.js +1 -1
  364. package/dist/semiotic-experimental-auxiliary.module.min.js +2 -0
  365. package/dist/semiotic-experimental-node-auxiliary.module.min.js +2 -0
  366. package/dist/semiotic-experimental-node.module.min.js +2 -0
  367. package/dist/semiotic-experimental-react-shared.module.min.js +2 -0
  368. package/dist/semiotic-experimental-vacp.min.js +1 -1
  369. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  370. package/dist/semiotic-experimental.d.ts +1 -1
  371. package/dist/semiotic-experimental.min.js +1 -1
  372. package/dist/semiotic-experimental.module.min.js +1 -1
  373. package/dist/semiotic-geo.d.ts +4 -1
  374. package/dist/semiotic-network.d.ts +7 -4
  375. package/dist/semiotic-ordinal.d.ts +4 -1
  376. package/dist/semiotic-physics.d.ts +11 -4
  377. package/dist/semiotic-realtime-core.d.ts +11 -4
  378. package/dist/semiotic-realtime-core.min.js +2 -1
  379. package/dist/semiotic-realtime-core.module.min.js +2 -1
  380. package/dist/semiotic-realtime-react.d.ts +4 -3
  381. package/dist/semiotic-realtime-react.min.js +1 -1
  382. package/dist/semiotic-realtime-react.module.min.js +1 -1
  383. package/dist/semiotic-realtime.d.ts +3 -1
  384. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -0
  385. package/dist/semiotic-recipes-core.d.ts +7 -5
  386. package/dist/semiotic-recipes-core.min.js +9 -1
  387. package/dist/semiotic-recipes-core.module.min.js +1 -1
  388. package/dist/semiotic-recipes-geo-cjs.min.js +1 -0
  389. package/dist/semiotic-recipes-react.min.js +1 -1
  390. package/dist/semiotic-recipes-react.module.min.js +1 -1
  391. package/dist/semiotic-recipes.min.js +7 -1
  392. package/dist/semiotic-recipes.module.min.js +2 -1
  393. package/dist/semiotic-server-edge-node.module.min.js +1 -0
  394. package/dist/semiotic-server-edge.d.ts +3 -2
  395. package/dist/semiotic-server-edge.min.js +1 -1
  396. package/dist/semiotic-server-edge.module.min.js +1 -1
  397. package/dist/semiotic-server-node.min.js +1 -1
  398. package/dist/semiotic-server-node.module.min.js +1 -1
  399. package/dist/semiotic-server.d.ts +3 -2
  400. package/dist/semiotic-themes-core.d.ts +5 -48
  401. package/dist/semiotic-themes-core.min.js +1 -1
  402. package/dist/semiotic-themes-core.module.min.js +1 -1
  403. package/dist/semiotic-themes-react.min.js +1 -1
  404. package/dist/semiotic-themes-react.module.min.js +1 -1
  405. package/dist/semiotic-themes.min.js +1 -1
  406. package/dist/semiotic-themes.module.min.js +1 -1
  407. package/dist/semiotic-utils-core.d.ts +11 -5
  408. package/dist/semiotic-utils-core.min.js +1 -1
  409. package/dist/semiotic-utils-core.module.min.js +1 -1
  410. package/dist/semiotic-utils-react.d.ts +2 -0
  411. package/dist/semiotic-utils-react.min.js +1 -1
  412. package/dist/semiotic-utils-react.module.min.js +1 -1
  413. package/dist/semiotic-utils.min.js +2 -1
  414. package/dist/semiotic-utils.module.min.js +2 -1
  415. package/dist/semiotic-value.min.js +1 -1
  416. package/dist/semiotic-value.module.min.js +1 -1
  417. package/dist/semiotic-xy.d.ts +4 -1
  418. package/dist/semiotic.d.ts +68 -25
  419. package/dist/semiotic.min.js +1 -1
  420. package/dist/semiotic.module.min.js +1 -1
  421. package/dist/server.min.js +1 -1
  422. package/dist/server.module.min.js +1 -1
  423. package/dist/xy.min.js +1 -1
  424. package/dist/xy.module.min.js +1 -1
  425. package/package.json +53 -19
  426. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +0 -20
  427. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +0 -2
  428. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +0 -1
  429. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +0 -2
  430. package/dist/chunk-chartContainerDataAudit-IQ3NBN3Q.module.min.js +0 -2
  431. package/dist/chunk-chunk-2B3AIKUZ.module.min.js +0 -2
  432. package/dist/chunk-chunk-2CXCXRB4.module.min.js +0 -1
  433. package/dist/chunk-chunk-3GCILWPB.module.min.js +0 -2
  434. package/dist/chunk-chunk-46KRGJQP.module.min.js +0 -1
  435. package/dist/chunk-chunk-4ITOQRXM.module.min.js +0 -2
  436. package/dist/chunk-chunk-4MLLQUGW.module.min.js +0 -2
  437. package/dist/chunk-chunk-57RBPDBQ.module.min.js +0 -2
  438. package/dist/chunk-chunk-5UKL5W76.module.min.js +0 -2
  439. package/dist/chunk-chunk-5VVNW5AZ.module.min.js +0 -1
  440. package/dist/chunk-chunk-66PCWJUG.module.min.js +0 -1
  441. package/dist/chunk-chunk-6V5VQVCT.module.min.js +0 -2
  442. package/dist/chunk-chunk-7LE56WAE.module.min.js +0 -2
  443. package/dist/chunk-chunk-7T25U75Z.module.min.js +0 -2
  444. package/dist/chunk-chunk-ACLDBMRH.module.min.js +0 -2
  445. package/dist/chunk-chunk-AF53TBSN.module.min.js +0 -2
  446. package/dist/chunk-chunk-BTZYH2IE.module.min.js +0 -1
  447. package/dist/chunk-chunk-BWV55BZK.module.min.js +0 -2
  448. package/dist/chunk-chunk-BZNOAHJV.module.min.js +0 -2
  449. package/dist/chunk-chunk-CD6PVVS3.module.min.js +0 -2
  450. package/dist/chunk-chunk-DTSNLGRK.module.min.js +0 -2
  451. package/dist/chunk-chunk-FC3NZWYR.module.min.js +0 -2
  452. package/dist/chunk-chunk-FEPXDKJP.module.min.js +0 -1
  453. package/dist/chunk-chunk-FJ76HWQZ.module.min.js +0 -1
  454. package/dist/chunk-chunk-FRGBMTZR.module.min.js +0 -1
  455. package/dist/chunk-chunk-G75OPF5N.module.min.js +0 -2
  456. package/dist/chunk-chunk-H5IFO6CU.module.min.js +0 -2
  457. package/dist/chunk-chunk-HADHLMY5.module.min.js +0 -1
  458. package/dist/chunk-chunk-HBFA4NN6.module.min.js +0 -1
  459. package/dist/chunk-chunk-HCNDE26Q.module.min.js +0 -2
  460. package/dist/chunk-chunk-IY7RYD4S.module.min.js +0 -1
  461. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  462. package/dist/chunk-chunk-J3XWETBJ.module.min.js +0 -2
  463. package/dist/chunk-chunk-JJ4BSUYL.module.min.js +0 -2
  464. package/dist/chunk-chunk-JRHXQGEV.module.min.js +0 -2
  465. package/dist/chunk-chunk-KTWEBFMX.module.min.js +0 -2
  466. package/dist/chunk-chunk-L6FFYGYS.module.min.js +0 -1
  467. package/dist/chunk-chunk-LJDH3WV3.module.min.js +0 -2
  468. package/dist/chunk-chunk-LSJUXBMF.module.min.js +0 -1
  469. package/dist/chunk-chunk-N3Q33XCB.module.min.js +0 -2
  470. package/dist/chunk-chunk-NWIGA3UK.module.min.js +0 -1
  471. package/dist/chunk-chunk-OG3TTJGJ.module.min.js +0 -2
  472. package/dist/chunk-chunk-OZK46A5U.module.min.js +0 -1
  473. package/dist/chunk-chunk-PMR47KRY.module.min.js +0 -2
  474. package/dist/chunk-chunk-Q2YADC2V.module.min.js +0 -2
  475. package/dist/chunk-chunk-QQJNG23C.module.min.js +0 -2
  476. package/dist/chunk-chunk-RGJ6TKAH.module.min.js +0 -2
  477. package/dist/chunk-chunk-ROP4HI7H.module.min.js +0 -2
  478. package/dist/chunk-chunk-SFLUSZ73.module.min.js +0 -2
  479. package/dist/chunk-chunk-TCMHJWFJ.module.min.js +0 -1
  480. package/dist/chunk-chunk-TSCFL235.module.min.js +0 -1
  481. package/dist/chunk-chunk-U66USBWU.module.min.js +0 -1
  482. package/dist/chunk-chunk-UEZ6SHW5.module.min.js +0 -2
  483. package/dist/chunk-chunk-UOQRPGPK.module.min.js +0 -2
  484. package/dist/chunk-chunk-VUWYT7DY.module.min.js +0 -2
  485. package/dist/chunk-chunk-W5HWGQMD.module.min.js +0 -2
  486. package/dist/chunk-chunk-WFHZHWT7.module.min.js +0 -1
  487. package/dist/chunk-chunk-WGROBM3I.module.min.js +0 -2
  488. package/dist/chunk-chunk-WSDJFBKX.module.min.js +0 -2
  489. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +0 -2
  490. package/dist/chunk-chunk-YWZB3KPI.module.min.js +0 -2
  491. package/dist/chunk-statisticalOverlays-HMYYSGPE.module.min.js +0 -2
  492. package/dist/components/stream/test-utils/frameScheduler.d.ts +0 -12
  493. package/dist/components/stream/test-utils/revisionConsumption.d.ts +0 -13
  494. package/dist/test-utils/canvasMock.d.ts +0 -86
  495. package/dist/test-utils/capturedFrameProps.d.ts +0 -67
  496. package/dist/test-utils/frameMock.d.ts +0 -81
  497. package/dist/test-utils/ordinalFixtures.d.ts +0 -48
  498. /package/dist/{chunk-chunk-JJ2OOIET.module.min.js → c-GGISSW5E.min.js} +0 -0
  499. /package/dist/{chunk-chunk-SIRIJ3DY.module.min.js → c-N4G2L7ID.min.js} +0 -0
  500. /package/dist/{chunk-chunk-CA3YDW6F.module.min.js → c-S6U5CGT5.min.js} +0 -0
  501. /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),I=(0,p.useRef)(null),P=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,I.current=null,void S.current(null);const r=t.x.domain(),s=t.y.domain(),a=I.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,I.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 I.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};I.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&&I.current))return;if(!b.current)return;if("y"===i)return;const e=I.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,I.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,I.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};I.current=t,S.current(t)}},[s,g,i,l,c]),(0,f.jsxs)("svg",{ref:b,width:n,height:o,...P.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,f.jsx)("title",{children:P.svgProps["aria-label"]}),(0,f.jsx)("desc",{id:P.descriptionId,children:P.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 I(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 P(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 N(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 $(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 D(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]=I(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=N(p);if(i){const{se:d,meanX:h,ssX:f}=$(p,i),g=D(a),b=P(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,Ie,Pe,Re,Te,_e,Le,Ne,$e,De,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"}]},Ie={fields:[Ce],aggregates:[{kind:"normalized-total",role:"value",groupAccessor:"categoryAccessor",defaultGroupAccessor:"category",whenProp:"normalize"}]},Pe={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"}]},Ne={fields:[Ce]},$e={fields:[{...Ce,dataProp:"edges",requirements:["finite","non-negative"],missingValue:1}]},De={LineChart:Ae,AreaChart:Ae,BumpChart:Ae,Scatterplot:Te,ConnectedScatterplot:ke,QuadrantChart:Te,MinimapChart:Ae,BubbleChart:Re,StackedAreaChart:Pe,DifferenceChart:Le,CandlestickChart:_e,Heatmap:Ne,BarChart:{fields:[Ce]},GroupedBarChart:{fields:[Ce]},StackedBarChart:Ie,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:$e,ChordDiagram:$e,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)??De[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:()=>VN,AreaChart:()=>Wm,AreaChartCapability:()=>pE,BUILT_IN_AUDIENCES:()=>NF,BUILT_IN_INTENT_IDS:()=>EH,BarChart:()=>Ng,BarChartCapability:()=>IE,BigNumber:()=>C_,BoxPlot:()=>Kg,BoxPlotCapability:()=>zE,BubbleChart:()=>hy,BubbleChartCapability:()=>bE,BumpChart:()=>Em,BumpChartCapability:()=>mE,CANONICAL_FIXTURES:()=>nz,CandlestickChart:()=>sf,CandlestickChartCapability:()=>SE,CategoryColorProvider:()=>oh,ChainReactionChart:()=>m_,ChartContainer:()=>aD,ChartGrid:()=>wD,ChartRecipe:()=>vH,ChordDiagram:()=>Ww,ChordDiagramCapability:()=>VE,ChoroplethMapCapability:()=>eO,CirclePack:()=>QS,CirclePackCapability:()=>ZE,CollisionSwarmChart:()=>aP,ConnectedScatterplot:()=>ly,ConnectedScatterplotCapability:()=>gE,ContextLayout:()=>AD,CrucibleChart:()=>YT,DEFAULT_LIFECYCLE_THRESHOLDS:()=>Dn,DEFAULT_SCALE_THRESHOLDS:()=>QB,DetailsPanel:()=>ID,DifferenceChart:()=>Vm,DifferenceChartCapability:()=>kE,DistanceCartogramCapability:()=>oO,DonutChart:()=>yb,DonutChartCapability:()=>LE,DotPlot:()=>sb,DotPlotCapability:()=>TE,EventDropChart:()=>VI,FlowMapCapability:()=>nO,ForceDirectedGraph:()=>Fw,ForceDirectedGraphCapability:()=>GE,FunnelChart:()=>jb,FunnelChartCapability:()=>$E,GaltonBoardChart:()=>WI,GaugeChart:()=>Ab,GaugeChartCapability:()=>DE,GauntletChart:()=>vR,GroupedBarChart:()=>Fg,GroupedBarChartCapability:()=>PE,Heatmap:()=>fy,HeatmapCapability:()=>AE,Histogram:()=>eb,HistogramCapability:()=>FE,IntentMark:()=>_H,LikertChart:()=>Hb,LikertChartCapability:()=>EE,LineChart:()=>ym,LineChartCapability:()=>hE,LinkedCharts:()=>ap,MinimapChart:()=>Fy,MinimapChartCapability:()=>wE,MobileAnnotationCalloutList:()=>rW,MobileChartContainer:()=>dD,MobileStandardControls:()=>s$,MultiAxisLineChart:()=>nf,MultiAxisLineChartCapability:()=>xE,MultiLineTooltip:()=>ru,OrbitDiagram:()=>tA,OrbitDiagramCapability:()=>JE,PacketFlowChart:()=>xP,PhysicsCustomChart:()=>JI,PieChart:()=>hb,PieChartCapability:()=>_E,ProcessFlowChart:()=>RP,ProcessSankey:()=>HS,ProcessSankeyCapability:()=>XE,ProportionalSymbolMapCapability:()=>tO,QuadrantChart:()=>Xy,QuadrantChartCapability:()=>vE,RealtimeHeatmap:()=>HA,RealtimeHistogram:()=>_A,RealtimeLineChart:()=>IA,RealtimeSwarmChart:()=>DA,RealtimeWaterfallChart:()=>OA,RidgelinePlot:()=>lb,RidgelinePlotCapability:()=>qE,SankeyDiagram:()=>Yw,SankeyDiagramCapability:()=>YE,Scatterplot:()=>iy,ScatterplotCapability:()=>fE,ScatterplotMatrix:()=>_y,SmallMultipleChart:()=>bD,StackedAreaChart:()=>Km,StackedAreaChartCapability:()=>yE,StackedBarChart:()=>Bg,StackedBarChartCapability:()=>RE,SwarmPlot:()=>Gg,SwarmPlotCapability:()=>HE,SwimlaneChart:()=>Gb,SwimlaneChartCapability:()=>OE,TemporalHistogram:()=>LA,ThemeProvider:()=>Rh,TooltipProvider:()=>j_,TreeDiagram:()=>GS,TreeDiagramCapability:()=>UE,Treemap:()=>XS,TreemapCapability:()=>QE,UnitPileChart:()=>oP,ViolinPlot:()=>ob,ViolinPlotCapability:()=>WE,accessibilityCaveats:()=>cB,analystPersona:()=>_F,annotationFreshnessFor:()=>La,annotationStableId:()=>Us,applyAnnotationLifecycle:()=>Ea,applyAnnotationStatus:()=>qa,applyAudienceBias:()=>bO,applyScaleBias:()=>uE,auditAccessibility:()=>aB,auditData:()=>at,auditMobileVisualization:()=>O$,auditObservedScene:()=>jH,auditVisualizationControls:()=>E_,bandFromAge:()=>Bn,buildNavigationTree:()=>aN,buildReaderGrounding:()=>qO,buildRecipeNavigationTree:()=>sN,chartGenerationTool:()=>mF,clampMobileRange:()=>KN,classifyCardinalityBand:()=>tE,classifyFieldBand:()=>nE,classifyRowBand:()=>eE,clearVariantDiscovery:()=>ZH,communicativeActForIntent:()=>GL,compareBands:()=>oE,computeAnnotationFreshness:()=>Na,computeEffectiveScale:()=>sE,configToJSX:()=>ML,copyConfig:()=>CL,countNodes:()=>lN,createChartToolHandler:()=>vF,createIndexedDBConversationArcSink:()=>LN,createLocalStorageConversationArcSink:()=>_N,createWebhookConversationArcSink:()=>NN,currentTimestamp:()=>Pa,dataQualityToAnnotations:()=>rF,dataScientistPersona:()=>LF,defineChartRecipe:()=>O_,describeChart:()=>nN,describeRecipeChart:()=>NL,deserializeSelections:()=>pB,diagnoseConfig:()=>JD,diagnoseTokenEncoding:()=>DD,diffProfile:()=>VF,disableConversationArc:()=>HN,effectiveFamiliarity:()=>vO,enableConversationArc:()=>zN,evaluateVariantProposal:()=>UH,executivePersona:()=>TF,explainCapabilityFit:()=>IO,exportChart:()=>P_,filterAnnotationsByStatus:()=>Wa,flattenVisible:()=>cN,formatAccessibilityAudit:()=>dB,formatDataAudit:()=>Ge,formatMobileVisualizationAudit:()=>H$,fromConfig:()=>kL,fromDbtArtifacts:()=>aF,fromGreatExpectations:()=>uF,fromURL:()=>AL,fromVegaLite:()=>vB,getCapabilities:()=>dO,getCapability:()=>hO,getChartRecipe:()=>tL,getConversationArcStore:()=>WN,getIntent:()=>$H,getRecipeLayout:()=>iL,getRegisteredVariantDiscovery:()=>QH,getStreamCapabilities:()=>OF,inferIntent:()=>IF,intentManifestFromRecipe:()=>RH,isJsonSafe:()=>H_,isRegisteredRecipeLayout:()=>z_,listChartRecipes:()=>nL,listIntents:()=>DH,loadConversationArc:()=>$N,mobileVisualizationCaveats:()=>W$,normalizeTokenEncoding:()=>$D,prepareChart:()=>pF,profileData:()=>KB,profileNumericFields:()=>We,proposeVariant:()=>XH,rankBumpData:()=>_m,receivabilityBias:()=>gO,recipeToChartCapability:()=>K_,recordAnnotationStatusChange:()=>EN,recordAudienceChange:()=>BN,registerChartCapability:()=>lO,registerChartRecipe:()=>J_,registerConversationArcSink:()=>TN,registerIntent:()=>BH,registerRecipeLayout:()=>oL,registerStreamChartCapability:()=>BF,registerVariantDiscovery:()=>KH,repairChartConfig:()=>dF,replayConversationArc:()=>DN,resolveCardinalityToNumber:()=>iE,resolveChartRecipe:()=>sL,resolveCommunicativeAct:()=>YL,resolveRecipeRoleField:()=>U_,resolveResponsiveRules:()=>Nh,resolveRowsToNumber:()=>rE,responsiveRuleMatches:()=>Lh,runQualityScorecard:()=>XF,scaleHints:()=>dE,scoreChart:()=>PO,serializeSelections:()=>hB,stretchFamiliarityCeiling:()=>xO,subscribeToConversationArcChange:()=>RN,suggestCharts:()=>jO,suggestChartsGrouped:()=>RO,suggestDashboard:()=>RF,suggestStreamCharts:()=>WF,suggestStretchCharts:()=>PF,suggestTokenEncoding:()=>OD,summarizeArc:()=>tW,summarizeData:()=>IB,summarizeIntentManifest:()=>PH,toAnthropicTool:()=>yF,toConfig:()=>wL,toDataAuditNotifications:()=>Ve,toOpenAIResponsesTool:()=>bF,toOpenAITool:()=>fF,toURL:()=>SL,tokenTaskIntentToCapabilityIntents:()=>ED,unregisterChartCapability:()=>uO,unregisterChartRecipe:()=>eL,unregisterRecipeLayout:()=>rL,unregisterStreamChartCapability:()=>EF,useBrushSelection:()=>vh,useCategoryColors:()=>rh,useChartFocus:()=>QO,useChartInterrogation:()=>XO,useChartObserver:()=>Xh,useChartSuggestions:()=>az,useConversationArc:()=>nW,useFilteredData:()=>xh,useLinkedChartsActive:()=>Zh,useLinkedHover:()=>gh,useMobileRangeControls:()=>ZN,useNavigationSync:()=>MF,useSelection:()=>yh,useSelectionActions:()=>fh,useTheme:()=>Th,validateChartRecipe:()=>F_,validateProps:()=>_D,withCurrentProvenance:()=>Ra,withProvenance:()=>Ia,zoomMobileRange:()=>QN}),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=It(e);return[function({children:t,initialState:o}){const r=(0,Ct.useRef)(o),i=(0,Ct.useMemo)(()=>It(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 It(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(Pt(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 Pt(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}},Nt={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}},$t={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 Dt(e,t){if("light"===t)return Lt;if("dark"===t)return Nt;if("high-contrast"===t)return $t;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?Nt: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:Dt(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 In(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 Pn(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=>Pn(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 Nn(e,t,n){return e+(t-e)*n}function $n(){return"undefined"!=typeof performance?performance.now():Date.now()}var Dn={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??Dn.fresh)>e?"fresh":t*(n.aging??Dn.aging)>e?"aging":t*(n.stale??Dn.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 Io(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 Po(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 No(){return this.updateResults.last}function $o(){return this.updateResults.last}function Do(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:No,getUpdateSnapshot:$o,subscribeUpdateResult:Do,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),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?.()??$n()}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))}}Po(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.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:o,getY:r}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const 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:Io(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Io(t.yScaleType,r,[s,n.width-s]),y:(0,Mo.scaleLinear)().domain(o).range(e)}}var a;return{x:Io(t.xScaleType,o,[s,n.width-s]),y:Io(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=Io,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,I=e.config.heatmapValueFormat,P=[];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];P.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:I}:void 0),i,e))}return P}(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=$n()){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=Nn(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=Nn(n.x,e._targetX,i),e.y=Nn(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Nn(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=Nn(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=Nn(n.x,e._targetX,i),e.y=Nn(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Nn(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=Nn(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=Nn(n.x,e._targetX,i),e.y=Nn(n.y,e._targetY,i),void 0!==n.w&&(e.w=Nn(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Nn(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:Nn(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=Nn(n.x,e._targetX,i),e.y=Nn(n.y,e._targetY,i),void 0!==n.w&&(e.w=Nn(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Nn(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:Nn(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=Nn(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Nn(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Nn(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Nn(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Nn(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Nn(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]=Nn(t[o][0],n[o][0],i),e.path[o][1]=Nn(t[o][1],n[o][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Nn(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]=Nn(t[n][0],o[n][0],i),e.topPath[n][1]=Nn(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]=Nn(n[t][0],r[t][0],i),e.bottomPath[t][1]=Nn(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 Ir(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 Pr(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],Nr=[.5,.5];function $r(e,t){const[n,o]=e.viewBox??Lr,[r,i]=e.anchor??Nr,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 Dr(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=$r(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:Dr(s.fill,n,o);l&&(e.fillStyle=i(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:Dr(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);Pr(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>Pr(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>Pr(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>Pr(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=Ir(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=Ir(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 Ii=require("react"),Pi={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:{...Pi,...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,Ii.useRef)("fresh");(0,Ii.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 Ni({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 $i=require("react"),Di=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)),I=A.length;return{items:y,offset:j,totalRows:I,totalHeight:I*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-"+Di.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]=Di.useState(0),[y,f]=Di.useState(0),g=Di.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=P(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 Is(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 Ps(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)(Is,{"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)(Is,{"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 Ns(e){return null==e?null:e+""}function $s(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Ds(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 $s(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?$s(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Ns(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Ns(e.pointId)===o);if(r)return $s(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Ns(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:$s(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 $s(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=Ds(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)(Ps,{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]=I(i),[l,u]=I(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)(Ps,{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=N(c);if(!e)return null;l=e}const u=c.length,{se:d,meanX:h,ssX:p}=$(c,l),m=D(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=Ds(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=Ds(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=[],I=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let P=!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?Ds(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,I,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 P=!0,{...e,dx:h.dx,dy:h.dy,...f?{connector:f}:{}}}),T=P?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 N;return N=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}(N,M):N}function Ia(e,t){const n={...e};return t.provenance&&(n.provenance=t.provenance),t.lifecycle&&(n.lifecycle=t.lifecycle),n}function Pa(){return(new Date).toISOString()}function Ra(e,t={}){const n=e.provenance;return{...e,provenance:{...n,...t,createdAt:t.createdAt??n?.createdAt??Pa()}}}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 Na(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 $a={fresh:null,aging:.55,stale:.35,expired:.2},Da={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,$a,e),a=Ba(t.strokeDasharray,Da,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,$i.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||uc,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??nc(s.x,i,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return dc(d,Math.max(55,p+8))},[s,c,u,t,h]),m=(0,$i.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||uc,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o);return dc((e?.tickValues??nc(s.y,i,h)).map(e=>({value:e,pixel:s.y(e),label:t(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:I,onAnnotationActivate:P,onObservation:R,chartId:T,chartType:_,autoPlaceAnnotations:L,svgAnnotationRules:N,xAccessor:$,yAccessor:D,annotationData:B,pointNodes:E,curve:O,underlayRendered:F,canvasObscuresUnderlay:z=!0,linkedCrosshairName:H,linkedCrosshairSourceId:W,children:q}=e,G=Xs({onAnnotationActivate:P,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,$i.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||uc,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===m?Math.max(2,r):Math.min(r,o),l=e?.tickValues??nc(s.x,i,m),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),y=e?.autoRotate?Math.max(20,Math.min(p+8,55)):Math.max(55,p+8);let f=dc(d,y);if(f.length>1&&(f=f.filter((e,t)=>0===t||e.label+""!=f[t-1].label+"")),e?.includeMax&&f.length>0&&"exact"!==m&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),o=f[f.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,f.length,u);y>t-o&&f.length>1&&(f=f.slice(0,-1)),f.push({value:e,pixel:t,label:r})}}return f},[a,s,c,h,t,m]),K=(0,$i.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,$i.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||p||uc,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===m?Math.max(2,r):Math.min(r,o);let l=dc((e?.tickValues??nc(s.y,i,m)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==m&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),o=l[l.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,p,n,m]),Z=(0,$i.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||uc,o=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return dc((e.tickValues??nc(s.y,"exact"===m?Math.max(2,r):Math.min(r,o),m)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,p,n,m]),J=(0,$i.useRef)(new Map),ee=(0,$i.useRef)(I?.length??0),te=I?.length??0;ee.current!==te&&(ee.current=te,J.current=new Map);const ne=(0,$i.useMemo)(()=>{if(!I||0===I.length)return null;const e=Wa(I),o=ra(0,G),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:$,yAccessor:D,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,N,r)},[I,L,N,t,n,$,D,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,$i.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=g?12:18,v=n+(g?58:40),x={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},k={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=o?.tickAnchor,A=e?.tickAnchor,C=ic(U),M=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:b,textAnchor:g?"end":oc(S,e.pixel===C.min,e.pixel===C.max),fontWeight:o?600:400,fill:y,fontSize:o?13:12,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:x},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",...x},children:e.label})})]},"xtick-"+t)}),l&&(0,cc.jsx)("text",{x:t/2,y:v,textAnchor:"middle",fill:f,fontSize:12,className:"semiotic-axis-label",style:{userSelect:"none",...k},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(A,e.pixel===M.min,e.pixel===M.max),fontWeight:n?600:400,fill:y,fontSize:n?13:12,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:x},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",...x},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",...k},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?w:x},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",...x},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",...k},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=$r(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:Dr(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Dr(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"),Ic=require("react/jsx-runtime"),Pc=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 Nc(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 Nc({...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 Nc({...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,I=i?0:f-y>Math.PI?1:0;let P="";if(d)P+=`M${x.x},${x.y}`,P+=` A${s},${s} 0 0 1 ${g.x},${g.y}`;else{const e=Lc(n,o);P+=`M${e.x},${e.y}`}if(h)P+=` A${n},${n} 0 ${j} 1 ${b.x},${b.y}`,P+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=Lc(n,r);P+=` A${n},${n} 0 ${j} 1 ${e.x},${e.y}`}if(i)P+=" L0,0";else{if(h)P+=` L${M.x},${M.y}`,P+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=Lc(t,r);P+=` L${e.x},${e.y}`}if(d)P+=` A${t},${t} 0 ${I} 0 ${S.x},${S.y}`,P+=` A${s},${s} 0 0 1 ${C.x},${C.y}`;else{const e=Lc(t,o);P+=` A${t},${t} 0 ${I} 0 ${e.x},${e.y}`}}return P+=" Z",P}function $c(e){const t=Nc({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:Nc({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:o[r]})}return{clipPath:t,slices:n}}var Dc=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,Dc.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,Dc.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,Dc.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",Il={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"},Pl={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))"},Nl={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},$l={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 Dl({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:Il,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:Pl,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:Nl,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:$l,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),I=k.slice(0,j),P=k.length-j;return(0,xl.jsxs)("div",{ref:p,id:o,className:jl,tabIndex:-1,onBlur:y,style:Il,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:Pl,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:Nl,children:P>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:I.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))})]}),P>0&&(0,xl.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:$l,children:["Show ",Math.min(25,P)," more"," ",1===P?"node":"nodes"," (",P," 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(){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 su(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&&("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 au=require("react/jsx-runtime");function cu({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,au.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 lu=d(require("react")),uu=require("react"),du=require("react");function hu(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 pu(){const[e,t]=(0,du.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,du.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),hu(e,e=>t(e.matches))},[]),e}var mu=require("react");function yu(e,t,n){const o=(0,mu.useRef)(null),[r,i]=(0,mu.useState)(null);return(0,mu.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 fu=()=>"undefined"!=typeof performance?performance.now():Date.now();function gu(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 bu(e,t){const n=e();return Number.isFinite(n)?n:t}var vu=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??fu,this.lastWallTime=bu(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=bu(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??fu;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=bu(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:gu(n)))}},xu="undefined"==typeof window?uu.useEffect:uu.useLayoutEffect,wu={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function ku(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Su(e){const t=pu(),n=(0,uu.useRef)(t);n.current=t;const[o,r]=yu(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,uu.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=ku(e.foregroundGraphics,r,a),d=ku(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-"+lu.useId(),f=(0,uu.useRef)(null);if(!f.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;f.current=new vu({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,uu.useRef)(null),v=(0,uu.useRef)(e.frameScheduler??wu);v.current=e.frameScheduler??wu;const x=(0,uu.useRef)(null),w=(0,uu.useRef)(!1),k=(0,uu.useRef)(()=>{}),S=(0,uu.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,uu.useCallback)(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);xu(()=>{g.setPaused(!0===e.paused)},[g,e.paused]),(0,uu.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,uu.useEffect)(()=>()=>{A()},[A]);const C=(0,uu.useRef)(()=>{}),M=(0,uu.useRef)(()=>{}),j=(0,uu.useRef)(null),I=(0,uu.useRef)(null),P=(0,uu.useRef)(null),R=(0,uu.useCallback)(()=>{const e=j.current;j.current=null,e&&C.current(e)},[]),T=(0,uu.useCallback)(e=>{if(j.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===I.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,I.current=null,P.current=null,R()});t||(I.current=n,P.current=e)}},[R]),_=(0,uu.useCallback)(()=>{j.current=null,null!==I.current&&((P.current??v.current).cancelAnimationFrame(I.current),I.current=null,P.current=null),M.current()},[]);(0,uu.useEffect)(()=>()=>{j.current=null,null!==I.current&&((P.current??v.current).cancelAnimationFrame(I.current),I.current=null,P.current=null)},[]);const L=e.themeDirtyRef;return xu(()=>{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 Au=require("react"),Cu=require("react/jsx-runtime");function Mu(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,scheduleRender:i}=e,s=(0,Au.useRef)(null),a=(0,Au.useRef)(null),c=(0,Au.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,Au.useEffect)(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,i()):t()})},[t,n,o,r,i]),(0,Au.useEffect)(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.canvasPaintInvalidator?e.canvasPaintInvalidator():e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function ju({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?(0,Cu.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:(0,Cu.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Iu(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 Pu(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}function Ru(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 Tu(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}var _u=require("react");function Lu(e,t,n,o){const r=(0,_u.useRef)({accessor:t,onChange:n,readData:o}),i=(0,_u.useRef)([]);return r.current={accessor:t,onChange:n,readData:o},(0,_u.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 Nu(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 $u(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 Du=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Bu=3156e7;function Eu(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")}`}:Bu>t?e=>{const t=new Date(e);return`${Du[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Bu>t?e=>{const t=new Date(e);return`${Du[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Ou(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 Fu=require("d3-shape");function zu(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 Hu=(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){zu(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,Fu.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,Fu.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 Wu(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function qu(e,t,n=.3){Wu(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 Gu(e,t,n=.6){if(!Wu(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 Yu(e,t,n,o=.35){Wu(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Vu=require("d3-shape");function Xu(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,Vu.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 Uu(e,t){const n=si(t.curve);if(e.beginPath(),n)(0,Vu.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 Ku=(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(Xu(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&&(Xu(e,t),Yu(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,Uu(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,Uu(e,t),e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Qu=(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()),Gu(e,n)}finally{e.restore()}}},Zu=new Map;function Ju(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=Zu.get(o);return r||(r=new Path2D(mo(e,t)),Zu.size>256&&Zu.clear(),Zu.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 ed=(e,t)=>{const n=e.globalAlpha;for(const o of t)"symbol"===o.type&&Ju(e,o,o.x,o.y,n,"#4e79a7");e.globalAlpha=n};function td(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=$r(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 nd=(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&td(e,o,o.x,o.y,n);e.globalAlpha=n};function od(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 rd(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 id(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 sd=(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)ad(e,t);else if(t.cornerRadii&&gc(t.cornerRadii))e.fillStyle=rd(e,t),od(e,t),e.fill(),id(e,t)&&e.stroke();else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=rd(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(),id(e,t)&&e.stroke()}else e.fillStyle=rd(e,t),e.fillRect(t.x,t.y,t.w,t.h),id(e,t)&&e.strokeRect(t.x,t.y,t.w,t.h);qu(e,t),e.globalAlpha=1}};function ad(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 cd(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 ld(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var ud=(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)),qu(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):ld(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=cd(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}},dd=(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()}},hd={line:[Ku,Hu,Qu],area:[Ku,Qu],stackedarea:[Ku,Qu],scatter:[Qu,ed],bubble:[Qu,ed],heatmap:[ud],bar:[sd],swarm:[Qu],waterfall:[(e,t,n,o)=>{sd(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:[dd],mixed:[Ku,Hu,Qu],custom:[Ku,sd,ud,Hu,Qu,ed,nd,dd]},pd=new Set;function md(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 yd(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;pd.has(n)||(pd.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function fd(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=md(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||(yd(n.id,e.type??"unknown"),i([e]))}a()}function gd(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=md(o,t);if(!i)return r();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(yd(i.id,t.type??"unknown"),r())}function bd(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 vd=require("react/jsx-runtime");function xd(e){return"string"==typeof e?e:"value"}function wd(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function kd(e,t){if(!t)return wd(e);try{const n=t(e);return null==n?wd(e):n}catch{return wd(e)}}function Sd(e,t){return"function"==typeof t?t(e):e[t]}function Ad(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 Cd(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?kd(Sd(o,t.accessor),t.format):null;return(0,vd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=r&&(0,vd.jsx)("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((e,t)=>{const n=kd(Sd(o,e.accessor),e.format);return(0,vd.jsxs)("div",{style:t>0?{marginTop:2}:void 0,children:[(0,vd.jsxs)("span",{style:{opacity:.7},children:[e.label,": "]}),(0,vd.jsx)("span",{children:n})]},t)})]})}}function Md({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=Sd(a,e),l=Sd(a,t),u=n?Sd(a,n):void 0;return(0,vd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,vd.jsx)("div",{style:{fontWeight:"bold"},children:wd(c)}),(0,vd.jsx)("div",{style:{marginTop:4},children:kd(l,i)}),null!=u&&(0,vd.jsxs)("div",{style:{marginTop:2,opacity:.8},children:[o||xd(n),": ",wd(u)]})]})}}var jd=require("react/jsx-runtime");function Id(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Pd({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,jd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=e.title&&(0,jd.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,jd.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,jd.jsx)("span",{style:{fontWeight:600},children:Id(e.value)})]},e.key))]})}return(0,jd.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,jd.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Id(n)}),(0,jd.jsx)("div",{style:{opacity:.7,fontSize:11},children:Id(o)})]})}function Rd(e){return"touch"===e?"touch":"pointer"}function Td(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 _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:"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 Ld(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}))}Pd.ownsChrome=!0;var Nd=require("react");function $d({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){const i=!(!e&&!n),s=!(!t&&!n),a=(0,Nd.useCallback)((t,i)=>{e?.(t,i),_d({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,Nd.useCallback)((e,i)=>{t?.(e,i),Ld({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 Dd=require("react");function Bd(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 Ed(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 Od(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?Fd(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?Fd(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 Fd(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 zd(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 Hd(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 Wd(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function qd(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}function Gd({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=(0,Dd.useRef)(-1),u=(0,Dd.useRef)(null),d=(0,Dd.useRef)(null),h=(0,Dd.useCallback)(h=>{if(Td(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=Bd(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=Od(h.key,Ed(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 Yd(e){const t=e.datum;return{...t||{},...t?.properties||{},data:t,properties:t?.properties,x:e.x,y:e.y,__semioticHoverData:!0}}var Vd=require("react/jsx-runtime"),Xd={top:20,right:20,bottom:30,left:40},Ud=il;function Kd(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Qd=(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:I=.1,scalePadding:P,sizeRange:R,size:T=[500,300],responsiveWidth:_,responsiveHeight:L,margin:N,className:$,background:D,renderMode:B,lineStyle:E,pointStyle:O,areaStyle:F,barStyle:z,waterfallStyle:H,swarmStyle:W,barColors:q,colorScheme:G,boundsAccessor:Y,boundsStyle:V,y0Accessor:X,band:U,gradientFill:K,lineGradient:Q,semanticLineStops:Z,areaGroups:J,openAccessor:ee,highAccessor:te,lowAccessor:ne,closeAccessor:oe,candlestickStyle:re,showAxes:ie=!0,axes:se,xLabel:ae,yLabel:ce,yLabelRight:le,xFormat:ue,yFormat:de,axisExtent:he,tickFormatTime:pe,tickFormatValue:me,hoverAnnotation:ye,tooltipContent:fe,customHoverBehavior:ge,customClickBehavior:be,onObservation:ve,annotationObservationCallback:xe,chartId:we,enableHover:ke,hoverRadius:Se=30,tooltipMode:Ae,annotations:Ce,onAnnotationActivate:Me,autoPlaceAnnotations:je,svgAnnotationRules:Ie,showGrid:Pe,legend:Re,legendHoverBehavior:Te,legendClickBehavior:_e,legendHighlightedCategory:Le,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:De,legendCategoryAccessor:Be,onCategoriesChange:Ee,backgroundGraphics:Oe,foregroundGraphics:Fe,canvasPreRenderers:ze,svgPreRenderers:He,title:We,categoryAccessor:qe,brush:Ge,onBrush:Ye,decay:Ve,pulse:Xe,transition:Ue,animate:Ke,staleness:Qe,frameScheduler:Ze,clock:Je,random:et,seed:tt,paused:nt=!1,suspendWhenHidden:ot=!0,heatmapAggregation:rt,heatmapXBins:it,heatmapYBins:st,showValues:at,heatmapValueFormat:ct,marginalGraphics:lt,pointIdAccessor:ut,xScaleType:dt,yScaleType:ht,accessibleTable:pt=!0,description:mt,summary:yt,linkedCrosshairName:vt,linkedCrosshairSourceId:xt,customLayout:wt,onLayoutError:kt,layoutConfig:Ct,layoutSelection:Mt}=e,{customHoverBehavior:jt,customClickBehavior:It,hasClickBehavior:Pt}=$d({customHoverBehavior:ge,customClickBehavior:be,onObservation:ve,chartId:we,chartType:"StreamXYFrame"}),Tt=(0,bt.useId)().replace(/:/g,""),_t=(0,bt.useRef)(!1),Lt=(0,bt.useRef)({w:-1,h:-1}),Nt=(0,bt.useRef)(!1),$t=Su({sizeProp:T,responsiveWidth:_,responsiveHeight:L,userMargin:N,marginDefault:Xd,title:We,legend:Re,legendPosition:$e,animate:Ke,transitionProp:Ue,frameScheduler:Ze,clock:Je,random:et,seed:tt,paused:nt,suspendWhenHidden:ot,themeDirtyRef:_t}),Dt=Gc(),Bt=Uc(),{reducedMotionRef:Et,responsiveRef:Ot,size:Ft,currentTheme:zt,transition:Ht,introEnabled:Wt,tableId:qt,rafRef:Gt,renderFnRef:Yt,scheduleRender:Vt,frameRuntime:Xt}=$t;let Ut=$t.margin;if(lt){const e=60,t={...$t.margin};lt.top&&e>t.top&&(t.top=e),lt.bottom&&e>t.bottom&&(t.bottom=e),lt.left&&e>t.left&&(t.left=e),lt.right&&e>t.right&&(t.right=e),Ut=t}const Kt=Ft[0]-Ut.left-Ut.right,Qt=Ft[1]-Ut.top-Ut.bottom,Zt=(0,bt.useMemo)(()=>ft(r),[r]),Jt=ye??ke,[en,tn]=(0,bt.useState)(0),nn=(0,bt.useRef)(0),[on,rn]=(0,bt.useState)(null),sn=Pu(Fe,Ft,Ut,on),an=Pu(Oe,Ft,Ut,on),cn=(0,bt.useRef)(null),ln=(0,bt.useRef)(null),un=(0,bt.useRef)(void 0),[dn,hn]=(0,bt.useState)(null),pn=(0,bt.useRef)(Ud.primary),mn=(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}}}()),yn=(0,bt.useRef)(!1),fn=yr("StreamXYFrame"),[gn,bn]=(0,bt.useState)(!1),[vn,xn]=(0,bt.useState)([]),[wn,kn]=(0,bt.useState)([]),Sn="streaming"===o||["bar","swarm","waterfall"].includes(n),An=Qc((0,bt.useMemo)(()=>({chartType:n,runtimeMode:Sn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Sn?k:"right",extentPadding:I,scalePadding:P,axisExtent:he,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Sn?C:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:p,groupAccessor:m||(y?"_lineGroup":void 0),categoryAccessor:qe,lineDataAccessor:y,xScaleType:dt,yScaleType:ht,xExtent:M,yExtent:j,sizeRange:R,binSize:x,normalize:g,baseline:b,stackOrder:v,boundsAccessor:Y,boundsStyle:V,y0Accessor:X,band:U,gradientFill:ao(K),areaGroups:J?new Set(J):void 0,lineGradient:co(Q),semanticLineStops:Z,openAccessor:ee,highAccessor:te,lowAccessor:ne,closeAccessor:oe,candlestickStyle:re,lineStyle:E,pointStyle:O,areaStyle:F,swarmStyle:W,waterfallStyle:H,colorScheme:G,barColors:q,barStyle:z,annotations:Ce,decay:Ve,pulse:Xe,transition:Ht,introAnimation:Wt,staleness:Qe,clock:Xt.now,heatmapAggregation:rt,heatmapXBins:it,heatmapYBins:st,showValues:at,heatmapValueFormat:ct,pointIdAccessor:ut,curve:f,themeCategorical:zt?.colors?.categorical,themeSemantic:Rt(zt),themeSequential:zt?.colors?.sequential,themeDiverging:zt?.colors?.diverging,customLayout:wt,onLayoutError:kt,layoutConfig:Ct,layoutMargin:Ut}),[n,Sn,A,S,k,I,P,he,a,c,l,C,w,u,d,h,p,m,y,qe,dt,ht,M,j,R,x,g,b,v,Y,V,X,U,K,J,Q,Z,ee,te,ne,oe,re,E,O,F,W,H,G,q,z,Ce,Ve,Xe,Ht,Wt,Qe,Xt.now,rt,it,st,at,ct,ut,f,zt,wt,kt,Ct,Ut])),Cn=(0,bt.useRef)(null);Cn.current||(Cn.current=new ar(An));const Mn=Lu(Cn,Be,Ee,e=>e.getData());Mr(Cn,An,_t,Vt),jr(Cn,Mt,_t,Vt);const jn=(0,bt.useRef)(null);jn.current||(jn.current=new At(e=>{const t=Cn.current;t&&t.ingest(e)&&(_t.current=!0,Vt())},{chunkThreshold:i,chunkSize:s})),(0,bt.useEffect)(()=>{jn.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const In=(0,bt.useCallback)(e=>{jn.current?.push(e)},[]),Pn=(0,bt.useCallback)(e=>{jn.current?.pushMany(e)},[]),Rn=(0,bt.useCallback)(()=>{jn.current?.clear(),Cn.current?.clear(),_t.current=!0,Vt()},[Vt]);(0,bt.useImperativeHandle)(t,()=>({push:In,pushMany:Pn,remove:e=>{jn.current?.flush();const t=Cn.current?.remove(e)??[];return t.length>0&&(cn.current&&t.some(e=>e===cn.current?.data)&&(cn.current=null,hn(null)),_t.current=!0,Vt()),t},update:(e,t)=>{jn.current?.flush();const n=Cn.current?.update(e,t)??[];return n.length>0&&(_t.current=!0,Vt()),n},clear:Rn,getData:()=>(jn.current?.flush(),Cn.current?.getData()??[]),getScales:()=>Cn.current?.scales??null,getExtents:()=>Cn.current?.getExtents()??null,getCustomLayout:()=>Cn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Cn.current?.lastCustomLayoutFailure??null}),[In,Pn,Rn,Vt]),(0,bt.useEffect)(()=>{if(r){if(y&&Zt.length>0&&"object"==typeof Zt[0]&&null!==Zt[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(Zt[0][e])){const t=[];for(const n of Zt){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 jn.current?.setBoundedData(t)}}jn.current?.setBoundedData(Zt)}},[r,Zt,y]);const{canvasRef:Tn,interactionCanvasRef:_n}=Mu($t,{storeRef:Cn,dirtyRef:_t,hydrated:Dt,wasHydratingFromSSR:Bt,cleanup:()=>jn.current?.clear(),canvasPaintDependencies:[n,Kt,Qt,ie,D,Oe,E,B,ze,Vt]}),{hoverHandlerRef:Ln,hoverLeaveRef:Nn,onPointerMove:$n,onPointerLeave:Dn}=$t;Ln.current=e=>{if(!Jt)return;const t=Tn.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-Ut.left,i=e.clientY-o.top-Ut.top;if(0>r||r>Kt||0>i||i>Qt)return void(cn.current&&(cn.current=null,ln.current=null,hn(null),jt?.(null),Vt()));const s=Cn.current;if(!s||0===s.scene.length)return;const c=ql(Se,e.pointerType),l=fi(s.scene,r,i,c,s.quadtree,s.maxPointRadius),u="multi"===Ae,d=()=>{cn.current&&(cn.current=null,ln.current=null,hn(null),jt&&jt(null),Vt())};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,Kt));if(e.length>0){const t=s.scales.y.invert,o=pn.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?(cn.current=g,ln.current=l?.node??null,hn(g),jt?.(g),Vt()):d()},Nn.current=()=>{cn.current&&(cn.current=null,ln.current=null,hn(null),jt?.(null),Vt())};const Bn=(0,bt.useRef)(()=>{});Bn.current=e=>{if(Qs(e.target))return;if(!It)return;const t=Tn.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-Ut.left,r=e.clientY-n.top-Ut.top;if(0>o||o>Kt||0>r||r>Qt)return void It(null);const i=Cn.current;if(!i||0===i.scene.length)return void It(null);const s=ql(Se,un.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:Rd(un.current)})};const En=(0,bt.useCallback)(e=>Bn.current(e),[]),{kbFocusIndexRef:On,focusedNavPointRef:Fn,onKeyDown:zn}=(Hn={storeRef:Cn,hoverRef:cn,hoveredNodeRef:ln,setHoverPoint:hn,customHoverBehavior:jt,customClickBehavior:It,scheduleRender:Vt},Gd({...Hn,extractPoints:zd,toHover:(e,t)=>qd({...e,datum:oo(e.datum,t.resolvedRibbons)})}));var Hn;const Wn=(0,bt.useCallback)(e=>{un.current=e.pointerType,On.current=-1,Fn.current=null,$n(e)},[Fn,On,$n]),qn=(0,bt.useCallback)(e=>{un.current="mouse",On.current=-1,Fn.current=null,$n({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Fn,On,$n]),Gn=(0,bt.useCallback)(e=>{un.current=e.pointerType},[]);Yt.current=()=>{if(Gt.current=null,!Xt.isActive)return;const e=Tn.current,t=_n.current;if(!e||!t)return;const o=Cn.current;if(!o)return;const r=Xt.now(),i=o.advanceTransition(Et.current?r+1e6:r),s=!Et.current&&i,l=Lt.current.w!==Kt||Lt.current.h!==Qt,u=_t.current||i||l,d=o.consumeStylePaintPending();let h=!1;const p=o.getLastUpdateResult(),m=fn.current.beforeCompute(p,s);!u||s&&!l||(o.computeScene({width:Kt,height:Qt}),Lt.current={w:Kt,h:Qt},h=!0,Mn()),fn.current.afterCompute(m,h,l);const y=Iu(o,r,h,Nt),f=Tu(),g=mn.current.resolve(e);pn.current=g.primary;const b=Ti(Qe,o.lastIngestTime>0?r-o.lastIngestTime:0),v=Qe&&b.isStale;if(u||d||y.changed){const t=Ru(e,Ft,Ut,f);if(t){if(t.clearRect(-Ut.left,-Ut.top,Ft[0],Ft[1]),Qe&&1>b.alpha&&(t.globalAlpha=b.alpha),nl(t,{background:D,hasBackgroundGraphics:!!Oe,themeBackground:g.background,x:-Ut.left,y:-Ut.top,width:Ft[0],height:Ft[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Kt,Qt),t.clip()),ze&&o.scales)for(const e of ze)t.save(),e(t,o.scene,o.scales,{width:Kt,height:Qt}),t.restore();const e=wt?hd.custom:hd[n];fd({context:t,nodes:o.scene,renderMode:B,pixelRatio:f,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:Kt,height:Qt})}}),t.restore(),Qe&&1>b.alpha&&(t.globalAlpha=1)}}const x=!!(Jt&&cn.current&&o.scales),w=!!(ln.current&&Array.isArray(ye)&&ye.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=x||w;if(rl(k,yn.current)){const e=Ru(t,Ft,Ut,f);if(e&&(e.clearRect(-Ut.left,-Ut.top,Ft[0],Ft[1]),x&&cn.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||bd(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,cn.current,Kt,Qt,"object"==typeof Jt?Jt:{},ln.current,g),w&&ln.current&&Array.isArray(ye))){const t=ye.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,ln.current,t,g)}yn.current=k}u&&e&&e.setAttribute("aria-label",wl(o.scene,n+" chart"));const S=_t.current;if(_t.current=S&&s&&!h,S&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!on||e(on.x.domain()[0])!==e(o.scales.x.domain()[0])||e(on.x.domain()[1])!==e(o.scales.x.domain()[1])||e(on.y.domain()[0])!==e(o.scales.y.domain()[0])||e(on.y.domain()[1])!==e(o.scales.y.domain()[1])||on.x.range()[0]!==o.scales.x.range()[0]||on.x.range()[1]!==o.scales.x.range()[1]||on.y.range()[0]!==o.scales.y.range()[0]||on.y.range()[1]!==o.scales.y.range()[1])&&rn(o.scales),lt){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];xn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),kn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((Ce&&Ce.length>0||wt)&&(h||s))||!h&&33>r-nn.current||(tn(e=>e+1),nn.current=r),Qe?.showBadge&&bn(!!v),(s||null!=o.activeTransition||y.pending)&&Vt()},_i(Qe,Cn,_t,Vt,gn,bn);const Yn=(0,bt.useMemo)(()=>{if(ue||pe)return;const e=Cn.current;return e?.xIsDate&&on?Eu(on.x.domain()):void 0},[ue,pe,on]),Vn=ue||pe||Yn,Xn=Jt&&dn?fe?fe(dn):(0,Vd.jsx)(Pd,{hover:dn}):null,Un=Xn?(0,Vd.jsx)(cu,{x:dn.x,y:dn.y,containerWidth:Kt,containerHeight:Qt,margin:Ut,className:"stream-frame-tooltip",children:Xn}):null,Kn=Fn.current,Qn=(0,Vd.jsx)(Hl,{active:On.current>=0,hoverPoint:dn,margin:Ut,size:Ft,shape:Kn?.shape,width:Kn?.w,height:Kn?.h}),Zn=Nu(a,C,"__semiotic_resolvedX","__semiotic_resolvedTime"),Jn=Nu(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),eo=Zn.key,to=Jn.key,no=$u(Zn,Jn,Ce&&Ce.length>0||!1);if(Hc||!Dt&&Bt){const e=Cn.current;e&&r&&(e.ingest({inserts:Zt,bounded:!0}),e.computeScene({width:Kt,height:Qt}));const t=e?.scene??[],n=e?.scales??null,o=Pu(Fe,Ft,Ut,n),i=Pu(Oe,Ft,Ut,n),s=Vn||(()=>{if(e?.xIsDate&&n)return Eu(n.x.domain())})();return(0,Vd.jsxs)("div",{ref:Ot,className:"stream-xy-frame"+($?" "+$:""),role:"img","aria-label":mt||("string"==typeof We?We:"XY chart"),style:{position:"relative",width:_?"100%":Ft[0],height:L?"100%":Ft[1]},children:[(0,Vd.jsx)(El,{summary:yt}),(0,Vd.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ft[0],height:Ft[1],style:{position:"absolute",left:0,top:0},children:[(0,Vd.jsx)("g",{transform:`translate(${Ut.left},${Ut.top})`,children:i}),(0,Vd.jsxs)("g",{transform:`translate(${Ut.left},${Ut.top})`,children:[D&&(0,Vd.jsx)("rect",{x:0,y:0,width:Kt,height:Qt,fill:D}),He&&n&&He.map((e,o)=>(0,Vd.jsx)(gt.Fragment,{children:e(t,n,{width:Kt,height:Qt})},"svgpre-"+o)),t.map((e,t)=>gd({node:e,index:t,renderMode:B,fallback:()=>zc(e,t,Tt)})).filter(Boolean)]})]}),(0,Vd.jsx)(hc,{width:Kt,height:Qt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Ut,scales:n,showAxes:ie,axes:se,xLabel:ae,yLabel:ce,yLabelRight:le,xFormat:s,yFormat:de||me,axisExtent:he,showGrid:Pe,title:We,legend:Re,legendHoverBehavior:Te,legendClickBehavior:_e,legendHighlightedCategory:Le,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:De,foregroundGraphics:br(o,Ar(Cn.current?.customLayoutOverlays,Mt??null)),marginalGraphics:lt,xValues:[],yValues:[],annotations:Ce,onAnnotationActivate:Me,onObservation:xe??ve,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Ie,annotationFrame:0,xAccessor:eo,yAccessor:to,annotationData:no(Cn.current?.getData()),pointNodes:Ou(Cn.current?.scene),curve:"string"==typeof f?f:void 0,linkedCrosshairName:vt,linkedCrosshairSourceId:xt})]})}return(0,Vd.jsxs)("div",{ref:Ot,className:"stream-xy-frame"+($?" "+$:""),role:"group","aria-label":mt||("string"==typeof We?We:"XY chart"),tabIndex:0,style:{position:"relative",width:_?"100%":Ft[0],height:L?"100%":Ft[1],overflow:"visible",touchAction:Kd(Ge)},onKeyDown:zn,children:["production"!==process.env.NODE_ENV&&Cn.current&&(0,Vd.jsx)(fr,{store:Cn.current,diagnostics:fn.current}),pt&&(0,Vd.jsx)(Ol,{tableId:qt}),pt&&(0,Vd.jsx)(Dl,{scene:Cn.current?.scene??[],chartType:n+" chart",tableId:qt,chartTitle:"string"==typeof We?We:void 0}),(0,Vd.jsx)(El,{summary:yt}),(0,Vd.jsx)(yl,{hoverPoint:dn}),(0,Vd.jsxs)("div",{role:"img","aria-label":mt||("string"==typeof We?We:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Jt?Wn:void 0,onMouseMove:Jt?qn:void 0,onPointerLeave:Jt?Dn:void 0,onMouseLeave:Jt?Dn:void 0,onPointerDown:Jt||Pt?Gn:void 0,onClick:Pt?En:void 0,children:[(0,Vd.jsx)(ju,{size:Ft,margin:Ut,children:an}),(0,Vd.jsx)(lc,{width:Kt,height:Qt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Ut,scales:on,showAxes:ie,axes:se,showGrid:Pe,xFormat:Vn,yFormat:de||me,axisExtent:he}),(0,Vd.jsx)("canvas",{ref:Tn,"aria-label":wl(Cn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Vd.jsx)("canvas",{ref:_n,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Vd.jsx)(hc,{width:Kt,height:Qt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Ut,scales:on,showAxes:ie,axes:se,xLabel:ae,yLabel:ce,yLabelRight:le,xFormat:Vn,yFormat:de||me,axisExtent:he,showGrid:Pe,title:We,legend:Re,legendHoverBehavior:Te,legendClickBehavior:_e,legendHighlightedCategory:Le,legendIsolatedCategories:Ne,legendPosition:$e,legendLayout:De,foregroundGraphics:br(sn,Ar(Cn.current?.customLayoutOverlays,Mt??null)),marginalGraphics:lt,xValues:vn,yValues:wn,annotations:Ce,onAnnotationActivate:Me,onObservation:xe??ve,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Ie,annotationFrame:en,xAccessor:eo,yAccessor:to,annotationData:no(Cn.current?.getData()),pointNodes:Ou(Cn.current?.scene),curve:"string"==typeof f?f:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!tl({background:D,hasBackgroundGraphics:!!Oe,themeBackground:zt?.colors.background}),linkedCrosshairName:vt,linkedCrosshairSourceId:xt}),(Ge||Ye)&&(0,Vd.jsx)(St,{width:Kt,height:Qt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Ut,dimension:Ge?.dimension??"xy",scales:on,onBrush:Ye??(()=>{}),binSize:x,snap:Ge?.snap,binBoundaries:Ge?.binBoundaries??("bar"===n?Cn.current?.getBinBoundaries():void 0),snapDuring:Ge?.snapDuring,streaming:"streaming"===o}),Qe?.showBadge&&(0,Vd.jsx)(Ni,{isStale:gn,position:Qe.badgePosition}),Qn,Un]})]})}));Qd.displayName="StreamXYFrame";var Zd=Qd,Jd=require("react"),eh=require("react"),th=require("react/jsx-runtime"),nh=(0,eh.createContext)(null);function oh({colors:e,categories:t,colorScheme:n="category10",children:o}){const r=(0,eh.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]=Pn(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,th.jsx)(nh.Provider,{value:r,children:o})}function rh(){return(0,eh.useContext)(nh)}function ih(e){return e?"string"==typeof e?{name:e}:e:null}oh.displayName="CategoryColorProvider";var sh=.5;function ah(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??sh;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e}var ch=require("react");function lh(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 uh(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(lh(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function dh(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function hh(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[ph,mh]=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||!hh(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),s=dh(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=dh(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 yh(e){const t=(0,ch.useId)(),n=e.clientId||t,{name:o}=e,r=mh(e=>e.selections.get(o)),i=mh(e=>e.setClause),s=mh(e=>e.clearClause),a=(0,ch.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,ch.useMemo)(()=>r&&0!==r.clauses.size?uh(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,ch.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,ch.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,ch.useCallback)(()=>{s(o,n)},[s,o,n]),clientId:n}}function fh(e,t){const n=(0,ch.useId)(),o=t||n,r=mh(e=>e.setClause),i=mh(e=>e.clearClause);return{selectPoints:(0,ch.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,ch.useCallback)(()=>i(e,o),[e,o,i]),clientId:o}}function gh(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=yh({name:t,fields:n});return{onHover:(0,ch.useCallback)(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Pt(t)&&i(t)},[n,i,s]),predicate:o,isActive:r}}function bh(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function vh(e){const{name:t,xField:n,yField:o}=e,{predicate:r,isActive:i,selectInterval:s,clear:a}=yh({name:t,fields:[n,o].filter(Boolean)}),c=n&&o?"xyBrush":n?"xBrush":"yBrush",l=(0,ch.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&&bh(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&bh(e)&&o&&(t[o]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Pt(t)&&s(t)},[c,n,o,s,a]);return{brushInteraction:(0,ch.useMemo)(()=>({brush:c,during:l,end:l}),[c,l]),predicate:r,isActive:i,clear:a}}function xh(e,t,n){const o=mh(e=>e.selections.get(t));return(0,ch.useMemo)(()=>{if(!o||0===o.clauses.size)return e;const t=uh(o,n);return e.filter(t)},[e,o,n])}var wh=d(require("react")),kh={light:Lt,dark:Nt,"high-contrast":$t,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 Sh(e){return kh[e]}var Ah=require("react/jsx-runtime"),Ch=wh.createContext(void 0),Mh="undefined"==typeof window?wh.useEffect:wh.useLayoutEffect;function jh(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return Sh(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function Ih({theme:e}){const t=Et(e=>e.setTheme),n=Et(e=>e.theme),o=wh.useRef(n);o.current=n;const r=wh.useRef(null);wh.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===$t?Lt:o.current,t("high-contrast")),hu(n,e=>{e.matches?(r.current=o.current===$t?r.current??Lt:o.current,t("high-contrast")):(function(e,t){e(t===Lt?"light":t===Nt?"dark":t===$t?"high-contrast":t)}(t,r.current??Lt),r.current=null)})},[e,t]);const i=wh.useRef(!1);return Mh(()=>{i.current?void 0!==e&&t(jh(e)):i.current=!0},[e,t]),null}function Ph({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=wh.useContext(Ch),r={};return o&&(r["data-semiotic-theme"]=o),(0,Ah.jsx)("div",{style:n,...r,children:e})}function Rh({theme:e,children:t}){const n="string"==typeof e&&Sh(e)?e:void 0,o=wh.useMemo(()=>function(e){return void 0!==e?Dt(Lt,jh(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?$t:Lt}(e),[e]);return(0,Ah.jsx)(Bt,{initialState:{theme:o},children:(0,Ah.jsxs)(Ch.Provider,{value:n,children:[(0,Ah.jsx)(Ih,{theme:e}),(0,Ah.jsx)(Ph,{children:t})]})})}function Th(){return Et(e=>e.theme)}function _h(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Lh(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 Nh(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=>Lh(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"])_h(e[o])&&_h(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 $h=44,Dh={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:$h,snap:"nearestDatum",brushHandleSize:$h,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Bh(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 Dh;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??$h,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??$h,standardControls:a.standardControls??!1}}var Eh={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}}},Oh={top:10,bottom:10,left:10,right:10};function Fh(e){return e.compactMode?e.marginDefaults:Oh}function zh(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 Hh(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 Wh(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 qh(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var Gh=require("react"),Yh=require("react"),Vh=require("react");function Xh(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,Vh.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 Uh=require("react/jsx-runtime"),Kh=(0,Yh.createContext)(!1),Qh=(0,Yh.createContext)(!1);function Zh(){return(0,Yh.useContext)(Qh)}var Jh=(0,Yh.createContext)(null),ep="undefined"==typeof window?Yh.useEffect:Yh.useLayoutEffect;function tp(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}function np(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 op(e){const t=(0,Yh.useContext)(Jh),n=(0,Yh.useId)(),o=tp(e),r=(0,Yh.useRef)([]);np(r.current,o)||(r.current=o);const i=r.current;ep(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),ep(()=>{t&&t.registerCategories(n,i)},[t,n,i])}var rp="__linked-legend-isolate__",ip="__linked-legend-highlight__";function sp({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}=yh({name:n,fields:[o],clientId:rp}),{selectPoints:l,clear:u}=yh({name:n,fields:[o],clientId:ip}),d=mh(e=>e.selections.get(n)),{isolatedCategories:h,highlightedCategory:p}=(0,Yh.useMemo)(()=>{const e=new Set;let t=null;const n=d?.clauses.get(rp)?.fields[o];if("point"===n?.type)for(const t of n.values)e.add(t+"");const r=d?.clauses.get(ip)?.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,Yh.useCallback)(e=>{"highlight"===t&&(e?l({[o]:[e.label]}):u())},[t,o,l,u]),y=(0,Yh.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]]=yu([0,0],!0,!1),b=(0,Yh.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,Uh.jsx)("div",{ref:f,style:{width:"100%",display:"block"},children:(0,Uh.jsx)("svg",{width:"100%",height:Math.max(30,22*b+8),style:{display:"block",overflow:"visible"},children:(0,Uh.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 ap({children:e,selections:t,showLegend:n,legendPosition:o="top",legendInteraction:r="none",legendSelectionName:i="legend",legendField:s="category"}){const a=(0,Yh.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=rh(),[l,u]=(0,Yh.useState)({}),d=(0,Yh.useRef)({}),h=(0,Yh.useMemo)(()=>({registerCategories:(e,t)=>{const n=tp(t);u(t=>np(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,Yh.useMemo)(()=>{const e=[];for(const t of Object.values(l))for(const n of t)e.push(n);return tp(e)},[l]),m=(0,Yh.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,Uh.jsx)(ph,{initialState:a,children:(0,Uh.jsx)(Ys,{children:(0,Uh.jsx)(Qh.Provider,{value:!0,children:(0,Uh.jsx)(Jh.Provider,{value:h,children:(0,Uh.jsx)(oh,{colors:m,children:(0,Uh.jsxs)(Kh.Provider,{value:y&&f,children:[y&&"top"===o&&(0,Uh.jsx)(sp,{categoryColors:m,interaction:r,selectionName:i,field:s}),e,y&&"bottom"===o&&(0,Uh.jsx)(sp,{categoryColors:m,interaction:r,selectionName:i,field:s})]})})})})})})}function cp({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 lp(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 up({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,Yh.useContext)(Kh),m=null!==(0,Yh.useContext)(Jh),y=void 0!==o?o:!p&&!!t,f=!!t&&(y||m),g=(0,Gh.useMemo)(()=>f?void 0!==a?a:lp(e,t):[],[a,t,e,f]);op(m&&t?g:[]);const b=(0,Gh.useMemo)(()=>{if(!y||!t)return;const o=cp({data:e,colorBy:t,colorScale:n,getColor:In,categories:g});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[y,t,e,n,g]),v=(0,Gh.useMemo)(()=>Bi(b,c),[b,c]),{hasAxis:x,hasAxisLabel:w,rotatedTicks:k}=h??{},S=(0,Gh.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 dp(e,t,n){const[o,r]=(0,Gh.useState)(null),[i,s]=(0,Gh.useState)(new Set),a=(0,Gh.useMemo)(()=>new Set,[]),c=(0,Gh.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,Gh.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,Gh.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 hp=[];function pp(){const e=Th(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function mp(e,t,n,o,r){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Pn(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 yp(e,t,n){const o=rh(),r=pp();return(0,Jd.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&&qh(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&&qh(i)){const n=Rn(e,t,s);return e=>i[e]||n(e)}return Rn(e,t,s)}if(i&&qh(i)){const e=Rn([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,o,r])}function fp(e,t,n){return(0,Jd.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 gp({selection:e,linkedHover:t,fallbackFields:n=hp,unwrapData:o=!1,onObservation:r,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Jd.useId)(),h=(0,Jd.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,Jd.useMemo)(()=>"series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n,[h,l,n]),m=yh({name:e?.name||"__unused__",fields:p}),y=gh({name:h?.name||"hover",fields:p}),f=Vs(e=>e.pushObservation),g=(0,Jd.useCallback)(e=>{r?.(e),f?.(e)},[r,f]),b=e?{isActive:m.isActive,predicate:m.predicate}:null,[v,x]=(0,Jd.useState)(null),w=(0,Jd.useRef)(!1),k=l||n[0],S=(0,Jd.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,Jd.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=Hh(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)&&_d({onObservation:g,datum:e?Wh(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,Jd.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,Jd.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=Hh(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=Wh(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])}qh(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)&&Ld({onObservation:g,datum:n?Wh(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,Jd.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,Jd.useEffect)(()=>()=>{w.current&&C(!1)},[C]),(0,Jd.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 bp(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 vp(e,t,n){return function(e,t,n){const o=Eh[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,s=Nh({...t,mode:e},{width:t.width??r,height:t.height??i}).props,a=s.mode||e||"primary",c=Eh[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:zh(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Bh(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(e,t,n)}var xp=require("react/jsx-runtime");function wp({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return(0,xp.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,xp.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,xp.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,xp.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,xp.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 kp=d(require("react")),Sp=require("react/jsx-runtime"),Ap=class extends kp.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,Sp.jsx)(wp,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Cp=require("react/jsx-runtime"),Mp="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function jp({componentName:e,width:t,height:n,children:o}){return(0,Cp.jsx)(Ap,{fallback:o=>(0,Cp.jsx)(wp,{componentName:e,message:o.message,width:t,height:n}),children:o})}var Ip={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"},Pp={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Rp(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Cp.jsx)("div",{style:{...Ip,width:t,height:n},children:o||"No data available"}):null}function Tp(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return(0,Cp.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,Cp.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,Cp.jsx)("div",{className:"semiotic-loading-bar",style:{...Pp,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 _p(e,t,n,o){if(!Mp)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 Lp(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 Np(e,t,n=3){let o,r=n+1;for(const n of t){const t=Lp(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function $p(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function Dp(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(Np(e,t,3)??null)}function Bp(e){return` Or use a function: ${e}={d => d.myValue}.`}function Ep({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=$p(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=Dp(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`+Bp(r)}}}return null}function Op({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 Fp({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=$p(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=Dp(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`+Bp(o)}}}return null}var zp=require("react"),Hp=require("react");function Wp(e){const t=Et(e=>e.theme.colors.selectionOpacity);return(0,Hp.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}function qp(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:I,axisChrome:P}=e,R=void 0===n,T=(0,zp.useMemo)(()=>ft(t),[t]),[_,L]=(0,zp.useState)([]),N=(0,zp.useCallback)(e=>{L(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),$="string"==typeof o?o:void 0,D=(0,zp.useMemo)(()=>Bh(w,{width:M,mobileSemantics:k}),[w,M,k]),{activeSelectionHook:B,hoverSelectionHook:E,customHoverBehavior:O,customClickBehavior:F,crosshairSourceId:z}=gp({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:p,onClick:v,hoverHighlight:x,colorByField:$,mobileInteraction:D}),H=bp(c,z),W=yp(T,o,r),q=(0,zp.useMemo)(()=>lp(T,o),[T,o]),G=(0,zp.useMemo)(()=>R&&_.length>0?_:q,[R,_,q]),Y=dp(i,o,G),V=(0,zp.useMemo)(()=>E||(Y.legendSelectionHook?Y.legendSelectionHook:B),[E,Y.legendSelectionHook,B]),X=Wp(a),U=pp(),K=rh(),Q=(0,zp.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}=up({data:T,colorBy:o,colorScale:Q,showLegend:m,legendPosition:s,userMargin:g,defaults:b,categories:G,additionalLegend:y,chartWidth:M,legendLayout:f,hasTitle:I,axisChrome:P}),te=(0,zp.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=N),e},[Z,ee,f,i,Y.onLegendHover,Y.onLegendClick,Y.highlightedCategory,Y.isolatedCategories,R,o,N]),ne=Array.isArray(n)?ft(n):n,oe=Tp(S,M,j,A),re=oe?null:Rp(ne,M,j,C);return{data:T,colorScale:W,allCategories:G,legendState:Y,effectiveSelectionHook:V,activeSelectionHook:B,customHoverBehavior:O,customClickBehavior:F,mobileInteraction:D,legend:Z,margin:J,legendPosition:ee,earlyReturn:oe||re||null,legendBehaviorProps:te,crosshairProps:H,resolvedSelection:X}}var Gp=require("react");function Yp(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 Vp(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Kp(t(e))}function Xp(e,t){const n=Vp(e),o=Vp(t);return(e,t)=>{const r=o(e);return{value:r,x:n(e),y:r,category:t}}}function Up(e,t){const n=Vp(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 Kp(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 Qp(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=Kp(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 Zp(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!Qp(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function Jp(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,Zp(s,t,n(s,i))),a}:r}function em(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,Gp.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=In(e,n,o)):p=r||Sn,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,Zp(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,Gp.useMemo)(()=>Yp(y,{stroke:c,strokeWidth:l,opacity:u}),[y,c,l,u]);return(0,Gp.useMemo)(()=>ah(f,d??null,h),[f,d,h])}var tm=require("react");function nm(e,t){const{variant:n,frameRef:o,overrides:r}=t,i=(0,tm.useRef)(r);i.current=r,(0,tm.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 om(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),o&&(l.summary=o),void 0!==r&&(l.accessibleTable=r),i&&(l.className=i),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function rm(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 im(e){const{tooltip:t,defaultTooltipContent:n}=e;return{tooltipContent:!1===t?()=>null:su(t)||n}}var sm="__forecastSegment",am=null;async function cm(){return am||(am=await Promise.resolve().then(()=>(ee(),W))),am}var lm=require("react"),um="__semiotic_resolvedX",dm="__semiotic_resolvedY";function hm(e){const{data:t,xAccessor:n,yAccessor:o,forecast:r,anomaly:i,groupBy:s}=e,a="string"==typeof n?n:um,c="string"==typeof o?o:dm,l=(0,lm.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[um]=n(t)),s&&(r[dm]=o(t)),r}):t},[t,r,i,n,o]),[u,d]=(0,lm.useState)(null),[h,p]=(0,lm.useState)([]),m=(0,lm.useRef)(r),y=(0,lm.useRef)(i);return(0,lm.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 cm()).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 cm()).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 pm=require("react/jsx-runtime"),mm="__lineObjectSeries",ym=(0,mt.forwardRef)(function(e,t){const n=(0,mt.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:I="break",anomaly:P,forecast:R,band:T,xExtent:_,yExtent:L,frameProps:N={},selection:$,linkedHover:D,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}=N,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;_p("LineChart",ye,"xAccessor",u),_p("LineChart",ye,"yAccessor",d);const{effectiveData:fe,statisticalAnnotations:ge}=hm({data:me,xAccessor:u,yAccessor:d,forecast:R,anomaly:P,groupBy:h}),be="__compoundGroup",ve=!(!R||!h),xe=ve?be:R?sm: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[sm]||"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?mm:xe,Ie=(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,[mm]:o,[p]:r.map(t=>({...t,[mm]: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[sm]=t[sm],"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:Pe,hasGaps:Re}=(0,mt.useMemo)(()=>{if("interpolate"===I){let e=!1;const t=[];for(const n of Ie){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"===I){let e=!1;const t=[];for(const n of Ie){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"===I){let e=!1;const t="string"==typeof d?d:"y",n=[];for(const o of Ie){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:Ie,hasGaps:!1}},[Ie,I,p,Ce,je,d]),Te="object"==typeof j?j:{},_e=Te.position||"end",Le=Te.fontSize||11,Ne=(0,mt.useMemo)(()=>{if(!j||!Se)return[];const e="function"==typeof Se?Se:e=>e[Se],t=new Set;for(const n of Pe){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,Pe,p,_e]),$e=(0,mt.useMemo)(()=>{if(!j)return o.marginDefaults;const e=Ne.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,Ne,Le,_e,o.marginDefaults]),De=qp({data:fe,rawData:r,colorBy:Se,colorScheme:y,legendInteraction:G,legendPosition:Y,selection:$,linkedHover:D,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:$e,loading:H,loadingContent:W,emptyContent:q,width:oe,height:re,hasTitle:!!ce,axisChrome:es({showAxes:o.showAxes,xLabel:he})}),Be=De.colorScale,Ee=De.effectiveSelectionHook,Oe=De.resolvedSelection,Fe=De.customHoverBehavior,ze=De.customClickBehavior,He=De.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)(()=>Xp(u,d),[u,d]),Ge=em({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 cm()).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=In(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 Pe){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,Pe,p,u,d,_e,Le]),Ze=De.margin,Je=h||m,et=(0,mt.useMemo)(()=>Cd([{label:he||xd(u),accessor:u,role:"x",format:a},{label:pe||xd(d),accessor:d,role:"y",format:c},...Je?[{label:xd(Je),accessor:Je,role:"group"}]:[],...Ad(T,c)]),[u,d,he,pe,Je,a,c,T]),tt=Ep({componentName:"LineChart",data:Me?fe[0]?.[p]||[]:r,accessors:{xAccessor:u,yAccessor:d}}),nt=(0,mt.useMemo)(()=>Me||je||Re?Pe.flatMap(e=>{const t=e[p]||[];return je&&"string"==typeof je?t.map(t=>({...t,[je]:t[je]??e[je]})):t}):ke,[Pe,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"===I&&Re?"_gapSegment":je||void 0,...T&&{band:T},curve:g,lineStyle:Xe,...b&&{pointStyle:Ue},size:[oe,re],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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,...De.legendBehaviorProps,...ce&&{title:ce},...le&&{description:le},...ue&&{summary:ue},...void 0!==de&&{accessibleTable:de},...s&&{className:s},...null!=e.animate&&{animate:e.animate},tooltipContent:!1===A?()=>null:"multi"===A?iu():su(A)||et,..."multi"===A&&{tooltipMode:"multi"},...rm({linkedHover:D,selection:$,onObservation:B,onClick:E,hoverRadius:F,hoverHighlight:O,mobileInteraction:De.mobileInteraction,customHoverBehavior:Fe,customClickBehavior:ze}),...C&&{pointIdAccessor:C},...(M?.length||ge.length||Qe.length)&&{annotations:[...M||[],...ge,...Qe]},...He,...te};return De.earlyReturn?De.earlyReturn:tt?(0,pm.jsx)(wp,{componentName:"LineChart",message:tt,width:oe,height:re}):(0,pm.jsx)(jp,{componentName:"LineChart",width:oe,height:re,children:(0,pm.jsx)(Zd,{ref:n,...rt})})});ym.displayName="LineChart";var fm=require("react"),gm=require("react"),bm=require("react");function vm(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 xm(e){const t=(0,bm.useRef)(null);return nm(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:vp(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,bm.useMemo)(()=>vm(e.margin),[e.margin])}}function wm(e){const t=xm(e),{resolved:n,normalizedMargin:o}=t,r=qp({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 km=require("react/jsx-runtime"),Sm=(0,gm.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,...I}=M,P=(0,gm.useMemo)(()=>Bi(j,S),[j,S]),{frameRef:R,resolved:T,safeData:_,setup:L,earlyReturn:N}=wm({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:n,colorBy:w,colorScheme:k,legend:P,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}),$=L.effectiveSelectionHook,D=(0,gm.useMemo)(()=>$?.isActive?{isActive:!0,predicate:$.predicate}:null,[$?.isActive,$?.predicate]);if(N)return N;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,...D&&{layoutSelection:D},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,...om({title:z,description:H,summary:W,accessibleTable:q,className:u,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...rm({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,...I};return(0,km.jsx)(jp,{componentName:"XYCustomChart",width:B,height:E,children:(0,km.jsx)(Zd,{ref:R,...V})})});function Am(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 Cm(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 Mm(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=Am(e.x,s,s,t.x,c),u=Am(e.y,e.y,t.y,t.y,c),d=Cm(e.x,s,s,t.x,c),h=Cm(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 jm(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=Mm(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}}Sm.displayName="XYCustomChart";var Im=require("react/jsx-runtime"),Pm="Other";function Rm(e,t,n){return"function"==typeof e?e(t,n):t[e]}function Tm(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function _m(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=Rm(n,e,t),p=Tm(i);let m=a.get(p);null==m&&(m=s.length,a.set(p,m),s.push(i),c.set(m,[]));const y=Rm(r,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const f=Number(Rm(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:Pm,__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 Lm({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,Im.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 Nm(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 $m(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:void 0}function Dm(e){return{value:e.__bumpValue,x:$m(e.__bumpXValue),y:e.__bumpValue,category:e.__bumpSeries}}function Bm(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?Nm(n.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=jm(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,Zp(o[0].__bumpRaw,t.styleRules,Dm(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,Zp(e.__bumpRaw,t.styleRules,Dm(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,Im.jsx)(Lm,{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,Im.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 Em=(0,fm.forwardRef)(function(e,t){const n=pp(),o=Th(),{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:I=!0,tooltip:P,frameProps:R={},xFormat:T,yFormat:_,onClick:L}=e,N=(0,fm.useMemo)(()=>_m(r,{xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c,highlightTop:m}),[r,i,s,a,c,m]),{axes:$,areaStyle:D,pointStyle:B,...E}=R,O=(0,fm.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)?mp(void 0,a,i,e,u):s??c??"#b8bec8");return d}({seriesOrder:N.seriesOrder,overallOrder:N.overallOrder,highlightTop:m,color:e.color,colorScheme:b,neutralColor:y,themeCategorical:n,themeNeutral:o.colors.textSecondary}),[N.seriesOrder,N.overallOrder,m,e.color,b,y,n,o.colors.textSecondary]),F=(0,fm.useMemo)(()=>({ribbon:l,curve:u,samplesPerSegment:h,ribbonSizeRange:d,valueExtent:N.valueExtent,seriesOrder:N.seriesOrder,lineWidth:p,ribbonOpacity:v,lineOpacity:x,neutralColor:y,color:e.color,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity,styleRules:f,areaStyle:D,pointStyle:B,labelStyle:g,showPoints:w,pointRadius:k,showLabels:S}),[l,u,h,d,N.valueExtent,N.seriesOrder,p,v,x,y,e.color,e.stroke,e.strokeWidth,e.opacity,f,D,B,g,w,k,S]),z=(0,fm.useCallback)((e,t)=>{if(0===N.xValues.length)return"";const n=N.xValues[Math.max(0,Math.min(N.xValues.length-1,Math.round(Number(e))))];return T?T(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},[N.xValues,T]),H=(0,fm.useCallback)(e=>_?_(e):e.toLocaleString(),[_]),W=(0,fm.useMemo)(()=>"multi"===P?void 0:su(P),[P]),q=(0,fm.useCallback)(e=>{const t=e?.data??e;return t?!1===P?null:W?W({...e,data:t.__bumpRaw,__semioticHoverData:!0}):(0,Im.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,Im.jsx)("div",{style:{fontWeight:700},children:t.__bumpSeries}),(0,Im.jsxs)("div",{children:[z(t.x)," · Rank ",t.__bumpRank]}),(0,Im.jsxs)("div",{children:["Value: ",H(t.__bumpValue)]})]}):null},[H,z,W,P]),G=(0,fm.useMemo)(()=>{if(L)return(e,t)=>{L(e.__bumpRaw??e,t)}},[L]),Y=Math.max(1,N.seriesOrder.length),V=N.xValues.map((e,t)=>t),X=Array.from({length:Y},(e,t)=>t+1),U=$??[{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,fm.useMemo)(()=>function(e,t){if(!e?.length)return;const n=new Map(t.map((e,t)=>[Tm(e),t]));return e.map(e=>{const t={...e},o=o=>{if(!(o in e))return;const r=n.get(Tm(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,N.xValues),[e.annotations,N.xValues]);return(0,Im.jsx)(Sm,{ref:t,data:N.data,layout:Bm,layoutConfig:F,xExtent:[0,Math.max(1,N.xValues.length-1)],yExtent:[Y+.5,.5],showAxes:A,showGrid:C,showLegend:M,enableHover:j,hoverHighlight:I,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}})});Em.displayName="BumpChart";var Om=require("react"),Fm=require("react");function zm(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,Fm.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]),I=(0,Fm.useMemo)(()=>e=>{const t={};if(i){if(s){const n=In(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,Zp(e,C,M?M(e):{value:void 0})),t},[i,s,a,p,m,y,C,M]),P=(0,Fm.useMemo)(()=>Yp(I,{stroke:c,strokeWidth:l,opacity:u}),[I,c,l,u]);return{flattenedData:j,lineStyle:(0,Fm.useMemo)(()=>ah(P,d??null,h),[P,d,h]),pointStyle:(0,Fm.useMemo)(()=>{if(f)return e=>{const t={r:g,fillOpacity:1};return i?s&&(t.fill=In(e.parentLine||e,i,s)):t.fill=a||Sn,t}},[f,g,i,s,a]),defaultTooltipContent:(0,Fm.useMemo)(()=>Cd([{label:x||xd(b),accessor:b,role:"x",format:k},{label:w||xd(v),accessor:v,role:"y",format:S},...A?[{label:xd(A),accessor:A,role:"group"}]:[],...Ad(e.band,S)]),[b,v,x,w,A,k,S,e.band])}}var Hm=require("react/jsx-runtime"),Wm=(0,Om.forwardRef)(function(e,t){const n=(0,Om.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:I,forecast:P,anomaly:R,band:T,xExtent:_,yExtent:L,frameProps:N={},selection:$,linkedHover:D,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,Om.useMemo)(()=>ft(r),[r]),ce=g||d,le=(0,Om.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,Om.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,Om.useMemo)(()=>co(k),[k]),he=(0,Om.useMemo)(()=>y&&le?.stops.length?le.stops.flatMap(({offset:e,color:t})=>t?[{offset:e,color:t}]:[]):void 0,[le,y]);_p("AreaChart",ae,"xAccessor",l),_p("AreaChart",ae,"yAccessor",u);const pe=qp({data:ae,rawData:r,colorBy:ce,colorScheme:b,legendInteraction:q,legendPosition:G,selection:$,linkedHover:D,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}=hm({data:ae,xAccessor:l,yAccessor:u,forecast:P,anomaly:R,groupBy:d}),fe=(0,Om.useMemo)(()=>Xp(l,u),[l,u]),{flattenedData:ge,lineStyle:be,pointStyle:ve,defaultTooltipContent:xe}=zm({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=Ep({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,...om({title:te,description:ne,summary:oe,accessibleTable:re,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===j?{tooltipContent:iu(),tooltipMode:"multi"}:im({tooltip:j,defaultTooltipContent:xe}),...rm({linkedHover:D,selection:$,onObservation:B,onClick:E,hoverHighlight:O,mobileInteraction:pe.mobileInteraction,customHoverBehavior:pe.customHoverBehavior,customClickBehavior:pe.customClickBehavior}),...(I&&I.length>0||ye.length>0)&&{annotations:[...I||[],...ye]},..._&&{xExtent:_},...L&&{yExtent:L},...pe.crosshairProps,...N};return pe.earlyReturn?pe.earlyReturn:we?(0,Hm.jsx)(wp,{componentName:"AreaChart",message:we,width:K,height:Q}):(0,Hm.jsx)(jp,{componentName:"AreaChart",width:K,height:Q,children:(0,Hm.jsx)(Zd,{ref:n,...ke})})});Wm.displayName="AreaChart";var qm=require("react"),Gm=require("react/jsx-runtime");function Ym(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 Vm=(0,qm.forwardRef)(function(e,t){const n=(0,qm.useRef)(null),o=vp(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:I,linkedHover:P,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:N,loadingContent:$,emptyContent:D,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,qm.useMemo)(()=>"function"==typeof l?e=>Ym(l(e)):e=>Ym(e[l]),[l]),J=(0,qm.useMemo)(()=>"function"==typeof u?e=>Ym(u(e)):e=>Ym(e[u]),[u]),ee=(0,qm.useMemo)(()=>"function"==typeof d?e=>Ym(d(e)):e=>Ym(e[d]),[d]),[te,ne]=(0,qm.useState)([]),oe=(0,qm.useRef)([]),re=null==r,ie=(0,qm.useMemo)(()=>ft(re?te:r),[re,te,r]),se=(0,qm.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,qm.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,qm.useMemo)(()=>[...se,...ae],[se,ae]),le=(0,qm.useMemo)(()=>{const e=new Set;for(const t of se)e.add(t.__diffSegment);return Array.from(e)},[se]);(0,qm.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=qp({data:ie,rawData:r,colorBy:"__diffWinner",colorScheme:[m,y],legendInteraction:B,legendPosition:E,selection:I,linkedHover:P,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:N,loadingContent:$,emptyContent:D,width:z,height:H,hasTitle:!!Y,axisChrome:es({showAxes:o.showAxes,xLabel:K})}),de=(0,qm.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,qm.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,qm.useCallback)(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?m:y,strokeWidth:g,fill:"none"}),[m,y,g]),me=(0,qm.useCallback)(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?m:y,r:v}),[m,y,v]),ye=(0,qm.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,Gm.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[c&&(0,Gm.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:c}),(0,Gm.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Gm.jsx)("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),(0,Gm.jsxs)("span",{children:[h,": ",s(r)]})]}),(0,Gm.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[(0,Gm.jsx)("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),(0,Gm.jsxs)("span",{children:[p,": ",s(i)]})]}),null!=r&&null!=i&&Number.isFinite(r)&&Number.isFinite(i)&&(0,Gm.jsxs)("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(r-i)]})]})},[ie,Z,J,ee,a,m,y,h,p]),fe="multi"===S,ge=(0,qm.useMemo)(()=>!1===S?()=>null:fe?ye:su(S)||ye,[S,fe,ye]),be=(0,qm.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},...om({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),tooltipContent:ge,...fe&&{tooltipMode:"multi"},...rm({linkedHover:P,selection:I,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,Gm.jsx)(jp,{componentName:"DifferenceChart",width:z,height:H,children:(0,Gm.jsx)(Zd,{ref:n,...ve})})});"function"==typeof Vm&&(Vm.displayName="DifferenceChart");var Xm=require("react"),Um=require("react/jsx-runtime"),Km=(0,Xm.forwardRef)(function(e,t){const n=(0,Xm.useRef)(null),o=vp(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:I,frameProps:P={},selection:R,linkedHover:T,onObservation:_,onClick:L,hoverHighlight:N,chartId:$,loading:D,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,Xm.useMemo)(()=>ft(r),[r]),oe=p||d;nm(t,{variant:"xy",frameRef:n});const re=qp({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:N,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"StackedAreaChart",chartId:$,showLegend:U,userMargin:i,marginDefaults:o.marginDefaults,loading:D,loadingContent:B,emptyContent:E,width:G,height:Y,hasTitle:!!K,axisChrome:es({showAxes:o.showAxes,xLabel:ee})}),ie=(0,Xm.useMemo)(()=>Xp(l,u),[l,u]),{flattenedData:se,lineStyle:ae,pointStyle:ce,defaultTooltipContent:le}=zm({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=Ep({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,...om({title:K,description:Q,summary:Z,accessibleTable:J,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===C?{tooltipContent:iu(),tooltipMode:"multi"}:im({tooltip:C,defaultTooltipContent:le}),...rm({linkedHover:T,selection:R,onObservation:_,onClick:L,hoverHighlight:N,mobileInteraction:re.mobileInteraction,customHoverBehavior:re.customHoverBehavior,customClickBehavior:re.customClickBehavior}),...M&&M.length>0&&{annotations:M},...j&&{xExtent:j},...I&&{yExtent:I},...re.crosshairProps,...P};return re.earlyReturn?re.earlyReturn:ue?(0,Um.jsx)(wp,{componentName:"StackedAreaChart",message:ue,width:G,height:Y}):(0,Um.jsx)(jp,{componentName:"StackedAreaChart",width:G,height:Y,children:(0,Um.jsx)(Zd,{ref:n,...de})})});Km.displayName="StackedAreaChart";var Qm=d(require("react")),Zm=require("react"),Jm=require("react");function ey(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,Jm.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=In(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,Zp(e,y,f?f(e):{value:void 0})),u},[t,n,o,r,i,s,a,c,m,y,f]),b=(0,Jm.useMemo)(()=>Yp(g,{stroke:l,strokeWidth:u,opacity:d}),[g,l,u,d]);return(0,Jm.useMemo)(()=>ah(b,h??null,p),[b,h,p])}var ty=require("react");function ny(e){const{accessor:t,data:n,isPushMode:o}=e,r=(0,ty.useRef)(null),[i,s]=(0,ty.useState)(0),a=(0,ty.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,ty.useCallback)(()=>{o&&(r.current=null,s(e=>e+1))},[o]);return{domain:(0,ty.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 oy(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 ry=require("react/jsx-runtime"),iy=(0,Zm.forwardRef)(function(e,t){const n=(0,Zm.useRef)(null),o=vp(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:I,xExtent:P,yExtent:R,frameProps:T={},selection:_,linkedHover:L,linkedBrush:N,onObservation:$,onClick:D,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,Zm.useMemo)(()=>ft(r),[r]),se=void 0===r,{domain:ae,trackPushed:ce,reset:le}=ny({accessor:f,data:ie,isPushMode:se}),ue=(0,Zm.useCallback)(e=>{ce([e]),n.current?.push(e)},[ce]),de=(0,Zm.useCallback)(e=>{ce(e),n.current?.pushMany(e)},[ce]);nm(t,{variant:"xy",frameRef:n,overrides:{push:ue,pushMany:de,clear:()=>{le(),n.current?.clear()}}});const he=qp({data:ie,rawData:r,colorBy:p,colorScheme:m,legendInteraction:H,legendPosition:W,selection:_,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:$,onClick:D,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=ih(N),me=vh({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=Qm.useRef(me.brushInteraction);fe.current=me.brushInteraction;const ge=(0,Zm.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)},[]);_p("Scatterplot",ie,"xAccessor",l),_p("Scatterplot",ie,"yAccessor",u);const be=(0,Zm.useMemo)(()=>f?ae??[0,1]:void 0,[f,ae]),ve=(0,Zm.useMemo)(()=>f?e=>Tn(e,f,g,be):void 0,[f,g,be]),xe=(0,Zm.useMemo)(()=>Xp(l,u),[l,u]),we=ey({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,Zm.useMemo)(()=>Cd([{label:oe||xd(l),accessor:l,role:"x",format:a},{label:re||xd(u),accessor:u,role:"y",format:c},...p?[{label:xd(p),accessor:p,role:"color"}]:[],...f?[{label:xd(f),accessor:f,role:"size"}]:[]]),[l,u,oe,re,p,f,a,c]),{effectiveData:Se,statisticalAnnotations:Ae}=hm({data:ie,xAccessor:l,yAccessor:u,forecast:j,anomaly:I}),Ce=(0,Zm.useMemo)(()=>{const e=oy(M);return e||0!==Ae.length?[...e?[e]:[],...C||[],...Ae]:C},[M,C,Ae]);if(he.earlyReturn)return he.earlyReturn;const Me=Ep({componentName:"Scatterplot",data:r,accessors:{xAccessor:l,yAccessor:u}});if(Me)return(0,ry.jsx)(wp,{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,...om({title:J,description:ee,summary:te,accessibleTable:ne,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:k,defaultTooltipContent:ke}),...rm({linkedHover:L,selection:_,onObservation:$,onClick:D,hoverHighlight:B,mobileInteraction:he.mobileInteraction,customHoverBehavior:he.customHoverBehavior,customClickBehavior:he.customClickBehavior}),...S&&{marginalGraphics:S},...A&&{pointIdAccessor:A},...Ce&&Ce.length>0&&{annotations:Ce},...P&&{xExtent:P},...R&&{yExtent:R},...pe&&{brush:{dimension:ye},onBrush:ge},...he.crosshairProps,...T};return(0,ry.jsx)(jp,{componentName:"Scatterplot",width:X,height:U,children:(0,ry.jsx)(Zd,{ref:n,...je})})});iy.displayName="Scatterplot";var sy=require("react"),ay=require("react/jsx-runtime");function cy(e,t){return sn(1===t?.5:e/(t-1))}var ly=(0,sy.forwardRef)(function(e,t){const n=(0,sy.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:I,chartId:P,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,stroke:N,strokeWidth:$,opacity:D}=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,sy.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]);_p("ConnectedScatterplot",V,"xAccessor",l),_p("ConnectedScatterplot",V,"yAccessor",u);const U=qp({data:V,rawData:r,colorBy:void 0,colorScheme:void 0,legendInteraction:L,selection:A,linkedHover:C,fallbackFields:[],unwrapData:!1,onObservation:M,onClick:j,hoverHighlight:I,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ConnectedScatterplot",chartId:P,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??sh,Q=(0,sy.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=cy(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,sy.useMemo)(()=>[Q],[Q]),J=(0,sy.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=cy(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,ay.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,ay.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,ay.jsx)(ay.Fragment,{children:s})},[m]),ee=(0,sy.useMemo)(()=>[J],[J]),te=ey({colorScale:void 0,baseStyleExtras:(0,sy.useMemo)(()=>e=>{const t=X.get(e),n=t?.idx??0,o=t?.total??1;return{fill:o>0?cy(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,X]),stroke:N,strokeWidth:$,opacity:D,styleRules:p,ruleContext:(0,sy.useMemo)(()=>Xp(l,u),[l,u]),effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection}),ne=h||("string"==typeof d?d:"Order"),oe=(0,sy.useMemo)(()=>Cd([{label:G||xd(l),accessor:l,role:"x",format:a},{label:Y||xd(u),accessor:u,role:"y",format:c},...d?[{label:ne,accessor:d,role:"group"}]:[]]),[l,u,G,Y,d,ne,a,c]),re=Ep({componentName:"ConnectedScatterplot",data:r,accessors:{xAccessor:l,yAccessor:u}}),{effectiveData:ie,statisticalAnnotations:se}=hm({data:V,xAccessor:l,yAccessor:u,forecast:v,anomaly:x});if(U.earlyReturn)return U.earlyReturn;const ae=oy(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,...om({title:z,description:H,summary:W,accessibleTable:q,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:y,defaultTooltipContent:oe}),...rm({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:I,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,ay.jsx)(wp,{componentName:"ConnectedScatterplot",message:re,width:B,height:E}):(0,ay.jsx)(jp,{componentName:"ConnectedScatterplot",width:B,height:E,children:(0,ay.jsx)(Zd,{ref:n,...le})})});ly.displayName="ConnectedScatterplot";var uy=require("react"),dy=require("react/jsx-runtime"),hy=(0,uy.forwardRef)(function(e,t){const n=(0,uy.useRef)(null),o=vp(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:I,linkedBrush:P,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:N,loadingContent:$,emptyContent:D,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,uy.useMemo)(()=>ft(r),[r]),te=void 0===r,ne=qp({data:ee,rawData:r,colorBy:p,colorScheme:m,legendInteraction:B,legendPosition:E,selection:j,linkedHover:I,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:N,loadingContent:$,emptyContent:D,width:W,height:q,hasTitle:!!X,axisChrome:es({showAxes:o.showAxes,xLabel:Z})}),{domain:oe,trackPushed:re,reset:ie}=ny({accessor:d,data:ee,isPushMode:te}),se=(0,uy.useCallback)(e=>{re([e]),n.current?.push(e)},[re]),ae=(0,uy.useCallback)(e=>{re(e),n.current?.pushMany(e)},[re]);nm(t,{variant:"xy",frameRef:n,overrides:{push:se,pushMany:ae,clear:()=>{ie(),n.current?.clear()}}});const ce=ih(P),le=(vh({name:ce?.name||"__unused_brush__",xField:ce?.xField||("string"==typeof l?l:void 0),yField:ce?.yField||("string"==typeof u?u:void 0)}),(0,uy.useMemo)(()=>({stroke:b,strokeWidth:g}),[b,g])),ue=(0,uy.useMemo)(()=>oe??[0,1],[oe]),de=(0,uy.useCallback)(e=>Tn(e,d,h,ue),[d,h,ue]),he=(0,uy.useMemo)(()=>Xp(l,u),[l,u]),pe=ey({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,uy.useMemo)(()=>Cd([{label:Z||xd(l),accessor:l,role:"x",format:a},{label:J||xd(u),accessor:u,role:"y",format:c},{label:xd(d),accessor:d,role:"size"},...p?[{label:xd(p),accessor:p,role:"color"}]:[]]),[l,u,Z,J,d,p,a,c]);if(ne.earlyReturn)return ne.earlyReturn;const ye=Ep({componentName:"BubbleChart",data:r,accessors:{xAccessor:l,yAccessor:u},requiredProps:{sizeBy:d}});if(ye)return(0,dy.jsx)(wp,{componentName:"BubbleChart",message:ye,width:W,height:q});const fe=oy(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,...om({title:X,description:U,summary:K,accessibleTable:Q,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:v,defaultTooltipContent:me}),...rm({linkedHover:I,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,dy.jsx)(jp,{componentName:"BubbleChart",width:W,height:q,children:(0,dy.jsx)(Zd,{ref:n,...be})})});hy.displayName="BubbleChart";var py=require("react"),my=require("d3-scale");T();var yy=require("react/jsx-runtime"),fy=(0,py.forwardRef)(function(e,t){const n=(0,py.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:P,loading:R,loadingContent:T,emptyContent:_,showLegend:L,legendPosition:N,legend:$,legendInteraction:D}=e,{width:B,height:E,enableHover:O,title:F,description:z,summary:H,accessibleTable:W,xLabel:q,yLabel:G}=o,Y=Tp(R,B,E,T),V=Y?null:Rp(r,B,E,_),X=(0,py.useMemo)(()=>ft(r),[r]),U=function(){const e=Th();return e?.colors?.sequential||void 0}(),K=h??U??"blues",Q=L??!1,Z=N??"right",{customHoverBehavior:J,customClickBehavior:ee,crosshairSourceId:te}=gp({selection:S,linkedHover:A,fallbackFields:[],onObservation:C,onClick:M,chartType:"Heatmap",chartId:P,hoverHighlight:j,colorByField:void 0,mobileInteraction:o.mobileInteraction});Wp(S);const ne=bp(A,te);dp(D,void 0,[]);const oe=(0,py.useMemo)(()=>"function"==typeof l?e=>l(e):e=>e[l],[l]),re=(0,py.useMemo)(()=>I(X.map(oe)),[X,oe]),ie=(0,py.useMemo)(()=>{if("custom"===K&&p)return p;const e=pn(K);return(0,my.scaleSequential)(e).domain(re)},[K,p,re]),se=(0,py.useMemo)(()=>{const e=Number.isFinite(g)?Math.max(0,g):1;return()=>({stroke:f,strokeWidth:e})},[f,g]),ae=(0,py.useMemo)(()=>Cd([{label:q||xd(a),accessor:a,role:"x",format:u},{label:G||xd(c),accessor:c,role:"y",format:d},{label:xd(l),accessor:l,role:"value",format:y}]),[a,c,q,G,l,u,d,y]),ce=Ep({componentName:"Heatmap",data:r,accessors:{xAccessor:a,yAccessor:c,valueAccessor:l}}),le=(0,py.useMemo)(()=>{if(Q)return{gradient:{colorFn:e=>ie(e),domain:re,label:"string"==typeof l?l:"value",format:y},legendDistance:$?.legendDistance}},[Q,ie,re,l,y,$?.legendDistance]),{margin:ue}=up({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},...om({title:F,description:z,summary:H,accessibleTable:W,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:b,defaultTooltipContent:ae}),...rm({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,yy.jsx)(wp,{componentName:"Heatmap",message:ce,width:B,height:E}):(0,yy.jsx)(jp,{componentName:"Heatmap",width:B,height:E,children:(0,yy.jsx)(Zd,{ref:n,...de})}))});fy.displayName="Heatmap";var gy=d(require("react")),by=require("react");T();var vy=d(require("react")),xy=require("react/jsx-runtime"),wy=null,ky=null;function Sy(e){const[t,n]=vy.useState(()=>wy);return vy.useEffect(()=>{if(t)return;let e=!1;return(wy?Promise.resolve(wy):(ky||(ky=Promise.resolve().then(()=>(ce(),ne)).then(e=>wy=e.ScatterplotMatrixBrushOverlay).catch(e=>{throw ky=null,e})),ky)).then(t=>{e||n(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?(0,xy.jsx)(t,{...e}):null}var Ay=require("react/jsx-runtime"),Cy="__splomIdx",My="splom-hover-source",jy={top:4,bottom:4,left:4,right:4};function Iy({data:e,xField:t,yField:n,cellSize:o,pointRadius:r,pointOpacity:i,colorBy:s,colorScale:a,brushSelectionName:c,hoverSelectionName:l,unselectedOpacity:u,mobileInteraction:d,mode:h,onPointHover:p,onPointClick:m}){const y=(0,by.useRef)(null),f=yh({name:c,clientId:`splom-${t}-${n}`,fields:[t,n]}),g=vh({name:c,xField:t,yField:n}),b=yh({name:l,clientId:My,fields:[Cy]}),v=b.selectPoints,x=(0,by.useCallback)(e=>{e?g.brushInteraction.during(e):g.brushInteraction.end(null)},[g.brushInteraction]),w=(0,by.useCallback)(e=>{if(!e)return void p?.(null);const t=e.data,n=t?.[Cy];void 0!==n&&(v({[Cy]:[n]}),p?.(t,e.x+jy.left,e.y+jy.top))},[v,p]),k=(0,by.useCallback)(e=>{if(!e)return void m?.(null);const t=e.data;t&&m?.(t,e.x+jy.left,e.y+jy.top)},[m]),S=(0,by.useCallback)(e=>{const t={opacity:i,r:r};return t.fill=s?In(e,s,a):Sn,"hover"===h?b.isActive&&b.predicate(e)?(t.opacity=1,t.r=2.5*r,t.stroke="#333",t.strokeWidth=1.5):b.isActive&&(t.opacity=.6*i):f.isActive&&!f.predicate(e)&&(t.opacity=u),t},[i,r,s,h,a,b,f,u]);return(0,Ay.jsxs)("div",{style:{position:"relative",width:o,height:o},children:[(0,Ay.jsx)(Zd,{ref:y,chartType:"scatter",data:e,size:[o,o],xAccessor:t,yAccessor:n,pointStyle:S,margin:jy,showAxes:!1,enableHover:"hover"===h,...rm({forceHoverBehavior:"hover"===h,forceClickBehavior:!!m,mobileInteraction:d,customHoverBehavior:w,customClickBehavior:k}),tooltipContent:"hover"===h?()=>null:void 0}),"brush"===h&&(0,Ay.jsx)(Sy,{frameRef:y,cellSize:o,onBrush:x})]})}function Py({data:e,field:t,label:n,cellSize:o,bins:r,colorBy:i,colorScale:s,brushSelectionName:a,hoverSelectionName:c,mode:l}){const u=yh({name:a,clientId:"splom-diag-"+t,fields:[t]}),d=yh({name:c,clientId:`splom-diag-${t}-hover`,fields:[Cy]}),h="hover"===l?d:u,p=h.isActive,m=h.predicate,y=(0,by.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]=I(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=P(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,Ay.jsxs)("svg",{width:o,height:o,style:{overflow:"hidden"},children:[(0,Ay.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,Ay.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,Ay.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,Ay.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,Ay.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 Ry({label:e,cellSize:t}){return(0,Ay.jsx)("svg",{width:t,height:t,children:(0,Ay.jsx)("text",{x:t/2,y:t/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:e})})}function Ty(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,tooltip:f,showLegend:g,idAccessor:b,width:v,className:x,onObservation:w,onClick:k,chartId:S}=e,A="splom",C="splom-hover",M=Bh(e.mobileInteraction,{mode:e.mode,width:v??n.length*s,mobileSemantics:e.mobileSemantics}),j=p?"hover":h?"brush":"hover",I=mh(e=>e.clearSelection),[P,R]=(0,by.useState)(null),T=(0,by.useCallback)(()=>{I(C),R(null)},[I,C]),_=(0,by.useMemo)(()=>(t||[]).map((e,t)=>void 0!==e[Cy]?e:{...e,[Cy]:t}),[t]),L=yp(_,r,i),N=(0,by.useCallback)((e,t,n,o)=>[40+e*(s+a)+(n??0),t*(s+a)+(o??0)],[40,s,a]),$=void 0!==g?g:!!r,D=(0,by.useMemo)(()=>{if(!$||!r)return null;const e="string"==typeof r?r:null;return e?Array.from(new Set(_.map(t=>t[e]).filter(e=>null!=e))).map(e=>({label:e+"",color:L?L(e+""):Sn})):null},[$,r,_,L]),B=(0,by.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,Ay.jsxs)("div",{className:x,style:{position:"relative"},children:[D&&(0,Ay.jsx)("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:D.map(e=>(0,Ay.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,Ay.jsx)("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:e.color}}),(0,Ay.jsx)("span",{style:{fontSize:11},children:e.label})]},e.label))}),(0,Ay.jsxs)("div",{style:B,onMouseLeave:"hover"===j?T:void 0,children:[n.map((e,t)=>(0,Ay.jsxs)(gy.Fragment,{children:[(0,Ay.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,Ay.jsx)(Ry,{label:o[e]||e,cellSize:s},"diag-"+e):(0,Ay.jsx)(Py,{data:_,field:e,label:o[e]||e,cellSize:s,bins:d,colorBy:r,colorScale:L,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,mode:j},"diag-"+e):(0,Ay.jsx)(Iy,{data:_,xField:n,yField:e,fieldLabels:o,cellSize:s,pointRadius:c,pointOpacity:l,colorBy:r,colorScale:L,brushSelectionName:A,hoverSelectionName:C,unselectedOpacity:m,showGrid:y,tooltip:f,mobileInteraction:M,mode:j,onPointHover:"hover"===j?(o,r,s)=>{if(o){if(R({datum:o,xField:n,yField:e,colIndex:i,rowIndex:t,px:r??0,py:s??0}),w){const[e,n]=N(i,t,r,s);w({type:"hover",datum:o,x:e,y:n,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}}else R(null),w&&w({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0,onPointClick:k||w?(e,n,o)=>{if(!e)return;const[r,s]=N(i,t,n,o);k&&k(e,{x:r,y:s}),w&&w({type:"click",datum:e,x:r,y:s,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:S})}:void 0},`cell-${e}-${n}`))]},"row-"+e)),(0,Ay.jsx)("div",{})," ",n.map(e=>(0,Ay.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:o[e]||e},"col-label-"+e))]}),P&&"hover"===j&&(()=>{const e=P.datum,t=o[P.xField]||P.xField,n=o[P.yField]||P.yField,i=r?"function"==typeof r?r(e):e[r]:null,c=b?"function"==typeof b?b(e):e[b]:"Row "+e[Cy];return(0,Ay.jsxs)("div",{style:{position:"absolute",left:40+P.colIndex*(s+a)+P.px,top:P.rowIndex*(s+a)+P.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,Ay.jsx)("div",{style:{fontWeight:"bold",marginBottom:2},children:c+""}),(0,Ay.jsxs)("div",{children:[t,": ",null!=e[P.xField]?Number(e[P.xField]).toFixed(1):"–"]}),(0,Ay.jsxs)("div",{children:[n,": ",null!=e[P.yField]?Number(e[P.yField]).toFixed(1):"–"]}),null!=i&&(0,Ay.jsxs)("div",{style:{opacity:.8},children:["string"==typeof r?r:"group",": ",i+""]})]})})()]})}function _y(e){const{brushMode:t="crossfilter",hoverMode:n=!0}=e,o={};return!n&&t&&(o.splom={resolution:t}),n&&(o["splom-hover"]={resolution:"union"}),(0,Ay.jsx)(ap,{selections:o,children:(0,Ay.jsx)(Ty,{...e})})}_y.displayName="ScatterplotMatrix";var Ly=require("react"),Ny=d(require("react")),$y=require("react/jsx-runtime"),Dy=null,By=null;function Ey(e){const[t,n]=Ny.useState(()=>Dy);return Ny.useEffect(()=>{if(t)return;let e=!1;return(Dy?Promise.resolve(Dy):(By||(By=Promise.resolve().then(()=>(ye(),le)).then(e=>Dy=e.MinimapBrushOverlay).catch(e=>{throw By=null,e})),By)).then(t=>{e||n(()=>t)}).catch(()=>{}),()=>{e=!0}},[t]),t?(0,$y.jsx)(t,{...e}):null}var Oy=require("react/jsx-runtime");function Fy(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:I,tooltip:P,minimap:R={},renderBefore:T=!1,onBrush:_,brushExtent:L,yExtent:N,frameProps:$={},loading:D,loadingContent:B,emptyContent:E}=e,O=Tp(D,n,o,B),F=O?null:Rp(t,n,o,E),z=(0,Ly.useMemo)(()=>ft(t),[t]),[H,W]=(0,Ly.useState)(null),q=L??H,G=(0,Ly.useCallback)(e=>{L||W(e),_?.(e)},[L,_]),Y=(0,Ly.useRef)(null),[V,X]=(0,Ly.useState)(null);(0,Ly.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,Ly.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,Ly.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=yp(z,g,b),J=em({lineWidth:x,colorBy:g,colorScale:Z,fillArea:w,areaOpacity:k}),ee=(0,Ly.useMemo)(()=>{if(R.lineStyle)return R.lineStyle},[R.lineStyle]),te=em({lineWidth:1,colorBy:g,colorScale:Z}),ne=ee??te,oe=(0,Ly.useMemo)(()=>{if(S)return e=>{const t={r:A,fillOpacity:1};return t.fill=g?In(e.parentLine||e,g,Z):Sn,t}},[S,A,g,Z]),{legend:re,margin:ie,legendPosition:se}=up({data:K,colorBy:g,colorScale:Z,showLegend:j,legendPosition:I,userMargin:r,chartWidth:n,hasTitle:!!s,axisChrome:{hasAxis:!0,hasAxisLabel:!!l}}),ae=R.height||60,ce=(0,Ly.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,Ly.useMemo)(()=>Cd([{label:l||xd(p),accessor:p,role:"x",format:d},{label:u||xd(m),accessor:m,role:"y",format:h}]),[p,m,l,u,d,h]),de=Ep({componentName:"MinimapChart",data:t,accessors:{xAccessor:p,yAccessor:m}});if(de)return(0,Oy.jsx)(wp,{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,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===P?()=>null:su(P)||ue,...q&&{xExtent:q},...N&&{yExtent:N},...void 0!==e.axisExtent&&{axisExtent:e.axisExtent},...void 0!==e.autoPlaceAnnotations&&{autoPlaceAnnotations:e.autoPlaceAnnotations},...$},me={chartType:he,data:Q,xAccessor:p,yAccessor:m,groupAccessor:y||void 0,curve:v,lineStyle:ne,size:[n,ae+ce.top+ce.bottom],margin:ce,showAxes:R.showAxes??!1,background:R.background,enableHover:!1,...N&&{yExtent:N}},ye=(0,Oy.jsxs)("div",{style:{position:"relative",width:n,overflow:"hidden"},children:[(0,Oy.jsx)(Zd,{ref:Y,...me}),(0,Oy.jsx)(Ey,{width:n-ce.left-ce.right,height:ae,margin:ce,scales:V,brushDirection:le,extent:q,onBrush:G})]},"minimap"),fe=(0,Oy.jsx)("div",{style:{overflow:"hidden"},children:(0,Oy.jsx)(Zd,{...pe})},"main");return O||F||(0,Oy.jsx)(jp,{componentName:"MinimapChart",width:n,height:o,children:(0,Oy.jsxs)("div",{className:"minimap-chart"+(i?" "+i:""),children:[T?ye:fe,T?fe:ye]})})}Fy.displayName="MinimapChart";var zy=require("react"),Hy={label:"Low / High",color:"#E9C46A",opacity:.08},Wy={label:"High / High",color:"#2A9D8F",opacity:.08},qy={label:"Low / Low",color:"#E76F51",opacity:.08},Gy={label:"High / Low",color:"#86BBD8",opacity:.08};T();var Yy=require("react/jsx-runtime");function Vy(e,t){return{label:t?.label??e.label,color:t?.color??e.color,opacity:t?.opacity??e.opacity}}var Xy=(0,zy.forwardRef)(function(e,t){const n=(0,zy.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:P,linkedHover:R,onObservation:T,onClick:_,hoverHighlight:L,chartId:N,loading:$,loadingContent:D,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,zy.useMemo)(()=>({topLeft:Vy(Hy,p?.topLeft),topRight:Vy(Wy,p?.topRight),bottomLeft:Vy(qy,p?.bottomLeft),bottomRight:Vy(Gy,p?.bottomRight)}),[p]),ne=(0,zy.useMemo)(()=>ft(r),[r]),oe=qp({data:ne,rawData:r,colorBy:g,colorScheme:b,legendInteraction:E,legendPosition:O,selection:P,linkedHover:R,fallbackFields:"string"==typeof g?[g]:[],unwrapData:!1,onObservation:T,onClick:_,hoverHighlight:L,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"QuadrantChart",chartId:N,showLegend:X,userMargin:i,marginDefaults:o.marginDefaults,loading:$,loadingContent:D,emptyContent:B,width:q,height:G,hasTitle:!!U,axisChrome:es({showAxes:o.showAxes,xLabel:J})});_p("QuadrantChart",ne,"xAccessor",l),_p("QuadrantChart",ne,"yAccessor",u);const re=(0,zy.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,zy.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?I(e):void 0},[ne,x]),se=(0,zy.useMemo)(()=>"function"==typeof l?l:e=>+e[l],[l]),ae=(0,zy.useMemo)(()=>"function"==typeof u?u:e=>+e[u],[u]),ce=(0,zy.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,zy.useMemo)(()=>x?e=>Tn(e,x,w,ie):void 0,[x,w,ie]),ue=(0,zy.useMemo)(()=>Xp(l,u),[l,u]),de=ey({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,zy.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,zy.useMemo)(()=>Cd([...he?[{label:he,accessor:he,role:"title"}]:[],{label:J||xd(l),accessor:l,role:"x",format:a},{label:ee||xd(u),accessor:u,role:"y",format:c},...g?[{label:xd(g),accessor:g,role:"color"}]:[],...x?[{label:xd(x),accessor:x,role:"size"}]:[]]),[he,l,u,J,ee,g,x,a,c]),me=Ep({componentName:"QuadrantChart",data:r,accessors:{xAccessor:l,yAccessor:u}}),ye=(0,zy.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,zy.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,zy.useMemo)(()=>{const e=j.canvasPreRenderers||[];return[...fe,...e]},[fe,j.canvasPreRenderers]),be=(0,zy.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,Yy.jsxs)(Yy.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,Yy.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,Yy.jsx)("line",{x1:c,y1:0,x2:c,y2:i,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),(0,Yy.jsx)("line",{x1:0,y1:l,x2:r,y2:l,stroke:e.stroke,strokeWidth:e.strokeWidth,strokeDasharray:e.dashArray}),y&&(0,Yy.jsxs)(Yy.Fragment,{children:[(0,Yy.jsx)("text",{x:8,y:8+f,fill:te.topLeft.color,fontWeight:600,fontSize:f,opacity:.5,children:te.topLeft.label}),(0,Yy.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,Yy.jsx)("text",{x:8,y:i-8,fill:te.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5,children:te.bottomLeft.label}),(0,Yy.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,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:su(A)||pe,...rm({linkedHover:R,selection:P,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,Yy.jsx)(wp,{componentName:"QuadrantChart",message:me,width:q,height:G}):(0,Yy.jsx)(jp,{componentName:"QuadrantChart",width:q,height:G,children:(0,Yy.jsx)(Zd,{ref:n,...ve})})});Xy.displayName="QuadrantChart";var Uy=d(require("react")),Ky=require("react"),Qy=require("react/jsx-runtime"),Zy="__ma_unitized",Jy="__ma_series";function ef(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function tf(e,t){return t[0]+e*(t[1]-t[0])}var nf=(0,Ky.forwardRef)(function(e,t){const n=(0,Ky.useRef)(null),o=(0,Ky.useRef)([]),r=(0,Ky.useRef)(e.series);r.current=e.series,(0,Ky.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,[Zy]:ef(a,s),[Jy]: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,[Zy]:ef(a,s),[Jy]: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=vp(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:I,stroke:P,strokeWidth:R,opacity:T}=e,{width:_,height:L,enableHover:N,showGrid:$,showLegend:D=!0,title:B,description:E,summary:O,accessibleTable:F,xLabel:z}=i,H=(0,Ky.useMemo)(()=>ft(s),[s]),W=(0,Ky.useMemo)(()=>ft(d),[d]),q=W,G=2===W.length,Y=(0,Ky.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=Tp(A,_,L,C),X=V?null:Rp(s,_,L,M),U=pp(),K=(0,Ky.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,Ky.useMemo)(()=>W.map((e,t)=>e.label||"Series "+(t+1)),[W]),{unitizedData:Z,extents:J}=(0,Ky.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,[Zy]:r,[Jy]: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,[Zy]:ef(i,e[o]),[Jy]:Q[o]})}return{unitizedData:t,extents:e}},[H,W,G,Q]),ee=(0,Ky.useMemo)(()=>{if(G&&J.length>=2)return[{orient:"left",label:Q[0],tickFormat:W[0].format||(e=>{const t=tf(e,J[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:Q[1],tickFormat:W[1].format||(e=>{const t=tf(e,J[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[G,J,W,Q]),te=qp({data:(0,Ky.useMemo)(()=>Z.length>0?Z:Q.map(e=>({[Jy]:e})),[Z,Q]),rawData:s,colorBy:Jy,colorScheme:K,legendInteraction:j,legendPosition:I,selection:b,linkedHover:v,fallbackFields:[Jy],unwrapData:!1,onObservation:x,onClick:w,hoverHighlight:k,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"MultiAxisLineChart",chartId:S,showLegend:D,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,Ky.useMemo)(()=>{const e=new Map;return Q.forEach((t,n)=>e.set(t,K[n])),e},[Q,K]),oe=em({lineWidth:m,resolveStroke:(0,Ky.useCallback)(e=>ne.get(e[Jy])||K[0],[ne,K]),stroke:P,strokeWidth:R,opacity:T,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=(0,Ky.useMemo)(()=>{if(!1===y)return()=>null;return su(y)||(e=>{const t=e.data||e,n=t[Jy],o=Q.indexOf(n),r=t[Zy],i=G&&o>=0&&J[o]?tf(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 Uy.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},Uy.createElement("div",{style:{fontWeight:600,marginBottom:4,color:K[o]||"inherit"}},n),Uy.createElement("div",null,`${"string"==typeof u?u:"x"}: ${a}`),Uy.createElement("div",null,`${n}: ${s(i)}`))})},[y,Q,K,J,G,W,u]);if(te.earlyReturn)return te.earlyReturn;const ie=Ep({componentName:"MultiAxisLineChart",data:s,accessors:{xAccessor:u}}),se=G?[0,1]:void 0,ae={chartType:"line",...null!=s&&{data:Z},xAccessor:u,yAccessor:Zy,groupAccessor:Jy,lineStyle:oe,colorScheme:K,size:[_,L],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,showAxes:i.showAxes,...ee&&{axes:ee},xLabel:z,...G?{}:{yLabel:Q[0]},xFormat:l,...G&&se&&{yExtent:se},enableHover:N,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:$,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},...rm({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,Qy.jsx)(wp,{componentName:"MultiAxisLineChart",message:ie,width:_,height:L}):(0,Qy.jsx)(jp,{componentName:"MultiAxisLineChart",width:_,height:L,children:(0,Qy.jsx)(Zd,{ref:n,...ae})}))});nf.displayName="MultiAxisLineChart";var of=require("react"),rf=require("react/jsx-runtime"),sf=(0,of.forwardRef)(function(e,t){const n=(0,of.useRef)(null);nm(t,{variant:"xy",frameRef:n});const o=vp(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:I,height:P,enableHover:R,showGrid:T,title:_,description:L,summary:N,accessibleTable:$,xLabel:D,yLabel:B}=o,E=Tp(C,I,P,M),O=E?null:Rp(r,I,P,j),F=(0,of.useMemo)(()=>ft(r),[r]),z=null==h||null==p;_p("CandlestickChart",F,"xAccessor",l),_p("CandlestickChart",F,"highAccessor",u),_p("CandlestickChart",F,"lowAccessor",d),z||(_p("CandlestickChart",F,"openAccessor",h),_p("CandlestickChart",F,"closeAccessor",p));const{customHoverBehavior:H,customClickBehavior:W,crosshairSourceId:q}=gp({selection:x,linkedHover:w,onObservation:k,onClick:S,chartType:"CandlestickChart",chartId:A,mobileInteraction:o.mobileInteraction}),G=bp(w,q),Y=(0,of.useMemo)(()=>{const e=o.marginDefaults,t="sparkline"===o.mode?{...e,top:0,bottom:0}:e;return null==i?t:{...t,...vm(i)}},[i,o.marginDefaults,o.mode]),V=(0,of.useMemo)(()=>{const e=[{label:D||xd(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})),Cd(e)},[l,D,a,c,u,d,h,p,z]),X=Ep({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(I/40))),extentPadding:I>200?.1:.02,size:[I,P],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Y,showAxes:o.showAxes,xLabel:D,yLabel:B,xFormat:a,yFormat:c,enableHover:R,showGrid:T,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},...om({title:_,description:L,summary:N,accessibleTable:$,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:y,defaultTooltipContent:V}),...rm({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,rf.jsx)(wp,{componentName:"CandlestickChart",message:X,width:I,height:P}):(0,rf.jsx)(jp,{componentName:"CandlestickChart",width:I,height:P,children:(0,rf.jsx)(Zd,{ref:n,...U})}))});sf.displayName="CandlestickChart";var af=require("react"),cf=require("react"),lf=require("d3-scale"),uf=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 df(e){const t=e.getSymbol;return t?fo(t,e.config.symbolMap):null}function hf(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 pf(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 mf=require("d3-array");function yf(e){const t=e.length,n=e[0],o=e[t-1];return{n:t,min:n,q1:(0,mf.quantile)(e,.25)??n,median:(0,mf.quantile)(e,.5)??(n+o)/2,q3:(0,mf.quantile)(e,.75)??o,max:o,mean:e.reduce((e,t)=>e+t,0)/t}}T();var ff=require("d3-scale"),gf={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=df(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);hf(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=df(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;hf(c,u,o,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:pf,donut:pf,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,mf.quantile)(n,.25)??o,h=(0,mf.quantile)(n,.5)??(o+r)/2,p=(0,mf.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=P(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,mf.quantile)(t,.25)??n,i=(0,mf.quantile)(t,.5)??(n+o)/2,s=(0,mf.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:yf(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]=I(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=P(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=P(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:yf(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,ff.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 bf(e,t,n){return An(e,t,n)}function vf(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Pn(n,e)||"#4e79a7":t=>{if(n){const e=Pn(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 xf=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wf=["scene-style","data-paint","accessibility","evidence"],kf=(e,t)=>({retainedData:e,invalidations:t}),Sf=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Af=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Cf=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mf=["scene-geometry","data-paint","accessibility","evidence"],jf=["scene-style","data-paint","accessibility","evidence"],If=[],Pf={chartType:kf("rebuild",Sf),runtimeMode:kf("rebuild",Sf),categoryAccessor:kf("rebuild",Sf),valueAccessor:kf("rebuild",Sf),oAccessor:kf("rebuild",Sf),rAccessor:kf("rebuild",Sf),stackBy:kf("rebuild",Sf),groupBy:kf("rebuild",Sf),timeAccessor:kf("rebuild",Sf),accessorRevision:kf("rebuild",Sf),colorAccessor:kf("rebuild",jf),symbolAccessor:kf("rebuild",Mf),connectorAccessor:kf("rebuild",Mf),dataIdAccessor:kf("rebuild",Mf),projection:kf("preserve",Af),extentPadding:kf("preserve",Af),axisExtent:kf("preserve",Af),rExtent:kf("preserve",Af),oExtent:kf("preserve",Af),multiAxis:kf("preserve",Af),normalize:kf("preserve",Af),bins:kf("preserve",Af),oSort:kf("preserve",Cf),barPadding:kf("preserve",Cf),roundedTop:kf("preserve",Cf),baselinePadding:kf("preserve",Cf),innerRadius:kf("preserve",Cf),cornerRadius:kf("preserve",Cf),startAngle:kf("preserve",Cf),sweepAngle:kf("preserve",Cf),trackFill:kf("preserve",Cf),showOutliers:kf("preserve",Cf),showIQR:kf("preserve",Cf),amplitude:kf("preserve",Cf),connectorOpacity:kf("preserve",Cf),showLabels:kf("preserve",Cf),dynamicColumnWidth:kf("rebuild",Cf),customLayout:kf("preserve",Cf),layoutConfig:kf("preserve",Cf),layoutMargin:kf("preserve",Cf),symbolMap:kf("preserve",Mf),pieceStyle:kf("preserve",jf),summaryStyle:kf("preserve",jf),connectorStyle:kf("preserve",jf),gradientFill:kf("preserve",jf),colorScheme:kf("preserve",jf),themeCategorical:kf("preserve",jf),themeSemantic:kf("preserve",jf),themeSequential:kf("preserve",jf),themeDiverging:kf("preserve",jf),barColors:kf("preserve",jf),decay:kf("preserve",jf),pulse:kf("preserve",jf),staleness:kf("preserve",jf),layoutSelection:kf("preserve",jf),windowSize:kf("preserve",If),windowMode:kf("preserve",If),clock:kf("preserve",If),transition:kf("preserve",If),introAnimation:kf("preserve",If),onLayoutError:kf("preserve",If)},Rf=kf("preserve",Cf),Tf=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}},xf)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},wf):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Pf[o]??Rf;"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)}},_f=require("d3-quadtree"),Lf=class{constructor(e){this.rExtent=new Ft,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Tf,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new uf,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?.()??$n()}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(),Po(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,lf.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;m=(0,lf.scaleLinear)().domain(l).range([o,n])}else u?(p=(0,lf.scaleBand)().domain(c).range([0,e.height]).padding(h),m=(0,lf.scaleLinear)().domain(l).range([0,e.width])):(p=(0,lf.scaleBand)().domain(c).range([0,e.width]).padding(h),m=(0,lf.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,lf.scaleLinear)().domain([s,a]).range([0,e.width]):(0,lf.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=gf[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=bf(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:vf(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,_f.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=Nn(o?o.opacity??1:0,e._targetOpacity,n)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Nn(o.x,e._targetX,n),e.y=Nn(o.y,e._targetY,n)),void 0!==e._targetR&&void 0!==o?.r&&(e.r=Nn(o.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style.opacity=Nn(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=Nn(o.x,e._targetX,n),e.y=Nn(o.y,e._targetY,n),void 0!==o.w&&(e.w=Nn(o.w,e._targetW,n),e.h=Nn(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:Nn(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=Nn(o.startAngle,e._targetStartAngle,n),e.endAngle=Nn(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 Nf(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=$f(i,t,n);break;case"point":if(r)break;e=Df(i,t,n,o);break;case"symbol":e=Bf(i,t,n,o);break;case"glyph":e=Ef(i,t,n,o);break;case"wedge":if(null===i.datum)break;e=Of(i,t,n);break;case"boxplot":e=Ff(i,t,n);break;case"violin":e=zf(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function $f(e,t,n){const o=Ir(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function Df(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Pr(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function Bf(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>Pr(yo(e.size),o)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function Ef(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>Pr(r.radius,o)?null:{datum:e.datum,x:i,y:s,distance:l}}function Of(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 Ff(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 zf(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(Lf);var Hf=require("react"),Wf=require("react/jsx-runtime");function qf(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,Hf.useMemo)(()=>!s||h?[]:(u||nc(s.r,5,d)).map(e=>({value:e,pixel:s.r(e),label:(l||Gf)(e)})),[s,l,h,u,d]),y=c&&s&&!h,f=a&&s&&!h;return y||f?(0,Wf.jsx)("svg",{width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:(0,Wf.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(0,Wf.jsx)("g",{className:"ordinal-grid",children:m.map((e,o)=>(0,Wf.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,Wf.jsx)(Wf.Fragment,{children:(0,Wf.jsxs)(Wf.Fragment,p?{children:[(0,Wf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Wf.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[(0,Wf.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Wf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function Gf(e){return Math.round(100*e)/100+""}function Yf(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:I,svgAnnotationRules:P,xAccessor:R,yAccessor:T,annotationData:_,underlayRendered:L,canvasObscuresUnderlay:N=!0,children:$}=e,D=Xs({onAnnotationActivate:A,onObservation:C,chartId:M,chartType:j}),B="radial"===s?.projection,E="horizontal"===s?.projection,O=!1!==c,F=!L||N,z=(0,Hf.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,Hf.useMemo)(()=>a&&s&&!B?(H||nc(s.r,5,q)).map(e=>({value:e,pixel:s.r(e),label:(h||Gf)(e)})):[],[a,s,h,B,H,q]),Y=(0,Hf.useRef)(new Map),V=(0,Hf.useRef)(S?.length??0),X=S?.length??0;V.current!==X&&(V.current=X,Y.current=new Map);const U=(0,Hf.useMemo)(()=>{if(!S||0===S.length)return null;const e=Wa(S),o=ra(0,D),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(I?ja({annotations:e,context:a,..."object"==typeof I?I:{}}):e,o,P,a)},[S,I,P,t,n,s,R,T,_,D]);return a||m||y||k||U&&U.length>0||p||$?(0,Wf.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Wf.jsx)("title",{children:"string"==typeof m?m:"Ordinal Chart"}),(0,Wf.jsx)("desc",{children:"string"==typeof m?m+" (ordinal data visualization)":"Ordinal data visualization"}),(0,Wf.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&!B&&F&&(0,Wf.jsx)("g",{className:"ordinal-grid",children:G.map((e,o)=>(0,Wf.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,Wf.jsx)("g",{className:"ordinal-axes",children:(0,Wf.jsxs)(Wf.Fragment,E?{children:[(0,Wf.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[F&&(0,Wf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),z.map((t,n)=>(0,Wf.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Wf.jsx)("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?(0,Wf.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,Wf.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Wf.jsx)("div",{style:{textAlign:"right",userSelect:"none",...e},children:t.label})})]},"cat-"+n)),l&&(0,Wf.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,Wf.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[F&&(0,Wf.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,Wf.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,Wf.jsxs)("g",{transform:`translate(${t.pixel},${n})`,children:[(0,Wf.jsx)("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Wf.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,Wf.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,Wf.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,Wf.jsx)("line",{x1:0,y1:o,x2:t,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),z.map((t,o)=>(0,Wf.jsxs)("g",{transform:`translate(${t.pixel},${n})`,children:[(0,Wf.jsx)("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?(0,Wf.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,Wf.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Wf.jsx)("div",{style:{textAlign:"center",userSelect:"none",...e},children:t.label})})]},"cat-"+o)),l&&(0,Wf.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,Wf.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[F&&(0,Wf.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),G.map((t,n)=>(0,Wf.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Wf.jsx)("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),(0,Wf.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,Wf.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,$]}),m&&"string"==typeof m?(0,Wf.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,Wf.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 Vf=d(require("react")),Xf=require("react/jsx-runtime"),Uf=null,Kf=null;function Qf(e){const[t,n]=Vf.useState(()=>Uf);return Vf.useEffect(()=>{if(t)return;let e=!1;return(Uf?Promise.resolve(Uf):(Kf||(Kf=Promise.resolve().then(()=>(be(),fe)).then(e=>Uf=e.OrdinalBrushOverlay).catch(e=>{throw Kf=null,e})),Kf)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,Xf.jsx)(t,{...e}):null}var Zf=require("d3-shape");function Jf(e,t){const n=t._gradientBand.colors;if(0===n.length)return;const{clipPath:o,slices:r}=$c({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 eg(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 tg(e,t){const n={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},o=(0,Zf.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 ng=(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)Jf(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(eg(e,t),Yu(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=Nc({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),tg(e,t)):(eg(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&&(eg(e,t),Yu(e,t)),e.globalAlpha=1}},og=(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()}},rg=(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()}},ig=(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}},sg=(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 ag(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 cg(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}var lg=new Map;function ug(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=lg.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 lg.set(n,i),i}function dg(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 hg(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 pg(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}function mg(e){return"rect"===e.type||"point"===e.type||"symbol"===e.type||"glyph"===e.type}function yg(e){return(t,n,o,r)=>{e(t,n.filter(mg),{x:o.r,y:o.r},r)}}var fg=yg(sd),gg=yg(Qu),bg=yg(ed),vg=yg(nd),xg=e=>[ig,...e],wg={bar:xg([fg]),clusterbar:xg([fg]),point:xg([gg,bg]),swarm:xg([gg,bg]),pie:[ng],donut:[ng],boxplot:xg([og,gg]),violin:xg([rg]),histogram:xg([fg]),ridgeline:xg([rg]),timeline:xg([fg]),funnel:[fg,sg,(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?ag(r):null!=i?`${ag(r)} (${cg(i)})`:ag(r),e.measureText(a).width+16>o){if(s||null==i)continue;if(a=ag(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":[fg,(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=ug(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?pg(r):"",d=hg(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(),dg(e,g,b,m,y,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),dg(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:xg([fg]),custom:xg([fg,gg,bg,vg,ng,og,rg,sg])},kg=require("react/jsx-runtime");function Sg(e){const t=Zl(e,{skipPositional:!1});return null==t.title&&0===t.entries.length?null:(0,kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=t.title&&(0,kg.jsx)("div",{style:{fontWeight:"bold"},children:t.title+""}),t.entries.map(e=>(0,kg.jsxs)("div",{children:[(0,kg.jsxs)("span",{style:{opacity:.7},children:[e.key,":"]})," ","number"==typeof e.value?e.value.toLocaleString():e.value+""]},e.key))]})}function Ag({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,kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[e&&(0,kg.jsx)("div",{style:{fontWeight:"bold"},children:e+""}),(0,kg.jsxs)("div",{children:["n = ",n.n]}),(0,kg.jsxs)("div",{children:["Min: ",n.min.toLocaleString()]}),(0,kg.jsxs)("div",{children:["Q1: ",n.q1.toLocaleString()]}),(0,kg.jsxs)("div",{children:["Median: ",n.median.toLocaleString()]}),(0,kg.jsxs)("div",{children:["Q3: ",n.q3.toLocaleString()]}),(0,kg.jsxs)("div",{children:["Max: ",n.max.toLocaleString()]}),(0,kg.jsxs)("div",{style:{opacity:.8},children:["Mean: ",n.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const r=t.length;return(0,kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[e&&(0,kg.jsx)("div",{style:{fontWeight:"bold"},children:e+""}),(0,kg.jsxs)("div",{children:[r," items"]})]})}if(null!=t.bin&&null!=t.count){const e=t.range||[];return(0,kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[t.category&&(0,kg.jsx)("div",{style:{fontWeight:"bold"},children:t.category+""}),(0,kg.jsxs)("div",{children:["Count: ",t.count]}),2===e.length&&(0,kg.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 Sg(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,kg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[a&&(0,kg.jsx)("div",{style:{fontWeight:"bold"},children:a+""}),""!==c&&(0,kg.jsx)("div",{children:"number"==typeof c?c.toLocaleString():c+""})]}):Sg(t)}Ag.ownsChrome=!0;var Cg=require("react/jsx-runtime"),Mg={top:50,right:40,bottom:60,left:70},jg=(0,cf.memo)((0,cf.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,barPadding:k,roundedTop:S,gradientFill:A,trackFill:C,baselinePadding:M,innerRadius:j,cornerRadius:I,normalize:P,startAngle:R,sweepAngle:T,dynamicColumnWidth:_,bins:L,showOutliers:N,showIQR:$,amplitude:D,connectorOpacity:B,showLabels:E,connectorAccessor:O,connectorStyle:F,dataIdAccessor:z,rExtent:H,oExtent:W,extentPadding:q=.05,oSort:G,windowMode:Y="sliding",windowSize:V=200,pieceStyle:X,summaryStyle:U,renderMode:K,colorScheme:Q,barColors:Z,showAxes:J=!0,showCategoryTicks:ee,categoryLabel:te,valueLabel:ne,categoryFormat:oe,valueFormat:re,oLabel:ie,rLabel:se,oFormat:ae,rFormat:ce,rTickValues:le,tickLabelEdgeAlign:ue,axisExtent:de,enableHover:he=!0,hoverAnnotation:pe,tooltipContent:me,customHoverBehavior:ye,customClickBehavior:fe,onObservation:ge,annotationObservationCallback:be,chartId:ve,annotations:xe,onAnnotationActivate:we,autoPlaceAnnotations:ke,svgAnnotationRules:Se,showGrid:Ae=!1,legend:Ce,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ie,legendIsolatedCategories:Pe,legendPosition:Re,legendLayout:Te,legendCategoryAccessor:_e,onCategoriesChange:Le,backgroundGraphics:Ne,foregroundGraphics:$e,title:De,className:Be,background:Ee,centerContent:Oe,decay:Fe,pulse:ze,transition:He,animate:We,staleness:qe,frameScheduler:Ge,clock:Ye,random:Ve,seed:Xe,paused:Ue=!1,suspendWhenHidden:Ke=!0,brush:Qe,onBrush:Ze,accessibleTable:Je=!0,description:et,summary:tt,customLayout:nt,onLayoutError:ot,layoutConfig:rt,layoutSelection:it}=e,{customHoverBehavior:st,customClickBehavior:at,hasClickBehavior:ct}=$d({customHoverBehavior:ye,customClickBehavior:fe,onObservation:ge,chartId:ve,chartType:"StreamOrdinalFrame"}),lt=y??i,ut=m??s,dt=(0,cf.useRef)(!0),ht=Su({sizeProp:b,responsiveWidth:v,responsiveHeight:x,userMargin:w,marginDefault:Mg,title:De,legend:Ce,legendPosition:Re,animate:We,transitionProp:He,frameScheduler:Ge,clock:Ye,random:Ve,seed:Xe,paused:Ue,suspendWhenHidden:Ke,themeDirtyRef:dt}),{reducedMotionRef:pt,responsiveRef:mt,size:yt,margin:gt,adjustedWidth:bt,adjustedHeight:vt,currentTheme:xt,transition:wt,introEnabled:kt,tableId:St,rafRef:Ct,renderFnRef:Mt,scheduleRender:jt,frameRuntime:It}=ht,Pt=Gc(),Tt=Uc(),_t=(0,cf.useMemo)(()=>ft(r),[r]),Lt=te??ie,Nt=ne??se,$t=oe??ae,Dt=re??ce,Bt=(0,cf.useRef)(null),[Et,Ot]=(0,cf.useState)(null),[Ft,zt]=(0,cf.useState)(null),Ht=Pu($e,yt,gt,Ft),Wt=Pu(Ne,yt,gt,Ft),qt=Ne||"transparent"===Ee?null:(0,Cg.jsx)("rect",{className:"semiotic-canvas-background","data-semiotic-layer":"canvas-background",x:-gt.left,y:-gt.top,width:yt[0],height:yt[1],fill:Ee||"var(--semiotic-bg, transparent)"}),[Gt,Yt]=(0,cf.useState)(0),Vt=(0,cf.useRef)(0),[Xt,Ut]=(0,cf.useState)(!1),Kt=(0,cf.useRef)({w:-1,h:-1}),Qt=(0,cf.useRef)(!1),Zt=yr("StreamOrdinalFrame"),Jt=he||pe,en="streaming"===o,tn=Qc((0,cf.useMemo)(()=>({chartType:n,runtimeMode:en?"streaming":"bounded",windowSize:V,windowMode:Y,extentPadding:q,projection:g,oAccessor:en?void 0:lt,rAccessor:en?void 0:ut,accessorRevision:f,colorAccessor:a,symbolAccessor:c,symbolMap:l,stackBy:u,groupBy:d,multiAxis:h,timeAccessor:en?p:void 0,valueAccessor:en?m||("string"==typeof ut||"function"==typeof ut?ut:void 0):void 0,categoryAccessor:en?lt:void 0,rExtent:H,oExtent:W,axisExtent:de,barPadding:k,roundedTop:S,gradientFill:ao(A),trackFill:C,baselinePadding:M,innerRadius:j,cornerRadius:I,normalize:P,startAngle:R,sweepAngle:T,dynamicColumnWidth:_,bins:L,showOutliers:N,showIQR:$,amplitude:D,connectorOpacity:B,showLabels:E,connectorAccessor:O,connectorStyle:F,dataIdAccessor:z,oSort:G,pieceStyle:X,summaryStyle:U,colorScheme:Q,themeCategorical:xt?.colors?.categorical,themeSemantic:Rt(xt),themeSequential:xt?.colors?.sequential,themeDiverging:xt?.colors?.diverging,barColors:Z,decay:Fe,pulse:ze,transition:wt,introAnimation:kt,staleness:qe,clock:It.now,customLayout:nt,onLayoutError:ot,layoutConfig:rt,layoutMargin:gt}),[n,en,V,Y,q,g,lt,ut,f,a,c,l,u,d,h,p,m,H,W,de,k,S,A,C,M,j,I,P,R,T,_,L,N,$,D,B,E,O,F,z,G,X,U,Q,xt,Z,Fe,ze,wt,kt,qe,It.now,nt,ot,rt,gt])),nn=(0,cf.useRef)(null);nn.current||(nn.current=new Lf(tn));const on=Lu(nn,_e,Le,e=>e.getData());Mr(nn,tn,dt,jt),jr(nn,it,dt,jt);const rn=(0,cf.useRef)(null);rn.current||(rn.current=new At(e=>{const t=nn.current;t&&t.ingest(e)&&(dt.current=!0,jt())}));const sn=(0,cf.useCallback)(e=>{rn.current?.push(e)},[]),an=(0,cf.useCallback)(e=>{rn.current?.pushMany(e)},[]),cn=(0,cf.useCallback)(()=>{rn.current?.clear(),nn.current?.clear(),dt.current=!0,jt()},[jt]),ln=(0,cf.useCallback)(e=>{rn.current?.clearLastData(),rn.current?.setReplacementData(e)},[]);(0,cf.useImperativeHandle)(t,()=>({push:sn,pushMany:an,replace:ln,remove:e=>{rn.current?.flush();const t=nn.current?.remove(e)??[];if(t.length>0){const e=Bt.current?.data;!!Bt.current&&t.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Bt.current=null,Ot(null)),dt.current=!0,jt()}return t},update:(e,t)=>{rn.current?.flush();const n=nn.current?.update(e,t)??[];return n.length>0&&(dt.current=!0,jt()),n},clear:cn,getData:()=>(rn.current?.flush(),nn.current?.getData()??[]),getScales:()=>nn.current?.scales??null,getCustomLayout:()=>nn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>nn.current?.lastCustomLayoutFailure??null}),[sn,an,ln,cn,jt]),(0,cf.useEffect)(()=>{r&&rn.current?.setBoundedData(_t)},[r,_t]);const{canvasRef:un}=Mu(ht,{storeRef:nn,dirtyRef:dt,hydrated:Pt,wasHydratingFromSSR:Tt,cleanup:()=>rn.current?.clear(),canvasPaintDependencies:[n,bt,vt,J,Ee,Ne,K,jt]}),{hoverHandlerRef:dn,hoverLeaveRef:hn,onPointerMove:pn,onPointerLeave:mn}=ht;dn.current=e=>{if(!Jt)return;const t=un.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-gt.left,i=e.clientY-o.top-gt.top;if(0>r||r>bt||0>i||i>vt)return void(Bt.current&&(Bt.current=null,Ot(null),st&&st(null),jt()));const s=nn.current;if(!s||0===s.scene.length)return;const a="radial"===g,c=Nf(s.scene,a?r-bt/2:r,a?i-vt/2:i,30,s.pointQuadtree,s.maxPointRadius);if(!c)return void(Bt.current&&(Bt.current=null,Ot(null),st&&st(null),jt()));const l=Yl(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof lt?lt:void 0,__rAccessor:"string"==typeof ut?ut:void 0,__chartType:n});Bt.current=l,Ot(l),st?.(l),jt()},hn.current=()=>{Bt.current&&(Bt.current=null,Ot(null),st?.(null),jt())};const yn=(0,cf.useCallback)(e=>{if(Qs(e.target))return;if(!at)return;const t=un.current;if(!t)return at(null),void jt();const o=t.getBoundingClientRect(),r=e.clientX-o.left-gt.left,i=e.clientY-o.top-gt.top;if(0>r||r>bt||0>i||i>vt)return at(null),void jt();const s=nn.current;if(!s||0===s.scene.length)return at(null),void jt();const a="radial"===g,c=Nf(s.scene,a?r-bt/2:r,a?i-vt/2:i,30,s.pointQuadtree,s.maxPointRadius);if(!c)return at(null),void jt();at(Yl(c.datum||{},c.x,c.y,{...c.stats&&{stats:c.stats},...c.category&&{category:c.category},__oAccessor:"string"==typeof lt?lt:void 0,__rAccessor:"string"==typeof ut?ut:void 0,__chartType:n}),{type:"activate",inputType:Rd(e.nativeEvent.pointerType)}),jt()},[at,un,gt.left,gt.top,bt,vt,g,lt,ut,n,jt]),{kbFocusIndexRef:fn,focusedNavPointRef:gn,onKeyDown:bn}=function({chartType:e,oAccessor:t,rAccessor:n,...o}){return Gd({...o,extractPoints:Hd,toHover:o=>({...qd(o),__oAccessor:"string"==typeof t?t:void 0,__rAccessor:"string"==typeof n?n:void 0,__chartType:e})})}({storeRef:nn,hoverRef:Bt,setHoverPoint:Ot,customHoverBehavior:st,customClickBehavior:at,scheduleRender:jt,chartType:n,oAccessor:lt,rAccessor:ut}),vn=(0,cf.useCallback)(e=>{fn.current=-1,gn.current=null,pn(e)},[gn,fn,pn]);Mt.current=()=>{if(Ct.current=null,!It.isActive)return;const e=un.current;if(!e)return;const t=e.getContext("2d");if(!t)return;const o=nn.current;if(!o)return;const r=It.now(),i=o.advanceTransition(pt.current?r+1e6:r),s=!pt.current&&i,a=Kt.current.w!==bt||Kt.current.h!==vt,c=dt.current;let l=!1;const u=Zt.current.beforeCompute(o.getLastUpdateResult(),s);!c&&!a||s&&!a||(o.computeScene({width:bt,height:vt}),Kt.current={w:bt,h:vt},l=!0,on()),Zt.current.afterCompute(u,l,a),dt.current=c&&s&&!l;const d=Iu(o,r,l,Qt);(l||s)&&e.setAttribute("aria-label",wl(o.scene,n+" chart"));const h=Tu(),p=yt[0]*h,m=yt[1]*h;e.width===p&&e.height===m||(e.width=p,e.height=m,e.style.width=yt[0]+"px",e.style.height=yt[1]+"px"),t.setTransform(h,0,0,h,0,0),t.clearRect(0,0,yt[0],yt[1]);const y=qe&&o.lastIngestTime>0&&r-o.lastIngestTime>(qe?.threshold??5e3);y&&(t.globalAlpha=qe?.dimOpacity??.5);const f="radial"===g;t.save(),t.beginPath(),t.rect(gt.left,gt.top,bt,vt),t.clip(),f?(t.save(),t.translate(gt.left+bt/2,gt.top+vt/2)):t.translate(gt.left,gt.top);const b=nt?wg.custom:wg[n]||[],v={width:bt,height:vt},x=o.scales;x&&fd({context:t,nodes:o.scene,renderMode:K,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?(zt(o.scales),Yt(e=>e+1),Vt.current=r):s&&o.scales&&r-Vt.current>=33&&(Yt(e=>e+1),Vt.current=r),qe?.showBadge&&Ut(!!y),(s||null!=o.activeTransition||d.pending)&&jt()},_i(qe,nn,dt,jt,Xt,Ut);const xn=Jt&&Et?me?me(Et):(0,Cg.jsx)(Ag,{hover:Et}):null,wn="radial"===g,kn=xn?(0,Cg.jsx)(cu,{x:Et?wn?Et.x+bt/2:Et.x:0,y:Et?wn?Et.y+vt/2:Et.y:0,containerWidth:bt,containerHeight:vt,margin:gt,className:"stream-ordinal-tooltip",children:xn}):null,Sn="horizontal"===g?lt:ut,An=Nu("horizontal"===g?ut:lt,void 0,"__semiotic_resolvedO",""),Cn=Nu(Sn,void 0,"__semiotic_resolvedR",""),Mn=An.key,jn=Cn.key,In=$u(An,Cn,xe&&xe.length>0||!1);if(Hc||!Pt&&Tt){const e=nn.current;e&&r&&(e.ingest({inserts:_t,bounded:!0}),e.computeScene({width:bt,height:vt}));const t=e?.scene??[],n=e?.scales??null,o=Pu($e,yt,gt,n),i=Pu(Ne,yt,gt,n),s="radial"===g,a=s?gt.left+bt/2:gt.left,c=s?gt.top+vt/2:gt.top;return(0,Cg.jsxs)("div",{ref:mt,className:"stream-ordinal-frame"+(Be?" "+Be:""),role:"img","aria-label":et||("string"==typeof De?De:"Ordinal chart"),style:{position:"relative",width:v?"100%":yt[0],height:x?"100%":yt[1]},children:[(0,Cg.jsx)(El,{summary:tt}),(0,Cg.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:yt[0],height:yt[1],style:{position:"absolute",left:0,top:0},children:[i&&(0,Cg.jsx)("g",{transform:`translate(${gt.left},${gt.top})`,children:i}),(0,Cg.jsxs)("g",{transform:`translate(${a},${c})`,children:[Ee&&(0,Cg.jsx)("rect",{x:0,y:0,width:bt,height:vt,fill:Ee}),t.map((e,t)=>gd({node:e,index:t,renderMode:K,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,Dc.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,Dc.jsxs)(Tc.Fragment,{children:[a,(0,Dc.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,Dc.jsxs)(Tc.Fragment,{children:[a,(0,Dc.jsx)("path",{d:l,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return(0,Dc.jsxs)(Tc.Fragment,{children:[a,(0,Dc.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,Dc.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}=$c({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,Dc.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,Dc.jsx)("defs",{children:(0,Dc.jsx)("clipPath",{id:e,children:(0,Dc.jsx)("path",{d:r})})}),(0,Dc.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,Dc.jsx)("path",{d:e.d,fill:wc(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&(0,Dc.jsx)("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},i)}let r;if(o.roundedEnds)r=Nc({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,Dc.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,Dc.jsxs)("g","vertical"===t.projection?{children:[(0,Dc.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,Dc.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,Dc.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,Dc.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,Dc.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,Dc.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,Dc.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,Dc.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,Dc.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,Dc.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,Dc.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,Dc.jsx)("line",{x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,Dc.jsx)("circle",{cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,Dc.jsx)("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,Dc.jsx)("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,Dc.jsx)("g",{children:n},i)}case"connector":return(0,Dc.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,Dc.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,St)})).filter(Boolean)]})]}),(0,Cg.jsx)(Yf,{width:bt,height:vt,totalWidth:yt[0],totalHeight:yt[1],margin:gt,scales:n,showAxes:J,showCategoryTicks:ee,oLabel:Lt,rLabel:Nt,oFormat:$t,rFormat:Dt,rTickValues:le,tickLabelEdgeAlign:ue,axisExtent:de,showGrid:Ae,title:De,legend:Ce,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ie,legendIsolatedCategories:Pe,legendPosition:Re,legendLayout:Te,foregroundGraphics:br(o,Ar(nn.current?.customLayoutOverlays,it??null)),annotations:xe,onAnnotationActivate:we,onObservation:be??ge,chartId:ve,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:ke,svgAnnotationRules:Se,annotationFrame:0,xAccessor:Mn,yAccessor:jn,annotationData:In(e?.getData())}),Oe&&"radial"===g&&(0,Cg.jsx)("div",{style:{position:"absolute",left:gt.left+bt/2,top:gt.top+vt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Oe})]})}return(0,Cg.jsxs)("div",{ref:mt,className:"stream-ordinal-frame"+(Be?" "+Be:""),role:"group","aria-label":et||("string"==typeof De?De:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:v?"100%":yt[0],height:x?"100%":yt[1],overflow:"visible"},onKeyDown:bn,children:["production"!==process.env.NODE_ENV&&nn.current&&(0,Cg.jsx)(fr,{store:nn.current,diagnostics:Zt.current}),Je&&(0,Cg.jsx)(Ol,{tableId:St}),Je&&(0,Cg.jsx)(Dl,{scene:nn.current?.scene??[],chartType:n+" chart",tableId:St,chartTitle:"string"==typeof De?De:void 0}),(0,Cg.jsx)(El,{summary:tt}),(0,Cg.jsx)(yl,{hoverPoint:Et}),(0,Cg.jsxs)("div",{role:"img","aria-label":et||("string"==typeof De?De:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Jt?vn:void 0,onMouseLeave:Jt?mn:void 0,onClick:ct?yn:void 0,children:[(0,Cg.jsxs)(ju,{size:yt,margin:gt,children:[qt,Wt]}),(0,Cg.jsx)(qf,{width:bt,height:vt,totalWidth:yt[0],totalHeight:yt[1],margin:gt,scales:Ft,showAxes:J,showGrid:Ae,rFormat:Dt,rTickValues:le,axisExtent:de}),(0,Cg.jsx)("canvas",{ref:un,"aria-label":wl(nn.current?.scene??[],n+" chart"),style:{position:"absolute",top:0,left:0,width:yt[0],height:yt[1]}}),(0,Cg.jsx)(Yf,{width:bt,height:vt,totalWidth:yt[0],totalHeight:yt[1],margin:gt,scales:Ft,showAxes:J,showCategoryTicks:ee,oLabel:Lt,rLabel:Nt,oFormat:$t,rFormat:Dt,rTickValues:le,axisExtent:de,showGrid:Ae,title:De,legend:Ce,legendHoverBehavior:Me,legendClickBehavior:je,legendHighlightedCategory:Ie,legendIsolatedCategories:Pe,legendPosition:Re,legendLayout:Te,foregroundGraphics:br(Ht,Ar(nn.current?.customLayoutOverlays,it??null)),annotations:xe,onAnnotationActivate:we,onObservation:be??ge,chartId:ve,chartType:"StreamOrdinalFrame",autoPlaceAnnotations:ke,svgAnnotationRules:Se,annotationFrame:Gt,xAccessor:Mn,yAccessor:jn,annotationData:In(nn.current?.getData()),underlayRendered:!0,canvasObscuresUnderlay:!1}),(Qe||Ze)&&"radial"!==g&&(0,Cg.jsx)(Qf,{width:bt,height:vt,totalWidth:yt[0],totalHeight:yt[1],margin:gt,scales:Ft,onBrush:Ze||(()=>{})}),Oe&&"radial"===g&&(0,Cg.jsx)("div",{style:{position:"absolute",left:gt.left+bt/2,top:gt.top+vt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Oe}),qe?.showBadge&&(0,Cg.jsx)(Ni,{isStale:Xt,position:qe.badgePosition}),(0,Cg.jsx)(Hl,{active:fn.current>=0,hoverPoint:Et,margin:gt,size:yt,shape:gn.current?.shape,width:gn.current?.w,height:gn.current?.h}),kn]})]})}));jg.displayName="StreamOrdinalFrame";var Ig=jg,Pg=require("react");function Rg({ref:e,frameRef:t,setup:n}){return(0,Pg.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 Tg=require("react");function _g(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,Tg.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=In(e,t,n)}else l.fill=mp(o,r,i,p?a:void 0,s);if(f&&f.length>0){const t=Zp(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,Tg.useMemo)(()=>Yp(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,Tg.useMemo)(()=>ah(v,d??null,h),[v,d,h])}var Lg=require("react/jsx-runtime"),Ng=(0,af.forwardRef)(function(e,t){const n=vp(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,af.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:I,chartId:P,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:N,color:$,stroke:D,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,af.useMemo)(()=>ft(r),[r]),ee=qp({data:J,rawData:r,colorBy:d,colorScheme:h,legendInteraction:L,legendPosition:N,selection:A,linkedHover:C,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"BarChart",chartId:P,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}=Rg({ref:t,frameRef:o,setup:ee});_p("BarChart",J,"categoryAccessor",a),_p("BarChart",J,"valueAccessor",c);const oe=fp(J,p,c),re=pp(),ie=(0,af.useMemo)(()=>new Map,[]),se=(0,af.useMemo)(()=>Vp(c),[c]),ae=_g({colorBy:d,colorScale:ee.colorScale,color:$,themeCategorical:re,colorScheme:h,categoryIndexMap:ie,userPieceStyle:S?.pieceStyle,stroke:D,strokeWidth:B,opacity:E,styleRules:g,resolveRuleValue:se,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ce=(0,af.useMemo)(()=>Md({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,af.useMemo)(()=>ao(f),[f]);if(ee.earlyReturn)return ee.earlyReturn;const ue=Ep({componentName:"BarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ue)return(0,Lg.jsx)(wp,{componentName:"BarChart",message:ue,width:H,height:W});const de=oy(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,...om({title:V,description:X,summary:U,accessibleTable:K,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:v,defaultTooltipContent:ce}),...rm({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:I,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,Lg.jsx)(jp,{componentName:"BarChart",width:H,height:W,children:(0,Lg.jsx)(Ig,{ref:o,...pe})})});Ng.displayName="BarChart";var $g=require("react"),Dg=require("react/jsx-runtime"),Bg=(0,$g.forwardRef)(function(e,t){const n=vp(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,$g.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:I,hoverHighlight:P,chartId:R,loading:T,loadingContent:_,emptyContent:L,legendInteraction:N,legendPosition:$,color:D,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,$g.useMemo)(()=>ft(r),[r]),J=h||c,ee=qp({data:Z,rawData:r,colorBy:J,colorScheme:p,legendInteraction:N,legendPosition:$,selection:C,linkedHover:M,fallbackFields:J?["string"==typeof J?J:""]:[],unwrapData:!0,onObservation:j,onClick:I,hoverHighlight:P,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=pp(),ne=(0,$g.useMemo)(()=>new Map,[]),oe=(0,$g.useMemo)(()=>Vp(l),[l]),re=_g({colorBy:J,colorScale:ee.colorScale,color:D,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,$g.useMemo)(()=>Md({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),se=Ep({componentName:"StackedBarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{stackBy:c}}),{effectiveLegendProps:ae,effectiveMargin:ce}=Rg({ref:t,frameRef:o,setup:ee}),le=(0,$g.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,...om({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:w,defaultTooltipContent:ie}),...rm({linkedHover:M,selection:C,onObservation:j,onClick:I,hoverHighlight:P,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,Dg.jsx)(wp,{componentName:"StackedBarChart",message:se,width:z,height:H}):(0,Dg.jsx)(jp,{componentName:"StackedBarChart",width:z,height:H,children:(0,Dg.jsx)(Ig,{ref:o,...ue})})});Bg.displayName="StackedBarChart";var Eg=require("react"),Og=require("react/jsx-runtime"),Fg=(0,Eg.forwardRef)(function(e,t){const n=vp(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",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:I,chartId:P,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:N,color:$,stroke:D,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,Eg.useMemo)(()=>ft(r),[r]),Z=h||c,J=qp({data:Q,rawData:r,colorBy:Z,colorScheme:p,legendInteraction:L,legendPosition:N,selection:A,linkedHover:C,fallbackFields:Z?["string"==typeof Z?Z:""]:[],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"GroupedBarChart",chartId:P,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=pp(),te=(0,Eg.useMemo)(()=>new Map,[]),ne=(0,Eg.useMemo)(()=>Vp(l),[l]),oe=_g({colorBy:Z,colorScale:J.colorScale,color:$,themeCategorical:ee,colorScheme:p,categoryIndexMap:te,userPieceStyle:S.pieceStyle,stroke:D,strokeWidth:B,opacity:E,styleRules:b,resolveRuleValue:ne,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),re=(0,Eg.useMemo)(()=>Md({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),ie=Ep({componentName:"GroupedBarChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l},requiredProps:{groupBy:c}}),{effectiveLegendProps:se,effectiveMargin:ae}=Rg({ref:t,frameRef:o,setup:J}),ce=(0,Eg.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,...om({title:G,description:Y,summary:V,accessibleTable:X,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:x,defaultTooltipContent:re}),...rm({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:I,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior}),...w&&w.length>0&&{annotations:w},...k&&{rExtent:k},...Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e))};return ie?(0,Og.jsx)(wp,{componentName:"GroupedBarChart",message:ie,width:F,height:z}):(0,Og.jsx)(jp,{componentName:"GroupedBarChart",width:F,height:z,children:(0,Og.jsx)(Ig,{ref:o,...le})})});Fg.displayName="GroupedBarChart";var zg=require("react"),Hg=require("react");function Wg({brushProp:e,onBrushProp:t,linkedBrush:n,valueAccessor:o}){const r=(0,Hg.useMemo)(()=>ih("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),[n]),i="string"==typeof o?o:"value",s=vh({name:r?.name||"__unused_ordinal_brush__",xField:r?.xField||i}),a=(0,Hg.useRef)(s.brushInteraction);a.current=s.brushInteraction;const c=(0,Hg.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 qg=require("react/jsx-runtime"),Gg=(0,zg.forwardRef)(function(e,t){const n=vp(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);nm(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:P,onObservation:R,onClick:T,hoverHighlight:_,chartId:L,loading:N,loadingContent:$,emptyContent:D,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,zg.useMemo)(()=>ft(r),[r]),oe=qp({data:ne,rawData:r,colorBy:d,colorScheme:h,legendInteraction:B,legendPosition:E,selection:j,linkedHover:P,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:N,loadingContent:$,emptyContent:D,width:G,height:Y,hasTitle:!!K,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!ee,hasValueLabel:!!te})}),re=Wg({brushProp:S,onBrushProp:A,linkedBrush:C,valueAccessor:c}),ie=(0,zg.useMemo)(()=>{if(p)return I(ne.map(e=>"function"==typeof p?p(e):e[p]))},[ne,p]),se=pp(),ae=(0,zg.useMemo)(()=>new Map,[]),ce=_g({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,zg.useMemo)(()=>Md({categoryAccessor:a,valueAccessor:c,groupAccessor:d||void 0,valueFormat:u}),[a,c,d,u]);if(oe.earlyReturn)return oe.earlyReturn;const ue=Ep({componentName:"SwarmPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ue)return(0,qg.jsx)(wp,{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,...om({title:K,description:Q,summary:Z,accessibleTable:J,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:x,defaultTooltipContent:le}),...rm({linkedHover:P,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,qg.jsx)(jp,{componentName:"SwarmPlot",width:G,height:Y,children:(0,qg.jsx)(Ig,{ref:o,...de})})});Gg.displayName="SwarmPlot";var Yg=require("react"),Vg=require("react/jsx-runtime");function Xg(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,Vg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Vg.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),null!=o.n&&(0,Vg.jsxs)("div",{children:["n = ",o.n]}),null!=o.min&&(0,Vg.jsxs)("div",{children:["Min: ",o.min.toLocaleString()]}),null!=o.q1&&(0,Vg.jsxs)("div",{children:["Q1: ",o.q1.toLocaleString()]}),(0,Vg.jsxs)("div",{children:["Median: ",o.median.toLocaleString()]}),null!=o.q3&&(0,Vg.jsxs)("div",{children:["Q3: ",o.q3.toLocaleString()]}),null!=o.max&&(0,Vg.jsxs)("div",{children:["Max: ",o.max.toLocaleString()]}),null!=o.mean&&(0,Vg.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,Vg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Vg.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),i>0&&(0,Vg.jsxs)("div",{children:["n = ",i]}),null!=s&&(0,Vg.jsxs)("div",{children:["Median: ",s.toLocaleString()]})]})}return(0,Vg.jsx)("div",{className:"semiotic-tooltip",style:eu,children:(0,Vg.jsx)("div",{style:{fontWeight:"bold"},children:n+""})})}}var Ug=require("react/jsx-runtime"),Kg=(0,Yg.forwardRef)(function(e,t){const n=vp(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,Yg.useRef)(null);nm(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:I,legendInteraction:P,legendPosition:R,color:T,stroke:_,strokeWidth:L,opacity:N,showCategoryTicks:$,categoryFormat:D}=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,Yg.useMemo)(()=>ft(r),[r]),U=qp({data:X,rawData:r,colorBy:d,colorScheme:h,legendInteraction:P,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:I,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=pp(),Q=(0,Yg.useMemo)(()=>new Map,[]),Z=_g({colorBy:d,colorScale:U.colorScale,color:T,themeCategorical:K,colorScheme:h,categoryIndexMap:Q,userPieceStyle:void 0,stroke:_,strokeWidth:L,opacity:N,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),J=(0,Yg.useMemo)(()=>Xg(),[]);if(U.earlyReturn)return U.earlyReturn;const ee=Ep({componentName:"BoxPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ee)return(0,Ug.jsx)(wp,{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,...D&&{oFormat:D},showGrid:F,showCategoryTicks:$,...U.legendBehaviorProps,...om({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:f,defaultTooltipContent:J}),...rm({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,Ug.jsx)(jp,{componentName:"BoxPlot",width:B,height:E,children:(0,Ug.jsx)(Ig,{ref:o,...te})})});Kg.displayName="BoxPlot";var Qg=require("react"),Zg=require("react/jsx-runtime"),Jg=e=>{const t=e?.category;return null==t?"All":t+""},eb=(0,Qg.forwardRef)(function(e,t){const n=vp(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,Qg.useRef)(null);nm(t,{variant:"xy",frameRef:o});const{data:r,margin:i,className:s,categoryAccessor:a=Jg,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:I,loadingContent:P,emptyContent:R,legendInteraction:T,legendPosition:_,color:L,stroke:N,strokeWidth:$,opacity:D,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,Qg.useMemo)(()=>ft(r),[r]),Q=qp({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:I,loadingContent:P,emptyContent:R,width:O,height:F,hasTitle:!!q,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal",hasCategoryLabel:!!X,hasValueLabel:!!U})}),Z=Wg({brushProp:b,onBrushProp:v,linkedBrush:x,valueAccessor:c}),J=(0,Qg.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=pp(),te=(0,Qg.useMemo)(()=>new Map,[]),ne=_g({colorBy:h,colorScale:Q.colorScale,color:L,themeCategorical:ee,colorScheme:p,categoryIndexMap:te,userPieceStyle:void 0,stroke:N,strokeWidth:$,opacity:D,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),oe=(0,Qg.useMemo)(()=>e=>{const t=e.data||e,n=t.category||e.category||"",o=t.count,r=t.range;return(0,Zg.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Zg.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),null!=o&&(0,Zg.jsxs)("div",{children:["Count: ",o]}),r&&2===r.length&&(0,Zg.jsxs)("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]);if(Q.earlyReturn)return Q.earlyReturn;const re=Ep({componentName:"Histogram",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(re)return(0,Zg.jsx)(wp,{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,...om({title:q,description:G,summary:Y,accessibleTable:V,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:y,defaultTooltipContent:oe}),...rm({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,Zg.jsx)(jp,{componentName:"Histogram",width:O,height:F,children:(0,Zg.jsx)(Ig,{ref:o,...ie})})});eb.displayName="Histogram";var tb=require("react"),nb=require("react/jsx-runtime"),ob=(0,tb.forwardRef)(function(e,t){const n=vp(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,tb.useRef)(null);nm(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:I,chartId:P,loading:R,loadingContent:T,emptyContent:_,legendInteraction:L,legendPosition:N,color:$,stroke:D,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,tb.useMemo)(()=>ft(r),[r]),J=qp({data:Z,rawData:r,colorBy:m,colorScheme:y,legendInteraction:L,legendPosition:N,selection:A,linkedHover:C,fallbackFields:m?["string"==typeof m?m:""]:["string"==typeof a?a:""],unwrapData:!0,onObservation:M,onClick:j,hoverHighlight:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"ViolinPlot",chartId:P,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=Wg({brushProp:x,onBrushProp:w,linkedBrush:k,valueAccessor:c}),te=pp(),ne=(0,tb.useMemo)(()=>new Map,[]),oe=_g({colorBy:m,colorScale:J.colorScale,color:$,themeCategorical:te,colorScheme:y,categoryIndexMap:ne,userPieceStyle:void 0,stroke:D,strokeWidth:B,opacity:E,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),re=(0,tb.useMemo)(()=>Xg({valueAccessor:c}),[c]);if(J.earlyReturn)return J.earlyReturn;const ie=Ep({componentName:"ViolinPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ie)return(0,nb.jsx)(wp,{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,...om({title:Y,description:V,summary:X,accessibleTable:U,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:g,defaultTooltipContent:re}),...rm({linkedHover:C,selection:A,onObservation:M,onClick:j,hoverHighlight:I,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,nb.jsx)(jp,{componentName:"ViolinPlot",width:z,height:H,children:(0,nb.jsx)(Ig,{ref:o,...se})})});ob.displayName="ViolinPlot";var rb=require("react"),ib=require("react/jsx-runtime"),sb=(0,rb.forwardRef)(function(e,t){const n=vp(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,rb.useRef)(null);nm(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:I,emptyContent:P,legendInteraction:R,legendPosition:T,color:_,stroke:L,strokeWidth:N,opacity:$,categoryFormat:D}=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,rb.useMemo)(()=>ft(r),[r]),U=qp({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:I,emptyContent:P,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=fp(X,p,c),Q=pp(),Z=(0,rb.useMemo)(()=>new Map,[]),J=_g({colorBy:d,colorScale:U.colorScale,color:_,themeCategorical:Q,colorScheme:h,categoryIndexMap:Z,userPieceStyle:x?.pieceStyle,stroke:L,strokeWidth:N,opacity:$,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{r:m,fillOpacity:.8}}),ee=(0,rb.useMemo)(()=>Md({categoryAccessor:a,valueAccessor:c,valueFormat:u}),[a,c,u]);if(U.earlyReturn)return U.earlyReturn;const te=Ep({componentName:"DotPlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(te)return(0,ib.jsx)(wp,{componentName:"DotPlot",message:te,width:B,height:E});const ne=oy(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,...D&&{oFormat:D},showGrid:F,oSort:p,...U.legendBehaviorProps,...om({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:f,defaultTooltipContent:ee}),...rm({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,ib.jsx)(jp,{componentName:"DotPlot",width:B,height:E,children:(0,ib.jsx)(Ig,{ref:o,...re})})});sb.displayName="DotPlot";var ab=require("react"),cb=require("react/jsx-runtime"),lb=(0,ab.forwardRef)(function(e,t){const n=vp(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,ab.useRef)(null);nm(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:I,legendInteraction:P,legendPosition:R,color:T,stroke:_,strokeWidth:L,opacity:N,showCategoryTicks:$,categoryFormat:D}=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=qp({data:X,rawData:r,colorBy:p,colorScheme:m,legendInteraction:P,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:I,width:B,height:E,hasTitle:!!H,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===l?"horizontal":"vertical",hasCategoryLabel:!!Y,hasValueLabel:!!V})}),K=pp(),Q=(0,ab.useMemo)(()=>new Map,[]),Z=_g({colorBy:p,colorScale:U.colorScale,color:T,themeCategorical:K,colorScheme:m,categoryIndexMap:Q,userPieceStyle:void 0,stroke:_,strokeWidth:L,opacity:N,effectiveSelectionHook:U.effectiveSelectionHook,resolvedSelection:U.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),J=(0,ab.useMemo)(()=>Xg(),[]);if(U.earlyReturn)return U.earlyReturn;const ee=Ep({componentName:"RidgelinePlot",data:r,accessors:{categoryAccessor:a,valueAccessor:c}});if(ee)return(0,cb.jsx)(wp,{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,...D&&{oFormat:D},showGrid:F,showCategoryTicks:$,oSort:!1,amplitude:d,...U.legendBehaviorProps,...om({title:H,description:W,summary:q,accessibleTable:G,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:f,defaultTooltipContent:J}),...rm({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,cb.jsx)(jp,{componentName:"RidgelinePlot",width:B,height:E,children:(0,cb.jsx)(Ig,{ref:o,...te})})});lb.displayName="RidgelinePlot";var ub=require("react"),db=require("react/jsx-runtime"),hb=(0,ub.forwardRef)(function(e,t){const n=vp(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,ub.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:I,strokeWidth:P,opacity:R}=e,{width:T,height:_,enableHover:L,showLegend:N,title:$,description:D,summary:B,accessibleTable:E}=n,O=(0,ub.useMemo)(()=>ft(r),[r]),F=l||a,z=qp({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:N,userMargin:i,marginDefaults:n.marginDefaults,loading:k,loadingContent:S,emptyContent:A,width:T,height:_,hasTitle:!!$,axisChrome:{hasAxis:!1}}),H=pp(),W=(0,ub.useMemo)(()=>new Map,[]),q=_g({colorBy:F,colorScale:z.colorScale,color:j,themeCategorical:H,colorScheme:u,categoryIndexMap:W,userPieceStyle:y?.pieceStyle,stroke:I,strokeWidth:P,opacity:R,effectiveSelectionHook:z.effectiveSelectionHook,resolvedSelection:z.resolvedSelection,cycleByCategory:!0}),G=(0,ub.useMemo)(()=>Md({categoryAccessor:a,valueAccessor:c,groupAccessor:l&&l!==a?l:void 0,groupLabel:"string"==typeof l?l:"group",pieData:!0}),[a,c,l]),Y=Ep({componentName:"PieChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}}),{effectiveLegendProps:V,effectiveMargin:X}=Rg({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,...om({title:$,description:D,summary:B,accessibleTable:E,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:p,defaultTooltipContent:G}),...rm({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,db.jsx)(wp,{componentName:"PieChart",message:Y,width:T,height:_}):(0,db.jsx)(jp,{componentName:"PieChart",width:T,height:_,children:(0,db.jsx)(Ig,{ref:o,...U})})});hb.displayName="PieChart";var pb=require("react"),mb=require("react/jsx-runtime"),yb=(0,pb.forwardRef)(function(e,t){const n=vp(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,pb.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:I,color:P,stroke:R,strokeWidth:T,opacity:_}=e,{width:L,height:N,enableHover:$,showLegend:D,title:B,description:E,summary:O,accessibleTable:F}=n,z=(0,pb.useMemo)(()=>ft(r),[r]),H=d||a,W=qp({data:z,rawData:r,colorBy:H,colorScheme:h,legendInteraction:j,legendPosition:I,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:D,userMargin:i,marginDefaults:n.marginDefaults,loading:A,loadingContent:C,emptyContent:M,width:L,height:N,hasTitle:!!B,axisChrome:{hasAxis:!1}}),q=l??Math.max(2,.15*Math.min(L,N)),G=pp(),Y=(0,pb.useMemo)(()=>new Map,[]),V=_g({colorBy:H,colorScale:W.colorScale,color:P,themeCategorical:G,colorScheme:h,categoryIndexMap:Y,userPieceStyle:g?.pieceStyle,stroke:R,strokeWidth:T,opacity:_,effectiveSelectionHook:W.effectiveSelectionHook,resolvedSelection:W.resolvedSelection,cycleByCategory:!0}),X=(0,pb.useMemo)(()=>Md({categoryAccessor:a,valueAccessor:c,groupAccessor:d&&d!==a?d:void 0,groupLabel:"string"==typeof d?d:"group",pieData:!0}),[a,c,d]),U=Ep({componentName:"DonutChart",data:r,accessors:{categoryAccessor:a,valueAccessor:c}}),{effectiveLegendProps:K,effectiveMargin:Q}=Rg({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,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Q,enableHover:$,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:!1,...K,...om({title:B,description:E,summary:O,accessibleTable:F,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:y,defaultTooltipContent:X}),...rm({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,mb.jsx)(wp,{componentName:"DonutChart",message:U,width:L,height:N}):(0,mb.jsx)(jp,{componentName:"DonutChart",width:L,height:N,children:(0,mb.jsx)(Ig,{ref:o,...Z})})});yb.displayName="DonutChart";var fb=require("react");function gb(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 bb(e){return Math.max(0,Math.min(1,e))}function vb(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 xb(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 wb(e,t,n){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:bb(e.offset),color:e.color??n,opacity:null==e.opacity?1:bb(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=vb(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=bb(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=vb(t.color),l=vb(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?xb(f,g,b):`rgba(${Math.round(f)},${Math.round(g)},${Math.round(b)},${v})`}return r(o[o.length-1])}function kb(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}T();var Sb=require("react/jsx-runtime"),Ab=(0,fb.forwardRef)(function(e,t){const n=vp(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,fb.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:P}=e,{width:R,height:T,title:_,description:L,summary:N,accessibleTable:$}=n,D=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,fb.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=kb("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(wb(l.stops,e*(t+.5)/n,i||p[0]?.color||"#007bff"));const r=kb("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=kb("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=kb("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:D}),[s,a,c,l,d,h,v,w,D]),W=(0,fb.useMemo)(()=>Yp(z,{stroke:M,strokeWidth:j,opacity:P}),[z,M,j,P]),{sweepRad:q,startAngleDeg:G}=gb(x),Y=function(e=240){const{sweepRad:t,offsetRad:n}=gb(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]=I(r),[c,l]=I(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,fb.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,Sb.jsxs)("div",{style:{textAlign:"center",lineHeight:1.2},children:[(0,Sb.jsx)("div",{style:{fontSize:Math.max(16,.3*K),fontWeight:700,color:"var(--semiotic-text, #333)"},children:e}),v&&(0,Sb.jsxs)("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[a," – ",c]})]})},[g,B,a,c,b,v,K,i]),ne=(0,fb.useMemo)(()=>r&&null==g?{type:"gauge-value",text:b?b(B):Math.round(B)+""}:null,[r,g,B,b]),oe=(0,fb.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,fb.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,Sb.jsxs)("g",{transform:`translate(${o},${r})`,children:[(0,Sb.jsx)("line",{x1:0,y1:0,x2:e.tipX,y2:e.tipY,stroke:e.color,strokeWidth:s,strokeLinecap:"round"}),(0,Sb.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,Sb.jsxs)("g",{transform:`translate(${r},${i})`,children:[(0,Sb.jsx)("line",{x1:l,y1:u,x2:d,y2:h,stroke:"var(--semiotic-border, #ccc)",strokeWidth:2,strokeLinecap:"round"}),(0,Sb.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,Sb.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,fb.useMemo)(()=>{const e=[...H,...S||[]];return oe&&e.push(oe),ne&&e.push(ne),e},[H,S,oe,ne]),se=(0,fb.useMemo)(()=>e=>{const t=e?.data?.[0]||e?.data||e,n=t?._zone||"",o=t?._isFill;return(0,Sb.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,Sb.jsx)("div",{style:{fontWeight:600},children:n}),(0,Sb.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,Sb.jsx)(wp,{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,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:su(k)||se,svgAnnotationRules:re,...ie.length>0&&{annotations:ie},..._&&{title:_},...L&&{description:L},...N&&{summary:N},...void 0!==$&&{accessibleTable:$},...C&&{className:C},...null!=e.animate&&{animate:e.animate},...A};return(0,Sb.jsx)(jp,{componentName:"GaugeChart",width:R,height:T,children:(0,Sb.jsx)(Ig,{ref:o,...ae})})});Ab.displayName="GaugeChart";var Cb=require("react"),Mb=require("react/jsx-runtime"),jb=(0,Cb.forwardRef)(function(e,t){const n=vp(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,Cb.useRef)(null);nm(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:I,color:P,stroke:R,strokeWidth:T,opacity:_,categoryFormat:L}=e,N="vertical"===h,{width:$,height:D,enableHover:B,showLegend:E,title:O,description:F,summary:z,accessibleTable:H}=n,W=N?{top:O?60:40,right:20,bottom:60,left:60}:{top:O?40:10,right:10,bottom:10,left:10},q=(0,Cb.useMemo)(()=>ft(r),[r]),G=u||l,Y=!G,V=qp({data:q,rawData:r,colorBy:G,colorScheme:d,legendInteraction:j,legendPosition:I,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:$,height:D,hasTitle:!!O,axisChrome:ts({showAxes:N,projection:N?"vertical":"horizontal",hasCategoryLabel:!1,hasValueLabel:!1})});_p("FunnelChart",q,"stepAccessor",a),_p("FunnelChart",q,"valueAccessor",c);const X=pp(),U=(0,Cb.useMemo)(()=>new Map,[]),K=(0,Cb.useMemo)(()=>{if(Y)return P||(X?.[0]?X[0]:Array.isArray(d)&&d[0]?d[0]:"#4e79a7")},[Y,P,X,d]),Q=_g({colorBy:K?void 0:G,colorScale:V.colorScale,color:K??P,themeCategorical:X,colorScheme:d,categoryIndexMap:U,userPieceStyle:g?.pieceStyle,stroke:R,strokeWidth:T,opacity:_,effectiveSelectionHook:V.effectiveSelectionHook,resolvedSelection:V.resolvedSelection}),Z=(0,Cb.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,Mb.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[n&&(0,Mb.jsx)("div",{style:{fontWeight:"bold"},children:n+""}),a&&a!==n&&(0,Mb.jsx)("div",{style:{marginTop:2,opacity:.8},children:a+""}),s&&(0,Mb.jsx)("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),(0,Mb.jsxs)("div",{style:{marginTop:4},children:[o+"",c]})]})},[]);if(V.earlyReturn)return V.earlyReturn;const J=Ep({componentName:"FunnelChart",data:r,accessors:{stepAccessor:a,valueAccessor:c}});if(J)return(0,Mb.jsx)(wp,{componentName:"FunnelChart",message:J,width:$,height:D});const ee={chartType:N?"bar-funnel":"funnel",...null!=r&&{data:q},oAccessor:a,rAccessor:c,...l&&{stackBy:l},projection:N?"vertical":"horizontal",barPadding:N?40:0,pieceStyle:Q,size:[$,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:V.margin,enableHover:B,...e.dataIdAccessor&&{dataIdAccessor:e.dataIdAccessor},showAxes:N,showCategoryTicks:N,...L&&{oFormat:L},showGrid:N,...!N&&{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:su(y)||Z,...rm({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,Mb.jsx)(jp,{componentName:"FunnelChart",width:$,height:D,children:(0,Mb.jsx)(Ig,{ref:o,...ee})})});jb.displayName="FunnelChart";var Ib=d(require("react")),Pb=require("react"),Rb=require("react"),Tb=require("react"),_b={RdBu:mn,PiYG:yn,PRGn:fn,BrBG:gn,RdYlBu:bn,RdYlGn:vn,Spectral:xn},Lb="__likert_neutral_neg",Nb="__likert_neutral_pos";function $b(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Db(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 Bb(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:Lb,__likertPct:-e}),i.push({...t,__likertLevel:Nb,__likertPct:e})}else i.push(r>e?{...t,__likertPct:-t.__likertPct}:t)}return i}function Eb(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===Lb?i=n:n.__likertLevel===Nb?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 Ob=["Very Low","Low","Neutral","High","Very High"],Fb=require("react/jsx-runtime"),zb=new Map,Hb=(0,Pb.forwardRef)(function(e,t){const n=vp(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,Pb.useRef)(null),{data:r,margin:i,className:s,categoryAccessor:a="question",valueAccessor:c,levelAccessor:l,countAccessor:u="count",levels:d=Ob,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:I,legendInteraction:P,legendPosition:R,categoryFormat:T,stroke:_,strokeWidth:L,opacity:N}=e,{width:$,height:D,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=Th();return e?.colors?.diverging||void 0}(),K=(0,Pb.useMemo)(()=>p&&Array.isArray(p)&&p.length>=d.length?p:function(e,t){if(0>=e)return[];if(t){const n=_b[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,Pb.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,Tb.useMemo)(()=>$b(n,"question"),[n]),u=(0,Tb.useMemo)(()=>c?$b(o,"score"):null,[c,o]),d=(0,Tb.useMemo)(()=>c?null:$b(r,"level"),[c,r]),h=(0,Tb.useMemo)(()=>c?null:$b(i,"count"),[c,i]),p=(0,Tb.useRef)([]);return{processedData:(0,Tb.useMemo)(()=>{const n=e||[];if(0===n.length)return[];let o=Db(n,t,l,u,d,h);return s&&(o=Bb(o,t),o=Eb(o,t)),o},[e,t,l,u,d,h,s]),reAggregate:(0,Tb.useCallback)(e=>{let n=Db(e,t,l,u,d,h);s&&(n=Bb(n,t),n=Eb(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,Rb.useRef)(new Set),s=(0,Rb.useRef)([]),[a,c]=(0,Rb.useState)(0),l=rh(),u=pp(),d=(0,Rb.useCallback)(e=>{if(!t)return null;const n="function"==typeof t?t(e):e[t];return null!=n?n+"":null},[t]),h=(0,Rb.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,Rb.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,Rb.useCallback)(e=>t=>{h([t]),e(t)},[h]),y=(0,Rb.useCallback)(e=>t=>{h(t),e(t)},[h]),f=(0,Rb.useCallback)(()=>{i.current=new Set,s.current=[],c(e=>e+1)},[]);op(e&&t?s.current:[]);const g=(0,Rb.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 cp({data:c,colorBy:a,colorScale:e=>l?.[e]||d(e)||"#999",getColor:In})},[e,t,o,n,l,u,a]),b=(0,Rb.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,Pb.useCallback)(e=>oe(e=>{ee.current.push(e),J(ee.current)})(e),[oe,J,ee]),se=(0,Pb.useCallback)(e=>re(e=>{ee.current.push(...e),J(ee.current)})(e),[re,J,ee]);(0,Pb.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=qp({data:Z,rawData:r,colorBy:te,colorScheme:K,legendInteraction:P,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:I,width:$,height:D,hasTitle:!!F,axisChrome:{hasAxis:!1!==n.showAxes,hasAxisLabel:Y?!!G:!!q}}),ce=(0,Pb.useMemo)(()=>{const e=d.length;return e%2!=0&&Q.get(d[Math.floor(e/2)])||"#888"},[d,Q]),le=_g({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:zb,userPieceStyle:b?.pieceStyle,stroke:_,strokeWidth:L,opacity:N,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.resolvedSelection,baseStyleExtras:e=>{const t=e.__likertLevelLabel||e.data?.__likertLevelLabel,n=e.__likertLevel||e.data?.__likertLevel;if(n===Lb||n===Nb)return{fill:ce};const o=t||n;return o&&Q.has(o)?{fill:Q.get(o)}:{fill:"#888"}}}),ue=(0,Pb.useMemo)(()=>{const e=d.length;return e%2!=0?d[Math.floor(e/2)]:""},[d]),de=(0,Pb.useMemo)(()=>e=>{const t=e.data||e,n=t.__likertLevel||"Unknown",o=n===Lb||n===Nb?ue:n,r=t.__likertCategory||"",i=Math.abs(t.__likertPct||0),s=n===Lb||n===Nb?2*i:i,a=t.__likertCount||0;return Ib.createElement("div",{className:"semiotic-tooltip",style:eu},Ib.createElement("div",{style:{fontWeight:"bold"}},r),Ib.createElement("div",{style:{marginTop:4}},`${o}: ${s.toFixed(1)}% (n=${a})`))},[ue]),he=(0,Pb.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)),Ep({componentName:"LikertChart",data:r,accessors:e,requiredProps:{levels:d}})},[r,a,c,l,u,d,X]),pe=(0,Pb.useMemo)(()=>[{styleFn:e=>({fill:Q.get(e.label)||"#888"}),items:d.map(e=>({label:e})),label:""}],[d,Q]),me=(0,Pb.useMemo)(()=>!1!==O?{...ae.legendBehaviorProps,legend:{legendGroups:pe},legendPosition:R||ae.legendPosition||"bottom"}:ae.legendBehaviorProps,[ae.legendBehaviorProps,ae.legendPosition,R,O,pe]),ye=(0,Pb.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,Pb.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:[$,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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:su(y)||de,...rm({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,Fb.jsx)(wp,{componentName:"LikertChart",message:he,width:$,height:D}):(0,Fb.jsx)(jp,{componentName:"LikertChart",width:$,height:D,children:(0,Fb.jsx)(Ig,{ref:o,...ge})})});Hb.displayName="LikertChart";var Wb=require("react"),qb=require("react/jsx-runtime"),Gb=(0,Wb.forwardRef)(function(e,t){const n=vp(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,Wb.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:I,emptyContent:P,legendInteraction:R,legendPosition:T,color:_,stroke:L,strokeWidth:N,opacity:$,categoryFormat:D,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,Wb.useMemo)(()=>ft(r),[r]),ne=h||c,oe=(0,Wb.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=qp({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:I,emptyContent:P,width:q,height:G,hasTitle:!!U,axisChrome:ts({showAxes:n.showAxes,projection:"horizontal"===u?"horizontal":"vertical",hasCategoryLabel:!1!==O&&!!J,hasValueLabel:!!ee})}),ie=Wg({brushProp:g,onBrushProp:b,linkedBrush:v,valueAccessor:l}),se=pp(),ae=(0,Wb.useMemo)(()=>new Map,[]),ce=_g({colorBy:ne,colorScale:re.colorScale,color:_,themeCategorical:se,colorScheme:p,categoryIndexMap:ae,userPieceStyle:x?.pieceStyle,stroke:L,strokeWidth:N,opacity:$,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection,cycleByCategory:!0}),le=(0,Wb.useMemo)(()=>Md({categoryAccessor:c,valueAccessor:l,groupAccessor:a,valueFormat:d}),[c,a,l,d]),ue=Ep({componentName:"SwimlaneChart",data:r,accessors:{categoryAccessor:a,valueAccessor:l,subcategoryAccessor:c},requiredProps:{subcategoryAccessor:c}}),{effectiveLegendProps:de,effectiveMargin:he}=Rg({ref:t,frameRef:o,setup:re}),pe=(0,Wb.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},...D&&{oFormat:D},...void 0!==O&&{showCategoryTicks:O},showGrid:V,...de,...om({title:U,description:K,summary:Q,accessibleTable:Z,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...im({tooltip:y,defaultTooltipContent:le}),...rm({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,qb.jsx)(wp,{componentName:"SwimlaneChart",message:ue,width:q,height:G}):(0,qb.jsx)(jp,{componentName:"SwimlaneChart",width:q,height:G,children:(0,qb.jsx)(Ig,{ref:o,...me})})});Gb.displayName="SwimlaneChart";var Yb=require("react"),Vb=d(require("react")),Xb=require("react"),Ub={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Kb={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Qb=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?Zb(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 Zb(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];Jb(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;Jb(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 Jb(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 ev(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function tv(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 nv(e){return e.y0-e.y1>0?"up":"down"}function ov(e,t){return t(e.source)==t(e.target)}function rv(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 iv(e){return e.target.x0-e.source.x1}function sv(e,t){var n=cv(e),o=iv(t)/Math.tan(n);return"up"==nv(e)?e.y1-o:e.y1+o}function av(e,t){var n=cv(e),o=iv(t)/Math.tan(n);return"up"==nv(e)?e.y1+o:e.y1-o}function cv(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function lv(e,t){return t(e)}function uv(e){return hv(e.source)}function dv(e){return hv(e.target)}function hv(e){return(e.y0+e.y1)/2}function pv(e){return e.virtual?0:e.value}function mv(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!ov(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!ov(e,t)?o+1:o}),n+o}function yv(e){return e.target.depth}function fv(e,t){return e.sourceLinks.length?e.depth:t-1}function gv(e,t){return e.y0-t.y0}function bv(e,t){return t.y0-e.y0}function vv(e,t){return e.y1-t.y1}function xv(e,t){return t.y1-e.y1}function wv(e,t){return Sv(e.source,t.source)||e.index-t.index}function kv(e,t){return Sv(e.target,t.target)||e.index-t.index}function Sv(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Av(e,t){return Cv(e)==Cv(t)?"bottom"==e.circularLinkType?bv(e,t):gv(e,t):Cv(t)-Cv(e)}function Cv(e){return e.target.column-e.source.column}function Mv(e,t){return jv(e)==jv(t)}function jv(e){return e.y0-e.y1>0?"up":"down"}var Iv=require("d3-array");function Pv(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,Iv.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}),Rv(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Rv(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,ov(e,t)&&rv(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?bv:gv);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?xv:vv),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 Rv(e,t,n){e.sort(Av);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(ov(e,t)&&rv(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&&Tv(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 Tv(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var _v=require("d3-array");function Lv(e){return function(){return e}}function Nv(e){return e.index}function $v(e){return e.nodes}function Dv(e){return e.links}function Bv(e,t,n){var o=(0,_v.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+=hv(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=hv(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?mv(t,n)-mv(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==mv(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 Ev(e,t,n,o,r,i){var s=(0,_v.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&&mv(r,n)>0){var c=(0,_v.mean)(r.sourceLinks,dv),l=(0,_v.mean)(r.targetLinks,uv),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-hv(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,_v.mean)(r.sourceLinks,dv),p=(0,_v.mean)(r.targetLinks,uv),m=((h&&p?(h+p)/2:h||p)-hv(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||Sv),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 Ov(e){e.nodes.forEach(function(e){e.sourceLinks.sort(kv),e.targetLinks.sort(wv)}),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 Fv(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,a=Nv,c=fv,l=void 0,u=32,d=2,h=$v,p=Dv;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,_v.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=ev(n,o)),"object"!=typeof r&&(r=e.target=ev(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=tv(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){lv(e,t)!=lv(r.source,t)&&lv(e,t)!=lv(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),ov(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,_v.sum)(e.sourceLinks,pv),(0,_v.sum)(e.targetLinks,pv)),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,_v.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,_v.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,_v.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,_v.min)(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,_v.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,_v.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),Bv(h,l,a),Ev(h,l,a,p,p,u),Ov(h),Pv(h,a,d,10,8),Bv(h,l,a),Ev(h,l,a,p,p,u),Ov(h),Pv(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 lv(n.source,t)==lv(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(!Mv(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=sv(t,e);return e.y1-n}if(t.target.column>e.target.column)return sv(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 lv(n.target,t)==lv(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(!Mv(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=av(t,e);return e.y0-n}if(t.source.column>e.source.column)return av(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,_v.min)(t,function(e){return e.y0}),s=(0,_v.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),Pv(h,a,d,10,8)}(m),m}return m.update=function(e){return Ov(e),Pv(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:Lv(e),m):h},m.links=function(e){return arguments.length?(p="function"==typeof e?e:Lv(e),m):p},m.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Lv(e),m):a},m.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Lv(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 zv=require("d3-interpolate");function Hv(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 Wv=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,zv.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,zv.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=Hv({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 qv(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 Gv=new Set,Yv=new WeakMap;function Vv(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Yv.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Yv.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}`;Gv.has(e)||(Gv.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 Xv={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(yv))-1:0},justify:fv},Uv={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=Fv().extent(d).links(u).nodes(l).nodeAlign(Xv[i]||fv).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(Vv(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(Vv(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?qv(e):Wv(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}}},Kv=require("d3-force"),Qv=require("d3-scale");T();var Zv={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=Jv(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=ex(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=ex(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=tx(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,Kv.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,Kv.forceSimulation)();if(void 0===n.random&&void 0===n.seed||m.randomSource(n.random??gu(n.seed)),m.force("charge",(0,Kv.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,Kv.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,Kv.forceCenter)(i,s).strength(.8)).force("x",(0,Kv.forceX)(i).strength(c)).force("y",(0,Kv.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=tx(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(Vv(t,"nodeSize")),o=r?r(Vv(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(Vv(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(Vv(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 Jv(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 ex(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 tx(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]=I(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,Qv.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 nx=require("d3-chord"),ox=require("d3-shape"),rx=Zt,ix={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,nx.chord)().padAngle(r);s&&f.sortGroups(s);const g=f(y),b=g.groups,v=(0,ox.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:rx,m=new Map;e.forEach((e,t)=>{m.set(e.id,p[t%p.length])});const y=(0,nx.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(Vv(n,"nodeStyle")).fill||m.get(n.id)||p[t%p.length]:m.get(n.id)||p[t%p.length];const i=u?u(Vv(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=sx(o,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Vv(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(Vv(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 sx(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 ax=require("d3-hierarchy"),cx=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function lx(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 ux(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 dx(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 hx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:cx}function px(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 mx(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 yx={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,ax.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,ax.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,ax.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,ax.treemap)().size([n,o]).tile(ax.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,ax.pack)().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){(0,ax.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:ux(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?fx(r,o,n):"treemap"===i||"partition"===i?gx(r,o):"circlepack"===i&&bx(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(Vv(t,"nodeStyle"));let a=i.fill||px(n);if(n.colorByDepth&&void 0!==t.depth){const e=hx(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=mx(r,s,c,p,l),f=i(Vv(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=dx(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(Vv(n,"nodeStyle"));let a=s.fill||px(t);if(t.colorByDepth&&void 0!==n.depth){const e=hx(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=dx(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(Vv(a,"nodeStyle")).fill||px(t);if(t.colorByDepth&&void 0!==a.depth){const e=hx(t);d=e[a.depth%e.length]}const h="string"==typeof d?lx(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(Vv(n,"nodeStyle"));let s=i.fill||px(t);if(t.colorByDepth&&void 0!==n.depth){const e=hx(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=dx(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(Vv(r,"nodeStyle")).fill||px(t);if(t.colorByDepth&&void 0!==r.depth){const e=hx(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?lx(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 fx(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 gx(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 bx(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 vx=require("d3-shape");function xx(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var wx={sankey:Uv,force:Zv,chord:ix,tree:yx,cluster:yx,treemap:yx,circlepack:yx,partition:yx,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=xx(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,vx.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=xx(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(Vv(t,"nodeSize")),o=r?r(Vv(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(Vv(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=xx(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 kx(e){return wx[e]}var Sx=require("d3-quadtree");function Ax(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 Cx(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(!Mx(e))return!1;return!0}return Mx(t.points)}function Mx(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 jx=require("d3-interpolate");var Ix="rgba(34, 197, 94, 0.7)",Px=2e3,Rx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tx=["scene-style","data-paint","accessibility","evidence"],_x=(e,t)=>({retainedData:e,invalidations:t}),Lx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nx=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$x=["scene-geometry","data-paint","overlay","accessibility","evidence"],Dx=["scene-style","data-paint","accessibility","evidence"],Bx=["scene-geometry","data-paint","overlay","accessibility","evidence"],Ex=[],Ox={chartType:_x("rebuild",Lx),nodeIDAccessor:_x("rebuild",Lx),sourceAccessor:_x("rebuild",Lx),targetAccessor:_x("rebuild",Lx),valueAccessor:_x("rebuild",Lx),edgeIdAccessor:_x("rebuild",Lx),childrenAccessor:_x("rebuild",Lx),hierarchySum:_x("rebuild",Lx),orientation:_x("preserve",Nx),nodeAlign:_x("preserve",Nx),nodePaddingRatio:_x("preserve",Nx),nodeWidth:_x("preserve",Nx),edgeSort:_x("preserve",Nx),iterations:_x("preserve",Nx),forceStrength:_x("preserve",Nx),padAngle:_x("preserve",Nx),groupWidth:_x("preserve",Nx),sortGroups:_x("preserve",Nx),treeOrientation:_x("preserve",Nx),edgeType:_x("preserve",Nx),padding:_x("preserve",Nx),paddingTop:_x("preserve",Nx),orbitMode:_x("preserve",Nx),orbitSize:_x("preserve",Nx),orbitSpeed:_x("preserve",Nx),orbitRevolution:_x("preserve",Nx),orbitRevolutionStyle:_x("preserve",Nx),orbitEccentricity:_x("preserve",Nx),orbitShowRings:_x("preserve",Nx),orbitAnimated:_x("preserve",Nx),customNetworkLayout:_x("preserve",Nx),layoutConfig:_x("preserve",Nx),nodeSize:_x("preserve",$x),nodeSizeRange:_x("preserve",$x),colorByDepth:_x("preserve",$x),nodeLabel:_x("preserve",Bx),showLabels:_x("preserve",Bx),labelMode:_x("preserve",Bx),nodeStyle:_x("preserve",Dx),edgeStyle:_x("preserve",Dx),colorBy:_x("preserve",Dx),colorScheme:_x("preserve",Dx),themeCategorical:_x("preserve",Dx),themeSemantic:_x("preserve",Dx),edgeColorBy:_x("preserve",Dx),edgeOpacity:_x("preserve",Dx),showParticles:_x("preserve",Dx),particleStyle:_x("preserve",Dx),decay:_x("preserve",Dx),pulse:_x("preserve",Dx),thresholds:_x("preserve",Dx),staleness:_x("preserve",Dx),layoutSelection:_x("preserve",Dx),clock:_x("preserve",Ex),random:_x("preserve",Ex),seed:_x("preserve",Ex),tensionConfig:_x("preserve",Ex),transition:_x("preserve",Ex),introAnimation:_x("preserve",Ex),onLayoutError:_x("preserve",Ex),__skipForceSimulation:_x("preserve",Ex),__hierarchyRoot:_x("preserve",Ex),__orbitState:_x("preserve",Ex),__previousPositions:_x("preserve",Ex)},Fx=_x("preserve",Nx),zx=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}},Rx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Tx):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Ox[o]??Fx;"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)}},Hx=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 zx,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={...Ub,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Qb(2e3))}currentTime(){return this.config.clock?.()??$n()}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={...Ub,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new Qb(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,{...Ax(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,{...Ax(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...Ax(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&&Cx(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,Ax(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Ax(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=kx(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=bf(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:vf(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=kx(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,Sx.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=kx(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=kx(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=Nn(e._prevX0,e._targetX0,n),e.x1=Nn(e._prevX1,e._targetX1,n),e.y0=Nn(e._prevY0,e._targetY0,n),e.y1=Nn(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=Nn(e._prevY0,e._targetY0,n),e.y1=Nn(e._prevY1,e._targetY1,n),e.sankeyWidth=Nn(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,jx.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,jx.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===Ix&&(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>=Px)return;const n=1-t/Px;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=Ix,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&&Px>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")}};Hx.QUADTREE_THRESHOLD=500;var Wx=Hx;Fo(Wx);var qx=d(require("react")),Gx=require("react/jsx-runtime");function Yx(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=qx.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=qx.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=qx.useMemo(()=>ra(),[]),I=M?oa(M.filter(e=>"widget"!==e.type),j,S,C):null,P=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,Gx.jsxs)(Gx.Fragment,{children:[P&&(0,Gx.jsx)("style",{children:Fs},"annotation-widget-disclosure-style"),(0,Gx.jsxs)("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,Gx.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,Gx.jsx)("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),(0,Gx.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>(0,Gx.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)),I,y]}),a&&"string"==typeof a?(0,Gx.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,Gx.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,Gx.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,Gx.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)})]})}Yx.displayName="NetworkSVGOverlay";var Vx=d(require("react")),Xx=require("react/jsx-runtime"),Ux={position:"absolute",top:0,left:0,pointerEvents:"none"};function Kx({marks:e,margin:t,selection:n=null,overscan:o=400}){const r=Vx.useRef(null),i=function(e,t,n){const[o,r]=Vx.useState(null);return Vx.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]),Vx.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,Xx.jsx)("div",{className:"semiotic-network-html-marks",ref:r,style:{...Ux,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,Xx.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,Xx.jsx)(Sr,{value:n,children:s}):s}var Qx=require("react/jsx-runtime");function Zx({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:I,annotations:P,onAnnotationActivate:R,annotationObservationCallback:T,onObservation:_,chartId:L,autoPlaceAnnotations:N,svgAnnotationRules:$}=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 D=t?.sceneNodes??[],B=t?.sceneEdges??[],E=t?.labels??[];return(0,Qx.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,Qx.jsx)(El,{summary:b}),(0,Qx.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,Qx.jsx)("g",{transform:`translate(${r.left},${r.top})`,children:a}),(0,Qx.jsxs)("g",{transform:`translate(${r.left},${r.top})`,children:[v&&(0,Qx.jsx)("rect",{x:0,y:0,width:i,height:s,fill:v}),B.map((e,t)=>gd({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Ic.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,Ic.jsxs)(Mc.Fragment,{children:[r&&(0,Ic.jsx)("defs",{children:r}),(0,Ic.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,Ic.jsxs)(Mc.Fragment,{children:[r&&(0,Ic.jsx)("defs",{children:r}),(0,Ic.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,Ic.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),D.map((e,t)=>gd({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,Ic.jsxs)(Mc.Fragment,{children:[o&&(0,Ic.jsx)("defs",{children:o}),(0,Ic.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,Ic.jsxs)(Mc.Fragment,{children:[o&&(0,Ic.jsx)("defs",{children:o}),(0,Ic.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,Ic.jsxs)(Mc.Fragment,{children:[r&&(0,Ic.jsx)("defs",{children:r}),(0,Ic.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,Ic.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,Ic.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,Qx.jsx)(Yx,{width:i,height:s,totalWidth:o[0],totalHeight:o[1],margin:r,labels:E,sceneNodes:D,title:y,legend:w,legendPosition:k,legendLayout:S,legendHoverBehavior:A,legendClickBehavior:C,legendHighlightedCategory:M,legendIsolatedCategories:j,foregroundGraphics:br(c,Ar(t?.customLayoutOverlays,I??null)),annotations:P,onAnnotationActivate:R,onObservation:T??_,chartId:L,chartType:"StreamNetworkFrame",autoPlaceAnnotations:N,svgAnnotationRules:$,annotationFrame:0}),(0,Qx.jsx)(Kx,{marks:t?.customLayoutHtmlMarks,margin:r,selection:I??null})]})}function Jx(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 ew(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function tw(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function nw(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}var ow=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(ew(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(ew(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 rw(e){let t=null;return{get:()=>(t&&!t.isDead||(t=e()),t),resetForTest:()=>{if(t){try{t.terminate()}catch{}t=null}}}}var iw={};function sw(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}var aw=class{constructor(e=function(){const e="string"==typeof iw.url&&iw.url?new URL("./forceLayoutWorker.js",iw.url):Jx("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new ow({name:"Force layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:o}=nw(t);return o?{requestId:n,ok:!1,error:tw(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()}},cw=rw(()=>new aw),lw=require("react/jsx-runtime"),uw=/^(value|amount|total|count|weight|score)$/i;function dw({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,lw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,lw.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,lw.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,lw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,lw.jsx)("div",{children:e.map((e,t)=>(0,lw.jsxs)("span",{children:[t>0&&(0,lw.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?(0,lw.jsx)("strong",{children:e}):(0,lw.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,lw.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=>uw.test(e.key));return(0,lw.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,lw.jsx)("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>(0,lw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",wd(e.value)]},e.key)),!a&&null!=t.value&&t.value>0&&(0,lw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&(0,lw.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function hw(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function pw(e,t){if(!t.pathD)return;e.save();const n=hw(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 mw(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 yw(e,t){if(!t.pathD)return;e.save();const n=hw(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 fw(e,t){if(!t.pathD)return;e.save();const n=hw(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 gw(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>Pr(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=Ir(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>Pr(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>Pr(r.radius,o)?null:{type:"node",datum:e.datum,x:i,y:s,distance:l}}(e,t,n,o);default:return null}}dw.ownsChrome=!0;var bw=null,vw=null;function xw(){return vw||((bw=document.createElement("canvas")).width=1,bw.height=1,vw=bw.getContext("2d")),vw}function ww(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 kw(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=ww(e),r=xw();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=ww(e),r=xw();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 Sw(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=gw(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=kw(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 Aw=require("react"),Cw="StreamNetworkFrame",Mw=require("react/jsx-runtime"),jw={top:20,right:80,bottom:20,left:80},Iw={top:40,right:40,bottom:40,left:40},Pw=new Set(["chord","force","circlepack","orbit"]),Rw=[800,600],Tw=(0,Xb.memo)((0,Xb.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:I="curve",padding:P,paddingTop:R,tensionConfig:T,showParticles:_=!1,particleStyle:L,renderMode:N,nodeStyle:$,edgeStyle:D,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=Rw,responsiveWidth:X,responsiveHeight:U,margin:K,className:Q,background:Z,enableHover:J=!0,tooltipContent:ee,customHoverBehavior:te,customClickBehavior:ne,onObservation:oe,annotationObservationCallback:re,chartId:ie,onTopologyChange:se,annotations:ae,onAnnotationActivate:ce,autoPlaceAnnotations:le,svgAnnotationRules:ue,legend:de,legendPosition:he,legendLayout:pe,legendHoverBehavior:me,legendClickBehavior:ye,legendHighlightedCategory:fe,legendIsolatedCategories:ge,title:be,foregroundGraphics:ve,backgroundGraphics:xe,decay:we,pulse:ke,transition:Se,animate:Ae,staleness:Ce,frameScheduler:Me,clock:je,random:Ie,seed:Pe,paused:Re=!1,suspendWhenHidden:Te=!0,thresholds:_e,accessibleTable:Le=!0,description:Ne,summary:$e,orbitMode:De,orbitSize:Be,orbitSpeed:Ee,orbitRevolution:Oe,orbitRevolutionStyle:Fe,orbitEccentricity:ze,orbitShowRings:He,orbitAnimated:We,customNetworkLayout:qe,onLayoutError:Ge,layoutConfig:Ye,layoutSelection:Ve}=e,Xe=Pw.has(n)?Iw:jw,Ue=(0,Xb.useRef)(!0),Ke=Su({sizeProp:V,responsiveWidth:X,responsiveHeight:U,userMargin:K,marginDefault:Xe,title:be,legend:de,legendPosition:he,foregroundGraphics:ve,backgroundGraphics:xe,animate:Ae,transitionProp:Se,frameScheduler:Me,clock:je,random:Ie,seed:Pe,paused:Re,suspendWhenHidden:Te,themeDirtyRef:Ue}),{reducedMotionRef:Qe,responsiveRef:Ze,size:Je,margin:et,adjustedWidth:tt,adjustedHeight:nt,resolvedForeground:ot,resolvedBackground:rt,transition:it,introEnabled:st,tableId:at,rafRef:ct,renderFnRef:lt,scheduleRender:ut,frameRuntime:dt,currentTheme:ht}=Ke,pt=Gc(),mt=Uc(),yt=(0,Xb.useMemo)(()=>ft(o),[o]),gt=(0,Xb.useMemo)(()=>Array.isArray(r)?ft(r):r,[r]),bt=(0,Xb.useMemo)(()=>({...Ub,...T}),[T]),vt=(0,Xb.useMemo)(()=>({...Kb,...L}),[L]),xt=(0,Xb.useMemo)(()=>{return{chartType:(e={chartType:n,clock:dt.now,random:Ie,seed:Pe,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:I,padding:P,paddingTop:R,tensionConfig:bt,showParticles:_,particleStyle:vt,nodeStyle:$,edgeStyle:D,nodeLabel:q,showLabels:G,labelMode:Y,colorBy:B,colorScheme:E,edgeColorBy:O,edgeOpacity:F,colorByDepth:z,nodeSize:H,nodeSizeRange:W,decay:we,pulse:ke,transition:it,introAnimation:st,staleness:Ce,thresholds:_e,orbitMode:De,orbitSize:Be,orbitSpeed:Ee,orbitRevolution:Oe,orbitRevolutionStyle:Fe,orbitEccentricity:ze,orbitShowRings:He,orbitAnimated:We,customNetworkLayout:qe,onLayoutError:Ge,layoutConfig:Ye,currentTheme:ht}).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,dt.now,Ie,Pe,a,c,l,u,d,h,p,m,y,f,g,b,v,S,A,C,M,j,I,P,R,bt,_,vt,$,D,q,G,Y,B,E,O,F,z,H,W,we,ke,it,st,Ce,_e,De,Be,Ee,Oe,Fe,ze,He,We,qe,Ge,Ye,ht]),wt=Qc(xt),kt=Qc({chartType:(St={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:I,padding:P,paddingTop:R,random:Ie,seed:Pe,tensionConfig:bt,customNetworkLayout:qe,orbitMode:De,orbitSize:Be,orbitEccentricity:ze}).chartType,nodeIDAccessor:St.nodeIDAccessor,sourceAccessor:St.sourceAccessor,targetAccessor:St.targetAccessor,valueAccessor:St.valueAccessor,edgeIdAccessor:St.edgeIdAccessor,childrenAccessor:St.childrenAccessor,hierarchySum:St.hierarchySum,orientation:St.orientation,nodeAlign:St.nodeAlign,nodePaddingRatio:St.nodePaddingRatio,nodeWidth:St.nodeWidth,iterations:St.iterations,forceStrength:St.forceStrength,padAngle:St.padAngle,groupWidth:St.groupWidth,sortGroups:St.sortGroups,edgeSort:St.edgeSort,treeOrientation:St.treeOrientation,edgeType:St.edgeType,padding:St.padding,paddingTop:St.paddingTop,random:St.random,seed:St.seed,tensionConfig:St.tensionConfig,customNetworkLayout:St.customNetworkLayout,orbitMode:St.orbitMode,orbitSize:St.orbitSize,orbitEccentricity:St.orbitEccentricity});var St;const At=(0,Xb.useRef)(0),Ct=(0,Xb.useRef)(0),Mt=(0,Xb.useRef)(!1),jt=(0,Xb.useRef)(null);jt.current||(jt.current=new Wx(wt));const It=yr("StreamNetworkFrame"),Pt=(0,Xb.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]),[Tt,_t]=(0,Xb.useState)(null),[Lt,Nt]=(0,Xb.useState)(0),[$t,Dt]=(0,Xb.useState)(0),[Bt,Et]=(0,Xb.useState)(!1),[Ot,Ft]=(0,Xb.useState)(!1),zt=(0,Xb.useRef)(0),Ht=(0,Xb.useRef)(null),Wt=(0,Xb.useRef)(!1),qt=(0,Xb.useRef)(k);qt.current=k;const Gt=(0,Xb.useRef)(wt);Gt.current=wt;const Yt=(0,Xb.useRef)(null),Vt=(0,Xb.useRef)(new Map),Xt=(0,Xb.useRef)(0),Ut=(0,Xb.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:Vt.current,colorIndexRef:Xt}),[B,E]),Kt=(0,Xb.useCallback)(e=>{Xt.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:Vt.current,colorScheme:E})},[E]),Qt=(0,Xb.useCallback)((e,t)=>{Pt(e,t),Kt(e),Ue.current=!1,e.markStylePaintPending()},[Pt,Kt]),Zt=(0,Xb.useCallback)(()=>{jt.current?.markStylePaintPending()},[]),Jt=(en=ht,en?.colors?.border||en?.colors?.secondary||en?.colors?.primary||"#999");var en;const tn=(0,Xb.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,jt.current?.nodes),[]),nn=(0,Xb.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:Ut,resolveEndpoint:tn,fallback:Jt}),[O,Ut,Jt,tn]),on=(0,Xb.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:vt.color,particleColorBy:vt.colorBy,hasExplicitParticleColorBy:!!L?.colorBy,getEdgeColor:nn,getNodeColor:Ut,resolveEndpoint:tn,fallback:Jt}),[L?.colorBy,vt.color,vt.colorBy,Ut,nn,Jt,tn]),rn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!qe,_,!!ke,jt.current?.isAnimating??!1);Mr(jt,wt,Ue,ut),jr(jt,Ve,Ue,ut),(0,Xb.useEffect)(()=>{const e=jt.current;e&&(Qt(e,[tt,nt]),Nt(e=>e+1),ut())},[ht,tt,nt,Qt,ut]);const sn=(0,Xb.useCallback)(()=>{const e=jt.current;if(e&&(e.runLayout([tt,nt]),Qt(e,[tt,nt]),Nt(e.layoutVersion),se)){const{nodes:t,edges:n}=e.getLayoutData();se(t,n)}},[tt,nt,Qt,se]),an=(0,Xb.useRef)(!1),cn=(0,Xb.useCallback)((e=!1)=>!(!e&&!an.current||(an.current=!1,sn(),0)),[sn]),ln=(0,Xb.useCallback)(()=>cn(!1),[cn]),un=(0,Xb.useCallback)(e=>{const t=jt.current;if(!t)return!1;let n=!1,o=an.current;for(const r of e)null!=r&&"object"==typeof r&&(n=!0,t.ingestEdge(r)&&(o=!0));const r=cn(o);return n||r},[cn]),dn=(0,Xb.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=jt.current;t&&(t.ingestEdge(e)&&(an.current=!0),dt.isActive?ut():ln())},[ln,dt,ut]),hn=(0,Xb.useCallback)(e=>{un(e)&&ut()},[un,ut]);(0,Xb.useEffect)(()=>dt.subscribe(()=>{dt.isActive||ln()}),[ln,dt]);const pn=(0,Xb.useCallback)(()=>{an.current=!1,jt.current?.clear(),Vt.current.clear(),Xt.current=0,Nt(jt.current?.layoutVersion??0),_t(null),Yt.current=null,Ue.current=!0,ut()},[ut]),mn=(0,Xb.useCallback)(()=>{const e=jt.current;e&&(e.tension+=999,cn(!0),ut())},[cn,ut]);(0,Xb.useImperativeHandle)(t,()=>({push:dn,pushMany:hn,removeNode:e=>{const t=jt.current?.removeNode(e)??!1;if(t){const t=Yt.current?.data?"function"==typeof a?a(Yt.current.data):Yt.current.data[a]:void 0;Yt.current&&"node"===Yt.current.nodeOrEdge&&t===e&&(Yt.current=null,_t(null)),Vt.current.delete(e)}return cn(t)&&(Ue.current=!0,ut()),t},removeEdge:(e,t)=>{const n=jt.current?.removeEdge(e,t)??!1;if(n&&Yt.current&&"edge"===Yt.current.nodeOrEdge){const n=Yt.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&&(Yt.current=null,_t(null))}return cn(n)&&(Ue.current=!0,ut()),n},updateNode:(e,t)=>{const n=jt.current?.updateNode(e,t)??null;return cn(null!==n)&&(Ue.current=!0,ut()),n},updateEdge:(e,t,n)=>{const o=jt.current?.updateEdge(e,t,n)??[];return cn(o.length>0)&&(Ue.current=!0,ut()),o},clear:pn,getTopology:()=>(ln(),jt.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(ln(),jt.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(ln(),jt.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{ln();const e=jt.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:mn,getTension:()=>(ln(),jt.current?.tension??0)}),[dn,hn,pn,mn,ln,cn,a,ut,d]);const yn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),fn=yn?i||(Array.isArray(r)?void 0:r):void 0;(0,Xb.useEffect)(()=>{const e=jt.current;if(!e)return;const t=++zt.current;if(Ht.current?.abort(),Ht.current=null,yn&&fn)an.current=!1,e.ingestHierarchy(fn,[tt,nt]),Qt(e,[tt,nt]),Nt(e.layoutVersion),Ft(!1),qt.current?.("ready"),ut();else{const i=yt,s=Array.isArray(gt)?gt:[];if(null==o&&null==r||(an.current=!1),0===i.length&&0===s.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||pn(),Ft(!1),void qt.current?.("ready");const a=[tt,nt],c="force"===n&&!qe&&sw()&&!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&&mt&&!Wt.current&&e.sceneNodes.length>0)return Wt.current=!0,Ft(!1),qt.current?.("ready"),Ue.current=!0,void ut();if(c){const n=new AbortController;Ht.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=tx(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,Gt.current,a,o);return Ft(!0),qt.current?.("pending"),function(e,t){return sw()?cw.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===zt.current&&(e.applyForceLayoutPositions(n,a),Qt(e,a),Ft(!1),qt.current?.("ready"),Nt(e.layoutVersion),ut())}).catch(n=>{"AbortError"!==n.name&&t===zt.current&&(e.runLayout(a),Qt(e,a),Ft(!1),qt.current?.("error"),Nt(e.layoutVersion),ut())}),()=>n.abort()}e.ingestBounded(i,s,a),Qt(e,a),Nt(e.layoutVersion),Ft(!1),qt.current?.("ready"),ut()}},[yt,gt,o,r,i,fn,yn,tt,nt,kt,x,b,mt,n,qe,Ie,ut,pn,Qt]);const gn=Vb.useRef(!1);(0,Xb.useEffect)(()=>{gn.current||s&&s.length>0&&(gn.current=!0,hn(s))},[s,hn]);const{customHoverBehavior:bn,customClickBehavior:vn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:(0,Aw.useCallback)((t,r)=>{e?.(t,r),_d({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Cw,chartId:o,context:r})},[e,n,o]),customClickBehavior:(0,Aw.useCallback)((e,r)=>{t?.(e,r),Ld({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Cw,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:te,customClickBehavior:ne,onObservation:oe,chartId:ie}),{hoverHandlerRef:xn,hoverLeaveRef:wn,onPointerMove:Sn,onPointerLeave:An}=Ke,Cn=()=>!qe||(jt.current?.hasCustomRestyle??!1);xn.current=e=>{if(!J)return;const t=Cn(),n=Ln.current;if(!n)return;const o=jt.current;if(!o)return;const r=Sw({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:et,adjustedWidth:tt,adjustedHeight:nt,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Yt.current=r.hover,_t(r.hover),bn?.(r.hover),t&&ut()):Yt.current&&(Yt.current=null,_t(null),bn?.(null),t&&ut())},wn.current=()=>{if(Yt.current){const e=Cn();Yt.current=null,_t(null),bn?.(null),e&&ut()}};const Mn=(0,Xb.useRef)(()=>{});Mn.current=e=>{if(Qs(e.target))return;if(!ne&&!oe)return;const t=Ln.current;if(!t)return;const n=jt.current;if(!n)return;const o=Sw({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:et,adjustedWidth:tt,adjustedHeight:nt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?vn(o.hover,{type:"activate",inputType:Rd(e.nativeEvent.pointerType)}):"miss"===o.kind&&vn(null)};const jn=(0,Xb.useCallback)(e=>Mn.current(e),[]),In=(0,Xb.useRef)(-1),Pn=(0,Xb.useRef)(null),Rn=(0,Xb.useRef)(-1),Tn=(0,Xb.useCallback)(e=>{if(Td(e))return;const t=jt.current;if(!t)return;const n=()=>{In.current=-1,Pn.current=null,Rn.current=-1,Yt.current=null,_t(null),bn?.(null),ut()},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=Bd(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 vn?.(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,Rn.current=-1;const t=r.flat[0];Pn.current={shape:t.shape,w:t.w,h:t.h};const n=Yl(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Yt.current=n,_t(n),bn?.(n,{type:"focus",inputType:"keyboard"}),void ut()}const s=Ed(r,i),a=function(e,t,n,o,r){const i=n.flat[t.flatIndex];if(!i)return Od(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=Wd(t.source),i=Wd(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=Od(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,s,r,t.sceneEdges??[],Rn);if(null===a)return;if(e.preventDefault(),0>a)return void n();In.current=a;const c=r.flat[a];Pn.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"};Yt.current=l,_t(l),bn?.(l,{type:"focus",inputType:"keyboard"}),ut()},[vn,bn,ut]),_n=(0,Xb.useCallback)(e=>{In.current=-1,Pn.current=null,Sn(e)},[Sn]);lt.current=()=>{if(ct.current=null,ln(),!dt.isActive)return;const e=Ln.current;if(!e)return;const t=jt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:i,adjustedWidth:s,adjustedHeight:a,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:p,random:m,reducedMotion:y,showParticles:f,isContinuous:g,animate:b,decay:v,pulse:x,thresholds:w,staleness:k,particleStyle:S,getParticleColor:A,pendingAnnotationFrameRef:C,lastAnnotationFrameTimeRef:M,setAnnotationFrame:j,scheduleNextFrame:I,syncColorMap:P}=e,R=t.getContext("2d");if(!R)return;const T=h.current?Math.min((p-h.current)/1e3,.1):.016;h.current=p;const _=n.advanceTransition(y?p+1e6:p),L=!y&&_,N=!y&&n.tickAnimation([s,a],T),$=d.current,D=o?.beforeCompute(n.getLastUpdateResult(),L),B=_||$||N;B&&(n.buildScene([s,a]),$&&P?.()),D&&o?.afterCompute(D,B,!1);const E=f&&!y&&!!n.particlePool,O=ol({dirtyOrRebuilt:$,transitioning:L,animationTicked:N,continuous:E||g,liveEncoding:!!v||!!x||!!w||!1!==b&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}),F=!!k&&n.lastIngestTime>0&&p-n.lastIngestTime>(k?.threshold??5e3);if(O){const e=Tu();if(!Ru(t,r,i,e))return;if(R.clearRect(-i.left,-i.top,r[0],r[1]),nl(R,{background:c,hasBackgroundGraphics:u,width:s,height:a}),v&&n.applyDecay(),x&&n.applyPulse(p),w&&n.applyThresholds(p),!1!==b&&n.applyTopologyDiff(p),F&&(R.globalAlpha=k?.dimOpacity??.5),fd({context:R,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":pw(e,n);break;case"line":mw(e,n);break;case"ribbon":yw(e,n);break;case"curved":fw(e,n)}}(R,e)}),fd({context:R,nodes:n.sceneNodes,renderMode:l,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),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)),qu(e,t),e.restore())}}(R,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),di(e,t.style,"#007bff",()=>e.fill()),hi(e,t.style,()=>e.stroke()),Gu(e,t),e.restore())}}(R,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),di(e,t.style,"#007bff",()=>e.fill()),hi(e,t.style,()=>e.stroke()),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const o of t)"symbol"===o.type&&Ju(e,o,o.cx,o.cy,n,"#007bff");e.globalAlpha=n}(R,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&td(e,o,o.cx,o.cy,n);e.globalAlpha=n}(R,t)}}),E&&!F){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,T,S,m);const t=.5*(S.speedMultiplier??1);let o;if(S.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(T,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}(R,n.particlePool,e,S,A)}}F&&(R.globalAlpha=1)}d.current=!1,($||L||N)&&t.setAttribute("aria-label",kl(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const z=$||L||N||C.current;z&&p-M.current>=33?(j(e=>e+1),M.current=p,C.current=!1):C.current=!!z,(g||L||null!=n.transition||N||n.hasActivePulses||n.hasActiveThresholds||!1!==b&&n.hasActiveTopologyDiff||C.current)&&I()}({canvas:e,store:t,sceneRevisionDiagnostics:It.current,size:Je,margin:et,adjustedWidth:tt,adjustedHeight:nt,background:Z,renderMode:N,hasBackgroundGraphics:!!xe,dirtyRef:Ue,lastFrameTimeRef:At,now:dt.now(),random:dt.random,reducedMotion:!!Qe.current,showParticles:_,isContinuous:rn,animate:Ae,decay:we,pulse:ke,thresholds:_e,staleness:Ce,particleStyle:vt,getParticleColor:on,pendingAnnotationFrameRef:Mt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:Dt,scheduleNextFrame:()=>{ut()},syncColorMap:()=>Kt(t)})};const{canvasRef:Ln}=Mu(Ke,{hydrated:pt,wasHydratingFromSSR:mt,storeRef:jt,dirtyRef:Ue,skipInitialCanvasPaintInvalidation:!0,canvasPaintInvalidator:Zt,canvasPaintDependencies:[n,tt,nt,Z,xe,N,ut]});_i(Ce,jt,Ue,ut,Bt,Et);const Nn=J&&Tt?(0,Mw.jsx)(cu,{x:Tt.x,y:Tt.y,containerWidth:tt,containerHeight:nt,margin:et,className:"stream-network-tooltip",zIndex:2,children:ee?ee(Tt):(0,Mw.jsx)(dw,{data:Tt})}):null;if(Hc||!pt&&mt)return(0,Mw.jsx)(Zx,{props:e,store:jt.current,responsiveRef:Ze,size:Je,margin:et,adjustedWidth:tt,adjustedHeight:nt,resolvedBackground:rt,resolvedForeground:ot});const $n=jt.current;return(0,Mw.jsxs)("div",{ref:Ze,className:"stream-network-frame"+(Q?" "+Q:""),role:"group","aria-label":Ne||("string"==typeof be?be:"Network chart"),tabIndex:0,"aria-busy":Ot||void 0,style:{position:"relative",width:X?"100%":Je[0],height:U?"100%":Je[1],overflow:"visible"},onKeyDown:Tn,children:["production"!==process.env.NODE_ENV&&jt.current&&(0,Mw.jsx)(fr,{store:jt.current,diagnostics:It.current}),Le&&(0,Mw.jsx)(Ol,{tableId:at}),Le&&(0,Mw.jsx)(Bl,{nodes:$n?.sceneNodes??[],edges:$n?.sceneEdges??[],chartType:"Network chart",tableId:at,chartTitle:"string"==typeof be?be:void 0}),(0,Mw.jsx)(El,{summary:$e}),(0,Mw.jsx)(yl,{hoverPoint:Tt}),(0,Mw.jsxs)("div",{role:"img","aria-label":Ne||("string"==typeof be?be:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:J?_n:void 0,onMouseLeave:J?An:void 0,onClick:ne||oe?jn:void 0,children:[Ot&&!1!==w&&(0,Mw.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Tp(!0,Je[0],Je[1],w)}),(0,Mw.jsx)(ju,{size:Je,margin:et,overflowVisible:!0,children:rt}),(0,Mw.jsx)("canvas",{ref:Ln,"aria-label":kl($n?.sceneNodes?.length??0,$n?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,Mw.jsx)(Yx,{width:tt,height:nt,totalWidth:Je[0],totalHeight:Je[1],margin:et,labels:$n?.labels||[],sceneNodes:$n?.sceneNodes,title:be,legend:de,legendPosition:he,legendLayout:pe,legendHoverBehavior:me,legendClickBehavior:ye,legendHighlightedCategory:fe,legendIsolatedCategories:ge,foregroundGraphics:br(ot,Ar(jt.current?.customLayoutOverlays,Ve??null)),annotations:ae,onAnnotationActivate:ce,onObservation:re??oe,chartId:ie,chartType:"StreamNetworkFrame",autoPlaceAnnotations:le,svgAnnotationRules:ue,annotationFrame:$t}),(0,Mw.jsx)(Kx,{marks:$n?.customLayoutHtmlMarks,margin:et,selection:Ve??null}),(0,Mw.jsx)(Hl,{active:In.current>=0,hoverPoint:Tt,margin:et,size:Je,shape:Pn.current?.shape,width:Pn.current?.w,height:Pn.current?.h}),Nn,Ce?.showBadge&&(0,Mw.jsx)(Ni,{isStale:Bt,position:Ce.badgePosition})]})]})}));Tw.displayName="StreamNetworkFrame";var _w=Tw,Lw=require("react");function Nw(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 $w(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 Dw(e){return"function"==typeof e?e:t=>t[e]||1}function Bw({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=In(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=In(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 Ew(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,I=(0,Lw.useMemo)(()=>ft(n),[n]),P=(0,Lw.useMemo)(()=>ft(t),[t]),R=Tp(A,w,k,C),T=R?null:Rp("nodes"===j?void 0===t?void 0:P:void 0===n?void 0:I,w,k,M),_=(0,Lw.useMemo)(()=>o?$w(P,I,r,i):P,[o,P,I,r,i]),L=yp(_,s,a),N=pp(),$=(0,Lw.useMemo)(()=>Array.isArray(a)&&a.length>0?a:[...An(a,N,kn)],[a,N]),D=(0,Lw.useMemo)(()=>lp(_,s),[_,s]),B=dp(u,s,D),{legend:E,margin:O,legendPosition:F}=up({data:_,colorBy:s,colorScale:L,showLegend:c,legendPosition:l,userMargin:x,defaults:v,categories:D,chartWidth:w,hasTitle:S}),z=(0,Lw.useMemo)(()=>Bh(y,{width:w,mobileSemantics:f}),[y,w,f]),H=gp({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:I,colorScale:L,effectivePalette:$,themeCategorical:N,allCategories:D,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 Ow=require("react/jsx-runtime"),Fw=(0,Yb.forwardRef)(function(e,t){const n=(0,Yb.useRef)(null);nm(t,{variant:"network",frameRef:n});const o=vp(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:I,frameProps:P={},onObservation:R,onClick:T,chartId:_,selection:L,linkedHover:N,loading:$,loadingContent:D,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=Ew({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:N,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:$,loadingContent:D,emptyContent:B,emptyDataKey:"nodes"}),ee=(0,Yb.useMemo)(()=>new Map,[]),te=(0,Yb.useMemo)(()=>e=>{const t={};return t.fill=p?In(e.data||e,p,J.colorScale):mp(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,Yb.useMemo)(()=>Up(p,"number"==typeof f?void 0:f),[p,f]),oe=(0,Yb.useMemo)(()=>Yp(Jp(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,Yb.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,Yb.useMemo)(()=>{if(X&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[X,h]),le=Fp({componentName:"ForceDirectedGraph",nodes:r,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:W}});return le?(0,Ow.jsx)(wp,{componentName:"ForceDirectedGraph",message:le,width:q,height:G}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,Ow.jsx)(jp,{componentName:"ForceDirectedGraph",width:q,height:G,children:(0,Ow.jsx)(_w,{ref:n,chartType:"force",...null!=r&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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===I?()=>null:su(I)||void 0,...rm({linkedHover:N,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},...P})})});Fw.displayName="ForceDirectedGraph";var zw=require("react"),Hw=require("react/jsx-runtime"),Ww=(0,zw.forwardRef)(function(e,t){const n=(0,zw.useRef)(null);nm(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=vp(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:I,loadingContent:P,emptyContent:R,legendInteraction:T,stroke:_,strokeWidth:L,opacity:N}=e,{width:$,height:D,enableHover:B,showLabels:E=!0,title:O,description:F,summary:z,accessibleTable:H}=o,W=Ew({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:$,height:D,hasTitle:!!O,loading:I,loadingContent:P,emptyContent:R}),q=(0,zw.useMemo)(()=>new Map,[]),G=(0,zw.useMemo)(()=>new Map,[]),Y=W.safeNodes.length>0,V=(0,zw.useMemo)(()=>{if(Y)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=In(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,zw.useMemo)(()=>Up(h),[h]),U=(0,zw.useMemo)(()=>{if(V||m&&m.length>0)return Yp(Jp(V,m,X,e=>e.data||e),{stroke:_,strokeWidth:L,opacity:N})},[V,m,X,_,L,N]),K=(0,zw.useMemo)(()=>{if(Y)return Bw({edgeColorBy:y,colorBy:h,colorScale:W.colorScale,nodeStyleFn:U||(e=>({fill:mp(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,zw.useMemo)(()=>K?Yp(K,{stroke:_,strokeWidth:L,opacity:N}):void 0,[K,_,L,N]),Z=(0,zw.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=Fp({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,Hw.jsx)(wp,{componentName:"ChordDiagram",message:J,width:$,height:D}):W.loadingEl?W.loadingEl:W.emptyEl?W.emptyEl:(0,Hw.jsx)(jp,{componentName:"ChordDiagram",width:$,height:D,children:(0,Hw.jsx)(_w,{ref:n,chartType:"chord",...W.safeNodes.length>0&&{nodes:W.safeNodes},...null!=i&&{edges:W.safeEdges},size:[$,D],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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:su(w)||void 0,...rm({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})})});Ww.displayName="ChordDiagram";var qw=require("react"),Gw=require("react/jsx-runtime"),Yw=(0,qw.forwardRef)(function(e,t){const n=(0,qw.useRef)(null);nm(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=vp(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:I,linkedHover:P,loading:R,loadingContent:T,emptyContent:_,showLegend:L,legendPosition:N,legendInteraction:$,stroke:D,strokeWidth:B,opacity:E}=e,{width:O,height:F,enableHover:z,showLabels:H=!0,title:W,description:q,summary:G,accessibleTable:Y}=o,V=Ew({nodes:r,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:c,targetAccessor:l,colorBy:h,colorScheme:p,showLegend:L,legendPosition:N,legendInteraction:$,selection:I,linkedHover:P,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,qw.useMemo)(()=>new Map,[]),U=(0,qw.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?In(e.data||e,h,V.colorScale):mp(void 0,V.themeCategorical,p,void 0,X),t},[h,V.colorScale,V.themeCategorical,p,X]),K=(0,qw.useMemo)(()=>Up(h,u),[h,u]),Q=(0,qw.useMemo)(()=>Yp(Jp(U,m,K,e=>e.data||e),{stroke:D,strokeWidth:B,opacity:E}),[U,m,K,D,B,E]),Z=(0,qw.useMemo)(()=>Bw({edgeColorBy:y,colorBy:h,colorScale:V.colorScale,nodeStyleFn:Q,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,V.colorScale,Q,w]),J=(0,qw.useMemo)(()=>Yp(Z,{stroke:D,strokeWidth:B,opacity:E}),[Z,D,B,E]),ee=(0,qw.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=Fp({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Gw.jsx)(wp,{componentName:"SankeyDiagram",message:te,width:O,height:F}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:(0,Gw.jsx)(jp,{componentName:"SankeyDiagram",width:O,height:F,children:(0,Gw.jsx)(_w,{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,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:su(S)||void 0,...rm({linkedHover:P,selection:I,onObservation:C,onClick:M,mobileInteraction:V.mobileInteraction,customHoverBehavior:V.customHoverBehavior,customClickBehavior:V.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:V.legend,legendPosition:V.legendPosition,...$&&"none"!==$&&{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})})});Yw.displayName="SankeyDiagram";var Vw=require("react"),Xw={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Uw(e="static"){return Xw[e]??Xw.static}var Kw=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function Qw(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Kw.has(e.kind)?"fatal":"warn"}function Zw(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 Jw(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 ek(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 tk(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=ek(i,e),n=ek(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 nk(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 ok(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 rk(e,t){return t>e?-1:e>t?1:0}function ik(e){return e.occupants.map(e=>e.id).sort(rk).join("\0")}function sk(e,t,n=0){return e.slice(0,-1).map((o,r)=>null!=o.group&&o.group===e[r+1].group?n:t)}function ak(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 ck(e,t,n){if(0===e.length)return[];const{padding:o,plotH:r,valueScale:i}=n,s=n.stackValueScale??i,a=sk(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 lk(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 uk(e,t,n,o,r,i){const s=i.adjacentClearance?[...i.adjacentClearance]:tk(ak(o,n)).adjacentClearance,a=ck(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=sk(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 ck(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=lk(a,u),h=lk(c,u);e[n]+=(y[s]+h-d)*l,r[n]+=l,e[s]+=(y[n]+d-h)*l,r[s]+=l}const i=Jw({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};dk(n(c),t)>dk(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 dk(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 hk(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 pk(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 mk(e,t){let n=0,o=1;for(let r=0;28>r;r++){const r=(n+o)/2;e>pk(0,t,t,1,r)?n=r:o=r}return(n+o)/2}function yk(e,t,n){const o=t+lk(e,n),r=e.value*n/2;return[o-r,o+r]}function fk(e,t,n,o){return Math.max(0,Math.min(t,o)-Math.max(e,n))/Math.max(1e-9,t-e)}function gk(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]=yk(p,r[s.source],a),[v,x]=yk(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=mk((e-y)/(f-y),u),c=pk(g,g,v,v,n),l=pk(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=hk(t[n.id],e),h=r[n.id];d=Math.max(d,fk(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 bk(e,t,n,o,r,i,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:dk(s,n),transitOcclusion:gk(n,o,r,i,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function vk(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function xk(e,t){return e.map(e=>({t:vk(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function wk(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 kk(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)||rk(e.edge?.id??"",t.edge?.id??"")||rk(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}})},I=()=>{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,I(),j(e.time)):"transfer-out"!==e.kind&&(I(),"out"!==e.kind||v+x>1e-12||(w=0),j(e.time))}const P=[];let R=0;for(;C.length>R;){let e=R;for(;C.length>e+1&&C[e+1].t===C[R].t;)e++;P.push(C[R]);for(let t=R+1;e>=t;t++){const e=P[P.length-1];C[t].topMass===e.topMass&&C[t].botMass===e.botMass&&(C[t].boundaryOffset??0)===(e.boundaryOffset??0)||P.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(P.length>0){const e=P[P.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&&P.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const n=P[0],o=P.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)&&P.unshift({t:i,topMass:r.topMass,botMass:r.botMass,...null!=r.boundaryOffset&&{boundaryOffset:r.boundaryOffset}})}let N=P;if("max"===r&&null!=d&&null!=T&&T>d){let e,t=0;for(const n of P){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}};N=[...P.filter(e=>d>e.t),{t:d,...t},{t:T,...t},...P.filter(e=>e.t>T)]}}return{samples:N,peak:k,topPeak:S,botPeak:A,localAttachments:M}}function Sk(e){const t={};return e.forEach((e,n)=>{for(const o of e.occupants)t[o.id]=n}),t}function Ak(e,t,n){e.splice(0,e.length,...n);const o=Sk(n);for(const e of Object.keys(t))delete t[e];Object.assign(t,o)}function Ck(e){const t=new Map,n=[];e.forEach((e,o)=>{if(!e.group)return void n.push({anchor:o,stableId:ik(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(ik).join("\0")}`,slots:o.slots});return n.sort((e,t)=>e.anchor-t.anchor||rk(e.stableId,t.stableId))}function Mk(e){return e.some(e=>e.group)?Ck(e).flatMap(e=>e.slots):[...e]}function jk(e){return e.flatMap(e=>e.slots)}function Ik(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 Pk(e,t){e.some(e=>e.group)&&Ak(e,t,Mk(e))}function Rk(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 Tk(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]],Rk)}function _k(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 Lk(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 Nk=e=>{let t=1;for(let n=2;e>=n;n++)t*=n;return t},$k=828*Nk(8),Dk=3e3;function Bk(e,t,n,o,r,i,s){const a=[...r],c=new Map(r.map(e=>[e,ik(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])||!Rk(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 tk(ak([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,I=new Map;for(const e of t)j.has(e.source)||j.set(e.source,new Set),I.has(e.target)||I.set(e.target,new Set),j.get(e.source).add(e.target),I.get(e.target).add(e.source);const P=t.flatMap(e=>{if(!(e=>{const t=new Set([...j.get(e.source)??[],...I.get(e.source)??[]]),n=new Set([...j.get(e.target)??[],...I.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 P)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),N=new Float64Array(r.length),$=new Float64Array(r.length+1),D=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]);N[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]);N[o]=N[n]+S(e[t-1],e[t])*s.valueScale+s.padding}const n=A.get(e[e.length-1]),o=N[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;N.length>t;t++)N[t]*=e}}$[0]=0;for(let t=0;e.length>t;t++)$[t+1]=$[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(N[e.source]-N[e.target])*e.weight,Math.abs(t-i)>=2){const n=Math.min(t,i)+1;r+=($[Math.max(t,i)]-$[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=Sk(o),i=o.slice(0,-1).map((e,t)=>S(e,o[t+1])),a=uk(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:_k(r,t),pixelLength:dk(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+Lk(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+Lk(n,t,u),0),w.fullCrossing++}const c=E(e);return O(a,{...c,transitOcclusion:gk(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)=>rk(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=nk(e,d,e=>F(e).cost,{passes:6,compare:W,maxEvaluations:Dk});let n=F(t),o=Dk;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+=Lk(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+=Lk(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:Nk(e.length)*(e.length+C.length+_.length))>$k)return t;const n=ok(e,D,{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=Ck(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)||rk(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=jk(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=Ck(e);if(1>=t.length)return jk(t);const n=e=>F(jk(e)).cost;t=Ck(G(e)),t=Ik(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=nk(t,o,n,{passes:6,compare:(e,t)=>rk(e.stableId,t.stableId),maxEvaluations:Dk}),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:Dk});const r=t.length>8?1/0:Nk(t.length)*(t.length+C.length+_.length);if($k>=r){const e=ok(t,e=>D(jk(e)),{maxItems:8,maxEvaluations:5e4}),n=jk(e),o=jk(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=Ik(t,d,W),jk(t)})(H):G(H);if(!Y&&"crossing-min+inside-out"===s.laneOrder&&H.length>1)if(q){const e=Ck(H);let t=F(jk(e)),n=jk(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)||rk(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=jk(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=Ck(H),t=z(jk(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=jk(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=Ik(Ck(H),d,W),H=jk(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+=Lk(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+=Lk(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=Mk(a);H=Mk(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 Ak(r,i,H),{before:U,after:X,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function Ek(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 Ok=new Map,Fk=1e-9,zk=1e5;function Hk(e,t){let n=1/0,o=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>Fk&&(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 Wk(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function qk(e,t){return rk(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Gk(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 Yk(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 Vk(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 Xk(e,t,n){return!!n.has(e)&&t.some(t=>!Vk(e,t,n))}function Uk(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 Kk(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=Gk(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=Uk(e,s);i[t].set(n,(i[t].get(n)??0)+o),i[n].set(t,(i[n].get(t)??0)+o)}const a=Yk(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=Vk(e[n],e[o],a)?r:-r;if(Math.abs(i)>Fk&&(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>Fk||Fk>=Math.abs(e)&&t>Fk,f=(e,t,n,o)=>e>n+Fk||Fk>=Math.abs(e-n)&&t>o+Fk;let g=0;for(let n=0;32>n&&zk>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++<zk;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>=zk)break}for(let u=0;e.length-1>u;u++){for(let m=u+1;e.length>m&&g++<zk;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>=zk)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 Qk(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=Ok.get(r);if(i)return Ek(i.slots,n,o);const s={};for(const t of e)s[t.id]=Hk(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||rk(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(qk(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=qk(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)&&(Wk(t[o],t[r])||Wk(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(qk(e,n))||!!Wk(t[e],t[n])||!(!d.has(e)&&!d.has(n))&&!i.has(qk(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))&&!Xk(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,Yk(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=Gk(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=Uk(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=Yk(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]+=Vk(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:Kk(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)=>rk(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)||rk(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(Ok.has(e)&&Ok.delete(e),Ok.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}});Ok.size>12;){const e=Ok.keys().next().value;if(null==e)break;Ok.delete(e)}}(r,g),g}function Zk(e){return e.topMass+e.botMass}function Jk(e,t){const n=e.samples.filter(e=>e.t===t);if(n.length>0)return n.reduce((e,t)=>Zk(t)<Zk(e)?e:t,n[0]);let o=null;for(const n of e.samples){if(n.t>t)break;o=n}return o}function eS(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=Jk(t[r.id],e);if(!i||1e-9>=Zk(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})=>Zk(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=Jk(n,e);null!=t&&s&&Zk(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 tS(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=Ek(r.frozenSlots,n,b);x=e.slots,v=e.slotByNode,w=x.map(ik)}else if("reuse"===c){const o=Qk(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});Pk(x,v),0===w.length&&(w=x.map(ik));let k=null;r.frozenSlots||(r.fixedSlotOrder?function(e,t,n){const o=new Map(n.map((e,t)=>[e,t]));Ak(e,t,[...e].sort((e,t)=>(o.get(ik(e))??1/0)-(o.get(ik(t))??1/0)||rk(ik(e),ik(t))))}(x,v,r.fixedSlotOrder):r.runOrdering&&l&&"insertion"!==l&&(k=Bk(e,t,n,b,x,v,{plotH:i,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:m}))),Pk(x,v);const S=uk(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,I=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(ik),initialSlotOrder:w,ordering:k,crossingsBefore:C,crossingsAfter:M,lengthBefore:j,lengthAfter:I}}function nS(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function oS(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 rS=require("react/jsx-runtime"),iS="var(--semiotic-grid, #94a3b8)",sS="var(--semiotic-text-secondary, #475569)",aS="var(--semiotic-text-secondary, #94a3b8)",cS=require("react"),lS=require("d3-scale"),uS=require("d3-scale");function dS(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),I="number"==typeof A&&Number.isFinite(A)&&A>0;if(j&&C>1e-9&&M>0&&("auto"===A||I)){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 P="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:P,cp2X:P}}function hS(e){return Math.max(18,11*e.length*.58)}function pS(e){const t=1.22*hS(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 mS(e,t){const n=e.labelX-hS(e.labelText),o=t.labelX-hS(t.labelText);return t.labelX+3>=n&&e.labelX+3>=o}var yS=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function fS(e){return e.replace(yS,(e,t,n)=>`${n},${t}`)}function gS(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 bS(e){return{...e,pathD:fS(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function vS(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=Uw(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"===Qw(o)?t.push(o):n.push(o);return{fatal:t,warnings:n}}(k),C=function(e,t,n="static"){if("strip"!==Uw(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,uS.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||rk(e.id,t.id):(e,t)=>t.value-e.value||rk(e.id,t.id),i="temporal"===o?(e,t)=>e.startTime-t.startTime||rk(e.id,t.id):(e,t)=>t.value-e.value||rk(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||rk(e.partner,n.partner):e.latestEnd-n.latestEnd||rk(e.partner,n.partner):(e,t)=>t.total-e.total||rk(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]=kk(t,y,f,void 0,u);const b=tS(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)||rk(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||rk(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]=kk(t,y,f,void 0,u);const w=tS(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+sk(w.slots,C,m).reduce((e,t)=>e+t,0),j=k>0?Math.max(0,(o-M)/k):1,I=Number.isFinite(c)&&c>0?Math.min(j,c):j;let P=tS(e,t,g,y,{plotH:o,padding:C,valueScale:I,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)&&P.slots.length>1&&(Bk(e,t,g,P.laneLifetime,P.slots,P.slotByNode,{plotH:o,padding:C,valueScale:I,groupPadding:m,laneOrder:s,ribbonLane:h,domain:p,lanePlacement:l,mode:"geometry-refine"}),P=tS(e,t,g,y,{plotH:o,padding:C,valueScale:I,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(ik),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=wk(e,a,o),u=wk(s,c,o);r.set(i.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return r}(t,g,P.centerlines,I);g={};for(const t of e)g[t.id]=kk(t,y,f,n,u);P=tS(e,t,g,y,{plotH:o,padding:C,valueScale:I,packing:i,laneOrder:s,lifetimeMode:a,frozenSlots:P.slots,fixedSlotOrder:P.slots.map(ik),lanePlacement:l,groupPadding:m,ribbonLane:h,domain:p,stackValueScale:j})}const T=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),_=[...P.slots].sort((e,t)=>(T.get(ik(e))??1/0)-(T.get(ik(t))??1/0)||rk(ik(e),ik(t))),L={};_.forEach((e,t)=>{for(const n of e.occupants)L[n.id]=t});const N=uk(e,t,g,_,L,{plotH:o,padding:C,valueScale:I,stackValueScale:j,lanePlacement:"stack",groupPadding:m}),$=eS(e,g,_,L,N.centerlines,I,m),D=bk(Tk(L,t),_k(L,t),t,$,_,L,N.centerlines,P.laneLifetime,I,N.verticalUtilization,h,p);g=eS(e,g,P.slots,P.slotByNode,P.centerlines,I,m);const B=bk(Tk(P.slotByNode,t),_k(P.slotByNode,t),t,g,P.slots,P.slotByNode,P.centerlines,P.laneLifetime,I,P.verticalUtilization,h,p);return{nodeData:g,sides:f,valueScale:I,padding:C,compressedPadding:12>C,centerlines:P.centerlines,laneLifetime:P.laneLifetime,slots:P.slots,slotByNode:P.slotByNode,crossingsBefore:"insertion"===s?null:D.crossings,crossingsAfter:"insertion"===s?null:B.crossings,lengthBefore:"insertion"===s?null:D.weightedLength,lengthAfter:"insertion"===s?null:B.weightedLength,layoutQualityBefore:D,layoutQuality:B}}(t,C,{plotH:w,...u,ribbonLane:s,domain:o}),{centerlines:I,nodeData:P,valueScale:R}=j,T=Up(g,b),_=[],L=[],N=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),$=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),D=new Map;for(const e of C){const t=P[e.source]?.localAttachments.get(e.id),n=P[e.target]?.localAttachments.get(e.id);t&&n&&D.set(e.id,dS(t,I[e.source],n,I[e.target],R,M,s,o,{minRun:a,sourceRunwayStart:N.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,N,M,s,$),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,N,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,$);t.forEach((e,t)=>{const n=P[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=xk(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,I[e.id],R,M,o);if(!a)return;const c=xk(r,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],h=I[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=Zp(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=xk(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(vk(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]=wk(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]=wk(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}=Hv(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-hS(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)mS(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)mS(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:fS(e.pathD),gradientStubs:e.gradientStubs?.map(bS),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*hS(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]=pS(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+hS(e.labelText):hS(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:fS(e.pathD),bezier:gS(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:A,xScale:M}}var xS=require("d3-scale"),wS={};function kS(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 SS(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function AS(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 CS=class{constructor(e=function(){const e="string"==typeof wS.url&&wS.url?new URL("./processSankeyLayoutWorker.js",wS.url):Jx("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new ow({name:"ProcessSankey layout",createWorker:()=>e,parseMessage:e=>{const t=e,{requestId:n,error:o}=nw(t);return o?{requestId:n,ok:!1,error:tw(o)}:{requestId:n,ok:!0,payload:{layout:AS(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()}},MS=rw(()=>new CS);function jS(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 IS(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 PS(e){const t=IS(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 RS(e){const t=IS(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 TS=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:(0,lS.scaleTime)().domain(e).range([0,t])});function _S(e,t){const n=Uc(),{execution:o="auto",workerThreshold:r,colorById:i,fallbackPalette:s,rawNodeById:a,rawEdgeById:c}=t,l=(0,cS.useMemo)(()=>Object.keys(i).sort().map(e=>`${e}:${i[e]}`).join("|"),[i]),u=(0,cS.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&&!!SS()&&!jS(e)&&kS(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",n)}(e,o,r),h=(0,cS.useMemo)(()=>e?d?null:vS(e):TS([0,1],1),[u,d,e]),p=(0,cS.useRef)(n),[m,y]=(0,cS.useState)(()=>e?n?{...vS(e),status:"ready",error:null}:d?{...TS(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...vS(e),status:"ready",error:null}:{...TS([0,1],1),status:"ready",error:null});return(0,cS.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(!SS()||jS(e)||!kS(n,e.nodes.length,e.edges.length,l,u,o))return vS(e);try{const t=await function(e,t){return SS()?MS.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,n){return{input:{nodes:e.nodes.map(PS),edges:e.edges.map(RS),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,xS.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 vS(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 LS=require("react");function NS(e,t){return"function"==typeof e?e(t):t[e]}var $S=require("react"),DS=.22;function BS(e,t,n){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,n))}var ES=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=!BS(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,DS):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!BS({__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?DS: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=!BS(n,i,r);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:o?DS:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...o&&t?{opacity:DS}:{}},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&&BS({__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 OS(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var FS=require("react/jsx-runtime");var zS=require("react/jsx-runtime"),HS=(0,Vw.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:I="temporal",groupPadding:P=0,ribbonLane:R="both",ribbonMinRun:T=0,lifetimeMode:_="half",showLaneRails:L=!1,showQualityReadout:N=!1,showLabels:$=!0,labelPriorityAccessor:D,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,Vw.useRef)(null),fe=(0,Vw.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,LS.useState)([]),[h,p]=(0,LS.useState)([]),m=(0,LS.useRef)(u),y=(0,LS.useRef)(h);m.current=u,y.current=h;const f=(0,LS.useCallback)(e=>{m.current=e,d(e)},[]),g=(0,LS.useCallback)(e=>{y.current=e,p(e)},[]),b=void 0!==o,v=ft(b?o:u),x=(0,LS.useMemo)(()=>{const e=ft(n??[]),t=h;if(0===e.length&&0===t.length)return $w([],v,s,a);const o=new Set,i=[];for(const t of e){const e=NS(r,t)+"";o.has(e)||(o.add(e),i.push(t))}for(const e of t){const t=NS(r,e)+"";o.has(t)||(o.add(t),i.push(e))}const c=$w([],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,LS.useRef)(null),k=(0,LS.useCallback)((e,t)=>{const n=NS(i,e);return null!=n?n+"":`${NS(s,e)}-${NS(a,e)}-${t}`},[i,s,a]),S=(0,LS.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=NS(s,t)&&null!=NS(a,t)},[s,a]),A=(0,LS.useCallback)(e=>NS(r,e)+"",[r]);return nm(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=NS(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=NS(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,Vw.useMemo)(()=>{const e=(ge??[]).map(e=>{const t=xe(e),n=a?NS(a,e):t,o={id:t,label:null==n?t:n+"",__raw:e},r=f?NS(f,e):null;null!=r&&r+""!=""&&(o.group=r+"");const i=y?NS(y,e):null;if(Array.isArray(i)&&2===i.length){const e=nS(i[0]),t=nS(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:NS(c,e)+"",target:NS(l,e)+"",value:Number(NS(u,e)),startTime:nS(NS(d,e)),endTime:nS(NS(h,e)),__raw:e};if(p){const t=nS(NS(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(m){const t=nS(NS(m,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[nS(r[0]),nS(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=Ew({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)=>{OS(e)?ce(e.data,t):ce(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:pe,marginDefaults:oS(!!V,N,i.length>0,k),userMargin:Y,width:q,height:G,hasTitle:!!V,loading:J,loadingContent:ee,emptyContent:te}),Ie=(x??!!b)&&!!b,Pe=(0,Vw.useCallback)(e=>null!=Y&&("number"==typeof Y||null!=Y[e]),[Y]),Re=(0,Vw.useMemo)(()=>{const e={...je.margin};return Ie&&("right"===w&&!Pe("right")&&140>e.right?e.right=140:"bottom"===w&&!Pe("bottom")&&80>e.bottom&&(e.bottom=80)),e},[je.margin,Ie,w,Pe]),Te=q-Re.left-Re.right,_e=G-Re.top-Re.bottom,Le="vertical"===k?_e:Te,Ne=(0,Vw.useCallback)((e,t)=>{if(b&&ge){const t=Ce.get(e);if(t)return In(t,b,je.colorScale)}return je.effectivePalette[t%je.effectivePalette.length]||"#475569"},[b,ge,Ce,je.colorScale,je.effectivePalette]),$e=_S((0,Vw.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:Ne,showLabels:$,labelPriorityAccessor:D,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:I,groupPadding:P}}:null,[ke,Se,Ae,Te,_e,k,R,T,ne,Ne,$,D,B,E,O,b,u,S,A,C,_,M,j,I,P]),{execution:F,workerThreshold:z,colorById:(0,Vw.useMemo)(()=>{const e={};return ke.forEach((t,n)=>{e[t.id]=Ne(t.id,n)}),e},[ke,Ne]),fallbackPalette:je.effectivePalette,rawNodeById:Ce,rawEdgeById:Me}),{issues:De,warnings:Be,layout:Ee,xScale:Oe}=$e,Fe=$e.layoutConfig,ze=$e.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,Vw.useRef)(W);He.current=W,(0,Vw.useEffect)(()=>{He.current?.(ze)},[ze]),(0,Vw.useEffect)(()=>{0!==Be.length&&console.warn("ProcessSankey warnings:",Be.map(Zw).join("; "))},[Be]);const We=(0,Vw.useMemo)(()=>{if(!Ie||!b)return;const e=new Map;(ge??[]).forEach((t,n)=>{const o=NS(b,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:Ne(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},[Ie,b,ge,Ne,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,$S.useMemo)(()=>!1!==t&&n?void 0===t||!0===t?null:su(t)||null:null,[t,n]),h=(0,$S.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,$S.useCallback)(e=>i?i(e):e+"",[i]);return(0,$S.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!OS(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,FS.jsxs)("div",{style:{minWidth:160},children:[(0,FS.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),s.length>0&&(0,FS.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,FS.jsx)("thead",{children:(0,FS.jsxs)("tr",{style:{opacity:.6},children:[(0,FS.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,FS.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&(0,FS.jsx)("th",{})]})}),(0,FS.jsx)("tbody",{children:s.map((e,t)=>(0,FS.jsxs)("tr",{children:[(0,FS.jsx)("td",{style:{paddingRight:8},children:h(e.t)}),(0,FS.jsx)("td",{style:{textAlign:"right"},children:p(e.total)}),null!=i&&(0,FS.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&(0,FS.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",s.length," of ",i," samples"]})]})}const r=n,i=NS(s,r),m=NS(a,r),y=NS(c,r),f=NS(l,r),g=NS(u,r);return(0,FS.jsxs)("div",{style:{minWidth:160},children:[(0,FS.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",m+""]}),(0,FS.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=y&&(0,FS.jsxs)(FS.Fragment,{children:[(0,FS.jsx)("span",{style:{opacity:.6},children:"value"}),(0,FS.jsx)("span",{style:{textAlign:"right"},children:p(Number(y))})]}),null!=f&&(0,FS.jsxs)(FS.Fragment,{children:[(0,FS.jsx)("span",{style:{opacity:.6},children:"start"}),(0,FS.jsx)("span",{style:{textAlign:"right"},children:h(nS(f))})]}),null!=g&&(0,FS.jsxs)(FS.Fragment,{children:[(0,FS.jsx)("span",{style:{opacity:.6},children:"end"}),(0,FS.jsx)("span",{style:{textAlign:"right"},children:h(nS(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,Vw.useMemo)(()=>{if(!Ee)return null;const e=Be.map(e=>Zw(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),I=Math.max(j,M(C??s)),P=a.map((e,t)=>({tick:e,index:t,coordinate:m(p(e.date))})).filter(({coordinate:e})=>e>=j-.5&&I+.5>=e),R=null!==(w??null)&&null!=k&&null!=S,T=c&&(R||u.length>0)?(0,rS.jsxs)("g",{fill:aS,fontSize:10,textAnchor:"end",children:[R&&(0,rS.jsxs)(rS.Fragment,{children:[(0,rS.jsxs)("text",{x:r,y:-14,children:["crossings: ",x," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(S.pixelLength)]}),(0,rS.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,rS.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,rS.jsx)("text",{x:r,y:"vertical"===o?-3:2,fontSize:10,fill:aS,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,L=(e,t)=>h?h(e,t):iS;return(0,rS.jsxs)("g","vertical"===o?{children:[T,_,P.map(({index:e,coordinate:t})=>(0,rS.jsx)("line",{x1:0,y1:t,x2:r,y2:t,stroke:iS,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,rS.jsxs)("g",{children:[(0,rS.jsx)("line",{x1:i,y1:s,x2:i,y2:a,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,rS.jsx)("line",{x1:i-4,y1:s,x2:i+4,y2:s,stroke:c,strokeOpacity:.5}),(0,rS.jsx)("line",{x1:i-4,y1:a,x2:i+4,y2:a,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),(0,rS.jsx)("line",{x1:-4,y1:j,x2:-4,y2:I,stroke:iS}),P.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,rS.jsxs)("g",{transform:`translate(-4,${n})`,children:[(0,rS.jsx)("line",{x2:-6,stroke:iS}),(0,rS.jsx)("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:sS,children:r})]},t)})]}:{children:[T,_,P.map(({index:e,coordinate:t})=>(0,rS.jsx)("line",{x1:t,y1:0,x2:t,y2:i,stroke:iS,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,rS.jsxs)("g",{children:[(0,rS.jsx)("line",{x1:s,y1:i,x2:a,y2:i,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,rS.jsx)("line",{x1:s,y1:i-4,x2:s,y2:i+4,stroke:c,strokeOpacity:.5}),(0,rS.jsx)("line",{x1:a,y1:i-4,x2:a,y2:i+4,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),(0,rS.jsx)("line",{x1:j,y1:i+4,x2:I,y2:i+4,stroke:iS}),P.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,rS.jsxs)("g",{transform:`translate(${n},${i+4})`,children:[(0,rS.jsx)("line",{y2:6,stroke:iS}),(0,rS.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:sS,children:r})]},t)})]})}({layout:Ee,nodes:ke,orientation:k,plotW:Te,plotH:_e,timelineExtent:Le,axisTicks:i,showQualityReadout:N,showLaneRails:L,warnings:e,timeFormat:oe?e=>oe(e):void 0,colorOf:Ne,toTime:nS,xScale:e=>Number(Oe(e))})},[Ee,ke,k,Te,_e,Le,i,N,L,Be,oe,Ne,Oe]),Ye=(0,Vw.useMemo)(()=>(ge??[]).map(e=>({id:xe(e),data:e})),[ge,xe]),Ve=(0,Vw.useMemo)(()=>{const e=new Map;for(const t of Fe.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Fe]),Xe=(0,Vw.useMemo)(()=>(be??[]).map((e,t)=>{const n=we(e,t),o=Number(NS(u,e));return{id:n,source:NS(c,e)+"",target:NS(l,e)+"",value:Number.isFinite(o)?o:0,bezier:Ve.get(n),data:e}}),[be,we,c,l,u,Ve]);return De.length>0?(0,zS.jsxs)("svg",{width:q,height:G,role:"img","aria-label":V??"Process Sankey validation failed",children:[(0,zS.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),De.map((e,t)=>(0,zS.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Zw(e)},t))]}):je.loadingEl?je.loadingEl:je.emptyEl?je.emptyEl:(0,zS.jsxs)("div",{style:{position:"relative",width:q,height:G},children:["pending"===ze&&!1!==H&&!Ee&&(0,zS.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Tp(!0,q,G,H)}),(0,zS.jsx)(_w,{ref:ve,chartType:"force",nodes:Ye,edges:Xe,customNetworkLayout:ES,layoutConfig:Fe,size:[q,G],responsiveWidth:Q,responsiveHeight:Z,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,...rm({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})]})});HS.displayName="ProcessSankey";var WS=require("react"),qS=require("react/jsx-runtime");function GS(e){const t=vp(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:I}=e,{width:P,height:R,enableHover:T,showLabels:_=!0,title:L,description:N,summary:$,accessibleTable:D}=t,B=Ew({nodes:(0,WS.useMemo)(()=>Nw(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:P,height:R,hasTitle:!!L,loading:S,loadingContent:A}),E=(0,WS.useMemo)(()=>new Map,[]),O=(0,WS.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Mn[(e.depth||0)%Mn.length]:u?In(e.data||e,u,B.colorScale):mp(void 0,B.themeCategorical,d,void 0,E),t},[u,h,B.colorScale,B.themeCategorical,d,E]),F=(0,WS.useMemo)(()=>Yp(O,{stroke:M,strokeWidth:j,opacity:I}),[O,M,j,I]),z=(0,WS.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=(0,WS.useMemo)(()=>Yp(z,{stroke:M,strokeWidth:j,opacity:I}),[z,M,j,I]),W=(0,WS.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return Dw(c)},[i,c]),q=Op({componentName:"TreeDiagram",data:n});return q?(0,qS.jsx)(wp,{componentName:"TreeDiagram",message:q,width:P,height:R}):B.loadingEl?B.loadingEl:(0,qS.jsx)(jp,{componentName:"TreeDiagram",width:P,height:R,children:(0,qS.jsx)(_w,{chartType:i,...null!=n&&{data:n},size:[P,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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:su(f)||void 0,...rm({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:N,summary:$,accessibleTable:D,...null!=e.animate&&{animate:e.animate},...g})})}GS.displayName="TreeDiagram";var YS=require("react"),VS=require("react/jsx-runtime");function XS(e){const t=vp(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:I}=e,{nodeStyle:P,...R}=g,{width:T,height:_,enableHover:L,showLabels:N=!0,title:$,description:D,summary:B,accessibleTable:E}=t,O=Ew({nodes:(0,YS.useMemo)(()=>Nw(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:!!$,loading:S,loadingContent:A}),F=Wp(b),z=O.customHoverBehavior,H=(0,YS.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),W=(0,YS.useMemo)(()=>new Map,[]),q=(0,YS.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?In(e.data||e,c,O.colorScale):mp(void 0,O.themeCategorical,l,void 0,W),t},[c,u,O.colorScale,O.themeCategorical,l,W]),G=(0,YS.useMemo)(()=>y||P?e=>({...q(e),...P?P(e)??{}:{},...y?y(e)??{}:{}}):q,[q,y,P]),Y=(0,YS.useMemo)(()=>Yp(G,{stroke:M,strokeWidth:j,opacity:I}),[G,M,j,I]),V=(0,YS.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??sh;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,YS.useMemo)(()=>Dw(s),[s]),U=void 0!==m?m:!N||"parent"!==d&&"all"!==d?void 0:18,K=Op({componentName:"Treemap",data:n});return K?(0,VS.jsx)(wp,{componentName:"Treemap",message:K,width:T,height:_}):O.loadingEl?O.loadingEl:(0,VS.jsx)(jp,{componentName:"Treemap",width:T,height:_,children:(0,VS.jsx)(_w,{chartType:"treemap",...null!=n&&{data:n},size:[T,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:O.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:X,padding:p,paddingTop:U,nodeStyle:V,colorBy:c,colorScheme:O.effectivePalette,colorByDepth:u,nodeLabel:N?h||a:void 0,showLabels:N,labelMode:d,enableHover:L,tooltipContent:!1===f?()=>null:su(f)||void 0,...rm({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:$,description:D,summary:B,accessibleTable:E,...null!=e.animate&&{animate:e.animate},...R})})}XS.displayName="Treemap";var US=require("react"),KS=require("react/jsx-runtime");function QS(e){const t=vp(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:I,enableHover:P,showLabels:R=!0,title:T,description:_,summary:L,accessibleTable:N}=t,$=Ew({nodes:(0,US.useMemo)(()=>Nw(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:I,hasTitle:!!T,loading:w,loadingContent:k}),D=(0,US.useMemo)(()=>new Map,[]),B=(0,US.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Mn[(e.depth||0)%Mn.length]:c?In(e.data||e,c,$.colorScale):mp(void 0,$.themeCategorical,l,void 0,D),t},[c,u,$.colorScale,h,$.themeCategorical,l,D]),E=(0,US.useMemo)(()=>Yp(B,{stroke:A,strokeWidth:C,opacity:M}),[B,A,C,M]),O=(0,US.useMemo)(()=>Dw(s),[s]),F=Op({componentName:"CirclePack",data:n});return F?(0,KS.jsx)(wp,{componentName:"CirclePack",message:F,width:j,height:I}):$.loadingEl?$.loadingEl:(0,KS.jsx)(jp,{componentName:"CirclePack",width:j,height:I,children:(0,KS.jsx)(_w,{chartType:"circlepack",...null!=n&&{data:n},size:[j,I],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:$.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:O,padding:p,nodeStyle:E,colorBy:c,colorScheme:$.effectivePalette,colorByDepth:u,nodeLabel:R?d||a:void 0,showLabels:R,enableHover:P,tooltipContent:!1===m?()=>null:su(m)||void 0,...rm({linkedHover:x,selection:v,onObservation:f,onClick:g,mobileInteraction:$.mobileInteraction,customHoverBehavior:$.customHoverBehavior,customClickBehavior:$.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:$.legendState.onLegendHover,legendClickBehavior:$.legendState.onLegendClick,legendHighlightedCategory:$.legendState.highlightedCategory,legendIsolatedCategories:$.legendState.isolatedCategories},className:r,title:T,description:_,summary:L,accessibleTable:N,...null!=e.animate&&{animate:e.animate},...y})})}QS.displayName="CirclePack";var ZS=require("react"),JS=require("react/jsx-runtime"),eA=Mn;function tA(e){const t=vp(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:I,loading:P,loadingContent:R,stroke:T,strokeWidth:_,opacity:L}=e,{width:N,height:$,enableHover:D,title:B,description:E,summary:O,accessibleTable:F}=t,z=Ew({nodes:(0,ZS.useMemo)(()=>Nw(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:l?void 0:a,colorScheme:c,showLegend:!1,legendInteraction:void 0,selection:j,linkedHover:I,onObservation:A,onClick:C,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:M,marginDefaults:Fh(t),userMargin:o,width:N,height:$,hasTitle:!!B,loading:P,loadingContent:R}),H=(0,ZS.useMemo)(()=>new Map,[]),{colorScale:W,customClickBehavior:q,customHoverBehavior:G,themeCategorical:Y}=z,V=(0,ZS.useMemo)(()=>{if(Array.isArray(c))return c;const e=wn[c];return Array.isArray(e)?e:kn},[c]),X=(0,ZS.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=l?n?V[0]:eA[(e.depth||0)%eA.length]:a?In(e.data||e,a,W):mp(void 0,Y,c,void 0,H),t.opacity=n?1:.85,t},[a,l,W,V,Y,c,H]),U=(0,ZS.useMemo)(()=>Yp(X,{stroke:T,strokeWidth:_,opacity:L}),[X,T,_,L]),K=(0,ZS.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=(0,ZS.useMemo)(()=>e=>{G(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[G]),Z=(0,ZS.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=Op({componentName:"OrbitDiagram",data:n});return J?(0,JS.jsx)(wp,{componentName:"OrbitDiagram",message:J,width:N,height:$}):z.loadingEl?z.loadingEl:(0,JS.jsx)(jp,{componentName:"OrbitDiagram",width:N,height:$,children:(0,JS.jsx)(_w,{chartType:"orbit",...null!=n&&{data:n},size:[N,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,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&&D,tooltipContent:v?void 0:!1===x?()=>null:su(x)||void 0,...rm({linkedHover:I,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})})}tA.displayName="OrbitDiagram";var nA=require("react"),oA=require("react/jsx-runtime"),rA={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"},iA={opacity:.7,marginRight:4};function sA(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function aA(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function cA(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const i=e?.data??null,s=sA(i,t,"time"),a=sA(i,n,"value");return(0,oA.jsxs)("div",{className:"semiotic-tooltip",style:rA,children:[(0,oA.jsxs)("div",{children:[(0,oA.jsxs)("span",{style:iA,children:[o,":"]}),aA(s)]}),(0,oA.jsxs)("div",{children:[(0,oA.jsxs)("span",{style:iA,children:[r,":"]}),aA(a)]})]})}}function lA(e,t){return null!=e?e:Math.max(t?.length??0,200)}var uA=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}},dA=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 uA,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new uA;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 hA(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 pA={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},mA=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function yA(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;mA.lastIndex=0;let n,o=0,r=0;for(;null!==(n=mA.exec(t));){const e=parseFloat(n[1]),t=pA[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 fA="time",gA="value",bA="__aggLower",vA="__aggUpper",xA="__aggPartial",wA="count",kA="__aggStart",SA="__aggEnd";function AA(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[fA]:(e.start+e.end)/2,[gA]:hA(e,n),[wA]:e.count,[xA]:e.partial,[kA]:e.start,[SA]:e.end},i=function(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=hA(e,n),i=e.stddev*o;return[r-i,r+i]}(e,o,n,r);return i&&(t[bA]=i[0],t[vA]=i[1]),t})}var CA=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}},MA=require("react/jsx-runtime");function jA(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 IA=(0,nA.forwardRef)(function(e,t){const n=vp(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:I,pulse:P,staleness:R,transition:T,linkedHover:_,selection:L,onObservation:N,chartId:$,loading:D,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??cA({timeAccessor:u,valueAccessor:d}),X=(0,nA.useRef)(null),{customHoverBehavior:U}=gp({selection:L,linkedHover:_,unwrapData:!0,onObservation:N,chartType:"RealtimeLineChart",chartId:$}),K=(0,nA.useCallback)(e=>{k&&k(e),U(e)},[k,U]),Q=null!=z,[Z,J]=(0,nA.useState)([]),ee=(0,nA.useRef)(null),te=(0,nA.useRef)(z);te.current=z;const ne=(0,nA.useRef)(Q);ne.current=Q;const oe=(0,nA.useRef)(Z);oe.current=Z;const re=(0,nA.useRef)({timeAccessor:u,valueAccessor:d});re.current={timeAccessor:u,valueAccessor:d},(0,nA.useEffect)(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=yA("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?yA(e.hop):void 0,r=null!=e.gap?yA(e.gap):void 0;return new dA({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=jA(o,e,"time"),i=jA(o,n,"value");null!=r&&null!=i&&t.push(r,i)}}J(t?AA(t,e):[])},[Q?[z.window??"tumbling",z.size,z.hop??"",z.gap??"",z.retain??""].join("|"):"",Q,l]),(0,nA.useEffect)(()=>{Q&&ee.current&&J(AA(ee.current,te.current))},[z?.stat,z?.band,z?.sigma]);const ie=(0,nA.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=jA(n,o,"time"),i=jA(n,r,"value");null!=e&&null!=i&&t.push(e,i)}J(AA(t,n))},[]),se=null!=H,ae=(0,nA.useRef)(null),ce=(0,nA.useRef)(H);ce.current=H;const le=(0,nA.useRef)(se);le.current=se;const ue=(0,nA.useRef)(N);ue.current=N;const de=(0,nA.useRef)($);de.current=$,(0,nA.useEffect)(()=>{ae.current=se?function(e){const t=yA(e.lateness);return null==t?null:new CA({lateness:t,getTime:e=>jA(e,re.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${H.lateness}|${H.latePolicy??"drop"}`:"",se]);const he=(0,nA.useCallback)(e=>{0!==e.length&&(ne.current?ie(e):X.current?.pushMany(e))},[ie]),pe=(0,nA.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:jA(i,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:de.current})}}}he(n)},[he]);(0,nA.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=Tp(D,Y[0],Y[1],B),ye=me?null:Rp(Q?void 0:l,Y[0],Y[1],E),fe={stroke:y,strokeWidth:f,strokeDasharray:g};null!=b&&(fe.opacity=b);const ge=lA(c,l),be=Q?Z:l,ve=Q?fA:u,xe=Q?gA:d,we=Q&&z&&"none"!==(z.band??"none")?{y0Accessor:bA,y1Accessor:vA,perSeries:!1}:void 0;return me||ye||(0,MA.jsx)(Zd,{ref:X,chartType:"line",runtimeMode:"streaming",size:Y,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,...rm({linkedHover:_,selection:L,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:I,pulse:P,staleness:R,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});IA.displayName="RealtimeLineChart";var PA=require("react");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();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var TA=require("react/jsx-runtime"),_A=(0,PA.forwardRef)(function(e,t){const n=vp(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:I,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,linkedHover:L,selection:N,decay:$,pulse:D,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,PA.useMemo)(()=>b?e=>b[e]??v??"#999":void 0,[b,v]),{legend:ee,margin:te,legendPosition:ne}=up({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=sA(o,t,"time"),r=sA(o,n,"value");return(0,oA.jsxs)("div",{className:"semiotic-tooltip",style:rA,children:[(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"x:"}),aA(e)]}),(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"y:"}),aA(r)]})]})}return(0,oA.jsxs)("div",{className:"semiotic-tooltip",style:rA,children:[(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"range:"}),aA(o.binStart),"–",aA(o.binEnd)]}),null!=o.total&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"count:"}),aA(o.total)]}),null!=o.category&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"category:"}),aA(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),re=(0,PA.useRef)(null),{customHoverBehavior:ie}=gp({selection:N,linkedHover:L,unwrapData:!0,onObservation:O,chartType:"RealtimeHistogram",chartId:F}),se=(0,PA.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=ih(U),le="string"==typeof d?d:"time",ue=vh({name:ce?.name||"__unused_hist_brush__",xField:ce?.xField||le,...ce?.yField?{yField:ce.yField}:{}}),de=(0,PA.useRef)(ue.brushInteraction);de.current=ue.brushInteraction;const he=(0,PA.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,PA.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=Tp(z,Z[0],Z[1],H),me=pe?null:Rp(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=lA(l,u),be=(0,PA.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=RA(r,n,"time"),i=RA(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,TA.jsx)(Zd,{ref:re,chartType:"bar",runtimeMode:"streaming",size:Z,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,...rm({linkedHover:L,selection:N,onObservation:O,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:se}),annotations:I,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,decay:$,pulse:D,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 LA(e){return(0,TA.jsx)(_A,{...e,windowMode:"growing"})}_A.displayName="RealtimeHistogram",LA.displayName="TemporalHistogram";var NA=require("react"),$A=require("react/jsx-runtime"),DA=(0,NA.forwardRef)(function(e,t){const n=vp(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:I,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,linkedHover:L,selection:N,onObservation:$,chartId:D,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??cA({timeAccessor:u,valueAccessor:d}),V=(0,NA.useRef)(null),{customHoverBehavior:X}=gp({selection:N,linkedHover:L,unwrapData:!0,onObservation:$,chartType:"RealtimeSwarmChart",chartId:D}),U=(0,NA.useCallback)(e=>{j&&j(e),X(e)},[j,X]);(0,NA.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=Tp(B,G[0],G[1],E),Q=K?null:Rp(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=lA(c,l);return K||Q||(0,$A.jsx)(Zd,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:G,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,...rm({linkedHover:L,selection:N,onObservation:$,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:I,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:T,tickFormatValue:_,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});DA.displayName="RealtimeSwarmChart";var BA=require("react"),EA=require("react/jsx-runtime"),OA=(0,BA.forwardRef)(function(e,t){const n=vp(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:I,svgAnnotationRules:P,tickFormatTime:R,tickFormatValue:T,linkedHover:_,selection:L,onObservation:N,chartId:$,loading:D,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=sA(o,t,"time"),i=o?.delta??sA(o,n,"value"),s=o?.cumEnd,a="number"==typeof i?0>i?aA(i):"+"+aA(i):aA(i);return(0,oA.jsxs)("div",{className:"semiotic-tooltip",style:rA,children:[(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"x:"}),aA(r)]}),(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"Δ:"}),a]}),null!=s&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"total:"}),aA(s)]})]})}}({timeAccessor:u,valueAccessor:d}),Y=(0,BA.useRef)(null),{customHoverBehavior:V}=gp({selection:L,linkedHover:_,unwrapData:!0,onObservation:N,chartType:"RealtimeWaterfallChart",chartId:$}),X=(0,BA.useCallback)(e=>{M&&M(e),V(e)},[M,V]);(0,BA.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=Tp(D,q[0],q[1],B),K=U?null:Rp(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=lA(c,l);return U||K||(0,EA.jsx)(Zd,{ref:Y,chartType:"waterfall",runtimeMode:"streaming",size:q,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,...rm({linkedHover:_,selection:L,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:X}),annotations:j,autoPlaceAnnotations:I,svgAnnotationRules:P,tickFormatTime:R,tickFormatValue:T,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});OA.displayName="RealtimeWaterfallChart";var FA=require("react"),zA=require("react/jsx-runtime"),HA=(0,FA.forwardRef)(function(e,t){const n=vp(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:I,pulse:P,staleness:R,linkedHover:T,selection:_,onObservation:L,chartId:N,loading:$,loadingContent:D,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??sA(i,t,"time"),a=i?.yCenter??sA(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,d=i?.agg??"count";return(0,oA.jsxs)("div",{className:"semiotic-tooltip",style:rA,children:[(0,oA.jsxs)("div",{children:[(0,oA.jsxs)("span",{style:iA,children:[o,":"]}),aA(s)]}),(0,oA.jsxs)("div",{children:[(0,oA.jsxs)("span",{style:iA,children:[r,":"]}),aA(a)]}),null!=c&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"count:"}),aA(c)]}),"sum"===d&&null!=l&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"sum:"}),aA(l)]}),"mean"===d&&null!=u&&(0,oA.jsxs)("div",{children:[(0,oA.jsx)("span",{style:iA,children:"mean:"}),aA(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=(0,FA.useRef)(null),{customHoverBehavior:Y}=gp({selection:_,linkedHover:T,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:N}),V=(0,FA.useCallback)(e=>{k&&k(e),Y(e)},[k,Y]);(0,FA.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=Tp($,W[0],W[1],D),U=X?null:Rp(l,W[0],W[1],B),K=E?`${i||""} semiotic-emphasis-${E}`.trim():i,Q=lA(c,l);return X||U||(0,zA.jsx)(Zd,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:W,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,...rm({linkedHover:T,selection:_,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:S,autoPlaceAnnotations:A,svgAnnotationRules:C,tickFormatTime:M,tickFormatValue:j,decay:I,pulse:P,staleness:R,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});HA.displayName="RealtimeHeatmap";var WA=require("react"),qA=d(require("react")),GA=require("react"),YA={names:["--semiotic-bg","--surface-1","--surface-0"],fallback:"#f8fafc"},VA={names:["--semiotic-border","--surface-3"],fallback:"#334155"},XA={names:["--semiotic-danger","--viz-4"],fallback:"#dc2626"},UA={names:["--semiotic-focus","--accent","--viz-9"],fallback:"#f97316"},KA={names:["--semiotic-grid","--surface-3"],fallback:"#cbd5e1"},QA={names:["--semiotic-primary","--accent","--viz-5"],fallback:"#0ea5e9"},ZA={names:["--semiotic-success","--viz-2"],fallback:"#22c55e"},JA={names:["--semiotic-text","--text-primary"],fallback:"#0f172a"},eC={names:["--semiotic-text-secondary","--text-secondary"],fallback:"#475569"},tC={names:["--semiotic-warning","--viz-9","--viz-3"],fallback:"#f97316"};function nC(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 oC(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 oC(`#${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 rC=d(require("react")),iC=require("d3-scale"),sC=require("react/jsx-runtime");function aC(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function cC(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=rC.useMemo(()=>function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(y),[y]),C=rC.useMemo(()=>function(e){const{width:t,height:n,pointNodes:o=[],data:r}=e;return{scales:{x:(0,iC.scaleLinear)().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:(0,iC.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=rC.useMemo(()=>A&&x?ja({annotations:A,context:C,..."object"==typeof x?x:{}}):A,[C,x,A]),j=rC.useMemo(()=>ra(0,S),[S]),I=M?oa(M,j,w,C):null,P=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,sC.jsxs)(sC.Fragment,{children:[P?(0,sC.jsx)("style",{children:Fs},"physics-annotation-disclosure-style"):null,(0,sC.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,sC.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[I,k]}),s&&"string"==typeof s?(0,sC.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,sC.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 lC=2500;function uC(e){return"function"==typeof e}function dC(e){return void 0===e||!1===e||!uC(e.binAccessor)&&!uC(e.labelAccessor)&&!uC(e.valueAccessor)}function hC(e){if(void 0!==e){if(!1===e)return!1;if(!dC(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 pC(e){if(e)return{chartId:e.chartId,chartType:e.chartType,sensors:e.sensors}}function mC(e){return function(e){return!uC(e?.timeAccessor)}(e)}function yC(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:pC(n),sediment:hC(o)}}var fC={};function gC(){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 bC=class{constructor(e=function(){const e="string"==typeof fC.url&&fC.url?new URL("./physicsWorker.js",fC.url):Jx("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(gC());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(gC())},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(!mC(n))throw new TypeError("Physics worker spawn pacing only supports string time accessors");const r=await this.request({type:"init",config:yC(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:yC(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(!mC(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 vC(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 xC={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},wC=1e-9,kC=.005;function SC(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function AC(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 CC(e,t,n){return Math.max(t,Math.min(n,e))}function MC(e,t,n){return Math.min(e??n,t??n)}function jC(e,t,n){return CC(Math.max(e??n,t??n),0,1)}function IC(e){return 0>e?-1:1}function PC(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 RC(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 TC(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function _C(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:IC(c),ny:0,penetration:l}:{nx:0,ny:IC(u),penetration:d}:null}function LC(e,t,n,o,r,i,s){const a=i/2,c=s/2,l=e-CC(e,o-a,o+a),u=t-CC(t,r-c,r+c),d=l*l+u*u;if(d>n*n)return null;if(wC>=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 NC(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(wC>=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 _C(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=LC(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?LC(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function $C(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?LC(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):_C(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>wC?CC(((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(wC>=y){const e=Math.sqrt(u);return e>wC?{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 DC(e,t){return`${e}\0${t}`}function BC(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function EC(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:SC(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function OC(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 FC(e){return{id:e.id,shape:AC(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:OC(e.bodyFilter),index:e.index}}function zC(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 HC(e,t){return!!t?.some(t=>Object.is(e,t))}function WC(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=zC(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!HC(n,t.oneOf)||t.notOneOf&&HC(n,t.notOneOf))}function qC(e,t){return WC(t,e.bodyFilter)}var GC=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={...xC,...e},this.random=vC(this.options.seed)}init(e={}){this.options={...xC,...e},this.random=vC(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(wC,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:SC(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))BC(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:AC(t.shape),bodyFilter:OC(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:SC(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(BC)}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(EC),colliders:this.sortedColliders().map(FC),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=vC(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=EC(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=FC(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(wC>=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=NC(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=PC(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&&TC(PC(e[i]),PC(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(wC>=i)return;const s=Math.max(0,n.penetration-kC)/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+MC(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(wC>=Math.abs(c)||wC>=l)return;const u=jC(e.friction,t.friction,this.options.friction),d=CC(-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(!qC(e,o))continue;if(!TC(PC(o),RC(e)))continue;const t=$C(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-kC),e.y+=n.ny*Math.max(0,n.penetration-kC);const o=e.vx*n.nx+e.vy*n.ny;if(0>o){const r=MC(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=jC(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=PC(o);for(const r of n){if(!qC(r,o))continue;if(!TC(e,RC(r)))continue;if(!$C(o,r))continue;const n=DC(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}=BC(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()}},YC=class{constructor(e={}){this.id="builtin",this.capabilities={...(new GC).capabilities,engine:"builtin"},this.world=new GC(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 VC(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new YC(e)}(t)}var XC=["binId","targetBin","category","windowIndex","lane","group"];function UC(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 KC(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 QC(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 ZC(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function JC(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?ZC(t,e):void 0}function eM(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function tM(e){const t=KC(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:KC(e.x),y:KC(e.y),value:t}}var nM=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=eM(JC(this.config.binAccessor,e,t))??function(e){for(const t of XC){const n=eM(ZC(e,t));if(n)return n}return"sediment"}(e),o=eM(JC(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?ZC(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,UC(s.x,e.x),UC(s.y,e.y),UC(s.value,r),i>0&&(s.bodyIds.push(e.id),s.bodyIds.length>i&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-i))),tM(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(tM)}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:QC(t.x),y:QC(t.y),value:QC(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 oM(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var rM={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},iM={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function sM(e={},t=iM){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 aM(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function cM(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 lM(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function uM(e){return{...aM(e),sequence:e.sequence,spawnAt:e.spawnAt}}function dM(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 hM(e){return!1!==e&&{...e}}function pM(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function mM(e){return{...e,gravity:{...e.gravity}}}function yM(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 fM(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function gM(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 bM(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 vM=require("d3-quadtree"),xM=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=yM(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,vM.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},wM=["data","scene-geometry","data-paint","accessibility","evidence"],kM=["scene-geometry","data-paint","accessibility","evidence"],SM=["overlay","accessibility","evidence"],AM=(e,t)=>({retainedData:e,invalidations:t}),CM=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],MM=["scene-geometry","data-paint","accessibility","evidence"],jM=[],IM={engine:AM("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:AM("preserve",MM),colliders:AM("preserve",MM),sediment:AM("preserve",MM),bodyBudget:AM("preserve",CM),bodyLimit:AM("preserve",CM),eviction:AM("preserve",CM),fixedDt:AM("preserve",jM),maxDeltaSeconds:AM("preserve",jM),maxSubsteps:AM("preserve",jM),settleStepLimit:AM("preserve",jM),timeScale:AM("preserve",jM),observation:AM("preserve",jM)},PM=AM("preserve",CM);function RM(e){let t="preserve";const n=new Set;for(const o of e){const e=IM[o]??PM;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var TM=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function _M(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&TM.every(n=>e[n]===t[n])}function LM(e,t,n,o){return e||!t?"paused":n||!o?"running":"settled"}var NM=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}},$M=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new xM,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 NM;const{bodyBudget:t,colliders:n,engine:o,kernel:r,observation:i,sediment:s,...a}=e;this.config={...rM,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=o,this.observation=sM(i),this.sediment=new nM(s??!1),this.world=VC(o,{fixedDt:this.config.fixedDt,...r}),this.quiescence.setKernelOptions(r),n&&this.world.setColliders(dM(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!_M(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=VC(r,e.options),this.world.restore(e),this.revision+=1}if(i&&!_M(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=sM(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(dM(n)),this.revision+=1),this.configInput={...this.configInput,...e};const l=RM(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(dM(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},RM(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],o=t?function(e,t={}){const n=cM(t.startAt)??0,o=t.pacing??"immediate";if("arrival"===o){const o=e.map((e,n)=>function(e,t,n){return"function"==typeof n?cM(n(e,t)):"string"==typeof n?cM(lM(e,n)):cM(e.spawnAt)??cM(lM(e,"arrivalTime"))??cM(lM(e,"timestamp"))??cM(lM(e,"time"))??cM(lM(e,"eventTime"))}(e,n,t.timeAccessor)),r=o.filter(e=>null!=e),i=r.length>0?Math.min(...r):0,s=cM(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{...aM(e),spawnAt:n+s/a}})}if("object"==typeof o){const t=cM(o.ratePerSec);if(t&&t>0)return e.map((e,o)=>({...aM(e),spawnAt:n+o/t}))}return e.map(e=>({...aM(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of o)this.queue.push({...aM(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(pM),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?wM:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(aM(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},wM)}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?wM:[])),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"},wM)}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?wM:kM:[]),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?wM:kM),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?SM:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?SM:[])}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?wM:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},kM),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},kM)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},kM)}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:hM(this.bodyBudget),config:{...this.config,kernel:mM(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(uM),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:hM(e.bodyBudget??{}),kernel:mM(e.world.options)},this.bodyBudget=hM(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(uM).sort(pM),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??LM(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"},wM)}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}=fM(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(fM(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=oM(e.bodyLimit),i=oM(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const o=oM(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=LM(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 DM(e,t,n){const o=new $M(e);return t?.length&&(o.enqueue(t,n),o.materializeDueSpawns()),o}function BM(){return"undefined"!=typeof performance?performance.now():Date.now()}var EM=d(require("react-dom/server"));function OM(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 FM={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function zM(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 HM(e,t){const n="function"==typeof t?t(e):t;return{...FM,...n??{}}}function WM(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)??zM(e)},r={style:HM(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:OM(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 qM=require("react/jsx-runtime"),GM={top:0,right:0,bottom:0,left:0};function YM(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function VM(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 XM(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=zC(e.datum,t),o=zC(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function UM(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 KM(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,I=0,P=0,R=0,T=0,_=0,L=0,N=0,$=0,D=0,B=-1,E=!1;function O(e,n){const o=n(e);return!!o&&o.activeRegionIds.includes(t)}function F(){D+=1}function z(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function H(n,o,r,i){const 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),N=Math.max(N,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(!WC(t,e.bodyFilter))continue;const n=XM(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,N=L+j;S=N,A=null==A?L:Math.min(A,L);const D={start:L,end:N,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=VM(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,D.arrivals+=1,D.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,I+=r,D.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),y.delete(n.bodyId),k+=1,P+=n.total,D.completions+=1,D.completedWork+=n.total;const s=Math.max(0,S-n.queuedAt);$+=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()}(D);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:I,completedWork:P,blockedCount:R,abandonedCount:T,abandonedWork:_,peakQueueDepth:L,peakRemainingWork:N,queueAge:{count:i.length,meanSeconds:i.length>0?s/i.length:0,p50Seconds:UM(i,.5),p95Seconds:UM(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:k>0?$/k:0,window:Y(),simulatedAt:S,metricRevision:D}},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 QM(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}var ZM=require("react");function JM(){return"undefined"==typeof document||!document.hidden}function ej(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 tj(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function nj(e){return e.sensorId??"stream-region-"+e.id}function oj(e){const t=nj(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 rj(e){if(e)return{activeRegionIds:Array.from(e.activeRegionIds),regionIds:Array.from(e.regionIds),charges:{...e.charges},attributes:{...e.attributes},energy:e.energy}}function ij(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 sj(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 aj(e){return e.some(e=>null!=e.force||null!=e.damping||null!=e.impulseOnEnter||null!=e.impulseOnExit)}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}var lj=[];function uj(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||!aj(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=rj(o);if(s)for(const n of o.activeRegionIds){const o=i.get(n);if(!o)continue;const c=ij(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=rj(u);let h=lj;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=cj(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=>rj(e.regionState.get(t))}),e.onTick?.(e.result,t),{regionEffectsApplied:r,bodyForcesApplied:i,snapshot:n}}function dj(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 hj=require("react");function pj(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function mj(e,t){const n="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,pj(e.thickness)??pj(n)??pj(t.thickness)??4)}var yj=d(require("react")),fj=require("react/jsx-runtime"),gj={border:0,clip:"rect(0 0 0 0)",height:1,margin:-1,overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:1},bj="semiotic-accessible-data-table",vj=bj+" semiotic-accessible-data-table-hidden",xj=bj+" semiotic-accessible-data-table-visible",wj={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"},kj={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Sj={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)"},Aj={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Cj={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))"},Mj={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},jj={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ij={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 Pj(e){return null==e?null:"string"==typeof e||"number"==typeof e||"boolean"==typeof e?e+"":null}function Rj(e){return{__semioticHoverData:!0,body:e,data:e.datum??e,id:e.id,type:"body",x:e.x,y:e.y}}function Tj(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 _j(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 Lj(e){const t=Nj(e.datum??e);return t.length?t.map(([e,t])=>`${e}: ${t}`).join(", "):"Physics body "+e.id}function Nj(e){return e&&"object"==typeof e?Object.entries(e).map(([e,t])=>{if(e.startsWith("_"))return null;const n=Pj(t);return null==n?null:[e,n]}).filter(e=>null!=e).slice(0,8):[]}function $j({hover:e}){const t=Nj(e.data);return(0,fj.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[(0,fj.jsx)("div",{style:{fontWeight:700,marginBottom:t.length?4:0},children:e.id}),t.map(([e,t])=>(0,fj.jsxs)("div",{children:[(0,fj.jsxs)("span",{style:{opacity:.72},children:[e,": "]}),(0,fj.jsx)("span",{children:t})]},e))]})}function Dj(e){return e.datum&&"object"==typeof e.datum?Object.entries(e.datum).map(([e,t])=>{const n=Pj(t);return null==n?null:`${e}: ${n}`}).filter(e=>null!=e).slice(0,8).join(", "):""}function Bj(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 Ej(e){const{chartTitle:t,items:n,tableId:o}=e,[r,i]=yj.useState(!1),[s,a]=yj.useState(5),c=hl(),l=c?.visible??!1,u=r||l,d=yj.useRef(null),h="Data summary for "+(t??"physics chart");yj.useEffect(()=>{u||a(5)},[u]);const p=yj.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),m=yj.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!n.length)return(0,fj.jsx)("span",{id:o,tabIndex:-1,style:gj});if(!u)return(0,fj.jsx)("div",{id:o,className:vj,role:"region","aria-label":h,tabIndex:-1,style:gj,onFocus:p,children:(0,fj.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,fj.jsxs)("div",{ref:d,id:o,className:xj,role:"region","aria-label":h,tabIndex:-1,onBlur:m,style:wj,children:[(0,fj.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close","aria-label":"Close data summary",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},style:Sj,children:"×"}),(0,fj.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:kj,children:Bj(n)}),(0,fj.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Semantic items for "+(t??"physics chart"),style:Aj,children:[(0,fj.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:jj,children:g>0?`First ${y} of ${n.length} semantic items`:`All ${n.length} semantic items`}),(0,fj.jsx)("thead",{children:(0,fj.jsxs)("tr",{children:[(0,fj.jsx)("th",{scope:"col",style:Cj,children:"Item"}),(0,fj.jsx)("th",{scope:"col",style:Cj,children:"Description"}),(0,fj.jsx)("th",{scope:"col",style:Cj,children:"Group"}),(0,fj.jsx)("th",{scope:"col",style:Cj,children:"Position"}),(0,fj.jsx)("th",{scope:"col",style:Cj,children:"Data"})]})}),(0,fj.jsx)("tbody",{children:f.map((e,t)=>(0,fj.jsxs)("tr",{children:[(0,fj.jsx)("th",{scope:"row",style:Mj,children:e.label}),(0,fj.jsx)("td",{style:Mj,children:e.description??e.label}),(0,fj.jsx)("td",{style:Mj,children:e.group??""}),(0,fj.jsxs)("td",{style:Mj,children:[Math.round(e.x),", ",Math.round(e.y)]}),(0,fj.jsx)("td",{style:Mj,children:Dj(e)})]},e.id??`${e.label}-${t}`))})]}),g>0?(0,fj.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ij,children:["Show ",Math.min(25,g)," more"," ",1===g?"row":"rows"," (",g," remaining)"]}):null]})}$j.ownsChrome=!0;var Oj=require("react/jsx-runtime"),Fj=[640,360],zj={top:0,right:0,bottom:0,left:0},Hj=new Set(["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),Wj="StreamPhysicsFrame",qj=(0,GA.memo)((0,GA.forwardRef)(function(e,t){const{accessibleTable:n=!0,annotations:o,onAnnotationActivate:r,autoPlaceAnnotations:i,background:s,backgroundGraphics:a,bodySemanticItemLimit:c=200,bodySemanticItems:l=!1,bodySemanticUpdateMs:u=200,bodyForces:d,bodyStyle:h,chartId:p,className:m,frameScheduler:y,clock:f,random:g,seed:b,color:v,config:x,controllers:w,continuous:k=!1,description:S,emphasis:A,chartMode:C,enableHover:M=!0,foregroundGraphics:j,hoverRadius:I=16,initialSpawns:P,initialSpawnPacing:R,legend:T,legendClickBehavior:_,legendHighlightedCategory:L,legendHoverBehavior:N,legendIsolatedCategories:$,legendLayout:D,legendPosition:B,margin:E,onClick:O,onObservation:F,onRegionEvent:z,onSimulationExecutionChange:H,onBodyHover:W,onBodyPointerDown:q,onSemanticItemActivate:G,onSemanticItemFocus:Y,onTick:V,opacity:X,paused:U=!1,regionEffects:K=[],responsiveHeight:Q,responsiveWidth:Z,selectedBodyStyle:J={stroke:"#111827",strokeWidth:2,opacity:1},selection:ee,semanticItems:te=[],simulationExecution:ne="auto",size:oe=Fj,stroke:re,strokeWidth:ie,summary:se,suspendWhenHidden:ae=!0,svgAnnotationRules:ce,title:le,tooltipContent:ue,workerBodyThreshold:de=lC,renderBody:he,beforePaint:pe,afterPaint:me}=e,ye=qA.useMemo(()=>({color:v,stroke:re,strokeWidth:ie,opacity:X}),[v,X,re,ie]),fe=(0,GA.useRef)(F);fe.current=F;const ge=(0,GA.useRef)(p);ge.current=p;const be=(0,GA.useRef)(new Map),ve=(0,GA.useRef)(K);ve.current=K;const xe=(0,GA.useRef)(d),we=(0,GA.useRef)(V);we.current=V;const ke=qA.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=QM(n,o.bodyForce(e)));return n}}}(w),[w]),Se=(0,GA.useRef)(ke);Se.current=ke;const Ae=k||!!ke?.continuous,Ce=(0,GA.useRef)(Ae);Ce.current=Ae;const Me=qA.useMemo(()=>{if(!d&&!ke?.bodyForce)return d;if(!ke?.bodyForce)return d;if(!d)return ke.bodyForce;const e=ke.bodyForce;return t=>{const n="function"==typeof d?d(t):d,o="function"==typeof e?e(t):e;return n||o?{x:(n?.x??0)+(o?.x??0),y:(n?.y??0)+(o?.y??0)}:null}},[d,ke]);xe.current=Me;const je=qA.useMemo(()=>new Map(K.map(e=>[nj(e),e])),[K]),Ie=qA.useMemo(()=>new Map(K.map(e=>[e.id,e])),[K]),Pe=qA.useMemo(()=>K.map(sj).filter(e=>null!=e),[K]),[Re,Te]=qA.useState([]),_e=qA.useMemo(()=>Re.length||Pe.length?[...te,...Re,...Pe]:te,[Re,Pe,te]),Le=qA.useMemo(()=>aj(K),[K]),Ne=!!Me,$e=(0,GA.useRef)(null),De=(0,GA.useRef)(f??BM);De.current=f??BM;const Be=(0,GA.useCallback)((e,t,n)=>{const o=$e.current;if(!o||!n)return!1;const r=o.readBodies().find(t=>t.id===e),i=rj(be.current.get(e));if(!r||!i)return!1;const s=ij(n,{body:r,region:t,regionState:i});return!(!s||!s.x&&!s.y||(o.applyImpulse(e,s.x??0,s.y??0),0))},[]),Ee=(0,GA.useCallback)((e,t,n)=>{if(!n.bodyId)return;const o=rj(be.current.get(n.bodyId));if(!o)return;const r={bodyId:n.bodyId,datum:n.datum,observation:n,region:t,regionState:o,type:e};"region-enter"===e?t.onEnter?.(r):t.onExit?.(r),z?.(r)},[z]),Oe=(0,GA.useCallback)(e=>{const t=e.sensorId?je.get(e.sensorId):void 0;if(!t||!e.bodyId)return;const n=function(e,t){let n=e.get(t);return n||(n={activeRegionIds:new Set,attributes:{},charges:{},energy:0,regionIds:new Set},e.set(t,n)),n}(be.current,e.bodyId),o=$e.current?.readBodies().find(t=>t.id===e.bodyId),r=rj(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)}Be(e.bodyId,t,t.impulseOnEnter),Ee("region-enter",t,e)}else"physics-proximity-exit"===e.type&&(n.activeRegionIds.delete(t.id),Be(e.bodyId,t,t.impulseOnExit),Ee("region-exit",t,e))},[Be,Ee,je]),Fe=qA.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=mj(r,t),s=r.colliderId??`${n}${r.id}`;let a;if("x"===e){const e=pj(r.x),n=pj(r.y1)??pj(t.plotBounds?.y)??pj(r.y),o=pj(r.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??pj(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=pj(r.y),n=pj(r.x1)??pj(t.plotBounds?.x)??pj(r.x),o=pj(r.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??pj(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:pj(r.restitution)??pj(t.barrierRestitution)},..."barrier"!==r.physics||null==r.friction&&null==t.barrierFriction?{}:{friction:pj(r.friction)??pj(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:nj(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...oj(e)]),d=Object.fromEntries(i.map(e=>[nj(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:p,chartType:Wj,config:x,onRegionObservation:Oe,regionEffects:K,seed:b,size:oe}),[o,p,x,Oe,K,b,oe]);if(!$e.current){const e=DM(Fe,P,R);e.setPaused(U),ae&&e.setVisible(JM()),$e.current=e}const ze=(0,GA.useRef)(-1),He=(0,GA.useRef)(null),We=(0,GA.useRef)(!0),qe=yr("StreamPhysicsFrame"),Ge=(0,GA.useRef)(""),Ye=(0,GA.useId)().replace(/:/g,""),Ve=(0,GA.useRef)(!1),Xe=(0,GA.useRef)(!1),Ue=(0,GA.useRef)(0),Ke=(0,GA.useRef)(!1),Qe=(0,GA.useRef)(!1),Ze=(0,GA.useRef)(null),Je=(0,GA.useRef)(!1),et=Su({sizeProp:oe,responsiveWidth:Z,responsiveHeight:Q,userMargin:E,marginDefault:zj,foregroundGraphics:j,backgroundGraphics:a,frameScheduler:y,clock:f,random:g,seed:b,paused:U,suspendWhenHidden:ae}),{margin:tt,rafRef:nt,reducedMotion:ot,reducedMotionRef:rt,renderFnRef:it,cancelRender:st,resolvedBackground:at,resolvedForeground:ct,responsiveRef:lt,scheduleRender:ut,size:dt,frameRuntime:ht}=et,pt=(0,GA.useRef)(ht.now);pt.current=ht.now;const mt=Gc(),yt=Uc(),[ft,gt]=qA.useState(null),[bt,vt]=qA.useState(null),xt=(0,GA.useRef)(null),wt=(0,GA.useRef)(0),kt=(0,GA.useRef)(new Map),St=Ye+"-physics-live",At=(0,GA.useCallback)((e,t,n=!1)=>{if(!l)return void Te(e=>e.length?[]:e);const o=pt.current();if(!n&&u>0&&u>o-wt.current)return;wt.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=Tj(r);i.push({datum:r.datum??r,description:Lj(r),group:"body",label:_j(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,l,c);Te(e=>function(e,t){if(e.length!==t.length)return!0;for(let n=0;e.length>n;n+=1){const o=e[n],r=t[n];if(o.id!==r.id||o.label!==r.label||o.description!==r.description||o.group!==r.group||o.bodyId!==r.bodyId||Math.round(o.x)!==Math.round(r.x)||Math.round(o.y)!==Math.round(r.y))return!0}return!1}(e,r)?r:e)},[c,l,u]),Ct=(0,GA.useCallback)(e=>{if(!_e.length)return;const t=Math.max(0,Math.min(e,_e.length-1));ze.current=t;const n=_e[t];if(xt.current=n.bodyId??null,gt(n),Y?.(n),n.bodyId&&$e.current){const e=$e.current.readBodies().find(e=>e.id===n.bodyId);if(e){const t=Rj(e);vt(t),W?.(e,t)}}},[_e,W,Y]),Mt=(0,GA.useCallback)(()=>{ze.current=-1,xt.current=null,gt(null),Y?.(null)},[Y]),jt=function({onObservationRef:e,chartIdRef:t,wallClockRef:n}){return(0,hj.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:fe,chartIdRef:ge,wallClockRef:De}),It=(0,GA.useCallback)(()=>{vt(e=>e?(W?.(null,null),jt("hover-end"),null):e)},[jt,W]),Pt=(0,GA.useCallback)(e=>{if(!M||!$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=Rj(n);vt(e=>e&&e.id===o.id&&e.x===o.x&&e.y===o.y?e:(W?.(n,o),jt("hover",{datum:n.datum,x:n.x,y:n.y}),o))},[It,jt,M,I,W]),Rt=(0,GA.useCallback)(e=>{Mt();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;q?.(i,e),i?(jt("click",{datum:i.datum,x:i.x,y:i.y}),jt("activate",{datum:i.datum,inputType:"touch"===e.pointerType?"touch":"pointer"}),O?.(i.datum??null,{x:i.x,y:i.y,body:i})):(jt("click-end"),O?.(null,{x:o,y:r,body:null}),It())},[It,Mt,jt,I,q,O]);(0,GA.useEffect)(()=>{if(!_e.length)return void Mt();const e=ze.current;if(_e.length>e){if(e>=0){const t=_e[e];if(xt.current=t.bodyId??null,gt(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=Rj(e);vt(e=>e?.id===t.id&&Math.round(e.x)===Math.round(t.x)&&Math.round(e.y)===Math.round(t.y)?e:t)}}}}else Ct(_e.length-1)},[_e,Mt,Ct]),(0,GA.useEffect)(()=>{M||It()},[It,M]);const Tt=(0,GA.useCallback)(e=>{if(Td(e))return;if(!_e.length)return;if("Escape"===e.key)return e.preventDefault(),void Mt();if(("Enter"===e.key||" "===e.key)&&ze.current>=0){e.preventDefault();const t=_e[ze.current];return jt("activate",{datum:t.datum??{id:t.id,label:t.label},inputType:"keyboard"}),void G?.(t)}if(!Hj.has(e.key))return;e.preventDefault();const t=ze.current;if(0>t){Ct(0);const e=_e[0];return void jt("focus",{datum:e.datum??{id:e.id,label:e.label},inputType:"keyboard"})}const n=Math.max(1,Math.floor(.1*_e.length));let o=t;if("Home"===e.key?o=0:"End"===e.key?o=_e.length-1:"PageDown"===e.key?o=Math.min(_e.length-1,t+n):"PageUp"===e.key?o=Math.max(0,t-n):"ArrowRight"===e.key||"ArrowDown"===e.key?o=Math.min(_e.length-1,t+1):"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(o=Math.max(0,t-1)),Ct(o),o!==t){const e=_e[o];jt("focus",{datum:e.datum??{id:e.id,label:e.label},inputType:"keyboard"})}},[Mt,jt,Ct,G,_e]),[_t,Lt]=qA.useState([]),Nt=(0,GA.useRef)(0),$t=!!o?.length&&o.some(e=>null!=e.pointId||null!=e.bodyId||"latest"===e.anchor),{canvasRef:Dt}=Mu(et,{hydrated:mt,wasHydratingFromSSR:yt,storeRef:$e,dirtyRef:We,manageFrameRuntime:!1,skipInitialCanvasPaintInvalidation:!0,canvasPaintDependencies:[s,a,ut]}),Bt=(0,GA.useCallback)(()=>{const e=Dt.current,t=$e.current;if(!e||!t)return;const n=qe.current.beforeCompute(t.getLastUpdateResult(),!1),o=Tu(),r=Ru(e,dt,tt,o);if(!r)return void qe.current.afterCompute(n,!1,!1);const i=function(e){const t=nC(e,QA),n=nC(e,XA),o=nC(e,tC),r=nC(e,ZA),i=nC(e,VA),s=nC(e,YA),a=nC(e,JA),c=nC(e,eC),l=nC(e,UA),u=nC(e,KA);return{annotationBackground:oC(s,.94),annotationStroke:i,annotationText:a,background:s,border:i,closedWindowFill:oC(n,.08),closedWindowStroke:oC(n,.55),danger:n,focus:l,grid:u,gutterFill:oC(c,.14),lateFill:o,openWindowFill:oC(t,.07),openWindowStroke:oC(t,.3),primary:t,selectedFill:o,selectedStroke:l,success:r,text:a,textSecondary:c,warning:o}}(r);r.clearRect(-tt.left,-tt.top,dt[0],dt[1]),a||"transparent"===s||(r.fillStyle=s??i.background,r.fillRect(-tt.left,-tt.top,dt[0],dt[1]));const c=t.snapshot(),l=t.readBodies();if(At(l,c.simulationState),$t){const e=pt.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,aC(e))}))}(l);Lt(e=>e.length===t.length&&e.every((e,n)=>e.pointId===t[n].pointId&&Math.round(e.x)===Math.round(t[n].x)&&Math.round(e.y)===Math.round(t[n].y))?e:t)}}pe&&(r.save(),pe(r,l),r.restore());for(const e of l){const t=be.current.get(e.id),n=t?Array.from(t.activeRegionIds).map(e=>Ie.get(e)).filter(e=>null!=e):[],o=dj(e,c.simulationState,h,J,ee,rj(t),n,i.primary,i.text,ye);he?(r.save(),he(r,e,o),r.restore()):ej(r,e,o)}me&&(r.save(),me(r,l),r.restore()),function(e,t,n){let o=!1;for(const[r,i]of t){const 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,kt.current,pt.current()),qe.current.afterCompute(n,!0,!1),We.current=!1},[Dt,qe,dt,tt,a,s,At,$t,pe,me,h,J,ee,ye,he,Ie]),Et=(0,GA.useCallback)((e,t)=>{const n=$e.current,o=`${ne}:${e}:${t??""}`;Ge.current!==o&&(Ge.current=o,H?.({execution:e,liveBodies:n?.liveBodyCount()??0,queuedBodies:n?.queueSize()??0,reason:t,requested:ne}))},[H,ne]),Ot=(0,GA.useCallback)((e,t=!0)=>{Ue.current+=1,Ve.current=!1,Ke.current=!1,Qe.current=!1,Je.current=!1,Ze.current?.terminate(),Ze.current=null,t&&Et("sync",e)},[Et]),Ft=(0,GA.useCallback)(()=>mt?"undefined"==typeof window||"undefined"==typeof Worker?"worker unavailable":Le?"runtime region effects require sync":Ne?"body forces require sync":ke?"physics controllers require sync":function(e){return!e||!e.engine&&dC(e.sediment)&&(!(t=e.colliders)||t.every(e=>{const t=e.bodyFilter;return!t||"function"!=typeof t}));var t}(Fe??{})?mC(R)?Xe.current?"worker fallback":null:"spawn pacing is not worker-cloneable":"config is not worker-cloneable":"hydrating",[Fe,ke,Ne,Le,mt,R]),zt=(0,GA.useCallback)(()=>{const e=$e.current,t=Ft();if(!e||t)return{reason:t,useWorker:!1};const n=e.liveBodyCount(),o=e.queueSize(),r=function(e,t,n=0,o=lC){return"sync"!==e&&("worker"===e||t+n>=o)}(ne,n,o,de);return{reason:r?"worker"===ne?"forced worker":"body threshold":"below threshold",useWorker:r}},[ne,de,Ft]),Ht=(0,GA.useCallback)(e=>{const t=$e.current;return t&&e.snapshot?(t.restore(e.snapshot),We.current=!0,t):t},[]),Wt=(0,GA.useCallback)((e,t=!0)=>{const n=Ht(e);if(!n)return;t&&V?.(e.result,n.controls()),Bt();const o=n.snapshot();!e.result.shouldContinue&&kt.current.size<=0||o.paused||!o.visible||rt.current||ut()},[Ht,V,Bt,rt,ut]),qt=(0,GA.useCallback)(e=>{Xe.current=!0,Ot("worker failed: "+((e instanceof Error?e.message:e+"")||"unknown error"))},[Ot]),Gt=(0,GA.useCallback)(()=>{const e=$e.current;if(!e)return!1;const t=zt();if(!t.useWorker)return Ve.current||Je.current?Ot(t.reason??"sync fallback"):Et("sync",t.reason??"sync"),!1;if(Ve.current||Je.current)return!0;const n=Ze.current??new bC;Ze.current=n,Je.current=!0;const o=Ue.current+1;return Ue.current=o,n.initFromSnapshot(Fe??{},e.snapshot()).then(e=>{if(Ue.current!==o)return;Je.current=!1,Ve.current=!0,Xe.current=!1,Ht(e),Et("worker",t.reason??"worker"),Bt();const n=$e.current?.snapshot();e.result.shouldContinue&&n&&!n.paused&&n.visible&&!rt.current&&(He.current=null,ut())}).catch(e=>{Ue.current===o&&qt(e)}),!0},[Ht,Fe,qt,Bt,rt,Et,ut,Ot,zt]),Yt=(0,GA.useCallback)(e=>"frame"===e.type||"removed"===e.type?e.frame:null,[]),Vt=(0,GA.useCallback)((e,t=!0)=>{const n=Ze.current;if(!n||!Ve.current)return;const o=Ue.current;n.request(e).then(e=>{if(Ue.current!==o)return;const n=Yt(e);n&&Wt(n,t)}).catch(qt)},[Wt,Yt,qt]),Xt=(0,GA.useCallback)(()=>{const e=$e.current;if(!e)return;const t=Gt(),n=e.snapshot(),o=Ae||Ne||Le||!!ke;n.paused||!n.visible||!e.hasPendingWork()&&!o||rt.current?it.current():t&&Je.current||ut()},[ke,Ae,Ne,Le,rt,it,ut,Gt]),Ut=(0,GA.useCallback)(()=>{st(),nt.current=null;const e=$e.current;if(!e)return;const t=rt.current;if(t&&(He.current=null),Ve.current&&Ze.current){if(Ke.current)return void(Qe.current=!0);let n=0;if(!t){const e=pt.current();n=null!==He.current?(e-He.current)/1e3:0,He.current=e}const o=Ze.current,r=Ue.current;return Ke.current=!0,void(t?o.settle():o.tick(n)).then(e=>{Ke.current=!1;const t=Qe.current;Qe.current=!1,Ue.current===r&&(Wt(e),t&&Xt())}).catch(o=>{Ke.current=!1;const i=Qe.current;if(Qe.current=!1,Ue.current!==r)return;qt(o);const s=t?e.settleWithObservations():e.tick(n);uj({store:e,result:s,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,composed:Se.current,onTick:we.current}),Bt(),i&&Xt()})}const n=Se.current,o=t=>uj({store:e,result:t,composed:n,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,onTick:we.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=pt.current(),n=He.current;He.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;Bt(),(Ce.current||i.shouldContinue||s||a||n||kt.current.size>0)&&!c.paused&&c.visible&&!rt.current&&ut()},[Wt,qt,Bt,st,Xt,ut,rt,nt]);it.current=Ut,(0,GA.useEffect)(()=>{Xe.current=!1,(Ve.current||Je.current)&&Ot("config changed",!1),$e.current?.updateConfig(Fe??{}),Xt()},[Fe,Ot]),(0,GA.useEffect)(()=>{Xe.current=!1,Xt()},[mt,ne,de]),(0,GA.useEffect)(()=>{Xt()},[ot,Xt]),function({cancelRender:e,frameRuntime:t,lastFrameTimeRef:n,paused:o,postWorkerCommand:r,requestRender:i,storeRef:s,suspendWhenHidden:a}){const c=(0,ZM.useRef)(r);c.current=r;const l=(0,ZM.useRef)(i);l.current=i,(0,ZM.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,ZM.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=JM();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:st,frameRuntime:ht,lastFrameTimeRef:He,paused:U,postWorkerCommand:Vt,requestRender:Xt,storeRef:$e,suspendWhenHidden:ae}),(0,GA.useEffect)(()=>()=>Ot("unmount",!1),[Ot]),(0,GA.useEffect)(()=>{Bt()},[Bt]),(0,GA.useImperativeHandle)(t,()=>({...$e.current.controls(),applyImpulse:(e,t,n)=>{$e.current.applyImpulse(e,t,n),Vt({type:"applyImpulse",id:e,ix:t,iy:n}),Xt()},clear:()=>{$e.current.clear(),be.current.clear(),kt.current.clear(),Vt({type:"clear"}),Xt()},clearRegionState:e=>{e?be.current.delete(e):be.current.clear(),Xt()},getData:()=>$e.current.readBodies(),getRegionState:e=>e?rj(be.current.get(e)):function(e){const t={};return e.forEach((e,n)=>{const o=rj(e);o&&(t[n]=o)}),t}(be.current),getStore:()=>$e.current,pause:()=>{ht.setPaused(!0),He.current=null,st(),$e.current.setPaused(!0),Vt({type:"setPaused",paused:!0},!1),Xt()},push:(e,t)=>{$e.current.enqueue(e,t),mC(t)?Vt({type:"enqueue",spawns:[e],pacing:t}):(Ve.current||Je.current)&&Ot("spawn pacing is not worker-cloneable"),Xt()},pushMany:(e,t)=>{$e.current.enqueue(e,t),mC(t)?Vt({type:"enqueue",spawns:e,pacing:t}):(Ve.current||Je.current)&&Ot("spawn pacing is not worker-cloneable"),Xt()},popBodies:(e,t={})=>{const n=$e.current,o=new Map(n.readBodies().map(e=>[e.id,e])),r=n.remove(e),i=pt.current();for(const e of r){const n=o.get(e);n&&(be.current.delete(e),kt.current.set(e,{body:n,color:t.color??"#f59e0b",durationMs:Math.max(120,t.durationMs??520),radius:t.radius??tj(n),scale:null!=t.scale&&t.scale>0?t.scale:1,startedAt:i}),xt.current===e&&(xt.current=null,gt(null)),vt(t=>t?.id===e?null:t))}return r.length&&(Vt({type:"remove",ids:r}),Xt()),r},remove:e=>{const t=$e.current.remove(e);for(const t of e)be.current.delete(t);return Vt({type:"remove",ids:e}),Xt(),t},restore:e=>{$e.current.restore(e),be.current.clear(),kt.current.clear(),Vt({type:"restore",snapshot:e},!1),Xt()},resume:()=>{ht.setPaused(!1),He.current=null,$e.current.setPaused(!1),Vt({type:"setPaused",paused:!1},!1),Xt()},settle:e=>{const t=$e.current.settle(e);return Vt({type:"settle",maxSteps:e}),Xt(),t},settleWithObservations:e=>{const t=$e.current.settleWithObservations(e);return Vt({type:"settle",maxSteps:e}),Xt(),t},step:e=>{const t=$e.current,n=t.tick(e);return uj({store:t,result:n,regionEffects:ve.current,regionState:be.current,bodyForces:xe.current,composed:Se.current,onTick:we.current}),Vt({type:"tick",deltaSeconds:e}),Bt(),n}}),[st,ht,Bt,Vt,Xt,Ot]);const Kt=Hc||!mt&&yt,Qt=["stream-physics-frame",C?"stream-physics-frame--mode-"+C:null,A?"stream-physics-frame--emphasis-"+A:null,m].filter(Boolean).join(" "),Zt=S??("string"==typeof le?le:void 0)??"Physics chart",Jt=Ye+"-physics-table",en=Math.max(1,dt[0]-tt.left-tt.right),tn=Math.max(1,dt[1]-tt.top-tt.bottom),nn=M&&bt?ue?ue(bt):(0,Oj.jsx)($j,{hover:bt}):null,on=nn&&bt?(0,Oj.jsx)(cu,{x:bt.x-tt.left,y:bt.y-tt.top,containerWidth:en,containerHeight:tn,margin:tt,className:"stream-physics-tooltip",children:nn}):null;if(Kt){const e=$e.current??DM(Fe,P,R),t="string"==typeof le?le:void 0,{svg:n}=function(e,t={}){const{width:n=640,height:o=360,title:r,description:i,background:s,backgroundGraphics:a,className:c,foregroundGraphics:l,idPrefix:u="physics",margin:d,renderBodySVG:h,...p}=t,m=WM(e,p),y={...GM,...d},f=[n,o],g=YM(a,f,y),b=YM(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:EM.renderToStaticMarkup((0,qM.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,qM.jsx)("title",{id:x,children:r}),i&&(0,qM.jsx)("desc",{id:w,children:i}),!a&&s&&"transparent"!==s?(0,qM.jsx)("rect",{x:0,y:0,width:n,height:o,fill:s}):null,g,(0,qM.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:dt[0],height:dt[1],title:t,description:S,background:a||"transparent"===s?void 0:s,backgroundGraphics:at,className:"stream-physics-frame__svg",foregroundGraphics:ct,idPrefix:"physics-"+Ye,margin:tt});return(0,Oj.jsxs)("div",{ref:lt,className:Qt,"data-semiotic-mode":C,role:"img","aria-label":Zt,style:{width:dt[0],height:dt[1]},children:[(0,Oj.jsx)(El,{summary:se}),(0,Oj.jsx)("div",{dangerouslySetInnerHTML:{__html:n}})]})}return(0,Oj.jsxs)("div",{ref:lt,className:Qt,"data-semiotic-mode":C,role:"group","aria-label":Zt,"aria-describedby":ft?St:void 0,tabIndex:0,style:{position:"relative",width:dt[0],height:dt[1]},onKeyDown:Tt,children:["production"!==process.env.NODE_ENV&&$e.current&&(0,Oj.jsx)(fr,{store:$e.current,diagnostics:qe.current}),n?(0,Oj.jsx)(Ol,{tableId:Jt}):null,n?(0,Oj.jsx)(Ej,{chartTitle:"string"==typeof le?le:Zt,items:_e,tableId:Jt}):null,(0,Oj.jsx)(El,{summary:se}),(0,Oj.jsx)(yl,{hoverPoint:bt}),(0,Oj.jsx)("div",{id:St,"aria-live":"polite","aria-atomic":"true",style:gj,children:ft?ft.description??ft.label:""}),(0,Oj.jsxs)("div",{role:"img","aria-label":Zt,style:{position:"relative",width:"100%",height:"100%"},children:[(0,Oj.jsx)(ju,{size:dt,margin:tt,children:at}),(0,Oj.jsx)("canvas",{ref:Dt,width:dt[0],height:dt[1],"aria-hidden":"true",style:{position:"absolute",left:0,top:0,display:"block"},onPointerDown:Rt,onPointerMove:M?Pt:void 0,onPointerLeave:M?It:void 0}),ct,(0,Oj.jsx)(cC,{width:en,height:tn,totalWidth:dt[0],totalHeight:dt[1],margin:tt,title:le,legend:T,legendPosition:B,legendLayout:D,legendHoverBehavior:N,legendClickBehavior:_,legendHighlightedCategory:L,legendIsolatedCategories:$,pointNodes:_t,annotations:o,onAnnotationActivate:r,onObservation:F,chartId:p,chartType:Wj,autoPlaceAnnotations:i,svgAnnotationRules:ce}),(0,Oj.jsx)(Hl,{active:null!=ft,hoverPoint:ft?{x:ft.x,y:ft.y}:null,margin:tt,size:dt,shape:ft?.shape,width:ft?.width,height:ft?.height,pathData:ft?.pathData}),on]})]})}));qj.displayName="StreamPhysicsFrame";var Gj=qj;function Yj(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 Vj(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 Xj(e,t="#4e79a7",n){const o=n?.styleRules,r=!!o&&o.length>0,i=r?Vp(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:Vj(a),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&s&&Object.assign(c,Zp(s,o,{value:i?i(s):void 0,category:null==a?void 0:a+""})),c}}function Uj(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 Kj(e,t,n){if(!e.length)return[];const o=Yj(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 Qj(e,t,n){return"function"==typeof n?n(e,t):e[n]}function Zj(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 Jj(e,t,n){return Math.max(t,Math.min(n,e))}function eI(e,t){const n=Zj(e);return null!=n&&n>0?n:t}function tI(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function nI(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 oI=require("d3-scale");function rI(e){const{data:t,valueAccessor:n,bins:o,ballRadius:r,seed:i,size:s,valueExtent:a}=e,c=Yj(s),l=t.map((e,t)=>Zj(Qj(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=Zj(e[0]),n=Zj(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,oI.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=Zj(Qj(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:Uj(i,[...gM({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...bM({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 iI=require("d3-scale");function sI(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 aI(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 cI(e){const{data:t,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:i,seed:s,size:a}=e,c=eI(r,1),l=Yj(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((Qj(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),f=aI(l.plot,y,i),g=Math.max(0,f.tubeWidth/2-i-1),b=u.map(()=>[]);t.forEach((e,t)=>{const r=(Qj(e,t,n)??"unknown")+"",s=m(r),a=o?Zj(Qj(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=[...gM({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:Uj(s,w,"UnitPileChart"),initialSpawns:p,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}var lI=require("d3-scale");function uI(e){const{data:t,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:i,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=Yj(a),h=nI(s),p=[],m=[],y=new Map;t.forEach((e,t)=>{const s=Zj(Qj(e,t,n));if(null==s)return;const a=o?(Qj(e,t,o)??"All")+"":"All",c=r?Zj(Qj(e,t,r)):null,l=Jj(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?Zj(c[0]):null,b=c?Zj(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,lI.scaleLinear)().domain([w,k]).range([A,C]),j=Math.max(1,m.length),I=Math.min(Math.max(28,3*S),d.plot.height/4),P=d.plot.y+I,R=Math.max(0,d.plot.y+d.plot.height-I-P),T=e=>{const t=y.get(e)??0;return 1===j?d.plot.y+.54*d.plot.height:P+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:Jj(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:Uj(s,gM({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 dI(e){if(Array.isArray(e)&&e.length>=2){const t=Zj(e[0]),n=Zj(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=Zj(t.x),o=Zj(t.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function hI(e){return Array.isArray(e)?e.map(dI).filter(e=>null!=e):[]}function pI(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:Jj(e.x,t.plot.x,t.plot.x+t.plot.width),y:Jj(e.y,t.plot.y,t.plot.y+t.plot.height)}}function mI(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 yI(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=Jj(t,0,1)*mI(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 fI(e,t){const n=yI(e,Math.max(0,t-.02)),o=yI(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 gI(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=Yj(y),x=nI(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=(Qj(e,t,i)??e.id??t)+"",o=Zj(Qj(e,t,s)),r=Zj(Qj(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(Qj(e,t,f)),o=A(Qj(e,t,g)),r=Math.max(0,Zj(Qj(e,t,b))??0),i=hI(d?Qj(e,t,d):void 0),s=i.length?i:hI(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=(I=S,"normalized"===(j=t)||"pixels"===j?j:I.length>0&&I.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var j,I;const P=new Map;for(const[e,t]of w)P.set(e,pI(t,v,M));const R=[];for(const e of C){let t=e.rawPath.map(e=>pI(e,v,M));if(2>t.length){const n=P.get(e.source),o=P.get(e.target);n&&o&&(t=[n,o])}else P.has(e.source)||P.set(e.source,t[0]),P.has(e.target)||P.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=eI(u,.12),_=Math.max(1,Math.round(r)),L=R.map(e=>Math.max(1,Math.round(e.throughput*T))),N=L.reduce((e,t)=>e+t,0),$=N>_?_/N:1;R.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(L[t]*$))});let D=R.reduce((e,t)=>e+t.packetCount,0);for(;D>_;){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,D-=1}const B=new Map,E=new Map,O=[],F=eI(n,90),z=eI(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=mI(e.path);for(let o=0;e.packetCount>o;o+=1){const r=(o+.5)/e.packetCount,i=p?r:Jj(.12+.84*r+.04*(x()-.5),.04,.98),s=p?i:Math.max(0,i-(.18+.12*x())),a=yI(e.path,s),c=yI(e.path,i),l=fI(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(P,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+tI(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=Uj(m,[...gM({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(P,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+tI(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 bI(e,t,n){return Math.max(t,Math.min(n,e))}function vI(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 xI(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 wI(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...xI({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function kI(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 SI(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,o=Yj(n),r=Jj(e.ballRadius??6,2,18),i=e.seed??1,s=nI(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=bI(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,y=bI(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=bI(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 I=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}}),P=I[A],R=P.x0,T=P.x1,_=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=bI((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=bI((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=bI((e-T)/Math.max(1,a-T),0,1);return"top"===n?g+(c-g)*o:b+(l-b)*o},L=I.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)}}),N={thickness:k,friction:x,restitution:w},$=[];"lane"===t?$.push(vI(v+"-top",s,c,a,c,N),vI(v+"-bottom",s,l,a,l,N),vI(v+"-left",s,c,s,l,{...N,thickness:Math.max(6,k-2)}),vI(v+"-right",a,c,a,l,{...N,thickness:Math.max(6,k)})):"funnel"===t?$.push(vI(v+"-top",s,c,a,g,N),vI(v+"-bottom",s,l,a,b,N),vI(v+"-left",s,c,s,l,{...N,thickness:Math.max(6,k-2)}),vI(v+"-right",a,g,a,b,{...N,thickness:Math.max(6,k)})):$.push(vI(v+"-left-top",s,c,R,g,N),vI(v+"-left-bottom",s,l,R,b,N),vI(v+"-center-top",R,g,T,g,N),vI(v+"-center-bottom",R,b,T,b,N),vI(v+"-right-top",T,g,a,c,N),vI(v+"-right-bottom",T,b,a,l,N),vI(v+"-left",s,c,s,l,{...N,thickness:Math.max(6,k-2)}),vI(v+"-right",a,c,a,l,{...N,thickness:Math.max(6,k)}));const D=e.membraneDampingScale??.5,B=s,E=Math.max(1,("bowtie"===t?R:a)-B),O=(e.membranes??[]).map(e=>{const t=B+bI(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=bI(e.cost,0,2);return{...xI({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:R,centerRight:T,pinchHeight:y,pinchTop:g,pinchBottom:b,stages:L,membranes:O,colliders:$,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{...xI({...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:kI(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:kI(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...xI({...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{...xI({...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:kI(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{...xI({...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:kI(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?wI({...n,kind:e.kind??"force-field",force:kI(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...xI({...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(wI({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?Qj(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",o=(Qj(e,t,c)??w)+"",i=v.has(o)?o:w;C.set(i,(C.get(i)??0)+1);const s=l?(Qj(e,t,l)??"")+"":void 0,p=s&&u?(Qj(e,t,u)??s)+"":s,m=d?Zj(Qj(e,t,d))??1:1,y=h?Zj(Qj(e,t,h)):null,f=Jj(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,I=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&&I.set(e.groupId,e.groupLabel)}const P=Jj(e.groupAnchorAlong??.55,.15,.9),R=b.left+(b.right-b.left)*P,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:I.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)),N=new Map(_.map(e=>[e.id,e])),$=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=N.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}}}),D={kernel:{seed:i,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:b.colliders,fixedDt:1/60,maxSubsteps:8},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:D,initialSpawns:$,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 AI=require("react");function CI(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 MI(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 jI(e,t){const n=e?.getData().find(e=>e.id===t),o=n?.datum;if(o&&"object"==typeof o)return o}function II(e,t){const{frameRef:n,spawnDatum:o,seedRows:r,idAccessor:i,bodyIdsForSeed:s,seedSpawns:a}=t,c=(0,AI.useRef)(new Map),l=(0,AI.useRef)(new Map),u=(0,AI.useRef)(""),d=r?r.map((e,t)=>MI(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=MI(t,e,i);c.current.set(n,t),l.current.set(n,s?.(t,n,e)??CI(n,a))}(0,AI.useImperativeHandle)(e,()=>{const e=c.current,t=l.current;function r(e,t){const n=o(e,t);return{datumId:n.datumId||MI(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=jI(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 PI=require("react"),RI=require("react/jsx-runtime");function TI(e){return!!e&&"string"==typeof e.name}function _I(e,t=!1){if(!e?.datum)return null;const n=e.datum,o=n.sourceDatum;return t&&o&&"object"==typeof o?o:n}function LI(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=TI(t)?t:void 0,{activeSelectionHook:d,customHoverBehavior:h}=gp({selection:u,linkedHover:n,fallbackFields:l?[l]:a,onObservation:e.onObservation,onClick:e.onClick,chartType:r,chartId:i,colorByField:l}),p=TI(t)?null:t??null,m=(0,PI.useMemo)(()=>{if(p)return p;if(!d?.isActive)return null;const e=d.predicate;return{isActive:!0,predicate:t=>{const n=_I(t,c);return null!=n&&e(n)}}},[d?.isActive,d?.predicate,p,c]),y=(0,PI.useMemo)(()=>{if(n||s)return(e,t)=>{if(s?.(e,t),!n)return;const o=_I(e,c);h(o&&t?{...t,data:o}:null)}},[h,s,n,c]);return(0,PI.useMemo)(()=>({selection:m,onBodyHover:y}),[y,m])}var NI=new Set(["sample","mechanical"]);function $I(e,t,n,o){const[r,i]=(0,PI.useState)(0),s=(0,PI.useRef)(null),a=(0,PI.useRef)(!1),c=function(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:null}(t),l=(0,PI.useRef)(c),u=(0,PI.useRef)(!!n),d=(0,PI.useRef)(o);l.current=c,u.current=!!n,d.current=o;const h=(0,PI.useCallback)(()=>{null!=s.current&&(clearTimeout(s.current),s.current=null)},[]),p=(0,PI.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,PI.useEffect)(()=>{null==c||n?h():a.current&&p()},[h,c,n,p]),(0,PI.useEffect)(()=>h,[h]);const m=e?.observation?.onSimulationStateChange,y=(0,PI.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,PI.useMemo)(()=>null==c?e:{...e,observation:{...e?.observation,onSimulationStateChange:y}},[e,c,y]),rerunKey:r}}function DI(e,t,n){const o=n?.hasSimulationMode?function(e){const t=e=>"string"==typeof e&&NI.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=vp(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,PI.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=FI(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 BI(e){const[t,n]=e.size;return Tp(e.loading,t,n,e.loadingContent)||Rp(e.data,t,n,e.emptyContent)}function EI(e,t,n){return(0,RI.jsx)(jp,{componentName:e,width:t[0],height:t[1],children:n})}function OI(e,t){return e?t?n=>(0,RI.jsxs)(RI.Fragment,{children:["function"==typeof e?e(n):e,"function"==typeof t?t(n):t]}):e:t}function FI(e,t){return!1===e?{enableHover:!1}:{enableHover:t?.enableHover,tooltipContent:su(e)||t?.tooltipContent}}function zI(e,t,n,o){return{accessibleTable:o?.accessibleTable??e.accessibleTable??t?.accessibleTable,annotations:e.annotations??t?.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations??t?.autoPlaceAnnotations,background:e.background??t?.background,chartId:e.chartId??t?.chartId,chartMode:o?.chartMode??t?.chartMode,className:o?.className??e.className??t?.className,color:e.color??t?.color,description:o?.description??e.description??t?.description,emphasis:e.emphasis??t?.emphasis,enableHover:o?.enableHover??t?.enableHover,hoverRadius:e.hoverRadius??t?.hoverRadius,legend:e.legend??t?.legend,legendLayout:e.legendLayout??t?.legendLayout,legendPosition:e.legendPosition??t?.legendPosition,margin:o?.margin??t?.margin,onClick:null!=e.onClick?(t,n)=>{t&&e.onClick?.(t,{x:n.x,y:n.y})}:t?.onClick,onObservation:e.onObservation??t?.onObservation,onAnnotationActivate:t?.onAnnotationActivate,opacity:e.opacity??t?.opacity,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 HI=require("react/jsx-runtime"),WI=(0,WA.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=DI(e,[700,420],{hasSimulationMode:!0}),{chartSize:S,simulationMode:A,showProjection:C,className:M,title:j,chartMode:I,margin:P,enableHover:R,description:T,summary:_,accessibleTable:L}=k,N=s??("sparkline"===I?1.5:"context"===I?4:6),$=(0,WA.useRef)(null),D=Math.max(1,Math.round(y??i-1)),B=(0,WA.useMemo)(()=>"mechanical"===A?[0,D]: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),[D,A,w]),E=(0,WA.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=Jj(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=nI(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:D,seed:x}):n??[],[i,c,n,p,D,x,A]),O=(0,WA.useMemo)(()=>rI({data:E,valueAccessor:o,bins:i,ballRadius:N,seed:x,size:S,valueExtent:B}),[i,E,S,N,B,x,o]),F=$I(O.config,g,m);II(t,{frameRef:$,spawnDatum:(0,WA.useCallback)((e,t)=>{const n=rI({data:[e],valueAccessor:o,bins:i,ballRadius:N,seed:x+t+1,size:S,valueExtent:B}).initialSpawns[0]??{id:(e.id??"galton-push-"+t)+"",x:Yj(S).plot.x,y:Yj(S).plot.y,mass:1,shape:{type:"circle",radius:N},datum:e};return{datumId:(e.id??n.id)+"",spawns:[n]}},[i,S,N,B,x,o]),seedRows:E,seedSpawns:O.initialSpawns});const z="mechanical"===A&&null==a?"side":a,H=(0,WA.useMemo)(()=>Xj(z,"#4e79a7",{styleRules:r,valueAccessor:o}),[z,r,o]),W=(0,WA.useMemo)(()=>Kj(O.projectionRows,S,"bin"),[S,O.projectionRows]),{selection:q,onBodyHover:G}=LI({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=BI({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=Yj(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,HI.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,HI.jsxs)(HI.Fragment,{children:[Array.from({length:c+1},(e,t)=>{const n=a.plot.x+t*l;return(0,HI.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,HI.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,HI.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,HI.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,HI.jsxs)("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[(0,HI.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,HI.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=FI(e.tooltip,u),U=zI(e,u,W,{selection:q,chartMode:I,className:M,title:j,description:T,summary:_,accessibleTable:L,enableHover:R,margin:P});return EI("GaltonBoardChart",S,(0,HI.jsx)(Gj,{...u,...X,...U,ref:$,onBodyHover:G,config:F.config,foregroundGraphics:OI(V,u?.foregroundGraphics),initialSpawns:O.initialSpawns,initialSpawnPacing:O.initialSpawnPacing,paused:m,responsiveHeight:b,responsiveWidth:v,size:S,bodyStyle:H},F.rerunKey))}),qI=require("react"),GI=require("react/jsx-runtime"),YI=require("react"),VI=(0,qI.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=DI(e,[760,360]),{chartSize:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:I,description:P,summary:R,accessibleTable:T}=w,_=(0,qI.useRef)(null),L=(0,qI.useMemo)(()=>s??[],[s]),N=(0,qI.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=Yj(c),h=t.map((e,t)=>Zj(Qj(e,t,n))).filter(e=>null!=e),p=Zj(l?.[0]),m=Zj(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):Zj(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,iI.scaleLinear)().domain([v,C]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),j=Array.from({length:x},()=>({value:0,secondary:0})),I=[];t.forEach((e,t)=>{const i=Zj(Qj(e,t,n));if(null==i)return;const a=Zj(Qj(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,I.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 P=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,iI.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:Uj(a,[...gM({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...sI({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:P,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:I,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]),$=$I(N.config,h,d),D=N.metadata;II(t,{frameRef:_,spawnDatum:(0,qI.useCallback)((e,t)=>{const r=D?function(e,t,n,o){const r=Zj(Qj(e,t,o.timeAccessor));if(null==r)return null;const i=Zj(Qj(e,t,o.arrivalAccessor))??r,{windowPlot:s,windowStart:a,windowCount:c,windowSize:l,watermarkValue:u}=n,d=a+c*l,h=(0,iI.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,D,{timeAccessor:f,arrivalAccessor:n,ballRadius:o}):null,i=r??{id:(e.id??"event-push-"+t)+"",x:Yj(k).plot.x,y:Yj(k).plot.y,mass:1,shape:{type:"circle",radius:o},datum:e};return{datumId:(e.id??i.id)+"",spawns:[i]}},[n,o,k,D,f]),seedRows:L,seedSpawns:N.initialSpawns});const B=(0,qI.useMemo)(()=>Xj(r,"#4e79a7",{styleRules:i,valueAccessor:f}),[r,i,f]),E=(0,qI.useMemo)(()=>function(e,t,n){if(!t)return Kj(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"}})}(N.projectionRows,D,k),[k,N.projectionRows,D]),{selection:O,onBodyHover:F}=LI({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=BI({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=Yj(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,GI.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,GI.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,GI.jsxs)("g",{children:[(0,GI.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,GI.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,GI.jsxs)("g",{children:[(0,GI.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,GI.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,GI.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,GI.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,GI.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,GI.jsx)("line",{x1:s.x,x2:s.x+s.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),(0,GI.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,GI.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,GI.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]})}}(N.projectionRows,N.metadata,S),W=FI(e.tooltip,c),q=zI(e,c,E,{selection:O,chartMode:M,className:A,title:C,description:P,summary:R,accessibleTable:T,enableHover:I,margin:j});return EI("EventDropChart",k,(0,YI.createElement)(Gj,{...c,...W,...q,ref:_,onBodyHover:F,key:$.rerunKey,config:$.config,foregroundGraphics:OI(H,c?.foregroundGraphics),initialSpawns:N.initialSpawns,initialSpawnPacing:N.initialSpawnPacing,paused:d,responsiveHeight:p,responsiveWidth:m,size:k,bodyStyle:B}))}),XI=require("react"),UI=require("d3-scale");function KI(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 QI(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=bf(e.colorScheme,e.themeCategorical,Zt),o=Yj(e.size),r={data:e.data,scales:{x:(0,UI.scaleLinear)().domain(e.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,UI.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:vf(n,e.colorScheme),config:e.layoutConfig??{},world:new $M(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:KI(t,i),context:r,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:s,result:i}}var ZI=require("react/jsx-runtime"),JI=(0,XI.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=DI(e,[700,380]),{chartSize:C,className:M,title:j,chartMode:I,margin:P,enableHover:R,description:T,summary:_,accessibleTable:L}=A,N=(0,XI.useRef)(null),$=(0,XI.useRef)(null),D=(0,XI.useRef)(""),{selection:B,onBodyHover:E}=LI({selection:e.selection,linkedHover:e.linkedHover,colorBy:r,chartType:"PhysicsCustomChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:u?.onBodyHover}),O=BI({data:c,emptyContent:l,loading:p,loadingContent:m,size:C}),F=null!=O,z=(0,XI.useMemo)(()=>ft(c??[]),[c]),H=Et(e=>e.theme),W=(0,XI.useMemo)(()=>Rt(H)??{},[H]),q=H?.colors?.categorical??Lt.colors.categorical,G=(0,XI.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,XI.useMemo)(()=>QI({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]);D.current===G&&null!=$.current||(D.current=G,$.current=Y.initialSpawns);const V=$.current,X=(0,XI.useMemo)(()=>{const e=[...Y.result.controllers??[],...a??[],...u.controllers??[]];return e.length?e:void 0},[u.controllers,a,Y.result.controllers]),U=(0,XI.useMemo)(()=>{const e=[...Y.result.regionEffects??[],...u.regionEffects??[]];return e.length?e:void 0},[u.regionEffects,Y.result.regionEffects]),K=(0,XI.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]);II(t,{frameRef:N,spawnDatum:(0,XI.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=QI({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,XI.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]);if(O)return O;const Z=FI(e.tooltip,u),J=zI(e,u,Y.result.semanticItems,{selection:B,chartMode:I,className:M,title:j??w,description:T,summary:_,accessibleTable:L,enableHover:R,margin:P});return EI("PhysicsCustomChart",C,(0,ZI.jsx)(Gj,{...u,...Z,...J,ref:N,onBodyHover:E,backgroundGraphics:OI(u.backgroundGraphics,Y.result.backgroundOverlays),bodyForces:Y.result.bodyForces??u.bodyForces,bodyStyle:Y.result.bodyStyle??u.bodyStyle??K,config:Y.config,controllers:X,foregroundGraphics:OI(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}))});JI.displayName="PhysicsCustomChart";var eP=require("react"),tP=require("react/jsx-runtime"),nP=require("react"),oP=(0,eP.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=DI(e,[700,380],{hasSimulationMode:!0}),{chartSize:w,simulationMode:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:I,description:P,summary:R,accessibleTable:T}=x,_=(0,eP.useRef)(null),L="mechanical"===k&&null==b?"value":b,N=(0,eP.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=eI(e.unitValue,1),i=nI(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]),$=(0,eP.useMemo)(()=>cI({data:N,categoryAccessor:o,valueAccessor:L,unitValue:g,ballRadius:n,seed:f,size:w}),[n,o,w,N,L,f,g]),D=$I($.config,p,h);II(t,{frameRef:_,spawnDatum:(0,eP.useCallback)((e,t)=>{const r=cI({data:[e],categoryAccessor:o,valueAccessor:L,unitValue:g,ballRadius:n,seed:f+t+1,size:w}),i={id:(e.id??"pile-push-"+t)+"",x:Yj(w).plot.x,y:Yj(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:N,seedSpawns:$.initialSpawns});const B="mechanical"===k&&null==r?"category":r,E=(0,eP.useMemo)(()=>Xj(B,"#4e79a7",{styleRules:v,valueAccessor:b}),[B,v,b]),O=(0,eP.useMemo)(()=>Kj($.projectionRows,w,"category"),[w,$.projectionRows]),{selection:F,onBodyHover:z}=LI({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=BI({data:"mechanical"===k?N: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=Yj(o),i=aI(r.plot,e.length,t),s=r.plot.y+r.plot.height;return(0,tP.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,tP.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,tP.jsxs)("g",{children:[(0,tP.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,tP.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,tP.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}`)})]})}}($.projectionRows,n,S),q=FI(e.tooltip,a),G=zI(e,a,O,{selection:F,chartMode:M,className:A,title:C,description:P,summary:R,accessibleTable:T,enableHover:I,margin:j});return EI("UnitPileChart",w,(0,nP.createElement)(Gj,{...a,...q,...G,ref:_,onBodyHover:z,key:D.rerunKey,config:D.config,foregroundGraphics:OI(W,a?.foregroundGraphics),initialSpawns:$.initialSpawns,initialSpawnPacing:$.initialSpawnPacing,paused:h,responsiveHeight:m,responsiveWidth:y,size:w,bodyStyle:E}))}),rP=require("react"),iP=require("react/jsx-runtime");function sP(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}var aP=(0,rP.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=DI(e,[700,360]),{chartSize:k,showProjection:S,className:A,title:C,chartMode:M,margin:j,enableHover:I,description:P,summary:R,accessibleTable:T}=w,_=h??("sparkline"===M?2:"context"===M?4:5),L=(0,rP.useRef)(null),N=(0,rP.useMemo)(()=>i??[],[i]),$=(0,rP.useMemo)(()=>uI({data:N,xAccessor:v,groupAccessor:c,radiusAccessor:p,pointRadius:_,seed:g,size:k,xExtent:x,collisionIterations:r,settle:b}),[N,k,r,c,_,p,g,b,v,x]),D=$I($.config,m,d);II(t,{frameRef:L,spawnDatum:(0,rP.useCallback)((e,t)=>{const n=uI({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:Yj(k).plot.x,y:Yj(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:N,seedSpawns:$.initialSpawns});const B=n??c,E=(0,rP.useMemo)(()=>Xj(B,"#4e79a7",{styleRules:o,valueAccessor:v}),[B,o,v]),{selection:O,onBodyHover:F}=LI({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=BI({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=Yj(n),r=o.plot.y+o.plot.height,[i,s]=e.xExtent,a=i+(s-i)/2,c=[{label:sP(i),x:e.xRange[0]},{label:sP(a),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:sP(s),x:e.xRange[1]}];return(0,iP.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,iP.jsxs)("g",{children:[(0,iP.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,iP.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,iP.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,iP.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,iP.jsxs)("g",{children:[(0,iP.jsx)("line",{x1:e.x,x2:e.x,y1:r,y2:r+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),(0,iP.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}`))]})}}($.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"}})}($.metadata),q=FI(e.tooltip,a),G=zI(e,a,W,{selection:O,chartMode:M,className:A,title:C,description:P,summary:R,accessibleTable:T,enableHover:I,margin:j});return EI("CollisionSwarmChart",k,(0,iP.jsx)(Gj,{...a,...q,...G,ref:L,onBodyHover:F,config:D.config,foregroundGraphics:OI(H,a?.foregroundGraphics),initialSpawns:$.initialSpawns,paused:d,responsiveHeight:y,responsiveWidth:f,size:k,bodyStyle:E},D.rerunKey))}),cP=require("react");function lP(e){return e.toLocaleString(void 0,1e3>Math.abs(e)?{maximumFractionDigits:1}:{maximumFractionDigits:0})}function uP(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}var dP=require("react/jsx-runtime"),hP=require("react");function pP(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 mP(e){if(!e||"object"!=typeof e)return[];const t=e.flowPath;return Array.isArray(t)?t.map(pP).filter(e=>null!=e):[]}function yP(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 fP(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 gP(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function bP(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 vP(e,t,n){const o=yP({...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=gP(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 xP=(0,cP.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:I=1,showNodeLabels:P=!0,showSensors:R=!1,showStaticFlow:T=!0,sourceAccessor:_="source",styleRules:L,targetAccessor:N="target",throughputAccessor:$="value"}=e,D=DI(e,[760,420]),{chartSize:B,className:E,title:O,chartMode:F,margin:z,enableHover:H,description:W,summary:q,accessibleTable:G}=D,Y=(0,cP.useRef)(null),V=(0,cP.useMemo)(()=>g??[],[g]),X=(0,cP.useMemo)(()=>u??s??i??[],[i,s,u]),U=(0,cP.useMemo)(()=>gI({nodes:V,links:X,nodeIdAccessor:m,nodeXAccessor:y,nodeYAccessor:f,sourceAccessor:_,targetAccessor:N,throughputAccessor:$,pathAccessor:w,coordinateMode:r,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:c,pathConstraint:k,reducedMotion:A,seed:I,size:B}),[X,V,B,r,c,p,m,y,f,v,x,w,k,A,I,_,N,$]);II(t,{frameRef:Y,spawnDatum:(0,cP.useCallback)((e,t)=>{const n=gI({nodes:V,links:[e],nodeIdAccessor:m,nodeXAccessor:y,nodeYAccessor:f,sourceAccessor:_,targetAccessor:N,throughputAccessor:$,pathAccessor:w,coordinateMode:r,particleRate:x,maxParticles:p,particleRadius:v,flowSpeed:c,pathConstraint:k,reducedMotion:A,seed:I+t+1,size:B}),o={id:(e.id??"physical-flow-push-"+t)+"",x:Yj(B).plot.x,y:Yj(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,I,_,N,$]),seedRows:X,seedSpawns:U.initialSpawns});const K=o??"source",Q=(0,cP.useMemo)(()=>Xj(K,"#2563eb",{styleRules:L,valueAccessor:$}),[K,L,$]),Z=$I((0,cP.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,cP.useRef)(l?.onTick);J.current=l?.onTick;const ee=(0,cP.useCallback)((e,t)=>{A||"none"===k||function(e,t){const n=e.readBodies(),o=[],r=[];for(const i of n){const n=mP(i.datum);if(2>n.length)continue;const s=yP(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*gP(i))){o.push(i.id),r.push(vP(i,n,l));continue}const u=fP(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]=bP(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}=LI({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=BI({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,dP.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,dP.jsxs)("g",{children:[(0,dP.jsx)("path",{d:uP(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),(0,dP.jsx)("path",{d:uP(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),n?(0,dP.jsx)("text",{x:n.x,y:n.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:lP(e.throughput)}):null]},e.id)}):null,e.nodes.map(e=>(0,dP.jsxs)("g",{children:[o&&a.has(e.sensorId)?(0,dP.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,dP.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,dP.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:P,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}: ${lP(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:uP(e.path),group:"flow"}}):[];var se;const ae=FI(e.tooltip,l),ce=zI(e,l,ie,{selection:te,chartMode:F,className:E,title:O,description:W,summary:q,accessibleTable:G,enableHover:H,margin:z});return EI("PacketFlowChart",B,(0,hP.createElement)(Gj,{...l,...ae,...ce,key:Z.rerunKey,ref:Y,onBodyHover:ne,config:Z.config,continuous:!A&&"none"!==k,foregroundGraphics:OI(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}))});xP.displayName="PacketFlowChart";var wP=require("react"),kP=require("react/jsx-runtime"),SP={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 AP(e,t,n){return Math.max(t,Math.min(n,e))}function CP(e){return 6.2*e.length}function MP(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 jP(e,t,n="auto"){const o=Math.max(1,Math.floor(t/6.2)),r="compact"===n?MP(e,o):"full"===n?e:CP(e)>t?MP(e,o):e;return{text:r,textLength:CP(r)>t?Math.max(4,t):void 0}}function IP(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 PP=require("react/jsx-runtime"),RP=(0,wP.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:I="horizontal",seed:P=1,settle:R,springDamping:T,springStiffness:_,stageAccessor:L="stage",stages:N,workAccessor:$}=e,D=DI(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}=D,X=(0,wP.useRef)(null),U=(0,wP.useMemo)(()=>ft(i??[]),[i]),K=(0,wP.useMemo)(()=>({data:U,stages:N,size:B,idAccessor:m,stageAccessor:L,groupBy:l,groupLabelAccessor:d,workAccessor:$,radiusAccessor:A,ballRadius:n,seed:P,route:I,groupCompletion:u,groupAnchorAlong:c,springStiffness:_,springDamping:T,gravityX:h,gravityY:p,settle:R}),[n,B,h,p,c,l,u,d,m,A,I,U,P,R,T,_,L,N,$]),Q=(0,wP.useMemo)(()=>SI(K),[K]),Z=Q.metadata;II(t,{frameRef:X,spawnDatum:(0,wP.useCallback)((e,t)=>{const o=SI({...K,data:[e],seed:P+t+1,settle:!0}).initialSpawns[0]??{id:(e.id??"process-flow-push-"+t)+"",x:Yj(B).plot.x,y:Yj(B).plot.y,mass:1,shape:{type:"circle",radius:n},datum:e};return{datumId:(e.id??o.id)+"",spawns:[o]}},[n,K,B,P]),seedRows:U,seedSpawns:Q.initialSpawns});const J=(0,wP.useMemo)(()=>Xj(r),[r]),ee=(0,wP.useMemo)(()=>{if(!f)return a.controllers;const e=[...N.filter(e=>e.capacity&&e.capacity.unitsPerSecond>0).map(e=>{const t=e.capacity.unitsPerSecond;return KM({id:"process-capacity-"+e.id,regionId:"process-stage-"+e.id,unitsPerSecond:t,unitAccessor:e.capacity.unitAccessor??($?"string"==typeof $?$:e=>{const t=e.datum;if(!t)return 1;try{return Number($(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,N,$]),[te,ne]=(0,wP.useState)({}),oe=(0,wP.useRef)(ee);oe.current=ee;const re=(0,wP.useRef)(a.onTick);re.current=a.onTick;const ie=!1!==O||null!=g;(0,wP.useEffect)(()=>{if(!g)return;const e=Object.values(te);e.length&&g(e)},[te,g]);const se=(0,wP.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,wP.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=$I((0,wP.useMemo)(()=>({...Q.config,...null!=v?{bodyLimit:v,eviction:"oldest"}:{},...a.config}),[v,a.config,Q.config]),C,S),{selection:le,onBodyHover:ue}=LI({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=BI({data:i,emptyContent:s,loading:w,loadingContent:k,size:B});if(de)return de;if(!N?.length)return EI("ProcessFlowChart",B,(0,PP.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,kP.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,kP.jsx)("defs",{children:(0,kP.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,kP.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,kP.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,kP.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,kP.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,kP.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=SP[n],c=Math.max(12,e.width-8),l=AP(c-8,22,88),d=jP(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=jP(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=jP(w,Math.max(16,c-8),"auto"),S=Math.max(30,p-15),A=S-13;return(0,kP.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,kP.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,kP.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,kP.jsxs)(kP.Fragment,{children:[(0,kP.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,kP.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,kP.jsx)("title",{children:e.label}),d.text]})]}):null,x?(0,kP.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,kP.jsx)("title",{children:g}),v.text]}):null,o&&null!=e.count?(0,kP.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,kP.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=AP(Math.max(54,CP(e.label)+18,CP(c)+16),54,104),u=jP(e.label,l-12,"auto"),d=jP(c,l-12,"auto");return(0,kP.jsxs)("g",{"data-group":e.id,children:[(0,kP.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,kP.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,kP.jsx)("title",{children:e.label}),u.text]}),(0,kP.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,kP.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=Yj(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,PP.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,PP.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=[...Kj(Q.projectionRows,B,"stage"),...IP(Z?.groups??[])],ye=FI(e.tooltip,a),fe=zI(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 EI("ProcessFlowChart",B,(0,PP.jsx)(Gj,{...a,...ye,...fe,ref:X,onBodyHover:ue,controllers:ee,regionEffects:ge,selection:le??a.selection,backgroundGraphics:OI(he,a.backgroundGraphics),foregroundGraphics:OI(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}))});RP.displayName="ProcessFlowChart";var TP=require("react"),_P="gauntlet-core",LP="gauntlet-positive",NP="gauntlet-negative";function $P(e){const t=HP(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 DP(e,t,n,o){return n?"function"==typeof n?n(e,t):e[n]??o:o}function BP(e){return e?.label??e?.id??"property"}function EP(e){return`gauntlet:${e}:core`}function OP(e,t){return`gauntlet:${e}:positive:${t}`}function FP(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}var zP={left:28,top:76,rightInset:30,thickness:8};function HP(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return zP;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 WP(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function qP(e,t,n,o){const r=HP(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 GP(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 YP(e,t,n,o){const r=GP(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 VP(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 XP(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 UP(e,t,n,o,r){const i=DP(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=o.map(e=>e.id),a=[...DP(e,t,n.positiveAccessor,s)],c=[...DP(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:i,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...DP(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(DP(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:DP(e,t,n.initialViability,100)}}function KP(e,t,n,o,r,i,s){const a=WP(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:_P,projectId:e.id,sourceDatum:e.datum},y=[{...d,id:EP(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=qP(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=VP(e.activePositiveIds,t,a),s=o.radius??Math.max(2,10*a),c=qP(f.x+Math.cos(i.angle)*i.radius,f.y+Math.sin(i.angle)*i.radius,s,n);y.push({id:OP(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:LP,projectId:e.id,property:o,sourceDatum:e.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:EP(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(QP(e,r,o,f.x,f.y,n,d.spawnAt??e.startedAt))}),y}function QP(e,t,n,o,r,i,s){const a=WP(i),c=t.radius??Math.max(2,7.2*a),l=qP(o+(n%4*12-12)*a,r+(54+12*Math.floor(n/4))*a,c,i);return{id:FP(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:NP,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:EP(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...t.spring??{}}]}}function ZP(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 JP(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 eR(e,t){return JP(e.activePositiveIds,t.popPositive)}function tR(e,t){const n=JP(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 nR(e,t,n){if(t.when&&!t.when(n))return e;let o={...e};const r=eR(o,t);r.length&&(o={...o,activePositiveIds:o.activePositiveIds.filter(e=>!r.includes(e)),poppedPositiveIds:Array.from(new Set([...o.poppedPositiveIds,...r]))});const i=tR(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=ZP(t.addPositive);s.length&&(o={...o,activePositiveIds:Array.from(new Set([...o.activePositiveIds,...s])),missingPositiveIds:o.missingPositiveIds.filter(e=>!s.includes(e))});const a=ZP(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 oR(e,t){return{id:e.id,label:e.label??e.id,summary:e.summary??t.find(e=>e.summary)?.summary,time:e.time}}function rR(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 iR(e,t){const n=e.datum;return!(!n?.__gauntlet||n.projectId!==t||n.kind!==NP)}function sR(e){const t=e.id.slice(e.id.lastIndexOf(":")+1),n=Number(t);return Number.isFinite(n)?n:-1}function aR(e,t){return 2>Math.hypot(e.vx,e.vy)&&4>Math.hypot(t.x,t.y)?null:t}var cR=require("react/jsx-runtime");function lR(e){const t=e.data;return t?.__gauntlet?(0,cR.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,cR.jsx)("strong",{children:t.kind===_P?"string"==typeof t.sourceDatum?.label?t.sourceDatum.label:t.projectId:BP(t.property)}),(0,cR.jsx)("div",{children:t.kind===LP?"Positive property":t.kind===NP?"Negative property":"Project core"})]}):null}function uR(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===_P)e.fillStyle=dR(e,n.fill,"#0f766e"),e.strokeStyle=dR(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=dR(e,n.fill??t?.color,"#38bdf8"),e.strokeStyle=dR(e,n.stroke,"#0f172a"),e.lineWidth=1.1,e.beginPath(),o.kind===NP?e.rect(-r,-r,2*r,2*r):e.arc(0,0,r,0,2*Math.PI),e.fill(),e.stroke(),e.fillStyle=dR(e,"var(--semiotic-bg, #07111f)","#07111f"),e.font=`900 ${o.kind===NP?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 dR(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 hR({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,cR.jsx)(cR.Fragment,{children:e.gates.map(i=>(0,cR.jsxs)("g",{children:[(0,cR.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,cR.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 pR({layout:e,states:t,compact:n=!1}){return n?(0,cR.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,cR.jsx)(hR,{layout:e,compact:!0,showLabels:!1})}):(0,cR.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,cR.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,cR.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,cR.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,cR.jsx)(hR,{layout:e,compact:!1,showLabels:!0}),(0,cR.jsxs)("g",{children:[(0,cR.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,cR.jsx)("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),(0,cR.jsxs)("g",{children:[(0,cR.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,cR.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),(0,cR.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 mR(e){const t=e.datum;return!!t?.__gauntlet&&(t.kind===_P?{label:t.projectId+" project core",group:"project",description:"Project core carrying positive and negative properties."}:{label:`${BP(t.property)} ${t.kind===LP?"positive":"negative"} property`,group:t.kind===LP?"positive property":"negative property",description:`${BP(t.property)} attached to ${t.projectId}.`})}function yR({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,cR.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,cR.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,cR.jsxs)("g",{children:[(0,cR.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,cR.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 fR=require("react/jsx-runtime"),gR=require("react"),bR=[],vR=(0,TP.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=bR,projectPlacement:k,rerunMS:S,responsiveHeight:A,responsiveWidth:C,seed:M,showTethers:j=!0,terminalBehavior:I="outcome",viability:P}=e,R=(0,TP.useRef)(null),T=(0,TP.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]),_=DI(e,[900,520]),{chartSize:L,showProjection:N,showChrome:$,className:D,title:B,chartMode:E,margin:O,enableHover:F,description:z,summary:H,accessibleTable:W}=_,{selection:q,onBodyHover:G}=LI({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=BI({data:a,emptyContent:c,loading:p,loadingContent:m,size:L}),V=(0,TP.useMemo)(()=>ft(a??[]),[a]),X=(0,TP.useMemo)(()=>V.map((e,t)=>DP(e,t,T.idAccessor,null!=e.id?e.id+"":"project-"+t)+"").join("|"),[V,T.idAccessor]),U=(0,TP.useMemo)(()=>new Map(w.map(e=>[e.id,e])),[w]),K=(0,TP.useMemo)(()=>new Map(y.map(e=>[e.id,e])),[y]),Q=(0,TP.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,TP.useMemo)(()=>new Map(Q.gates.map(e=>[e.id,e])),[Q.gates]),J=(0,TP.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:_P}: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,TP.useState)(()=>V.map((e,t)=>{const n=UP(e,t,T,w,K);return{...n,viability:P?.(n,{negativeProperties:K,positiveProperties:U})??XP(n,U,K)}})),ne=(0,TP.useRef)(ee),oe=(0,TP.useRef)(0),re=(0,TP.useRef)(new Map),ie=(0,TP.useRef)([]),se=(0,TP.useRef)(f);se.current=f;const ae=(0,TP.useRef)(V);ae.current=V;const ce=(0,TP.useRef)(b);ce.current=b;const le=(0,TP.useRef)({negativeById:K,positiveById:U,positiveProperties:w,stateAccessors:T,viability:P});le.current={negativeById:K,positiveById:U,positiveProperties:w,stateAccessors:T,viability:P};const ue=(0,TP.useCallback)((e,t,n=0)=>{const o=le.current,r=UP(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})??XP(r,o.positiveById,o.negativeById)}},[]),de=(0,TP.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=$I((0,TP.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:[...$P(Q),...u.config?.colliders??[]]}),[u.config?.colliders,u.config?.kernel,Q,M]),S,x,de),pe=(0,TP.useMemo)(()=>function(e){const{dataKey:t,gates:n,statesRef:o,processedGateVisitsRef:r}=e;return n.flatMap(e=>e.capacity&&e.capacity.unitsPerSecond>0?[KM({id:`gauntlet-capacity-${t}-${e.id}`,regionId:"gauntlet-gate-"+e.id,unitsPerSecond:e.capacity.unitsPerSecond,bodyFilter:{property:"datum.kind",equals:_P},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,TP.useMemo)(()=>[...pe,...u.controllers??[]],[pe,u.controllers]);(0,TP.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,TP.useEffect)(()=>{ne.current=ee,ce.current?.(ee)},[ee]);const ye=(0,TP.useCallback)(e=>[...("function"==typeof l?l(e,Q):l)??[]].sort((e,t)=>e.time-t.time),[l,Q]),fe=(0,TP.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,TP.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,TP.useMemo)(()=>ee.flatMap((e,t)=>{const n=YP(e,t,Q,k);return KP(e,t,Q,n,U,K,o)}),[o,Q,K,U,k,ee]),ve=(0,TP.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,TP.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=YP(d,t.current.length,i,s),p=KP(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=YP(t,d.length,i,s);h.push(...KP(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(EP(n.id),...n.activePositiveIds.map(e=>OP(n.id,e))),n.negativeIds.forEach((e,t)=>{s.push(FP(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=YP(y,0>h?t.current.length:h,i,s);r.current?.remove([EP(n.id),...n.activePositiveIds.map(e=>OP(n.id,e)),...n.negativeIds.map((e,t)=>FP(n.id,e,t))]),r.current?.pushMany(KP(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,TP.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===EP(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)iR(o,e.id)&&(n=Math.max(n,sR(o)));return Math.max(e.negativeIds.length,n+1)}(t,d),y=ZP(n.addNegative).flatMap((e,n)=>{const o=s.get(e);return o?[QP(t,o,m+n,h,p,r)]:[]}),f=ZP(n.addPositive).flatMap(e=>{if(!i.get(e)||t.activePositiveIds.includes(e))return[];const n={...GP(r),routeY:p,socketY:p,startX:h,startY:p};return KP({...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=eR(t,n);for(const e of g){const n=i.get(e);c([OP(t.id,e)],{color:n?.popColor??n?.color,durationMs:900,radius:(n?.radius??10)+3,scale:l})}const b=tR(t,n),v=function(e,t,n){const o=t.filter(t=>iR(t,e.id)).sort((e,t)=>sR(e)-sR(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):FP(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,TP.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=YP(y,m,o,i),g=n.find(e=>e.id===EP(y.id)),b=WP(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!==_P){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===LP&&p.property){const t=VP(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===NP&&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=qP(e.x,e.y,i,o);const s=qP(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!==LP||y.killed?0:3.2*(r?.buoyancy??r?.value??1),c=p.kind===NP?{x:.22*(r?.pull?.x??-8),y:.22*(r?.pull?.y??22)}:{x:0,y:0};return aR(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 aR(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=WP(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 aR(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:I,elapsed:oe.current}),[r,Z,Q,K,U,ye,k,I]),Se=(0,TP.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===EP(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=nR(b,e,o))}const s={...oR(n,i),appliedAt:o};b=rR(b,s),h(e.id,e=>{let t=rR(e,s);if(t===e)return e;for(const e of i)t=nR(t,e,{event:n,gate:r,negativeProperties:y,positiveProperties:m,project:t});const o=p?.(t,{negativeProperties:y,positiveProperties:m})??XP(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:P,positiveById:U,negativeById:K,outcome:v,reportCapacity:ge})},[we,fe,i,u,Z,Q,K,v,U,ye,ge,ve,P]),Ae=(0,TP.useCallback)((e,t)=>{const n="function"==typeof u.bodyStyle?u.bodyStyle(e,t):u.bodyStyle,o=e.datum;return o?.__gauntlet?{fill:o.kind===_P?"var(--semiotic-primary, #0f766e)":o.property?.color??"var(--semiotic-primary, #38bdf8)",stroke:o.kind===_P?"#f8fafc":"#0f172a",opacity:.96,...n}:n??{}},[u]),Ce=(0,TP.useMemo)(()=>"function"==typeof n?n(ee,Q):n??[],[n,Q,ee]),Me=(0,TP.useMemo)(()=>IP(Ce),[Ce]),je=(0,TP.useMemo)(()=>N?function(e,t){if(!e.length)return[];const n=Math.max(40,(t.width-80)/e.length);return e.map((e,t)=>{const o=`${e.id}: viability ${Math.round(e.viability)}, ${e.outcome||e.stage}`;return{id:"gauntlet-projection-"+e.id,label:o,description:o,datum:e,x:40+(t+.5)*n,y:28,shape:"rect",width:Math.max(16,.55*n),height:22,group:"settled projection"}})}(ee,Q):[],[Q,N,ee]),Ie=(0,TP.useMemo)(()=>[...je,...Me],[Me,je]),Pe=(0,TP.useCallback)((e,t)=>{u.onBodyPointerDown?.(e,t)},[u]),Re=(0,TP.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,TP.useCallback)((e,t)=>{u.beforePaint?.(e,t),j&&function(e,t){const n=new Map(t.filter(e=>e.datum?.kind===_P).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===_P)continue;const r=n.get(t.projectId);r&&(e.globalAlpha=t.kind===NP?.24:.36,e.strokeStyle=t.kind===NP?"#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,TP.useMemo)(()=>[...J,...u.regionEffects??[]],[u.regionEffects,J]);if(Y)return Y;const Le=FI(e.tooltip,u),Ne=zI(e,u,Ie,{selection:q,chartMode:E,className:D,title:B,description:z,summary:H,accessibleTable:W,enableHover:F,margin:O}),$e=N?(0,fR.jsx)(yR,{states:ee,layout:Q}):void 0,De=OI($?(0,fR.jsx)(pR,{layout:Q,states:ee,compact:_.resolved.compactMode}):void 0,u.backgroundGraphics),Be=OI($e,u.foregroundGraphics),Ee=u.renderBody??uR,Oe=Le.tooltipContent??lR;return EI("GauntletChart",L,(0,gR.createElement)(Gj,{...u,...Le,...Ne,key:`${L[0]}x${L[1]}:${X}:${he.rerunKey}`,ref:R,onBodyHover:G,accessibleTable:e.accessibleTable??u.accessibleTable,backgroundGraphics:De,bodyForces:ke,bodySemanticItems:u.bodySemanticItems??mR,bodyStyle:Ae,beforePaint:Te,onClick:g?Re:Ne.onClick,config:he.config,controllers:me,enableHover:Le.enableHover??!0,foregroundGraphics:Be,hoverRadius:e.hoverRadius??u.hoverRadius??18,initialSpawns:be,initialSpawnPacing:h,onBodyPointerDown:Pe,onTick:Se,paused:x,regionEffects:_e,renderBody:Ee,responsiveHeight:A,responsiveWidth:C,size:L,tooltipContent:Oe}))});vR.displayName="GauntletChart";var xR=require("react"),wR=1e-9;function kR(e,t){return t>e?-1:e>t?1:0}function SR(e){return{...e}}function AR(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 CR(e){const t=Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:SR(t.initialMetrics),metrics:SR(t.metrics),productIds:[...t.productIds],history:AR(t.history)}])),n=Object.fromEntries(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:SR(t.metrics),sourceIds:[...t.sourceIds],history:AR(t.history)}])),o=Object.fromEntries(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?SR(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:n,relations:o,input:{amount:e.input.amount,metrics:SR(e.input.metrics)},metrics:SR(e.metrics),loss:{amount:e.loss.amount,metrics:SR(e.loss.metrics)},history:AR(e.history)}}function MR(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function jR(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(kR)}function IR(e,t){return e?Object.entries(e).flatMap(([e,n])=>Number.isFinite(n)?[]:[MR("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function PR(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}function RR(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(MR("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(MR("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(kR);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||o.push(MR("warning","empty-selector","Selector matched no source components.",n)),{ids:d,diagnostics:o}}function TR(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 _R(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 LR(e,t,n){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(MR("error","unknown-outlet",`Unknown outlet "${t}".`,n,[t])),1))}function NR(e,t,n){const o=jR(t);t.length||e.diagnostics.push(MR("error","empty-source-list","A product requires at least one source component.",n)),o.length&&e.diagnostics.push(MR("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(MR("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(MR("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(MR("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 $R(e,t,n,o,r){const i=o?.amount??0;(!Number.isFinite(i)||0>i||i>t+wR)&&e.diagnostics.push(MR("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",r+".amount")),e.diagnostics.push(...IR(o?.metrics,r+".metrics"));for(const[t,i]of Object.entries(o?.metrics??{}))(0>i||i>Number(n[t]??0)+wR)&&e.diagnostics.push(MR("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 DR(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 BR(e,t,n,o){void 0!==t.amount&&Math.abs(t.amount-n)>wR&&e.diagnostics.push(MR("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${n}.`,o,[t.id]))}function ER(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(MR("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,o+".state")),e.diagnostics.push(...IR(t.metricsDelta,o+".metricsDelta")),LR(e,t.outletId,o+".outletId");const n=RR(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(MR("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=TR(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&&PR(n.metrics,t.metricsDelta),n.history.push(s)}return r.history.push(s),void(n.ids.length&&_R(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(MR("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=jR(t),r=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(MR("error","insufficient-relation-sources","A relation requires at least two source components.",n)),o.length&&e.diagnostics.push(MR("error","duplicate-source",`Relation source ids must be unique: ${o.join(", ")}.`,n,o)),r.length&&e.diagnostics.push(MR("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(...IR(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=TR(e,t,{sourceIds:[...n.sourceIds],relationIds:[n.id]});return r.history.push(s),void _R(e,{type:"activate-relation",sourceIds:[...n.sourceIds],relationIds:[n.id]})}if("resolve-relation"===t.type){const n=jR(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(MR("error","duplicate-relation","Relation ids must be unique.",o+".relationIds",n)),i.length&&e.diagnostics.push(MR("error","unknown-relation",`Unknown relation: ${i.join(", ")}.`,o+".relationIds",i)),s.length&&e.diagnostics.push(MR("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=TR(e,t,{relationIds:[...t.relationIds]});return r.history.push(a),void _R(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(MR("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(MR("error","duplicate-product",`Product "${t.productId}" has already been formed.`,o+".productId",[t.productId])),"contribute"!==t.type||i&&"forming"===i.status||e.diagnostics.push(MR("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,o+".productId",[t.productId]));const s=NR(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=jR(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(MR("error","duplicate-relation","Basis relations must be unique.",o,r)),i.length&&e.diagnostics.push(MR("error","unknown-relation",`Unknown basis relation: ${i.join(", ")}.`,o,i)),s.length&&e.diagnostics.push(MR("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,o,s)),c.length&&e.diagnostics.push(MR("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)PR(t,n.metrics);return t}(s);if(!$R(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=TR(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let m;if("combine"===t.type){if(h&&BR(e,n,d,o+".productId"),m=DR(n,t.sourceIds,d,u,e,h,p),h&&!LR(e,m.outletId,o+".productId"))return;r.products[t.productId]=m}else m=i,m.sourceIds.push(...t.sourceIds),m.amount+=d,PR(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;_R(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,c),_R(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&&_R(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(!LR(e,a,i+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(MR("error","product-already-complete",`Product "${t.id}" is already complete.`,i,[t.id]));s&&(BR(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=TR(e,r,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),_R(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(MR("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,o+".productId",[t.productId]))}if("split"===t.type){const n=NR(e,[t.sourceId],o+".sourceId");t.products.length||e.diagnostics.push(MR("error","empty-split","A split requires at least one product allocation.",o+".products"));const i=t.products.map(e=>e.productId),s=jR(i);s.length&&e.diagnostics.push(MR("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(MR("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,o+".products",c)),l.length&&e.diagnostics.push(MR("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(MR("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${o}.products.${n}.amount`)),e.diagnostics.push(...IR(r.metrics,`${o}.products.${n}.metrics`));if(!n?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=n[0];if(!$R(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(MR("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)>wR)return void e.diagnostics.push(MR("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=TR(e,t,{sourceIds:[u.id],productIds:i});if(t.products.forEach((n,i)=>{const s=a[i],c=d>wR?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=DR({...s,amount:m[i],metrics:h},[u.id],m[i],{...h},e,!0,g);LR(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),_R(e,{type:"split-source",sourceIds:[u.id],productIds:i});for(const t of i)_R(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){LR(e,t.outletId,o+".outletId");const n=RR(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(MR("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=TR(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&&_R(e,{type:"retarget-component",sourceIds:n.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...IR(t.metricsDelta,o+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let n,i;if("run"===t.target)PR(r.metrics,t.metricsDelta);else if("components"in t.target){const i=RR(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)PR(r.components[e].metrics,t.metricsDelta)}else{i=[...t.target.productIds];const n=jR(i),s=i.filter(e=>!r.products[e]);if(n.length&&e.diagnostics.push(MR("error","duplicate-product","Metric target product ids must be unique.",o+".target.productIds",n)),s.length&&e.diagnostics.push(MR("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)PR(r.products[e].metrics,t.metricsDelta)}return void r.history.push(TR(e,t,{sourceIds:n,productIds:i}))}t.outcome.trim()?(r.outcome=t.outcome,r.summary=t.summary,r.history.push(TR(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(MR("error","invalid-outcome","Outcome must be a non-empty string.",o+".outcome"))}function OR(e,t,n){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[MR("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const o=CR(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(ER(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 FR=[900,520],zR=[{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}],HR=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),WR=1e-9;function qR(e,t){return t>e?-1:e>t?1:0}function GR(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function YR(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(qR)}function VR(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function XR(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(GR("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,i)),o}}function UR(e,t,n){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(GR("error","invalid-metrics","Metrics must be a numeric object.",n)),{};const o={};for(const[r,i]of Object.entries(e)){const e=VR(i);null!=e?o[r]=e:t.push(GR("error","invalid-metric",`Metric "${r}" must be finite.`,`${n}.${r}`))}return o}function KR(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 QR(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+WR).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),r=[];let i=e;for(const[e,t]of o)e>i+WR&&r.push([i,e]),i=Math.max(i,t);return t>i+WR&&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 ZR(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 JR(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?ZR(e):1}function eT(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:JR(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function tT(e){return"crucible:component:"+encodeURIComponent(e)}function nT(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>WR?o[0]+(o[1]-o[0])*Math.sqrt(Math.max(0,e-r)/(i-r)):(o[0]+o[1])/2}function oT(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 rT(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 iT(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 sT(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 aT(e,t,n={}){const o=Object.values(e.products).sort((e,t)=>qR(e.id,t.id)),r=Object.values(e.components).sort((e,t)=>qR(e.id,t.id)),i=[...r.map(e=>e.amount),...o.map(e=>e.amount)],s=oT(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)||qR(e.id,t.id));const n=rT(r.length,sT(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*nT(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=iT(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=rT(n.length,sT(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=ZR(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=nT(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:tT(e.id),x:o.x,y:o.y,mass:Math.max(.25,r*r*.015),shape:{type:"circle",radius:r},datum:c}}),...c]}var cT=aT;function lT(e){return Array.isArray(e)?e.map(lT):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>qR(e,t)).map(([e,t])=>[e,lT(t)])):e}function uT(e,t=e.duration){const n=function(e,t){const n=VR(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-WR,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=CR(e.initialState);const r=[],i=[],s=[];for(const t of e.events){if(t.authoredAt>n.elapsed+WR)break;const a=OR(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 dT(e){const t=function(e){const t=[];e.length||t.push(GR("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const n=YR(e.map(e=>e.id));n.length&&t.push(GR("error","duplicate-phase-id",`Phase ids must be unique: ${n.join(", ")}.`,"phases",n));let o=0;return{phases:e.map((e,n)=>{const r=VR(e.duration),i=null!=r&&r>0?r:0;e.id.trim()||t.push(GR("error","invalid-phase-id","Phase ids may not be empty.",`phases.${n}.id`)),null!=r&&r>0||t.push(GR("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(GR("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=KR(e.outlets??zR),r=(e.products??[]).map(e=>({...e,metrics:e.metrics?{...e.metrics}:void 0})),i=function(e,t,n){const o=[],r=YR(e.map(e=>e.id));r.length&&o.push(GR("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(GR("error","invalid-event-id","Event ids may not be empty.",`events.${r}.id`)),"time"in e.at&&void 0!==e.at.time){const i=VR(e.at.time);if(null==i||0>i||i>n+WR)return void o.push(GR("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=>WR>=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}:WR>=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(GR("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(GR("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(GR("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=((XR(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(GR("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));o.push(l);const u=VR(XR(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(GR("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=UR(XR(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=XR(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),m=HR.has(p)?p:"active";HR.has(p)||t.push(GR("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=XR(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",f=XR(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=YR(o);s.length&&t.push(GR("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=UR(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=FR,t=zR){const n=Math.max(1,VR(e[0])??900),o=Math.max(1,VR(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=KR(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??FR,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(...QR({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}),...QR({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}),...QR({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=YR(t.map(e=>e.id)),i=YR(e.map(e=>e.id));return r.length&&n.push(GR("error","duplicate-outlet-id",`Outlet ids must be unique: ${r.join(", ")}.`,"outlets",r)),i.length&&n.push(GR("error","duplicate-product-id",`Product ids must be unique: ${i.join(", ")}.`,"products",i)),t.forEach((e,t)=>{e.id.trim()||n.push(GR("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||n.push(GR("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||n.push(GR("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(GR("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(GR("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),UR(e.metrics??{},n,`products.${t}.metrics`)}),n}(r,o),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>qR(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(lT(d)));var d;const h=function(e,t,n={}){const o=Object.values(e.components).sort((e,t)=>qR(e.id,t.id)),r=o.map(e=>e.amount),i=oT(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}}(JR(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=nT(e.amount,r,n.bodyRadius,i),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:tT(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:eT(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=uT(m),f=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),g=f.length?[GR("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=cT(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),m.diagnostics=[...p,...y.diagnostics,...g],m}function hT(e,t){return e.playing=t&&!e.complete,e}function pT(e,t,n=!1){const o=uT(e,t);return{...o,state:hT(o.state,n)}}function mT(e,t,n,o=t.playing){const r=pT(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 yT(e,t,n={}){return aT(t,e.layout,n)}function fT(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 gT(e,t){return e.phases[t.phaseIndex]??e.phases.find(e=>e.id===t.phaseId)}function bT(e,t,n={}){return new Map(yT(e,t,n).flatMap(e=>{const t=e.datum;return t?.__crucible?[[`${t.kind}:${t.semanticId}`,{x:e.x,y:e.y}]]:[]}))}function vT(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 xT(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 wT(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 kT(e){const t=e.productIds.length?` Contributes to ${e.productIds.join(", ")}.`:e.outletId?` Routed to ${e.outletId}.`:"",n=e.reason?` ${e.reason}.`:"";return`${wT(e.amount)} amount; ${e.status}.${t}${n}`}function ST(e){const t=e.outletId?` Routed to ${e.outletId}.`:"";return`${e.status} product with ${e.sourceIds.length} source${1===e.sourceIds.length?"":"s"} and ${wT(e.amount)} amount.${t}`}function AT(e,t,n){const o=t.datum;if(!o?.__crucible)return;const r="circle"===t.shape.type?t.shape.radius:8,i=xT(e,n.fill,"product"===o.kind?"#b8792d":"#356b63"),s=xT(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=xT(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 CT=require("react/jsx-runtime"),MT="var(--semiotic-text, #26323a)",jT="var(--semiotic-text-secondary, #6c7377)",IT="var(--semiotic-primary, #b8792d)",PT="var(--semiotic-danger, #9f3d35)",RT="var(--semiotic-success, #356b63)";function TT(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 _T({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,CT.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,CT.jsxs)("defs",{children:[(0,CT.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,CT.jsx)("stop",{offset:"0",stopColor:IT,stopOpacity:"0.03"}),(0,CT.jsx)("stop",{offset:"0.66",stopColor:IT,stopOpacity:"0.1"}),(0,CT.jsx)("stop",{offset:"1",stopColor:PT,stopOpacity:"0.18"})]}),(0,CT.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,CT.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:MT,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,CT.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:MT,strokeOpacity:"0.52",strokeWidth:o?1:2.2}),(0,CT.jsx)("path",{d:TT(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,CT.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:MT,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:o?2:5}),o?null:(0,CT.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,CT.jsxs)("g",{children:[(0,CT.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?o.color??IT:u?RT:MT,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,CT.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?MT:jT,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,CT.jsxs)("g",{children:[(0,CT.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?PT:RT),fillOpacity:"0.1",stroke:e.color??("left"===e.side?PT:RT),strokeDasharray:"3 3",strokeOpacity:"0.62"}),o?null:(0,CT.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:jT,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function LT(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function NT({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,LT(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,CT.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,CT.jsxs)("g",{children:[(0,CT.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?PT:"complete"===e.status?IT:RT,fillOpacity:"0.68"}),c>4&&a>=34?(0,CT.jsxs)(CT.Fragment,{children:[(0,CT.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:jT,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,CT.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:MT,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:850,textAnchor:"middle",children:[wT(u),"amount"===r&&o?" "+o:""]})]}):null]},e.key)})})}function $T({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,CT.jsxs)("div",{"aria-label":"Crucible replay controls",className:"semiotic-crucible-controls",style:{alignItems:"center",color:MT,display:"flex",flexWrap:"wrap",fontFamily:"system-ui, sans-serif",fontSize:11,gap:6,marginBottom:7},children:[e.playPause?(0,CT.jsx)("button",{type:"button",disabled:a,onClick:c,"aria-pressed":r,children:r?"Pause":i?"Replay":"Play"}):null,e.stepPhase?(0,CT.jsx)("button",{type:"button",disabled:a,onClick:u,children:"Next phase"}):null,e.reset?(0,CT.jsx)("button",{type:"button",disabled:a,onClick:l,children:"Reset"}):null,e.timeline?(0,CT.jsxs)("div",{style:{alignItems:"center",display:"flex",flex:"1 1 150px",gap:7,minWidth:130},children:[(0,CT.jsx)("span",{style:{fontWeight:750,whiteSpace:"nowrap"},children:o}),(0,CT.jsx)("span",{"aria-hidden":"true",style:{background:"rgba(38,50,58,0.14)",borderRadius:2,flex:1,height:4,overflow:"hidden"},children:(0,CT.jsx)("span",{style:{background:IT,display:"block",height:"100%",transform:`scaleX(${h})`,transformOrigin:"left center"}})}),(0,CT.jsxs)("span",{style:{color:jT,fontVariantNumeric:"tabular-nums"},children:[n.toFixed(1),"s"]})]}):null,e.speed?(0,CT.jsxs)("label",{style:{alignItems:"center",display:"flex",gap:4},children:["Speed",(0,CT.jsxs)("select",{disabled:a,value:s,onChange:e=>d(Number(e.currentTarget.value)),children:[(0,CT.jsx)("option",{value:.25,children:"¼×"}),(0,CT.jsx)("option",{value:.5,children:"½×"}),(0,CT.jsx)("option",{value:1,children:"1×"}),(0,CT.jsx)("option",{value:2,children:"2×"})]})]}):null]})}function DT(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)":MT,strokeWidth:"product"===i?.kind?1.8:1.1,opacity:.96,...r}}var BT=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function ET(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 OT(e){return"number"==typeof e&&Number.isFinite(e)?e:ET((e??"crucible")+"")}function FT(e){const t=Number(e);return Number.isFinite(t)&&t>0?Math.max(.05,Math.min(8,t)):1}function zT(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 HT(e){return BT[ET(e)%BT.length]}function WT(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 qT=require("react/jsx-runtime"),GT=require("react"),YT=(0,xR.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:I,playback:P="replay",playbackRate:R=1,products:T,projection:_,radiusRange:L,rerunMS:N,responsiveHeight:$,responsiveWidth:D,seed:B,showBonds:E=!0,snapshotAt:O}=e,F=(0,xR.useRef)(null),z=(0,xR.useRef)(j);z.current=j;const H=pu(),W=Uc(),q=DI(e,FR),{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]=yu(Y,D,!1),re=D?Math.max(1,oe[0]):Y[0],ie=Y[1],se=(0,xR.useMemo)(()=>[re,ie],[ie,re]),ae=(0,xR.useMemo)(()=>ft(l??[]),[l]),ce=(0,xR.useMemo)(()=>dT({data:ae,phases:I,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,I,T,L,se,ae,B]),le=Object.values(ce.initialState.components).map((e,t)=>zT(e,s,t)).join("\0"),ue=`${ce.semanticKey}:${se[0]}x${se[1]}:${(r??"auto")+""}:${L?.join(",")??"auto"}:${le}`,de=(0,xR.useRef)(ce),he=(0,xR.useRef)(ue);he.current!==ue&&(he.current=ue,de.current=ce);const pe=de.current,me="snapshot"===P||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,VR(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,VR(t.progress??0)??0));return n.start+n.duration*o}(e,t)}(pe,O):0,fe=!me,ge=(0,xR.useMemo)(()=>pT(pe,ye,fe&&!j),[he.current,ye,fe]),[be,ve]=(0,xR.useState)(ge),xe=(0,xR.useRef)(be),[we,ke]=(0,xR.useState)(fe),Se=(0,xR.useRef)(we),[Ae,Ce]=(0,xR.useState)(0),[Me,je]=(0,xR.useState)(()=>FT(R)),Ie=(0,xR.useRef)(bT(pe,ge.state,{seed:B,bodyRadius:r,radiusRange:L})),Pe=(0,xR.useRef)(""),Re=(0,xR.useRef)(C),Te=(0,xR.useRef)(S),_e=(0,xR.useRef)(A),Le=(0,xR.useRef)(k);Re.current=C,Te.current=S,_e.current=A,Le.current=k;const Ne=(0,xR.useRef)({seed:B,bodyRadius:r,radiusRange:L});Ne.current={seed:B,bodyRadius:r,radiusRange:L};const $e=(0,xR.useCallback)((e,t=!1)=>{if(xe.current=e,Ie.current=bT(de.current,e.state,Ne.current),ve(e),t)for(const t of e.observations)Te.current?.(t)},[]);(0,xR.useEffect)(()=>{je(FT(R))},[R]),(0,xR.useEffect)(()=>{const e=!me,t=pT(pe,me?ye:0,e&&!z.current);Se.current=e,ke(e),$e(t)},[$e,pe,ye,me,ue]),(0,xR.useEffect)(()=>{const e=xe.current,t=Se.current&&!j&&!e.state.complete;if(e.state.playing===t)return;const n={...e,state:CR(e.state)};n.state.playing=t,$e(n)},[$e,j]),(0,xR.useEffect)(()=>{for(const e of pe.diagnostics)_e.current?.(e)},[ue,pe.diagnostics]),(0,xR.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 De=(0,xR.useCallback)(()=>{Pe.current="";const e=!me,t=pT(de.current,0,e&&!j);Se.current=e,ke(e),$e(t)},[$e,j,me]),Be=(0,xR.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=$I(Be,N,Ee,De),Fe=(0,xR.useCallback)(()=>{if("number"!=typeof N||!Number.isFinite(N)||0>N)return;const e=`${ue}:${Ae}:${Oe.rerunKey}`;Pe.current!==e&&(Pe.current=e,Oe.config?.observation?.onSimulationStateChange?.("settled","running"))},[Oe.config,Oe.rerunKey,N,Ae,ue]),ze=(0,xR.useCallback)(()=>{const e=pT(de.current,0,!1);Se.current=!1,ke(!1),$e(e),Ce(e=>e+1)},[$e]),He=(0,xR.useCallback)(()=>{const e=de.current,t=mT(e,xe.current.state,e.duration,!1);Se.current=!1,ke(!1),$e(t,!0);const n=yT(e,t.state,Ne.current),o=F.current;o&&(o.clear(),o.pushMany(n),o.step(0),o.settle()),Fe()},[$e,Fe]),We=(0,xR.useCallback)(()=>{Se.current=!1,ke(!1);const e={...xe.current,state:CR(xe.current.state)};e.state.playing=!1,$e(e)},[$e]),qe=(0,xR.useCallback)(()=>{if(Pe.current="",me){const e=pT(de.current,ye,!1);return Se.current=!1,ke(!1),$e(e),void Ce(e=>e+1)}const e=pT(de.current,0,!j);Se.current=!0,ke(!0),$e(e),Ce(e=>e+1)},[$e,j,ye,me]),Ge=(0,xR.useCallback)(()=>{if(me)return void qe();if(xe.current.state.complete)return void qe();Se.current=!0,ke(!0);const e={...xe.current,state:CR(xe.current.state)};e.state.playing=!j,$e(e)},[$e,j,qe,me]),Ye=(0,xR.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=mT(e,xe.current.state,t,!1);Se.current=!1,ke(!1),$e(n,!0);const o=F.current;o&&(o.clear(),o.pushMany(yT(e,n.state,Ne.current)),o.step(0))},[$e]);(0,xR.useImperativeHandle)(t,()=>({play:Ge,pause:We,reset:ze,replay:qe,stepPhase:Ye,settle:He,getCrucibleState:()=>CR(xe.current.state)}),[We,Ge,qe,ze,He,Ye]);const Ve=(0,xR.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=mT(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,yT(de.current,r.state,Ne.current)),r.state.complete){Se.current=!1,ke(!1);const e=yT(de.current,r.state,Ne.current);t.clear(),t.pushMany(e),t.step(0),t.settle()}$e(r,i),r.state.complete&&Fe()},[$e,h,j,Fe,me]),Xe=(0,xR.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=gT(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=vT(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=vT(n,t.id),r=fT(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=fT(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+fT(d,29))+h)*e,y:s.y+Math.sin(u*(1.8+fT(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>fT(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"===gT(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:Ie.current}),[]),Ue=(0,xR.useMemo)(()=>new Map(Object.keys(pe.initialState.components).map((e,t)=>[e,t])),[pe.initialState.components]),Ke=(0,xR.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??HT(e?.id??n.semanticId)}const o=xe.current.state.components[n.semanticId];return o?HT(zT(o,s,Ue.get(o.id)??0)):"var(--semiotic-primary, #356b63)"},[s,Ue,e.color]),Qe=(0,xR.useCallback)((t,n)=>({...DT(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,xR.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:kT(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:ST(o),group:"derived product · "+o.status,datum:o}}(e,xe.current.state),[h]),Je=(0,xR.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,xR.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,xR.useMemo)(()=>_??{groupBy:"outlet",measure:"count"},[_]),nt=(0,xR.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 PR(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)||kR(e.key,t.key))}(be.state,tt),[tt,be.state]),ot=(0,xR.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=LT(e,r),a="amount"===r&&o?`${wT(s)} ${o}`:`${wT(s)} ${r}`;return{id:"crucible-projection-"+e.key,label:`${e.label}: ${a}`,description:`${e.count} source component${1===e.count?"":"s"}; ${wT(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=FI(e.tooltip,h),{selection:it,onBodyHover:st}=LI({selection:e.selection,linkedHover:e.linkedHover,colorBy:s,chartType:"CrucibleChart",chartId:e.chartId,onObservation:e.onObservation,onClick:e.onClick,onBodyHover:h?.onBodyHover}),at=zI({...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??WT(be.state,o),accessibleTable:J,enableHover:ee,margin:te}),ct=OI(V?(0,qT.jsx)(_T,{layout:pe.layout,phases:pe.phases,state:be.state,compact:q.compactMode||360>se[0]||260>se[1]}):void 0,h.backgroundGraphics),lt=OI(X?(0,qT.jsx)(NT,{rows:nt,layout:pe.layout,projection:tt,amountLabel:o}):void 0,h.foregroundGraphics),ut=(0,xR.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,CT.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,CT.jsx)("strong",{children:o.label}),(0,CT.jsx)("div",{style:{opacity:.78,fontSize:11,letterSpacing:"0.06em",textTransform:"uppercase"},children:r?"Product · "+o.status:"Source · "+o.status}),(0,CT.jsx)("div",{style:{marginTop:4},children:r?ST(o):kT(o)})]})}(e,xe.current.state),[]),dt=me?yT(pe,be.state,Ne.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=BI({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,qT.jsxs)("div",{className:U,role:"alert",style:{maxWidth:"100%",width:se[0]},children:[(0,qT.jsx)("strong",{children:"CrucibleChart could not compile this treatment tape."}),(0,qT.jsx)("ul",{children:gt.map((e,t)=>(0,qT.jsx)("li",{children:e.message},`${e.code}-${t}`))})]}):EI("CrucibleChart",se,(0,qT.jsxs)("div",{ref:ne,className:"semiotic-crucible-chart",style:{maxWidth:"100%",overflow:"hidden",position:"relative",width:D?"100%":se[0]},children:[pt?(0,qT.jsx)($T,{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,GT.createElement)(Gj,{...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??AT,responsiveHeight:$,responsiveWidth:!1,seed:OT(B),size:se,tooltipContent:rt.tooltipContent??ut})]}))});YT.displayName="CrucibleChart";var VT=require("react");function XT(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 UT(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 KT(e,t){return t>e?-1:e>t?1:0}function QT(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ZT(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function JT(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function e_(e,t,n={}){const o=new Set(n.completedTaskIDs??[]),r=[...XT(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 t_=[];function n_(e,t=0){if(e instanceof Date)return e.getTime();const n=Number(e);return Number.isFinite(n)?n:t}function o_(e){if(null==e.completionTime)return null;const t=n_(e.completionTime,NaN);return Number.isFinite(t)?t:null}function r_(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 i_(e,t,n,o){const r=e.nodes.map(o_).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=o_(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:r_(e,l,c,a),blockers:c,previewTaskID:null}}function s_(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 a_(e){const t=e.datum;return"dependency-ball"===t?.kind&&Array.isArray(t.route)?t:null}function c_(e){const t=a_(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 l_(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 u_=require("react/jsx-runtime");function d_({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,u_.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,u_.jsx)("defs",{children:(0,u_.jsx)("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:(0,u_.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,u_.jsxs)("g",{children:[(0,u_.jsx)("line",{x1:r,x2:r,y1:h,y2:s-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),(0,u_.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,u_.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,u_.jsxs)("g",{children:[(0,u_.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,u_.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,u_.jsxs)("g",{children:[(0,u_.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,u_.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,u_.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,u_.jsxs)("g",{opacity:d?.28:1,children:[(0,u_.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,u_.jsx)("circle",{cx:y-8,cy:i.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),(0,u_.jsxs)("g",{onPointerDown:()=>l(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[(0,u_.jsx)("rect",{x:y,y:f,width:i.width,height:i.height,fill:"transparent"}),(0,u_.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,u_.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 h_=require("react/jsx-runtime"),p_={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},m_=(0,VT.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:I,className:P,accessibleTable:R=!0,enableHover:T=!0}=e,_=(0,VT.useRef)(null),[L,N]=(0,VT.useState)([]),$=b?Array.from(b):L,D=(0,VT.useMemo)(()=>new Set($),[$]),B=n_(f,1/0),E="settle"===w,O=(0,VT.useMemo)(()=>function(e){const t=[],n=new Map,o=[],r=new Set;e.data.forEach((i,s)=>{const a=(UT(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=(UT(i,s,e.laneAccessor)??"Unassigned")+"";r.has(c)||(r.add(c),o.push(c));const l=UT(i,s,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,e=>e+""))).sort(KT),d=UT(i,s,e.blockerAccessor),h=UT(i,s,e.statusAccessor)??(d?"blocked":"waiting");n.set(a,{id:a,label:(UT(i,s,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:i,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:UT(i,s,e.startAccessor),end:UT(i,s,e.endAccessor),progress:JT(UT(i,s,e.progressAccessor)),status:h,completionTime:UT(i,s,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!UT(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:QT(o,e.id),sourceID:o,targetID:e.id,sourceIndex:i.index,targetIndex:e.index,socketID:ZT(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)=>KT(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=ZT(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>KT(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(KT);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(KT);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,VT.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)=>KT(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,VT.useState)(()=>i_(O,m,B,E)),W=(0,VT.useRef)(z),q=(0,VT.useCallback)(e=>{W.current=e,H(e)},[]),G=(0,VT.useCallback)(e=>x?.(e),[x]);(0,VT.useEffect)(()=>{const e=i_(O,m,B,E);_.current?.clear(),W.current=e,H(e)},[O,m,B,E]);const Y=(0,VT.useCallback)(e=>{const t=D.has(e)?$.filter(t=>t!==e):[e];b||N(t),v?.(t)},[b,v,D,$]),V=(0,VT.useCallback)(e=>{if(E)return;const t=s_(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(l_(o,e)))}n.length&&(q(t),_.current?.pushMany(n,{pacing:{ratePerSec:8}}))},[q,F,O,E]),X=(0,VT.useCallback)((e,t)=>{const n=O.byID.get(e),o=W.current;if(!n||o.completed.has(e))return;const r=s_(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,VT.useCallback)(e=>{const t=s_(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,VT.useCallback)((e,t)=>{const n=[],o=[];for(const e of t.readBodies()){const t=a_(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,VT.useCallback)(()=>{const e=s_(W.current);for(const t of O.edges)e.completed.has(t.sourceID)&&e.delivered.add(t.id);e.inFlight.clear(),e.armed=r_(O,e.delivered,e.blockers,e.completed),e.playing=!1,_.current?.settle(),q(e),G({type:"machine-settled"})},[q,G,O]),Z=(0,VT.useCallback)(()=>{const e=s_(W.current);e.playing=!1,q(e)},[q]),J=(0,VT.useCallback)(()=>{const e=W.current,t=O.nodes.map(e=>({node:e,time:o_(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=>e_(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,VT.useCallback)(()=>{if(E)return void Q();const e=s_(W.current);e.playing=!0,q(e)},[q,E,Q]);(0,VT.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,VT.useCallback)(()=>{_.current?.clear(),q(i_(O,m,B,E))},[q,O,m,B,E]),ne=(0,VT.useCallback)(e=>{if(!O.byID.has(e))return;const t=s_(W.current);t.previewTaskID=e,q(t);const n=e_(O,e,{completedTaskIDs:t.completed});G({type:"blocker-previewed",blockerID:e,downstreamTaskIDs:n.downstreamTaskIDs})},[q,G,O]),oe=(0,VT.useCallback)(()=>{const e=s_(W.current);e.previewTaskID=null,q(e)},[q]),re=(0,VT.useCallback)((e,t)=>{if(!O.byID.has(e))return;const n=s_(W.current);n.blockers.set(e,t),n.armed.delete(e),q(n)},[q,O]),ie=(0,VT.useCallback)(e=>{if(!O.byID.has(e))return;const t=s_(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,VT.useCallback)(e=>e_(O,e,{completedTaskIDs:W.current.completed}),[O]),ae=(0,VT.useCallback)(()=>{const e=W.current;return{currentTime:e.currentTime,playing:e.playing,previewTaskID:e.previewTaskID,selectedTaskIDs:[...$],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,$]);(0,VT.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??$[0]??null,le=ce?e_(O,ce,{completedTaskIDs:z.completed}):null,ue=(0,VT.useMemo)(()=>new Set(le?.downstreamTaskIDs??[]),[le?.downstreamTaskIDs]),de=(0,VT.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,VT.useMemo)(()=>(0,h_.jsx)(d_,{machine:O,layout:F,runtime:z,downstreamSet:ue,selectedSet:D,width:S,height:A,seed:k,reduced:E,onSelectTask:Y}),[ue,A,F,O,E,z,k,Y,D,S]),pe=(0,VT.useMemo)(()=>{const e=[...z.blockers.keys()].map(e=>e_(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,VT.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,h_.jsxs)("div",O.valid?{className:P,style:{width:S,maxWidth:"100%",position:"relative"},children:[ye.length>0&&(0,h_.jsx)("div",{"aria-label":"Chain reaction replay controls",style:{display:"flex",flexWrap:"wrap",gap:6,marginBottom:8},children:ye.map(e=>(0,h_.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,h_.jsx)(Gj,{ref:_,size:[S,A],responsiveWidth:C,responsiveHeight:M,title:j,description:I??"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:t_,bodyForces:c_,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,h_.jsxs)("table",{style:p_,children:[(0,h_.jsx)("caption",{children:pe}),(0,h_.jsx)("thead",{children:(0,h_.jsxs)("tr",{children:[(0,h_.jsx)("th",{children:"Task"}),(0,h_.jsx)("th",{children:"Lane"}),(0,h_.jsx)("th",{children:"Progress"}),(0,h_.jsx)("th",{children:"State"}),(0,h_.jsx)("th",{children:"Waiting on"}),(0,h_.jsx)("th",{children:"Downstream reach"})]})}),(0,h_.jsx)("tbody",{children:O.nodes.map(e=>{const t=e_(O,e.id,{completedTaskIDs:z.completed});return(0,h_.jsxs)("tr",{children:[(0,h_.jsx)("th",{scope:"row",children:e.label}),(0,h_.jsx)("td",{children:e.lane}),(0,h_.jsxs)("td",{children:[Math.round(100*e.progress),"%"]}),(0,h_.jsx)("td",{children:z.completed.has(e.id)?"Completed":z.blockers.has(e.id)?"Blocked":z.armed.has(e.id)?"Armed":"Waiting"}),(0,h_.jsx)("td",{children:z.blockers.get(e.id)??(e.dependencyIDs.filter(e=>!z.completed.has(e)).join(", ")||"None")}),(0,h_.jsxs)("td",{children:[t.downstreamTaskCount," tasks / ",t.affectedLaneCount," lanes"]})]},e.id)})})]})]}:{className:P,role:"alert",style:{width:S,maxWidth:"100%"},children:[(0,h_.jsx)("strong",{children:"ChainReactionChart could not compile this dependency graph."}),(0,h_.jsx)("ul",{children:O.diagnostics.map((e,t)=>(0,h_.jsx)("li",{children:e.message},`${e.code}-${t}`))})]})});m_.displayName="ChainReactionChart";var y_=require("react");function f_(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 g_(e,t,n){return`${t??""}${e}${n??""}`}var b_=require("react"),v_=require("react/jsx-runtime"),x_={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 w_(e,t,n){return void 0===e?n:"function"==typeof e?e(t):e}function k_(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function S_(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}var A_=(0,y_.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:I,borderColor:P,borderRadius:R,className:T,style:_,animate:L,stalenessThreshold:N,staleLabel:$,headerSlot:D,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=x_[w]??x_.tile,Z=k??Q.align,J=S??Q.width,ee=A??Q.height,te=pu(),ne=Uc(),[oe,re]=(0,y_.useState)([]),[ie,se]=(0,y_.useState)(null),[ae,ce]=(0,y_.useState)(null),[le,ue]=(0,y_.useState)(null),de=(0,y_.useRef)([]),he=(0,y_.useRef)(null),pe=(0,y_.useRef)(n);(0,y_.useEffect)(()=>{pe.current=n},[n]);const me=(0,y_.useRef)(x);(0,y_.useEffect)(()=>{me.current=x},[x]);const ye=(0,y_.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,y_.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,y_.useCallback)(e=>fe([e]),[fe]);(0,y_.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,y_.useMemo)(()=>f_(i??"number",{locale:s,currency:a,precision:c}),[i,s,a,c]),we=(0,y_.useMemo)(()=>f_(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,y_.useState)(()=>o),s=(0,y_.useRef)(o),a=(0,y_.useRef)(null),c=(0,y_.useRef)(e),l=(0,y_.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,y_.useRef)(e);return(0,y_.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,y_.useRef)(!Se||te||ne?Ae:0).current),Me=ke?Ce:Number.isFinite(be)?be:0,je=(0,y_.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]),Ie=je?je.level:"neutral",Pe=j??function(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}(Ie,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,Ne=(0,y_.useMemo)(()=>new Intl.NumberFormat(s??"en-US",{style:"percent",maximumFractionDigits:1,minimumFractionDigits:0,signDisplay:"exceptZero"}),[s]),$e=null!=Re&&Number.isFinite(be)&&(f??1)&&0!==Re?Ne.format((be-Re)/Math.abs(Re)):null,De=function({target:e,value:t,format:n,locale:o,currency:r,precision:i}){const s=(0,b_.useMemo)(()=>new Intl.NumberFormat(o??"en-US",{style:"percent",maximumFractionDigits:0}),[o]),a=(0,b_.useMemo)(()=>f_(e?.format??n??"number",{locale:o,currency:r,precision:i}),[e?.format,n,o,r,i]);return(0,b_.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=De?.percent??null,Ee=De?.text??null,Oe=function(e,t){const[n,o]=(0,y_.useState)(!1);return(0,y_.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,N),Fe=Number.isFinite(Me)?g_(xe(Me),l,u):"",ze={value:ve?null:be,formattedValue:Fe,level:Ie,color:Pe,delta:Te,deltaFormatted:Le,deltaPercent:$e,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)?g_(xe(be),l,u):"",unit:d,comparisonLabel:h?.label,delta:Te,deltaFormatted:Le,deltaPercent:$e,targetText:Ee,thresholdLabel:je?.label,stale:Oe,staleLabel:$}),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:I??Q.background,border:Q.border?"1px solid "+(P??"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,y_.useCallback)(e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top,r={value:ve?NaN:be,level:Ie,delta:Te};W&&W(r,{x:n,y:o}),q&&q({type:"click",datum:r,x:n,y:o,chartType:"BigNumber",chartId:G,timestamp:Date.now()})},[W,q,G,ve,be,Ie,Te]),Ve="inline"===w?"span":"div",Xe=["semiotic-bignumber","semiotic-bignumber--mode-"+w,"semiotic-bignumber--level-"+Ie,"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,v_.jsx)(Ve,{role:"status","aria-live":"polite","aria-busy":"true",className:Xe+" semiotic-bignumber--loading",style:{...Ge,opacity:1},children:U??(0,v_.jsx)(M_,{width:e,height:t,mode:w})})}return ve?!1===K?null:(0,v_.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,v_.jsx)(jp,{componentName:"BigNumber",width:"number"==typeof J?J:280,height:"number"==typeof ee?ee:160,children:(0,v_.jsxs)(Ve,{role:"group","aria-label":He,"data-chart":"BigNumber","data-mode":w,"data-level":Ie,"data-stale":Oe?"true":void 0,"data-sentiment":_e,className:Xe,style:Ge,onClick:W||q?Ye:void 0,children:[Q.showHeader&&(o||r||D)?(0,v_.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:w_(D,ze,(0,v_.jsxs)(v_.Fragment,{children:[o?(0,v_.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,v_.jsx)("span",{className:"semiotic-bignumber__caption",style:{fontSize:Q.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:r}):null]}))}):null,w_(B,ze,(0,v_.jsxs)(Ve,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Ie,style:{display:"inline"===w?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Pe,fontSize:Q.valueSize||void 0,lineHeight:1.05},children:[(0,v_.jsx)("span",{className:"semiotic-bignumber__value-text",children:Fe}),d?(0,v_.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||De||h)?(0,v_.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:w_(E,ze,(0,v_.jsxs)(v_.Fragment,{children:[Le?(0,v_.jsxs)("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+Ue,style:{display:"inline-flex",alignItems:"center",gap:4,color:k_(_e),fontWeight:600},children:[(0,v_.jsx)("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+Ue,children:S_(_e)}),(0,v_.jsx)("span",{className:"semiotic-bignumber__delta-amount",children:Le}),$e?(0,v_.jsxs)("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",$e,")"]}):null]}):null,h?.label?(0,v_.jsx)("span",{className:"semiotic-bignumber__comparison-label",children:h.label}):null,De?(0,v_.jsxs)("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[Le||h?.label?(0,v_.jsx)("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,(0,v_.jsx)("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:Be}),(0,v_.jsxs)("span",{className:"semiotic-bignumber__target-value",children:["of ",De.formattedValue,De.label?" "+De.label:""]})]}):null]}))}):null,Q.showChart&&null!=F?(0,v_.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,v_.jsx)("div",{style:{pointerEvents:"auto",lineHeight:0},children:w_(F,ze,null)})}):null,Q.showTrend&&null!=O?(0,v_.jsx)("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:We.left,right:We.right,bottom:We.bottom+(null!=H?28:0)},children:w_(O,ze,null)}):null,null!=H?(0,v_.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:w_(H,ze,null)}):null,V?(0,v_.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]})})});A_.displayName="BigNumber";var C_=A_;function M_(e){const t=Math.floor(.45*e.width),n=Math.floor(.6*e.width),o=(e,t)=>(0,v_.jsx)("div",{style:{width:e,height:t,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return(0,v_.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[j_,I_]=jt(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));async function P_(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"),R_(s,a),"svg"===n){const e=(new XMLSerializer).serializeToString(a);T_(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?(T_(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 R_(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++)R_(n[e],o[e])}function T_(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 __=d(require("react")),L_=["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"],N_=new Set(L_);function $_(e){return N_.has(e)}var D_=["value","threshold","partition-boundary","time-window","range-boundary"];function B_(e,t,n,o,r){return{id:e,...t?{controlId:t}:{},status:n,message:o,...r?{remediation:r}:{}}}function E_({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=D_.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(B_(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(B_(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(B_(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(B_(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(B_(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(B_(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(B_(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(B_(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(B_(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 O_(e){return F_(e),e}function F_(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=E_({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(!z_(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(!H_(t))throw Error(`Portable chart recipe "${e.id}" has a layout config schema that is not JSON-safe.`)}}function z_(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function H_(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=>H_(e,t)):Object.entries(e).every(([,e])=>H_(e,t));return t.delete(e),o}function W_(e){return"string"==typeof e?e:e.id??e.name}function q_(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 G_(e){const t=new Set(e.intents.map(W_));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 Y_(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 V_(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 X_(e,t,n){return V_(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,n))}function U_(e,t,n){if(t.field&&X_(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&&X_(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=V_(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 K_(e){const t={},n=[];for(const o of e.intents){const e=W_(o);e&&(t[e]=q_(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:G_(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:Y_(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&&!U_(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=U_(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 Q_=Symbol.for("semiotic.chartRecipeRegistry");function Z_(){const e=globalThis;return e[Q_]||(e[Q_]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[Q_]}function J_(e){F_(e),Z_().recipes.set(e.id,e),Z_().capabilities.set(e.id,K_(e))}function eL(e){Z_().recipes.delete(e),Z_().capabilities.delete(e)}function tL(e){return Z_().recipes.get(e)}function nL(){return Array.from(Z_().recipes.values())}function oL(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.`);Z_().layouts.set(e,t)}function rL(e){Z_().layouts.delete(e)}function iL(e){return Z_().layouts.get(e)}function sL(e){return"string"==typeof e?tL(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}function aL(e){return"string"==typeof e?e:e.id??e.name}function cL(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function lL(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 uL(e,t,n){return n??sL(t.recipe)??sL(t.recipeId)??tL(e)}function dL(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 hL(e,t){return e.dataRoles.find(e=>e.role===t)}function pL(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function mL(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=dL(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 yL="1",fL=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"]),gL=new Set(["data","nodes","edges","points","areas","lines","flows"]);function bL(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(bL).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=bL(o);void 0!==e&&(t[n]=e)}return t}function vL(e,t){return!!gL.has(e)&&("areas"!==e||"string"!=typeof t)}var xL="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function wL(e,t,n){const o=tL(e)??sL(t.recipe)??sL(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&&!fL.has(r)&&"recipeId"!==r&&(t||!vL(r,i)))if("function"==typeof i||i?.$$typeof){if(n)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`)}else if(H_(i))o[r]=xL(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(aL).filter(e=>!!e),i={name:e.name,intents:r,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!H_(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:yL,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:yL,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}(o,t,n);if(!$_(e))throw Error(`Unknown component "${e}". Known components: ${L_.join(", ")}`);const r=!1!==n?.includeData,i={};for(const[e,n]of Object.entries(t))if(null!=n&&!fL.has(e)&&(r||!vL(e,n))&&"function"!=typeof n&&!n?.$$typeof)try{i[e]=xL(bL(n))}catch{}return{component:e,props:i,version:yL,createdAt:(new Date).toISOString(),...n?.selections?{selections:n.selections}:{}}}function kL(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=tL(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:{...xL(e.props),recipeId:e.recipeId}}}if(!$_(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:xL(e.props)}}function SL(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function AL(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 CL(e,t="json"){const n="jsx"===t?ML(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 ML(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 jL=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),IL=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),PL=new Set(["PieChart","DonutChart","FunnelChart"]),RL=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function TL(e,t){return IL.has(e)||PL.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 _L(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function LL(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}function NL(e,t,n={}){const o=lL(t),r=cL(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=pL(e,["nominal","ordinal"]),i=pL(e,["quantitative"]),s=r?dL(r,n,t):void 0,a=i?dL(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:aL(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 $L={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"},DL=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),BL=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function EL(e){return $L[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function OL(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var FL=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),zL={"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"},HL={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},WL=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],qL={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function GL(e){return zL[e]}function YL(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=WL.indexOf(o),n=WL.indexOf(t);-1===e||-1!==n&&e>=n||(t=o)}return t}(n.intentScores);if(e&&zL[e]&&(n.intentScores[e]??0)>=3)return zL[e]}return n?.family?HL[n.family]:function(e){return PL.has(e)||"StackedAreaChart"===e?"apportioning":FL.has(e)?"relating":IL.has(e)?"comparing":RL.has(e)?"characterizing":jL.has(e)?"tracking":DL.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var VL=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),XL=new Set(["system","agent","watcher"]),UL=new Set(["ai","agent","system","computed","dbt","great-expectations"]),KL=new Set(["rule","statistical-test","llm-inference","computed"]);function QL(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||!VL.has(t.type))return!1;const n=t.provenance;return!(!n||"object"!=typeof n)&&(XL.has(n.authorKind)||UL.has(n.source)||KL.has(n.basis))})}function ZL(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 JL={"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 eN(e){const t=JL["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 tN(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(eN),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 nN(e,t,n={}){const o=void 0!==n.levels,r=new Set(n.levels??["l1","l2","l3"]);o||!n.capability&&!QL(t)||r.add("l4");const i=uL(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=NL(i,t,{levels:e,locale:n.locale,audience:n.audience,includeCaveats:n.includeCaveats}),a=tN(t);return{...s,text:a?`${a} ${s.text}`.trim():s.text,...a?{annotations:a}:{}}}const s=ZL(n.locale??"en"),a=EL(e),c=Array.isArray(t.data)?t.data:null,l=_L(t),u=BL.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=OL(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=OL(o.secondary??o.secondaryCount),a=OL(o.observed??o.observedCount);return{label:LL(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}=TL(e,t),y="string"==typeof d&&d?d:h,f="string"==typeof p&&p?p:m,g={};if(BL.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)} ${rN(c,a)} across ${n.length} ${rN(n.length,s)}; no ${rN(2,s)} are non-empty yet.`;else{const e=d>0?` ${i(d)} ${rN(d,a)} ${1===d?"is":"are"} marked ${h}.`:"";o.l2=`The settled projection contains ${i(c)} ${rN(c,a)} across ${n.length} ${rN(n.length,s)}; ${l.length} ${rN(l.length,s)} ${1===l.length?"is":"are"} non-empty. The largest ${s} is ${u.label} with ${i(u.count)} ${rN(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)} ${rN(u.count,a)} (${t}); ${e.label} follows with ${i(e.count)} ${rN(e.count,a)}.`:`The settled projection is concentrated in ${u.label}, which holds all ${i(u.count)} ${rN(u.count,a)}.`}}(e,a,u,g,r,s),r.has("l1")&&!BL.has(e))if(jL.has(e)||IL.has(e))g.l1=`A ${a} of ${y} by ${f}`+(l?`, split by ${l}.`:".");else if(PL.has(e))g.l1=`A ${a} showing ${y} across ${f} categories.`;else if(RL.has(e))g.l1=`A ${a} of the distribution of ${y}`+(l?` by ${l}.`:".");else if(DL.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} ${rN(e,"node")}`:null,null!=n?`${n} ${rN(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=jL.has(e)||IL.has(e)||PL.has(e)||RL.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:LL(null!=c?n(c):null,o),maxLabel:LL(null!=l?n(l):null,o),first:m,last:y,firstLabel:LL(null!=h?n(h):null,o),lastLabel:LL(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=PL.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&&jL.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`${oN(t)} is constant at ${n(o)} across the series.`;if(.04>m/(Math.abs(e.mean)||1))return`${oN(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?`${oN(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&&IL.has(e)&&(g.l3=`The highest ${f} is ${v.maxLabel} and the lowest is ${v.minLabel}.`),r.has("l4")){const o=QL(t)?"alerting":YL(e,n.capability);o&&(g.l4=function(e,t,n,o,r,i,s,a){const c=qL[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(IL.has(n)||PL.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 ${EL(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=tN(t);return{text:w?`${w} ${x}`.trim():x,levels:g,...w?{annotations:w}:{}}}function oN(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function rN(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function iN(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function sN(e,t,n={}){const o=lL(t),r=cL(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?hL(e,s.groupByRole):void 0)??(s?.groupBy?.[0]?hL(e,s.groupBy[0])??e.dataRoles.find(e=>e.field===s.groupBy?.[0]):void 0)??pL(e,["nominal","ordinal"]),l=c?dL(c,r,o):void 0,u=(s?.idRole?hL(e,s.idRole):void 0)??pL(e,["identifier"]),d=u?dL(u,r,o):void 0,h={id:"root",role:"chart",label:s?.summaryTemplate?mL(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?mL(s.itemLabelTemplate,t,e,r,o,{count:o.length}):function(e,t,n,o){const r=pL(t,["nominal","ordinal"]),i=t.dataRoles.filter(e=>"quantitative"===e.semanticType),s=r?dL(r,n,o):void 0,a=[];s&&null!=e[s]&&a.push(e[s]+"");for(const t of i){const r=dL(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-"+iN(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-"+iN(e),role:"datum",label:`…and ${t.length-o.length} more items`,level:3}),{id:"group-"+iN(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 aN(e,t,n={}){const o=n.locale??"en",r=Math.max(1,n.maxLeaves??200),i=ZL(o),s=uL(e,t,n.recipe);if(s)return sN(s,t,{maxLeaves:r,locale:o});const a={id:"root",role:"chart",label:nN(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=eN(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=jL.has(e)||IL.has(e)||PL.has(e)||RL.has(e);if(!l||0===l.length||!u)return c&&(a.children=[c]),a;const{measure:d,measureFallback:h,dimension:p,dimensionFallback:m}=TL(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=_L(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=LL(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(jL.has(e)||IL.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)}`:`${LL(u[0],i)} to ${LL(u[u.length-1],i)} (${IL.has(e)?u.length+" categories":l.length+" points"})`;S.push({id:w("axis"),role:"axis",level:2,label:`${IL.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=nN(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 cN(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 lN(e){let t=1;if(e.children)for(const n of e.children)t+=lN(n);return t}var uN=d(require("react")),dN=null,hN=new Set,pN=new Set,mN="semiotic:conversation-arc",yN="semiotic-conversation-arc",fN="events",gN=1e3;function bN(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 vN(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function xN(e,t){try{const n=t();n&&"function"==typeof n.then&&Promise.resolve(n).catch(t=>vN(e,t))}catch(t){vN(e,t)}}function wN(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function kN(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 vN("localStorage load",e),[]}}(e.getItem(t))}catch(e){return vN("localStorage read",e),[]}}var SN=Object.freeze([]),AN=SN,CN=!1;function MN(){return CN?(AN=dN?Object.freeze(dN.buffer.slice()):SN,CN=!1,AN):AN}function jN(){CN=!0}var IN=new Set;function PN(){for(const e of IN)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function RN(e){return IN.add(e),()=>{IN.delete(e)}}function TN(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return pN.add(e),()=>{pN.delete(e)}}function _N(e={}){const t=e.key??mN,n=bN(e.maxEvents,gN,"createLocalStorageConversationArcSink: maxEvents");return{record(o){const r=wN(e.storage),i=kN(r,t);i.push(o),function(e,t,n,o){if(e)try{e.setItem(t,JSON.stringify(n.slice(-o)))}catch(e){vN("localStorage write",e)}}(r,t,i,n)},clear(){const n=wN(e.storage);if(n)try{n.removeItem(t)}catch(e){vN("localStorage clear",e)}},load:()=>kN(wN(e.storage),t)}}function LN(e={}){const t=e.dbName??yN,n=e.storeName??fN,o=bN(e.maxEvents,gN,"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 vN("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=()=>{vN("IndexedDB open",r.error),n(null)},r.onblocked=()=>{vN("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=()=>{vN("IndexedDB record",r.error),o()}}catch(e){vN("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=()=>vN("IndexedDB trim",s.error),r.oncomplete=()=>o(),r.onerror=()=>{vN("IndexedDB trim",r.error),o()}}catch(e){vN("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=()=>{vN("IndexedDB clear",o.error),t()}}catch(e){vN("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=()=>{vN("IndexedDB load",o.error),n([])}}catch(e){vN("IndexedDB load",e),n([])}}):Promise.resolve([])}(await i(),n)}}function NN(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 $N(e,t={}){const n=Array.isArray(e)?e.slice():[],o=bN(t.capacity,Math.max(dN?.capacity??gN,n.length,1),"loadConversationArc: capacity"),r=t.sessionId??n[0]?.sessionId??dN?.sessionId??ON();for(dN?(dN.enabled=t.enabled??!1,dN.sessionId=r,dN.capacity=o):dN={enabled:t.enabled??!1,sessionId:r,capacity:o,buffer:[]},t.append||(dN.buffer=[]),dN.buffer.push(...n);dN.buffer.length>dN.capacity;)dN.buffer.shift();return jN(),PN(),MN()}function DN(e,t={}){return $N(e,t)}function BN(e,t,n){return qN.record({type:"audience-set",audience:e,previous:t??void 0,...n})}function EN(e,t){return qN.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function ON(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function FN(){return dN}function zN(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(dN){if(dN.enabled=!0,e.sessionId&&(dN.sessionId=e.sessionId),null!=e.capacity){for(dN.capacity=t;dN.buffer.length>dN.capacity;)dN.buffer.shift();jN()}}else dN={enabled:!0,sessionId:e.sessionId??ON(),capacity:t,buffer:[]},jN();return PN(),qN}function HN(){dN&&(dN.enabled=!1,PN())}function WN(){return qN}var qN={get enabled(){return dN?.enabled??!1},get sessionId(){return dN?.sessionId??null},get capacity(){return dN?.capacity??0},record(e){const t=FN();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();jN(),PN();for(const e of hN)try{e(n)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of pN)t.record&&xN("sink record",()=>t.record?.(e))}(n),n},flush(){const e=FN();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],jN(),PN(),function(e){for(const t of pN)t.flush&&xN("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>MN(),subscribe:e=>(hN.add(e),()=>{hN.delete(e)}),clear(){const e=FN();e&&(e.buffer=[],jN(),PN()),function(){for(const e of pN)e.clear&&xN("sink clear",()=>e.clear?.())}()},reset(){if(hN.clear(),pN.clear(),AN=SN,CN=!1,!dN)return PN(),void IN.clear();dN.buffer=[],dN.enabled=!1,dN=null,PN(),IN.clear()}},GN=require("react/jsx-runtime"),YN={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function VN({tree:e,label:t,visible:n=!1,className:o,onActiveChange:r,activeId:i,chartId:s,onObservation:a,onAnnotationActivate:c}){const[l,u]=uN.useState(()=>new Set([e.id])),[d,h]=uN.useState(e.id),p=void 0!==i,m=p?i:d,y=uN.useRef(null),f=uN.useRef(new Map),g=Vs(e=>e.pushObservation),b=uN.useCallback(e=>{a?.(e),g?.(e)},[a,g]),v=uN.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=uN.useMemo(()=>cN(e,l),[e,l]);uN.useEffect(()=>{p||x.some(e=>e.id===d)||h(e.id)},[x,d,e.id,p]),uN.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]),uN.useEffect(()=>{y.current?.contains(document.activeElement)&&f.current.get(m)?.focus()},[m]);const w=uN.useCallback((e,t,n)=>{const o=WN();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=uN.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=uN.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,GN.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,GN.jsxs)("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[n&&r?i?"▾ ":"▸ ":"",e.label]}),r&&i&&(0,GN.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,GN.jsx)("div",{ref:y,className:"semiotic-nav-tree"+(o?" "+o:""),style:n?void 0:YN,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,GN.jsx)("ul",{role:"tree","aria-label":t||"Chart navigation",style:n?{margin:0,padding:0}:void 0,children:M(e,1,1)})})}var XN=d(require("react")),UN=require("react/jsx-runtime");function KN(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 QN(e,t,n,o=1,r=o){const i="in"===n?o:-o;return KN([e[0]+i,e[1]-i],t,r)}function ZN(e){const{domain:t,initialValue:n=t,step:o=1,minSpan:r=o,label:i,formatValue:s,onChange:a}=e,[c,l]=XN.useState(()=>KN(n,t,r)),u=KN(c,t,r),d=XN.useCallback(e=>{const n=KN(e,t,r);l(n),a?.(n)},[t,r,a]),h=XN.useMemo(()=>({label:i,domain:t,value:u,step:o,formatValue:s,onChange:d,onClear:()=>d(t)}),[t,s,i,d,o,u]),p=XN.useMemo(()=>({onZoomIn:()=>d(QN(u,t,"in",o,r)),onZoomOut:()=>d(QN(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 JN={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)))"},e$={fontSize:11,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #57606a)"};function t$(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 n$(e){return"function"==typeof e}function o$({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,UN.jsxs)("section",{style:JN,"aria-label":"Brush controls",children:[(0,UN.jsx)("div",{style:e$,children:e?.label??"Filter range"}),r?(0,UN.jsxs)("div",{style:{display:"grid",gap:8},children:[(0,UN.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12},children:[(0,UN.jsxs)("span",{children:["Start: ",s(u)]}),(0,UN.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,UN.jsxs)("label",{style:{display:"grid",gap:4,fontSize:12},children:[(0,UN.jsxs)("span",{children:["End: ",s(d)]}),(0,UN.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,UN.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,UN.jsx)("button",{type:"button",disabled:i||!n$(e?.onClear),onClick:e?.onClear,style:t$(t),children:"Clear range"})]})}function r$({zoom:e,targetSize:t}){const n=!0===e?.disabled;return(0,UN.jsxs)("section",{style:JN,"aria-label":"Zoom controls",children:[(0,UN.jsx)("div",{style:e$,children:e?.label??"Zoom"}),(0,UN.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,UN.jsx)("button",{type:"button","aria-label":"Zoom out",disabled:n||!n$(e?.onZoomOut),onClick:e?.onZoomOut,style:t$(t),children:"-"}),(0,UN.jsx)("button",{type:"button","aria-label":"Reset zoom",disabled:n||!n$(e?.onReset),onClick:e?.onReset,style:t$(t),children:"Reset"}),(0,UN.jsx)("button",{type:"button","aria-label":"Zoom in",disabled:n||!n$(e?.onZoomIn),onClick:e?.onZoomIn,style:t$(t),children:"+"})]})]})}function i$({legend:e,targetSize:t}){const n=!0===e?.disabled,o=e?.items??[];return(0,UN.jsxs)("section",{style:JN,"aria-label":"Legend controls",children:[(0,UN.jsx)("div",{style:e$,children:e?.label??"Series"}),o.length>0&&(0,UN.jsx)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:o.map(o=>{const r=!1!==o.active;return(0,UN.jsxs)("button",{type:"button",disabled:n||o.disabled||!e?.onToggle,onClick:()=>e?.onToggle?.(o.id,!r),style:t$(t,r),"aria-pressed":r,children:[o.color&&(0,UN.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,UN.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[(0,UN.jsx)("button",{type:"button",disabled:n||!n$(e?.onShowAll),onClick:e?.onShowAll,style:t$(t),children:"Show all"}),(0,UN.jsx)("button",{type:"button",disabled:n||!n$(e?.onHideAll),onClick:e?.onHideAll,style:t$(t),children:"Hide all"})]})]})}function s$({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,UN.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,UN.jsx)(o$,{brush:s,targetSize:t}),l.includes("zoom")&&(0,UN.jsx)(r$,{zoom:a,targetSize:t}),l.includes("legend")&&(0,UN.jsx)(i$,{legend:c,targetSize:t})]})}var a$=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),c$=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),l$=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),u$=new Set(["LineChart","AreaChart","StackedAreaChart"]),d$=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]),h$=new Set(["LineChart","AreaChart","StackedAreaChart","ConnectedScatterplot"]),p$=new Set(["PieChart","DonutChart"]),m$={PieChart:"valueAccessor",DonutChart:"valueAccessor",FunnelChart:"valueAccessor"},y$=new Set(Object.keys(m$)),f$={StackedBarChart:"valueAccessor",StackedAreaChart:"yAccessor"},g$=new Set(["BigNumber"]),b$=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),v$=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),x$=new Set(["StreamPhysicsFrame","GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]),w$=new Set(["OrbitDiagram",...x$]),k$=new Set(["GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart"]),S$=new Set(["GaltonBoardChart","EventDropChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]),A$=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),C$=new Set(["MultiAxisLineChart"]),M$=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),j$={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},I$="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.",P$=new Set([...b$,"RealtimeLineChart","RealtimeHeatmap"]),R$=Object.fromEntries(Object.entries(j$).map(([e,t])=>[e,[t,"hoverRadius"]]));function T$(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function _$(e){return"string"==typeof e&&e.trim().length>0}function L$(e){const t=T$(e.capability)?e.capability:null,n=T$(e.recipe)?e.recipe:null,o=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,n?.mobile];for(const e of o)if(T$(e))return e;return null}function N$(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 $$(e){return N$(e.size)||N$(T$(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function D$(e,t){e.push({...t,status:"pass"})}function B$(e,t){e.push({...t,status:"warn"})}function E$(e,t){e.push({...t,status:"manual"})}function O$(e,t={},n={}){const o=n.viewportWidth??390,r=n.targetSize??44,i=$$(t),s=Nh(t,{width:o,height:i?.[1]}),a=[],c=$$(t=s.props),l=L$(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=L$(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=_$(t.title)||_$(t.summary)||_$(t.description)||!0===l?.summary||_$(l?.summary);if(s.matches.length>0&&D$(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?B$(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."}):D$(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&&B$(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&&B$(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&&B$(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 E$(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,T$(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:P$.has(e)?1.25*o:v$.has(e)?Math.max(8,Math.floor(o/34)):o)?B$(a,{id:"density.mark-budget",category:"density",impact:P$.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."}):D$(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&&B$(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&&(P$.has(e)||v$.has(e))&&E$(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=T$(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=L$(e),n=T$(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||_$(t?.interaction?.hoverFallback)}(e)}(t)?D$(a,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):B$(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=R$[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=T$(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?B$(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?B$(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."}):D$(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=L$(e),o=T$(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)&&B$(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||B$(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=>T$(e)):[];if(w.length>("number"==typeof l?.maxAnnotations?l.maxAnnotations:3)&&430>=o&&B$(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=>!_$(e.mobileText)&&!_$(e.shortText)&&!_$(e.label));e.length>0&&E$(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||E$(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?(D$(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?B$(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&&E$(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."})):E$(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||B$(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:I$}}var F$={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},z$=["layout","density","interaction","annotation","semantics"];function H$(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 z$){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(` ${F$[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 W$(){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 q$,G$=d(require("react")),Y$=[];function V$(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function X$(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function U$(e){return Array.isArray(e)?e.length>0:!!e}var K$=require("react/jsx-runtime"),Q$={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Z$(){const e=function(){const e=cl.useContext(ul);return e?e.toggle:null}();return e?(0,K$.jsx)("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:cD,children:(0,K$.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,K$.jsx)("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),(0,K$.jsx)("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),(0,K$.jsx)("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var J$={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)"},eD={error:4,warning:3,info:2,success:1,neutral:0};function tD({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,K$.jsxs)("svg",{...t,children:[(0,K$.jsx)("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),(0,K$.jsx)("path",{d:"M8 6.4v3.4"}),(0,K$.jsx)("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return(0,K$.jsxs)("svg",{...t,children:[(0,K$.jsx)("circle",{cx:"8",cy:"8",r:"6.4"}),(0,K$.jsx)("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return(0,K$.jsxs)("svg",{...t,children:[(0,K$.jsx)("circle",{cx:"8",cy:"8",r:"6.4"}),(0,K$.jsx)("path",{d:"M8 7.4V11"}),(0,K$.jsx)("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return(0,K$.jsxs)("svg",{...t,children:[(0,K$.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,K$.jsx)("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function nD({notification:e,level:t,onDismiss:n}){const o=J$[t]??J$.info,r=!1!==e.dismissible;return(0,K$.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,K$.jsxs)("div",{style:{flex:1,minWidth:0},children:[e.source&&(0,K$.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,K$.jsx)("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:o},children:e.title}),(0,K$.jsx)("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),r&&(0,K$.jsx)("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:n,style:{...cD,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function oD({visible:e,onDismiss:t}){const[n,o]=__.useState(!1),r=__.useRef(null),i=__.useRef(null);if(__.useEffect(()=>{0===e.length&&n&&o(!1)},[e.length,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)=>eD[t.level]>eD[e]?t.level:e,e[0].level),a=J$[s]??J$.info,c=e.length,l=`${c} chart notification${1===c?"":"s"}, most severe: ${s}`;return(0,K$.jsxs)("div",{ref:r,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[(0,K$.jsx)("span",{style:Q$,role:"status","aria-live":"polite",children:l}),(0,K$.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:{...cD,color:a,position:"relative"},children:[(0,K$.jsx)(tD,{level:s}),(0,K$.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,K$.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,K$.jsx)(nD,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var rD={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 iD({height:e}){return(0,K$.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 sD({error:e}){return(0,K$.jsx)("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:(0,K$.jsx)("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var aD=__.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=__.useRef(null),C=__.useRef(null),[M,j]=__.useState(!1),I=function(e,t){const[n,o]=G$.useState(Y$),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 G$.useEffect(()=>{let e=!0;return s&&r&&i?((q$??(q$=Promise.resolve().then(()=>(ht(),lt)).catch(e=>{throw q$=void 0,e})),q$).then(({buildChartDataAuditNotifications:t})=>{e&&o(t({component:r,props:i},{checkOutliers:a,errorsOnly:c,max:l}))}).catch(()=>{e&&o(Y$)}),()=>{e=!1}):(o(e=>0===e.length?e:Y$),()=>{e=!1})},[a,r,s,c,l,i]),n}(s,h),P=__.useMemo(()=>[...d??[],...I],[d,I]),[R,T]=__.useState(()=>new Set);__.useEffect(()=>{T(e=>{if(0===e.size)return e;const t=new Set(P.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})},[P]);const _=__.useMemo(()=>P.map((e,t)=>({notification:e,index:t,key:e.id??t+"",level:e.level??"info"})).filter(({key:e})=>!R.has(e)),[P,R]),L=__.useCallback(e=>{T(t=>new Set(t).add(e.key)),p?.(e.notification,e.index)},[p]),N=!1!==i?.export&&void 0!==i?.export,$=!1!==i?.fullscreen&&void 0!==i?.fullscreen,D=!1!==i?.copyConfig&&void 0!==i?.copyConfig&&s,B=!0===i?.dataSummary,E=__.useMemo(()=>{if(!a||!s?.component||!s?.props)return"";const e="object"==typeof a?a.levels:void 0;try{return nN(s.component,s.props,e?{levels:e}:{}).text}catch{return""}},[a,s]),O="object"==typeof a&&!0===a.visible,F=__.useMemo(()=>{if(!c||!s?.component||!s?.props)return null;const e="object"==typeof c?c.maxLeaves:void 0;try{return aN(s.component,s.props,e?{maxLeaves:e}:{})}catch{return null}},[c,s]),z="object"==typeof c&&!0===c.visible,H=__.useMemo(()=>"object"==typeof i?.export?i.export:{},[i?.export]),W="object"==typeof i?.copyConfig?i.copyConfig.format:"json",q=__.useCallback(async e=>{C.current&&await P_(C.current,{...H,...e})},[H]),G=__.useCallback(()=>{A.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):A.current.requestFullscreen().catch(()=>{}))},[]),Y=__.useCallback(async e=>{s&&await CL({...s,version:s.version??"1",createdAt:s.createdAt??(new Date).toISOString()},e||W||"json")},[s,W]);__.useEffect(()=>{const e=()=>{j(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),__.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=V$(J)?J:null,te=ee?.controls??(V$(J)?void 0:J)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(Z),ne=__.useMemo(()=>function(e,t){return U$(t)?e&&"object"==typeof e?{...e,standardControls:t}:!1===e||null==e?e:{standardControls:t}:e}(Z,te),[Z,te]),oe=X&&U$(te)?(0,K$.jsx)(s$,{controls:te,targetSize:ee?.targetSize??X$(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=__.useMemo(()=>{if(!x||!s?.component||!s?.props)return null;const e="object"==typeof x?x:{},t=s.props;try{return O$(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]);__.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,K$.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||N||$||D||B||g||le,de=__.useMemo(()=>{if(!X||!__.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?__.cloneElement(n,t):n},[n,X,K,Q,ne]),he=m?(0,K$.jsx)(iD,{height:r}):y?(0,K$.jsx)(sD,{error:y}):f?(0,K$.jsx)(Ap,{children:de}):de;return pe=(0,K$.jsxs)(K$.Fragment,{children:[(0,K$.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,K$.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,K$.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,K$.jsxs)("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[e&&(0,K$.jsx)("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:e}),t&&(0,K$.jsx)("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:e?2:0},children:t})]}),(0,K$.jsxs)("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[l,le&&(0,K$.jsx)(oD,{visible:_,onDismiss:L}),N&&(0,K$.jsx)("button",{className:"semiotic-chart-action",onClick:()=>q(),title:"Export chart","aria-label":"Export chart",style:cD,children:(0,K$.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,K$.jsx)("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),(0,K$.jsx)("path",{d:"M2 12h10"})]})}),B&&(0,K$.jsx)(Z$,{}),$&&(0,K$.jsx)("button",{className:"semiotic-chart-action",onClick:G,title:M?"Exit fullscreen":"Fullscreen","aria-label":M?"Exit fullscreen":"Enter fullscreen",style:cD,children:(0,K$.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,K$.jsxs)(K$.Fragment,M?{children:[(0,K$.jsx)("path",{d:"M9 1v4h4"}),(0,K$.jsx)("path",{d:"M5 13V9H1"}),(0,K$.jsx)("path",{d:"M13 5H9V1"}),(0,K$.jsx)("path",{d:"M1 9h4v4"})]}:{children:[(0,K$.jsx)("path",{d:"M1 5V1h4"}),(0,K$.jsx)("path",{d:"M13 9v4H9"}),(0,K$.jsx)("path",{d:"M9 1h4v4"}),(0,K$.jsx)("path",{d:"M5 13H1V9"})]})})}),D&&(0,K$.jsx)("button",{className:"semiotic-chart-action",onClick:()=>Y(),title:"Copy config","aria-label":"Copy chart configuration",style:cD,children:(0,K$.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,K$.jsx)("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),(0,K$.jsx)("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),g&&(0,K$.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:rD[g].bg,color:rD[g].color,lineHeight:"18px"},children:g})]})]}),u&&(0,K$.jsx)("div",{className:"semiotic-chart-banner",children:u}),ce,re&&(0,K$.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,K$.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,K$.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)"}:Q$,children:E}),F&&(0,K$.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,K$.jsx)(VN,{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,K$.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,K$.jsx)(dl,{children:pe}):pe;var pe}),cD={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},lD=d(require("react")),uD=require("react/jsx-runtime");function dD({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]=lD.useState(()=>l??c.find(e=>!e.disabled)?.id),[w,k]=lD.useState(m);lD.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=lD.useCallback(e=>{e.disabled||(void 0===l&&x(e.id),u?.(e))},[l,u]),C=c.length?(0,uD.jsx)("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:c.map(e=>(0,uD.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,uD.jsx)("span",{children:e.label}),e.description&&(0,uD.jsx)("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,M=a||C?(0,uD.jsxs)("div",{className:"semiotic-mobile-summary-card",children:[a&&(0,uD.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},I=lD.useMemo(()=>{if(!g||!lD.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?lD.cloneElement(e,n):e},[e,g]),P=!!d&&"sheet"===p,R=!!d&&"inline"===p||P&&w,T=P?(0,uD.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,uD.jsxs)("div",{className:"semiotic-mobile-control-stack",children:[t,T]}):void 0;return(0,uD.jsxs)("div",{className:"semiotic-mobile-chart-shell",children:[(0,uD.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,uD.jsx)(aD,{...b,controls:_,mobile:j,children:I}),R&&(0,uD.jsxs)("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof h?h:"Chart details",children:[(0,uD.jsxs)("div",{className:"semiotic-mobile-detail-header",children:[(0,uD.jsx)("span",{children:h}),P&&(0,uD.jsx)("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),(0,uD.jsx)("div",{className:"semiotic-mobile-detail-body",children:d})]})]})}var hD=d(require("react")),pD=require("react/jsx-runtime");function mD(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function yD(e,t){const n="function"==typeof t?t(e):e[t];return Array.isArray(n)?n:[]}function fD(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 gD(e,t){if(!hD.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?hD.cloneElement(e,o):e}function bD({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:I,style:P}){const R=Zh(),T=e||"function"==typeof t?[]:hD.Children.toArray(t),_=e??T.map((e,t)=>({id:"panel-"+(t+1)})),L=_.length,N=hD.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 yD(t,n))i.push(mD(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]),$=hD.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]),D=hD.useMemo(()=>({linkedHover:$.linkedHover,selection:$.selection}),[$.linkedHover,$.selection]),B=hD.useMemo(()=>{const e={mode:c,height:l,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:C??fD(L),...D,...j};"legend"!==M&&(e.showLegend=!1),"direct"===M&&(e.directLabel=!0);for(const t of p)t in N&&(e[t]=N[t]);return e},[c,l,A,C,L,D,j,M,p,N]),E=(0,pD.jsxs)("section",{className:["semiotic-small-multiple-chart",I].filter(Boolean).join(" "),style:P,"data-semiotic-small-multiple":"true",children:[(0,pD.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:N}):T[n];return(0,pD.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,pD.jsxs)("header",{className:"semiotic-small-multiple-heading",children:[e.title&&(0,pD.jsx)("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&(0,pD.jsx)("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&(0,pD.jsx)("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),(0,pD.jsx)("div",{className:"semiotic-small-multiple-plot",children:gD(r,o)})]},e.id??n)})]});return!0===g||"auto"===g&&(f||m||y||b||!0===v)&&!R?(0,pD.jsx)(ap,{selections:b,showLegend:v,legendPosition:x,legendInteraction:w,legendSelectionName:k??$.name??"small-multiples",legendField:S??$.fields?.[0]??"category",children:E}):E}var vD=d(require("react")),xD=require("react/jsx-runtime");function wD({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-"+vD.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,xD.jsxs)(xD.Fragment,{children:[(0,xD.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,xD.jsx)("div",{className:m,style:{display:"grid",gridTemplateColumns:p,gap:o,width:"100%",...u},children:vD.Children.map(e,e=>{if(!vD.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?vD.cloneElement(e,n):e;return"primary"!==e.props.emphasis||void 0!==h&&2>h?o:(0,xD.jsx)("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:o})})})]})}wD.displayName="ChartGrid";var kD=d(require("react")),SD=require("react/jsx-runtime");function AD({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-"+kD.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,SD.jsxs)(SD.Fragment,{children:[(0,SD.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,SD.jsxs)("div",{className:["semiotic-context-layout",l,a].filter(Boolean).join(" "),"data-mobile-position":r,style:h,children:[(0,SD.jsx)("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),(0,SD.jsx)("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}AD.displayName="ContextLayout";var CD=require("react"),MD=require("react/jsx-runtime"),jD=200;function ID({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,CD.useState)(null),[p,m]=(0,CD.useState)(null),[y,f]=(0,CD.useState)(!1),[g,b]=(0,CD.useState)(!1),v=(0,CD.useRef)(null),x=(0,CD.useRef)(void 0),w="click"===o?["click","click-end"]:["hover","hover-end"],{latest:k}=Xh({types:w,chartId:r,limit:1}),S=void 0!==i?i:k,A=(0,CD.useCallback)(()=>{b(!0),f(!1),clearTimeout(x.current),x.current=setTimeout(()=>{b(!1),h(null),m(null)},jD)},[]);if((0,CD.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),jD)),!0))}else!s||"click-end"!==S.type&&"hover-end"!==S.type||A()},[s,A,S]),(0,CD.useEffect)(()=>{c?.(y)},[y,c]),(0,CD.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 ${jD}ms ease-out, opacity ${jD}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,MD.jsxs)("div",{ref:v,className:`semiotic-details-panel semiotic-details-${t}${l?" "+l:""}`,style:{...M,...u},children:[a&&(0,MD.jsx)("button",{className:"semiotic-details-close",onClick:A,"aria-label":"Close details",style:PD,children:(0,MD.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:(0,MD.jsx)("path",{d:"M2 2l8 8M10 2l-8 8"})})}),(0,MD.jsx)("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:C})]})}var PD={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};ID.displayName="DetailsPanel";var RD={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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"]},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"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},binSize:{type:"number"},direction:{type:"string",enum:["up","down"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},transition:{type:"object"}}},TemporalHistogram:{required:["data","binSize"],dataShape:"array",dataAccessors:["timeAccessor","valueAccessor","categoryAccessor"],props:{data:{type:"array"},binSize:{type:"number"},size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},direction:{type:"string",enum:["up","down"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},linkedHover:{type:["boolean","string","object"]},linkedBrush:{type:["string","object"]},brush:{type:["boolean","string","object"]},onBrush:{type:"function"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},categoryAccessor:{type:["string","function"]},colors:{type:"object"},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},pointStyle:{type:"function"},yScaleType:{type:"string",enum:["linear","log","symlog"]},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltip:{type:["function","object"]},tooltipContent:{type:"function"},onHover:{type:"function"},annotations:{type:"array"},autoPlaceAnnotations:{type:["boolean","object"]},responsiveRules:{type:"array"},mobileSemantics:{type:"object"},mobileInteraction:{type:["boolean","object"]},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]}}},GaltonBoardChart:{required:[],dataShape:"array",dataAccessors:["valueAccessor"],props:{data:{type:"array"},size:{type:"array"},width:{type:"number"},height:{type:"number"},className:{type:"string"},title:{type:"string"},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"},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"},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"},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"},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"},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"},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"]},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"},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 TD(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function _D(e,t){const n=[];null!=t&&"object"==typeof t||(t={});const o=RD[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(RD).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(!TD(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=Np(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=Ep({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=Op({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=Fp({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 LD=80,ND=100;function $D(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function DD(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)>ND?LD:ND);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 BD(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 ED(e){const t=BD(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 OD(e){const t=BD(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:DD(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:DD(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:DD(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:DD(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 FD(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 zD(e,t){const n=FD(e),o=FD(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}var HD=120,WD=250,qD=["xExtent","yExtent","rExtent"],GD=8;function YD(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:null}function VD(e,t,n){if("function"==typeof t)return t(e);const o="string"==typeof t?t:n;return e?.[o]}ct();var XD=new Set(["category10","tableau10","set3","blues","reds","greens","oranges","purples","greys","viridis","plasma","inferno","magma","cividis","turbo"]),UD=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIdAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function KD(e){return"object"==typeof e&&null!==e&&("tokenType"in e||"tokenSemantics"in e||"countStrategy"in e||"unitValue"in e||"unit"in e)}function QD(e){return"number"==typeof e&&Number.isFinite(e)&&e>=0?e:void 0}function ZD(e,t){const n=QD(e.visibleTokens);if(null!=n)return n;const o=QD(t.denominator);if("fixed-denominator"===t.countStrategy&&null!=o)return o;const r=QD(t.tokenCount),i=QD(t.maxTokens);return null!=r&&null!=i?Math.min(r,i):r??o??i}function JD(e,t){const n=[],o=_D(e,function(e){const t={...e};return delete t.tokenEncoding,delete t.visibleTokens,KD(t.encoding)&&delete t.encoding,t}(t));for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});if(!RD[e])return{ok:0===n.length,diagnoses:n};!function(e,t,n){const o=RD[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=RD[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){a$.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){c$.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=RD[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(!l$.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(!u$.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(!d$.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=zD(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=zD(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=RD[e];r?.props?.colorScheme?.enum||XD.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 (${[...XD].join(", ")}) or pass an explicit color array, e.g. colorScheme={["#1f77b4", "#ff7f0e"]}.`})}(e,t,n),function(e,t,n){const o=RD[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 UD)"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=[];KD(t.tokenEncoding)&&o.push({source:"tokenEncoding",encoding:t.tokenEncoding}),KD(t.encoding)&&o.push({source:"encoding",encoding:t.encoding});for(const{source:e,encoding:r}of o){const o=ZD(t,r);for(const t of DD(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>HD?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>WD&&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 qD){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(!u$.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=m$[e],r=f$[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){h$.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(!p$.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>GD&&n.push({severity:"warning",code:"PIE_TOO_MANY_SLICES",message:`${s.size} slices — angle judgments degrade rapidly past ~${GD} 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(S$.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=YD(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=YD(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?YD(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=YD(VD(t,e,"time")),r=YD(VD(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=YD(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=YD(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=YD(VD(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((YD(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."}),(YD(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=YD(e[0]),r=YD(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=VD(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==YD(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=YD(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=YD(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=YD(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 eB=["title","description","summary"];function tB(e){return"string"==typeof e&&e.trim().length>0}var nB=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]),oB="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 rB(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 iB(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 sB(e){return e.physics&&"object"==typeof e.physics?e.physics:{}}function aB(e,t,n={}){const o=[],r=tL(e),i=x$.has(e),s=!!RD[e]||!!r||i,a=!0===n.inChartContainer,c=!0===n.describe,l=!0===n.navigable,u=g$.has(e),d=a$.has(e),{hasTitle:h,hasDescription:p,hasSummary:m,unsupportedFinding:y}=function(e,t){const n=RD[e]?.props,o=e=>!!n?.[e],r=eB.filter(e=>tB(t[e])&&!o(e));return{hasTitle:o("title")&&tB(t.title),hasDescription:o("description")&&tB(t.description),hasSummary:o("summary")&&tB(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=sB(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=sB(e);return!0===e.settledProjection||!0===t.settledProjection}(t)||k$.has(e)&&f,k=function(e){const t=sB(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=zD(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||w$.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=>nB.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=j$[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(tB).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+=iB(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(b$.has(e)){const e=tB(t.xLabel),n=tB(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(C$.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(rB).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=y$.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,...w$.has(e)||A$.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=M$.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||tB(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:oB}}function cB(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 lB={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},uB=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function dB(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 uB){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(` ${lB[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 hB(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 pB(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 mB(e){return"nominal"===e||"ordinal"===e}function yB(e){return"quantitative"===e||"temporal"===e}T();var fB={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"},gB={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"},bB={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function vB(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=fB[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=bB[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=I(t)[0];break;case"max":o=I(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),wB(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",mB(e?.type)&&yB(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)):yB(e?.type)&&mB(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",xB(i,s,h,m,y),a?.field&&(h.lineBy=a.field),o.interpolate){const e=gB[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",xB(i,s,h,m,y),o.interpolate){const e=gB[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",xB(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",mB(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)):mB(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",xB(i,s,h,m,y),d&&(h.data=d)}return wB(f,h,t)}function xB(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 wB(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 kB=require("react"),SB=/^\d{4}[-/]\d{2}/,AB=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function CB(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?SB.test(e)&&!Number.isNaN(Date.parse(e))?"date":AB.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function MB(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 jB(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 IB(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=CB(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}=MB(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:jB(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}=MB(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 PB=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,RB=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,TB=/(size|magnitude|volume|weight|count|amount)/i,_B=/^(category|label|name|type|group|region|segment|kind|class)$/i,LB=/^(series|group|type|category|segment|cohort|product)$/i,NB=new Set(["numeric"]),$B=new Set(["numeric","date"]),DB=new Set(["numeric"]),BB=new Set(["date"]),EB=new Set(["categorical","boolean"]);function OB(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function FB(e,t){return t.test(e)?.2:0}function zB(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 HB(e,t,n,o,r={}){const i=[];for(const[s,a]of Object.entries(e)){const e=OB(a);if(!n.has(e))continue;let c,l=.5;l+=FB(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=zB(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 WB(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 qB=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,GB=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,YB=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,VB=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,XB=/^(value|weight|amount|count|magnitude|volume)$/i;function UB(e,t){return e.find(e=>t.test(e))}function KB(e,t={}){const n=IB(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=UB(n,qB),r=UB(n,GB);if(!o||!r||o===r)return null;const i=UB(n,YB),s=UB(n,VB),a=UB(n,XB),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=HB(n.fields,o,$B,PB,{computeMonotonic:!0}),s=HB(n.fields,o,DB,RB),a=HB(n.fields,o,NB,TB),c=HB(n.fields,o,EB,_B),l=HB(n.fields,o,EB,LB),u=HB(n.fields,o,BB,/(date|time|timestamp)/i,{computeMonotonic:!0}),d=u[0]?.field;let h=d,p=d?"time":"none";if(!h){const e=i.find(e=>PB.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?WB(o,b):void 0,w=v?WB(o,v):void 0,k=h?WB(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 QB={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},ZB=["tiny","small","medium","large","huge"];function JB(e){return{rows:{...QB.rows,...e?.rows??{}},cardinality:{...QB.cardinality,...e?.cardinality??{}},fields:{...QB.fields,...e?.fields??{}}}}function eE(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const n=JB(t?.thresholds).rows;return e>n.tiny?e>n.small?e>n.medium?e>n.large?"huge":"large":"medium":"small":"tiny"}function tE(e,t){if(!Number.isFinite(e)||0>e)return"low";const n=JB(t?.thresholds).cardinality;return e>n.low?e>n.medium?"high":"medium":"low"}function nE(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const n=JB(t?.thresholds).fields;return e>n.narrow?e>n.typical?"wide":"typical":"narrow"}function oE(e,t){return ZB.indexOf(e)-ZB.indexOf(t)}function rE(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=JB(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 iE(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=JB(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 sE(e,t){const n=e.rowCount??0,o=t?.rows,r=rE(o,n,t),i=eE(r,t),s=Object.keys(e.fields??{}).length,a=t?.fields,c="number"==typeof a?a:"string"==typeof a?function(e,t){const n=JB(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=nE(c,t),u=e.primary.category,d=iE((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?tE(d,t):void 0,growth:t?.growth??"static",rowsSource:void 0!==o?"declared":"measured"}}var aE=2.5,cE=1,lE=3;function uE(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(-aE,Math.min(aE,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>oE(n.rowBand,l.minBand)||l.maxBand&&oE(n.rowBand,l.maxBand)>0?c=!0:"number"==typeof l.bias?(a+=Math.max(-lE,Math.min(lE,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(-cE,Math.min(cE,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 dE(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(aE,.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(aE,.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(aE,.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 hE={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},numericContracts:De.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:dE({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})};Fe();var pE={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:De.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:dE({rows:{sweetSpot:[6,200],caveatAbove:2e3}})};Fe();var mE={component:"BumpChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:De.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:dE({rows:{sweetSpot:[8,200],caveatBelow:4,caveatAbove:1500}})};Fe();var yE={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",numericContracts:De.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:dE({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})};Fe();var fE={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},numericContracts:De.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:dE({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})};Fe();var gE={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:De.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 bE={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:De.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:dE({rows:{sweetSpot:[10,500],caveatAbove:1500}})};Fe();var vE={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:De.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:{...Hy},topRight:{...Wy},bottomLeft:{...qy},bottomRight:{...Gy}}}}},xE={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 wE={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},numericContracts:De.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 kE={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:De.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 SE={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:De.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 AE={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:De.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:dE({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})};Fe();var CE=/(^|[^a-z])(date|time|timestamp|month|week|day|year|quarter|qtr|hour|minute)(?=[^a-z]|$)/i,ME=/^(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,jE=/^(\d{4}(-\d{1,2}(-\d{1,2})?)?|q[1-4]|week\s*\d+|wk\s*\d+|\d{1,2}:\d{2})$/i,IE={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},numericContracts:De.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(CE.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();(ME.test(o)||jE.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:dE({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})};Fe();var PE={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},numericContracts:De.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 RE={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:De.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 TE={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},numericContracts:De.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:dE({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})};Fe();var _E={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},numericContracts:De.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:dE({cardinality:{sweetSpot:[2,5],caveatAbove:6}})};Fe();var LE={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},numericContracts:De.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 NE=/(stage|step|funnel|status|outcome|phase)/i,$E={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},numericContracts:De.FunnelChart,fits:e=>e.primary.y?Object.keys(e.fields).find(e=>NE.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=>NE.test(e));return{data:e.data,stepAccessor:t,valueAccessor:e.primary.y,...e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{}}}},DE={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},BE=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,EE={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=>BE.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=>BE.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},OE={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 FE={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:De.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 zE={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},numericContracts:De.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 HE={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},numericContracts:De.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 WE={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:De.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 qE={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},numericContracts:De.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})},GE={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 YE={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},numericContracts:De.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 VE={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},numericContracts:De.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"})},XE={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}},UE={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 KE(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+KE(t),0):1}var QE={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=KE(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}}},ZE={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"})},JE={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"})},eO={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 tO={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",numericContracts:De.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"})},nO={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"})},oO={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 rO(e){return Number.isFinite("number"==typeof e?e:Number(e))}function iO(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 sO(e,t){return e.data.some(e=>e&&"object"==typeof e&&t in e)}var aO=[hE,pE,mE,yE,fE,gE,bE,vE,xE,wE,kE,SE,AE,IE,PE,RE,TE,_E,LE,$E,DE,EE,OE,FE,zE,HE,WE,qE,GE,YE,VE,XE,UE,QE,ZE,JE,eO,tO,nO,oO,{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=>rO(e.x)&&rO(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:iO(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":sO(e,"stage")||sO(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=(sO(e,"stage")?"stage":sO(e,"status")&&"status")||e.primary.category||"stage",n=sO(e,"id")?"id":void 0,o=(sO(e,"featureId")?"featureId":sO(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}],cO=new Map;function lO(e){var t,n;cO.set(e.component,e),t=e.component,(n=e.numericContracts)?Oe().contracts.set(t,n):Oe().contracts.delete(t)}function uO(e){cO.delete(e),function(e){Oe().contracts.delete(e)}(e)}function dO(){if(0===cO.size&&0>=Z_().capabilities.size)return aO;const e=new Map;for(const t of aO)e.set(t.component,t);for(const t of Array.from(Z_().capabilities.values()))e.set(t.component,t);for(const[t,n]of cO)e.set(t,n);return Array.from(e.values())}function hO(e){return dO().find(t=>t.component===e)}var pO=.5,mO=1,yO=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),fO={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function gO(e,t){if("visual"===t)return{delta:0,caveats:[]};let n=0;const o=[],r=[];for(const t of e.findings){if(!yO.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 ${fO[t]}: ${o.slice(0,3).join("; ")}`,caveats:r}}function bO(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)*pO),a&&(u+=("increase"===a.direction?1:-1)*mO*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 vO(e,t,n){return n?n.familiarity?.[e]??t:t}function xO(e){return e&&2===e.exposureLevel?4:3}function wO(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 kO(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 SO(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 AO(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 CO(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 MO(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 jO(e,t={}){const n=t.profile??KB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??dO(),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=sE(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]=wO(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=kO(o,i),l=MO(c,r),y=SO(e.rubric,i),f=e.buildProps(n,i);let g;d&&(g=gO(aB(e.component,f),u));const b=bO(l,y,e.component,t.audience,g),v=uE(e,p,h,t.scale,t.quality);if(v.excluded)continue;const x=CO(e,t);if(x.excluded)continue;const w=b.score+v.delta+x.delta;if(s>w)continue;const k=AO(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 IO(e,t={}){const n=t.profile??KB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=t.capabilities??dO(),r=t.allow?new Set(t.allow):null,i=t.deny?new Set(t.deny):null,s=sE(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:jO(e,{...t,profile:n}),rejected:c,profile:n}}function PO(e,t,n={}){const o=dO().find(t=>t.component===e);if(!o)return{reason:`No capability registered for "${e}"`};const r=n.profile??KB(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]=wO(t,r);const l=kO(c,s),u=MO(l,a),d=SO(o.rubric,s),h=AO(o,r,l,a),p=CO(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 RO(e,t={}){const n=t.profile??KB(e??[],{rawInput:t.rawInput,seriesField:t.seriesField}),o=sE(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]=jO(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 TO=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","UnitPileChart","CollisionSwarmChart","PacketFlowChart","ProcessFlowChart","PhysicsCustomChart"]);function _O(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function LO(e){return _O(e)?e:void 0}function NO(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function $O(e){const t=NO(e);return null==t?void 0:Math.max(0,Math.floor(t))}function DO(...e){return e.map(LO).find(Boolean)}function BO(...e){return e.find(Array.isArray)}function EO(e){const t={};for(const[n,o]of Object.entries(e))void 0!==o&&(t[n]=o);return t}function OO(e,t,n){return e["string"==typeof t&&t?t:n]}function FO(e){return e instanceof Date?e.toISOString():"number"==typeof e?Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+"":(e??"—")+""}function zO(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function HO(e){return Number.isInteger(e)?e+"":Math.round(1e3*e)/1e3+""}function WO(e,t,n){const o=e?.filter(e=>!0===LO(e)?.sensor).length,r=LO(t?.observation),i=LO(r?.sensors),s=BO(n?.activeSensors);return Math.max(o??0,i?Object.keys(i).length:0,s?.length??0)||void 0}function qO(e,t,n={}){const{capability:o,audience:r,locale:i}=n,s=n.levels??["l1","l2","l3"],a=!1!==n.includeStructure,c=YL(e,o),l=nN(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?aN(e,t,{maxLeaves:n.maxLeaves,locale:i}):void 0,g=function(e,t,n){if(!1===n)return;const o=_O(n)?n:void 0,r=LO(t.physics),i=DO(o?.snapshot,r?.snapshot,t.physicsSnapshot,function(e){const t=LO(e);return!!t&&(_O(t.world)||"simulationState"in t||"liveBodyOrder"in t)}(t.snapshot)?t.snapshot:void 0),s=DO(o?.evidence,r?.evidence,t.physicsEvidence,t.settledEvidence),a=DO(o?.config,r?.config,i?.config,t.config),c=DO(LO(i?.world),LO(r?.world)),l=DO(LO(a?.kernel),LO(c?.options)),u=BO(c?.bodies),d=BO(c?.colliders,a?.colliders),h=BO(i?.queue,r?.queue),p=BO(i?.liveBodyOrder),m=BO(c?.springs),y=BO(i?.activeSensorPairs),f=function(e){if(!e||0===e.length)return;const t=e.map((e,t)=>{const n=LO(e);if(!n)return;const o=NO(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=NO(n.secondary??n.secondaryCount),a=NO(n.observed??n.observedCount);return EO({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=LO(e.settledProjection),i=LO(t?.settledProjection);return BO(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=LO(e);if(!n)return;const o=NO(n.count)??0,r=NO(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=$O(t?.bins)??n?.length??0,r=NO(t?.count)??n?.reduce((e,t)=>e+t.count,0)??0,i=NO(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}:{}}}(BO(o?.sediment,r?.sediment,i?.sediment),DO(o?.sedimentTotals,r?.sedimentTotals)),b=p?.length??u?.length??$O(s?.bodyCount),v=function(e){if(e)return e.filter(e=>!0===LO(e)?.sleeping).length}(u)??$O(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=LO(l?.gravity),A=NO(S?.x),C=NO(S?.y),M=EO({state:w,settled:k,elapsedSeconds:NO(i?.elapsedSeconds),paused:"boolean"==typeof i?.paused?i.paused:void 0,visible:"boolean"==typeof i?.visible?i.visible:void 0,seed:NO(l?.seed),gravity:null!=A&&null!=C?{x:A,y:C}:void 0,fixedDt:NO(a?.fixedDt??l?.fixedDt),timeScale:NO(a?.timeScale),maxSubsteps:$O(a?.maxSubsteps),liveBodies:b,sleepingBodies:v,queued:x,bodyLimit:NO(a?.bodyLimit),eviction:"string"==typeof a?.eviction?a.eviction:void 0}),j=EO({colliders:d?.length,sensors:WO(d,a,c),springs:m?.length,activeSensorPairs:y?.length}),I=Object.keys(j).length>0,P=TO.has(e);if(!(Object.keys(M).length>0||I||f||g)||!P&&null==n)return;const R={simulation:M,...I?{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 ${zO(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 "+HO(n.seed):void 0,n.gravity?`gravity (${HO(n.gravity.x)}, ${HO(n.gravity.y)})`:void 0,null!=n.fixedDt?`fixed step ${HO(n.fixedDt)}s`:void 0,null!=n.timeScale?HO(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} ${zO(r.colliders,"collider")}`:void 0,null!=r.sensors?`${r.sensors} ${zO(r.sensors,"sensor")}`:void 0,null!=r.springs?`${r.springs} ${zO(r.springs,"spring")}`:void 0,null!=r.activeSensorPairs?`${r.activeSensorPairs} active sensor ${zO(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 ${HO(e.count)}.`:"";t.push(`Physics aggregates: ${HO(i.totalCount)} settled ${zO(i.totalCount,"body")} across ${i.rows.length} ${zO(i.rows.length,"container")}; ${i.populatedCount} populated.${n}`)}const s=e.sediment;if(s){const e=null!=s.total?", value total "+HO(s.total):"",n=s.leader?`; largest sediment bin is ${s.leader.label} with ${HO(s.leader.count)}`:"";t.push(`Physics sediment: ${s.count} retained ${zO(s.count,"body")} in ${s.bins} ${zO(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 ${FO(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 ${FO(e)} to ${FO(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 ${FO(t.domain[0])} to ${FO(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=OO(i,t.sourceAccessor,"source"),r=OO(i,t.targetAccessor,"target"),s=OO(i,t.valueAccessor,"value");o.push("ProcessSankey"!==e||null==i.startTime&&null==i.endTime?`${FO(n)} to ${FO(r)} has value ${FO(s)}.`:`${FO(n)} to ${FO(r)} has value ${FO(s)} over ${FO(i.startTime)}–${FO(i.endTime)}.`)}}}if("Treemap"===e||"CirclePack"===e||"TreeDiagram"===e||"OrbitDiagram"===e){const e=LO(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=LO(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(`${FO(e[s])} has value ${FO(e[i])}.`)}}if(TO.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=>NO(OO(e,r,i))).filter(e=>null!=e);s.length>0&&o.push(`Observed ${"string"==typeof r?r:i} ranges from ${FO(Math.min(...s))} to ${FO(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 GO=500,YO=2e3;function VO(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}function XO(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,kB.useState)([]),[m,y]=(0,kB.useState)([]),[f,g]=(0,kB.useState)(!1),[b,v]=(0,kB.useState)(null),x=(0,kB.useMemo)(()=>IB(t??[]),[t]),w=s||a,k=(0,kB.useMemo)(()=>w?KB(t??[]):void 0,[w,t]),S=(0,kB.useMemo)(()=>a&&k?jO(t,{profile:k,intent:c,maxResults:l??5}):void 0,[a,k,t,c,l]),A=(0,kB.useMemo)(()=>{if(d&&r)return qO(r,{data:t??[],...i??{}},"object"==typeof d?d:void 0)},[d,r,i,t]),C=(0,kB.useRef)(n);C.current=n;const M=(0,kB.useRef)(r);M.current=r;const j=(0,kB.useRef)(i);j.current=i;const I=(0,kB.useRef)(t);I.current=t;const P=(0,kB.useRef)(x);P.current=x;const R=(0,kB.useRef)(k);R.current=k;const T=(0,kB.useRef)(S);T.current=S;const _=(0,kB.useRef)(u);_.current=u;const L=(0,kB.useRef)(A);L.current=A;const N=(0,kB.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();WN().record({type:"interrogation-asked",component:M.current,query:VO(t,GO)});try{const e=await C.current(t,{data:I.current??[],summary:P.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();WN().record({type:"interrogation-answered",component:M.current,answer:VO(e.answer,YO),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();WN().record({type:"interrogation-answered",component:M.current,error:!0,latencyMs:Math.max(0,Math.round(t-n))})}finally{g(!1)}},[]),$=(0,kB.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]))},[]),D=(0,kB.useCallback)(()=>{p([]),y([]),v(null)},[]);return{ask:N,announce:$,history:h,summary:x,annotations:(0,kB.useMemo)(()=>{const e=o??[];return 0===e.length?m:0===m.length?e:[...e,...m]},[o,m]),loading:f,error:b,reset:D}}var UO=require("react"),KO=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function QO(e={}){const{chartId:t,types:n=KO}=e,{latest:o}=Xh({chartId:t,types:n,limit:1});return(0,UO.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 ZO={failColor:"var(--semiotic-danger)",warnColor:"var(--semiotic-warning)",passColor:"var(--semiotic-success)"};function JO(e){if("number"==typeof e)return e;const t=Date.parse(e);return Number.isNaN(t)?void 0:t}function eF(e,t){return"pass"===e?t.passColor??ZO.passColor:"warn"===e?t.warnColor??ZO.warnColor:t.failColor??ZO.failColor}function tF(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 nF(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 oF(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 rF(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=eF(s.status,t),a=nF(s),c={provenance:oF(s),lifecycle:i},l=e=>o.push({result:s,reason:e}),u=e=>n.push(Ia(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?JO(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 iF(e){switch(e){case"pass":return"pass";case"warn":return"warn";case"fail":return"fail";default:return"error"}}function sF(e){if(!e)return"dbt check";const t=e.split(".");return t[t.length-1]||e}function aF(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=iF(r.status),i=sF(r.unique_id),s=tF(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=iF(i.status);if("pass"===r&&!t.includePassed)continue;const s=sF(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 rF(n,t)}function cF(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function lF(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 uF(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=cF(a.min_value),d=cF(a.max_value),h=cF(a.value),p=cF(i.result?.observed_value),m=c??"value",y=lF(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 rF(r,t)}function dF(e,t,n={}){const o=n.profile??KB(t??[],{rawInput:n.rawInput}),r=hO(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:jO(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:jO(t,{profile:o,intent:n.intent,maxResults:i,deny:[e],includeVariants:!1}),profile:o,...s.length?{repairs:s}:{}}}var hF={valid:!1,errors:[]};function pF(e,t={}){const n=e.component,o=e.props??{},r=[],i=!!RD[n];i||r.push(`Unknown component "${n}". It is not in the chart registry — pick a known chart.`);const s=i?_D(n,o):{...hF};if(!s.valid)for(const e of s.errors)r.push(e);const a=!1!==t.diagnose&&i?JD(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=dF(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=wL(n,o),h=ML(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 mF(e={}){const t=e.components??Object.keys(RD).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 yF(e){return{name:e.name,description:e.description,input_schema:e.inputSchema}}function fF(e){return{type:"function",function:{name:e.name,description:e.description,parameters:e.inputSchema}}}function gF(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=>gF(e,!1)))return!1}if(o.includes("array")&&(!n.items||!gF(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=>gF(e,!1)))return!1}return!0}function bF(e,t={}){const n=t.strict??!1;if(n&&!gF(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 vF(e){return t=>pF(t,e?e(t):{})}var xF=require("react"),wF="",kF=["hover","click","focus","activate"];function SF(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=SF(t);if(e)return e}return null}function AF(e,t){return e?t.map(t=>e[t]+"").join(wF):""}function CF(e,t){if(e.id===t)return e;for(const n of e.children??[]){const e=CF(n,t);if(e)return e}return null}function MF(e){const{tree:t,chartId:n,observe:o=kF}=e,r=e.selectionName??"__semiotic-nav-sync"+(n?":"+n:""),i=(0,xF.useMemo)(()=>{if(e.matchFields)return e.matchFields;const n=SF(t);return n?Object.keys(n).filter(e=>{return!e.startsWith("_")&&(null==(t=n[e])||"string"==typeof t||"number"==typeof t||"boolean"==typeof t);var t}):[]},[e.matchFields,t]),s=(0,xF.useMemo)(()=>{const e=new Map,n=t=>{if("datum"===t.role&&t.datum){const n=AF(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}=yh({name:r,fields:i}),l=(0,xF.useMemo)(()=>[...o,"hover-end"],[o]),{latest:u}=Xh({chartId:n,types:l,limit:1}),[d,h]=(0,xF.useState)(t.id),p=(0,xF.useRef)(d);p.current=d;const m=(0,xF.useRef)(t);(0,xF.useEffect)(()=>{const e=m.current;m.current=t;const n=CF(e,p.current),o=CF(t,p.current);"datum"===n?.role&&"datum"===o?.role&&n.datum&&o.datum&&i.length>0&&AF(n.datum,i)===AF(o.datum,i)||n&&o&&"datum"!==n.role&&"datum"!==o.role||(h(t.id),c())},[t,c,i]);const y=(0,xF.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,xF.useMemo)(()=>{const e=new Set;if(0===i.length||!f)return e;for(const t of f){const n=s.get(AF(t,i));n&&e.add(n)}return e},[f,s,i]),b=(0,xF.useCallback)(e=>{const t="number"==typeof e?f?.[e]:e;if(!t||0===i.length)return!1;const n=s.get(AF(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,xF.useRef)(null),x=(0,xF.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(AF(t,i));r&&h(e=>e===r?e:r)},[n,o,s,i]),w=(0,xF.useRef)(null);return(0,xF.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 jF=[{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 IF(e){if("string"!=typeof e||0===e.trim().length)return null;const t=new Map;for(const n of jF)for(const o of n.patterns)if(o.test(e)){const e=t.get(n.intent)??0;t.set(n.intent,Math.min(5,0===e?n.weight:e+.5));break}if(0===t.size)return null;const n=Array.from(t.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[o,...r]=n;return{intent:o.intent,confidence:o.confidence,alternates:r}}function PF(e,t={}){const n=t.audience;if(!n)return[];const o=t.profile??KB(e??[],{rawInput:t.rawInput}),r=xO(n),i=t.scoreTolerance??1.5,s=t.maxResults??5,a=dO(),c=new Map;for(const e of a)c.set(e.component,vO(e.component,e.rubric.familiarity,n));const l=jO(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 RF(e,t={}){const n=t.profile??KB(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=jO(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?PF(e,{profile:n,audience:t.audience,deny:Array.from(u).map(e=>e.split("/")[0]),maxResults:t.maxStretchPanels??Math.min(3,o)}):[],profile:n}}var TF={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},_F={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},LF={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},NF={executive:TF,analyst:_F,"data-scientist":LF},$F=[{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}}}],DF=new Map;function BF(e){DF.set(e.component,e)}function EF(e){DF.delete(e)}function OF(){if(0===DF.size)return $F;const e=new Map;for(const t of $F)e.set(t.component,t);for(const[t,n]of DF)e.set(t,n);return Array.from(e.values())}function FF(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 zF(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 HF(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 WF(e,t={}){const n=t.capabilities??OF(),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]=FF(r,e);const i=zF(n,o);if(r>i)continue;const l={...t.rubric},u=t.caveats?Array.from(t.caveats(e)):[],d=HF(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 qF=["x","y","size","category","series","time"];function GF(e,t){const n=e.fields[t];return n?"numeric"===n.type?"numeric":"categorical"===n.type?"categorical":"date"===n.type?"date":"unknown":"unknown"}function YF(e){const t=new Set;for(const n of dO())null===n.fits(e)&&t.add(n.component);return t}function VF(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=GF(e,r),i=GF(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 qF){const o=e.primary[n],r=t.primary[n];o!==r&&a.push({role:n,from:o,to:r})}const c=YF(e),l=YF(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 XF(e,t=dO()){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=KB(c.data,{rawInput:c.rawInput}),l=IO(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 UF=(()=>{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})))})(),KF=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),QF=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],ZF=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),JF=Array.from({length:80},(e,t)=>{const n=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:n,grade:Math.min(100,1.8*n+30+20*(Math.random()-.5))}}),ez=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),tz=[{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}],nz=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:UF,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:UF,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:UF,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:KF,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:QF,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:QF,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:ZF,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:ZF,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:JF,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:JF,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:tz,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:tz,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:ez,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"]}],oz=require("react"),rz=e=>RN(e),iz=()=>WN().enabled,sz=()=>!1;function az(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,oz.useMemo)(()=>h??KB(e??[],{rawInput:c,seriesField:l}),[h,e,c,l]),m=(0,oz.useMemo)(()=>jO(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,oz.useSyncExternalStore)(rz,iz,sz),f=(0,oz.useRef)(null);return(0,oz.useEffect)(()=>{if(0===m.length)return void(f.current=null);if(!y)return void(f.current=null);const e=WN(),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 cz=d(require("react")),lz=require("react"),uz=require("react/jsx-runtime"),dz=(0,lz.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:I,setup:P,earlyReturn:R}=wm({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=P.effectiveSelectionHook,_=(0,lz.useMemo)(()=>T?.isActive?{isActive:!0,predicate:T.predicate}:null,[T?.isActive,T?.predicate]);if(R)return R;const{width:L,height:N,enableHover:$,showGrid:D,title:B,description:E,summary:O,accessibleTable:F}=j,z={chartType:"custom",...null!=n&&{data:I},customLayout:o,layoutConfig:r,onLayoutError:i,..._&&{layoutSelection:_},oAccessor:s,rAccessor:a,oExtent:c,rExtent:l,projection:u,colorAccessor:p,colorScheme:m,size:[L,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:P.margin,enableHover:$,showAxes:y,showGrid:D,annotations:f,...om({title:B,description:E,summary:O,accessibleTable:F,className:h,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...rm({linkedHover:x,selection:v,onObservation:g,onClick:b,hoverHighlight:!1,mobileInteraction:P.mobileInteraction,customHoverBehavior:P.customHoverBehavior,customClickBehavior:P.customClickBehavior}),...C};return(0,uz.jsx)(jp,{componentName:"OrdinalCustomChart",width:L,height:N,children:(0,uz.jsx)(Ig,{ref:M,...z})})});dz.displayName="OrdinalCustomChart";var hz=require("react"),pz=require("react/jsx-runtime"),mz=(0,hz.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}=xm({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,hz.useMemo)(()=>ft(n),[n]),M=(0,hz.useMemo)(()=>ft(o),[o]),j=(0,hz.useMemo)(()=>void 0===n&&void 0===o?void 0:[...C,...M],[o,n,M,C]),I=Bh(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:P,customClickBehavior:R,activeSelectionHook:T}=gp({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:I}),_=(0,hz.useMemo)(()=>T?.isActive?{isActive:!0,predicate:T.predicate}:null,[T?.isActive,T?.predicate]),{width:L,height:N,enableHover:$,title:D,description:B,summary:E,accessibleTable:O}=S,F=Tp(e.loading,L,N,e.loadingContent),z=F?null:Rp(j,L,N,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,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:A,enableHover:$,...om({title:D,description:B,summary:E,accessibleTable:O,className:d,animate:e.animate,autoPlaceAnnotations:x}),...rm({linkedHover:y,selection:m,onObservation:f,onClick:g,mobileInteraction:I,customHoverBehavior:P,customClickBehavior:R,linkedHoverInClickPredicate:!1}),layoutSelection:_,...null!=v&&{annotations:v},...w};return(0,pz.jsx)(jp,{componentName:"NetworkCustomChart",width:L,height:N,children:(0,pz.jsx)(_w,{ref:k,...H})})});mz.displayName="NetworkCustomChart";var yz=require("react"),fz=require("react"),gz=require("d3-geo"),bz=require("d3-quadtree"),vz=require("d3-geo"),xz={mercator:vz.geoMercator,equalEarth:vz.geoEqualEarth,albersUsa:vz.geoAlbersUsa,orthographic:vz.geoOrthographic,naturalEarth:vz.geoNaturalEarth1,equirectangular:vz.geoEquirectangular};function wz(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function kz(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Sz(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function Az(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 Cz(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 Mz(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 jz(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 Iz=require("d3-scale");T();var Pz=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rz=["scene-style","data-paint","accessibility","evidence"],Tz=(e,t)=>({retainedData:e,invalidations:t}),_z=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lz=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nz=["scene-geometry","data-paint","accessibility","evidence"],$z=["scene-style","data-paint","accessibility","evidence"],Dz=["overlay","accessibility","evidence"],Bz=[],Ez={xAccessor:Tz("rebuild",_z),yAccessor:Tz("rebuild",_z),lineDataAccessor:Tz("rebuild",_z),pointIdAccessor:Tz("rebuild",Nz),lineIdAccessor:Tz("rebuild",Nz),windowSize:Tz("rebuild",_z),projection:Tz("preserve",Lz),projectionExtent:Tz("preserve",Lz),fitPadding:Tz("preserve",Lz),lineType:Tz("preserve",Lz),flowStyle:Tz("preserve",Lz),graticule:Tz("preserve",Lz),projectionTransform:Tz("preserve",Lz),customLayout:Tz("preserve",Lz),layoutConfig:Tz("preserve",Lz),layoutMargin:Tz("preserve",Lz),areaStyle:Tz("preserve",$z),pointStyle:Tz("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Tz("preserve",$z),colorScheme:Tz("preserve",$z),themeCategorical:Tz("preserve",$z),themeDiverging:Tz("preserve",$z),themeSemantic:Tz("preserve",$z),themeSequential:Tz("preserve",$z),decay:Tz("preserve",$z),pulse:Tz("preserve",$z),layoutSelection:Tz("preserve",$z),annotations:Tz("preserve",Dz),autoPlaceAnnotations:Tz("preserve",Dz),clock:Tz("preserve",Bz),transition:Tz("preserve",Bz),introAnimation:Tz("preserve",Bz),onLayoutError:Tz("preserve",Bz)},Oz=Tz("preserve",Lz),Fz=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}},Pz)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Rz):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Ez[o]??Oz;"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)}},zz=require("d3-geo");function Hz(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 Wz=class e{constructor(e){this.updateResults=new Fz,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:Hz(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??$n()}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:Hz(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,vz.geoEqualEarth)();if("string"==typeof e){const t=xz[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,vz.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=xz[e.type],n=t?t():(0,vz.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,gz.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,gz.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=wz(n.xAccessor,"lon"),i=wz(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=kz(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,gz.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,gz.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,gz.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,bz.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=bf(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:vf(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=wz(e.xAccessor,"lon"),c=wz(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,zz.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:Sz(e.areaStyle,t,u),datum:t,interactive:!0})}const p=kz(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,zz.geoDistance)(o,i)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,zz.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=Sz(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?Mz(r,u):jz(r[0],r[r.length-1],0,0,u)):r=Cz(r[0],r[r.length-1]);const h=Az(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,zz.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=P(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,Iz.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,Iz.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=Nn(e.x,e._targetX,n),e.y=Nn(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}};Wz.QUADTREE_THRESHOLD=500;var qz=Wz;function Gz(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);Pr(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);Pr(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=Yz(t,n,s,a,c,l);i>=h&&d>h&&(u=e,d=h)}}return u?{node:u,distance:d}:null}function Yz(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(qz);var Vz=require("react"),Xz=require("react/jsx-runtime");function Uz(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,Vz.useRef)([f?.length??0,new Map]),j=f?.length??0;M.current[0]!==j&&(M.current=[j,new Map]);const I=(0,Vz.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||I&&I.length>0?(0,Xz.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Xz.jsx)("title",{children:"string"==typeof a?a:"XY Chart"}),(0,Xz.jsx)("desc",{children:"string"==typeof a?a+" (XY data visualization)":"XY data visualization"}),(0,Xz.jsxs)("g",{transform:"translate("+i.left+","+i.top+")",children:[I,y]}),a&&"string"==typeof a?(0,Xz.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,Xz.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 Kz=require("d3-zoom"),Qz=require("d3-selection");function Zz([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t,n]}function Jz(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 eH=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 tH=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=nH(s),c=oH(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 nH(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 oH(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 rH(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 iH=require("react/jsx-runtime");function sH({data:e}){if(!e)return null;if(e.properties)return(0,iH.jsx)("div",{className:"semiotic-tooltip",style:eu,children:(0,iH.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,iH.jsxs)("div",{className:"semiotic-tooltip",style:eu,children:[null!=o&&(0,iH.jsx)("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:o}),n.entries.map(e=>(0,iH.jsxs)("div",{children:[(0,iH.jsxs)("span",{style:{opacity:.7},children:[e.key,": "]}),(0,iH.jsx)("span",{style:{fontWeight:600},children:wd(e.value)})]},e.key))]})}sH.ownsChrome=!0;var aH={top:10,right:10,bottom:10,left:10},cH=null;function lH(){if(null!==cH)return cH;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 cH=e||t||n}function uH(){return lH()?12:30}var dH={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 hH(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function pH(e){return e?e.getContext("2d"):null}var mH=require("react/jsx-runtime"),yH=(0,fz.memo)((0,fz.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:I,tileCacheSize:P,size:R,width:T,height:_,responsiveWidth:L,responsiveHeight:N,margin:$,className:D,background:B,windowSize:E=500,renderMode:O,areaStyle:F,pointStyle:z,lineStyle:H,colorScheme:W,enableHover:q=!0,hoverAnnotation:G,tooltipContent:Y,allowTooltipOverflow:V=!1,customClickBehavior:X,customHoverBehavior:U,onObservation:K,annotationObservationCallback:Q,chartId:Z,annotations:J,onAnnotationActivate:ee,autoPlaceAnnotations:te,svgAnnotationRules:ne,decay:oe,pulse:re,transition:ie,animate:se,staleness:ae,frameScheduler:ce,clock:le,random:ue,seed:de,paused:he=!1,suspendWhenHidden:pe=!0,backgroundGraphics:me,foregroundGraphics:ye,title:fe,legend:ge,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:we,legendHighlightedCategory:ke,legendIsolatedCategories:Se,legendCategoryAccessor:Ae,onCategoriesChange:Ce,showAxes:Me,accessibleTable:je=!0,description:Ie,summary:Pe}=e,{customHoverBehavior:Re,customClickBehavior:Te,hasClickBehavior:_e}=$d({customHoverBehavior:U,customClickBehavior:X,onObservation:K,chartId:Z,chartType:"StreamGeoFrame"}),Le=R||[T||600,_||400],Ne=(0,fz.useRef)(!0),$e=Su({sizeProp:Le,responsiveWidth:L,responsiveHeight:N,userMargin:$,marginDefault:aH,title:fe,legend:ge,legendPosition:be,foregroundGraphics:ye,backgroundGraphics:me,animate:se,transitionProp:ie,frameScheduler:ce,clock:le,random:ue,seed:de,paused:he,suspendWhenHidden:pe,themeDirtyRef:Ne}),{reducedMotionRef:De,responsiveRef:Be,size:Ee,margin:Oe,adjustedWidth:Fe,adjustedHeight:ze,resolvedForeground:He,resolvedBackground:We,transition:qe,introEnabled:Ge,tableId:Ye,frameRuntime:Ve,rafRef:Xe,renderFnRef:Ue,scheduleRender:Ke,currentTheme:Qe}=$e,Ze=Gc(),Je=Uc(),et=(0,fz.useMemo)(()=>Array.isArray(s)?ft(s):s,[s]),tt=(0,fz.useMemo)(()=>ft(a),[a]),nt=(0,fz.useMemo)(()=>ft(c),[c]),ot=(0,fz.useMemo)(()=>null!=A?A:"orthographic"===hH(n),[A,n]),rt=Qc((0,fz.useMemo)(()=>({projection:n,projectionExtent:o,fitPadding:r,xAccessor:p,yAccessor:m,lineDataAccessor:y,lineType:b,flowStyle:v,areaStyle:F,pointStyle:z,lineStyle:H,colorScheme:W,themeSemantic:Rt(Qe),themeSequential:Qe?.colors?.sequential,themeDiverging:Qe?.colors?.diverging,themeCategorical:Qe?.colors?.categorical,graticule:x,projectionTransform:i,windowSize:E,clock:Ve.now,decay:oe,pulse:re,transition:qe,introAnimation:Ge,annotations:J,pointIdAccessor:f,lineIdAccessor:g,customLayout:l,layoutConfig:u,onLayoutError:h,layoutMargin:Oe}),[n,o,r,p,m,y,b,v,F,z,H,W,Qe,x,i,E,Ve.now,oe,re,qe,Ge,J,f,g,l,u,h,Oe])),it=(0,fz.useRef)(null);it.current||(it.current=new qz(rt));const st=(0,fz.useRef)(null),at=(0,fz.useRef)(null),ct=(0,fz.useRef)(null);j&&!ct.current&&(ct.current=new eH(P||256));const lt=(0,fz.useRef)(J),ut=(0,fz.useRef)(null),dt=(0,fz.useRef)(Kz.zoomIdentity),ht=(0,fz.useRef)(!1),pt=(0,fz.useRef)(null),mt=(0,fz.useCallback)(e=>{pt.current=e,Be&&"object"==typeof Be&&(Be.current=e)},[Be]),yt=(0,fz.useRef)(null),gt=(0,fz.useRef)(null),bt=(0,fz.useRef)(null),vt=(0,fz.useRef)(0);if(C&&!bt.current){const e=M?.maxPerLine??uH();bt.current=new tH(50*e)}const xt=(0,fz.useRef)(null),wt=(0,fz.useRef)(null),kt=(0,fz.useRef)(!1),St=(0,fz.useRef)(!1),At=yr("StreamGeoFrame"),Ct=(0,fz.useRef)(void 0),[Mt,jt]=(0,fz.useState)(null),[,It]=(0,fz.useState)(0),Pt=(0,fz.useRef)(0),[Tt,_t]=(0,fz.useState)(!1),Lt=Lu(it,Ae,Ce,e=>e.getPoints());Mr(it,rt,Ne,Ke),jr(it,d,Ne,Ke),(0,fz.useEffect)(()=>{const e=it.current;e&&(et&&e.setAreas(et),a&&e.setPoints(tt),c&&e.setLines(nt),Ne.current=!0,Ke())},[et,a,tt,c,nt,Ke]);const Nt=(0,fz.useCallback)(e=>{null!=e&&"object"==typeof e&&(it.current?.pushPoint(e),Ne.current=!0,Ke())},[Ke]),$t=(0,fz.useCallback)(e=>{const t=ft(e);0!==t.length&&(it.current?.pushMany(t),Ne.current=!0,Ke())},[Ke]),Dt=(0,fz.useCallback)(e=>{null!=e&&"object"==typeof e&&(it.current?.pushLine(e),Ne.current=!0,Ke())},[Ke]),Bt=(0,fz.useCallback)(e=>{const t=ft(e);0!==t.length&&(it.current?.pushManyLines(t),Ne.current=!0,Ke())},[Ke]),Et=(0,fz.useCallback)(()=>{it.current?.clear(),Ne.current=!0,Ke()},[Ke]);(0,fz.useImperativeHandle)(t,()=>({push:Nt,pushMany:$t,removePoint:e=>{const t=it.current?.removePoint(e)??[];return t.length>0&&(Ne.current=!0,Ke()),t},pushLine:Dt,pushManyLines:Bt,removeLine:e=>{const t=it.current?.removeLine(e)??[];return t.length>0&&(Ne.current=!0,Ke()),t},getLines:()=>it.current?.getLines()??[],clear:Et,getProjection:()=>it.current?.scales?.projection??null,getGeoPath:()=>it.current?.scales?.geoPath??null,getCartogramLayout:()=>it.current?.cartogramLayout??null,getCustomLayout:()=>it.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>it.current?.lastCustomLayoutFailure??null,getZoom:()=>dt.current.k,resetZoom:()=>{const e=pt.current;e&&ut.current&&(0,Qz.select)(e).call(ut.current.transform,Kz.zoomIdentity)},getData:()=>it.current?.getPoints()??[]}),[Nt,$t,Dt,Bt,Et,Ke]);const{hoverHandlerRef:Ot,onPointerMove:Ft,onPointerLeave:zt}=$e,{canvasRef:Ht,interactionCanvasRef:Wt}=Mu($e,{hydrated:Ze,wasHydratingFromSSR:Je,storeRef:it,dirtyRef:Ne,cleanup:()=>ct.current?.clear(),canvasPaintDependencies:[Fe,ze,B,me,O,Ke]});(0,fz.useEffect)(()=>{Ot.current=e=>{if(!q)return;const t=it.current;if(!t||!t.scene.length)return;const n=Ht.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Oe.left,i=e.clientY-o.top-Oe.top;if(0>r||r>Fe||0>i||i>ze)return xt.current=null,wt.current=null,jt(null),Re?.(null),void Ke();at.current||(at.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const s=pH(at.current);if(!s)return;const a=ql(30,e.pointerType),c=ql(6,e.pointerType),l=Gz(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};xt.current=a,wt.current=e,jt(a),Re?.(a),Ke()}else xt.current&&(xt.current=null,wt.current=null,jt(null),Re?.(null),Ke())}},[q,Fe,ze,Oe,Re,Ke,Ot,Ht]),$e.hoverLeaveRef.current=()=>{xt.current=null,wt.current=null,jt(null),Re?.(null),Ke()};const qt=(0,fz.useCallback)(e=>{if(Qs(e.target))return;if(!Te)return;const t=it.current;if(!t||!t.scene.length)return void Te(null);const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Oe.left,r=e.clientY-n.top-Oe.top;if(0>o||o>Fe||0>r||r>ze)return void Te(null);at.current||(at.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=pH(at.current);if(!i)return void Te(null);const s=ql(30,Ct.current),a=ql(6,Ct.current),c=Gz(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 Te({...n,data:t,properties:t?.properties,__semioticHoverData:!0,x:o,y:r,time:o,value:r},{type:"activate",inputType:Rd(Ct.current)})}Te(null)},[ze,Fe,Te,Oe]),{kbFocusIndexRef:Gt,focusedNavPointRef:Yt,onKeyDown:Vt}=function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s}){const a=(0,Dd.useRef)(-1),c=(0,Dd.useRef)(null),l=(0,Dd.useCallback)(l=>{if(Td(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?.(Yd(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=Yd(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:it,hoverRef:xt,hoveredNodeRef:wt,setHoverPoint:jt,customHoverBehavior:Re,customClickBehavior:Te,scheduleRender:Ke}),Xt=(0,fz.useCallback)(e=>{Ct.current=e.pointerType,Gt.current=-1,Yt.current=null,Ft(e)},[Yt,Gt,Ft]),Ut=(0,fz.useCallback)(e=>{Ct.current=e.pointerType},[]);Ue.current=()=>{if(Xe.current=null,!Ve.isActive)return;const e=Ht.current,t=it.current;if(!e||!t)return;const n=Ve.now();let o=!1;const r=gt.current;let i=!1;r&&(gt.current=null,t.applyRotation(r,{width:Fe,height:ze}),i=!0);const s=t.advanceTransition(De.current?n+1e6:n),a=!De.current&&s,c=At.current.beforeCompute(t.getLastUpdateResult(),a);let l=!1;if(Ne.current&&!s){const n={width:Fe,height:ze},o=t.hasProjection(),r=ot&&o?t.getRotation():null;t.computeScene(n);const i=dt.current,s=1!==i.k||0!==i.x||0!==i.y;ot&&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")),Lt()}At.current.afterCompute(c,l,!1);const u=Tu(),d=C&&!De.current&&!!bt.current,h=t.consumeStylePaintPending(),p=Iu(t,n,l,St),m=ol({dirtyOrRebuilt:l,transitioning:a,continuous:d,liveEncoding:p.changed,forced:i||h});if(j&&ct.current){const e=st.current;if(e&&t.scales?.projection){const n=Ru(e,Ee,Oe,u);if(n){n.clearRect(-Oe.left,-Oe.top,Ee[0],Ee[1]),n.save(),n.beginPath(),n.rect(0,0,Fe,ze),n.clip();const e=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:s,onTileLoad:a}=t,c=o.scale(),l=o.translate(),u=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*c*Math.PI,translate:l}),d=Tu();let h=!0;for(const t of u.tiles){const[o,r,i]=Zz(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=Jz(n,i,o,r,d),l=t}if(!l.loaded){h=!1;continue}const p=u.scale;e.drawImage(l.img,(t[0]+u.translate[0])*p-.5,(t[1]+u.translate[1])*p-.5,p+1,p+1)}return h}(n,{tileURL:j,projection:t.scales.projection,width:Fe,height:ze,tileCache:ct.current,onTileLoad:()=>Ke()});n.restore(),e||(o=!0)}}}if(m){const r=Ru(e,Ee,Oe,u);if(!r)return;r.clearRect(-Oe.left,-Oe.top,Ee[0],Ee[1]),j||nl(r,{background:B,hasBackgroundGraphics:!!me,width:Fe,height:ze}),r.save(),r.beginPath(),r.rect(0,0,Fe,ze),r.clip();const i=t.scene,s={width:Fe,height:ze};if(fd({context:r,nodes:i,renderMode:O,pixelRatio:u,paintBuiltIn:e=>{!function(e,t){const n=t.filter(e=>"geoarea"===e.type);for(const t of n){if(!t.pathData)continue;t._cachedPath2D||(t._cachedPath2D=new Path2D(t.pathData));const n=t._cachedPath2D,o=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)}Yu(e,t,n),e.globalAlpha=1,e.setLineDash([])}}(r,e),Hu(r,e,0,s),Qu(r,e),nd(r,e)}}),d&&bt.current){const e=bt.current,t=i.filter(e=>"line"===e.type);if(t.length>0){const i=M||{},s=.3*(i.speedMultiplier??1),a=i.maxPerLine??uH(),c=i.spawnRate??(lH()?.06:.15),l=i.radius??2,u=i.opacity??.7,d=n/1e3,h=vt.current>0?Math.min(d-vt.current,.1):.016;vt.current=d;const p=t.map(e=>e.path),m=t.map(e=>e.style.strokeWidth||2);for(let n=0;t.length>n;n++)Ve.random()<c&&e.countForLine(n)<a&&e.spawn(n,Ve.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=wt.current,f=!(!y||"geoarea"!==y.type&&"point"!==y.type),g=rl(f,kt.current),b=Wt.current;if(b&&g){const e=Ru(b,Ee,Oe,u);if(e){if(e.clearRect(-Oe.left,-Oe.top,Ee[0],Ee[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 G?G:void 0,o=n?.pointColor||bd(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()}}kt.current=f}const v=J!==lt.current;v&&(lt.current=J),(l||v||a&&J&&J.length>0)&&(l||v||n-Pt.current>=33)&&(It(e=>e+1),Pt.current=n),(a||null!=t.activeTransition||p.pending||o)&&Ke()},_i(ae,it,Ne,Ke,Tt,_t),(0,fz.useEffect)(()=>{if("production"!==process.env.NODE_ENV&&j){const e=hH(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,fz.useEffect)(()=>{const e=pt.current;if(!w||!e)return ut.current&&e&&((0,Qz.select)(e).on(".zoom",null),ut.current=null),void(e&&(0,Qz.select)(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=k||[1,8],o={width:Fe,height:ze};if(ot){let r=dt.current.k;const i=e=>{r=Math.max(t,Math.min(n,e)),dt.current=Kz.zoomIdentity.scale(r);const i=it.current;i&&(i.applyZoomScale(r,o),Ne.current=!1,Ke(),i.scales?.projection&&S?.({projection:i.scales.projection,zoom:i.currentZoom}))};ut.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=it.current;if(!o)return;const r=o.getRotation();yt.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=yt.current;t&&(gt.current=[t.rotation[0]+(e.clientX-t.x)*c,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*c)),t.rotation[2]],Ke())},d=t=>{if(!yt.current)return;yt.current=null,e.releasePointerCapture(t.pointerId);const n=gt.current;if(n){gt.current=null;const e=it.current;e&&(e.applyRotation(n,o),Ke())}const r=it.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),ut.current=null}}const r=(0,Kz.zoom)().scaleExtent([t,n]).extent([[0,0],[Ee[0],Ee[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;dt.current=t,ht.current=!0;const n=it.current;n&&(n.applyZoomTransform(t,o),Ne.current=!1,Ke())}).on("end",e=>{dt.current=e.transform,ht.current=!1;const t=it.current;t?.scales?.projection&&S?.({projection:t.scales.projection,zoom:t.currentZoom})});return ut.current=r,(0,Qz.select)(e).call(r),()=>{(0,Qz.select)(e).on(".zoom",null)}},[w,k,ot,Ee,Fe,ze,Oe,S,Ke]);const Kt=q&&!1!==G,Qt=Kt&&Mt?Y?Y(Mt):(0,mH.jsx)(sH,{data:Mt}):null,Zt=Qt?(0,mH.jsx)(cu,{x:Mt.x,y:Mt.y,containerWidth:Fe,containerHeight:ze,margin:Oe,className:"stream-frame-tooltip",zIndex:10,children:Qt}):null;if(Hc||!Ze&&Je){const e=it.current;e&&(et||a||c)&&(et&&e.setAreas(et),a&&e.setPoints(tt),c&&e.setLines(nt),e.computeScene({width:Fe,height:ze}));const t=e?.scene??[];return(0,mH.jsxs)("div",{ref:mt,className:"stream-geo-frame"+(D?" "+D:""),role:"img","aria-label":Ie||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:L?"100%":Ee[0],height:N?"100%":Ee[1]},children:[(0,mH.jsx)(El,{summary:Pe}),(0,mH.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[(0,mH.jsx)("g",{transform:`translate(${Oe.left},${Oe.top})`,children:We}),(0,mH.jsxs)("g",{transform:`translate(${Oe.left},${Oe.top})`,children:[B&&(0,mH.jsx)("rect",{x:0,y:0,width:Fe,height:ze,fill:B}),t.map((e,t)=>gd({node:e,index:t,renderMode:O,fallback:()=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=ei(n.style.fill)?oi(n.style.fill,`geoarea-${t}-hatch`):void 0;return(0,Rc.jsxs)(Pc.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)(Pc.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,mH.jsx)(Uz,{width:Fe,height:ze,totalWidth:Ee[0],totalHeight:Ee[1],margin:Oe,showAxes:!1,title:fe,legend:ge,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:we,legendHighlightedCategory:ke,legendIsolatedCategories:Se,foregroundGraphics:br(He,Ar(it.current?.customLayoutOverlays,d??null)),annotations:J,onAnnotationActivate:ee,onObservation:Q??K,chartId:Z,chartType:"StreamGeoFrame",autoPlaceAnnotations:te,svgAnnotationRules:ne,pointNodes:rH(t),geoProjection:it.current?.scales?.projectedPoint})]})}return(0,mH.jsxs)("div",{ref:mt,className:"stream-geo-frame"+(D?" "+D:""),role:"group","aria-label":Ie||("string"==typeof fe?fe:"Geographic chart"),tabIndex:0,style:{position:"relative",width:L?"100%":Ee[0],height:N?"100%":Ee[1],overflow:V?"visible":"hidden",...w?{touchAction:"none"}:{}},onKeyDown:Vt,children:["production"!==process.env.NODE_ENV&&it.current&&(0,mH.jsx)(fr,{store:it.current,diagnostics:At.current}),je&&(0,mH.jsx)(Ol,{tableId:Ye}),je&&(0,mH.jsx)(Dl,{scene:it.current?.scene??[],chartType:"Geographic chart",tableId:Ye,chartTitle:"string"==typeof fe?fe:void 0}),(0,mH.jsx)(El,{summary:Pe}),(0,mH.jsx)(yl,{hoverPoint:Mt}),(0,mH.jsxs)("div",{role:"img","aria-label":Ie||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Kt?Xt:void 0,onPointerLeave:Kt?zt:void 0,onPointerDown:Kt||_e?Ut:void 0,onClick:_e?qt:void 0,children:[(0,mH.jsx)(ju,{size:Ee,margin:Oe,children:We}),j&&(0,mH.jsx)("canvas",{ref:st,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,mH.jsx)("canvas",{ref:Ht,"aria-label":wl(it.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),(0,mH.jsx)("canvas",{ref:Wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,mH.jsx)(Uz,{width:Fe,height:ze,totalWidth:Ee[0],totalHeight:Ee[1],margin:Oe,showAxes:Me,title:fe,legend:ge,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:we,legendHighlightedCategory:ke,legendIsolatedCategories:Se,foregroundGraphics:br(He,Ar(it.current?.customLayoutOverlays,d??null)),annotations:J,onAnnotationActivate:ee,onObservation:Q??K,chartId:Z,chartType:"StreamGeoFrame",autoPlaceAnnotations:te,svgAnnotationRules:ne,pointNodes:rH(it.current?.scene),geoProjection:it.current?.scales?.projectedPoint}),ae?.showBadge&&(0,mH.jsx)(Ni,{isStale:Tt,position:ae.badgePosition}),w&&(0,mH.jsxs)("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Oe.bottom+8,left:Oe.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[(0,mH.jsx)("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=pt.current,n=ut.current;t&&n?.scaleBy&&n.scaleBy((0,Qz.select)(t),1.5)},style:dH,children:"+"}),(0,mH.jsx)("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=pt.current,n=ut.current;t&&n?.scaleBy&&n.scaleBy((0,Qz.select)(t),1/1.5)},style:dH,children:"−"})]}),I&&(0,mH.jsx)("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Oe.bottom+2,right:Oe.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2},children:I}),(0,mH.jsx)(Hl,{active:Gt.current>=0,hoverPoint:Mt,margin:Oe,size:Ee,shape:Yt.current?.shape,width:Yt.current?.w,height:Yt.current?.h,pathData:Yt.current?.pathData}),Zt]})]})}));yH.displayName="StreamGeoFrame";var fH=yH,gH=require("react/jsx-runtime"),bH=(0,yz.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:I,normalizedMargin:P}=xm({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,yz.useMemo)(()=>ft(n),[n]),T=(0,yz.useMemo)(()=>ft(o),[o]),_=(0,yz.useMemo)(()=>ft(r),[r]),L=(0,yz.useMemo)(()=>[...R,..._,...T],[R,_,T]),N=qp({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:P,marginDefaults:I.marginDefaults,loading:k,loadingContent:S,emptyContent:A,width:I.width,height:I.height,hasTitle:!!I.title}),$=N.effectiveSelectionHook,D=(0,yz.useMemo)(()=>$?.isActive?{isActive:!0,predicate:$.predicate}:null,[$?.isActive,$?.predicate]);if(N.earlyReturn)return N.earlyReturn;const{width:B,height:E,enableHover:O,title:F,description:z,summary:H,accessibleTable:W}=I,q=su(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:D,colorBy:h,colorScheme:p,size:[B,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:N.margin,enableHover:O,...om({title:F,description:z,summary:H,accessibleTable:W,className:C,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations}),...!1===m?{tooltipContent:()=>null}:q?{tooltipContent:q}:{},...rm({linkedHover:b,selection:g,onObservation:v,onClick:x,hoverHighlight:!1,mobileInteraction:N.mobileInteraction,customHoverBehavior:N.customHoverBehavior,customClickBehavior:N.customClickBehavior,linkedHoverInClickPredicate:!1}),...y&&y.length>0&&{annotations:y},...M};return(0,gH.jsx)(jp,{componentName:"GeoCustomChart",width:B,height:E,children:(0,gH.jsx)(fH,{ref:j,...G})})});function vH(e){const t=sL(e.recipe)??(e.recipeId?tL(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:z_(e.layout)?iL(e.layout.id):void 0}(t);if(!n){const e=z_(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?Sm:"OrdinalFrame"===t.frameFamily||"OrdinalCustomChart"===t.frameFamily?dz:"NetworkFrame"===t.frameFamily||"NetworkCustomChart"===t.frameFamily?mz:"GeoFrame"===t.frameFamily||"GeoCustomChart"===t.frameFamily?bH:void 0;if(!i)throw Error(`Chart recipe "${t.id}" uses unsupported frame family "${t.frameFamily}".`);return cz.createElement(i,r)}function xH(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function wH(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function kH(e){return"number"==typeof e&&Number.isFinite(e)}function SH(e){if(kH(e.x)&&kH(e.y)&&kH(e.w)&&kH(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(kH(e.x)&&kH(e.y)&&kH(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(kH(e.cx)&&kH(e.cy)&&kH(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(kH(e.cx)&&kH(e.cy)&&kH(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)&&kH(e[0])&&kH(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 AH(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 CH(e,t,n,o,r){if(e===t)return!0;const i=n.dataRoles.map(e=>dL(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 MH(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 jH(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??cL({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!=wH(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(MH("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(SH),d=u.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;a.push(MH("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(MH("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(MH("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(xH),f=y.filter(e=>!e).length,g=new Set,b=y.filter(e=>!(!e||!g.has(e)&&(g.add(e),1)));a.push(MH("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(MH("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=wH(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)CH(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(MH("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(MH("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(MH("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(MH("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 I=(e.chart?.selectedIds??[]).filter(e=>!g.has(e));e.chart?.selectedIds&&a.push(MH("interaction.selection-reachability","interaction",0===I.length,"Selected/highlighted states resolve to observed marks.",I.length+" selected ids are not reachable in the scene.","fail",{missing:I}));const P=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?dL(n,o,k):void 0}).filter(e=>!!e),T=new Set(P.flatMap(e=>Object.keys(e.values))),_=R.filter(e=>!T.has(e));a.push(MH("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(MH("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 N=e.chart;if(N){for(const[e,n]of[["title",t.accessibility.requiresTitle],["summary",t.accessibility.requiresSummary],["description","required"===t.accessibility.description]])n&&a.push(MH("accessibility."+e,"accessibility","string"==typeof N[e]&&N[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(MH("accessibility.fallback-table","accessibility",!1!==N.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),N.navigationTree&&a.push(MH("accessibility.navigation-depth","accessibility",(N.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const $=e.theme?.background??"#ffffff",D=n.filter(e=>{const t=e.style?.fill??e.fill;if("string"!=typeof t||!t.startsWith("#")||!$.startsWith("#"))return!1;const n=zD(t,$);return null!=n&&3>n}).length;a.push(MH("visual.contrast","visual",0===D,"All statically checkable mark fills meet 3:1 contrast.",D+" marks have fill contrast below 3:1.","warn",{background:$}));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>AH(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(aL).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}}bH.displayName="GeoCustomChart";var IH=d(require("react"));function PH(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 RH(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 TH=require("react/jsx-runtime");function _H({manifest:e,label:t="Intent Mark",className:n,showSummary:o=!0}){const[r,i]=IH.useState(!1),s=IH.useMemo(()=>JSON.stringify(e,null,2),[e]),a=IH.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(s),i(!0),window.setTimeout(()=>i(!1),1200))},[s]);return(0,TH.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,TH.jsxs)("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),(0,TH.jsxs)("div",{style:{padding:"0 10px 10px"},children:[o&&(0,TH.jsx)("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:PH(e)}),(0,TH.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,TH.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 LH=[{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"}],NH=new Map(LH.map(e=>[e.id,e]));function $H(e){return NH.get(e)}function DH(){return Array.from(NH.values())}function BH(e){NH.set(e.id,e)}var EH=new Set(LH.map(e=>e.id)),OH=new Set;function FH(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function zH(e,t){return void 0===e?0:FH("function"==typeof e?e(t):e,0,5)}function HH(e){return e?Array.isArray(e)?[...e]:[e]:[]}function WH(e,t,n){const o={};for(const[n,r]of Object.entries(e.intentScores))o[n]=zH(r,t);if(n)for(const[e,t]of Object.entries(n))o[e]=FH((o[e]??0)+t,0,5);return o}function qH(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 GH(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 YH(e,t,n){return e.some(e=>e.props?.[t]===n)}var VH=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);var XH=(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=HH(n.intent),s=[];for(const e of r)s.push(GH(t,e));const a=i.includes("rank")||i.includes("compare-categories");!VH.has(e)||"categorical"!==t.family||YH(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=YH(r,"normalize",!0)||YH(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=dO().filter(t=>t.component!==e).filter(e=>null===e.fits(o)).map(e=>{const t=WH(e,o);return{candidate:e,fit:qH(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 OH)try{r(o(e,t,n)??[])}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e)}return Array.from(o.values())}(e,t,n),UH=(e,t,n,o={})=>{const r=hO(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=HH(o.intent),a=WH(r,t,e.intentDeltas),c=qH(a,s),l=function(e,t){return t?{familiarity:Math.round(FH((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(FH(n.accuracy,1,5)),precision:Math.round(FH(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=gO(aB(e.baseComponent,i),d)}const h=bO(c,l,e.baseComponent,n,u),p=FH(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=FH(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=FH(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 KH(e){return OH.add(e),()=>{OH.delete(e)}}function QH(){return Array.from(OH)}function ZH(){OH.clear()}var JH=require("react"),eW={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function tW(e){if(0===e.length)return eW;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 nW(e={}){const{enableOnMount:t=!0,disableOnUnmount:n=!1,capacity:o,sessionId:r}=e;(0,JH.useEffect)(()=>(t&&zN({capacity:o,sessionId:r}),()=>{n&&HN()}),[t,n,o,r]);const i=(0,JH.useCallback)(e=>RN(e),[]),s=(0,JH.useCallback)(()=>WN().getEvents(),[]),a=(0,JH.useSyncExternalStore)(i,s,s),[c,l]=(0,JH.useState)(()=>WN().enabled),[u,d]=(0,JH.useState)(()=>WN().sessionId);(0,JH.useEffect)(()=>(l(WN().enabled),d(WN().sessionId),RN(()=>{const e=WN();l(e.enabled),d(e.sessionId)})),[]);const h=(0,JH.useMemo)(()=>tW(a),[a]),p=(0,JH.useCallback)(e=>WN().record(e),[]),m=(0,JH.useCallback)(()=>WN().clear(),[]);return{history:a,summary:h,enabled:c,sessionId:u,record:p,clear:m}}var oW=require("react/jsx-runtime");function rW({items:e,title:t="Additional notes",empty:n=null,ordered:o=!0,renderItem:r,className:i,style:s}){if(!e.length)return n?(0,oW.jsx)(oW.Fragment,{children:n}):null;const a=o?"ol":"ul";return(0,oW.jsxs)("section",{className:["semiotic-mobile-annotation-callouts",i].filter(Boolean).join(" "),style:s,children:[(0,oW.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,oW.jsx)("h3",{children:t}),(0,oW.jsx)(a,{children:e.map((e,t)=>(0,oW.jsx)("li",{children:r?r(e,t):(0,oW.jsxs)(oW.Fragment,{children:[(0,oW.jsx)("span",{children:e.label}),(e.source||e.emphasis)&&(0,oW.jsx)("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}
2
+ module.exports=require("./semiotic-client-cjs-shared.min.js").ai;