@legionworks/facet 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/LICENSE-MIT +23 -0
  3. package/README.md +158 -0
  4. package/dist/gallery/chunk-4g8rem85.css +656 -0
  5. package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
  6. package/dist/gallery/frame/artifact.css +8424 -0
  7. package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
  8. package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
  9. package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
  10. package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
  11. package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
  12. package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
  13. package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
  14. package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
  15. package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
  16. package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
  17. package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
  18. package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
  19. package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
  20. package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
  21. package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
  22. package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
  23. package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
  24. package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
  25. package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
  26. package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
  27. package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
  28. package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
  29. package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
  30. package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
  31. package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
  32. package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
  33. package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
  34. package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
  35. package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
  36. package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
  37. package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
  38. package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
  39. package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
  40. package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
  41. package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
  42. package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
  43. package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
  44. package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
  45. package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
  46. package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
  47. package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
  48. package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
  49. package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
  50. package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
  51. package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
  52. package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
  53. package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
  54. package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
  55. package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
  56. package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
  57. package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
  58. package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
  59. package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
  60. package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
  61. package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
  62. package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
  63. package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
  64. package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
  65. package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
  66. package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
  67. package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
  68. package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
  69. package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
  70. package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
  71. package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
  72. package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
  73. package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
  74. package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
  75. package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
  76. package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
  77. package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
  78. package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
  79. package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
  80. package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
  81. package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
  82. package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
  83. package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
  84. package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
  85. package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
  86. package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
  87. package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
  88. package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
  89. package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
  90. package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
  91. package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
  92. package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
  93. package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
  94. package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
  95. package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
  96. package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
  97. package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
  98. package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
  99. package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
  100. package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
  101. package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
  102. package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
  103. package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
  104. package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
  105. package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
  106. package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
  107. package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
  108. package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
  109. package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
  110. package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
  111. package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
  112. package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
  113. package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
  114. package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
  115. package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
  116. package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
  117. package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
  118. package/dist/gallery/frame/frame.css +183 -0
  119. package/dist/gallery/frame/runtime/chart.js +42744 -0
  120. package/dist/gallery/frame/runtime/html.js +14 -0
  121. package/dist/gallery/frame/runtime/markdown.js +1403 -0
  122. package/dist/gallery/frame/runtime/mermaid.js +32 -0
  123. package/dist/gallery/frame/runtime/svg.js +14 -0
  124. package/dist/gallery/frame/runtime/tsx.js +52 -0
  125. package/dist/gallery/index.html +104 -0
  126. package/docs/reference/cli.md +163 -0
  127. package/docs/reference/export.md +106 -0
  128. package/docs/reference/html.md +215 -0
  129. package/docs/reference/http.md +85 -0
  130. package/docs/reference/mcp.md +78 -0
  131. package/docs/reference/security.md +119 -0
  132. package/docs/reference/storage.md +93 -0
  133. package/docs/reference/tsx.md +101 -0
  134. package/docs/reference/validation.md +212 -0
  135. package/package.json +89 -0
  136. package/scripts/build-gallery.ts +127 -0
  137. package/scripts/launch-netns.sh +67 -0
  138. package/skills/facet/SKILL.md +100 -0
  139. package/src/cli/client.ts +311 -0
  140. package/src/cli/commands/create.ts +49 -0
  141. package/src/cli/commands/doctor.ts +249 -0
  142. package/src/cli/commands/export.ts +179 -0
  143. package/src/cli/commands/instantiate.ts +35 -0
  144. package/src/cli/commands/list.ts +49 -0
  145. package/src/cli/commands/open.ts +75 -0
  146. package/src/cli/commands/pin.ts +39 -0
  147. package/src/cli/commands/promote.ts +49 -0
  148. package/src/cli/commands/publish.ts +122 -0
  149. package/src/cli/commands/read-back.ts +56 -0
  150. package/src/cli/commands/status.ts +114 -0
  151. package/src/cli/commands/watch.ts +146 -0
  152. package/src/cli/main.ts +522 -0
  153. package/src/cli/output.ts +106 -0
  154. package/src/cli/parser.ts +376 -0
  155. package/src/cli/presenter.ts +212 -0
  156. package/src/cli/service-metadata.ts +134 -0
  157. package/src/cli/spawn-service.ts +326 -0
  158. package/src/css.d.ts +4 -0
  159. package/src/gallery-web/app.ts +1581 -0
  160. package/src/gallery-web/export-menu.ts +121 -0
  161. package/src/gallery-web/export.ts +112 -0
  162. package/src/gallery-web/favicon.ts +54 -0
  163. package/src/gallery-web/frame/entries/chart.ts +6 -0
  164. package/src/gallery-web/frame/entries/html.ts +6 -0
  165. package/src/gallery-web/frame/entries/markdown.ts +6 -0
  166. package/src/gallery-web/frame/entries/mermaid.ts +6 -0
  167. package/src/gallery-web/frame/entries/svg.ts +6 -0
  168. package/src/gallery-web/frame/entries/tsx.ts +6 -0
  169. package/src/gallery-web/frame/frame-payload.ts +91 -0
  170. package/src/gallery-web/frame/renderer-validation.ts +13 -0
  171. package/src/gallery-web/frame/renderers/chart.ts +182 -0
  172. package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
  173. package/src/gallery-web/frame/renderers/html.ts +48 -0
  174. package/src/gallery-web/frame/renderers/markdown.ts +81 -0
  175. package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
  176. package/src/gallery-web/frame/renderers/registry.ts +260 -0
  177. package/src/gallery-web/frame/renderers/svg.ts +393 -0
  178. package/src/gallery-web/frame/renderers/tsx.ts +61 -0
  179. package/src/gallery-web/frame/runtime.ts +501 -0
  180. package/src/gallery-web/frame/styles/artifact.css +8424 -0
  181. package/src/gallery-web/frame/styles/frame.css +183 -0
  182. package/src/gallery-web/frame/styles/html-source.css +23 -0
  183. package/src/gallery-web/frame/view-box.ts +33 -0
  184. package/src/gallery-web/frame-html.ts +72 -0
  185. package/src/gallery-web/index.html +104 -0
  186. package/src/gallery-web/session.ts +107 -0
  187. package/src/gallery-web/sse-client.ts +212 -0
  188. package/src/gallery-web/styles/app.css +420 -0
  189. package/src/gallery-web/styles/tokens.css +112 -0
  190. package/src/gallery-web/styles/verdict.css +186 -0
  191. package/src/gallery-web/swap.ts +64 -0
  192. package/src/gallery-web/theme.ts +40 -0
  193. package/src/gallery-web/view-state.ts +93 -0
  194. package/src/harness-adapters/claude-code/README.md +10 -0
  195. package/src/harness-adapters/claude-code/facet.sh +4 -0
  196. package/src/harness-adapters/codex/README.md +10 -0
  197. package/src/harness-adapters/codex/facet.sh +4 -0
  198. package/src/harness-adapters/mcp/README.md +13 -0
  199. package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
  200. package/src/harness-adapters/mcp/main.ts +15 -0
  201. package/src/harness-adapters/mcp/server.ts +164 -0
  202. package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
  203. package/src/harness-adapters/opencode/README.md +10 -0
  204. package/src/harness-adapters/opencode/facet.sh +4 -0
  205. package/src/runtime/compiled-entrypoints.ts +69 -0
  206. package/src/service/dispatcher.ts +717 -0
  207. package/src/service/export.ts +218 -0
  208. package/src/service/http-utils.ts +55 -0
  209. package/src/service/lexical/expectations.ts +210 -0
  210. package/src/service/lifecycle/idle-controller.ts +125 -0
  211. package/src/service/lifecycle/orphan-cleanup.ts +128 -0
  212. package/src/service/lifecycle/process-lock.ts +235 -0
  213. package/src/service/main.ts +136 -0
  214. package/src/service/process.ts +240 -0
  215. package/src/service/router-guards.ts +239 -0
  216. package/src/service/router.ts +627 -0
  217. package/src/service/security/auth.ts +168 -0
  218. package/src/service/security/host-origin.ts +138 -0
  219. package/src/service/security/http-guards.ts +13 -0
  220. package/src/service/security/leases.ts +182 -0
  221. package/src/service/security/token-store.ts +138 -0
  222. package/src/service/server.ts +356 -0
  223. package/src/service/store/database.ts +61 -0
  224. package/src/service/store/evidence-retention.ts +234 -0
  225. package/src/service/store/migrations.ts +167 -0
  226. package/src/service/store/repository-lifecycle.ts +121 -0
  227. package/src/service/store/repository.ts +732 -0
  228. package/src/service/store/schema.ts +218 -0
  229. package/src/service/stored-verdict.ts +97 -0
  230. package/src/service/stream.ts +301 -0
  231. package/src/service/verdict-enrichment.ts +45 -0
  232. package/src/shared/build/frame-bundle-plugins.ts +61 -0
  233. package/src/shared/build-mode.ts +28 -0
  234. package/src/shared/config/evidence-read.ts +98 -0
  235. package/src/shared/config/limits.ts +56 -0
  236. package/src/shared/config/paths.ts +96 -0
  237. package/src/shared/contracts/artifact-types.ts +2 -0
  238. package/src/shared/contracts/artifact.ts +98 -0
  239. package/src/shared/contracts/commands/_shared.ts +59 -0
  240. package/src/shared/contracts/commands/guards.ts +86 -0
  241. package/src/shared/contracts/commands/index.ts +204 -0
  242. package/src/shared/contracts/commands/names.ts +35 -0
  243. package/src/shared/contracts/commands/requests.ts +149 -0
  244. package/src/shared/contracts/commands/results.ts +200 -0
  245. package/src/shared/contracts/envelope.ts +140 -0
  246. package/src/shared/contracts/events.ts +41 -0
  247. package/src/shared/contracts/observed-counts.ts +19 -0
  248. package/src/shared/contracts/renderers.ts +6 -0
  249. package/src/shared/contracts/validation.ts +296 -0
  250. package/src/shared/errors/facet-error.ts +127 -0
  251. package/src/shared/errors/store-error.ts +68 -0
  252. package/src/shared/evidence-image.ts +37 -0
  253. package/src/shared/export.ts +31 -0
  254. package/src/shared/html/policy.ts +108 -0
  255. package/src/shared/html/style-vocabulary.ts +352 -0
  256. package/src/shared/logging/logger.ts +108 -0
  257. package/src/shared/logging/redact.ts +49 -0
  258. package/src/shared/security/frozen-csp.ts +13 -0
  259. package/src/shared/storage-version.ts +2 -0
  260. package/src/shared/tsx/execution.ts +29 -0
  261. package/src/shared/tsx/import-policy.ts +94 -0
  262. package/src/shared/util/dir-permissions.ts +94 -0
  263. package/src/shared/util/mermaid-nodes.ts +230 -0
  264. package/src/shared/util/process.ts +67 -0
  265. package/src/shared/util/time.ts +21 -0
  266. package/src/shared/version.ts +3 -0
  267. package/src/validation/sandbox/limits.ts +41 -0
  268. package/src/validation/sandbox/netns.ts +177 -0
  269. package/src/validation/tier0/chart.ts +177 -0
  270. package/src/validation/tier0/dom-shim.ts +54 -0
  271. package/src/validation/tier0/html.ts +408 -0
  272. package/src/validation/tier0/markdown.ts +285 -0
  273. package/src/validation/tier0/mermaid.ts +98 -0
  274. package/src/validation/tier0/runner.ts +504 -0
  275. package/src/validation/tier0/svg.ts +321 -0
  276. package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
  277. package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
  278. package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
  279. package/src/validation/tier0/tsx/ast-policy.ts +181 -0
  280. package/src/validation/tier0/tsx/compiler.ts +156 -0
  281. package/src/validation/tier0/worker-dispatch.ts +211 -0
  282. package/src/validation/tier0/worker-entry.ts +96 -0
  283. package/src/validation/tier0/worker-input.ts +75 -0
  284. package/src/validation/tier1/browser-process.ts +147 -0
  285. package/src/validation/tier1/cdp-pipe.ts +281 -0
  286. package/src/validation/tier1/entries/chart.ts +5 -0
  287. package/src/validation/tier1/entries/html.ts +6 -0
  288. package/src/validation/tier1/entries/markdown.ts +5 -0
  289. package/src/validation/tier1/entries/mermaid.ts +5 -0
  290. package/src/validation/tier1/entries/svg.ts +5 -0
  291. package/src/validation/tier1/entries/tsx.ts +5 -0
  292. package/src/validation/tier1/frame-target.ts +162 -0
  293. package/src/validation/tier1/harness-entry.ts +261 -0
  294. package/src/validation/tier1/harness.ts +215 -0
  295. package/src/validation/tier1/isolated-probe.ts +94 -0
  296. package/src/validation/tier1/launcher.ts +177 -0
  297. package/src/validation/tier1/limits.ts +80 -0
  298. package/src/validation/tier1/nonce.ts +17 -0
  299. package/src/validation/tier1/protocol-probe.ts +519 -0
  300. package/src/validation/tier1/runner.ts +1122 -0
  301. package/src/validation/tier1/verdict.ts +246 -0
  302. package/src/validation/tier1/webp.ts +69 -0
  303. package/templates/README.md +88 -0
  304. package/templates/bar-compare.vl.json +63 -0
  305. package/templates/capacity-report.tsx +102 -0
  306. package/templates/decision-record.md +24 -0
  307. package/templates/deployment-state.mmd +40 -0
  308. package/templates/exemplar.md +91 -0
  309. package/templates/facet-story.tsx +799 -0
  310. package/templates/fleet-dashboard.html +141 -0
  311. package/templates/html-release-ledger.html +91 -0
  312. package/templates/html-status-report.html +114 -0
  313. package/templates/incident-console.tsx +147 -0
  314. package/templates/legion-boundaries.mmd +23 -0
  315. package/templates/legion-flow.mmd +15 -0
  316. package/templates/legion-sequence.mmd +14 -0
  317. package/templates/legion-state.mmd +7 -0
  318. package/templates/metric-card.svg +29 -0
  319. package/templates/observability-map.svg +101 -0
  320. package/templates/pipeline-audit.md +108 -0
  321. package/templates/release-metrics.vl.json +98 -0
  322. package/templates/service-topology.mmd +47 -0
  323. package/templates/status-report.md +32 -0
  324. package/templates/system-map.svg +53 -0
  325. package/templates/timeseries.vl.json +71 -0
  326. package/templates/tsx-interactive-counter.tsx +19 -0
  327. package/templates/tsx-status-report.tsx +31 -0
