semiotic 3.8.0 → 3.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/CLAUDE.md +14 -9
  2. package/README.md +56 -55
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +240 -30
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +3 -2
  7. package/ai/system-prompt.md +7 -3
  8. package/dist/__tests__/scenarios/mcpProtocolTypes.d.ts +20 -0
  9. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  10. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  11. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  12. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  13. package/dist/chunk-chunk-27HVVXS6.module.min.js +1 -0
  14. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  15. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  16. package/dist/chunk-chunk-2UN3ANRN.module.min.js +2 -0
  17. package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
  18. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  19. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  20. package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
  21. package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
  22. package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
  23. package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
  24. package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
  25. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  26. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  27. package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
  28. package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
  29. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  30. package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
  31. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  32. package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
  33. package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
  34. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  35. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  36. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  37. package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
  38. package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
  39. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  40. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  41. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  42. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  43. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  44. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  45. package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
  46. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  47. package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
  48. package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
  49. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
  50. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  51. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  52. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  53. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  54. package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
  55. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  56. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  57. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  58. package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
  59. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  60. package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
  61. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
  62. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  63. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  64. package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
  65. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  66. package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
  67. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  68. package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
  69. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  70. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  71. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  72. package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
  73. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  74. package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
  75. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
  76. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  77. package/dist/components/AccessibleNavTree.d.ts +7 -1
  78. package/dist/components/ai/chartClinicMetadata.generated.d.ts +15 -0
  79. package/dist/components/ai/useNavigationSync.d.ts +17 -2
  80. package/dist/components/chartContainerMobile.d.ts +9 -0
  81. package/dist/components/charts/geo/ChoroplethMap.d.ts +19 -2
  82. package/dist/components/charts/geo/DistanceCartogram.d.ts +14 -2
  83. package/dist/components/charts/geo/FlowMap.d.ts +10 -6
  84. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +14 -2
  85. package/dist/components/charts/index.d.ts +6 -0
  86. package/dist/components/charts/network/ChordDiagram.d.ts +9 -1
  87. package/dist/components/charts/network/ForceDirectedGraph.d.ts +11 -0
  88. package/dist/components/charts/network/SankeyDiagram.d.ts +9 -1
  89. package/dist/components/charts/ordinal/BarChart.d.ts +21 -0
  90. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +11 -0
  91. package/dist/components/charts/ordinal/StackedBarChart.d.ts +11 -0
  92. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +7 -0
  93. package/dist/components/charts/physics/EventDropChart.d.ts +7 -0
  94. package/dist/components/charts/physics/GaltonBoardChart.d.ts +8 -0
  95. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  96. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +4 -25
  97. package/dist/components/charts/physics/PhysicsPileChart.d.ts +7 -0
  98. package/dist/components/charts/physics/physicsChartShared.d.ts +17 -1
  99. package/dist/components/charts/physics/physicsCustomLayout.d.ts +32 -0
  100. package/dist/components/charts/shared/AnnotationLabel.d.ts +88 -0
  101. package/dist/components/charts/shared/annotationActivation.d.ts +35 -0
  102. package/dist/components/charts/shared/annotationLabelLayout.d.ts +5 -0
  103. package/dist/components/charts/shared/annotationRules.d.ts +2 -1
  104. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  105. package/dist/components/charts/shared/chartSelectionUtils.d.ts +4 -0
  106. package/dist/components/charts/shared/chartSpecCore.d.ts +3 -3
  107. package/dist/components/charts/shared/datumTypes.d.ts +2 -0
  108. package/dist/components/charts/shared/diagnoseAnnotationChecks.d.ts +2 -0
  109. package/dist/components/charts/shared/formatUtils.d.ts +3 -3
  110. package/dist/components/charts/shared/hatchFill.d.ts +87 -0
  111. package/dist/components/charts/shared/hooks.d.ts +7 -6
  112. package/dist/components/charts/shared/knownChartComponents.d.ts +9 -0
  113. package/dist/components/charts/shared/leastSquaresRegression.d.ts +16 -0
  114. package/dist/components/charts/shared/mergeShapeStyle.d.ts +3 -2
  115. package/dist/components/charts/shared/semanticInteractions.d.ts +42 -0
  116. package/dist/components/charts/shared/sparseArray.d.ts +1 -1
  117. package/dist/components/charts/shared/streamPropsHelpers.d.ts +6 -4
  118. package/dist/components/charts/shared/styleRules.d.ts +205 -0
  119. package/dist/components/charts/shared/tooltipUtils.d.ts +22 -9
  120. package/dist/components/charts/shared/types.d.ts +9 -6
  121. package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +16 -2
  122. package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
  123. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  124. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -2
  125. package/dist/components/charts/shared/useLikertAggregation.d.ts +4 -4
  126. package/dist/components/charts/shared/useOrdinalBrush.d.ts +2 -1
  127. package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +24 -1
  128. package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
  129. package/dist/components/charts/shared/useXYLineStyle.d.ts +10 -0
  130. package/dist/components/charts/shared/useXYPointStyle.d.ts +19 -1
  131. package/dist/components/charts/shared/validateChartData.d.ts +7 -5
  132. package/dist/components/charts/shared/validationMap.d.ts +11 -2
  133. package/dist/components/charts/shared/validationMap.generated.d.ts +6 -0
  134. package/dist/components/charts/shared/withChartWrapper.d.ts +4 -3
  135. package/dist/components/charts/value/targetPresentation.d.ts +22 -0
  136. package/dist/components/charts/value/types.d.ts +5 -6
  137. package/dist/components/charts/xy/AreaChart.d.ts +8 -0
  138. package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
  139. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +7 -0
  140. package/dist/components/charts/xy/DifferenceChart.d.ts +1 -52
  141. package/dist/components/charts/xy/Heatmap.d.ts +2 -2
  142. package/dist/components/charts/xy/LineChart.d.ts +11 -0
  143. package/dist/components/charts/xy/QuadrantChart.d.ts +7 -0
  144. package/dist/components/charts/xy/Scatterplot.d.ts +10 -0
  145. package/dist/components/charts/xy/StackedAreaChart.d.ts +7 -0
  146. package/dist/components/charts/xy/differenceSegments.d.ts +49 -0
  147. package/dist/components/charts/xy/scatterplotMatrixInteractionTypes.d.ts +12 -0
  148. package/dist/components/controls/SentenceFilter.d.ts +97 -0
  149. package/dist/components/data/fromVegaLite.d.ts +19 -9
  150. package/dist/components/rough/createRoughRenderMode.d.ts +46 -0
  151. package/dist/components/semiotic-ai.d.ts +3 -1
  152. package/dist/components/semiotic-controls.d.ts +2 -0
  153. package/dist/components/semiotic-geo.d.ts +4 -0
  154. package/dist/components/semiotic-network.d.ts +4 -0
  155. package/dist/components/semiotic-ordinal.d.ts +6 -0
  156. package/dist/components/semiotic-physics.d.ts +4 -0
  157. package/dist/components/semiotic-rough.d.ts +4 -0
  158. package/dist/components/semiotic-utils-core.d.ts +4 -0
  159. package/dist/components/semiotic-xy.d.ts +4 -0
  160. package/dist/components/semiotic.d.ts +9 -1
  161. package/dist/components/server/optionalImageTypes.d.ts +37 -0
  162. package/dist/components/server/serverChartConfigShared.d.ts +9 -5
  163. package/dist/components/server/serverChartConfigs.d.ts +4 -4
  164. package/dist/components/server/staticAnnotations.d.ts +6 -3
  165. package/dist/components/server/staticLegend.d.ts +1 -1
  166. package/dist/components/server/staticNetwork.d.ts +4 -4
  167. package/dist/components/server/staticSVGChrome.d.ts +5 -4
  168. package/dist/components/store/ObservationStore.d.ts +21 -1
  169. package/dist/components/stream/AccessibleDataTable.d.ts +4 -10
  170. package/dist/components/stream/AriaLiveTooltip.d.ts +9 -0
  171. package/dist/components/stream/CanvasHitTester.d.ts +4 -4
  172. package/dist/components/stream/DataSourceAdapter.d.ts +1 -1
  173. package/dist/components/stream/FrameRuntime.d.ts +57 -0
  174. package/dist/components/stream/GeoParticlePool.d.ts +1 -1
  175. package/dist/components/stream/GeoPipelineStore.d.ts +43 -12
  176. package/dist/components/stream/GeoSVGOverlay.d.ts +64 -0
  177. package/dist/components/stream/NetworkCanvasHitTester.d.ts +2 -1
  178. package/dist/components/stream/NetworkPipelineStore.d.ts +24 -21
  179. package/dist/components/stream/NetworkSSRFrame.d.ts +17 -0
  180. package/dist/components/stream/NetworkSVGOverlay.d.ts +6 -0
  181. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  182. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  183. package/dist/components/stream/OrdinalCanvasHitTester.d.ts +2 -2
  184. package/dist/components/stream/OrdinalPipelineStore.d.ts +13 -13
  185. package/dist/components/stream/OrdinalSVGOverlay.d.ts +9 -1
  186. package/dist/components/stream/OrdinalStyleResolver.d.ts +12 -0
  187. package/dist/components/stream/ParticlePool.d.ts +1 -1
  188. package/dist/components/stream/PipelineStore.d.ts +12 -16
  189. package/dist/components/stream/SVGOverlay.d.ts +6 -0
  190. package/dist/components/stream/SceneGraph.d.ts +3 -3
  191. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  192. package/dist/components/stream/accessorUtils.d.ts +2 -2
  193. package/dist/components/stream/annotationAccessorResolver.d.ts +2 -2
  194. package/dist/components/stream/frameGraphics.d.ts +4 -0
  195. package/dist/components/stream/frameKeyboardNavigation.d.ts +45 -0
  196. package/dist/components/stream/geoPipelineHelpers.d.ts +3 -3
  197. package/dist/components/stream/geoPipelineUpdateResults.d.ts +34 -0
  198. package/dist/components/stream/geoSceneBuilder.d.ts +16 -0
  199. package/dist/components/stream/geoTypes.d.ts +48 -15
  200. package/dist/components/stream/hitTestUtils.d.ts +2 -2
  201. package/dist/components/stream/hoverUtils.d.ts +4 -2
  202. package/dist/components/stream/layouts/forceLayoutWorkerClient.d.ts +1 -0
  203. package/dist/components/stream/layouts/hierarchyUtils.d.ts +2 -2
  204. package/dist/components/stream/networkCustomLayoutRunner.d.ts +23 -0
  205. package/dist/components/stream/networkCustomRestyle.d.ts +15 -0
  206. package/dist/components/stream/networkFrameAnimation.d.ts +7 -0
  207. package/dist/components/stream/networkFrameHandleTypes.d.ts +39 -0
  208. package/dist/components/stream/networkFrameObservations.d.ts +15 -0
  209. package/dist/components/stream/networkFramePaint.d.ts +11 -2
  210. package/dist/components/stream/networkInteractionTypes.d.ts +26 -0
  211. package/dist/components/stream/networkPipelineConfig.d.ts +2 -2
  212. package/dist/components/stream/networkPipelineUpdateResults.d.ts +38 -0
  213. package/dist/components/stream/networkTypes.d.ts +37 -56
  214. package/dist/components/stream/ordinalCanvasRenderers.d.ts +2 -2
  215. package/dist/components/stream/ordinalPipelineUpdateResults.d.ts +20 -1
  216. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -2
  217. package/dist/components/stream/ordinalTypes.d.ts +30 -3
  218. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +2 -0
  219. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +6 -0
  220. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +21 -6
  221. package/dist/components/stream/physics/physicsFrameObservations.d.ts +19 -0
  222. package/dist/components/stream/physics/physicsFrameSetup.d.ts +4 -0
  223. package/dist/components/stream/physics/physicsPipelineUpdateResults.d.ts +19 -1
  224. package/dist/components/stream/physics/usePhysicsFrameLifecyclePolicy.d.ts +3 -1
  225. package/dist/components/stream/pipelineConfig.d.ts +4 -2
  226. package/dist/components/stream/pipelineDecay.d.ts +2 -2
  227. package/dist/components/stream/pipelinePulse.d.ts +2 -2
  228. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +23 -2
  229. package/dist/components/stream/pipelineTransitions.d.ts +1 -1
  230. package/dist/components/stream/pipelineUpdateContract.d.ts +7 -0
  231. package/dist/components/stream/pipelineUpdateStore.d.ts +21 -0
  232. package/dist/components/stream/renderBackend.d.ts +27 -0
  233. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +15 -1
  234. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +3 -2
  235. package/dist/components/stream/renderers/networkParticleRenderer.d.ts +1 -1
  236. package/dist/components/stream/sceneRenderBackendTypes.d.ts +28 -0
  237. package/dist/components/stream/sceneRevisionDiagnostics.d.ts +31 -4
  238. package/dist/components/stream/streamSemanticTypes.d.ts +16 -0
  239. package/dist/components/stream/streamThemeTypes.d.ts +14 -0
  240. package/dist/components/stream/svgOverlayUtils.d.ts +10 -0
  241. package/dist/components/stream/test-utils/frameScheduler.d.ts +12 -0
  242. package/dist/components/stream/test-utils/revisionConsumption.d.ts +13 -0
  243. package/dist/components/stream/titleLayout.d.ts +31 -0
  244. package/dist/components/stream/types.d.ts +30 -65
  245. package/dist/components/stream/useCanvasFrameHost.d.ts +71 -0
  246. package/dist/components/stream/useFrame.d.ts +23 -0
  247. package/dist/components/stream/useLegendCategoryEmission.d.ts +3 -3
  248. package/dist/components/stream/useSemanticFrameInteractions.d.ts +22 -0
  249. package/dist/components/stream/useUpdateResultSnapshot.d.ts +7 -0
  250. package/dist/components/stream/xyFrameAxisTypes.d.ts +50 -0
  251. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -5
  252. package/dist/controls.min.js +1 -1
  253. package/dist/controls.module.min.js +1 -1
  254. package/dist/forceLayoutWorker.js +1 -1
  255. package/dist/geo.min.js +1 -1
  256. package/dist/geo.module.min.js +1 -1
  257. package/dist/network.min.js +1 -1
  258. package/dist/network.module.min.js +1 -1
  259. package/dist/ordinal.min.js +1 -1
  260. package/dist/ordinal.module.min.js +1 -1
  261. package/dist/physics-matter.min.js +1 -1
  262. package/dist/physics-matter.module.min.js +1 -1
  263. package/dist/physics-rapier.min.js +1 -1
  264. package/dist/physics-rapier.module.min.js +1 -1
  265. package/dist/physics.min.js +1 -1
  266. package/dist/physics.module.min.js +1 -1
  267. package/dist/physicsWorker.js +1 -1
  268. package/dist/realtime.min.js +1 -1
  269. package/dist/realtime.module.min.js +1 -1
  270. package/dist/rough.min.js +1 -0
  271. package/dist/rough.module.min.js +1 -0
  272. package/dist/semiotic-ai-core.min.js +1 -1
  273. package/dist/semiotic-ai-core.module.min.js +1 -1
  274. package/dist/semiotic-ai.d.ts +3 -1
  275. package/dist/semiotic-ai.min.js +1 -1
  276. package/dist/semiotic-ai.module.min.js +1 -1
  277. package/dist/semiotic-controls.d.ts +2 -0
  278. package/dist/semiotic-data.min.js +1 -1
  279. package/dist/semiotic-data.module.min.js +1 -1
  280. package/dist/semiotic-experimental.min.js +1 -1
  281. package/dist/semiotic-experimental.module.min.js +1 -1
  282. package/dist/semiotic-geo.d.ts +4 -0
  283. package/dist/semiotic-network.d.ts +4 -0
  284. package/dist/semiotic-ordinal.d.ts +6 -0
  285. package/dist/semiotic-physics.d.ts +4 -0
  286. package/dist/semiotic-realtime-core.min.js +1 -1
  287. package/dist/semiotic-realtime-core.module.min.js +1 -1
  288. package/dist/semiotic-realtime-react.min.js +1 -1
  289. package/dist/semiotic-realtime-react.module.min.js +1 -1
  290. package/dist/semiotic-recipes-core.min.js +1 -1
  291. package/dist/semiotic-recipes-core.module.min.js +1 -1
  292. package/dist/semiotic-recipes-react.min.js +1 -1
  293. package/dist/semiotic-recipes-react.module.min.js +1 -1
  294. package/dist/semiotic-recipes.min.js +1 -1
  295. package/dist/semiotic-recipes.module.min.js +1 -1
  296. package/dist/semiotic-rough.d.ts +4 -0
  297. package/dist/semiotic-server-edge.min.js +1 -1
  298. package/dist/semiotic-server-edge.module.min.js +1 -1
  299. package/dist/semiotic-server-node.min.js +1 -1
  300. package/dist/semiotic-server-node.module.min.js +1 -1
  301. package/dist/semiotic-themes-core.min.js +1 -1
  302. package/dist/semiotic-themes-core.module.min.js +1 -1
  303. package/dist/semiotic-themes-react.min.js +1 -1
  304. package/dist/semiotic-themes-react.module.min.js +1 -1
  305. package/dist/semiotic-themes.min.js +1 -1
  306. package/dist/semiotic-themes.module.min.js +1 -1
  307. package/dist/semiotic-utils-core.d.ts +4 -0
  308. package/dist/semiotic-utils-core.min.js +1 -1
  309. package/dist/semiotic-utils-core.module.min.js +1 -1
  310. package/dist/semiotic-utils-react.min.js +1 -1
  311. package/dist/semiotic-utils-react.module.min.js +1 -1
  312. package/dist/semiotic-utils.min.js +1 -1
  313. package/dist/semiotic-utils.module.min.js +1 -1
  314. package/dist/semiotic-value.min.js +1 -1
  315. package/dist/semiotic-value.module.min.js +1 -1
  316. package/dist/semiotic-xy.d.ts +4 -0
  317. package/dist/semiotic.d.ts +9 -1
  318. package/dist/semiotic.min.js +1 -1
  319. package/dist/semiotic.module.min.js +1 -1
  320. package/dist/server.min.js +1 -1
  321. package/dist/server.module.min.js +1 -1
  322. package/dist/test-utils/capturedFrameProps.d.ts +67 -0
  323. package/dist/test-utils/frameMock.d.ts +12 -9
  324. package/dist/xy.min.js +1 -1
  325. package/dist/xy.module.min.js +1 -1
  326. package/package.json +29 -10
  327. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  328. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  329. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  330. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  331. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{useRef as e,useState as t,useEffect as n,useMemo as r,useCallback as o,useImperativeHandle as i,forwardRef as a,memo as s}from"react";function l(e){return Array.isArray(e)?e[0]:e}function c(e,t,n,r){return{data:l(e),x:t,y:n,__semioticHoverData:!0,...r}}var u={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},d={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};function h(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function f(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function g(e){const t=e.map(h),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return f(e,n,r)}if(e>=1){const[e,r,o]=t[n];return f(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return f(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var y=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],p=g(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),m=g(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),b=g(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),v=g(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),x=g(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),k=g(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),w={blues:p,reds:m,greens:b,viridis:g(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:v,purples:x,greys:k,plasma:g(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:g(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:g(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:g(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:g(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])},S=(g(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),g(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),g(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),g(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),g(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),g(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),g(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=n[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?A(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}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 A(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];M(c,u,d,h,l,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;o.x+=-g/y*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,a,s]=e.points;M(o,i,a,s,t,r);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function M(e,t,n,r,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*n.x+u*r.x,i.y=l*e.y+3*s*o*t.y+3*a*c*n.y+u*r.y}function L(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function C(e,t){var n,r=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}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,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=r[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>a[y]||s[t].push(a[y])}i[t]=g}else{if(r[t]===n[t]){var p=[],m=[],b=0;for(g=l.length-1;g>=0;--g){var v=l[g];if(o[v]=!1,p.push(v),m.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){l.length=g;break}}d.push(p);var x=Array(b);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--b]=m[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],n=a);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return t?void 0:r}function E(e){return e.y0-e.y1>0?"up":"down"}function D(e,t){return t(e.source)==t(e.target)}function N(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 I(e){return e.target.x0-e.source.x1}function T(e,t){var n=P(e),r=I(t)/Math.tan(n);return"up"==E(e)?e.y1-r:e.y1+r}function _(e,t){var n=P(e),r=I(t)/Math.tan(n);return"up"==E(e)?e.y1+r:e.y1-r}function P(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function R(e,t){return t(e)}function $(e){return O(e.source)}function W(e){return O(e.target)}function O(e){return(e.y0+e.y1)/2}function z(e){return e.virtual?0:e.value}function B(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!D(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!D(e,t)?r+1:r}),n+r}function j(e){return e.target.depth}function H(e,t){return e.sourceLinks.length?e.depth:t-1}function F(e,t){return e.y0-t.y0}function Y(e,t){return t.y0-e.y0}function X(e,t){return e.y1-t.y1}function G(e,t){return t.y1-e.y1}function q(e,t){return Q(e.source,t.source)||e.index-t.index}function V(e,t){return Q(e.target,t.target)||e.index-t.index}function Q(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function K(e,t){return Z(e)==Z(t)?"bottom"==e.circularLinkType?Y(e,t):F(e,t):Z(t)-Z(e)}function Z(e){return e.target.column-e.source.column}function U(e,t){return J(e)==J(t)}function J(e){return e.y0-e.y1>0?"up":"down"}import{min as ee}from"d3-array";function te(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=ee(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),ne(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),ne(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+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,D(e,t)&&N(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+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-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Y:F);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?G:X),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-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,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function ne(e,t,n){e.sort(K);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(D(e,t)&&N(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&re(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function re(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as oe,max as ie,sum as ae,mean as se,group as le,groups as ce}from"d3-array";function ue(e){return function(){return e}}function de(e){return e.index}function he(e){return e.nodes}function fe(e){return e.links}function ge(e,t,n){var r=ce(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=O(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=O(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=s.get(e),r=s.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?B(t,n)-B(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==B(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function ye(e,t,n,r,o,i){var a=ce(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&B(o,n)>0){var l=se(o.sourceLinks,W),c=se(o.targetLinks,$),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-O(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=se(o.sourceLinks,W),f=se(o.targetLinks,$),g=((h&&f?(h+f)/2:h||f)-O(o))*t;o.y0+=g,o.y1+=g}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||Q),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+r;if((a=l-r-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+o-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function pe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(V),e.targetLinks.sort(q)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function me(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=de,l=H,c=void 0,u=32,d=2,h=he,f=fe;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,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 le(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 r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=L(n,r)),"object"!=typeof o&&(o=e.target=L(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=C(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=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,c),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){R(e,t)!=R(o.source,t)&&R(e,t)!=R(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),D(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(ae(e.sourceLinks,z),ae(e.targetLinks,z)),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 r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,l);var f=i;if(null!==a){var g=ce(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=ie(g,function(e){return e.length});y>1&&(f=Math.max(1,(r-t)*a/(y-1)))}(function(e,t,n){var r=ce(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 o=oe(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/ae(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=ie(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,f,o),ge(h,c,s),ye(h,c,s,f,f,u),pe(h),te(h,s,d,10,8),ge(h,c,s),ye(h,c,s,f,f,u),pe(h),te(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return R(n.source,t)==R(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!U(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=T(t,e);return e.y1-n}if(t.target.column>e.target.column)return T(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return R(n.target,t)==R(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!U(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=_(t,e);return e.y0-n}if(t.source.column>e.source.column)return _(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=oe(t,function(e){return e.y0}),a=ie(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(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),te(h,s,d,10,8)}(g),g}return g.update=function(e){return pe(e),te(e,s,d,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:ue(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:ue(e),g):f},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:ue(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:ue(e),g):l},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}import{interpolateNumber as be}from"d3-interpolate";import{line as ve,curveLinearClosed as xe}from"d3-shape";function ke(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+r)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${o},${i}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}var we=e=>{let t,n,r,o,i,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=be(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,d=be(e.source.x1,e.target.x0),{pathD:h}=ke({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 Se(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+s},${o-t}L${n+s},${o+t}L${n},${o+t}ZM${i},${a-t}L${i-l},${a-t}L${i-l},${a+t}L${i},${a+t}Z`}const o=r.sourceX,i=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${i-d*t}L${l},${i-d*t}L${l+n},${i-d*t+d*h}L${l+n},${u+d*n-d*h}L${l+n-h},${u+d*n}L${c-n+h},${u+d*n}L${c-n},${u+d*n-d*h}L${c-n},${s-d*t+d*h}L${c-n+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+n},${s+d*t}L${c+n},${u-d*n}L${l-n},${u-d*n}L${l-n},${i+d*t}L${o},${i+d*t}Z`}var Ae=new Set,Me=new WeakMap;function Le(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Me.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Me.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Ae.has(e)||(Ae.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,r)}});return n.set(t,r),r}var Ce={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(j))-1:0},justify:H};function Ee(e){return"string"==typeof e?e:e.id}var De={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=me().extent(d).links(u).nodes(c).nodeAlign(Ce[i]||H).nodeId(e=>e.id).nodeWidth(a).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-n,s=r[0],l=r[1];if(i>0&&a>0&&(0>e||0>n||t>s||o>l)){const t=Math.min(s/i,l/a),r=-e*t+(s-i*t)/2,o=-n*t+(l-a*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,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 f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.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 g=new Map;for(const e of t)g.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Ee(e.source),n=Ee(e.target),r=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),a=f.get(n);i&&(r.source=i),a&&(r.target=a)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:y,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],f=[],g=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 r=i?i(Le(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:a,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?g.get(r.id)||u.get(r.id)||o:g.get(t.id)||u.get(t.id)||o;const i=a?a(Le(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?Se(e):we(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(m=n.nodeLabel)?"function"==typeof m?m:e=>e[m]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,l,c;"down"===o?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(s=n.x0-6,c="end"):(s=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:s,y:l,text:a+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:d,sceneEdges:h,labels:f}}};import{forceSimulation as Ne,forceCenter as Ie,forceX as Te,forceY as _e,forceLink as Pe,forceManyBody as Re,forceCollide as $e}from"d3-force";import{scaleLinear as We}from"d3-scale";function Oe(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var ze={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,a=r[1]/2,s=n.__previousPositions;let l=0;const c=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=s?.get(t.id);e?l++:n?(t.x=n.x,t.y=n.y,l++):c.push(t)}const u=l>0&&.3>=(e.length>0?c.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of c){const r=Be(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=je(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/r.length+a*Math.cos(i),e.y=n/r.length+a*Math.sin(i)}else{const t=je(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(n),e.y=a+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=i+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}const d=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=He(n.nodeSize,n.nodeSizeRange,e),f=e=>h(e);if(d>0){const n=new Map,r=new Map;for(const t of e)n.set(t.id,0),r.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(r,(n.get(r)??0)+1)}const s=Pe().strength(e=>{const t=e.weight,r="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(n.get("string"==typeof e.source?e.source:e.source.id)??1,n.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?r.get(e.source):e.source,n="string"==typeof e.target?r.get(e.target):e.target,o=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,o)}).id(e=>e.id),l=Ne().force("charge",Re().strength(e=>{const t=n.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",$e(e=>f(e)+3).strength(.9).iterations(2)).force("center",Ie(i,a).strength(.8)).force("x",Te(i).strength(.06)).force("y",_e(a).strength(.06));if(l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));s.links(e),l.force("link",s)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;d>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,a=He(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:y,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Le(t,"nodeSize")),r=o?o(Le(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(Le(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=a(Le(n,"nodeSize"));d.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:d}}};function Be(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function je(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 He(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 r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,a]=Oe(o);if(i===a)return()=>(r[0]+r[1])/2;const s=We().domain([i,a]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:s(n)}}import{chord as Fe,ribbon as Ye}from"d3-chord";import{arc as Xe}from"d3-shape";var Ge=y,qe={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(r[0],r[1])/2,l=s-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=d(e);y[n][r]=o}const p=Fe().padAngle(o);a&&p.sortGroups(a);const m=p(y),b=m.groups,v=Xe().innerRadius(l).outerRadius(s);for(const t of b){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=x.get("string"==typeof e.source?e.source:e.source.id),r=x.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Ge,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const y=Ye().radius(s),p=[],m=[],b=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(Le(n,"nodeStyle")).fill||g.get(n.id)||f[t%f.length]:g.get(n.id)||f[t%f.length];const i=u?u(Le(n,"nodeStyle")):{};p.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,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 r=y(t);if(!r)continue;const o=Ve(r,l,c);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)a=d(Le(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?a=g.get(n.id)||a:t&&(a=g.get(t.id)||a)}const s=d?d(Le(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:p,sceneEdges:m,labels:b}}};function Ve(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as Qe,tree as Ke,cluster as Ze,treemap as Ue,pack as Je,partition as et,treemapBinary as tt}from"d3-hierarchy";var nt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function rt(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function ot(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function it(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 at(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:nt}function st(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 lt(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var ct={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=Qe(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=Ke();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=Ze();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,a=Ue().size([n,r]).tile(tt).padding(o);i>0&&a.paddingTop(i),a(e)}(c,n,u,d);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;Je().size([n,r]).padding(o)(e)}(c,n,u,d);break;case"partition":!function(e,t,n,r){et().size([n,r]).padding(t.padding??1)(e)}(c,n,u,d)}const h=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const r=h[t],o={id:ot(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?ut(o,r,n):"treemap"===i||"partition"===i?dt(o,r):"circlepack"===i&&ht(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const a=[],s=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=o(Le(t,"nodeStyle"));let s=i.fill||st(n);if(n.colorByDepth&&void 0!==t.depth){const e=at(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);const g=lt(o,a,l,f,c),p=i(Le(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:p.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??y},datum:e})}if(!1!==n.showLabels){const t=it(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,s=n.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=s+t/n*10,i=0>e?"end":"start"):(r=a,o=s-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=a-f-6,i="end"):(r=a+f+6,i="start"),o=s):(r=a,o=s+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Le(n,"nodeStyle"));let s=a.fill||st(t);if(t.colorByDepth&&void 0!==n.depth){const e=at(t);s=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=it(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;const c=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Le(s,"nodeStyle")).fill||st(t);if(t.colorByDepth&&void 0!==s.depth){const e=at(t);d=e[s.depth%e.length]}const h="string"==typeof d?rt(d):t.themeSemantic?.text??"#000";i.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(Le(n,"nodeStyle"));let a=i.fill||st(t);if(t.colorByDepth&&void 0!==n.depth){const e=at(t);a=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=it(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=n?n(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let l=r(Le(o,"nodeStyle")).fill||st(t);if(t.colorByDepth&&void 0!==o.depth){const e=at(t);l=e[o.depth%e.length]}if(s){const n="string"==typeof l?rt(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ut(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function dt(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 ht(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}import{pie as ft}from"d3-shape";function gt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var yt={sankey:De,force:ze,chord:qe,tree:ct,cluster:ct,treemap:ct,circlepack:ct,partition:ct,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=gt(n);h.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function g(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,b=g(a(e));r.push({id:b,x:y,y:p,x0:y,x1:y,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,y,p){const m=i(t);if(!m?.length)return;const b=m.length;let v=0,x=0,k=0;for(;b>x;)x+=s[Math.min(k,s.length-1)],k++,v++;let w=0;for(let b=0;v>b;b++){const x=s[Math.min(b,s.length-1)],k=m.slice(w,w+x);if(!k.length)break;const S=(b+1)/v,A={id:n,depth:y,data:t,parentId:n},M=p?f/u(A)*S:f*S,L=ft().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),C=d(A);for(let t=0;k.length>t;t++){const i=(L[t].startAngle+L[t].endAngle)/2,s=k[t],u=g(a(s)),d=l+M*Math.sin(i),f=c+M*Math.cos(i)*C;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:s}),h.metaMap.set(u,{ring:M,angle:i,depth:y,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,M,y+1,!0)}w+=x}}(e,b,y,p,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=gt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Le(t,"nodeSize")),r=o?o(Le(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=a(Le(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=gt(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const l=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function pt(e){return yt[e]}import{scaleOrdinal as mt}from"d3-scale";var bt={category10:y,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...w},vt=y,xt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],kt=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],wt=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 St(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||wt.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):vt[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)}(r))%vt.length]}function At(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 Mt(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>At(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return mt().domain(r).range(n).unknown("#999");const i=bt[n]||bt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:vt;return mt().domain(r).range(e).unknown("#999")}}function Lt(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&At(n,e)||"#4e79a7":t=>{if(n){const e=At(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Ct(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Ct))}function Et(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function Dt(e,t,n){return e+(t-e)*n}function Nt(){return"undefined"!=typeof performance?performance.now():Date.now()}import{quadtree as It}from"d3-quadtree";function Tt(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 _t(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(!Pt(e))return!1;return!0}return Pt(t.points)}function Pt(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Rt}from"d3-interpolate";function $t(e,t,n){if(1>=n)return 1;const r=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 r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}var Wt="rgba(34, 197, 94, 0.7)",Ot=2e3,zt=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this._stylePaintPending=!1,this.config=e,this.tensionConfig={...u,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new S(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(e.layoutSelection=t.layoutSelection),this.config=e,this.tensionConfig={...u,...e.tensionConfig},!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new S(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...Tt(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,{...Tt(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...Tt(o),data:n});const l=`${r}\0${o}\0${e}`,h={source:r,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&_t(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(n)}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:r}=e,o=0===this.nodes.size;let i=!1;const a=Nt();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Tt(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Tt(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;return l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0),o||i||c||this.tension>=this.tensionConfig.threshold}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=pt(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=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,r,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;r.length>e;e++){const t=r[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 o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&n.length>0&&a>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:Nt(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:Nt(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=Nt()),this.previousNodeIds=e,this.previousEdgeKeys=t}setLayoutSelection(e){this.config.layoutSelection=e}snapshotBaseStyles(){this._baseStyles=new WeakMap;for(const e of this.sceneNodes)this._baseStyles.set(e,e.style);for(const e of this.sceneEdges)this._baseStyles.set(e,e.style)}consumeStylePaintPending(){const e=this._stylePaintPending;return this._stylePaintPending=!1,e}restyleScene(e){if(this._customRestyle){const t=this._customRestyle;for(const n of this.sceneNodes){const r=this._baseStyles.get(n)??n.style,o=t(n,e);n.style=o?{...r,...o}:r}}if(this._customRestyleEdge){const t=this._customRestyleEdge;for(const n of this.sceneEdges){const r=this._baseStyles.get(n)??n.style,o=t(n,e);n.style=o?{...r,...o}:r}}this._stylePaintPending=!0}buildScene(e){if(this.config.customNetworkLayout){const t=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),r=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=bt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(this.config.colorScheme,this.config.themeCategorical,y),o={nodes:t,edges:n,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:this.config.themeSemantic??{},categorical:[...r]},resolveColor:Lt(r,this.config.colorScheme),config:this.config.layoutConfig??{},selection:this.config.layoutSelection??null};let i;try{i=this.config.customNetworkLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,n=function(e,t,n,r){const o=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: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}("network",e,t,this.layoutVersion);this.lastCustomLayoutFailure=n,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e);try{this.config.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return void(t||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++))}return this.sceneNodes=i.sceneNodes??[],this.sceneEdges=i.sceneEdges??[],this.labels=i.labels??[],this.customLayoutOverlays=i.overlays??null,this.customLayoutHtmlMarks=i.htmlMarks??[],this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=i.restyle,this._customRestyleEdge=i.restyleEdge,this.hasCustomRestyle=!(!i.restyle&&!i.restyleEdge),this.hasCustomRestyle&&(this.snapshotBaseStyles(),this.restyleScene(this.config.layoutSelection??null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;Ct(r)&&0===n.length&&Et(o,"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)&&Et(o,"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.`)}({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=pt(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=It().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=pt(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=pt(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,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=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Dt(e._prevX0,e._targetX0,n),e.x1=Dt(e._prevX1,e._targetX1,n),e.y0=Dt(e._prevY0,e._targetY0,n),e.y1=Dt(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=Dt(e._prevY0,e._targetY0,n),e.y1=Dt(e._prevY1,e._targetY1,n),e.sankeyWidth=Dt(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 r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(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))),r=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-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="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 o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,a=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=Rt(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(r)},{x:e.y1,y:s(1-r)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=Rt(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(r),y:e.y0},{x:s(1-r),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,r,o,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,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const l=i-s;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const l=e.edgeTimestamps.get(`${a}\0${s}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const 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 r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const a=$t(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*a}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===Wt&&(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>=Ot)return;const n=1-t/Ot;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=Wt,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&&Ot>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const l=t.metric(s);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const 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 null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=Nt(),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0&&(this.layoutVersion++,this.lastIngestTime=Nt()),i}removeNode(e){if(!this.nodes.has(e))return!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=Nt(),!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 r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&(this.layoutVersion++,this.lastIngestTime=Nt()),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()}};zt.QUADTREE_THRESHOLD=500;var Bt=zt;import*as jt from"react";function Ht(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:jt.createElement(jt.Fragment,null,...t)}import*as Ft from"react";import{jsx as Yt}from"react/jsx-runtime";var Xt={isActive:!1,predicate:()=>!0},Gt=Ft.createContext(null);function qt({value:e,children:t}){return Yt(Gt.Provider,{value:e,children:t})}function Vt(){return Ft.useContext(Gt)??Xt}function Qt(e,t){return null!=e?Yt(qt,{value:t,children:e}):e}import{useEffect as Kt,useRef as Zt}from"react";var Ut=[40,40],Jt=[.5,.5];function en(e,t){const[n,r]=e.viewBox??Ut,[o,i]=e.anchor??Jt,a=r>0?r:1,s=Math.max(0,t)/a,l=(n>0?n:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-i*c}}function tn(e,t){const n=en(e,t),r=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of r){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function nn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var rn=null;function on(e){if("undefined"==typeof Path2D)return null;rn||(rn=new Map);const t=rn.get(e);if(t)return t;const n=new Path2D(e);return rn.size>1024&&rn.clear(),rn.set(e,n),n}function an(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Ut,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:i*(1-s),width:o,height:i*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function sn(e,t){const n=en(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 ln(e,t,n,r,o,i=e=>e){for(const a of t.parts){const t=on(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=o?"none"===a.fill?void 0:o:nn(a.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?a.stroke&&"none"!==a.stroke?o:void 0:nn(a.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function cn(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?un(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?un(n,n.groups[e-1],i[o]):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 un(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function dn(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as hn}from"react/jsx-runtime";var fn="var(--semiotic-focus, #005fcc)";function gn({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!s)if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=hn("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:fn,strokeWidth:2,strokeDasharray:"4,2"})}else u=hn("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:fn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:fn,strokeWidth:2,strokeDasharray:"4,2"});else u=hn("g",{transform:`translate(${n.left},${n.top})`,children:hn("path",{d:s,fill:"none",stroke:fn,strokeWidth:2.5,strokeDasharray:"6,3"})});return hn("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as yn from"react";var pn=["name","label","title"],mn=["type","kind","category","group","class","status","role","shape"],bn=["value","amount","total","count","weight","score"],vn=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 xn(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}import{jsx as kn,jsxs as wn}from"react/jsx-runtime";var Sn={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 An(e,t){return"function"==typeof t?t(e):e[t]}function Mn(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 Ln(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=An(e,n);a=Mn(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=An(e,o);s.push({label:n,value:Mn(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Mn(e[n],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=Mn(e[t[0]],r))}}const l={...Sn,...o};return wn("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&kn("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>wn("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&wn("span",{children:[e.label,": "]}),e.value]},t))]})}}function Cn(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=l(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data);const r=t(n);return null==r?null:kn("div",{className:"semiotic-tooltip",style:Sn,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ln(e):Ln())}}import{jsx as En}from"react/jsx-runtime";function Dn({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=yn.useRef(null),[u,d]=yn.useState(null);yn.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[i,a,n,r]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!yn.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 r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),g=f?null:Sn;return l?En("div",{ref:c,className:f?a:(a+" semiotic-tooltip").trim(),style:{...g||{},position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}import*as Nn from"react";import{useCallback as In,useEffect as Tn,useLayoutEffect as _n,useMemo as Pn,useRef as Rn}from"react";import{createContext as $n,useCallback as Wn,useContext as On,useMemo as zn,useRef as Bn,useSyncExternalStore as jn}from"react";import{jsx as Hn}from"react/jsx-runtime";function Fn(e){let t=null;const n=()=>(t||(t=$n(null)),t),r=Yn(e);return[function({children:t,initialState:r}){const o=Bn(r),i=zn(()=>Yn(e,o.current),[]),a=n();return Hn(a.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=On(o)??r,a=Bn(e);a.current=e;const s=Bn({hasValue:!1,value:void 0}),l=Wn(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=Wn(()=>a.current(i.getState()),[i]);return jn(i.subscribe,l,c)}]}function Yn(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Xn(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 Gn(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:qn}}),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 qn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Vn={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}},Qn={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}},Kn={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:qn,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 Zn(e,t){if("light"===t)return Vn;if("dark"===t)return Qn;if("high-contrast"===t)return Kn;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?Qn:Vn;return Gn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Gn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Un,Jn]=Fn(e=>({theme:Vn,setTheme(t){e(e=>({theme:Zn(e.theme,t)}))}}));import{useState as er,useEffect as tr}from"react";import{useRef as nr,useState as rr,useEffect as or}from"react";var ir=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,ar=new WeakMap,sr=0,lr=!1,cr=null,ur=null;function dr(e,t){if(!t)return t;const n=ir.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(lr)return;if("undefined"==typeof window||"undefined"==typeof document)return;lr=!0;const e=()=>{sr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{cr=window.matchMedia("(prefers-color-scheme: dark)"),ur=e,"function"==typeof cr.addEventListener?cr.addEventListener("change",ur):"function"==typeof cr.addListener&&cr.addListener(ur)}catch{}}();let o=ar.get(r);o&&o.version===sr||(o={version:sr,map:new Map},ar.set(r,o));const i=o.map.get(t);if(void 0!==i)return i;const a=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return o.map.set(t,a),a}var hr="undefined"==typeof window?Tn:_n,fr={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function gr(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function yr(e){const t=function(){const[e,t]=er(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return tr(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(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)}(e,e=>t(e.matches))},[]),e}(),n=Rn(t);n.current=t;const[r,o]=function(e,t,n){const r=nr(null),[o,i]=rr(null);return or(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=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 o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=Pn(()=>({...e.marginDefault,...e.userMargin}),[e.marginDefault,e.userMargin]),a=o[0]-i.left-i.right,s=o[1]-i.top-i.bottom,l=gr(e.foregroundGraphics,o,i),c=gr(e.backgroundGraphics,o,i),u=Jn(e=>e.theme),{transition:d,introEnabled:h}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+Nn.useId(),g=Rn(null),y=Rn(e.frameScheduler??fr);y.current=e.frameScheduler??fr;const p=Rn(null),m=Rn(!1),b=Rn(()=>{}),v=In(()=>{if(null!==g.current||m.current)return;const e=y.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(m.current=!0),g.current=null,p.current=null;try{b.current()}finally{e&&(m.current=!1)}});n=!0,t||(g.current=r,p.current=e)},[]),x=In(()=>{null!==g.current&&((p.current??y.current).cancelAnimationFrame(g.current),g.current=null,p.current=null)},[]);Tn(()=>()=>{x()},[x]);const k=Rn(()=>{}),w=Rn(()=>{}),S=Rn(null),A=Rn(null),M=Rn(null),L=In(()=>{const e=S.current;S.current=null,e&&k.current(e)},[]),C=In(e=>{if(S.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===A.current){const e=y.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,A.current=null,M.current=null,L()});t||(A.current=n,M.current=e)}},[L]),E=In(()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null),w.current()},[]);Tn(()=>()=>{S.current=null,null!==A.current&&((M.current??y.current).cancelAnimationFrame(A.current),A.current=null,M.current=null)},[]);const D=e.themeDirtyRef;return hr(()=>{D&&(sr++,D.current=!0,v())},[u,v,D]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:i,adjustedWidth:a,adjustedHeight:s,resolvedForeground:l,resolvedBackground:c,currentTheme:u,transition:d,introEnabled:h,tableId:f,rafRef:g,renderFnRef:b,scheduleRender:v,cancelRender:x,hoverHandlerRef:k,hoverLeaveRef:w,onPointerMove:C,onPointerLeave:E}}import{useEffect as pr,useRef as mr}from"react";var br={fresh:1,aging:.7,stale:.45,expired:.25},vr={alpha:1,band:"fresh",isStale:!1};import{jsx as xr}from"react/jsx-runtime";function kr({isStale:e,position:t}){return xr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import*as wr from"react";import*as Sr from"react";import{jsx as Ar,jsxs as Mr}from"react/jsx-runtime";var Lr={fill:(e,t)=>Ar("rect",{style:e,width:t,height:t}),line:(e,t)=>Ar("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Cr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Lr[n])(r(e,t),o),i}function Er({swatchSize:e}){return Ar("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 Dr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Nr=(e,t,n,r,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:b,labelGap:v,rowHeight:x}=u;return f.forEach((e,c)=>{const u=Cr(e,c,d,h,b),k=Dr(e,r,o),w=o&&o.size>0&&o.has(e.label);g.push(Mr("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?s===i&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?w||!1:void 0,"aria-current":p&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{l(s,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&Ar("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,w&&Ar(Er,{swatchSize:b}),Ar("text",{y:b/2,x:b+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),y+=x}),g};function Ir({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Sr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(Ar("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return Mr("g",{"aria-label":i||"Gradient legend",children:[Ar("defs",{children:Ar("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&Ar("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Ar("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),Ar("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])}),Ar("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(Ar("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return Mr("g",{"aria-label":i||"Gradient legend",children:[i&&Ar("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Ar("defs",{children:Ar("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),Ar("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),Ar("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])}),Ar("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])})]})}function Tr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[f,g]=Sr.useState(0),[y,p]=Sr.useState(0),m=Sr.useCallback((e,t)=>{g(e),p(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(Ar("line",{stroke:"gray",x1:0,y1:d,x2:t,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(Ar("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(Ar("g",{className:"legend-item",transform:`translate(0,${d})`,children:Nr(e,n,r,o,i,a,s,f,l,c,u)},"legend-group-"+f)),d+=e.items.length*u.rowHeight+8}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const y=((e,t,n,r,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[],{swatchSize:p,labelGap:m,itemGap:b,rowHeight:v,align:x}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,S=g.map(e=>p+m+7*e.label.length),A=[];let M=0,L=0;S.forEach((e,t)=>{const n=0===L?e:L+b+e;d&&d>0&&L>0&&n>d?(A.push({start:M,end:t,width:L}),M=t,L=e):L=n}),g.length>0&&A.push({start:M,end:g.length,width:L}),A.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=g[d],x=Cr(e,d,h,f,p),A=Dr(e,r,o),M=o&&o.size>0&&o.has(e.label);y.push(Mr("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?s===i&&d===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?M||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?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)+g.length)%g.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(s,d),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&Ar("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:p+m+2+7*e.label.length,height:p+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,M&&Ar(Er,{swatchSize:p}),Ar("text",{y:p/2,x:p+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const C=Math.max(0,...A.map(e=>e.width)),E=A.length;return{items:y,offset:C,totalRows:E,totalHeight:E*v}})(e,r,o,i,a,s,l,t,c,u,d,d.maxWidth??n);g+=y.offset+5,f.push({label:e.label,...y,offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=g+12});const g=d.maxWidth??n;let y=h>g?0:"center"===d.align?Math.max(0,(g-h)/2):"end"===d.align?Math.max(0,g-h):0;const p=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(p.push(Ar("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),y+=16),p.push(Ar("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+r)),y+=n.offset+5,e[r+1]&&p.push(Ar("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),y+=12}),Ar("g",{children:p})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:a,metrics:h}),v=!(!n&&!r);return Mr("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&Ar("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}function _r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as Pr}from"react/jsx-runtime";function Rr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:a,title:s,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===i||"bottom"===i,g=!!s,y=Math.max(0,n-o.left-o.right),p=Math.max(1,f?a?.maxWidth??y:100);let m,b;return"left"===i?(m=Math.max(4,o.left-p-10),b=o.top):"top"===i?(m=o.left,b=g?32:8):"bottom"===i?(m=o.left,b=r-o.bottom+38):(m=n-o.right+10,b=o.top),Pr("g",{transform:`translate(${m}, ${b})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?Pr(Ir,{config:t.gradient,orientation:f?"horizontal":"vertical",width:p}):_r(t)?Pr(Tr,{legendGroups:t.legendGroups,title:"",width:p,orientation:f?"horizontal":"vertical",legendLayout:a,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t)});var v}import{jsx as $r}from"react/jsx-runtime";var Wr={secondary:0,primary:3},Or=".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 zr(e){return!0===e?._annotationDeferred}function Br(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function jr(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Hr(e){return Math.max(.72,.95-.06*e)}import*as Fr from"react";import{jsx as Yr,jsxs as Xr}from"react/jsx-runtime";function Gr(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let a="";for(const e of o)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function qr(e,t,n,r){return"curly"===e?r?`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`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Vr(e,t,n,r){if(!e)return Yr("g",{className:"annotation-note"});const{label:o,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!i)return Yr("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,g=i?c?[i]:Gr(i,l):[],y=o?c?[o]:Gr(o,l):[],p="leftRight"===u?"end"===h?-4:4:0;let m=0;const b=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push(Yr("foreignObject",{className:"annotation-note-html",x:"end"===h?p-l:"middle"===h?p-l/2:p,y:-16,width:l,height:Math.max(f,(g.length+y.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:Xr("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&Yr("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&Yr("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(g.length>0&&(b.push(Yr("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:g.map((e,t)=>Yr("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=g.length*f),y.length>0&&b.push(Yr("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:m,children:y.map((e,t)=>Yr("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=Yr("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=Yr("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+y.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),Xr("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[Yr("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),x]})}function Qr(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(Yr("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(Yr("rect",{width:e,height:r,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=r||0,a=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(Yr("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push(Yr("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(Yr("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(Yr("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(Yr("path",{d:qr(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return Yr("g",{className:"annotation-subject",children:i})}function Kr(e,t,n,r,o,i){const a=[];let s=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,a=e-o,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;s=o+a*h,l=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);s=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-s);if(i){const r=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,f=(n?.curve??.25)*c,g=r+d*f,y=i+h*f;a.push(Yr("path",{className:"connector-curve",d:`M${s},${l}Q${g},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(y-l,g-s)}else a.push(Yr("line",{x1:s,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push(Yr("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return Yr("g",{className:"annotation-connector",children:a})}function Zr(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:g,strokeDasharray:y,events:p={},"data-testid":m}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-b),null!=a&&(w=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return Xr("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":m,...null!=g&&{opacity:g},...y&&{strokeDasharray:y},...p,children:[!x.has("connector")&&Kr(k,w,l,d,S,c),!x.has("subject")&&Qr(S,c,d,b,v),!x.has("note")&&Vr(s,k,w,d)]})}function Ur(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return Yr(Zr,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return Yr("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return Yr(Zr,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}import{packEnclose as Jr}from"d3-hierarchy";import{area as eo,curveLinear as to,curveMonotoneX as no,curveMonotoneY as ro,curveStep as oo,curveStepAfter as io,curveStepBefore as ao,curveBasis as so,curveCardinal as lo,curveCatmullRom as co}from"d3-shape";import uo from"regression";function ho(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 fo(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 go(e){return null==e?null:e+""}function yo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function po(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return yo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:r(i),y:o(a)}}(n);return r?yo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return go(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>go(e.pointId)===r);if(o)return yo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return go(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const a=ho(i,n),s=fo(i,n);return null==a||null==s?null:yo(t,n,{x:a,y:s})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=ho(e,n),i=fo(e,n)),null!=o&&null!=i)return yo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function mo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}import{jsx as bo,jsxs as vo}from"react/jsx-runtime";var xo={linear:to,monotoneX:no,monotoneY:ro,step:oo,stepAfter:io,stepBefore:ao,basis:so,cardinal:lo,catmullRom:co};var ko=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function wo(e){return!!e&&"object"==typeof e&&ko.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function So(e){return"primary"===e?.emphasis||!0===e?.defensive}function Ao(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Mo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var Lo=32,Co=6,Eo=4,Do=8,No=72;var Io={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function To(e){if(!_o(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 _o(e){return wo(e)}function Po(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function Ro(e,t,n,r,o){const i=e+n,a=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function $o(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Wo(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 Oo(e,t,n,r,o,i,a,s){const l=$o(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,s);for(const e of n)c+=12*Wo(l,e);for(const e of r)c+=4*Wo(l,e);return c}function zo(e){const{annotations:t,context:n,defaultOffset:r=Lo,notePadding:o=Co,markPadding:i=Eo,edgePadding:a=Do,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=No,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:g,cohesion:y,audience:p}=e,m=n.width||0,b=n.height||0,v="object"==typeof g?g:{},x=v.breakpoint??480,k=!!g&&x>=m,w=k&&!1!==v.preferShortText?t.map(To):t,S=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,A=d||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),M=k&&!f?v.responsive??{minWidth:x}:f,L=k&&!y?v.cohesion:y;if(0===w.length||0>=m||0>=b)return w.slice();const C=[],E=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 D=!1;const N=w.map((e,t)=>{if(!_o(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 r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[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?po(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=[...Po("string"==typeof e.title?e.title:void 0,t),...Po("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push($o(Ro(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Oo(Ro(i.x,i.y,e.dx,e.dy,u),e,C,E,m,b,o,a);f>t&&(h=e,f=t)}if(!h)return e;const g=$o(Ro(i.x,i.y,h.dx,h.dy,u),o);C.push(g);const y=Math.hypot(h.dx,h.dy),p=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return D=!0,{...e,dx:h.dx,dy:h.dy,...p?{connector:p}:{}}}),I=D?N:w.slice();let T=I;if(h){let e=!1;const t=I.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});T=e?t:I}{let e=!1;const t=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?Io[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});T=e?t:T}const _=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}(p),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Ao(m,b,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=Ao(n,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,wo(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>So(e.annotation)),c=s.filter(e=>!So(e.annotation)).sort((e,t)=>Mo(t.annotation)-Mo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:T,width:m,height:b,...n});for(const e of r)_.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(const e of T)_o(e)&&"secondary"===e.emphasis&&_.add(e);if(_.size>0)for(const e of T)!0===e?.defensive&&_.delete(e);let P;return P=0===_.size?T:A?T.map(e=>_.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!_.has(e)),L?function(e,t){let n=!1;const r=e.map(e=>_o(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(P,L):P}import{symbol as Bo,symbolCircle as jo,symbolCross as Ho,symbolDiamond as Fo,symbolSquare as Yo,symbolStar as Xo,symbolTriangle as Go,symbolWye as qo}from"d3-shape";var Vo={circle:jo,square:Yo,triangle:Go,diamond:Fo,star:Xo,cross:Ho,wye:qo};function Qo(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*Ko(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):Bo(Vo[r]??jo,Math.max(1,t))()??""}function Ko(e){return Math.sqrt(Math.max(1,e)/Math.PI)}import{Fragment as Zo,jsx as Uo,jsxs as Jo}from"react/jsx-runtime";function ei(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:g,foregroundGraphics:y,sceneNodes:p,annotations:m,autoPlaceAnnotations:b,svgAnnotationRules:v}=e,x=wr.useMemo(()=>{const e=(p||[]).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 r=sn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),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,Ko(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:p}},[n,p,t]),k=wr.useMemo(()=>m&&b?zo({annotations:m,context:x,..."object"==typeof b?b:{}}):m,[m,b,x]),w=wr.useMemo(()=>function(e,t,n){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const r=po(e,t,n);if(!r)return null;const{x:o,y:i}=r;if(!mo(o,i,n))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return bo(Ur,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+t)}case"x-threshold":{const r=ho(null!=e.value?{...e,x:e.value}:e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(n.height||0)-4:"center"===i?(n.height||0)/2:12;const s=r>.6*(n.width||0),l=s?r-4:r+4,c=s?"end":"start";return vo("g",{opacity:e.opacity,children:[bo("line",{x1:r,y1:0,x2:r,y2:n.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&bo("text",{x:l,y:a,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"y-threshold":{const r=fo(null!=e.value?{...e,y:e.value}:e,n);if(null==r)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,s;return"left"===i?(a=4,s="start"):"center"===i?(a=(n.width||0)/2,s="middle"):(a=(n.width||0)-4,s="end"),vo("g",{opacity:e.opacity,children:[bo("line",{x1:0,y1:r,x2:n.width||0,y2:r,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&bo("text",{x:a,y:r-4,textAnchor:s,fill:o,fontSize:12,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"enclose":{const r=(e.coordinates||[]).map(e=>({x:ho({...e,type:"point"},n),y:fo({...e,type:"point"},n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=Jr(r),i=e.padding||10;return vo("g",{children:[bo("circle",{cx:o.x,cy:o.y,r:o.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&&bo("text",{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"rect-enclose":{const r=(e.coordinates||[]).map(e=>({x:ho({...e,type:"point"},n),y:fo({...e,type:"point"},n)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const o=e.padding||10,i=r.map(e=>e.x),a=r.map(e=>e.y),[s,l]=Oe(i),[c,u]=Oe(a),d=s-o,h=l+o,f=c-o;return vo("g",{children:[bo("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&bo("text",{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+t)}case"highlight":{const r=n.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return bo("g",{children:o.map((t,r)=>{const o=ho(t,n),a=fo(t,n);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return bo("circle",{cx:o,cy:a,r:s,...l},"hl-"+r)})},"ann-"+t)}case"bracket":{const r=ho(e,n),o=fo(e,n);return bo(Ur,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",a="ordinal"===n.frameType,s="horizontal"===n.projection,l=a?o:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of r){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=r.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=r.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=n.scales?.x??n.scales?.time,g=n.scales?.y??n.scales?.value;if(!f||!g)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,n+1),o=t-n,i=e(d[n]);return i+(e(d[r])-i)*o},p=f,m=g;let b;if(a)if(s){const e=y(m);b=(t,n)=>[p(n),e(t)]}else{const e=y(p);b=(t,n)=>[e(t),m(n)]}else b=(e,t)=>[p(e),m(t)];const v=e.method||"linear";let x;x="loess"===v?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],g+=t*o[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*g-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3):("polynomial"===v?uo.polynomial(u,{order:e.order||2}):uo.linear(u)).points;const k=x.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",S=x[x.length-1],[A,M]=b(S[0],S[1]);return vo("g",{children:[bo("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&bo("text",{x:A+4,y:M-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"band":{const r=n.scales?.y??n.scales?.value,o=r?.(e.y0)??0,i=r?.(e.y1)??(n.height||0);return vo("g",{opacity:e.opacity,children:[bo("rect",{x:0,y:Math.min(o,i),width:n.width||0,height:Math.abs(i-o),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&bo("text",{x:(n.width||0)-4,y:Math.max(Math.min(o,i),0)+13,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"x-band":{const r=n.scales?.x??n.scales?.time,o=null!=e.x0&&r?r(e.x0):null,i=null!=e.x1&&r?r(e.x1):null;return null==o||null==i?null:vo("g",{opacity:e.opacity,children:[bo("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:n.height||0,fill:e.fill||e.color||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity??.1}),e.label&&bo("text",{x:Math.min(o,i)+4,y:13,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",stroke:"var(--semiotic-bg, #ffffff)",strokeWidth:3,paintOrder:"stroke",children:e.label})]},"ann-"+t)}case"envelope":{const r=n.data||[];if(2>r.length)return null;const o=n.xAccessor||"x",i=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const d=xo[n.curve||"linear"]||to,h=eo().x(e=>i(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return vo("g",{children:[bo("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&bo("text",{x:i(u[u.length-1][o])+4,y:a(u[u.length-1][s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{const r=n.data||[];if(2>r.length)return null;const o=n.yAccessor||"y",i=n.scales?.x??n.scales?.time,a=n.scales?.y??n.scales?.value;if(!i||!a)return null;const s=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,g=e.fill||"#6366f1",y=e.fillOpacity??.1,p=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=r.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>d*u});return vo("g",{children:[f&&bo("rect",{x:0,y:Math.min(b,v),width:n.width||0,height:Math.abs(v-b),fill:g,fillOpacity:y}),x.map((e,t)=>{const r=ho(e,n),o=fo(e,n);return null==r||null==o?null:bo("circle",{cx:r,cy:o,r:m,fill:p,fillOpacity:.7,stroke:p,strokeWidth:1.5},"anomaly-"+t)}),e.label&&bo("text",{x:(n.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{const r=n.data||[];if(3>r.length)return null;const o=n.xAccessor||"x",i=n.yAccessor||"y",a=n.scales?.x??n.scales?.time,s=n.scales?.y??n.scales?.value;if(!a||!s)return null;const l=r.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=uo.polynomial(l,{order:e.order||2}).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,o=0;for(const[e,i]of l)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const a=(e*o-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)).reduce((e,t)=>e+t*t,0),h=Math.sqrt(d/Math.max(u-2,1)),f=l.reduce((e,t)=>e+t[0],0)/u,g=l.reduce((e,t)=>e+(t[0]-f)**2,0),y=e.confidence??.95,p=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,m=e.steps??5,b=l[u-1][0],v=(b-l[0][0])/Math.max(u-1,1),x=[];for(let e=1;m>=e;e++)x.push(b+e*v);const k=[];for(const e of x){const t=c(e),n=h*Math.sqrt(1+1/u+(g>0?(e-f)**2/g:0))*p;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const w=`M${k.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,S=k.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),A=`${a(b)},${s(c(b))}`,M=e.strokeColor||"#6366f1";return vo("g",{children:[bo("path",{d:w,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),bo("polyline",{points:`${A} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&bo("text",{x:a(k[k.length-1].x)+4,y:s(k[k.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{const i=po(e,t,n);if(!i)return null;r=i.x,o=i.y}if(!mo(r,o,n))return null;const i=e.width??32,a=e.height??32;return bo("foreignObject",{x:r+(e.dx??0)-i/2,y:o+(e.dy??0)-a/2,width:i,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:bo("div",{style:{width:i,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:e.content??bo("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"})})},"ann-"+t)}case"text":{const r=po(e,t,n);if(!r)return null;const{x:o,y:i}=r,a=o+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=bo("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Fr.cloneElement(c,{key:"ann-text-"+t}):vo("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[bo("line",{x1:o,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Fr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+t)}case"category-highlight":{const r=e.category;if(null==r)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=n.scales?.o,a=n.scales?.x,s=n.scales?.y,l=o(i)?i:o(a)?a:o(s)?s:null;if(!l)return null;const c=l(r+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return vo("g",(n.projection?"vertical"===n.projection:l===a)?{children:[bo("rect",{x:c,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),f&&bo("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[bo("rect",{x:0,y:c,width:n.width||0,height:u,fill:d,fillOpacity:h}),f&&bo("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+t)}default:return null}},[]),S=k?function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let a;if(n){const o=n(e,i,r);a=null!=o?o:t(e,i,r)}else a=t(e,i,r);a&&o.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:jr(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>zr(e.annotation)),o=e.some(e=>null!=Br(e.annotation)),i=e.some(e=>"layer"===Br(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=Wr[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=zr(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;a=$r("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Hr(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const s=Br(t.annotation);return s&&(a=$r("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=$r("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return r&&s.unshift($r("style",{children:Or},"annotation-disclosure-style")),i&&s.unshift($r("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(o)}(k.filter(e=>"widget"!==e.type),w,v,x):null,A=!0===k?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Jo(Zo,{children:[A&&Uo("style",{children:Or},"annotation-widget-disclosure-style"),Jo("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Uo("title",{children:"string"==typeof s?s:"Network Chart"}),Uo("desc",{children:"string"==typeof s?s+" — network data visualization":"Network data visualization"}),Jo("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>Uo("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),S,y]}),s&&"string"==typeof s?Uo("text",{x:r/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?Uo("foreignObject",{x:0,y:0,width:r,height:i.top,children:s}):null,Rr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:s,legendLayout:g,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),k?.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{const n=!0===e._annotationDeferred,r=p.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=e.width??32,a=e.height??32;return Uo("div",{className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0))+(e.dx??0)-o/2,top:i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0))+(e.dy??-16)-a/2,width:o,height:a,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:e.content??Uo("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"})},"widget-"+t)})]})}ei.displayName="NetworkSVGOverlay";import*as ti from"react";import{jsx as ni}from"react/jsx-runtime";var ri={position:"absolute",top:0,left:0,pointerEvents:"none"};function oi({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=ti.useRef(null),i=function(e,t,n){const[r,o]=ti.useState(null);return ti.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",a),s.disconnect()}},[t,e,n]),ti.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,a=t.left-n,s=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(a>t+e.width||t>s||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const a=ni("div",{className:"semiotic-network-html-marks",ref:o,style:{...ri,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>ni("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?ni(qt,{value:n,children:a}):a}import*as ii from"react";import{arc as ai}from"d3-shape";import{jsx as si,jsxs as li}from"react/jsx-runtime";var ci={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ui(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}var di="undefined"==typeof window||"undefined"==typeof document;import{useEffect as hi,useLayoutEffect as fi,useRef as gi,useState as yi,useSyncExternalStore as pi}from"react";var mi="undefined"!=typeof window?fi:hi,bi=()=>()=>{},vi=()=>!1,xi=()=>!0;function ki(){const e=pi(bi,vi,xi);return gi(e).current}import{useRef as wi}from"react";function Si(e){const t=wi(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Mi(e,t);if(!Li(e)||!Li(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Mi(n,o))return!1}else{if(!Li(n)||!Li(o))return!1;if(!Ai(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function Ai(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function Mi(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 Li(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}import*as Ci from"react";import*as Ei from"react";import{jsx as Di}from"react/jsx-runtime";var Ni=Ei.createContext(null);import{jsx as Ii,jsxs as Ti}from"react/jsx-runtime";var _i={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Pi(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var Ri=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},$i="semiotic-accessible-data-table",Wi=$i+" semiotic-accessible-data-table-hidden",Oi=$i+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",zi={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"},Bi={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},ji={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)"},Hi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Fi={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))"},Yi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Xi={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Gi={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 qi({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,a]=Ci.useState(!1),[s,l]=Ci.useState(5),c=Ei.useContext(Ni),u=c?.visible??!1,d=i||u,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ci.useRef(null);Ci.useEffect(()=>{d||l(5)},[d]);const g=Ci.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),y=Ci.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return r?Ii("span",{id:r,tabIndex:-1,style:_i}):null;if(!d)return Ii("div",{id:r,className:Wi,tabIndex:-1,onFocus:g,style:_i,role:"region","aria-label":h,children:Ti("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const p=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??e,n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="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),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+o)}}const w=[];for(let e=0;p.length>e;e++){const t=p[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=b.get(r)??0,i=v.get(r)??0,a=x.get(r)??0,s=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}w.sort((e,t)=>t.degree-e.degree);let S=0,A=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>A&&(A=t.degree);S=e/w.length}const M=m.some(e=>{const t=e?.datum??e;return"number"==typeof t?.value&&Number.isFinite(t.value)}),L=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&L.push(`Mean degree: ${Ri(S)}, max degree: ${A}.`);const C=Math.min(s,w.length),E=w.slice(0,C),D=w.length-C;return Ti("div",{ref:f,id:r,className:Oi,tabIndex:-1,onBlur:y,style:zi,role:"region","aria-label":h,children:[Ii("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:ji,children:"×"}),Ii("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Bi,children:L.join(" ")}),Ti("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Hi,children:[Ii("caption",{className:"semiotic-accessible-data-table-caption",style:Xi,children:D>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Ii("thead",{children:Ti("tr",{children:[Ii("th",{style:Fi,children:"id"}),Ii("th",{style:Fi,children:"degree"}),Ii("th",{style:Fi,children:"in"}),Ii("th",{style:Fi,children:"out"}),M&&Ii("th",{style:Fi,children:"w. degree"}),M&&Ii("th",{style:Fi,children:"w. in"}),M&&Ii("th",{style:Fi,children:"w. out"})]})}),Ii("tbody",{children:E.map((e,t)=>Ti("tr",{children:[Ii("td",{style:Yi,children:e.id}),Ii("td",{style:Yi,children:e.degree}),Ii("td",{style:Yi,children:e.inDeg}),Ii("td",{style:Yi,children:e.outDeg}),M&&Ii("td",{style:Yi,children:Ri(e.wDegree)}),M&&Ii("td",{style:Yi,children:Ri(e.wInDeg)}),M&&Ii("td",{style:Yi,children:Ri(e.wOutDeg)})]},t))})]}),D>0&&Ti("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:Gi,children:["Show ",Math.min(25,D)," more"," ",1===D?"node":"nodes"," (",D," remaining)"]})]})}function Vi({summary:e}){return e?Ii("div",{role:"note",style:_i,children:e}):null}function Qi({tableId:e}){return Ii("a",{href:"#"+e,style:_i,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,_i)},children:"Skip to data table"})}function Ki({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 Ii("div",{"aria-live":"polite","aria-atomic":"true",style:_i,children:t})}var Zi=Object.freeze([]);function Ui(e){if(!e)return Zi;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}import*as Ji from"react";import{jsx as ea,jsxs as ta}from"react/jsx-runtime";function na({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return ea("div",{role:"alert",style:{width:r,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:ta("div",{style:{textAlign:"center",maxWidth:400},children:[ea("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),ea("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&ea("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}import{jsx as ra}from"react/jsx-runtime";var oa=class extends Ji.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:ra(na,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as ia}from"react/jsx-runtime";function aa({componentName:e,width:t,height:n,children:r}){return ia(oa,{fallback:r=>ia(na,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var sa={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"},la={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ca(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return ia("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(i+a)-a))/2);return ia("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:o},(e,n)=>ia("div",{className:"semiotic-loading-bar",style:{...la,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function ua(e,t,n,r,o=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}function da(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function ha(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var fa=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(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)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(ha());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(ha())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},ga=null;function ya(e,t){return da()?t?.aborted?Promise.reject(ha()):(ga&&!ga.isDead||(ga=new fa),ga).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}import{jsx as pa,jsxs as ma}from"react/jsx-runtime";import{jsx as ba,jsxs as va}from"react/jsx-runtime";var xa=/^(value|amount|total|count|weight|score)$/i;function ka({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?va("div",{className:"semiotic-tooltip",style:Sn,children:[va("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&&va("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 r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return va("div",{className:"semiotic-tooltip",style:Sn,children:[ba("div",{children:e.map((e,t)=>va("span",{children:[t>0&&ba("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?ba("strong",{children:e}):ba("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&ba("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=function(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&vn.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>pn.includes(e.lower));const a=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=xn(l,mn),u=xn(l,bn),d=new Set(mn),h=new Set(bn),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:f}}(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>xa.test(e.key));return va("div",{className:"semiotic-tooltip",style:Sn,children:[ba("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>{return va("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!s&&null!=t.value&&t.value>0&&va("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&va("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function wa(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Sa(e,t){if(!t.pathD)return;e.save();const n=wa(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=dr(e,i)||i;n.addColorStop(0,1===r.from?a:"transparent"),n.addColorStop(1,1===r.to?a:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=dr(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 Aa(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=dr(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 Ma(e,t){if(!t.pathD)return;e.save();const n=wa(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=dr(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 La(e,t){if(!t.pathD)return;e.save();const n=wa(t),r=t.style.stroke||"#999";e.strokeStyle=dr(e,r)||r,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="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function Ca(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ea(e,t,n=.3){Ca(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 Da(e,t,n=.6){if(!Ca(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}ka.ownsChrome=!0;var Na=new Map;function Ia(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Na.get(t);return n||(n=new Path2D(Qo(e.symbolType,e.size)),Na.size>256&&Na.clear(),Na.set(t,n)),n}catch{return null}}import{curveMonotoneX as Ta,curveMonotoneY as _a,curveCardinal as Pa,curveCatmullRom as Ra,curveStep as $a,curveStepBefore as Wa,curveStepAfter as Oa,curveBasis as za,curveNatural as Ba}from"d3-shape";function ja(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=en(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const n=function(e,t,n){return null==t?n:"string"!=typeof t?t:dr(e,t)||n}(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);const u=an(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&ln(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),ln(e,i,c,t.accent,void 0,l),e.restore()}function Ha(e){const{canvas:t,store:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:a,background:s,dirtyRef:l,lastFrameTimeRef:c,reducedMotion:u,showParticles:d,isContinuous:h,animate:f,decay:g,pulse:y,thresholds:p,staleness:m,particleStyle:b,getParticleColor:v,pendingAnnotationFrameRef:x,lastAnnotationFrameTimeRef:k,setAnnotationFrame:w,scheduleNextFrame:S}=e,A=t.getContext("2d");if(!A)return;const M=performance.now(),L=c.current?Math.min((M-c.current)/1e3,.1):.016;c.current=M;const C=n.advanceTransition(u?M+1e6:M),E=!u&&C,D=!u&&n.tickAnimation([i,a],L),N=l.current;(C||N||D)&&n.buildScene([i,a]);const I=d&&!u&&!!n.particlePool,T=!!((_={dirtyOrRebuilt:N,transitioning:E,animationTicked:D,continuous:I||h,liveEncoding:!!g||!!y||!!p||!1!==f&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||_.transitioning||_.animationTicked||_.continuous||_.liveEncoding||_.forced);var _;const P=!!m&&n.lastIngestTime>0&&M-n.lastIngestTime>(m?.threshold??5e3);if(T){if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(s,0,0,l,0,0),o.translate(n.left,n.top),o}(t,r,o,function(){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))}()))return;if(A.clearRect(-o.left,-o.top,r[0],r[1]),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:a=0,width:s,height:l}=t;if("transparent"===n)return!1;if(r)return!1;const c=n||(o&&"transparent"!==o?o:"")||null;if(!c)return!1;const u=dr(e,c);u&&(e.fillStyle=u,e.fillRect(i,a,s,l))}(A,{background:s,width:i,height:a}),g&&n.applyDecay(),y&&n.applyPulse(M),p&&n.applyThresholds(M),!1!==f&&n.applyTopologyDiff(M),P&&(A.globalAlpha=m?.dimOpacity??.5),function(e,t){for(const n of t)switch(n.type){case"bezier":Sa(e,n);break;case"line":Aa(e,n);break;case"ribbon":Ma(e,n);break;case"curved":La(e,n)}}(A,n.sceneEdges),function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Ea(e,t),e.restore())}}(A,n.sceneNodes),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),Da(e,t),e.restore())}}(A,n.sceneNodes),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(A,n.sceneNodes),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=Ia(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle="string"==typeof t.style.fill&&dr(e,t.style.fill)||t.style.fill,e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(A,n.sceneNodes),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&ja(e,r,r.cx,r.cy,n);e.globalAlpha=n}(A,n.sceneNodes),I&&!P){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r){const o=r.spawnRate??.1,i=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=i)continue;const s=a.value*o*n*(a.bezier.circular?.3:1),l=Math.floor(s),c=s-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(r)<i;t++)e.spawn(r)}}(n.particlePool,e,L,b);const t=.5*(b.speedMultiplier??1);let r;if(b.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(L,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=dr(e,c)||c,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(A,n.particlePool,e,b,v)}}P&&(A.globalAlpha=1)}l.current=!1,(N||E||D)&&t.setAttribute("aria-label",Pi(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const R=N||E||D||x.current;R&&M-k.current>=33?(w(e=>e+1),k.current=M,x.current=!1):x.current=!!R,(h||E||null!=n.transition||D||n.hasActivePulses||n.hasActiveThresholds||!1!==f&&n.hasActiveTopologyDiff||x.current)&&S()}function Fa(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:vt,a=Array.from(n);for(let e=0;a.length>e;e++){const t=a[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return a.length}function Ya(e,t=30){return Math.max((e??4)+5,12,t)}function Xa(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Ga(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>Ya(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(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}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Xa(Math.atan2(o,r)),s=Xa(e.startAngle),l=Xa(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>Ya(Ko(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=sn(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,l=n-a,c=Math.sqrt(s*s+l*l);return c>Ya(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:a,distance:c}}(e,t,n,r);default:return null}}var qa=null,Va=null;function Qa(){return Va||((qa=document.createElement("canvas")).width=1,qa.height=1,Va=qa.getContext("2d")),Va}function Ka(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 Za(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=Ka(e),o=Qa();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let a=((t-e.x1)*r+(n-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*r,l=e.y1+a*o,c=Math.sqrt((t-s)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=Ka(e),o=Qa();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Ua(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:l,nodeQuadtree:u,maxNodeRadius:d,hitRadius:h=30}=e,f=t-r.left-o.left,g=n-r.top-o.top;if(0>f||f>i||0>g||g>a)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,a=0){let s=null,l=o,c=1/0;if(i){const e=function(e,t,n,r,o,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,o,l,y,p)=>{if(o>u||c>y||l>h||d>p)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=a(e)-n,u=Math.sqrt(l*l+c*c);Ya(s(e),r)>=u&&g>u&&(f=e,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(i,n,r,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Ga(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(s=e,c=n)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=Za(e,n,r);t&&l>t.distance&&(s=t,l=t.distance)}return s}(s,l,f,g,h,u,d);return y?{kind:"hit",hover:c(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{jsx as Ja,jsxs as es}from"react/jsx-runtime";var ts={top:20,right:80,bottom:20,left:80},ns={top:40,right:40,bottom:40,left:40},rs=new Set(["chord","force","circlepack","orbit"]),os=[800,600],is=s(a(function(a,s){const{chartType:l,nodes:h,edges:f,data:g,initialEdges:y,nodeIDAccessor:p="id",sourceAccessor:m="source",targetAccessor:b="target",valueAccessor:v="value",edgeIdAccessor:x,childrenAccessor:k,hierarchySum:w,orientation:S="horizontal",nodeAlign:A="justify",nodePaddingRatio:M=.05,nodeWidth:L=15,iterations:C=300,forceStrength:E=.1,layoutExecution:D="auto",layoutLoadingContent:N,onLayoutStateChange:I,padAngle:T=.01,groupWidth:_=20,sortGroups:P,edgeSort:R,treeOrientation:$="vertical",edgeType:W="curve",padding:O,paddingTop:z,tensionConfig:B,showParticles:j=!1,particleStyle:H,nodeStyle:F,edgeStyle:Y,colorBy:X,colorScheme:G="category10",edgeColorBy:q="source",edgeOpacity:V=.5,colorByDepth:Q=!1,nodeSize:K=8,nodeSizeRange:Z=[5,20],nodeLabel:U,showLabels:J=!0,labelMode:ee,size:te=os,responsiveWidth:ne,responsiveHeight:re,margin:oe,className:ie,background:ae,enableHover:se=!0,tooltipContent:le,customHoverBehavior:ce,customClickBehavior:ue,onObservation:de,chartId:he,onTopologyChange:fe,annotations:ge,autoPlaceAnnotations:ye,svgAnnotationRules:pe,legend:me,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:ke,legendHighlightedCategory:we,legendIsolatedCategories:Se,title:Ae,foregroundGraphics:Me,backgroundGraphics:Le,decay:Ce,pulse:Ee,transition:De,animate:Ne,staleness:Ie,thresholds:Te,accessibleTable:_e=!0,description:Pe,summary:Re,orbitMode:$e,orbitSize:We,orbitSpeed:Oe,orbitRevolution:ze,orbitRevolutionStyle:Be,orbitEccentricity:je,orbitShowRings:Fe,orbitAnimated:Ye,customNetworkLayout:Xe,onLayoutError:Ge,layoutConfig:qe,layoutSelection:Ve}=a,Qe=rs.has(l)?ns:ts,Ke=e(!0),Ze=yr({sizeProp:te,responsiveWidth:ne,responsiveHeight:re,userMargin:oe,marginDefault:Qe,foregroundGraphics:Me,backgroundGraphics:Le,animate:Ne,transitionProp:De,themeDirtyRef:Ke}),{reducedMotionRef:Ue,responsiveRef:Je,size:et,margin:tt,adjustedWidth:nt,adjustedHeight:rt,resolvedForeground:ot,resolvedBackground:it,transition:at,introEnabled:st,tableId:lt,rafRef:ct,renderFnRef:ut,scheduleRender:dt,cancelRender:ht,currentTheme:ft}=Ze,gt=function(){const[e,t]=yi(!1);return mi(()=>{t(!0)},[]),e}(),yt=ki(),pt=r(()=>Ui(h),[h]),mt=r(()=>Array.isArray(f)?Ui(f):f,[f]),bt=r(()=>({...u,...B}),[B]),xt=r(()=>({...d,...H}),[H]),kt=r(()=>{return{chartType:(e={chartType:l,nodeIDAccessor:p,sourceAccessor:m,targetAccessor:b,valueAccessor:v,edgeIdAccessor:x,childrenAccessor:k,hierarchySum:w,orientation:S,nodeAlign:A,nodePaddingRatio:M,nodeWidth:L,iterations:C,forceStrength:E,padAngle:T,groupWidth:_,sortGroups:P,edgeSort:R,treeOrientation:$,edgeType:W,padding:O,paddingTop:z,tensionConfig:bt,showParticles:j,particleStyle:xt,nodeStyle:F,edgeStyle:Y,nodeLabel:U,showLabels:J,labelMode:ee,colorBy:X,colorScheme:G,edgeColorBy:q,edgeOpacity:V,colorByDepth:Q,nodeSize:K,nodeSizeRange:Z,decay:Ce,pulse:Ee,transition:at,introAnimation:st,staleness:Ie,thresholds:Te,orbitMode:$e,orbitSize:We,orbitSpeed:Oe,orbitRevolution:ze,orbitRevolutionStyle:Be,orbitEccentricity:je,orbitShowRings:Fe,orbitAnimated:Ye,customNetworkLayout:Xe,onLayoutError:Ge,layoutConfig:qe,currentTheme:ft}).chartType,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Xn(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},[l,p,m,b,v,k,w,S,A,M,L,C,E,T,_,P,R,$,W,O,z,bt,j,xt,F,Y,U,J,ee,X,G,q,V,Q,K,Z,Ce,Ee,at?.duration,at?.easing,st,Ie,Te,$e,We,Oe,ze,Be,je,Fe,Ye,ft,Xe,Ge,qe]),wt=Si(kt),St=Si({chartType:(At={chartType:l,nodeIDAccessor:p,sourceAccessor:m,targetAccessor:b,valueAccessor:v,edgeIdAccessor:x,childrenAccessor:k,hierarchySum:w,orientation:S,nodeAlign:A,nodePaddingRatio:M,nodeWidth:L,iterations:C,forceStrength:E,padAngle:T,groupWidth:_,sortGroups:P,edgeSort:R,treeOrientation:$,edgeType:W,padding:O,paddingTop:z,tensionConfig:bt,customNetworkLayout:Xe,orbitMode:$e,orbitSize:We,orbitEccentricity:je}).chartType,nodeIDAccessor:At.nodeIDAccessor,sourceAccessor:At.sourceAccessor,targetAccessor:At.targetAccessor,valueAccessor:At.valueAccessor,edgeIdAccessor:At.edgeIdAccessor,childrenAccessor:At.childrenAccessor,hierarchySum:At.hierarchySum,orientation:At.orientation,nodeAlign:At.nodeAlign,nodePaddingRatio:At.nodePaddingRatio,nodeWidth:At.nodeWidth,iterations:At.iterations,forceStrength:At.forceStrength,padAngle:At.padAngle,groupWidth:At.groupWidth,sortGroups:At.sortGroups,edgeSort:At.edgeSort,treeOrientation:At.treeOrientation,edgeType:At.edgeType,padding:At.padding,paddingTop:At.paddingTop,tensionConfig:At.tensionConfig,customNetworkLayout:At.customNetworkLayout,orbitMode:At.orbitMode,orbitSize:At.orbitSize,orbitEccentricity:At.orbitEccentricity});var At;const Mt=e(null),Lt=e(0),Ct=e(0),Et=e(!1),Dt=e(null);Dt.current||(Dt.current=new Bt(wt));const[Nt,It]=t(null),[Tt,_t]=t(0),[Pt,Rt]=t(0),[$t,Wt]=t(!1),[Ot,zt]=t(!1),jt=e(0),Ft=e(null),Yt=e(!1),Xt=e(I);Xt.current=I;const Gt=e(wt);Gt.current=wt;const qt=e(null),Vt=e(new Map),Ut=e(0),Jt=o(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,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(!o.has(e+"")){const t=Array.isArray(r)?r:vt;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(r)?r:vt,s=n?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:X,colorScheme:G,nodeColorMap:Vt.current,colorIndexRef:Ut}),[X,G]),tn=(rn=ft,rn?.colors?.border||rn?.colors?.secondary||rn?.colors?.primary||"#999");var rn;const on=o(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Dt.current?.nodes),[]),ln=o(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const a=o(t.source),s=o(t.target);return"target"===n&&s?r(s):a?r(a):i}({edge:e,edgeColorBy:q,getNodeColor:Jt,resolveEndpoint:on,fallback:tn}),[q,Jt,tn,on]),un=o(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:l}=e;if("function"==typeof n){const e=s(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=s(t.source),d=s(t.target);return"target"===c&&d?a(d):u?a(u):l}({edge:e,particleStyleColor:xt.color,particleColorBy:xt.colorBy,hasExplicitParticleColorBy:!!H?.colorBy,getEdgeColor:ln,getNodeColor:Jt,resolveEndpoint:on,fallback:tn}),[H?.colorBy,xt.color,xt.colorBy,Jt,ln,tn,on]),hn=("sankey"===l||!!Xe)&&j||!!Ee||(Dt.current?.isAnimating??!1);!function(e,t,n,r){Kt(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(Dt,wt,Ke,dt),function(e,t,n,r){const o=Zt(null);Kt(()=>{const i=e.current;if(!i)return;const a=t??null;o.current!==a&&(o.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,r())},[t,r,e,n])}(Dt,Ve,Ke,dt),n(()=>{const e=Dt.current;e&&(e.buildScene([nt,rt]),Ut.current=Fa({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:G}),Ke.current=!0,dt())},[ft,nt,rt,dt]);const fn=o(()=>{const e=Dt.current;if(e&&(e.runLayout([nt,rt]),e.buildScene([nt,rt]),Ke.current=!0,Ut.current=Fa({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:G}),_t(e.layoutVersion),fe)){const{nodes:t,edges:n}=e.getLayoutData();fe(t,n)}},[nt,rt,fe,G]),yn=o(e=>{if(null==e||"object"!=typeof e)return;const t=Dt.current;t&&(t.ingestEdge(e)&&fn(),dt())},[fn,dt]),pn=o(e=>{const t=Dt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&fn(),dt()},[fn,dt]),mn=o(()=>{Dt.current?.clear(),Vt.current.clear(),Ut.current=0,_t(Dt.current?.layoutVersion??0),It(null),qt.current=null,Ke.current=!0,dt()},[dt]),bn=o(()=>{const e=Dt.current;e&&(e.tension+=999,fn(),dt())},[fn,dt]);i(s,()=>({push:yn,pushMany:pn,removeNode:e=>{const t=Dt.current?.removeNode(e)??!1;if(t){const t=qt.current?.data?"function"==typeof p?p(qt.current.data):qt.current.data[p]:void 0;qt.current&&"node"===qt.current.nodeOrEdge&&t===e&&(qt.current=null,It(null)),Vt.current.delete(e),fn(),Ke.current=!0,dt()}return t},removeEdge:(e,t)=>{const n=Dt.current?.removeEdge(e,t)??!1;if(n){if(qt.current&&"edge"===qt.current.nodeOrEdge){const n=qt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!x||!n||("function"==typeof x?x:e=>e?.[x])(n)===e,r&&(qt.current=null,It(null))}fn(),Ke.current=!0,dt()}return n},updateNode:(e,t)=>{const n=Dt.current?.updateNode(e,t)??null;return n&&(Ke.current=!0,dt()),n},updateEdge:(e,t,n)=>{const r=Dt.current?.updateEdge(e,t,n)??[];return r.length>0&&(fn(),Ke.current=!0,dt()),r},clear:mn,getTopology:()=>Dt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Dt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Dt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Dt.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:bn,getTension:()=>Dt.current?.tension??0}),[yn,pn,mn,bn,fn,dt]);const vn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),xn=vn?g||(Array.isArray(f)?void 0:f):void 0;n(()=>{const e=Dt.current;if(!e)return;const t=++jt.current;if(Ft.current?.abort(),Ft.current=null,vn&&xn)e.ingestHierarchy(xn,[nt,rt]),e.buildScene([nt,rt]),zt(!1),Xt.current?.("ready"),Ke.current=!0,dt();else{const n=pt,r=Array.isArray(mt)?mt:[];if(0===n.length&&0===r.length)return null==h&&null==f||0>=e.nodes.size&&0>=e.edges.size||mn(),zt(!1),void Xt.current?.("ready");const o=[nt,rt],i="force"===l&&!Xe&&da()&&ua(D,n.length,r.length,C);if(i&&yt&&!Yt.current&&e.sceneNodes.length>0)return Yt.current=!0,zt(!1),Xt.current?.("ready"),Ke.current=!0,void dt();if(i){const i=new AbortController;Ft.current=i;const a=e._lastPositionSnapshot;e.ingestBounded(n,r,o,{deferLayout:!0});const s=e.getLayoutData(),l=function(e,t,n,r,o){const i=He(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.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,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength},size:r}}(s.nodes,s.edges,Gt.current,o,a);return zt(!0),Xt.current?.("pending"),ya(l,i.signal).then(({positions:n})=>{t===jt.current&&(e.applyForceLayoutPositions(n,o),e.buildScene(o),Ut.current=Fa({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:G}),zt(!1),Xt.current?.("ready"),_t(e.layoutVersion),Ke.current=!0,dt())}).catch(n=>{"AbortError"!==n.name&&t===jt.current&&(e.runLayout(o),e.buildScene(o),Ut.current=Fa({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:G}),zt(!1),Xt.current?.("error"),_t(e.layoutVersion),Ke.current=!0,dt())}),()=>i.abort()}e.ingestBounded(n,r,o),e.buildScene(o),zt(!1),Xt.current?.("ready"),Ut.current=Fa({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:G}),Ke.current=!0,dt()}},[pt,mt,h,f,g,xn,vn,nt,rt,St,D,C,yt,l,Xe,dt,mn,G]),n(()=>{y&&y.length>0&&pn(y)},[]);const kn=o(e=>{if(ce&&ce(e),de){const t=Date.now();de(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:he}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:he})}},[ce,de,he]),wn=o(e=>{if(ue&&ue(e),de){const t=Date.now();de(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:he}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:he})}},[ue,de,he]),{hoverHandlerRef:Sn,hoverLeaveRef:An,onPointerMove:Mn,onPointerLeave:Ln}=Ze,Cn=()=>!Xe||(Dt.current?.hasCustomRestyle??!1);Sn.current=e=>{if(!se)return;const t=Cn(),n=Mt.current;if(!n)return;const r=Dt.current;if(!r)return;const o=Ua({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:tt,adjustedWidth:nt,adjustedHeight:rt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(qt.current=o.hover,It(o.hover),kn&&(kn(o.hover),t&&(Ke.current=!0)),t&&dt()):qt.current&&(qt.current=null,It(null),kn&&(kn(null),t&&(Ke.current=!0)),t&&dt())},An.current=()=>{if(qt.current){const e=Cn();qt.current=null,It(null),kn&&(kn(null),e&&(Ke.current=!0)),e&&dt()}};const En=e(()=>{});En.current=e=>{if(!ue&&!de)return;const t=Mt.current;if(!t)return;const n=Dt.current;if(!n)return;const r=Ua({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:tt,adjustedWidth:nt,adjustedHeight:rt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?wn(r.hover):"miss"===r.kind&&wn(null)};const Nn=o(e=>En.current(e),[]),In=e(-1),Tn=e(null),_n=e(-1),Pn=o(e=>{const t=Dt.current;if(!t)return;const n=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=sn(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===n.length)return;const r=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.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 r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(n),o=In.current;if(0>o){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),In.current=0,_n.current=-1;const t=r.flat[0];Tn.current={shape:t.shape,w:t.w,h:t.h};const n=c(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return qt.current=n,It(n),kn&&(kn(n),Ke.current=!0),void dt()}const i=function(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)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(r,o),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return cn(e,t,n);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=dn(t.source),i=dn(t.target),a=null!=o,s=null!=i;a&&o+""===n&&s?r.push(i+""):s&&i+""===n&&a&&r.push(o+"")}return r}(a,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=cn(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,i,r,t.sceneEdges??[],_n);if(null===a)return;if(e.preventDefault(),0>a)return In.current=-1,Tn.current=null,_n.current=-1,qt.current=null,It(null),kn&&(kn(null),Ke.current=!0),void dt();In.current=a;const s=r.flat[a];Tn.current={shape:s.shape,w:s.w,h:s.h};const l={data:s.datum||{},x:s.x,y:s.y,__semioticHoverData:!0,nodeOrEdge:"node"};qt.current=l,It(l),kn&&(kn(l),Ke.current=!0),dt()},[kn,dt]),Rn=o(e=>{In.current=-1,Tn.current=null,Mn(e)},[Mn]);ut.current=()=>{ct.current=null;const e=Mt.current;if(!e)return;const t=Dt.current;t&&Ha({canvas:e,store:t,size:et,margin:tt,adjustedWidth:nt,adjustedHeight:rt,background:ae,dirtyRef:Ke,lastFrameTimeRef:Lt,reducedMotion:!!Ue.current,showParticles:j,isContinuous:hn,animate:Ne,decay:Ce,pulse:Ee,thresholds:Te,staleness:Ie,particleStyle:xt,getParticleColor:un,pendingAnnotationFrameRef:Et,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:Rt,scheduleNextFrame:()=>{dt()}})},function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:a,cleanup:s}=e;mi(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,a?.(),i.current()},[t,n]);const l=gi(s);l.current=s,hi(()=>()=>l.current?.(),[])}({hydrated:gt,wasHydratingFromSSR:yt,storeRef:Dt,dirtyRef:Ke,renderFnRef:ut,cancelRender:ht}),n(()=>{Ke.current=!0,dt()},[l,nt,rt,ae,dt]),function(e,t,n,r,o,i){const a=mr("fresh");pr(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return vr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...br,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:vr}(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===o||(a.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(s)},[e,o,r])}(Ie,Dt,Ke,dt,$t,Wt);const $n=se&&Nt?Ja(Dn,{x:Nt.x,y:Nt.y,containerWidth:nt,containerHeight:rt,margin:tt,className:"stream-network-tooltip",zIndex:2,children:le?le(Nt):Ja(ka,{data:Nt})}):null;if(di||!gt&&yt){const e=Dt.current;if(e){const t=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=t?g||(Array.isArray(f)?void 0:f):void 0;if(t&&n)e.ingestHierarchy(n,[nt,rt]),e.buildScene([nt,rt]);else{const t=pt,n=Array.isArray(mt)?mt:[];(t.length>0||n.length>0)&&(e.ingestBounded(t,n,[nt,rt]),e.buildScene([nt,rt]))}}const t=e?.sceneNodes??[],n=e?.sceneEdges??[],r=e?.labels??[];return es("div",{ref:Je,className:"stream-network-frame"+(ie?" "+ie:""),role:"img","aria-label":Pe||("string"==typeof Ae?Ae:"Network chart"),style:{position:"relative",width:ne?"100%":et[0],height:re?"100%":et[1]},children:[Ja(Vi,{summary:Re}),es("svg",{xmlns:"http://www.w3.org/2000/svg",width:et[0],height:et[1],style:{position:"absolute",left:0,top:0},children:[it&&Ja("g",{transform:`translate(${tt.left},${tt.top})`,children:it}),es("g",{transform:`translate(${tt.left},${tt.top})`,children:[ae&&Ja("rect",{x:0,y:0,width:nt,height:rt,fill:ae}),n.map((e,t)=>function(e,t){switch(e.type){case"line":return si("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return si("path",{d:n.pathD,fill:ui(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return si("path",{d:n.pathD,fill:ui(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 si("path",{d:n.pathD,fill:ui(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),t.map((e,t)=>function(e,t){switch(e.type){case"circle":{const n=e;return si("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:ui(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+t)}case"rect":{const n=e;return si("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:ui(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+t)}case"arc":{const n=e,r=ai().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ci)||"";return si("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:ui(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+t)}case"symbol":{const n=e,r=Qo(n.symbolType,n.size,n.path);return si("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ui(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return function(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=en(o,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=an(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:nn(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:nn(n.stroke??"none",s,e.accent);return o||i?si("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return li("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&si("clipPath",{id:c,children:si("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?si("g",{children:d(e.ghostColor)}):null,l&&c?si("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)).filter(Boolean),r.map((e,t)=>function(e,t){return si("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)]})]}),Ja(ei,{width:nt,height:rt,totalWidth:et[0],totalHeight:et[1],margin:tt,labels:r,sceneNodes:t,title:Ae,legend:me,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:ke,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:Ht(ot,Qt(Dt.current?.customLayoutOverlays,Ve??null)),annotations:ge,autoPlaceAnnotations:ye,svgAnnotationRules:pe,annotationFrame:0}),Ja(oi,{marks:e?.customLayoutHtmlMarks,margin:tt,selection:Ve??null})]})}const Wn=Dt.current;return es("div",{ref:Je,className:"stream-network-frame"+(ie?" "+ie:""),role:"group","aria-label":Pe||("string"==typeof Ae?Ae:"Network chart"),tabIndex:0,"aria-busy":Ot||void 0,style:{position:"relative",width:ne?"100%":et[0],height:re?"100%":et[1],overflow:"visible"},onKeyDown:Pn,children:[_e&&Ja(Qi,{tableId:lt}),_e&&Ja(qi,{nodes:Wn?.sceneNodes??[],edges:Wn?.sceneEdges??[],chartType:"Network chart",tableId:lt,chartTitle:"string"==typeof Ae?Ae:void 0}),Ja(Vi,{summary:Re}),Ja(Ki,{hoverPoint:Nt}),es("div",{role:"img","aria-label":Pe||("string"==typeof Ae?Ae:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:se?Rn:void 0,onMouseLeave:se?Ln:void 0,onClick:ue||de?Nn:void 0,children:[Ot&&!1!==N&&Ja("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:ca(!0,et[0],et[1],N)}),it&&Ja("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:et[0],height:et[1],pointerEvents:"none",overflow:"visible"},children:Ja("g",{transform:`translate(${tt.left},${tt.top})`,children:it})}),Ja("canvas",{ref:Mt,"aria-label":Pi(Wn?.sceneNodes?.length??0,Wn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Ja(ei,{width:nt,height:rt,totalWidth:et[0],totalHeight:et[1],margin:tt,labels:Wn?.labels||[],sceneNodes:Wn?.sceneNodes,title:Ae,legend:me,legendPosition:be,legendLayout:ve,legendHoverBehavior:xe,legendClickBehavior:ke,legendHighlightedCategory:we,legendIsolatedCategories:Se,foregroundGraphics:Ht(ot,Qt(Dt.current?.customLayoutOverlays,Ve??null)),annotations:ge,autoPlaceAnnotations:ye,svgAnnotationRules:pe,annotationFrame:Pt}),Ja(oi,{marks:Wn?.customLayoutHtmlMarks,margin:tt,selection:Ve??null}),Ja(gn,{active:In.current>=0,hoverPoint:Nt,margin:tt,size:et,shape:Tn.current?.shape,width:Tn.current?.w,height:Tn.current?.h}),$n,Ie?.showBadge&&Ja(kr,{isStale:$t,position:Ie.badgePosition})]})]})}));is.displayName="StreamNetworkFrame";var as=is;import{useImperativeHandle as ss}from"react";function ls(e,t){const{variant:n,frameRef:r,overrides:o,deps:i}=t;ss(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},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 r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);return{...e,...o}},i??[])}import{useMemo as cs,forwardRef as us,useRef as ds}from"react";import{useMemo as hs,useCallback as fs,useState as gs,useId as ys,useEffect as ps,useRef as ms}from"react";import{createContext as bs,useContext as vs,useMemo as xs}from"react";import{jsx as ks}from"react/jsx-runtime";var ws=bs(null);import{createContext as Ss,useContext as As,useEffect as Ms,useId as Ls,useLayoutEffect as Cs,useMemo as Es,useRef as Ds,useState as Ns,useCallback as Is}from"react";function Ts(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function _s(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Ps(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[Rs,$s]=Fn(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&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,r]of n){const n=t.fields[e];if(!n||!Ps(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),a=_s(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=_s(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),[Ws,Os]=Fn(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}))}}));import{useId as zs,useMemo as Bs,useCallback as js}from"react";import{useSyncExternalStore as Hs}from"react";var Fs={positions:new Map},Ys=new Set;function Xs(){for(const e of Ys)e()}function Gs(e,t){const n=Fs.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Fs.positions);r.delete(e),Fs={positions:r},Xs()}function qs(e,t){const n=Fs.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Fs.positions);r.delete(e),Fs={positions:r},Xs()}function Vs(e){const t=zs(),n=e.clientId||t,{name:r}=e,o=$s(e=>e.selections.get(r)),i=$s(e=>e.setClause),a=$s(e=>e.clearClause),s=Bs(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Bs(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Ts(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:js(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:js(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:js(()=>{a(r,n)},[a,r,n]),clientId:n}}import{jsx as Qs,jsxs as Ks}from"react/jsx-runtime";var Zs=Ss(!1);Ss(!1);var Us=Ss(null),Js="undefined"==typeof window?Ms:Cs;import*as el from"react";import{jsx as tl,jsxs as nl}from"react/jsx-runtime";function rl(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ol(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function il(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>ol(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])rl(e[r])&&rl(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}function al(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function sl(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 ll(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}el.createContext(void 0);var cl={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function ul(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!i)return cl;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function dl(){const e=Jn(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function hl(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=At(n,r);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=bt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:"#007bff"}function fl({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:r=!1,onObservation:o,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=ys(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),f="series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n||[],g=Vs({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=Vs({name:t,fields:n});return{onHover:js(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,a,t]),predicate:r,isActive:o}}({name:h?.name||"hover",fields:f}),p=Os(e=>e.pushObservation),m=e?{isActive:g.isActive,predicate:g.predicate}:null,[b,v]=gs(null),x=ms(!1),k=c||n[0],w=hs(()=>{if(!l||null==b||!k)return null;const e=b,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,b,k]),S=fs(e=>{const n=!e&&x.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=al(e,t,h.xField);null!=n&&function(e,t,n){const r=Fs.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Fs={positions:new Map(Fs.positions).set(e,{xValue:t,sourceId:n})},Xs())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||n||Gs(h.name||"hover",d),"x-position"===h?.mode||n||y.onHover(null);if(l&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];v(null!=n?n+"":null)}else n||v(null);if(o||p){const t={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(e){const n=sl(e),r={...t,type:"hover",datum:n||{},x:e.x??0,y:e.y??0};o&&o(r),p&&p(r)}else{const e={...t,type:"hover-end"};o&&o(e),p&&p(e)}}},[t,y,h,d,o,i,a,p,l,k,u]),A=fs((n=!0)=>{x.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&g.clear(),n&&l&&v(null),"x-position"===h?.mode&&(qs(h.name||"hover",d),Gs(h.name||"hover",d))},[t,h,y,e,u,g,l,d]),M=fs(n=>{const r=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),c=!!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=al(n,e,h.xField);null!=t&&function(e,t,n){const r=Fs.positions.get(e);if(r?.locked){const t=new Map(Fs.positions);return t.delete(e),Fs={positions:t},Xs(),!1}Fs={positions:new Map(Fs.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Xs()}(h.name||"hover",t,d)}if(r)if(n){x.current=!0;const r=sl(n);if(t&&"x-position"!==h?.mode&&y.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}ll(e)&&g.selectPoints(e)}if(l&&k){const e=r?.[k];v(null!=e?e+"":null)}}else c&&A();if(n||c){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}if(o||p){const e={timestamp:Date.now(),chartType:i||"unknown",chartId:a};if(n){const t=sl(n),r={...e,type:"click",datum:t||{},x:n.x??0,y:n.y??0};o&&o(r),p&&p(r)}else{const t={...e,type:"click-end"};o&&o(t),p&&p(t)}}}},[s,o,p,i,a,h,d,u,t,y,e,g,f,l,k,A]);return ps(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&x.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),ps(()=>()=>{x.current&&A(!1)},[A]),ps(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{qs(e,d),Gs(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:m,hoverSelectionHook:w,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:d}}function gl({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s}){const l=As(Zs),c=null!==As(Us),u=void 0!==r?r:!l&&!!t,d=!!t&&(u||c),h=hs(()=>{if(!d)return[];if(void 0!==s)return s;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[s,t,e,d]);!function(e){const t=As(Us),n=Ls(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=Ds([]);(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})(o.current,r)||(o.current=r);const i=o.current;Js(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),Js(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(c&&t?h:[]);const f=hs(()=>{if(!u||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?r(a,t,n):n?n(o):xt[i%xt.length];return{label:o+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:St,categories:h});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[u,t,e,n,h]),g=hs(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return f&&("right"===o&&!r("right")&&110>n.right?n.right=110:"left"===o&&!r("left")&&110>n.left?n.left=110:"top"===o&&!r("top")&&50>n.top?n.top=50:"bottom"===o&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,i,f,o]);return{legend:f,margin:g,legendPosition:o}}var yl={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function pl(e,t,n){const r=yl[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,a=il({...t,mode:e},{width:t.width??o,height:t.height??i}).props,s=a.mode||e,l=yl[s||"primary"],c="context"===s||"sparkline"===s,u=s&&"primary"!==s||!n?.width?l.width:n.width;return{width:a.width??u,height:a.height??(s&&"primary"!==s||!n?.height?l.height:n.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:ml(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:ul(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}function ml(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{useMemo as bl}from"react";function vl(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function xl(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function kl(e){return"function"==typeof e?e:t=>t[e]||1}function wl({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return a=>{const s={fillOpacity:o,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=St(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=St(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function Sl(e){const{nodes:t,edges:n,inferNodes:r=!0,sourceAccessor:o="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:c,legendInteraction:u,selection:d,linkedHover:h,onObservation:f,onClick:g,mobileInteraction:y,mobileSemantics:p,chartType:m,chartId:b,marginDefaults:v,userMargin:x,width:k,height:w,loading:S,loadingContent:A,emptyContent:M,emptyDataKey:L="edges"}=e,C=bl(()=>Ui(n),[n]),E=bl(()=>Ui(t),[t]),D=ca(S,k,w,A),N=D?null:function(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?ia("div",{style:{...sa,width:t,height:n},children:r||"No data available"}):null}("nodes"===L?void 0===t?void 0:E:void 0===n?void 0:C,k,w,M),I=bl(()=>r?xl(E,C,o,i):E,[r,E,C,o,i]),T=function(e,t,n){const r=vs(ws),o=dl();return hs(()=>{if(!t)return;const i=r??void 0,a=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&ll(i)){const e=Mt(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return Mt(n.map(e=>({_cat:e})),"_cat",a)}if(i&&ll(i)){const n=Mt(e,t,a);return e=>i[e]||n(e)}return Mt(e,t,a)}if(i&&ll(i)){const e=Mt([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,r,o])}(I,a,s),_=dl(),P=bl(()=>{if(Array.isArray(s))return s;if(_&&_.length>0)return _;if("string"==typeof s){const e=bt[s];if(Array.isArray(e)&&e.length>0)return e}return vt},[s,_]),R=bl(()=>{if(!a)return[];const e=new Set;for(const t of I){const n="function"==typeof a?a(t):t[a];null!=n&&e.add(n+"")}return Array.from(e)},[I,a]),$=function(e,t,n){const[r,o]=gs(null),[i,a]=gs(new Set),s=hs(()=>new Set,[]),l=fs(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=fs(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=hs(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(u,a,R),{legend:W,margin:O,legendPosition:z}=gl({data:I,colorBy:a,colorScale:T,showLegend:l,legendPosition:c,userMargin:x,defaults:v,categories:R}),B=bl(()=>ul(y,{width:k,mobileSemantics:p}),[y,k,p]),j=fl({selection:d,linkedHover:h,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:g,mobileInteraction:B,chartType:m,chartId:b}),{customHoverBehavior:H,customClickBehavior:F,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G}=j;return{safeNodes:I,safeEdges:C,colorScale:T,effectivePalette:P,themeCategorical:_,allCategories:R,legendState:$,legend:W,margin:O,legendPosition:z,mobileInteraction:B,customHoverBehavior:H,customClickBehavior:F,activeSelectionHook:Y,hoverSelectionHook:X,crosshairSourceId:G,loadingEl:D,emptyEl:N}}function Al(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return 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 Ml(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=e[i-1]===t[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function Ll(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=Ml(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}function Cl({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 El({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!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(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:a).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=Ll(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var a;return null}function Dl(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={},g=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||r||o||a)&&(f.customHoverBehavior=u),d&&(l||(h?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||n))&&(f.customClickBehavior=d),null!=g&&(f.hoverRadius=g),f}import{jsx as Nl}from"react/jsx-runtime";var Il=us(function(e,t){const n=ds(null);ls(t,{variant:"network",frameRef:n});const r=pl(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:o,edges:i,margin:a,className:s,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:g,nodeSize:y=8,nodeSizeRange:p=[5,20],edgeWidth:m=1,edgeColor:b="#999",edgeOpacity:v=.6,iterations:x=300,forceStrength:k=.1,layoutExecution:w="auto",layoutLoadingContent:S,onLayoutStateChange:A,tooltip:M,frameProps:L={},onObservation:C,onClick:E,chartId:D,selection:N,linkedHover:I,loading:T,loadingContent:_,emptyContent:P,legendInteraction:R,legendPosition:$,stroke:W,strokeWidth:O,opacity:z}=e,B=l??c??"id",{width:j,height:H,enableHover:F,showLegend:Y,showLabels:X=!1,title:G,description:q,summary:V,accessibleTable:Q}=r,K=Sl({nodes:o,edges:i,inferNodes:!1,nodeIdAccessor:B,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:g,showLegend:Y,legendPosition:$,legendInteraction:R,selection:N,linkedHover:I,onObservation:C,onClick:E,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:D,marginDefaults:r.marginDefaults,userMargin:a,width:j,height:H,loading:T,loadingContent:_,emptyContent:P,emptyDataKey:"nodes"}),Z=cs(()=>new Map,[]),U=cs(()=>e=>{const t={};return t.fill=f?St(e.data||e,f,K.colorScale):hl(void 0,K.themeCategorical,g,void 0,Z),"number"==typeof y&&(t.r=y),t},[f,K.colorScale,y,K.themeCategorical,g,Z]),J=cs(()=>Al(U,{stroke:W,strokeWidth:O,opacity:z}),[U,W,O,z]),ee=cs(()=>e=>{const t=e.data||e;let n;if("number"==typeof m)n=m;else if("function"==typeof m)n=m(t);else{const e=t[m],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:1}return{stroke:b,strokeWidth:n,opacity:v}},[m,b,v]),te=cs(()=>Al(ee,{stroke:W,strokeWidth:O,opacity:z}),[ee,W,O,z]),ne=cs(()=>{if(X&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[X,h]),re=El({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:B}});return re?Nl(na,{componentName:"ForceDirectedGraph",message:re,width:j,height:H}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:Nl(aa,{componentName:"ForceDirectedGraph",width:j,height:H,children:Nl(as,{ref:n,chartType:"force",...null!=o&&{nodes:K.safeNodes},...null!=i&&{edges:K.safeEdges},size:[j,H],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,nodeIDAccessor:B,sourceAccessor:u,targetAccessor:d,iterations:x,forceStrength:k,layoutExecution:w,layoutLoadingContent:S,onLayoutStateChange:A,nodeStyle:J,edgeStyle:te,colorBy:f,colorScheme:K.effectivePalette,nodeSize:y,nodeSizeRange:p,nodeLabel:ne,showLabels:X,enableHover:F,tooltipContent:!1===M?()=>null:Cn(M)||void 0,...Dl({linkedHover:I,selection:N,onObservation:C,onClick:E,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:K.legend,legendPosition:K.legendPosition,...R&&"none"!==R&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},className:s,title:G,description:q,summary:V,accessibleTable:Q,...null!=e.animate&&{animate:e.animate},...L})})});Il.displayName="ForceDirectedGraph";import{useEffect as Tl,useMemo as _l,useRef as Pl,useState as Rl}from"react";import{forceCenter as $l,forceCollide as Wl,forceLink as Ol,forceManyBody as zl,forceSimulation as Bl,forceX as jl,forceY as Hl}from"d3-force";function Fl(e,t,n={}){const r=n.iterations??260,o=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,l=n.damping??.84,c=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=function(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}}(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const g=500,y=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),p=new Set(e.map(e=>e.id)),m=t.filter(e=>p.has(e.source)&&p.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=Bl(y).randomSource(h).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",zl().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",Wl(e=>(e=>"function"==typeof c?c(e.data):c)(e)+u).strength(.9).iterations(2)).force("center",$l(g,g).strength(.8)).force("x",jl(g).strength(s)).force("y",Hl(g).strength(s));m.length>0&&e.force("link",Ol(m).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/n})),e.stop();for(let t=0;r>t;t+=1)e.tick()}let b=1/0,v=1/0,x=-1/0,k=-1/0;for(const e of y){const t=e.x??g,n=e.y??g;b>t&&(b=t),v>n&&(v=n),t>x&&(x=t),n>k&&(k=n)}const w=x-b,S=k-v,A={};for(const e of y)A[e.id]={x:0===w?.5:d+((e.x??g)-b)/w*(1-2*d),y:0===S?.5:d+((e.y??g)-v)/S*(1-2*d)};return A}var Yl=new WeakMap;function Xl(e){const t=[];for(const n of Object.keys(e).sort()){const r=e[n];if(void 0!==r){if("function"==typeof r)return null;t.push(`${n}:${r+""}`)}}return t.join("|")}function Gl(e,t,n){return null==n?null:Yl.get(e)?.get(t)?.get(n)??null}function ql(e,t,n,r){if(null==n)return;let o=Yl.get(e);o||(o=new WeakMap,Yl.set(e,o));let i=o.get(t);if(i||(i=new Map,o.set(t,i)),!i.has(n)&&i.size>=16){const e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(n,r)}function Vl(e,t,n={}){const r=ki(),{seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}=n,p=_l(()=>({seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}),[o,i,a,s,l,c,u,d,h,f,g,y]),m=Pl(r),[b,v]=Rl(()=>{if("undefined"==typeof window||r){const n=Fl(e,t,p);return ql(e,t,Xl(p),n),{positions:n,status:"ready",error:null}}const n=Gl(e,t,Xl(p));return n?{positions:n,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return Tl(()=>{if(m.current)return void(m.current=!1);const n=Xl(p),r=Gl(e,t,n);if(r)return void v(e=>"ready"===e.status&&e.positions===r?e:{positions:r,status:"ready",error:null});const o=new AbortController;return v(e=>({positions:e.positions,status:"pending",error:null})),async function(e,t,n={}){const{execution:r="auto",signal:o,workerThreshold:i,nodeRadius:a,...s}=n,l=s.iterations??260;if(!da()||!ua(r,e.length,t.length,l,i))return Fl(e,t,{...s,nodeRadius:a});const c={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(e.map(e=>[e.id,a(e)])):null==a?void 0:Object.fromEntries(e.map(e=>[e.id,a]))};try{return(await ya(c,o)).positions}catch(n){if("AbortError"===n?.name)throw n;return Fl(e,t,{...s,nodeRadius:a})}}(e,t,{...p,signal:o.signal}).then(r=>{ql(e,t,n,r),v({positions:r,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&v(t=>({positions:t.positions,status:"error",error:e}))}),()=>o.abort()},[e,t,p]),b}import{useMemo as Ql,forwardRef as Kl,useRef as Zl}from"react";import{jsx as Ul}from"react/jsx-runtime";var Jl=Kl(function(e,t){const n=Zl(null);ls(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=pl(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:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,edgeColorBy:g="source",orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:m=.05,nodeWidth:b=15,nodeLabel:v,edgeOpacity:x=.5,edgeSort:k,tooltip:w,frameProps:S={},onObservation:A,onClick:M,chartId:L,selection:C,linkedHover:E,loading:D,loadingContent:N,emptyContent:I,showLegend:T,legendPosition:_,legendInteraction:P,stroke:R,strokeWidth:$,opacity:W}=e,{width:O,height:z,enableHover:B,showLabels:j=!0,title:H,description:F,summary:Y,accessibleTable:X}=r,G=Sl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:T,legendPosition:_,legendInteraction:P,selection:C,linkedHover:E,onObservation:A,onClick:M,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:L,marginDefaults:r.marginDefaults,userMargin:a,width:O,height:z,loading:D,loadingContent:N,emptyContent:I}),q=Ql(()=>new Map,[]),V=Ql(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?St(e.data||e,h,G.colorScale):hl(void 0,G.themeCategorical,f,void 0,q),t},[h,G.colorScale,G.themeCategorical,f,q]),Q=Ql(()=>Al(V,{stroke:R,strokeWidth:$,opacity:W}),[V,R,$,W]),K=Ql(()=>wl({edgeColorBy:g,colorBy:h,colorScale:G.colorScale,nodeStyleFn:Q,edgeOpacity:x,baseStyle:{stroke:"none",strokeWidth:0}}),[g,h,G.colorScale,Q,x]),Z=Ql(()=>Al(K,{stroke:R,strokeWidth:$,opacity:W}),[K,R,$,W]),U=Ql(()=>{if(!j)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[j,v,d]),J=El({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return J?Ul(na,{componentName:"SankeyDiagram",message:J,width:O,height:z}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:Ul(aa,{componentName:"SankeyDiagram",width:O,height:z,children:Ul(as,{ref:n,chartType:"sankey",...G.safeNodes.length>0&&{nodes:G.safeNodes},...null!=i&&{edges:G.safeEdges},size:[O,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:G.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:y,nodeAlign:p,nodePaddingRatio:m,nodeWidth:b,nodeStyle:Q,edgeStyle:Z,colorBy:h,colorScheme:G.effectivePalette,edgeColorBy:g,edgeOpacity:x,edgeSort:k,nodeLabel:U,showLabels:j,enableHover:B,tooltipContent:!1===w?()=>null:Cn(w)||void 0,...Dl({linkedHover:E,selection:C,onObservation:A,onClick:M,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:G.legend,legendPosition:G.legendPosition,...P&&"none"!==P&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},className:s,title:H,description:F,summary:Y,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...S})})});Jl.displayName="SankeyDiagram";import{useMemo as ec,forwardRef as tc,useRef as nc}from"react";import{jsx as rc}from"react/jsx-runtime";var oc=tc(function(e,t){const n=nc(null);ls(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=pl(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:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,edgeColorBy:g="source",padAngle:y=.01,groupWidth:p=20,sortGroups:m,nodeLabel:b,edgeOpacity:v=.5,tooltip:x,frameProps:k={},onObservation:w,onClick:S,chartId:A,selection:M,linkedHover:L,loading:C,loadingContent:E,emptyContent:D,legendInteraction:N,stroke:I,strokeWidth:T,opacity:_}=e,{width:P,height:R,enableHover:$,showLabels:W=!0,title:O,description:z,summary:B,accessibleTable:j}=r,H=Sl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:!1,legendInteraction:N,selection:M,linkedHover:L,onObservation:w,onClick:S,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:a,width:P,height:R,loading:C,loadingContent:E,emptyContent:D}),F=ec(()=>new Map,[]),Y=H.safeNodes.length>0,X=ec(()=>{if(Y)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=St(e.data||e,h,H.colorScale);else{const r=Array.isArray(f)?f:bt[f]||vt,o=Array.isArray(r)?r:vt;n.fill=o[(e.index??t??0)%o.length]}return n}},[Y,h,H.colorScale,f]),G=ec(()=>X?Al(X,{stroke:I,strokeWidth:T,opacity:_}):void 0,[X,I,T,_]),q=ec(()=>{if(Y)return wl({edgeColorBy:g,colorBy:h,colorScale:H.colorScale,nodeStyleFn:G||(e=>({fill:hl(void 0,H.themeCategorical,f,void 0,F)})),edgeOpacity:v,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:v}})},[Y,g,h,H.colorScale,G,v,H.themeCategorical,f,F]),V=ec(()=>q?Al(q,{stroke:I,strokeWidth:T,opacity:_}):void 0,[q,I,T,_]),Q=ec(()=>{if(!W)return;const e=b||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[W,b,d]),K=El({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return K?rc(na,{componentName:"ChordDiagram",message:K,width:P,height:R}):H.loadingEl?H.loadingEl:H.emptyEl?H.emptyEl:rc(aa,{componentName:"ChordDiagram",width:P,height:R,children:rc(as,{ref:n,chartType:"chord",...H.safeNodes.length>0&&{nodes:H.safeNodes},...null!=i&&{edges:H.safeEdges},size:[P,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:H.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:y,groupWidth:p,sortGroups:m,nodeStyle:G,edgeStyle:V,colorBy:h,colorScheme:H.effectivePalette,edgeColorBy:g,edgeOpacity:v,nodeLabel:Q,showLabels:W,enableHover:$,tooltipContent:!1===x?()=>null:Cn(x)||void 0,...Dl({linkedHover:L,selection:M,onObservation:w,onClick:S,mobileInteraction:H.mobileInteraction,customHoverBehavior:H.customHoverBehavior,customClickBehavior:H.customClickBehavior,linkedHoverInClickPredicate:!1}),...N&&"none"!==N&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},className:s,title:O,description:z,summary:B,accessibleTable:j,...null!=e.animate&&{animate:e.animate},...k})})});oc.displayName="ChordDiagram";import{useMemo as ic}from"react";import{jsx as ac}from"react/jsx-runtime";function sc(e){const t=pl(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:r,className:o,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:f="curve",nodeLabel:g,nodeSize:y=5,tooltip:p,frameProps:m={},onObservation:b,onClick:v,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:A,legendInteraction:M,stroke:L,strokeWidth:C,opacity:E}=e,{width:D,height:N,enableHover:I,showLabels:T=!0,title:_,description:P,summary:R,accessibleTable:$}=t,W=Sl({nodes:ic(()=>vl(n??null,s),[n,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:M,selection:k,linkedHover:w,onObservation:b,onClick:v,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:D,height:N,loading:S,loadingContent:A}),O=ic(()=>new Map,[]),z=ic(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?kt[(e.depth||0)%kt.length]:u?St(e.data||e,u,W.colorScale):hl(void 0,W.themeCategorical,d,void 0,O),t},[u,h,W.colorScale,W.themeCategorical,d,O]),B=ic(()=>Al(z,{stroke:L,strokeWidth:C,opacity:E}),[z,L,C,E]),j=ic(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=ic(()=>Al(j,{stroke:L,strokeWidth:C,opacity:E}),[j,L,C,E]),F=ic(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return kl(l)},[i,l]),Y=Cl({componentName:"TreeDiagram",data:n});return Y?ac(na,{componentName:"TreeDiagram",message:Y,width:D,height:N}):W.loadingEl?W.loadingEl:ac(aa,{componentName:"TreeDiagram",width:D,height:N,children:ac(as,{chartType:i,...null!=n&&{data:n},size:[D,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:F,treeOrientation:a,edgeType:f,nodeStyle:B,edgeStyle:H,colorBy:u,colorScheme:W.effectivePalette,colorByDepth:h,nodeSize:y,nodeLabel:T?g||c:void 0,showLabels:T,enableHover:I,tooltipContent:!1===p?()=>null:Cn(p)||void 0,...Dl({linkedHover:w,selection:k,onObservation:b,onClick:v,mobileInteraction:W.mobileInteraction,customHoverBehavior:W.customHoverBehavior,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...M&&"none"!==M&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:o,title:_,description:P,summary:R,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...m})})}sc.displayName="TreeDiagram";import{useMemo as lc,useCallback as cc}from"react";import{useMemo as uc}from"react";import{jsx as dc}from"react/jsx-runtime";function hc(e){const t=pl(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:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:f=4,paddingTop:g,nodeStyle:y,tooltip:p,frameProps:m={},selection:b,linkedHover:v,onObservation:x,onClick:k,chartId:w,loading:S,loadingContent:A,legendInteraction:M,stroke:L,strokeWidth:C,opacity:E}=e,{nodeStyle:D,...N}=m,{width:I,height:T,enableHover:_,showLabels:P=!0,title:R,description:$,summary:W,accessibleTable:O}=t,z=Sl({nodes:lc(()=>vl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:M,selection:b,linkedHover:v,onObservation:x,onClick:k,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:w,marginDefaults:t.marginDefaults,userMargin:r,width:I,height:T,loading:S,loadingContent:A}),B=function(e){const t=Jn(e=>e.theme.colors.selectionOpacity);return uc(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(b),j=z.customHoverBehavior,H=cc(e=>{if(!e)return j(null);const t=e.data||e;j({data:t?.data||t})},[j]),F=lc(()=>new Map,[]),Y=lc(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?kt[(e.depth||0)%kt.length]:l?St(e.data||e,l,z.colorScale):hl(void 0,z.themeCategorical,c,void 0,F),t},[l,u,z.colorScale,z.themeCategorical,c,F]),X=lc(()=>y||D?e=>({...Y(e),...D?D(e)??{}:{},...y?y(e)??{}:{}}):Y,[Y,y,D]),G=lc(()=>Al(X,{stroke:L,strokeWidth:C,opacity:E}),[X,L,C,E]),q=lc(()=>z.activeSelectionHook?e=>{const t={...G(e)};if(z.activeSelectionHook.isActive)if(z.activeSelectionHook.predicate(e.data||e))B?.selectedStyle&&Object.assign(t,B.selectedStyle);else{const e=B?.unselectedOpacity??.5;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,B?.unselectedStyle&&Object.assign(t,B.unselectedStyle)}return t}:G,[G,z.activeSelectionHook,B]),V=lc(()=>kl(a),[a]),Q=void 0!==g?g:!P||"parent"!==d&&"all"!==d?void 0:18,K=Cl({componentName:"Treemap",data:n});return K?dc(na,{componentName:"Treemap",message:K,width:I,height:T}):z.loadingEl?z.loadingEl:dc(aa,{componentName:"Treemap",width:I,height:T,children:dc(as,{chartType:"treemap",...null!=n&&{data:n},size:[I,T],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:V,padding:f,paddingTop:Q,nodeStyle:q,colorBy:l,colorScheme:z.effectivePalette,colorByDepth:u,nodeLabel:P?h||s:void 0,showLabels:P,labelMode:d,enableHover:_,tooltipContent:!1===p?()=>null:Cn(p)||void 0,...Dl({linkedHover:v,selection:b,onObservation:x,onClick:k,mobileInteraction:z.mobileInteraction,customHoverBehavior:H,customClickBehavior:z.customClickBehavior,linkedHoverInClickPredicate:!1}),...M&&"none"!==M&&{legendHoverBehavior:z.legendState.onLegendHover,legendClickBehavior:z.legendState.onLegendClick,legendHighlightedCategory:z.legendState.highlightedCategory,legendIsolatedCategories:z.legendState.isolatedCategories},className:o,title:R,description:$,summary:W,accessibleTable:O,...null!=e.animate&&{animate:e.animate},...N})})}hc.displayName="Treemap";import{useMemo as fc}from"react";import{jsx as gc}from"react/jsx-runtime";function yc(e){const t=pl(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:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:f=4,tooltip:g,frameProps:y={},onObservation:p,onClick:m,chartId:b,selection:v,linkedHover:x,loading:k,loadingContent:w,legendInteraction:S,stroke:A,strokeWidth:M,opacity:L}=e,{width:C,height:E,enableHover:D,showLabels:N=!0,title:I,description:T,summary:_,accessibleTable:P}=t,R=Sl({nodes:fc(()=>vl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:p,onClick:m,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:r,width:C,height:E,loading:k,loadingContent:w}),$=fc(()=>new Map,[]),W=fc(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?kt[(e.depth||0)%kt.length]:l?St(e.data||e,l,R.colorScale):hl(void 0,R.themeCategorical,c,void 0,$),t},[l,u,R.colorScale,h,R.themeCategorical,c,$]),O=fc(()=>Al(W,{stroke:A,strokeWidth:M,opacity:L}),[W,A,M,L]),z=fc(()=>kl(a),[a]),B=Cl({componentName:"CirclePack",data:n});return B?gc(na,{componentName:"CirclePack",message:B,width:C,height:E}):R.loadingEl?R.loadingEl:gc(aa,{componentName:"CirclePack",width:C,height:E,children:gc(as,{chartType:"circlepack",...null!=n&&{data:n},size:[C,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:R.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:z,padding:f,nodeStyle:O,colorBy:l,colorScheme:R.effectivePalette,colorByDepth:u,nodeLabel:N?d||s:void 0,showLabels:N,enableHover:D,tooltipContent:!1===g?()=>null:Cn(g)||void 0,...Dl({linkedHover:x,selection:v,onObservation:p,onClick:m,mobileInteraction:R.mobileInteraction,customHoverBehavior:R.customHoverBehavior,customClickBehavior:R.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:R.legendState.onLegendHover,legendClickBehavior:R.legendState.onLegendClick,legendHighlightedCategory:R.legendState.highlightedCategory,legendIsolatedCategories:R.legendState.isolatedCategories},className:o,title:I,description:T,summary:_,accessibleTable:P,...null!=e.animate&&{animate:e.animate},...y})})}yc.displayName="CirclePack";import{useMemo as pc}from"react";import{jsx as mc}from"react/jsx-runtime";var bc=kt;function vc(e){const t=pl(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:r,className:o,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:f,revolutionStyle:g,eccentricity:y=1,showRings:p=!0,nodeRadius:m=6,showLabels:b=!1,animated:v=!0,tooltip:x,foregroundGraphics:k,annotations:w,frameProps:S={},onObservation:A,onClick:M,chartId:L,selection:C,linkedHover:E,loading:D,loadingContent:N,stroke:I,strokeWidth:T,opacity:_}=e,{width:P,height:R,enableHover:$,title:W,description:O,summary:z,accessibleTable:B}=t,j=Sl({nodes:pc(()=>vl(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:s,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:C,linkedHover:E,onObservation:A,onClick:M,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:L,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:P,height:R,loading:D,loadingContent:N}),H=pc(()=>new Map,[]),{colorScale:F,customClickBehavior:Y,customHoverBehavior:X,themeCategorical:G}=j,q=pc(()=>{if(Array.isArray(l))return l;const e=bt[l];return Array.isArray(e)?e:vt},[l]),V=pc(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=c?n?q[0]:bc[(e.depth||0)%bc.length]:s?St(e.data||e,s,F):hl(void 0,G,l,void 0,H),t.opacity=n?1:.85,t},[s,c,F,q,G,l,H]),Q=pc(()=>Al(V,{stroke:I,strokeWidth:T,opacity:_}),[V,I,T,_]),K=pc(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Z=pc(()=>e=>{X(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[X]),U=pc(()=>e=>{Y(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Y]),J=Cl({componentName:"OrbitDiagram",data:n});return J?mc(na,{componentName:"OrbitDiagram",message:J,width:P,height:R}):j.loadingEl?j.loadingEl:mc(aa,{componentName:"OrbitDiagram",width:P,height:R,children:mc(as,{chartType:"orbit",...null!=n&&{data:n},size:[P,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:j.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:Q,edgeStyle:K,colorBy:s,colorScheme:j.effectivePalette,colorByDepth:c,nodeSize:m,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&$,tooltipContent:v?void 0:!1===x?()=>null:Cn(x)||void 0,...Dl({linkedHover:E,selection:C,onObservation:A,onClick:M,mobileInteraction:j.mobileInteraction,customHoverBehavior:Z,customClickBehavior:U,linkedHoverInClickPredicate:!1}),foregroundGraphics:k,annotations:w,className:o,title:W,description:O,summary:z,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:f,orbitRevolutionStyle:g,orbitEccentricity:y,orbitShowRings:p,orbitAnimated:v,accessibleTable:B,...null!=e.animate&&{animate:e.animate},...S})})}vc.displayName="OrbitDiagram";import{useMemo as xc,useState as kc,useRef as wc,useCallback as Sc}from"react";import{scaleTime as Ac}from"d3-scale";import{forwardRef as Mc}from"react";function Lc(e,t,n){const r=[],o=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)o.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}function Cc(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`:e.kind}function Ec(e,t,n){const r=t.incoming[e.id],o=t.outgoing[e.id],i=[];for(const e of r)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of o)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const a={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},s=()=>{i.sort((e,t)=>e.time-t.time||(a[e.kind]??99)-(a[t.kind]??99))},l=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};s();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?y:p);if(r>0){const o=f(e.time);g.push({time:o,delta:-r,kind:"transfer-out",side:t}),g.push({time:o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:p-=r,"top"===e.side?y+=r:p+=r,n-=r}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),s();let m=0,b=0,v=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:m,botMass:b}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:b;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:b+=e.delta,m+b>v&&(v=m+b),m>x&&(x=m),b>k&&(k=b),w.push({t:e.time,topMass:m,botMass:b})}const A=[];let M=0;for(;w.length>M;){let e=M;for(;w.length>e+1&&w[e+1].t===w[M].t;)e++;A.push(w[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||A.push(w[t])}M=e+1}const L=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let C=null;for(const e of o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let E=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===E||e.systemOutTime>E)&&(E=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=L?L:-1/0,null!=E?E:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],r=Math.min(null!=c?c:1/0,null!=C?C:1/0);Number.isFinite(r)&&n.t>r&&n.topMass+n.botMass>0&&A.unshift({t:r,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:v,topPeak:x,botPeak:k,localAttachments:S}}function Dc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Nc(e,t){return e.map(e=>({t:Dc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Ic(e,t,n){const r=e.value*n;if("out"===e.kind){const o=e.sideMassBefore*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}const o=e.sideMassAfter*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}function Tc(e,t){let n=0;for(let r=0;t.length>r;r++)for(let o=r+1;t.length>o;o++){const i=t[r],a=t[o];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&n++)}return n}function _c(e,t){let n=0;for(const r of t)n+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return n}function Pc(e,t){return 1e3*Tc(e,t)+_c(e,t)}function Rc(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function $c(e,t,n){e.length>8||n.length>40?(function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=Rc(e,t),a=Pc(t,n);for(let s=0;r>s;s++){const r=Array(o).fill(0),s=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),s[n]+=e.value||1,r[o]+=n*(e.value||1),s[o]+=e.value||1}const l=Array.from({length:o},(e,t)=>t).sort((e,t)=>(s[e]>0?r[e]/s[e]:e)-(s[t]>0?r[t]/s[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=Pc(t,n);if(a>d)a=d,i=Rc(e,t);else if(d===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=Pc(t,n);for(let a=0;r>a;a++){let r=!1;for(let a=0;o-1>a;a++){const o=e[a];e[a]=e[a+1],e[a+1]=o;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const s=Pc(t,n);if(i>s)i=s,r=!0;else{const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!r)break}}(e,t,n,6)):function(e,t,n){const r=e.length;if(1>=r)return;const o={...t},i=Object.keys(o),a=Array.from({length:r},(e,t)=>t),s=a.slice(),l={...o};let c=a.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=s[o[e]];const e=Pc(l,n);u>e&&(u=e,c=a.slice())},h=(e,t)=>{const n=a[e],r=a[t];a[e]=r,a[t]=n,s[n]=t,s[r]=e};d();const f=Array(r).fill(0);let g=0;for(;r>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function Wc(e,t,n,r,o){const{plotH:i,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="full"}=o,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,g={};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 o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}g[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}const y={},p=[];if("reuse"===l){const n=new Map;for(const t of e)n.set(t.id,0);const o=new Map;for(const t of e)o.set(t.id,0);for(const e of t)o.set(e.target,(o.get(e.target)??0)+1);const i=[];for(const t of e)0===(o.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of r.outgoing[e]??[]){const r=(n.get(e)??0)+1;r>(n.get(t.target)??0)&&n.set(t.target,r),o.set(t.target,o.get(t.target)-1),0===o.get(t.target)&&i.push(t.target)}}const a=[...e].filter(e=>null!==g[e.id].start).sort((e,t)=>{const r=n.get(e.id)??0,o=n.get(t.id)??0;return r!==o?r-o:g[e.id].start-g[t.id].start}),s=e.filter(e=>null===g[e.id].start);for(const e of[...a,...s]){const t=g[e.id];let n=-1;for(let e=0;p.length>e;e++){const r=p[e].occupants[p[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.end){n=e;break}}-1===n&&(p.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=p.length-1),p[n].occupants.push({id:e.id,end:t?.end??-1/0}),p[n].peak.topPeak=Math.max(p[n].peak.topPeak,d[e.id]),p[n].peak.botPeak=Math.max(p[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{p.push({occupants:[{id:e.id,end:g[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,b=null,v=null,x=null;const k=()=>{m=Tc(y,t),v=_c(y,t)},w=()=>{b=Tc(y,t),x=_c(y,t)};"crossing-min"===c?(k(),$c(p,y,t),w()):"inside-out"===c?(k(),function(e,t){const n=e.length;if(1>=n)return;const r=e=>e.peak.topPeak+e.peak.botPeak,o=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=o[0].idx;let s=a-1,l=a+1;for(let e=1;o.length>e;e++)e%2==1&&n>l||0>s?i[l++]=o[e].idx:i[s--]=o[e].idx;const c=i.map(t=>e[t]),u=new Map;i.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(p,y),w()):"crossing-min+inside-out"===c&&(k(),$c(p,y,t),function(e,t,n){const r=e.length;if(1>=r)return;const o=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((r-1)/2);let a=Pc(t,n);for(const{slot:s}of o){const o=e.indexOf(s);if(0>o)continue;const l=i;if(o===l)continue;const c=e[o];e.splice(o,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>o){for(let e=o+1;l>=e;e++)u.set(e,e-1);u.set(o,l)}else{for(let e=l;o>e;e++)u.set(e,e+1);u.set(o,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Pc(t,n);if(d>a){const n=e[l];e.splice(l,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>l){for(let e=l+1;o>=e;e++)i.set(e,e-1);i.set(l,o)}else{for(let e=o;l>e;e++)i.set(e,e+1);i.set(l,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=d}}(p,y,t),w());const S=p.map(e=>{const t=new Map;for(const r of e.occupants){const e=n[r.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[r,o]of e){if(r>t)break;n=o}return n},M=[];for(let e=0;p.length-1>e;e++){const t=S[e],n=S[e+1],r=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let o=0;for(const e of r){const r=A(t,e),i=A(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}M.push(o)}const L=[];let C=a+(p[0]?.peak.topPeak??0)*s;p.length>0&&L.push(C);for(let e=1;p.length>e;e++)C+=M[e-1]*s+a,L.push(C);if(p.length>0&&(C+=p[p.length-1].peak.botPeak*s+a),C>i){const e=i/C;for(let t=0;L.length>t;t++)L[t]*=e}const E=0===p.length?0:p[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+p[p.length-1].peak.botPeak,D={};for(const t of e)D[t.id]=L[y[t.id]];return{effectiveSlotsHeight:E,centerlines:D,laneLifetime:g,slots:p,slotByNode:y,slotCenter:L,crossingsBefore:m,crossingsAfter:b,lengthBefore:v,lengthAfter:x}}var Oc=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0}=e.config,o=[];for(const e of n)o.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];o.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)o.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const i=r?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:o,labels:i}};function zc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Bc,jsx as jc,jsxs as Hc}from"react/jsx-runtime";function Fc(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Yc(e,t){return"function"==typeof e?e(t):t[e]}var Xc=Mc(function(e,t){const{nodes:n,edges:r,domain:o,axisTicks:i=[],nodeIdAccessor:a="id",sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:c="value",startTimeAccessor:u="startTime",endTimeAccessor:d="endTime",systemInTimeAccessor:h,systemOutTimeAccessor:f,xExtentAccessor:g="xExtent",edgeIdAccessor:y="id",colorBy:p,colorScheme:m,showLegend:b,legendPosition:v="right",pairing:x="temporal",packing:k="reuse",laneOrder:w="crossing-min",ribbonLane:S="both",lifetimeMode:A="half",showLaneRails:M=!1,showQualityReadout:L=!1,showLabels:C=!0,width:E=600,height:D=400,margin:N,title:I,description:T,summary:_,accessibleTable:P,responsiveWidth:R,responsiveHeight:$,loading:W,loadingContent:O,emptyContent:z,edgeOpacity:B=.35,timeFormat:j,valueFormat:H,tooltip:F,enableHover:Y=!0,onObservation:X,onClick:G,showParticles:q=!1,particleStyle:V,chartId:Q,frameProps:K={}}=e,[Z,U]=kc([]),[J,ee]=kc([]),te=wc(Z),ne=wc(J);te.current=Z,ne.current=J;const re=Sc(e=>{te.current=e,U(e)},[]),oe=Sc(e=>{ne.current=e,ee(e)},[]),ie=void 0!==r,ae=Ui(ie?r:Z),se=xc(()=>{const e=Ui(n??[]),t=J;if(0===e.length&&0===t.length)return xl([],ae,s,l);const r=new Set,o=[];for(const t of e){const e=Yc(a,t)+"";r.has(e)||(r.add(e),o.push(t))}for(const e of t){const t=Yc(a,e)+"";r.has(t)||(r.add(t),o.push(e))}const i=xl([],ae,s,l);for(const e of i)r.has(e.id)||(r.add(e.id),o.push(e));return o},[n,J,ae,a,s,l]),le=wc(null),ce=Sc((e,t)=>{const n=Yc(y,e);return null!=n?n+"":`${Yc(s,e)}-${Yc(l,e)}-${t}`},[y,s,l]),ue=Sc(e=>{if(null==e)return!1;const t=e;return null!=Yc(s,t)&&null!=Yc(l,t)},[s,l]);ls(t,{variant:"network",frameRef:le,overrides:{push(e){if(ue(e)){if(ie)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");re([...te.current,e])}else oe([...ne.current,e])},pushMany(e){const t=[],n=[];for(const r of e)ue(r)?t.push(r):n.push(r);t.length>0&&(ie?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):re([...te.current,...t])),n.length>0&&oe([...ne.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ie){const e=te.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(ce(i,o))?n.push(i):r.push(i)}r.length!==e.length&&re(r)}const r=ne.current,o=[];for(const e of r){const r=Yc(a,e)+"";t.has(r)?n.push(e):o.push(e)}return o.length!==r.length&&oe(o),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!ie){let e=!1;const o=te.current.map((o,i)=>n.has(ce(o,i))?(r.push(o),e=!0,t(o)):o);e&&re(o)}let o=!1;const i=ne.current.map(e=>{const i=Yc(a,e)+"";return n.has(i)?(r.push(e),o=!0,t(e)):e});return o&&oe(i),r},clear(){ie||re([]),oe([]),le.current?.clear()},getData:()=>ae??[],getScales:()=>null},deps:[ie,ue,ce,a,ae,re,oe]});const de=ce,he=Sc(e=>Yc(a,e)+"",[a]),{nodes:fe,edges:ge,domain:ye,rawNodeById:pe,rawEdgeById:me}=xc(()=>{const e=(se??[]).map(e=>{const t={id:he(e),__raw:e},n=g?Yc(g,e):null;if(Array.isArray(n)&&2===n.length){const e=Fc(n[0]),r=Fc(n[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(ae??[]).map((e,t)=>{const n={id:de(e,t),source:Yc(s,e)+"",target:Yc(l,e)+"",value:Number(Yc(c,e)),startTime:Fc(Yc(u,e)),endTime:Fc(Yc(d,e)),__raw:e};if(h){const t=Fc(Yc(h,e));Number.isFinite(t)&&(n.systemInTime=t)}if(f){const t=Fc(Yc(f,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Fc(o[0]),Fc(o[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:i}},[se,ae,o,he,de,g,s,l,c,u,d,h,f]),be=Sl({nodes:se,edges:ae,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:s,targetAccessor:l,colorBy:p,colorScheme:m,showLegend:!1,legendPosition:v,selection:void 0,linkedHover:void 0,onObservation:X,onClick:G,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:Q,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:N,width:E,height:D,loading:W,loadingContent:O,emptyContent:z}),ve=(b??!!p)&&!!p,xe=Sc(e=>null!=N&&("number"==typeof N||null!=N[e]),[N]),we=xc(()=>{const e={...be.margin};return ve&&("right"===v&&!xe("right")&&140>e.right?e.right=140:"bottom"===v&&!xe("bottom")&&80>e.bottom&&(e.bottom=80)),e},[be.margin,ve,v,xe]),Se=E-we.left-we.right,Ae=D-we.top-we.bottom,Me=xc(()=>Lc(fe,ge,ye),[fe,ge,ye]),Le=xc(()=>Me.length>0?null:function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half"}=n,l=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),c=function(e,t,n,r="value"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const a=[...n.values()];a.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:o);return a};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(r,"source"),n=s(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,l,o);let u={};for(const t of e)u[t.id]=Ec(t,l,c);const d=Wc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=c.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(h.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],n=l.incoming[t.id],r=new Set(e.map(e=>c.get(e.id).sourceSide)),o=new Set(n.map(e=>c.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(c.get(n.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],n=l.outgoing[t.id];if(0===e.length||0===n.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===c.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},o=(e,t)=>{const o=r(),i="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,a="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=i||0>=a)return!1;const s=Math.min(i,a),l=n.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const t of e)u[t.id]=Ec(t,l,c);const f=Wc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),g=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*r/Math.max(f.slots.length+1,1)),p=g>0?Math.max(0,(r-y*(f.slots.length+1))/g):1,m=Wc(e,t,u,l,{plotH:r,padding:y,valueScale:p,packing:i,laneOrder:a,lifetimeMode:s});return{nodeData:u,sides:c,valueScale:p,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(fe,ge,{plotH:Ae,pairing:x,packing:k,laneOrder:w,lifetimeMode:A}),[Me,fe,ge,Ae,x,k,w,A]),Ce=xc(()=>Ac().domain(ye).range([0,Se]),[ye,Se]),Ee=Sc((e,t)=>{if(p&&se){const t=pe.get(e);if(t)return St(t,p,be.colorScale)}return be.effectivePalette[t%be.effectivePalette.length]||"#475569"},[p,se,pe,be.colorScale,be.effectivePalette]),De=xc(()=>{const e=new Map;return fe.forEach((t,n)=>e.set(t.id,n)),e},[fe]),Ne=xc(()=>{if(!Le)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Le,r=[],o=[];return fe.forEach((o,i)=>{const a=t[o.id];if(!a||0===a.samples.length)return;const s=function(e,t,n,r,o){if(0===e.length)return null;const i=Nc(e,o),a=e=>t-i[e].topMass*n,s=e=>t+i[e].botMass*n;let l=`M${r(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${a(e)}`;l+=` L${r(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${s(e)}`;return l+" Z"}(a.samples,e[o.id],n,Ce,ye);if(!s)return;const l=Nc(a.samples,ye),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=e[o.id]+(c.botMass-c.topMass)*n/2,d=Ee(o.id,i),h=pe.get(o.id)??o,f=function(e,t,n,r,o){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,s=n.centerlines[e],l=Nc(i.samples,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=r(c.t),h=r(u.t),f=e=>r(Dc(e,o)),g=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),r=f(n.startTime),o=t-20,i=Math.max(d,o);if(r>i){const[n,l]=Ic(e,s,a);g.push({pathD:y(i,n,r,l),x0:o,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),r=f(n.endTime),o=t+20,i=Math.min(h,o);if(i>r){const[n,l]=Ic(e,s,a);g.push({pathD:y(r,n,i,l),x0:t,x1:o,from:1,to:0})}}}}return g}(o.id,ge,Le,Ce,ye);r.push({id:o.id,pathD:s,fill:d,stroke:d,strokeWidth:.5,...f.length>0&&{gradientStubs:f},rawDatum:h,labelX:Ce(c.t)-4,labelY:u,labelText:o.id})}),ge.forEach(r=>{const i=t[r.source]?.localAttachments.get(r.id),a=t[r.target]?.localAttachments.get(r.id);if(!i||!a)return;const s=De.get(r.source)??0,l=Ee(r.source,s),c=function(e,t,n,r,o,i,a,s){const l=o,c=e=>s?Math.max(s[0],Math.min(s[1],e)):e,u=i(c(e.time)),d=i(c(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,b,v;"top"===e.side?(p=t-g,m=p+h):(m=t+g,p=m-h),"top"===n.side?(b=r-y,v=b+f):(v=r+y,b=v-f);const x="source"===a?u+.85*(d-u):"target"===a?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:b,tBot:v,cp1X:x,cp2X:x}}(i,e[r.source],a,e[r.target],n,Ce,S,ye),{pathD:u,bezier:d}=ke(c),h=me.get(r.id)??r;o.push({id:r.id,pathD:u,fill:l,opacity:B,rawDatum:h,bezier:d})}),{bands:r,ribbons:o}},[Le,fe,ge,Ce,ye,Ee,pe,me,S,B,De]),Ie=xc(()=>({bands:Ne.bands,ribbons:Ne.ribbons,showLabels:C}),[Ne,C]),Te=xc(()=>{if(!ve||!p)return;const e=new Map;(se??[]).forEach((t,n)=>{const r=Yc(p,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:Ee(he(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},[ve,p,se,Ee,he]),_e=xc(()=>!1!==F&&Y?void 0===F||!0===F?null:Cn(F)||null:null,[F,Y]),Pe=Sc(e=>j?j(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[j]),Re=Sc(e=>H?H(e):e+"",[H]),$e=Sc(e=>{if(!e||!e.data)return null;const t=e.data;if(!zc(t))return null;const n=t.data;if(_e)return _e(n);if("band"===t.__kind){const e=t.id,n=Le?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(Le.nodeData[e]):[],r=5,o=n.length>r?n.length:null,i=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[{...n[0],mark:"min"},{...n[Math.floor(.25*r)],mark:"q25"},{...n[Math.floor(.5*r)],mark:"median"},{...n[Math.floor(.75*r)],mark:"q75"},{...n[r],mark:"max"}],i=new Set,a=[];for(const e of o)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,r);return Hc("div",{style:{minWidth:160},children:[jc("div",{style:{fontWeight:600,marginBottom:4},children:e}),i.length>0&&Hc("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[jc("thead",{children:Hc("tr",{style:{opacity:.6},children:[jc("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),jc("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=o&&jc("th",{})]})}),jc("tbody",{children:i.map((e,t)=>Hc("tr",{children:[jc("td",{style:{paddingRight:8},children:Pe(e.t)}),jc("td",{style:{textAlign:"right"},children:Re(e.total)}),null!=o&&jc("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=o&&Hc("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",i.length," of ",o," samples"]})]})}const r=n,o=Yc(s,r),i=Yc(l,r),a=Yc(c,r),h=Yc(u,r),f=Yc(d,r);return Hc("div",{style:{minWidth:160},children:[Hc("div",{style:{fontWeight:600,marginBottom:4},children:[o+""," → ",i+""]}),Hc("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&Hc(Bc,{children:[jc("span",{style:{opacity:.6},children:"value"}),jc("span",{style:{textAlign:"right"},children:Re(Number(a))})]}),null!=h&&Hc(Bc,{children:[jc("span",{style:{opacity:.6},children:"start"}),jc("span",{style:{textAlign:"right"},children:Pe(Fc(h))})]}),null!=f&&Hc(Bc,{children:[jc("span",{style:{opacity:.6},children:"end"}),jc("span",{style:{textAlign:"right"},children:Pe(Fc(f))})]})]})]})},[Le,_e,Pe,Re,s,l,c,u,d]),We=xc(()=>{if(!Le)return null;const{centerlines:e,laneLifetime:t,nodeData:n,valueScale:r,compressedPadding:o,crossingsBefore:a,crossingsAfter:s,lengthBefore:l,lengthAfter:c}=Le;let u=null,d=null;for(const e of fe){const n=t[e.id];if(!n||null===n.start||null===n.end)continue;const r=Ce(n.start),o=Ce(n.end);(null===u||u>r)&&(u=r),(null===d||o>d)&&(d=o)}const h=e=>Math.max(0,Math.min(Se,e)),f=h(u??0),g=Math.max(f,h(d??Se));return Hc("g",{children:[L&&null!==(s??null)&&Hc("text",{x:Se,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(l)," → ",Math.round(c)]}),o&&jc("text",{x:Se,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),i.map((e,t)=>{const n=Ce(Fc(e.date));return f-.5>n||n>g+.5?null:jc("line",{x1:n,y1:0,x2:n,y2:Ae,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),M&&fe.map((o,i)=>{const a=t[o.id];if(!a||null===a.start)return null;const s=n[o.id],l=s?{topPeak:s.topPeak,botPeak:s.botPeak}:{topPeak:0,botPeak:0},c=e[o.id]+(l.botPeak-l.topPeak)*r/2,u=Ce(a.start),d=Ce(a.end),h=Ee(o.id,i);return Hc("g",{children:[jc("line",{x1:u,y1:c,x2:d,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),jc("line",{x1:u,y1:c-4,x2:u,y2:c+4,stroke:h,strokeOpacity:.5}),jc("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+o.id)}),jc("line",{x1:f,y1:Ae+4,x2:g,y2:Ae+4,stroke:"#94a3b8"}),i.map((e,t)=>{const n=Fc(e.date),r=Ce(n);if(f-.5>r||r>g+.5)return null;const o=null!=e.label?e.label:j?j(new Date(n)):"";return Hc("g",{transform:`translate(${r},${Ae+4})`,children:[jc("line",{y2:6,stroke:"#94a3b8"}),jc("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:o})]},t)})]})},[Le,i,Ce,Se,Ae,M,fe,Ee,L,j]),Oe=xc(()=>(se??[]).map(e=>({id:he(e),data:e})),[se,he]),ze=xc(()=>{const e=new Map;for(const t of Ne.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ne]),Be=xc(()=>(ae??[]).map((e,t)=>{const n=de(e,t),r=Number(Yc(c,e));return{id:n,source:Yc(s,e)+"",target:Yc(l,e)+"",value:Number.isFinite(r)?r:0,bezier:ze.get(n),data:e}}),[ae,de,s,l,c,ze]),je=be.loadingEl,He=be.emptyEl;return Me.length>0?Hc("svg",{width:E,height:D,role:"img","aria-label":I??"Process Sankey validation failed",children:[jc("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Me.map((e,t)=>jc("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Cc(e)},t))]}):je||He||jc(as,{ref:le,chartType:"force",nodes:Oe,edges:Be,customNetworkLayout:Oc,layoutConfig:Ie,size:[E,D],responsiveWidth:R,responsiveHeight:$,margin:we,title:I,description:T??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:_,accessibleTable:P,enableHover:Y,tooltipContent:!1===F?()=>null:$e,backgroundGraphics:We,showParticles:q,particleStyle:V,legend:Te,legendPosition:v,onObservation:X,...G&&{customClickBehavior:e=>{if(!e||!e.data||!G)return;const t=e.data;zc(t)&&G(t.data,{x:e.x,y:e.y})}},chartId:Q,colorScheme:Array.isArray(m)?m:void 0,...K})});Xc.displayName="ProcessSankey";import{forwardRef as Gc,useMemo as qc}from"react";import{useMemo as Vc,useRef as Qc}from"react";import{jsx as Kc}from"react/jsx-runtime";var Zc=Gc(function(e,t){const{nodes:n,edges:r,layout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",margin:u,className:d,colorBy:h,colorScheme:f,selection:g,linkedHover:y,onObservation:p,onClick:m,chartId:b,annotations:v,autoPlaceAnnotations:x,frameProps:k={}}=e,{frameRef:w,resolved:S,normalizedMargin:A}=function(e){const t=Qc(null);return ls(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:pl(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:Vc(()=>function(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}(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),M=qc(()=>Ui(n??[]),[n]),L=qc(()=>Ui(r??[]),[r]),C=ul(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:E,customClickBehavior:D,activeSelectionHook:N}=fl({selection:g,linkedHover:y,fallbackFields:"string"==typeof h?[h]:[],onObservation:p,onClick:m,chartType:"NetworkCustomChart",chartId:b,colorByField:"string"==typeof h?h:void 0,mobileInteraction:C}),I=qc(()=>N?.isActive?{isActive:!0,predicate:N.predicate}:null,[N?.isActive,N?.predicate]),{width:T,height:_,enableHover:P,title:R,description:$,summary:W,accessibleTable:O}=S,z={chartType:"force",...null!=n&&{nodes:M},...null!=r&&{edges:L},customNetworkLayout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,size:[T,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:A,className:d,title:R,description:$,summary:W,accessibleTable:O,enableHover:P,...Dl({linkedHover:y,selection:g,onObservation:p,onClick:m,mobileInteraction:C,customHoverBehavior:E,customClickBehavior:D,linkedHoverInClickPredicate:!1}),layoutSelection:I,...null!=v&&{annotations:v},...null!=x&&{autoPlaceAnnotations:x},...k};return Kc(aa,{componentName:"NetworkCustomChart",width:T,height:_,children:Kc(as,{ref:w,...z})})});Zc.displayName="NetworkCustomChart";var Uc={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Jc=8;function eu(e){const t=function(e){return null==e?void 0:e+""}(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Uc},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??8,style:{...Uc},datum:e.datum,id:t,label:e.label}}export{oc as ChordDiagram,yc as CirclePack,Jc as DEFAULT_HIT_RADIUS,Il as ForceDirectedGraph,Zc as NetworkCustomChart,vc as OrbitDiagram,Xc as ProcessSankey,Jl as SankeyDiagram,as as StreamNetworkFrame,sc as TreeDiagram,hc as Treemap,Cc as formatProcessSankeyIssue,tn as glyphExtent,en as glyphPlacement,eu as networkHitTarget,il as resolveResponsiveRules,ol as responsiveRuleMatches,Vt as useCustomLayoutSelection,Vl as useForceLayout,Lc as validateProcessSankey};
2
+ import{useForceLayout as m}from"./chunk-chunk-7LHMKRKE.module.min.js";import{DEFAULT_HIT_RADIUS as n,networkHitTarget as u}from"./chunk-chunk-J3XWETBJ.module.min.js";import{ChordDiagram as o,CirclePack as k,ForceDirectedGraph as c,NetworkCustomChart as h,OrbitDiagram as i,ProcessSankey as r,SankeyDiagram as e,TreeDiagram as t,Treemap as p,formatProcessSankeyIssue as s,validateProcessSankey as d}from"./chunk-chunk-E7MIQX7D.module.min.js";import"./chunk-chunk-JCG72SGW.module.min.js";import"./chunk-chunk-BHYTYMY2.module.min.js";import{StreamNetworkFrame_default as j}from"./chunk-chunk-2UN3ANRN.module.min.js";import"./chunk-chunk-XOYX77KF.module.min.js";import"./chunk-chunk-FAKO3RGQ.module.min.js";import{useCustomLayoutSelection as l}from"./chunk-chunk-5UKL5W76.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as E,makeNodeRuleContext as f,makeRuleValueResolver as N,matchesThreshold as O,resolveStyleRules as X,ruleMatches as Z}from"./chunk-chunk-EMO5NUGE.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import"./chunk-chunk-STZFFTAN.module.min.js";import{hatchFillId as F,hatchPatternDef as J,isHatchFill as K,resolveResponsiveRules as T,resolveSvgFill as U,responsiveRuleMatches as Y}from"./chunk-chunk-ODUZEEBH.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import{glyphExtent as B,glyphPlacement as H}from"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";export{o as ChordDiagram,k as CirclePack,n as DEFAULT_HIT_RADIUS,c as ForceDirectedGraph,h as NetworkCustomChart,i as OrbitDiagram,r as ProcessSankey,e as SankeyDiagram,j as StreamNetworkFrame,t as TreeDiagram,p as Treemap,E as composeStyleRules,s as formatProcessSankeyIssue,B as glyphExtent,H as glyphPlacement,F as hatchFillId,J as hatchPatternDef,K as isHatchFill,f as makeNodeRuleContext,N as makeRuleValueResolver,O as matchesThreshold,u as networkHitTarget,T as resolveResponsiveRules,X as resolveStyleRules,U as resolveSvgFill,Y as responsiveRuleMatches,Z as ruleMatches,l as useCustomLayoutSelection,m as useForceLayout,d as validateProcessSankey};