semiotic 3.9.2 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (452) hide show
  1. package/README.md +99 -74
  2. package/agent-skill/semiotic-charts/SKILL.md +13 -7
  3. package/ai/artifact-contract-reference.md +408 -0
  4. package/ai/artifact-surface-inventory.json +5586 -0
  5. package/ai/behaviorContracts.cjs +24 -2
  6. package/ai/cli.js +480 -56
  7. package/ai/dist/mcp-server.js +68 -68
  8. package/ai/examples.md +1 -1
  9. package/ai/reference.md +31 -14
  10. package/ai/schema.json +1868 -438
  11. package/ai/surface-manifest.json +11 -4
  12. package/ai/system-prompt.md +2 -0
  13. package/ai/task-packets/compare-category-totals.json +301 -0
  14. package/ai/task-packets/compare-category-totals.md +188 -0
  15. package/ai/task-packets/correct-published-chart.json +271 -0
  16. package/ai/task-packets/correct-published-chart.md +597 -0
  17. package/ai/task-packets/index.json +40 -0
  18. package/ai/task-packets/update-live-chart.json +289 -0
  19. package/ai/task-packets/update-live-chart.md +424 -0
  20. package/dist/c-2N7IU2NY.min.js +1 -0
  21. package/dist/c-2WK7YJLL.min.js +1 -0
  22. package/dist/c-33QOXEUG.min.js +1 -0
  23. package/dist/c-42PLDTX7.min.js +1 -0
  24. package/dist/c-447VIMRO.min.js +1 -0
  25. package/dist/c-4FN7Q6VQ.min.js +1 -0
  26. package/dist/c-553QUDKA.min.js +1 -0
  27. package/dist/c-55BAJ333.min.js +1 -0
  28. package/dist/c-7242NXSG.min.js +1 -0
  29. package/dist/c-7EGHJU2F.min.js +1 -0
  30. package/dist/c-7HP7MB2I.min.js +1 -0
  31. package/dist/c-7NBU5ZKS.min.js +1 -0
  32. package/dist/c-AFBSWT77.min.js +1 -0
  33. package/dist/c-AJ7EC32V.min.js +1 -0
  34. package/dist/c-AQADQNY7.min.js +1 -0
  35. package/dist/c-ATM475SA.min.js +1 -0
  36. package/dist/c-AVO3Q7T7.min.js +1 -0
  37. package/dist/c-AZKPVBOC.min.js +1 -0
  38. package/dist/c-BNFJMDHN.min.js +1 -0
  39. package/dist/c-BNG5ECK5.min.js +1 -0
  40. package/dist/c-BOHCQILI.min.js +1 -0
  41. package/dist/c-CCTGN5CK.min.js +1 -0
  42. package/dist/c-CPSPZH6A.min.js +1 -0
  43. package/dist/c-CPV4N35K.min.js +1 -0
  44. package/dist/c-D6HAAPTX.min.js +1 -0
  45. package/dist/c-DE5Q3U2X.min.js +1 -0
  46. package/dist/c-DK662R77.min.js +1 -0
  47. package/dist/c-DY2676CR.min.js +1 -0
  48. package/dist/c-E32M6XW5.min.js +1 -0
  49. package/dist/c-E4JDJH4I.min.js +1 -0
  50. package/dist/c-E7I2L7CU.min.js +1 -0
  51. package/dist/c-EBOQ7ER7.min.js +1 -0
  52. package/dist/c-ELDWAO2V.min.js +1 -0
  53. package/dist/c-EUBTECGM.min.js +1 -0
  54. package/dist/c-GNTXRXRN.min.js +1 -0
  55. package/dist/c-GSZRZRD6.min.js +1 -0
  56. package/dist/c-GWX7JGMF.min.js +1 -0
  57. package/dist/c-GXV3C3MO.min.js +1 -0
  58. package/dist/c-HHTK2R75.min.js +1 -0
  59. package/dist/c-HLLFJYTY.min.js +1 -0
  60. package/dist/c-HPOYKCCG.min.js +1 -0
  61. package/dist/c-HXDKPIKR.min.js +1 -0
  62. package/dist/c-I4QJ6YLM.min.js +1 -0
  63. package/dist/c-IDJV3CZK.min.js +1 -0
  64. package/dist/c-ITKX3RC5.min.js +1 -0
  65. package/dist/c-JG2JCQLP.min.js +1 -0
  66. package/dist/c-JLGRHXGZ.min.js +1 -0
  67. package/dist/c-JO2UGTCP.min.js +1 -0
  68. package/dist/c-JUKIWTBJ.min.js +1 -0
  69. package/dist/c-KCRJGUHP.min.js +1 -0
  70. package/dist/c-LMGSSD2E.min.js +1 -0
  71. package/dist/c-LYQMZMZQ.min.js +1 -0
  72. package/dist/c-LYVKDBQJ.min.js +1 -0
  73. package/dist/c-MVR3RWF3.min.js +1 -0
  74. package/dist/c-MXCP7GNZ.min.js +1 -0
  75. package/dist/c-NG7BLZTR.min.js +1 -0
  76. package/dist/c-NYZ2QNAM.min.js +1 -0
  77. package/dist/c-OO5QLMJC.min.js +1 -0
  78. package/dist/c-OOVX2JPQ.min.js +1 -0
  79. package/dist/c-ORLEBW72.min.js +1 -0
  80. package/dist/c-P65V6HLO.min.js +1 -0
  81. package/dist/c-PP6VY3QU.min.js +1 -0
  82. package/dist/c-PRIKOLTE.min.js +1 -0
  83. package/dist/c-PSNI6KAZ.min.js +1 -0
  84. package/dist/c-PYNW54D2.min.js +1 -0
  85. package/dist/c-QA3HMQJP.min.js +1 -0
  86. package/dist/c-ROEHCIGV.min.js +1 -0
  87. package/dist/c-S3AZX5PP.min.js +1 -0
  88. package/dist/c-T2V7O2LO.min.js +1 -0
  89. package/dist/c-TIXX5CAU.min.js +1 -0
  90. package/dist/c-TKG2NP7G.min.js +1 -0
  91. package/dist/c-VJTDST2R.min.js +1 -0
  92. package/dist/c-VXLOLYTO.min.js +1 -0
  93. package/dist/c-W4ZUKSEQ.min.js +1 -0
  94. package/dist/c-WH2O53VI.min.js +1 -0
  95. package/dist/c-WNGH47HF.min.js +1 -0
  96. package/dist/c-WUWXGQYA.min.js +1 -0
  97. package/dist/c-XDQKXPX4.min.js +1 -0
  98. package/dist/{c-CKLIFCGN.min.js → c-XSB27XPS.min.js} +1 -1
  99. package/dist/c-YDECTEUW.min.js +1 -0
  100. package/dist/c-YF3YKVQI.min.js +1 -0
  101. package/dist/c-YLZIV3VS.min.js +1 -0
  102. package/dist/c-ZYPXQF7B.min.js +1 -0
  103. package/dist/components/Annotation.d.ts +2 -1
  104. package/dist/components/ai/chartRecipeRegistry.d.ts +6 -1
  105. package/dist/components/ai/chartRecipes.d.ts +4 -0
  106. package/dist/components/ai/describePhysicsProjection.d.ts +18 -0
  107. package/dist/components/ai/describePhysicsSource.d.ts +13 -0
  108. package/dist/components/artifact/ArtifactInspector.d.ts +26 -0
  109. package/dist/components/artifact/ArtifactInspectorContextSections.d.ts +18 -0
  110. package/dist/components/artifact/artifactContractDiff.d.ts +8 -0
  111. package/dist/components/artifact/artifactInspectorSummary.d.ts +53 -0
  112. package/dist/components/artifact/artifactRevision.d.ts +54 -0
  113. package/dist/components/artifact/artifactTestFixtures.d.ts +17 -0
  114. package/dist/components/artifact/attachmentAudit.d.ts +13 -0
  115. package/dist/components/artifact/claimCorrections.d.ts +3 -0
  116. package/dist/components/artifact/claimGraph.d.ts +5 -0
  117. package/dist/components/artifact/claimLifecycle.d.ts +32 -0
  118. package/dist/components/artifact/claims.d.ts +24 -0
  119. package/dist/components/artifact/collection.d.ts +10 -0
  120. package/dist/components/artifact/collectionCorrectionScope.d.ts +4 -0
  121. package/dist/components/artifact/collectionImpact.d.ts +11 -0
  122. package/dist/components/artifact/collectionLineage.d.ts +3 -0
  123. package/dist/components/artifact/collectionOperations.d.ts +8 -0
  124. package/dist/components/artifact/collectionPolicy.d.ts +22 -0
  125. package/dist/components/artifact/collectionTypes.d.ts +117 -0
  126. package/dist/components/artifact/configurationRepair.d.ts +8 -0
  127. package/dist/components/artifact/contract.d.ts +30 -0
  128. package/dist/components/artifact/evaluateArtifact.d.ts +12 -0
  129. package/dist/components/artifact/evaluateArtifactTypes.d.ts +78 -0
  130. package/dist/components/artifact/evaluationPresentation.d.ts +9 -0
  131. package/dist/components/artifact/evidenceSample.d.ts +8 -0
  132. package/dist/components/artifact/exportPaths.d.ts +8 -0
  133. package/dist/components/artifact/fieldPolicies.d.ts +12 -0
  134. package/dist/components/artifact/fingerprint.d.ts +36 -0
  135. package/dist/components/artifact/grounding.d.ts +51 -0
  136. package/dist/components/artifact/groundingBudget.d.ts +38 -0
  137. package/dist/components/artifact/hostTransfer.d.ts +13 -0
  138. package/dist/components/artifact/identity.d.ts +19 -0
  139. package/dist/components/artifact/inheritance.d.ts +48 -0
  140. package/dist/components/artifact/inheritanceIntegrity.d.ts +3 -0
  141. package/dist/components/artifact/jsonCompatibility.d.ts +2 -0
  142. package/dist/components/artifact/obligations.d.ts +3 -0
  143. package/dist/components/artifact/policies.d.ts +45 -0
  144. package/dist/components/artifact/policyRelations.d.ts +3 -0
  145. package/dist/components/artifact/recordProjection.d.ts +7 -0
  146. package/dist/components/artifact/representation.d.ts +50 -0
  147. package/dist/components/artifact/serialization.d.ts +40 -0
  148. package/dist/components/artifact/temporal.d.ts +32 -0
  149. package/dist/components/artifact/temporalAdapters.d.ts +75 -0
  150. package/dist/components/artifact/temporalAuditHelpers.d.ts +12 -0
  151. package/dist/components/artifact/temporalPresentation.d.ts +8 -0
  152. package/dist/components/artifact/types.d.ts +341 -0
  153. package/dist/components/artifact/validation.d.ts +13 -0
  154. package/dist/components/artifact/validationFieldStatus.d.ts +7 -0
  155. package/dist/components/artifact/validationPrimitives.d.ts +24 -0
  156. package/dist/components/artifact/validationSurfaces.d.ts +7 -0
  157. package/dist/components/artifact/validationTemporal.d.ts +3 -0
  158. package/dist/components/charts/geo/FlowMap.d.ts +7 -0
  159. package/dist/components/charts/geo/flowMapLineStyle.d.ts +18 -0
  160. package/dist/components/charts/ordinal/DonutChart.d.ts +2 -0
  161. package/dist/components/charts/ordinal/FunnelChart.d.ts +2 -0
  162. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +6 -0
  163. package/dist/components/charts/ordinal/PieChart.d.ts +2 -0
  164. package/dist/components/charts/ordinal/RadarChart.d.ts +2 -0
  165. package/dist/components/charts/ordinal/StackedBarChart.d.ts +6 -0
  166. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
  167. package/dist/components/charts/physics/EventDropChart.d.ts +3 -1
  168. package/dist/components/charts/physics/GaltonBoardChart.d.ts +4 -2
  169. package/dist/components/charts/physics/ProcessFlowChart.d.ts +6 -0
  170. package/dist/components/charts/physics/UnitPileChart.d.ts +2 -1
  171. package/dist/components/charts/physics/collisionSwarmPacking.d.ts +14 -0
  172. package/dist/components/charts/physics/collisionSwarmPhysics.d.ts +1 -0
  173. package/dist/components/charts/physics/eventDropAdmission.d.ts +32 -0
  174. package/dist/components/charts/physics/eventDropPhysics.d.ts +22 -1
  175. package/dist/components/charts/physics/galtonBoardPhysics.d.ts +2 -9
  176. package/dist/components/charts/physics/physicsChartReconcile.d.ts +4 -0
  177. package/dist/components/charts/physics/physicsChartUtils.d.ts +1 -1
  178. package/dist/components/charts/physics/physicsGaltonData.d.ts +10 -0
  179. package/dist/components/charts/physics/physicsHocHandle.d.ts +2 -0
  180. package/dist/components/charts/physics/physicsPileData.d.ts +11 -0
  181. package/dist/components/charts/physics/physicsPilePhysics.d.ts +5 -12
  182. package/dist/components/charts/physics/physicsProjectionOverlays.d.ts +1 -1
  183. package/dist/components/charts/physics/physicsSourceRows.d.ts +8 -0
  184. package/dist/components/charts/physics/usePhysicsChartData.d.ts +19 -0
  185. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +4 -0
  186. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +14 -6
  187. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +4 -0
  188. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +4 -0
  189. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +4 -0
  190. package/dist/components/charts/realtime/realtimeAccessors.d.ts +4 -0
  191. package/dist/components/charts/realtime/realtimeChartRuntime.d.ts +8 -7
  192. package/dist/components/charts/realtime/realtimeChartTypes.d.ts +7 -0
  193. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +17 -11
  194. package/dist/components/charts/shared/GaugeReadout.d.ts +9 -0
  195. package/dist/components/charts/shared/ThresholdAnnotation.d.ts +18 -0
  196. package/dist/components/charts/shared/ThresholdEndCap.d.ts +7 -0
  197. package/dist/components/charts/shared/auditAccessibilityText.d.ts +4 -2
  198. package/dist/components/charts/shared/numericTickFormatter.d.ts +2 -0
  199. package/dist/components/charts/shared/radialCenterContent.d.ts +10 -0
  200. package/dist/components/charts/shared/tooltipUtils.d.ts +1 -1
  201. package/dist/components/charts/shared/useChartLegend.d.ts +4 -0
  202. package/dist/components/charts/shared/useXYPointStyle.d.ts +2 -0
  203. package/dist/components/charts/xy/BubbleChart.d.ts +7 -0
  204. package/dist/components/charts/xy/CandlestickChart.d.ts +7 -0
  205. package/dist/components/charts/xy/DifferenceChart.d.ts +7 -0
  206. package/dist/components/charts/xy/MinimapChart.d.ts +7 -0
  207. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +7 -0
  208. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +6 -0
  209. package/dist/components/charts/xy/WaterfallChart.d.ts +8 -0
  210. package/dist/components/charts/xy/differenceMarkStyle.d.ts +28 -0
  211. package/dist/components/charts/xy/multiAxisFields.d.ts +23 -0
  212. package/dist/components/charts/xy/scatterplotMatrixCells.d.ts +50 -0
  213. package/dist/components/evidence/chartEvidenceEnvelope.d.ts +16 -8
  214. package/dist/components/evidence/evidenceEnvelopeInput.d.ts +8 -0
  215. package/dist/components/evidence/evidenceEnvelopeValidation.d.ts +11 -0
  216. package/dist/components/evidence/evidenceGate.d.ts +3 -1
  217. package/dist/components/evidence/renderedSceneHash.d.ts +23 -0
  218. package/dist/components/evidence/stableJsonHash.d.ts +4 -0
  219. package/dist/components/export/chartConfig.d.ts +40 -5
  220. package/dist/components/export/chartConfigArtifact.d.ts +6 -0
  221. package/dist/components/legendLayout.d.ts +18 -0
  222. package/dist/components/legendStyles.d.ts +4 -0
  223. package/dist/components/recipes/firstAvailableTrack.d.ts +17 -0
  224. package/dist/components/recipes/intervals.d.ts +1 -1
  225. package/dist/components/semiotic-ai-core.d.ts +33 -22
  226. package/dist/components/semiotic-ai.d.ts +15 -3
  227. package/dist/components/semiotic-artifact-react.d.ts +10 -0
  228. package/dist/components/semiotic-artifact.d.ts +23 -0
  229. package/dist/components/semiotic-experimental.d.ts +1 -1
  230. package/dist/components/semiotic-physics.d.ts +4 -4
  231. package/dist/components/semiotic-text.d.ts +2 -0
  232. package/dist/components/semiotic-utils-core.d.ts +18 -18
  233. package/dist/components/semiotic.d.ts +3 -3
  234. package/dist/components/server/renderEvidence.d.ts +12 -0
  235. package/dist/components/server/renderToStaticSVG.d.ts +3 -0
  236. package/dist/components/server/staticSVGChrome.d.ts +1 -4
  237. package/dist/components/server/staticXYAxisTicks.d.ts +2 -38
  238. package/dist/components/server/staticXYGrid.d.ts +1 -1
  239. package/dist/components/server/svgSizing.d.ts +6 -0
  240. package/dist/components/shared/svgRoot.d.ts +17 -0
  241. package/dist/components/store/selectionProvenance.d.ts +6 -0
  242. package/dist/components/stream/GeoSVGOverlay.d.ts +4 -0
  243. package/dist/components/stream/NetworkSVGOverlay.d.ts +4 -0
  244. package/dist/components/stream/OrdinalSVGOverlay.d.ts +4 -0
  245. package/dist/components/stream/SVGOverlay.d.ts +4 -0
  246. package/dist/components/stream/SceneToSVG.d.ts +4 -19
  247. package/dist/components/stream/SceneToSVGXY.d.ts +13 -0
  248. package/dist/components/stream/StreamGeoFrame.d.ts +1 -2
  249. package/dist/components/stream/StreamOrdinalFrame.d.ts +1 -2
  250. package/dist/components/stream/XYGrid.d.ts +11 -0
  251. package/dist/components/stream/axisTickUtils.d.ts +0 -1
  252. package/dist/components/stream/hitTestUtils.d.ts +2 -0
  253. package/dist/components/stream/overlayAccessibleText.d.ts +18 -0
  254. package/dist/components/stream/physics/PhysicsControllers.d.ts +1 -1
  255. package/dist/components/stream/physics/PhysicsKernel.d.ts +9 -0
  256. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +5 -4
  257. package/dist/components/stream/physics/PhysicsPipelineTypes.d.ts +9 -0
  258. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +3 -0
  259. package/dist/components/stream/physics/physicsCanvasCoordinates.d.ts +5 -0
  260. package/dist/components/stream/physics/physicsFixedPosition.d.ts +16 -0
  261. package/dist/components/stream/physics/physicsKernelCloning.d.ts +6 -0
  262. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +2 -0
  263. package/dist/components/stream/physics/physicsPipelineSettle.d.ts +15 -9
  264. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +8 -17
  265. package/dist/components/stream/physics/physicsSemanticUI.d.ts +9 -0
  266. package/dist/components/stream/pipelineConfig.d.ts +4 -0
  267. package/dist/components/stream/pipelineStoreUpdateResults.d.ts +1 -1
  268. package/dist/components/stream/resolveXYAxes.d.ts +13 -0
  269. package/dist/components/stream/sceneToSVGShared.d.ts +2 -1
  270. package/dist/components/stream/seriesGeometry.d.ts +13 -0
  271. package/dist/components/stream/streamEncodingTypes.d.ts +53 -0
  272. package/dist/components/stream/types.d.ts +4 -53
  273. package/dist/components/stream/useGeoFrameHandle.d.ts +16 -0
  274. package/dist/components/stream/useOrdinalFrameHandle.d.ts +15 -0
  275. package/dist/components/stream/useXYFrameHandle.d.ts +15 -0
  276. package/dist/components/stream/xyAxisTicks.d.ts +25 -0
  277. package/dist/components/stream/xyDateTicks.d.ts +3 -2
  278. package/dist/components/stream/xyFrameAxisTypes.d.ts +2 -0
  279. package/dist/components/stream/xySceneBuilders/ribbonScene.d.ts +1 -1
  280. package/dist/components/stream/xySceneBuilders/types.d.ts +1 -0
  281. package/dist/components/text/annotationTextLayout.d.ts +28 -0
  282. package/dist/components/text/pretextAnnotationLayout.d.ts +29 -0
  283. package/dist/components/text/usePretextAnnotations.d.ts +12 -0
  284. package/dist/controls.module.min.js +1 -1
  285. package/dist/geo.min.js +1 -1
  286. package/dist/geo.module.min.js +1 -1
  287. package/dist/network.module.min.js +1 -1
  288. package/dist/ordinal.module.min.js +1 -1
  289. package/dist/physics-matter.min.js +1 -1
  290. package/dist/physics-matter.module.min.js +1 -1
  291. package/dist/physics-rapier.min.js +1 -1
  292. package/dist/physics-rapier.module.min.js +1 -1
  293. package/dist/physics.module.min.js +1 -1
  294. package/dist/physicsWorker.js +1 -1
  295. package/dist/processSankeyLayoutWorker.js +1 -1
  296. package/dist/rough.min.js +1 -1
  297. package/dist/rough.module.min.js +1 -1
  298. package/dist/semiotic-access.module.min.js +1 -1
  299. package/dist/semiotic-ai-artifact-policy-constants.module.min.js +2 -0
  300. package/dist/semiotic-ai-core.d.ts +33 -22
  301. package/dist/semiotic-ai-core.min.js +1 -1
  302. package/dist/semiotic-ai-core.module.min.js +1 -1
  303. package/dist/semiotic-ai-hash-primitives.module.min.js +2 -0
  304. package/dist/semiotic-ai.d.ts +15 -3
  305. package/dist/semiotic-ai.module.min.js +1 -1
  306. package/dist/semiotic-artifact-react.d.ts +10 -0
  307. package/dist/semiotic-artifact-react.min.js +2 -0
  308. package/dist/semiotic-artifact-react.module.min.js +2 -0
  309. package/dist/semiotic-artifact.d.ts +23 -0
  310. package/dist/semiotic-artifact.min.js +1 -0
  311. package/dist/semiotic-artifact.module.min.js +1 -0
  312. package/dist/semiotic-client-cjs-shared.min.js +1 -1
  313. package/dist/semiotic-client-glyph.module.min.js +1 -1
  314. package/dist/semiotic-client-responsive.module.min.js +1 -1
  315. package/dist/semiotic-client-shared.module.min.js +1 -1
  316. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +1 -1
  317. package/dist/semiotic-data.min.js +1 -1
  318. package/dist/semiotic-data.module.min.js +1 -1
  319. package/dist/semiotic-evidence.min.js +1 -1
  320. package/dist/semiotic-evidence.module.min.js +1 -1
  321. package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
  322. package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
  323. package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
  324. package/dist/semiotic-experimental-vacp.min.js +1 -1
  325. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  326. package/dist/semiotic-experimental.d.ts +1 -1
  327. package/dist/semiotic-line.module.min.js +1 -1
  328. package/dist/semiotic-physics.d.ts +4 -4
  329. package/dist/semiotic-realtime-core.module.min.js +1 -1
  330. package/dist/semiotic-realtime-react.module.min.js +1 -1
  331. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
  332. package/dist/semiotic-recipes-core.module.min.js +1 -1
  333. package/dist/semiotic-recipes-geo-cjs.min.js +1 -1
  334. package/dist/semiotic-recipes-react.min.js +1 -1
  335. package/dist/semiotic-server-edge-node.module.min.js +1 -1
  336. package/dist/semiotic-server-edge.min.js +1 -1
  337. package/dist/semiotic-server-edge.module.min.js +1 -1
  338. package/dist/semiotic-server-node.min.js +1 -1
  339. package/dist/semiotic-server-node.module.min.js +1 -1
  340. package/dist/semiotic-text.d.ts +2 -0
  341. package/dist/semiotic-text.min.js +2 -0
  342. package/dist/semiotic-text.module.min.js +2 -0
  343. package/dist/semiotic-themes-core.min.js +1 -1
  344. package/dist/semiotic-themes-core.module.min.js +1 -1
  345. package/dist/semiotic-themes.min.js +1 -1
  346. package/dist/semiotic-themes.module.min.js +1 -1
  347. package/dist/semiotic-utils-core.d.ts +18 -18
  348. package/dist/semiotic-utils-core.min.js +1 -1
  349. package/dist/semiotic-utils-core.module.min.js +1 -1
  350. package/dist/semiotic-value.module.min.js +1 -1
  351. package/dist/semiotic.d.ts +3 -3
  352. package/dist/semiotic.module.min.js +1 -1
  353. package/dist/server.min.js +1 -1
  354. package/dist/server.module.min.js +1 -1
  355. package/dist/xy.module.min.js +1 -1
  356. package/package.json +55 -14
  357. package/spec/README.md +8 -3
  358. package/spec/v0.1/artifact-contract.schema.json +2299 -0
  359. package/spec/v0.1/examples/artifact-contract-full.json +369 -0
  360. package/spec/v0.1/examples/artifact-contract-unknown-state.json +46 -0
  361. package/dist/c-3BLJEQNG.min.js +0 -1
  362. package/dist/c-3SCUN5HI.min.js +0 -1
  363. package/dist/c-3VVKFA4M.min.js +0 -1
  364. package/dist/c-43TJZS3F.min.js +0 -1
  365. package/dist/c-4DTZPSUD.min.js +0 -1
  366. package/dist/c-4ES5367Y.min.js +0 -1
  367. package/dist/c-52TEGIUJ.min.js +0 -1
  368. package/dist/c-54IRWOGM.min.js +0 -1
  369. package/dist/c-5D2S4RMI.min.js +0 -1
  370. package/dist/c-5JWCTX3G.min.js +0 -1
  371. package/dist/c-6CMMSN6N.min.js +0 -1
  372. package/dist/c-6HRB2L7H.min.js +0 -1
  373. package/dist/c-6O5EVOPH.min.js +0 -1
  374. package/dist/c-7W4SV36A.min.js +0 -1
  375. package/dist/c-A4WRGZFX.min.js +0 -1
  376. package/dist/c-AG7WWVIH.min.js +0 -1
  377. package/dist/c-AH6J4MTN.min.js +0 -1
  378. package/dist/c-AKAF6JAD.min.js +0 -1
  379. package/dist/c-ALYR5LKK.min.js +0 -1
  380. package/dist/c-BBKITSXB.min.js +0 -1
  381. package/dist/c-BYDPC44I.min.js +0 -1
  382. package/dist/c-CFFIU2MW.min.js +0 -1
  383. package/dist/c-CGNHBHCE.min.js +0 -1
  384. package/dist/c-CJYSXIFV.min.js +0 -1
  385. package/dist/c-CZF7MV67.min.js +0 -1
  386. package/dist/c-D53OKBSY.min.js +0 -1
  387. package/dist/c-DADXPJXV.min.js +0 -1
  388. package/dist/c-DBQ2V7CH.min.js +0 -1
  389. package/dist/c-DPMVAUAW.min.js +0 -1
  390. package/dist/c-ECJCKLYY.min.js +0 -1
  391. package/dist/c-EGATGOWJ.min.js +0 -1
  392. package/dist/c-EGR6VYBW.min.js +0 -1
  393. package/dist/c-ESNR43AN.min.js +0 -1
  394. package/dist/c-F3LIKINL.min.js +0 -1
  395. package/dist/c-F5ZB5GJ6.min.js +0 -1
  396. package/dist/c-G36WS6LN.min.js +0 -1
  397. package/dist/c-G3VYMHKE.min.js +0 -1
  398. package/dist/c-GGISSW5E.min.js +0 -1
  399. package/dist/c-GR6MOEQC.min.js +0 -1
  400. package/dist/c-GSVCN34B.min.js +0 -1
  401. package/dist/c-GYOQCEFP.min.js +0 -1
  402. package/dist/c-H3DNMTCC.min.js +0 -1
  403. package/dist/c-I6J3FEZE.min.js +0 -1
  404. package/dist/c-IGH6MGJ5.min.js +0 -1
  405. package/dist/c-II2EEAJN.min.js +0 -1
  406. package/dist/c-IUHFPMHD.min.js +0 -1
  407. package/dist/c-J6M4JHRS.min.js +0 -1
  408. package/dist/c-JM3MGLQV.min.js +0 -1
  409. package/dist/c-KM3N7F7R.min.js +0 -1
  410. package/dist/c-LF5BZFNC.min.js +0 -1
  411. package/dist/c-LKBSGFQC.min.js +0 -1
  412. package/dist/c-MNF2S4AA.min.js +0 -1
  413. package/dist/c-MT3WBK7M.min.js +0 -1
  414. package/dist/c-NDJADPIF.min.js +0 -1
  415. package/dist/c-NVPQCIL5.min.js +0 -1
  416. package/dist/c-NY3JWV2K.min.js +0 -1
  417. package/dist/c-OFWJBEE5.min.js +0 -1
  418. package/dist/c-OYFHP5F5.min.js +0 -1
  419. package/dist/c-PGKQGGQ2.min.js +0 -1
  420. package/dist/c-PPWDL5ZI.min.js +0 -1
  421. package/dist/c-Q2IPZ3MU.min.js +0 -1
  422. package/dist/c-QKHMBE2E.min.js +0 -1
  423. package/dist/c-QMVM3AY6.min.js +0 -1
  424. package/dist/c-QSGWX53A.min.js +0 -1
  425. package/dist/c-RJKEKZOO.min.js +0 -1
  426. package/dist/c-RSVIHIQ4.min.js +0 -1
  427. package/dist/c-S6U5CGT5.min.js +0 -1
  428. package/dist/c-SFDIIU5G.min.js +0 -1
  429. package/dist/c-SLGMUBUL.min.js +0 -1
  430. package/dist/c-SRTBCRVE.min.js +0 -1
  431. package/dist/c-T6UAIKBH.min.js +0 -1
  432. package/dist/c-TMCTEVVW.min.js +0 -1
  433. package/dist/c-TMOSJLT3.min.js +0 -1
  434. package/dist/c-TZW3JGJ5.min.js +0 -1
  435. package/dist/c-U6ESPM7V.min.js +0 -1
  436. package/dist/c-UC5PTTFI.min.js +0 -1
  437. package/dist/c-USFMFKIH.min.js +0 -1
  438. package/dist/c-VGKUEZBC.min.js +0 -1
  439. package/dist/c-VGW3VG3I.min.js +0 -1
  440. package/dist/c-VN2HG5BS.min.js +0 -1
  441. package/dist/c-VPZDY5Q4.min.js +0 -1
  442. package/dist/c-VRXUB2F2.min.js +0 -1
  443. package/dist/c-VUBQNQJH.min.js +0 -1
  444. package/dist/c-VUH4PGZY.min.js +0 -1
  445. package/dist/c-W3CE4A4S.min.js +0 -1
  446. package/dist/c-X5UBGU2V.min.js +0 -1
  447. package/dist/c-XDRV7RKW.min.js +0 -1
  448. package/dist/c-YGZHURXZ.min.js +0 -1
  449. package/dist/c-YZVRZGX2.min.js +0 -1
  450. /package/dist/{c-N4G2L7ID.min.js → c-HYW2XA4Q.min.js} +0 -0
  451. /package/dist/{c-ENF72HU5.min.js → c-QAVFOEUY.min.js} +0 -0
  452. /package/dist/{c-OCI56QF2.min.js → c-V4XMSLC3.min.js} +0 -0