@@ -0,0 +1,1339 @@
1
+ import {
2
+ clear,
3
+ common_default,
4
+ defaultConfig2,
5
+ getAccDescription,
6
+ getAccTitle,
7
+ getConfig2,
8
+ getDiagramTitle,
9
+ setAccDescription,
10
+ setAccTitle,
11
+ setDiagramTitle,
12
+ setupGraphViewbox
13
+ } from "./markdown-92n37gd4.js";
14
+ import {
15
+ select_default
16
+ } from "./markdown-xw8dsk8b.js";
17
+ import {
18
+ __name
19
+ } from "./markdown-1s5vwkf2.js";
20
+ import {
21
+ Tableau10_default,
22
+ ordinal
23
+ } from "./markdown-dy5sgjhc.js";
24
+ import"./markdown-809k7q41.js";
25
+ // node_modules/d3-sankey/node_modules/d3-array/src/max.js
26
+ function max(values, valueof) {
27
+ let max2;
28
+ if (valueof === undefined) {
29
+ for (const value of values) {
30
+ if (value != null && (max2 < value || max2 === undefined && value >= value)) {
31
+ max2 = value;
32
+ }
33
+ }
34
+ } else {
35
+ let index = -1;
36
+ for (let value of values) {
37
+ if ((value = valueof(value, ++index, values)) != null && (max2 < value || max2 === undefined && value >= value)) {
38
+ max2 = value;
39
+ }
40
+ }
41
+ }
42
+ return max2;
43
+ }
44
+ // node_modules/d3-sankey/node_modules/d3-array/src/min.js
45
+ function min(values, valueof) {
46
+ let min2;
47
+ if (valueof === undefined) {
48
+ for (const value of values) {
49
+ if (value != null && (min2 > value || min2 === undefined && value >= value)) {
50
+ min2 = value;
51
+ }
52
+ }
53
+ } else {
54
+ let index = -1;
55
+ for (let value of values) {
56
+ if ((value = valueof(value, ++index, values)) != null && (min2 > value || min2 === undefined && value >= value)) {
57
+ min2 = value;
58
+ }
59
+ }
60
+ }
61
+ return min2;
62
+ }
63
+ // node_modules/d3-sankey/node_modules/d3-array/src/sum.js
64
+ function sum(values, valueof) {
65
+ let sum2 = 0;
66
+ if (valueof === undefined) {
67
+ for (let value of values) {
68
+ if (value = +value) {
69
+ sum2 += value;
70
+ }
71
+ }
72
+ } else {
73
+ let index = -1;
74
+ for (let value of values) {
75
+ if (value = +valueof(value, ++index, values)) {
76
+ sum2 += value;
77
+ }
78
+ }
79
+ }
80
+ return sum2;
81
+ }
82
+ // node_modules/d3-sankey/src/align.js
83
+ function targetDepth(d) {
84
+ return d.target.depth;
85
+ }
86
+ function left(node) {
87
+ return node.depth;
88
+ }
89
+ function right(node, n) {
90
+ return n - 1 - node.height;
91
+ }
92
+ function justify(node, n) {
93
+ return node.sourceLinks.length ? node.depth : n - 1;
94
+ }
95
+ function center(node) {
96
+ return node.targetLinks.length ? node.depth : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1 : 0;
97
+ }
98
+
99
+ // node_modules/d3-sankey/src/constant.js
100
+ function constant(x) {
101
+ return function() {
102
+ return x;
103
+ };
104
+ }
105
+
106
+ // node_modules/d3-sankey/src/sankey.js
107
+ function ascendingSourceBreadth(a, b) {
108
+ return ascendingBreadth(a.source, b.source) || a.index - b.index;
109
+ }
110
+ function ascendingTargetBreadth(a, b) {
111
+ return ascendingBreadth(a.target, b.target) || a.index - b.index;
112
+ }
113
+ function ascendingBreadth(a, b) {
114
+ return a.y0 - b.y0;
115
+ }
116
+ function value(d) {
117
+ return d.value;
118
+ }
119
+ function defaultId(d) {
120
+ return d.index;
121
+ }
122
+ function defaultNodes(graph) {
123
+ return graph.nodes;
124
+ }
125
+ function defaultLinks(graph) {
126
+ return graph.links;
127
+ }
128
+ function find(nodeById, id) {
129
+ const node = nodeById.get(id);
130
+ if (!node)
131
+ throw new Error("missing: " + id);
132
+ return node;
133
+ }
134
+ function computeLinkBreadths({ nodes }) {
135
+ for (const node of nodes) {
136
+ let y0 = node.y0;
137
+ let y1 = y0;
138
+ for (const link of node.sourceLinks) {
139
+ link.y0 = y0 + link.width / 2;
140
+ y0 += link.width;
141
+ }
142
+ for (const link of node.targetLinks) {
143
+ link.y1 = y1 + link.width / 2;
144
+ y1 += link.width;
145
+ }
146
+ }
147
+ }
148
+ function Sankey() {
149
+ let x0 = 0, y0 = 0, x1 = 1, y1 = 1;
150
+ let dx = 24;
151
+ let dy = 8, py;
152
+ let id = defaultId;
153
+ let align = justify;
154
+ let sort;
155
+ let linkSort;
156
+ let nodes = defaultNodes;
157
+ let links = defaultLinks;
158
+ let iterations = 6;
159
+ function sankey() {
160
+ const graph = { nodes: nodes.apply(null, arguments), links: links.apply(null, arguments) };
161
+ computeNodeLinks(graph);
162
+ computeNodeValues(graph);
163
+ computeNodeDepths(graph);
164
+ computeNodeHeights(graph);
165
+ computeNodeBreadths(graph);
166
+ computeLinkBreadths(graph);
167
+ return graph;
168
+ }
169
+ sankey.update = function(graph) {
170
+ computeLinkBreadths(graph);
171
+ return graph;
172
+ };
173
+ sankey.nodeId = function(_) {
174
+ return arguments.length ? (id = typeof _ === "function" ? _ : constant(_), sankey) : id;
175
+ };
176
+ sankey.nodeAlign = function(_) {
177
+ return arguments.length ? (align = typeof _ === "function" ? _ : constant(_), sankey) : align;
178
+ };
179
+ sankey.nodeSort = function(_) {
180
+ return arguments.length ? (sort = _, sankey) : sort;
181
+ };
182
+ sankey.nodeWidth = function(_) {
183
+ return arguments.length ? (dx = +_, sankey) : dx;
184
+ };
185
+ sankey.nodePadding = function(_) {
186
+ return arguments.length ? (dy = py = +_, sankey) : dy;
187
+ };
188
+ sankey.nodes = function(_) {
189
+ return arguments.length ? (nodes = typeof _ === "function" ? _ : constant(_), sankey) : nodes;
190
+ };
191
+ sankey.links = function(_) {
192
+ return arguments.length ? (links = typeof _ === "function" ? _ : constant(_), sankey) : links;
193
+ };
194
+ sankey.linkSort = function(_) {
195
+ return arguments.length ? (linkSort = _, sankey) : linkSort;
196
+ };
197
+ sankey.size = function(_) {
198
+ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];
199
+ };
200
+ sankey.extent = function(_) {
201
+ return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];
202
+ };
203
+ sankey.iterations = function(_) {
204
+ return arguments.length ? (iterations = +_, sankey) : iterations;
205
+ };
206
+ function computeNodeLinks({ nodes: nodes2, links: links2 }) {
207
+ for (const [i, node] of nodes2.entries()) {
208
+ node.index = i;
209
+ node.sourceLinks = [];
210
+ node.targetLinks = [];
211
+ }
212
+ const nodeById = new Map(nodes2.map((d, i) => [id(d, i, nodes2), d]));
213
+ for (const [i, link] of links2.entries()) {
214
+ link.index = i;
215
+ let { source, target } = link;
216
+ if (typeof source !== "object")
217
+ source = link.source = find(nodeById, source);
218
+ if (typeof target !== "object")
219
+ target = link.target = find(nodeById, target);
220
+ source.sourceLinks.push(link);
221
+ target.targetLinks.push(link);
222
+ }
223
+ if (linkSort != null) {
224
+ for (const { sourceLinks, targetLinks } of nodes2) {
225
+ sourceLinks.sort(linkSort);
226
+ targetLinks.sort(linkSort);
227
+ }
228
+ }
229
+ }
230
+ function computeNodeValues({ nodes: nodes2 }) {
231
+ for (const node of nodes2) {
232
+ node.value = node.fixedValue === undefined ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value)) : node.fixedValue;
233
+ }
234
+ }
235
+ function computeNodeDepths({ nodes: nodes2 }) {
236
+ const n = nodes2.length;
237
+ let current = new Set(nodes2);
238
+ let next = new Set;
239
+ let x = 0;
240
+ while (current.size) {
241
+ for (const node of current) {
242
+ node.depth = x;
243
+ for (const { target } of node.sourceLinks) {
244
+ next.add(target);
245
+ }
246
+ }
247
+ if (++x > n)
248
+ throw new Error("circular link");
249
+ current = next;
250
+ next = new Set;
251
+ }
252
+ }
253
+ function computeNodeHeights({ nodes: nodes2 }) {
254
+ const n = nodes2.length;
255
+ let current = new Set(nodes2);
256
+ let next = new Set;
257
+ let x = 0;
258
+ while (current.size) {
259
+ for (const node of current) {
260
+ node.height = x;
261
+ for (const { source } of node.targetLinks) {
262
+ next.add(source);
263
+ }
264
+ }
265
+ if (++x > n)
266
+ throw new Error("circular link");
267
+ current = next;
268
+ next = new Set;
269
+ }
270
+ }
271
+ function computeNodeLayers({ nodes: nodes2 }) {
272
+ const x = max(nodes2, (d) => d.depth) + 1;
273
+ const kx = (x1 - x0 - dx) / (x - 1);
274
+ const columns = new Array(x);
275
+ for (const node of nodes2) {
276
+ const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));
277
+ node.layer = i;
278
+ node.x0 = x0 + i * kx;
279
+ node.x1 = node.x0 + dx;
280
+ if (columns[i])
281
+ columns[i].push(node);
282
+ else
283
+ columns[i] = [node];
284
+ }
285
+ if (sort)
286
+ for (const column of columns) {
287
+ column.sort(sort);
288
+ }
289
+ return columns;
290
+ }
291
+ function initializeNodeBreadths(columns) {
292
+ const ky = min(columns, (c) => (y1 - y0 - (c.length - 1) * py) / sum(c, value));
293
+ for (const nodes2 of columns) {
294
+ let y = y0;
295
+ for (const node of nodes2) {
296
+ node.y0 = y;
297
+ node.y1 = y + node.value * ky;
298
+ y = node.y1 + py;
299
+ for (const link of node.sourceLinks) {
300
+ link.width = link.value * ky;
301
+ }
302
+ }
303
+ y = (y1 - y + py) / (nodes2.length + 1);
304
+ for (let i = 0;i < nodes2.length; ++i) {
305
+ const node = nodes2[i];
306
+ node.y0 += y * (i + 1);
307
+ node.y1 += y * (i + 1);
308
+ }
309
+ reorderLinks(nodes2);
310
+ }
311
+ }
312
+ function computeNodeBreadths(graph) {
313
+ const columns = computeNodeLayers(graph);
314
+ py = Math.min(dy, (y1 - y0) / (max(columns, (c) => c.length) - 1));
315
+ initializeNodeBreadths(columns);
316
+ for (let i = 0;i < iterations; ++i) {
317
+ const alpha = Math.pow(0.99, i);
318
+ const beta = Math.max(1 - alpha, (i + 1) / iterations);
319
+ relaxRightToLeft(columns, alpha, beta);
320
+ relaxLeftToRight(columns, alpha, beta);
321
+ }
322
+ }
323
+ function relaxLeftToRight(columns, alpha, beta) {
324
+ for (let i = 1, n = columns.length;i < n; ++i) {
325
+ const column = columns[i];
326
+ for (const target of column) {
327
+ let y = 0;
328
+ let w = 0;
329
+ for (const { source, value: value2 } of target.targetLinks) {
330
+ let v = value2 * (target.layer - source.layer);
331
+ y += targetTop(source, target) * v;
332
+ w += v;
333
+ }
334
+ if (!(w > 0))
335
+ continue;
336
+ let dy2 = (y / w - target.y0) * alpha;
337
+ target.y0 += dy2;
338
+ target.y1 += dy2;
339
+ reorderNodeLinks(target);
340
+ }
341
+ if (sort === undefined)
342
+ column.sort(ascendingBreadth);
343
+ resolveCollisions(column, beta);
344
+ }
345
+ }
346
+ function relaxRightToLeft(columns, alpha, beta) {
347
+ for (let n = columns.length, i = n - 2;i >= 0; --i) {
348
+ const column = columns[i];
349
+ for (const source of column) {
350
+ let y = 0;
351
+ let w = 0;
352
+ for (const { target, value: value2 } of source.sourceLinks) {
353
+ let v = value2 * (target.layer - source.layer);
354
+ y += sourceTop(source, target) * v;
355
+ w += v;
356
+ }
357
+ if (!(w > 0))
358
+ continue;
359
+ let dy2 = (y / w - source.y0) * alpha;
360
+ source.y0 += dy2;
361
+ source.y1 += dy2;
362
+ reorderNodeLinks(source);
363
+ }
364
+ if (sort === undefined)
365
+ column.sort(ascendingBreadth);
366
+ resolveCollisions(column, beta);
367
+ }
368
+ }
369
+ function resolveCollisions(nodes2, alpha) {
370
+ const i = nodes2.length >> 1;
371
+ const subject = nodes2[i];
372
+ resolveCollisionsBottomToTop(nodes2, subject.y0 - py, i - 1, alpha);
373
+ resolveCollisionsTopToBottom(nodes2, subject.y1 + py, i + 1, alpha);
374
+ resolveCollisionsBottomToTop(nodes2, y1, nodes2.length - 1, alpha);
375
+ resolveCollisionsTopToBottom(nodes2, y0, 0, alpha);
376
+ }
377
+ function resolveCollisionsTopToBottom(nodes2, y, i, alpha) {
378
+ for (;i < nodes2.length; ++i) {
379
+ const node = nodes2[i];
380
+ const dy2 = (y - node.y0) * alpha;
381
+ if (dy2 > 0.000001)
382
+ node.y0 += dy2, node.y1 += dy2;
383
+ y = node.y1 + py;
384
+ }
385
+ }
386
+ function resolveCollisionsBottomToTop(nodes2, y, i, alpha) {
387
+ for (;i >= 0; --i) {
388
+ const node = nodes2[i];
389
+ const dy2 = (node.y1 - y) * alpha;
390
+ if (dy2 > 0.000001)
391
+ node.y0 -= dy2, node.y1 -= dy2;
392
+ y = node.y0 - py;
393
+ }
394
+ }
395
+ function reorderNodeLinks({ sourceLinks, targetLinks }) {
396
+ if (linkSort === undefined) {
397
+ for (const { source: { sourceLinks: sourceLinks2 } } of targetLinks) {
398
+ sourceLinks2.sort(ascendingTargetBreadth);
399
+ }
400
+ for (const { target: { targetLinks: targetLinks2 } } of sourceLinks) {
401
+ targetLinks2.sort(ascendingSourceBreadth);
402
+ }
403
+ }
404
+ }
405
+ function reorderLinks(nodes2) {
406
+ if (linkSort === undefined) {
407
+ for (const { sourceLinks, targetLinks } of nodes2) {
408
+ sourceLinks.sort(ascendingTargetBreadth);
409
+ targetLinks.sort(ascendingSourceBreadth);
410
+ }
411
+ }
412
+ }
413
+ function targetTop(source, target) {
414
+ let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;
415
+ for (const { target: node, width } of source.sourceLinks) {
416
+ if (node === target)
417
+ break;
418
+ y += width + py;
419
+ }
420
+ for (const { source: node, width } of target.targetLinks) {
421
+ if (node === source)
422
+ break;
423
+ y -= width;
424
+ }
425
+ return y;
426
+ }
427
+ function sourceTop(source, target) {
428
+ let y = target.y0 - (target.targetLinks.length - 1) * py / 2;
429
+ for (const { source: node, width } of target.targetLinks) {
430
+ if (node === source)
431
+ break;
432
+ y += width + py;
433
+ }
434
+ for (const { target: node, width } of source.sourceLinks) {
435
+ if (node === target)
436
+ break;
437
+ y -= width;
438
+ }
439
+ return y;
440
+ }
441
+ return sankey;
442
+ }
443
+ // node_modules/d3-sankey/node_modules/d3-shape/node_modules/d3-path/src/path.js
444
+ var pi = Math.PI;
445
+ var tau = 2 * pi;
446
+ var epsilon = 0.000001;
447
+ var tauEpsilon = tau - epsilon;
448
+ function Path() {
449
+ this._x0 = this._y0 = this._x1 = this._y1 = null;
450
+ this._ = "";
451
+ }
452
+ function path() {
453
+ return new Path;
454
+ }
455
+ Path.prototype = path.prototype = {
456
+ constructor: Path,
457
+ moveTo: function(x, y) {
458
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y);
459
+ },
460
+ closePath: function() {
461
+ if (this._x1 !== null) {
462
+ this._x1 = this._x0, this._y1 = this._y0;
463
+ this._ += "Z";
464
+ }
465
+ },
466
+ lineTo: function(x, y) {
467
+ this._ += "L" + (this._x1 = +x) + "," + (this._y1 = +y);
468
+ },
469
+ quadraticCurveTo: function(x1, y1, x, y) {
470
+ this._ += "Q" + +x1 + "," + +y1 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
471
+ },
472
+ bezierCurveTo: function(x1, y1, x2, y2, x, y) {
473
+ this._ += "C" + +x1 + "," + +y1 + "," + +x2 + "," + +y2 + "," + (this._x1 = +x) + "," + (this._y1 = +y);
474
+ },
475
+ arcTo: function(x1, y1, x2, y2, r) {
476
+ x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;
477
+ var x0 = this._x1, y0 = this._y1, x21 = x2 - x1, y21 = y2 - y1, x01 = x0 - x1, y01 = y0 - y1, l01_2 = x01 * x01 + y01 * y01;
478
+ if (r < 0)
479
+ throw new Error("negative radius: " + r);
480
+ if (this._x1 === null) {
481
+ this._ += "M" + (this._x1 = x1) + "," + (this._y1 = y1);
482
+ } else if (!(l01_2 > epsilon))
483
+ ;
484
+ else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {
485
+ this._ += "L" + (this._x1 = x1) + "," + (this._y1 = y1);
486
+ } else {
487
+ var x20 = x2 - x0, y20 = y2 - y0, l21_2 = x21 * x21 + y21 * y21, l20_2 = x20 * x20 + y20 * y20, l21 = Math.sqrt(l21_2), l01 = Math.sqrt(l01_2), l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2), t01 = l / l01, t21 = l / l21;
488
+ if (Math.abs(t01 - 1) > epsilon) {
489
+ this._ += "L" + (x1 + t01 * x01) + "," + (y1 + t01 * y01);
490
+ }
491
+ this._ += "A" + r + "," + r + ",0,0," + +(y01 * x20 > x01 * y20) + "," + (this._x1 = x1 + t21 * x21) + "," + (this._y1 = y1 + t21 * y21);
492
+ }
493
+ },
494
+ arc: function(x, y, r, a0, a1, ccw) {
495
+ x = +x, y = +y, r = +r, ccw = !!ccw;
496
+ var dx = r * Math.cos(a0), dy = r * Math.sin(a0), x0 = x + dx, y0 = y + dy, cw = 1 ^ ccw, da = ccw ? a0 - a1 : a1 - a0;
497
+ if (r < 0)
498
+ throw new Error("negative radius: " + r);
499
+ if (this._x1 === null) {
500
+ this._ += "M" + x0 + "," + y0;
501
+ } else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {
502
+ this._ += "L" + x0 + "," + y0;
503
+ }
504
+ if (!r)
505
+ return;
506
+ if (da < 0)
507
+ da = da % tau + tau;
508
+ if (da > tauEpsilon) {
509
+ this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0);
510
+ } else if (da > epsilon) {
511
+ this._ += "A" + r + "," + r + ",0," + +(da >= pi) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1));
512
+ }
513
+ },
514
+ rect: function(x, y, w, h) {
515
+ this._ += "M" + (this._x0 = this._x1 = +x) + "," + (this._y0 = this._y1 = +y) + "h" + +w + "v" + +h + "h" + -w + "Z";
516
+ },
517
+ toString: function() {
518
+ return this._;
519
+ }
520
+ };
521
+ var path_default = path;
522
+ // node_modules/d3-sankey/node_modules/d3-shape/src/array.js
523
+ var slice = Array.prototype.slice;
524
+
525
+ // node_modules/d3-sankey/node_modules/d3-shape/src/constant.js
526
+ function constant_default(x) {
527
+ return function constant2() {
528
+ return x;
529
+ };
530
+ }
531
+
532
+ // node_modules/d3-sankey/node_modules/d3-shape/src/point.js
533
+ function x(p) {
534
+ return p[0];
535
+ }
536
+ function y(p) {
537
+ return p[1];
538
+ }
539
+
540
+ // node_modules/d3-sankey/node_modules/d3-shape/src/link/index.js
541
+ function linkSource(d) {
542
+ return d.source;
543
+ }
544
+ function linkTarget(d) {
545
+ return d.target;
546
+ }
547
+ function link(curve) {
548
+ var source = linkSource, target = linkTarget, x2 = x, y2 = y, context = null;
549
+ function link2() {
550
+ var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);
551
+ if (!context)
552
+ context = buffer = path_default();
553
+ curve(context, +x2.apply(this, (argv[0] = s, argv)), +y2.apply(this, argv), +x2.apply(this, (argv[0] = t, argv)), +y2.apply(this, argv));
554
+ if (buffer)
555
+ return context = null, buffer + "" || null;
556
+ }
557
+ link2.source = function(_) {
558
+ return arguments.length ? (source = _, link2) : source;
559
+ };
560
+ link2.target = function(_) {
561
+ return arguments.length ? (target = _, link2) : target;
562
+ };
563
+ link2.x = function(_) {
564
+ return arguments.length ? (x2 = typeof _ === "function" ? _ : constant_default(+_), link2) : x2;
565
+ };
566
+ link2.y = function(_) {
567
+ return arguments.length ? (y2 = typeof _ === "function" ? _ : constant_default(+_), link2) : y2;
568
+ };
569
+ link2.context = function(_) {
570
+ return arguments.length ? (context = _ == null ? null : _, link2) : context;
571
+ };
572
+ return link2;
573
+ }
574
+ function curveHorizontal(context, x0, y0, x1, y1) {
575
+ context.moveTo(x0, y0);
576
+ context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);
577
+ }
578
+ function linkHorizontal() {
579
+ return link(curveHorizontal);
580
+ }
581
+ // node_modules/d3-sankey/src/sankeyLinkHorizontal.js
582
+ function horizontalSource(d) {
583
+ return [d.source.x1, d.y0];
584
+ }
585
+ function horizontalTarget(d) {
586
+ return [d.target.x0, d.y1];
587
+ }
588
+ function sankeyLinkHorizontal_default() {
589
+ return linkHorizontal().source(horizontalSource).target(horizontalTarget);
590
+ }
591
+ // node_modules/mermaid/dist/chunks/mermaid.core/sankeyDiagram-W5VNT64P.mjs
592
+ var parser = function() {
593
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
594
+ for (o2 = o2 || {}, l = k.length;l--; o2[k[l]] = v)
595
+ ;
596
+ return o2;
597
+ }, "o"), $V0 = [1, 9], $V1 = [1, 10], $V2 = [1, 5, 10, 12];
598
+ var parser2 = {
599
+ trace: /* @__PURE__ */ __name(function trace() {}, "trace"),
600
+ yy: {},
601
+ symbols_: { error: 2, start: 3, SANKEY: 4, NEWLINE: 5, csv: 6, opt_eof: 7, record: 8, csv_tail: 9, EOF: 10, "field[source]": 11, COMMA: 12, "field[target]": 13, "field[value]": 14, field: 15, escaped: 16, non_escaped: 17, DQUOTE: 18, ESCAPED_TEXT: 19, NON_ESCAPED_TEXT: 20, $accept: 0, $end: 1 },
602
+ terminals_: { 2: "error", 4: "SANKEY", 5: "NEWLINE", 10: "EOF", 11: "field[source]", 12: "COMMA", 13: "field[target]", 14: "field[value]", 18: "DQUOTE", 19: "ESCAPED_TEXT", 20: "NON_ESCAPED_TEXT" },
603
+ productions_: [0, [3, 4], [6, 2], [9, 2], [9, 0], [7, 1], [7, 0], [8, 5], [15, 1], [15, 1], [16, 3], [17, 1]],
604
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
605
+ var $0 = $$.length - 1;
606
+ switch (yystate) {
607
+ case 7:
608
+ const source = yy.findOrCreateNode($$[$0 - 4].trim().replaceAll('""', '"'));
609
+ const target = yy.findOrCreateNode($$[$0 - 2].trim().replaceAll('""', '"'));
610
+ const value2 = parseFloat($$[$0].trim());
611
+ yy.addLink(source, target, value2);
612
+ break;
613
+ case 8:
614
+ case 9:
615
+ case 11:
616
+ this.$ = $$[$0];
617
+ break;
618
+ case 10:
619
+ this.$ = $$[$0 - 1];
620
+ break;
621
+ }
622
+ }, "anonymous"),
623
+ table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, { 5: [1, 3] }, { 6: 4, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 1: [2, 6], 7: 11, 10: [1, 12] }, o($V1, [2, 4], { 9: 13, 5: [1, 14] }), { 12: [1, 15] }, o($V2, [2, 8]), o($V2, [2, 9]), { 19: [1, 16] }, o($V2, [2, 11]), { 1: [2, 1] }, { 1: [2, 5] }, o($V1, [2, 2]), { 6: 17, 8: 5, 15: 6, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 15: 18, 16: 7, 17: 8, 18: $V0, 20: $V1 }, { 18: [1, 19] }, o($V1, [2, 3]), { 12: [1, 20] }, o($V2, [2, 10]), { 15: 21, 16: 7, 17: 8, 18: $V0, 20: $V1 }, o([1, 5, 10], [2, 7])],
624
+ defaultActions: { 11: [2, 1], 12: [2, 5] },
625
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
626
+ if (hash.recoverable) {
627
+ this.trace(str);
628
+ } else {
629
+ var error = new Error(str);
630
+ error.hash = hash;
631
+ throw error;
632
+ }
633
+ }, "parseError"),
634
+ parse: /* @__PURE__ */ __name(function parse(input) {
635
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
636
+ var args = lstack.slice.call(arguments, 1);
637
+ var lexer2 = Object.create(this.lexer);
638
+ var sharedState = { yy: {} };
639
+ for (var k in this.yy) {
640
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
641
+ sharedState.yy[k] = this.yy[k];
642
+ }
643
+ }
644
+ lexer2.setInput(input, sharedState.yy);
645
+ sharedState.yy.lexer = lexer2;
646
+ sharedState.yy.parser = this;
647
+ if (typeof lexer2.yylloc == "undefined") {
648
+ lexer2.yylloc = {};
649
+ }
650
+ var yyloc = lexer2.yylloc;
651
+ lstack.push(yyloc);
652
+ var ranges = lexer2.options && lexer2.options.ranges;
653
+ if (typeof sharedState.yy.parseError === "function") {
654
+ this.parseError = sharedState.yy.parseError;
655
+ } else {
656
+ this.parseError = Object.getPrototypeOf(this).parseError;
657
+ }
658
+ function popStack(n) {
659
+ stack.length = stack.length - 2 * n;
660
+ vstack.length = vstack.length - n;
661
+ lstack.length = lstack.length - n;
662
+ }
663
+ __name(popStack, "popStack");
664
+ function lex() {
665
+ var token;
666
+ token = tstack.pop() || lexer2.lex() || EOF;
667
+ if (typeof token !== "number") {
668
+ if (token instanceof Array) {
669
+ tstack = token;
670
+ token = tstack.pop();
671
+ }
672
+ token = self.symbols_[token] || token;
673
+ }
674
+ return token;
675
+ }
676
+ __name(lex, "lex");
677
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
678
+ while (true) {
679
+ state = stack[stack.length - 1];
680
+ if (this.defaultActions[state]) {
681
+ action = this.defaultActions[state];
682
+ } else {
683
+ if (symbol === null || typeof symbol == "undefined") {
684
+ symbol = lex();
685
+ }
686
+ action = table[state] && table[state][symbol];
687
+ }
688
+ if (typeof action === "undefined" || !action.length || !action[0]) {
689
+ var errStr = "";
690
+ expected = [];
691
+ for (p in table[state]) {
692
+ if (this.terminals_[p] && p > TERROR) {
693
+ expected.push("'" + this.terminals_[p] + "'");
694
+ }
695
+ }
696
+ if (lexer2.showPosition) {
697
+ errStr = "Parse error on line " + (yylineno + 1) + `:
698
+ ` + lexer2.showPosition() + `
699
+ Expecting ` + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
700
+ } else {
701
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
702
+ }
703
+ this.parseError(errStr, {
704
+ text: lexer2.match,
705
+ token: this.terminals_[symbol] || symbol,
706
+ line: lexer2.yylineno,
707
+ loc: yyloc,
708
+ expected
709
+ });
710
+ }
711
+ if (action[0] instanceof Array && action.length > 1) {
712
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
713
+ }
714
+ switch (action[0]) {
715
+ case 1:
716
+ stack.push(symbol);
717
+ vstack.push(lexer2.yytext);
718
+ lstack.push(lexer2.yylloc);
719
+ stack.push(action[1]);
720
+ symbol = null;
721
+ if (!preErrorSymbol) {
722
+ yyleng = lexer2.yyleng;
723
+ yytext = lexer2.yytext;
724
+ yylineno = lexer2.yylineno;
725
+ yyloc = lexer2.yylloc;
726
+ if (recovering > 0) {
727
+ recovering--;
728
+ }
729
+ } else {
730
+ symbol = preErrorSymbol;
731
+ preErrorSymbol = null;
732
+ }
733
+ break;
734
+ case 2:
735
+ len = this.productions_[action[1]][1];
736
+ yyval.$ = vstack[vstack.length - len];
737
+ yyval._$ = {
738
+ first_line: lstack[lstack.length - (len || 1)].first_line,
739
+ last_line: lstack[lstack.length - 1].last_line,
740
+ first_column: lstack[lstack.length - (len || 1)].first_column,
741
+ last_column: lstack[lstack.length - 1].last_column
742
+ };
743
+ if (ranges) {
744
+ yyval._$.range = [
745
+ lstack[lstack.length - (len || 1)].range[0],
746
+ lstack[lstack.length - 1].range[1]
747
+ ];
748
+ }
749
+ r = this.performAction.apply(yyval, [
750
+ yytext,
751
+ yyleng,
752
+ yylineno,
753
+ sharedState.yy,
754
+ action[1],
755
+ vstack,
756
+ lstack
757
+ ].concat(args));
758
+ if (typeof r !== "undefined") {
759
+ return r;
760
+ }
761
+ if (len) {
762
+ stack = stack.slice(0, -1 * len * 2);
763
+ vstack = vstack.slice(0, -1 * len);
764
+ lstack = lstack.slice(0, -1 * len);
765
+ }
766
+ stack.push(this.productions_[action[1]][0]);
767
+ vstack.push(yyval.$);
768
+ lstack.push(yyval._$);
769
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
770
+ stack.push(newState);
771
+ break;
772
+ case 3:
773
+ return true;
774
+ }
775
+ }
776
+ return true;
777
+ }, "parse")
778
+ };
779
+ var lexer = /* @__PURE__ */ function() {
780
+ var lexer2 = {
781
+ EOF: 1,
782
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
783
+ if (this.yy.parser) {
784
+ this.yy.parser.parseError(str, hash);
785
+ } else {
786
+ throw new Error(str);
787
+ }
788
+ }, "parseError"),
789
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
790
+ this.yy = yy || this.yy || {};
791
+ this._input = input;
792
+ this._more = this._backtrack = this.done = false;
793
+ this.yylineno = this.yyleng = 0;
794
+ this.yytext = this.matched = this.match = "";
795
+ this.conditionStack = ["INITIAL"];
796
+ this.yylloc = {
797
+ first_line: 1,
798
+ first_column: 0,
799
+ last_line: 1,
800
+ last_column: 0
801
+ };
802
+ if (this.options.ranges) {
803
+ this.yylloc.range = [0, 0];
804
+ }
805
+ this.offset = 0;
806
+ return this;
807
+ }, "setInput"),
808
+ input: /* @__PURE__ */ __name(function() {
809
+ var ch = this._input[0];
810
+ this.yytext += ch;
811
+ this.yyleng++;
812
+ this.offset++;
813
+ this.match += ch;
814
+ this.matched += ch;
815
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
816
+ if (lines) {
817
+ this.yylineno++;
818
+ this.yylloc.last_line++;
819
+ } else {
820
+ this.yylloc.last_column++;
821
+ }
822
+ if (this.options.ranges) {
823
+ this.yylloc.range[1]++;
824
+ }
825
+ this._input = this._input.slice(1);
826
+ return ch;
827
+ }, "input"),
828
+ unput: /* @__PURE__ */ __name(function(ch) {
829
+ var len = ch.length;
830
+ var lines = ch.split(/(?:\r\n?|\n)/g);
831
+ this._input = ch + this._input;
832
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
833
+ this.offset -= len;
834
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
835
+ this.match = this.match.substr(0, this.match.length - 1);
836
+ this.matched = this.matched.substr(0, this.matched.length - 1);
837
+ if (lines.length - 1) {
838
+ this.yylineno -= lines.length - 1;
839
+ }
840
+ var r = this.yylloc.range;
841
+ this.yylloc = {
842
+ first_line: this.yylloc.first_line,
843
+ last_line: this.yylineno + 1,
844
+ first_column: this.yylloc.first_column,
845
+ last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
846
+ };
847
+ if (this.options.ranges) {
848
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
849
+ }
850
+ this.yyleng = this.yytext.length;
851
+ return this;
852
+ }, "unput"),
853
+ more: /* @__PURE__ */ __name(function() {
854
+ this._more = true;
855
+ return this;
856
+ }, "more"),
857
+ reject: /* @__PURE__ */ __name(function() {
858
+ if (this.options.backtrack_lexer) {
859
+ this._backtrack = true;
860
+ } else {
861
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
862
+ ` + this.showPosition(), {
863
+ text: "",
864
+ token: null,
865
+ line: this.yylineno
866
+ });
867
+ }
868
+ return this;
869
+ }, "reject"),
870
+ less: /* @__PURE__ */ __name(function(n) {
871
+ this.unput(this.match.slice(n));
872
+ }, "less"),
873
+ pastInput: /* @__PURE__ */ __name(function() {
874
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
875
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
876
+ }, "pastInput"),
877
+ upcomingInput: /* @__PURE__ */ __name(function() {
878
+ var next = this.match;
879
+ if (next.length < 20) {
880
+ next += this._input.substr(0, 20 - next.length);
881
+ }
882
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
883
+ }, "upcomingInput"),
884
+ showPosition: /* @__PURE__ */ __name(function() {
885
+ var pre = this.pastInput();
886
+ var c = new Array(pre.length + 1).join("-");
887
+ return pre + this.upcomingInput() + `
888
+ ` + c + "^";
889
+ }, "showPosition"),
890
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
891
+ var token, lines, backup;
892
+ if (this.options.backtrack_lexer) {
893
+ backup = {
894
+ yylineno: this.yylineno,
895
+ yylloc: {
896
+ first_line: this.yylloc.first_line,
897
+ last_line: this.last_line,
898
+ first_column: this.yylloc.first_column,
899
+ last_column: this.yylloc.last_column
900
+ },
901
+ yytext: this.yytext,
902
+ match: this.match,
903
+ matches: this.matches,
904
+ matched: this.matched,
905
+ yyleng: this.yyleng,
906
+ offset: this.offset,
907
+ _more: this._more,
908
+ _input: this._input,
909
+ yy: this.yy,
910
+ conditionStack: this.conditionStack.slice(0),
911
+ done: this.done
912
+ };
913
+ if (this.options.ranges) {
914
+ backup.yylloc.range = this.yylloc.range.slice(0);
915
+ }
916
+ }
917
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
918
+ if (lines) {
919
+ this.yylineno += lines.length;
920
+ }
921
+ this.yylloc = {
922
+ first_line: this.yylloc.last_line,
923
+ last_line: this.yylineno + 1,
924
+ first_column: this.yylloc.last_column,
925
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
926
+ };
927
+ this.yytext += match[0];
928
+ this.match += match[0];
929
+ this.matches = match;
930
+ this.yyleng = this.yytext.length;
931
+ if (this.options.ranges) {
932
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
933
+ }
934
+ this._more = false;
935
+ this._backtrack = false;
936
+ this._input = this._input.slice(match[0].length);
937
+ this.matched += match[0];
938
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
939
+ if (this.done && this._input) {
940
+ this.done = false;
941
+ }
942
+ if (token) {
943
+ return token;
944
+ } else if (this._backtrack) {
945
+ for (var k in backup) {
946
+ this[k] = backup[k];
947
+ }
948
+ return false;
949
+ }
950
+ return false;
951
+ }, "test_match"),
952
+ next: /* @__PURE__ */ __name(function() {
953
+ if (this.done) {
954
+ return this.EOF;
955
+ }
956
+ if (!this._input) {
957
+ this.done = true;
958
+ }
959
+ var token, match, tempMatch, index2;
960
+ if (!this._more) {
961
+ this.yytext = "";
962
+ this.match = "";
963
+ }
964
+ var rules = this._currentRules();
965
+ for (var i = 0;i < rules.length; i++) {
966
+ tempMatch = this._input.match(this.rules[rules[i]]);
967
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
968
+ match = tempMatch;
969
+ index2 = i;
970
+ if (this.options.backtrack_lexer) {
971
+ token = this.test_match(tempMatch, rules[i]);
972
+ if (token !== false) {
973
+ return token;
974
+ } else if (this._backtrack) {
975
+ match = false;
976
+ continue;
977
+ } else {
978
+ return false;
979
+ }
980
+ } else if (!this.options.flex) {
981
+ break;
982
+ }
983
+ }
984
+ }
985
+ if (match) {
986
+ token = this.test_match(match, rules[index2]);
987
+ if (token !== false) {
988
+ return token;
989
+ }
990
+ return false;
991
+ }
992
+ if (this._input === "") {
993
+ return this.EOF;
994
+ } else {
995
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
996
+ ` + this.showPosition(), {
997
+ text: "",
998
+ token: null,
999
+ line: this.yylineno
1000
+ });
1001
+ }
1002
+ }, "next"),
1003
+ lex: /* @__PURE__ */ __name(function lex() {
1004
+ var r = this.next();
1005
+ if (r) {
1006
+ return r;
1007
+ } else {
1008
+ return this.lex();
1009
+ }
1010
+ }, "lex"),
1011
+ begin: /* @__PURE__ */ __name(function begin(condition) {
1012
+ this.conditionStack.push(condition);
1013
+ }, "begin"),
1014
+ popState: /* @__PURE__ */ __name(function popState() {
1015
+ var n = this.conditionStack.length - 1;
1016
+ if (n > 0) {
1017
+ return this.conditionStack.pop();
1018
+ } else {
1019
+ return this.conditionStack[0];
1020
+ }
1021
+ }, "popState"),
1022
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
1023
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
1024
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
1025
+ } else {
1026
+ return this.conditions["INITIAL"].rules;
1027
+ }
1028
+ }, "_currentRules"),
1029
+ topState: /* @__PURE__ */ __name(function topState(n) {
1030
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
1031
+ if (n >= 0) {
1032
+ return this.conditionStack[n];
1033
+ } else {
1034
+ return "INITIAL";
1035
+ }
1036
+ }, "topState"),
1037
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
1038
+ this.begin(condition);
1039
+ }, "pushState"),
1040
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
1041
+ return this.conditionStack.length;
1042
+ }, "stateStackSize"),
1043
+ options: { "case-insensitive": true },
1044
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
1045
+ var YYSTATE = YY_START;
1046
+ switch ($avoiding_name_collisions) {
1047
+ case 0:
1048
+ this.pushState("csv");
1049
+ return 4;
1050
+ break;
1051
+ case 1:
1052
+ this.pushState("csv");
1053
+ return 4;
1054
+ break;
1055
+ case 2:
1056
+ return 10;
1057
+ break;
1058
+ case 3:
1059
+ return 5;
1060
+ break;
1061
+ case 4:
1062
+ return 12;
1063
+ break;
1064
+ case 5:
1065
+ this.pushState("escaped_text");
1066
+ return 18;
1067
+ break;
1068
+ case 6:
1069
+ return 20;
1070
+ break;
1071
+ case 7:
1072
+ this.popState("escaped_text");
1073
+ return 18;
1074
+ break;
1075
+ case 8:
1076
+ return 19;
1077
+ break;
1078
+ }
1079
+ }, "anonymous"),
1080
+ rules: [/^(?:sankey-beta\b)/i, /^(?:sankey\b)/i, /^(?:$)/i, /^(?:((\u000D\u000A)|(\u000A)))/i, /^(?:(\u002C))/i, /^(?:(\u0022))/i, /^(?:([\u0020-\u0021\u0023-\u002B\u002D-\u007E])*)/i, /^(?:(\u0022)(?!(\u0022)))/i, /^(?:(([\u0020-\u0021\u0023-\u002B\u002D-\u007E])|(\u002C)|(\u000D)|(\u000A)|(\u0022)(\u0022))*)/i],
1081
+ conditions: { csv: { rules: [2, 3, 4, 5, 6, 7, 8], inclusive: false }, escaped_text: { rules: [7, 8], inclusive: false }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 8], inclusive: true } }
1082
+ };
1083
+ return lexer2;
1084
+ }();
1085
+ parser2.lexer = lexer;
1086
+ function Parser() {
1087
+ this.yy = {};
1088
+ }
1089
+ __name(Parser, "Parser");
1090
+ Parser.prototype = parser2;
1091
+ parser2.Parser = Parser;
1092
+ return new Parser;
1093
+ }();
1094
+ parser.parser = parser;
1095
+ var sankey_default = parser;
1096
+ var links = [];
1097
+ var nodes = [];
1098
+ var nodesMap = /* @__PURE__ */ new Map;
1099
+ var clear2 = /* @__PURE__ */ __name(() => {
1100
+ links = [];
1101
+ nodes = [];
1102
+ nodesMap = /* @__PURE__ */ new Map;
1103
+ clear();
1104
+ }, "clear");
1105
+ var SankeyLink = class {
1106
+ constructor(source, target, value2 = 0) {
1107
+ this.source = source;
1108
+ this.target = target;
1109
+ this.value = value2;
1110
+ }
1111
+ static {
1112
+ __name(this, "SankeyLink");
1113
+ }
1114
+ };
1115
+ var addLink = /* @__PURE__ */ __name((source, target, value2) => {
1116
+ links.push(new SankeyLink(source, target, value2));
1117
+ }, "addLink");
1118
+ var SankeyNode = class {
1119
+ constructor(ID) {
1120
+ this.ID = ID;
1121
+ }
1122
+ static {
1123
+ __name(this, "SankeyNode");
1124
+ }
1125
+ };
1126
+ var findOrCreateNode = /* @__PURE__ */ __name((ID) => {
1127
+ ID = common_default.sanitizeText(ID, getConfig2());
1128
+ let node = nodesMap.get(ID);
1129
+ if (node === undefined) {
1130
+ node = new SankeyNode(ID);
1131
+ nodesMap.set(ID, node);
1132
+ nodes.push(node);
1133
+ }
1134
+ return node;
1135
+ }, "findOrCreateNode");
1136
+ var getNodes = /* @__PURE__ */ __name(() => nodes, "getNodes");
1137
+ var getLinks = /* @__PURE__ */ __name(() => links, "getLinks");
1138
+ var getGraph = /* @__PURE__ */ __name(() => ({
1139
+ nodes: nodes.map((node) => ({ id: node.ID })),
1140
+ links: links.map((link2) => ({
1141
+ source: link2.source.ID,
1142
+ target: link2.target.ID,
1143
+ value: link2.value
1144
+ }))
1145
+ }), "getGraph");
1146
+ var sankeyDB_default = {
1147
+ nodesMap,
1148
+ getConfig: /* @__PURE__ */ __name(() => getConfig2().sankey, "getConfig"),
1149
+ getNodes,
1150
+ getLinks,
1151
+ getGraph,
1152
+ addLink,
1153
+ findOrCreateNode,
1154
+ getAccTitle,
1155
+ setAccTitle,
1156
+ getAccDescription,
1157
+ setAccDescription,
1158
+ getDiagramTitle,
1159
+ setDiagramTitle,
1160
+ clear: clear2
1161
+ };
1162
+ var Uid = class _Uid {
1163
+ static {
1164
+ __name(this, "Uid");
1165
+ }
1166
+ static {
1167
+ this.count = 0;
1168
+ }
1169
+ static next(name) {
1170
+ return new _Uid(name + ++_Uid.count);
1171
+ }
1172
+ constructor(id) {
1173
+ this.id = id;
1174
+ this.href = `#${id}`;
1175
+ }
1176
+ toString() {
1177
+ return "url(" + this.href + ")";
1178
+ }
1179
+ };
1180
+ var alignmentsMap = {
1181
+ left,
1182
+ right,
1183
+ center,
1184
+ justify
1185
+ };
1186
+ var findCentralNodeLayer = /* @__PURE__ */ __name((nodes2) => {
1187
+ let maxValue = 0;
1188
+ let centralLayer = 0;
1189
+ for (const node of nodes2) {
1190
+ const value2 = node.value ?? 0;
1191
+ if (value2 > maxValue) {
1192
+ maxValue = value2;
1193
+ centralLayer = node.layer ?? 0;
1194
+ }
1195
+ }
1196
+ return centralLayer;
1197
+ }, "findCentralNodeLayer");
1198
+ var draw = /* @__PURE__ */ __name(function(text, id, _version, diagObj) {
1199
+ const { securityLevel, sankey: conf } = getConfig2();
1200
+ const defaultSankeyConfig = defaultConfig2.sankey;
1201
+ let sandboxElement;
1202
+ if (securityLevel === "sandbox") {
1203
+ sandboxElement = select_default("#i" + id);
1204
+ }
1205
+ const root = securityLevel === "sandbox" ? select_default(sandboxElement.nodes()[0].contentDocument.body) : select_default("body");
1206
+ const svg = securityLevel === "sandbox" ? root.select(`[id="${id}"]`) : select_default(`[id="${id}"]`);
1207
+ const width = conf?.width ?? defaultSankeyConfig.width;
1208
+ const height = conf?.height ?? defaultSankeyConfig.width;
1209
+ const useMaxWidth = conf?.useMaxWidth ?? defaultSankeyConfig.useMaxWidth;
1210
+ const nodeAlignment = conf?.nodeAlignment ?? defaultSankeyConfig.nodeAlignment;
1211
+ const prefix = conf?.prefix ?? defaultSankeyConfig.prefix;
1212
+ const suffix = conf?.suffix ?? defaultSankeyConfig.suffix;
1213
+ const showValues = conf?.showValues ?? defaultSankeyConfig.showValues;
1214
+ const nodeWidth = conf?.nodeWidth ?? defaultSankeyConfig.nodeWidth ?? 10;
1215
+ const nodePadding = conf?.nodePadding ?? defaultSankeyConfig.nodePadding ?? 12;
1216
+ const labelStyle = conf?.labelStyle ?? defaultSankeyConfig.labelStyle ?? "legacy";
1217
+ const nodeColors = conf?.nodeColors ?? {};
1218
+ const graph = diagObj.db.getGraph();
1219
+ const nodeAlign = alignmentsMap[nodeAlignment];
1220
+ const sankey = Sankey().nodeId((d) => d.id).nodeWidth(nodeWidth).nodePadding(nodePadding + (showValues ? 15 : 0)).nodeAlign(nodeAlign).extent([
1221
+ [0, 0],
1222
+ [width, height]
1223
+ ]);
1224
+ sankey(graph);
1225
+ const centralNodeLayer = findCentralNodeLayer(graph.nodes);
1226
+ const colorScheme = ordinal(Tableau10_default);
1227
+ const getNodeColor = /* @__PURE__ */ __name((nodeId) => {
1228
+ return nodeColors[nodeId] ?? colorScheme(nodeId);
1229
+ }, "getNodeColor");
1230
+ svg.append("g").attr("class", "nodes").selectAll(".node").data(graph.nodes).join("g").attr("class", "node").attr("id", (d) => (d.uid = Uid.next("node-")).id).attr("transform", function(d) {
1231
+ return "translate(" + d.x0 + "," + d.y0 + ")";
1232
+ }).attr("x", (d) => d.x0).attr("y", (d) => d.y0).append("rect").attr("height", (d) => {
1233
+ return d.y1 - d.y0;
1234
+ }).attr("width", (d) => d.x1 - d.x0).attr("fill", (d) => getNodeColor(d.id));
1235
+ const getText = /* @__PURE__ */ __name(({ id: id2, value: value2 }) => {
1236
+ if (!showValues) {
1237
+ return id2;
1238
+ }
1239
+ return `${id2}
1240
+ ${prefix}${Math.round(value2 * 100) / 100}${suffix}`;
1241
+ }, "getText");
1242
+ const getLabelPosition = /* @__PURE__ */ __name((d) => {
1243
+ if (labelStyle === "outlined") {
1244
+ const nodeLayer = d.layer ?? 0;
1245
+ if (nodeLayer < centralNodeLayer) {
1246
+ return { x: d.x0 - 6, anchor: "end" };
1247
+ }
1248
+ return { x: d.x1 + 6, anchor: "start" };
1249
+ }
1250
+ if (d.x0 < width / 2) {
1251
+ return { x: d.x1 + 6, anchor: "start" };
1252
+ }
1253
+ return { x: d.x0 - 6, anchor: "end" };
1254
+ }, "getLabelPosition");
1255
+ const labelsGroup = svg.append("g").attr("class", "node-labels").attr("font-size", 14);
1256
+ const appendLabel = /* @__PURE__ */ __name((className) => labelsGroup.selectAll(className ? `.${className}` : "text").data(graph.nodes).join("text").attr("class", className ?? null).attr("x", (d) => getLabelPosition(d).x).attr("y", (d) => (d.y1 + d.y0) / 2).attr("dy", `${showValues ? "0" : "0.35"}em`).attr("text-anchor", (d) => getLabelPosition(d).anchor).text(getText), "appendLabel");
1257
+ if (labelStyle === "outlined") {
1258
+ appendLabel("sankey-label-bg");
1259
+ appendLabel("sankey-label-fg");
1260
+ } else {
1261
+ appendLabel();
1262
+ }
1263
+ const link2 = svg.append("g").attr("class", "links").attr("fill", "none").attr("stroke-opacity", 0.5).selectAll(".link").data(graph.links).join("g").attr("class", "link").style("mix-blend-mode", "multiply");
1264
+ const linkColor = conf?.linkColor ?? "gradient";
1265
+ if (linkColor === "gradient") {
1266
+ const gradient = link2.append("linearGradient").attr("id", (d) => (d.uid = Uid.next("linearGradient-")).id).attr("gradientUnits", "userSpaceOnUse").attr("x1", (d) => d.source.x1).attr("x2", (d) => d.target.x0);
1267
+ gradient.append("stop").attr("offset", "0%").attr("stop-color", (d) => getNodeColor(d.source.id));
1268
+ gradient.append("stop").attr("offset", "100%").attr("stop-color", (d) => getNodeColor(d.target.id));
1269
+ }
1270
+ let coloring;
1271
+ switch (linkColor) {
1272
+ case "gradient":
1273
+ coloring = /* @__PURE__ */ __name((d) => d.uid, "coloring");
1274
+ break;
1275
+ case "source":
1276
+ coloring = /* @__PURE__ */ __name((d) => getNodeColor(d.source.id), "coloring");
1277
+ break;
1278
+ case "target":
1279
+ coloring = /* @__PURE__ */ __name((d) => getNodeColor(d.target.id), "coloring");
1280
+ break;
1281
+ default:
1282
+ coloring = linkColor;
1283
+ }
1284
+ link2.append("path").attr("d", sankeyLinkHorizontal_default()).attr("stroke", coloring).attr("stroke-width", (d) => Math.max(1, d.width));
1285
+ setupGraphViewbox(undefined, svg, 0, useMaxWidth);
1286
+ }, "draw");
1287
+ var sankeyRenderer_default = {
1288
+ draw
1289
+ };
1290
+ var prepareTextForParsing = /* @__PURE__ */ __name((text) => {
1291
+ const textToParse = text.replaceAll(/^[^\S\n\r]+|[^\S\n\r]+$/g, "").replaceAll(/([\n\r])+/g, `
1292
+ `).trim();
1293
+ return textToParse;
1294
+ }, "prepareTextForParsing");
1295
+ var getStyles = /* @__PURE__ */ __name((options) => `.label {
1296
+ font-family: ${options.fontFamily};
1297
+ }
1298
+
1299
+ .node-labels {
1300
+ font-family: ${options.fontFamily};
1301
+ }
1302
+
1303
+ /* Outlined label style - background stroke for better readability */
1304
+ .sankey-label-bg {
1305
+ stroke: ${options.mainBkg || options.background || "#fff"};
1306
+ stroke-width: 4px;
1307
+ stroke-linejoin: round;
1308
+ paint-order: stroke;
1309
+ }
1310
+
1311
+ /* Foreground label text */
1312
+ .sankey-label-fg {
1313
+ fill: ${options.textColor};
1314
+ }
1315
+
1316
+ /* Node styling */
1317
+ .node rect {
1318
+ shape-rendering: crispEdges;
1319
+ }
1320
+
1321
+ /* Link styling */
1322
+ .link {
1323
+ fill: none;
1324
+ stroke-opacity: 0.5;
1325
+ mix-blend-mode: multiply;
1326
+ }
1327
+ `, "getStyles");
1328
+ var styles_default = getStyles;
1329
+ var originalParse = sankey_default.parse.bind(sankey_default);
1330
+ sankey_default.parse = (text) => originalParse(prepareTextForParsing(text));
1331
+ var diagram = {
1332
+ styles: styles_default,
1333
+ parser: sankey_default,
1334
+ db: sankeyDB_default,
1335
+ renderer: sankeyRenderer_default
1336
+ };
1337
+ export {
1338
+ diagram
1339
+ };