semiotic 3.10.1 → 3.10.3

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 (353) hide show
  1. package/README.md +64 -63
  2. package/ai/artifact-surface-inventory.json +4 -1
  3. package/ai/behaviorContracts.cjs +1 -1
  4. package/ai/dist/mcp-server.js +25 -24
  5. package/ai/examples.md +28 -0
  6. package/ai/reference.md +9 -4
  7. package/ai/schema.json +121 -5
  8. package/ai/surface-manifest.json +3 -2
  9. package/ai/system-prompt.md +1 -1
  10. package/ai/task-packets/compare-category-totals.json +7 -53
  11. package/ai/task-packets/compare-category-totals.md +4 -4
  12. package/ai/task-packets/correct-published-chart.json +7 -53
  13. package/ai/task-packets/correct-published-chart.md +4 -4
  14. package/ai/task-packets/index.json +9 -9
  15. package/ai/task-packets/update-live-chart.json +8 -54
  16. package/ai/task-packets/update-live-chart.md +4 -4
  17. package/dist/c-27DCB5T6.min.js +18 -0
  18. package/dist/c-2MONF2P6.min.js +1 -0
  19. package/dist/c-3AGX252H.min.js +1 -0
  20. package/dist/c-3B6JZEZT.min.js +1 -0
  21. package/dist/c-3BYZXCX3.min.js +4 -0
  22. package/dist/c-3DIPZJDO.min.js +1 -0
  23. package/dist/c-3FOUMWLR.min.js +1 -0
  24. package/dist/c-3NA6I656.min.js +2 -0
  25. package/dist/c-3OFVBWQY.min.js +1 -0
  26. package/dist/{c-QA3HMQJP.min.js → c-3PFVJFBK.min.js} +1 -1
  27. package/dist/c-3PPO7ZJF.min.js +4 -0
  28. package/dist/c-3YEW2PK6.min.js +1 -0
  29. package/dist/c-43XNOQNQ.min.js +391 -0
  30. package/dist/c-4JKDJUYD.min.js +1 -0
  31. package/dist/c-4LKK5YWB.min.js +1 -0
  32. package/dist/c-4V3CD337.min.js +1 -0
  33. package/dist/c-4XLHPQTP.min.js +1 -0
  34. package/dist/c-5NYONM6V.min.js +5 -0
  35. package/dist/c-5PIKBUMF.min.js +1 -0
  36. package/dist/c-6IVBV5NO.min.js +1 -0
  37. package/dist/c-7APWCEPL.min.js +1 -0
  38. package/dist/{c-ORLEBW72.min.js → c-7FKPPCGN.min.js} +1 -1
  39. package/dist/c-ABMGCCLT.min.js +1 -0
  40. package/dist/c-AINGQGUN.min.js +1 -0
  41. package/dist/c-AXJ2QI3F.min.js +1 -0
  42. package/dist/c-BQYD7T4E.min.js +1 -0
  43. package/dist/{c-V4XMSLC3.min.js → c-BYJJ7EMG.min.js} +1 -1
  44. package/dist/c-C4SXYFXL.min.js +1 -0
  45. package/dist/c-CLDCKFBE.min.js +1 -0
  46. package/dist/c-CLJCJSFU.min.js +1 -0
  47. package/dist/c-CLLCX3PT.min.js +2 -0
  48. package/dist/c-CO4NDAD6.min.js +51 -0
  49. package/dist/c-ECHBKW7U.min.js +1 -0
  50. package/dist/c-EPJWM2UT.min.js +1 -0
  51. package/dist/c-FD2BXSRG.min.js +1 -0
  52. package/dist/c-FHNY57SO.min.js +209 -0
  53. package/dist/c-FMCUQ6JX.min.js +1 -0
  54. package/dist/c-FOTTQHOO.min.js +1 -0
  55. package/dist/c-FU7A5KSY.min.js +1 -0
  56. package/dist/c-GHN6IR4Y.min.js +1 -0
  57. package/dist/{c-J6DVC236.min.js → c-GK263BF4.min.js} +1 -1
  58. package/dist/c-GSCO3FWL.min.js +1 -0
  59. package/dist/c-GYLOSK7M.min.js +1 -0
  60. package/dist/c-HK4OSLZA.min.js +1 -0
  61. package/dist/c-HLGTD5SJ.min.js +1 -0
  62. package/dist/c-HNHKIMIV.min.js +61 -0
  63. package/dist/{c-D6HAAPTX.min.js → c-IBRLFKWA.min.js} +1 -1
  64. package/dist/c-IIV73MUW.min.js +1 -0
  65. package/dist/c-IJCZGUG6.min.js +31 -0
  66. package/dist/c-ISA6IJ6V.min.js +41 -0
  67. package/dist/c-JC76YAHB.min.js +33 -0
  68. package/dist/c-JJKRER47.min.js +1 -0
  69. package/dist/c-JO6AYCU4.min.js +1 -0
  70. package/dist/c-JOPGDP6N.min.js +1 -0
  71. package/dist/c-JWHPG6S2.min.js +1 -0
  72. package/dist/c-JXVYIXTV.min.js +1 -0
  73. package/dist/c-K2ZIYDI3.min.js +1 -0
  74. package/dist/c-K37JAIWA.min.js +4 -0
  75. package/dist/c-KXH7LFIL.min.js +26 -0
  76. package/dist/c-M43PK7K4.min.js +1 -0
  77. package/dist/c-MTX2AO5S.min.js +1 -0
  78. package/dist/c-N5WT7TXG.min.js +1 -0
  79. package/dist/c-NATWERHZ.min.js +1 -0
  80. package/dist/{c-42PLDTX7.min.js → c-O53GOO7H.min.js} +1 -1
  81. package/dist/c-OVQB75PE.min.js +1 -0
  82. package/dist/c-P3SKRNZN.min.js +1 -0
  83. package/dist/c-P5NXQWIM.min.js +1 -0
  84. package/dist/c-P7BQMVQQ.min.js +1 -0
  85. package/dist/{c-GNTXRXRN.min.js → c-PDQHLOKU.min.js} +1 -1
  86. package/dist/c-PITYSOPK.min.js +1 -0
  87. package/dist/c-QPO24R7Q.min.js +1 -0
  88. package/dist/c-QXLDCATV.min.js +1 -0
  89. package/dist/c-R2HUSWKB.min.js +1 -0
  90. package/dist/{c-HYW2XA4Q.min.js → c-RHDOOQ4X.min.js} +1 -1
  91. package/dist/c-RZPP5ERV.min.js +1 -0
  92. package/dist/c-SAP5KY6R.min.js +9 -0
  93. package/dist/{c-WUWXGQYA.min.js → c-SJIB5RNI.min.js} +1 -1
  94. package/dist/c-SQNEVNWT.min.js +1 -0
  95. package/dist/c-STHZWF3D.min.js +1 -0
  96. package/dist/c-TIDKVMMZ.min.js +1 -0
  97. package/dist/c-TIMGODBG.min.js +1 -0
  98. package/dist/c-TR7OHUAO.min.js +2 -0
  99. package/dist/c-TVKZC4BY.min.js +1 -0
  100. package/dist/c-U5XVLSHN.min.js +1 -0
  101. package/dist/c-U6NLVFN4.min.js +1 -0
  102. package/dist/{c-VJTDST2R.min.js → c-UBHICVSC.min.js} +1 -1
  103. package/dist/c-UMGHCBH5.min.js +114 -0
  104. package/dist/c-UOPPO26M.min.js +1 -0
  105. package/dist/c-UUDAON4Z.min.js +1 -0
  106. package/dist/c-V32TPPY2.min.js +1 -0
  107. package/dist/c-V5KFJWQQ.min.js +1 -0
  108. package/dist/c-VEMCBQZZ.min.js +100 -0
  109. package/dist/{c-P65V6HLO.min.js → c-VN557BQE.min.js} +1 -1
  110. package/dist/c-WD2RL76M.min.js +116 -0
  111. package/dist/c-Y342FJ6K.min.js +1 -0
  112. package/dist/c-YL7HJL5J.min.js +1 -0
  113. package/dist/c-YM6CT4LJ.min.js +1 -0
  114. package/dist/{c-MVR3RWF3.min.js → c-YMFUIO54.min.js} +1 -1
  115. package/dist/c-YQVOKPKR.min.js +1 -0
  116. package/dist/c-YRJ3BJQZ.min.js +1 -0
  117. package/dist/c-YT5KPVNP.min.js +1 -0
  118. package/dist/c-Z6GRGS53.min.js +1 -0
  119. package/dist/c-ZVOFLE2P.min.js +46 -0
  120. package/dist/components/CategoryColors.d.ts +7 -0
  121. package/dist/components/LinkedCharts.d.ts +2 -1
  122. package/dist/components/ai/audienceProfile.d.ts +18 -1
  123. package/dist/components/ai/describeChart.d.ts +5 -1
  124. package/dist/components/ai/intentManifest.d.ts +16 -0
  125. package/dist/components/ai/intentRegistry.d.ts +12 -0
  126. package/dist/components/ai/intents.d.ts +6 -6
  127. package/dist/components/ai/streamSchema.d.ts +19 -0
  128. package/dist/components/ai/streamingTypes.d.ts +57 -11
  129. package/dist/components/ai/suggestCharts.d.ts +1 -1
  130. package/dist/components/ai/suggestStreamCharts.d.ts +43 -8
  131. package/dist/components/ai/suggestStreamDashboard.d.ts +35 -0
  132. package/dist/components/ai/variantDiscovery.d.ts +1 -1
  133. package/dist/components/charts/ordinal/BarChart.streamCapability.d.ts +2 -0
  134. package/dist/components/charts/ordinal/DonutChart.streamCapability.d.ts +2 -0
  135. package/dist/components/charts/ordinal/GroupedBarChart.streamCapability.d.ts +2 -0
  136. package/dist/components/charts/ordinal/PieChart.streamCapability.d.ts +2 -0
  137. package/dist/components/charts/ordinal/StackedBarChart.streamCapability.d.ts +2 -0
  138. package/dist/components/charts/realtime/RealtimeAccumulator.d.ts +14 -0
  139. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +6 -5
  140. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -1
  141. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +2 -161
  142. package/dist/components/charts/realtime/RealtimeLineChart.types.d.ts +175 -0
  143. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +6 -5
  144. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +6 -5
  145. package/dist/components/charts/realtime/aggregate.d.ts +11 -1
  146. package/dist/components/charts/realtime/resolveWindowSize.d.ts +1 -1
  147. package/dist/components/charts/shared/DirectLabelLayer.d.ts +25 -0
  148. package/dist/components/charts/shared/directLabels.d.ts +12 -0
  149. package/dist/components/charts/shared/knownChartComponents.d.ts +4 -1
  150. package/dist/components/charts/shared/lineSeriesSsr.d.ts +0 -12
  151. package/dist/components/charts/shared/useChartSetup.d.ts +3 -1
  152. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -1
  153. package/dist/components/charts/value/BigNumber.streamCapability.d.ts +2 -0
  154. package/dist/components/charts/value/GaugeChart.streamCapability.d.ts +2 -0
  155. package/dist/components/charts/xy/BubbleChart.d.ts +4 -1
  156. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +4 -1
  157. package/dist/components/charts/xy/LineChart.d.ts +4 -1
  158. package/dist/components/charts/xy/Scatterplot.d.ts +7 -0
  159. package/dist/components/data/transforms.d.ts +1 -0
  160. package/dist/components/realtime/HyperLogLog.d.ts +19 -0
  161. package/dist/components/realtime/ReorderBuffer.d.ts +2 -2
  162. package/dist/components/realtime/TDigest.d.ts +22 -0
  163. package/dist/components/realtime/WindowAccumulator.d.ts +22 -5
  164. package/dist/components/realtime/applyChangelog.d.ts +38 -0
  165. package/dist/components/realtime/minHeap.d.ts +3 -0
  166. package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +1 -1
  167. package/dist/components/recipes/layout1d.d.ts +2 -20
  168. package/dist/components/recipes/minGapPlacement.d.ts +20 -0
  169. package/dist/components/semiotic-ai-core.d.ts +8 -3
  170. package/dist/components/semiotic-ai-stream.d.ts +10 -0
  171. package/dist/components/semiotic-ai.d.ts +4 -6
  172. package/dist/components/semiotic-realtime-core.d.ts +6 -2
  173. package/dist/components/semiotic-stream-types.d.ts +14 -0
  174. package/dist/components/semiotic-xy.d.ts +1 -0
  175. package/dist/components/semiotic.d.ts +3 -11
  176. package/dist/components/server/encodeSvgFramesToGif.d.ts +2 -0
  177. package/dist/components/server/rasterizeSVG.d.ts +2 -0
  178. package/dist/components/server/registerServerXYPlugins.d.ts +2 -0
  179. package/dist/components/server/renderEvidence.d.ts +4 -0
  180. package/dist/components/server/serverChartConfigs.d.ts +5 -0
  181. package/dist/components/server/serverChartConfigsRealtime.d.ts +6 -0
  182. package/dist/components/server/serverRealtimeCategoryColors.d.ts +3 -0
  183. package/dist/components/server/staticAnnotations.d.ts +9 -0
  184. package/dist/components/stream/SceneGraph.d.ts +3 -3
  185. package/dist/components/stream/StalenessBadge.d.ts +5 -2
  186. package/dist/components/stream/pipelinePathJoin.d.ts +27 -0
  187. package/dist/components/stream/pipelineTransitionTypes.d.ts +43 -0
  188. package/dist/components/stream/pipelineTransitions.d.ts +5 -35
  189. package/dist/components/stream/seriesGeometry.d.ts +2 -1
  190. package/dist/components/stream/streamEncodingTypes.d.ts +9 -0
  191. package/dist/components/stream/types.d.ts +25 -2
  192. package/dist/components/text/axisLabelAssessment.d.ts +15 -0
  193. package/dist/components/text/browserAxisLabelAssessment.d.ts +1 -0
  194. package/dist/components/text/browserLabelMeasurement.d.ts +3 -0
  195. package/dist/components/text/labelMeasurement.d.ts +19 -0
  196. package/dist/components/text/labelPlacement.d.ts +71 -0
  197. package/dist/components/text/useAxisLabelAssessment.d.ts +6 -0
  198. package/dist/components/text/useLabelMeasurer.d.ts +3 -0
  199. package/dist/controls.module.min.js +71 -1
  200. package/dist/geo.min.js +231 -1
  201. package/dist/geo.module.min.js +31 -1
  202. package/dist/network.module.min.js +1 -1
  203. package/dist/ordinal.module.min.js +1 -1
  204. package/dist/physics-matter.module.min.js +1 -1
  205. package/dist/physics-rapier.module.min.js +1 -1
  206. package/dist/physics.module.min.js +1 -1
  207. package/dist/physicsWorker.js +1 -1
  208. package/dist/rough.min.js +2 -1
  209. package/dist/rough.module.min.js +2 -1
  210. package/dist/semiotic-access.module.min.js +1 -1
  211. package/dist/semiotic-ai-artifact-policy-constants.module.min.js +1 -1
  212. package/dist/semiotic-ai-core.d.ts +8 -3
  213. package/dist/semiotic-ai-core.min.js +4 -1
  214. package/dist/semiotic-ai-core.module.min.js +4 -1
  215. package/dist/semiotic-ai-hash-primitives.module.min.js +1 -1
  216. package/dist/semiotic-ai.d.ts +4 -6
  217. package/dist/semiotic-ai.module.min.js +14 -1
  218. package/dist/semiotic-artifact-react.min.js +269 -1
  219. package/dist/semiotic-artifact-react.module.min.js +137 -1
  220. package/dist/semiotic-artifact.min.js +3 -1
  221. package/dist/semiotic-artifact.module.min.js +3 -1
  222. package/dist/semiotic-atlas-core.min.js +2 -1
  223. package/dist/semiotic-atlas-core.module.min.js +1 -1
  224. package/dist/semiotic-atlas-selection.module.min.js +1 -1
  225. package/dist/semiotic-atlas.module.min.js +11 -1
  226. package/dist/semiotic-client-cjs-shared.min.js +1530 -1
  227. package/dist/semiotic-client-glyph.module.min.js +3 -1
  228. package/dist/semiotic-client-responsive.module.min.js +1 -1
  229. package/dist/semiotic-client-shared.module.min.js +1 -1
  230. package/dist/semiotic-custom-layout-selection-cjs-shared.min.js +2 -1
  231. package/dist/semiotic-data.min.js +1 -1
  232. package/dist/semiotic-data.module.min.js +1 -1
  233. package/dist/semiotic-evidence.min.js +3 -1
  234. package/dist/semiotic-evidence.module.min.js +3 -1
  235. package/dist/semiotic-experimental-auxiliary.module.min.js +8 -1
  236. package/dist/semiotic-experimental-node-auxiliary.module.min.js +8 -1
  237. package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
  238. package/dist/semiotic-experimental-vacp.min.js +1 -1
  239. package/dist/semiotic-experimental-vacp.module.min.js +1 -1
  240. package/dist/semiotic-line.module.min.js +1 -1
  241. package/dist/semiotic-realtime-core.d.ts +6 -2
  242. package/dist/semiotic-realtime-core.module.min.js +1 -1
  243. package/dist/semiotic-realtime-react.module.min.js +1 -1
  244. package/dist/semiotic-recipes-core-cjs-base.min.js +160 -1
  245. package/dist/semiotic-recipes-core.module.min.js +72 -1
  246. package/dist/semiotic-recipes-geo-cjs.min.js +1 -1
  247. package/dist/semiotic-recipes-react.min.js +3 -1
  248. package/dist/semiotic-server-edge-node.module.min.js +391 -1
  249. package/dist/semiotic-server-edge.min.js +651 -1
  250. package/dist/semiotic-server-edge.module.min.js +372 -1
  251. package/dist/semiotic-server-node.min.js +651 -1
  252. package/dist/semiotic-server-node.module.min.js +1 -1
  253. package/dist/semiotic-text.min.js +1 -1
  254. package/dist/semiotic-text.module.min.js +1 -1
  255. package/dist/semiotic-themes-core.min.js +1 -1
  256. package/dist/semiotic-themes-core.module.min.js +1 -1
  257. package/dist/semiotic-themes.min.js +1 -1
  258. package/dist/semiotic-themes.module.min.js +1 -1
  259. package/dist/semiotic-utils-core.min.js +11 -1
  260. package/dist/semiotic-utils-core.module.min.js +8 -1
  261. package/dist/semiotic-value.module.min.js +15 -1
  262. package/dist/semiotic-xy.d.ts +1 -0
  263. package/dist/semiotic.d.ts +3 -11
  264. package/dist/semiotic.module.min.js +10 -1
  265. package/dist/server.min.js +651 -1
  266. package/dist/server.module.min.js +1 -1
  267. package/dist/xy.module.min.js +1 -1
  268. package/package.json +8 -7
  269. package/dist/c-2N7IU2NY.min.js +0 -1
  270. package/dist/c-2RL2QPZJ.min.js +0 -1
  271. package/dist/c-2WK7YJLL.min.js +0 -1
  272. package/dist/c-45CQWZZ6.min.js +0 -1
  273. package/dist/c-4BRHKVKV.min.js +0 -1
  274. package/dist/c-7242NXSG.min.js +0 -1
  275. package/dist/c-7DVPSB5C.min.js +0 -1
  276. package/dist/c-7EGHJU2F.min.js +0 -1
  277. package/dist/c-A7OGOFSL.min.js +0 -1
  278. package/dist/c-AFBSWT77.min.js +0 -1
  279. package/dist/c-AH5HWZWS.min.js +0 -1
  280. package/dist/c-AJ7EC32V.min.js +0 -1
  281. package/dist/c-AQADQNY7.min.js +0 -1
  282. package/dist/c-ATM475SA.min.js +0 -1
  283. package/dist/c-AVO3Q7T7.min.js +0 -1
  284. package/dist/c-B7GW7IHJ.min.js +0 -1
  285. package/dist/c-BNFJMDHN.min.js +0 -1
  286. package/dist/c-BOHCQILI.min.js +0 -1
  287. package/dist/c-C3TZLTZK.min.js +0 -1
  288. package/dist/c-CGQAQWBV.min.js +0 -1
  289. package/dist/c-CPV4N35K.min.js +0 -1
  290. package/dist/c-DIPEYUOW.min.js +0 -1
  291. package/dist/c-E4JDJH4I.min.js +0 -1
  292. package/dist/c-E72OTUZU.min.js +0 -1
  293. package/dist/c-E7I2L7CU.min.js +0 -1
  294. package/dist/c-ELDWAO2V.min.js +0 -1
  295. package/dist/c-EUBTECGM.min.js +0 -1
  296. package/dist/c-EUMPMDCS.min.js +0 -1
  297. package/dist/c-EZZT2WAE.min.js +0 -1
  298. package/dist/c-FHBVFCQB.min.js +0 -1
  299. package/dist/c-G4HCO2IQ.min.js +0 -1
  300. package/dist/c-G5VIJEOK.min.js +0 -1
  301. package/dist/c-GHVOXAYH.min.js +0 -1
  302. package/dist/c-GXV3C3MO.min.js +0 -1
  303. package/dist/c-HHTK2R75.min.js +0 -1
  304. package/dist/c-HLLFJYTY.min.js +0 -1
  305. package/dist/c-HP4ZFM47.min.js +0 -1
  306. package/dist/c-HPOYKCCG.min.js +0 -1
  307. package/dist/c-HYDTS5OP.min.js +0 -1
  308. package/dist/c-I4QJ6YLM.min.js +0 -1
  309. package/dist/c-IK33LNZ6.min.js +0 -1
  310. package/dist/c-IK3PZHRY.min.js +0 -1
  311. package/dist/c-JIMJF6F6.min.js +0 -1
  312. package/dist/c-JUKIWTBJ.min.js +0 -1
  313. package/dist/c-KKPMHAZC.min.js +0 -1
  314. package/dist/c-L6WNDBHV.min.js +0 -1
  315. package/dist/c-LDEX5OFW.min.js +0 -1
  316. package/dist/c-LESEUVC5.min.js +0 -1
  317. package/dist/c-LYQMZMZQ.min.js +0 -1
  318. package/dist/c-MB6CV5NC.min.js +0 -1
  319. package/dist/c-MOKJOIPE.min.js +0 -1
  320. package/dist/c-N3FXLRNT.min.js +0 -1
  321. package/dist/c-N5NPTJVJ.min.js +0 -1
  322. package/dist/c-NHBL4J67.min.js +0 -1
  323. package/dist/c-ODG6TFSY.min.js +0 -1
  324. package/dist/c-PRIKOLTE.min.js +0 -1
  325. package/dist/c-PSKKFZNP.min.js +0 -1
  326. package/dist/c-PSNI6KAZ.min.js +0 -1
  327. package/dist/c-QAVFOEUY.min.js +0 -1
  328. package/dist/c-R2P4RR7Q.min.js +0 -1
  329. package/dist/c-RFC7UAG7.min.js +0 -1
  330. package/dist/c-S3AZX5PP.min.js +0 -1
  331. package/dist/c-SGAURYHG.min.js +0 -1
  332. package/dist/c-SJMWU6UX.min.js +0 -1
  333. package/dist/c-STIIGQOD.min.js +0 -1
  334. package/dist/c-T2ASIJVZ.min.js +0 -1
  335. package/dist/c-T2V7O2LO.min.js +0 -1
  336. package/dist/c-TKG2NP7G.min.js +0 -1
  337. package/dist/c-TX3THUTO.min.js +0 -1
  338. package/dist/c-TX7XJM3Z.min.js +0 -1
  339. package/dist/c-UC7SIU2W.min.js +0 -1
  340. package/dist/c-UMXSJIOV.min.js +0 -1
  341. package/dist/c-VRSXMLYF.min.js +0 -1
  342. package/dist/c-VSLWSAN2.min.js +0 -1
  343. package/dist/c-VXLOLYTO.min.js +0 -1
  344. package/dist/c-W4ZUKSEQ.min.js +0 -1
  345. package/dist/c-WCBRPILW.min.js +0 -1
  346. package/dist/c-WGHT7OCY.min.js +0 -1
  347. package/dist/c-WWCW3APR.min.js +0 -1
  348. package/dist/c-XSB27XPS.min.js +0 -1
  349. package/dist/c-Y6PYUMFU.min.js +0 -1
  350. package/dist/c-YDECTEUW.min.js +0 -1
  351. package/dist/c-YF3YKVQI.min.js +0 -1
  352. package/dist/c-YLZIV3VS.min.js +0 -1
  353. package/dist/c-ZIVPFTOC.min.js +0 -1
@@ -1 +1,160 @@
1
- function e(e,t=[],n){const o=void 0===n?void 0:new Set("string"==typeof n?[n]:n),r=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&o?.has(e.partition)),i=new Set(r.map(e=>e.id)),s=new Set(r.map(e=>e.entityId)),a=new Map;let c=0;for(const t of e){if(void 0!==n&&"string"==typeof t.roles.occurrence&&!i.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===n&&(c+=t.entityCount);for(const[t,o]of e)(void 0===n||s.has(t))&&a.set(t,o)}return[...a.values()].reduce((e,t)=>e+t,c)}function t(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function n(){return Object.create(null)}function o(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function r(e,t,n){return t.has(e)?"node":(function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o=n.nodeIdsBySection,r=e)?o[r]:void 0)?"section":"global";var o,r}function i(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function s(t){const n=t.spec.comparison;if(!n)return;const o=n.partitions.map(o=>{const r=i(t.ledger,n.denominatorMeasureId,o)?.value??0,s={};return s["repeated-state-episode"]=e(t.motifs.matches.filter(e=>"repeated-state-episode"===e.template),t.source.occurrences,o),{partition:o,assigned:r,motifUsers:s,outcomes:{purchases:i(t.ledger,"purchases",o)?.value??0}}});return{partitions:[...n.partitions],denominatorMeasureId:n.denominatorMeasureId,referencePartition:n.referencePartition,rows:o}}function a(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return i(e.ledger,n,t)?.value}function c(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function l(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return!(!o?.sectionId||!t.coordinate.sectionIds.includes(o.sectionId))}function u(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function d(e,t){return e.sectionByNode.get(t)}function h(e,t){const n=new Set,o=[];for(const r of t){const t=d(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function f(e,t,n){return e.pairs.get(t)?.get(n)??[]}function p(e){return e.entityCount??1}function m(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=p(r));return{entityIds:n,entityCount:o}}function g(e,t,o,r,i,s){if(2>o.length)return;const{kept:a,truncation:c}=function(e,t){return null!=t&&e.length>t?{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}:{kept:e}}(o,s),l=[t,...a],u=[];for(const n of a){const o="fan-out"===e?f(i,t,n):f(i,n,t);u.push(...o)}const d=h(i,[t,...o]),p=m(r.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:a}:{destination:t,sources:a},nodePath:l,edgeIds:u,startSectionId:d[0],completionSectionId:d[d.length-1],intersectSectionIds:d,entityIds:p.entityIds,entityWeights:n(),entityCount:p.entityCount,flags:{occurrence:p.entityIds.length>0,temporal:!1,trajectorySupported:p.entityIds.length>0,enriched:!1},truncation:c}}function y(e,t,n){return 1===t.length&&1===n.length}function x(e){return e.entityCount??1}function b(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function w(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=function(e,t){const n=new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),u=new Map([[r,r]]),d=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=u.get(e):t=u.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>u.has(e)).reduce(d);u.get(e)!==t&&(u.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>u.has(t)?[[e,u.get(t)===r?null:n[u.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>u.has(t)),unreachableNodeIds:n.filter((e,t)=>!u.has(t))}}function M(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function v(e,i,a={}){const c=function(e,o){const r=[];e.schemaVersion!==Ps&&M(r,"schema-version","expected schemaVersion "+Ps),e.relations.directed&&!0===e.relations.edgeIdRequired||M(r,"relations","Phase 1 requires directed edges with ids"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&M(r,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&M(r,"coordinate","Phase 1 kernel uses ordinal sections");const i=n();for(const n of o.nodes)n.id?(i[n.id]&&M(r,"duplicate-node","duplicate node id",n.id),t(i,n.id,!0),"ordinal"===e.coordinate.kind&&n.sectionId&&!e.coordinate.sectionIds.includes(n.sectionId)&&M(r,"section-membership",`node section ${n.sectionId} is not in the coordinate`,n.id)):M(r,"node-id","node is missing id");const s=n();for(const e of o.edges)e.id?(s[e.id]&&M(r,"duplicate-edge","duplicate edge id",e.id),t(s,e.id,!0),i[e.source]||M(r,"dangling-source","edge source is not a node",e.id),i[e.target]||M(r,"dangling-target","edge target is not a node",e.id)):M(r,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])i[t]||M(r,"missing-root","display root is not a node",t);const a=e.forest.requiredPaths;if(a)if("directed-admitted"!==a.relationScopeId&&M(r,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(a.roots)&&0!==a.roots.length)for(const e of a.roots)i[e]||M(r,"required-path-roots","required-path root is not a node",e);else M(r,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&M(r,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(2>e.comparison.partitions.length&&M(r,"comparison","comparison requires at least two partitions"),e.measures[e.comparison.denominatorMeasureId]||M(r,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(c=e.measures)||"object"!=typeof c||Array.isArray(c))M(r,"measures","measures must be an object");else for(const[t,n]of Object.entries(e.measures))"rate"!==n.unitKind||n.timeDenominator||M(r,"rate-denominator","rate measures require a timeDenominator",t);var c;for(const t of o.measureValues)e.measures[t.measureId]?Number.isFinite(t.value)||M(r,"non-finite-measure","measure value is not finite",t.measureId):M(r,"unknown-measure","measureValue refers to an undeclared measure",t.measureId);for(const e of o.occurrences??[])if(e.id&&e.entityId){void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||0>e)||M(r,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)i[t]||M(r,"occurrence-node","occurrence path references a missing node",e.id)}else M(r,"occurrence","occurrence needs id and entityId");return{ok:r.every(e=>"fatal"!==e.severity),issues:r}}(e,i);if(!c.ok)return{ok:!1,issues:c.issues};const v=a.generation??1,k=function(e,o){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:n()};const r=n();for(const n of e.coordinate.sectionIds)t(r,n,[]);for(const e of o.nodes){if(!e.sectionId)continue;const t=r[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:r}}(e,i),$=function(e,o){const r=e.motifs.matchBudget,i=function(e){const t=new Map(e.nodes.map(e=>[e.id,new Set])),n=new Map(e.nodes.map(e=>[e.id,new Set])),o=new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}(o),s=[];for(const e of o.nodes){const t=g("fan-out",e.id,i.outgoing.get(e.id)??[],o,i,r);t&&s.push(t);const n=g("fan-in",e.id,i.incoming.get(e.id)??[],o,i,r);n&&s.push(n)}s.push(...function(e,t){const o=t.incoming,r=t.outgoing,i=[];for(const s of e.nodes){const a=o.get(s.id)??[],c=r.get(s.id)??[];if(1!==c.length)continue;const l=1===a.length&&y(0,o.get(a[0])??[],r.get(a[0])??[]);if(y(0,a,c)&&l)continue;const u=[s.id];let d=s.id;const p=new Set([d]);for(;;){const e=(r.get(d)??[])[0];if(!e||p.has(e))break;if(u.push(e),p.add(e),!y(0,o.get(e)??[],r.get(e)??[]))break;d=e}if(2>u.length)continue;const g=[];for(let e=0;u.length-1>e;e++)g.push(...f(t,u[e],u[e+1]));const x=h(t,u),b=m(e.occurrences??[],u[0]);i.push({id:"serial-chain:"+u.join(">"),template:"serial-chain",roles:{nodes:u,start:u[0],end:u[u.length-1]},nodePath:u,edgeIds:g,startSectionId:x[0],completionSectionId:x[x.length-1],intersectSectionIds:x,entityIds:b.entityIds,entityWeights:n(),entityCount:b.entityCount,flags:{occurrence:b.entityIds.length>0,temporal:!1,trajectorySupported:b.entityIds.length>0,enriched:!1}})}return i}(o,i)),s.push(...function(e,o){const r=[];for(const i of e.occurrences??[]){if(i.missingPrehistory)continue;const e=new Map,s=new Set;for(const[a,c]of i.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,a);continue}if(s.has(c))continue;s.add(c);const u=i.nodePath.slice(l,a+1),f=h(o,u),m=n();t(m,i.entityId,p(i)),r.push({id:`repeated-state-episode:${i.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:i.id},nodePath:u,edgeIds:[],startSectionId:d(o,u[0]),completionSectionId:d(o,u[u.length-1]),intersectSectionIds:f,entityIds:[i.entityId],entityWeights:m,entityCount:p(i),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return r}(o,i)),function(e,o){const r=o.occurrences??[];if(0!==r.length)for(const o of e){if("repeated-state-episode"===o.template)continue;const e=o.nodePath,i=n();for(const n of r)n.missingPrehistory||e.some(e=>n.nodePath.includes(e))&&t(i,n.entityId,p(n));const s=Object.keys(i);o.entityIds=s,o.entityWeights=i,o.entityCount=s.reduce((e,t)=>e+(i[t]??0),0),o.flags={...o.flags,occurrence:s.length>0,trajectorySupported:s.length>0}}}(s,o);const a=[];for(const e of o.occurrences??[])e.missingPrehistory&&(a.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),a.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const c=Fs.filter(e=>!Os.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:s,incompleteCandidates:a,unsupportedTemplates:c}}(e,i),S=function(e,o){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return function(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=function(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),u=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!u.has(e.id)).map(e=>e.id)}}}(o,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const r=o.edges.map(e=>e.id),i=e.forest.display.rankingPolicyId??"main-transport",{mode:s,order:a}=function(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}(i),c=t=>l(o,e,t.source)&&l(o,e,t.target),d=new Map;for(const e of o.nodes)d.set(e.id,[]);for(const e of o.edges)d.has(e.target)||d.set(e.target,[]),d.get(e.target).push(e);const h=n(),f=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:o.nodes[0]?[o.nodes[0].id]:[],p=new Set(f);for(const e of o.nodes){if(p.has(e.id))continue;const n=u(d.get(e.id)??[],a),o=n.find(e=>c(e))??n[0];o&&t(h,e.id,o.id)}let m;m="tree-only"===s?Object.values(h):o.edges.filter(e=>c(e)).map(e=>e.id);const g=new Set(m),y=r.filter(e=>!g.has(e));return{forest:{kind:"rooted-backbone",roots:[...f],rankingPolicyId:i,backboneEdgeIds:m,primaryParentEdgeIdByNode:h},residual:{residualEdgeIds:y,originalEdgeIds:r}}}(e,i);!function(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw Error("original edge IDs != backbone ⊎ residual")}(S.residual,S.forest);const I=function(e,o,i){const s=[],a=new Set(o.nodes.map(e=>e.id)),c=new Set;for(const t of o.measureValues){const n=e.measures[t.measureId];if(!n)continue;const o=r(t.subjectId,a,i);s.push({measureId:t.measureId,subjectId:t.subjectId,subjectKind:o,value:t.value,status:t.status,unitKind:n.unitKind,countUnit:n.countUnit,timeDenominator:n.timeDenominator}),"section"===o&&c.add(`${t.measureId}\0${t.subjectId}`)}const l=n();for(const e of o.nodes)t(l,e.id,e);const u=n(),d=n();for(const e of s){if("node"!==e.subjectKind)continue;const t=l[e.subjectId];if(!t?.sectionId)continue;const n=`${e.measureId}\0${t.sectionId}`;c.has(n)||(u[n]=(u[n]??0)+e.value,"exact"!==e.status?d[n]=e.status:d[n]||(d[n]="exact"))}for(const[t,n]of Object.entries(u)){const o=t.split("\0"),r=o[0],i=e.measures[r];i&&s.push({measureId:r,subjectId:o[1],subjectKind:"section",value:n,status:d[t]??"exact",unitKind:i.unitKind,countUnit:i.countUnit,timeDenominator:i.timeDenominator})}return{entries:s}}(e,i,k),A=function(e,o){const r=n();for(const n of e.nodes)t(r,n.id,n.completeness??"known");const i=n();for(const e of o.unsupportedTemplates)t(i,e,"unsupported-template");if(o.incompleteCandidates.length>0){const e=new Set(o.incompleteCandidates.map(e=>e.template));for(const n of e)t(i,n,"incomplete")}const s=o.matches.find(e=>e.truncation),a={nodes:r,motifs:i,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return s?.truncation&&(a.truncation={disclosed:!0,template:s.template,omitted:s.truncation.omitted}),a}(i,$),C=function(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;e.length-1>o;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}(i),j=function(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}(e,i,v),N="observed-prefix"===e.forest.display.kind||(i.occurrences?.length??0)>0?function(e,r={}){function i(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const s={id:"",stateId:"",prefix:[],children:new Map,occurrenceIds:[],entityCount:0,partitionCounts:new Map};for(const t of e){if(t.missingPrehistory)continue;const e=x(t);let n=s;n.occurrenceIds.push(t.id),n.entityCount+=e,b(n,t.partition,e);for(const r of t.nodePath){const i=[...n.prefix,r],s=o(i,i.length-1);let a=n.children.get(r);a||(a={id:s,stateId:r,prefix:i,children:new Map,occurrenceIds:[],entityCount:0,partitionCounts:new Map},n.children.set(r,a)),a.occurrenceIds.push(t.id),a.entityCount+=e,b(a,t.partition,e),n=a}}const a=[],c=[],l=r.referencePartition;return function e(o,r){if(o.id){const e=n();for(const[n,r]of o.partitionCounts)t(e,n,r);a.push({id:o.id,stateId:o.stateId,prefix:o.prefix,parentId:r,childIds:i(o).map(e=>o.children.get(e).id),entityCount:o.entityCount,occurrenceIds:[...o.occurrenceIds],partitionCounts:e}),c.push(o.id)}for(const t of i(o))e(o.children.get(t),o.id||null)}(s,null),{kind:"observed-prefix",rootIds:i(s).map(e=>s.children.get(e).id),nodes:a,order:c,referencePartition:l}}(i.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,E={sourceGraphRef:i.graphRef,analysisRevision:j,spec:e,source:i,sections:k,motifs:$,forest:S.forest,residualEdges:S.residual,ports:C,ledger:I,completeness:A,provenance:{sourceRevision:i.revision,analysisRevision:j,generation:v,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?"ordinal:"+e.coordinate.sectionIds.join(","):"numeric:"+e.coordinate.field,forestRoots:[...e.forest.display.roots??S.forest.roots],rankingPolicyId:S.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:N,...e.forest.requiredPaths&&{requiredPaths:w(i,e.forest.requiredPaths)}};return E.comparison=s(E),{ok:!0,atlas:E,issues:c.issues}}function k(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function $(t,n={}){const o=n.templates??["repeated-state-episode"],r="ordinal"===t.spec.coordinate.kind?t.spec.coordinate.sectionIds:[],i=void 0!==n.partition?a(t,n.partition)??0:t.spec.comparison?t.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:t.ledger.entries.find(e=>"global"===e.subjectKind&&e.measureId===t.spec.motifs.denominatorRef)?.value??0,s=o=>e(o,t.source.occurrences,n.partition??t.spec.comparison?.partitions),c=[],l=t.motifs.incompleteCandidates.length>0;for(const e of o)for(const o of r){const r=t.motifs.matches.filter(t=>t.template===e),a=s(r.filter(e=>e.completionSectionId===o)),u=s(r.filter(e=>e.intersectSectionIds.includes(o)));c.push({template:e,sectionId:o,partition:n.partition,completionCount:a,intersectionCount:u,denominator:i,status:l?"incomplete":"exact"})}return{templates:o,sections:r,cells:c}}function S(e){return e.entityCount??1}function I(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:S(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:o(e.nodePath,e.nodePath.length-1)}}function A(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:$(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(I).filter(e=>!!e),r=new Map;for(const e of n){const n=t.order.indexOf(e.signature),o=r.get(e.signature),i=-1===n?t.order.length:n;(null==o||o>i)&&r.set(e.signature,i)}const i=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(r.get(e)??0)-(r.get(t)??0);return 0!==n?n:e.localeCompare(t)}),a=[];for(const e of n)for(let t=0;e.nodePath.length-1>t;t++){const n=o(e.nodePath,t),r=o(e.nodePath,t+1);a.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:r,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const l=function(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>({id:"capsule:"+e.id,matchId:e.id,template:e.template,entryState:"string"==typeof e.roles.state?e.roles.state:e.nodePath[0],exitState:e.nodePath[e.nodePath.length-1],entityCount:e.entityCount,occurrenceIds:k(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}(e.motifs.matches),u=e.comparison??s(e),d=[];if(u&&u.partitions.length>=2){const e=u.rows[0],t=u.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;d.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:c(o,r,n),denominator:n}),d.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:c(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const h={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:a.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:i,ribbons:a,capsules:l,profile:$(e),differences:d,prefixForest:t,sceneSeeds:h}}function C(e,t){return e.groups.some(e=>function(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}(e.nodePath,t))}function j(e){return"function"==typeof e?e:t=>t[e]}function N(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function E(e){return null==e?null:e.data??e.datum??e}function P(e,t){const n=new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function F(e){const t=Object.create(null);return e((e,n)=>{t[e]=n}),t}function z(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function O(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!z(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function L(e){return e.join("|")}function R(e,t=.72){const n=(0,ga.interpolateLab)(e,"#ffffff"),o=(0,ga.interpolateLab)(e,"#000000"),r=(0,ga.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function T(e,t,n=.72){return R(e,n)(t)}function W(e){return F(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function q(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function D(e,t,n){return Math.max(t,Math.min(n,e))}function B(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function V(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function G(e,t){const n=D(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function Y(e,t,n){const o=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,r=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(r(t.weight)>0?1:0),0),s=i>0?Math.min(Math.max(0,Math.floor(n?.minPerCategory??0)),Math.floor(o/i)):0,a=e.reduce((e,t)=>e+r(t.weight),0);if(0>=o||0>=a)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const c=e.map(e=>{const t=r(e.weight),n=t/a*o;return{...e,exact:n,cells:t>0?Math.max(s,Math.floor(n)):0,remainder:n-Math.floor(n)}});let l=c.reduce((e,t)=>e+t.cells,0);for(;l>o;){const e=c.filter(e=>e.cells>s).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,l--}const u=c.filter(e=>r(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||r(t.weight)-r(e.weight)||e.key.localeCompare(t.key));for(let e=0;o>l;e++)u[e%u.length].cells++,l++;return c}function H(e,t,n,o){const r=new Set;return e.map((e,i)=>{const s=t(e,i)+"",a=Number(n(e,i));if(!s)throw Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||0>a)throw Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function _(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null==n.epsilon||0>n.epsilon?1e-9:n.epsilon,s=H(e,n.beforeId,n.beforeValue,"Before"),a=H(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),u=s.reduce((e,t)=>e+t.value,0),d=a.reduce((e,t)=>e+t.value,0),h=i>=Math.abs(u-d);if(!h&&!n.allowImbalance)throw Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],p=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of p){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const m=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;m.length>y&&g.length>x;){const e=m[y],t=g[x],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value>i||(y+=1),t.value>i||(x+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:m.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function X(e){return Number.isFinite(e)?Math.max(0,e):0}function U(e,t){const n=Number(t.unit),o=X(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=Math.ceil(o/n-ba),a=Math.min(r,s),c=s>r,l=[];for(let e=0;a>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));ba>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function K(e,t,n){const o=U(e,n),r=Math.max(X(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=U(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+ba);let c=Math.min(1,Math.max(0,s-a));ba>c&&(c=0);const l=[];for(const e of i.units)a>e.index||(e.index===a&&c>0?e.fraction-c>ba&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function Q(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Z(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,s=n.linkStrength??.045,a=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=Q(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const p=Ma/2,m=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=new Set(e.map(e=>e.id)),y=t.filter(e=>g.has(e.source)&&g.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,wa.forceSimulation)(m).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,wa.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,wa.forceCollide)(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",(0,wa.forceCenter)(p,p).strength(.8)).force("x",(0,wa.forceX)(p).strength(a)).force("y",(0,wa.forceY)(p).strength(a));y.length>0&&e.force("link",(0,wa.forceLink)(y).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return s/.045/n})),e.stop();for(let t=0;o>t;t+=1)e.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const e of m){const t=e.x??p,n=e.y??p;x>t&&(x=t),b>n&&(b=n),t>w&&(w=t),n>M&&(M=n)}const v=w-x,k=M-b,$={};for(const e of m)Object.defineProperty($,e.id,{value:{x:0===v?.5:d+((e.x??p)-x)/v*(1-2*d),y:0===k?.5:d+((e.y??p)-b)/k*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return $}function J(e){return e?e.map(Number).filter(Number.isFinite):[]}function ee(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function te(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function ne(e){if(e.samples)return J(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function oe(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function re(e,t){const n=te(t),o=function(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:J(e),data:e}:e}(e);let r,i,s,a,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?U(B(o.value),e):K(B(o.value),B(o.rangeValue),e);r=t.units.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){a=Math.floor(B(o.denominator??n.denominator)),s=B(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>oe(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=a,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=ne(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,ee(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=function(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}(e,r);return oe(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=ne(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,ee(n));r=("random-sample"===n.countStrategy?function(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=Q(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return oe(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>oe(n,t,1,{datum:e})),i=e.length;else{const e=U(B(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=function(e,t){const n=ee(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:se(n,{visibleTokens:r.length+(u?.length??0)})}}function ie(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,s=t.cellHeight??i,a=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,p=t.y??0;return n.map((e,n)=>{let o,m;return"column"===r?(m=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),m=n%l),"left"===t.columnDirection&&(m=h-1-m),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:m,x:f+m*(i+a)+c[0]*i,y:p+o*(s+a)+c[1]*s}})}function se(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||B(e.denominator)>ka?va:ka);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function ae(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function ce(e){const t=ae(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function le(e){const t=ae(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:se(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:se(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:se(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:se(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function ue(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return function(e){const t=1.5*de(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t);const r=Object.prototype.hasOwnProperty.call(Sa,o)?Sa[o]:$a.symbolCircle;return(0,$a.symbol)(r,Math.max(1,t))()??""}function de(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function he(e,t,n){if(!n&&"circle"===(e??"circle"))return de(t);const o=n?"p:"+n:`s:${e??"circle"}:${t}`,r=Aa.get(o);if(null!=r)return r;const i=ue(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Aa.size>512&&Aa.clear(),Aa.set(o,s),s):de(t)}function fe(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function pe(e,t,n){return"function"==typeof e?e(t)??n:e??n}function me(e,t){return"function"==typeof e?e(t):e}function ge(e){return e.sample??e.value??e.index}function ye(e,t){return void 0!==t.datum?pe(t.datum,e,null):e.datum??null}function xe(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?pe(t.rangeColor,e,qa):pe(t.color,e,Ta):pe(t.inactiveColor,e,Wa),stroke:"none",...me(t.style,e)??{}}}function be(e,t){const n=me(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:ye(e,t),accessibleDatum:me(t.accessibleDatum,e),accessibility:me(t.accessibility,e),pointId:n,_transitionKey:n}}function we({input:e,encoding:t,options:n={}}){if(!fe(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=fe(e)?{...e,encoding:te(e.encoding)}:re(e,t),r=function(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return function(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,s=Math.max(1,Math.floor(t.rows??1)),a=e.map(ge),c=Math.min(...a),l=Math.max(...a)-c||1;return e.map((a,u)=>{const d=ge(a),h=u%s,f=t.valueToX?t.valueToX(d,a):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),p=t.valueToY?t.valueToY(d,a):o+h*(r+i);return{...a,x:f,y:p,row:h,column:u}})}(n,t);if("dotplot"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,s=t.cellWidth??r+i,a=t.cellHeight??r+i,c=e.map(ge),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return e.map(r=>{const i=ge(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*s),h=Math.round((c-n)/Math.max(1,s)),f=d.get(h)??0;d.set(h,f+1);const p=t.valueToY?t.valueToY(i,r):o+f*a;return{...r,x:n+h*s,y:p,row:f,column:h}})}(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:ge(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:function(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}(n,t,i);return ie(n,{...t,columns:a,cellWidth:i,cellHeight:s})}(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>function(e,t,n){if("dot"===n.tokenType)return function(e,t){const n=pe(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:pe(t.radius,e,n/2),style:xe(e,t),...be(e,t)}}(e,t);const o=me(t.glyph,e)??function(e){if(e)return Ra[e]}(n.icon);if(o)return function(e,t,n){const o=xe(e,n),r=pe(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??Ta)+"",accent:pe(n.accent,e,Da),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:pe(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?me(n.ghostColor,e)??Wa:void 0,rotation:me(n.rotation,e),style:o,...be(e,n)}}(e,o,t);const r=(i=n.icon)&&Ba.has(i)?i:void 0;var i;return function(e,t){const n=pe(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:pe(t.symbolType,e,"circle"),path:me(t.symbolPath,e),rotation:me(t.rotation,e),style:xe(e,t),...be(e,t)}}(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}(e,n,o.encoding))}}function Me(e){return`${e.getUTCFullYear()}-${ve(e.getUTCMonth()+1)}-${ve(e.getUTCDate())}`}function ve(e){return 10>e?"0"+e:e+""}function ke(){const e=(ma??(ma=Ha.createContext(null)),ma);return Ha.useContext(e)??_a}function $e(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Se(e,t){const n=$e(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Ie(e,t){if(Ja.has(t))return Se(e,t)}function Ae(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Ce(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function je(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function Ne(e){return Ja.has(e)?e:"monument"}function Ee(e,t){const n=je(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=Ae(t.idAccessor,"id"),a=Ae(t.nameAccessor,"name"),c=Ae(t.longitudeAccessor,"lon"),l=Ae(t.latitudeAccessor,"lat"),u=Ae(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Ae(t.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const p of e){const e=Number(c(p)),m=Number(l(p));if(!Number.isFinite(e)||!Number.isFinite(m))continue;const g=(s(p)??`${e},${m}`)+"",y=(a(p)??g)+"",x=Ne(u(p)),[b,w]=Ce(e,m,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,S={...p,id:g,name:y,kind:x,lon:e,lat:m,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(p))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=S);const I=`${v}:${M}`,A=h.get(I)??[];A.push(S),h.set(I,A)}const p=new Map;f&&p.set("city",1);const m=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,s=(t+.5)*r-o,a=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=p.get(e.kind)??0,i=p.get(t.kind)??0,s=r*r*.35;return e.cellDistanceSq+o*s-(t.cellDistanceSq+i*s)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&p.set(c.kind,(p.get(c.kind)??0)+1),m.push({id:n,row:e,column:t,centerXKm:s,centerYKm:a,terrainIndex:Math.abs((17*e+31*t)%Ka.length),landmark:c,landmarks:l})}return m}function Pe({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=ke(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);return(0,Xa.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,u=a.isActive&&!a.predicate(s)?.28:1;return(0,Xa.jsxs)("g",{opacity:u,children:[(0,Xa.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),(0,Xa.jsx)(ze,{kind:s.kind,href:Ie(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&(0,Xa.jsx)(Fe,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},s.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);return(0,Xa.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[(0,Xa.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),(0,Xa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function Fe({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,s=Math.max(r,i.length*r*.58);return(0,Xa.jsxs)("g",{transform:`translate(${e},${t})`,children:[(0,Xa.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),(0,Xa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function ze({kind:e,href:t,x:n,y:o,size:r}){if(t)return(0,Xa.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=oc[e];return(0,Xa.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:nc[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:(0,Xa.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}function Oe(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Le(e,t,n){return Math.max(t,Math.min(n,e))}function Re(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(t>o&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function Te(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function We(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=Le(Number.isFinite(t.occupancy)?Number(t.occupancy):ic,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):sc;let i=Oe(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=Oe(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));n.length>i*s&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=Re(n.map(e=>e.x)),c=Re(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:Te(e.x,a)*Math.max(0,i-1),desiredRow:Te(e.y,c)*Math.max(0,s-1)})),u=(i-1)/2,d=(s-1)/2;l.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const h=new Set;for(let e=0;s>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=(o%i-e.desiredColumn)**2+(Math.floor(o/i)-e.desiredRow)**2;(n>r||r===n&&t>o)&&(t=o,n=r)}0>t||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function qe(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function De(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function Be({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=ke();return(0,rc.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);return(0,rc.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function Ve(){throw Error("geographicDotGrid requires the geo recipe bundle")}function Ge(e,t,n){return Math.max(t,Math.min(n,e))}function Ye(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function He(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function _e(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function Xe(e,t){const n=_e(e);return(e.id??n.id??n.name??"feature-"+t)+""}function Ue(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function Ke(e){if(!e)return 0;const t=fc.get(e);if(t)return t;const n=pc;return pc+=1,fc.set(e,n),n}function Qe(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(n=e[0],o=t[0][0],r=t[1][0],o>r?o>n&&n>r:o>n||n>r));var n,o,r}function Ze(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&Qe(t,n.bounds))try{if(Ve())return{feature:e,index:o}}catch{}}return null}function Je(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=function(e,t){if(0===e.length)return null;const n=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(n[0][0])&&Number.isFinite(n[0][1])&&Number.isFinite(n[1][0])&&Number.isFinite(n[1][1])?n:null}(r,t.geoPath);if(!i)return{dots:[],cellSize:lc,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[Ge(i[0][0],s,Math.max(s,n.width-s)),Ge(i[0][1],s,Math.max(s,n.height-s))],[Ge(i[1][0],s,Math.max(s,n.width-s)),Ge(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:lc,features:r};const u=Ye(o.columns);let d=Math.max(2,u?c/u:Ye(o.cellSize)??lc);const h=Math.max(100,Math.round(Ye(o.maxSamples)??uc)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const p=o.gridOrigin?.[0]??0,m=o.gridOrigin?.[1]??0,[g,y]=Ue(a[0][0],a[1][0],p,d),[x,b]=Ue(a[0][1],a[1][1],m,d),w=[],M=function(e){return e.map((e,t)=>{if(hc.has(e))return{feature:e,index:t,bounds:hc.get(e)??null};try{const n=function(){throw Error("geographicDotGrid requires the geo recipe bundle")}();return hc.set(e,n),{feature:e,index:t,bounds:n}}catch{return hc.set(e,null),{feature:e,index:t,bounds:null}}})}(r);for(let e=x;b>=e;e+=1){const n=m+(e+.5)*d;for(let r=g;y>=r;r+=1){const i=t.invertedPoint(p+(r+.5)*d,n);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;const s=Ze(M,i);if(!s)continue;const a={..._e(s.feature),featureId:Xe(s.feature,s.index),featureIndex:s.index,gridRow:e,gridColumn:r,longitude:i[0],latitude:i[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(a,w.length)||w.push(a)}}return{dots:w,cellSize:d,features:r}}function et(e){return Math.round(1e4*e)/1e4}function tt(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${et(Number(e[0]))},${et(Number(e[1]))}`:"null"}function nt(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function ot(e){return"number"==typeof e&&Number.isFinite(e)?et(e)+"":null===e?"null":"unavailable"}function rt(e){const t=e.scales.projection;return[ot(nt(t,"scale")),tt(nt(t,"translate")),tt(nt(t,"center")),(n=nt(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>et(Number(e))).join(","):"unavailable"),ot(nt(t,"clipAngle")),ot(nt(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>tt(e.scales.projectedPoint(t,n)))].join("|");var n}function it(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function st(e,t){const n="function"==typeof t?t(e):e[t];return bc(n)?n:void 0}function at(e){return[...e].sort((e,t)=>e.localeCompare(t))}function ct(e,t,n){const o=new Map([[e,0]]),r=[e];for(;r.length>0;){const e=r.shift(),i=o.get(e);for(const s of at(n.get(e)??[]))t.has(s)&&!o.has(s)&&(o.set(s,i+1),r.push(s))}return o}function lt(e,t,n){return[...ct(e,t,n).entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))[0][0]}function ut(e,t,n){const o=new Set(e),r=e.filter(e=>1>=(t.get(e)?.size??0))[0]??e[0],i=ct(n&&o.has(n)?n:lt(lt(r,o,t),o,t),o,t),s=Math.max(0,...i.values()),a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?1/0:n.reduce((e,t)=>e+t,0)/n.length};a[e].sort((e,t)=>r(e)-r(t)||e.localeCompare(t))};for(let e=0;4>e;e+=1){for(let e=1;a.length>e;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function dt(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:st(e.data,s),authoredY:st(e.data,a)})),l=c.length>0&&c.every(e=>bc(e.authoredX)&&bc(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=function(e,t,n,o,r,i){const s=function(e,t){const n=new Map(e.map(e=>[e,new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}(e.map(e=>e.id),t),a=function(e){const t=new Set(e.keys()),n=[];for(;t.size>0;){const o=at(t)[0],r=[o],i=[];for(t.delete(o);r.length>0;){const n=r.shift();i.push(n);for(const o of at(e.get(n)??[]))t.has(o)&&(t.delete(o),r.push(o))}n.push(i.sort((e,t)=>e.localeCompare(t)))}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}(s),c=new Map(e.map(e=>[e.id,e.data])),l=new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),p=Math.max(0,d-2*f),m=a.length>1?Math.min(r,p/a.length):0,g=Math.max(0,p-m*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=ut(e,s,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{l.set(n,{id:n,x:i,y:1===e.length?x+t/2:x+o/(e.length-1)*t,data:c.get(n)})})}),x+=t+m}return l}(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}const h=c.map(e=>e.authoredX),f=c.map(e=>e.authoredY),p=Math.min(...h),m=Math.max(...h),g=Math.min(...f),y=Math.max(...f),x=Math.max(1,n.width-2*r),b=Math.max(1,n.height-2*r),w=e=>({x:m===p?n.width/2:r+(e.x-p)/(m-p)*x,y:y===g?n.height/2:r+(e.y-g)/(y-g)*b}),M=new Map;for(const e of c){const t=w({x:e.authoredX,y:e.authoredY});M.set(e.id,{id:e.id,...t,data:e.data})}return{positions:M,mode:"authored",warnings:d,projectAuthoredPoint:w}}function ht(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(.001>r||.001>i||.001>Math.abs(r-i))return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function ft(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=e.length-1>r?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(.001>l)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(.001>Math.abs(u))return{x:o.x+s.x*t,y:o.y+s.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:o.x+a*h,y:o.y+c*h}})}function pt(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(.001>=l){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},d={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function mt(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):N(e.data,t.labelAccessor??"label",e.id)}function gt(e){return"string"==typeof e?e:e.id}function yt(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,function(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:e.id+""}:{id:e+""});return t.length>0?t:[{id:"network"}]}(o)}function xt(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function bt(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function wt(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??1/0)-(n.get(t)??1/0)||e.localeCompare(t))}function Mt(e,t){const n=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(n.get(e.descriptor.id)??1/0)-(n.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function vt(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>"number"==typeof e.x&&"number"==typeof e.y?t.projectAuthoredPoint({x:e.x,y:e.y}):null).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function kt(e,t){return F(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function $t(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):N(e.data,i.labelAccessor??"label",e.id)+"")||e.id,u=Math.max(2*s,l.length*s*.58),d=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,f=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-u},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-u/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-u/2}].map((e,t)=>{const n={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},o=a.filter(e=>{return(o=e).right>(t=n).left&&t.right>o.left&&o.bottom>t.top&&t.bottom>o.top;var t,o}).length;return{candidate:e,box:n,score:1e4*o+10*(Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height))+t}}).sort((e,t)=>e.score-t.score)[0];a.push(f.box),c.push({x:f.candidate.x,y:f.candidate.y,text:l,anchor:f.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function St(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function It(e){return(1e-12>Math.abs(e)?0:e)+""}function At(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function Ct(e,t){return Number.isFinite(e)?D(e,0,1):t}async function jt(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(ca(),aa));return o(e,t,n)}async function Nt(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>(fa(),da));return t(e)}function Et(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function Pt(e,t,n){if(2>e.length)return"";const o=function(e){const t=[e[0]];for(let n=1;e.length-1>n;n++){const o=e[n-1],r=e[n],i=e[n+1],s=Ac(o,r),a=Ac(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Ic(r,o,c/s),u=Ic(r,i,c/a);t.push(l);for(let e=1;12>=e;e++){const n=e/12;t.push(Ic(Ic(l,r,n),Ic(r,u,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||Ac(t[n-1],e)>1e-8)}(e);if(2>o.length)return"";const r=[0];for(let e=1;o.length>e;e++)r.push(r[e-1]+Ac(o[e-1],o[e]));const i=r[r.length-1],s=ft(o,1),a=[1,-1].map(e=>o.map((o,a)=>Ic(o,s[a],e*(t+(n-t)*r[a]/i)/2)));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function Ft(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function zt(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function Ot(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function Lt(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,u={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":return(0,Pc.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":return(0,Pc.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);return(0,Pc.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;return(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),(0,Pc.jsx)("path",{d:t,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);return(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),(0,Pc.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),(0,Pc.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:return(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}function Rt(e){return(0,Oc.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Tt(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function Wt(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function qt(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:(0,Oc.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function Dt(e){const t=e.spacing??8;return{def:(0,Oc.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:(0,Oc.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function Bt(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,p)=>{const m=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===p?"start":e.edgeAnchor&&p===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:m,y:x}:{x:x,y:m};return(0,Oc.jsxs)("g",{children:[(r>0||i>0)&&(0,Oc.jsx)("line",{...n?{x1:m,x2:m,y1:g,y2:y}:{x1:g,x2:y,y1:m,y2:m},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),(0,Oc.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:a,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${p}`)});return(0,Oc.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function Vt(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,(0,Oc.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&(0,Oc.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),(0,Oc.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),(0,Oc.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function Gt(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:s,inAdj:a,undirected:c}=Kt(r,t),l=Qt(r,s,a,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ut(e)})),u=new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function Yt(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Ht(e){return"string"==typeof e?e:e?.id}function _t(e,t,n,o,r){const i=new Set(e);let s=new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,Yt(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return Yt(`${e.length}#${o}#${a.join(";")}`)}function Xt(e,t,n,o,r,i,s){function a(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=p.get(o);m.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+h/2}const{layer:c,layerCount:l}=function(e,t){const n=new Set(e),o=new Map,r=new Set,i=e=>{const s=o.get(e);if(void 0!==s)return s;if(r.has(e))return 0;r.add(e);let a=0;for(const o of t.get(e)??[])n.has(o)&&(a=Math.max(a,1+i(o)));return r.delete(e),o.set(e,a),a};let s=0;for(const t of e)s=Math.max(s,i(t));const a=new Map;for(const t of e)a.set(t,s-o.get(t));return{layer:a,layerCount:s+1}}(e.ids,o),u=Array.from({length:l},()=>[]);for(const t of e.ids)u[c.get(t)].push(t);const d=.14*Math.min(i.width,i.height),h=Math.max(1,i.width-2*d),f=Math.max(1,i.height-2*d),p=new Map,m=new Set(e.ids);for(let e=0;l>e;e+=1){let t=u[e];e>0&&(t=[...t].sort((e,t)=>a(e)-a(t)));const n=t.length,o=i.y+d+(1===l?.5:e/(l-1))*f;t.forEach((e,t)=>{p.set(e,{x:i.x+d+(1===n?.5:t/(n-1))*h,y:o})})}const g=u.reduce((e,t)=>Math.max(e,t.length),1),y=D(Math.min(s,h/(2.4*g),f/(2.4*l)),1.4,s),x=e.ids.map(e=>{const o=p.get(e);return{id:e,cx:o.x,cy:o.y,r:y,datum:t.get(e)??W({id:e}),category:n.get(e)??""}}),b=[];for(const t of e.ids){const e=p.get(t);for(const n of o.get(t)??[]){if(!m.has(n))continue;const t=p.get(n);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function Ut(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function Kt(e,t){const n=new Set(e),o=new Map,r=new Map,i=new Map;for(const t of e)o.set(t,new Set),r.set(t,new Set),i.set(t,new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function Qt(e,t,n,o,r){const i=new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}s.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:_t(c,t,n,h,r)})}return s}function Zt(e,t,n){return e?Xt(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}function Jt(e){return E(e)??e}function en(e){return"string"==typeof e?e:e.id}function tn(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function nn(e){return Math.round(100*e)/100+""}function on(e,t){if(2>e.length)return"";let n=`M${nn(e[0][0])},${nn(e[0][1])}`;for(let o=1;e.length-1>o;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(0>=l){n+=`L${nn(i[0])},${nn(i[1])}`;continue}const u=[(i[0]-r[0])/a,(i[1]-r[1])/a],d=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${nn(h[0])},${nn(h[1])}Q${nn(i[0])},${nn(i[1])} ${nn(f[0])},${nn(f[1])}`}const o=e[e.length-1];return`${n}L${nn(o[0])},${nn(o[1])}`}function rn(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,u=t-s*o*.44,d=[l+a*r*.5,u+i*r*.5],h=[l-a*r*.5,u-i*r*.5];return`M${nn(c[0])},${nn(c[1])}L${nn(d[0])},${nn(d[1])}L${nn(h[0])},${nn(h[1])}Z`}function sn(e,t){return`${t}\0${e}`}function an(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function cn(e,t,n){if(1>=e)return 0;const o=Math.max(0,n.flowGap??.75),r=an(t,n);return Math.min(o,Math.max(0,(r-Math.min(.1,r))/(e-1)))}function ln(e,t,n){const o="function"==typeof t?t(e):N(e,t,n);return null==o||""===o?n:o+""}function un(e,t){const n="function"==typeof t?t(e):N(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:e+""}return n+""}}function dn(e,t){const n="function"==typeof t?t(e):N(e,t,1);return Number(n)}function hn(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function fn(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=new Map,f=new Map;for(const t of e){const e=ln(t,o,d.length+"");if(h.has(e))continue;const n=ln(t,i,e),s=ln(t,r,e),a={id:e,label:n,group:s,datum:t};d.push(a),h.set(e,a);const c=f.get(s);c?c.push(a):f.set(s,[a])}const p=new Set(d.map(e=>e.id)),m=[],g=new Map,y=new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=hn(`${n.groupIdPrefix??"group:"}${e}`,p),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};m.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};m.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=new Map;let M=0;for(const e of t){const t=un(e,s),n=un(e,a),o=dn(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!(r&&i&&Number.isFinite(o)&&o>0)){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:m,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function pn(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function mn(e,t,n){return t>e?t:e>n?n:e}function gn(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function yn(e,t,n){const o=new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function xn(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function bn(e,t){return function(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}(xn(e,t),e.bottomRadius,t)}function wn(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-bn(e,r),s=0;for(;100>s&&Math.abs(i)>1e-4;)r+=i/o,i=t-bn(e,r),s++;return r}function Mn(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function vn(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,s=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>s&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const a=e-2*t;t>a?e>2*t&&n.push({x:0,y:0}):o(a)};return o(e-t),n}function kn(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),s=vn(xn(e,n),t),a=s.length-r,c=a>1?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Mn(97*i+t,.15),z:l+Mn(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function $n(e,t,n,o){if(0>=o)return[];const r=function(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=xn(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Jc)),r++}return r}(e,t,o),i=Math.max(t,n-r*Jc)+.875,s=[];let a=0;for(let t=0;r>t&&o>a;t++){const n=i+Jc*t,r=xn(e,n),c=Math.max(1,Math.floor(2*r/Jc)),l=(2*r-c*Jc)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>a;e++)s.push({cx:u+(l+Jc)*e+.875,cy:d+.875,rotation:Mn(53*t+e,10)}),a++}return s}function Sn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function In(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function An(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Cn(e){return null==e?null:e+""}function jn(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Nn(e){return!!e&&"object"==typeof e&&nl.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function En(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Pn(e){return"primary"===e?.emphasis||!0===e?.defensive}function Fn(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:ol))):1/0}function zn(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function On(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??rl),i=Fn(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Nn(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Pn(e.annotation)),l=a.filter(e=>!Pn(e.annotation)).sort((e,t)=>zn(t.annotation)-zn(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}function Ln(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(ml,t.source)?ml[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function Rn(e){if(!Tn(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Tn(e){return Nn(e)}function Wn(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function qn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Dn(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Bn(e,t,n,o,r,i,s,a){const c=qn(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,a);for(const e of n)l+=12*Dn(c,e);for(const e of o)l+=4*Dn(c,e);return l}function Vn(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return jn(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}(n);return o?jn(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Cn(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Cn(e.pointId)===o);if(r)return jn(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Cn(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const s=In(i,n),a=An(i,n);return null==s||null==a?null:jn(t,n,{x:s,y:a})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=In(e,n),i=An(e,n)),null!=r&&null!=i)return jn(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function Gn(e){const{annotations:t,context:n,defaultOffset:o=il,notePadding:r=sl,markPadding:i=al,edgePadding:s=cl,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ll,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:m,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof p?p:{},w=b.breakpoint??fl,M=!!p&&w>=y,v=M&&!1!==b.preferShortText?t.map(Rn):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!f?b.responsive??{minWidth:w}:f,I=M&&!m?b.cohesion:m;if(0===v.length||0>=y||0>=x)return v.slice();const A=[],C=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let j=!1;const N=v.map((e,t)=>{if(!Tn(e))return e;const i=Vn(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...En("string"==typeof e.title?e.title:void 0,o,7),...En("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}(!0===e.defensive?Ln(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:ul,dy:dl}}(e);return A.push(qn(Wn(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(o)){const t=Bn(Wn(i.x,i.y,e.dx,e.dy,u),e,A,C,y,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=qn(Wn(i.x,i.y,h.dx,h.dy,u),r);A.push(p);const m=Math.hypot(h.dx,h.dy),g=c&&m>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),E=j?N:v.slice();let P=E;if(h){let e=!1;const t=E.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<hl?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});P=e?t:E}{let e=!1;const t=P.map(t=>{if(!0!==t?.defensive)return t;const n=Ln(t);return n!==t&&(e=!0),n});P=e?t:P}const F=new Set;if(k){const e="object"==typeof k?k:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return pl;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?pl:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Fn(y,x,e))*t))},{deferred:o}=On({annotations:P,width:y,height:x,...n});for(const e of o)F.add(e)}if(S&&("object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:fl)>=y)for(const e of P)Tn(e)&&"secondary"===e.emphasis&&F.add(e);if(F.size>0)for(const e of P)!0===e?.defensive&&F.delete(e);let z;return z=0===F.size?P:$?P.map(e=>F.has(e)?{...e,_annotationDeferred:!0}:e):P.filter(e=>!F.has(e)),I?function(e,t){let n=!1;const o=e.map(e=>Tn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(z,I):z}function Yn(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Hn(e,t={}){const n=t.fuels??gl,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=Yn(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:yl[e],mw:n,ba:t.ba})}return r}function _n(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=Yn(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Xn(e){const t=Yn(e.demand);if(0>=t)return 0;const n=Yn(e.capacityOrNetGen),o=Yn(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function Un(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=Yn(e.demandMw),n=Yn(e.netGenMw),o=Xn({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function Kn(e={},t={}){const{watch:n,comfortable:o}={...xl,...e},r=t.field,i=r?{field:r}:{},s=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:s,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function Qn(e={}){const{tight:t,watch:n,comfortable:o}={...xl,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function Zn(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=Yn(o.demandMw),i=Yn(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=Xn({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of gl){const t=Yn(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function Jn(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function eo(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function to(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function no(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function oo(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function ro(e,t={}){const n=oo(t.start,"start"),o=oo(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new wl;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function io(e,t){const n=oo(t.start,"start"),o=oo(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(r>i)return[];const c=(i-r)/s>Math.log2(e.length+1),l=[],u=[];if(c){for(const t of e){const e=n(t),r=o(t);e>r||(l.push(e),u.push(r))}l.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0;const f=[];for(let t=r;i>=t;t+=s){let r=0;if(c){for(;l.length>d&&t>=l[d];)d++;for(;u.length>h&&(a?t>=u[h]:t>u[h]);)h++;r=d-h}else for(const i of e){const e=n(i),s=o(i);e>t||(a?t>=s:t>s)||r++}f.push({value:t,count:r})}return f}function so(e){return"function"==typeof e?e:t=>t[e]}function ao(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function co(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function lo(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function uo(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function ho(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function fo(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function po(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function mo(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",s="x"===n?"width":"height",a="x"===n?"height":"width",c=new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[a]+d[a])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[s]+d[s])/2+o-Math.abs(h);if(0>=f)continue;const p=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-p),c.set(d.id,(c.get(d.id)??0)+p)}return c}function go(e,t){if("function"==typeof e)return e;const n=e??t;return e=>N(e,n,void 0)}function yo(e,t,n,o){const r=o.fixedAxis??"y",i=e=>go(o.sourceAccessor,"source")(e)+"",s=e=>go(o.targetAccessor,"target")(e)+"",a=o.size??(()=>vl),c=o.iterations??180,l=o.attraction??.012,u=o.anchorStrength??.003,d=o.collisionStrength??.12,h=o.collisionPadding??15,f=o.edgePadding??42,p=o.fixedPadding??16,m=o.damping??.72,g=o.spread??1,[y,x]=o.fixedDomain,b=x-y||1,w=("y"===r?n.y:n.x)+p,M=("y"===r?n.y+n.height:n.x+n.width)-p,v=("y"===r?n.x:n.y)+f,k=("y"===r?n.x+n.width:n.y+n.height)-f,$=Math.max(1,k-v),S=e.map(e=>{const t=E(e)??e,n=(r=e,go(o.idAccessor,"id")(r)+"");var r;const{width:i,height:s}=a(t),c=(e=>Number(go(o.fixedAccessor,"fixed")(e)))(e),l=v+function(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}(n)*$;return{data:t,id:n,width:i,height:s,fixedValue:c,fixed:(u=c,w+(u-y)/b*(M-w)),free:l,anchor:l};var u}),I=new Map(S.map(e=>[e.id,e])),A=e=>"y"===r?e.width:e.height;for(let e=0;c>e;e++){const e=new Map;for(const t of S)e.set(t.id,0);for(const n of t){const t=I.get(i(n)),o=I.get(s(n));if(!t||!o)continue;const r=(o.free-t.free)*l;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of S)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*u);const n=mo(S.map(e=>({id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===r?"x":"y",padding:h,strength:d});for(const t of S)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of S){t.free+=(e.get(t.id)??0)*m;const n=A(t)/2;t.free=Math.max(v+n,Math.min(k-n,t.free))}}if(1!==g){const e=(v+k)/2;for(const t of S){const n=A(t)/2;t.free=Math.max(v+n,Math.min(k-n,e+(t.free-e)*g))}}const C=S.map(e=>({data:e.data,id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:C,byId:new Map(C.map(e=>[e.id,e]))}}function xo(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?D((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?D(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=D(n/c,0,1);return u+(d-u)*r}}}function bo(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function wo(e){let t=0;for(const n of e)t+=Il[n]??.6;return t}function Mo(e,t){return Math.max(8,wo(e)*t*1.05+1)}function vo(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}function ko(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));return(0,$l.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[(0,$l.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);return(0,$l.jsxs)("g",{children:[(0,$l.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),(0,$l.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&(0,$l.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function $o(e){return null==e?void 0:e+""}function So(e){const t=$o(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??jl,style:{...Cl,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function Io(e){return So(e)}function Ao(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...Cl,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function Co(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Cl,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:$o(e.id)}}function jo(e){const t=$o(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Cl,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??jl,style:{...Cl,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function No(e){const t={style:{...Cl,cursor:e.cursor},datum:e.datum,id:$o(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?{type:e.type??"curved",pathD:e.pathD,...t}:{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function Eo(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,a.push(e)};let u=null;for(let n=0;e.length>n;n++){const a=t(e[n],n);if(s&&!a){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,a)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),a}function Po(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Fo(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function zo(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function Oo(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>zo(t(e),n,o))}function Lo(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=a>c?a:c,u=Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function Ro(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 To(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],s=e[r+1],a=[...new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=Ro(i,e),n=Ro(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function Wo(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>a;e++){const e=new Map(r.map((e,t)=>[e,t])),c=new Map,l=new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,s>u)s=u,i=[...r];else if(u===s)break}return i}function qo(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;s>e&&a>i;e++){let e=!1;for(let n=0;o.length-1>n&&a>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,r>s?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function Do(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,c>e&&(c=e,a=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>s;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function Bo(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,s]=t(e[r]);for(let a=r+1;e.length>a;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);0>(i-c)*(s-l)&&o++}}return o}function Vo(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,a=new Map;return e.forEach((e,t)=>{a.set(e.id,{id:e.id,x:i+s*t,y:o,index:t})}),a}function Go(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Yo(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,p=new Map;let m=i;return c||1!==e.length||(m=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];p.set(e.id,{id:e.id,x:m+n/2,y:o,index:t,width:n}),m+=n+a+f}),p}function Yo(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function Ho(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new wl,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function _o(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function Xo(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Uo(e,t,n){return e-n.arcLift-t*n.levelStep}function Ko(e,t=Qo){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Qo(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}function Zo(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Jo(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+El)%El}function er(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??El;return e=>i+(e-n)/r*(s-i)}function tr(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function nr(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=Zo(e,t,{center:i});return`${or(n)},${or(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=El-1e-6){const e=i?.x??0,t=i?.y??0,n=`${or(e)},${or(t-c)}`,o=`${or(e)},${or(t+c)}`;let r=`M${n} A${or(c)},${or(c)} 0 1 1 ${o} A${or(c)},${or(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${or(e)},${or(t-a)}`,o=`${or(e)},${or(t+a)}`;r+=` M${n} A${or(a)},${or(a)} 0 1 0 ${o} A${or(a)},${or(a)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=s(e,c),f=s(t,c);if(0>=a){const e=i?.x??0,t=i?.y??0;return`M${or(e)},${or(t)} L${h} A${or(c)},${or(c)} 0 ${d} ${u} ${f} Z`}const p=s(t,a),m=s(e,a);return`M${h} A${or(c)},${or(c)} 0 ${d} ${u} ${f} L${p} A${or(a)},${or(a)} 0 ${d} ${1===u?0:1} ${m} Z`}function or(e){return Math.round(1e3*e)/1e3}function rr(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ir(e,t){return{x:e.x-t.x,y:e.y-t.y}}function sr(e,t){return{x:e.x*t,y:e.y*t}}function ar(e){return Math.hypot(e.x,e.y)}function cr(e){const t=ar(e)||1;return{x:e.x/t,y:e.y/t}}function lr(e,t){const[n,o]=e.viewBox??Pl,[r,i]=e.anchor??Fl,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function ur(e,t){const n=lr(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function dr(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Pl,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function hr(e,t){const n=he(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function fr(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??Ol,strokeWidth:2,fill:"none"}):e=>({fill:e.color??Ol,stroke:e.color??Ol})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??Ol,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;return(0,zl.jsx)("path",{d:ue(t,hr(t,Ll-1)),transform:`translate(${Ll},${Ll})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??Ol,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>(0,zl.jsx)("circle",{cx:Ll,cy:Ll,r:e.r,fill:e.color??r})})}return t}function pr(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push((0,zl.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[mr(e,n,e.color??e.line??s,s),(0,zl.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},"legend-"+u)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),(0,zl.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function mr(e,t,n,o){if(e.shape){const o=hr(e.shape,t/2-1);return(0,zl.jsx)("path",{d:ue(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;return(0,zl.jsxs)("g",{children:[(0,zl.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>(0,zl.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),(0,zl.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return(0,zl.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}function gr(e){const t=e,n=[wr(t,["datum","data"]),wr(t,["datum"]),wr(t,["data","data"]),wr(t,["data"]),wr(t,["node","datum","data"]),wr(t,["node","datum"]),e];for(const e of n){if(!Mr(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function yr(e,t={}){const n=gr(e);if(!n)return[];const o=new Set(Rl);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:br(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):xr(i)}),r.length>=(t.maxEntries??8)))break;return r}function xr(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function br(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function wr(e,t){let n=e;for(const e of t){if(!Mr(n))return;n=n[e]}return n}function Mr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function vr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function kr(e,t){return vr(e,t)?e[t]:void 0}function $r(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Sr(){return Object.create(null)}function Ir(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function Ar(e,t){const n={};for(const t of e)$r(n,t.id,0);for(const e of t)$r(n,e.source,(kr(n,e.source)??0)+1),$r(n,e.target,(kr(n,e.target)??0)+1);return n}function Cr(e,t){const n={};$r(n,t,0);const o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])vr(n,r)||($r(n,r,n[t]+1),o.push(r))}return n}function jr(e,t,n,o){if(n===o)return n?[n]:[];const r=Ir(e,t),i=Sr();i[n]=null;const s=[n];let a=0;for(;s.length>a;){const e=s[a];if(a+=1,e===o)break;for(const t of r.get(e)||[])vr(i,t)||(i[t]=e,s.push(t))}if(!vr(i,o))return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function Nr(e,t,n,o=1){const r=Ir(e,t);if(!r.has(n))return new Set;const i=Cr(r,n),s=new Set;for(const e of Object.keys(i))i[e]>o||s.add(e);return s}function Er(e,t){const n=Ir(e,t),o={};for(const t of e)$r(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],i=Sr(),s=Sr(),a=Sr();for(const t of e)i[t.id]=[],s[t.id]=0,a[t.id]=-1;s[t]=1,a[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>a[t]&&(a[t]=a[e]+1,c.push(t)),a[t]===a[e]+1&&(s[t]+=s[e],i[t].push(e))}const u=Sr();for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=s[t]/s[e]*(1+u[e]);e!==t&&$r(o,e,(kr(o,e)??0)+u[e])}}for(const e of Object.keys(o))$r(o,e,o[e]/2);return o}function Pr(e,t){const n=Ir(e,t),o={};for(const t of e){const e=Cr(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;$r(o,t.id,r>0?(i-1)/r:0)}return o}function Fr(e,t){const n=Ir(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){$r(o,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);$r(o,t.id,2*i/(r*(r-1)))}return o}function zr(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))$r(n,o,t>0?e[o]/t:0);return n}function Or(e,t,n,o={}){const r=Ir(e,t),i=Sr();for(const t of e)i[t.id]=Cr(r,t.id);let s=o.minHops??4,a=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=kr(n,r),d=kr(n,c);if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=s&&a>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(a+=.02,a>c&&(a=o.startThreshold??.08,s=Math.max(2,s-1))),u+=1}return{problemIds:l,threshold:a,minHops:s}}function Lr(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function Rr(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function Tr(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}async function Wr(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260,l=Tr()&&function(e,t,n,o,r=Wl){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(o,e.length,t.length,c,i);if(!l)return Z(e,t,{...a,nodeRadius:s});const u={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const e=await function(e,t){return Tr()?Bl.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(u,r);return e.positions}catch(n){if("AbortError"===n?.name)throw n;return Z(e,t,{...a,nodeRadius:s})}}function qr(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function Dr(e,t){return!!t?.some(t=>Object.is(e,t))}function Br(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=qr(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!Dr(n,t.oneOf)||t.notOneOf&&Dr(n,t.notOneOf))}function Vr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Gr(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function Yr(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=Vr(e,n),r=Gr(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function Hr(e,t){return(t??Object.keys(e)).map(t=>Vr(e,t)).filter(Gr).map(e=>({label:e.label??e.id,value:e.count}))}function _r(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?Vr(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Xr(e,t,n){return Math.max(t,Math.min(n,e))}function Ur(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Kr(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Xr(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,m=Xr(d*h+p,.06*d,.5*d),g=m/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=Xr(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(k),I=a-s;let A=s;const C=k.map((e,t)=>{const n=A,o=t===k.length-1?a:A+(e.share??1)/S*I;return A=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),j=C[$],N=j.x0,E=j.x1,P=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Xr((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=Xr((e-s)/Math.max(1,N-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(E>=e)return"top"===n?y:x;const o=Xr((e-E)/Math.max(1,a-E),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},F=C.map(e=>{const t=Math.min(P(e.x0,"top"),P(e.x1,"top")),n=Math.max(P(e.x0,"bottom"),P(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:v,friction:w,restitution:M},O=[];"lane"===t?O.push(Ur(b+"-top",s,c,a,c,z),Ur(b+"-bottom",s,l,a,l,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)})):"funnel"===t?O.push(Ur(b+"-top",s,c,a,y,z),Ur(b+"-bottom",s,l,a,x,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,y,a,x,{...z,thickness:Math.max(6,v)})):O.push(Ur(b+"-left-top",s,c,N,y,z),Ur(b+"-left-bottom",s,l,N,x,z),Ur(b+"-center-top",N,y,E,y,z),Ur(b+"-center-bottom",N,x,E,x,z),Ur(b+"-right-top",E,y,a,c,z),Ur(b+"-right-bottom",E,x,a,l,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)}));const L=e.membraneDampingScale??.5,R=s,T=Math.max(1,("bowtie"===t?N:a)-R),W=(e.membranes??[]).map(e=>{const t=R+Xr(e.offset,0,1)*T,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:W.map(e=>Jr({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??L,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:E,pinchHeight:m,pinchTop:y,pinchBottom:x,stages:F,membranes:W,colliders:O,regionEffects:q,boundaryY:P}}function Qr(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function Zr(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Qr({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Jr(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Xr(e.cost,0,2);return{...Qr({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function ei(e){return{...Qr({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function ti(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function ni(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Qr({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function oi(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function ri(e){return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function ii(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Qr({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function si(e){return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function ai(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function ci(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Ur(t+"-top",e.left,e.top,e.right,e.top,n),Ur(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Ur(t+"-left",e.left,e.top,e.left,e.bottom,n),Ur(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}function li(e,t,n){return Math.max(t,Math.min(n,e))}function ui(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=li(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),u=li(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+a,h=e.boundaryY(u,"bottom")-a;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function di(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function hi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function fi(e,t,n,o,r){return"function"==typeof o?o(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}(e,o??r)}function pi(e){const t=Number(e.toFixed(Yl));return Object.is(t,-0)?0:t}function mi(e,t,n,o){const r=e.flatMap((e,r)=>{const i=hi(fi(e,r,t,n,"time")),s=hi(fi(e,r,t,o,"value"));return null==i||null==s?[]:[{time:pi(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function gi(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=function(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];return"step"!==n&&a&&a.time!==c.time?c.value+(t-c.time)/(a.time-c.time)*(a.value-c.value):c.value}function yi(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function xi(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=function(e){const t=(e??Vl).map(e=>{const t=hi(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return pi(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),r=function(e){if(Array.isArray(e)){if(e.length>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);return Array.from(new Set(e.map(hi).filter(e=>null!=e).map(pi))).sort((e,t)=>e-t)}const t=e,n=hi(t.start),o=hi(t.end),r=hi(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+a)break;s.push(pi(Math.min(t,o)))}if(s.length&&a>=Math.abs(s[s.length-1]-o)||s.push(pi(o)),s.length>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}(e.sampleAt),i=e.runs.map(t=>mi(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>gi(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?yi(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?yi(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function bi(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function wi(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=hi(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=pi(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function Mi(e,t,n){return t>e?"below":e>n?"above":"inside"}function vi(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;a.length-1>o;o+=1){const r=a[o],i=a[o+1];if(r>=i)continue;const s=(r+i)/2,d=(i-r)*n,h=Mi(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function ki(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=mi(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??bi(t,"lower"),a=n.upper??bi(t,"upper"),c=t.points.map(e=>{const t=gi(i,e.time,o,r),n=wi(e,s),c=wi(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Mi(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,p=0,m=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>p&&(p=n,m=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=vi(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:p,peakDeficitAt:m}}function $i(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Si(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Ii(e){return!!Si(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Si(e.visitsByStage)&&Si(e.firstEnteredAt)&&Si(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function Ai(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function Ci(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,Ai(e)]))}}function ji(e,t,n={}){if("region-enter"!==t.type)return e;const o=function(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=$i(e.entities,i),a=Ii(s)?s:Ai(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=$i(a.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,p={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:f+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:d}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:d},regressionCount:c>=0&&c>r?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:p}}}function Ni(e){const t=e.bodyIds.map(t=>{const n=$i(e.entities,t);return Ii(n)?n:Ai(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=$i(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function Ei(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function Pi(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=qr(e.datum,t),o=qr(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Fi(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function zi(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(l)}function n(){G+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:l,work:e.total,queuedAt:e.queuedAt}}function r(t,r,i,s){const a={bodyId:t.id,jobId:r.jobId,visitId:r.visitId,visit:r.visit,remaining:r.work,total:r.work,queuedAt:r.queuedAt,sequence:s};return x.set(r.jobId,a),$.delete(t.id),k.set(t.id,r.jobId),z+=1,O+=r.work,n(),function(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:l,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:x.size})}(t,a,i),a}function i(e){if(x.size>=p||0===b.size)return;const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(x.size>=p)break;const t=v.get(n.jobId);t&&w.has(n.jobId)?(b.delete(n.jobId),$.delete(n.bodyId),r(t,n,e,n.sequence)):b.delete(n.jobId)}}function s(){let e=0;for(const t of x.values())e+=t.remaining;return e}function a(){D=Math.max(D,x.size),B=Math.max(B,s())}function c(){const e=E-m,t=Math.max(0,Math.min(m,E-(P??E)));let n=0,o=0,r=0,i=0,s=0;for(const t of S){if(e>t.end)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;s+=a>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/a):t.processedWork}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&u>0?Math.max(0,Math.min(1,s/(u*t))):0,pressure:u>0?a/u:0}}const l=e.regionId,u=Math.max(0,e.unitsPerSecond),d=e.queueLayout??"lane",h=e.queueSlotSpacing??14,f=e.queueStiffness??.35,p=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,m=Math.max(.25,e.metricWindowSeconds??30),g=Math.max(1/60,e.snapshotIntervalSeconds??.25),y=e.releaseImpulse??{x:90,y:0},x=new Map,b=new Map,w=new Map,M=new Map,v=new Map,k=new Map,$=new Map,S=[];let I=0,A=new Map,C=new Map,j=0,N=0,E=0,P=null,F=0,z=0,O=0,L=0,R=0,T=0,W=0,q=0,D=0,B=0,V=0,G=0,Y=-1,H=!1;return{id:e.id??"capacity-queue:"+l,continuous:!1!==e.continuous,tick:s=>{const c=s.controls.readBodies(),d=new Map,h=new Map;for(const n of c){if(d.set(n.id,n),!t(n.id,s.getRegionState))continue;if(!Br(n,e.bodyFilter))continue;const o=Pi(n,e.jobKey),r=h.get(o)??[];r.push(n),h.set(o,r)}const f=Number.isFinite(s.dt)?Math.max(0,s.dt):0;if(!H){const e=Number.isFinite(s.elapsed)?Math.max(0,s.elapsed):f;E=Math.max(0,e-f),H=!0}const z=E,O=z+f;E=O,P=null==P?z:Math.min(P,z);const D={start:z,end:O,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},B=new Map;for(const[e,t]of h){const n=w.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];B.set(e,o),v.set(e,o)}for(const[t,r]of w){if(B.has(t))continue;const i=x.get(t),a=d.get(r.bodyId)??v.get(t);if(i){x.delete(t),k.delete(i.bodyId),W+=1,q+=i.remaining,n();const c={...o(i),abandonedAt:E,remainingWork:i.remaining,queueSeconds:Math.max(0,E-i.queuedAt)};a&&e.onAbandoned?.(a,c),s.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:l,work:i.total,remainingWork:i.remaining,jobId:t,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,abandonedAt:E,queueSeconds:c.queueSeconds,queueDepth:x.size})}b.delete(t),$.delete(r.bodyId),w.delete(t),v.delete(t)}for(const[t,o]of B){if(w.has(t))continue;const i=(M.get(t)??0)+1;M.set(t,i);const a=Ei(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${l}:${t}:${i}`,visit:i,regionId:l,work:a,queuedAt:E};w.set(t,c),F+=1,D.arrivals+=1,D.arrivalWork+=a;const u=I++;if(p>x.size)r(o,c,s,u);else{const r={...c,blockedAt:E,sequence:u};b.set(t,r),$.set(o.id,t),T+=1,n(),e.onBlocked?.(o,r),s.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:l,work:a,jobId:t,visitId:c.visitId,visit:i,queuedAt:E,blockedAt:E,queueDepth:x.size,blockedDepth:b.size})}}i(s),a();const G=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);let _=u*f;for(const t of G){if(0>=_)break;const r=Math.min(t.remaining,_);if(t.remaining-=r,_-=r,L+=r,D.processedWork+=r,t.remaining>1e-6)continue;x.delete(t.jobId),k.delete(t.bodyId),N+=1,R+=t.total,D.completions+=1,D.completedWork+=t.total;const i=Math.max(0,E-t.queuedAt);V+=i,n();const a=d.get(t.bodyId);if(!a)continue;s.controls.applyImpulse(t.bodyId,y.x??0,y.y??0);const c={...o(t),completedAt:E,queueSeconds:i};e.onProcessed?.(a,c),s.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:l,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:E,queueSeconds:i,queueDepth:x.size})}i(s),a(),function(){const e=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);A=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);C=new Map(t.map((e,t)=>[e.bodyId,t])),j=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&S.push(e);const t=E-m;for(;S.length>0&&t>S[0].end;)S.shift()}(D);const X=Math.floor(E/g);X!==Y&&(Y=X,n())},getSnapshot:()=>{const e=s(),t=function(){let e=0;for(const t of b.values())e+=t.work;return e}(),n=x.size,o=Array.from(x.values()).map(e=>Math.max(0,E-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:l,queueDepth:n,processedCount:N,unitsPerSecond:u,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:b.size,blockedWork:t,arrivalCount:F,admittedCount:z,admittedWork:O,processedWork:L,completedWork:R,blockedCount:T,abandonedCount:W,abandonedWork:q,peakQueueDepth:D,peakRemainingWork:B,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:Fi(o,.5),p95Seconds:Fi(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:N>0?V/N:0,window:c(),simulatedAt:E,metricRevision:G}},bodyForce:e=>{if("none"===d)return null;const t=k.get(e.body.id),n=$.get(e.body.id),o=t?x.get(t):void 0,r=n?b.get(n):void 0;if(!o&&!r)return null;const i=o?A.get(e.body.id):C.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;a.length>e;e+=1)if(a[e].id===l){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}return s?{x:((r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*h))-e.body.x)*f,y:(s.y-(i-((r?b.size:j)-1)/2)*h/Math.max(1,Math.sqrt(r?b.size:j))-e.body.y)*f*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Oi(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Li(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=Oi(n,o.bodyForce(e)));return n}}}function Ri(e){const t=new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function Ti(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=new Map,r=new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,s),r.set(i.id,s),d+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=n?i:s;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*a,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*a}}const u=o.get(e.body.id);if(!u||0>=a)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*a,y:(d.y-e.body.y)*a}:null}}}function Wi(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):qr(e.datum,t.deadlineAccessor)??qr(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function qi(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!Br(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=Wi(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"!==a.state||a.deadlineAt>r||t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function Di(e){const t=new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&Br(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=u.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function Bi(e,t,n){return Math.max(t,Math.min(n,e))}function Vi(e){return e.length*Xl}function Gi(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function Yi(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Xl)),r="compact"===n?Gi(e,o):"full"===n?e:Vi(e)>t?Gi(e,o):e;return{text:r,textLength:Vi(r)>t?Math.max(4,t):void 0}}function Hi(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:p,midY:m,stages:g,groups:y=[]}=e,x=p-f;return(0,Hl.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,Hl.jsx)("defs",{children:(0,Hl.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Hl.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,Hl.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,Hl.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,Hl.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?(0,Hl.jsx)("line",{x1:d+8,x2:h-8,y1:m,y2:m,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=_l[n],c=Math.max(12,e.width-8),l=Bi(c-8,22,88),d=Yi(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,y=function(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),b=Yi(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=Yi(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return(0,Hl.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,Hl.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),g.length-1>t?(0,Hl.jsx)("polygon",{points:`${e.x1-2},${m-7} ${e.x1+8},${m} ${e.x1-2},${m+7}`,fill:i.accent,opacity:.85}):null,h?(0,Hl.jsxs)(Hl.Fragment,{children:[(0,Hl.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),(0,Hl.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:e.label}),d.text]})]}):null,w?(0,Hl.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?(0,Hl.jsxs)("text",{x:e.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=Bi(Math.max(54,Vi(e.label)+18,Vi(c)+16),54,104),u=Yi(e.label,l-12,"auto"),d=Yi(c,l-12,"auto");return(0,Hl.jsxs)("g",{"data-group":e.id,children:[(0,Hl.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),(0,Hl.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:e.label}),u.text]}),(0,Hl.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function _i(e){const[t,n]=e.size,o=e.flow??Ul.flow,r=function(e){if(null==e){const e=Ul.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??Ul.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??Ul.chargeExtent),l=a*Math.max(0,e.projectionExtent??Ul.projectionExtent),u=a*Math.max(0,e.destinationExtent??Ul.destinationExtent),d=Math.max(0,a-c-u-l),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),f=("down"===o?s.width:s.height)/h.length,p="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),m=p(0,c),g=p(c,d),y=c+d,x=p(y,u),b=p(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,a=(f-r)/2;return"down"===o?{id:e.id,label:e.label,order:t,x:s.x+n+a,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*f,centerY:x.y+x.height/2}:{id:e.id,label:e.label,order:t,x:x.x,y:s.y+n+a,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:m,apparatus:g,destinations:w,projection:b}}function Xi(e,t){return e.destinations.find(e=>e.id===t)}function Ui(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function Ki(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:o+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:o+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:o+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:o+"-wall-right",shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function Qi(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Zi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ji(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function es(e,t,n){return Zi(e[t])??n}function ts(e,t){return"number"==typeof e?e:e?.[t]??0}function ns(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!s&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return u}function os(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...function(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...function(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],m=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(o+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:m,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}({...s,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...ns({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),s&&a.push(...ns({band:s,idPrefix:s.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function rs(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(a-s)/(d-1):0,p=t.width/h,m=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?p/2:0;for(let o=0;h>o;o+=1){const a=t.x+p*(o+.5)+n;t.x+r>a||a>t.x+t.width-r||m.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return m}function is(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=Q(l),f=ts(u,"x"),p=ts(u,"y");return e.map((e,l)=>{const u=Ji(t.x,e,l,es(e,"x",0)),m=Ji(t.y,e,l,es(e,"y",0)),g=Ji(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:m+(h()-.5)*p,vx:Ji(s,e,l,0),vy:Ji(a,e,l,0),mass:Ji(i,e,l,1),spawnAt:Ji(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function ss(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function as(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return Zi("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function cs(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function ls(e,t,n="group"){const o=Ar(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function us(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{cs(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function ds(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function hs(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;cs(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function fs(e,t,n={}){const o=(n.order??ls(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function ps(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ms(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function gs(e,t){const n=ps(e.note)?e.note:void 0;return t?ms(e.mobileText)||ms(e.shortText)||ms(e.label)||ms(n?.mobileText)||ms(n?.shortText)||ms(n?.label)||ms(n?.title):ms(e.label)||ms(e.mobileText)||ms(e.shortText)||ms(n?.label)||ms(n?.title)}function ys(e,t,n){const o=function(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=ps(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=ps(e.lifecycle)?e.lifecycle:void 0,c=((a?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function xs(e,t){if(!t)return e;const n=gs(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function bs(e,t={}){const n=Array.isArray(e)?e.filter(ps):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,s=!1!==t.preservePrimary,a=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>xs(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:ys(e,n,t)})).filter(e=>!!Nn(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=s?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),p=[...d,...f].slice(0,Math.max(a,c)),m=new Set(p.map(e=>e.index)),g=u.filter(e=>!m.has(e.index)),y=[...l,...p.sort((e,t)=>e.index-t.index).map(e=>xs(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>function(e,t,n,o){const r=gs(e,o);if(!r)return null;const i=ms(e.id)||ms(e.key)||ms(e.pointId)||"annotation-"+(t+1),s=ps(e.provenance)?ms(e.provenance.source)||ms(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:ms(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:a,visible:y,deferred:x,calloutList:w,hidden:v}}function ws(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function Ms(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function vs(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:Ms(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=function(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}(e,t),l=function(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}(t);return{family:e,props:s,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function ks(e={}){const t=ws(e);return vs("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function $s(e={}){const t=ws(e);return vs("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Ss(e={}){return vs("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Is(e={}){const t=ws(e);return vs("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function As(e={}){const t=ws(e);return vs("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function Cs(e={}){return vs("geo",e,{showLegend:e.showLegend??!1})}function js(e={}){return vs("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Ns(e,t={}){switch(e){case"line":return ks(t);case"area":return $s(t);case"ordinal":return Ss(t);case"scatter":return Is(t);case"network":return As(t);case"geo":return Cs(t);case"small-multiple":return js(t)}}function Es(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var Ps,Fs,zs,Os,Ls=Object.create,Rs=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,Ws=Object.getOwnPropertyNames,qs=Object.getPrototypeOf,Ds=Object.prototype.hasOwnProperty,Bs=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Ws(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Vs=(e,t)=>{for(var n in t)Rs(e,n,{get:t[n],enumerable:!0})},Gs=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Ws(t))Ds.call(e,r)||r===n||Rs(e,r,{get:()=>t[r],enumerable:!(o=Ts(t,r))||o.enumerable});return e},Ys=(e,t,n)=>(n=null!=e?Ls(qs(e)):{},Gs(!t&&e&&e.__esModule?n:Rs(n,"default",{value:e,enumerable:!0}),e)),Hs=Bs({"src/components/recipes/atlas/entityCounts.ts"(){}}),_s=Bs({"src/components/recipes/atlas/ids.ts"(){}}),Xs=Bs({"src/components/recipes/atlas/ledger.ts"(){_s()}}),Us=Bs({"src/components/recipes/atlas/compare.ts"(){Hs(),Xs()}}),Ks=Bs({"src/components/recipes/atlas/completeness.ts"(){_s()}}),Qs=Bs({"src/components/recipes/atlas/directedGraph.ts"(){}}),Zs=Bs({"src/components/recipes/atlas/rootedForest.ts"(){Qs()}}),Js=Bs({"src/components/recipes/atlas/forests.ts"(){_s(),Zs()}}),ea=Bs({"src/components/recipes/atlas/types.ts"(){Ps="0.2",Fs=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],zs=["serial-chain","fan-out","fan-in"],Os=[...zs,"repeated-state-episode"]}}),ta=Bs({"src/components/recipes/atlas/motifs.ts"(){_s(),ea()}}),na=Bs({"src/components/recipes/atlas/prefixForest.ts"(){_s()}}),oa=Bs({"src/components/recipes/atlas/sections.ts"(){_s()}}),ra=Bs({"src/components/recipes/atlas/support.ts"(){}}),ia=Bs({"src/components/recipes/atlas/requiredPaths.ts"(){Qs()}}),sa=Bs({"src/components/recipes/atlas/validate.ts"(){_s(),ea()}}),aa={};Vs(aa,{prepareNetworkAtlas:()=>v});var ca=Bs({"src/components/recipes/atlas/prepare.ts"(){Us(),Ks(),Js(),Xs(),ta(),na(),oa(),ra(),ia(),sa()}}),la=Bs({"src/components/recipes/atlas/capsules.ts"(){}}),ua=Bs({"src/components/recipes/atlas/profile.ts"(){Hs(),Us()}}),da={};Vs(da,{assignedDenominator:()=>a,prepareMotifBraid:()=>A,ribbonSupportsRoute:()=>C});var ha,fa=Bs({"src/components/recipes/atlas/braid.ts"(){la(),Us(),ra(),_s(),ua()}}),pa={};Vs(pa,{DEFAULT_AREA_PER_ANNOTATION:()=>ol,DEFAULT_GLYPH_ANCHOR:()=>Fl,DEFAULT_GLYPH_VIEWBOX:()=>Pl,DEFAULT_HIT_RADIUS:()=>jl,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>Ua,GRID_FUEL_KEYS:()=>gl,GRID_FUEL_LABELS:()=>yl,LayoutCache:()=>ya,SYMBOL_SEQUENCE:()=>Ia,TAU:()=>El,absorbRegion:()=>ii,activeCountOverDomain:()=>io,addPoints:()=>rr,adjacencyFlowLayout:()=>qc,adjacencyMatrix:()=>fs,aggregateAdjacencyFlow:()=>fn,aggregateRegionCounts:()=>Yr,allocateCells:()=>Y,analyzeNetEnsemble:()=>Gt,angleScale:()=>er,annotationBudget:()=>Fn,annotationDensity:()=>On,annotationLayout:()=>Gn,arcLayout:()=>us,arcPath:()=>ds,arrivalReplay:()=>as,axisFixedForceLayout:()=>kl,axisFixedForcePositions:()=>yo,balanceSnapshotsToFlows:()=>_,bandLabel:()=>qt,betweenness:()=>Er,bfsDistances:()=>Cr,bobaLayout:()=>tl,bodyGroupSpec:()=>ai,boundsOf:()=>Tt,boxEdgeAnchors:()=>lo,buildAdjacency:()=>Ir,buildTooltipEntries:()=>yr,bulletLayout:()=>Xc,calendarLayout:()=>Ya,capacitatedRegion:()=>oi,chargeGateRegion:()=>ei,circularLayout:()=>hs,clamp:()=>D,closeness:()=>Pr,clustering:()=>Fr,collidersFromScales:()=>os,comparePhysicsTrace:()=>ki,composePhysicsControllers:()=>Li,computeTransitDiagramPositions:()=>dt,countPairwiseCrossings:()=>Bo,createCapacityQueueController:()=>zi,createDependencyGateController:()=>Di,createPortalController:()=>Ri,createProcessJourneyLedger:()=>Ci,createServiceLevelController:()=>qi,createServiceResourcePoolController:()=>Ti,cubicPath:()=>po,cubicPoint:()=>ho,cubicTangent:()=>fo,curvedEdgePath:()=>ao,cyclicRangeContains:()=>zo,dagreLayout:()=>yc,degree:()=>Ar,demandForecastRows:()=>_n,describePhysicsStageGeography:()=>Qi,diagnoseTokenEncoding:()=>se,dimFor:()=>O,egoNetwork:()=>Nr,estimateLabelWidth:()=>Yo,extractTooltipDatum:()=>gr,fanOutBend:()=>uo,flextreeLayout:()=>gc,forceFieldRegion:()=>si,forceLayout:()=>Z,forceLayoutAsync:()=>Wr,formatMw:()=>to,formatReservePct:()=>no,formatTooltipValue:()=>xr,galtonPegs:()=>rs,generateTokens:()=>re,geoAreaHitTarget:()=>Ao,geoHitTarget:()=>Io,geographicDotGridLayout:()=>mc,geographicGridLayout:()=>ac,glyphExtent:()=>ur,glyphFractionClipRect:()=>dr,glyphPlacement:()=>lr,gridEventAnnotations:()=>Jn,gridifyGeographicPoints:()=>We,groupBy:()=>P,groupCompletionRows:()=>_r,hatchFill:()=>Dt,hitTargetPoint:()=>So,hitTargetRect:()=>Co,hullFromBoxes:()=>Wt,intervalLanesLayout:()=>Ml,isometricLandmarkLayout:()=>tc,isotypeBoltGlyph:()=>Fa,isotypeBusGlyph:()=>za,isotypeChipGlyph:()=>Pa,isotypeGhost:()=>Na,isotypeInk:()=>Ca,isotypeNetworkGlyphs:()=>Ra,isotypePaper:()=>ja,isotypePersonGlyph:()=>La,isotypePersonPath:()=>Oa,isotypeServerGlyph:()=>Ea,layoutChipStrip:()=>Go,layoutSequence:()=>Vo,layoutTokenGrid:()=>ie,legendGroupsFrom:()=>fr,legendSwatches:()=>pr,lineageDagLayout:()=>Sc,linearAxis:()=>Bt,makeShade:()=>R,marimekkoLayout:()=>Hc,markCallout:()=>Vt,matchesHighlight:()=>z,mean:()=>V,membraneRegion:()=>Jr,mermaidDagLayout:()=>zc,mobileAnnotationStrategy:()=>bs,mobileAreaChartRecipe:()=>$s,mobileBrushAlternatives:()=>Es,mobileChartFamilyRecipe:()=>Ns,mobileGeoChartRecipe:()=>Cs,mobileLineChartRecipe:()=>ks,mobileNetworkChartRecipe:()=>As,mobileOrdinalChartRecipe:()=>Ss,mobileScatterplotRecipe:()=>Is,mobileSmallMultipleRecipe:()=>js,motifBraidLayout:()=>Ec,mulberry32:()=>Q,netEnsembleLayout:()=>Tc,networkEdgeHitTarget:()=>No,networkHitTarget:()=>jo,nonNegativeFinite:()=>B,normalizePoint:()=>cr,normalizeScores:()=>zr,normalizeTokenEncoding:()=>te,octilinearRoute:()=>ht,offsetTransitPath:()=>ft,orderByBarycenter:()=>Wo,orderByGroupDegree:()=>ls,orderExactSmall:()=>Do,orthogonalEdgePath:()=>co,packBandsBySilhouette:()=>To,packIntervals:()=>ro,packSpanLevels:()=>Ho,packedClusterMatrix:()=>Vc,parallelCoordinatesLayout:()=>Qc,partitionSharedEdges:()=>Ko,physicsChargePoint:()=>Ui,physicsDestination:()=>Xi,physicsReferenceEnvelope:()=>xi,physicsStageColliders:()=>Ki,physicsStageGeography:()=>_i,placeWithMinGap:()=>Lo,pointMagnitude:()=>ar,polarToXY:()=>Zo,portalRegion:()=>ri,prepareMotifBraid:()=>Nt,prepareNetworkAtlasAsync:()=>jt,pressureFieldRegion:()=>ni,processChrome:()=>Hi,processJourneyRows:()=>Ni,processLaneWalls:()=>ci,processStageLayout:()=>Kr,processStageRegions:()=>Zr,processVolumePolygons:()=>di,proximityProblem:()=>Or,radiusScale:()=>tr,readField:()=>N,rectCollide:()=>mo,refineByAdjacentSwaps:()=>qo,regionCountsToProjectionRows:()=>Hr,reserveAnnotationBands:()=>Qn,reserveMarginPct:()=>Xn,reserveSeries:()=>Un,ringArcPath:()=>nr,roundedEnclosure:()=>Rt,roundedTransitPath:()=>pt,routeSurfaceRegion:()=>ti,runLengthEncode:()=>Nl,runs:()=>Eo,sampleGeographicDotGrid:()=>Je,scaleArcBand:()=>_o,scalePoint:()=>sr,sedimentBake:()=>ss,selectCyclicRange:()=>Oo,selectIsometricLandmarks:()=>Ee,shade:()=>T,shortestArcDelta:()=>Fo,shortestPath:()=>jr,signatureKey:()=>L,spanArcPath:()=>Xo,spanArcPeakY:()=>Uo,spawnFromTokens:()=>is,stackFuelSeries:()=>Hn,stageTargetInVolume:()=>ui,subtractPoints:()=>ir,suggestTokenEncoding:()=>le,summarizeOperatingPoint:()=>Zn,symbolExtent:()=>he,symbolPathString:()=>ue,symbolRadius:()=>de,thresholdBandsForReserve:()=>Kn,tightestHours:()=>eo,tokenLayer:()=>we,tokenTaskIntentToCapabilityIntents:()=>ce,transitDiagramLayout:()=>wc,unitize:()=>U,unitizeRange:()=>K,unwrapDatum:()=>E,updateProcessJourney:()=>ji,waffleLayout:()=>xa,withAlpha:()=>G,wordTrailsLayout:()=>Al,wordTrailsProgressiveReveal:()=>xo,wrapValue:()=>Po,xyToAngle:()=>Jo}),module.exports=(ha=pa,Gs(Rs({},"__esModule",{value:!0}),ha));var ma,ga=require("d3-interpolate"),ya=class{constructor(e=12){this.maxSize=e,this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},xa=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,i=n*o;if(0>=n||0>=o||0>=i)return{nodes:[]};const{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const a=(s.width-r*(o-1))/o,c=(s.height-r*(n-1))/n;if(0>=a||0>=c)return{nodes:[]};const l=(null==(u=t.categoryAccessor)?null:"function"==typeof u?u:e=>e[u])??(()=>"_default");var u;const d=function(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}(t.valueAccessor)??(()=>1),h=new Map,f=[];for(const t of e.data){const e=l(t)+"",n=Number(d(t)),o=Number.isFinite(n)?Math.max(0,n):0;h.has(e)||f.push(e),h.set(e,(h.get(e)??0)+o)}const p=Array.from(h.values()).reduce((e,t)=>e+t,0);if(0>=p)return{nodes:[]};let m;if(t.categoryOrder&&t.categoryOrder.length>0){const e=new Set,n=[];for(const o of t.categoryOrder)h.has(o)&&!e.has(o)&&(e.add(o),n.push(o));m=[...n,...f.filter(t=>!e.has(t))]}else m=f;if(0===m.length)return{nodes:[]};const g=m.map(e=>({cat:e,exact:(h.get(e)??0)/p*i})).map(e=>({...e,count:Math.floor(e.exact)})),y=g.reduce((e,t)=>e+t.count,0),x=g.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;i-y>e;e++)g[x[e%x.length].i].count+=1;const b="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",w="string"==typeof t.valueAccessor?t.valueAccessor:"value",M=(e,t,n)=>F(o=>{o("category",e),o("value",h.get(e)??0),o("share",(h.get(e)??0)/p),"category"!==b&&o(b,e),"value"!==w&&o(w,h.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),v=[];let k=0;for(const t of g){const i=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)v.push({type:"rect",x:s.x+k%o*(a+r),y:s.y+(n-1-Math.floor(k/o))*(c+r),w:a,h:c,style:{fill:i,stroke:"none"},datum:M(t.cat,k,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),k++}return{nodes:v}},ba=1e-6,wa=require("d3-force"),Ma=1e3,va=80,ka=100,$a=require("d3-shape"),Sa={circle:$a.symbolCircle,square:$a.symbolSquare,triangle:$a.symbolTriangle,diamond:$a.symbolDiamond,star:$a.symbolStar,cross:$a.symbolCross,wye:$a.symbolWye},Ia=["circle","triangle","diamond","star","square","chevron","cross","wye"],Aa=new Map,Ca="#334155",ja="#f8fafc",Na="#cbd5e1",Ea={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Pa={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Fa={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},za={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},Oa="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",La={viewBox:[18,40],anchor:[.5,1],parts:[{d:Oa,fill:"color",stroke:"color",strokeWidth:1.4}]},Ra={server:Ea,chip:Pa,bolt:Fa,bus:za,person:La},Ta="var(--semiotic-primary, #4e79a7)",Wa="var(--semiotic-border, #d1d5db)",qa="var(--semiotic-secondary, #9ca3af)",Da="var(--semiotic-bg, #ffffff)",Ba=new Set(Ia),Va=require("d3-interpolate"),Ga=864e5,Ya=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=new Map;let s=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const n=Me(e),a=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Va.interpolateRgb)(u,d)(t)},f=t.gutter??2,p=t.labelInset??0,m=Math.min((n.width-p-53*f)/54,(n.height-6*f)/7);if(0>=m)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*Ga),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*Ga);if(o.getUTCFullYear()!==a)continue;const r=Me(o),s=i.get(r),c=null==s?u:h(s);b.push({type:"rect",x:n.x+p+e*(m+f),y:n.y+t*(m+f),w:m,h:m,style:{fill:c,stroke:"none"},datum:{date:o,value:s??0}})}return{nodes:b}},Ha=Ys(require("react")),_a=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),Xa=require("react/jsx-runtime"),Ua={resource:32,city:64},Ka=["#739b58","#83a964","#668d52","#8baa68"],Qa={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Za={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},Ja=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),ec=new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),tc=e=>{const t=je(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:Ka,i=e.dimensions.width/2,s=(e.dimensions.height-t*o)/2+o/2,a=Ee(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:s+(e.column+e.row)*(o/2)}));return{nodes:a.map(t=>{const i=function(e,t){const n=$e(e,t),o=function(e){return ec.has(e)?e:void 0}("string"==typeof n?n:$e(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=$e(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=Se(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??Se(e.config.terrainPalette,s)??Se(Qa,s)??Qa.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,Se(Za,l)??Za.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:(0,Xa.jsx)(Pe,{tiles:a,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??Ua.resource,citySize:e.config.citySpriteSize??Ua.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},nc={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},oc={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},rc=require("react/jsx-runtime"),ic=.72,sc=1.8,ac=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=o?function(e){return e.areas.map((t,n)=>{const o=function(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??"area-"+t;return{...n,id:o+""}}(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),i=r.filter((e,n)=>!t.filter||t.filter(e.datum,n)),s=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(qe(e,t.columnAccessor)),y:Number(qe(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}(i.map(e=>e.datum),t),a=o?i:function(e){return e.points.map(t=>{const n=Number(qe(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(qe(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:i.map(e=>e.datum)}),c=s??We(a,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===c.length)return{nodes:[]};const l=Re(c.map(e=>e.row)),u=Re(c.map(e=>e.column)),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(1,Math.round(u[1]-u[0])+1),f=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*f)/h,m=Math.max(1,e.dimensions.height-2*f)/d,g=(e.dimensions.width-p*h)/2,y=(e.dimensions.height-m*d)/2,x=Le(t.cellPadding??.12,0,.8),b=Math.max(1,.5*Math.min(p,m)*(1-x)),w=t.sizeAccessor?c.map(e=>Number(qe(e.datum,t.sizeAccessor))):[],M=t.sizeDomain??Re(w),v=t.sizeRange??[.36,1],k=Le(Math.min(v[0],v[1]),.05,1),$=Le(Math.max(v[0],v[1]),k,1),S=c.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=(qe(r,t.idAccessor,["id","key","name"])??"grid-"+o)+"",s=(qe(r,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",a=Math.max(1,t.maxLabelLength??4),c=s.length>a?s.slice(0,a):s,d=qe(r,t.categoryAccessor),h=null==d?void 0:d+"",f=qe(r,t.fillAccessor),x=null!=f?f+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",w=t.sizeAccessor?Number(qe(r,t.sizeAccessor)):NaN,v=t.sizeAccessor&&Number.isFinite(w)?Math.sqrt(Le(Te(w,M),0,1)):1,S=b*(k+v*($-k)),I="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:c,category:h,row:n.row,column:n.column,x:g+(n.column-u[0]+.5)*p,y:y+(n.row-l[0]+.5)*m,radius:S,style:{fill:x,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...I}}}),I=t.shape??"circle";return{nodes:S.map(e=>{return"circle"===I?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===I?function(e,t,n){const o=[];for(let r=0;6>r;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return De(o)}(e.x,e.y,e.radius):De([[(t=e.x)-(o=e.radius),(n=e.y)-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===I?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:(0,rc.jsx)(Be,{marks:S,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??Le(.23*Math.min(p,m),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},cc=require("react/jsx-runtime"),lc=10,uc=25e3,dc=new WeakMap,hc=new WeakMap,fc=new WeakMap,pc=1,mc=e=>{const t=function(e){let t=dc.get(e.areas);t||(t=new Map,dc.set(e.areas,t));const n=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Ke(t.featureFilter),Ke(t.dotFilter),rt(e)].join("::")}(e),o=t.get(n);if(o)return o;const r=Je(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,Ye(n.dotRadius)??t.cellSize*Ge(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,u=s+(a.gridRow+.5)*t.cellSize,d=He(a,n.categoryAccessor),h=He(a,n.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},p=`dot-${a.gridRow}-${a.gridColumn}`;if("circle"===o)return{type:"point",x:l,y:u,r:r,style:f,datum:a,interactive:!1,pointId:p,_transitionKey:p};const m="hexagon"===o?function(e,t,n){return it(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}(l,u,r):function(e,t,n){return it([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}(l,u,r);return{type:"geoarea",pathData:m,centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?(0,cc.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?(0,cc.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},Xe(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},gc=e=>{const t=e.config,n=t.nodeWidth??80,o=t.nodeHeight??30,r=t.orientation??"vertical",i=t.edgeCurve??"curved",s=!1!==t.showLabels,a=t.labelAccessor??"id",c="function"==typeof a?a:e=>N(e,a,e.id??"")+"",l=new Map,u=[],d=[],h=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:i,h:a}=h(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:a}),u.push({type:"rect",x:o-i/2,y:r-a/2,w:i,h:a,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),s&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=l.get("string"==typeof t.source?t.source:t.source.id),s=l.get(n);if(!o||!s)continue;const a="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:s.x,y:s.y-s.h/2}:{x:s.x-s.w/2,y:s.y};if("line"===i)f.push({type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(a.y+c.y)/2,o=(a.x+c.x)/2;f.push({type:"curved",pathD:"vertical"===r?`M${a.x},${a.y} C${a.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${a.x},${a.y} C${o},${a.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:f,labels:d}},yc=e=>{const t=e.config,n=t.nodeWidth??100,o=t.nodeHeight??36,r=t.edgeStyle??"polyline",i=!1!==t.showLabels,s=t.labelAccessor??"label",a="function"==typeof s?s:e=>N(e,s,e.id??"")+"",c=new Map,l=[],u=[],d=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:s,h:h}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:s,h:h}),l.push({type:"rect",x:o-s/2,y:r-h/2,w:s,h:h,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:a(n)+""}),i&&u.push({x:o,y:r,text:a(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const h=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,f=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),o=c.get(e);if(!n||!o)continue;const i=t.data??{},s=Array.isArray(i.points)?i.points:t.points;if(s&&s.length>=2)if("smooth"!==r||3>s.length){const e="M"+s.map(e=>`${e.x},${e.y}`).join(" L ");f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${s[0].x},${s[0].y}`;for(let t=1;s.length-1>t;t++)e+=` Q${s[t].x},${s[t].y} ${(s[t].x+s[t+1].x)/2},${(s[t].y+s[t+1].y)/2}`;const n=s[s.length-1];e+=` T${n.x},${n.y}`,f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else f.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:h,strokeWidth:1},datum:t})}return{sceneNodes:l,sceneEdges:f,labels:u}},xc=require("react"),bc=e=>"number"==typeof e&&Number.isFinite(e),wc=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:E(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),s=e.edges.map(e=>({source:gt(e.source),target:gt(e.target),data:E(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=dt(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?function(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=new Map,l=new Map(e.map(e=>[e.id,new Map]));for(const e of a){const t={id:e.id,label:mt(e,n)+"",color:xt(e,n,o)},r=new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(l.get(e.id)?.values()??[])]))}}(i,s,t,e.resolveColor):void 0,l=function(e,t,n){const o=new Map;for(const r of e){const e=r.target>r.source?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??yt(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>e.key.localeCompare(t.key))}(s,t,c),u=new Map(i.map(e=>[e.id,new Set])),d=new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)u.get(e)?.add(n.id),n.color&&d.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),f=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),p=new Map,m=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=Mt(n,t),c=(s.length-1)/2*(h+f)+h/2;for(const e of[n.source,n.target])p.set(e,Math.max(p.get(e)??0,c));s.forEach((c,l)=>{u.get(n.source)?.add(c.descriptor.id),u.get(n.target)?.add(c.descriptor.id);const p=vt(c.edge,a,t,c.edge.source!==n.source),g=ft(p?[o,...p,i]:ht(o,i),(l-(s.length-1)/2)*(h+f)),y=kt(c.edge,c.descriptor),x=bt(c.descriptor,c.edge,t,e.resolveColor);d.has(c.descriptor.id)||d.set(c.descriptor.id,x),m.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:pt(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=new Map,y=[],x=[],b=e=>(mt(e,t)||e.id)+"";if("minimap"===n){const n=new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of u.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,p.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(const n of o){const o=wt(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(b).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:F(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),u={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length>1?(o.forEach((t,i)=>{const a={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:-Math.PI/2+i/o.length*Math.PI*2,endAngle:-Math.PI/2+(i+1)/o.length*Math.PI*2,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(a)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})):y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&d.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})}}else for(const e of i){const o=a.positions.get(e.id);if(!o)continue;const i=wt(u.get(e.id)??[],t),s=i.length>1||!0===e.data.interchange||!0===e.data.transfer,c=s?t.interchangeRadius??Math.max("primary"===n?7:5,p.get(e.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(e.id,c);const l=b(e);if(y.push({type:"circle",cx:o.x,cy:o.y,r:c,style:null!=t.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:s?"primary"===n?3:2:1.5,opacity:r(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${l}${s?", interchange":""}`,tableFields:{station:l,lines:i.join(", ")}},id:e.id,label:l}),t.renderStation){const a=t.renderStation({station:e.data,x:o.x,y:o.y,radius:c,lineIds:i,interchange:s,mode:n});null!=a&&x.push((0,xc.createElement)("g",{key:e.id,opacity:r(e.data),style:{pointerEvents:"none"}},a))}}const w=x.length>0?(0,xc.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:m,sceneNodes:y,overlays:w,labels:$t(i,a.positions,u,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return M;const v=(e,t)=>({opacity:r(e.datum,t)});return{...M,restyle:v,restyleEdge:v}},Mc=require("react/jsx-runtime"),vc=require("react/jsx-runtime"),kc={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},$c={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Sc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.layerAccessor??"x",r=t.rowAccessor??"y",i=t.partitionAccessor??"partition",s=t.semanticAccessor??"semantic",a=t.labelAccessor??"label",c=t.storesAccessor??"stores",l=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...kc,...t.partitionColors},h={...$c,...t.edgeColors},f=t.accentColor??"var(--semiotic-focus, #ffcc33)",p=t.borderColor??"var(--semiotic-border, #555)",m=t.dimOpacity??.14,g=t.edgeOpacity??.5,y=t.edgeWidth??1.25,x=t.backEdgeWidth??t.edgeWidth??1.5,b=!1!==t.showStoreChips,w=t.storeChipColor??"var(--semiotic-info, #6a8caf)",M=t.hullGroupAccessor;let v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0;const n=new Map;for(const r of e.nodes){const e=Math.round(Number(N(r,o,0)));t=Math.max(t,e),n.set(e,(n.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),S=n.height/Math.max(1,k);let I=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),A=Math.min(t.nodeHeight??54,Math.max(8,S-(t.minGapY??18)));const C=t.lod&&"auto"!==t.lod?t.lod:16>I?"dot":48>I?"icon":108>I?"compact":"full";if("dot"===C){const e=Math.min(I,A,11);I=e,A=e}const j=Math.max(1,n.width-I),E=Math.max(1,n.height-A),P=Math.max(1,k-1),F=e=>n.x+I/2+(v>1?e/(v-1):.5)*j,z=e=>n.y+A/2+(e+P/2)/P*E,O=t.reachableIds?new Set(t.reachableIds):null,L=t.selectedId??null,R=e.selection,T=new Map,W=new Map,q=[],D=null==M?null:new Map,V=[];for(const t of e.nodes){const e=t.id,n=Number(N(t,o,0)),l=Number(N(t,r,0)),u=N(t,i,"processor")+"",h=N(t,s,"processor")+"",g=N(t,a,e)+"",y=At(N(t,c,[])),x=t.data??t,b=F(n),w=z(l);T.set(e,{cx:b,cy:w});const v=O?O.has(e):null,k=R?.isActive?R.predicate(x):null,$=null!==v?!v:null!==k&&!k;W.set(e,$);const S=null!=L&&e===L,j=$&&!S?m:1,E=Object.prototype.hasOwnProperty.call(d,u)?d[u]:d.unknown;if("dot"===C?q.push({type:"circle",cx:b,cy:w,r:I/2,style:{fill:E,opacity:j,stroke:S?f:"transparent",strokeWidth:S?2:0},datum:t,id:e,label:g}):(q.push({type:"rect",x:b-I/2,y:w-A/2,w:I,h:A,style:{fill:E,opacity:j,stroke:S?f:p,strokeWidth:S?3:1},datum:t,id:e,label:g}),V.push({id:e,cx:b,cy:w,partition:u,semantic:h,label:g,stores:y,opacity:j,selected:S,node:x})),D&&null!=M){const n=N(t,M,null);if(null!=n){const t=n+"",o=D.get(t)??[];o.push({id:e,x:b-I/2,y:w-A/2,w:I,h:A}),D.set(t,o)}}}const G=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,o=T.get(e),r=T.get(n);if(!o||!r)continue;const i=!!N(t,l,!1),s=N(t,u,"internal")+"",a=W.get(e)||W.get(n)?Math.min(g,1.4*m):g,c=i?h.back:Object.prototype.hasOwnProperty.call(h,s)?h[s]:h.internal;let d;if(i){const e=o.cx,t=o.cy+A/2,n=r.cx,i=r.cy+A/2,s=Math.max(48,.28*Math.abs(e-n))+A;d=`M${e},${t} C${e},${t+s} ${n},${i+s} ${n},${i}`}else{const e=o.cx+I/2,t=o.cy,n=r.cx-I/2,i=r.cy,s=(e+n)/2;d=`M${e},${t} C${s},${t} ${s},${i} ${n},${i}`}const f={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?x:y,fill:"none",opacity:a,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};G.push(f)}const Y=0===V.length?null:(0,vc.jsx)("g",{className:"lineage-dag-glyphs",children:V.map(e=>function(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):function(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";return(0,vc.jsxs)("g",{children:[(0,vc.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),(0,vc.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(e.semantic,e.partition,i),l="full"===r,u="icon"!==r,d="full"===r&&t.showChips&&e.stores.length>0;return(0,vc.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[(0,vc.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),u&&(0,vc.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:(0,vc.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&(0,vc.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),d&&e.stores.map((e,n)=>(0,vc.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:(0,vc.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}(e,{w:I,h:A,lod:C,partColors:d,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))}),H=D&&D.size>0?function(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);return(0,Mc.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=function(e,t){if(0===t||3>e.length)return e;const n=0>e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)?-1:1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},u=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,p=d.y/h,m=t/Math.max(1e-6,f*u.x+p*u.y);return{x:o.x+f*m,y:o.y+p*m}})}(function(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(2>=t.length)return t;const n=[];for(const e of t){for(;n.length>=2&&0>=St(n[n.length-2],n[n.length-1],e);)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&0>=St(o[o.length-2],o[o.length-1],n);)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=function(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${It(e.x)},${It(e.y)}`).join(" ")+" Z";const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${It(o.x)},${It(o.y)}`;for(let e=1;n.length>e;e++){const t=n[e];r+=` L${It(t.incoming.x)},${It(t.incoming.y)}`,r+=` Q${It(t.point.x)},${It(t.point.y)} ${It(t.outgoing.x)},${It(t.outgoing.y)}`}const i=n[0];return r+=` L${It(i.incoming.x)},${It(i.incoming.y)}`,r+=` Q${It(i.point.x)},${It(i.point.y)} ${It(i.outgoing.x)},${It(i.outgoing.y)} Z`,r}(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),s=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),a=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);return(0,Mc.jsxs)("g",{"data-lineage-hull":e,opacity:s?t.dimOpacity:void 0,children:[(0,Mc.jsx)("path",{className:"lineage-dag-hull",d:r,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),l?(0,Mc.jsx)("text",{className:"lineage-dag-hull-label",x:a+8,y:c+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:l}):null]},e)})})}(D,{colors:t.hullColors,padding:null==t.hullPadding?16:B(t.hullPadding),radius:null==t.hullRadius?12:B(t.hullRadius),fillOpacity:Ct(t.hullFillOpacity,.08),strokeOpacity:Ct(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:W,selectedId:L,dimOpacity:m}):null;return H?{sceneNodes:q,sceneEdges:G,backgrounds:H,overlays:Y}:{sceneNodes:q,sceneEdges:G,overlays:Y}},Ic=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Ac=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Cc={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},jc=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Nc=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Ec=e=>{const t=e.config.braid,n=e.dimensions.plot,o=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],r=t.groups.filter(e=>o.includes(e.partition)&&e.nodePath.length>0),i=[],s=[],a=[];if(0===r.length)return{sceneNodes:s,sceneEdges:i,labels:a};const c=new Set(r.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...r].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=o.map(e=>d.filter(t=>t.partition===e)),f=function(e){const t=new Map;for(const n of e){const e=zt(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}(d),p=Et(f.map(e=>e.depth)),m=r.map(e=>Et(e.stepEntityCounts??[e.entityCount])),g=Et(m),y=e=>e>0?Math.max(1,10*e/g):0,x=new Map(r.map((e,t)=>[e.id,y(m[t])])),b=n.height/o.length,{semantic:w}=e.theme,M=(e,t,n,o={})=>a.push({x:e,y:t,text:n,fill:w.text??"#333",fontSize:10,anchor:"middle",...o}),v={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},k=new Map(f.map(e=>{const t=h.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?x.get(n.id)+3:0),5));return[e.id,Et(t,24)]})),$=Et([...k.values()],24),S=Math.min(n.width/4,$/2+16),I=(n.width-2*S)/Math.max(p-1,1),A=e=>n.x+S+(e-1)*I,C=48+$/2,j=22+$/2,N=(e,t)=>e+C+(u.get(t)+.5)*Math.max(0,b-C-j)/l.length,E=(t,n,o,r,s)=>{const a=jc(n,r),c=jc(n,s),l=y(a),u=y(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(n.signature);i.push({type:"curved",id:o,pathD:d?Pt(t,l,u):pt(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...v,id:o,kind:"braid-track",nodeId:n.nodePath[s],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:s+1,fromCount:a,toCount:c}})};return o.forEach((e,t)=>{const o=n.y+t*b,r=h[t];if(e&&M(n.x+8,o+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;p>=e;e++)M(A(e),o+34,"Step "+e);const i=new Map;for(const t of f){const n=r.filter(e=>t.signatures.has(e.signature));if(0===n.length)continue;const a=A(t.depth),c=V([...t.signatures].map(e=>N(o,e))),l=Ft(n.map(e=>x.get(e.id)));i.set(t.id,new Map(n.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=k.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;s.push({type:"glyph",id:h,cx:a,cy:c,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:Cc,accent:w.border??"#888",style:{fill:w.surface??"#fff"},datum:{...v,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),M(a,c+u/2+12,t.state)}for(const t of r){const n=zt(t.signature);for(let o=1;n.length>o;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset;E(1e-8>Math.abs(r.y-s.y)?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s],t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:s,sceneEdges:i,labels:a,restyle:Nc,restyleEdge:Nc}},Pc=require("react/jsx-runtime"),Fc={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},zc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",f=t.textColor??"var(--semiotic-text, #e6e6e6)",p=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",m=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(N(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(N(e,a,0))-Number(N(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*k)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*k:.5*v)),I=(r?$:S)/2+6,A=Math.max(1,w-2*I),C=e=>(r?n.x:n.y)+I+(x>1?(i?x-1-e:e)/(x-1)*A:A/2),j=new Map,E=[],P=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=C(e),a=(r?n.y:n.x)+(i+1)/(t.length+1)*M,u=r?s:a,p=r?a:s,g=N(o,l,"rect")+"",y=N(o,c,o.id)+"";j.set(o.id,{cx:u,cy:p,shape:g}),E.push({type:"rect",x:u-$/2,y:p-S/2,w:$,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:y,type:Fc[g]??"process",shape:g},id:o.id,label:y}),P.push((0,Pc.jsxs)("g",{children:[Lt(g,u,p,$,S,d,"diamond"===g?m:h,1.5),(0,Pc.jsx)("text",{x:u,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:Ot(y,Math.max(4,Math.floor(($-12)/7)))})]},"n-"+o.id))});const F=[];return e.edges.forEach((e,t)=>{const n="string"==typeof e.target?e.target:e.target.id,o=j.get("string"==typeof e.source?e.source:e.source.id),i=j.get(n);if(!o||!i)return;const s=r?o.cx+$/2:o.cx,a=r?o.cy:o.cy+S/2,c=r?i.cx-$/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${s},${a} C${(s+c)/2},${a} ${(s+c)/2},${l} ${c},${l}`:`M${s},${a} C${s},${(a+l)/2} ${c},${(a+l)/2} ${c},${l}`,m=Math.atan2(l-a,c-s),g=c-9*Math.cos(m),y=l-9*Math.sin(m),x=4.5*-Math.sin(m),b=4.5*Math.cos(m),w=`${c},${l} ${g+x},${y+b} ${g-x},${y-b}`,M=N(e,u,void 0),v=(s+c)/2,k=(a+l)/2;F.push((0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),(0,Pc.jsx)("polygon",{points:w,fill:p}),"string"==typeof M&&M.length>0&&(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("rect",{x:v-6.5*M.length/2-4,y:k-9,width:6.5*M.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),(0,Pc.jsx)("text",{x:v,y:k,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:M})]})]},"e-"+t))}),{sceneNodes:E,overlays:(0,Pc.jsxs)("g",{className:"mermaid-dag",children:[F,P]})}},Oc=require("react/jsx-runtime"),Lc=require("react/jsx-runtime"),Rc=new ya(8),Tc=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,p=t.fingerprintRounds??3,m=!1!==t.groupByMotif,g=t.sort??"frequency",y=new Map,x=new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,N(t,s,"")+""))}const w=[];for(const t of e.edges){const e=Ht(t.source??N(t,o,void 0)),n=Ht(t.target??N(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,undirected:k}=Kt(b,w),$=Qt(b,M,v,k,p),S=new Map;if(m)for(const e of $){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...$].sort((e,t)=>t.nodeCount-e.nodeCount));const I=[...S.entries()];I.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const A=Yt(b.join(",")+"|"+[...M.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),C=L([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),c,l,u,d,h,f,p,m,g,a,I.map(([e,t])=>e+":"+t.length).join(","),A]),j=Rc.getOrCompute(C,()=>function(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e)s+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=s)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),s=[],a=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const a=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=Xt(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:a,y:c,width:r,height:r},t.nodeRadius);s.push({component:e,lod:"full",cx:a+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else s.push({component:e,lod:"glyph",cx:a+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const p=Zt(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});a.push({motif:l,descriptor:Ut(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:p}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:s,bands:a}}(I,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:a,nodeDatum:y,nodeCategory:x,outAdj:M,inAdj:v})),E=e.theme.semantic||{},P=t.convergeColor??E.info??"#4c78a8",F=t.branchColor??E.warning??"#e8853a",z=t.edgeColor??E.border??"#9aa0aa",R=t.colorMode??"directedness",T={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},q=t=>"motif"===R?e.resolveColor(t.motif):"category"===R||t.directed?P:F,D=[],B=[];for(const t of j.cells){const n=t.component,o=q(n);if("full"===t.lod){for(const e of t.edges)B.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:z,strokeWidth:1,opacity:.5},datum:null});for(const n of t.nodes){const t="category"===R&&n.category?e.resolveColor(n.category):o,r={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:t,opacity:O(n.datum,T)},datum:n.datum,id:n.id,label:N(n.datum,i,n.id)+""};D.push(r)}}else{const e=W({id:`motif-${n.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:n.motif,shape:Ut(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:O(e,T),stroke:z,strokeWidth:.75},datum:e,id:e.id+"",label:Ut(n)};D.push(r)}}return{sceneNodes:D,sceneEdges:B,overlays:function(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(Rt({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push((0,Lc.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>(0,Lc.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>(0,Lc.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push((0,Lc.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push((0,Lc.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push((0,Lc.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,Lc.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),(0,Lc.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),(0,Lc.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),(0,Lc.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;return(0,Lc.jsx)("g",{className:"net-ensemble-overlays",children:n})}(j.bands,{convergeColor:P,branchColor:F,edgeColor:z,plot:n,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===R,textColor:E.text??"var(--semiotic-text, #1a1a1a)",subText:E.textSecondary??"var(--semiotic-text-secondary, #888)"})}},Wc=Ys(require("react")),qc=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:Jt(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[e+"",t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,u=n.x+(n.width-l)/2,d=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),f=h/2,p=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):N(e.datum,t.labelAccessor??"label",e.id)+"";return{id:e.id,label:o,datum:e.datum,index:n,cx:u+(n+.5)*c,cy:d+(n+.5)*c}}),m=new Map(p.map(e=>[e.id,e])),g=new Map(p.map(e=>[e.id,e.index])),y=function(e,t,n){const o=new Map;for(const r of e){const e=en(r.source),i=en(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=Jt(r),l=tn("function"==typeof n.valueAccessor?n.valueAccessor(c):N(c,n.valueAccessor??"value",r.value??1),0);if(0>=l)continue;let u=o.get(e);u||(u=new Map,o.set(e,u));const d=u.get(i);d?(d.value+=l,d.edgeCount+=1,d.memberEdges.push(c)):u.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=F(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}(e.edges,g,t),x=function(e,t,n){const o=new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(sn(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),r(sn(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=an(t,n);let s=null==n.flowScale?1/0:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=cn(e.length,t,n);o>0&&(s=Math.min(s,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??1/0);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=cn(e.length,t,n);o>0&&(l=Math.min(l,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}if(1>l)for(const t of e)t.width*=l;return o}(y,h,t),b=function(e,t,n,o){const r=new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=cn(s.length,n,o);let u=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}(x,m,h,t),w=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),M=e.theme.semantic.text??"var(--semiotic-text, currentColor)",v=e.theme.semantic.surface??"var(--semiotic-bg, white)",k=e.theme.semantic.border??"var(--semiotic-border, currentColor)",$=e.theme.semantic.grid??k,S=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),I=t.valueFormat??(e=>Math.round(100*e)/100+""),A=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),C=new Map(p.map(e=>[e.id,0])),j=new Map(p.map(e=>[e.id,0])),E=[],P=[],z=[];for(const n of y){const o=m.get(n.source),r=m.get(n.target);if(!o||!r)continue;C.set(o.id,(C.get(o.id)??0)+n.value),j.set(r.id,(j.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):w);const a=b.get(n.key+":source")??o.cy,l=b.get(n.key+":target")??r.cx;let h,p,g,y,x,k,$;if(n.targetIndex>n.sourceIndex){const e=[o.cx+f,a],t=[l,r.cy-f];h=[e,[t[0],e[1]],t],p=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,x=t[0]-A-4,k=e[1]-n.width/2-3,$="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-f,a],i=[l,r.cy+f];h=[e,[i[0],e[1]],i],p=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,x=i[0]+A+4,k=e[1]+n.width/2+(t.valueFontSize??10),$="start"}else{const e=u+(o.index+1)*c,t=d+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+f+2,e-i),m=Math.max(o.cy+f+2,t-i),b=[o.cx+f,a],w=[l,r.cy+f];h=[b,[s,b[1]],[s,m],[w[0],m],w],p=(s+w[0])/2,g=m,y=Math.PI,x=s-3,k=m-n.width/2-3,$="end"}const S=on(h,A);if(z.push({type:"curved",id:"adjacency-flow-"+n.key,label:`${o.label} to ${r.label}: ${I(n.value,n.datum)}`,pathD:S,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${I(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&P.push({x:x,y:k,text:I(n.value,n.datum),anchor:$,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:M,stroke:v,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(2>=e)continue;E.push(Wc.createElement("path",{key:"arrow-"+n.key,className:"semiotic-adjacency-flow-arrow",d:rn(p,g,y,Math.max(3,1.08*e),e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const O=p.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):S);return{type:"rect",id:n.id,label:n.label,x:n.cx-f,y:n.cy-f,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??k,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:j.get(n.id)??0,outgoing:C.get(n.id)??0}}}}),L=Math.max(2,t.maxLabelLength??14),R=p.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=L,n.length>o?n.slice(0,Math.max(1,o-1))+"…":n),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??v};var n,o});let T=null;if(t.showGrid??!0){const e=[];for(let t=0;p.length>=t;t+=1){const n=u+t*c,o=d+t*c;e.push(Wc.createElement("line",{key:"grid-v-"+t,x1:n,y1:d,x2:n,y2:d+l,stroke:$,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),Wc.createElement("line",{key:"grid-h-"+t,x1:u,y1:o,x2:u+l,y2:o,stroke:$,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}T=Wc.createElement(Wc.Fragment,null,...e)}return{sceneEdges:z,sceneNodes:O,labels:[...P,...R],backgrounds:T,overlays:Wc.createElement(Wc.Fragment,null,...E)}},Dc=require("react/jsx-runtime"),Bc=new ya(12),Vc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],p=t.shadeStrength??.72,m=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,$=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,I=$?t.headerHeight??26:0,A=S?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,j=n.x+A,E=n.y+I,F=Math.max(1,n.width-A),z=Math.max(1,n.height-I-C),T=[];for(const t of e.nodes){const e=t.data??t;T.push({id:t.id,col:N(t,o,"—")+"",row:N(t,r,"—")+"",sizeVal:i?Number(N(t,i,1)):1,colorKey:s?N(t,s,"")+"":"",symVal:a?N(t,a,"")+"":"",shadeVal:c?pn(N(t,c,null)):NaN,marker:!!l&&!!N(t,l,!1),iconVal:u?N(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===T.length)return{sceneNodes:[]};let W=1/0,q=-1/0;if(i)for(const e of T)Number.isFinite(e.sizeVal)&&(W>e.sizeVal&&(W=e.sizeVal),e.sizeVal>q&&(q=e.sizeVal));t.sizeDomain&&([W,q]=t.sizeDomain),Number.isFinite(W)&&Number.isFinite(q)||(W=0,q=1);const D=e=>{if(W>=q)return(h+f)/2;const t=Math.sqrt(mn((e-W)/(q-W),0,1));return h+t*(f-h)};let B=1/0,V=-1/0;if(c)for(const e of T)Number.isFinite(e.shadeVal)&&(B>e.shadeVal&&(B=e.shadeVal),e.shadeVal>V&&(V=e.shadeVal));t.shadeDomain&&([B,V]=t.shadeDomain);const G=e=>{if(!c||!Number.isFinite(e)||B>=V)return.5;const t=mn((e-B)/(V-B),0,1);return m?1-t:t},Y=t.colorMap,H=new Map,_=(t,n)=>{let o=H.get(t);return o||(o=R(Y&&Object.prototype.hasOwnProperty.call(Y,t)&&"string"==typeof Y[t]&&Y[t]?Y[t]:e.resolveColor(t),p),H.set(t,o)),o(n)},X=new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))X.set(e,n);let U=0;const K=t.iconMap,Q=e=>u&&K&&Object.prototype.hasOwnProperty.call(K,e)?K[e]??null:null,Z=e=>u?"circle":(e=>{if(!a)return d;let t=X.get(e);return t||(t=Ia[U%Ia.length],U++,X.set(e,t)),t})(e.symVal),J=t.maxAreaFraction??.4;let ee=0;const te=Array(T.length),ne=Array(T.length);for(let e=0;T.length>e;e++){const t=T[e],n=D(t.sizeVal);te[e]=n,t.baseShape=Z(t),t.iconShape=Q(t.iconVal);const o=he(t.baseShape,Math.PI*n*n);ne[e]=o,ee+=Math.PI*o*o}const oe=J*F*z,re=ee>oe?Math.sqrt(oe/ee):1;for(let e=0;T.length>e;e++){const t=T[e],n=te[e]*re;t.size=Math.PI*n*n,t.packR=ne[e]*re}const ie=new Map,se=new Map;for(const e of T)ie.set(e.col,(ie.get(e.col)??0)+1),se.set(e.row,(se.get(e.row)??0)+1);const ae=t.columnOrder?.filter(e=>ie.has(e))??[...ie.keys()].sort((e,t)=>(ie.get(t)??0)-(ie.get(e)??0)),ce=t.rowOrder?.filter(e=>se.has(e))??[...se.keys()].sort((e,t)=>(se.get(t)??0)-(se.get(e)??0)),le=L([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),I,A,C,g,y,x,b,w,M,v,h,f,W,q,J,ae.join(","),ce.join(","),T.length,gn(T)]),de=Bc.getOrCompute(le,()=>function(e,t){const n=new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=Math.max(1,t.innerW-t.columnGap*Math.max(0,o.length-1)),i=t.proportionExponent,s=o.map(e=>Math.pow(n.get(e).length,i)),a=s.reduce((e,t)=>e+t,0)||1,c=e=>"uniform"===t.cellSizing?r/o.length:s[e]/a*r,l=new Map,u=[];let d=t.innerX;for(let e=0;o.length>e;e++)u.push({col:o[e],x:d,w:c(e)}),d+=c(e)+t.columnGap;let h=1;const f=new Map,p=[],m=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},g=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=function(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,u=new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=function(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}(a),f=new Float64Array(d);let p=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>p&&(p=f[t]);const m=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/m,b=r/Math.ceil(d/m);for(let e=0;d>e;e++){const o=e%m,r=Math.floor(e/m);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*p),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=f[e]+f[n],a=o*o+r*r;if(s*s>a)if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],s=t+i,a=t+o-i,u=n+i,d=n+r-i;g[e]=a>s?mn(g[e],s,a):c,y[e]=d>u?mn(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}(a,n,o,r,i,t.packPadding,t.iterations,h++);let u=1/0,d=1/0,f=-1/0,p=-1/0;for(const e of a){const t=c.get(e.id);l.set(e.id,{px:t.px,py:t.py}),m(s,t.px,t.py,e.r),u>t.px-e.r&&(u=t.px-e.r),t.px+e.r>f&&(f=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>p&&(p=t.py+e.r)}return Number.isFinite(u)?{x:u-Gc,y:d-Gc,w:f-u+2*Gc,h:p-d+2*Gc}:null};if("banded"===t.rowMode){const r=new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e),i)),d=c.reduce((e,t)=>e+t,0)||1,h=new Map;let p=t.innerY+t.innerH;for(let e=0;s.length>e;e++){const n="uniform"===t.cellSizing?a/s.length:c[e]/d*a,o=p-n;h.set(s[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=P(n.get(e),e=>e.row);for(const e of s){const n=o.get(e),r=h.get(e);n&&r&&g(n,u[t].x,r.y,u[t].w,r.h,e)}});const m=[],y=new Map;for(const e of s){const t=h.get(e);y.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&m.push({x:n.minX-Gc,y:n.minY-Gc,w:n.maxX-n.minX+2*Gc,h:n.maxY-n.minY+2*Gc})}return{positions:l,enclosures:m,colBands:u,rowLabelY:y}}const y=new Map;o.forEach((e,o)=>{const r=P(n.get(e),e=>e.row),s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e).length,i)),l=c.reduce((e,t)=>e+t,0)||1;let d=t.innerY+t.innerH;s.forEach((e,n)=>{const i="uniform"===t.cellSizing?a/s.length:c[n]/l*a,h=d-i,f=g(r.get(e),u[o].x,h,u[o].w,i,e);if(f){p.push(f);const t=y.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,y.set(e,t)}d=h-t.rowGap})});const x=new Map;for(const[e,t]of y)x.set(e,t.sum/t.n);return{positions:l,enclosures:p,colBands:u,rowLabelY:x}}(T,{columnOrder:ae,rowOrder:ce,innerX:j,innerY:E,innerW:F,innerH:z,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),fe=e.selection,pe=fe?.isActive?fe.predicate:null,me=t.highlight??null,ge=t.dimOpacity??.16,ye=t.markStroke,xe=t.markStrokeWidth??0,be=t.markerColor??"#ffffff",we=t.iconColor??"rgba(255,255,255,0.92)",Me=t.iconStrokeWidth??1,ve=t.iconScale??.72,ke=[],$e=[],Se=[];for(const e of T){const t=de.positions.get(e.id);if(!t)continue;const n=O(e.datum,{highlight:me,predicate:pe,dimOpacity:ge}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:_(e.colorKey,G(e.shadeVal)),opacity:n,...ye?{stroke:ye,strokeWidth:xe}:{}},datum:e.datum,id:e.id,label:e.id+""};if(ke.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ve,r=he(e.iconShape,100);Se.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>ge+.001&&$e.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Ie=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(C>0?.45*C:9),r=[];for(let e=0;t.callouts.length>e;e++){const n=t.callouts[e],o=T.find(e=>e.datum[n.field]+""==n.value+"");if(!o)continue;const i=de.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=new Map;i.forEach((e,t)=>{s.set(e.ci,j+(t+.5)/i.length*F)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),Ie.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const Ae=function(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);return(0,Dc.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>Rt({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&(0,Dc.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>(0,Dc.jsx)("path",{d:ue(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&(0,Dc.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>(0,Dc.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>qt({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>qt({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>Vt(e))]})}(de,{markerDots:$e,markerColor:be,iconMarks:Se,iconColor:we,iconStrokeWidth:Me,callouts:Ie,plot:n,showEnclosures:k,showColumnHeaders:$,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*I,labelX:n.x+A-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel});return{sceneNodes:ke,overlays:Ae}},Gc=4,Yc=Ys(require("react")),Hc=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=j(t.categoryAccessor),r=j(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>F(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),d=!1!==t.showCategoryLabels,h=Math.max(0,n.height-(t.labelPadding??(d?22:0))),f=[],p=new Map,m=[],g=new Set,y=new Map;for(const t of e.data){const e=o(t)+"",n=r(t)+"",s=i(t);p.has(e)||(f.push(e),p.set(e,0),y.set(e,new Map)),g.has(n)||(g.add(n),m.push(n)),p.set(e,(p.get(e)??0)+s);const a=y.get(e);a.set(n,(a.get(n)??0)+s)}const x=t.categoryOrder?yn(t.categoryOrder,f,e=>p.has(e)):f,b=t.stackOrder?yn(t.stackOrder,m,()=>!0):m,w=x.reduce((e,t)=>e+(p.get(t)??0),0);if(0>=w)return{nodes:[]};const M=Math.max(0,n.width-s*Math.max(0,x.length-1)),v=[],k=[];let $=n.x;for(const t of x){const o=p.get(t)??0,r=o/w*M;if(0>=r)continue;k.push({cat:t,x:$,w:r});const i=y.get(t);let a=n.y;for(const n of b){const s=i.get(n)??0;if(0>=s)continue;const c=s/o*h;v.push({type:"rect",x:$,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,s),group:n}),a+=c}$+=r+s}return{nodes:v,overlays:d&&k.length>0?function(e,t,n){const o=e.map((e,o)=>qt({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return Yc.createElement(Yc.Fragment,null,...o)}(k,n.y+h+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}},_c=Ys(require("react")),Xc=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=t.rowHeight??28,r=t.rowGap??12,i=!1!==t.showLabels,s=i?t.labelWidth??120:0,a=!1!==t.showTicks,c=a?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+s,d=Math.max(0,n.width-s);if(0>=d)return{nodes:[]};const h=j(t.categoryAccessor),f=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},p=e=>f("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),m=e=>f("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),g=e=>{const n="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(n)?n.map(f).sort((e,t)=>e-t):[]},y="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",x="string"==typeof t.valueAccessor?t.valueAccessor:"value",b="string"==typeof t.targetAccessor?t.targetAccessor:"target",w=t.actualColor??e.theme.semantic.primary??"#3b6cb1",M=e.theme.semantic.text??"currentColor",v=t.targetColor??`var(--semiotic-text, ${M})`,k=[`var(--semiotic-surface, ${e.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${e.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${e.theme.semantic.border??"#a3a8af"})`],$=`var(--semiotic-text, ${M})`,S=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,I=[],A=[];for(let t=0;e.data.length>t;t++){const i=e.data[t],s=g(i),a=p(i),l=m(i),f=Math.max(a,l,...s.length?s:[0]);if(0>=f)continue;const M=n.y+t*(o+r+c);if(M+o+c>n.y+n.height)break;A.push({yTop:M,label:h(i),actual:a,target:l,maxVal:f});const $=e=>u+e/f*d,S=h(i),C=e=>F(t=>{t("metric",S),"metric"!==y&&t(y,S),e(t)});let j=u;for(let e=0;s.length>e;e++){const t=$(s[e]),n=t-j;n>0&&I.push({type:"rect",x:j,y:M,w:n,h:o,style:{fill:k[Math.min(e,k.length-1)],stroke:"none"},datum:C(t=>{t("range",e),t("rangeValue",s[e]),t("kind","range")}),group:"range-"+e}),j=t}const N=Math.max(6,Math.floor(.45*o));I.push({type:"rect",x:u,y:M+(o-N)/2,w:$(a)-u,h:N,style:{fill:w,stroke:"none"},datum:C(e=>{e("value",a),e("kind","actual"),"value"!==x&&e(x,a)}),group:"actual"});const E=3,P=Math.floor(.8*o);I.push({type:"rect",x:$(l)-E/2,y:M+(o-P)/2,w:E,h:P,style:{fill:v,stroke:"none"},datum:C(e=>{e("target",l),e("kind","target"),"target"!==b&&e(b,l)}),group:"target"})}const C=[];for(let e=0;A.length>e;e++){const t=A[e];if(i&&C.push(qt({keyId:"bullet-label-"+e,text:t.label,x:n.x+s-8,y:t.yTop+o/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:$})),a){const n=5,r=t.yTop+o+2;for(let o=0;n>o;o++){const i=t.maxVal*o/(n-1),s=u+i/t.maxVal*d;C.push(_c.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:s,x2:s,y1:r,y2:r+3,stroke:S,strokeWidth:1}),qt({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:s,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:S}))}}}return{nodes:I,overlays:C.length>0?_c.createElement(_c.Fragment,null,...C):null}},Uc=Ys(require("react")),Kc=require("d3-scale"),Qc=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,Kc.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",p=t.dimmedOpacity??.08,m=t.highlightFn,g=[],y=[];for(const n of e.data){const r=u?e.resolveColor(u(n)+""):f,i=!m||m(n),s=O(n,{predicate:m,baseOpacity:d,dimOpacity:p,brighten:.4}),a=i?y:g;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:m&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+s,f=n.y+n.height-a,p=[];for(let e=0;o.length>e;e++){const a=o[e],m=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();p.push(Uc.createElement("line",{key:"pc-axis-line-"+e,x1:m,x2:m,y1:h,y2:f,stroke:i,strokeWidth:1})),p.push(qt({keyId:"pc-axis-label-"+e,text:a,x:m,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=r[a],w=5;for(let t=0;w>t;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);p.push(Uc.createElement("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:o,y2:o,stroke:i,strokeWidth:1}),qt({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:m+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Uc.createElement(Uc.Fragment,null,...p)}return{nodes:g.concat(y),overlays:x}},Zc=require("react/jsx-runtime"),Jc=1.75,el="#222222",tl=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=j(t.categoryAccessor??"name"),r=j(t.teaVolumeAccessor??"teaVolume"),i=j(t.bobaVolumeAccessor??"bobaVolume"),s=j(t.iceVolumeAccessor??"iceVolume"),a=j(t.cupHeightAccessor??"cupHeight"),c=j(t.cupTopRadiusAccessor??"cupTopRadius"),l=j(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=j(t.bobaRadiusAccessor??"bobaRadius"),d=t.cupWidthRatio??.82,h=e.scales.o,f=h.bandwidth(),p=Math.max(1,n.height-26-8),m=n.y+8,g=[],y=[];for(const t of e.data){const n=o(t)+"",x=h(n);if(null==x)continue;const b={height:Sn(a(t),15.5),topRadius:Sn(c(t),4.75),bottomRadius:Sn(l(t),3.75)},w=Sn(u(t),.6),M=Math.max(0,Sn(r(t),450)),v=Math.max(0,Sn(i(t),110)),k=Math.max(0,Sn(s(t),135)),$=Math.PI*w*w,S=Math.floor(v/$),I=S*$,A=Math.floor(k/5.359375),C=A*Jc*Jc*Jc,j=M+I+C,N=wn(b,j),E=Math.min(b.height,Math.max(0,N)),P=xn(b,E),{pearls:F,layers:z}=kn(b,w,S),O=E,L=$n(b,z*w*2,O,A),R=b.height-20.32,T=Math.min(0,R),D=Math.min(f*d/(2*(b.topRadius+1)),p/(b.height-T)),B=x+f/2,V=e=>B+e*D,G=e=>m+(e-T)*D,Y=V(-(b.topRadius+1)),H=V(b.topRadius+1),_=G(T),X=G(b.height),U=W({name:n,teaVolume:M,bobaVolume:Math.round(I),iceVolume:Math.round(C),totalVolume:Math.round(j),numBobas:S,numIce:A,kind:"boba cup"});g.push({type:"rect",x:Y,y:_,w:Math.max(1,H-Y),h:Math.max(1,X-_),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+q(n)});const K=b.height-O,Q=q(n),Z=e.resolveColor(n);y.push((0,Zc.jsxs)("g",{children:[M>0?(0,Zc.jsx)("path",{d:`M${V(-P)},${G(K)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(P)},${G(K)} z`,fill:"#D2B799"}):null,F.map((e,t)=>(0,Zc.jsx)("circle",{cx:V(e.x),cy:G(e.z),r:w*D,fill:"#222222",opacity:.5},"p-"+t)),L.map((e,t)=>(0,Zc.jsx)("rect",{x:V(e.cx)-.95*Jc*D/2,y:G(e.cy)-.95*Jc*D/2,width:.95*Jc*D,height:.95*Jc*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${V(e.cx)} ${G(e.cy)})`},"i-"+t)),(0,Zc.jsx)("path",{d:`M${V(-b.topRadius)},${G(0)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(b.topRadius)},${G(0)}`,fill:"none",stroke:el,strokeWidth:2.5}),(0,Zc.jsx)("line",{x1:V(-(b.topRadius+1)),y1:G(0),x2:V(b.topRadius+1),y2:G(0),stroke:el,strokeWidth:3,strokeLinecap:"round"}),M>0?(0,Zc.jsx)("path",{d:`M${V(-.635)},${G(R)} L${V(-.635)},${G(b.height-.4)} L${V(.635)},${G(b.height-1.27-.4)} L${V(.635)},${G(R)} z`,fill:"#4F91CB",stroke:el,strokeWidth:1,opacity:.78}):null,(0,Zc.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),(0,Zc.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${S} pearls · ${Math.round(j)} cm³`})]},"boba-"+Q))}return{nodes:g,overlays:(0,Zc.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},nl=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),ol=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),rl=1,il=32,sl=6,al=4,cl=8,ll=72,ul=30,dl=-30,hl=8,fl=480,pl=3,ml={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},gl=["naturalGas","coal","nuclear","hydro","wind","solar","other"],yl={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},xl={tight:5,watch:12,comfortable:20},bl=Ys(require("react")),wl=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]>e)n=this.count++,n===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,this.tree[t]>e&&t++;n=t-this.capacity}let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return n>=t||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},Ml=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=so(t.laneAccessor),r=so(t.startAccessor),i=so(t.endAccessor),s=t.idAccessor?so(t.idAccessor):null,a=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,p=t.bottomInset??0,m=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-p)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+a)),S=[];M.forEach((t,r)=>{const i=n.y+r*v,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:p}=ro(a,{start:k,end:$}),g=new Map,y=new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/p,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),a=$(e)-o;S.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:m(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?s(e)+"":void 0})}});const I=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,j=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+a)-o);j.push(bl.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&j.push(qt({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:A}))});const N=!1!==t.showLaneLabels,E=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;j.push(bl.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),N&&j.push(qt({keyId:"lane-label-"+t,text:e,x:n.x-E,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:I}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));j.push(Bt({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:A}))}return{nodes:S,overlays:bl.createElement(bl.Fragment,null,...j)}},vl={width:60,height:34},kl=e=>{const{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=yo(e.nodes,e.edges,t,e.config),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[];e.edges.forEach((t,o)=>{const i=r.get((a=t,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(a):N(a,e.config.sourceAccessor??"source",void 0))+""));var a;const c=r.get((t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):N(t,e.config.targetAccessor??"target",void 0))+"")(t));if(!i||!c)return;const{from:l,to:u}=lo({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:c.x,cy:c.y,width:c.width,height:c.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:ao(l,u,{orientation:"y"===n?"vertical":"horizontal",bend:uo(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:E(t)??t})});const a=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:a}},$l=require("react/jsx-runtime"),Sl=1.15,Il={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278},Al=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=j(t.textAccessor),r=e=>{const n=Number(j(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},i=j(t.columnAccessor),s=e=>Number(j(t.segmentAccessor)(e)),a=t.minFontSize??11,c=t.maxFontSize??42,l=t.columnGutter??18,u=t.collisionPadding??2,d=!1!==t.showColumnLabels,h=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,p=t.segmentTickFormat??(e=>Math.round(e)+""),m=t.rotate??0,g=!0===t.repeatWords,y=!1!==t.scaleToFit,x=t.packingDensity??.6,b="string"==typeof t.textAccessor?t.textAccessor:"word",w="string"==typeof t.weightAccessor?t.weightAccessor:"weight",M="string"==typeof t.columnAccessor?t.columnAccessor:"column",v="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",k=[],$=new Map;let S=1/0,I=-1/0;for(let t=0;e.data.length>t;t++){const n=e.data[t],a=i(n)+"",c=o(n)+"",l=r(n),u=s(n);c&&Number.isFinite(u)&&($.has(a)||(k.push(a),$.set(a,[])),$.get(a).push({col:a,text:c,weight:l,segment:u,datum:n,dataIndex:t}),S>u&&(S=u),u>I&&(I=u))}if(0===k.length)return{nodes:[]};if(!g)for(const[e,t]of $){const n=new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}$.set(e,[...n.values()])}let A=1/0,C=-1/0;for(const e of $.values())for(const t of e)A>t.weight&&(A=t.weight),t.weight>C&&(C=t.weight);if(!Number.isFinite(A))return{nodes:[]};const N=t.columnOrder?[...t.columnOrder.filter(e=>$.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,E=new Map(N.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[P,z]=t.segmentDomain??[S,I],O=z-P||1,L=C-A||1,R=d?22:0,T=h?52:0,W=n.x+T,q=n.y+R,B=Math.max(0,n.width-T),V=Math.max(0,n.height-R),G=N.length,Y=G>0?Math.max(0,B-l*Math.max(0,G-1))/G:0,H=q+14,_=q+V-14,X=e=>H+(e-P)/O*(_-H),U=Y*V;let K=1/0,Q=1/0;const Z=N.map((e,n)=>{const o=E.get(e),r=($.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:n,resolvedColumnColor:o},i=t.wordOpacity?Number(t.wordOpacity(r)):1,s=t.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(l=e.weight,a+Math.sqrt((l-A)/L)*(c-a)),opacity:Number.isFinite(i)?D(i,0,1):0,color:s||o,info:r};var l});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*wo(e.text);i+=t*Sl*e.baseFont*e.baseFont,Q=Math.min(Q,(Y-8-1)/(t*e.baseFont))}return i>0&&(K=Math.min(K,Math.sqrt(x*U/i))),{col:e,colLeft:W+n*(Y+l),center:W+n*(Y+l)+Y/2,rows:r}}).filter(e=>null!==e),J=e=>{const t=[];let n=0;for(const o of Z){if(0>=Y)continue;const r=o.colLeft+4,i=o.colLeft+Y-4,s=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:Mo(t.text,r),h:r*Sl+2,anchorY:X(t.segment),seed:(bo(i)-.5)*Math.min(.5*Y,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),a=[];for(const e of s){const s=e.w/2,c=e.h/2,l=D(o.center+e.seed,r+s,i-s),d=e.anchorY;let h=l,f=D(d,H+c,_-c),p=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,m={x:D(l+n*Math.cos(o),r+s,i-s),y:D(d+n*Math.sin(o),H+c,_-c),w:e.w,h:e.h};if(!vo(m,a,u)){h=m.x,f=m.y,p=!0;break}}p||n++,a.push({x:h,y:f,w:e.w,h:e.h});const g=Math.sqrt((e.weight-A)/L),y=m>0?2*(bo(e.id+"r")-.5)*m:0;t.push({id:e.id,text:e.text,x:h,y:f,fontSize:e.font,rotation:y,color:e.color,opacity:e.opacity,datum:F(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==b&&t(b,e.text),"weight"!==w&&t(w,e.weight),"column"!==M&&t(M,o.col),"segment"!==v&&t(v,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:n}};let ee=y?Math.min(1,K,Q):Math.min(1,Q),te=J(ee);if(y)for(let e=0;6>e&&te.unplaced>0&&ee>.1;e++)ee*=.88,te=J(ee);const ne=te.placed.filter(e=>e.opacity>0);return{nodes:ne.map(e=>{const t=Mo(e.text,e.fontSize)/2,n=e.fontSize*Sl/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:(0,$l.jsxs)("g",{className:"semiotic-word-trails",children:[h&&ko({x:n.x+T-10,yTop:H,yBot:_,segLo:P,segHi:z,segToY:X,tickCount:f,tickFormat:p,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),d&&N.map((e,t)=>Y>0?(0,$l.jsx)("text",{x:W+t*(Y+l)+Y/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:E.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ne.map(e=>(0,$l.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}},Cl={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},jl=8,Nl=Eo,El=2*Math.PI,Pl=[40,40],Fl=[.5,.5],zl=require("react/jsx-runtime"),Ol="var(--semiotic-text, currentColor)",Ll=8,Rl=new Set(["rows"]),Tl=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(Lr(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(Lr(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Wl=4e4,ql={},Dl=class{constructor(e=function(){const e="string"==typeof ql.url&&ql.url?new URL("./forceLayoutWorker.js",ql.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new Tl({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=function(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}(t);return o?{requestId:n,ok:!1,error:Rr(o)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Bl=function(){let e=null;return{get:()=>(e&&!e.isDead||(e=new Dl),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),Vl=[.1,.5,.9],Gl=1e6,Yl=12,Hl=require("react/jsx-runtime"),_l={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Xl=6.2,Ul={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1};
1
+ function e(e,t=[],n){const o=void 0===n?void 0:new Set("string"==typeof n?[n]:n),r=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&o?.has(e.partition)),i=new Set(r.map(e=>e.id)),s=new Set(r.map(e=>e.entityId)),a=/* @__PURE__ */new Map;let c=0;for(const t of e){if(void 0!==n&&"string"==typeof t.roles.occurrence&&!i.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===n&&(c+=t.entityCount);for(const[t,o]of e)(void 0===n||s.has(t))&&a.set(t,o)}return[...a.values()].reduce((e,t)=>e+t,c)}function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function n(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function o(){/* @__PURE__ */
2
+ return Object.create(null)}function r(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function i(e,n,o){return n.has(e)?"node":(t(r=o.nodeIdsBySection,i=e)?r[i]:void 0)?"section":"global";var r,i}function s(e,t,r){const s=[],a=new Set(t.nodes.map(e=>e.id)),c=/* @__PURE__ */new Set;for(const n of t.measureValues){const t=e.measures[n.measureId];if(!t)continue;const o=i(n.subjectId,a,r);s.push({measureId:n.measureId,subjectId:n.subjectId,subjectKind:o,value:n.value,status:n.status,unitKind:t.unitKind,countUnit:t.countUnit,timeDenominator:t.timeDenominator}),"section"===o&&c.add(`${n.measureId}\0${n.subjectId}`)}const l=o();for(const e of t.nodes)n(l,e.id,e);const u=o(),d=o();for(const e of s){if("node"!==e.subjectKind)continue;const t=l[e.subjectId];if(!t?.sectionId)continue;const n=`${e.measureId}\0${t.sectionId}`;c.has(n)||(u[n]=(u[n]??0)+e.value,"exact"!==e.status?d[n]=e.status:d[n]||(d[n]="exact"))}for(const[t,n]of Object.entries(u)){const o=t.split("\0"),r=o[0],i=e.measures[r];i&&s.push({measureId:r,subjectId:o[1],subjectKind:"section",value:n,status:d[t]??"exact",unitKind:i.unitKind,countUnit:i.countUnit,timeDenominator:i.timeDenominator})}return{entries:s}}function a(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function c(t){const n=t.spec.comparison;if(!n)return;const o=n.partitions.map(o=>{const r=a(t.ledger,n.denominatorMeasureId,o)?.value??0,i={};return i["repeated-state-episode"]=e(t.motifs.matches.filter(e=>"repeated-state-episode"===e.template),t.source.occurrences,o),{partition:o,assigned:r,motifUsers:i,outcomes:{purchases:a(t.ledger,"purchases",o)?.value??0}}});return{partitions:[...n.partitions],denominatorMeasureId:n.denominatorMeasureId,referencePartition:n.referencePartition,rows:o}}function l(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return a(e.ledger,n,t)?.value}function u(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function d(e,t){const r=o();for(const t of e.nodes)n(r,t.id,t.completeness??"known");const i=o();for(const e of t.unsupportedTemplates)n(i,e,"unsupported-template");if(t.incompleteCandidates.length>0){const e=new Set(t.incompleteCandidates.map(e=>e.template));for(const t of e)n(i,t,"incomplete")}const s=t.matches.find(e=>e.truncation),a={nodes:r,motifs:i,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return s?.truncation&&(a.truncation={disclosed:!0,template:s.template,omitted:s.truncation.omitted}),a}function h(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}function f(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}function p(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=h(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),u=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!u.has(e.id)).map(e=>e.id)}}}function m(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}function g(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return!(!o?.sectionId||!t.coordinate.sectionIds.includes(o.sectionId))}function y(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function x(e,t){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return p(t,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const r=t.edges.map(e=>e.id),i=e.forest.display.rankingPolicyId??"main-transport",{mode:s,order:a}=m(i),c=n=>g(t,e,n.source)&&g(t,e,n.target),l=/* @__PURE__ */new Map;for(const e of t.nodes)l.set(e.id,[]);for(const e of t.edges)l.has(e.target)||l.set(e.target,[]),l.get(e.target).push(e);const u=o(),d=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:t.nodes[0]?[t.nodes[0].id]:[],h=new Set(d);for(const e of t.nodes){if(h.has(e.id))continue;const t=y(l.get(e.id)??[],a),o=t.find(e=>c(e))??t[0];o&&n(u,e.id,o.id)}let f;f="tree-only"===s?Object.values(u):t.edges.filter(e=>c(e)).map(e=>e.id);const x=new Set(f),b=r.filter(e=>!x.has(e));return{forest:{kind:"rooted-backbone",roots:[...d],rankingPolicyId:i,backboneEdgeIds:f,primaryParentEdgeIdByNode:u},residual:{residualEdgeIds:b,originalEdgeIds:r}}}function b(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw Error("original edge IDs != backbone ⊎ residual")}function w(e){const t=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),n=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),o=/* @__PURE__ */new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=/* @__PURE__ */new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}function M(e,t){return e.sectionByNode.get(t)}function v(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){const t=M(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function k(e,t,n){return e.pairs.get(t)?.get(n)??[]}function $(e){return e.entityCount??1}function S(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=$(r));return{entityIds:n,entityCount:o}}function I(e,t){return null!=t&&e.length>t?{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}:{kept:e}}function A(e,t,n,r,i,s){if(2>n.length)return;const{kept:a,truncation:c}=I(n,s),l=[t,...a],u=[];for(const n of a){const o="fan-out"===e?k(i,t,n):k(i,n,t);u.push(...o)}const d=v(i,[t,...n]),h=S(r.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:a}:{destination:t,sources:a},nodePath:l,edgeIds:u,startSectionId:d[0],completionSectionId:d[d.length-1],intersectSectionIds:d,entityIds:h.entityIds,entityWeights:o(),entityCount:h.entityCount,flags:{occurrence:h.entityIds.length>0,temporal:!1,trajectorySupported:h.entityIds.length>0,enriched:!1},truncation:c}}function C(e,t,n){return 1===t.length&&1===n.length}function j(e,t){const n=t.incoming,r=t.outgoing,i=[];for(const s of e.nodes){const a=n.get(s.id)??[],c=r.get(s.id)??[];if(1!==c.length)continue;const l=1===a.length&&C(0,n.get(a[0])??[],r.get(a[0])??[]);if(C(0,a,c)&&l)continue;const u=[s.id];let d=s.id;const h=/* @__PURE__ */new Set([d]);for(;;){const e=(r.get(d)??[])[0];if(!e||h.has(e))break;if(u.push(e),h.add(e),!C(0,n.get(e)??[],r.get(e)??[]))break;d=e}if(2>u.length)continue;const f=[];for(let e=0;u.length-1>e;e++)f.push(...k(t,u[e],u[e+1]));const p=v(t,u),m=S(e.occurrences??[],u[0]);i.push({id:"serial-chain:"+u.join(">"),template:"serial-chain",roles:{nodes:u,start:u[0],end:u[u.length-1]},nodePath:u,edgeIds:f,startSectionId:p[0],completionSectionId:p[p.length-1],intersectSectionIds:p,entityIds:m.entityIds,entityWeights:o(),entityCount:m.entityCount,flags:{occurrence:m.entityIds.length>0,temporal:!1,trajectorySupported:m.entityIds.length>0,enriched:!1}})}return i}function N(e,t){const r=t.occurrences??[];if(0!==r.length)for(const t of e){if("repeated-state-episode"===t.template)continue;const e=t.nodePath,i=o();for(const t of r)t.missingPrehistory||e.some(e=>t.nodePath.includes(e))&&n(i,t.entityId,$(t));const s=Object.keys(i);t.entityIds=s,t.entityWeights=i,t.entityCount=s.reduce((e,t)=>e+(i[t]??0),0),t.flags={...t.flags,occurrence:s.length>0,trajectorySupported:s.length>0}}}function E(e,t){const r=[];for(const i of e.occurrences??[]){if(i.missingPrehistory)continue;const e=/* @__PURE__ */new Map,s=/* @__PURE__ */new Set;for(const[a,c]of i.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,a);continue}if(s.has(c))continue;s.add(c);const u=i.nodePath.slice(l,a+1),d=v(t,u),h=o();n(h,i.entityId,$(i)),r.push({id:`repeated-state-episode:${i.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:i.id},nodePath:u,edgeIds:[],startSectionId:M(t,u[0]),completionSectionId:M(t,u[u.length-1]),intersectSectionIds:d,entityIds:[i.entityId],entityWeights:h,entityCount:$(i),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return r}function P(e,t){const n=e.motifs.matchBudget,o=w(t),r=[];for(const e of t.nodes){const i=A("fan-out",e.id,o.outgoing.get(e.id)??[],t,o,n);i&&r.push(i);const s=A("fan-in",e.id,o.incoming.get(e.id)??[],t,o,n);s&&r.push(s)}r.push(...j(t,o)),r.push(...E(t,o)),N(r,t);const i=[];for(const e of t.occurrences??[])e.missingPrehistory&&(i.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),i.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const s=Yc.filter(e=>!_c.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:r,incompleteCandidates:i,unsupportedTemplates:s}}function F(e){return e.entityCount??1}function z(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function O(e,t={}){function i(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const s={id:"",stateId:"",prefix:[],children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map};for(const t of e){if(t.missingPrehistory)continue;const e=F(t);let n=s;n.occurrenceIds.push(t.id),n.entityCount+=e,z(n,t.partition,e);for(const o of t.nodePath){const i=[...n.prefix,o],s=r(i,i.length-1);let a=n.children.get(o);a||(a={id:s,stateId:o,prefix:i,children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map},n.children.set(o,a)),a.occurrenceIds.push(t.id),a.entityCount+=e,z(a,t.partition,e),n=a}}const a=[],c=[],l=t.referencePartition;return function e(t,r){if(t.id){const e=o();for(const[o,r]of t.partitionCounts)n(e,o,r);a.push({id:t.id,stateId:t.stateId,prefix:t.prefix,parentId:r,childIds:i(t).map(e=>t.children.get(e).id),entityCount:t.entityCount,occurrenceIds:[...t.occurrenceIds],partitionCounts:e}),c.push(t.id)}for(const n of i(t))e(t.children.get(n),t.id||null)}(s,null),{kind:"observed-prefix",rootIds:i(s).map(e=>s.children.get(e).id),nodes:a,order:c,referencePartition:l}}function L(e,t){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:o()};const r=o();for(const t of e.coordinate.sectionIds)n(r,t,[]);for(const e of t.nodes){if(!e.sectionId)continue;const t=r[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:r}}function R(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}function T(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;e.length-1>o;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}function W(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=f(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),u=/* @__PURE__ */new Map([[r,r]]),d=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=u.get(e):t=u.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>u.has(e)).reduce(d);u.get(e)!==t&&(u.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>u.has(t)?[[e,u.get(t)===r?null:n[u.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>u.has(t)),unreachableNodeIds:n.filter((e,t)=>!u.has(t))}}function q(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function D(e,t){const r=[];e.schemaVersion!==Gc&&q(r,"schema-version","expected schemaVersion "+Gc),e.relations.directed&&!0===e.relations.edgeIdRequired||q(r,"relations","Phase 1 requires directed edges with ids"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&q(r,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&q(r,"coordinate","Phase 1 kernel uses ordinal sections");const i=o();for(const o of t.nodes)o.id?(i[o.id]&&q(r,"duplicate-node","duplicate node id",o.id),n(i,o.id,!0),"ordinal"===e.coordinate.kind&&o.sectionId&&!e.coordinate.sectionIds.includes(o.sectionId)&&q(r,"section-membership",`node section ${o.sectionId} is not in the coordinate`,o.id)):q(r,"node-id","node is missing id");const s=o();for(const e of t.edges)e.id?(s[e.id]&&q(r,"duplicate-edge","duplicate edge id",e.id),n(s,e.id,!0),i[e.source]||q(r,"dangling-source","edge source is not a node",e.id),i[e.target]||q(r,"dangling-target","edge target is not a node",e.id)):q(r,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])i[t]||q(r,"missing-root","display root is not a node",t);const a=e.forest.requiredPaths;if(a)if("directed-admitted"!==a.relationScopeId&&q(r,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(a.roots)&&0!==a.roots.length)for(const e of a.roots)i[e]||q(r,"required-path-roots","required-path root is not a node",e);else q(r,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&q(r,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(2>e.comparison.partitions.length&&q(r,"comparison","comparison requires at least two partitions"),e.measures[e.comparison.denominatorMeasureId]||q(r,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(c=e.measures)||"object"!=typeof c||Array.isArray(c))q(r,"measures","measures must be an object");else for(const[t,n]of Object.entries(e.measures))"rate"!==n.unitKind||n.timeDenominator||q(r,"rate-denominator","rate measures require a timeDenominator",t);var c;for(const n of t.measureValues)e.measures[n.measureId]?Number.isFinite(n.value)||q(r,"non-finite-measure","measure value is not finite",n.measureId):q(r,"unknown-measure","measureValue refers to an undeclared measure",n.measureId);for(const e of t.occurrences??[])if(e.id&&e.entityId){void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||0>e)||q(r,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)i[t]||q(r,"occurrence-node","occurrence path references a missing node",e.id)}else q(r,"occurrence","occurrence needs id and entityId");return{ok:r.every(e=>"fatal"!==e.severity),issues:r}}function B(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function V(e,t,n={}){const o=D(e,t);if(!o.ok)return{ok:!1,issues:o.issues};const r=n.generation??1,i=L(e,t),a=P(e,t),l=x(e,t);b(l.residual,l.forest);const u=s(e,t,i),h=d(t,a),f=T(t),p=B(e,t,r),m="observed-prefix"===e.forest.display.kind||(t.occurrences?.length??0)>0?O(t.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,g={sourceGraphRef:t.graphRef,analysisRevision:p,spec:e,source:t,sections:i,motifs:a,forest:l.forest,residualEdges:l.residual,ports:f,ledger:u,completeness:h,provenance:{sourceRevision:t.revision,analysisRevision:p,generation:r,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?"ordinal:"+e.coordinate.sectionIds.join(","):"numeric:"+e.coordinate.field,forestRoots:[...e.forest.display.roots??l.forest.roots],rankingPolicyId:l.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:m,...e.forest.requiredPaths&&{requiredPaths:W(t,e.forest.requiredPaths)}};return g.comparison=c(g),{ok:!0,atlas:g,issues:o.issues}}function G(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function Y(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>({id:"capsule:"+e.id,matchId:e.id,template:e.template,entryState:"string"==typeof e.roles.state?e.roles.state:e.nodePath[0],exitState:e.nodePath[e.nodePath.length-1],entityCount:e.entityCount,occurrenceIds:G(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=/* @__PURE__ */new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}function H(t,n={}){const o=n.templates??["repeated-state-episode"],r="ordinal"===t.spec.coordinate.kind?t.spec.coordinate.sectionIds:[],i=void 0!==n.partition?l(t,n.partition)??0:t.spec.comparison?t.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:t.ledger.entries.find(e=>"global"===e.subjectKind&&e.measureId===t.spec.motifs.denominatorRef)?.value??0,s=o=>e(o,t.source.occurrences,n.partition??t.spec.comparison?.partitions),a=[],c=t.motifs.incompleteCandidates.length>0;for(const e of o)for(const o of r){const r=t.motifs.matches.filter(t=>t.template===e),l=s(r.filter(e=>e.completionSectionId===o)),u=s(r.filter(e=>e.intersectSectionIds.includes(o)));a.push({template:e,sectionId:o,partition:n.partition,completionCount:l,intersectionCount:u,denominator:i,status:c?"incomplete":"exact"})}return{templates:o,sections:r,cells:a}}function _(e){return e.entityCount??1}function X(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:_(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:r(e.nodePath,e.nodePath.length-1)}}function U(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:H(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(X).filter(e=>!!e),o=/* @__PURE__ */new Map;for(const e of n){const n=t.order.indexOf(e.signature),r=o.get(e.signature),i=-1===n?t.order.length:n;(null==r||r>i)&&o.set(e.signature,i)}const i=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(o.get(e)??0)-(o.get(t)??0);return 0!==n?n:e.localeCompare(t)}),s=[];for(const e of n)for(let t=0;e.nodePath.length-1>t;t++){const n=r(e.nodePath,t),o=r(e.nodePath,t+1);s.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:o,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const a=Y(e.motifs.matches),l=e.comparison??c(e),d=[];if(l&&l.partitions.length>=2){const e=l.rows[0],t=l.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;d.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:u(o,r,n),denominator:n}),d.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:u(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const h={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:s.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:i,ribbons:s,capsules:a,profile:H(e),differences:d,prefixForest:t,sceneSeeds:h}}function K(e,t){return e.groups.some(e=>R(e.nodePath,t))}function Q(e){return"function"==typeof e?e:t=>t[e]}function Z(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function J(e){return null==e?null:e.data??e.datum??e}function ee(e,t){const n=/* @__PURE__ */new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function te(e){const t=/* @__PURE__ */Object.create(null);return e((e,n)=>{t[e]=n}),t}function ne(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function oe(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!ne(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function re(e){return e.join("|")}function ie(e,t=.72){const n=(0,Cl.interpolateLab)(e,"#ffffff"),o=(0,Cl.interpolateLab)(e,"#000000"),r=(0,Cl.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function se(e,t,n=.72){return ie(e,n)(t)}function ae(e){return te(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function ce(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function le(e,t,n){return Math.max(t,Math.min(n,e))}function ue(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function de(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function he(e,t){const n=le(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function fe(e,t,n){const o=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,r=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(r(t.weight)>0?1:0),0),s=i>0?Math.min(Math.max(0,Math.floor(n?.minPerCategory??0)),Math.floor(o/i)):0,a=e.reduce((e,t)=>e+r(t.weight),0);if(0>=o||0>=a)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const c=e.map(e=>{const t=r(e.weight),n=t/a*o;return{...e,exact:n,cells:t>0?Math.max(s,Math.floor(n)):0,remainder:n-Math.floor(n)}});let l=c.reduce((e,t)=>e+t.cells,0);for(;l>o;){const e=c.filter(e=>e.cells>s).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,l--}const u=c.filter(e=>r(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||r(t.weight)-r(e.weight)||e.key.localeCompare(t.key));for(let e=0;o>l;e++)u[e%u.length].cells++,l++;return c}function pe(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}function me(e,t,n,o){const r=/* @__PURE__ */new Set;return e.map((e,i)=>{const s=t(e,i)+"",a=Number(n(e,i));if(!s)throw Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||0>a)throw Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function ge(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null==n.epsilon||0>n.epsilon?1e-9:n.epsilon,s=me(e,n.beforeId,n.beforeValue,"Before"),a=me(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),u=s.reduce((e,t)=>e+t.value,0),d=a.reduce((e,t)=>e+t.value,0),h=i>=Math.abs(u-d);if(!h&&!n.allowImbalance)throw Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],p=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of p){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const m=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;m.length>y&&g.length>x;){const e=m[y],t=g[x],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value>i||(y+=1),t.value>i||(x+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:m.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function ye(e){return Number.isFinite(e)?Math.max(0,e):0}function xe(e,t){const n=Number(t.unit),o=ye(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=Math.ceil(o/n-El),a=Math.min(r,s),c=s>r,l=[];for(let e=0;a>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));El>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function be(e,t,n){const o=xe(e,n),r=Math.max(ye(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=xe(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+El);let c=Math.min(1,Math.max(0,s-a));El>c&&(c=0);const l=[];for(const e of i.units)a>e.index||(e.index===a&&c>0?e.fraction-c>El&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function we(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function Me(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,s=n.linkStrength??.045,a=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=we(n.seed??1),f=/* @__PURE__ */new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const p=Fl/2,m=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=e=>"function"==typeof l?l(e.data):l,y=new Set(e.map(e=>e.id)),x=t.filter(e=>y.has(e.source)&&y.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,Pl.forceSimulation)(m).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,Pl.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,Pl.forceCollide)(e=>g(e)+u).strength(.9).iterations(2)).force("center",(0,Pl.forceCenter)(p,p).strength(.8)).force("x",(0,Pl.forceX)(p).strength(a)).force("y",(0,Pl.forceY)(p).strength(a));x.length>0&&e.force("link",(0,Pl.forceLink)(x).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return s/.045/n})),e.stop();for(let t=0;o>t;t+=1)e.tick()}let b=1/0,w=1/0,M=-1/0,v=-1/0;for(const e of m){const t=e.x??p,n=e.y??p;b>t&&(b=t),w>n&&(w=n),t>M&&(M=t),n>v&&(v=n)}const k=M-b,$=v-w,S={};for(const e of m)Object.defineProperty(S,e.id,{value:{x:0===k?.5:d+((e.x??p)-b)/k*(1-2*d),y:0===$?.5:d+((e.y??p)-w)/$*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return S}function ve(e){return e?e.map(Number).filter(Number.isFinite):[]}function ke(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function $e(e,t){const n=ke(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}function Se(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:ve(e),data:e}:e}function Ie(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Ae(e){if(e.samples)return ve(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function Ce(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}function je(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=we(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}function Ne(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function Ee(e,t){const n=Ie(t),o=Se(e);let r,i,s,a,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?xe(ue(o.value),e):be(ue(o.value),ue(o.rangeValue),e);r=t.units.map(e=>Ne(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>Ne(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){a=Math.floor(ue(o.denominator??n.denominator)),s=ue(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>Ne(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=a,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Ae(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,ke(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=Ce(e,r);return Ne(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Ae(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,ke(n));r=("random-sample"===n.countStrategy?je(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return Ne(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>Ne(n,t,1,{datum:e})),i=e.length;else{const e=xe(ue(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>Ne(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=$e(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:Fe(n,{visibleTokens:r.length+(u?.length??0)})}}function Pe(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,s=t.cellHeight??i,a=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,p=t.y??0;return n.map((e,n)=>{let o,m;return"column"===r?(m=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),m=n%l),"left"===t.columnDirection&&(m=h-1-m),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:m,x:f+m*(i+a)+c[0]*i,y:p+o*(s+a)+c[1]*s}})}function Fe(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||ue(e.denominator)>Ol?zl:Ol);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function ze(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function Oe(e){const t=ze(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function Le(e){const t=ze(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:Fe(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:Fe(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:Fe(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:Fe(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function Re(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return qe(t);const r=Object.prototype.hasOwnProperty.call(Rl,o)?Rl[o]:Ll.symbolCircle;return(0,Ll.symbol)(r,Math.max(1,t))()??""}function Te(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function We(e,t,n){if(!n&&"circle"===(e??"circle"))return Te(t);const o=n?"p:"+n:`s:${e??"circle"}:${t}`,r=Wl.get(o);if(null!=r)return r;const i=Re(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Wl.size>512&&Wl.clear(),Wl.set(o,s),s):Te(t)}function qe(e){const t=1.5*Te(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}function De(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function Be(e,t,n){return"function"==typeof e?e(t)??n:e??n}function Ve(e,t){return"function"==typeof e?e(t):e}function Ge(e){return e.sample??e.value??e.index}function Ye(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function He(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}function _e(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,s=Math.max(1,Math.floor(t.rows??1)),a=e.map(Ge),c=Math.min(...a),l=Math.max(...a)-c||1;return e.map((a,u)=>{const d=Ge(a),h=u%s,f=t.valueToX?t.valueToX(d,a):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),p=t.valueToY?t.valueToY(d,a):o+h*(r+i);return{...a,x:f,y:p,row:h,column:u}})}function Xe(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,s=t.cellWidth??r+i,a=t.cellHeight??r+i,c=e.map(Ge),l=Math.min(...c),u=Math.max(...c)-l||1,d=/* @__PURE__ */new Map;return e.map(r=>{const i=Ge(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*s),h=Math.round((c-n)/Math.max(1,s)),f=d.get(h)??0;d.set(h,f+1);const p=t.valueToY?t.valueToY(i,r):o+f*a;return{...r,x:n+h*s,y:p,row:f,column:h}})}function Ue(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:Ge(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}function Ke(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return He(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return _e(n,t);if("dotplot"===o)return Xe(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return Ue(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:Ye(n,t,i);return Pe(n,{...t,columns:a,cellWidth:i,cellHeight:s})}function Qe(e){if(e)return Ul[e]}function Ze(e,t){return void 0!==t.datum?Be(t.datum,e,null):e.datum??null}function Je(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?Be(t.rangeColor,e,Zl):Be(t.color,e,Kl):Be(t.inactiveColor,e,Ql),stroke:"none",...Ve(t.style,e)??{}}}function et(e,t){const n=Ve(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:Ze(e,t),accessibleDatum:Ve(t.accessibleDatum,e),accessibility:Ve(t.accessibility,e),pointId:n,_transitionKey:n}}function tt(e,t){const n=Be(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:Be(t.radius,e,n/2),style:Je(e,t),...et(e,t)}}function nt(e,t){const n=Be(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:Be(t.symbolType,e,"circle"),path:Ve(t.symbolPath,e),rotation:Ve(t.rotation,e),style:Je(e,t),...et(e,t)}}function ot(e,t,n){const o=Je(e,n),r=Be(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??Kl)+"",accent:Be(n.accent,e,Jl),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:Be(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?Ve(n.ghostColor,e)??Ql:void 0,rotation:Ve(n.rotation,e),style:o,...et(e,n)}}function rt(e,t,n){if("dot"===n.tokenType)return tt(e,t);const o=Ve(t.glyph,e)??Qe(n.icon);if(o)return ot(e,o,t);const r=(i=n.icon)&&eu.has(i)?i:void 0;var i;return nt(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}function it({input:e,encoding:t,options:n={}}){if(!De(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=De(e)?{...e,encoding:Ie(e.encoding)}:Ee(e,t),r=Ke(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>rt(e,n,o.encoding))}}function st(e){return`${e.getUTCFullYear()}-${at(e.getUTCMonth()+1)}-${at(e.getUTCDate())}`}function at(e){return 10>e?"0"+e:e+""}function ct(){const e=(Al??(Al=ru.createContext(null)),Al);return ru.useContext(e)??iu}function lt(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function ut(e,t){const n=lt(e,t);return"string"==typeof n&&n.length>0?n:void 0}function dt(e){return hu.has(e)?e:void 0}function ht(e,t){const n=lt(e,t),o=dt("string"==typeof n?n:lt(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=lt(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=ut(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}function ft(e,t){if(du.has(t))return ut(e,t)}function pt(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function mt(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function gt(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function yt(e){return du.has(e)?e:"monument"}function xt(e,t){const n=gt(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=pt(t.idAccessor,"id"),a=pt(t.nameAccessor,"name"),c=pt(t.longitudeAccessor,"lon"),l=pt(t.latitudeAccessor,"lat"),u=pt(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?pt(t.candidatePriorityAccessor,"priority"):()=>0,h=/* @__PURE__ */new Map;let f=null;for(const p of e){const e=Number(c(p)),m=Number(l(p));if(!Number.isFinite(e)||!Number.isFinite(m))continue;const g=(s(p)??`${e},${m}`)+"",y=(a(p)??g)+"",x=yt(u(p)),[b,w]=mt(e,m,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,S={...p,id:g,name:y,kind:x,lon:e,lat:m,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(p))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=S);const I=`${v}:${M}`,A=h.get(I)??[];A.push(S),h.set(I,A)}const p=/* @__PURE__ */new Map;f&&p.set("city",1);const m=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,s=(t+.5)*r-o,a=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=p.get(e.kind)??0,i=p.get(t.kind)??0,s=r*r*.35;return e.cellDistanceSq+o*s-(t.cellDistanceSq+i*s)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&p.set(c.kind,(p.get(c.kind)??0)+1),m.push({id:n,row:e,column:t,centerXKm:s,centerYKm:a,terrainIndex:Math.abs((17*e+31*t)%cu.length),landmark:c,landmarks:l})}return m}function bt({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=ct(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */ /* @__PURE__ */
3
+ return(0,su.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,u=a.isActive&&!a.predicate(s)?.28:1;/* @__PURE__ */ /* @__PURE__ */
4
+ return(0,su.jsxs)("g",{opacity:u,children:[
5
+ /* @__PURE__ */
6
+ /* @__PURE__ */(0,su.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),
7
+ /* @__PURE__ */
8
+ /* @__PURE__ */(0,su.jsx)(Mt,{kind:s.kind,href:ft(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&/* @__PURE__ */ /* @__PURE__ */(0,su.jsx)(wt,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},s.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);/* @__PURE__ */ /* @__PURE__ */
9
+ return(0,su.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[
10
+ /* @__PURE__ */
11
+ /* @__PURE__ */(0,su.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),
12
+ /* @__PURE__ */
13
+ /* @__PURE__ */(0,su.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function wt({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,s=Math.max(r,i.length*r*.58);/* @__PURE__ */ /* @__PURE__ */
14
+ return(0,su.jsxs)("g",{transform:`translate(${e},${t})`,children:[
15
+ /* @__PURE__ */
16
+ /* @__PURE__ */(0,su.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),
17
+ /* @__PURE__ */
18
+ /* @__PURE__ */(0,su.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function Mt({kind:e,href:t,x:n,y:o,size:r}){if(t)/* @__PURE__ */ /* @__PURE__ */
19
+ return(0,su.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=mu[e];/* @__PURE__ */ /* @__PURE__ */
20
+ return(0,su.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:pu[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:/* @__PURE__ */ /* @__PURE__ */(0,su.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}function vt(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function kt(e,t,n){return Math.max(t,Math.min(n,e))}function $t(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(t>o&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function St(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function It(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=kt(Number.isFinite(t.occupancy)?Number(t.occupancy):yu,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):xu;let i=vt(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=vt(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));n.length>i*s&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=$t(n.map(e=>e.x)),c=$t(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:St(e.x,a)*Math.max(0,i-1),desiredRow:St(e.y,c)*Math.max(0,s-1)})),u=(i-1)/2,d=(s-1)/2;l.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const h=/* @__PURE__ */new Set;for(let e=0;s>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=(o%i-e.desiredColumn)**2+(Math.floor(o/i)-e.desiredRow)**2;(n>r||r===n&&t>o)&&(t=o,n=r)}0>t||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function At(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function Ct(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??"area-"+t;return{...n,id:o+""}}function jt(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function Nt(e,t,n){const o=[];for(let r=0;6>r;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return jt(o)}function Et(e){return e.areas.map((t,n)=>{const o=Ct(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Pt(e){return e.points.map(t=>{const n=Number(At(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(At(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Ft(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(At(e,t.columnAccessor)),y:Number(At(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}function zt({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=ct();/* @__PURE__ */ /* @__PURE__ */
21
+ return(0,gu.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);/* @__PURE__ */ /* @__PURE__ */
22
+ return(0,gu.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function Ot(){throw Error("geographicDotGrid requires the geo recipe bundle")}function Lt(){throw Error("geographicDotGrid requires the geo recipe bundle")}function Rt(e,t,n){return Math.max(t,Math.min(n,e))}function Tt(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function Wt(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function qt(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function Dt(e,t){const n=qt(e);return(e.id??n.id??n.name??"feature-"+t)+""}function Bt(e,t){if(0===e.length)return null;const n=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(n[0][0])&&Number.isFinite(n[0][1])&&Number.isFinite(n[1][0])&&Number.isFinite(n[1][1])?n:null}function Vt(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function Gt(e){if(!e)return 0;const t=Su.get(e);if(t)return t;const n=Iu;return Iu+=1,Su.set(e,n),n}function Yt(e){return e.map((e,t)=>{if($u.has(e))return{feature:e,index:t,bounds:$u.get(e)??null};try{const n=Ot();return $u.set(e,n),{feature:e,index:t,bounds:n}}catch{return $u.set(e,null),{feature:e,index:t,bounds:null}}})}function Ht(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(n=e[0],o=t[0][0],r=t[1][0],o>r?o>n&&n>r:o>n||n>r));var n,o,r}function _t(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&Ht(t,n.bounds))try{if(Lt())return{feature:e,index:o}}catch{}}return null}function Xt(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=Bt(r,t.geoPath);if(!i)return{dots:[],cellSize:Mu,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[Rt(i[0][0],s,Math.max(s,n.width-s)),Rt(i[0][1],s,Math.max(s,n.height-s))],[Rt(i[1][0],s,Math.max(s,n.width-s)),Rt(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:Mu,features:r};const u=Tt(o.columns);let d=Math.max(2,u?c/u:Tt(o.cellSize)??Mu);const h=Math.max(100,Math.round(Tt(o.maxSamples)??vu)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const p=o.gridOrigin?.[0]??0,m=o.gridOrigin?.[1]??0,[g,y]=Vt(a[0][0],a[1][0],p,d),[x,b]=Vt(a[0][1],a[1][1],m,d),w=[],M=Yt(r);for(let e=x;b>=e;e+=1){const n=m+(e+.5)*d;for(let r=g;y>=r;r+=1){const i=t.invertedPoint(p+(r+.5)*d,n);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;const s=_t(M,i);if(!s)continue;const a={...qt(s.feature),featureId:Dt(s.feature,s.index),featureIndex:s.index,gridRow:e,gridColumn:r,longitude:i[0],latitude:i[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(a,w.length)||w.push(a)}}return{dots:w,cellSize:d,features:r}}function Ut(e){return Math.round(1e4*e)/1e4}function Kt(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${Ut(Number(e[0]))},${Ut(Number(e[1]))}`:"null"}function Qt(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function Zt(e){return"number"==typeof e&&Number.isFinite(e)?Ut(e)+"":null===e?"null":"unavailable"}function Jt(e){const t=e.scales.projection;return[Zt(Qt(t,"scale")),Kt(Qt(t,"translate")),Kt(Qt(t,"center")),(n=Qt(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>Ut(Number(e))).join(","):"unavailable"),Zt(Qt(t,"clipAngle")),Zt(Qt(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>Kt(e.scales.projectedPoint(t,n)))].join("|");var n}function en(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Gt(t.featureFilter),Gt(t.dotFilter),Jt(e)].join("::")}function tn(e){let t=ku.get(e.areas);t||(t=/* @__PURE__ */new Map,ku.set(e.areas,t));const n=en(e),o=t.get(n);if(o)return o;const r=Xt(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}function nn(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function on(e,t,n){return nn([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}function rn(e,t,n){return nn(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}function sn(e,t){const n="function"==typeof t?t(e):e[t];return Eu(n)?n:void 0}function an(e){return[...e].sort((e,t)=>e.localeCompare(t))}function cn(e,t){const n=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}function ln(e){const t=new Set(e.keys()),n=[];for(;t.size>0;){const o=an(t)[0],r=[o],i=[];for(t.delete(o);r.length>0;){const n=r.shift();i.push(n);for(const o of an(e.get(n)??[]))t.has(o)&&(t.delete(o),r.push(o))}n.push(i.sort((e,t)=>e.localeCompare(t)))}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}function un(e,t,n){const o=/* @__PURE__ */new Map([[e,0]]),r=[e];for(;r.length>0;){const e=r.shift(),i=o.get(e);for(const s of an(n.get(e)??[]))t.has(s)&&!o.has(s)&&(o.set(s,i+1),r.push(s))}return o}function dn(e,t,n){return[...un(e,t,n).entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))[0][0]}function hn(e,t,n){const o=new Set(e),r=e.filter(e=>1>=(t.get(e)?.size??0))[0]??e[0],i=un(n&&o.has(n)?n:dn(dn(r,o,t),o,t),o,t),s=Math.max(0,...i.values()),a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?1/0:n.reduce((e,t)=>e+t,0)/n.length};a[e].sort((e,t)=>r(e)-r(t)||e.localeCompare(t))};for(let e=0;4>e;e+=1){for(let e=1;a.length>e;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function fn(e,t,n,o,r,i){const s=cn(e.map(e=>e.id),t),a=ln(s),c=new Map(e.map(e=>[e.id,e.data])),l=/* @__PURE__ */new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),p=Math.max(0,d-2*f),m=a.length>1?Math.min(r,p/a.length):0,g=Math.max(0,p-m*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=hn(e,s,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{l.set(n,{id:n,x:i,y:1===e.length?x+t/2:x+o/(e.length-1)*t,data:c.get(n)})})}),x+=t+m}return l}function pn(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:sn(e.data,s),authoredY:sn(e.data,a)})),l=c.length>0&&c.every(e=>Eu(e.authoredX)&&Eu(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=fn(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}const h=c.map(e=>e.authoredX),f=c.map(e=>e.authoredY),p=Math.min(...h),m=Math.max(...h),g=Math.min(...f),y=Math.max(...f),x=Math.max(1,n.width-2*r),b=Math.max(1,n.height-2*r),w=e=>({x:m===p?n.width/2:r+(e.x-p)/(m-p)*x,y:y===g?n.height/2:r+(e.y-g)/(y-g)*b}),M=/* @__PURE__ */new Map;for(const e of c){const t=w({x:e.authoredX,y:e.authoredY});M.set(e.id,{id:e.id,...t,data:e.data})}return{positions:M,mode:"authored",warnings:d,projectAuthoredPoint:w}}function mn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(.001>r||.001>i||.001>Math.abs(r-i))return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function gn(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=e.length-1>r?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(.001>l)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(.001>Math.abs(u))return{x:o.x+s.x*t,y:o.y+s.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:o.x+a*h,y:o.y+c*h}})}function yn(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(.001>=l){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},d={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function xn(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):Z(e.data,t.labelAccessor??"label",e.id)}function bn(e){return"string"==typeof e?e:e.id}function wn(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:e.id+""}:{id:e+""});return t.length>0?t:[{id:"network"}]}function Mn(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,wn(o)}function vn(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function kn(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=/* @__PURE__ */new Map,l=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(const e of a){const t={id:e.id,label:xn(e,n)+"",color:vn(e,n,o)},r=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=/* @__PURE__ */new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(l.get(e.id)?.values()??[])]))}}function $n(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function Sn(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=r.target>r.source?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:/* @__PURE__ */new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??Mn(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>e.key.localeCompare(t.key))}function In(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??1/0)-(n.get(t)??1/0)||e.localeCompare(t))}function An(e,t){const n=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(n.get(e.descriptor.id)??1/0)-(n.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function Cn(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>"number"==typeof e.x&&"number"==typeof e.y?t.projectAuthoredPoint({x:e.x,y:e.y}):null).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function jn(e,t){return te(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function Nn(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):Z(e.data,i.labelAccessor??"label",e.id)+"")||e.id,u=Math.max(2*s,l.length*s*.58),d=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,f=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-u},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-u/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-u/2}].map((e,t)=>{const n={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},o=a.filter(e=>{return(o=e).right>(t=n).left&&t.right>o.left&&o.bottom>t.top&&t.bottom>o.top;var t,o}).length;return{candidate:e,box:n,score:1e4*o+10*(Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height))+t}}).sort((e,t)=>e.score-t.score)[0];a.push(f.box),c.push({x:f.candidate.x,y:f.candidate.y,text:l,anchor:f.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function En(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function Pn(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(2>=t.length)return t;const n=[];for(const e of t){for(;n.length>=2&&0>=En(n[n.length-2],n[n.length-1],e);)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&0>=En(o[o.length-2],o[o.length-1],n);)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}function Fn(e,t){if(0===t||3>e.length)return e;const n=0>e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)?-1:1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},u=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,p=d.y/h,m=t/Math.max(1e-6,f*u.x+p*u.y);return{x:o.x+f*m,y:o.y+p*m}})}function zn(e){return(1e-12>Math.abs(e)?0:e)+""}function On(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${zn(e.x)},${zn(e.y)}`).join(" ")+" Z";const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${zn(o.x)},${zn(o.y)}`;for(let e=1;n.length>e;e++){const t=n[e];r+=` L${zn(t.incoming.x)},${zn(t.incoming.y)}`,r+=` Q${zn(t.point.x)},${zn(t.point.y)} ${zn(t.outgoing.x)},${zn(t.outgoing.y)}`}const i=n[0];return r+=` L${zn(i.incoming.x)},${zn(i.incoming.y)}`,r+=` Q${zn(i.point.x)},${zn(i.point.y)} ${zn(i.outgoing.x)},${zn(i.outgoing.y)} Z`,r}function Ln(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);/* @__PURE__ */ /* @__PURE__ */
23
+ return(0,Fu.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=Fn(Pn(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=On(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),s=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),a=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);/* @__PURE__ */ /* @__PURE__ */
24
+ return(0,Fu.jsxs)("g",{"data-lineage-hull":e,opacity:s?t.dimOpacity:void 0,children:[
25
+ /* @__PURE__ */
26
+ /* @__PURE__ */(0,Fu.jsx)("path",{className:"lineage-dag-hull",d:r,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),l?/* @__PURE__ */ /* @__PURE__ */(0,Fu.jsx)("text",{className:"lineage-dag-hull-label",x:a+8,y:c+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:l}):null]},e)})})}function Rn(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function Tn(e,t){return Number.isFinite(e)?le(e,0,1):t}function Wn(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):qn(e.semantic,e.partition,i),l="full"===r,u="icon"!==r,d="full"===r&&t.showChips&&e.stores.length>0;/* @__PURE__ */ /* @__PURE__ */
27
+ return(0,zu.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[
28
+ /* @__PURE__ */
29
+ /* @__PURE__ */(0,zu.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),u&&
30
+ /* @__PURE__ */
31
+ /* @__PURE__ */(0,zu.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,zu.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&/* @__PURE__ */ /* @__PURE__ */(0,zu.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),d&&e.stores.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,zu.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:/* @__PURE__ */ /* @__PURE__ */(0,zu.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}function qn(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";/* @__PURE__ */ /* @__PURE__ */
32
+ return(0,zu.jsxs)("g",{children:[
33
+ /* @__PURE__ */
34
+ /* @__PURE__ */(0,zu.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),
35
+ /* @__PURE__ */
36
+ /* @__PURE__ */(0,zu.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}async function Dn(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(wl(),bl));return o(e,t,n)}async function Bn(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>(Sl(),kl));return t(e)}function Vn(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function Gn(e){const t=[e[0]];for(let n=1;e.length-1>n;n++){const o=e[n-1],r=e[n],i=e[n+1],s=Wu(o,r),a=Wu(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Tu(r,o,c/s),u=Tu(r,i,c/a);t.push(l);for(let e=1;12>=e;e++){const n=e/12;t.push(Tu(Tu(l,r,n),Tu(r,u,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||Wu(t[n-1],e)>1e-8)}function Yn(e,t,n){if(2>e.length)return"";const o=Gn(e);if(2>o.length)return"";const r=[0];for(let e=1;o.length>e;e++)r.push(r[e-1]+Wu(o[e-1],o[e]));const i=r[r.length-1],s=gn(o,1),a=[1,-1].map(e=>o.map((o,a)=>Tu(o,s[a],e*(t+(n-t)*r[a]/i)/2)));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function Hn(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function _n(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function Xn(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=_n(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:/* @__PURE__ */new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}function Un(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function Kn(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,u={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":/* @__PURE__ */ /* @__PURE__ */
37
+ return(0,Gu.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":/* @__PURE__ */ /* @__PURE__ */
38
+ return(0,Gu.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":/* @__PURE__ */ /* @__PURE__ */
39
+ return(0,Gu.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);/* @__PURE__ */ /* @__PURE__ */
40
+ return(0,Gu.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;/* @__PURE__ */ /* @__PURE__ */
41
+ return(0,Gu.jsxs)("g",{children:[
42
+ /* @__PURE__ */
43
+ /* @__PURE__ */(0,Gu.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),
44
+ /* @__PURE__ */
45
+ /* @__PURE__ */(0,Gu.jsx)("path",{d:t,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
46
+ return(0,Gu.jsxs)("g",{children:[
47
+ /* @__PURE__ */
48
+ /* @__PURE__ */(0,Gu.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),
49
+ /* @__PURE__ */
50
+ /* @__PURE__ */(0,Gu.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),
51
+ /* @__PURE__ */
52
+ /* @__PURE__ */(0,Gu.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:/* @__PURE__ */ /* @__PURE__ */
53
+ return(0,Gu.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}function Qn(e){/* @__PURE__ */ /* @__PURE__ */
54
+ return(0,_u.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Zn(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function Jn(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function eo(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,_u.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function to(e){const t=e.spacing??8;return{def:/* @__PURE__ */ /* @__PURE__ */(0,_u.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:/* @__PURE__ */ /* @__PURE__ */(0,_u.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function no(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,p)=>{const m=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===p?"start":e.edgeAnchor&&p===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:m,y:x}:{x:x,y:m};/* @__PURE__ */ /* @__PURE__ */
55
+ return(0,_u.jsxs)("g",{children:[(r>0||i>0)&&/* @__PURE__ */ /* @__PURE__ */(0,_u.jsx)("line",{...n?{x1:m,x2:m,y1:g,y2:y}:{x1:g,x2:y,y1:m,y2:m},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),
56
+ /* @__PURE__ */
57
+ /* @__PURE__ */(0,_u.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:a,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${p}`)});/* @__PURE__ */ /* @__PURE__ */
58
+ return(0,_u.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function oo(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,/* @__PURE__ */ /* @__PURE__ */(0,_u.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&/* @__PURE__ */ /* @__PURE__ */(0,_u.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),
59
+ /* @__PURE__ */
60
+ /* @__PURE__ */(0,_u.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),
61
+ /* @__PURE__ */
62
+ /* @__PURE__ */(0,_u.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function ro(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(Qn({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push(
63
+ /* @__PURE__ */
64
+ /* @__PURE__ */(0,Xu.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Xu.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>/* @__PURE__ */ /* @__PURE__ */(0,Xu.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push(
65
+ /* @__PURE__ */
66
+ /* @__PURE__ */(0,Xu.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push(
67
+ /* @__PURE__ */
68
+ /* @__PURE__ */(0,Xu.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push(
69
+ /* @__PURE__ */
70
+ /* @__PURE__ */(0,Xu.jsxs)("g",{style:{pointerEvents:"none"},children:[
71
+ /* @__PURE__ */
72
+ /* @__PURE__ */(0,Xu.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),
73
+ /* @__PURE__ */
74
+ /* @__PURE__ */(0,Xu.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),
75
+ /* @__PURE__ */
76
+ /* @__PURE__ */(0,Xu.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),
77
+ /* @__PURE__ */
78
+ /* @__PURE__ */(0,Xu.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;/* @__PURE__ */ /* @__PURE__ */
79
+ return(0,Xu.jsx)("g",{className:"net-ensemble-overlays",children:n})}function io(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=/* @__PURE__ */new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:s,inAdj:a,undirected:c}=fo(r,t),l=po(r,s,a,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:ho(e)})),u=/* @__PURE__ */new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function so(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function ao(e){return"string"==typeof e?e:e?.id}function co(e,t,n,o,r){const i=new Set(e);let s=/* @__PURE__ */new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=/* @__PURE__ */new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,so(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return so(`${e.length}#${o}#${a.join(";")}`)}function lo(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set,i=e=>{const s=o.get(e);if(void 0!==s)return s;if(r.has(e))return 0;r.add(e);let a=0;for(const o of t.get(e)??[])n.has(o)&&(a=Math.max(a,1+i(o)));return r.delete(e),o.set(e,a),a};let s=0;for(const t of e)s=Math.max(s,i(t));const a=/* @__PURE__ */new Map;for(const t of e)a.set(t,s-o.get(t));return{layer:a,layerCount:s+1}}function uo(e,t,n,o,r,i,s){function a(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=p.get(o);m.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+h/2}const{layer:c,layerCount:l}=lo(e.ids,o),u=Array.from({length:l},()=>[]);for(const t of e.ids)u[c.get(t)].push(t);const d=.14*Math.min(i.width,i.height),h=Math.max(1,i.width-2*d),f=Math.max(1,i.height-2*d),p=/* @__PURE__ */new Map,m=new Set(e.ids);for(let e=0;l>e;e+=1){let t=u[e];e>0&&(t=[...t].sort((e,t)=>a(e)-a(t)));const n=t.length,o=i.y+d+(1===l?.5:e/(l-1))*f;t.forEach((e,t)=>{p.set(e,{x:i.x+d+(1===n?.5:t/(n-1))*h,y:o})})}const g=u.reduce((e,t)=>Math.max(e,t.length),1),y=le(Math.min(s,h/(2.4*g),f/(2.4*l)),1.4,s),x=e.ids.map(e=>{const o=p.get(e);return{id:e,cx:o.x,cy:o.y,r:y,datum:t.get(e)??ae({id:e}),category:n.get(e)??""}}),b=[];for(const t of e.ids){const e=p.get(t);for(const n of o.get(t)??[]){if(!m.has(n))continue;const t=p.get(n);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function ho(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function fo(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const t of e)o.set(t,/* @__PURE__ */new Set),r.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function po(e,t,n,o,r){const i=/* @__PURE__ */new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}s.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:co(c,t,n,h,r)})}return s}function mo(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e)s+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=s)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),s=[],a=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const a=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=uo(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:a,y:c,width:r,height:r},t.nodeRadius);s.push({component:e,lod:"full",cx:a+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else s.push({component:e,lod:"glyph",cx:a+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const p=go(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});a.push({motif:l,descriptor:ho(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:p}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:s,bands:a}}function go(e,t,n){return e?uo(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}function yo(e){return J(e)??e}function xo(e){return"string"==typeof e?e:e.id}function bo(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function wo(e){return Math.round(100*e)/100+""}function Mo(e,t){if(2>e.length)return"";let n=`M${wo(e[0][0])},${wo(e[0][1])}`;for(let o=1;e.length-1>o;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(0>=l){n+=`L${wo(i[0])},${wo(i[1])}`;continue}const u=[(i[0]-r[0])/a,(i[1]-r[1])/a],d=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${wo(h[0])},${wo(h[1])}Q${wo(i[0])},${wo(i[1])} ${wo(f[0])},${wo(f[1])}`}const o=e[e.length-1];return`${n}L${wo(o[0])},${wo(o[1])}`}function vo(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,u=t-s*o*.44,d=[l+a*r*.5,u+i*r*.5],h=[l-a*r*.5,u-i*r*.5];return`M${wo(c[0])},${wo(c[1])}L${wo(d[0])},${wo(d[1])}L${wo(h[0])},${wo(h[1])}Z`}function ko(e,t){return`${t}\0${e}`}function $o(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=xo(r.source),i=xo(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=yo(r),l=bo("function"==typeof n.valueAccessor?n.valueAccessor(c):Z(c,n.valueAccessor??"value",r.value??1),0);if(0>=l)continue;let u=o.get(e);u||(u=/* @__PURE__ */new Map,o.set(e,u));const d=u.get(i);d?(d.value+=l,d.edgeCount+=1,d.memberEdges.push(c)):u.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=te(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}function So(e,t,n){const o=/* @__PURE__ */new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(ko(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),r(ko(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=Ao(t,n);let s=null==n.flowScale?1/0:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=Co(e.length,t,n);o>0&&(s=Math.min(s,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??1/0);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=Co(e.length,t,n);o>0&&(l=Math.min(l,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}if(1>l)for(const t of e)t.width*=l;return o}function Io(e,t,n,o){const r=/* @__PURE__ */new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=Co(s.length,n,o);let u=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}function Ao(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function Co(e,t,n){if(1>=e)return 0;const o=Math.max(0,n.flowGap??.75),r=Ao(t,n);return Math.min(o,Math.max(0,(r-Math.min(.1,r))/(e-1)))}function jo(e,t,n){const o="function"==typeof t?t(e):Z(e,t,n);return null==o||""===o?n:o+""}function No(e,t){const n="function"==typeof t?t(e):Z(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:e+""}return n+""}}function Eo(e,t){const n="function"==typeof t?t(e):Z(e,t,1);return Number(n)}function Po(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function Fo(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map;for(const t of e){const e=jo(t,o,d.length+"");if(h.has(e))continue;const n=jo(t,i,e),s=jo(t,r,e),a={id:e,label:n,group:s,datum:t};d.push(a),h.set(e,a);const c=f.get(s);c?c.push(a):f.set(s,[a])}const p=new Set(d.map(e=>e.id)),m=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=Po(`${n.groupIdPrefix??"group:"}${e}`,p),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};m.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};m.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map;let M=0;for(const e of t){const t=No(e,s),n=No(e,a),o=Eo(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!(r&&i&&Number.isFinite(o)&&o>0)){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=/* @__PURE__ */new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:m,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function zo(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function Oo(e,t,n){return t>e?t:e>n?n:e}function Lo(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function Ro(e,t){const n=/* @__PURE__ */new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=Math.max(1,t.innerW-t.columnGap*Math.max(0,o.length-1)),i=t.proportionExponent,s=o.map(e=>Math.pow(n.get(e).length,i)),a=s.reduce((e,t)=>e+t,0)||1,c=e=>"uniform"===t.cellSizing?r/o.length:s[e]/a*r,l=/* @__PURE__ */new Map,u=[];let d=t.innerX;for(let e=0;o.length>e;e++)u.push({col:o[e],x:d,w:c(e)}),d+=c(e)+t.columnGap;let h=1;const f=/* @__PURE__ */new Map,p=[],m=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},g=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=To(a,n,o,r,i,t.packPadding,t.iterations,h++);let u=1/0,d=1/0,f=-1/0,p=-1/0;for(const e of a){const t=c.get(e.id);l.set(e.id,{px:t.px,py:t.py}),m(s,t.px,t.py,e.r),u>t.px-e.r&&(u=t.px-e.r),t.px+e.r>f&&(f=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>p&&(p=t.py+e.r)}return Number.isFinite(u)?{x:u-nd,y:d-nd,w:f-u+2*nd,h:p-d+2*nd}:null};if("banded"===t.rowMode){const r=/* @__PURE__ */new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e),i)),d=c.reduce((e,t)=>e+t,0)||1,h=/* @__PURE__ */new Map;let p=t.innerY+t.innerH;for(let e=0;s.length>e;e++){const n="uniform"===t.cellSizing?a/s.length:c[e]/d*a,o=p-n;h.set(s[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=ee(n.get(e),e=>e.row);for(const e of s){const n=o.get(e),r=h.get(e);n&&r&&g(n,u[t].x,r.y,u[t].w,r.h,e)}});const m=[],y=/* @__PURE__ */new Map;for(const e of s){const t=h.get(e);y.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&m.push({x:n.minX-nd,y:n.minY-nd,w:n.maxX-n.minX+2*nd,h:n.maxY-n.minY+2*nd})}return{positions:l,enclosures:m,colBands:u,rowLabelY:y}}const y=/* @__PURE__ */new Map;o.forEach((e,o)=>{const r=ee(n.get(e),e=>e.row),s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e).length,i)),l=c.reduce((e,t)=>e+t,0)||1;let d=t.innerY+t.innerH;s.forEach((e,n)=>{const i="uniform"===t.cellSizing?a/s.length:c[n]/l*a,h=d-i,f=g(r.get(e),u[o].x,h,u[o].w,i,e);if(f){p.push(f);const t=y.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,y.set(e,t)}d=h-t.rowGap})});const x=/* @__PURE__ */new Map;for(const[e,t]of y)x.set(e,t.sum/t.n);return{positions:l,enclosures:p,colBands:u,rowLabelY:x}}function To(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,u=/* @__PURE__ */new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=Lo(a),f=new Float64Array(d);let p=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>p&&(p=f[t]);const m=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/m,b=r/Math.ceil(d/m);for(let e=0;d>e;e++){const o=e%m,r=Math.floor(e/m);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*p),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=f[e]+f[n],a=o*o+r*r;if(s*s>a)if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],s=t+i,a=t+o-i,u=n+i,d=n+r-i;g[e]=a>s?Oo(g[e],s,a):c,y[e]=d>u?Oo(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}function Wo(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function qo(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);/* @__PURE__ */ /* @__PURE__ */
80
+ return(0,Ju.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>Qn({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Ju.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Ju.jsx)("path",{d:Re(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Ju.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Ju.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>eo({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>eo({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>oo(e))]})}function Do(e,t,n){const o=e.map((e,o)=>eo({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return od.createElement(od.Fragment,null,...o)}function Bo(e,t,n){const o=/* @__PURE__ */new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function Vo(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}function Go(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function Yo(e,t){return Vo(Go(e,t),e.bottomRadius,t)}function Ho(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-Yo(e,r),s=0;for(;100>s&&Math.abs(i)>1e-4;)r+=i/o,i=t-Yo(e,r),s++;return r}function _o(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Xo(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,s=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>s&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const a=e-2*t;t>a?e>2*t&&n.push({x:0,y:0}):o(a)};return o(e-t),n}function Uo(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),s=Xo(Go(e,n),t),a=s.length-r,c=a>1?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+_o(97*i+t,.15),z:l+_o(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function Ko(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=Go(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/dd)),r++}return r}function Qo(e,t,n,o){if(0>=o)return[];const r=Ko(e,t,o),i=Math.max(t,n-r*dd)+.875,s=[];let a=0;for(let t=0;r>t&&o>a;t++){const n=i+dd*t,r=Go(e,n),c=Math.max(1,Math.floor(2*r/dd)),l=(2*r-c*dd)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>a;e++)s.push({cx:u+(l+dd)*e+.875,cy:d+.875,rotation:_o(53*t+e,10)}),a++}return s}function Zo(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Jo(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function er(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function tr(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}function nr(e){return null==e?null:e+""}function or(e){return nr(e.provenance?.stableId??e.stableId)}function rr(e){return nr(e.stableId??e.id??e.provenance?.stableId)}function ir(e,t,n){return t.stickyPositionCache?.set(e,n),n}function sr(e,t,n){const o=or(e);if(!o)return null;const r=n.pointNodes?.find(e=>nr(e.pointId)===o);if(r)return ir(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>rr(e)===o);if(!i)return null;const s=Jo(i,n),a=er(i,n);return null==s||null==a?null:ir(t,n,{x:s,y:a})}function ar(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return ir(t,n,{x:r.x,y:r.y})}const o=tr(n);return o?ir(t,n,o):null}if("semantic"===o){const o=sr(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=Jo(e,n),i=er(e,n)),null!=r&&null!=i)return ir(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function cr(e){return"string"==typeof e?.type?e.type:""}function lr(e){return!!e&&"object"==typeof e&&pd.has(cr(e))}function ur(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function dr(e){return"primary"===e?.emphasis||!0===e?.defensive}function hr(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:md))):1/0}function fr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function pr(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??gd),i=hr(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,lr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>dr(e.annotation)),l=a.filter(e=>!dr(e.annotation)).sort((e,t)=>fr(t.annotation)-fr(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}function mr(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:vd,dy:kd}}function gr(e){const t=e?.familiarity;if(!t)return Id;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?Id:n.reduce((e,t)=>e+t,0)/n.length}function yr(e){if(!e)return 1;const t=gr(e);return t>2?4>t?1:.6:1.5}function xr(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Ad,t.source)?Ad[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function br(e,t){let n=!1;const o=e.map(e=>vr(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}function wr(e){if(!vr(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Mr(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<$d?e:{...e,_redundantConnector:!0}}function vr(e){return lr(e)}function kr(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...ur("string"==typeof e.title?e.title:void 0,o,7),...ur("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}function $r(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function Sr(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ir(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Ar(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}function Cr(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function jr(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}function Nr(e,t,n,o,r,i,s,a){const c=Sr(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*Ar(c,r,i,a);for(const e of n)l+=12*Ir(c,e);for(const e of o)l+=4*Ir(c,e);return l}function Er(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?ar(e,t,n):{x:e.x,y:e.y}}function Pr(e){const{annotations:t,context:n,defaultOffset:o=yd,notePadding:r=xd,markPadding:i=bd,edgePadding:s=wd,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Md,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:m,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof p?p:{},w=b.breakpoint??Sd,M=!!p&&w>=y,v=M&&!1!==b.preferShortText?t.map(wr):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!f?b.responsive??{minWidth:w}:f,I=M&&!m?b.cohesion:m;if(0===v.length||0>=y||0>=x)return v.slice();const A=[],C=jr(n,i);let j=!1;const N=v.map((e,t)=>{if(!vr(e))return e;const i=Er(e,t,n);if(!i)return e;const u=kr(!0===e.defensive?xr(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=mr(e);return A.push(Sr($r(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of Cr(o)){const t=Nr($r(i.x,i.y,e.dx,e.dy,u),e,A,C,y,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=Sr($r(i.x,i.y,h.dx,h.dy,u),r);A.push(p);const m=Math.hypot(h.dx,h.dy),g=c&&m>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),E=j?N:v.slice();let P=E;if(h){let e=!1;const t=E.map(t=>{const n=Mr(t);return n!==t&&(e=!0),n});P=e?t:E}{let e=!1;const t=P.map(t=>{if(!0!==t?.defensive)return t;const n=xr(t);return n!==t&&(e=!0),n});P=e?t:P}const F=/* @__PURE__ */new Set;if(k){const e="object"==typeof k?k:{},t=yr(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??hr(y,x,e))*t))},{deferred:o}=pr({annotations:P,width:y,height:x,...n});for(const e of o)F.add(e)}if(S&&("object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:Sd)>=y)for(const e of P)vr(e)&&"secondary"===e.emphasis&&F.add(e);if(F.size>0)for(const e of P)!0===e?.defensive&&F.delete(e);let z;return z=0===F.size?P:$?P.map(e=>F.has(e)?{...e,_annotationDeferred:!0}:e):P.filter(e=>!F.has(e)),I?br(z,I):z}function Fr(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function zr(e,t={}){const n=t.fuels??Cd,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=Fr(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:jd[e],mw:n,ba:t.ba})}return r}function Or(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=Fr(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Lr(e){const t=Fr(e.demand);if(0>=t)return 0;const n=Fr(e.capacityOrNetGen),o=Fr(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function Rr(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=Fr(e.demandMw),n=Fr(e.netGenMw),o=Lr({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function Tr(e={},t={}){const{watch:n,comfortable:o}={...Nd,...e},r=t.field,i=r?{field:r}:{},s=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:s,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function Wr(e={}){const{tight:t,watch:n,comfortable:o}={...Nd,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function qr(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=Fr(o.demandMw),i=Fr(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=Lr({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of Cd){const t=Fr(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function Dr(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Br(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Vr(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function Gr(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function Yr(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function Hr(e,t={}){const n=Yr(t.start,"start"),o=Yr(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new Pd;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function _r(e,t){const n=Yr(t.start,"start"),o=Yr(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(r>i)return[];const c=(i-r)/s>Math.log2(e.length+1),l=[],u=[];if(c){for(const t of e){const e=n(t),r=o(t);e>r||(l.push(e),u.push(r))}l.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0;const f=[];for(let t=r;i>=t;t+=s){let r=0;if(c){for(;l.length>d&&t>=l[d];)d++;for(;u.length>h&&(a?t>=u[h]:t>u[h]);)h++;r=d-h}else for(const i of e){const e=n(i),s=o(i);e>t||(a?t>=s:t>s)||r++}f.push({value:t,count:r})}return f}function Xr(e){return"function"==typeof e?e:t=>t[e]}function Ur(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function Kr(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function Qr(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Zr(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Jr(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function ei(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function ti(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function ni(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",s="x"===n?"width":"height",a="x"===n?"height":"width",c=/* @__PURE__ */new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[a]+d[a])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[s]+d[s])/2+o-Math.abs(h);if(0>=f)continue;const p=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-p),c.set(d.id,(c.get(d.id)??0)+p)}return c}function oi(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function ri(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Z(e,n,void 0)}function ii(e,t,n,o){const r=o.fixedAxis??"y",i=e=>Number(ri(o.fixedAccessor,"fixed")(e)),s=e=>ri(o.sourceAccessor,"source")(e)+"",a=e=>ri(o.targetAccessor,"target")(e)+"",c=o.size??(()=>zd),l=o.iterations??180,u=o.attraction??.012,d=o.anchorStrength??.003,h=o.collisionStrength??.12,f=o.collisionPadding??15,p=o.edgePadding??42,m=o.fixedPadding??16,g=o.damping??.72,y=o.spread??1,[x,b]=o.fixedDomain,w=b-x||1,M=("y"===r?n.y:n.x)+m,v=("y"===r?n.y+n.height:n.x+n.width)-m,k=("y"===r?n.x:n.y)+p,$=("y"===r?n.x+n.width:n.y+n.height)-p,S=Math.max(1,$-k),I=e.map(e=>{const t=J(e)??e,n=(r=e,ri(o.idAccessor,"id")(r)+"");var r;const{width:s,height:a}=c(t),l=i(e),u=k+oi(n)*S;return{data:t,id:n,width:s,height:a,fixedValue:l,fixed:(d=l,M+(d-x)/w*(v-M)),free:u,anchor:u};var d}),A=new Map(I.map(e=>[e.id,e])),C=e=>"y"===r?e.width:e.height;for(let e=0;l>e;e++){const e=/* @__PURE__ */new Map;for(const t of I)e.set(t.id,0);for(const n of t){const t=A.get(s(n)),o=A.get(a(n));if(!t||!o)continue;const r=(o.free-t.free)*u;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of I)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*d);const n=ni(I.map(e=>({id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===r?"x":"y",padding:f,strength:h});for(const t of I)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of I){t.free+=(e.get(t.id)??0)*g;const n=C(t)/2;t.free=Math.max(k+n,Math.min($-n,t.free))}}if(1!==y){const e=(k+$)/2;for(const t of I){const n=C(t)/2;t.free=Math.max(k+n,Math.min($-n,e+(t.free-e)*y))}}const j=I.map(e=>({data:e.data,id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:j,byId:new Map(j.map(e=>[e.id,e]))}}function si(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?le((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?le(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=le(n/c,0,1);return u+(d-u)*r}}}function ai(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function ci(e){let t=0;for(const n of e)t+=Td[n]??.6;return t}function li(e,t){return Math.max(8,ci(e)*t*1.05+1)}function ui(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}function di(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));/* @__PURE__ */ /* @__PURE__ */
81
+ return(0,Ld.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[
82
+ /* @__PURE__ */
83
+ /* @__PURE__ */(0,Ld.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);/* @__PURE__ */ /* @__PURE__ */
84
+ return(0,Ld.jsxs)("g",{children:[
85
+ /* @__PURE__ */
86
+ /* @__PURE__ */(0,Ld.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),
87
+ /* @__PURE__ */
88
+ /* @__PURE__ */(0,Ld.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Ld.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function hi(e){return null==e?void 0:e+""}function fi(e){const t=hi(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??Dd,style:{...qd,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function pi(e){return fi(e)}function mi(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...qd,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function gi(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qd,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:hi(e.id)}}function yi(e){const t=hi(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qd,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??Dd,style:{...qd,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function xi(e){const t={style:{...qd,cursor:e.cursor},datum:e.datum,id:hi(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?{type:e.type??"curved",pathD:e.pathD,...t}:{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function bi(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,a.push(e)};let u=null;for(let n=0;e.length>n;n++){const a=t(e[n],n);if(s&&!a){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,a)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),a}function wi(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Mi(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function vi(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function ki(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>vi(t(e),n,o))}function $i(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=a>c?a:c,u=Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function Si(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 Ii(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],s=e[r+1],a=[.../* @__PURE__ */new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=Si(i,e),n=Si(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function Ai(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>a;e++){const e=new Map(r.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,s>u)s=u,i=[...r];else if(u===s)break}return i}function Ci(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;s>e&&a>i;e++){let e=!1;for(let n=0;o.length-1>n&&a>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,r>s?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function ji(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,c>e&&(c=e,a=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>s;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function Ni(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,s]=t(e[r]);for(let a=r+1;e.length>a;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);0>(i-c)*(s-l)&&o++}}return o}function Ei(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,a=/* @__PURE__ */new Map;return e.forEach((e,t)=>{a.set(e.id,{id:e.id,x:i+s*t,y:o,index:t})}),a}function Pi(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Fi(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,p=/* @__PURE__ */new Map;let m=i;return c||1!==e.length||(m=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];p.set(e.id,{id:e.id,x:m+n/2,y:o,index:t,width:n}),m+=n+a+f}),p}function Fi(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function zi(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new Pd,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function Oi(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function Li(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Ri(e,t,n){return e-n.arcLift-t*n.levelStep}function Ti(e,t=Wi){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=/* @__PURE__ */new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=/* @__PURE__ */new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Wi(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}function qi(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Di(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+Vd)%Vd}function Bi(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??Vd;return e=>i+(e-n)/r*(s-i)}function Vi(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function Gi(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=qi(e,t,{center:i});return`${Yi(n)},${Yi(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=Vd-1e-6){const e=i?.x??0,t=i?.y??0,n=`${Yi(e)},${Yi(t-c)}`,o=`${Yi(e)},${Yi(t+c)}`;let r=`M${n} A${Yi(c)},${Yi(c)} 0 1 1 ${o} A${Yi(c)},${Yi(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${Yi(e)},${Yi(t-a)}`,o=`${Yi(e)},${Yi(t+a)}`;r+=` M${n} A${Yi(a)},${Yi(a)} 0 1 0 ${o} A${Yi(a)},${Yi(a)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=s(e,c),f=s(t,c);if(0>=a){const e=i?.x??0,t=i?.y??0;return`M${Yi(e)},${Yi(t)} L${h} A${Yi(c)},${Yi(c)} 0 ${d} ${u} ${f} Z`}const p=s(t,a),m=s(e,a);return`M${h} A${Yi(c)},${Yi(c)} 0 ${d} ${u} ${f} L${p} A${Yi(a)},${Yi(a)} 0 ${d} ${1===u?0:1} ${m} Z`}function Yi(e){return Math.round(1e3*e)/1e3}function Hi(e,t){return{x:e.x+t.x,y:e.y+t.y}}function _i(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Xi(e,t){return{x:e.x*t,y:e.y*t}}function Ui(e){return Math.hypot(e.x,e.y)}function Ki(e){const t=Ui(e)||1;return{x:e.x/t,y:e.y/t}}function Qi(e,t){const[n,o]=e.viewBox??Gd,[r,i]=e.anchor??Yd,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Zi(e,t){const n=Qi(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Ji(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Gd,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function es(e,t){const n=We(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function ts(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??_d,strokeWidth:2,fill:"none"}):e=>({fill:e.color??_d,stroke:e.color??_d})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??_d,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;/* @__PURE__ */ /* @__PURE__ */
89
+ return(0,Hd.jsx)("path",{d:Re(t,es(t,Xd-1)),transform:`translate(${Xd},${Xd})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??_d,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>/* @__PURE__ */ /* @__PURE__ */(0,Hd.jsx)("circle",{cx:Xd,cy:Xd,r:e.r,fill:e.color??r})})}return t}function ns(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push(
90
+ /* @__PURE__ */
91
+ /* @__PURE__ */(0,Hd.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[os(e,n,e.color??e.line??s,s),
92
+ /* @__PURE__ */
93
+ /* @__PURE__ */(0,Hd.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},"legend-"+u)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),/* @__PURE__ */ /* @__PURE__ */(0,Hd.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function os(e,t,n,o){if(e.shape){const o=es(e.shape,t/2-1);/* @__PURE__ */ /* @__PURE__ */
94
+ return(0,Hd.jsx)("path",{d:Re(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;/* @__PURE__ */ /* @__PURE__ */
95
+ return(0,Hd.jsxs)("g",{children:[
96
+ /* @__PURE__ */
97
+ /* @__PURE__ */(0,Hd.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>/* @__PURE__ */ /* @__PURE__ */(0,Hd.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),
98
+ /* @__PURE__ */
99
+ /* @__PURE__ */(0,Hd.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}/* @__PURE__ */ /* @__PURE__ */
100
+ return(0,Hd.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}function rs(e){const t=e,n=[cs(t,["datum","data"]),cs(t,["datum"]),cs(t,["data","data"]),cs(t,["data"]),cs(t,["node","datum","data"]),cs(t,["node","datum"]),e];for(const e of n){if(!ls(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function is(e,t={}){const n=rs(e);if(!n)return[];const o=new Set(Ud);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:as(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):ss(i)}),r.length>=(t.maxEntries??8)))break;return r}function ss(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function as(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function cs(e,t){let n=e;for(const e of t){if(!ls(n))return;n=n[e]}return n}function ls(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function us(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ds(e,t){return us(e,t)?e[t]:void 0}function hs(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function fs(){/* @__PURE__ */
101
+ return Object.create(null)}function ps(e,t){const n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,/* @__PURE__ */new Set);for(const e of t)n.has(e.source)||n.set(e.source,/* @__PURE__ */new Set),n.has(e.target)||n.set(e.target,/* @__PURE__ */new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function ms(e,t){const n={};for(const t of e)hs(n,t.id,0);for(const e of t)hs(n,e.source,(ds(n,e.source)??0)+1),hs(n,e.target,(ds(n,e.target)??0)+1);return n}function gs(e,t){const n={};hs(n,t,0);const o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])us(n,r)||(hs(n,r,n[t]+1),o.push(r))}return n}function ys(e,t,n,o){if(n===o)return n?[n]:[];const r=ps(e,t),i=fs();i[n]=null;const s=[n];let a=0;for(;s.length>a;){const e=s[a];if(a+=1,e===o)break;for(const t of r.get(e)||[])us(i,t)||(i[t]=e,s.push(t))}if(!us(i,o))return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function xs(e,t,n,o=1){const r=ps(e,t);if(!r.has(n))/* @__PURE__ */return new Set;const i=gs(r,n),s=/* @__PURE__ */new Set;for(const e of Object.keys(i))i[e]>o||s.add(e);return s}function bs(e,t){const n=ps(e,t),o={};for(const t of e)hs(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],i=fs(),s=fs(),a=fs();for(const t of e)i[t.id]=[],s[t.id]=0,a[t.id]=-1;s[t]=1,a[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>a[t]&&(a[t]=a[e]+1,c.push(t)),a[t]===a[e]+1&&(s[t]+=s[e],i[t].push(e))}const u=fs();for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=s[t]/s[e]*(1+u[e]);e!==t&&hs(o,e,(ds(o,e)??0)+u[e])}}for(const e of Object.keys(o))hs(o,e,o[e]/2);return o}function ws(e,t){const n=ps(e,t),o={};for(const t of e){const e=gs(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;hs(o,t.id,r>0?(i-1)/r:0)}return o}function Ms(e,t){const n=ps(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){hs(o,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);hs(o,t.id,2*i/(r*(r-1)))}return o}function vs(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))hs(n,o,t>0?e[o]/t:0);return n}function ks(e,t,n,o={}){const r=ps(e,t),i=fs();for(const t of e)i[t.id]=gs(r,t.id);let s=o.minHops??4,a=o.startThreshold??.08;const c=o.maxThreshold??.2,l=/* @__PURE__ */new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=ds(n,r),d=ds(n,c);if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=s&&a>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(a+=.02,a>c&&(a=o.startThreshold??.08,s=Math.max(2,s-1))),u+=1}return{problemIds:l,threshold:a,minHops:s}}function $s(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}function Ss(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function Is(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function As(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}function Cs(e,t,n,o,r=Qd){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}function js(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Ns(){const e="string"==typeof Zd.url&&Zd.url?new URL("./forceLayoutWorker.js",Zd.url):$s("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}function Es(e,t){return js()?eh.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}async function Ps(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260;if(!js()||!Cs(o,e.length,t.length,c,i))return Me(e,t,{...a,nodeRadius:s});const l={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{return(await Es(l,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return Me(e,t,{...a,nodeRadius:s})}}function Fs(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function zs(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function Os(e,t){return!!t?.some(t=>Object.is(e,t))}function Ls(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=zs(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!Os(n,t.oneOf)||t.notOneOf&&Os(n,t.notOneOf))}function Rs(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Ts(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],m=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(o+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:m,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}function Ws(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function qs(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function Ds(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=Ws(e,n),r=qs(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function Bs(e,t){return(t??Object.keys(e)).map(t=>Ws(e,t)).filter(qs).map(e=>({label:e.label??e.id,value:e.count}))}function Vs(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?Ws(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Gs(e,t,n){return Math.max(t,Math.min(n,e))}function Ys(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function Hs(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function _s(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Gs(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,m=Gs(d*h+p,.06*d,.5*d),g=m/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=Gs(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=Ys(k),I=a-s;let A=s;const C=k.map((e,t)=>{const n=A,o=t===k.length-1?a:A+(e.share??1)/S*I;return A=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),j=C[$],N=j.x0,E=j.x1,P=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Gs((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=Gs((e-s)/Math.max(1,N-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(E>=e)return"top"===n?y:x;const o=Gs((e-E)/Math.max(1,a-E),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},F=C.map(e=>{const t=Math.min(P(e.x0,"top"),P(e.x1,"top")),n=Math.max(P(e.x0,"bottom"),P(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:v,friction:w,restitution:M},O=[];"lane"===t?O.push(Hs(b+"-top",s,c,a,c,z),Hs(b+"-bottom",s,l,a,l,z),Hs(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Hs(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)})):"funnel"===t?O.push(Hs(b+"-top",s,c,a,y,z),Hs(b+"-bottom",s,l,a,x,z),Hs(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Hs(b+"-right",a,y,a,x,{...z,thickness:Math.max(6,v)})):O.push(Hs(b+"-left-top",s,c,N,y,z),Hs(b+"-left-bottom",s,l,N,x,z),Hs(b+"-center-top",N,y,E,y,z),Hs(b+"-center-bottom",N,x,E,x,z),Hs(b+"-right-top",E,y,a,c,z),Hs(b+"-right-bottom",E,x,a,l,z),Hs(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Hs(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)}));const L=e.membraneDampingScale??.5,R=s,T=Math.max(1,("bowtie"===t?N:a)-R),W=(e.membranes??[]).map(e=>{const t=R+Gs(e.offset,0,1)*T,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:W.map(e=>Ks({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??L,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:E,pinchHeight:m,pinchTop:y,pinchBottom:x,stages:F,membranes:W,colliders:O,regionEffects:q,boundaryY:P}}function Xs(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function Us(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Xs({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Ks(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Gs(e.cost,0,2);return{...Xs({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function Qs(e){return{...Xs({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Zs(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Xs({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Js(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Xs({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function ea(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Xs({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function ta(e){return{...Xs({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function na(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Xs({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function oa(e){return{...Xs({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function ra(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function ia(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Hs(t+"-top",e.left,e.top,e.right,e.top,n),Hs(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Hs(t+"-left",e.left,e.top,e.left,e.bottom,n),Hs(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}function sa(e,t,n){return Math.max(t,Math.min(n,e))}function aa(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=sa(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),u=sa(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+a,h=e.boundaryY(u,"bottom")-a;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function ca(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function la(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function ua(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function da(e,t,n,o,r){return"function"==typeof o?o(e,t,n):ua(e,o??r)}function ha(e){const t=Number(e.toFixed(oh));return Object.is(t,-0)?0:t}function fa(e){const t=(e??th).map(e=>{const t=la(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return ha(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function pa(e){if(Array.isArray(e)){if(e.length>nh)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${nh} points`);return Array.from(new Set(e.map(la).filter(e=>null!=e).map(ha))).sort((e,t)=>e-t)}const t=e,n=la(t.start),o=la(t.end),r=la(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>nh)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${nh} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+a)break;s.push(ha(Math.min(t,o)))}if(s.length&&a>=Math.abs(s[s.length-1]-o)||s.push(ha(o)),s.length>nh)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${nh} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}function ma(e,t,n,o){const r=e.flatMap((e,r)=>{const i=la(da(e,r,t,n,"time")),s=la(da(e,r,t,o,"value"));return null==i||null==s?[]:[{time:ha(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function ga(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}function ya(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=ga(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];return"step"!==n&&a&&a.time!==c.time?c.value+(t-c.time)/(a.time-c.time)*(a.value-c.value):c.value}function xa(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function ba(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=fa(e.quantiles),r=pa(e.sampleAt),i=e.runs.map(t=>ma(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>ya(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?xa(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?xa(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function wa(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Ma(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=la(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=ha(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function va(e,t,n){return t>e?"below":e>n?"above":"inside"}function ka(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;a.length-1>o;o+=1){const r=a[o],i=a[o+1];if(r>=i)continue;const s=(r+i)/2,d=(i-r)*n,h=va(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function $a(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=ma(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??wa(t,"lower"),a=n.upper??wa(t,"upper"),c=t.points.map(e=>{const t=ya(i,e.time,o,r),n=Ma(e,s),c=Ma(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":va(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,p=0,m=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>p&&(p=n,m=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=ka(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:p,peakDeficitAt:m}}function Sa(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Ia(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Aa(e){return!!Ia(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Ia(e.visitsByStage)&&Ia(e.firstEnteredAt)&&Ia(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function Ca(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function ja(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}function Na(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,Ca(e)]))}}function Ea(e,t,n={}){if("region-enter"!==t.type)return e;const o=ja(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=Sa(e.entities,i),a=Aa(s)?s:Ca(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=Sa(a.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,p={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:f+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:d}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:d},regressionCount:c>=0&&c>r?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:p}}}function Pa(e){const t=e.bodyIds.map(t=>{const n=Sa(e.entities,t);return Aa(n)?n:Ca(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=Sa(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function Fa(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function za(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=zs(e.datum,t),o=zs(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Oa(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function La(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(f)}function n(){X+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:f,work:e.total,queuedAt:e.queuedAt}}function r(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:f,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:v.size})}function i(e,t,o,i){const s={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,s),C.delete(e.id),A.set(e.id,t.jobId),T+=1,W+=t.work,n(),r(e,s,o),s}function s(e){if(v.size>=x||0===k.size)return;const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(v.size>=x)break;const t=I.get(n.jobId);t&&$.has(n.jobId)?(k.delete(n.jobId),C.delete(n.bodyId),i(t,n,e,n.sequence)):k.delete(n.jobId)}}function a(){let e=0;for(const t of v.values())e+=t.remaining;return e}function c(){let e=0;for(const t of k.values())e+=t.work;return e}function l(){Y=Math.max(Y,v.size),H=Math.max(H,a())}function u(){const e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);E=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);P=new Map(t.map((e,t)=>[e.bodyId,t])),F=e.length}function d(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&j.push(e);const t=O-b;for(;j.length>0&&t>j[0].end;)j.shift()}function h(){const e=O-b,t=Math.max(0,Math.min(b,O-(L??O)));let n=0,o=0,r=0,i=0,s=0;for(const t of j){if(e>t.end)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;s+=a>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/a):t.processedWork}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&p>0?Math.max(0,Math.min(1,s/(p*t))):0,pressure:p>0?a/p:0}}const f=e.regionId,p=Math.max(0,e.unitsPerSecond),m=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,j=[];let N=0,E=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map,F=0,z=0,O=0,L=null,R=0,T=0,W=0,q=0,D=0,B=0,V=0,G=0,Y=0,H=0,_=0,X=0,U=-1,K=!1;return{id:e.id??"capacity-queue:"+f,continuous:!1!==e.continuous,tick:r=>{const a=r.controls.readBodies(),c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const n of a){if(c.set(n.id,n),!t(n.id,r.getRegionState))continue;if(!Ls(n,e.bodyFilter))continue;const o=za(n,e.jobKey),i=h.get(o)??[];i.push(n),h.set(o,i)}const m=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!K){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):m;O=Math.max(0,e-m),K=!0}const g=O,y=g+m;O=y,L=null==L?g:Math.min(L,g);const b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},j=/* @__PURE__ */new Map;for(const[e,t]of h){const n=$.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];j.set(e,o),I.set(e,o)}for(const[t,i]of $){if(j.has(t))continue;const s=v.get(t),a=c.get(i.bodyId)??I.get(t);if(s){v.delete(t),A.delete(s.bodyId),V+=1,G+=s.remaining,n();const c={...o(s),abandonedAt:O,remainingWork:s.remaining,queueSeconds:Math.max(0,O-s.queuedAt)};a&&e.onAbandoned?.(a,c),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:f,work:s.total,remainingWork:s.remaining,jobId:t,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:O,queueSeconds:c.queueSeconds,queueDepth:v.size})}k.delete(t),C.delete(i.bodyId),$.delete(t),I.delete(t)}for(const[t,o]of j){if($.has(t))continue;const s=(S.get(t)??0)+1;S.set(t,s);const a=Fa(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${f}:${t}:${s}`,visit:s,regionId:f,work:a,queuedAt:O};$.set(t,c),R+=1,b.arrivals+=1,b.arrivalWork+=a;const l=N++;if(x>v.size)i(o,c,r,l);else{const i={...c,blockedAt:O,sequence:l};k.set(t,i),C.set(o.id,t),B+=1,n(),e.onBlocked?.(o,i),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:f,work:a,jobId:t,visitId:c.visitId,visit:s,queuedAt:O,blockedAt:O,queueDepth:v.size,blockedDepth:k.size})}}s(r),l();const E=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);let P=p*m;for(const t of E){if(0>=P)break;const i=Math.min(t.remaining,P);if(t.remaining-=i,P-=i,q+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),A.delete(t.bodyId),z+=1,D+=t.total,b.completions+=1,b.completedWork+=t.total;const s=Math.max(0,O-t.queuedAt);_+=s,n();const a=c.get(t.bodyId);if(!a)continue;r.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);const l={...o(t),completedAt:O,queueSeconds:s};e.onProcessed?.(a,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:f,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:O,queueSeconds:s,queueDepth:v.size})}s(r),l(),u(),d(b);const F=Math.floor(O/w);F!==U&&(U=F,n())},getSnapshot:()=>{const e=a(),t=c(),n=v.size,o=Array.from(v.values()).map(e=>Math.max(0,O-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:f,queueDepth:n,processedCount:z,unitsPerSecond:p,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:R,admittedCount:T,admittedWork:W,processedWork:q,completedWork:D,blockedCount:B,abandonedCount:V,abandonedWork:G,peakQueueDepth:Y,peakRemainingWork:H,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:Oa(o,.5),p95Seconds:Oa(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:z>0?_/z:0,window:h(),simulatedAt:O,metricRevision:X}},bodyForce:e=>{if("none"===m)return null;const t=A.get(e.body.id),n=C.get(e.body.id),o=t?v.get(t):void 0,r=n?k.get(n):void 0;if(!o&&!r)return null;const i=o?E.get(e.body.id):P.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;a.length>e;e+=1)if(a[e].id===f){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}return s?{x:((r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*g))-e.body.x)*y,y:(s.y-(i-((r?k.size:F)-1)/2)*g/Math.max(1,Math.sqrt(r?k.size:F))-e.body.y)*y*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Ra(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Ta(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=Ra(n,o.bodyForce(e)));return n}}}function Wa(e){const t=/* @__PURE__ */new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function qa(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=/* @__PURE__ */new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,s),r.set(i.id,s),d+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=n?i:s;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*a,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*a}}const u=o.get(e.body.id);if(!u||0>=a)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*a,y:(d.y-e.body.y)*a}:null}}}function Da(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):zs(e.datum,t.deadlineAccessor)??zs(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function Ba(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=/* @__PURE__ */new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!Ls(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=Da(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"!==a.state||a.deadlineAt>r||t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function Va(e){const t=/* @__PURE__ */new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&Ls(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=u.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function Ga(e,t,n){return Math.max(t,Math.min(n,e))}function Ya(e){return e.length*sh}function Ha(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function _a(e,t,n="auto"){const o=Math.max(1,Math.floor(t/sh)),r="compact"===n?Ha(e,o):"full"===n?e:Ya(e)>t?Ha(e,o):e;return{text:r,textLength:Ya(r)>t?Math.max(4,t):void 0}}function Xa(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Ua(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function Ka(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:p,midY:m,stages:g,groups:y=[]}=e,x=p-f;/* @__PURE__ */ /* @__PURE__ */
102
+ return(0,rh.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
103
+ /* @__PURE__ */
104
+ /* @__PURE__ */(0,rh.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,rh.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
105
+ /* @__PURE__ */
106
+ /* @__PURE__ */(0,rh.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),
107
+ /* @__PURE__ */
108
+ /* @__PURE__ */(0,rh.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),
109
+ /* @__PURE__ */
110
+ /* @__PURE__ */(0,rh.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),
111
+ /* @__PURE__ */
112
+ /* @__PURE__ */(0,rh.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?/* @__PURE__ */ /* @__PURE__ */(0,rh.jsx)("line",{x1:d+8,x2:h-8,y1:m,y2:m,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=Xa(e),i=ih[n],c=Math.max(12,e.width-8),l=Ga(c-8,22,88),d=_a(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,y=Ua(e),b=_a(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=_a(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;/* @__PURE__ */ /* @__PURE__ */
113
+ return(0,rh.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[
114
+ /* @__PURE__ */
115
+ /* @__PURE__ */(0,rh.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),g.length-1>t?/* @__PURE__ */ /* @__PURE__ */(0,rh.jsx)("polygon",{points:`${e.x1-2},${m-7} ${e.x1+8},${m} ${e.x1-2},${m+7}`,fill:i.accent,opacity:.85}):null,h?/* @__PURE__ */ /* @__PURE__ */(0,rh.jsxs)(rh.Fragment,{children:[
116
+ /* @__PURE__ */
117
+ /* @__PURE__ */(0,rh.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),
118
+ /* @__PURE__ */
119
+ /* @__PURE__ */(0,rh.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
120
+ /* @__PURE__ */
121
+ /* @__PURE__ */(0,rh.jsx)("title",{children:e.label}),d.text]})]}):null,w?/* @__PURE__ */ /* @__PURE__ */(0,rh.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[
122
+ /* @__PURE__ */
123
+ /* @__PURE__ */(0,rh.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,rh.jsxs)("text",{x:e.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[
124
+ /* @__PURE__ */
125
+ /* @__PURE__ */(0,rh.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=Ga(Math.max(54,Ya(e.label)+18,Ya(c)+16),54,104),u=_a(e.label,l-12,"auto"),d=_a(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
126
+ return(0,rh.jsxs)("g",{"data-group":e.id,children:[
127
+ /* @__PURE__ */
128
+ /* @__PURE__ */(0,rh.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),
129
+ /* @__PURE__ */
130
+ /* @__PURE__ */(0,rh.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[
131
+ /* @__PURE__ */
132
+ /* @__PURE__ */(0,rh.jsx)("title",{children:e.label}),u.text]}),
133
+ /* @__PURE__ */
134
+ /* @__PURE__ */(0,rh.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
135
+ /* @__PURE__ */
136
+ /* @__PURE__ */(0,rh.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function Qa(e){if(null==e){const e=ah.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Za(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}function Ja(e){const[t,n]=e.size,o=e.flow??ah.flow,r=Qa(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??ah.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??ah.chargeExtent),l=a*Math.max(0,e.projectionExtent??ah.projectionExtent),u=a*Math.max(0,e.destinationExtent??ah.destinationExtent),d=Math.max(0,a-c-u-l),h=Za(e.destinations),f=("down"===o?s.width:s.height)/h.length,p="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),m=p(0,c),g=p(c,d),y=c+d,x=p(y,u),b=p(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,a=(f-r)/2;return"down"===o?{id:e.id,label:e.label,order:t,x:s.x+n+a,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*f,centerY:x.y+x.height/2}:{id:e.id,label:e.label,order:t,x:x.x,y:s.y+n+a,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:m,apparatus:g,destinations:w,projection:b}}function ec(e,t){return e.destinations.find(e=>e.id===t)}function tc(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function nc(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:o+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:o+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:o+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:o+"-wall-right",shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function oc(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function rc(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function ic(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function sc(e,t,n){return rc(e[t])??n}function ac(e,t){return"number"==typeof e?e:e?.[t]??0}function cc(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=/* @__PURE__ */new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}function lc(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=cc(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!s&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return u}function uc(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...Rs(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...Ts({...s,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...lc({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),s&&a.push(...lc({band:s,idPrefix:s.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function dc(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(a-s)/(d-1):0,p=t.width/h,m=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?p/2:0;for(let o=0;h>o;o+=1){const a=t.x+p*(o+.5)+n;t.x+r>a||a>t.x+t.width-r||m.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return m}function hc(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=we(l),f=ac(u,"x"),p=ac(u,"y");return e.map((e,l)=>{const u=ic(t.x,e,l,sc(e,"x",0)),m=ic(t.y,e,l,sc(e,"y",0)),g=ic(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:m+(h()-.5)*p,vx:ic(s,e,l,0),vy:ic(a,e,l,0),mass:ic(i,e,l,1),spawnAt:ic(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function fc(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=Fs(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function pc(e,t,n){return rc("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}function mc(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:pc(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function gc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function yc(e,t,n="group"){const o=ms(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function xc(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{gc(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function bc(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function wc(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;gc(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function Mc(e,t,n={}){const o=(n.order??yc(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function vc(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function kc(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function $c(e,t){const n=vc(e.note)?e.note:void 0;return t?kc(e.mobileText)||kc(e.shortText)||kc(e.label)||kc(n?.mobileText)||kc(n?.shortText)||kc(n?.label)||kc(n?.title):kc(e.label)||kc(e.mobileText)||kc(e.shortText)||kc(n?.label)||kc(n?.title)}function Sc(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Ic(e,t,n){const o=Sc(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=vc(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=vc(e.lifecycle)?e.lifecycle:void 0,c=((a?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function Ac(e,t){if(!t)return e;const n=$c(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function Cc(e,t,n,o){const r=$c(e,o);if(!r)return null;const i=kc(e.id)||kc(e.key)||kc(e.pointId)||"annotation-"+(t+1),s=vc(e.provenance)?kc(e.provenance.source)||kc(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:kc(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}function jc(e,t={}){const n=Array.isArray(e)?e.filter(vc):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,s=!1!==t.preservePrimary,a=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>Ac(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:Ic(e,n,t)})).filter(e=>!!lr(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=s?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),p=[...d,...f].slice(0,Math.max(a,c)),m=new Set(p.map(e=>e.index)),g=u.filter(e=>!m.has(e.index)),y=[...l,...p.sort((e,t)=>e.index-t.index).map(e=>Ac(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>Cc(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:a,visible:y,deferred:x,calloutList:w,hidden:v}}function Nc(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function Ec(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function Pc(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function Fc(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function zc(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:Fc(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=Ec(e,t),l=Nc(t);return{family:e,props:s,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function Oc(e={}){const t=Pc(e);return zc("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Lc(e={}){const t=Pc(e);return zc("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Rc(e={}){return zc("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Tc(e={}){const t=Pc(e);return zc("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Wc(e={}){const t=Pc(e);return zc("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function qc(e={}){return zc("geo",e,{showLegend:e.showLegend??!1})}function Dc(e={}){return zc("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Bc(e,t={}){switch(e){case"line":return Oc(t);case"area":return Lc(t);case"ordinal":return Rc(t);case"scatter":return Tc(t);case"network":return Wc(t);case"geo":return qc(t);case"small-multiple":return Dc(t)}}function Vc(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var Gc,Yc,Hc,_c,Xc=Object.create,Uc=Object.defineProperty,Kc=Object.getOwnPropertyDescriptor,Qc=Object.getOwnPropertyNames,Zc=Object.getPrototypeOf,Jc=Object.prototype.hasOwnProperty,el=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Qc(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},tl=(e,t)=>{for(var n in t)Uc(e,n,{get:t[n],enumerable:!0})},nl=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Qc(t))Jc.call(e,r)||r===n||Uc(e,r,{get:()=>t[r],enumerable:!(o=Kc(t,r))||o.enumerable});return e},ol=(e,t,n)=>(n=null!=e?Xc(Zc(e)):{},nl(!t&&e&&e.__esModule?n:Uc(n,"default",{value:e,enumerable:!0}),e)),rl=el({"src/components/recipes/atlas/entityCounts.ts"(){}}),il=el({"src/components/recipes/atlas/ids.ts"(){}}),sl=el({"src/components/recipes/atlas/ledger.ts"(){il()}}),al=el({"src/components/recipes/atlas/compare.ts"(){rl(),sl()}}),cl=el({"src/components/recipes/atlas/completeness.ts"(){il()}}),ll=el({"src/components/recipes/atlas/directedGraph.ts"(){}}),ul=el({"src/components/recipes/atlas/rootedForest.ts"(){ll()}}),dl=el({"src/components/recipes/atlas/forests.ts"(){il(),ul()}}),hl=el({"src/components/recipes/atlas/types.ts"(){Gc="0.2",Yc=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],Hc=["serial-chain","fan-out","fan-in"],_c=[...Hc,"repeated-state-episode"]}}),fl=el({"src/components/recipes/atlas/motifs.ts"(){il(),hl()}}),pl=el({"src/components/recipes/atlas/prefixForest.ts"(){il()}}),ml=el({"src/components/recipes/atlas/sections.ts"(){il()}}),gl=el({"src/components/recipes/atlas/support.ts"(){}}),yl=el({"src/components/recipes/atlas/requiredPaths.ts"(){ll()}}),xl=el({"src/components/recipes/atlas/validate.ts"(){il(),hl()}}),bl={};tl(bl,{prepareNetworkAtlas:()=>V});var wl=el({"src/components/recipes/atlas/prepare.ts"(){al(),cl(),dl(),sl(),fl(),pl(),ml(),gl(),yl(),xl()}}),Ml=el({"src/components/recipes/atlas/capsules.ts"(){}}),vl=el({"src/components/recipes/atlas/profile.ts"(){rl(),al()}}),kl={};tl(kl,{assignedDenominator:()=>l,prepareMotifBraid:()=>U,ribbonSupportsRoute:()=>K});var $l,Sl=el({"src/components/recipes/atlas/braid.ts"(){Ml(),al(),gl(),il(),vl()}}),Il={};tl(Il,{DEFAULT_AREA_PER_ANNOTATION:()=>md,DEFAULT_GLYPH_ANCHOR:()=>Yd,DEFAULT_GLYPH_VIEWBOX:()=>Gd,DEFAULT_HIT_RADIUS:()=>Dd,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>au,GRID_FUEL_KEYS:()=>Cd,GRID_FUEL_LABELS:()=>jd,LayoutCache:()=>jl,SYMBOL_SEQUENCE:()=>Tl,TAU:()=>Vd,absorbRegion:()=>na,activeCountOverDomain:()=>_r,addPoints:()=>Hi,adjacencyFlowLayout:()=>Zu,adjacencyMatrix:()=>Mc,aggregateAdjacencyFlow:()=>Fo,aggregateRegionCounts:()=>Ds,allocateCells:()=>fe,analyzeNetEnsemble:()=>io,angleScale:()=>Bi,annotationBudget:()=>hr,annotationDensity:()=>pr,annotationLayout:()=>Pr,arcLayout:()=>xc,arcPath:()=>bc,arrivalReplay:()=>mc,axisFixedForceLayout:()=>Od,axisFixedForcePositions:()=>ii,balanceSnapshotsToFlows:()=>ge,bandLabel:()=>eo,betweenness:()=>bs,bfsDistances:()=>gs,bobaLayout:()=>fd,bodyGroupSpec:()=>ra,boundsOf:()=>Zn,boxEdgeAnchors:()=>Qr,buildAdjacency:()=>ps,buildTooltipEntries:()=>is,bulletLayout:()=>sd,calendarLayout:()=>ou,capacitatedRegion:()=>ea,chargeGateRegion:()=>Qs,circularLayout:()=>wc,clamp:()=>le,closeness:()=>ws,clustering:()=>Ms,collidersFromScales:()=>uc,comparePhysicsTrace:()=>$a,composePhysicsControllers:()=>Ta,computeTransitDiagramPositions:()=>pn,countPairwiseCrossings:()=>Ni,createCapacityQueueController:()=>La,createDependencyGateController:()=>Va,createPortalController:()=>Wa,createProcessJourneyLedger:()=>Na,createServiceLevelController:()=>Ba,createServiceResourcePoolController:()=>qa,cubicPath:()=>ti,cubicPoint:()=>Jr,cubicTangent:()=>ei,curvedEdgePath:()=>Ur,cyclicRangeContains:()=>vi,dagreLayout:()=>ju,degree:()=>ms,demandForecastRows:()=>Or,describePhysicsStageGeography:()=>oc,diagnoseTokenEncoding:()=>Fe,dimFor:()=>oe,egoNetwork:()=>xs,estimateLabelWidth:()=>Fi,extractTooltipDatum:()=>rs,fanOutBend:()=>Zr,flextreeLayout:()=>Cu,forceFieldRegion:()=>oa,forceLayout:()=>Me,forceLayoutAsync:()=>Ps,formatMw:()=>Vr,formatReservePct:()=>Gr,formatTooltipValue:()=>ss,galtonPegs:()=>dc,generateTokens:()=>Ee,geoAreaHitTarget:()=>mi,geoHitTarget:()=>pi,geographicDotGridLayout:()=>Au,geographicGridLayout:()=>bu,glyphExtent:()=>Zi,glyphFractionClipRect:()=>Ji,glyphPlacement:()=>Qi,gridEventAnnotations:()=>Dr,gridifyGeographicPoints:()=>It,groupBy:()=>ee,groupCompletionRows:()=>Vs,hatchFill:()=>to,hitTargetPoint:()=>fi,hitTargetRect:()=>gi,hullFromBoxes:()=>Jn,intervalLanesLayout:()=>Fd,isometricLandmarkLayout:()=>fu,isotypeBoltGlyph:()=>Yl,isotypeBusGlyph:()=>Hl,isotypeChipGlyph:()=>Gl,isotypeGhost:()=>Bl,isotypeInk:()=>ql,isotypeNetworkGlyphs:()=>Ul,isotypePaper:()=>Dl,isotypePersonGlyph:()=>Xl,isotypePersonPath:()=>_l,isotypeServerGlyph:()=>Vl,layoutChipStrip:()=>Pi,layoutSequence:()=>Ei,layoutTokenGrid:()=>Pe,legendGroupsFrom:()=>ts,legendSwatches:()=>ns,lineageDagLayout:()=>Ru,linearAxis:()=>no,makeShade:()=>ie,marimekkoLayout:()=>rd,markCallout:()=>oo,matchesHighlight:()=>ne,mean:()=>de,membraneRegion:()=>Ks,mermaidDagLayout:()=>Hu,mobileAnnotationStrategy:()=>jc,mobileAreaChartRecipe:()=>Lc,mobileBrushAlternatives:()=>Vc,mobileChartFamilyRecipe:()=>Bc,mobileGeoChartRecipe:()=>qc,mobileLineChartRecipe:()=>Oc,mobileNetworkChartRecipe:()=>Wc,mobileOrdinalChartRecipe:()=>Rc,mobileScatterplotRecipe:()=>Tc,mobileSmallMultipleRecipe:()=>Dc,motifBraidLayout:()=>Vu,mulberry32:()=>we,netEnsembleLayout:()=>Ku,networkEdgeHitTarget:()=>xi,networkHitTarget:()=>yi,nonNegativeFinite:()=>ue,normalizePoint:()=>Ki,normalizeScores:()=>vs,normalizeTokenEncoding:()=>Ie,octilinearRoute:()=>mn,offsetTransitPath:()=>gn,orderByBarycenter:()=>Ai,orderByGroupDegree:()=>yc,orderExactSmall:()=>ji,orthogonalEdgePath:()=>Kr,packBandsBySilhouette:()=>Ii,packIntervals:()=>Hr,packSpanLevels:()=>zi,packedClusterMatrix:()=>td,parallelCoordinatesLayout:()=>ld,partitionSharedEdges:()=>Ti,physicsChargePoint:()=>tc,physicsDestination:()=>ec,physicsReferenceEnvelope:()=>ba,physicsStageColliders:()=>nc,physicsStageGeography:()=>Ja,placeWithMinGap:()=>$i,pointMagnitude:()=>Ui,polarToXY:()=>qi,portalRegion:()=>ta,prepareMotifBraid:()=>Bn,prepareNetworkAtlasAsync:()=>Dn,pressureFieldRegion:()=>Js,processChrome:()=>Ka,processJourneyRows:()=>Pa,processLaneWalls:()=>ia,processStageLayout:()=>_s,processStageRegions:()=>Us,processVolumePolygons:()=>ca,proximityProblem:()=>ks,radiusScale:()=>Vi,readField:()=>Z,rectCollide:()=>ni,refineByAdjacentSwaps:()=>Ci,regionCountsToProjectionRows:()=>Bs,reserveAnnotationBands:()=>Wr,reserveMarginPct:()=>Lr,reserveSeries:()=>Rr,ringArcPath:()=>Gi,roundedEnclosure:()=>Qn,roundedTransitPath:()=>yn,routeSurfaceRegion:()=>Zs,runLengthEncode:()=>Bd,runs:()=>bi,sampleGeographicDotGrid:()=>Xt,scaleArcBand:()=>Oi,scalePoint:()=>Xi,sedimentBake:()=>fc,selectCyclicRange:()=>ki,selectIsometricLandmarks:()=>xt,shade:()=>se,shortestArcDelta:()=>Mi,shortestPath:()=>ys,signatureKey:()=>re,spanArcPath:()=>Li,spanArcPeakY:()=>Ri,spawnFromTokens:()=>hc,stackFuelSeries:()=>zr,stageTargetInVolume:()=>aa,subtractPoints:()=>_i,suggestTokenEncoding:()=>Le,summarizeOperatingPoint:()=>qr,symbolExtent:()=>We,symbolPathString:()=>Re,symbolRadius:()=>Te,thresholdBandsForReserve:()=>Tr,tightestHours:()=>Br,tokenLayer:()=>it,tokenTaskIntentToCapabilityIntents:()=>Oe,transitDiagramLayout:()=>Pu,unitize:()=>xe,unitizeRange:()=>be,unwrapDatum:()=>J,updateProcessJourney:()=>Ea,waffleLayout:()=>Nl,withAlpha:()=>he,wordTrailsLayout:()=>Wd,wordTrailsProgressiveReveal:()=>si,wrapValue:()=>wi,xyToAngle:()=>Di}),module.exports=($l=Il,nl(Uc({},"__esModule",{value:!0}),$l));var Al,Cl=require("d3-interpolate"),jl=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},Nl=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,i=n*o;if(0>=n||0>=o||0>=i)return{nodes:[]};const{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const a=(s.width-r*(o-1))/o,c=(s.height-r*(n-1))/n;if(0>=a||0>=c)return{nodes:[]};const l=(null==(u=t.categoryAccessor)?null:"function"==typeof u?u:e=>e[u])??(()=>"_default");var u;const d=pe(t.valueAccessor)??(()=>1),h=/* @__PURE__ */new Map,f=[];for(const t of e.data){const e=l(t)+"",n=Number(d(t)),o=Number.isFinite(n)?Math.max(0,n):0;h.has(e)||f.push(e),h.set(e,(h.get(e)??0)+o)}const p=Array.from(h.values()).reduce((e,t)=>e+t,0);if(0>=p)return{nodes:[]};let m;if(t.categoryOrder&&t.categoryOrder.length>0){const e=/* @__PURE__ */new Set,n=[];for(const o of t.categoryOrder)h.has(o)&&!e.has(o)&&(e.add(o),n.push(o));m=[...n,...f.filter(t=>!e.has(t))]}else m=f;if(0===m.length)return{nodes:[]};const g=m.map(e=>({cat:e,exact:(h.get(e)??0)/p*i})).map(e=>({...e,count:Math.floor(e.exact)})),y=g.reduce((e,t)=>e+t.count,0),x=g.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;i-y>e;e++)g[x[e%x.length].i].count+=1;const b="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",w="string"==typeof t.valueAccessor?t.valueAccessor:"value",M=(e,t,n)=>te(o=>{o("category",e),o("value",h.get(e)??0),o("share",(h.get(e)??0)/p),"category"!==b&&o(b,e),"value"!==w&&o(w,h.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),v=[];let k=0;for(const t of g){const i=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)v.push({type:"rect",x:s.x+k%o*(a+r),y:s.y+(n-1-Math.floor(k/o))*(c+r),w:a,h:c,style:{fill:i,stroke:"none"},datum:M(t.cat,k,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),k++}return{nodes:v}},El=1e-6,Pl=require("d3-force"),Fl=1e3,zl=80,Ol=100,Ll=require("d3-shape"),Rl={circle:Ll.symbolCircle,square:Ll.symbolSquare,triangle:Ll.symbolTriangle,diamond:Ll.symbolDiamond,star:Ll.symbolStar,cross:Ll.symbolCross,wye:Ll.symbolWye},Tl=["circle","triangle","diamond","star","square","chevron","cross","wye"],Wl=/* @__PURE__ */new Map,ql="#334155",Dl="#f8fafc",Bl="#cbd5e1",Vl={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Gl={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Yl={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},Hl={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},_l="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",Xl={viewBox:[18,40],anchor:[.5,1],parts:[{d:_l,fill:"color",stroke:"color",strokeWidth:1.4}]},Ul={server:Vl,chip:Gl,bolt:Yl,bus:Hl,person:Xl},Kl="var(--semiotic-primary, #4e79a7)",Ql="var(--semiotic-border, #d1d5db)",Zl="var(--semiotic-secondary, #9ca3af)",Jl="var(--semiotic-bg, #ffffff)",eu=new Set(Tl),tu=require("d3-interpolate"),nu=864e5,ou=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=/* @__PURE__ */new Map;let s=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const n=st(e),a=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??/* @__PURE__ */(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,tu.interpolateRgb)(u,d)(t)},f=t.gutter??2,p=t.labelInset??0,m=Math.min((n.width-p-53*f)/54,(n.height-6*f)/7);if(0>=m)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*nu),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*nu);if(o.getUTCFullYear()!==a)continue;const r=st(o),s=i.get(r),c=null==s?u:h(s);b.push({type:"rect",x:n.x+p+e*(m+f),y:n.y+t*(m+f),w:m,h:m,style:{fill:c,stroke:"none"},datum:{date:o,value:s??0}})}return{nodes:b}},ru=ol(require("react")),iu=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),su=require("react/jsx-runtime"),au={resource:32,city:64},cu=["#739b58","#83a964","#668d52","#8baa68"],lu={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},uu={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},du=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),hu=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),fu=e=>{const t=gt(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:cu,i=e.dimensions.width/2,s=(e.dimensions.height-t*o)/2+o/2,a=xt(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:s+(e.column+e.row)*(o/2)}));return{nodes:a.map(t=>{const i=ht(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??ut(e.config.terrainPalette,s)??ut(lu,s)??lu.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,ut(uu,l)??uu.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,su.jsx)(bt,{tiles:a,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??au.resource,citySize:e.config.citySpriteSize??au.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},pu={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},mu={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},gu=require("react/jsx-runtime"),yu=.72,xu=1.8,bu=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=(o?Et(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,n)=>!t.filter||t.filter(e.datum,n)),i=Ft(r.map(e=>e.datum),t),s=o?r:Pt({...e,points:r.map(e=>e.datum)}),a=i??It(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===a.length)return{nodes:[]};const c=$t(a.map(e=>e.row)),l=$t(a.map(e=>e.column)),u=Math.max(1,Math.round(c[1]-c[0])+1),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(0,t.layoutPadding??8),f=Math.max(1,e.dimensions.width-2*h)/d,p=Math.max(1,e.dimensions.height-2*h)/u,m=(e.dimensions.width-f*d)/2,g=(e.dimensions.height-p*u)/2,y=kt(t.cellPadding??.12,0,.8),x=Math.max(1,.5*Math.min(f,p)*(1-y)),b=t.sizeAccessor?a.map(e=>Number(At(e.datum,t.sizeAccessor))):[],w=t.sizeDomain??$t(b),M=t.sizeRange??[.36,1],v=kt(Math.min(M[0],M[1]),.05,1),k=kt(Math.max(M[0],M[1]),v,1),$=a.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=(At(r,t.idAccessor,["id","key","name"])??"grid-"+o)+"",s=(At(r,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",a=Math.max(1,t.maxLabelLength??4),u=s.length>a?s.slice(0,a):s,d=At(r,t.categoryAccessor),h=null==d?void 0:d+"",y=At(r,t.fillAccessor),b=null!=y?y+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",M=t.sizeAccessor?Number(At(r,t.sizeAccessor)):NaN,$=t.sizeAccessor&&Number.isFinite(M)?Math.sqrt(kt(St(M,w),0,1)):1,S=x*(v+$*(k-v)),I="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:u,category:h,row:n.row,column:n.column,x:m+(n.column-l[0]+.5)*f,y:g+(n.row-c[0]+.5)*p,radius:S,style:{fill:b,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...I}}}),S=t.shape??"circle";return{nodes:$.map(e=>{return"circle"===S?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===S?Nt(e.x,e.y,e.radius):jt([[(t=e.x)-(o=e.radius),(n=e.y)-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===S?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:/* @__PURE__ */ /* @__PURE__ */(0,gu.jsx)(zt,{marks:$,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??kt(.23*Math.min(f,p),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},wu=require("react/jsx-runtime"),Mu=10,vu=25e3,ku=/* @__PURE__ */new WeakMap,$u=/* @__PURE__ */new WeakMap,Su=/* @__PURE__ */new WeakMap,Iu=1,Au=e=>{const t=tn(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,Tt(n.dotRadius)??t.cellSize*Rt(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,u=s+(a.gridRow+.5)*t.cellSize,d=Wt(a,n.categoryAccessor),h=Wt(a,n.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},p=`dot-${a.gridRow}-${a.gridColumn}`;return"circle"===o?{type:"point",x:l,y:u,r:r,style:f,datum:a,interactive:!1,pointId:p,_transitionKey:p}:{type:"geoarea",pathData:"hexagon"===o?rn(l,u,r):on(l,u,r),centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?/* @__PURE__ */ /* @__PURE__ */(0,wu.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?/* @__PURE__ */ /* @__PURE__ */(0,wu.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},Dt(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Cu=e=>{const t=e.config,n=t.nodeWidth??80,o=t.nodeHeight??30,r=t.orientation??"vertical",i=t.edgeCurve??"curved",s=!1!==t.showLabels,a=t.labelAccessor??"id",c="function"==typeof a?a:e=>Z(e,a,e.id??"")+"",l=/* @__PURE__ */new Map,u=[],d=[],h=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:i,h:a}=h(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:a}),u.push({type:"rect",x:o-i/2,y:r-a/2,w:i,h:a,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),s&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=l.get("string"==typeof t.source?t.source:t.source.id),s=l.get(n);if(!o||!s)continue;const a="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:s.x,y:s.y-s.h/2}:{x:s.x-s.w/2,y:s.y};if("line"===i)f.push({type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(a.y+c.y)/2,o=(a.x+c.x)/2;f.push({type:"curved",pathD:"vertical"===r?`M${a.x},${a.y} C${a.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${a.x},${a.y} C${o},${a.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:f,labels:d}},ju=e=>{const t=e.config,n=t.nodeWidth??100,o=t.nodeHeight??36,r=t.edgeStyle??"polyline",i=!1!==t.showLabels,s=t.labelAccessor??"label",a="function"==typeof s?s:e=>Z(e,s,e.id??"")+"",c=/* @__PURE__ */new Map,l=[],u=[],d=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:s,h:h}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:s,h:h}),l.push({type:"rect",x:o-s/2,y:r-h/2,w:s,h:h,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:a(n)+""}),i&&u.push({x:o,y:r,text:a(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const h=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,f=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),o=c.get(e);if(!n||!o)continue;const i=t.data??{},s=Array.isArray(i.points)?i.points:t.points;if(s&&s.length>=2)if("smooth"!==r||3>s.length){const e="M"+s.map(e=>`${e.x},${e.y}`).join(" L ");f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${s[0].x},${s[0].y}`;for(let t=1;s.length-1>t;t++)e+=` Q${s[t].x},${s[t].y} ${(s[t].x+s[t+1].x)/2},${(s[t].y+s[t+1].y)/2}`;const n=s[s.length-1];e+=` T${n.x},${n.y}`,f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else f.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:h,strokeWidth:1},datum:t})}return{sceneNodes:l,sceneEdges:f,labels:u}},Nu=require("react"),Eu=e=>"number"==typeof e&&Number.isFinite(e),Pu=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:J(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),s=e.edges.map(e=>({source:bn(e.source),target:bn(e.target),data:J(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=pn(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?kn(i,s,t,e.resolveColor):void 0,l=Sn(s,t,c),u=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),d=/* @__PURE__ */new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)u.get(e)?.add(n.id),n.color&&d.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),f=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),p=/* @__PURE__ */new Map,m=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=An(n,t),c=(s.length-1)/2*(h+f)+h/2;for(const e of[n.source,n.target])p.set(e,Math.max(p.get(e)??0,c));s.forEach((c,l)=>{u.get(n.source)?.add(c.descriptor.id),u.get(n.target)?.add(c.descriptor.id);const p=Cn(c.edge,a,t,c.edge.source!==n.source),g=gn(p?[o,...p,i]:mn(o,i),(l-(s.length-1)/2)*(h+f)),y=jn(c.edge,c.descriptor),x=$n(c.descriptor,c.edge,t,e.resolveColor);d.has(c.descriptor.id)||d.set(c.descriptor.id,x),m.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:yn(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=/* @__PURE__ */new Map,y=[],x=[],b=e=>(xn(e,t)||e.id)+"";if("minimap"===n){const n=/* @__PURE__ */new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of u.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,p.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(const n of o){const o=In(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(b).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:te(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),u={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length>1?(o.forEach((t,i)=>{const a={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:-Math.PI/2+i/o.length*Math.PI*2,endAngle:-Math.PI/2+(i+1)/o.length*Math.PI*2,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(a)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})):y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&d.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})}}else for(const e of i){const o=a.positions.get(e.id);if(!o)continue;const i=In(u.get(e.id)??[],t),s=i.length>1||!0===e.data.interchange||!0===e.data.transfer,c=s?t.interchangeRadius??Math.max("primary"===n?7:5,p.get(e.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(e.id,c);const l=b(e);if(y.push({type:"circle",cx:o.x,cy:o.y,r:c,style:null!=t.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:s?"primary"===n?3:2:1.5,opacity:r(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${l}${s?", interchange":""}`,tableFields:{station:l,lines:i.join(", ")}},id:e.id,label:l}),t.renderStation){const a=t.renderStation({station:e.data,x:o.x,y:o.y,radius:c,lineIds:i,interchange:s,mode:n});null!=a&&x.push((0,Nu.createElement)("g",{key:e.id,opacity:r(e.data),style:{pointerEvents:"none"}},a))}}const w=x.length>0?(0,Nu.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:m,sceneNodes:y,overlays:w,labels:Nn(i,a.positions,u,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return M;const v=(e,t)=>({opacity:r(e.datum,t)});return{...M,restyle:v,restyleEdge:v}},Fu=require("react/jsx-runtime"),zu=require("react/jsx-runtime"),Ou={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},Lu={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Ru=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.layerAccessor??"x",r=t.rowAccessor??"y",i=t.partitionAccessor??"partition",s=t.semanticAccessor??"semantic",a=t.labelAccessor??"label",c=t.storesAccessor??"stores",l=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...Ou,...t.partitionColors},h={...Lu,...t.edgeColors},f=t.accentColor??"var(--semiotic-focus, #ffcc33)",p=t.borderColor??"var(--semiotic-border, #555)",m=t.dimOpacity??.14,g=t.edgeOpacity??.5,y=t.edgeWidth??1.25,x=t.backEdgeWidth??t.edgeWidth??1.5,b=!1!==t.showStoreChips,w=t.storeChipColor??"var(--semiotic-info, #6a8caf)",M=t.hullGroupAccessor;let v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0;const n=/* @__PURE__ */new Map;for(const r of e.nodes){const e=Math.round(Number(Z(r,o,0)));t=Math.max(t,e),n.set(e,(n.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),S=n.height/Math.max(1,k);let I=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),A=Math.min(t.nodeHeight??54,Math.max(8,S-(t.minGapY??18)));const C=t.lod&&"auto"!==t.lod?t.lod:16>I?"dot":48>I?"icon":108>I?"compact":"full";if("dot"===C){const e=Math.min(I,A,11);I=e,A=e}const j=Math.max(1,n.width-I),N=Math.max(1,n.height-A),E=Math.max(1,k-1),P=e=>n.x+I/2+(v>1?e/(v-1):.5)*j,F=e=>n.y+A/2+(e+E/2)/E*N,z=t.reachableIds?new Set(t.reachableIds):null,O=t.selectedId??null,L=e.selection,R=/* @__PURE__ */new Map,T=/* @__PURE__ */new Map,W=[],q=null==M?null:/* @__PURE__ */new Map,D=[];for(const t of e.nodes){const e=t.id,n=Number(Z(t,o,0)),l=Number(Z(t,r,0)),u=Z(t,i,"processor")+"",h=Z(t,s,"processor")+"",g=Z(t,a,e)+"",y=Rn(Z(t,c,[])),x=t.data??t,b=P(n),w=F(l);R.set(e,{cx:b,cy:w});const v=z?z.has(e):null,k=L?.isActive?L.predicate(x):null,$=null!==v?!v:null!==k&&!k;T.set(e,$);const S=null!=O&&e===O,j=$&&!S?m:1,N=Object.prototype.hasOwnProperty.call(d,u)?d[u]:d.unknown;if("dot"===C?W.push({type:"circle",cx:b,cy:w,r:I/2,style:{fill:N,opacity:j,stroke:S?f:"transparent",strokeWidth:S?2:0},datum:t,id:e,label:g}):(W.push({type:"rect",x:b-I/2,y:w-A/2,w:I,h:A,style:{fill:N,opacity:j,stroke:S?f:p,strokeWidth:S?3:1},datum:t,id:e,label:g}),D.push({id:e,cx:b,cy:w,partition:u,semantic:h,label:g,stores:y,opacity:j,selected:S,node:x})),q&&null!=M){const n=Z(t,M,null);if(null!=n){const t=n+"",o=q.get(t)??[];o.push({id:e,x:b-I/2,y:w-A/2,w:I,h:A}),q.set(t,o)}}}const B=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,o=R.get(e),r=R.get(n);if(!o||!r)continue;const i=!!Z(t,l,!1),s=Z(t,u,"internal")+"",a=T.get(e)||T.get(n)?Math.min(g,1.4*m):g,c=i?h.back:Object.prototype.hasOwnProperty.call(h,s)?h[s]:h.internal;let d;if(i){const e=o.cx,t=o.cy+A/2,n=r.cx,i=r.cy+A/2,s=Math.max(48,.28*Math.abs(e-n))+A;d=`M${e},${t} C${e},${t+s} ${n},${i+s} ${n},${i}`}else{const e=o.cx+I/2,t=o.cy,n=r.cx-I/2,i=r.cy,s=(e+n)/2;d=`M${e},${t} C${s},${t} ${s},${i} ${n},${i}`}const f={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?x:y,fill:"none",opacity:a,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};B.push(f)}const V=0===D.length?null:/* @__PURE__ */ /* @__PURE__ */(0,zu.jsx)("g",{className:"lineage-dag-glyphs",children:D.map(e=>Wn(e,{w:I,h:A,lod:C,partColors:d,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))}),G=q&&q.size>0?Ln(q,{colors:t.hullColors,padding:null==t.hullPadding?16:ue(t.hullPadding),radius:null==t.hullRadius?12:ue(t.hullRadius),fillOpacity:Tn(t.hullFillOpacity,.08),strokeOpacity:Tn(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:T,selectedId:O,dimOpacity:m}):null;return G?{sceneNodes:W,sceneEdges:B,backgrounds:G,overlays:V}:{sceneNodes:W,sceneEdges:B,overlays:V}},Tu=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Wu=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),qu={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},Du=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Bu=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Vu=e=>{const t=e.config.braid,n=e.dimensions.plot,o=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],r=t.groups.filter(e=>o.includes(e.partition)&&e.nodePath.length>0),i=[],s=[],a=[];if(0===r.length)return{sceneNodes:s,sceneEdges:i,labels:a};const c=new Set(r.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...r].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=o.map(e=>d.filter(t=>t.partition===e)),f=Xn(d),p=Vn(f.map(e=>e.depth)),m=r.map(e=>Vn(e.stepEntityCounts??[e.entityCount])),g=Vn(m),y=e=>e>0?Math.max(1,10*e/g):0,x=new Map(r.map((e,t)=>[e.id,y(m[t])])),b=n.height/o.length,{semantic:w}=e.theme,M=(e,t,n,o={})=>a.push({x:e,y:t,text:n,fill:w.text??"#333",fontSize:10,anchor:"middle",...o}),v={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},k=new Map(f.map(e=>{const t=h.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?x.get(n.id)+3:0),5));return[e.id,Vn(t,24)]})),$=Vn([...k.values()],24),S=Math.min(n.width/4,$/2+16),I=(n.width-2*S)/Math.max(p-1,1),A=e=>n.x+S+(e-1)*I,C=48+$/2,j=22+$/2,N=(e,t)=>e+C+(u.get(t)+.5)*Math.max(0,b-C-j)/l.length,E=(t,n,o,r,s)=>{const a=Du(n,r),c=Du(n,s),l=y(a),u=y(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(n.signature);i.push({type:"curved",id:o,pathD:d?Yn(t,l,u):yn(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...v,id:o,kind:"braid-track",nodeId:n.nodePath[s],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:s+1,fromCount:a,toCount:c}})};return o.forEach((e,t)=>{const o=n.y+t*b,r=h[t];if(e&&M(n.x+8,o+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;p>=e;e++)M(A(e),o+34,"Step "+e);const i=/* @__PURE__ */new Map;for(const t of f){const n=r.filter(e=>t.signatures.has(e.signature));if(0===n.length)continue;const a=A(t.depth),c=de([...t.signatures].map(e=>N(o,e))),l=Hn(n.map(e=>x.get(e.id)));i.set(t.id,new Map(n.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=k.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;s.push({type:"glyph",id:h,cx:a,cy:c,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:qu,accent:w.border??"#888",style:{fill:w.surface??"#fff"},datum:{...v,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),M(a,c+u/2+12,t.state)}for(const t of r){const n=_n(t.signature);for(let o=1;n.length>o;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset;E(1e-8>Math.abs(r.y-s.y)?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s],t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:s,sceneEdges:i,labels:a,restyle:Bu,restyleEdge:Bu}},Gu=require("react/jsx-runtime"),Yu={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},Hu=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",f=t.textColor??"var(--semiotic-text, #e6e6e6)",p=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",m=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=/* @__PURE__ */new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(Z(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(Z(e,a,0))-Number(Z(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*k)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*k:.5*v)),I=(r?$:S)/2+6,A=Math.max(1,w-2*I),C=e=>(r?n.x:n.y)+I+(x>1?(i?x-1-e:e)/(x-1)*A:A/2),j=/* @__PURE__ */new Map,N=[],E=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=C(e),a=(r?n.y:n.x)+(i+1)/(t.length+1)*M,u=r?s:a,p=r?a:s,g=Z(o,l,"rect")+"",y=Z(o,c,o.id)+"";j.set(o.id,{cx:u,cy:p,shape:g}),N.push({type:"rect",x:u-$/2,y:p-S/2,w:$,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:y,type:Yu[g]??"process",shape:g},id:o.id,label:y}),E.push(
137
+ /* @__PURE__ */
138
+ /* @__PURE__ */(0,Gu.jsxs)("g",{children:[Kn(g,u,p,$,S,d,"diamond"===g?m:h,1.5),
139
+ /* @__PURE__ */
140
+ /* @__PURE__ */(0,Gu.jsx)("text",{x:u,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:Un(y,Math.max(4,Math.floor(($-12)/7)))})]},"n-"+o.id))});const P=[];return e.edges.forEach((e,t)=>{const n="string"==typeof e.target?e.target:e.target.id,o=j.get("string"==typeof e.source?e.source:e.source.id),i=j.get(n);if(!o||!i)return;const s=r?o.cx+$/2:o.cx,a=r?o.cy:o.cy+S/2,c=r?i.cx-$/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${s},${a} C${(s+c)/2},${a} ${(s+c)/2},${l} ${c},${l}`:`M${s},${a} C${s},${(a+l)/2} ${c},${(a+l)/2} ${c},${l}`,m=Math.atan2(l-a,c-s),g=c-9*Math.cos(m),y=l-9*Math.sin(m),x=4.5*-Math.sin(m),b=4.5*Math.cos(m),w=`${c},${l} ${g+x},${y+b} ${g-x},${y-b}`,M=Z(e,u,void 0),v=(s+c)/2,k=(a+l)/2;P.push(
141
+ /* @__PURE__ */
142
+ /* @__PURE__ */(0,Gu.jsxs)("g",{children:[
143
+ /* @__PURE__ */
144
+ /* @__PURE__ */(0,Gu.jsx)("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),
145
+ /* @__PURE__ */
146
+ /* @__PURE__ */(0,Gu.jsx)("polygon",{points:w,fill:p}),"string"==typeof M&&M.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Gu.jsxs)("g",{children:[
147
+ /* @__PURE__ */
148
+ /* @__PURE__ */(0,Gu.jsx)("rect",{x:v-6.5*M.length/2-4,y:k-9,width:6.5*M.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),
149
+ /* @__PURE__ */
150
+ /* @__PURE__ */(0,Gu.jsx)("text",{x:v,y:k,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:M})]})]},"e-"+t))}),{sceneNodes:N,overlays:/* @__PURE__ */ /* @__PURE__ */(0,Gu.jsxs)("g",{className:"mermaid-dag",children:[P,E]})}},_u=require("react/jsx-runtime"),Xu=require("react/jsx-runtime"),Uu=new jl(8),Ku=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,p=t.fingerprintRounds??3,m=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,Z(t,s,"")+""))}const w=[];for(const t of e.edges){const e=ao(t.source??Z(t,o,void 0)),n=ao(t.target??Z(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,undirected:k}=fo(b,w),$=po(b,M,v,k,p),S=/* @__PURE__ */new Map;if(m)for(const e of $){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...$].sort((e,t)=>t.nodeCount-e.nodeCount));const I=[...S.entries()];I.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const A=so(b.join(",")+"|"+[...M.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),C=re([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),c,l,u,d,h,f,p,m,g,a,I.map(([e,t])=>e+":"+t.length).join(","),A]),j=Uu.getOrCompute(C,()=>mo(I,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:a,nodeDatum:y,nodeCategory:x,outAdj:M,inAdj:v})),N=e.theme.semantic||{},E=t.convergeColor??N.info??"#4c78a8",P=t.branchColor??N.warning??"#e8853a",F=t.edgeColor??N.border??"#9aa0aa",z=t.colorMode??"directedness",O={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},L=t=>"motif"===z?e.resolveColor(t.motif):"category"===z||t.directed?E:P,R=[],T=[];for(const t of j.cells){const n=t.component,o=L(n);if("full"===t.lod){for(const e of t.edges)T.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:F,strokeWidth:1,opacity:.5},datum:null});for(const n of t.nodes){const t="category"===z&&n.category?e.resolveColor(n.category):o,r={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:t,opacity:oe(n.datum,O)},datum:n.datum,id:n.id,label:Z(n.datum,i,n.id)+""};R.push(r)}}else{const e=ae({id:`motif-${n.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:n.motif,shape:ho(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:oe(e,O),stroke:F,strokeWidth:.75},datum:e,id:e.id+"",label:ho(n)};R.push(r)}}return{sceneNodes:R,sceneEdges:T,overlays:ro(j.bands,{convergeColor:E,branchColor:P,edgeColor:F,plot:n,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===z,textColor:N.text??"var(--semiotic-text, #1a1a1a)",subText:N.textSecondary??"var(--semiotic-text-secondary, #888)"})}},Qu=ol(require("react")),Zu=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:yo(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[e+"",t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,u=n.x+(n.width-l)/2,d=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),f=h/2,p=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):Z(e.datum,t.labelAccessor??"label",e.id)+"";return{id:e.id,label:o,datum:e.datum,index:n,cx:u+(n+.5)*c,cy:d+(n+.5)*c}}),m=new Map(p.map(e=>[e.id,e])),g=new Map(p.map(e=>[e.id,e.index])),y=$o(e.edges,g,t),x=Io(So(y,h,t),m,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,$=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),S=t.valueFormat??(e=>Math.round(100*e)/100+""),I=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),A=new Map(p.map(e=>[e.id,0])),C=new Map(p.map(e=>[e.id,0])),j=[],N=[],E=[];for(const n of y){const o=m.get(n.source),r=m.get(n.target);if(!o||!r)continue;A.set(o.id,(A.get(o.id)??0)+n.value),C.set(r.id,(C.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):b);const a=x.get(n.key+":source")??o.cy,l=x.get(n.key+":target")??r.cx;let h,p,g,y,v,k,$;if(n.targetIndex>n.sourceIndex){const e=[o.cx+f,a],t=[l,r.cy-f];h=[e,[t[0],e[1]],t],p=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,v=t[0]-I-4,k=e[1]-n.width/2-3,$="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-f,a],i=[l,r.cy+f];h=[e,[i[0],e[1]],i],p=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,v=i[0]+I+4,k=e[1]+n.width/2+(t.valueFontSize??10),$="start"}else{const e=u+(o.index+1)*c,t=d+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+f+2,e-i),m=Math.max(o.cy+f+2,t-i),x=[o.cx+f,a],b=[l,r.cy+f];h=[x,[s,x[1]],[s,m],[b[0],m],b],p=(s+b[0])/2,g=m,y=Math.PI,v=s-3,k=m-n.width/2-3,$="end"}const P=Mo(h,I);if(E.push({type:"curved",id:"adjacency-flow-"+n.key,label:`${o.label} to ${r.label}: ${S(n.value,n.datum)}`,pathD:P,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${S(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&N.push({x:v,y:k,text:S(n.value,n.datum),anchor:$,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(2>=e)continue;j.push(Qu.createElement("path",{key:"arrow-"+n.key,className:"semiotic-adjacency-flow-arrow",d:vo(p,g,y,Math.max(3,1.08*e),e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const P=p.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):$);return{type:"rect",id:n.id,label:n.label,x:n.cx-f,y:n.cy-f,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:C.get(n.id)??0,outgoing:A.get(n.id)??0}}}}),F=Math.max(2,t.maxLabelLength??14),z=p.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=F,n.length>o?n.slice(0,Math.max(1,o-1))+"…":n),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??M};var n,o});let O=null;if(t.showGrid??!0){const e=[];for(let t=0;p.length>=t;t+=1){const n=u+t*c,o=d+t*c;e.push(Qu.createElement("line",{key:"grid-v-"+t,x1:n,y1:d,x2:n,y2:d+l,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),Qu.createElement("line",{key:"grid-h-"+t,x1:u,y1:o,x2:u+l,y2:o,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}O=Qu.createElement(Qu.Fragment,null,...e)}return{sceneEdges:E,sceneNodes:P,labels:[...N,...z],backgrounds:O,overlays:Qu.createElement(Qu.Fragment,null,...j)}},Ju=require("react/jsx-runtime"),ed=new jl(12),td=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],p=t.shadeStrength??.72,m=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,$=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,I=$?t.headerHeight??26:0,A=S?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,j=n.x+A,N=n.y+I,E=Math.max(1,n.width-A),P=Math.max(1,n.height-I-C),F=[];for(const t of e.nodes){const e=t.data??t;F.push({id:t.id,col:Z(t,o,"—")+"",row:Z(t,r,"—")+"",sizeVal:i?Number(Z(t,i,1)):1,colorKey:s?Z(t,s,"")+"":"",symVal:a?Z(t,a,"")+"":"",shadeVal:c?zo(Z(t,c,null)):NaN,marker:!!l&&!!Z(t,l,!1),iconVal:u?Z(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===F.length)return{sceneNodes:[]};let z=1/0,O=-1/0;if(i)for(const e of F)Number.isFinite(e.sizeVal)&&(z>e.sizeVal&&(z=e.sizeVal),e.sizeVal>O&&(O=e.sizeVal));t.sizeDomain&&([z,O]=t.sizeDomain),Number.isFinite(z)&&Number.isFinite(O)||(z=0,O=1);const L=e=>{if(z>=O)return(h+f)/2;const t=Math.sqrt(Oo((e-z)/(O-z),0,1));return h+t*(f-h)};let R=1/0,T=-1/0;if(c)for(const e of F)Number.isFinite(e.shadeVal)&&(R>e.shadeVal&&(R=e.shadeVal),e.shadeVal>T&&(T=e.shadeVal));t.shadeDomain&&([R,T]=t.shadeDomain);const W=e=>{if(!c||!Number.isFinite(e)||R>=T)return.5;const t=Oo((e-R)/(T-R),0,1);return m?1-t:t},q=t.colorMap,D=/* @__PURE__ */new Map,B=(t,n)=>{let o=D.get(t);return o||(o=ie(q&&Object.prototype.hasOwnProperty.call(q,t)&&"string"==typeof q[t]&&q[t]?q[t]:e.resolveColor(t),p),D.set(t,o)),o(n)},V=/* @__PURE__ */new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))V.set(e,n);let G=0;const Y=e=>{if(!a)return d;let t=V.get(e);return t||(t=Tl[G%Tl.length],G++,V.set(e,t)),t},H=t.iconMap,_=e=>u&&H&&Object.prototype.hasOwnProperty.call(H,e)?H[e]??null:null,X=e=>u?"circle":Y(e.symVal),U=t.maxAreaFraction??.4;let K=0;const Q=Array(F.length),J=Array(F.length);for(let e=0;F.length>e;e++){const t=F[e],n=L(t.sizeVal);Q[e]=n,t.baseShape=X(t),t.iconShape=_(t.iconVal);const o=We(t.baseShape,Math.PI*n*n);J[e]=o,K+=Math.PI*o*o}const ee=U*E*P,te=K>ee?Math.sqrt(ee/K):1;for(let e=0;F.length>e;e++){const t=F[e],n=Q[e]*te;t.size=Math.PI*n*n,t.packR=J[e]*te}const ne=/* @__PURE__ */new Map,se=/* @__PURE__ */new Map;for(const e of F)ne.set(e.col,(ne.get(e.col)??0)+1),se.set(e.row,(se.get(e.row)??0)+1);const ae=t.columnOrder?.filter(e=>ne.has(e))??[...ne.keys()].sort((e,t)=>(ne.get(t)??0)-(ne.get(e)??0)),ce=t.rowOrder?.filter(e=>se.has(e))??[...se.keys()].sort((e,t)=>(se.get(t)??0)-(se.get(e)??0)),le=re([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),I,A,C,g,y,x,b,w,M,v,h,f,z,O,U,ae.join(","),ce.join(","),F.length,Wo(F)]),ue=ed.getOrCompute(le,()=>Ro(F,{columnOrder:ae,rowOrder:ce,innerX:j,innerY:N,innerW:E,innerH:P,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),de=e.selection,he=de?.isActive?de.predicate:null,fe=t.highlight??null,pe=t.dimOpacity??.16,me=t.markStroke,ge=t.markStrokeWidth??0,ye=t.markerColor??"#ffffff",xe=t.iconColor??"rgba(255,255,255,0.92)",be=t.iconStrokeWidth??1,we=t.iconScale??.72,Me=[],ve=[],ke=[];for(const e of F){const t=ue.positions.get(e.id);if(!t)continue;const n=oe(e.datum,{highlight:fe,predicate:he,dimOpacity:pe}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:B(e.colorKey,W(e.shadeVal)),opacity:n,...me?{stroke:me,strokeWidth:ge}:{}},datum:e.datum,id:e.id,label:e.id+""};if(Me.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*we,r=We(e.iconShape,100);ke.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>pe+.001&&ve.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const $e=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(C>0?.45*C:9),r=[];for(let e=0;t.callouts.length>e;e++){const n=t.callouts[e],o=F.find(e=>e.datum[n.field]+""==n.value+"");if(!o)continue;const i=ue.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=/* @__PURE__ */new Map;i.forEach((e,t)=>{s.set(e.ci,j+(t+.5)/i.length*E)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),$e.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}return{sceneNodes:Me,overlays:qo(ue,{markerDots:ve,markerColor:ye,iconMarks:ke,iconColor:xe,iconStrokeWidth:be,callouts:$e,plot:n,showEnclosures:k,showColumnHeaders:$,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*I,labelX:n.x+A-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel})}},nd=4,od=ol(require("react")),rd=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=Q(t.categoryAccessor),r=Q(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>te(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),d=!1!==t.showCategoryLabels,h=Math.max(0,n.height-(t.labelPadding??(d?22:0))),f=[],p=/* @__PURE__ */new Map,m=[],g=/* @__PURE__ */new Set,y=/* @__PURE__ */new Map;for(const t of e.data){const e=o(t)+"",n=r(t)+"",s=i(t);p.has(e)||(f.push(e),p.set(e,0),y.set(e,/* @__PURE__ */new Map)),g.has(n)||(g.add(n),m.push(n)),p.set(e,(p.get(e)??0)+s);const a=y.get(e);a.set(n,(a.get(n)??0)+s)}const x=t.categoryOrder?Bo(t.categoryOrder,f,e=>p.has(e)):f,b=t.stackOrder?Bo(t.stackOrder,m,()=>!0):m,w=x.reduce((e,t)=>e+(p.get(t)??0),0);if(0>=w)return{nodes:[]};const M=Math.max(0,n.width-s*Math.max(0,x.length-1)),v=[],k=[];let $=n.x;for(const t of x){const o=p.get(t)??0,r=o/w*M;if(0>=r)continue;k.push({cat:t,x:$,w:r});const i=y.get(t);let a=n.y;for(const n of b){const s=i.get(n)??0;if(0>=s)continue;const c=s/o*h;v.push({type:"rect",x:$,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,s),group:n}),a+=c}$+=r+s}return{nodes:v,overlays:d&&k.length>0?Do(k,n.y+h+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}},id=ol(require("react")),sd=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=t.rowHeight??28,r=t.rowGap??12,i=!1!==t.showLabels,s=i?t.labelWidth??120:0,a=!1!==t.showTicks,c=a?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+s,d=Math.max(0,n.width-s);if(0>=d)return{nodes:[]};const h=Q(t.categoryAccessor),f=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},p=e=>f("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),m=e=>f("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),g=e=>{const n="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(n)?n.map(f).sort((e,t)=>e-t):[]},y="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",x="string"==typeof t.valueAccessor?t.valueAccessor:"value",b="string"==typeof t.targetAccessor?t.targetAccessor:"target",w=t.actualColor??e.theme.semantic.primary??"#3b6cb1",M=e.theme.semantic.text??"currentColor",v=t.targetColor??`var(--semiotic-text, ${M})`,k=[`var(--semiotic-surface, ${e.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${e.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${e.theme.semantic.border??"#a3a8af"})`],$=`var(--semiotic-text, ${M})`,S=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,I=[],A=[];for(let t=0;e.data.length>t;t++){const i=e.data[t],s=g(i),a=p(i),l=m(i),f=Math.max(a,l,...s.length?s:[0]);if(0>=f)continue;const M=n.y+t*(o+r+c);if(M+o+c>n.y+n.height)break;A.push({yTop:M,label:h(i),actual:a,target:l,maxVal:f});const $=e=>u+e/f*d,S=h(i),C=e=>te(t=>{t("metric",S),"metric"!==y&&t(y,S),e(t)});let j=u;for(let e=0;s.length>e;e++){const t=$(s[e]),n=t-j;n>0&&I.push({type:"rect",x:j,y:M,w:n,h:o,style:{fill:k[Math.min(e,k.length-1)],stroke:"none"},datum:C(t=>{t("range",e),t("rangeValue",s[e]),t("kind","range")}),group:"range-"+e}),j=t}const N=Math.max(6,Math.floor(.45*o));I.push({type:"rect",x:u,y:M+(o-N)/2,w:$(a)-u,h:N,style:{fill:w,stroke:"none"},datum:C(e=>{e("value",a),e("kind","actual"),"value"!==x&&e(x,a)}),group:"actual"});const E=3,P=Math.floor(.8*o);I.push({type:"rect",x:$(l)-E/2,y:M+(o-P)/2,w:E,h:P,style:{fill:v,stroke:"none"},datum:C(e=>{e("target",l),e("kind","target"),"target"!==b&&e(b,l)}),group:"target"})}const C=[];for(let e=0;A.length>e;e++){const t=A[e];if(i&&C.push(eo({keyId:"bullet-label-"+e,text:t.label,x:n.x+s-8,y:t.yTop+o/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:$})),a){const n=5,r=t.yTop+o+2;for(let o=0;n>o;o++){const i=t.maxVal*o/(n-1),s=u+i/t.maxVal*d;C.push(id.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:s,x2:s,y1:r,y2:r+3,stroke:S,strokeWidth:1}),eo({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:s,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:S}))}}}return{nodes:I,overlays:C.length>0?id.createElement(id.Fragment,null,...C):null}},ad=ol(require("react")),cd=require("d3-scale"),ld=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=/* @__PURE__ */Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,cd.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",p=t.dimmedOpacity??.08,m=t.highlightFn,g=[],y=[];for(const n of e.data){const r=u?e.resolveColor(u(n)+""):f,i=!m||m(n),s=oe(n,{predicate:m,baseOpacity:d,dimOpacity:p,brighten:.4}),a=i?y:g;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:m&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+s,f=n.y+n.height-a,p=[];for(let e=0;o.length>e;e++){const a=o[e],m=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();p.push(ad.createElement("line",{key:"pc-axis-line-"+e,x1:m,x2:m,y1:h,y2:f,stroke:i,strokeWidth:1})),p.push(eo({keyId:"pc-axis-label-"+e,text:a,x:m,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=r[a],w=5;for(let t=0;w>t;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);p.push(ad.createElement("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:o,y2:o,stroke:i,strokeWidth:1}),eo({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:m+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=ad.createElement(ad.Fragment,null,...p)}return{nodes:g.concat(y),overlays:x}},ud=require("react/jsx-runtime"),dd=1.75,hd="#222222",fd=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=Q(t.categoryAccessor??"name"),r=Q(t.teaVolumeAccessor??"teaVolume"),i=Q(t.bobaVolumeAccessor??"bobaVolume"),s=Q(t.iceVolumeAccessor??"iceVolume"),a=Q(t.cupHeightAccessor??"cupHeight"),c=Q(t.cupTopRadiusAccessor??"cupTopRadius"),l=Q(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=Q(t.bobaRadiusAccessor??"bobaRadius"),d=t.cupWidthRatio??.82,h=e.scales.o,f=h.bandwidth(),p=Math.max(1,n.height-26-8),m=n.y+8,g=[],y=[];for(const t of e.data){const n=o(t)+"",x=h(n);if(null==x)continue;const b={height:Zo(a(t),15.5),topRadius:Zo(c(t),4.75),bottomRadius:Zo(l(t),3.75)},w=Zo(u(t),.6),M=Math.max(0,Zo(r(t),450)),v=Math.max(0,Zo(i(t),110)),k=Math.max(0,Zo(s(t),135)),$=Math.PI*w*w,S=Math.floor(v/$),I=S*$,A=Math.floor(k/5.359375),C=A*dd*dd*dd,j=M+I+C,N=Ho(b,j),E=Math.min(b.height,Math.max(0,N)),P=Go(b,E),{pearls:F,layers:z}=Uo(b,w,S),O=E,L=Qo(b,z*w*2,O,A),R=b.height-20.32,T=Math.min(0,R),W=Math.min(f*d/(2*(b.topRadius+1)),p/(b.height-T)),q=x+f/2,D=e=>q+e*W,B=e=>m+(e-T)*W,V=D(-(b.topRadius+1)),G=D(b.topRadius+1),Y=B(T),H=B(b.height),_=ae({name:n,teaVolume:M,bobaVolume:Math.round(I),iceVolume:Math.round(C),totalVolume:Math.round(j),numBobas:S,numIce:A,kind:"boba cup"});g.push({type:"rect",x:V,y:Y,w:Math.max(1,G-V),h:Math.max(1,H-Y),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:_,group:n,_transitionKey:"boba-"+ce(n)});const X=b.height-O,U=ce(n),K=e.resolveColor(n);y.push(
151
+ /* @__PURE__ */
152
+ /* @__PURE__ */(0,ud.jsxs)("g",{children:[M>0?/* @__PURE__ */ /* @__PURE__ */(0,ud.jsx)("path",{d:`M${D(-P)},${B(X)} L${D(-b.bottomRadius)},${B(b.height)} L${D(b.bottomRadius)},${B(b.height)} L${D(P)},${B(X)} z`,fill:"#D2B799"}):null,F.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,ud.jsx)("circle",{cx:D(e.x),cy:B(e.z),r:w*W,fill:"#222222",opacity:.5},"p-"+t)),L.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,ud.jsx)("rect",{x:D(e.cx)-.95*dd*W/2,y:B(e.cy)-.95*dd*W/2,width:.95*dd*W,height:.95*dd*W,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${D(e.cx)} ${B(e.cy)})`},"i-"+t)),
153
+ /* @__PURE__ */
154
+ /* @__PURE__ */(0,ud.jsx)("path",{d:`M${D(-b.topRadius)},${B(0)} L${D(-b.bottomRadius)},${B(b.height)} L${D(b.bottomRadius)},${B(b.height)} L${D(b.topRadius)},${B(0)}`,fill:"none",stroke:hd,strokeWidth:2.5}),
155
+ /* @__PURE__ */
156
+ /* @__PURE__ */(0,ud.jsx)("line",{x1:D(-(b.topRadius+1)),y1:B(0),x2:D(b.topRadius+1),y2:B(0),stroke:hd,strokeWidth:3,strokeLinecap:"round"}),M>0?/* @__PURE__ */ /* @__PURE__ */(0,ud.jsx)("path",{d:`M${D(-.635)},${B(R)} L${D(-.635)},${B(b.height-.4)} L${D(.635)},${B(b.height-1.27-.4)} L${D(.635)},${B(R)} z`,fill:"#4F91CB",stroke:hd,strokeWidth:1,opacity:.78}):null,
157
+ /* @__PURE__ */
158
+ /* @__PURE__ */(0,ud.jsx)("text",{x:q,y:H+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),
159
+ /* @__PURE__ */
160
+ /* @__PURE__ */(0,ud.jsx)("text",{x:q,y:H+30,textAnchor:"middle",fontSize:10,fill:K,children:`${S} pearls · ${Math.round(j)} cm³`})]},"boba-"+U))}return{nodes:g,overlays:/* @__PURE__ */ /* @__PURE__ */(0,ud.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},pd=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),md=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),gd=1,yd=32,xd=6,bd=4,wd=8,Md=72,vd=30,kd=-30,$d=8,Sd=480,Id=3,Ad={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},Cd=["naturalGas","coal","nuclear","hydro","wind","solar","other"],jd={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},Nd={tight:5,watch:12,comfortable:20},Ed=ol(require("react")),Pd=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]>e)n=this.count++,n===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,this.tree[t]>e&&t++;n=t-this.capacity}let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return n>=t||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},Fd=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=Xr(t.laneAccessor),r=Xr(t.startAccessor),i=Xr(t.endAccessor),s=t.idAccessor?Xr(t.idAccessor):null,a=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,p=t.bottomInset??0,m=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-p)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+a)),S=[];M.forEach((t,r)=>{const i=n.y+r*v,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:p}=Hr(a,{start:k,end:$}),g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/p,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),a=$(e)-o;S.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:m(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?s(e)+"":void 0})}});const I=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,j=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+a)-o);j.push(Ed.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&j.push(eo({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:A}))});const N=!1!==t.showLaneLabels,E=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;j.push(Ed.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),N&&j.push(eo({keyId:"lane-label-"+t,text:e,x:n.x-E,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:I}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));j.push(no({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:A}))}return{nodes:S,overlays:Ed.createElement(Ed.Fragment,null,...j)}},zd={width:60,height:34},Od=e=>{const{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=ii(e.nodes,e.edges,t,e.config),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[],a=t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):Z(t,e.config.targetAccessor??"target",void 0))+"";e.edges.forEach((t,o)=>{const i=r.get((c=t,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(c):Z(c,e.config.sourceAccessor??"source",void 0))+""));var c;const l=r.get(a(t));if(!i||!l)return;const{from:u,to:d}=Qr({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:l.x,cy:l.y,width:l.width,height:l.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:Ur(u,d,{orientation:"y"===n?"vertical":"horizontal",bend:Zr(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:J(t)??t})});const c=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:c}},Ld=require("react/jsx-runtime"),Rd=1.15,Td={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278},Wd=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=Q(t.textAccessor),r=e=>{const n=Number(Q(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},i=Q(t.columnAccessor),s=e=>Number(Q(t.segmentAccessor)(e)),a=t.minFontSize??11,c=t.maxFontSize??42,l=t.columnGutter??18,u=t.collisionPadding??2,d=!1!==t.showColumnLabels,h=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,p=t.segmentTickFormat??(e=>Math.round(e)+""),m=t.rotate??0,g=!0===t.repeatWords,y=!1!==t.scaleToFit,x=t.packingDensity??.6,b="string"==typeof t.textAccessor?t.textAccessor:"word",w="string"==typeof t.weightAccessor?t.weightAccessor:"weight",M="string"==typeof t.columnAccessor?t.columnAccessor:"column",v="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",k=[],$=/* @__PURE__ */new Map;let S=1/0,I=-1/0;for(let t=0;e.data.length>t;t++){const n=e.data[t],a=i(n)+"",c=o(n)+"",l=r(n),u=s(n);c&&Number.isFinite(u)&&($.has(a)||(k.push(a),$.set(a,[])),$.get(a).push({col:a,text:c,weight:l,segment:u,datum:n,dataIndex:t}),S>u&&(S=u),u>I&&(I=u))}if(0===k.length)return{nodes:[]};if(!g)for(const[e,t]of $){const n=/* @__PURE__ */new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}$.set(e,[...n.values()])}let A=1/0,C=-1/0;for(const e of $.values())for(const t of e)A>t.weight&&(A=t.weight),t.weight>C&&(C=t.weight);if(!Number.isFinite(A))return{nodes:[]};const j=t.columnOrder?[...t.columnOrder.filter(e=>$.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,N=new Map(j.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[E,P]=t.segmentDomain??[S,I],F=P-E||1,z=C-A||1,O=d?22:0,L=h?52:0,R=n.x+L,T=n.y+O,W=Math.max(0,n.width-L),q=Math.max(0,n.height-O),D=j.length,B=D>0?Math.max(0,W-l*Math.max(0,D-1))/D:0,V=T+14,G=T+q-14,Y=e=>V+(e-E)/F*(G-V),H=B*q;let _=1/0,X=1/0;const U=j.map((e,n)=>{const o=N.get(e),r=($.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:n,resolvedColumnColor:o},i=t.wordOpacity?Number(t.wordOpacity(r)):1,s=t.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(l=e.weight,a+Math.sqrt((l-A)/z)*(c-a)),opacity:Number.isFinite(i)?le(i,0,1):0,color:s||o,info:r};var l});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*ci(e.text);i+=t*Rd*e.baseFont*e.baseFont,X=Math.min(X,(B-8-1)/(t*e.baseFont))}return i>0&&(_=Math.min(_,Math.sqrt(x*H/i))),{col:e,colLeft:R+n*(B+l),center:R+n*(B+l)+B/2,rows:r}}).filter(e=>null!==e),K=e=>{const t=[];let n=0;for(const o of U){if(0>=B)continue;const r=o.colLeft+4,i=o.colLeft+B-4,s=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:li(t.text,r),h:r*Rd+2,anchorY:Y(t.segment),seed:(ai(i)-.5)*Math.min(.5*B,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),a=[];for(const e of s){const s=e.w/2,c=e.h/2,l=le(o.center+e.seed,r+s,i-s),d=e.anchorY;let h=l,f=le(d,V+c,G-c),p=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,m={x:le(l+n*Math.cos(o),r+s,i-s),y:le(d+n*Math.sin(o),V+c,G-c),w:e.w,h:e.h};if(!ui(m,a,u)){h=m.x,f=m.y,p=!0;break}}p||n++,a.push({x:h,y:f,w:e.w,h:e.h});const g=Math.sqrt((e.weight-A)/z),y=m>0?2*(ai(e.id+"r")-.5)*m:0;t.push({id:e.id,text:e.text,x:h,y:f,fontSize:e.font,rotation:y,color:e.color,opacity:e.opacity,datum:te(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==b&&t(b,e.text),"weight"!==w&&t(w,e.weight),"column"!==M&&t(M,o.col),"segment"!==v&&t(v,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:n}};let Z=y?Math.min(1,_,X):Math.min(1,X),J=K(Z);if(y)for(let e=0;6>e&&J.unplaced>0&&Z>.1;e++)Z*=.88,J=K(Z);const ee=J.placed.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{const t=li(e.text,e.fontSize)/2,n=e.fontSize*Rd/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,Ld.jsxs)("g",{className:"semiotic-word-trails",children:[h&&di({x:n.x+L-10,yTop:V,yBot:G,segLo:E,segHi:P,segToY:Y,tickCount:f,tickFormat:p,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),d&&j.map((e,t)=>B>0?/* @__PURE__ */ /* @__PURE__ */(0,Ld.jsx)("text",{x:R+t*(B+l)+B/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:N.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ee.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,Ld.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}},qd={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Dd=8,Bd=bi,Vd=2*Math.PI,Gd=[40,40],Yd=[.5,.5],Hd=require("react/jsx-runtime"),_d="var(--semiotic-text, currentColor)",Xd=8,Ud=/* @__PURE__ */new Set(["rows"]),Kd=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(Ss(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(Ss(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Qd=4e4,Zd={},Jd=class{constructor(e=Ns()){this.session=new Kd({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=As(t);return o?{requestId:n,ok:!1,error:Is(o)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},eh=function(){let e=null;return{get:()=>(e&&!e.isDead||(e=new Jd),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),th=[.1,.5,.9],nh=1e6,oh=12,rh=require("react/jsx-runtime"),ih={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},sh=6.2,ah={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1};