@@ -1 +0,0 @@
1
- import{ModuleWorkerSession as e,createSharedWorkerSessionHolder as t,errorFromPayload as n,parseModuleWorkerErrorField as o}from"./c-4DTZPSUD.min.js";import{useCustomChartScaffold as r}from"./c-U6ESPM7V.min.js";import{validateNetworkData as i,validateObjectData as a}from"./c-RSVIHIQ4.min.js";import{useFrameImperativeHandle as s,useResolvedSelection as c}from"./c-F5ZB5GJ6.min.js";import{StreamNetworkFrame_default as l,registerLayoutPlugin as u}from"./c-ALYR5LKK.min.js";import{resolveNodeSizeFn as d}from"./c-6HRB2L7H.min.js";import{buildBaseMetadataProps as f,buildCustomBehaviorProps as h,mergeShapeStyle as g}from"./c-AG7WWVIH.min.js";import{resolveLabelFn as m,resolveNodeRefId as p}from"./c-MT3WBK7M.min.js";import{mulberry32 as y}from"./c-N4G2L7ID.min.js";import{commonJsWorkerModuleUrl as b}from"./c-VGW3VG3I.min.js";import{ChartError as v,DEFAULT_SELECTION_OPACITY as k,SafeRender as x,clampLegendReservation as S,composeStyleRules as w,createSeededFrameRandom as M,distinctCategories as P,filterSparseArray as L,makeNodeRuleContext as T,normalizeTooltip as A,renderEmptyState as D,renderLoadingState as I,reserveLegendMargin as E,resolveAxisFreeMarginDefaults as C,resolveDefaultFill as N,resolveMobileInteraction as O,resolveStyleRules as B,useChartLegendAndMargin as $,useChartMode as H,useChartSelection as R,useColorScale as F,useLegendInteraction as W,useThemeCategorical as _,useWasHydratingFromSSR as z}from"./c-VN2HG5BS.min.js";import{getMin as j}from"./c-GGISSW5E.min.js";import{COLOR_SCHEMES as X,DEFAULT_COLORS as Y,DEPTH_PALETTE_COLORS as G,createColorScale as q,getColor as V,resolveCategoricalPalette as K,schemeCategory10 as U}from"./c-EGR6VYBW.min.js";import{isHatchFill as Q}from"./c-QKHMBE2E.min.js";import{useMemo as Z,forwardRef as J,useRef as ee}from"react";import{forceSimulation as te,forceCenter as ne,forceX as oe,forceY as re,forceLink as ie,forceManyBody as ae,forceCollide as se}from"d3-force";var ce=new Set,le=new WeakMap;function ue(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=le.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,le.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ce.has(e)||(ce.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}var de={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r=n.forceStrength??.1,i=o[0]/2,a=o[1]/2,s=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),c=Math.min(.5,.06+1.8*(1-s)),l=n.__previousPositions;let u=0;const f=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=l?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):f.push(t)}const h=u>0&&.3>=(e.length>0?f.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of f){const o=fe(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=he(e.id),i=r%360*(Math.PI/180),a=(10+r%20)*s;e.x=t/o.length+a*Math.cos(i),e.y=n/o.length+a*Math.sin(i)}else{const t=he(e.id),n=t%360*(Math.PI/180),o=(15+t%30)*s;e.x=i+o*Math.cos(n),e.y=a+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5)*s,r=n*t;o.x=i+e*Math.cos(r),o.y=a+e*Math.sin(r)}}}const g=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),m=d(n.nodeSize,n.nodeSizeRange,e),y=e=>m(e);if(g>0){const l=new Map,u=new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t=p(e.source),n=p(e.target);l.set(t,(l.get(t)??0)+1),l.set(n,(l.get(n)??0)+1)}const d=ie().strength(e=>{const t=e.weight,n=p(e.source),o=p(e.target),i=Math.max(1,Math.min(l.get(n)??1,l.get(o)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*i))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,o=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*s);return Math.max(16,40*s,o)}).id(e=>e.id),f=te();if(void 0===n.random&&void 0===n.seed||f.randomSource(n.random??M(n.seed)),f.force("charge",ae().strength(e=>{const t=l.get(e.id)??0;return-15*s*y(e)*Math.sqrt(t+1)})).force("collide",se(e=>y(e)+3*s).strength(.9).iterations(2)).force("center",ne(i,a).strength(.8)).force("x",oe(i).strength(c)).force("y",re(a).strength(c)).force("bounds",function(e,t,n=2,o=.6){let r=[];const i=i=>{const a=o*Math.max(i,.2);for(const o of r){const r=o.x??e[0]/2,i=o.y??e[1]/2,s=o.vx??0,c=o.vy??0,l=t(o)+n,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),f=Math.min(e[1]/2,l),h=Math.max(e[1]/2,e[1]-l),g=r+s,m=i+c;u>g?o.vx=s+(u-g)*a:g>d&&(o.vx=s+(d-g)*a),f>m?o.vy=c+(f-m)*a:m>h&&(o.vy=c+(h-m)*a)}};return i.initialize=e=>{r=e},i}(o,y)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:p(e.source),target:p(e.target)}));d.links(e),f.force("link",d)}h?f.alpha(.3):.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;g>e;++e)f.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=g>0?2:0,r=Math.min(o[0]/2,e+n),i=Math.min(o[1]/2,e+n);t.x=Math.max(r,Math.min(o[0]-r,t.x)),t.y=Math.max(i,Math.min(o[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=b.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=b.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.edgeStyle,a=d(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:U,c=new Map;e.forEach((e,t)=>{c.set(e.id,s[t%s.length])});const l=[],u=[],f=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(ue(t,"nodeSize")),o=r?r(ue(t,"nodeStyle")):{},i={fill:o.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity,cursor:o.cursor};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),o="object"==typeof e.target?e.target:h.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=i?i(ue(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6,cursor:r.cursor},datum:e})}if(!1!==n.showLabels){const t=m(n.nodeLabel);for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=a(ue(n,"nodeSize"));f.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:f}}};function fe(e,t,n){const o=[];for(const r of t){const t=p(r.source),i=p(r.target);let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function he(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}u("force",de);import{useCallback as ge,useMemo as me,useState as pe}from"react";function ye(e){return e.data&&"object"==typeof e.data?e.data:e}function be(e,t,n){if(t)return n?.selectedStyle&&Object.assign(e,n.selectedStyle),e;const o=n?.unselectedOpacity??k;return e.opacity=o,e.fillOpacity=o,e.strokeOpacity=o,n?.unselectedStyle&&Object.assign(e,n.unselectedStyle),e}function ve(e,t,n){if(e)return t?o=>{const r={...e(o)};return t.isActive?be(r,t.predicate(ye(o)),n):r}:e}function ke(e,t,n){if(e)return t?o=>{const r={...e(o)};if(!t.isActive)return r;const i=ye(o),a="object"==typeof o.source?ye(o.source):null,s="object"==typeof o.target?ye(o.target):null;return be(r,a||s?!!a&&t.predicate(a)||!!s&&t.predicate(s):t.predicate(i),n)}:e}function xe(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Se(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function we(e){return"function"==typeof e?e:t=>t[e]||1}function Me({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return a=>{const s={fillOpacity:r,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=V(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=V(e.data||e,t,n):e&&(s.fill=o(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*r);return s}}function Pe(e){const{nodes:t,edges:n,inferNodes:o=!0,sourceAccessor:r="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:u,legendInteraction:d,frameLegend:f,selection:h,linkedHover:g,onObservation:m,onClick:p,mobileInteraction:y,mobileSemantics:b,chartType:v,chartId:k,marginDefaults:x,userMargin:S,width:w,height:M,hasTitle:T,loading:A,loadingContent:E,emptyContent:C,emptyDataKey:N="edges"}=e,B=me(()=>L(n),[n]),H=me(()=>L(t),[t]),z=void 0===t&&void 0===n,[j,X]=pe([]),G=ge(e=>{X(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),V=I(A,w,M,E),U=V?null:D("nodes"===N?void 0===t?void 0:H:void 0===n?void 0:B,w,M,C),Q=me(()=>o?Se(H,B,r,i):H,[o,H,B,r,i]),Z=F(Q,a,s),J=_(),ee=me(()=>Array.isArray(s)&&s.length>0?s:[...K(s,J,Y)],[s,J]),te=me(()=>P(Q,a),[Q,a]),ne=me(()=>z&&j.length>0?j:te,[z,j,te]),oe=me(()=>{if(Z)return Z;if(!a||0===ne.length)return;const e="__streamNetworkCategory";return q(ne.map(t=>({[e]:t})),e,ee)},[Z,a,ne,ee]),re=W(d,a,ne),{legend:ie,margin:ae,legendPosition:se,legendMarginReserved:ce}=$({data:Q,colorBy:a,colorScale:oe,showLegend:l,legendPosition:u,userMargin:S,defaults:x,categories:ne,chartWidth:w,chartHeight:M,frameLegend:f,hasTitle:T}),le=me(()=>{const e={};return ie&&ce&&(e.__legendMarginReservedFor=ie),z&&a&&(e.legendCategoryAccessor=a,e.onCategoriesChange=G),e},[ie,ce,z,a,G]),ue=me(()=>O(y,{width:w,mobileSemantics:b}),[y,w,b]),de=R({selection:h,linkedHover:g,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:m,onClick:p,mobileInteraction:ue,chartType:v,chartId:k}),{customHoverBehavior:fe,customClickBehavior:he,activeSelectionHook:ye,hoverSelectionHook:be,crosshairSourceId:ve}=de,ke=me(()=>be||(re.legendSelectionHook?re.legendSelectionHook:ye),[be,re.legendSelectionHook,ye]),xe=c(h);return{safeNodes:Q,safeEdges:B,colorScale:oe,effectivePalette:ee,themeCategorical:J,allCategories:ne,legendState:re,legend:ie,margin:ae,legendPosition:se,legendBehaviorProps:le,mobileInteraction:ue,customHoverBehavior:fe,customClickBehavior:he,activeSelectionHook:ye,hoverSelectionHook:be,effectiveSelectionHook:ke,resolvedSelection:xe,crosshairSourceId:ve,loadingEl:V,emptyEl:U}}import{jsx as Le}from"react/jsx-runtime";u("force",de);var Te=J(function(e,t){const n=ee(null);s(t,{variant:"network",frameRef:n});const o=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:r,edges:a,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:f,sourceAccessor:m="source",targetAccessor:p="target",nodeLabel:y,colorBy:b,colorScheme:k,styleRules:S,nodeSize:M=8,nodeSizeRange:P=[5,20],nodeStroke:L,nodeStrokeWidth:D,edgeWidth:I,edgeColor:E,edgeOpacity:C,iterations:O=300,forceStrength:B=.1,layoutExecution:$="auto",layoutLoadingContent:R,onLayoutStateChange:F,tooltip:W,frameProps:_={},onObservation:z,onClick:j,chartId:X,selection:Y,linkedHover:G,loading:q,loadingContent:K,emptyContent:U,legendInteraction:Q,legendPosition:J,stroke:te,strokeWidth:ne,opacity:oe}=e,re=d??f??"id",{width:ie,height:ae,enableHover:se,showLegend:ce,showLabels:le=!1,title:ue,description:de,summary:fe,accessibleTable:he}=o,ge=Pe({nodes:r,edges:a,inferNodes:!1,nodeIdAccessor:re,sourceAccessor:m,targetAccessor:p,colorBy:b,colorScheme:k,showLegend:ce,legendPosition:J,legendInteraction:Q,frameLegend:_,selection:Y,linkedHover:G,onObservation:z,onClick:j,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ForceDirectedGraph",chartId:X,marginDefaults:o.marginDefaults,userMargin:c,width:ie,height:ae,hasTitle:!!ue,loading:q,loadingContent:K,emptyContent:U,emptyDataKey:"nodes"}),me=Z(()=>new Map,[]),pe=Z(()=>e=>{const t={};return t.fill=b?V(e.data||e,b,ge.colorScale):N(void 0,ge.themeCategorical,k,void 0,me),"number"==typeof M&&(t.r=M),t},[b,ge.colorScale,M,ge.themeCategorical,k,me]),ye=Z(()=>T(b,"number"==typeof M?void 0:M),[b,M]),be=Z(()=>g(w(pe,S,ye,e=>e.data||e),{stroke:L??te,strokeWidth:D??ne,opacity:oe}),[pe,S,ye,L,te,D,ne,oe]),xe=Z(()=>ve(be,ge.effectiveSelectionHook,ge.resolvedSelection),[be,ge.effectiveSelectionHook,ge.resolvedSelection]),Se=E??te??"#999",we=C??oe??.6,Me=ne??1,Te=Z(()=>e=>{const t=e.data||e;let n;if(void 0===I)n=Me;else if("number"==typeof I)n=I;else if("function"==typeof I)n=I(t);else{const e=t[I],o="number"==typeof e?e:Number(e);n=Number.isFinite(o)&&o>0?o:Me}return{stroke:Se,strokeWidth:n,opacity:we}},[I,Se,we,Me]),Ae=Z(()=>ke(Te,ge.effectiveSelectionHook,ge.resolvedSelection),[Te,ge.effectiveSelectionHook,ge.resolvedSelection]),De=Z(()=>{if(le&&y)return"function"==typeof y?y:e=>e.data?.[y]??e[y]??e.id},[le,y]),Ie=i({componentName:"ForceDirectedGraph",nodes:r,edges:a,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:re}});return Ie?Le(v,{componentName:"ForceDirectedGraph",message:Ie,width:ie,height:ae}):ge.loadingEl?ge.loadingEl:ge.emptyEl?ge.emptyEl:Le(x,{componentName:"ForceDirectedGraph",width:ie,height:ae,children:Le(l,{ref:n,chartType:"force",...null!=r&&{nodes:ge.safeNodes},...null!=a&&{edges:ge.safeEdges},size:[ie,ae],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ge.margin,...ge.legendBehaviorProps,nodeIDAccessor:re,sourceAccessor:m,targetAccessor:p,iterations:O,forceStrength:B,layoutExecution:$,layoutLoadingContent:R,onLayoutStateChange:F,nodeStyle:xe,edgeStyle:Ae,colorBy:b,colorScheme:ge.effectivePalette,nodeSize:M,nodeSizeRange:P,nodeLabel:De,showLabels:le,enableHover:se,tooltipContent:!1===W?()=>null:A(W)||void 0,...h({linkedHover:G,selection:Y,onObservation:z,onClick:j,mobileInteraction:ge.mobileInteraction,customHoverBehavior:ge.customHoverBehavior,customClickBehavior:ge.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ge.legend,legendPosition:ge.legendPosition,...Q&&"none"!==Q&&{legendHoverBehavior:ge.legendState.onLegendHover,legendClickBehavior:ge.legendState.onLegendClick,legendHighlightedCategory:ge.legendState.highlightedCategory,legendIsolatedCategories:ge.legendState.isolatedCategories},className:u,title:ue,description:de,summary:fe,accessibleTable:he,...null!=e.animate&&{animate:e.animate},..._})})});Te.displayName="ForceDirectedGraph";import{useMemo as Ae,forwardRef as De,useRef as Ie}from"react";import{chord as Ee,ribbon as Ce}from"d3-chord";import{arc as Ne}from"d3-shape";var Oe=U,Be={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(o[0],o[1])/2,c=s-i,l=o[0]/2,u=o[1]/2,d=(f=n.valueAccessor)?"function"==typeof f?f:e=>e[f]??1:e=>e.value??1;var f;const h=new Map;for(let t=0;e.length>t;t++)h.set(e[t].id,t);const g=e.length,m=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t=p(e.source),n=p(e.target),o=h.get(t),r=h.get(n);if(void 0===o||void 0===r)continue;const i=d(e);m[o][r]=i}const y=Ee().padAngle(r);a&&y.sortGroups(a);const b=y(m),v=b.groups,k=Ne().innerRadius(c).outerRadius(s);for(const t of v){const n=e[t.index],o=k.centroid({innerRadius:c,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+l,n.y=o[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t=p(e.source),n=p(e.target),o=x.get(t),r=x.get(n);o&&(e.source=o),r&&(e.target=r)}const S=new Map;for(const e of t){const t=p(e.source),n=p(e.target);S.set(`${t}\0${n}`,e)}for(const t of b){const n=e[t.source.index].id,o=e[t.target.index].id,r=S.get(`${n}\0${o}`)||S.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){const{groupWidth:r=20,edgeOpacity:i=.5}=n,a=Math.min(o[0],o[1])/2,s=a-r,c=o[0]/2,l=o[1]/2,u=n.nodeStyle,d=n.edgeStyle,f=n.edgeColorBy||"source",h=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Oe,g=new Map;e.forEach((e,t)=>{g.set(e.id,h[t%h.length])});const p=Ce().radius(s),y=[],b=[],v=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let r;if(u){const e=u(ue(n,"nodeStyle"));r=("string"==typeof e.fill?e.fill:void 0)||g.get(n.id)||h[t%h.length]}else r=g.get(n.id)||h[t%h.length];const i=u?u(ue(n,"nodeStyle")):{};y.push({type:"arc",cx:c,cy:l,innerR:s,outerR:a,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:r,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity,cursor:i.cursor},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=p(t);if(!o)continue;const r=$e(o,c,l);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d){const t=d(ue(e,"edgeStyle"));a=("string"==typeof t.fill?t.fill:void 0)||a}else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===f&&n?a=g.get(n.id)||a:t&&(a=g.get(t.id)||a)}const s=d?d(ue(e,"edgeStyle")):{};b.push({type:"ribbon",pathD:r,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity,cursor:s.cursor},datum:e})}if(!1!==n.showLabels){const t=m(n.nodeLabel),o=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;v.push({x:c+Math.cos(a)*o,y:l+Math.sin(a)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:y,sceneEdges:b,labels:v}}};function $e(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}u("chord",Be);import{jsx as He}from"react/jsx-runtime";u("chord",Be);var Re=De(function(e,t){const n=Ie(null);s(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:r,edges:a,margin:c,className:u,sourceAccessor:d="source",targetAccessor:f="target",valueAccessor:m="value",nodeIdAccessor:p="id",colorBy:y,colorScheme:b,styleRules:k,edgeColorBy:S="source",padAngle:M=.01,groupWidth:P=20,sortGroups:L,nodeLabel:D,edgeOpacity:I=.5,tooltip:E,frameProps:C={},onObservation:O,onClick:B,chartId:$,selection:R,linkedHover:F,loading:W,loadingContent:_,emptyContent:z,legendPosition:j,legendInteraction:G,stroke:q,strokeWidth:K,opacity:U}=e,{width:Q,height:Z,enableHover:J,showLegend:ee,showLabels:te=!0,title:ne,description:oe,summary:re,accessibleTable:ie}=o,ae=Pe({nodes:r,edges:a,inferNodes:!0,nodeIdAccessor:p,sourceAccessor:d,targetAccessor:f,colorBy:y,colorScheme:b,showLegend:ee,legendPosition:j,legendInteraction:G,frameLegend:C,selection:R,linkedHover:F,onObservation:O,onClick:B,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"ChordDiagram",chartId:$,marginDefaults:o.marginDefaults,userMargin:c,width:Q,height:Z,hasTitle:!!ne,loading:W,loadingContent:_,emptyContent:z}),se=Ae(()=>new Map,[]),ce=Ae(()=>new Map,[]),le=ae.safeNodes.length>0||ae.allCategories.length>0,ue=Ae(()=>{if(le)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(y)n.fill=V(e.data||e,y,ae.colorScale);else{const o=Array.isArray(b)?b:X[b]||Y,r=Array.isArray(o)?o:Y,i=(e.id??e.data?.[p]??"")+"";ce.has(i)||ce.set(i,ce.size);const a=e.index??t??ce.get(i);n.fill=r[a%r.length]}return n}},[le,y,ae.colorScale,b,p,ce]),de=Ae(()=>T(y),[y]),fe=Ae(()=>{if(ue||k&&k.length>0)return g(w(ue,k,de,e=>e.data||e),{stroke:q,strokeWidth:K,opacity:U})},[ue,k,de,q,K,U]),he=Ae(()=>ve(fe,ae.effectiveSelectionHook,ae.resolvedSelection),[fe,ae.effectiveSelectionHook,ae.resolvedSelection]),ge=Ae(()=>{if(le)return Me({edgeColorBy:S,colorBy:y,colorScale:ae.colorScale,nodeStyleFn:he||(e=>({fill:N(void 0,ae.themeCategorical,b,void 0,se)})),edgeOpacity:I,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:I}})},[le,S,y,ae.colorScale,he,I,ae.themeCategorical,b,se]),me=Ae(()=>ge?g(ge,{stroke:q,strokeWidth:K,opacity:U}):void 0,[ge,q,K,U]),pe=Ae(()=>ke(me,ae.effectiveSelectionHook,ae.resolvedSelection),[me,ae.effectiveSelectionHook,ae.resolvedSelection]),ye=Ae(()=>{if(!te)return;const e=D||p;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[te,D,p]),be=i({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return be?He(v,{componentName:"ChordDiagram",message:be,width:Q,height:Z}):ae.loadingEl?ae.loadingEl:ae.emptyEl?ae.emptyEl:He(x,{componentName:"ChordDiagram",width:Q,height:Z,children:He(l,{ref:n,chartType:"chord",...ae.safeNodes.length>0&&{nodes:ae.safeNodes},...null!=a&&{edges:ae.safeEdges},size:[Q,Z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ae.margin,...ae.legendBehaviorProps,nodeIDAccessor:p,sourceAccessor:d,targetAccessor:f,valueAccessor:m,padAngle:M,groupWidth:P,sortGroups:L,nodeStyle:he,edgeStyle:pe,colorBy:y,colorScheme:ae.effectivePalette,edgeColorBy:S,edgeOpacity:I,nodeLabel:ye,showLabels:te,enableHover:J,tooltipContent:!1===E?()=>null:A(E)||void 0,...h({linkedHover:F,selection:R,onObservation:O,onClick:B,mobileInteraction:ae.mobileInteraction,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ae.legend,legendPosition:ae.legendPosition,...G&&"none"!==G&&{legendHoverBehavior:ae.legendState.onLegendHover,legendClickBehavior:ae.legendState.onLegendClick,legendHighlightedCategory:ae.legendState.highlightedCategory,legendIsolatedCategories:ae.legendState.isolatedCategories},className:u,title:ne,description:oe,summary:re,accessibleTable:ie,...null!=e.animate&&{animate:e.animate},...C})})});Re.displayName="ChordDiagram";import{useMemo as Fe,forwardRef as We,useRef as _e}from"react";function ze(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function je(e,t){var n,o=[],r=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;s[e].length>t;t++)(o=s[e][t])===n?(u(n,r),d=!0):i[o]||(d=l(o));if(d)c(e);else for(t=0;s[e].length>t;t++){var f=a[o=s[e][t]];f||(a[o]=f={}),f[o]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):o.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)n[c]=-1,o[c]=0,r[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],f=[];function h(t){var c=[t],l=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;l.length>0;){var h=e[t=l[l.length-1]];if(h.length>i[t]){for(var g=i[t];h.length>g;++g){var m=h[g];if(0>n[m]){n[m]=o[m]=u,r[m]=!0,u+=1,c.push(m),l.push(m);break}r[m]&&(o[t]=0|Math.min(o[t],o[m])),0>a[m]||s[t].push(a[m])}i[t]=g}else{if(o[t]===n[t]){var p=[],y=[],b=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),y.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){c.length=g;break}}d.push(p);var k=Array(b);for(g=0;y.length>g;g++)for(var x=0;y[g].length>x;x++)k[--b]=y[g][x];f.push(k)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&h(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(e,t){return e-t}),l=[g[0]];for(var m=1;g.length>m;m++)g[m]!==g[m-1]&&l.push(g[m]);f[c]=l}}return{components:d,adjacencyList:f}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,a=0;r.length>a;a++)for(var s=0;r[a].length>s;s++)i>r[a][s]&&(i=r[a][s],n=a);var c=r[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var f=e.length;f>n;){var h=d(n);if(n=h.leastVertex,s=h.adjList){for(var g=0;s.length>g;g++)for(var m=0;s[g].length>m;m++){var p=s[g][m];i[+p]=!1,a[p]={}}l(n),n+=1}else n=f}return t?void 0:o}function Xe(e){return e.y0-e.y1>0?"up":"down"}function Ye(e,t){return t(e.source)==t(e.target)}function Ge(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function qe(e){return e.target.x0-e.source.x1}function Ve(e,t){var n=Ue(e),o=qe(t)/Math.tan(n);return"up"==Xe(e)?e.y1-o:e.y1+o}function Ke(e,t){var n=Ue(e),o=qe(t)/Math.tan(n);return"up"==Xe(e)?e.y1+o:e.y1-o}function Ue(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Qe(e,t){return t(e)}function Ze(e){return et(e.source)}function Je(e){return et(e.target)}function et(e){return(e.y0+e.y1)/2}function tt(e){return e.virtual?0:e.value}function nt(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Ye(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Ye(e,t)?o+1:o}),n+o}function ot(e){return e.target.depth}function rt(e,t){return e.sourceLinks.length?e.depth:t-1}function it(e,t){return e.y0-t.y0}function at(e,t){return t.y0-e.y0}function st(e,t){return e.y1-t.y1}function ct(e,t){return t.y1-e.y1}function lt(e,t){return dt(e.source,t.source)||e.index-t.index}function ut(e,t){return dt(e.target,t.target)||e.index-t.index}function dt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ft(e,t){return ht(e)==ht(t)?"bottom"==e.circularLinkType?at(e,t):it(e,t):ht(t)-ht(e)}function ht(e){return e.target.column-e.source.column}function gt(e,t){return mt(e)==mt(t)}function mt(e){return e.y0-e.y1>0?"up":"down"}import{min as pt}from"d3-array";function yt(e,t,n,o,r){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=pt(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}),bt(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),bt(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Ye(e,t)&&Ge(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?at:it);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(l=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?ct:st),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function bt(e,t,n){e.sort(ft);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Ye(e,t)&&Ge(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;o.length>a;a++){var s=o[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&vt(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function vt(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as kt,max as xt,sum as St,mean as wt,group as Mt,groups as Pt}from"d3-array";function Lt(e){return function(){return e}}function Tt(e){return e.index}function At(e){return e.nodes}function Dt(e){return e.links}function It(e,t,n){var o=Pt(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var a=r.length;if(t)r.sort(t);else if(i>0){var s=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=et(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=et(e.target)*t,o+=t}}),o>0?r/o:NaN);s.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=s.get(e),o=s.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?nt(t,n)-nt(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==nt(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+r,t.y1=t.y0+t.value*e.ky)})})}function Et(e,t,n,o,r,i){var a=Pt(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,c=i;c>0;--c)l(s*=.99,n),u();function l(t,n){var o=a.length;a.forEach(function(r){var i=r.length,a=r[0].depth;r.forEach(function(r){var s;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&nt(r,n)>0){var c=wt(r.sourceLinks,Je),l=wt(r.targetLinks,Ze),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-et(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(a==o-1&&1==i)r.y0=e.y1/2-(s=r.y1-r.y0)/2,r.y1=e.y1/2+s/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)s=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+s;else{var f=wt(r.sourceLinks,Je),h=wt(r.targetLinks,Ze),g=((f&&h?(f+h)/2:f||h)-et(r))*t;r.y0+=g,r.y1+=g}})})}function u(){a.forEach(function(n){var i,a,s,c=e.y0,l=n.length;for(n.sort(t||dt),s=0;l>s;++s)(a=c-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+o;if((a=c-o-e.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=n[s]).y1+r-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function Ct(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ut),e.targetLinks.sort(lt)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Nt(){var e=0,t=0,n=1,o=1,r=24,i=8,a=null,s=Tt,c=rt,l=void 0,u=32,d=2,f=At,h=Dt;function g(){var g={nodes:f.apply(null,arguments),links:h.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return Mt(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=ze(n,o)),"object"!=typeof r&&(r=e.target=ze(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(f,s),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],a=i.source.index,s=i.target.index;o[a]||(o[a]=[]),o[s]||(o[s]=[]),-1===o[a].indexOf(s)&&o[a].push(s)}var c=je(o);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||l[o]&&l[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,l),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Qe(e,t)!=Qe(r.source,t)&&Qe(e,t)!=Qe(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Ye(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(St(e.sourceLinks,tt),St(e.targetLinks,tt)),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)})})}(f),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(f,l,c);var h=i;if(null!==a){var g=Pt(f.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),m=xt(g,function(e){return e.length});m>1&&(h=Math.max(1,(o-t)*a/(m-1)))}(function(e,t,n){var o=Pt(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=kt(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/St(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=xt(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,h,r),It(f,l,s),Et(f,l,s,h,h,u),Ct(f),yt(f,s,d,10,8),It(f,l,s),Et(f,l,s,h,h,u),Ct(f),yt(f,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Qe(n.source,t)==Qe(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!gt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Ve(t,e);return e.y1-n}if(t.target.column>e.target.column)return Ve(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y0=e.y1-a-t.width/2}})})}(f,s),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Qe(n.target,t)==Qe(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!gt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Ke(t,e);return e.y0-n}if(t.source.column>e.source.column)return Ke(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;r>i;i++)a+=o[i].width;t.y1=e.y1-a-t.width/2}})})}(f,s),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){let o=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=kt(t,function(e){return e.y0}),a=xt(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1)}),n.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=o(e.y0)-e.y0;e.y0=o(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(f),yt(f,s,d,10,8)}(g),g}return g.update=function(e){return Ct(e),yt(e,s,d,10,8),e},g.nodeWidth=function(e){return arguments.length?(r=+e,g):r},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(f="function"==typeof e?e:Lt(e),g):f},g.links=function(e){return arguments.length?(h="function"==typeof e?e:Lt(e),g):h},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Lt(e),g):s},g.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Lt(e),g):c},g.nodeSort=function(e){return arguments.length?(l=e,g):l},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],g):[[e,t],[n,o]]},g.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],g):[n-e,o-t]},g}import{interpolateNumber as Ot}from"d3-interpolate";import{line as Bt,curveLinearClosed as $t}from"d3-shape";function Ht(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:a,cp1X:s,cp2X:c}=e,l=(n+o)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${c},${i} ${r},${i}`,`L${r},${a}`,`C${c},${a} ${s},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:s,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}var Rt=e=>{let t,n,o,r,i,a,s,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=Ot(i,a),c=s(.5),l=s(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${a}L${o},${a}C${o},${l} ${r},${c} ${r},${i}Z`;const u=e.sankeyWidth/2,d=Ot(e.source.x1,e.target.x0),{pathD:f}=Ht({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 f};function Ft(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const n=o.sourceX,r=o.sourceY,i=o.targetX,a=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(o.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${n},${r-t}L${n+s},${r-t}L${n+s},${r+t}L${n},${r+t}ZM${i},${a-t}L${i-c},${a-t}L${i-c},${a+t}L${i},${a+t}Z`}const r=o.sourceX,i=o.sourceY,a=o.targetX,s=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,f=Math.max(4,Math.min(n,15));return`M${r},${i-d*t}L${c},${i-d*t}L${c+n},${i-d*t+d*f}L${c+n},${u+d*n-d*f}L${c+n-f},${u+d*n}L${l-n+f},${u+d*n}L${l-n},${u+d*n-d*f}L${l-n},${s-d*t+d*f}L${l-n+f},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${l+n},${s+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${i+d*t}L${r},${i+d*t}Z`}var Wt={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(ot))-1:0},justify:rt},_t={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:p(e.source),target:p(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const f=Nt().extent(d).links(u).nodes(l).nodeAlign(Wt[i]||rt).nodeId(e=>e.id).nodeWidth(a).iterations(c);f.nodePaddingRatio&&f.nodePaddingRatio(s),f();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of l)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,a=(o._circularWidth??o.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>r&&(r=i.verticalFullExtent+a)}const i=t-e,a=r-n,s=o[0],c=o[1];if(i>0&&a>0&&(0>e||0>n||t>s||r>c)){const t=Math.min(s/i,c/a),o=-e*t+(s-i*t)/2,r=-n*t+(c-a*t)/2;for(const e of l)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of l){const t=h.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const g=new Map;for(const e of t)if(e._edgeKey)g.set(e._edgeKey,e);else{const t=p(e.source),n=p(e.target);g.set(`${t}\0${n}`,e)}for(const e of u){const t=p(e.source),n=p(e.target),o=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=e.width??0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=r;const i=h.get(t),a=h.get(n);i&&(o.source=i),a&&(o.target=a)}}},buildScene(e,t,n,o){const r="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:U,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],f=[],h=[],g=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=i?i(ue(t,"nodeStyle")):{},a={fill:o.fill||u.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity,cursor:o.cursor};g.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:a,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?g.get(o.id)||u.get(o.id)||r:g.get(t.id)||u.get(t.id)||r;const i=a?a(ue(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||r;f.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity,cursor:i.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),f.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity,cursor:i.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Ft(e):Rt(e),l)&&f.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||r,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity,cursor:i.cursor},datum:e})}if(!1!==n.showLabels){const t=m(n.nodeLabel);for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,c,l;"down"===r?(s=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),c=n.y0+i/2),h.push({x:s,y:c,text:a+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:f,labels:h}}};u("sankey",_t);import{jsx as zt}from"react/jsx-runtime";u("sankey",_t);var jt=We(function(e,t){const n=_e(null);s(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const o=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:r,edges:a,margin:c,className:u,sourceAccessor:d="source",targetAccessor:f="target",valueAccessor:m="value",nodeIdAccessor:p="id",colorBy:y,colorScheme:b,styleRules:k,edgeColorBy:S="source",orientation:M="horizontal",nodeAlign:P="justify",nodePaddingRatio:L=.05,nodeWidth:D=15,nodeLabel:I,edgeOpacity:E=.5,edgeSort:C,tooltip:O,frameProps:B={},onObservation:$,onClick:R,chartId:F,selection:W,linkedHover:_,loading:z,loadingContent:j,emptyContent:X,showLegend:Y,legendPosition:G,legendInteraction:q,stroke:K,strokeWidth:U,opacity:Q}=e,{width:Z,height:J,enableHover:ee,showLabels:te=!0,title:ne,description:oe,summary:re,accessibleTable:ie}=o,ae=Pe({nodes:r,edges:a,inferNodes:!0,nodeIdAccessor:p,sourceAccessor:d,targetAccessor:f,colorBy:y,colorScheme:b,showLegend:Y,legendPosition:G,legendInteraction:q,frameLegend:B,selection:W,linkedHover:_,onObservation:$,onClick:R,mobileInteraction:o.mobileInteraction,mobileSemantics:o.mobileSemantics,chartType:"SankeyDiagram",chartId:F,marginDefaults:o.marginDefaults,userMargin:c,width:Z,height:J,hasTitle:!!ne,loading:z,loadingContent:j,emptyContent:X}),se=Fe(()=>new Map,[]),ce=Fe(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=y?V(e.data||e,y,ae.colorScale):N(void 0,ae.themeCategorical,b,void 0,se),t},[y,ae.colorScale,ae.themeCategorical,b,se]),le=Fe(()=>T(y,m),[y,m]),ue=Fe(()=>g(w(ce,k,le,e=>e.data||e),{stroke:K,strokeWidth:U,opacity:Q}),[ce,k,le,K,U,Q]),de=Fe(()=>ve(ue,ae.effectiveSelectionHook,ae.resolvedSelection),[ue,ae.effectiveSelectionHook,ae.resolvedSelection]),fe=Fe(()=>Me({edgeColorBy:S,colorBy:y,colorScale:ae.colorScale,nodeStyleFn:de,edgeOpacity:E,baseStyle:{stroke:"none",strokeWidth:0}}),[S,y,ae.colorScale,de,E]),he=Fe(()=>g(fe,{stroke:K,strokeWidth:U,opacity:Q}),[fe,K,U,Q]),ge=Fe(()=>ke(he,ae.effectiveSelectionHook,ae.resolvedSelection),[he,ae.effectiveSelectionHook,ae.resolvedSelection]),me=Fe(()=>{if(!te)return;const e=I||p;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[te,I,p]),pe=i({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return pe?zt(v,{componentName:"SankeyDiagram",message:pe,width:Z,height:J}):ae.loadingEl?ae.loadingEl:ae.emptyEl?ae.emptyEl:zt(x,{componentName:"SankeyDiagram",width:Z,height:J,children:zt(l,{ref:n,chartType:"sankey",...ae.safeNodes.length>0&&{nodes:ae.safeNodes},...null!=a&&{edges:ae.safeEdges},size:[Z,J],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ae.margin,...ae.legendBehaviorProps,nodeIDAccessor:p,sourceAccessor:d,targetAccessor:f,valueAccessor:m,orientation:M,nodeAlign:P,nodePaddingRatio:L,nodeWidth:D,nodeStyle:de,edgeStyle:ge,colorBy:y,colorScheme:ae.effectivePalette,edgeColorBy:S,edgeOpacity:E,edgeSort:C,nodeLabel:me,showLabels:te,enableHover:ee,tooltipContent:!1===O?()=>null:A(O)||void 0,...h({linkedHover:_,selection:W,onObservation:$,onClick:R,mobileInteraction:ae.mobileInteraction,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ae.legend,legendPosition:ae.legendPosition,...q&&"none"!==q&&{legendHoverBehavior:ae.legendState.onLegendHover,legendClickBehavior:ae.legendState.onLegendClick,legendHighlightedCategory:ae.legendState.highlightedCategory,legendIsolatedCategories:ae.legendState.isolatedCategories},className:u,title:ne,description:oe,summary:re,accessibleTable:ie,...null!=e.animate&&{animate:e.animate},...B})})});jt.displayName="SankeyDiagram";var Xt={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}};function Yt(e="static"){return Xt[e]??Xt.static}var Gt=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]);function qt(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Gt.has(e.kind)?"fatal":"warn"}function Vt(e,t,n,o={}){const r=Yt(o.usageMode??"static"),i=[],a=new Set;for(const t of e)a.has(t.id)&&i.push({kind:"duplicate-node",id:t.id,severity:r.duplicateIds}),a.add(t.id);const s=new Set,c=Array.isArray(n)&&2===n.length,l=c&&Number.isFinite(n[0])&&Number.isFinite(n[1]);c&&l&&l&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.id)&&i.push({kind:"duplicate-edge",id:e.id,severity:r.duplicateIds}),s.add(e.id),a.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&i.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&i.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}function Kt(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Ut(e){if(!e?.layoutQuality)return[];const t=[],n=e.layoutQuality,o=e.layoutQualityBefore;e.compressedPadding&&t.push({severity:"warning",code:"PROCESS_SANKEY_COMPRESSED_PADDING",message:"Lane gaps were compressed to fit peaks into the plot height.",fix:'Increase height, lower maxValueScale, use packing="reuse", or reduce concurrent peaks.'}),8>n.transitOcclusion||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_TRANSIT",message:`High transit occlusion (${n.transitOcclusion.toFixed(1)}) — ribbons cross dense intermediate lanes.`,fix:'Try laneOrder="crossing-min+inside-out", packing="reuse", or lanePlacement="hug" with a modest maxValueScale.'}),.92>n.verticalUtilization||t.push({severity:"warning",code:"PROCESS_SANKEY_HIGH_UTILIZATION",message:`Lane utilization is ${Math.round(100*n.verticalUtilization)}% of plot height.`,fix:"Increase chart height or cap band scale with maxValueScale."});const r=e.crossingsAfter??n.crossings;return null==r||3>r||t.push({severity:"warning",code:"PROCESS_SANKEY_RESIDUAL_CROSSINGS",message:`Ordering left ${r} edge-pair crossings`+(o?` (from ${o.crossings})`:"")+".",fix:'Prefer laneOrder="crossing-min" or "crossing-min+inside-out"; check for unavoidable fan-outs.'}),t}function Qt(e){if(!e?.layoutQuality)return null;const t=e.layoutQuality,n=e.layoutQualityBefore,o=e.crossingsAfter??t.crossings;return[`ProcessSankey layout uses ${e.slots?.length??"?"} packed lane(s).`,null!=o?`Edge-pair crossings ${n?n.crossings+" → ":""}${o}.`:null,`Pixel path length ${n?Math.round(n.pixelLength)+" → ":""}${Math.round(t.pixelLength)}.`,`Transit occlusion ${n?n.transitOcclusion.toFixed(1)+" → ":""}${t.transitOcclusion.toFixed(1)}.`,`Lane utilization ${Math.round(100*t.verticalUtilization)}%.`,e.compressedPadding?"Lane gaps were compressed to fit the plot.":null].filter(Boolean).join(" ")}function Zt(e){const t=[],n=e.domain;null==n?t.push({severity:"error",code:"PROCESS_SANKEY_MISSING_DOMAIN",message:"ProcessSankey requires domain: [tStart, tEnd].",fix:"Pass domain={[start, end]} as numbers or Date-compatible values."}):Array.isArray(n)&&2===n.length&&Number.isFinite(Number(n[0]))&&Number.isFinite(Number(n[1]))||t.push({severity:"error",code:"PROCESS_SANKEY_BAD_DOMAIN",message:"domain must be a 2-tuple of finite times.",fix:"Use domain={[t0, t1]} with t0 <= t1."});const o=e.edges;if(Array.isArray(o)&&o.length>0){const e=o[0];null!=e.startTime&&null!=e.endTime||t.push({severity:"warning",code:"PROCESS_SANKEY_EDGE_TIMES",message:"Edges should carry startTime and endTime for temporal layout.",fix:"Add startTime/endTime fields or set startTimeAccessor/endTimeAccessor."})}const r=e.nodes,i=Array.isArray(r)?r.length:0;return!0!==e.showLabels||24>i||t.push({severity:"warning",code:"PROCESS_SANKEY_LABEL_DENSITY",message:`showLabels={true} with ${i} nodes may overcrowd the plot.`,fix:'Use showLabels="auto" with optional labelPriorityAccessor / maxLabels.'}),80>(Array.isArray(o)?o.length:0)||null!=e.layoutExecution||"off"===e.packing||t.push({severity:"warning",code:"PROCESS_SANKEY_WORKER_HINT",message:"Dense ProcessSankey layouts benefit from worker packing/order.",fix:'layoutExecution defaults to "auto"; set layoutExecution="worker" or raise layoutWorkerThreshold deliberately.'}),t}function Jt(e,t,n,o={}){const r=!1!==o.inferOpeningStock,i=[];for(const t of n){const n=Number(t.value);if(!Number.isFinite(n))continue;const o=Number(t.endTime);t.target===e&&Number.isFinite(o)&&i.push({time:o,delta:n});const r=Number(t.startTime);if(t.source===e&&Number.isFinite(r)&&i.push({time:r,delta:-n}),t.target===e&&null!=t.systemOutTime){const e=Number(t.systemOutTime);Number.isFinite(e)&&i.push({time:e,delta:-n})}}i.sort((e,t)=>e.time-t.time||t.delta-e.delta);let a=0,s=0,c=0;for(const e of i)a+=e.delta,s=Math.min(s,a),e.time>t||(c+=e.delta);return r?c-s:c}function en(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function tn(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const a=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(a.push({start:e,end:e,weight:n,mean:r});a.length>1;){const e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const s=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=s>c?s:c,u=Array(r);for(const e of a){const t=Math.max(s,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function nn(e,t){let n=0,o=e.length-1,r=-1;for(;o>=n;){const i=n+o>>>1;e[i].at>t?o=i-1:(r=i,n=i+1)}return 0>r?{at:t,before:0,after:0}:e[r]}function on(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],a=e[r+1],s=[...new Set([...i.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of s){const t=nn(i,e),n=nn(a,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function rn(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],a=n(r),s=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>s;e++){const e=new Map(r.map((e,t)=>[e,t])),c=new Map,l=new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(s++,a>u)a=u,i=[...r];else if(u===a)break}return i}function an(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let a=0,s=[...o],c=1/0;const l=()=>{if(a>=i)return;const e=t(o);a++,c>e&&(c=e,s=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>a;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return s}function sn(){return Object.create(null)}function cn(e,t){return t>e?-1:e>t?1:0}function ln(e){return e.occupants.map(e=>e.id).sort(cn).join("\0")}function un(e,t,n=0){return e.slice(0,-1).map((o,r)=>null!=o.group&&o.group===e[r+1].group?n:t)}function dn(e,t){return e.map(e=>{const n=new Map;for(const o of e.occupants){const e=t[o.id];if(e)for(const t of e.samples){const e=n.get(t.t)??{before:0,after:0},o=t.boundaryOffset??0;n.set(t.t,{before:Math.max(e.before,t.topMass-o),after:Math.max(e.after,t.botMass+o)})}}return[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function fn(e,t,n){if(0===e.length)return[];const{padding:o,plotH:r,valueScale:i}=n,a=n.stackValueScale??i,s=un(e,o,n.groupPadding??0),c=[o+e[0].peak.topPeak*a];for(let n=1;e.length>n;n++)c.push(c[n-1]+t[n-1]*a+s[n-1]);const l=c[c.length-1]+e[e.length-1].peak.botPeak*a+o;if(l>r&&l>0){const e=r/l;for(let t=0;c.length>t;t++)c[t]*=e}return c}function hn(e,t){const n=(e.boundaryOffset??0)*t,o=e.value*t;if("out"===e.kind){const r=e.sideMassBefore*t;return n+("top"===e.side?o/2-r:r-o/2)}const r=e.sideMassAfter*t;return n+("top"===e.side?o/2-r:r-o/2)}function gn(e,t,n,o,r,i){const a=i.adjacentClearance?[...i.adjacentClearance]:on(dn(o,n)).adjacentClearance,s=fn(o,a,i);let c="hug"===i.lanePlacement?function(e,t,n,o,r,i,a){const s=e.length;if(0===s)return[];const{padding:c,plotH:l,valueScale:u}=a,d=un(e,c,a.groupPadding??0),f=r.map((e,t)=>e*u+d[t]),h=c+e[0].peak.topPeak*u,g=l-c-e[s-1].peak.botPeak*u;if(f.reduce((e,t)=>e+t,0)+1e-6>=g-h)return fn(e,r,a);let m=1===s?[(h+g)/2]:[...i];for(let e=0;12>e;e++){const e=Array(s).fill(0),r=Array(s).fill(0);for(const i of n){const n=t[i.source],a=t[i.target];if(null==n||null==a||n===a)continue;const s=o[i.source]?.localAttachments.get(i.id),c=o[i.target]?.localAttachments.get(i.id);if(!s||!c)continue;const l=i.value>0&&Number.isFinite(i.value)?i.value:1,d=hn(s,u),f=hn(c,u);e[n]+=(m[a]+f-d)*l,r[n]+=l,e[a]+=(m[n]+d-f)*l,r[a]+=l}const i=tn({desired:m.map((t,n)=>0===r[n]?t:.45*t+e[n]/r[n]*.55),minGaps:f,weights:r.map(e=>Math.max(1,e)),min:h,max:g});let a=0;for(let e=0;s>e;e++)a=Math.max(a,Math.abs(i[e]-m[e]));if(m=i,.01>a)break}return m}(o,r,t,n,a,s,i):[...s];if("hug"===i.lanePlacement){const n=t=>{const n=sn();for(const o of e)n[o.id]=t[r[o.id]];return n};mn(n(c),t)>mn(n(s),t)+1e-6&&(c=[...s])}const l=sn();for(const t of e)l[t.id]=c[r[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=l[t.id],o=n[t.id];Number.isFinite(e)&&o&&(u=Math.min(u,e-o.topPeak*i.valueScale),d=Math.max(d,e+o.botPeak*i.valueScale))}return{adjacentClearance:a,centerlines:l,slotCenter:c,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&i.plotH>0?Math.max(0,Math.min(1,(d-u)/i.plotH)):0}}function mn(e,t){let n=0;for(const o of t){const t=e[o.source],r=e[o.target];Number.isFinite(t)&&Number.isFinite(r)&&(n+=Math.abs(t-r)*(o.value>0?o.value:1))}return n}function pn(e,t){const n=e?.samples;if(!n||0===n.length||n[0].t>t)return{top:0,bot:0};let o=0,r=n.length-1,i=0;for(;r>=o;){const e=o+r>>>1;n[e].t>t?r=e-1:(i=e,o=e+1)}const a=n[i].boundaryOffset??0;return{top:n[i].topMass-a,bot:n[i].botMass+a}}function yn(e,t,n,o,r){const i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*n+r*r*r*o}function bn(e,t){let n=0,o=1;for(let r=0;28>r;r++){const r=(n+o)/2;e>yn(0,t,t,1,r)?n=r:o=r}return(n+o)/2}function vn(e,t,n){const o=t+hn(e,n),r=e.value*n/2;return[o-r,o+r]}function kn(e,t,n,o){return Math.max(0,Math.min(t,o)-Math.max(e,n))/Math.max(1e-9,t-e)}function xn(e,t,n,o,r,i,a){const{valueScale:s,domain:c,mode:l="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5;let d=0;for(const a of e){const e=o[a.source],f=o[a.target];if(null==e||null==f||2>Math.abs(e-f))continue;const h=t[a.source]?.localAttachments.get(a.id),g=t[a.target]?.localAttachments.get(a.id);if(!h||!g)continue;const m=Math.max(a.startTime,c?.[0]??-1/0),p=Math.min(a.endTime,c?.[1]??1/0);if(m>=p)continue;const[y,b]=vn(h,r[a.source],s),[v,k]=vn(g,r[a.target],s),x=Math.min(e,f)+1,S=Math.max(e,f)-1;for(let e=x;S>=e;e++){const o=n[e];if(!o)continue;const c=[m,p];if("quality"===l)for(const e of o.occupants)for(const n of t[e.id]?.samples??[])n.t>m&&p>n.t&&c.push(n.t);const f=e=>{const n=bn((e-m)/(p-m),u),c=yn(y,y,v,v,n),l=yn(b,b,k,k,n);let d=0;for(const n of o.occupants){if(n.id===a.source||n.id===a.target)continue;const o=i[n.id];if(null!=o?.start&&o.start>e)continue;if(null!=o?.end&&e>o.end)continue;const u=pn(t[n.id],e),f=r[n.id];d=Math.max(d,kn(c,l,f-u.top*s,f+u.bot*s))}return d},h=[...new Set(c)].sort((e,t)=>e-t);let g=0;for(let e=0;h.length-1>e;e++){const t=h[e],n=h[e+1]-t;g+=(f(t+.25*n)+f(t+.5*n)+f(t+.75*n))/3*n}d+=g/(p-m)*(a.value>0?a.value:1)}}return d}function Sn(e,t,n,o,r,i,a,s,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:mn(a,n),transitOcclusion:xn(n,o,r,i,a,s,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function wn(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Mn(e,t){return e.map(e=>({t:wn(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Pn(e,t,n){const o=t+(e.boundaryOffset??0)*n,r=e.value*n;if("out"===e.kind){const t=e.sideMassBefore*n;if("top"===e.side){const e=o-t;return[e,e+r]}const i=o+t;return[i-r,i]}const i=e.sideMassAfter*n;if("top"===e.side){const e=o-i;return[e,e+r]}const a=o+i;return[a-r,a]}function Ln(e,t,n,o,r="temporal"){const i=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(const e of i)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(c[e.kind]??99)-(c[t.kind]??99)||((e,t)=>{if(!o||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const n=o.get(e.edge.id)?.target,r=o.get(t.edge.id)?.target;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof r&&Number.isFinite(r)&&n!==r?"top"===e.side?n-r:r-n:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const n=o.get(e.edge.id)?.source,r=o.get(t.edge.id)?.source;return"number"==typeof n&&Number.isFinite(n)&&"number"==typeof r&&Number.isFinite(r)&&n!==r?"top"===e.side?r-n:n-r:0}return 0})(e,t)||cn(e.edge?.id??"",t.edge?.id??"")||cn(e.side,t.side)||e.delta-t.delta)},u=s.length?j(s.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,f=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;l();let h=null,g=0;for(const e of s)e.time!==h&&(h=e.time,g=0),e.sequence=g++;const m=e=>({time:e.time,phase:0,sequence:e.sequence??0}),p=[];let y=0,b=0;for(const e of s)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:b);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:b);if(o>0){const r=m(e);p.push({...r,delta:-o,kind:"transfer-out",side:t}),p.push({...r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:b-=o,"top"===e.side?y+=o:b+=o,n-=o}n>0&&null!==f&&(p.push({time:f,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:b+=n)}"top"===e.side?y-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:b+=t}s.push(...p),l();let v=0,k=0,x=0,S=0,w=0,M=0;const P=[],L=new Map,T=e=>{P.push({t:e,topMass:v,botMass:k,...Math.abs(x)>1e-12&&{boundaryOffset:x}})},A=()=>{S=Math.max(S,v+k),w=Math.max(w,v-x),M=Math.max(M,k+x)};for(const e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&T(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:k;L.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(x)>1e-12&&{boundaryOffset:x}})}"top"===e.side?v+=e.delta:k+=e.delta,"transfer-in"===e.kind?(x+="top"===e.side?e.delta:-e.delta,A(),T(e.time)):"transfer-out"!==e.kind&&(A(),"out"!==e.kind||v+k>1e-12||(x=0),T(e.time))}const D=[];let I=0;for(;P.length>I;){let e=I;for(;P.length>e+1&&P[e+1].t===P[I].t;)e++;D.push(P[I]);for(let t=I+1;e>=t;t++){const e=D[D.length-1];P[t].topMass===e.topMass&&P[t].botMass===e.botMass&&(P[t].boundaryOffset??0)===(e.boundaryOffset??0)||D.push(P[t])}I=e+1}const E=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let C=null;for(const e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let N=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===N||e.systemOutTime>N)&&(N=e.systemOutTime);if(D.length>0){const e=D[D.length-1],t=Math.max(null!=E?E:-1/0,null!=N?N:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&D.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const n=D[0],o=D.find(e=>e.topMass+e.botMass>0);let r,i=1/0;null!=d&&Number.isFinite(d)&&n.t>d&&n.topMass+n.botMass>0&&(i=d,r=n),o&&null!=C&&Number.isFinite(C)&&o.t>C&&i>C&&(i=C,r=o),r&&Number.isFinite(i)&&D.unshift({t:i,topMass:r.topMass,botMass:r.botMass,...null!=r.boundaryOffset&&{boundaryOffset:r.boundaryOffset}})}let O=D;if("max"===r&&null!=d&&null!=E&&E>d){let e,t=0;for(const n of D){const o=n.topMass+n.botMass;o>t&&(t=o,e=n)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};O=[...D.filter(e=>d>e.t),{t:d,...t},{t:E,...t},...D.filter(e=>e.t>E)]}}return{samples:O,peak:S,topPeak:w,botPeak:M,localAttachments:L}}function Tn(e){const t=sn();return e.forEach((e,n)=>{for(const o of e.occupants)t[o.id]=n}),t}function An(e,t,n){e.splice(0,e.length,...n);const o=Tn(n);for(const e of Object.keys(t))delete t[e];Object.assign(t,o)}function Dn(e){const t=new Map,n=[];e.forEach((e,o)=>{if(!e.group)return void n.push({anchor:o,stableId:ln(e),slots:[e]});const r=t.get(e.group)??{indexes:[],slots:[]};r.indexes.push(o),r.slots.push(e),t.set(e.group,r)});for(const[e,o]of t)n.push({anchor:o.indexes.reduce((e,t)=>e+t,0)/o.indexes.length,stableId:`${e}\0${o.slots.map(ln).join("\0")}`,slots:o.slots});return n.sort((e,t)=>e.anchor-t.anchor||cn(e.stableId,t.stableId))}function In(e){return e.some(e=>e.group)?Dn(e).flatMap(e=>e.slots):[...e]}function En(e){return e.flatMap(e=>e.slots)}function Cn(e,t,n){const o=new Map;return e.forEach((e,t)=>{for(const n of e.slots)o.set(n,t)}),e.map((e,r)=>{if(1>=e.slots.length)return e;const i=new Map;for(const t of e.slots)i.set(t,0);for(const e of t){const t=o.get(e.source),n=o.get(e.target);if(null==t||null==n)continue;const a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===r&&n!==r){const t=n>r?1:-1;i.set(e.source,(i.get(e.source)??0)+a*t)}else if(n===r&&t!==r){const n=t>r?1:-1;i.set(e.target,(i.get(e.target)??0)+a*n)}}const a=[...e.slots].sort((e,t)=>(i.get(e)??0)-(i.get(t)??0)||n(e,t));return{...e,slots:a}})}function Nn(e,t){e.some(e=>e.group)&&An(e,t,In(e))}function On(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Bn(e,t){return function(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,a]=t(e[r]);for(let s=r+1;e.length>s;s++){if(!n(e[r],e[s]))continue;const[c,l]=t(e[s]);0>(i-c)*(a-l)&&o++}}return o}(t,t=>[e[t.source],e[t.target]],On)}function $n(e,t){let n=0;for(const o of t){const t=e[o.source],r=e[o.target];null!=t&&null!=r&&(n+=Math.abs(t-r)*(o.value>0?o.value:1))}return n}function Hn(e,t,n){const[o,r]=n.get(e.first),[i,a]=n.get(e.second);return 0>(t.get(o)-t.get(i))*(t.get(r)-t.get(a))?1:0}var Rn=e=>{let t=1;for(let n=2;e>=n;n++)t*=n;return t},Fn=828*Rn(8),Wn=3e3;function _n(e,t,n,o,r,i,a){const s=[...r],c=new Map(r.map(e=>[e,ln(e)])),l=new Map;for(const e of r)for(const t of e.occupants)l.set(t.id,e);const u=new Map,d=[];for(const e of t){const t=l.get(e.source),n=l.get(e.target);t&&n&&(u.set(e,[t,n]),t!==n&&d.push({source:t,target:n,weight:e.value}))}const f=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let n=e+1;t.length>n;n++){if(!u.has(t[n])||!On(t[e],t[n]))continue;const o=new Set([...u.get(t[e]),...u.get(t[n])]);f.push({index:f.length,first:t[e],second:t[n],involvedSlots:o})}const h=new Map;for(const e of r)h.set(e,[]);for(const e of f)for(const t of e.involvedSlots)h.get(t)?.push(e);const g=new Uint32Array(f.length);let m=0;const p=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),y=a.plotH/Math.max(1,r.length),b=r.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),v=Math.max(1,p)*(Math.max(1,a.plotH)+y*Math.max(b,r.length)+1e-6*Math.max(1,r.length-1))+1,k=4*y,x={fullCrossing:0,localCrossing:0},S=new Map,w=(e,t)=>{let o=S.get(e);o||(o=new Map,S.set(e,o));const r=o.get(t);if(null!=r)return r;const i=function(e,t,n){return on(dn([e,t],n)).adjacentClearance[0]??0}(e,t,n);return o.set(t,i),i},M=new Map(r.map((e,t)=>[e,t])),P=t.flatMap(e=>{const t=u.get(e);return t?[{source:M.get(t[0]),target:M.get(t[1]),weight:e.value>0?e.value:1}]:[]}),L=new Map;for(const e of t){const t=u.get(e);t&&L.set(e,{source:M.get(t[0]),target:M.get(t[1])})}const T=new Map,A=new Map,D=new Map,I=(e,t,n)=>{e.has(t)||e.set(t,new Set),e.get(t).add(n)};for(const e of t)I(T,e.source,e.target),I(A,e.target,e.source),I(D,e.source,e.target),I(D,e.target,e.source);const E=t.flatMap(e=>{if(!(e=>1===T.get(e.source)?.size&&T.get(e.source).has(e.target)||1===D.get(e.source)?.size||1===D.get(e.target)?.size)(e))return[];const t=L.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(const n of E)t+=Math.max(0,Math.abs(e[n.source]-e[n.target])-1)*n.weight;return t*k},N=e=>{const t=new Int16Array(r.length);for(let n=0;e.length>n;n++)t[M.get(e[n])]=n;return C(t)},O=f.map(e=>{const t=L.get(e.first),n=L.get(e.second);return[t.source,t.target,n.source,n.target]}),B=new Int16Array(r.length),$=new Float64Array(r.length),H=new Float64Array(r.length+1),R=e=>{for(let t=0;e.length>t;t++)B[M.get(e[t])]=t;let t=0;for(const[e,n,o,r]of O)0>(B[e]-B[o])*(B[n]-B[r])&&t++;if(e.length>0){const t=M.get(e[0]);$[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){const n=M.get(e[t-1]),o=M.get(e[t]);$[o]=$[n]+w(e[t-1],e[t])*a.valueScale+a.padding}const n=M.get(e[e.length-1]),o=$[n]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(o>a.plotH&&o>0){const e=a.plotH/o;for(let t=0;$.length>t;t++)$[t]*=e}}H[0]=0;for(let t=0;e.length>t;t++)H[t+1]=H[t]+e[t].peak.topPeak+e[t].peak.botPeak;let n=0,o=0,r=0;for(const e of P){const t=B[e.source],i=B[e.target];if(n+=Math.abs(t-i)*e.weight,o+=Math.abs($[e.source]-$[e.target])*e.weight,Math.abs(t-i)>=2){const n=Math.min(t,i)+1;r+=(H[Math.max(t,i)]-H[n])*e.weight}}return t*v+o+r*y+C(B)+1e-6*n},F=(e,n)=>{const o=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)o[t+1]=o[t]+e[t].peak.topPeak+e[t].peak.botPeak;let r=0;for(const e of t){const t=n[e.source],i=n[e.target];if(null==t||null==i||2>Math.abs(t-i))continue;const a=Math.min(t,i)+1;r+=(o[Math.max(t,i)]-o[a])*(e.value>0?e.value:1)}return r},W=o=>{const r=Tn(o),i=o.slice(0,-1).map((e,t)=>w(e,o[t+1])),s=gn(e,t,n,o,r,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:i});return{map:r,geometry:s,weightedLength:$n(r,t),pixelLength:mn(s.centerlines,t),transitOcclusion:F(o,r)}},_=(e,t,n)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*v+t.pixelLength+t.transitOcclusion*y+N(n)+1e-6*t.weightedLength}),z=(e,t)=>{let n=t;if(null==n){const t=new Map(e.map((e,t)=>[e,t]));n=f.reduce((e,n)=>e+Hn(n,t,u),0),x.fullCrossing++}return _(n,W(e),e)},j=(e,r,i="quality")=>{let s=r;if(null==s){const t=new Map(e.map((e,t)=>[e,t]));s=f.reduce((e,n)=>e+Hn(n,t,u),0),x.fullCrossing++}const c=W(e);return _(s,{...c,transitOcclusion:xn(t,n,e,c.map,c.geometry.centerlines,o,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:i})},e)};let X=[...s];const Y=(e,t)=>cn(c.get(e),c.get(t)),G=function(e){const t=new Set;for(const n of e)if(n.group){if(t.has(n.group))return!0;t.add(n.group)}return!1}(X),q=e=>{const t=(e=>{const t=rn(e,d,e=>z(e).cost,{passes:6,compare:Y,maxEvaluations:Wn});let n=z(t),o=Wn;for(let e=0;6>e&&o>0;e++){let r=!1;const i=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&i.reverse();for(const e of i){if(0>=o--)break;const i=t[e],a=t[e+1],s=new Map(t.map((e,t)=>[e,t]));let c=0;const l=[];m++;for(const e of[...h.get(i)??[],...h.get(a)??[]])g[e.index]!==m&&(g[e.index]=m,l.push(e),c+=Hn(e,s,u));[t[e],t[e+1]]=[a,i];const d=new Map(s);d.set(i,e+1),d.set(a,e);let f=0;for(const e of l)f+=Hn(e,d,u);x.localCrossing+=l.length;const p=z(t,n.crossings-c+f);n.cost>p.cost?(n=p,r=!0):[t[e],t[e+1]]=[i,a]}if(!r)break}return t})(e);if((e.length>8?1/0:Rn(e.length)*(e.length+P.length+O.length))>Fn)return t;const n=an(e,R,{maxItems:8,maxEvaluations:5e4}),o=j(n),r=j(t);return o.crossings!==r.crossings&&r.crossings>o.crossings?n:t},V="geometry-refine"===a.mode;if(V||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!V&&"inside-out"===a.laneOrder)if(G){const e=Dn(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),n=[...e].sort((e,n)=>t(n)-t(e)||cn(e.stableId,n.stableId)),o=Array(n.length);let r=Math.floor((n.length-1)/2)-1,i=Math.floor((n.length-1)/2)+1;n.length>0&&(o[Math.floor((n.length-1)/2)]=n[0]);for(let e=1;n.length>e;e++)e%2==1&&n.length>i||0>r?o[i++]=n[e]:o[r--]=n[e];X=En(o)}else{const e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||Y(e,t)),t=Array(e.length);let n=Math.floor((e.length-1)/2)-1,o=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let r=1;e.length>r;r++)r%2==1&&e.length>o||0>n?t[o++]=e[r]:t[n--]=e[r];X=t}}else X=G?(e=>{let t=Dn(e);if(1>=t.length)return En(t);const n=e=>z(En(e)).cost;t=Dn(q(e)),t=Cn(t,d,Y);const o=function(e,t){const n=new Map;for(const t of e)for(const e of t.slots)n.set(e,t);const o=new Map;for(const e of t){const t=n.get(e.source),r=n.get(e.target);if(!t||!r||t===r)continue;const i=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=r.stableId>t.stableId?`${t.stableId}\0${r.stableId}`:`${r.stableId}\0${t.stableId}`,s=o.get(a);s?s.weight=(s.weight??0)+i:o.set(a,{source:t,target:r,weight:i})}return[...o.values()]}(t,d);t=rn(t,o,n,{passes:6,compare:(e,t)=>cn(e.stableId,t.stableId),maxEvaluations:Wn}),t=function(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const a=Math.max(0,n.passes??6),s=Math.max(1,n.maxEvaluations??1/0);for(let e=0;a>e&&s>i;e++){let e=!1;for(let n=0;o.length-1>n&&s>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const a=t(o);i++,r>a?(r=a,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}(t,n,{passes:8,maxEvaluations:Wn});const r=t.length>8?1/0:Rn(t.length)*(t.length+P.length+O.length);if(Fn>=r){const e=an(t,e=>R(En(e)),{maxItems:8,maxEvaluations:5e4}),n=En(e),o=En(t),r=j(n),i=j(o);r.crossings!==i.crossings?t=i.crossings>r.crossings?e:t:i.cost>r.cost&&(t=e)}return t=Cn(t,d,Y),En(t)})(X):q(X);if(!V&&"crossing-min+inside-out"===a.laneOrder&&X.length>1)if(G){const e=Dn(X);let t=z(En(e)),n=En(e),o=t;const r=Math.floor((e.length-1)/2),i=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>i(t)-i(e)||cn(e.stableId,t.stableId));for(const i of a){const a=e.indexOf(i);if(a===r)continue;e.splice(a,1),e.splice(r,0,i);const s=En(e),c=z(s);c.cost>t.cost?(e.splice(r,1),e.splice(a,0,i)):(t=c,o.cost>c.cost&&(n=s,o=c))}X=n}else{let e=z(X),t=[...X],n=e;const o=Math.floor((X.length-1)/2),r=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||Y(e,t));for(const i of r){const r=X.indexOf(i);if(r===o)continue;X.splice(r,1),X.splice(o,0,i);const a=z(X);a.cost>e.cost?(X.splice(o,1),X.splice(r,0,i)):(e=a,n.cost>a.cost&&(t=[...X],n=a))}X=t}if((V||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&X.length>1)if(G){let e=Dn(X),t=j(En(e),void 0,"score");for(let n=0;6>n&&e.length>1;n++){let n=!1;for(let o=0;e.length-1>o;o++){[e[o],e[o+1]]=[e[o+1],e[o]];const r=En(e),i=j(r,void 0,"score");t.cost>i.cost?(X=r,t=i,n=!0):[e[o],e[o+1]]=[e[o+1],e[o]]}if(!n)break}e=Cn(Dn(X),d,Y),X=En(e)}else{let e=j(X,void 0,"score");for(let t=0;X.length-1>t;t++){const n=X[t],o=X[t+1],r=new Map(X.map((e,t)=>[e,t]));let i=0;const a=[];m++;for(const e of[...h.get(n)??[],...h.get(o)??[]])g[e.index]!==m&&(g[e.index]=m,a.push(e),i+=Hn(e,r,u));[X[t],X[t+1]]=[o,n];const s=new Map(r);s.set(n,t+1),s.set(o,t);let c=0;for(const e of a)c+=Hn(e,s,u);x.localCrossing+=a.length;const l=j(X,e.crossings-i+c,"score");e.cost>l.cost?e=l:[X[t],X[t+1]]=[n,o]}}const K=In(s);X=In(X);let U=j(X);const Q=j(K);if(V){const e=N(K),t=N(X);(U.crossings>Q.crossings||U.crossings===Q.crossings&&t>e+1e-9||U.cost>Q.cost)&&(X=K,U=Q)}else U.cost>Q.cost&&(X=K,U=Q);const Z=function({order:e,after:t,nodes:n,edges:o,outgoingPartners:r,incomingPartners:i,slotForNode:a,averageGap:s,evaluate:c}){const l=(n,r)=>{const i=[...new Set(r.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(n),l=i[0],u=i[i.length-1];if(3>i.length||!i.includes(a)||u-l+1!==i.length||1>=Math.abs(2*a-l-u))return;const d=[...e];d.splice(a,1),d.splice(l+u>>1,0,n);const f=In(d),h=c(f),g=new Set(n.occupants.map(e=>e.id)),m=new Set(r.flatMap(e=>e.occupants.map(e=>e.id))),p=o.reduce((e,t)=>g.has(t.source)&&m.has(t.target)||g.has(t.target)&&m.has(t.source)?e+(t.value>0?t.value:1):e,0);(function(e,t,n=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+n>=e.cost})(h,t,Math.abs(2*a-l-u)*s*Math.max(1,p))&&(e=f,t=h)};for(const[e,t]of r)i.has(e)||3>t.size||l(a.get(e),[...t].map(e=>a.get(e)));for(const e of n){const t=a.get(e.id);e.group||!t.group||3>(i.get(e.id)?.size??0)||l(t,[...i.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,n)=>n.indexOf(e)===t))}return{order:e,after:t}}({order:X,after:U,nodes:e,edges:t,outgoingPartners:T,incomingPartners:A,slotForNode:l,averageGap:y,evaluate:j});return X=Z.order,U=Z.after,An(r,i,X),{before:Q,after:U,initialOrder:s.map(e=>c.get(e)),evaluations:x}}function zn(e,t,n){const o=e.map(e=>{const o=e.occupants.map(e=>({id:e.id,end:n[e.id]?.end??e.end}));let r=0,i=0;for(const e of o){const n=t[e.id];r=Math.max(r,n?.topPeak||0),i=Math.max(i,n?.botPeak||0)}return{occupants:o,peak:{topPeak:r,botPeak:i},...null!=e.group?{group:e.group}:{}}}),r=sn();return o.forEach((e,t)=>{for(const n of e.occupants)r[n.id]=t}),{slots:o,slotByNode:r}}var jn=new Map,Xn=1e5,Yn=1e-9;function Gn(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function qn(e,t){return cn(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Vn(e){const t=new Map,n=new Map;for(const o of e)n.has(o.source)||n.set(o.source,new Set),t.has(o.target)||t.set(o.target,new Set),n.get(o.source).add(o.target),t.get(o.target).add(o.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...n].map(([e,t])=>[e,t.size]))}}function Kn(e){const t=new Map,n=new Map,o=(e,t,n,o)=>{let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,(r.get(n)??0)+o)};for(const r of e){const e=r.value>0&&Number.isFinite(r.value)?r.value:1;o(t,r.source,r.target,e),o(n,r.target,r.source,e)}const r=new Map,i=e=>{if(r.has(e))return;const o=t.get(e),i=n.get(e),a=new Map;for(const[e,t]of o??[])a.set(e,(a.get(e)??0)+t);for(const[e,t]of i??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){const[t,n]=[...a][0];r.set(e,{partner:t,weight:n})}};for(const t of e)i(t.source),i(t.target);return r}function Un(e,t,n){const o=n.get(e),r=n.get(t);return!o||!r||o.partner===r.partner||o.partner===t||r.partner===e}function Qn(e,t,n){return!!n.has(e)&&t.some(t=>!Un(e,t,n))}function Zn(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function Jn(e,t,n,o){if(12>=e.length||1>=o.slotCount)return o.assignment;const r=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Map),a=Vn(n);for(const e of n){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n||t===n)continue;const o=Zn(e,a);i[t].set(n,(i[t].get(n)??0)+o),i[n].set(t,(i[n].get(t)??0)+o)}const s=Kn(n),c=e.map(e=>s.get(e)?.weight??0),l=Array.from({length:e.length},()=>new Map);let u=0;for(let n=0;e.length-1>n&&5e4>u;n++)if(s.has(e[n]))for(let o=n+1;e.length>o;o++){if(!s.has(e[o]))continue;if(t.conflicts(e[n],e[o]))continue;u++;const r=Math.min(c[n],c[o])||Math.max(c[n],c[o]),i=Un(e[n],e[o],s)?r:-r;if(Math.abs(i)>Yn&&(l[n].set(o,i),l[o].set(n,i),u>=5e4))break}const d=[...o.assignment],f=Array.from({length:o.slotCount},()=>[]);d.forEach((e,t)=>f[e].push(t));const h=(e,t,n)=>{const o=d[t],r=d[n];let i=0;const a=new Set;for(const s of[t,n])for(const[c,l]of e[s]){const e=c>s?`${s}:${c}`:`${c}:${s}`;if(a.has(e))continue;a.add(e);const u=(s===t?r:o)===(c===t?r:c===n?o:d[c]);d[s]===d[c]!==u&&(i+=u?l:-l)}return i},g=(e,t,n)=>{let o=0;for(const[r,i]of e[t]){const e=n===d[r];d[t]===d[r]!==e&&(o+=e?i:-i)}return o},m=(e,t)=>e>Yn||Yn>=Math.abs(e)&&t>Yn,p=(e,t,n,o)=>e>n+Yn||Yn>=Math.abs(e-n)&&t>o+Yn;let y=0;for(let n=0;32>n&&Xn>y;n++){let n=null,o=-1,r=-1,a=-1,s=-1/0,c=-1/0;for(let u=0;e.length>u;u++){for(let h=0;f.length>h&&y++<Xn;h++){if(h===d[u])continue;if(!f[h].every(n=>!t.conflicts(e[u],e[n])))continue;const y=g(i,u,h),b=g(l,u,h);m(y,b)&&p(y,b,s,c)&&(n="move",o=u,r=-1,a=h,s=y,c=b)}if(y>=Xn)break}for(let u=0;e.length-1>u;u++){for(let g=u+1;e.length>g&&y++<Xn;g++){const y=d[u],b=d[g];if(y===b)continue;if(!f[b].every(n=>n===g||!t.conflicts(e[u],e[n])))continue;if(!f[y].every(n=>n===u||!t.conflicts(e[g],e[n])))continue;const v=h(i,u,g),k=h(l,u,g);m(v,k)&&p(v,k,s,c)&&(n="swap",o=u,r=g,a=-1,s=v,c=k)}if(y>=Xn)break}if(null==n||-1===o)break;if("move"===n){const e=d[o];f[e].splice(f[e].indexOf(o),1),f[a].push(o),d[o]=a;continue}const u=d[o],b=d[r];f[u].splice(f[u].indexOf(o),1,r),f[b].splice(f[b].indexOf(r),1,o),d[o]=b,d[r]=u}return d}function eo(e,t){let n=1/0,o=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>1e-9&&(n=Math.min(n,t.t),o=Math.max(o,t.t));return Number.isFinite(n)&&Number.isFinite(o)?(null!=t.start&&(n=Math.max(n,t.start)),null!=t.end&&(o=Math.min(o,t.end)),n>o?{start:null,end:null}:{start:n,end:o}):{start:null,end:null}}function to(e,t,n,o){const r=function(e,t,n,o){return`${e.map(e=>{const t=n[e.id],r=o[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,r?.start??"",r?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,n,o),i=jn.get(r);if(i)return zn(i.slots,n,o);const a=sn();for(const t of e)a[t.id]=eo(n[t.id],o[t.id]);const s=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,n)=>t[e.id].start-t[n.id].start||t[e.id].end-t[n.id].end||cn(e.id,n.id)).map(e=>e.id)}(e,a),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=Kn(t),d=function(e,t,n,o,r,i){const a=new Set,s=new Map(e.map(e=>[e,new Set])),c=new Map(e.map(e=>[e,new Set]));for(const e of o)a.add(qn(e.source,e.target)),s.get(e.target)?.add(e.source),c.get(e.source)?.add(e.target);const l=new Map,u=new Set,d=(e,t)=>{for(let n=0;e.length>n;n++)for(let o=n+1;e.length>o;o++){const r=qn(e[n],e[o]);t instanceof Map?t.set(r,[e[n],e[o]]):t.add(r)}};for(const e of c.values())d([...e],l);for(const e of s.values())d([...e],u);const f=new Set;for(const[e,[o,r]]of l)u.has(e)&&(Gn(t[o],t[r])||Gn(n[o],n[r])&&(f.add(o),f.add(r)));return{conflicts:(e,n)=>{const o=r.get(e),s=r.get(n);return null!=o&&null!=s&&o!==s||!(null!=o==(null!=s)||a.has(qn(e,n))||i.has(e)&&i.has(n)&&Un(e,n,i))||!!Gn(t[e],t[n])||!(!f.has(e)&&!f.has(n))&&!a.has(qn(e,n))}}}(s,a,o,t,l,u),f=function(e,t,n=new Map){const o=[],r=[];for(const i of e){let e=o.findIndex(e=>e.every(e=>!t.conflicts(i,e))&&!Qn(i,e,n));-1!==e||n.has(i)||(e=o.findIndex(e=>e.every(e=>!t.conflicts(i,e)))),-1===e&&(e=o.length,o.push([])),o[e].push(i),r.push(e)}return{assignment:r,slotCount:o.length}}(s,d,u),h=function(e,t,n,o){if(0===e.length||e.length>12||1>=o.slotCount)return o.assignment;const r=new Map(e.map((e,t)=>[e,t])),i=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),s=Array.from({length:e.length},()=>new Map),c=Vn(n);for(const e of n){const t=r.get(e.source),n=r.get(e.target);if(null==t||null==n||t===n)continue;const o=Zn(e,c);i[t][n]+=o,i[n][t]+=o,s[t].set(n,(s[t].get(n)??0)+o),a[n].set(t,(a[n].get(t)??0)+o)}const l=Kn(n),u=e.map(e=>l.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let n=t+1;e.length>n;n++){for(const[e,o]of a[t])d[t][n]+=Math.min(o,a[n].get(e)??0);for(const[e,o]of s[t])d[t][n]+=Math.min(o,s[n].get(e)??0);if(l.has(e[t])&&l.has(e[n])){const o=Math.min(u[t],u[n])||Math.max(u[t],u[n]);d[t][n]+=Un(e[t],e[n],l)?o:-o}d[n][t]=d[t][n]}let f=[...o.assignment],h=(t=>{let n=0,o=0;for(let r=0;e.length>r;r++)for(let a=r+1;e.length>a;a++)t[r]===t[a]&&(n+=i[r][a],o+=d[r][a]);return{flow:n,affinity:o}})(f),g=0;const m=Array(e.length).fill(-1),p=Array.from({length:o.slotCount},()=>[]),y=(n,r,a,s)=>{if(g>=75e3)return;if(n===e.length)return g++,void((a>h.flow||a===h.flow&&s>h.affinity||a===h.flow&&s===h.affinity&&function(e,t){for(let n=0;Math.min(e.length,t.length)>n;n++)if(e[n]!==t[n])return t[n]>e[n];return t.length>e.length}(m,f))&&(f=[...m],h={flow:a,affinity:s}));const c=Math.min(r+1,o.slotCount-1);for(let o=0;c>=o;o++){if(p[o].some(o=>t.conflicts(e[n],e[o])))continue;let c=0,l=0;for(const e of p[o])c+=i[n][e],l+=d[n][e];if(m[n]=o,p[o].push(n),y(n+1,Math.max(r,o),a+c,s+l),p[o].pop(),m[n]=-1,g>=75e3)return}};return m[0]=0,p[0].push(0),y(1,0,0,0),f}(s,d,t,{...f,assignment:Jn(s,d,t,f)}),g=new Map,m=h.map(e=>(g.has(e)||g.set(e,g.size),g.get(e))),p=Array.from({length:g.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),y=sn();s.forEach((e,t)=>{const n=m[t],o=p[n];o.occupants.push({id:e,end:a[e].end??-1/0});const r=c.get(e)?.group;r&&(o.group=r),y[e]=n});for(const t of[...e].sort((e,t)=>cn(e.id,t.id)))null==y[t.id]&&(p[0].occupants.push({id:t.id,end:-1/0}),y[t.id]=0);for(const e of p){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||cn(e.id,t.id));for(const t of e.occupants){const o=n[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,o?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,o?.botPeak||0)}}const b={slots:p,slotByNode:y};return function(e,t){for(jn.has(e)&&jn.delete(e),jn.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(sn(),t.slotByNode)});jn.size>12;){const e=jn.keys().next().value;if(null==e)break;jn.delete(e)}}(r,b),b}function no(e){return e.topMass+e.botMass}function oo(e,t){const n=e.samples.filter(e=>e.t===t);if(n.length>0)return n.reduce((e,t)=>no(t)<no(e)?e:t,n[0]);let o=null;for(const n of e.samples){if(n.t>t)break;o=n}return o}function ro(e,t,n,o,r,i,a=0){const s=new Map;for(const n of e){if(!n.group||!t[n.id])continue;const e=s.get(n.group)??[];e.push(n),s.set(n.group,e)}if(0===s.size||0>=i)return t;const c=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,l]of s){const s=n.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;const u=s[0].slot,d=s.at(-1).slot,f=r[u.occupants[0]?.id],h=r[d.occupants[0]?.id];if(!Number.isFinite(f)||!Number.isFinite(h))continue;const g=(f-u.peak.topPeak*i+(h+d.peak.botPeak*i))/2,m=[...new Set(l.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),p=new Map;for(const e of l)p.set(e.id,new Map);for(const e of m){const n=new Map;for(const r of l){const i=oo(t[r.id],e);if(!i||1e-9>=no(i))continue;const a=o[r.id];if(null==a)continue;const s=n.get(a)??[];s.push({node:r,sample:i}),n.set(a,s)}const s=[...n].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>no(e)))}));if(0===s.length)continue;let c=g-(s.reduce((e,t)=>e+t.mass,0)*i+Math.max(0,a)*Math.max(0,s.length-1))/2;for(const t of s){for(const{node:n,sample:o}of t.active){const t=(c-r[n.id])/i+o.topMass-(o.boundaryOffset??0);p.get(n.id).set(e,t)}c+=t.mass*i+Math.max(0,a)}}for(const e of l){const n=t[e.id],o=c[e.id],r=p.get(e.id),i=[];for(const e of m){const t=r.get(e),o=n.samples.filter(t=>t.t===e);if(o.length>0){i.push(...o.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}})));continue}const a=oo(n,e);null!=t&&a&&no(a)>1e-9&&i.push({...a,t:e,boundaryOffset:(a.boundaryOffset??0)+t})}o.samples=i,o.localAttachments=new Map([...n.localAttachments].map(([e,t])=>{const n=r.get(t.time);return[e,{...t,...null!=n?{boundaryOffset:(t.boundaryOffset??0)+n}:{}}]}))}}return c}function io(e,t,n,o,r){const{plotH:i,padding:a,valueScale:s,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:f=0,ribbonLane:h="both",domain:g}=r,m=sn(),p=sn();for(const t of e)m[t.id]=n[t.id].topPeak||0,p[t.id]=n[t.id].botPeak||0;const y="half"===u,b=sn();for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=y?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=y?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}b[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}let v=sn(),k=[],x=[];if(r.frozenSlots){const e=zn(r.frozenSlots,n,b);k=e.slots,v=e.slotByNode,x=k.map(ln)}else if("reuse"===c){const o=to(e,t,n,b);k=o.slots,v=o.slotByNode}else e.forEach((e,t)=>{k.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:m[e.id],botPeak:p[e.id]},...e.group?{group:e.group}:{}}),v[e.id]=t});Nn(k,v),0===x.length&&(x=k.map(ln));let S=null;r.frozenSlots||(r.fixedSlotOrder?function(e,t,n){const o=new Map(n.map((e,t)=>[e,t]));An(e,t,[...e].sort((e,t)=>(o.get(ln(e))??1/0)-(o.get(ln(t))??1/0)||cn(ln(e),ln(t))))}(k,v,r.fixedSlotOrder):r.runOrdering&&l&&"insertion"!==l&&(S=_n(e,t,n,b,k,v,{plotH:i,padding:a,valueScale:s,groupPadding:f,laneOrder:l,ribbonLane:h,domain:g}))),Nn(k,v);const w=gn(e,t,n,k,v,{plotH:i,padding:a,valueScale:s,stackValueScale:r.stackValueScale,lanePlacement:d,groupPadding:f}),M=0===k.length?0:k[0].peak.topPeak+w.adjacentClearance.reduce((e,t)=>e+t,0)+k[k.length-1].peak.botPeak,P=S?.before.crossings??null,L=S?.after.crossings??null,T=S?.before.weightedLength??null,A=S?.after.weightedLength??null;return{effectiveSlotsHeight:M,centerlines:w.centerlines,laneLifetime:b,slots:k,slotByNode:v,slotCenter:w.slotCenter,stackCenter:w.stackCenter,verticalUtilization:w.verticalUtilization,selectedSlotOrder:k.map(ln),initialSlotOrder:x,ordering:S,crossingsBefore:P,crossingsAfter:L,lengthBefore:T,lengthAfter:A}}import{forwardRef as ao,useMemo as so,useRef as co,useCallback as lo,useEffect as uo}from"react";function fo(e,t,n,o="horizontal"){return"vertical"===o?{top:e?38:t?28:16,right:24,bottom:24,left:n?72:24}:{top:e?30:t?24:8,right:80,bottom:n?28:8,left:80}}import{Fragment as ho,jsx as go,jsxs as mo}from"react/jsx-runtime";var po="var(--semiotic-grid, #94a3b8)",yo="var(--semiotic-text-secondary, #475569)",bo="var(--semiotic-text-secondary, #94a3b8)";import{useEffect as vo,useMemo as ko,useRef as xo,useState as So}from"react";import{scaleTime as wo}from"d3-scale";import{scaleTime as Mo}from"d3-scale";function Po(e,t,n,o,r,i,a,s,c={}){const l=r,u=e=>s?Math.max(s[0],Math.min(s[1],e)):e;let d=i(u(e.time));const f=i(u(n.time)),h=e.value*l,g=n.value*l,m=t+(e.boundaryOffset??0)*l,p=o+(n.boundaryOffset??0)*l,y=e.sideMassBefore*l,b=n.sideMassAfter*l;let v,k,x,S;"top"===e.side?(v=m-y,k=v+h):(k=m+y,v=k-h),"top"===n.side?(x=p-b,S=x+g):(S=p+b,x=S-g);const w=c.sourceRunwayStart,M=c.minRun,P=Math.abs((x+S)/2-(v+k)/2),L=f-d,T="number"==typeof w&&Number.isFinite(w),A="number"==typeof M&&Number.isFinite(M)&&M>0;if(T&&P>1e-9&&L>0&&("auto"===M||A)){const t="source"===a?.85:"target"===a?.15:.5,n="auto"===M?Math.min(144,Math.sqrt(8*P/(1.5*Math.min(t*t,(1-t)*(1-t))))):M;if(n>L){const t=i(u(Math.min(w,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),f-n)))}}const D="source"===a?d+.85*(f-d):"target"===a?d+.15*(f-d):(d+f)/2;return{sx:d,sTop:v,sBot:k,tx:f,tTop:x,tBot:S,cp1X:D,cp2X:D}}function Lo(e){return Math.max(18,11*e.length*.58)}function To(e){const t=1.22*Lo(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Ao(e,t){const n=e.labelX-Lo(e.labelText),o=t.labelX-Lo(t.labelText);return t.labelX+3>=n&&e.labelX+3>=o}var Do=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;function Io(e){return e.replace(Do,(e,t,n)=>`${n},${t}`)}function Eo(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Co(e){return{...e,pathD:Io(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function No(e){const{nodes:t,edges:n,domain:o,plotW:r,plotH:i,ribbonLane:a,ribbonMinRun:s=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:f=!0,labelPriorityAccessor:h,maxLabels:g,selectionDatum:m="raw",styleRules:p,colorBy:y,valueAccessor:b,usageMode:v="static"}=e,k="vertical"===d?i:r,x="vertical"===d?r:i,S=Vt(t,n,o,{usageMode:v}),{fatal:w,warnings:M}=function(e){const t=[],n=[];for(const o of e)"fatal"===qt(o)?t.push(o):n.push(o);return{fatal:t,warnings:n}}(S),P=function(e,t,n="static"){if("strip"!==Yt(n).invalidSystemTime)return e;const o=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===o.size?e:e.map(e=>{if(!o.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}(n,S,v),L=Mo().domain(o).range([0,k]);if(w.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==f},issues:w,warnings:M,xScale:L};const A=function(e,t,n){const{plotH:o,pairing:r="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:f="both",domain:h}=n,g=Number.isFinite(d)?Math.max(0,d):0,m=function(e,t){const n=sn(),o=sn();for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),p=function(e,t,n,o="temporal"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime||cn(e.id,t.id):(e,t)=>t.value-e.value||cn(e.id,t.id),i="temporal"===o?(e,t)=>e.startTime-t.startTime||cn(e.id,t.id):(e,t)=>t.value-e.value||cn(e.id,t.id),a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const a=[...n.values()];a.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart||cn(e.partner,n.partner):e.latestEnd-n.latestEnd||cn(e.partner,n.partner):(e,t)=>t.total-e.total||cn(e.partner,t.partner));for(const e of a)e.edges.sort("target"===t?i:r);return a};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(o,"source"),n=s(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=o}}}return a}(e,t,m,r);let y=sn();for(const t of e)y[t.id]=Ln(t,m,p,void 0,u);const b=io(e,t,y,m,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:g,ribbonLane:f,domain:h}),v=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),k=new Set;for(const e of t){const t=b.slotByNode[e.source],n=b.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=p.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(k.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=m.outgoing[t.id],n=m.incoming[t.id],o=new Set(e.map(e=>p.get(e.id).sourceSide)),r=new Set(n.map(e=>p.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)b.slotByNode[t.source]===b.slotByNode[t.target]&&(p.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)b.slotByNode[n.source]===b.slotByNode[n.target]&&(p.get(n.id).sourceSide=t)}}!function(e,t,n){const o=new Map,r=[];for(const t of e)r.push({time:t.startTime,kind:"out",edge:t}),r.push({time:t.endTime,kind:"in",edge:t});r.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||cn(e.edge.id,t.edge.id));const i=e=>{let t=o.get(e);return t||(t={top:0,bot:0},o.set(e,t)),t},a=(e,t,n)=>{const o="top"===t?"bot":"top",r=Math.min(n,e[t]);e[t]-=r;const i=n-r;i>0&&(e[o]=Math.max(0,e[o]-i))};for(const e of r){const{edge:o}=e;if("in"===e.kind){const e=t.get(o.id)?.targetSide??"bot";i(o.target)[e]+=o.value;continue}const r=i(o.source),s=t.get(o.id);let c=s.sourceSide??"bot";if(n[o.source]===n[o.target]){const e=r.top>=o.value,t=r.bot>=o.value;e!==t?c=e?"top":"bot":e||t||r.top===r.bot||(c=r.top>r.bot?"top":"bot"),s.sourceSide=c,s.targetSide=c}a(r,c,o.value)}}(t,p,b.slotByNode),function(e,t,n,o){for(const r of e){const e=t.incoming[r.id],i=t.outgoing[r.id];if(0===e.length||0===i.length)continue;const a=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===n.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of i)"top"===n.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const r=a(),s="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,c="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=s||0>=c)return!1;const l=Math.min(s,c),u=i.filter(t=>!o.has(t.id)&&n.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value||cn(e.id,t.id));return 0!==u.length&&(n.get(u[0].id).sourceSide=t,!0)};let c=i.length+1;for(;c-- >0&&(s("top","bot")||s("bot","top")););}}(e,m,p,k),y=sn();for(const t of e)y[t.id]=Ln(t,m,p,void 0,u);const x=io(e,t,y,m,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:"stack",groupPadding:g,ribbonLane:f,domain:h}),S=x.effectiveSlotsHeight??x.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),w=x.slots.slice(0,-1).reduce((e,t,n)=>e+(null!=t.group&&t.group===x.slots[n+1].group?1:0),0),M=Math.max(1,x.slots.length+1-w),P=Math.min(12,Math.max(0,.35*o-w*g)/M),L=2*P+un(x.slots,P,g).reduce((e,t)=>e+t,0),T=S>0?Math.max(0,(o-L)/S):1,A=Number.isFinite(c)&&c>0?Math.min(T,c):T;let D=io(e,t,y,m,{plotH:o,padding:P,valueScale:A,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:v,lanePlacement:l,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T});const I=Number.isFinite(c)&&c>0&&T>c+1e-12;if("insertion"!==a&&("hug"===l||I)&&D.slots.length>1&&(_n(e,t,y,D.laneLifetime,D.slots,D.slotByNode,{plotH:o,padding:P,valueScale:A,groupPadding:g,laneOrder:a,ribbonLane:f,domain:h,lanePlacement:l,mode:"geometry-refine"}),D=io(e,t,y,m,{plotH:o,padding:P,valueScale:A,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:D.slots,fixedSlotOrder:D.slots.map(ln),lanePlacement:l,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T})),function(e,t){const n=(e,n)=>{for(const o of e){const e=new Map;for(const r of o){const o=`${("out"===n?t.get(r.id)?.sourceSide:t.get(r.id)?.targetSide)??""}\0${"out"===n?r.startTime:r.endTime}`,i="out"===n?`${r.target}\0${r.endTime}`:`${r.source}\0${r.startTime}`,a=e.get(o);if(null!=a&&a!==i)return!0;e.set(o,i)}}return!1};return n(Object.values(e.outgoing),"out")||n(Object.values(e.incoming),"in")}(m,p)){const n=function(e,t,n,o){const r=new Map;for(const i of e){const e=t[i.source]?.localAttachments.get(i.id),a=t[i.target]?.localAttachments.get(i.id),s=n[i.source],c=n[i.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(c)))continue;const l=Pn(e,s,o),u=Pn(a,c,o);r.set(i.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return r}(t,y,D.centerlines,A);y=sn();for(const t of e)y[t.id]=Ln(t,m,p,n,u);D=io(e,t,y,m,{plotH:o,padding:P,valueScale:A,packing:i,laneOrder:a,lifetimeMode:s,frozenSlots:D.slots,fixedSlotOrder:D.slots.map(ln),lanePlacement:l,groupPadding:g,ribbonLane:f,domain:h,stackValueScale:T})}const E=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),C=[...D.slots].sort((e,t)=>(E.get(ln(e))??1/0)-(E.get(ln(t))??1/0)||cn(ln(e),ln(t))),N=sn();C.forEach((e,t)=>{for(const n of e.occupants)N[n.id]=t});const O=gn(e,t,y,C,N,{plotH:o,padding:P,valueScale:A,stackValueScale:T,lanePlacement:"stack",groupPadding:g}),B=ro(e,y,C,N,O.centerlines,A,g),$=Sn(Bn(N,t),$n(N,t),t,B,C,N,O.centerlines,D.laneLifetime,A,O.verticalUtilization,f,h);y=ro(e,y,D.slots,D.slotByNode,D.centerlines,A,g);const H=Sn(Bn(D.slotByNode,t),$n(D.slotByNode,t),t,y,D.slots,D.slotByNode,D.centerlines,D.laneLifetime,A,D.verticalUtilization,f,h);return{nodeData:y,sides:p,valueScale:A,padding:P,compressedPadding:12>P,centerlines:D.centerlines,laneLifetime:D.laneLifetime,slots:D.slots,slotByNode:D.slotByNode,crossingsBefore:"insertion"===a?null:$.crossings,crossingsAfter:"insertion"===a?null:H.crossings,lengthBefore:"insertion"===a?null:$.weightedLength,lengthAfter:"insertion"===a?null:H.weightedLength,layoutQualityBefore:$,layoutQuality:H}}(t,P,{plotH:x,...u,ribbonLane:a,domain:o}),{centerlines:D,nodeData:I,valueScale:E}=A,C=T(y,b),N=[],O=[],$=0===s?new Map:function(e,t,n){const o=new Set(t.map(e=>e.target)),r=new Map(e.map(e=>[e.id,e])),i=new Map;for(const e of t){if(o.has(e.source))continue;const t=i.get(e.source)??[];t.push(e),i.set(e.source,t)}const a=new Map;for(const t of e){if(!t.group)continue;const e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}const s=new Set;for(const[e,t]of a){const n=t.flatMap(e=>i.get(e.id)??[]),r=new Set(n.map(e=>e.startTime));n.length>0&&1===r.size&&t.every(e=>{const t=e.xExtent?.[0],r=n[0].startTime;return!o.has(e.id)&&(i.get(e.id)?.length??0)>0&&Number.isFinite(t)&&r>t})&&s.add(e)}const c=new Map;for(const[e,t]of i){const o=r.get(e);if(o?.group&&!s.has(o.group))continue;const i=o?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),l=a[0]?.startTime-1;let u=null;for(let e=0;a.length>e;){const t=a[e].startTime;let o=e+1;for(;a.length>o&&a[o].startTime===t;)o++;for(let t=e;o>t;t++){const e=a[t],o=Number.isFinite(i)&&e.startTime>i,r=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!o&&!r)continue;let s=n[0];o&&(s=Math.max(s,i)),r&&(s=Math.max(s,e.systemInTime)),!o&&r&&Number.isFinite(l)&&(s=Math.max(s,l)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&c.set(e.id,s)}u=t,e=o}}for(const[e,t]of a){if(!s.has(e))continue;const n=t.flatMap(e=>i.get(e.id)??[]);if(!n.every(e=>c.has(e.id))){for(const e of n)c.delete(e.id);continue}const o=Math.max(...n.map(e=>c.get(e.id)));for(const e of n)c.set(e.id,o)}return c}(t,P,o),H=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),R=new Map;for(const e of P){const t=I[e.source]?.localAttachments.get(e.id),n=I[e.target]?.localAttachments.get(e.id);t&&n&&R.set(e.id,Po(t,D[e.source],n,D[e.target],E,L,a,o,{minRun:s,sourceRunwayStart:$.get(e.id)}))}const F=function(e,t,n,o,r,i){const a=new Map(t),s=new Map;for(const t of e){const e=i?.get(t.source),n=null==e?"node:"+t.source:"group:"+e,o=s.get(n)??new Map,r=o.get(t.startTime)??[];r.push(t),o.set(t.startTime,r),s.set(n,o)}for(const e of s.values())for(const[i,s]of e){if(!s.some(e=>n.has(e.id)))continue;const e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const c=o(i),l=Math.min(...e.map(e=>e.sx));if(l>=c-1e-9)continue;const u=Math.max(...s.map(e=>{const t=n.get(e.id);return null==t?c:Math.min(c,o(t))})),d=Math.min(c,Math.max(l,u));for(const e of s){const n=t.get(e.id),o=d+(n.tx-d)*("source"===r?.85:"target"===r?.15:.5);a.set(e.id,{...n,sx:d,cp1X:o,cp2X:o})}}return a}(P,R,$,L,a,H),W=function(e,t,n,o,r){const i=new Map;for(const a of e){if(!n.has(a.id))continue;const e=t.get(a.id);if(!e||e.sx>=o(a.startTime)-1e-9)continue;const s=r(e.sx);Number.isFinite(s)&&a.startTime>s&&i.set(a.id,s)}return i}(P,F,$,L,e=>o[0]+e/k*(o[1]-o[0])),_=function(e,t,n){const o=new Map,r=new Map;for(const[e,t]of n??[]){const n=r.get(t)??[];n.push(e),r.set(t,n)}for(const i of e){const e=t.get(i.id);if(null==e||!Number.isFinite(e)||e>=i.startTime)continue;const a=n?.get(i.source),s=null==a?[i.source]:r.get(a)??[i.source];for(const t of s){const n=o.get(t)??new Map,r=n.get(i.startTime);n.set(i.startTime,null==r?e:Math.min(r,e)),o.set(t,n)}}return o}(P,W,H);t.forEach((e,t)=>{const n=I[e.id];if(!n||0===n.samples.length)return;const r=(i=n.samples,(a=_.get(e.id))&&0!==a.size?i.map(e=>{const t=a.get(e.t);return null==t?e:{...e,t:t}}):i);var i,a;const s=function(e,t,n,o,r){if(0===e.length)return null;const i=Mn(e,r),a=e=>t+(i[e].boundaryOffset??0)*n,s=e=>a(e)-i[e].topMass*n,c=e=>a(e)+i[e].botMass*n;let l=`M${o(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)l+=` L${o(i[e].t)},${s(e)}`;l+=` L${o(i[i.length-1].t)},${c(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${o(i[e].t)},${c(e)}`;return l+" Z"}(r,D[e.id],E,L,o);if(!s)return;const c=Mn(r,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],f=D[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*E/2;let h,g,m=l(e.id,t),y=m,b=.5;const v=e.__raw??e;if(p&&p.length>0){const e=B(v,p,C(v));"string"==typeof e.fill?m=e.fill:null!=e.fill&&Q(e.fill)&&(g=e.fill,m=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:m),"string"==typeof e.stroke&&(y=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(h=e.fillOpacity),"number"==typeof e.opacity&&null==h&&(h=e.opacity)}const k=function(e,t,n,o,r,i){const a=n.nodeData[e];if(!a||0===a.samples.length)return[];const s=n.valueScale,c=n.centerlines[e],l=Mn(a.samples,r),u=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],f=o(u.t),h=o(d.t),g=e=>o(wn(e,r)),m=[],p=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=a.localAttachments.get(n.id),t=i?.get(n.id)??n.startTime;if(e&&"out"===e.kind&&t>n.systemInTime){const o=g(n.systemInTime),i=g(t),a=null!=r&&r[0]>n.systemInTime,l=a?o:o-20,u=a?Math.min(i,o+20):o,d=Math.max(f,l);if(i>d){const[t,n]=Pn(e,c,s);m.push({pathD:p(d,t,i,n),x0:l,x1:u,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=a.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=g(n.systemOutTime),o=g(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,a]=Pn(e,c,s);m.push({pathD:p(o,n,i,a),x0:t,x1:r,from:1,to:0})}}}}return m}(e.id,P,A,L,o,W);N.push({id:e.id,pathD:s,fill:m,stroke:y,strokeWidth:b,...null!=h&&{fillOpacity:h},...g&&{hatchFill:g},...k.length>0&&{gradientStubs:k},rawDatum:v,labelX:L("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:f,labelText:e.label??e.id})});const z=new Map;t.forEach((e,t)=>z.set(e.id,t)),P.forEach(e=>{const t=F.get(e.id);if(!t)return;const n=z.get(e.source)??0,o=l(e.source,n),{pathD:r,bezier:i}=Ht(t),a=e.__raw??e,s="function"==typeof c?Number(c(a)):c,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;O.push({id:e.id,pathD:r,fill:o,opacity:u,rawDatum:a,bezier:i})});const j=function(e,t,n){const o=e.map(e=>({...e})),r=new Map;for(const e of o){const n=t[e.id];if(null==n)continue;const o=r.get(n)??[];o.push(e),r.set(n,o)}const i=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,o=(e.length-1)/2;e.forEach((e,r)=>{e.labelY=Math.max(8,Math.min(n-8,t+16*(r-o)))})};for(const e of r.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],n=-1/0;for(const o of e){const e=o.labelX-Lo(o.labelText);t.length>0&&e>n+3&&(i(t),t=[],n=-1/0),t.push(o),n=Math.max(n,o.labelX)}i(t)}return function(e,t){const n=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;n.length>e;e+=1){let t=8;for(let o=0;e>o;o+=1)Ao(n[e],n[o])&&(t=Math.max(t,n[o].labelY+16));n[e].labelY=Math.max(n[e].labelY,t)}for(let e=n.length-1;e>=0;e-=1){let o=t-8;for(let t=e+1;n.length>t;t+=1)Ao(n[e],n[t])&&(o=Math.min(o,n[t].labelY-16));n[e].labelY=Math.min(n[e].labelY,o)}}}(o,n),o}(N,A.slotByNode,x).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Io(e.pathD),gradientStubs:e.gradientStubs?.map(Co),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),X="vertical"===d?function(e,t,n){const o=e.map(e=>({...e}));for(const e of o){const n=1.22*Lo(e.labelText)+4;e.labelX=t-4>n?Math.max(n/2+2,Math.min(t-n/2-2,e.labelX)):t/2}const r=[],i=[...o].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of i){const t=r[r.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?r.push([e]):t.push(e)}for(const e of r){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],o=new Map;for(const n of e){const[e,r]=To(n);let i=t.findIndex(t=>e>t+8);-1===i&&(i=t.length),t[i]=r,o.set(n,i)}const r=e.reduce((e,t)=>e+t.labelY,0)/e.length,i=14*t.length+8>r;for(const t of e){const e=o.get(t)??0;t.labelY=i?Math.min(n-8,12+14*e):Math.max(8,r-14*e)}}return o}(j,r,i):j,Y=new Map;if(null!=h)for(const e of t){const t=e.__raw??e,n="function"==typeof h?h(t):Number(t[h]);Number.isFinite(n)&&Y.set(e.id,n)}const G=function(e,t,n,o,r={}){if(!1===o)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===o)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let i=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*n)/14e3)));Number.isFinite(r.maxLabels)&&r.maxLabels>=0&&(i=Math.min(i,Math.floor(r.maxLabels)));const a=e.map((e,t)=>{const n=r.priorityById?.get(e.id),o=Math.abs(e.labelY);return{band:e,index:t,score:null!=n&&Number.isFinite(n)?1e6*n+Lo(e.labelText):Lo(e.labelText)+.01*o}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(a.slice(0,i).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(X,r,i,f,{...Y.size>0&&{priorityById:Y},...null!=g&&{maxLabels:g}});return{layout:A,layoutConfig:{bands:G,ribbons:O.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Io(e.pathD),bezier:Eo(e.bezier)}}(e,d)),showLabels:!1!==f,selectionDatum:m},issues:[],warnings:M,xScale:L}}import{scaleTime as Oo}from"d3-scale";function Bo(e,t,n,o="reuse",r="crossing-min",i=5e4){return"sync"!==e&&("worker"===e||function(e,t,n="reuse",o="crossing-min"){return e*e*("reuse"===n?80:1)+t*t*(o&&"insertion"!==o?40:1)+10*(e+t)}(t,n,o,r)>=i)}function $o(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Ho(e){if(!e)return null;const t=e.sides,n=t instanceof Map?t:new Map(Array.isArray(t)?t:[]);return{...e,sides:n}}var Ro=class{constructor(t=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./processSankeyLayoutWorker.js",import.meta.url):b("processSankeyLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-process-sankey-layout"})}()){this.session=new e({name:"ProcessSankey layout",createWorker:()=>t,parseMessage:e=>{const t=e,{requestId:r,error:i}=o(t);return i?{requestId:r,ok:!1,error:n(i)}:{requestId:r,ok:!0,payload:{layout:Ho(t.layout),layoutConfig:t.layoutConfig??{bands:[],ribbons:[],showLabels:!0},issues:t.issues??[],warnings:t.warnings??[],domain:t.domain??[0,1],timelineExtent:t.timelineExtent??0}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Fo=t(()=>new Ro);function Wo(e){if(function(e){if(!e||0===e.length)return!1;for(const t of e){if("function"==typeof t.when)return!0;if("function"==typeof t.style)return!0}return!1}(e.styleRules))return!0;if("function"==typeof e.edgeOpacity)return!0;if("function"==typeof e.labelPriorityAccessor)return!0;if(e.styleRules&&e.styleRules.length>0){if("function"==typeof e.colorBy)return!0;if("function"==typeof e.valueAccessor)return!0}return!1}function _o(e){if(null!=e&&"object"==typeof e){try{if("function"==typeof structuredClone)return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return}}}function zo(e){const t=_o(e.__raw);return{id:e.id,...null!=e.label&&{label:e.label},...null!=e.group&&{group:e.group},...null!=e.xExtent&&{xExtent:e.xExtent},...null!=t&&{__raw:t}}}function jo(e){const t=_o(e.__raw);return{id:e.id,source:e.source,target:e.target,value:e.value,startTime:e.startTime,endTime:e.endTime,...null!=e.systemInTime&&{systemInTime:e.systemInTime},...null!=e.systemOutTime&&{systemOutTime:e.systemOutTime},...null!=t&&{__raw:t}}}var Xo=(e,t)=>({layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:[],warnings:[],xScale:wo().domain(e).range([0,t])});function Yo(e,t){const n=z(),{execution:o="auto",workerThreshold:r,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:c}=t,l=ko(()=>Object.keys(i).sort().map(e=>`${e}:${i[e]}`).join("|"),[i]),u=ko(()=>e?[e.nodes,e.edges,e.plotW,e.plotH,e.orientation??"horizontal",e.ribbonLane,(e.ribbonMinRun??0)+"",e.edgeOpacity,(e.showLabels??!0)+"",e.layoutOpts.pairing??"temporal",e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",e.layoutOpts.lifetimeMode??"half",e.layoutOpts.maxValueScale??"",e.layoutOpts.lanePlacement??"stack",e.layoutOpts.nodeSizing??"temporal",e.layoutOpts.groupPadding??0,e.domain[0],e.domain[1],e.styleRules,l]:"null",[e,l]),d=!!e&&!n&&function(e,t,n){return"undefined"!=typeof window&&!!$o()&&!Wo(e)&&Bo(t,e.nodes.length,e.edges.length,e.layoutOpts.packing??"reuse",e.layoutOpts.laneOrder??"crossing-min",n)}(e,o,r),f=ko(()=>e?d?null:No(e):Xo([0,1],1),[u,d,e]),h=xo(n),[g,m]=So(()=>e?n?{...No(e),status:"ready",error:null}:d?{...Xo(e.domain,"vertical"===e.orientation?e.plotH:e.plotW),status:"pending",error:null}:{...No(e),status:"ready",error:null}:{...Xo([0,1],1),status:"ready",error:null});return vo(()=>{if(h.current)return void(h.current=!1);if(!e||!d)return;const t=new AbortController;return m(e=>({...e,status:"pending",error:null})),async function(e,t){const{execution:n="auto",workerThreshold:o,signal:r,colorById:i,fallbackPalette:a=["#475569"],rawNodeById:s=new Map,rawEdgeById:c=new Map}=t,l=e.layoutOpts.packing??"reuse",u=e.layoutOpts.laneOrder??"crossing-min";if(!$o()||Wo(e)||!Bo(n,e.nodes.length,e.edges.length,l,u,o))return No(e);try{const t=await function(e,t){return $o()?Fo.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(function(e,t,n){return{input:{nodes:e.nodes.map(zo),edges:e.edges.map(jo),domain:e.domain,plotW:e.plotW,plotH:e.plotH,orientation:e.orientation,ribbonLane:e.ribbonLane,ribbonMinRun:e.ribbonMinRun,edgeOpacity:"number"==typeof e.edgeOpacity?e.edgeOpacity:.35,layoutOpts:{...e.layoutOpts},showLabels:e.showLabels,..."string"==typeof e.labelPriorityAccessor&&{labelPriorityAccessor:e.labelPriorityAccessor},...null!=e.maxLabels&&{maxLabels:e.maxLabels},...null!=e.selectionDatum&&{selectionDatum:e.selectionDatum},...null!=e.usageMode&&{usageMode:e.usageMode},styleRules:e.styleRules,colorBy:"string"==typeof e.colorBy?e.colorBy:void 0,valueAccessor:"string"==typeof e.valueAccessor?e.valueAccessor:void 0},colorById:t,fallbackPalette:n}}(e,i,a),r);return function(e,t,n){const o=(e.layoutConfig.bands??[]).map(e=>({...e,rawDatum:t.get(e.id)??{id:e.id}})),r=(e.layoutConfig.ribbons??[]).map(e=>({...e,rawDatum:n.get(e.id)??{id:e.id}})),i=Oo().domain(e.domain).range([0,e.timelineExtent]);return{layout:e.layout,layoutConfig:{bands:o,ribbons:r,showLabels:e.layoutConfig.showLabels},issues:e.issues,warnings:e.warnings,xScale:i}}(t,s,c)}catch(t){if("AbortError"===t?.name)throw t;return No(e)}}(e,{execution:o,workerThreshold:r,signal:t.signal,colorById:i,fallbackPalette:a,rawNodeById:s,rawEdgeById:c}).then(e=>{m({...e,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&m(t=>({...t,status:"error",error:e}))}),()=>t.abort()},[u,d,o,r,a,s,c]),f?{...f,status:"ready",error:null}:g}import{useCallback as Go,useMemo as qo,useRef as Vo,useState as Ko}from"react";function Uo(e,t){return"function"==typeof e?e(t):t[e]}import{useCallback as Qo,useMemo as Zo}from"react";var Jo=.22;function er(e,t,n){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,n))}var tr=e=>{const{bands:t=[],ribbons:n=[],showLabels:o=!0,selectionDatum:r="raw"}=e.config,i=e.selection??null,a=[];for(const e of n){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},n=!er(t,i,r);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:n?Math.min(e.opacity,Jo):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!er({__kind:"band",data:e.rawDatum,id:e.id},i,r);for(let n=0;e.gradientStubs.length>n;n++){const o=e.gradientStubs[n];a.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?Jo:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,...null!=o.y0&&{y0:o.y0},...null!=o.y1&&{y1:o.y1},from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${n}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),n={__kind:"band",data:e.rawDatum,id:e.id},o=!er(n,i,r);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:o?Jo:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...o&&t?{opacity:Jo}:{}},datum:n})}const s=o?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),n=e.labelText.trim().length>0,o=t&&i?.isActive&&er({__kind:"band",data:e.rawDatum,id:e.id},i,r),a=n?e.labelText:o?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:a,labels:s}};function nr(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as or,jsx as rr,jsxs as ir}from"react/jsx-runtime";import{jsx as ar,jsxs as sr}from"react/jsx-runtime";var cr=ao(function(e,t){const{nodes:n,edges:o,domain:r,axisTicks:i=[],nodeIdAccessor:a="id",nodeLabel:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:f="value",startTimeAccessor:g="startTime",endTimeAccessor:m="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:y,xExtentAccessor:b="xExtent",groupBy:v,edgeIdAccessor:k="id",colorBy:x,colorScheme:w,showLegend:M,legendPosition:P="right",orientation:T="horizontal",pairing:D="temporal",packing:C="reuse",laneOrder:N="crossing-min",maxValueScale:O,lanePlacement:B="stack",nodeSizing:$="temporal",groupPadding:H=0,ribbonLane:R="both",ribbonMinRun:F=0,lifetimeMode:W="half",showLaneRails:_=!1,showQualityReadout:z=!1,showLabels:j=!0,labelPriorityAccessor:X,maxLabels:Y,selectionDatum:G="raw",styleRules:q,layoutExecution:K="auto",layoutWorkerThreshold:U,layoutLoadingContent:Q,onLayoutStateChange:Z,width:J=600,height:ee=400,margin:te,title:ne,description:oe,summary:re,accessibleTable:ie,responsiveWidth:ae,responsiveHeight:se,loading:ce,loadingContent:le,emptyContent:ue,edgeOpacity:de=.35,timeFormat:fe,valueFormat:he,tooltip:ge,enableHover:me=!0,onObservation:pe,onClick:ye,selection:be,linkedHover:ve,showParticles:ke=!1,particleStyle:xe,chartId:we,frameProps:Me={}}=e,Le=co(null),Te=co(null),{rawNodes:Ae,rawEdges:De,frameRef:Ie,getNodeId:Ee,getEdgeId:Ce}=function(e){const{ref:t,rawNodesProp:n,rawEdgesProp:o,nodeIdAccessor:r,edgeIdAccessor:i,sourceAccessor:a,targetAccessor:c,scalesRef:l,layoutSnapshotRef:u}=e,[d,f]=Ko([]),[h,g]=Ko([]),m=Vo(d),p=Vo(h);m.current=d,p.current=h;const y=Go(e=>{m.current=e,f(e)},[]),b=Go(e=>{p.current=e,g(e)},[]),v=void 0!==o,k=L(v?o:d),x=qo(()=>{const e=L(n??[]),t=h;if(0===e.length&&0===t.length)return Se([],k,a,c);const o=new Set,i=[];for(const t of e){const e=Uo(r,t)+"";o.has(e)||(o.add(e),i.push(t))}for(const e of t){const t=Uo(r,e)+"";o.has(t)||(o.add(t),i.push(e))}const s=Se([],k,a,c);for(const e of s)o.has(e.id)||(o.add(e.id),i.push(e));return i},[n,h,k,r,a,c]),S=Vo(null),w=Go((e,t)=>{const n=Uo(i,e);return null!=n?n+"":`${Uo(a,e)}-${Uo(c,e)}-${t}`},[i,a,c]),M=Go(e=>{if(null==e)return!1;const t=e;return null!=Uo(a,t)&&null!=Uo(c,t)},[a,c]),P=Go(e=>Uo(r,e)+"",[r]);return s(t,{variant:"network",frameRef:S,overrides:{push(e){if(M(e)){if(v)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");y([...m.current,e])}else b([...p.current,e])},pushMany(e){const t=[],n=[];for(const o of e)M(o)?t.push(o):n.push(o);t.length>0&&(v?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):y([...m.current,...t])),n.length>0&&b([...p.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!v){const e=m.current,o=[];for(let r=0;e.length>r;r++){const i=e[r];t.has(w(i,r))?n.push(i):o.push(i)}o.length!==e.length&&y(o)}const o=p.current,i=[];for(const e of o){const o=Uo(r,e)+"";t.has(o)?n.push(e):i.push(e)}return i.length!==o.length&&b(i),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!v){let e=!1;const r=m.current.map((r,i)=>n.has(w(r,i))?(o.push(r),e=!0,t(r)):r);e&&y(r)}let i=!1;const a=p.current.map(e=>{const a=Uo(r,e)+"";return n.has(a)?(o.push(e),i=!0,t(e)):e});return i&&b(a),o},clear(){v||y([]),b([]),S.current?.clear()},getData:()=>k??[],getScales:()=>l.current,getCustomLayout:()=>u.current}}),{rawNodes:x,rawEdges:k,frameRef:S,getNodeId:P,getEdgeId:w,isControlled:v}}({ref:t,rawNodesProp:n,rawEdgesProp:o,nodeIdAccessor:a,edgeIdAccessor:k,sourceAccessor:u,targetAccessor:d,scalesRef:Le,layoutSnapshotRef:Te}),{nodes:Ne,edges:Oe,domain:Be,rawNodeById:$e,rawEdgeById:He}=so(()=>{const e=(Ae??[]).map(e=>{const t=Ee(e),n=c?Uo(c,e):t,o={id:t,label:null==n?t:n+"",__raw:e},r=v?Uo(v,e):null;null!=r&&r+""!=""&&(o.group=r+"");const i=b?Uo(b,e):null;if(Array.isArray(i)&&2===i.length){const e=en(i[0]),t=en(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),t=(De??[]).map((e,t)=>{const n={id:Ce(e,t),source:Uo(u,e)+"",target:Uo(d,e)+"",value:Number(Uo(f,e)),startTime:en(Uo(g,e)),endTime:en(Uo(m,e)),__raw:e};if(p){const t=en(Uo(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(y){const t=en(Uo(y,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[en(r[0]),en(r[1])],o=new Map;for(const t of e)null!=t.__raw&&o.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:o,rawEdgeById:i}},[Ae,De,r,Ee,Ce,c,b,v,u,d,f,g,m,p,y]),Re=Pe({nodes:Ae,edges:De,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:u,targetAccessor:d,colorBy:x,colorScheme:w,showLegend:!1,legendPosition:P,frameLegend:Me,selection:be,linkedHover:ve,onObservation:pe,onClick:ye?(e,t)=>{nr(e)?ye(e.data,t):ye(e,t)}:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:we,marginDefaults:fo(!!ne,z,i.length>0,T),userMargin:te,width:J,height:ee,hasTitle:!!ne,loading:ce,loadingContent:le,emptyContent:ue}),Fe=Object.hasOwn(Me,"legend"),We=!Fe&&(M??!!x)&&!!x,_e=lo((e,t)=>{if(x&&Ae){const t=$e.get(e);if(t)return V(t,x,Re.colorScale)}return Re.effectivePalette[t%Re.effectivePalette.length]||"#475569"},[x,Ae,$e,Re.colorScale,Re.effectivePalette]),ze=so(()=>{if(!We||!x)return;const e=new Map;(Ae??[]).forEach((t,n)=>{const o=Uo(x,t),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:_e(Ee(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[We,x,Ae,_e,Ee]),je=Fe?Me.legend:ze,Xe=so(()=>{const e={...Re.margin};if(je){const t={...e};E(e,{legend:je,position:Re.legendPosition,size:[J,ee],hasTitle:!!ne,legendLayout:Me.legendLayout,minimumMargin:"right"===Re.legendPosition||"left"===Re.legendPosition?140:"top"===Re.legendPosition?50:80}),S(e,t,[J,ee],Re.legendPosition)}return e},[Re.margin,Re.legendPosition,je,J,ee,ne,Me.legendLayout]),Ye=J-Xe.left-Xe.right,Ge=ee-Xe.top-Xe.bottom,qe="vertical"===T?Ge:Ye,Ve=Yo(so(()=>Ye>0&&Ge>0?{nodes:Ne,edges:Oe,domain:Be,plotW:Ye,plotH:Ge,orientation:T,ribbonLane:R,ribbonMinRun:F,edgeOpacity:"function"==typeof de?e=>de(e):de,colorOf:_e,showLabels:j,labelPriorityAccessor:X,maxLabels:Y,selectionDatum:G,styleRules:q,usageMode:"push",colorBy:x,valueAccessor:f,layoutOpts:{pairing:D,packing:C,laneOrder:N,lifetimeMode:W,maxValueScale:O,lanePlacement:B,nodeSizing:$,groupPadding:H}}:null,[Ne,Oe,Be,Ye,Ge,T,R,F,de,_e,j,X,Y,G,q,x,f,D,C,N,W,O,B,$,H]),{execution:K,workerThreshold:U,colorById:so(()=>Object.fromEntries(Ne.map((e,t)=>[e.id,_e(e.id,t)])),[Ne,_e]),fallbackPalette:Re.effectivePalette,rawNodeById:$e,rawEdgeById:He}),{issues:Ke,warnings:Ue,layout:Qe,xScale:Ze}=Ve,Je=Ve.layoutConfig,et=Ve.status;Le.current=Qe?{time:Ze,centerlines:Qe.centerlines}:{time:Ze},Te.current=Qe?{layout:Qe,nodes:Ne,edges:Oe,bands:Je.bands,ribbons:Je.ribbons,warnings:Ue,status:et}:null;const tt=co(Z);tt.current=Z,uo(()=>{tt.current?.(et)},[et]),uo(()=>{0!==Ue.length&&console.warn("ProcessSankey warnings:",Ue.map(Kt).join("; "))},[Ue]);const nt=void 0!==je&&!Object.hasOwn(Me,"margin"),ot=function(e){const{tooltip:t,enableHover:n,layout:o,timeFormat:r,valueFormat:i,sourceAccessor:a,targetAccessor:s,valueAccessor:c,startTimeAccessor:l,endTimeAccessor:u}=e,d=Zo(()=>!1!==t&&n?void 0===t||!0===t?null:A(t)||null:null,[t,n]),f=Qo(e=>r?r(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[r]),h=Qo(e=>i?i(e):e+"",[i]);return Qo(e=>{if(!e||!e.data)return null;const t=e.data;if(!nr(t))return null;const n=t.data;if(d)return d(n);if("band"===t.__kind){const e=t.id,n=o?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,r=`${o.t}:${e}`;t.has(r)||(t.add(r),n.push({t:o.t,total:e}))}return n}(o.nodeData[e]):[],r=5,i=n.length>r?n.length:null,a=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,r=[{...n[0],mark:"min"},{...n[Math.floor(.25*o)],mark:"q25"},{...n[Math.floor(.5*o)],mark:"median"},{...n[Math.floor(.75*o)],mark:"q75"},{...n[o],mark:"max"}],i=new Set,a=[];for(const e of r)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,r);return ir("div",{style:{minWidth:160},children:[rr("div",{style:{fontWeight:600,marginBottom:4},children:e}),a.length>0&&ir("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[rr("thead",{children:ir("tr",{style:{opacity:.6},children:[rr("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),rr("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&rr("th",{})]})}),rr("tbody",{children:a.map((e,t)=>ir("tr",{children:[rr("td",{style:{paddingRight:8},children:f(e.t)}),rr("td",{style:{textAlign:"right"},children:h(e.total)}),null!=i&&rr("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&ir("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",a.length," of ",i," samples"]})]})}const r=n,i=Uo(a,r),g=Uo(s,r),m=Uo(c,r),p=Uo(l,r),y=Uo(u,r);return ir("div",{style:{minWidth:160},children:[ir("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",g+""]}),ir("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=m&&ir(or,{children:[rr("span",{style:{opacity:.6},children:"value"}),rr("span",{style:{textAlign:"right"},children:h(Number(m))})]}),null!=p&&ir(or,{children:[rr("span",{style:{opacity:.6},children:"start"}),rr("span",{style:{textAlign:"right"},children:f(en(p))})]}),null!=y&&ir(or,{children:[rr("span",{style:{opacity:.6},children:"end"}),rr("span",{style:{textAlign:"right"},children:f(en(y))})]})]})]})},[o,d,f,h,a,s,c,l,u])}({tooltip:ge,enableHover:me,layout:Qe,timeFormat:fe,valueFormat:he,sourceAccessor:u,targetAccessor:d,valueAccessor:f,startTimeAccessor:g,endTimeAccessor:m}),rt=so(()=>{if(!Qe)return null;const e=Ue.map(e=>Kt(e));return function(e){const t=e.layout,n=e.nodes,o=e.orientation,r=e.plotW,i=e.plotH,a=e.timelineExtent,s=e.axisTicks,c=e.showQualityReadout??!1,l=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,f=e.colorOf,h=e.toTime,g=e.xScale,{centerlines:m,laneLifetime:p,nodeData:y,valueScale:b,compressedPadding:v,crossingsBefore:k,crossingsAfter:x,layoutQualityBefore:S,layoutQuality:w}=t;let M=null,P=null;for(const e of n){const t=p[e.id];if(!t||null===t.start||null===t.end)continue;const n=g(t.start),o=g(t.end);(null===M||M>n)&&(M=n),(null===P||o>P)&&(P=o)}const L=e=>Math.max(0,Math.min(a,e)),T=L(M??0),A=Math.max(T,L(P??a)),D=s.map((e,t)=>({tick:e,index:t,coordinate:g(h(e.date))})).filter(({coordinate:e})=>e>=T-.5&&A+.5>=e),I=null!==(x??null)&&null!=S&&null!=w,E=c&&(I||u.length>0)?mo("g",{fill:bo,fontSize:10,textAnchor:"end",children:[I&&mo(ho,{children:[mo("text",{x:r,y:-14,children:["crossings: ",k," → ",x," ","pixel length: ",Math.round(S.pixelLength)," → ",Math.round(w.pixelLength)]}),mo("text",{x:r,y:-3,children:["transit: ",S.transitOcclusion.toFixed(1)," → ",w.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*w.verticalUtilization),"%"]})]}),u.map((e,t)=>mo("text",{x:r,y:I?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,C=v?go("text",{x:r,y:"vertical"===o?-3:2,fontSize:10,fill:bo,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,N=(e,t)=>f?f(e,t):po;return mo("g","vertical"===o?{children:[E,C,D.map(({index:e,coordinate:t})=>go("line",{x1:0,y1:t,x2:r,y2:t,stroke:po,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),l&&n.map((e,t)=>{const n=p[e.id];if(!n||null===n.start)return null;const o=y[e.id],r=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},i=m[e.id]+(r.botPeak-r.topPeak)*b/2,a=g(n.start),s=g(n.end),c=N(e.id,t);return mo("g",{children:[go("line",{x1:i,y1:a,x2:i,y2:s,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),go("line",{x1:i-4,y1:a,x2:i+4,y2:a,stroke:c,strokeOpacity:.5}),go("line",{x1:i-4,y1:s,x2:i+4,y2:s,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),go("line",{x1:-4,y1:T,x2:-4,y2:A,stroke:po}),D.map(({tick:e,index:t,coordinate:n})=>{const o=h(e.date),r=null!=e.label?e.label:d?d(new Date(o)):"";return mo("g",{transform:`translate(-4,${n})`,children:[go("line",{x2:-6,stroke:po}),go("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:yo,children:r})]},t)})]}:{children:[E,C,D.map(({index:e,coordinate:t})=>go("line",{x1:t,y1:0,x2:t,y2:i,stroke:po,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),l&&n.map((e,t)=>{const n=p[e.id];if(!n||null===n.start)return null;const o=y[e.id],r=o?{topPeak:o.topPeak,botPeak:o.botPeak}:{topPeak:0,botPeak:0},i=m[e.id]+(r.botPeak-r.topPeak)*b/2,a=g(n.start),s=g(n.end),c=N(e.id,t);return mo("g",{children:[go("line",{x1:a,y1:i,x2:s,y2:i,stroke:c,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),go("line",{x1:a,y1:i-4,x2:a,y2:i+4,stroke:c,strokeOpacity:.5}),go("line",{x1:s,y1:i-4,x2:s,y2:i+4,stroke:c,strokeOpacity:.5})]},"lane-"+e.id)}),go("line",{x1:T,y1:i+4,x2:A,y2:i+4,stroke:po}),D.map(({tick:e,index:t,coordinate:n})=>{const o=h(e.date),r=null!=e.label?e.label:d?d(new Date(o)):"";return mo("g",{transform:`translate(${n},${i+4})`,children:[go("line",{y2:6,stroke:po}),go("text",{y:20,textAnchor:"middle",fontSize:11,fill:yo,children:r})]},t)})]})}({layout:Qe,nodes:Ne,orientation:T,plotW:Ye,plotH:Ge,timelineExtent:qe,axisTicks:i,showQualityReadout:z,showLaneRails:_,warnings:e,timeFormat:fe?e=>fe(e):void 0,colorOf:_e,toTime:en,xScale:e=>Number(Ze(e))})},[Qe,Ne,T,Ye,Ge,qe,i,z,_,Ue,fe,_e,Ze]),it=so(()=>(Ae??[]).map(e=>({id:Ee(e),data:e})),[Ae,Ee]),at=so(()=>{const e=new Map;for(const t of Je.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Je]),st=so(()=>(De??[]).map((e,t)=>{const n=Ce(e,t),o=Number(Uo(f,e));return{id:n,source:Uo(u,e)+"",target:Uo(d,e)+"",value:Number.isFinite(o)?o:0,bezier:at.get(n),data:e}}),[De,Ce,u,d,f,at]);return Ke.length>0?sr("svg",{width:J,height:ee,role:"img","aria-label":ne??"Process Sankey validation failed",children:[ar("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ke.map((e,t)=>ar("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Kt(e)},t))]}):Re.loadingEl?Re.loadingEl:Re.emptyEl?Re.emptyEl:sr("div",{style:{position:"relative",width:J,height:ee},children:["pending"===et&&!1!==Q&&!Qe&&ar("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:I(!0,J,ee,Q)}),ar(l,{ref:Ie,chartType:"force",nodes:it,edges:st,customNetworkLayout:tr,layoutConfig:Je,size:[J,ee],responsiveWidth:ae,responsiveHeight:se,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Xe,title:ne,description:oe??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:re,accessibleTable:ie,enableHover:me,tooltipContent:!1===ge?()=>null:ot,backgroundGraphics:rt,showParticles:ke,particleStyle:xe,legend:je,legendPosition:Re.legendPosition,...nt&&{__legendMarginReservedFor:je},...h({linkedHover:ve,selection:be,onObservation:pe,onClick:ye,mobileInteraction:Re.mobileInteraction,customHoverBehavior:Re.customHoverBehavior,customClickBehavior:Re.customClickBehavior,linkedHoverInClickPredicate:!1}),chartId:we,colorScheme:Array.isArray(w)?w:void 0,layoutSelection:Re.effectiveSelectionHook,...Me})]})});cr.displayName="ProcessSankey";import{useMemo as lr}from"react";import{hierarchy as ur,tree as dr,cluster as fr,treemap as hr,pack as gr,partition as mr,treemapBinary as pr}from"d3-hierarchy";var yr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function br(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function vr(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function kr(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 xr(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:yr}function Sr(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 wr(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}var Mr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;if(!r)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,l=ur(r,a);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=o;switch(i){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=dr();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=fr();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,o){const r=t.padding??4,i=t.paddingTop??0,a=hr().size([n,o]).tile(pr).padding(r);i>0&&a.paddingTop(i),a(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,o){const r=t.padding??4;gr().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){mr().size([n,o]).padding(t.padding??1)(e)}(l,n,u,d)}const f=l.descendants();e.length=0,t.length=0;const h=new Map;for(let t=0;f.length>t;t++){const o=f[t],r={id:vr(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===i||"cluster"===i?Pr(r,o,n):"treemap"===i||"partition"===i?Lr(r,o):"circlepack"===i&&Tr(r,o),r.__hierarchyNode=o,e.push(r),h.set(o,r)}if("tree"===i||"cluster"===i)for(const e of f)if(e.parent){const n=h.get(e.parent),o=h.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){const a=[],s=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=o[0]/2,f=o[1]/2,h="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,o=t.y;u&&(e+=d,o+=f);const i=r(ue(t,"nodeStyle"));let s=i.fill||Sr(n);if(n.colorByDepth&&void 0!==t.depth){const e=xr(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:o,r:h,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity,cursor:i.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const m=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,a=t.y,c=o.x,h=o.y;u&&(r+=d,a+=f,c+=d,h+=f);const g=wr(r,a,c,h,l),p=i(ue(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:p.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??m,cursor:p.cursor},datum:e})}if(!1!==n.showLabels){const t=kr(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,a=n.x,s=n.y;if(u&&(a+=d,s+=f),u){const e=a-d,t=s-f,n=Math.sqrt(e*e+t*t);n>0?(o=a+e/n*10,r=s+t/n*10,i=0>e?"end":"start"):(o=a,r=s-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(o=a-h-6,i="end"):(o=a+h+6,i="start"),r=s):(o=a,r=s+h+14,i="middle");c.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:c}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=o(ue(n,"nodeStyle"));let s=a.fill||Sr(t);if(t.colorByDepth&&void 0!==n.depth){const e=xr(t);s=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,fillOpacity:a.fillOpacity,strokeOpacity:a.strokeOpacity,cursor:a.cursor},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=kr(t.nodeLabel),r=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const l=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(s):s.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=o(ue(s,"nodeStyle")).fill||Sr(t);if(t.colorByDepth&&void 0!==s.depth){const e=xr(t);d=e[s.depth%e.length]}const f="string"==typeof d?br(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:f}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:f})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);case"circlepack":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=o(ue(n,"nodeStyle"));let a=i.fill||Sr(t);if(t.colorByDepth&&void 0!==n.depth){const e=xr(t);a=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7,cursor:i.cursor},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=kr(t.nodeLabel);for(const r of e){const e=r.__radius??5,a=n?n(r):r.id;if(!a)continue;if(15>e)continue;const s=!(r.data?.children&&r.data.children.length>0);let c=o(ue(r,"nodeStyle")).fill||Sr(t);if(t.colorByDepth&&void 0!==r.depth){const e=xr(t);c=e[r.depth%e.length]}if(s){const n="string"==typeof c?br(c):t.themeSemantic?.text??"#000";i.push({x:r.x,y:r.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:r.x,y:r.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Pr(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Lr(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 Tr(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}u("tree",Mr),u("cluster",Mr),u("treemap",Mr),u("circlepack",Mr),u("partition",Mr);import{jsx as Ar}from"react/jsx-runtime";function Dr(e){const t=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:o,className:r,layout:i="tree",orientation:s="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:f,colorScheme:m,colorByDepth:p=!1,styleRules:y,edgeStyle:b="curve",nodeLabel:k,nodeSize:S=5,tooltip:M,frameProps:P={},onObservation:L,onClick:D,chartId:I,selection:E,linkedHover:C,loading:O,loadingContent:B,legendInteraction:$,legendPosition:R,stroke:F,strokeWidth:W,opacity:_}=e,{width:z,height:j,enableHover:X,showLegend:Y,showLabels:q=!0,title:K,description:U,summary:Q,accessibleTable:Z}=t,J=Pe({nodes:lr(()=>xe(n??null,c),[n,c]),edges:void 0,inferNodes:!1,colorBy:p?void 0:f,colorScheme:m,showLegend:Y,legendPosition:R,legendInteraction:$,frameLegend:P,selection:E,linkedHover:C,onObservation:L,onClick:D,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:I,marginDefaults:t.marginDefaults,userMargin:o,width:z,height:j,hasTitle:!!K,loading:O,loadingContent:B}),ee=lr(()=>new Map,[]),te=lr(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?G[(e.depth||0)%G.length]:f?V(e.data||e,f,J.colorScale):N(void 0,J.themeCategorical,m,void 0,ee),t},[f,p,J.colorScale,J.themeCategorical,m,ee]),ne=lr(()=>T(f,u),[f,u]),oe=lr(()=>w(te,y,ne,e=>e.data||e),[te,y,ne]),re=lr(()=>g(oe,{stroke:F,strokeWidth:W,opacity:_}),[oe,F,W,_]),ie=lr(()=>ve(re,J.effectiveSelectionHook,J.resolvedSelection),[re,J.effectiveSelectionHook,J.resolvedSelection]),ae=lr(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),se=lr(()=>g(ae,{stroke:F,strokeWidth:W,opacity:_}),[ae,F,W,_]),ce=lr(()=>ke(se,J.effectiveSelectionHook,J.resolvedSelection),[se,J.effectiveSelectionHook,J.resolvedSelection]),le=lr(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return we(u)},[i,u]),ue=a({componentName:"TreeDiagram",data:n});return ue?Ar(v,{componentName:"TreeDiagram",message:ue,width:z,height:j}):J.loadingEl?J.loadingEl:Ar(x,{componentName:"TreeDiagram",width:z,height:j,children:Ar(l,{chartType:i,...null!=n&&{data:n},size:[z,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:J.margin,...J.legendBehaviorProps,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:le,treeOrientation:s,edgeType:b,nodeStyle:ie,edgeStyle:ce,colorBy:f,colorScheme:J.effectivePalette,colorByDepth:p,nodeSize:S,nodeLabel:q?k||d:void 0,showLabels:q,enableHover:X,tooltipContent:!1===M?()=>null:A(M)||void 0,...h({linkedHover:C,selection:E,onObservation:L,onClick:D,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:r,title:K,description:U,summary:Q,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...P})})}u("tree",Mr),u("cluster",Mr),u("treemap",Mr),u("circlepack",Mr),u("partition",Mr),Dr.displayName="TreeDiagram";import{useMemo as Ir,useCallback as Er}from"react";import{jsx as Cr}from"react/jsx-runtime";function Nr(e){const t=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:o,className:r,childrenAccessor:i="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:f=!1,styleRules:m,labelMode:p="leaf",nodeLabel:y,padding:b=4,paddingTop:k,nodeStyle:S,tooltip:M,frameProps:P={},selection:L,linkedHover:D,onObservation:I,onClick:E,chartId:C,loading:O,loadingContent:B,legendInteraction:$,legendPosition:R,stroke:F,strokeWidth:W,opacity:_}=e,{nodeStyle:z,...j}=P,{width:X,height:Y,enableHover:q,showLegend:K,showLabels:U=!0,title:Q,description:Z,summary:J,accessibleTable:ee}=t,te=Pe({nodes:Ir(()=>xe(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:f?void 0:u,colorScheme:d,showLegend:K,legendPosition:R,legendInteraction:$,frameLegend:j,selection:L,linkedHover:D,onObservation:I,onClick:E,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:C,marginDefaults:t.marginDefaults,userMargin:o,width:X,height:Y,hasTitle:!!Q,loading:O,loadingContent:B}),ne=te.customHoverBehavior,oe=Er(e=>{if(!e)return ne(null);const t=e.data||e;ne({data:t?.data||t})},[ne]),re=Ir(()=>new Map,[]),ie=Ir(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=f?G[(e.depth||0)%G.length]:u?V(e.data||e,u,te.colorScale):N(void 0,te.themeCategorical,d,void 0,re),t},[u,f,te.colorScale,te.themeCategorical,d,re]),ae=Ir(()=>T(u,s),[u,s]),se=Ir(()=>w(ie,m,ae,e=>e.data||e),[ie,m,ae]),ce=Ir(()=>S||z?e=>({...se(e),...z?z(e)??{}:{},...S?S(e)??{}:{}}):se,[se,S,z]),le=Ir(()=>g(ce,{stroke:F,strokeWidth:W,opacity:_}),[ce,F,W,_]),ue=Ir(()=>ve(le,te.effectiveSelectionHook,te.resolvedSelection),[le,te.effectiveSelectionHook,te.resolvedSelection]),de=Ir(()=>we(s),[s]),fe=void 0!==k?k:!U||"parent"!==p&&"all"!==p?void 0:18,he=a({componentName:"Treemap",data:n});return he?Cr(v,{componentName:"Treemap",message:he,width:X,height:Y}):te.loadingEl?te.loadingEl:Cr(x,{componentName:"Treemap",width:X,height:Y,children:Cr(l,{chartType:"treemap",...null!=n&&{data:n},size:[X,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:te.margin,...te.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:i,hierarchySum:de,padding:b,paddingTop:fe,nodeStyle:ue,colorBy:u,colorScheme:te.effectivePalette,colorByDepth:f,nodeLabel:U?y||c:void 0,showLabels:U,labelMode:p,enableHover:q,tooltipContent:!1===M?()=>null:A(M)||void 0,...h({linkedHover:D,selection:L,onObservation:I,onClick:E,mobileInteraction:te.mobileInteraction,customHoverBehavior:oe,customClickBehavior:te.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:te.legend,legendPosition:te.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:te.legendState.onLegendHover,legendClickBehavior:te.legendState.onLegendClick,legendHighlightedCategory:te.legendState.highlightedCategory,legendIsolatedCategories:te.legendState.isolatedCategories},className:r,title:Q,description:Z,summary:J,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...j})})}u("treemap",Mr),Nr.displayName="Treemap";import{useMemo as Or}from"react";import{jsx as Br}from"react/jsx-runtime";function $r(e){const t=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:o,className:r,childrenAccessor:i="children",valueAccessor:s="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:f=!1,styleRules:m,nodeLabel:p,circleOpacity:y=.7,padding:b=4,tooltip:k,frameProps:S={},onObservation:M,onClick:P,chartId:L,selection:D,linkedHover:I,loading:E,loadingContent:C,legendInteraction:O,legendPosition:B,stroke:$,strokeWidth:R,opacity:F}=e,{width:W,height:_,enableHover:z,showLegend:j,showLabels:X=!0,title:Y,description:q,summary:K,accessibleTable:U}=t,Q=Pe({nodes:Or(()=>xe(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:f?void 0:u,colorScheme:d,showLegend:j,legendPosition:B,legendInteraction:O,frameLegend:S,selection:D,linkedHover:I,onObservation:M,onClick:P,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:L,marginDefaults:t.marginDefaults,userMargin:o,width:W,height:_,hasTitle:!!Y,loading:E,loadingContent:C}),Z=Or(()=>new Map,[]),J=Or(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:y};return t.fill=f?G[(e.depth||0)%G.length]:u?V(e.data||e,u,Q.colorScale):N(void 0,Q.themeCategorical,d,void 0,Z),t},[u,f,Q.colorScale,y,Q.themeCategorical,d,Z]),ee=Or(()=>T(u,s),[u,s]),te=Or(()=>w(J,m,ee,e=>e.data||e),[J,m,ee]),ne=Or(()=>g(te,{stroke:$,strokeWidth:R,opacity:F}),[te,$,R,F]),oe=Or(()=>ve(ne,Q.effectiveSelectionHook,Q.resolvedSelection),[ne,Q.effectiveSelectionHook,Q.resolvedSelection]),re=Or(()=>we(s),[s]),ie=a({componentName:"CirclePack",data:n});return ie?Br(v,{componentName:"CirclePack",message:ie,width:W,height:_}):Q.loadingEl?Q.loadingEl:Br(x,{componentName:"CirclePack",width:W,height:_,children:Br(l,{chartType:"circlepack",...null!=n&&{data:n},size:[W,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:Q.margin,...Q.legendBehaviorProps,nodeIDAccessor:c,childrenAccessor:i,hierarchySum:re,padding:b,nodeStyle:oe,colorBy:u,colorScheme:Q.effectivePalette,colorByDepth:f,nodeLabel:X?p||c:void 0,showLabels:X,enableHover:z,tooltipContent:!1===k?()=>null:A(k)||void 0,...h({linkedHover:I,selection:D,onObservation:M,onClick:P,mobileInteraction:Q.mobileInteraction,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:Q.legend,legendPosition:Q.legendPosition,...O&&"none"!==O&&{legendHoverBehavior:Q.legendState.onLegendHover,legendClickBehavior:Q.legendState.onLegendClick,legendHighlightedCategory:Q.legendState.highlightedCategory,legendIsolatedCategories:Q.legendState.isolatedCategories},className:r,title:Y,description:q,summary:K,accessibleTable:U,...null!=e.animate&&{animate:e.animate},...S})})}u("circlepack",Mr),$r.displayName="CirclePack";import{useMemo as Hr}from"react";import{pie as Rr}from"d3-shape";function Fr(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Wr={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,f=Fr(n);f.metaMap.clear(),o.length=0,r.length=0;const h=new Map;function g(e){const t=h.get(e)??0;return h.set(e,t+1),0===t?e:`${e}__${t}`}const m=t[0]/2,p=t[1]/2,y=Math.min(t[0],t[1])/2*.85,b=g(a(e));o.push({id:b,x:m,y:p,x0:m,x1:m,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(b,{ring:y,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,h,m,p){const y=i(t);if(!y?.length)return;const b=y.length;let v=0,k=0,x=0;for(;b>k;)k+=s[Math.min(x,s.length-1)],x++,v++;let S=0;for(let b=0;v>b;b++){const k=s[Math.min(b,s.length-1)],x=y.slice(S,S+k);if(!x.length)break;const w=(b+1)/v,M={id:n,depth:m,data:t,parentId:n},P=p?h/u(M)*w:h*w,L=Rr().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(x),T=d(M);for(let t=0;x.length>t;t++){const i=(L[t].startAngle+L[t].endAngle)/2,s=x[t],u=g(a(s)),d=c+P*Math.sin(i),h=l+P*Math.cos(i)*T;o.push({id:u,x:d,y:h,x0:d,x1:d,y0:h,y1:h,width:0,height:0,value:0,depth:m,data:s}),f.metaMap.set(u,{ring:P,angle:i,depth:m,parentId:n,eccentricity:T}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,h,P,m+1,!0)}S+=k}}(e,b,m,p,y,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.edgeStyle,a=n.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,c=[],l=[],u=[];if(!1!==n.orbitShowRings){const t=Fr(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const s=r/i*Math.PI*2,c=(r+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*o,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*o,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(ue(t,"nodeSize")),o=r?r(ue(t,"nodeStyle")):{};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:o.fill||n.themeSemantic?.primary||"#6366f1",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(t.depth??0)?1:.85),cursor:o.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),n="object"==typeof e.target?e.target:d.get(e.target);if(!t||!n)continue;if(null==t.x||null==n.x)continue;const o=i?i(ue(e,"edgeStyle")):{};l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||"rgba(128,128,128,0.35)",strokeWidth:o.strokeWidth??.5,opacity:o.opacity??1,cursor:o.cursor},datum:e})}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(ue(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;u.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=Fr(t),o=t.orbitSpeed??.25,r=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,a=o*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=s.get(e.parentId);if(!o)continue;const c=e.angle+i*a*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(c),t.y=o.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)};u("orbit",Wr);import{jsx as _r}from"react/jsx-runtime";u("orbit",Wr);var zr=G;function jr(e){const t=H(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:o,className:r,childrenAccessor:i="children",nodeIdAccessor:s="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,styleRules:f,orbitMode:m="flat",orbitSize:p=2.95,speed:y=.25,revolution:b,revolutionStyle:k,eccentricity:S=1,showRings:M=!0,nodeRadius:P=6,showLabels:L=!1,animated:D=!0,tooltip:I,foregroundGraphics:E,annotations:O,frameProps:B={},onObservation:$,onClick:R,chartId:F,selection:W,linkedHover:_,loading:z,loadingContent:j,legendPosition:G,legendInteraction:q,stroke:K,strokeWidth:U,opacity:Q}=e,{width:Z,height:J,enableHover:ee,showLegend:te,title:ne,description:oe,summary:re,accessibleTable:ie}=t,ae=Pe({nodes:Hr(()=>xe(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:te,legendPosition:G,legendInteraction:q,frameLegend:B,selection:W,linkedHover:_,onObservation:$,onClick:R,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:F,marginDefaults:C(t),userMargin:o,width:Z,height:J,hasTitle:!!ne,loading:z,loadingContent:j}),se=Hr(()=>new Map,[]),{colorScale:ce,customClickBehavior:le,customHoverBehavior:ue,themeCategorical:de}=ae,fe=Hr(()=>{if(Array.isArray(u))return u;const e=X[u];return Array.isArray(e)?e:Y},[u]),he=Hr(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=d?n?fe[0]:zr[(e.depth||0)%zr.length]:c?V(e.data||e,c,ce):N(void 0,de,u,void 0,se),t.opacity=n?1:.85,t},[c,d,ce,fe,de,u,se]),ge=Hr(()=>T(c,"value"),[c]),me=Hr(()=>w(he,f,ge,e=>e.data||e),[he,f,ge]),pe=Hr(()=>g(me,{stroke:K,strokeWidth:U,opacity:Q}),[me,K,U,Q]),ye=Hr(()=>ve(pe,ae.effectiveSelectionHook,ae.resolvedSelection),[pe,ae.effectiveSelectionHook,ae.resolvedSelection]),be=Hr(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),ke=Hr(()=>e=>{ue(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[ue]),Se=Hr(()=>e=>{le(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[le]),we=a({componentName:"OrbitDiagram",data:n});return we?_r(v,{componentName:"OrbitDiagram",message:we,width:Z,height:J}):ae.loadingEl?ae.loadingEl:_r(x,{componentName:"OrbitDiagram",width:Z,height:J,children:_r(l,{chartType:"orbit",...null!=n&&{data:n},size:[Z,J],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,maxDevicePixelRatio:e.maxDevicePixelRatio,margin:ae.margin,...ae.legendBehaviorProps,nodeIDAccessor:s,childrenAccessor:i,nodeStyle:ye,edgeStyle:be,colorBy:c,colorScheme:ae.effectivePalette,colorByDepth:d,nodeSize:P,nodeLabel:L?s:void 0,showLabels:L,enableHover:!D&&ee,tooltipContent:D?void 0:!1===I?()=>null:A(I)||void 0,...h({linkedHover:_,selection:W,onObservation:$,onClick:R,mobileInteraction:ae.mobileInteraction,customHoverBehavior:ke,customClickBehavior:Se,linkedHoverInClickPredicate:!1}),legend:ae.legend,legendPosition:ae.legendPosition,...q&&"none"!==q&&{legendHoverBehavior:ae.legendState.onLegendHover,legendClickBehavior:ae.legendState.onLegendClick,legendHighlightedCategory:ae.legendState.highlightedCategory,legendIsolatedCategories:ae.legendState.isolatedCategories},foregroundGraphics:E,annotations:O,className:r,title:ne,description:oe,summary:re,orbitMode:m,orbitSize:p,orbitSpeed:y,orbitRevolution:b,orbitRevolutionStyle:k,orbitEccentricity:S,orbitShowRings:M,orbitAnimated:D,accessibleTable:ie,...null!=e.animate&&{animate:e.animate},...B})})}jr.displayName="OrbitDiagram";import{forwardRef as Xr,useMemo as Yr}from"react";import{jsx as Gr}from"react/jsx-runtime";var qr=Xr(function(e,t){const{nodes:n,edges:o,layout:i,layoutConfig:a,onLayoutError:s,nodeIDAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",margin:g,className:m,colorBy:p,colorScheme:y,tooltip:b,selection:v,linkedHover:k,onObservation:S,onClick:w,chartId:M,annotations:P,autoPlaceAnnotations:T,frameProps:E={}}=e,{frameRef:C,resolved:N,normalizedMargin:B}=r({imperativeRef:t,imperativeVariant:"network",margin:g,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),$=Yr(()=>L(n),[n]),H=Yr(()=>L(o),[o]),F=Yr(()=>void 0===n&&void 0===o?void 0:[...$,...H],[o,n,H,$]),W=O(e.mobileInteraction,{mode:e.mode,width:N.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:_,customClickBehavior:z,activeSelectionHook:j}=R({selection:v,linkedHover:k,fallbackFields:"string"==typeof p?[p]:[],onObservation:S,onClick:w,chartType:"NetworkCustomChart",chartId:M,colorByField:"string"==typeof p?p:void 0,mobileInteraction:W}),X=Yr(()=>j?.isActive?{isActive:!0,predicate:j.predicate}:null,[j?.isActive,j?.predicate]),{width:Y,height:G,enableHover:q,title:V,description:K,summary:U,accessibleTable:Q}=N,Z=Yr(()=>A(b),[b]),J=I(e.loading,Y,G,e.loadingContent),ee=J?null:D(F,Y,G,e.emptyContent);if(J||ee)return J||ee;const te={chartType:"force",...null!=n&&{nodes:$},...null!=o&&{edges:H},customNetworkLayout:i,layoutConfig:a,onLayoutError:s,nodeIDAccessor:c,sourceAccessor:u,targetAccessor:d,colorBy:p,colorScheme:y,size:[Y,G],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:B,enableHover:q,...f({title:V,description:K,summary:U,accessibleTable:Q,className:m,animate:e.animate,maxDevicePixelRatio:e.maxDevicePixelRatio,autoPlaceAnnotations:T}),...!1===b?{tooltipContent:()=>null}:Z?{tooltipContent:Z}:{},...h({linkedHover:k,selection:v,onObservation:S,onClick:w,mobileInteraction:W,customHoverBehavior:_,customClickBehavior:z,linkedHoverInClickPredicate:!1}),layoutSelection:X,...null!=P&&{annotations:P},...E};return Gr(x,{componentName:"NetworkCustomChart",width:Y,height:G,children:Gr(l,{ref:C,...te})})});qr.displayName="NetworkCustomChart";import{forceCenter as Vr,forceCollide as Kr,forceLink as Ur,forceManyBody as Qr,forceSimulation as Zr,forceX as Jr,forceY as ei}from"d3-force";function ti(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,f=y(n.seed??1),h=new Map;for(const t of e)h.set(t.id,0);for(const e of t)h.set(e.source,(h.get(e.source)??0)+1),h.set(e.target,(h.get(e.target)??0)+1);const g=500,m=e.map(e=>({id:e.id,data:e,x:200+600*f(),y:200+600*f()})),p=new Set(e.map(e=>e.id)),b=t.filter(e=>p.has(e.source)&&p.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=Zr(m).randomSource(f).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",Qr().strength(e=>{const t=h.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",Kr(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",Vr(g,g).strength(.8)).force("x",Jr(g).strength(s)).force("y",ei(g).strength(s));b.length>0&&e.force("link",Ur(b).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(h.get("string"==typeof e.source?e.source:e.source.id)??1,h.get(t)??1));return a/.045/n})),e.stop();for(let t=0;o>t;t+=1)e.tick()}let v=1/0,k=1/0,x=-1/0,S=-1/0;for(const e of m){const t=e.x??g,n=e.y??g;v>t&&(v=t),k>n&&(k=n),t>x&&(x=t),n>S&&(S=n)}const w=x-v,M=S-k,P={};for(const e of m)Object.defineProperty(P,e.id,{value:{x:0===w?.5:d+((e.x??g)-v)/w*(1-2*d),y:0===M?.5:d+((e.y??g)-k)/M*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return P}export{de as forceLayoutPlugin,Te as ForceDirectedGraph,Be as chordLayoutPlugin,Re as ChordDiagram,_t as sankeyLayoutPlugin,jt as SankeyDiagram,Vt as validateProcessSankey,Kt as formatProcessSankeyIssue,Ut as diagnoseProcessSankeyLayout,Qt as explainProcessSankeyLayout,Zt as diagnoseProcessSankeyProps,Jt as inventoryAtTime,en as toProcessSankeyTime,cr as ProcessSankey,Mr as hierarchyLayoutPlugin,Dr as TreeDiagram,Nr as Treemap,$r as CirclePack,Wr as orbitLayoutPlugin,jr as OrbitDiagram,qr as NetworkCustomChart,ti as forceLayout};
@@ -1 +0,0 @@
1
- import{areaCanvasRenderer as t}from"./c-AH6J4MTN.min.js";import{lineCanvasRenderer as e}from"./c-CZF7MV67.min.js";import{barCanvasRenderer as o}from"./c-G3VYMHKE.min.js";import{pointCanvasRenderer as i}from"./c-T6UAIKBH.min.js";import{symbolCanvasRenderer as n}from"./c-5JWCTX3G.min.js";import{glyphCanvasRenderer as l}from"./c-54IRWOGM.min.js";import{renderRectPulse as a}from"./c-UC5PTTFI.min.js";import{parseCanvasColor as s,resolveCSSColor as r,resolveCanvasPaint as c}from"./c-QKHMBE2E.min.js";function h(t,e){const[o,i,n]=s(t,e);return.299*o+.587*i+.114*n>128?"#000":"#fff"}function f(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var m=(t,e,o,i)=>{const n=e.filter(t=>"heatcell"===t.type);t.save();try{const e=r(t,"var(--semiotic-font-family, sans-serif)")||"sans-serif";for(const o of n){const i=o.style;null!=i?.opacity&&(t.globalAlpha=i.opacity);const n=c(t,o.fill,"#4e79a7");t.fillStyle=n,t.fillRect(o.x,o.y,o.w,o.h);const l=Math.max(0,i?.strokeWidth??1);if(l>0&&(t.strokeStyle=r(t,i?.stroke??"var(--semiotic-surface, #fff)"),t.lineWidth=l,t.strokeRect(o.x,o.y,o.w,o.h)),a(t,o),t.globalAlpha=1,o.showValues&&null!=o.value){if(20>o.w||20>o.h)continue;const i=o.valueFormat?o.valueFormat(o.value):f(o.value),l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h))),a=o.x+o.w/2,s=o.y+o.h/2;t.fillStyle=h(t,"string"==typeof n?n:"#4e79a7"),t.font=`${l}px ${e}`,t.textAlign="center",t.textBaseline="middle",t.fillText(i,a,s)}}}finally{t.restore()}},d=(t,e,o,i)=>{for(const o of e){if("candlestick"!==o.type)continue;const e=o;t.save();const n=(e._decayOpacity??1)*(e.style?.opacity??1);1!==n&&(t.globalAlpha=n);const l=r(t,e.wickColor)||e.wickColor,a=60>i.height,s=a?Math.max(e.wickWidth,2):e.wickWidth,c=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=l,t.lineWidth=s,t.stroke()};if(a||c(),e.isRange){const o=e.dotRadius??Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=l,t.beginPath(),t.arc(e.x,e.highY,o,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,o,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const o=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),n=e.isUp?e.upColor:e.downColor,l=r(t,n)||n;t.fillStyle=l,t.fillRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1)),t.strokeStyle=l,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,o,e.bodyWidth,Math.max(i,1))}a&&c(),t.restore()}},y=i,u=(t,e,i,n)=>{o(t,e,i,n);const l=e.filter(t=>"rect"===t.type);if(2>l.length)return;const a=l[0].datum,s=a?._connectorStroke;if(s){t.save(),t.strokeStyle=r(t,s)||s,t.lineWidth=a?._connectorWidth??1,t.setLineDash([]);for(let e=0;l.length-1>e;e++){const o=l[e],n=l[e+1],a=o.datum,s=n.datum;if(null==a?.cumEnd||null==s?.baseline)continue;const r=i.y(a.cumEnd),c=o.x+o.w,h=n.x;t.beginPath(),t.moveTo(c,r),t.lineTo(h,r),t.stroke()}t.restore()}},p={chartType:"custom",buildScene:()=>[],canvasRenderers:[t,o,m,e,i,n,l,d,y,u]};export{m as heatmapCanvasRenderer,d as candlestickCanvasRenderer,y as swarmCanvasRenderer,u as waterfallCanvasRenderer,p as customXYPlugin};
@@ -1 +0,0 @@
1
- import{getMax as t}from"./c-GGISSW5E.min.js";import{useMemo as l}from"react";import{bin as i}from"d3-array";import{jsx as e,jsxs as n}from"react/jsx-runtime";function o({orient:o,config:r,values:s,scale:h,size:f,length:a}){const c=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(r),d="top"===o||"bottom"===o,x=l(()=>{if(0===s.length)return null;const l=h.domain(),r=f-8;if("boxplot"===c.type){const t=function(t){const l=[...t].sort((t,l)=>t-l),i=l.length;if(0===i)return null;const e=l[Math.floor(.25*i)],n=l[Math.floor(.5*i)],o=l[Math.floor(.75*i)],r=o-e;return{q1:e,median:n,q3:o,whiskerLow:Math.max(l[0],e-1.5*r),whiskerHigh:Math.min(l[i-1],o+1.5*r)}}(s);if(!t)return null;const{q1:l,median:i,q3:f,whiskerLow:a,whiskerHigh:x}=t,k=Math.min(.5*r,20),u=(r-k)/2+4;if(d){const t=h(l),r=h(f),s=h(i),d=h(a),p=h(x),y="top"===o?-1:1,g=0;return n("g",{"data-testid":"marginal-boxplot-"+o,children:[e("line",{x1:d,y1:g+y*(u+k/2),x2:p,y2:g+y*(u+k/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e("line",{x1:d,y1:g+y*u,x2:d,y2:g+y*(u+k),stroke:c.fill,strokeWidth:c.strokeWidth}),e("line",{x1:p,y1:g+y*u,x2:p,y2:g+y*(u+k),stroke:c.fill,strokeWidth:c.strokeWidth}),e("rect",{x:Math.min(t,r),y:"top"===o?g-u-k:g+u,width:Math.abs(r-t),height:k,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e("line",{x1:s,y1:"top"===o?g-u-k:g+u,x2:s,y2:"top"===o?g-u:g+u+k,stroke:c.fill,strokeWidth:2})]})}{const t=h(l),r=h(f),s=h(i),d=h(a),p=h(x),y="left"===o?-1:1,g=0;return n("g",{"data-testid":"marginal-boxplot-"+o,children:[e("line",{x1:g+y*(u+k/2),y1:d,x2:g+y*(u+k/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e("line",{x1:g+y*u,y1:d,x2:g+y*(u+k),y2:d,stroke:c.fill,strokeWidth:c.strokeWidth}),e("line",{x1:g+y*u,y1:p,x2:g+y*(u+k),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e("rect",{x:"left"===o?g-u-k:g+u,y:Math.min(t,r),width:k,height:Math.abs(r-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e("line",{x1:"left"===o?g-u-k:g+u,y1:s,x2:"left"===o?g-u:g+u+k,y2:s,stroke:c.fill,strokeWidth:2})]})}}const x=i().domain(l).thresholds(c.bins)(s);if(0===x.length)return null;const k=t(x.map(t=>t.length));if(0===k)return null;if("histogram"===c.type)return e("g",{"data-testid":"marginal-histogram-"+o,children:x.map((t,l)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/k*r;if(d){const n=h(t.x0),r=h(t.x1)-h(t.x0);return e("rect",{x:n,y:"top"===o?-4-i:4,width:Math.max(r,.5),height:i,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},l)}{const n=h(t.x0),r=h(t.x1)-h(t.x0);return e("rect",{x:"left"===o?-4-i:4,y:Math.min(n,n+r),width:i,height:Math.abs(r),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},l)}})});if("violin"===c.type){const t=r/2+4,l=[];for(const i of x){if(null==i.x0||null==i.x1)continue;const e=i.length/k*(r/2),n=h((i.x0+i.x1)/2);l.push(d?`${n},${"top"===o?-(t-e):t-e}`:`${"left"===o?-(t-e):t-e},${n}`)}for(let i=x.length-1;i>=0;i--){const e=x[i];if(null==e.x0||null==e.x1)continue;const n=e.length/k*(r/2),s=h((e.x0+e.x1)/2);l.push(d?`${s},${"top"===o?-(t+n):t+n}`:`${"left"===o?-(t+n):t+n},${s}`)}return e("g",{"data-testid":"marginal-violin-"+o,children:e("polygon",{points:l.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const t=[];if(d){const l=0,i=null!=x[0].x0?h(x[0].x0):0;t.push(`M${i},${l}`);for(const l of x){if(null==l.x0||null==l.x1)continue;const i=l.length/k*r,e=h((l.x0+l.x1)/2);t.push(`L${e},${"top"===o?-i-4:i+4}`)}const e=null!=x[x.length-1].x1?h(x[x.length-1].x1):a;t.push(`L${e},${l}`),t.push("Z")}else{const l=0,i=null!=x[0].x0?h(x[0].x0):0;t.push(`M${l},${i}`);for(const l of x){if(null==l.x0||null==l.x1)continue;const i=l.length/k*r,e=h((l.x0+l.x1)/2);t.push(`L${"left"===o?-i-4:i+4},${e}`)}const e=null!=x[x.length-1].x1?h(x[x.length-1].x1):a;t.push(`L${l},${e}`),t.push("Z")}return e("g",{"data-testid":"marginal-ridgeline-"+o,children:e("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[s,h,c,f,a,o,d,4]);return x?e("g",{className:"marginal-"+o,"data-testid":"marginal-"+o,children:x}):null}export{o as MarginalGraphics};