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
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{needsDataCanvasPaint as e,paintCanvasBackground as t}from"./chunk-chunk-XOYX77KF.module.min.js";import{StalenessBadge as r,attachUpdateResultStore as n,buildNavGraph as o,composeOverlays as i,computeDecayOpacity as a,createCustomLayoutFailureDiagnostic as s,extractNetworkNavPoints as c,findHitPointInQuadtree as l,formatVal as u,getHitRadius as d,hitTestRect as h,networkGlyphRenderer as y,nextNetworkIndex as f,normalizeAngle as g,paintSceneWithBackend as p,renderCirclePulse as m,renderRectPulse as v,renderSceneWithBackend as x,resolvePosition as k,useConfigSync as b,useLayoutSelectionSync as S,useStableShallow as _,useStalenessCheck as w,warnCustomLayoutDiagnostics as A}from"./chunk-chunk-FAKO3RGQ.module.min.js";import{CustomLayoutSelectionProvider as L,wrapWithCustomLayoutSelection as E}from"./chunk-chunk-5UKL5W76.module.min.js";import{commonJsWorkerModuleUrl as P}from"./chunk-chunk-SV4XAZ3Q.module.min.js";import{buildResolveColor as D,resolveCustomLayoutPalette as N}from"./chunk-chunk-STZFFTAN.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as R,AriaLiveTooltip as M,CanvasFrameBackground as T,DEFAULT_COLORS as C,FlippingTooltip as W,FocusRing as I,NetworkAccessibleDataTable as $,SceneRevisionDiagnosticsObserver as z,ScreenReaderSummary as F,SkipToTableLink as B,TITLE_BASELINE as O,UpdateResultTracker as Y,annotationActivationProps as X,annotationLayout as j,buildHoverData as H,computeEasing as G,computeNetworkAriaLabel as V,computeRawProgress as q,createDefaultAnnotationRules as Q,createSeededFrameRandom as K,defaultTooltipStyle as Z,emitClickObservations as U,emitHoverObservations as J,filterSparseArray as ee,getDevicePixelRatio as te,isAnnotationActivationTarget as re,isInteractiveKeyboardTarget as ne,isServerEnvironment as oe,lerp as ie,networkLabelToSVG as ae,networkSceneEdgeToSVG as se,networkSceneNodeToSVG as ce,now as le,observationInputType as ue,prepareCanvas as de,renderAnnotationPass as he,renderLegendFromConfig as ye,resolveCSSColor as fe,resolveCanvasFill as ge,runSceneBuild as pe,schemeCategory10 as me,smartTooltipEntries as ve,symbolPathString as xe,symbolRadius as ke,useAnnotationActivationOptions as be,useFrame as Se,useFrameCanvasHost as _e,useSceneRevisionDiagnostics as we}from"./chunk-chunk-ODUZEEBH.module.min.js";import{getMinMax as Ae}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as Le}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as Ee}from"./chunk-chunk-KTWEBFMX.module.min.js";import{renderLoadingState as Pe,useHydration as De,useWasHydratingFromSSR as Ne}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{useRef as Re,useState as Me,useEffect as Te,useMemo as Ce,useCallback as We,useImperativeHandle as Ie,forwardRef as $e,memo as ze}from"react";var Fe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Be={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Oe=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const r=this._freeIndices.pop();if(void 0===r)return null;const n=this.particles[r];return n.active=!0,n.t=0,n.offset=t()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,r,n){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=r[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(n?n[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?Ye(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 r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].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 r=0;e>r;r++)t.length>r?this.particles[r]=t[r]:(this.particles[r]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(r));this.capacity=e}};function Ye(e,t,r,n){if(e.circular&&e.segments)return void function(e,t,r,n,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),c=a-s,[l,u,d,h]=e[s];Xe(l,u,d,h,c,o);const y=h.x-l.x,f=h.y-l.y,g=Math.sqrt(y*y+f*f);if(g>.001){const e=y/g;o.x+=-f/g*r*n*2,o.y+=e*r*n*2}}(e.segments,t,r,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[o,i,a,s]=e.points;Xe(o,i,a,s,t,n);const c=s.x-o.x,l=s.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;n.x+=-l/u*r*e.halfWidth*2,n.y+=t*r*e.halfWidth*2}}function Xe(e,t,r,n,o,i){const a=1-o,s=a*a,c=s*a,l=o*o,u=l*o;i.x=c*e.x+3*s*o*t.x+3*a*l*r.x+u*n.x,i.y=c*e.y+3*s*o*t.y+3*a*l*r.y+u*n.y}function je(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function He(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,r){var o=[].concat(r).concat(e);t?t(o):n.push(o)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var f=i[t];y.length>f;++f){var g=y[f];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,c.push(g),l.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>a[g]||s[t].push(a[g])}i[t]=f}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(f=c.length-1;f>=0;--f){var x=c[f];if(o[x]=!1,p.push(x),m.push(s[x]),v+=s[x].length,a[x]=d.length,x===t){c.length=f;break}}d.push(p);var k=Array(v);for(f=0;m.length>f;f++)for(var b=0;m[f].length>b;b++)k[--v]=m[f][b];h.push(k)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var f=h[c];if(0!==f.length){f.sort(function(e,t){return e-t}),l=[f[0]];for(var g=1;f.length>g;g++)f[g]!==f[g-1]&&l.push(f[g]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.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],r=a);var c=o[r];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var f=0;s.length>f;f++)for(var g=0;s[f].length>g;g++){var p=s[f][g];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return t?void 0:n}function Ge(e){return e.y0-e.y1>0?"up":"down"}function Ve(e,t){return t(e.source)==t(e.target)}function qe(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function Qe(e){return e.target.x0-e.source.x1}function Ke(e,t){var r=Ue(e),n=Qe(t)/Math.tan(r);return"up"==Ge(e)?e.y1-n:e.y1+n}function Ze(e,t){var r=Ue(e),n=Qe(t)/Math.tan(r);return"up"==Ge(e)?e.y1+n:e.y1-n}function Ue(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Je(e,t){return t(e)}function et(e){return rt(e.source)}function tt(e){return rt(e.target)}function rt(e){return(e.y0+e.y1)/2}function nt(e){return e.virtual?0:e.value}function ot(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!Ve(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!Ve(e,t)?n+1:n}),r+n}function it(e){return e.target.depth}function at(e,t){return e.sourceLinks.length?e.depth:t-1}function st(e,t){return e.y0-t.y0}function ct(e,t){return t.y0-e.y0}function lt(e,t){return e.y1-t.y1}function ut(e,t){return t.y1-e.y1}function dt(e,t){return yt(e.source,t.source)||e.index-t.index}function ht(e,t){return yt(e.target,t.target)||e.index-t.index}function yt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ft(e,t){return gt(e)==gt(t)?"bottom"==e.circularLinkType?ct(e,t):st(e,t):gt(t)-gt(e)}function gt(e){return e.target.column-e.source.column}function pt(e,t){return mt(e)==mt(t)}function mt(e){return e.y0-e.y1>0?"up":"down"}import{min as vt}from"d3-array";function xt(e,t,r,n,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=vt(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),kt(i.links.filter(function(e){return"top"==e.circularLinkType}),t,r),kt(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,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,Ve(e,t)&&qe(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+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,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?ct:st);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),a=e.target.column,(l=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?ut:lt),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*r+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,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),i}function kt(e,t,r){e.sort(ft);var n=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(Ve(e,t)&&qe(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&bt(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function bt(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as St,max as _t,sum as wt,mean as At,group as Lt,groups as Et}from"d3-array";function Pt(e){return function(){return e}}function Dt(e){return e.index}function Nt(e){return e.nodes}function Rt(e){return e.links}function Mt(e,t,r){var n=Et(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.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 r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=rt(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=rt(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.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)?r.idx-n.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ot(t,r)-ot(e,r):"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==n.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==ot(t,r)?(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 Tt(e,t,r,n,o,i){var a=Et(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,c=i;c>0;--c)l(s*=.99,r),u();function l(t,r){var n=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&&ot(o,r)>0){var c=At(o.sourceLinks,tt),l=At(o.targetLinks,et),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-rt(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==n-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=At(o.sourceLinks,tt),y=At(o.targetLinks,et),f=((h&&y?(h+y)/2:h||y)-rt(o))*t;o.y0+=f,o.y1+=f}})})}function u(){a.forEach(function(r){var i,a,s,c=e.y0,l=r.length;for(r.sort(t||yt),s=0;l>s;++s)(a=c-(i=r[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-e.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=r[s]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function Ct(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ht),e.targetLinks.sort(dt)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=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=r+e.width/2,r+=e.width)})})}function Wt(){var e=0,t=0,r=1,n=1,o=24,i=8,a=null,s=Dt,c=at,l=void 0,u=32,d=2,h=Nt,y=Rt;function f(){var f={nodes:h.apply(null,arguments),links:y.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=r,h.y1=n,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return Lt(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=je(r,n)),"object"!=typeof o&&(o=e.target=je(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=He(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(h,l),function(e,t){var r=0,n=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:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){Je(e,t)!=Je(o.source,t)&&Je(e,t)!=Je(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),Ve(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(wt(e.sourceLinks,nt),wt(e.targetLinks,nt)),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,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-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(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.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?r(e,i):e.column})}(h,l,c);var y=i;if(null!==a){var f=Et(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=_t(f,function(e){return e.length});g>1&&(y=Math.max(1,(n-t)*a/(g-1)))}(function(e,t,r){var n=Et(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=St(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/wt(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=_t(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/i),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(h,y,o),Mt(h,l,s),Tt(h,l,s,y,y,u),Ct(h),xt(h,s,d,10,8),Mt(h,l,s),Tt(h,l,s,y,y,u),Ct(h),xt(h,s,d,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return Je(r.source,t)==Je(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!pt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=Ke(t,e);return e.y1-r}if(t.target.column>e.target.column)return Ke(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;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return Je(r.target,t)==Je(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!pt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=Ze(t,e);return e.y0-r}if(t.source.column>e.source.column)return Ze(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;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,r=e.links,n=!1,o=!1;if(r.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){let n=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=St(t,function(e){return e.y0}),a=_t(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1)}),r.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=n(e.y0)-e.y0;e.y0=n(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(h),xt(h,s,d,10,8)}(f),f}return f.update=function(e){return Ct(e),xt(e,s,d,10,8),e},f.nodeWidth=function(e){return arguments.length?(o=+e,f):o},f.nodePadding=function(e){return arguments.length?(i=+e,f):i},f.nodePaddingRatio=function(e){return arguments.length?(a=+e,f):a},f.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Pt(e),f):h},f.links=function(e){return arguments.length?(y="function"==typeof e?e:Pt(e),f):y},f.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Pt(e),f):s},f.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Pt(e),f):c},f.nodeSort=function(e){return arguments.length?(l=e,f):l},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.circularLinkGap=function(e){return arguments.length?(d=+e,f):d},f.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],r=+o[1][0],n=+o[1][1],f):[[e,t],[r,n]]},f.size=function(o){return arguments.length?(e=t=0,r=+o[0],n=+o[1],f):[r-e,n-t]},f}import{interpolateNumber as It}from"d3-interpolate";import{line as $t,curveLinearClosed as zt}from"d3-shape";function Ft(e){const{sx:t,sTop:r,sBot:n,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:c}=e,l=(r+n)/2,u=(i+a)/2;return{pathD:[`M${t},${r}`,`C${s},${r} ${c},${i} ${o},${i}`,`L${o},${a}`,`C${c},${a} ${s},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:s,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(n-r)/2}}}var Bt=e=>{let t,r,n,o,i,a,s,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=It(i,a),c=s(.5),l=s(.5),`M${t},${i}C${t},${c} ${r},${l} ${r},${a}L${n},${a}C${n},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,d=It(e.source.x1,e.target.x0),{pathD:h}=Ft({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 Ot(e){const t=e.sankeyWidth/2,r=(e._circularWidth??e.sankeyWidth)/2,n=e.circularPathData;if(!n)return null;if("down"===e.direction)return null;if(e._circularStub){const r=n.sourceX,o=n.sourceY,i=n.targetX,a=n.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*(n.rightFullExtent-r))),c=Math.max(15,Math.min(40,.33*(i-n.leftFullExtent)));return`M${r},${o-t}L${r+s},${o-t}L${r+s},${o+t}L${r},${o+t}ZM${i},${a-t}L${i-c},${a-t}L${i-c},${a+t}L${i},${a+t}Z`}const o=n.sourceX,i=n.sourceY,a=n.targetX,s=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(r,15));return`M${o},${i-d*t}L${c},${i-d*t}L${c+r},${i-d*t+d*h}L${c+r},${u+d*r-d*h}L${c+r-h},${u+d*r}L${l-r+h},${u+d*r}L${l-r},${u+d*r-d*h}L${l-r},${s-d*t+d*h}L${l-r+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${l+r},${s+d*t}L${l+r},${u-d*r}L${c-r},${u-d*r}L${c-r},${i+d*t}L${o},${i+d*t}Z`}var Yt=new Set,Xt=new WeakMap;function jt(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=Xt.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,Xt.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;Yt.has(e)||(Yt.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}var Ht={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(it))-1:0},justify:at};function Gt(e){return"string"==typeof e?e:e.id}var Vt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o="vertical"===r.orientation?"down":"right",i=r.nodeAlign||"justify",a=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const h=Wt().extent(d).links(u).nodes(l).nodeAlign(Ht[i]||at).nodeId(e=>e.id).nodeWidth(a).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of l)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(n._circularWidth??n.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,s=n[0],c=n[1];if(i>0&&a>0&&(0>e||0>r||t>s||o>c)){const t=Math.min(s/i,c/a),n=-e*t+(s-i*t)/2,o=-r*t+(c-a*t)/2;for(const e of l)e.x0=e.x0*t+n,e.x1=e.x1*t+n,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 r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of l){const t=y.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 f=new Map;for(const e of t)f.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=Gt(e.source),r=Gt(e.target),n=f.get(e._edgeKey?e._edgeKey:`${t}\0${r}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=e.width??0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=o;const i=y.get(t),a=y.get(r);i&&(n.source=i),a&&(n.target=a)}}},buildScene(e,t,r,n){const o="vertical"===r.orientation?"down":"right",i=r.nodeStyle,a=r.edgeStyle,s=r.edgeOpacity??.5,c=r.edgeColorBy||"source",l=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:me,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],y=[],f=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=i?i(jt(t,"nodeStyle")):{},a={fill:n.fill||u.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};f.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:r,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:a,datum:t,id:t.id,label:t.id})}const g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of g){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?f.get(n.id)||u.get(n.id)||o:f.get(t.id)||u.get(t.id)||o;const i=a?a(jt(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+n},${t.sourceY-r}L${t.sourceX+n},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-a},${t.targetY-r}L${t.targetX-a},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Ot(e):Bt(e),l)&&h.push({type:"bezier",pathD:l,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!==r.showLabels){const t=(p=r.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=t?t(r):r.id;if(!a)continue;let s,c,l;"down"===o?(s=r.y0+(r.y1-r.y0)/2,c=r.x1+14,l="start"):(n[0]/2>r.x0+e/2?(s=r.x0-6,l="end"):(s=r.x1+6,l="start"),c=r.y0+i/2),y.push({x:s,y:c,text:a+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:h,labels:y}}};import{forceSimulation as qt,forceCenter as Qt,forceX as Kt,forceY as Zt,forceLink as Ut,forceManyBody as Jt,forceCollide as er}from"d3-force";import{scaleLinear as tr}from"d3-scale";var rr={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o=r.forceStrength??.1,i=n[0]/2,a=n[1]/2,s=r.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),r=s?.get(t.id);e?c++:r?(t.x=r.x,t.y=r.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of l){const n=nr(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=or(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=or(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=i+n*Math.cos(r),e.y=a+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=i+e*Math.cos(o),n.y=a+e*Math.sin(o)}}}const d=r.__skipForceSimulation||0===r.iterations?0:u?40:r.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=ir(r.nodeSize,r.nodeSizeRange,e),y=e=>h(e);if(d>0){const n=new Map,s=new Map;for(const t of e)n.set(t.id,0),s.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,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 c=Ut().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?s.get(e.source):e.source,r="string"==typeof e.target?s.get(e.target):e.target,n=(t?y(t):0)+(r?y(r):0)+12;return Math.max(40,n)}).id(e=>e.id),l=qt();if(void 0===r.random&&void 0===r.seed||l.randomSource(r.random??K(r.seed)),l.force("charge",Jt().strength(e=>{const t=n.get(e.id)??0;return-15*y(e)*Math.sqrt(t+1)})).force("collide",er(e=>y(e)+3).strength(.9).iterations(2)).force("center",Qt(i,a).strength(.8)).force("x",Kt(i).strength(.06)).force("y",Zt(a).strength(.06)),l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));c.links(e),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;d>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=f.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=f.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.edgeStyle,a=ir(r.nodeSize,r.nodeSizeRange,e),s=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:me,c=new Map;e.forEach((e,t)=>{c.set(e.id,s[t%s.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(jt(t,"nodeSize")),n=o?o(jt(t,"nodeStyle")):{},i={fill:n.fill||c.get(t.id)||r.themeSemantic?.primary||"#007bff",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),n="object"==typeof e.target?e.target:h.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=i?i(jt(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==r.showLabels){const t=(y=r.nodeLabel)?"function"==typeof y?y:e=>e[y]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=a(jt(r,"nodeSize"));d.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var y;return{sceneNodes:l,sceneEdges:u,labels:d}}};function nr(e,t,r){const n=[];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=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function or(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ir(e,t,r){if(r.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],o=[];for(const t of r){const r=t.data?.[e];"number"==typeof r&&o.push(r)}if(0===o.length)return()=>n[0];const[i,a]=Ae(o);if(i===a)return()=>(n[0]+n[1])/2;const s=tr().domain([i,a]).range(n).clamp(!0);return t=>{const r=t.data?.[e];return null==r||"number"!=typeof r?n[0]:s(r)}}import{chord as ar,ribbon as sr}from"d3-chord";import{arc as cr}from"d3-shape";var lr=me,ur={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,s=Math.min(n[0],n[1])/2,c=s-i,l=n[0]/2,u=n[1]/2,d=(h=r.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const f=e.length,g=Array.from({length:f},()=>Array.from({length:f},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=y.get("string"==typeof e.source?e.source:e.source.id),n=y.get(t);if(void 0===r||void 0===n)continue;const o=d(e);g[r][n]=o}const p=ar().padAngle(o);a&&p.sortGroups(a);const m=p(g),v=m.groups,x=cr().innerRadius(c).outerRadius(s);for(const t of v){const r=e[t.index],n=x.centroid({innerRadius:c,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});r.x=n[0]+l,r.y=n[1]+u,r.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=k.get("string"==typeof e.source?e.source:e.source.id),n=k.get(t);r&&(e.source=r),n&&(e.target=n)}const b=new Map;for(const e of t)b.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 r=e[t.source.index].id,n=e[t.target.index].id,o=b.get(`${r}\0${n}`)||b.get(`${n}\0${r}`);o&&(o.__chordData=t)}},buildScene(e,t,r,n){const{groupWidth:o=20,edgeOpacity:i=.5}=r,a=Math.min(n[0],n[1])/2,s=a-o,c=n[0]/2,l=n[1]/2,u=r.nodeStyle,d=r.edgeStyle,h=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:lr,f=new Map;e.forEach((e,t)=>{f.set(e.id,y[t%y.length])});const g=sr().radius(s),p=[],m=[],v=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.__arcData;if(!n)continue;let o;o=u?u(jt(r,"nodeStyle")).fill||f.get(r.id)||y[t%y.length]:f.get(r.id)||y[t%y.length];const i=u?u(jt(r,"nodeStyle")):{};p.push({type:"arc",cx:c,cy:l,innerR:s,outerR:a,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=g(t);if(!n)continue;const o=dr(n,c,l);let a=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";if(d)a=d(jt(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===h&&r?a=f.get(r.id)||a:t&&(a=f.get(t.id)||a)}const s=d?d(jt(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!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,n=a+12;for(const r of e){const e=r.__arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;v.push({x:c+Math.cos(a)*n,y:l+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}};function dr(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}import{hierarchy as hr,tree as yr,cluster as fr,treemap as gr,pack as pr,partition as mr,treemapBinary as vr}from"d3-hierarchy";var xr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function kr(e){const[t,r,n]=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*r+.114*n>150?"#222":"#fff"}function br(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function Sr(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 _r(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:xr}function wr(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 Ar(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}var Lr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;if(!o)return;const i=r.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),s=r.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,l=hr(o,a);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(i){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=yr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=fr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"treemap":!function(e,t,r,n){const o=t.padding??4,i=t.paddingTop??0,a=gr().size([r,n]).tile(vr).padding(o);i>0&&a.paddingTop(i),a(e)}(l,r,u,d);break;case"circlepack":!function(e,t,r,n){const o=t.padding??4;pr().size([r,n]).padding(o)(e)}(l,r,u,d);break;case"partition":!function(e,t,r,n){mr().size([r,n]).padding(t.padding??1)(e)}(l,r,u,d)}const h=l.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;h.length>t;t++){const n=h[t],o={id:br(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?Er(o,n,r):"treemap"===i||"partition"===i?Pr(o,n):"circlepack"===i&&Dr(o,n),o.__hierarchyNode=n,e.push(o),y.set(n,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const r=y.get(e.parent),n=y.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){const a=[],s=[],c=[],l=r.treeOrientation||"vertical",u="radial"===l,d=n[0]/2,h=n[1]/2,y="number"==typeof(f=r.nodeSize)?f:5;var f;for(const t of e){let e=t.x,n=t.y;u&&(e+=d,n+=h);const i=o(jt(t,"nodeStyle"));let s=i.fill||wr(r);if(r.colorByDepth&&void 0!==t.depth){const e=_r(r);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:n,r:y,style:{fill:s,stroke:i.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const g=r.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,a=t.y,c=n.x,y=n.y;u&&(o+=d,a+=h,c+=d,y+=h);const f=Ar(o,a,c,y,l),p=i(jt(e,"edgeStyle"));s.push({type:"curved",pathD:f,style:{fill:"none",stroke:p.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??g},datum:e})}if(!1!==r.showLabels){const t=Sr(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===l?(r.data?.children&&0!==r.data.children.length?(n=a-y-6,i="end"):(n=a+y+6,i="start"),o=s):(n=a,o=s+y+14,i="middle");c.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:c}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=n(jt(r,"nodeStyle"));let s=a.fill||wr(t);if(t.colorByDepth&&void 0!==r.depth){const e=_r(t);s=e[r.depth%e.length]}o.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=Sr(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const l=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=r?r(s):s.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=n(jt(s,"nodeStyle")).fill||wr(t);if(t.colorByDepth&&void 0!==s.depth){const e=_r(t);d=e[s.depth%e.length]}const h="string"==typeof d?kr(d):t.themeSemantic?.text??"#000";i.push(l?{x:s.x0+e/2,y:s.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,r,0,o);case"circlepack":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.__radius??5;if(0>=e)continue;const i=n(jt(r,"nodeStyle"));let a=i.fill||wr(t);if(t.colorByDepth&&void 0!==r.depth){const e=_r(t);a=e[r.depth%e.length]}o.push({type:"circle",cx:r.x,cy:r.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=Sr(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=r?r(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let c=n(jt(o,"nodeStyle")).fill||wr(t);if(t.colorByDepth&&void 0!==o.depth){const e=_r(t);c=e[o.depth%e.length]}if(s){const r="string"==typeof c?kr(c):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:r})}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,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Er(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(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 Pr(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 Dr(e,t){const r=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}import{pie as Nr}from"d3-shape";function Rr(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Mr={sankey:Vt,force:rr,chord:ur,tree:Lr,cluster:Lr,treemap:Lr,circlepack:Lr,partition:Lr,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(r.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),c=r.orbitSize??2.95,l=r.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=Rr(r);h.metaMap.clear(),n.length=0,o.length=0;const y=new Map;function f(e){const t=y.get(e)??0;return y.set(e,t+1),0===t?e:`${e}__${t}`}const g=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=f(a(e));n.push({id:v,x:g,y:p,x0:g,x1:g,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,c,l,y,g,p){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,k=0,b=0;for(;v>k;)k+=s[Math.min(b,s.length-1)],b++,x++;let S=0;for(let v=0;x>v;v++){const k=s[Math.min(v,s.length-1)],b=m.slice(S,S+k);if(!b.length)break;const _=(v+1)/x,w={id:r,depth:g,data:t,parentId:r},A=p?y/u(w)*_:y*_,L=Nr().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(b),E=d(w);for(let t=0;b.length>t;t++){const i=(L[t].startAngle+L[t].endAngle)/2,s=b[t],u=f(a(s)),d=c+A*Math.sin(i),y=l+A*Math.cos(i)*E;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:g,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:g,parentId:r,eccentricity:E}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(s,u,d,y,A,g+1,!0)}S+=k}}(e,v,g,p,m,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],c=[],l=[];if(!1!==r.orbitShowRings){const t=Rr(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{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:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(l),y2:t+r*Math.cos(l)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(jt(t,"nodeSize")),n=o?o(jt(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:n.fill||r.themeSemantic?.primary||"#6366f1",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.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),r="object"==typeof e.target?e.target:u.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=a(jt(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t?r.data?.[t]??r.id:r.id;l.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:c,labels:l}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){const r=Rr(t),n=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())-r.startTime)/1e3,a=n*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=s.get(e.parentId);if(!n)continue;const c=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(c),t.y=n.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,r),!0)}};function Tr(e){return Mr[e]}import{quadtree as Cr}from"d3-quadtree";function Wr(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 Ir(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(!$r(e))return!1;return!0}return $r(t.points)}function $r(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 zr}from"d3-interpolate";var Fr="rgba(34, 197, 94, 0.7)",Br=2e3,Or=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yr=["scene-style","data-paint","accessibility","evidence"],Xr=(e,t)=>({retainedData:e,invalidations:t}),jr=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Hr=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Vr=["scene-style","data-paint","accessibility","evidence"],qr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Qr=[],Kr={chartType:Xr("rebuild",jr),nodeIDAccessor:Xr("rebuild",jr),sourceAccessor:Xr("rebuild",jr),targetAccessor:Xr("rebuild",jr),valueAccessor:Xr("rebuild",jr),edgeIdAccessor:Xr("rebuild",jr),childrenAccessor:Xr("rebuild",jr),hierarchySum:Xr("rebuild",jr),orientation:Xr("preserve",Hr),nodeAlign:Xr("preserve",Hr),nodePaddingRatio:Xr("preserve",Hr),nodeWidth:Xr("preserve",Hr),edgeSort:Xr("preserve",Hr),iterations:Xr("preserve",Hr),forceStrength:Xr("preserve",Hr),padAngle:Xr("preserve",Hr),groupWidth:Xr("preserve",Hr),sortGroups:Xr("preserve",Hr),treeOrientation:Xr("preserve",Hr),edgeType:Xr("preserve",Hr),padding:Xr("preserve",Hr),paddingTop:Xr("preserve",Hr),orbitMode:Xr("preserve",Hr),orbitSize:Xr("preserve",Hr),orbitSpeed:Xr("preserve",Hr),orbitRevolution:Xr("preserve",Hr),orbitRevolutionStyle:Xr("preserve",Hr),orbitEccentricity:Xr("preserve",Hr),orbitShowRings:Xr("preserve",Hr),orbitAnimated:Xr("preserve",Hr),customNetworkLayout:Xr("preserve",Hr),layoutConfig:Xr("preserve",Hr),nodeSize:Xr("preserve",Gr),nodeSizeRange:Xr("preserve",Gr),colorByDepth:Xr("preserve",Gr),nodeLabel:Xr("preserve",qr),showLabels:Xr("preserve",qr),labelMode:Xr("preserve",qr),nodeStyle:Xr("preserve",Vr),edgeStyle:Xr("preserve",Vr),colorBy:Xr("preserve",Vr),colorScheme:Xr("preserve",Vr),themeCategorical:Xr("preserve",Vr),themeSemantic:Xr("preserve",Vr),edgeColorBy:Xr("preserve",Vr),edgeOpacity:Xr("preserve",Vr),showParticles:Xr("preserve",Vr),particleStyle:Xr("preserve",Vr),decay:Xr("preserve",Vr),pulse:Xr("preserve",Vr),thresholds:Xr("preserve",Vr),staleness:Xr("preserve",Vr),layoutSelection:Xr("preserve",Vr),clock:Xr("preserve",Qr),random:Xr("preserve",Qr),seed:Xr("preserve",Qr),tensionConfig:Xr("preserve",Qr),transition:Xr("preserve",Qr),introAnimation:Xr("preserve",Qr),onLayoutError:Xr("preserve",Qr),__skipForceSimulation:Xr("preserve",Qr),__hierarchyRoot:Xr("preserve",Qr),__orbitState:Xr("preserve",Qr),__previousPositions:Xr("preserve",Qr)},Zr=Xr("preserve",Hr),Ur=class{constructor(){this.tracker=new Y}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Or)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Yr):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const r=new Set;for(const n of e){const e=Kr[n]??Zr;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)r.add(t)}return{retainedData:t,invalidations:r}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Jr=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Ur,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Fe,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Oe(2e3))}currentTime(){return this.config.clock?.()??le()}updateConfig(e){const t=this.config,r={...t,...e};t.__orbitState&&(r.__orbitState=t.__orbitState),t.__hierarchyRoot&&(r.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(r.layoutSelection=t.layoutSelection);const n=[...new Set([...Object.keys(t),...Object.keys(r)])].filter(e=>t[e]!==r[e]);this.config=r,this.tensionConfig={...Fe,...r.tensionConfig},!r.showParticles||"sankey"!==r.chartType&&!r.customNetworkLayout||this.particlePool||(this.particlePool=new Oe(2e3)),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,r,n){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...Wr(e),data:t})}for(let e=0;t.length>e;e++){const r=t[e],n=l(r)+"",o=u(r)+"",i=d(r),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(n)||this.nodes.set(n,{...Wr(n),data:r}),this.nodes.has(o)||this.nodes.set(o,{...Wr(o),data:r});const c=`${n}\0${o}\0${e}`,h={source:n,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:c};r&&"object"==typeof r&&Ir(r.bezier)&&(h.bezier=r.bezier),this.edges.set(c,h)}n?.deferLayout||this.runLayout(r),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,r,n){return this.ingestBounded(e,t,r,n),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,r]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=r.x,e.y=r.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:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Wr(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Wr(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=Tr(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values());const n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of r)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,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(r,n,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of r)this.nodes.set(e.id,e);for(let e=0;n.length>e;e++){const t=n[e],r=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=r,this.edges.set(r,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const r=e.get(t.id);r&&(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,r=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=r.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&&r.length>0&&a>0){const t=e[0]/2,r=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=r,e._prevY1=r;for(const e of this.edges.values())e._prevY0=r,e._prevY1=r,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:r,restyleEdge:n,baseStyles:o,selection:i}){const a=!(!r&&!n);if(r)for(const t of e){const e=o.get(t)??t.style,n=r(t,i);t.style=n?{...e,...n}:e}if(n)for(const e of t){const t=o.get(e)??e.style,r=n(e,i);e.style=r?{...t,...r}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:r,nodes:n,edges:o,previousResult:i,revision:a}){const c=N(e.colorScheme,e.themeCategorical,me),l={nodes:n,edges:o,dimensions:{width:r[0],height:r[1],plot:{x:0,y:0,width:r[0],height:r[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...c]},resolveColor:D(c,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const r=null!==i,n=s("network",t,r,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:n,preservedLastGoodScene:r}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const r=t.result;return this.sceneNodes=r.sceneNodes??[],this.sceneEdges=r.sceneEdges??[],this.labels=r.labels??[],this.customLayoutOverlays=r.overlays??null,this.customLayoutHtmlMarks=r.htmlMarks??[],this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=r.restyle,this._customRestyleEdge=r.restyleEdge,this.hasCustomRestyle=!(!r.restyle&&!r.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const r=new WeakMap;for(const t of e)r.set(t,t.style);for(const e of t)r.set(e,e.style);return r}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void A({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=Tr(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const r=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,n=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,r=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>r&&(r=e.r));if(this._maxNodeRadius=r,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const n=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(n[o++]=e);this._nodeQuadtree=Cr().x(e=>e.cx).y(e=>e.cy).addAll(n)}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=Tr(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Tr(this.config.chartType);if(!r?.tick)return!1;const n=r.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=r.hierarchical?Array.from(this.edges.values()):this.edgesArray;return r.tick(n,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=q(e,this.transition),r=G(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ie(e._prevX0,e._targetX0,r),e.x1=ie(e._prevX1,e._targetX1,r),e.y0=ie(e._prevY0,e._targetY0,r),e.y1=ie(e._prevY1,e._targetY1,r));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=ie(e._prevY0,e._targetY0,r),e.y1=ie(e._prevY1,e._targetY1,r),e.sankeyWidth=ie(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const r=e?.get(t.id);r&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.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 r=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(r){e._prevY0=r.y0,e._prevY1=r.y1,e._prevSankeyWidth=r.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,r=.5){const n="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!n||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(!r)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.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},r])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,r,n=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=r.x0,s=zr(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(n)},{x:e.y1,y:s(1-n)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=r.x0,s=zr(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(n),y:e.y0},{x:s(1-n),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,n,o,r))}(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 r=t.duration??500,n=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 c=i-s;r>c&&(t._pulseIntensity=1-c/r,t._pulseColor=n,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 c=e.edgeTimestamps.get(`${a}\0${s}`);if(!c)continue;const l=i-c;r>l&&(t._pulseIntensity=1-l/r,t._pulseColor=n)}}({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 r=e.nodeTimestamps.size;if(1>=r)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 r=0;e.cache.sortedNodes.length>r;r++)t.set(e.cache.sortedNodes[r][0],r);e.cache.ageMap=t}const n=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=n.get(e);if(void 0===i)continue;const s=a(t,i,r);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===Fr&&(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>=Br)return;const r=1-t/Br;for(const t of e.sceneNodes){const n=t.id;n&&e.addedNodes.has(n)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,r),t._pulseColor=Fr,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,r=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&Br>r-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const r=t.warningColor??"#f59e0b",n=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 c=t.metric(s);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=r):l=n,l&&(i.style={...i.style,fill:l},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const r of e){const e=t.metric(r);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 r=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>r-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 r=this.nodes.get(e);if(!r)return this.updateResults.recordNoop("update"),null;const n=r.data?{...r.data}:{};return r.data=t(r.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),n}updateEdge(e,t,r){const n=this.config.valueAccessor,o="function"==typeof n?n:n?e=>e[n]:e=>e.value,i=[];for(const[,n]of this.edges)if(("string"==typeof n.source?n.source:n.source.id)===e&&("string"==typeof n.target?n.target:n.target.id)===t){i.push(n.data?{...n.data}:{}),n.data=r(n.data??{});const e=o(n.data);null!=e&&(n.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const r=[];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 n="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Jr.QUADTREE_THRESHOLD=500;var en=Jr;n(en);import*as tn from"react";import{Fragment as rn,jsx as nn,jsxs as on}from"react/jsx-runtime";function an(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:y="right",legendLayout:f,foregroundGraphics:g,sceneNodes:p,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:k,chartType:b,autoPlaceAnnotations:S,svgAnnotationRules:_}=e,w=be({onAnnotationActivate:v,onObservation:x,chartId:k,chartType:b}),A=tn.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,r=e.cy??e.y;if("number"!=typeof t||"number"!=typeof r)return null;const n=Ee(e.glyph,e.size);return{x:t+n.centerDx,y:r+n.centerDy,r:Math.max(1,n.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),r=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof r?null:{x:t,y:r,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,ke(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),r=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:r,...t}]:[]});return{scales:null,width:t,height:r,frameType:"network",pointNodes:e,sceneNodes:p}},[r,p,t]),L=tn.useMemo(()=>m&&S?j({annotations:m,context:A,..."object"==typeof S?S:{}}):m,[m,S,A]),E=tn.useMemo(()=>Q("network"),[]),P=L?he(L.filter(e=>"widget"!==e.type),E,_,A):null,D=!0===L?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return on(rn,{children:[D&&nn("style",{children:R},"annotation-widget-disclosure-style"),on("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[nn("title",{children:"string"==typeof s?s:"Network Chart"}),nn("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),on("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>nn("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),P,g]}),s&&"string"==typeof s?nn("text",{x:n/2,y:O,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?nn("foreignObject",{x:0,y:0,width:n,height:i.top,children:s}):null,ye({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:y,title:s,legendLayout:f,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),L?.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{const r=!0===e._annotationDeferred,n=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(!n)return null;const o=i.left+(n.cx??(null!=n.x&&null!=n.w?n.x+n.w/2:n.x??0)),a=i.top+(n.cy??(null!=n.y&&null!=n.h?n.y+n.h/2:n.y??0)),s=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,d=e.content??nn("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return nn("div",{...X(e,w),className:r?"annotation-deferred":void 0,"data-annotation-disclosure":r?"deferred":void 0,style:{position:"absolute",left:o+s-l/2,top:a+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}an.displayName="NetworkSVGOverlay";import*as sn from"react";import{jsx as cn}from"react/jsx-runtime";var ln={position:"absolute",top:0,left:0,pointerEvents:"none"};function un({marks:e,margin:t,selection:r=null,overscan:n=400}){const o=sn.useRef(null),i=function(e,t,r){const[n,o]=sn.useState(null);return sn.useLayoutEffect(()=>{const e=t.current,r=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:r,overflowY:n}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${n} ${r}`))return t;t=t.parentElement}return null}(e);if(!e||!r)return void o(null);let n=0;const i=()=>{n=0;const t=r.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===n&&(n=window.requestAnimationFrame(i))};i(),r.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(r),()=>{0!==n&&window.cancelAnimationFrame(n),r.removeEventListener("scroll",a),s.disconnect()}},[t,e,r]),sn.useMemo(()=>{if(!e||!n)return e;const{scroll:t,originX:o,originY:i}=n,a=t.left-r,s=t.right+r,c=t.top-r,l=t.bottom+r;return e.filter(e=>{const t=o+e.x,r=i+e.y;return!(a>t+e.width||t>s||c>r+e.height||r>l)})},[e,n,r])}(e,o,n);if(!e||0===e.length)return null;const a=cn("div",{className:"semiotic-network-html-marks",ref:o,style:{...ln,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>cn("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!=r?cn(L,{value:r,children:a}):a}import{jsx as dn,jsxs as hn}from"react/jsx-runtime";function yn({props:e,store:t,responsiveRef:r,size:n,margin:o,adjustedWidth:a,adjustedHeight:s,resolvedBackground:c,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:y,className:f,description:g,title:p,responsiveWidth:m,responsiveHeight:v,summary:k,background:b,renderMode:S,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:P,legendHighlightedCategory:D,legendIsolatedCategories:N,layoutSelection:R,annotations:M,onAnnotationActivate:T,annotationObservationCallback:C,onObservation:W,chartId:I,autoPlaceAnnotations:$,svgAnnotationRules:z}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),r=e?y||(Array.isArray(h)?void 0:h):void 0;if(e&&r)t.ingestHierarchy(r,[a,s]),t.buildScene([a,s]);else{const e=ee(d),r=Array.isArray(h)?ee(h):[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[a,s]),t.buildScene([a,s]))}}const B=t?.sceneNodes??[],O=t?.sceneEdges??[],Y=t?.labels??[];return hn("div",{ref:r,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:m?"100%":n[0],height:v?"100%":n[1]},children:[dn(F,{summary:k}),hn("svg",{xmlns:"http://www.w3.org/2000/svg",width:n[0],height:n[1],style:{position:"absolute",left:0,top:0},children:[c&&dn("g",{transform:`translate(${o.left},${o.top})`,children:c}),hn("g",{transform:`translate(${o.left},${o.top})`,children:[b&&dn("rect",{x:0,y:0,width:a,height:s,fill:b}),O.map((e,t)=>x({node:e,index:t,renderMode:S,fallback:()=>se(e,t)})).filter(Boolean),B.map((e,t)=>x({node:e,index:t,renderMode:S,fallback:()=>ce(e,t)})).filter(Boolean),Y.map((e,t)=>ae(e,t)).filter(Boolean)]})]}),dn(an,{width:a,height:s,totalWidth:n[0],totalHeight:n[1],margin:o,labels:Y,sceneNodes:B,title:p,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:P,legendHighlightedCategory:D,legendIsolatedCategories:N,foregroundGraphics:i(l,E(t?.customLayoutOverlays,R??null)),annotations:M,onAnnotationActivate:T,onObservation:C??W,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:$,svgAnnotationRules:z,annotationFrame:0}),dn(un,{marks:t?.customLayoutHtmlMarks,margin:o,selection:R??null})]})}function fn(e,t,r,n,o=4e4){return"sync"!==e&&("worker"===e||n*(t+r)>=o)}function gn(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function pn(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var mn=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):P("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,r=t.requestId,n=null!=r?this.pending.get(r):this.pending.values().next().value;if(n){if(null!=r?this.pending.delete(r):this.pending.clear(),n.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 n.reject(e)}n.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(pn());const r=this.nextRequestId;this.nextRequestId+=1;const n={requestId:r,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(r),t?.removeEventListener("abort",i),o(pn())},a=()=>t?.removeEventListener("abort",i);this.pending.set(r,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(n)}catch(e){this.pending.delete(r),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()}},vn=null;function xn(e,t){return gn()?t?.aborted?Promise.reject(pn()):(vn&&!vn.isDead||(vn=new mn),vn).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}import{jsx as kn,jsxs as bn}from"react/jsx-runtime";var Sn=/^(value|amount|total|count|weight|score)$/i;function _n({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?bn("div",{className:"semiotic-tooltip",style:Z,children:[bn("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&&bn("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 r=t.__hierarchyNode;if(r){const e=[];let n=r;for(;n;){const r=n.data?.name??n.data?.id??t.id;null!=r&&e.unshift(r+""),n=n.parent}e.length>1&&e.shift();const o=e.length-1;return bn("div",{className:"semiotic-tooltip",style:Z,children:[kn("div",{children:e.map((e,t)=>bn("span",{children:[t>0&&kn("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?kn("strong",{children:e}):kn("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&kn("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const n=(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=ve(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>Sn.test(e.key));return bn("div",{className:"semiotic-tooltip",style:Z,children:[kn("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>bn("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",u(e.value)]},e.key)),!s&&null!=t.value&&t.value>0&&bn("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),n>0&&bn("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",n,o!==n&&` (weighted: ${o.toLocaleString()})`]})]})}function wn(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function An(e,t){if(!t.pathD)return;e.save();const r=wn(t);if(t.style.fill&&"none"!==t.style.fill){const n=t._gradient;if(n){const r=e.createLinearGradient(n.x0,0,n.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=fe(e,i)||i;r.addColorStop(0,1===n.from?a:"transparent"),r.addColorStop(1,1===n.to?a:"transparent"),e.fillStyle=r,e.globalAlpha=o}else e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(r)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(r)),e.restore()}function Ln(e,t){e.save();const r=t.style.stroke||"#999";e.strokeStyle=fe(e,r)||r,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 En(e,t){if(!t.pathD)return;e.save();const r=wn(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(r)),e.restore()}function Pn(e,t){if(!t.pathD)return;e.save();const r=wn(t),n=t.style.stroke||"#999";e.strokeStyle=fe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(r)),e.restore()}_n.ownsChrome=!0;var Dn=new Map;function Nn(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let r=Dn.get(t);return r||(r=new Path2D(xe(e.symbolType,e.size)),Dn.size>256&&Dn.clear(),Dn.set(t,r)),r}catch{return null}}function Rn(e){const{sceneNodes:t,nodes:r,nodeColorMap:n,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&n.set(e.id,e.style.fill);const i=Array.isArray(o)?o:C,a=Array.from(r);for(let e=0;a.length>e;e++){const t=a[e];n.has(t.id)||n.set(t.id,i[e%i.length])}return a.length}function Mn(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>d(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=h(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=g(Math.atan2(o,n)),s=g(e.startAngle),c=g(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);case"symbol":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>d(ke(e.size),n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"glyph":return function(e,t,r,n=30){if(null==e.datum)return null;const o=Ee(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,c=r-a,l=Math.sqrt(s*s+c*c);return l>d(o.radius,n)?null:{type:"node",datum:e.datum,x:i,y:a,distance:l}}(e,t,r,n);default:return null}}var Tn=null,Cn=null;function Wn(){return Cn||((Tn=document.createElement("canvas")).width=1,Tn.height=1,Cn=Tn.getContext("2d")),Cn}function In(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 $n(e,t,r){switch(e.type){case"bezier":return function(e,t,r){if(!e.pathD)return null;const n=In(e),o=Wn();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt((t-s)**2+(r-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;const n=In(e),o=Wn();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);default:return null}}function zn(e){const{clientX:t,clientY:r,canvasRect:n,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:c,nodeQuadtree:u,maxNodeRadius:d,hitRadius:h=30}=e,y=t-n.left-o.left,f=r-n.top-o.top;if(0>y||y>i||0>f||f>a)return{kind:"miss-outside"};const g=function(e,t,r,n,o=30,i,a=0){let s=null,c=o,u=1/0;if(i){const e=l(i,r,n,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},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Mn(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;u>r&&(s=e,u=r)}else c>e.distance&&(s=e,c=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=$n(e,r,n);t&&c>t.distance&&(s=t,c=t.distance)}return s}(s,c,y,f,h,u,d);return g?{kind:"hit",hover:H(g.datum||{},g.x,g.y,{nodeOrEdge:g.type})}:{kind:"miss"}}import{useCallback as Fn}from"react";var Bn="StreamNetworkFrame";import{jsx as On,jsxs as Yn}from"react/jsx-runtime";var Xn={top:20,right:80,bottom:20,left:80},jn={top:40,right:40,bottom:40,left:40},Hn=new Set(["chord","force","circlepack","orbit"]),Gn=[800,600],Vn=ze($e(function(n,a){const{chartType:s,nodes:l,edges:u,data:d,initialEdges:h,nodeIDAccessor:g="id",sourceAccessor:x="source",targetAccessor:A="target",valueAccessor:L="value",edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R="horizontal",nodeAlign:O="justify",nodePaddingRatio:Y=.05,nodeWidth:X=15,iterations:j=300,forceStrength:G=.1,layoutExecution:q="auto",layoutLoadingContent:Q,onLayoutStateChange:K,padAngle:Z=.01,groupWidth:ie=20,sortGroups:ae,edgeSort:se,treeOrientation:ce="vertical",edgeType:le="curve",padding:he,paddingTop:ye,tensionConfig:me,showParticles:ve=!1,particleStyle:xe,renderMode:ke,nodeStyle:be,edgeStyle:Ae,colorBy:Ee,colorScheme:$e="category10",edgeColorBy:ze="source",edgeOpacity:Oe=.5,colorByDepth:Ye=!1,nodeSize:Xe=8,nodeSizeRange:je=[5,20],nodeLabel:He,showLabels:Ge=!0,labelMode:Ve,size:qe=Gn,responsiveWidth:Qe,responsiveHeight:Ke,margin:Ze,className:Ue,background:Je,enableHover:et=!0,tooltipContent:tt,customHoverBehavior:rt,customClickBehavior:nt,onObservation:ot,annotationObservationCallback:it,chartId:at,onTopologyChange:st,annotations:ct,onAnnotationActivate:lt,autoPlaceAnnotations:ut,svgAnnotationRules:dt,legend:ht,legendPosition:yt,legendLayout:ft,legendHoverBehavior:gt,legendClickBehavior:pt,legendHighlightedCategory:mt,legendIsolatedCategories:vt,title:xt,foregroundGraphics:kt,backgroundGraphics:bt,decay:St,pulse:_t,transition:wt,animate:At,staleness:Lt,frameScheduler:Et,clock:Pt,random:Dt,seed:Nt,paused:Rt=!1,suspendWhenHidden:Mt=!0,thresholds:Tt,accessibleTable:Ct=!0,description:Wt,summary:It,orbitMode:$t,orbitSize:zt,orbitSpeed:Ft,orbitRevolution:Bt,orbitRevolutionStyle:Ot,orbitEccentricity:Yt,orbitShowRings:Xt,orbitAnimated:jt,customNetworkLayout:Ht,onLayoutError:Gt,layoutConfig:Vt,layoutSelection:qt}=n,Qt=Hn.has(s)?jn:Xn,Kt=Re(!0),Zt=Se({sizeProp:qe,responsiveWidth:Qe,responsiveHeight:Ke,userMargin:Ze,marginDefault:Qt,title:xt,legend:ht,legendPosition:yt,foregroundGraphics:kt,backgroundGraphics:bt,animate:At,transitionProp:wt,frameScheduler:Et,clock:Pt,random:Dt,seed:Nt,paused:Rt,suspendWhenHidden:Mt,themeDirtyRef:Kt}),{reducedMotionRef:Ut,responsiveRef:Jt,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,resolvedForeground:or,resolvedBackground:ar,transition:sr,introEnabled:cr,tableId:lr,rafRef:ur,renderFnRef:dr,scheduleRender:hr,frameRuntime:yr,currentTheme:fr}=Zt,gr=De(),pr=Ne(),mr=Ce(()=>ee(l),[l]),vr=Ce(()=>Array.isArray(u)?ee(u):u,[u]),xr=Ce(()=>({...Fe,...me}),[me]),kr=Ce(()=>({...Be,...xe}),[xe]),br=Ce(()=>{return{chartType:(e={chartType:s,clock:yr.now,random:Dt,seed:Nt,nodeIDAccessor:g,sourceAccessor:x,targetAccessor:A,valueAccessor:L,edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R,nodeAlign:O,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:G,padAngle:Z,groupWidth:ie,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:he,paddingTop:ye,tensionConfig:xr,showParticles:ve,particleStyle:kr,nodeStyle:be,edgeStyle:Ae,nodeLabel:He,showLabels:Ge,labelMode:Ve,colorBy:Ee,colorScheme:$e,edgeColorBy:ze,edgeOpacity:Oe,colorByDepth:Ye,nodeSize:Xe,nodeSizeRange:je,decay:St,pulse:_t,transition:sr,introAnimation:cr,staleness:Lt,thresholds:Tt,orbitMode:$t,orbitSize:zt,orbitSpeed:Ft,orbitRevolution:Bt,orbitRevolutionStyle:Ot,orbitEccentricity:Yt,orbitShowRings:Xt,orbitAnimated:jt,customNetworkLayout:Ht,onLayoutError:Gt,layoutConfig:Vt,currentTheme:fr}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Le(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},[s,yr.now,Dt,Nt,g,x,A,L,P,D,N,R,O,Y,X,j,G,Z,ie,ae,se,ce,le,he,ye,xr,ve,kr,be,Ae,He,Ge,Ve,Ee,$e,ze,Oe,Ye,Xe,je,St,_t,sr,cr,Lt,Tt,$t,zt,Ft,Bt,Ot,Yt,Xt,jt,Ht,Gt,Vt,fr]),Sr=_(br),_r=_({chartType:(wr={chartType:s,nodeIDAccessor:g,sourceAccessor:x,targetAccessor:A,valueAccessor:L,edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R,nodeAlign:O,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:G,padAngle:Z,groupWidth:ie,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:he,paddingTop:ye,random:Dt,seed:Nt,tensionConfig:xr,customNetworkLayout:Ht,orbitMode:$t,orbitSize:zt,orbitEccentricity:Yt}).chartType,nodeIDAccessor:wr.nodeIDAccessor,sourceAccessor:wr.sourceAccessor,targetAccessor:wr.targetAccessor,valueAccessor:wr.valueAccessor,edgeIdAccessor:wr.edgeIdAccessor,childrenAccessor:wr.childrenAccessor,hierarchySum:wr.hierarchySum,orientation:wr.orientation,nodeAlign:wr.nodeAlign,nodePaddingRatio:wr.nodePaddingRatio,nodeWidth:wr.nodeWidth,iterations:wr.iterations,forceStrength:wr.forceStrength,padAngle:wr.padAngle,groupWidth:wr.groupWidth,sortGroups:wr.sortGroups,edgeSort:wr.edgeSort,treeOrientation:wr.treeOrientation,edgeType:wr.edgeType,padding:wr.padding,paddingTop:wr.paddingTop,random:wr.random,seed:wr.seed,tensionConfig:wr.tensionConfig,customNetworkLayout:wr.customNetworkLayout,orbitMode:wr.orbitMode,orbitSize:wr.orbitSize,orbitEccentricity:wr.orbitEccentricity});var wr;const Ar=Re(0),Lr=Re(0),Er=Re(!1),Pr=Re(null);Pr.current||(Pr.current=new en(Sr));const Dr=we("StreamNetworkFrame"),Nr=We((e,t,r=!1)=>pe(Dr.current,e,()=>e.buildScene(t),r),[Dr]),[Rr,Mr]=Me(null),[Tr,Cr]=Me(0),[Wr,Ir]=Me(0),[$r,zr]=Me(!1),[Fr,Br]=Me(!1),Or=Re(0),Yr=Re(null),Xr=Re(!1),jr=Re(K);jr.current=K;const Hr=Re(Sr);Hr.current=Sr;const Gr=Re(null),Vr=Re(new Map),qr=Re(0),Qr=We(e=>function(e){const{node:t,colorBy:r,colorScheme:n,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof r)return r(t)+"";if("string"==typeof r&&t.data){const e=t.data[r];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(n)?n:C;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(n)?n:C,s=r?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:Ee,colorScheme:$e,nodeColorMap:Vr.current,colorIndexRef:qr}),[Ee,$e]),Kr=(Zr=fr,Zr?.colors?.border||Zr?.colors?.secondary||Zr?.colors?.primary||"#999");var Zr;const Ur=We(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Pr.current?.nodes),[]),Jr=We(e=>function(e){const{edge:t,edgeColorBy:r,getNodeColor:n,resolveEndpoint:o,fallback:i}=e;if("function"==typeof r)return r(t);const a=o(t.source),s=o(t.target);return"target"===r&&s?n(s):a?n(a):i}({edge:e,edgeColorBy:ze,getNodeColor:Qr,resolveEndpoint:Ur,fallback:Kr}),[ze,Qr,Kr,Ur]),tn=We(e=>function(e){const{edge:t,particleStyleColor:r,particleColorBy:n,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:c}=e;if("function"==typeof r){const e=s(t.source);return e?r(t,e):c}if(!o)return i(t);const l=n,u=s(t.source),d=s(t.target);return"target"===l&&d?a(d):u?a(u):c}({edge:e,particleStyleColor:kr.color,particleColorBy:kr.colorBy,hasExplicitParticleColorBy:!!xe?.colorBy,getEdgeColor:Jr,getNodeColor:Qr,resolveEndpoint:Ur,fallback:Kr}),[xe?.colorBy,kr.color,kr.colorBy,Qr,Jr,Kr,Ur]),rn=function(e,t,r,n,o){return("sankey"===e||t)&&r||n||o}(s,!!Ht,ve,!!_t,Pr.current?.isAnimating??!1);b(Pr,Sr,Kt,hr),S(Pr,qt,Kt,hr),Te(()=>{const e=Pr.current;e&&(Nr(e,[rr,nr]),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Kt.current=!0,hr())},[fr,rr,nr,Nr,hr,$e]);const nn=We(()=>{const e=Pr.current;if(e&&(e.runLayout([rr,nr]),Nr(e,[rr,nr]),Kt.current=!0,qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Cr(e.layoutVersion),st)){const{nodes:t,edges:r}=e.getLayoutData();st(t,r)}},[rr,nr,Nr,st,$e]),on=We(e=>{if(null==e||"object"!=typeof e)return;const t=Pr.current;t&&(t.ingestEdge(e)&&nn(),hr())},[nn,hr]),sn=We(e=>{const t=Pr.current;if(!t)return;let r=!1;for(const n of e)null!=n&&"object"==typeof n&&t.ingestEdge(n)&&(r=!0);r&&nn(),hr()},[nn,hr]),cn=We(()=>{Pr.current?.clear(),Vr.current.clear(),qr.current=0,Cr(Pr.current?.layoutVersion??0),Mr(null),Gr.current=null,Kt.current=!0,hr()},[hr]),ln=We(()=>{const e=Pr.current;e&&(e.tension+=999,nn(),hr())},[nn,hr]);Ie(a,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Pr.current?.removeNode(e)??!1;if(t){const t=Gr.current?.data?"function"==typeof g?g(Gr.current.data):Gr.current.data[g]:void 0;Gr.current&&"node"===Gr.current.nodeOrEdge&&t===e&&(Gr.current=null,Mr(null)),Vr.current.delete(e),nn(),Kt.current=!0,hr()}return t},removeEdge:(e,t)=>{const r=Pr.current?.removeEdge(e,t)??!1;if(r){if(Gr.current&&"edge"===Gr.current.nodeOrEdge){const r=Gr.current.data;let n;n=void 0!==t?("object"==typeof r?.source?r.source.id:r?.source)===e&&("object"==typeof r?.target?r.target.id:r?.target)===t:!P||!r||("function"==typeof P?P:e=>e?.[P])(r)===e,n&&(Gr.current=null,Mr(null))}nn(),Kt.current=!0,hr()}return r},updateNode:(e,t)=>{const r=Pr.current?.updateNode(e,t)??null;return r&&(Kt.current=!0,hr()),r},updateEdge:(e,t,r)=>{const n=Pr.current?.updateEdge(e,t,r)??[];return n.length>0&&(nn(),Kt.current=!0,hr()),n},clear:cn,getTopology:()=>Pr.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Pr.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Pr.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Pr.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:ln,getTension:()=>Pr.current?.tension??0}),[on,sn,cn,ln,g,nn,hr,P]);const dn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(s),hn=dn?d||(Array.isArray(u)?void 0:u):void 0;Te(()=>{const e=Pr.current;if(!e)return;const t=++Or.current;if(Yr.current?.abort(),Yr.current=null,dn&&hn)e.ingestHierarchy(hn,[rr,nr]),Nr(e,[rr,nr]),Br(!1),jr.current?.("ready"),Kt.current=!0,hr();else{const r=mr,n=Array.isArray(vr)?vr:[];if(0===r.length&&0===n.length)return null==l&&null==u||0>=e.nodes.size&&0>=e.edges.size||cn(),Br(!1),void jr.current?.("ready");const o=[rr,nr],i="force"===s&&!Ht&&gn()&&!Dt&&fn(q,r.length,n.length,j);if(i&&pr&&!Xr.current&&e.sceneNodes.length>0)return Xr.current=!0,Br(!1),jr.current?.("ready"),Kt.current=!0,void hr();if(i){const i=new AbortController;Yr.current=i;const a=e._lastPositionSnapshot;e.ingestBounded(r,n,o,{deferLayout:!0});const s=e.getLayoutData(),c=function(e,t,r,n,o){const i=ir(r.nodeSize,r.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,r="string"==typeof e.target?e.target:e.target.id,n=e.data?.weight,o="number"==typeof n&&Number.isFinite(n)?n:e.value;return{source:t,target:r,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:r.iterations,forceStrength:r.forceStrength,seed:r.seed},size:n}}(s.nodes,s.edges,Hr.current,o,a);return Br(!0),jr.current?.("pending"),xn(c,i.signal).then(({positions:r})=>{t===Or.current&&(e.applyForceLayoutPositions(r,o),Nr(e,o),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Br(!1),jr.current?.("ready"),Cr(e.layoutVersion),Kt.current=!0,hr())}).catch(r=>{"AbortError"!==r.name&&t===Or.current&&(e.runLayout(o),Nr(e,o),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Br(!1),jr.current?.("error"),Cr(e.layoutVersion),Kt.current=!0,hr())}),()=>i.abort()}e.ingestBounded(r,n,o),Nr(e,o),Br(!1),jr.current?.("ready"),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Kt.current=!0,hr()}},[mr,vr,l,u,d,hn,dn,rr,nr,_r,q,j,pr,s,Ht,Dt,hr,cn,$e,Nr]),Te(()=>{h&&h.length>0&&sn(h)},[h,sn]);const{customHoverBehavior:pn,customClickBehavior:mn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:r,chartId:n}){return{customHoverBehavior:Fn((t,o)=>{e?.(t,o),J({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Bn,chartId:n,context:o})},[e,r,n]),customClickBehavior:Fn((e,o)=>{t?.(e,o),U({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Bn,chartId:n,context:o})},[t,r,n])}}({customHoverBehavior:rt,customClickBehavior:nt,onObservation:ot,chartId:at}),{hoverHandlerRef:vn,hoverLeaveRef:kn,onPointerMove:bn,onPointerLeave:Sn}=Zt,wn=()=>!Ht||(Pr.current?.hasCustomRestyle??!1);vn.current=e=>{if(!et)return;const t=wn(),r=Vn.current;if(!r)return;const n=Pr.current;if(!n)return;const o=zn({clientX:e.clientX,clientY:e.clientY,canvasRect:r.getBoundingClientRect(),margin:tr,adjustedWidth:rr,adjustedHeight:nr,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?(Gr.current=o.hover,Mr(o.hover),pn&&(pn(o.hover),t&&(Kt.current=!0)),t&&hr()):Gr.current&&(Gr.current=null,Mr(null),pn&&(pn(null),t&&(Kt.current=!0)),t&&hr())},kn.current=()=>{if(Gr.current){const e=wn();Gr.current=null,Mr(null),pn&&(pn(null),e&&(Kt.current=!0)),e&&hr()}};const Dn=Re(()=>{});Dn.current=e=>{if(re(e.target))return;if(!nt&&!ot)return;const t=Vn.current;if(!t)return;const r=Pr.current;if(!r)return;const n=zn({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:tr,adjustedWidth:rr,adjustedHeight:nr,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===n.kind?mn(n.hover,{type:"activate",inputType:ue(e.nativeEvent.pointerType)}):"miss"===n.kind&&mn(null)};const Mn=We(e=>Dn.current(e),[]),Tn=Re(-1),Cn=Re(null),Wn=Re(-1),In=We(e=>{if(ne(e))return;const t=Pr.current;if(!t)return;const r=()=>{Tn.current=-1,Cn.current=null,Wn.current=-1,Gr.current=null,Mr(null),pn&&(pn(null),Kt.current=!0),hr()},n=c(t.sceneNodes);if(0===n.length)return void(0>Tn.current||r());const i=o(n);let a=Tn.current;if(i.flat.length>a||(r(),a=-1)," "===e.key&&a>=0){e.preventDefault();const t=i.flat[a];return void mn(H(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>a){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Tn.current=0,Wn.current=-1;const t=i.flat[0];Cn.current={shape:t.shape,w:t.w,h:t.h};const r=H(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Gr.current=r,Mr(r),pn&&(pn(r,{type:"focus",inputType:"keyboard"}),Kt.current=!0),void hr()}const s=k(i,a),l=f(e.key,s,i,t.sceneEdges??[],Wn);if(null===l)return;if(e.preventDefault(),0>l)return void r();Tn.current=l;const u=i.flat[l];Cn.current={shape:u.shape,w:u.w,h:u.h};const d={data:u.datum||{},x:u.x,y:u.y,__semioticHoverData:!0,nodeOrEdge:"node"};Gr.current=d,Mr(d),pn&&(pn(d,{type:"focus",inputType:"keyboard"}),Kt.current=!0),hr()},[mn,pn,hr]),$n=We(e=>{Tn.current=-1,Cn.current=null,bn(e)},[bn]);dr.current=()=>{if(ur.current=null,!yr.isActive)return;const r=Vn.current;if(!r)return;const n=Pr.current;n&&function(r){const{canvas:n,store:o,sceneRevisionDiagnostics:i,size:a,margin:s,adjustedWidth:c,adjustedHeight:l,background:u,renderMode:d,hasBackgroundGraphics:h=!1,dirtyRef:f,lastFrameTimeRef:g,now:x,random:k,reducedMotion:b,showParticles:S,isContinuous:_,animate:w,decay:A,pulse:L,thresholds:E,staleness:P,particleStyle:D,getParticleColor:N,pendingAnnotationFrameRef:R,lastAnnotationFrameTimeRef:M,setAnnotationFrame:T,scheduleNextFrame:C}=r,W=n.getContext("2d");if(!W)return;const I=g.current?Math.min((x-g.current)/1e3,.1):.016;g.current=x;const $=o.advanceTransition(b?x+1e6:x),z=!b&&$,F=!b&&o.tickAnimation([c,l],I),B=f.current,O=i?.beforeCompute(o.getLastUpdateResult(),z),Y=$||B||F;Y&&o.buildScene([c,l]),O&&i?.afterCompute(O,Y,!1);const X=S&&!b&&!!o.particlePool,j=!!A||!!L||!!E||!1!==w&&o.hasActiveTopologyDiff||o.hasActivePulses||o.hasActiveThresholds,H=o.consumeStylePaintPending(),G=e({dirtyOrRebuilt:B,transitioning:z,animationTicked:F,continuous:X||_,liveEncoding:j,forced:H}),q=!!P&&o.lastIngestTime>0&&x-o.lastIngestTime>(P?.threshold??5e3);if(G){const e=te();if(!de(n,a,s,e))return;if(W.clearRect(-s.left,-s.top,a[0],a[1]),t(W,{background:u,hasBackgroundGraphics:h,width:c,height:l}),A&&o.applyDecay(),L&&o.applyPulse(x),E&&o.applyThresholds(x),!1!==w&&o.applyTopologyDiff(x),q&&(W.globalAlpha=P?.dimOpacity??.5),p({context:W,nodes:o.sceneEdges,renderMode:d,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const r of t)switch(r.type){case"bezier":An(e,r);break;case"line":Ln(e,r);break;case"ribbon":En(e,r);break;case"curved":Pn(e,r)}}(W,e)}),p({context:W,nodes:o.sceneNodes,renderMode:d,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=ge(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(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)),v(e,t),e.restore())}}(W,t),function(e,t){for(const r of t){if("circle"!==r.type)continue;const t=r;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=ge(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),m(e,t),e.restore())}}(W,t),function(e,t){for(const r of t){if("arc"!==r.type)continue;const t=r;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=ge(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(W,t),function(e,t){const r=e.globalAlpha;for(const n of t){if("symbol"!==n.type)continue;const t=n;if(0>=t.size)continue;const o=Nn(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=r*i*(t.style.fillOpacity??1),e.fillStyle=ge(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=r*i,e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(W,t),y(W,t)}}),X&&!q){const e=o.edgesArray;if(e.length>0){!function(e,t,r,n,o=Math.random){const i=n.spawnRate??.1,a=n.maxPerEdge??50;for(let n=0;t.length>n;n++){const s=t[n];if(!s.bezier)continue;if(e.countForEdge(n)>=a)continue;const c=s.value*i*r*(s.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let d=l;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(n)<a;t++)e.spawn(n,o)}}(o.particlePool,e,I,D,k);const t=.5*(D.speedMultiplier??1);let r;if(D.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}o.particlePool.step(I,t,e,r),function(e,t,r,n,o){const i=n.radius??3;e.globalAlpha=n.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const c=r[s.edgeIndex];if(!c)continue;let l;l="string"==typeof n.color&&"inherit"!==n.color?n.color:o(c),e.fillStyle=fe(e,l)||l,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(W,o.particlePool,e,D,N)}}q&&(W.globalAlpha=1)}f.current=!1,(B||z||F)&&n.setAttribute("aria-label",V(o.sceneNodes?.length??0,o.sceneEdges?.length??0,"Network chart"));const Q=B||z||F||R.current;Q&&x-M.current>=33?(T(e=>e+1),M.current=x,R.current=!1):R.current=!!Q,(_||z||null!=o.transition||F||o.hasActivePulses||o.hasActiveThresholds||!1!==w&&o.hasActiveTopologyDiff||R.current)&&C()}({canvas:r,store:n,sceneRevisionDiagnostics:Dr.current,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,background:Je,renderMode:ke,hasBackgroundGraphics:!!bt,dirtyRef:Kt,lastFrameTimeRef:Ar,now:yr.now(),random:yr.random,reducedMotion:!!Ut.current,showParticles:ve,isContinuous:rn,animate:At,decay:St,pulse:_t,thresholds:Tt,staleness:Lt,particleStyle:kr,getParticleColor:tn,pendingAnnotationFrameRef:Er,lastAnnotationFrameTimeRef:Lr,setAnnotationFrame:Ir,scheduleNextFrame:()=>{hr()}})};const{canvasRef:Vn}=_e(Zt,{hydrated:gr,wasHydratingFromSSR:pr,storeRef:Pr,dirtyRef:Kt,canvasPaintDependencies:[s,rr,nr,Je,bt,ke,hr]});w(Lt,Pr,Kt,hr,$r,zr);const qn=et&&Rr?On(W,{x:Rr.x,y:Rr.y,containerWidth:rr,containerHeight:nr,margin:tr,className:"stream-network-tooltip",zIndex:2,children:tt?tt(Rr):On(_n,{data:Rr})}):null;if(oe||!gr&&pr)return On(yn,{props:n,store:Pr.current,responsiveRef:Jt,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,resolvedBackground:ar,resolvedForeground:or});const Qn=Pr.current;return Yn("div",{ref:Jt,className:"stream-network-frame"+(Ue?" "+Ue:""),role:"group","aria-label":Wt||("string"==typeof xt?xt:"Network chart"),tabIndex:0,"aria-busy":Fr||void 0,style:{position:"relative",width:Qe?"100%":er[0],height:Ke?"100%":er[1],overflow:"visible"},onKeyDown:In,children:["production"!==process.env.NODE_ENV&&Pr.current&&On(z,{store:Pr.current,diagnostics:Dr.current}),Ct&&On(B,{tableId:lr}),Ct&&On($,{nodes:Qn?.sceneNodes??[],edges:Qn?.sceneEdges??[],chartType:"Network chart",tableId:lr,chartTitle:"string"==typeof xt?xt:void 0}),On(F,{summary:It}),On(M,{hoverPoint:Rr}),Yn("div",{role:"img","aria-label":Wt||("string"==typeof xt?xt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:et?$n:void 0,onMouseLeave:et?Sn:void 0,onClick:nt||ot?Mn:void 0,children:[Fr&&!1!==Q&&On("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Pe(!0,er[0],er[1],Q)}),On(T,{size:er,margin:tr,overflowVisible:!0,children:ar}),On("canvas",{ref:Vn,"aria-label":V(Qn?.sceneNodes?.length??0,Qn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),On(an,{width:rr,height:nr,totalWidth:er[0],totalHeight:er[1],margin:tr,labels:Qn?.labels||[],sceneNodes:Qn?.sceneNodes,title:xt,legend:ht,legendPosition:yt,legendLayout:ft,legendHoverBehavior:gt,legendClickBehavior:pt,legendHighlightedCategory:mt,legendIsolatedCategories:vt,foregroundGraphics:i(or,E(Pr.current?.customLayoutOverlays,qt??null)),annotations:ct,onAnnotationActivate:lt,onObservation:it??ot,chartId:at,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ut,svgAnnotationRules:dt,annotationFrame:Wr}),On(un,{marks:Qn?.customLayoutHtmlMarks,margin:tr,selection:qt??null}),On(I,{active:Tn.current>=0,hoverPoint:Rr,margin:tr,size:er,shape:Cn.current?.shape,width:Cn.current?.w,height:Cn.current?.h}),qn,Lt?.showBadge&&On(r,{isStale:$r,position:Lt.badgePosition})]})]})}));Vn.displayName="StreamNetworkFrame";var qn=Vn;export{Ft as buildRibbonGeometry,fn as shouldUseForceWorker,gn as canUseForceWorker,xn as runForceLayoutWorker,qn as StreamNetworkFrame_default};
@@ -0,0 +1 @@
1
+ import{makeRuleValueResolver as t,resolveStyleRules as e}from"./chunk-chunk-EMO5NUGE.module.min.js";import{PhysicsPipelineStore as o,absorbRegion as n,bodyGroupSpec as i,capacitatedRegion as a,collidersFromPlotBounds as r,collidersFromXScaleBins as s,forceFieldRegion as l,groupCompletionRows as c,portalRegion as u,pressureFieldRegion as p,processStageLayout as d,routeSurfaceRegion as h}from"./chunk-chunk-DNY43POY.module.min.js";import{buildResolveColor as g,resolveCustomLayoutPalette as m,xySceneNodeToSVG as f}from"./chunk-chunk-ES4DCG3L.module.min.js";import{schemeCategory10 as y}from"./chunk-chunk-NO4MCQVD.module.min.js";function x(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}function w(t,e={}){const o=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),n=o.filter(t=>t.sleeping).length;return{bodyCount:o.length,sleepingCount:n,settled:"settled"===t.simulationState&&0===t.queue.length&&n===o.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:x(e.projectionRows)}}var b={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function M(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function v(t,e){const o="function"==typeof e?e(t):e;return{...b,...o??{}}}function k(t,e={}){const o=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),n={label:e.getBodyLabel?.(t)??M(t)},i={style:v(t,e.bodyStyle),datum:o,accessibleDatum:o,accessibility:n,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...i}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...i}}function S(t,e={}){return t.map(t=>k(t,e))}function P(t,e={}){const o=t.settle(e.maxSteps),n=t.readBodies(),i=t.snapshot();return{snapshot:i,bodies:n,sceneNodes:S(n,e),evidence:w(i,{bodies:n,projectionRows:e.projectionRows,stepsRun:o}),stepsRun:o}}import*as A from"react-dom/server";import{jsx as I,jsxs as C}from"react/jsx-runtime";function z(t,e={}){const{width:o=640,height:n=360,title:i,description:a,background:r,className:s,idPrefix:l="physics",...c}=e,u=P(t,c),p=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(l),d=i?p+"-title":void 0,h=a?p+"-desc":void 0,g=[d,h].filter(Boolean).join(" ")||void 0;return{svg:A.renderToStaticMarkup(C("svg",{xmlns:"http://www.w3.org/2000/svg",className:s??"stream-physics-frame",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-labelledby":g,children:[i&&I("title",{id:d,children:i}),a&&I("desc",{id:h,children:a}),r&&"transparent"!==r?I("rect",{x:0,y:0,width:o,height:n,fill:r}):null,I("g",{id:p+"-data-area",children:u.sceneNodes.map((t,e)=>f(t,e,p))})]})),scene:u,evidence:u.evidence}}import{scaleLinear as R}from"d3-scale";function T(t){const[e,o]=t;return{width:e,height:o,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,o-58)}}}function L(t){const e=(t??"")+"";if(!e)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let n=0;for(let t=0;e.length>t;t+=1)n=31*n+e.charCodeAt(t)>>>0;return o[n%o.length]}function E(o,n="#4e79a7",i){const a=i?.styleRules,r=!!a&&a.length>0,s=r?t(i?.valueAccessor):void 0;return t=>{const i=t.datum,l=i&&o?"function"==typeof o?o(i,0):i[o]:void 0,c={fill:null==l?n:L(l),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&i&&Object.assign(c,e(i,a,{value:s?s(i):void 0,category:null==l?void 0:l+""})),c}}function Y(t,e,o,n){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:o},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...n}}}function j(t,e,o){return"function"==typeof o?o(t,e):t[o]}function $(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function N(t,e,o){return Math.max(e,Math.min(o,t))}function D(t,e){const o=$(t);return null!=o&&o>0?o:e}function F(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function B(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}import{scaleLinear as W}from"d3-scale";function X(t){const e=Math.max(2,Math.round(t.bins)),o=Math.max(1,Math.round(t.pegRows??e-1)),n=Math.max(1,Math.round(t.count??Math.max(64,4*e))),i=N(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),a=B(t.seed??1),r=t.idPrefix??"mechanical";return Array.from({length:n},(t,e)=>{let n=0;for(let t=0;o>t;t+=1)a()<i&&(n+=1);const s=o/2;return{id:`${r}-${e}`,value:n,mechanical:!0,pegRows:o,branchProbability:i,pathRights:n,side:s>n?"left":n>s?"right":"center"}})}function O(t){const{data:e,valueAccessor:o,bins:n,ballRadius:i,seed:a,size:l,valueExtent:c}=t,u=T(l),p=e.map((t,e)=>$(j(t,e,o))).filter(t=>null!=t),d=function(t){if(!t)return;const e=$(t[0]),o=$(t[1]);return null!=e&&null!=o?e>o?[o,e]:[e,o]:void 0}(c),h=d?.[0]??(p.length?Math.min(...p):0),g=d?.[1]??(p.length?Math.max(...p):1),m=g===h?1:g-h,f=W().domain([0,n]).range([u.plot.x,u.plot.x+u.plot.width]),y=Array.from({length:n},()=>0),x=[];e.forEach((t,e)=>{const a=$(j(t,e,o));if(null==a)return;const r=Math.max(0,Math.min(n-1,Math.floor((a-h)/m*n)));y[r]+=1,x.push({id:(t.id??"galton-"+e)+"",x:f(r+.5),y:u.plot.y+i+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...t,value:a,bin:r}})});const w=u.plot.y+u.plot.height;return{config:Y(a,[...r({x:u.plot.x,y:u.plot.y,width:u.plot.width,height:u.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...s({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:f,yTop:u.plot.y-400,yBottom:w,wallThickness:6})],"GaltonBoardChart"),initialSpawns:x,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:n,plot:u.plot,valueExtent:[h,g]}}}import{scaleLinear as V}from"d3-scale";function _(t){const{count:e,idPrefix:o,wallThickness:n,xScale:i,yBottom:a,yTop:r,yTopForIndex:s}=t;return Array.from({length:e+1},(t,e)=>{const l=Math.min(a-1,s?.(e)??r),c=Math.max(1,a-l);return{id:`${o}-wall-${e}`,shape:{type:"aabb",x:i(e),y:l+c/2,width:n,height:c}}})}function U(t){const{data:e,timeAccessor:o,arrivalAccessor:n,windows:i,watermark:a,ballRadius:s,seed:l,size:c,timeExtent:u,timeScale:p=1}=t,d=T(c),h=e.map((t,e)=>$(j(t,e,o))).filter(t=>null!=t),g=$(u?.[0]),m=$(u?.[1]),f=h.length?Math.min(...h):0,y=h.length?Math.max(...h):f+i.size,x=Math.min(g??f,f),w=Math.max(m??y,y),b=Math.floor(x/i.size)*i.size,M=Math.max(1,Math.ceil((w-b+i.size)/i.size)),v=h.length?Math.max(...h):0,k="function"==typeof a?a(v):$(a?.value)??v-(a?.delay??i.size),S=Math.max(0,Math.min(M,Array.from({length:M},(t,e)=>e).reduce((t,e)=>b+(e+1)*i.size>k?t:t+1,0))),P=function(t,e){const o=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:o,height:t.plot.height},windowPlot:{x:t.plot.x+o,y:t.plot.y,width:Math.max(40,t.plot.width-o),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(d,s),A=b+M*i.size,I=V().domain([b,A]).range([P.windowPlot.x,P.windowPlot.x+P.windowPlot.width]),C=Array.from({length:M},()=>({value:0,secondary:0})),z=[];e.forEach((t,e)=>{const a=$(j(t,e,o));if(null==a)return;const r=$(j(t,e,n))??a,l=Math.max(0,Math.min(M-1,Math.floor((a-b)/i.size))),c=k>=b+(l+1)*i.size;C[l].value+=c?0:1,C[l].secondary+=c?1:0,z.push({id:(t.id??"event-"+e)+"",x:Math.max(P.windowPlot.x+s,Math.min(P.windowPlot.x+P.windowPlot.width-s,I(a))),y:d.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...t,eventTime:a,arrivalTime:r,windowIndex:l,late:c}})});const R=d.plot.y+d.plot.height,L=function(t,e){const o=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!o)return[];const n=t.windowStart,i=t.windowStart+t.windowCount*t.windowSize,a=V().domain([n,i]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),r=a(t.windowStart+o*t.windowSize),s=t.windowPlot.x,l=e+Math.max(18,Math.min(.3*t.windowPlot.height,r-s)),c=t=>r===s?e:l+(t-s)/(r-s)*(e-l),u=[];for(let e=0;o>e;e+=1){const o=t.windowStart+e*t.windowSize,n=o+t.windowSize,i=a(o),r=a(n);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:i,y1:c(i),x2:r,y2:c(r)})}return u}({closedWindowCount:S,gutter:P.gutter,plot:d.plot,windowCount:M,windowPlot:P.windowPlot,windowSize:i.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Y(l,[...r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),..._({idPrefix:"eventdrop-window",count:M,xScale:t=>I(b+t*i.size),yTop:P.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?P.wallTop:e+1.25*s},yBottom:R,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:z,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:p},projectionRows:C.map((t,e)=>({label:`${b+e*i.size}-${b+(e+1)*i.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:P.gutter,lidSegments:L,lateCount:C.reduce((t,e)=>t+e.secondary,0),plot:d.plot,windowPlot:P.windowPlot,watermarkValue:k,windowCount:M,windowSize:i.size,windowStart:b}}}function G(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),o=e.length?e:["Intake"],n=Math.max(o.length,Math.round(t.count??Math.max(48,12*o.length))),i=D(t.unitValue,1),a=B(t.seed??1),r=t.idPrefix??"mechanical-pile",s=o.map(()=>.65+.9*a()),l=s.reduce((t,e)=>t+e,0)||1,c=n-o.length,u=s.map(t=>t/l*c),p=u.map(t=>1+Math.floor(t));let d=n-p.reduce((t,e)=>t+e,0);const h=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%h.length)p[h[t].index]+=1,d-=1;return o.map((t,e)=>({id:`${r}-${e}`,category:t,value:p[e]*i,mechanical:!0,unitCount:p[e],unitValue:i,share:p[e]/n}))}function Z(t){const{data:e,categoryAccessor:o,valueAccessor:n,unitValue:i,ballRadius:a,seed:s,size:l}=t,c=D(i,1),u=T(l),p=[],d=new Map,h=new Map,g=[];function m(t){let e=d.get(t);return null==e&&(e=p.length,p.push(t),d.set(t,e)),e}e.forEach((t,e)=>{m((j(t,e,o)??"unknown")+"")});const f=Math.max(1,p.length),y=function(t,e,o){const n=t.width/Math.max(1,e),i=Math.max(2,2*o),a=Math.min(.7*n,Math.max(3.2*i,i+8)),r=Math.max(1,Math.floor(a/i));return{laneWidth:n,tubeWidth:a,ballDiameter:i,perRow:r,centerX:e=>t.x+(e+.5)*n,pileHeight:t=>Math.ceil(Math.max(0,t)/r)*i}}(u.plot,f,a),x=Math.max(0,y.tubeWidth/2-a-1),w=p.map(()=>[]);e.forEach((t,e)=>{const i=(j(t,e,o)??"unknown")+"",r=m(i),s=n?$(j(t,e,n)):1,l=Math.max(0,Math.round((s??0)/c)),p=y.centerX(r);for(let o=0;l>o;o+=1){const n=h.get(i)??0,s=y.perRow>1?((y.perRow>1?n%y.perRow:0)/(y.perRow-1)*2-1)*x:0;h.set(i,n+1),w[r].push({id:`${(t.id??"pile-"+e)+""}-${o}`,x:p+s,y:u.plot.y+a+2,vx:(o%3-1)*a/2,vy:0,mass:1,shape:{type:"circle",radius:a},datum:{...t,category:i,unitIndex:o}})}});const b=w.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of w)e.length>t&&g.push(e[t]);const M=u.plot.y+u.plot.height,v=[...r({x:u.plot.x,y:u.plot.y,width:u.plot.width,height:u.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=u.plot.y-400;for(let t=0;f>t;t+=1){const e=y.centerX(t);for(const o of[-1,1])v.push({id:`pile-tube-${t}-${0>o?"l":"r"}`,shape:{type:"aabb",x:e+o*y.tubeWidth/2,y:(k+M)/2,width:6,height:M-k}})}return{config:Y(s,v,"PhysicsPileChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:p.map(t=>({label:t,value:h.get(t)??0}))}}import{scaleLinear as q}from"d3-scale";function H(t){const{data:e,xAccessor:o,groupAccessor:n,radiusAccessor:i,pointRadius:a,seed:s,size:l,xExtent:c,collisionIterations:u,settle:p}=t,d=T(l),h=B(s),g=[],m=[],f=new Map;e.forEach((t,e)=>{const r=$(j(t,e,o));if(null==r)return;const s=n?(j(t,e,n)??"All")+"":"All",l=i?$(j(t,e,i)):null,c=N(null!=l&&l>0?l:a,2,18);!function(t){let e=f.get(t);null==e&&(e=m.length,m.push(t),f.set(t,e))}(s),g.push({datum:t,index:e,value:r,group:s,radius:c})});const y=g.map(t=>t.value),x=c?$(c[0]):null,w=c?$(c[1]):null,b=y.length?Math.min(...y):0,M=y.length?Math.max(...y):1;let v=x??b,k=w??M;if(v===k&&(v-=.5,k+=.5),v>k){const t=k;k=v,v=t}const S=Math.max(a,...g.map(t=>t.radius)),P=d.plot.x+S+8,A=d.plot.x+d.plot.width-S-8,I=q().domain([v,k]).range([P,A]),C=Math.max(1,m.length),z=d.plot.y+Math.max(28,3*S),R=Math.max(0,d.plot.y+d.plot.height-Math.max(28,3*S)-z),L=t=>{const e=f.get(t)??0;return 1===C?d.plot.y+.54*d.plot.height:z+e/(C-1)*R},E=new Map,D=g.map((t,e)=>{E.set(t.group,(E.get(t.group)??0)+1);const o=I(t.value),n=L(t.group),i=(h()-.5)*t.radius*1.6,a=(h()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:p?o+i:N(o+(e%9-4)*t.radius*2.5,P,A),y:p?n+a:d.plot.y-18-e%12*t.radius,vx:p?0:22*(h()-.5),vy:p?0:24+18*h(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:o,targetY:n},springs:[{target:{type:"point",x:o,y:n},restLength:0,stiffness:34,damping:5.5}]}});return{config:Y(s,r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:D,projectionRows:m.map(t=>({label:t,value:E.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[v,k],xRange:[P,A],groups:m.map(t=>({label:t,y:L(t),count:E.get(t)??0})),plot:d.plot}}}function K(t){if(Array.isArray(t)&&t.length>=2){const e=$(t[0]),o=$(t[1]);return null!=e&&null!=o?{x:e,y:o}:null}if(t&&"object"==typeof t){const e=t,o=$(e.x),n=$(e.y);return null!=o&&null!=n?{x:o,y:n}:null}return null}function Q(t){return Array.isArray(t)?t.map(K).filter(t=>null!=t):[]}function J(t,e,o){return"normalized"===o?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:N(t.x,e.plot.x,e.plot.x+e.plot.width),y:N(t.y,e.plot.y,e.plot.y+e.plot.height)}}function tt(t){let e=0;for(let o=1;t.length>o;o+=1)e+=Math.hypot(t[o].x-t[o-1].x,t[o].y-t[o-1].y);return e}function et(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const o=N(e,0,1)*tt(t);let n=0;for(let e=1;t.length>e;e+=1){const i=t[e-1],a=t[e],r=Math.hypot(a.x-i.x,a.y-i.y);if(r>0){if(n+r>=o){const t=(o-n)/r;return{x:i.x+(a.x-i.x)*t,y:i.y+(a.y-i.y)*t}}n+=r}}return{...t[t.length-1]}}function ot(t,e){const o=et(t,Math.max(0,e-.02)),n=et(t,Math.min(1,e+.02)),i=n.x-o.x,a=n.y-o.y,r=Math.hypot(i,a)||1;return{x:i/r,y:a/r}}function nt(t){const{coordinateMode:e,flowSpeed:o,links:n,maxParticles:i,nodeIdAccessor:a,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:u,particleRate:p,pathAccessor:d,pathConstraint:h="path",reducedMotion:g,seed:m,size:f,sourceAccessor:y,targetAccessor:x,throughputAccessor:w}=t,b=T(f),M=B(m),v=new Map,k=new Map,S=[];function P(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof a){const t=a(e,0);if(null!=t)return t+""}if("string"==typeof a&&null!=e[a])return e[a]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const o=(j(t,e,a)??t.id??e)+"",n=$(j(t,e,s)),i=$(j(t,e,l));if(null!=n&&null!=i){const t={x:n,y:i};v.set(o,t),S.push(t)}k.set(o,(t.label??t.name??o)+"")});const A=[];n.forEach((t,e)=>{const o=P(j(t,e,y)),n=P(j(t,e,x)),i=Math.max(0,$(j(t,e,w))??0),a=Q(d?j(t,e,d):void 0),r=a.length?a:Q(t.path??t.points??t.route);r.forEach(t=>S.push(t)),A.push({id:(t.id??`physical-flow-${o}-${n}-${e}`)+"",link:t,index:e,source:o,target:n,throughput:i,rawPath:r})});const I=(z=S,"normalized"===(C=e)||"pixels"===C?C:z.length>0&&z.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var C,z;const R=new Map;for(const[t,e]of v)R.set(t,J(e,b,I));const L=[];for(const t of A){let e=t.rawPath.map(t=>J(t,b,I));if(2>e.length){const o=R.get(t.source),n=R.get(t.target);o&&n&&(e=[o,n])}else R.has(t.source)||R.set(t.source,e[0]),R.has(t.target)||R.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const E=D(p,.12),W=Math.max(1,Math.round(i)),X=L.map(t=>Math.max(1,Math.round(t.throughput*E))),O=X.reduce((t,e)=>t+e,0),V=O>W?W/O:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(X[e]*V))});let _=L.reduce((t,e)=>t+e.packetCount,0);for(;_>W;){const t=L.reduce((t,e,o)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?o:t,-1);if(-1===t)break;L[t].packetCount-=1,_-=1}const U=new Map,G=new Map,Z=[],q=D(o,90),H=D(u,4);L.forEach((t,e)=>{U.set(t.target,(U.get(t.target)??0)+t.throughput),G.set(t.source,(G.get(t.source)??0)+t.throughput);const o=tt(t.path);for(let n=0;t.packetCount>n;n+=1){const i=(n+.5)/t.packetCount,a=g?i:N(.12+.84*i+.04*(M()-.5),.04,.98),r=g?a:Math.max(0,a-(.18+.12*M())),s=et(t.path,r),l=et(t.path,a),c=ot(t.path,r),u={x:-c.y,y:c.x},p=(M()-.5)*H*1.5;Z.push({id:`${t.id}-packet-${n}`,x:s.x+u.x*p,y:s.y+u.y*p,vx:g?0:c.x*q+10*(M()-.5),vy:g?0:c.y*q+10*(M()-.5),mass:.8,spawnAt:g?0:.04*e+n/32,shape:{type:"circle",radius:H},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:n,packetCount:t.packetCount,routeProgress:a,flowPath:t.path,flowPathLength:o,flowRouteId:t.id,flowSpeed:q,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==h&&g?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*H,stiffness:26,damping:4.25}]:void 0})}});const K=Math.max(18,5*H),nt=Array.from(R,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+F(t),point:e})),it=nt.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:K,height:K}})),at=Object.fromEntries(nt.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),rt=Y(m,[...r({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...it],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*H),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});rt.bodyLimit=W,rt.eviction="oldest",rt.observation={...rt.observation,sensors:at};const st=Array.from(R,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+F(t),incoming:U.get(t)??0,outgoing:G.get(t)??0})),lt=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:rt,initialSpawns:Z,projectionRows:st.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:I,particleCount:Z.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:st,links:lt}}}function it(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function at(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=t.size,r=T(o),s=N(t.ballRadius??6,2,18),g=t.seed??1,m=B(g),f=t.idAccessor,y=t.stageAccessor??"stage",x=t.groupBy,w=t.groupLabelAccessor,b=t.workAccessor,M=t.radiusAccessor,v=t.groupCompletion??(x?"allAbsorbed":"none"),k=t.springStiffness??.28,S=t.springDamping??.72,P=!0===t.settle,A=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),I=d({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:A,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),C=new Map(I.stages.map((t,e)=>[t.id,e])),z=new Map(I.stages.map(t=>[t.id,t])),R=I.stages[0].id,L=I.stages[0],E=new Set(e.filter(t=>t.absorb).map(t=>t.id)),Y=e.map(t=>{const e=z.get(t.id)??L;return function(t,e){const o={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return n({...o,kind:t.kind??"sink",force:it(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return u({...o,kind:t.kind??"force-field",force:it(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:t.portal.targetStageId}})}if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return a({...o,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:it(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...o.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return p({...o,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:it(t.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?h({...o,kind:t.kind??"force-field",force:it(t.force,14),damping:t.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):l({...o,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(t,{x:e.x,y:I.midY,width:e.width,height:I.bottomY-I.topY})});Y.unshift(h({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(I.left+I.right)/2,y:I.midY,width:I.right-I.left,height:I.bottomY-I.topY-12,force:8,damping:.012,semanticItem:!1}));const D=new Map;for(const t of I.stages)D.set(t.id,0);const F=[];t.data.forEach((t,e)=>{const o=(f?j(t,e,f)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",n=(j(t,e,y)??R)+"",i=C.has(n)?n:R;D.set(i,(D.get(i)??0)+1);const a=x?(j(t,e,x)??"")+"":void 0,r=a&&w?(j(t,e,w)??a)+"":a,l=b?$(j(t,e,b))??1:1,c=M?$(j(t,e,M)):null,u=N(null!=c&&c>0?c:s,2,18);F.push({datum:t,id:o,stageId:i,groupId:a||void 0,groupLabel:r||void 0,work:l,radius:u,index:e})});const W=new Map,X=new Map;for(const t of F){if(!t.groupId)continue;const e=W.get(t.groupId)??[];e.push(t.id),W.set(t.groupId,e),t.groupLabel&&X.set(t.groupId,t.groupLabel)}const O=N(t.groupAnchorAlong??.55,.15,.9),V=I.left+(I.right-I.left)*O,_=Array.from(W.keys()),U=_.map((t,o)=>{const n=W.get(t)??[],a=_.length>1?I.topY+28+o/Math.max(1,_.length-1)*(I.bottomY-I.topY-56):I.midY;return i({id:t,label:X.get(t)??t,bodyIds:n,anchor:{x:V,y:a},x:V,y:a,completion:"allAbsorbed"===v?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),G=F.filter(t=>E.has(t.stageId)).map(t=>t.id),Z=c(U,G),q=new Map(U.map(t=>[t.id,t])),H=F.map((t,e)=>{const o=z.get(t.stageId)??L,n=o.x+(m()-.5)*Math.min(24,.2*o.width),i=I.boundaryY(n,"top")+t.radius+10,a=I.boundaryY(n,"bottom")-t.radius-10,r=a>i?i+m()*Math.max(1,a-i):I.midY,s=P?n:I.left+18+e%7*4,l=P?r:I.midY+(m()-.5)*(I.bottomY-I.topY)*.35,c=[{target:{type:"point",x:n,y:r},restLength:.45*t.radius,stiffness:k,damping:S}];if(t.groupId){const e=q.get(t.groupId);e?.anchor&&!E.has(t.stageId)&&c.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:s,y:l,vx:P?0:40+40*m(),vy:P?0:20*(m()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:P?0:.03*e,springs:c,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),K={kernel:{seed:g,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:I.colliders,fixedDt:1/60,maxSubsteps:8},Q=I.stages.map(t=>({label:t.label??t.id,value:D.get(t.id)??0})),J=e.map(t=>{const e=z.get(t.id)??L;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:D.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:K,initialSpawns:H,initialSpawnPacing:P?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:Q,metadata:{kind:"process-flow",plot:r.plot,volume:I,stages:J,groups:U,groupCompletion:Z,regionEffects:Y}}}function rt(t,e){const o=e.config??{},n=(e.sensors??[]).map(t=>({...t,sensor:!0})),i=[...e.colliders??[],...n],a=[...t.colliders??[],...o.colliders??[],...i];return{...t,...o,observation:{...t.observation,...o.observation},...a.length>0&&{colliders:a}}}function st(t){const e=function(t,e,o){const n=t?.observation;return{...t,observation:{...n,chartId:e??n?.chartId??"physics-custom",chartType:n?.chartType??"PhysicsCustomChart",onObservation:o??n?.onObservation}}}(t.config,t.chartId,t.onObservation),n=m(t.colorScheme,t.themeCategorical,y),i=T(t.size),a={data:t.data,scales:{x:R().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:R().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...n]},resolveColor:g(n,t.colorScheme),config:t.layoutConfig??{},world:new o(e)},r=t.skipLayout?{}:t.layout(a)??{},s=function(t,e){if(!e?.length)return t;const o=new Map;for(const t of e){const{bodyId:e,...n}=t,i=o.get(e)??[];i.push(n),o.set(e,i)}return t.map(t=>{const e=o.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:rt(e,r),context:a,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}export{E as styleFromColorAccessor,X as generateGaltonMechanicalSamples,O as buildGaltonBoardPhysics,U as buildEventDropPhysics,G as generatePhysicsPileMechanicalSamples,Z as buildPhysicsPile,H as buildCollisionSwarmPhysics,nt as buildPhysicalFlowPhysics,at as buildProcessFlowPhysics,st as resolveCustomLayout,w as buildPhysicsSettledEvidence,k as physicsBodyToXYSceneNode,S as physicsBodiesToXYSceneNodes,P as buildPhysicsSettledScene,z as renderPhysicsSettledSVG};
@@ -0,0 +1 @@
1
+ import{createStore as t}from"./chunk-chunk-DSNGDNJY.module.min.js";var e={fresh:1,aging:1.5,stale:3};function n(t,e,n={}){return Number.isFinite(e)&&e>0?Number.isNaN(t)?"fresh":t===1/0?"expired":0>t||e*(n.fresh??1)>t?"fresh":e*(n.aging??1.5)>t?"aging":e*(n.stale??3)>t?"stale":"expired":"fresh"}var r=null;function i(t={},e){const{background:n="transparent",stroke:i="#000",lineWidth:o=1.5,spacing:a=6,angle:s=45}=t,u=Math.max(8,Math.ceil(2*a));let c;try{c=function(t){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(t,t):(r||(r=document.createElement("canvas")),r.width=t,r.height=t,r)}(u)}catch{return null}const f=c.getContext("2d");if(!f)return null;n&&"transparent"!==n?(f.fillStyle=n,f.fillRect(0,0,u,u)):f.clearRect(0,0,u,u),f.strokeStyle=i,f.lineWidth=o,f.lineCap="square";const l=s*Math.PI/180;if(45===s||-45===s){const t=s>0?1:-1;for(let e=-u;2*u>=e;e+=a)f.beginPath(),f.moveTo(e,0),f.lineTo(e+t*u,u),f.stroke()}else{f.save(),f.translate(u/2,u/2),f.rotate(l);const t=2*u;for(let e=-t;t>=e;e+=a)f.beginPath(),f.moveTo(-t,e),f.lineTo(t,e),f.stroke();f.restore()}return(e||f).createPattern(c,"repeat")}import{jsx as o,jsxs as a}from"react/jsx-runtime";function s(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function u(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}function c(t,e){let n=2166136261;const r=u(e);for(let t=0;r.length>t;t++)n^=r.charCodeAt(t),n=Math.imul(n,16777619);return`${t}-hatch-${(n>>>0).toString(36)}`}var f=new Map;function l(t,e){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${u(t)}@${n}`,o=f.get(r);if(void 0!==o)return o;const a=i({background:t.background,stroke:t.stroke,lineWidth:t.lineWidth,spacing:t.spacing,angle:t.angle},e);return f.set(r,a),a}function h(t,e){const{background:n="transparent",stroke:r="#000",lineWidth:i=1.5,spacing:s=6,angle:u=45,lineOpacity:c=1}=t,f=Math.max(8,Math.ceil(2*s));return a("pattern",{id:e,width:f,height:f,patternUnits:"userSpaceOnUse",patternTransform:0!==u?`rotate(${u})`:void 0,children:[n&&"transparent"!==n&&o("rect",{width:f,height:f,fill:n}),o("line",{x1:0,y1:0,x2:0,y2:f,stroke:r,strokeWidth:i,strokeOpacity:c}),o("line",{x1:s,y1:0,x2:s,y2:f,stroke:r,strokeWidth:i,strokeOpacity:c})]},e)}function p(t,e,n="#4e79a7"){if(s(t)){const n=c(e,t);return{fill:`url(#${n})`,def:h(t,n)}}return t&&"string"==typeof t?{fill:t}:{fill:n}}function m(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function d(t,e){const{when:n}=t,r=e.width,i=e.height,o=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),a=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof i||n.minHeight>i)||"number"==typeof n.maxHeight&&("number"!=typeof i||i>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function g(t,e,n=t.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:t,matches:[]};const r=n.map((t,e)=>({rule:t,index:e})).filter(t=>d(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:r.reduce((t,e)=>function(t,e){const n={...t,...e};for(const r of["margin","frameProps","mobileSemantics","style"])m(t[r])&&m(e[r])&&(n[r]={...t[r],...e[r]});return"string"==typeof t.className&&"string"==typeof e.className&&(n.className=`${t.className} ${e.className}`),n}(t,e.rule.transform),t),matches:r}}function y(t,e){return t===e}function b(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function v(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function x(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var[k,w]=t(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));export{y as accessorsEquivalent,b as resolveAccessor,v as resolveRawAccessor,x as resolveStringAccessor,e as DEFAULT_LIFECYCLE_THRESHOLDS,n as bandFromAge,i as createHatchPattern,s as isHatchFill,u as hatchFillKey,c as hatchFillId,l as resolveHatchCanvasPattern,h as hatchPatternDef,p as resolveSvgFill,w as useObservationSelector,d as responsiveRuleMatches,g as resolveResponsiveRules};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import*as e from"react";import{jsx as r}from"react/jsx-runtime";var t={isActive:!1,predicate:()=>!0},n=e.createContext(null);function i({value:e,children:t}){return r(n.Provider,{value:e,children:t})}function u(){return e.useContext(n)??t}function c(e,t){return null!=e?r(i,{value:t,children:e}):e}export{i as CustomLayoutSelectionProvider,u as useCustomLayoutSelection,c as wrapWithCustomLayoutSelection};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{buildNavGraph as t,extractGeoNavPoints as e,extractOrdinalNavPoints as r,extractXYNavPoints as n,navPointToHover as i,nextGraphIndex as s,nextIndex as o,renderCirclePulse as c,resolvePosition as u}from"./chunk-chunk-FAKO3RGQ.module.min.js";import{emitClickObservations as a,emitHoverObservations as l,isInteractiveKeyboardTarget as f,resolveCanvasFill as h}from"./chunk-chunk-ODUZEEBH.module.min.js";var p=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const r of t){const t=this.push(r);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t(this.buffer[(e+r)%this._capacity],r)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t[r]=this.buffer[(e+r)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let r=0,n=[];e.length>t&&(r=e.length-t,n=e.slice(0,r)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=r;e.length>t;t++)this.push(e[t]);return n}update(t,e){const r=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const s=(n+i)%this._capacity,o=this.buffer[s];if(t(o)){let t;t="object"!=typeof o||null===o?o:Array.isArray(o)?[...o]:{...o},r.push(t),this.buffer[s]=e(o)}}return r}remove(t){const e=[],r=[];if(this.forEach(n=>{t(n)?r.push(n):e.push(n)}),0===r.length)return r;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return r}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}};function y(t,e,r,n){return"function"==typeof e.style?e.style(n||{},r):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(r,n)}function d(t,e,r,n){if(!t.scales)return null;const i=[],s=[];for(const r of e){const e=t.getX(r);if(!Number.isFinite(e))continue;const o=n.getTop(r),c=n.getBottom(r);if(!Number.isFinite(o)||!Number.isFinite(c))continue;const u=t.scales.x(e),a=t.scales.y(o),l=t.scales.y(c);Number.isFinite(u)&&Number.isFinite(a)&&Number.isFinite(l)&&(i.push([u,a]),s.push([u,l]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:s,style:y(t,n,r,e[0]),datum:e,group:r,interactive:n.interactive}}function v(t){const e=[],r=[];if(!t)return{perSeries:e,aggregate:r};for(const n of t)n.perSeries?e.push(n):r.push(n);return{perSeries:e,aggregate:r}}function _(t,e,r){const n=[];for(const i of r){const r=d(t,e,"__ribbon_aggregate",i);r&&n.push(r)}return n}function g(t,e,r,n){const i=[];for(const s of n){const n=d(t,e,r,s);n&&i.push(n)}return i}function m(t,e){if(!t)return{};if(!e||0===e.length)return t;const r=[];for(const n of e){if("band"!==n.kind)continue;const e=n.getTop(t),i=n.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&r.push({y0:i,y1:e})}return 0===r.length?t:{...t,band:r[0],bands:r}}function b(t,e,r,n){const i=n.current,s=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,o=!s&&t.hasActivePulsesAt(e),c=!(r||s||!o&&!i)&&t.refreshPulse(e);return n.current=o,{changed:c,pending:o}}import{useCallback as k,useRef as z}from"react";function A(t,e,r,n){const i=z({accessor:e,onChange:r,readData:n}),s=z([]);return i.current={accessor:e,onChange:r,readData:n},k(()=>{const{accessor:e,onChange:r,readData:n}=i.current;if(!r||!e)return;const o=function(t,e){if(!e)return[];const r=new Set,n=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const s=t+"";r.has(s)||(r.add(s),n.push(s))}return n}(t.current?n(t.current):[],e);(function(t,e){if(t.length!==e.length)return!1;for(let r=0;t.length>r;r++)if(t[r]!==e[r])return!1;return!0})(o,s.current)||(s.current=o,r(o))},[t])}var w=(t,e,r,n)=>{const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{const e=t.globalAlpha;for(const r of i)t.beginPath(),t.arc(r.x,r.y,r.r,0,2*Math.PI),t.globalAlpha=e*(r.style.opacity??r.style.fillOpacity??1),t.fillStyle=h(t,r.style.fill,"#4e79a7"),t.fill(),r.style.stroke&&(t.strokeStyle=h(t,r.style.stroke,r.style.stroke),t.lineWidth=r.style.strokeWidth||1,t.stroke()),c(t,r)}finally{t.restore()}}};import{useCallback as R}from"react";function x({customHoverBehavior:t,customClickBehavior:e,onObservation:r,chartId:n,chartType:i}){return{customHoverBehavior:R((e,s)=>{t?.(e,s),l({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:i,chartId:n,context:s})},[n,i,t,r]),customClickBehavior:R((t,s)=>{e?.(t,s),a({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:i,chartId:n,context:s})},[n,i,e,r]),hasClickBehavior:!(!e&&!r)}}import{useCallback as D,useRef as B}from"react";function C({storeRef:e,hoverRef:r,hoveredNodeRef:n,setHoverPoint:i,customHoverBehavior:o,customClickBehavior:c,scheduleRender:a,extractPoints:l,toHover:h}){const p=B(-1),y=B(null),d=B(null),v=D(v=>{if(f(v))return;const _=e.current;if(!_)return;const g=()=>{p.current=-1,y.current=null,r.current=null,n&&(n.current=null),i(null),o(null),a()};if(0===_.scene.length)return void(0>p.current||g());let m;if(d.current?.version===_.version)m=d.current.graph;else{const e=l(_.scene);if(0===e.length)return void(0>p.current||g());m=t(e),d.current={version:_.version,graph:m}}let b=p.current;if(m.flat.length>b||(g(),b=-1),("Enter"===v.key||" "===v.key)&&b>=0)return v.preventDefault(),void c(h(m.flat[b],_),{type:"activate",inputType:"keyboard"});if(0>b){if("Escape"===v.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(v.key))return;v.preventDefault(),p.current=0;const t=m.flat[0];y.current=t;const e=h(t,_);return r.current=e,i(e),o(e,{type:"focus",inputType:"keyboard"}),void a()}const k=s(v.key,u(m,b),m);if(null===k)return;if(v.preventDefault(),0>k)return void g();p.current=k;const z=m.flat[k];y.current=z;const A=h(z,_);r.current=A,i(A),o(A,{type:"focus",inputType:"keyboard"}),a()},[c,o,l,r,n,a,i,e,h]);return{kbFocusIndexRef:p,focusedNavPointRef:y,onKeyDown:v}}function P(t){return C({...t,extractPoints:n,toHover:(t,e)=>i({...t,datum:m(t.datum,e.resolvedRibbons)})})}function E({chartType:t,oAccessor:e,rAccessor:n,...s}){return C({...s,extractPoints:r,toHover:r=>({...i(r),__oAccessor:"string"==typeof e?e:void 0,__rAccessor:"string"==typeof n?n:void 0,__chartType:t})})}function F(t){const e=t.datum;return{...e||{},...e?.properties||{},data:e,properties:e?.properties,x:t.x,y:t.y,__semioticHoverData:!0}}function H({storeRef:t,hoverRef:r,hoveredNodeRef:n,setHoverPoint:i,customHoverBehavior:s,customClickBehavior:c,scheduleRender:u}){const a=B(-1),l=B(null),h=D(h=>{if(f(h))return;const p=t.current;if(!p)return;const y=()=>{a.current=-1,l.current=null,r.current=null,n&&(n.current=null),i(null),s(null),u()};if(0===p.scene.length)return void(0>a.current||y());const d=e(p.scene);if(0===d.length)return void(0>a.current||y());let v=a.current;if(d.length>v||(y(),v=-1),("Enter"===h.key||" "===h.key)&&v>=0)return h.preventDefault(),void c(F(d[v]),{type:"activate",inputType:"keyboard"});const _=o(h.key,0>v?-1:v,d.length);if(null===_)return;if(h.preventDefault(),0>_)return void y();const g=0>v?0:_;a.current=g;const m=d[g];l.current=m;const b=F(m);r.current=b,i(b),s(b,{type:"focus",inputType:"keyboard"}),u()},[c,s,r,n,u,i,t]);return{kbFocusIndexRef:a,focusedNavPointRef:l,onKeyDown:h}}function N(t,e,r){const n=t.duration??500,i=r-e;return n>i?1-i/n:0}function T(t,e,r,n,i,s=("undefined"!=typeof performance?performance.now():Date.now())){const o=t.color??"rgba(255,255,255,0.6)",c=t.glowRadius??4;let u=!1;const a=i??(()=>{const t=new Map;for(let e=0;r.length>e;e++)t.set(r[e],e);return t})();for(const r of e){if("line"===r.type)continue;if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[r.datum];let i=0,c=!1;for(const r of e){const e=a.get(r);if(null==e)continue;c=!0;const o=n.get(e);if(null==o)continue;const u=N(t,o,s);u>i&&(i=u)}c&&(u=I(r,i,o)||u);continue}const e=a.get(r.datum);if(null==e)continue;const i=n.get(e);u=I(r,null==i?0:N(t,i,s),o,c)||u}return u}function I(t,e,r,n){let i=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,i=!0),t._pulseColor!==r&&(t._pulseColor=r,i=!0),t._pulseGlowRadius!==n&&(t._pulseGlowRadius=n,i=!0),i):(0!==t._pulseIntensity&&(t._pulseIntensity=0,i=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,i=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,i=!0),i)}function S(t,e,r=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const n=t.duration??500,i=e.peek();return null!=i&&n>r-i}function O(t,e,r){e>t.capacity&&(t.resize(e),r&&e>r.capacity&&r.resize(e))}function G(t,e){const r=new p(t.capacity);return t.forEach(()=>r.push(e)),r}function j(t,e,r,n){const i=t.push(e);return r&&r.push(n),i}function K(t,e,r){if(!e||0===e.size)return;const n=new Set;if(t.forEach((t,e)=>{r(t)&&n.add(e)}),0===n.size)return;const i=e.toArray();e.clear();for(let t=0;i.length>t;t++)n.has(t)||e.push(i[t])}export{p as RingBuffer,N as computePulseIntensity,T as applyPulse,I as setPulseState,S as hasActivePulses,v as partitionRibbons,_ as buildAggregateRibbons,g as buildPerSeriesRibbons,m as enrichDatumWithBand,O as ensureRingBufferCapacity,G as createTimestampBufferForData,j as pushWithTimestamp,K as compactTimestampBufferForRemoval,b as refreshIdlePulse,A as useLegendCategoryEmission,w as pointCanvasRenderer,x as useSemanticFrameInteractions,P as useXYKeyboardNavigation,E as useOrdinalKeyboardNavigation,H as useGeoKeyboardNavigation};