@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,979 @@
1
+ import {
2
+ populateCommonDb
3
+ } from "./markdown-b4s7ntq2.js";
4
+ import {
5
+ parse
6
+ } from "./markdown-ceefymn8.js";
7
+ import"./markdown-gx1p0ew0.js";
8
+ import"./markdown-pxfeh231.js";
9
+ import"./markdown-y18mve73.js";
10
+ import"./markdown-2x113yh8.js";
11
+ import"./markdown-56enrf2r.js";
12
+ import"./markdown-ag2sssf8.js";
13
+ import"./markdown-tnmabqvz.js";
14
+ import"./markdown-hab789t9.js";
15
+ import"./markdown-gxye5frz.js";
16
+ import"./markdown-k8xkn8mw.js";
17
+ import"./markdown-p740v4qm.js";
18
+ import"./markdown-ffg06nfz.js";
19
+ import"./markdown-w6sgd54z.js";
20
+ import"./markdown-rawhfvvc.js";
21
+ import"./markdown-v14td68x.js";
22
+ import"./markdown-dz3z5w30.js";
23
+ import {
24
+ selectSvgElement
25
+ } from "./markdown-6zz8efx2.js";
26
+ import {
27
+ cleanAndMerge
28
+ } from "./markdown-ff5wvb43.js";
29
+ import"./markdown-pzgd8z3s.js";
30
+ import {
31
+ clear,
32
+ configureSvgSize,
33
+ getAccDescription,
34
+ getAccTitle,
35
+ getConfig,
36
+ getConfig2,
37
+ getDiagramTitle,
38
+ getThemeVariables3,
39
+ setAccDescription,
40
+ setAccTitle,
41
+ setDiagramTitle
42
+ } from "./markdown-92n37gd4.js";
43
+ import {
44
+ log
45
+ } from "./markdown-xw8dsk8b.js";
46
+ import {
47
+ __name
48
+ } from "./markdown-1s5vwkf2.js";
49
+ import"./markdown-dy5sgjhc.js";
50
+ import"./markdown-809k7q41.js";
51
+
52
+ // node_modules/mermaid/dist/chunks/mermaid.core/wardleyDiagram-T6FBY63Y.mjs
53
+ var toPercent = /* @__PURE__ */ __name((value, context) => {
54
+ const normalized = value <= 1 ? value * 100 : value;
55
+ if (normalized < 0 || normalized > 100) {
56
+ throw new Error(`${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`);
57
+ }
58
+ return normalized;
59
+ }, "toPercent");
60
+ var toCoordinates = /* @__PURE__ */ __name((visibility, evolution, context) => {
61
+ return {
62
+ x: toPercent(evolution, `${context} evolution`),
63
+ y: toPercent(visibility, `${context} visibility`)
64
+ };
65
+ }, "toCoordinates");
66
+ var getFlowFromPort = /* @__PURE__ */ __name((port) => {
67
+ if (!port) {
68
+ return;
69
+ }
70
+ if (port === "+<>") {
71
+ return "bidirectional";
72
+ }
73
+ if (port === "+<") {
74
+ return "backward";
75
+ }
76
+ if (port === "+>") {
77
+ return "forward";
78
+ }
79
+ return;
80
+ }, "getFlowFromPort");
81
+ var extractFlowFromArrow = /* @__PURE__ */ __name((arrow) => {
82
+ if (!arrow?.startsWith("+")) {
83
+ return {};
84
+ }
85
+ const labelMatch = /^\+'([^']*)'/.exec(arrow);
86
+ const flowLabel = labelMatch?.[1];
87
+ if (arrow.includes("<>")) {
88
+ return { flow: "bidirectional", label: flowLabel };
89
+ }
90
+ if (arrow.includes("<")) {
91
+ return { flow: "backward", label: flowLabel };
92
+ }
93
+ if (arrow.includes(">")) {
94
+ return { flow: "forward", label: flowLabel };
95
+ }
96
+ return { label: flowLabel };
97
+ }, "extractFlowFromArrow");
98
+ var populateDb = /* @__PURE__ */ __name((ast, db) => {
99
+ populateCommonDb(ast, db);
100
+ if (ast.size) {
101
+ db.setSize(ast.size.width, ast.size.height);
102
+ }
103
+ if (ast.evolution) {
104
+ const stages = ast.evolution.stages.map((stage) => {
105
+ if (stage.secondName) {
106
+ return `${stage.name.trim()} / ${stage.secondName.trim()}`;
107
+ }
108
+ return stage.name.trim();
109
+ });
110
+ const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== undefined).map((stage) => stage.boundary);
111
+ db.updateAxes({ stages, stageBoundaries });
112
+ }
113
+ ast.anchors.forEach((anchor) => {
114
+ const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
115
+ db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
116
+ });
117
+ ast.components.forEach((component) => {
118
+ const coords = toCoordinates(component.visibility, component.evolution, `Component "${component.name}"`);
119
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : undefined;
120
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : undefined;
121
+ const sourceStrategy = component.decorator?.strategy;
122
+ db.addNode(component.name, component.name, coords.x, coords.y, "component", labelOffsetX, labelOffsetY, component.inertia, sourceStrategy);
123
+ });
124
+ ast.notes.forEach((note) => {
125
+ const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
126
+ db.addNote(note.text, coords.x, coords.y);
127
+ });
128
+ ast.pipelines.forEach((pipeline) => {
129
+ const parentNode = db.getNode(pipeline.parent);
130
+ if (!parentNode || typeof parentNode.y !== "number") {
131
+ throw new Error(`Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`);
132
+ }
133
+ const parentY = parentNode.y;
134
+ db.startPipeline(pipeline.parent);
135
+ pipeline.components.forEach((component) => {
136
+ const componentId = `${pipeline.parent}_${component.name}`;
137
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : undefined;
138
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : undefined;
139
+ const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
140
+ db.addNode(componentId, component.name, x, parentY, "pipeline-component", labelOffsetX, labelOffsetY);
141
+ db.addPipelineComponent(pipeline.parent, componentId);
142
+ });
143
+ });
144
+ ast.links.forEach((link) => {
145
+ const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
146
+ let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
147
+ const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
148
+ if (!flow && arrowFlow) {
149
+ flow = arrowFlow;
150
+ }
151
+ const annotation = link.linkLabel;
152
+ const label = flowLabel ?? annotation;
153
+ db.addLink(db.resolveNodeId(link.from), db.resolveNodeId(link.to), isDashed, label, flow);
154
+ });
155
+ ast.evolves.forEach((evolve) => {
156
+ const node = db.getNode(evolve.component);
157
+ if (node?.y !== undefined) {
158
+ const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
159
+ db.addTrend(evolve.component, target, node.y);
160
+ }
161
+ });
162
+ if (ast.annotations.length > 0) {
163
+ const annotationsBox = ast.annotations[0];
164
+ const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
165
+ db.setAnnotationsBox(coords.x, coords.y);
166
+ }
167
+ ast.annotation.forEach((annotation) => {
168
+ const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
169
+ db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
170
+ });
171
+ ast.accelerators.forEach((accelerator) => {
172
+ const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
173
+ db.addAccelerator(accelerator.name, coords.x, coords.y);
174
+ });
175
+ ast.deaccelerators.forEach((deaccelerator) => {
176
+ const coords = toCoordinates(deaccelerator.x, deaccelerator.y, `Deaccelerator "${deaccelerator.name}"`);
177
+ db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
178
+ });
179
+ }, "populateDb");
180
+ var parser = {
181
+ parser: {
182
+ yy: undefined
183
+ },
184
+ parse: /* @__PURE__ */ __name(async (input) => {
185
+ const ast = await parse("wardley", input);
186
+ log.debug(ast);
187
+ const db = parser.parser?.yy;
188
+ if (!db || typeof db.addNode !== "function") {
189
+ throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");
190
+ }
191
+ populateDb(ast, db);
192
+ }, "parse")
193
+ };
194
+ var WardleyBuilder = class {
195
+ constructor() {
196
+ this.nodes = /* @__PURE__ */ new Map;
197
+ this.links = [];
198
+ this.trends = /* @__PURE__ */ new Map;
199
+ this.pipelines = /* @__PURE__ */ new Map;
200
+ this.annotations = [];
201
+ this.notes = [];
202
+ this.accelerators = [];
203
+ this.deaccelerators = [];
204
+ this.axes = {};
205
+ }
206
+ static {
207
+ __name(this, "WardleyBuilder");
208
+ }
209
+ addNode(node) {
210
+ const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
211
+ const merged = {
212
+ ...existing,
213
+ ...node,
214
+ className: node.className ?? existing.className,
215
+ labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
216
+ labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
217
+ };
218
+ this.nodes.set(node.id, merged);
219
+ }
220
+ addLink(link) {
221
+ this.links.push(link);
222
+ }
223
+ addTrend(trend) {
224
+ this.trends.set(trend.nodeId, trend);
225
+ }
226
+ startPipeline(nodeId) {
227
+ this.pipelines.set(nodeId, { nodeId, componentIds: [] });
228
+ const node = this.nodes.get(nodeId);
229
+ if (node) {
230
+ node.isPipelineParent = true;
231
+ }
232
+ }
233
+ addPipelineComponent(pipelineNodeId, componentId) {
234
+ const pipeline = this.pipelines.get(pipelineNodeId);
235
+ if (pipeline) {
236
+ pipeline.componentIds.push(componentId);
237
+ }
238
+ const node = this.nodes.get(componentId);
239
+ if (node) {
240
+ node.inPipeline = true;
241
+ }
242
+ }
243
+ addAnnotation(annotation) {
244
+ this.annotations.push(annotation);
245
+ }
246
+ addNote(note) {
247
+ this.notes.push(note);
248
+ }
249
+ addAccelerator(accelerator) {
250
+ this.accelerators.push(accelerator);
251
+ }
252
+ addDeaccelerator(deaccelerator) {
253
+ this.deaccelerators.push(deaccelerator);
254
+ }
255
+ setAnnotationsBox(x, y) {
256
+ this.annotationsBox = { x, y };
257
+ }
258
+ setAxes(partial) {
259
+ this.axes = {
260
+ ...this.axes,
261
+ ...partial
262
+ };
263
+ }
264
+ setSize(width, height) {
265
+ this.size = { width, height };
266
+ }
267
+ getNode(id) {
268
+ return this.nodes.get(id);
269
+ }
270
+ resolveNodeId(name) {
271
+ if (this.nodes.has(name)) {
272
+ return name;
273
+ }
274
+ for (const [id, node] of this.nodes) {
275
+ if (node.label === name) {
276
+ return id;
277
+ }
278
+ }
279
+ return name;
280
+ }
281
+ build() {
282
+ const nodes = [];
283
+ for (const node of this.nodes.values()) {
284
+ if (typeof node.x !== "number" || typeof node.y !== "number") {
285
+ throw new Error(`Node "${node.label}" is missing coordinates`);
286
+ }
287
+ nodes.push(node);
288
+ }
289
+ return {
290
+ nodes,
291
+ links: [...this.links],
292
+ trends: [...this.trends.values()],
293
+ pipelines: [...this.pipelines.values()],
294
+ annotations: [...this.annotations],
295
+ notes: [...this.notes],
296
+ accelerators: [...this.accelerators],
297
+ deaccelerators: [...this.deaccelerators],
298
+ annotationsBox: this.annotationsBox,
299
+ axes: { ...this.axes },
300
+ size: this.size
301
+ };
302
+ }
303
+ clear() {
304
+ this.nodes.clear();
305
+ this.links = [];
306
+ this.trends.clear();
307
+ this.pipelines.clear();
308
+ this.annotations = [];
309
+ this.notes = [];
310
+ this.accelerators = [];
311
+ this.deaccelerators = [];
312
+ this.annotationsBox = undefined;
313
+ this.axes = {};
314
+ this.size = undefined;
315
+ }
316
+ };
317
+ var builder = new WardleyBuilder;
318
+ function getConfig3() {
319
+ return getConfig2()["wardley-beta"];
320
+ }
321
+ __name(getConfig3, "getConfig");
322
+ function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
323
+ builder.addNode({
324
+ id,
325
+ label,
326
+ x,
327
+ y,
328
+ className,
329
+ labelOffsetX,
330
+ labelOffsetY,
331
+ inertia,
332
+ sourceStrategy
333
+ });
334
+ }
335
+ __name(addNode, "addNode");
336
+ function addLink(sourceId, targetId, dashed = false, label, flow) {
337
+ builder.addLink({
338
+ source: sourceId,
339
+ target: targetId,
340
+ dashed,
341
+ label,
342
+ flow
343
+ });
344
+ }
345
+ __name(addLink, "addLink");
346
+ function addTrend(nodeId, targetX, targetY) {
347
+ builder.addTrend({ nodeId, targetX, targetY });
348
+ }
349
+ __name(addTrend, "addTrend");
350
+ function addAnnotation(number, coordinates, text) {
351
+ builder.addAnnotation({
352
+ number,
353
+ coordinates,
354
+ text
355
+ });
356
+ }
357
+ __name(addAnnotation, "addAnnotation");
358
+ function addNote(text, x, y) {
359
+ builder.addNote({
360
+ text,
361
+ x,
362
+ y
363
+ });
364
+ }
365
+ __name(addNote, "addNote");
366
+ function addAccelerator(name, x, y) {
367
+ builder.addAccelerator({
368
+ name,
369
+ x,
370
+ y
371
+ });
372
+ }
373
+ __name(addAccelerator, "addAccelerator");
374
+ function addDeaccelerator(name, x, y) {
375
+ builder.addDeaccelerator({
376
+ name,
377
+ x,
378
+ y
379
+ });
380
+ }
381
+ __name(addDeaccelerator, "addDeaccelerator");
382
+ function setAnnotationsBox(x, y) {
383
+ builder.setAnnotationsBox(x, y);
384
+ }
385
+ __name(setAnnotationsBox, "setAnnotationsBox");
386
+ function setSize(width, height) {
387
+ builder.setSize(width, height);
388
+ }
389
+ __name(setSize, "setSize");
390
+ function startPipeline(nodeId) {
391
+ builder.startPipeline(nodeId);
392
+ }
393
+ __name(startPipeline, "startPipeline");
394
+ function addPipelineComponent(pipelineNodeId, componentId) {
395
+ builder.addPipelineComponent(pipelineNodeId, componentId);
396
+ }
397
+ __name(addPipelineComponent, "addPipelineComponent");
398
+ function updateAxes(partial) {
399
+ builder.setAxes(partial);
400
+ }
401
+ __name(updateAxes, "updateAxes");
402
+ function getNode(id) {
403
+ return builder.getNode(id);
404
+ }
405
+ __name(getNode, "getNode");
406
+ function resolveNodeId(name) {
407
+ return builder.resolveNodeId(name);
408
+ }
409
+ __name(resolveNodeId, "resolveNodeId");
410
+ function getWardleyData() {
411
+ return builder.build();
412
+ }
413
+ __name(getWardleyData, "getWardleyData");
414
+ function clear2() {
415
+ builder.clear();
416
+ clear();
417
+ }
418
+ __name(clear2, "clear");
419
+ var wardleyDb_default = {
420
+ getConfig: getConfig3,
421
+ addNode,
422
+ addLink,
423
+ addTrend,
424
+ addAnnotation,
425
+ addNote,
426
+ addAccelerator,
427
+ addDeaccelerator,
428
+ setAnnotationsBox,
429
+ setSize,
430
+ startPipeline,
431
+ addPipelineComponent,
432
+ updateAxes,
433
+ getNode,
434
+ resolveNodeId,
435
+ getWardleyData,
436
+ clear: clear2,
437
+ setAccTitle,
438
+ getAccTitle,
439
+ setDiagramTitle,
440
+ getDiagramTitle,
441
+ getAccDescription,
442
+ setAccDescription
443
+ };
444
+ var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
445
+ var getTheme = /* @__PURE__ */ __name(() => {
446
+ const { themeVariables } = getConfig2();
447
+ return {
448
+ backgroundColor: themeVariables.wardley?.backgroundColor ?? themeVariables.background ?? "#fff",
449
+ axisColor: themeVariables.wardley?.axisColor ?? "#000",
450
+ axisTextColor: themeVariables.wardley?.axisTextColor ?? themeVariables.primaryTextColor ?? "#222",
451
+ gridColor: themeVariables.wardley?.gridColor ?? "rgba(100, 100, 100, 0.2)",
452
+ componentFill: themeVariables.wardley?.componentFill ?? "#fff",
453
+ componentStroke: themeVariables.wardley?.componentStroke ?? "#000",
454
+ componentLabelColor: themeVariables.wardley?.componentLabelColor ?? themeVariables.primaryTextColor ?? "#222",
455
+ linkStroke: themeVariables.wardley?.linkStroke ?? "#000",
456
+ evolutionStroke: themeVariables.wardley?.evolutionStroke ?? "#dc3545",
457
+ annotationStroke: themeVariables.wardley?.annotationStroke ?? "#000",
458
+ annotationTextColor: themeVariables.wardley?.annotationTextColor ?? themeVariables.primaryTextColor ?? "#222",
459
+ annotationFill: themeVariables.wardley?.annotationFill ?? themeVariables.background ?? "#fff"
460
+ };
461
+ }, "getTheme");
462
+ var getConfigValues = /* @__PURE__ */ __name(() => {
463
+ const wardleyConfig = getConfig2()["wardley-beta"];
464
+ return {
465
+ width: wardleyConfig?.width ?? 900,
466
+ height: wardleyConfig?.height ?? 600,
467
+ padding: wardleyConfig?.padding ?? 48,
468
+ nodeRadius: wardleyConfig?.nodeRadius ?? 6,
469
+ nodeLabelOffset: wardleyConfig?.nodeLabelOffset ?? 8,
470
+ axisFontSize: wardleyConfig?.axisFontSize ?? 12,
471
+ labelFontSize: wardleyConfig?.labelFontSize ?? 10,
472
+ showGrid: wardleyConfig?.showGrid ?? false,
473
+ useMaxWidth: wardleyConfig?.useMaxWidth ?? true
474
+ };
475
+ }, "getConfigValues");
476
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
477
+ log.debug(`Rendering Wardley map
478
+ ` + text);
479
+ const configValues = getConfigValues();
480
+ const theme = getTheme();
481
+ const squareSize = configValues.nodeRadius * 1.6;
482
+ const db = diagObj.db;
483
+ const data = db.getWardleyData();
484
+ const title = db.getDiagramTitle();
485
+ const width = data.size?.width ?? configValues.width;
486
+ const height = data.size?.height ?? configValues.height;
487
+ const svg = selectSvgElement(id);
488
+ svg.selectAll("*").remove();
489
+ configureSvgSize(svg, height, width, configValues.useMaxWidth);
490
+ svg.attr("viewBox", `0 0 ${width} ${height}`);
491
+ const root = svg.append("g").attr("class", "wardley-map");
492
+ const defs = svg.append("defs");
493
+ defs.append("marker").attr("id", `arrow-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.evolutionStroke).attr("stroke", "none");
494
+ defs.append("marker").attr("id", `link-arrow-end-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
495
+ defs.append("marker").attr("id", `link-arrow-start-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
496
+ root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
497
+ const chartWidth = width - configValues.padding * 2;
498
+ const chartHeight = height - configValues.padding * 2;
499
+ if (title) {
500
+ root.append("text").attr("class", "wardley-title").attr("x", width / 2).attr("y", configValues.padding / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
501
+ }
502
+ const projectX = /* @__PURE__ */ __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
503
+ const projectY = /* @__PURE__ */ __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
504
+ const axisGroup = root.append("g").attr("class", "wardley-axes");
505
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
506
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", configValues.padding).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
507
+ const xLabel = data.axes.xLabel ?? "Evolution";
508
+ const yLabel = data.axes.yLabel ?? "Visibility";
509
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", configValues.padding + chartWidth / 2).attr("y", height - configValues.padding / 4).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(xLabel);
510
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", configValues.padding / 3).attr("y", configValues.padding + chartHeight / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr("transform", `rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`).text(yLabel);
511
+ const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
512
+ if (stages.length > 0) {
513
+ const stageGroup = root.append("g").attr("class", "wardley-stages");
514
+ const boundaries = data.axes.stageBoundaries;
515
+ const stagePositions = [];
516
+ if (boundaries && boundaries.length === stages.length) {
517
+ let prevBoundary = 0;
518
+ boundaries.forEach((boundary) => {
519
+ stagePositions.push({ start: prevBoundary, end: boundary });
520
+ prevBoundary = boundary;
521
+ });
522
+ } else {
523
+ const stageWidth = 1 / stages.length;
524
+ stages.forEach((_, index) => {
525
+ stagePositions.push({
526
+ start: index * stageWidth,
527
+ end: (index + 1) * stageWidth
528
+ });
529
+ });
530
+ }
531
+ stages.forEach((stage, index) => {
532
+ const pos = stagePositions[index];
533
+ const startX = configValues.padding + pos.start * chartWidth;
534
+ const endX = configValues.padding + pos.end * chartWidth;
535
+ const centerX = (startX + endX) / 2;
536
+ if (index > 0) {
537
+ stageGroup.append("line").attr("x1", startX).attr("x2", startX).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8);
538
+ }
539
+ stageGroup.append("text").attr("class", "wardley-stage-label").attr("x", centerX).attr("y", height - configValues.padding / 1.5).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize - 2).attr("text-anchor", "middle").text(stage);
540
+ });
541
+ }
542
+ if (configValues.showGrid) {
543
+ const gridGroup = root.append("g").attr("class", "wardley-grid");
544
+ for (let i = 1;i < 4; i++) {
545
+ const ratio = i / 4;
546
+ const x = configValues.padding + chartWidth * ratio;
547
+ gridGroup.append("line").attr("x1", x).attr("x2", x).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
548
+ gridGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding - chartHeight * ratio).attr("y2", height - configValues.padding - chartHeight * ratio).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
549
+ }
550
+ }
551
+ const positions = /* @__PURE__ */ new Map;
552
+ data.nodes.forEach((node) => {
553
+ positions.set(node.id, {
554
+ x: projectX(node.x),
555
+ y: projectY(node.y),
556
+ node
557
+ });
558
+ });
559
+ if (data.pipelines.length > 0) {
560
+ const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
561
+ const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
562
+ data.pipelines.forEach((pipeline) => {
563
+ if (pipeline.componentIds.length === 0) {
564
+ return;
565
+ }
566
+ const sortedComponents = pipeline.componentIds.map((id2) => ({ id: id2, pos: positions.get(id2), node: data.nodes.find((n) => n.id === id2) })).filter((c) => c.pos && c.node).sort((a, b) => a.node.x - b.node.x);
567
+ for (let i = 0;i < sortedComponents.length - 1; i++) {
568
+ const current = sortedComponents[i];
569
+ const next = sortedComponents[i + 1];
570
+ pipelineLinksGroup.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", current.pos.x).attr("y1", current.pos.y).attr("x2", next.pos.x).attr("y2", next.pos.y).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
571
+ }
572
+ let minX = Infinity;
573
+ let maxX = -Infinity;
574
+ let y = 0;
575
+ pipeline.componentIds.forEach((componentId) => {
576
+ const pos = positions.get(componentId);
577
+ if (pos) {
578
+ minX = Math.min(minX, pos.x);
579
+ maxX = Math.max(maxX, pos.x);
580
+ y = pos.y;
581
+ }
582
+ });
583
+ if (minX !== Infinity && maxX !== -Infinity) {
584
+ const padding = 15;
585
+ const height2 = configValues.nodeRadius * 4;
586
+ const boxTop = y - height2 / 2;
587
+ const parentPos = positions.get(pipeline.nodeId);
588
+ if (parentPos) {
589
+ const centerX = (minX + maxX) / 2;
590
+ parentPos.x = centerX;
591
+ parentPos.y = boxTop - squareSize / 6;
592
+ }
593
+ pipelineGroup.append("rect").attr("class", "wardley-pipeline-box").attr("x", minX - padding).attr("y", boxTop).attr("width", maxX - minX + padding * 2).attr("height", height2).attr("fill", "none").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
594
+ }
595
+ });
596
+ }
597
+ const linksGroup = root.append("g").attr("class", "wardley-links");
598
+ const pipelineMap = /* @__PURE__ */ new Map;
599
+ data.pipelines.forEach((pipeline) => {
600
+ pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
601
+ });
602
+ const validLinks = data.links.filter((link) => {
603
+ if (!positions.has(link.source) || !positions.has(link.target)) {
604
+ return false;
605
+ }
606
+ const pipelineComponents = pipelineMap.get(link.target);
607
+ if (pipelineComponents?.has(link.source)) {
608
+ return false;
609
+ }
610
+ return true;
611
+ });
612
+ linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
613
+ const sourcePos = positions.get(link.source);
614
+ const targetPos = positions.get(link.target);
615
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
616
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
617
+ const dx = targetPos.x - sourcePos.x;
618
+ const dy = targetPos.y - sourcePos.y;
619
+ const distance = Math.sqrt(dx * dx + dy * dy);
620
+ return sourcePos.x + dx / distance * radius;
621
+ }).attr("y1", (link) => {
622
+ const sourcePos = positions.get(link.source);
623
+ const targetPos = positions.get(link.target);
624
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
625
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
626
+ const dx = targetPos.x - sourcePos.x;
627
+ const dy = targetPos.y - sourcePos.y;
628
+ const distance = Math.sqrt(dx * dx + dy * dy);
629
+ return sourcePos.y + dy / distance * radius;
630
+ }).attr("x2", (link) => {
631
+ const sourcePos = positions.get(link.source);
632
+ const targetPos = positions.get(link.target);
633
+ const targetNode = data.nodes.find((n) => n.id === link.target);
634
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
635
+ const dx = sourcePos.x - targetPos.x;
636
+ const dy = sourcePos.y - targetPos.y;
637
+ const distance = Math.sqrt(dx * dx + dy * dy);
638
+ return targetPos.x + dx / distance * radius;
639
+ }).attr("y2", (link) => {
640
+ const sourcePos = positions.get(link.source);
641
+ const targetPos = positions.get(link.target);
642
+ const targetNode = data.nodes.find((n) => n.id === link.target);
643
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
644
+ const dx = sourcePos.x - targetPos.x;
645
+ const dy = sourcePos.y - targetPos.y;
646
+ const distance = Math.sqrt(dx * dx + dy * dy);
647
+ return targetPos.y + dy / distance * radius;
648
+ }).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
649
+ if (link.flow === "forward" || link.flow === "bidirectional") {
650
+ return `url(#link-arrow-end-${id})`;
651
+ }
652
+ return null;
653
+ }).attr("marker-start", (link) => {
654
+ if (link.flow === "backward" || link.flow === "bidirectional") {
655
+ return `url(#link-arrow-start-${id})`;
656
+ }
657
+ return null;
658
+ });
659
+ linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
660
+ const sourcePos = positions.get(link.source);
661
+ const targetPos = positions.get(link.target);
662
+ const midX = (sourcePos.x + targetPos.x) / 2;
663
+ const dy = targetPos.y - sourcePos.y;
664
+ const dx = targetPos.x - sourcePos.x;
665
+ const distance = Math.sqrt(dx * dx + dy * dy);
666
+ const offset = 8;
667
+ const perpX = dy / distance;
668
+ return midX + perpX * offset;
669
+ }).attr("y", (link) => {
670
+ const sourcePos = positions.get(link.source);
671
+ const targetPos = positions.get(link.target);
672
+ const midY = (sourcePos.y + targetPos.y) / 2;
673
+ const dx = targetPos.x - sourcePos.x;
674
+ const dy = targetPos.y - sourcePos.y;
675
+ const distance = Math.sqrt(dx * dx + dy * dy);
676
+ const offset = 8;
677
+ const perpY = -dx / distance;
678
+ return midY + perpY * offset;
679
+ }).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
680
+ const sourcePos = positions.get(link.source);
681
+ const targetPos = positions.get(link.target);
682
+ const midX = (sourcePos.x + targetPos.x) / 2;
683
+ const midY = (sourcePos.y + targetPos.y) / 2;
684
+ const dx = targetPos.x - sourcePos.x;
685
+ const dy = targetPos.y - sourcePos.y;
686
+ const distance = Math.sqrt(dx * dx + dy * dy);
687
+ const offset = 8;
688
+ const perpX = dy / distance;
689
+ const perpY = -dx / distance;
690
+ const labelX = midX + perpX * offset;
691
+ const labelY = midY + perpY * offset;
692
+ let angle = Math.atan2(dy, dx) * 180 / Math.PI;
693
+ if (angle > 90 || angle < -90) {
694
+ angle += 180;
695
+ }
696
+ return `rotate(${angle} ${labelX} ${labelY})`;
697
+ }).text((link) => link.label);
698
+ const trendGroup = root.append("g").attr("class", "wardley-trends");
699
+ const trendsWithPositions = data.trends.map((trend) => {
700
+ const origin = positions.get(trend.nodeId);
701
+ if (!origin) {
702
+ return null;
703
+ }
704
+ const targetX = projectX(trend.targetX);
705
+ const targetY = projectY(trend.targetY);
706
+ const dx = targetX - origin.x;
707
+ const dy = targetY - origin.y;
708
+ const distance = Math.sqrt(dx * dx + dy * dy);
709
+ const shortenBy = configValues.nodeRadius + 2;
710
+ const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
711
+ const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
712
+ return {
713
+ origin,
714
+ targetX,
715
+ targetY,
716
+ adjustedX2,
717
+ adjustedY2
718
+ };
719
+ }).filter((trend) => trend !== null);
720
+ trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class", "wardley-trend").attr("x1", (trend) => trend.origin.x).attr("y1", (trend) => trend.origin.y).attr("x2", (trend) => trend.adjustedX2).attr("y2", (trend) => trend.adjustedY2).attr("stroke", theme.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${id})`);
721
+ const nodesGroup = root.append("g").attr("class", "wardley-nodes");
722
+ const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr("class", (node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" "));
723
+ nodeEnter.filter((node) => node.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#666").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
724
+ nodeEnter.filter((node) => node.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
725
+ nodeEnter.filter((node) => node.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
726
+ const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
727
+ marketNodes.append("circle").attr("class", "wardley-market-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
728
+ nodeEnter.filter((node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor").append("circle").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
729
+ const smallCircleRadius = configValues.nodeRadius * 0.7;
730
+ const triangleRadius = configValues.nodeRadius * 1.2;
731
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x).attr("y1", (node) => positions.get(node.id).y - triangleRadius).attr("x2", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
732
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
733
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x).attr("y2", (node) => positions.get(node.id).y - triangleRadius).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
734
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y - triangleRadius).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
735
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
736
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
737
+ nodeEnter.filter((node) => node.isPipelineParent === true).append("rect").attr("x", (node) => positions.get(node.id).x - squareSize / 2).attr("y", (node) => positions.get(node.id).y - squareSize / 2).attr("width", squareSize).attr("height", squareSize).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
738
+ nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
739
+ const pos = positions.get(node.id);
740
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
741
+ if (node.sourceStrategy) {
742
+ offset += configValues.nodeRadius + 10;
743
+ }
744
+ return pos.x + offset;
745
+ }).attr("y1", (node) => {
746
+ const pos = positions.get(node.id);
747
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
748
+ return pos.y - lineHeight / 2;
749
+ }).attr("x2", (node) => {
750
+ const pos = positions.get(node.id);
751
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
752
+ if (node.sourceStrategy) {
753
+ offset += configValues.nodeRadius + 10;
754
+ }
755
+ return pos.x + offset;
756
+ }).attr("y2", (node) => {
757
+ const pos = positions.get(node.id);
758
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
759
+ return pos.y + lineHeight / 2;
760
+ }).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
761
+ nodeEnter.append("text").attr("x", (node) => {
762
+ const pos = positions.get(node.id);
763
+ if (node.className === "anchor") {
764
+ return node.labelOffsetX !== undefined ? pos.x + node.labelOffsetX : pos.x;
765
+ }
766
+ let defaultOffset = configValues.nodeLabelOffset;
767
+ if (node.sourceStrategy && node.labelOffsetX === undefined) {
768
+ defaultOffset += 10;
769
+ }
770
+ const customOffset = node.labelOffsetX ?? defaultOffset;
771
+ return pos.x + customOffset;
772
+ }).attr("y", (node) => {
773
+ const pos = positions.get(node.id);
774
+ if (node.className === "anchor") {
775
+ return node.labelOffsetY !== undefined ? pos.y + node.labelOffsetY : pos.y - 3;
776
+ }
777
+ let defaultOffset = -configValues.nodeLabelOffset;
778
+ if (node.sourceStrategy && node.labelOffsetY === undefined) {
779
+ defaultOffset -= 10;
780
+ }
781
+ const customOffset = node.labelOffsetY ?? defaultOffset;
782
+ return pos.y + customOffset;
783
+ }).attr("class", "wardley-node-label").attr("fill", (node) => {
784
+ if (node.className === "evolved") {
785
+ return theme.evolutionStroke;
786
+ }
787
+ if (node.className === "anchor") {
788
+ return "#000";
789
+ }
790
+ return theme.componentLabelColor;
791
+ }).attr("font-size", configValues.labelFontSize).attr("font-weight", (node) => node.className === "anchor" ? "bold" : "normal").attr("text-anchor", (node) => node.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (node) => node.className === "anchor" ? "middle" : "auto").text((node) => node.label);
792
+ if (data.annotations.length > 0) {
793
+ const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
794
+ data.annotations.forEach((annotation) => {
795
+ const projectedCoords = annotation.coordinates.map((coord) => ({
796
+ x: projectX(coord.x),
797
+ y: projectY(coord.y)
798
+ }));
799
+ if (projectedCoords.length > 1) {
800
+ for (let i = 0;i < projectedCoords.length - 1; i++) {
801
+ annotationsGroup.append("line").attr("class", "wardley-annotation-line").attr("x1", projectedCoords[i].x).attr("y1", projectedCoords[i].y).attr("x2", projectedCoords[i + 1].x).attr("y2", projectedCoords[i + 1].y).attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
802
+ }
803
+ }
804
+ projectedCoords.forEach((coord) => {
805
+ const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
806
+ annotationNode.append("circle").attr("cx", coord.x).attr("cy", coord.y).attr("r", 10).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5);
807
+ annotationNode.append("text").attr("x", coord.x).attr("y", coord.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(annotation.number);
808
+ });
809
+ });
810
+ if (data.annotationsBox) {
811
+ let boxX = projectX(data.annotationsBox.x);
812
+ let boxY = projectY(data.annotationsBox.y);
813
+ const padding = 10;
814
+ const lineHeight = 16;
815
+ const fontSize = 11;
816
+ const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
817
+ const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
818
+ const textElements = [];
819
+ sortedAnnotations.forEach((annotation, idx) => {
820
+ const text2 = textBoxGroup.append("text").attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight).attr("font-size", fontSize).attr("fill", theme.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${annotation.number}. ${annotation.text}`);
821
+ textElements.push(text2);
822
+ });
823
+ if (textElements.length > 0) {
824
+ let maxWidth = 0;
825
+ let maxHeight = 0;
826
+ textElements.forEach((text2) => {
827
+ const textNode = text2.node();
828
+ const textWidth = textNode.getComputedTextLength();
829
+ maxWidth = Math.max(maxWidth, textWidth);
830
+ const bbox = textNode.getBBox();
831
+ maxHeight = Math.max(maxHeight, bbox.height);
832
+ });
833
+ const boxWidth = maxWidth + padding * 2 + 105;
834
+ const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
835
+ const minX = configValues.padding;
836
+ const maxX = width - configValues.padding - boxWidth;
837
+ const minY = configValues.padding;
838
+ const maxY = height - configValues.padding - boxHeight;
839
+ boxX = Math.max(minX, Math.min(boxX, maxX));
840
+ boxY = Math.max(minY, Math.min(boxY, maxY));
841
+ textElements.forEach((text2, idx) => {
842
+ text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
843
+ });
844
+ textBoxGroup.insert("rect", "text").attr("x", boxX).attr("y", boxY).attr("width", boxWidth).attr("height", boxHeight).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
845
+ }
846
+ }
847
+ }
848
+ if (data.notes.length > 0) {
849
+ const notesGroup = root.append("g").attr("class", "wardley-notes");
850
+ data.notes.forEach((note) => {
851
+ const noteX = projectX(note.x);
852
+ const noteY = projectY(note.y);
853
+ notesGroup.append("text").attr("x", noteX).attr("y", noteY).attr("text-anchor", "start").attr("font-size", 11).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(note.text);
854
+ });
855
+ }
856
+ if (data.accelerators.length > 0) {
857
+ const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
858
+ data.accelerators.forEach((accelerator) => {
859
+ const accX = projectX(accelerator.x);
860
+ const accY = projectY(accelerator.y);
861
+ const arrowWidth = 60;
862
+ const arrowHeight = 30;
863
+ const arrowHeadWidth = 20;
864
+ const arrowPath = `
865
+ M ${accX} ${accY - arrowHeight / 2}
866
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
867
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
868
+ L ${accX + arrowWidth} ${accY}
869
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
870
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
871
+ L ${accX} ${accY + arrowHeight / 2}
872
+ Z
873
+ `;
874
+ acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
875
+ acceleratorsGroup.append("text").attr("x", accX + arrowWidth / 2).attr("y", accY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(accelerator.name);
876
+ });
877
+ }
878
+ if (data.deaccelerators.length > 0) {
879
+ const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
880
+ data.deaccelerators.forEach((deaccelerator) => {
881
+ const decX = projectX(deaccelerator.x);
882
+ const decY = projectY(deaccelerator.y);
883
+ const arrowWidth = 60;
884
+ const arrowHeight = 30;
885
+ const arrowHeadWidth = 20;
886
+ const arrowPath = `
887
+ M ${decX + arrowWidth} ${decY - arrowHeight / 2}
888
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
889
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
890
+ L ${decX} ${decY}
891
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
892
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
893
+ L ${decX + arrowWidth} ${decY + arrowHeight / 2}
894
+ Z
895
+ `;
896
+ deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
897
+ deacceleratorsGroup.append("text").attr("x", decX + arrowWidth / 2).attr("y", decY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(deaccelerator.name);
898
+ });
899
+ }
900
+ }, "draw");
901
+ var wardleyRenderer_default = {
902
+ draw
903
+ };
904
+ var styles = /* @__PURE__ */ __name(({
905
+ wardley
906
+ } = {}) => {
907
+ const defaultThemeVariables = getThemeVariables3();
908
+ const currentConfig = getConfig();
909
+ const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
910
+ const w = cleanAndMerge(themeVariables.wardley, wardley);
911
+ return `
912
+ .wardley-background {
913
+ fill: ${w.backgroundColor};
914
+ }
915
+ .wardley-axes line, .wardley-axes path {
916
+ stroke: ${w.axisColor};
917
+ }
918
+ .wardley-axis-label {
919
+ fill: ${w.axisTextColor};
920
+ }
921
+ .wardley-stage-label {
922
+ fill: ${w.axisTextColor};
923
+ }
924
+ .wardley-grid line {
925
+ stroke: ${w.gridColor};
926
+ }
927
+ .wardley-node circle {
928
+ fill: ${w.componentFill};
929
+ stroke: ${w.componentStroke};
930
+ }
931
+ .wardley-node-label {
932
+ fill: ${w.componentLabelColor};
933
+ }
934
+ .wardley-link {
935
+ stroke: ${w.linkStroke};
936
+ }
937
+ .wardley-link--dashed {
938
+ stroke-dasharray: 4 4;
939
+ }
940
+ .wardley-link-label {
941
+ fill: ${w.axisTextColor};
942
+ }
943
+ .wardley-trend line {
944
+ stroke: ${w.evolutionStroke};
945
+ }
946
+ .wardley-annotation-line {
947
+ stroke: ${w.annotationStroke};
948
+ }
949
+ .wardley-annotation circle {
950
+ fill: ${w.annotationFill};
951
+ stroke: ${w.annotationStroke};
952
+ }
953
+ .wardley-annotation text {
954
+ fill: ${w.annotationTextColor};
955
+ }
956
+ .wardley-annotations-box rect {
957
+ fill: ${w.annotationFill};
958
+ stroke: ${w.annotationStroke};
959
+ }
960
+ .wardley-annotations-box text {
961
+ fill: ${w.annotationTextColor};
962
+ }
963
+ .wardley-pipeline-box {
964
+ stroke: ${w.componentStroke};
965
+ }
966
+ .wardley-notes text {
967
+ fill: ${w.axisTextColor};
968
+ }
969
+ `;
970
+ }, "styles");
971
+ var diagram = {
972
+ parser,
973
+ db: wardleyDb_default,
974
+ renderer: wardleyRenderer_default,
975
+ styles
976
+ };
977
+ export {
978
+ diagram
979
+ };