@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,975 @@
1
+ import {
2
+ selectSvgElement
3
+ } from "./markdown-6zz8efx2.js";
4
+ import {
5
+ at
6
+ } from "./markdown-82xmzhzd.js";
7
+ import {
8
+ parseFontSize
9
+ } from "./markdown-ff5wvb43.js";
10
+ import"./markdown-pzgd8z3s.js";
11
+ import {
12
+ clear,
13
+ common_default,
14
+ configureSvgSize,
15
+ getAccDescription,
16
+ getAccTitle,
17
+ getConfig2,
18
+ getDiagramTitle,
19
+ setAccDescription,
20
+ setAccTitle,
21
+ setDiagramTitle
22
+ } from "./markdown-92n37gd4.js";
23
+ import"./markdown-xw8dsk8b.js";
24
+ import {
25
+ __name
26
+ } from "./markdown-1s5vwkf2.js";
27
+ import"./markdown-dy5sgjhc.js";
28
+ import"./markdown-809k7q41.js";
29
+
30
+ // node_modules/mermaid/dist/chunks/mermaid.core/ishikawaDiagram-WSZJBQD7.mjs
31
+ var parser = function() {
32
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
33
+ for (o2 = o2 || {}, l = k.length;l--; o2[k[l]] = v)
34
+ ;
35
+ return o2;
36
+ }, "o"), $V0 = [1, 4], $V1 = [1, 14], $V2 = [1, 12], $V3 = [1, 13], $V4 = [6, 7, 8], $V5 = [1, 20], $V6 = [1, 18], $V7 = [1, 19], $V8 = [6, 7, 11], $V9 = [1, 6, 13, 14], $Va = [1, 23], $Vb = [1, 24], $Vc = [1, 6, 7, 11, 13, 14];
37
+ var parser2 = {
38
+ trace: /* @__PURE__ */ __name(function trace() {}, "trace"),
39
+ yy: {},
40
+ symbols_: { error: 2, start: 3, ishikawa: 4, spaceLines: 5, SPACELINE: 6, NL: 7, ISHIKAWA: 8, document: 9, stop: 10, EOF: 11, statement: 12, SPACELIST: 13, TEXT: 14, $accept: 0, $end: 1 },
41
+ terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "ISHIKAWA", 11: "EOF", 13: "SPACELIST", 14: "TEXT" },
42
+ productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 1], [12, 1], [12, 1]],
43
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
44
+ var $0 = $$.length - 1;
45
+ switch (yystate) {
46
+ case 6:
47
+ case 7:
48
+ return yy;
49
+ break;
50
+ case 15:
51
+ yy.addNode($$[$0 - 1].length, $$[$0].trim());
52
+ break;
53
+ case 16:
54
+ yy.addNode(0, $$[$0].trim());
55
+ break;
56
+ }
57
+ }, "anonymous"),
58
+ table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: $V3 }, o($V4, [2, 3]), { 1: [2, 2] }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 6], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, { 6: $V1, 9: 16, 12: 11, 13: $V2, 14: $V3 }, { 6: $V5, 7: $V6, 10: 17, 11: $V7 }, o($V8, [2, 18], { 14: [1, 21] }), o($V8, [2, 16]), o($V8, [2, 17]), { 6: $V5, 7: $V6, 10: 22, 11: $V7 }, { 1: [2, 7], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, o($V9, [2, 14], { 7: $Va, 11: $Vb }), o($Vc, [2, 8]), o($Vc, [2, 9]), o($Vc, [2, 10]), o($V8, [2, 15]), o($V9, [2, 13], { 7: $Va, 11: $Vb }), o($Vc, [2, 11]), o($Vc, [2, 12])],
59
+ defaultActions: { 2: [2, 1], 6: [2, 2] },
60
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
61
+ if (hash.recoverable) {
62
+ this.trace(str);
63
+ } else {
64
+ var error = new Error(str);
65
+ error.hash = hash;
66
+ throw error;
67
+ }
68
+ }, "parseError"),
69
+ parse: /* @__PURE__ */ __name(function parse(input) {
70
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
71
+ var args = lstack.slice.call(arguments, 1);
72
+ var lexer2 = Object.create(this.lexer);
73
+ var sharedState = { yy: {} };
74
+ for (var k in this.yy) {
75
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
76
+ sharedState.yy[k] = this.yy[k];
77
+ }
78
+ }
79
+ lexer2.setInput(input, sharedState.yy);
80
+ sharedState.yy.lexer = lexer2;
81
+ sharedState.yy.parser = this;
82
+ if (typeof lexer2.yylloc == "undefined") {
83
+ lexer2.yylloc = {};
84
+ }
85
+ var yyloc = lexer2.yylloc;
86
+ lstack.push(yyloc);
87
+ var ranges = lexer2.options && lexer2.options.ranges;
88
+ if (typeof sharedState.yy.parseError === "function") {
89
+ this.parseError = sharedState.yy.parseError;
90
+ } else {
91
+ this.parseError = Object.getPrototypeOf(this).parseError;
92
+ }
93
+ function popStack(n) {
94
+ stack.length = stack.length - 2 * n;
95
+ vstack.length = vstack.length - n;
96
+ lstack.length = lstack.length - n;
97
+ }
98
+ __name(popStack, "popStack");
99
+ function lex() {
100
+ var token;
101
+ token = tstack.pop() || lexer2.lex() || EOF;
102
+ if (typeof token !== "number") {
103
+ if (token instanceof Array) {
104
+ tstack = token;
105
+ token = tstack.pop();
106
+ }
107
+ token = self.symbols_[token] || token;
108
+ }
109
+ return token;
110
+ }
111
+ __name(lex, "lex");
112
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
113
+ while (true) {
114
+ state = stack[stack.length - 1];
115
+ if (this.defaultActions[state]) {
116
+ action = this.defaultActions[state];
117
+ } else {
118
+ if (symbol === null || typeof symbol == "undefined") {
119
+ symbol = lex();
120
+ }
121
+ action = table[state] && table[state][symbol];
122
+ }
123
+ if (typeof action === "undefined" || !action.length || !action[0]) {
124
+ var errStr = "";
125
+ expected = [];
126
+ for (p in table[state]) {
127
+ if (this.terminals_[p] && p > TERROR) {
128
+ expected.push("'" + this.terminals_[p] + "'");
129
+ }
130
+ }
131
+ if (lexer2.showPosition) {
132
+ errStr = "Parse error on line " + (yylineno + 1) + `:
133
+ ` + lexer2.showPosition() + `
134
+ Expecting ` + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
135
+ } else {
136
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
137
+ }
138
+ this.parseError(errStr, {
139
+ text: lexer2.match,
140
+ token: this.terminals_[symbol] || symbol,
141
+ line: lexer2.yylineno,
142
+ loc: yyloc,
143
+ expected
144
+ });
145
+ }
146
+ if (action[0] instanceof Array && action.length > 1) {
147
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
148
+ }
149
+ switch (action[0]) {
150
+ case 1:
151
+ stack.push(symbol);
152
+ vstack.push(lexer2.yytext);
153
+ lstack.push(lexer2.yylloc);
154
+ stack.push(action[1]);
155
+ symbol = null;
156
+ if (!preErrorSymbol) {
157
+ yyleng = lexer2.yyleng;
158
+ yytext = lexer2.yytext;
159
+ yylineno = lexer2.yylineno;
160
+ yyloc = lexer2.yylloc;
161
+ if (recovering > 0) {
162
+ recovering--;
163
+ }
164
+ } else {
165
+ symbol = preErrorSymbol;
166
+ preErrorSymbol = null;
167
+ }
168
+ break;
169
+ case 2:
170
+ len = this.productions_[action[1]][1];
171
+ yyval.$ = vstack[vstack.length - len];
172
+ yyval._$ = {
173
+ first_line: lstack[lstack.length - (len || 1)].first_line,
174
+ last_line: lstack[lstack.length - 1].last_line,
175
+ first_column: lstack[lstack.length - (len || 1)].first_column,
176
+ last_column: lstack[lstack.length - 1].last_column
177
+ };
178
+ if (ranges) {
179
+ yyval._$.range = [
180
+ lstack[lstack.length - (len || 1)].range[0],
181
+ lstack[lstack.length - 1].range[1]
182
+ ];
183
+ }
184
+ r = this.performAction.apply(yyval, [
185
+ yytext,
186
+ yyleng,
187
+ yylineno,
188
+ sharedState.yy,
189
+ action[1],
190
+ vstack,
191
+ lstack
192
+ ].concat(args));
193
+ if (typeof r !== "undefined") {
194
+ return r;
195
+ }
196
+ if (len) {
197
+ stack = stack.slice(0, -1 * len * 2);
198
+ vstack = vstack.slice(0, -1 * len);
199
+ lstack = lstack.slice(0, -1 * len);
200
+ }
201
+ stack.push(this.productions_[action[1]][0]);
202
+ vstack.push(yyval.$);
203
+ lstack.push(yyval._$);
204
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
205
+ stack.push(newState);
206
+ break;
207
+ case 3:
208
+ return true;
209
+ }
210
+ }
211
+ return true;
212
+ }, "parse")
213
+ };
214
+ var lexer = /* @__PURE__ */ function() {
215
+ var lexer2 = {
216
+ EOF: 1,
217
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
218
+ if (this.yy.parser) {
219
+ this.yy.parser.parseError(str, hash);
220
+ } else {
221
+ throw new Error(str);
222
+ }
223
+ }, "parseError"),
224
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
225
+ this.yy = yy || this.yy || {};
226
+ this._input = input;
227
+ this._more = this._backtrack = this.done = false;
228
+ this.yylineno = this.yyleng = 0;
229
+ this.yytext = this.matched = this.match = "";
230
+ this.conditionStack = ["INITIAL"];
231
+ this.yylloc = {
232
+ first_line: 1,
233
+ first_column: 0,
234
+ last_line: 1,
235
+ last_column: 0
236
+ };
237
+ if (this.options.ranges) {
238
+ this.yylloc.range = [0, 0];
239
+ }
240
+ this.offset = 0;
241
+ return this;
242
+ }, "setInput"),
243
+ input: /* @__PURE__ */ __name(function() {
244
+ var ch = this._input[0];
245
+ this.yytext += ch;
246
+ this.yyleng++;
247
+ this.offset++;
248
+ this.match += ch;
249
+ this.matched += ch;
250
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
251
+ if (lines) {
252
+ this.yylineno++;
253
+ this.yylloc.last_line++;
254
+ } else {
255
+ this.yylloc.last_column++;
256
+ }
257
+ if (this.options.ranges) {
258
+ this.yylloc.range[1]++;
259
+ }
260
+ this._input = this._input.slice(1);
261
+ return ch;
262
+ }, "input"),
263
+ unput: /* @__PURE__ */ __name(function(ch) {
264
+ var len = ch.length;
265
+ var lines = ch.split(/(?:\r\n?|\n)/g);
266
+ this._input = ch + this._input;
267
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
268
+ this.offset -= len;
269
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
270
+ this.match = this.match.substr(0, this.match.length - 1);
271
+ this.matched = this.matched.substr(0, this.matched.length - 1);
272
+ if (lines.length - 1) {
273
+ this.yylineno -= lines.length - 1;
274
+ }
275
+ var r = this.yylloc.range;
276
+ this.yylloc = {
277
+ first_line: this.yylloc.first_line,
278
+ last_line: this.yylineno + 1,
279
+ first_column: this.yylloc.first_column,
280
+ 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
281
+ };
282
+ if (this.options.ranges) {
283
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
284
+ }
285
+ this.yyleng = this.yytext.length;
286
+ return this;
287
+ }, "unput"),
288
+ more: /* @__PURE__ */ __name(function() {
289
+ this._more = true;
290
+ return this;
291
+ }, "more"),
292
+ reject: /* @__PURE__ */ __name(function() {
293
+ if (this.options.backtrack_lexer) {
294
+ this._backtrack = true;
295
+ } else {
296
+ 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).
297
+ ` + this.showPosition(), {
298
+ text: "",
299
+ token: null,
300
+ line: this.yylineno
301
+ });
302
+ }
303
+ return this;
304
+ }, "reject"),
305
+ less: /* @__PURE__ */ __name(function(n) {
306
+ this.unput(this.match.slice(n));
307
+ }, "less"),
308
+ pastInput: /* @__PURE__ */ __name(function() {
309
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
310
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
311
+ }, "pastInput"),
312
+ upcomingInput: /* @__PURE__ */ __name(function() {
313
+ var next = this.match;
314
+ if (next.length < 20) {
315
+ next += this._input.substr(0, 20 - next.length);
316
+ }
317
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
318
+ }, "upcomingInput"),
319
+ showPosition: /* @__PURE__ */ __name(function() {
320
+ var pre = this.pastInput();
321
+ var c = new Array(pre.length + 1).join("-");
322
+ return pre + this.upcomingInput() + `
323
+ ` + c + "^";
324
+ }, "showPosition"),
325
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
326
+ var token, lines, backup;
327
+ if (this.options.backtrack_lexer) {
328
+ backup = {
329
+ yylineno: this.yylineno,
330
+ yylloc: {
331
+ first_line: this.yylloc.first_line,
332
+ last_line: this.last_line,
333
+ first_column: this.yylloc.first_column,
334
+ last_column: this.yylloc.last_column
335
+ },
336
+ yytext: this.yytext,
337
+ match: this.match,
338
+ matches: this.matches,
339
+ matched: this.matched,
340
+ yyleng: this.yyleng,
341
+ offset: this.offset,
342
+ _more: this._more,
343
+ _input: this._input,
344
+ yy: this.yy,
345
+ conditionStack: this.conditionStack.slice(0),
346
+ done: this.done
347
+ };
348
+ if (this.options.ranges) {
349
+ backup.yylloc.range = this.yylloc.range.slice(0);
350
+ }
351
+ }
352
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
353
+ if (lines) {
354
+ this.yylineno += lines.length;
355
+ }
356
+ this.yylloc = {
357
+ first_line: this.yylloc.last_line,
358
+ last_line: this.yylineno + 1,
359
+ first_column: this.yylloc.last_column,
360
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
361
+ };
362
+ this.yytext += match[0];
363
+ this.match += match[0];
364
+ this.matches = match;
365
+ this.yyleng = this.yytext.length;
366
+ if (this.options.ranges) {
367
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
368
+ }
369
+ this._more = false;
370
+ this._backtrack = false;
371
+ this._input = this._input.slice(match[0].length);
372
+ this.matched += match[0];
373
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
374
+ if (this.done && this._input) {
375
+ this.done = false;
376
+ }
377
+ if (token) {
378
+ return token;
379
+ } else if (this._backtrack) {
380
+ for (var k in backup) {
381
+ this[k] = backup[k];
382
+ }
383
+ return false;
384
+ }
385
+ return false;
386
+ }, "test_match"),
387
+ next: /* @__PURE__ */ __name(function() {
388
+ if (this.done) {
389
+ return this.EOF;
390
+ }
391
+ if (!this._input) {
392
+ this.done = true;
393
+ }
394
+ var token, match, tempMatch, index;
395
+ if (!this._more) {
396
+ this.yytext = "";
397
+ this.match = "";
398
+ }
399
+ var rules = this._currentRules();
400
+ for (var i = 0;i < rules.length; i++) {
401
+ tempMatch = this._input.match(this.rules[rules[i]]);
402
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
403
+ match = tempMatch;
404
+ index = i;
405
+ if (this.options.backtrack_lexer) {
406
+ token = this.test_match(tempMatch, rules[i]);
407
+ if (token !== false) {
408
+ return token;
409
+ } else if (this._backtrack) {
410
+ match = false;
411
+ continue;
412
+ } else {
413
+ return false;
414
+ }
415
+ } else if (!this.options.flex) {
416
+ break;
417
+ }
418
+ }
419
+ }
420
+ if (match) {
421
+ token = this.test_match(match, rules[index]);
422
+ if (token !== false) {
423
+ return token;
424
+ }
425
+ return false;
426
+ }
427
+ if (this._input === "") {
428
+ return this.EOF;
429
+ } else {
430
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
431
+ ` + this.showPosition(), {
432
+ text: "",
433
+ token: null,
434
+ line: this.yylineno
435
+ });
436
+ }
437
+ }, "next"),
438
+ lex: /* @__PURE__ */ __name(function lex() {
439
+ var r = this.next();
440
+ if (r) {
441
+ return r;
442
+ } else {
443
+ return this.lex();
444
+ }
445
+ }, "lex"),
446
+ begin: /* @__PURE__ */ __name(function begin(condition) {
447
+ this.conditionStack.push(condition);
448
+ }, "begin"),
449
+ popState: /* @__PURE__ */ __name(function popState() {
450
+ var n = this.conditionStack.length - 1;
451
+ if (n > 0) {
452
+ return this.conditionStack.pop();
453
+ } else {
454
+ return this.conditionStack[0];
455
+ }
456
+ }, "popState"),
457
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
458
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
459
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
460
+ } else {
461
+ return this.conditions["INITIAL"].rules;
462
+ }
463
+ }, "_currentRules"),
464
+ topState: /* @__PURE__ */ __name(function topState(n) {
465
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
466
+ if (n >= 0) {
467
+ return this.conditionStack[n];
468
+ } else {
469
+ return "INITIAL";
470
+ }
471
+ }, "topState"),
472
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
473
+ this.begin(condition);
474
+ }, "pushState"),
475
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
476
+ return this.conditionStack.length;
477
+ }, "stateStackSize"),
478
+ options: { "case-insensitive": true },
479
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
480
+ var YYSTATE = YY_START;
481
+ switch ($avoiding_name_collisions) {
482
+ case 0:
483
+ return 6;
484
+ break;
485
+ case 1:
486
+ return 8;
487
+ break;
488
+ case 2:
489
+ return 8;
490
+ break;
491
+ case 3:
492
+ return 6;
493
+ break;
494
+ case 4:
495
+ return 7;
496
+ break;
497
+ case 5:
498
+ return 13;
499
+ break;
500
+ case 6:
501
+ return 14;
502
+ break;
503
+ case 7:
504
+ return 11;
505
+ break;
506
+ }
507
+ }, "anonymous"),
508
+ rules: [/^(?:\s*%%.*)/i, /^(?:ishikawa-beta\b)/i, /^(?:ishikawa\b)/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:[^\n]+)/i, /^(?:$)/i],
509
+ conditions: { INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7], inclusive: true } }
510
+ };
511
+ return lexer2;
512
+ }();
513
+ parser2.lexer = lexer;
514
+ function Parser() {
515
+ this.yy = {};
516
+ }
517
+ __name(Parser, "Parser");
518
+ Parser.prototype = parser2;
519
+ parser2.Parser = Parser;
520
+ return new Parser;
521
+ }();
522
+ parser.parser = parser;
523
+ var ishikawa_default = parser;
524
+ var IshikawaDB = class {
525
+ constructor() {
526
+ this.stack = [];
527
+ this.clear = this.clear.bind(this);
528
+ this.addNode = this.addNode.bind(this);
529
+ this.getRoot = this.getRoot.bind(this);
530
+ }
531
+ static {
532
+ __name(this, "IshikawaDB");
533
+ }
534
+ clear() {
535
+ this.root = undefined;
536
+ this.stack = [];
537
+ this.baseLevel = undefined;
538
+ clear();
539
+ }
540
+ getRoot() {
541
+ return this.root;
542
+ }
543
+ addNode(rawLevel, text) {
544
+ const label = common_default.sanitizeText(text, getConfig2());
545
+ if (!this.root) {
546
+ this.root = { text: label, children: [] };
547
+ this.stack = [{ level: 0, node: this.root }];
548
+ setDiagramTitle(label);
549
+ return;
550
+ }
551
+ this.baseLevel ??= rawLevel;
552
+ let level = rawLevel - this.baseLevel + 1;
553
+ if (level <= 0) {
554
+ level = 1;
555
+ }
556
+ while (this.stack.length > 1 && this.stack[this.stack.length - 1].level >= level) {
557
+ this.stack.pop();
558
+ }
559
+ const parent = this.stack[this.stack.length - 1].node;
560
+ const node = { text: label, children: [] };
561
+ parent.children.push(node);
562
+ this.stack.push({ level, node });
563
+ }
564
+ getAccTitle() {
565
+ return getAccTitle();
566
+ }
567
+ setAccTitle(title) {
568
+ setAccTitle(title);
569
+ }
570
+ getAccDescription() {
571
+ return getAccDescription();
572
+ }
573
+ setAccDescription(description) {
574
+ setAccDescription(description);
575
+ }
576
+ getDiagramTitle() {
577
+ return getDiagramTitle();
578
+ }
579
+ setDiagramTitle(title) {
580
+ setDiagramTitle(title);
581
+ }
582
+ };
583
+ var FONT_SIZE_DEFAULT = 14;
584
+ var SPINE_BASE_LENGTH = 250;
585
+ var BONE_STUB = 30;
586
+ var BONE_BASE = 60;
587
+ var BONE_PER_CHILD = 5;
588
+ var ANGLE = 82 * Math.PI / 180;
589
+ var COS_A = Math.cos(ANGLE);
590
+ var SIN_A = Math.sin(ANGLE);
591
+ var applyPaddedViewBox = /* @__PURE__ */ __name((svgEl, pad, maxW) => {
592
+ const bbox = svgEl.node().getBBox();
593
+ const w = bbox.width + pad * 2;
594
+ const h = bbox.height + pad * 2;
595
+ configureSvgSize(svgEl, h, w, maxW);
596
+ svgEl.attr("viewBox", `${bbox.x - pad} ${bbox.y - pad} ${w} ${h}`);
597
+ }, "applyPaddedViewBox");
598
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
599
+ const db = diagram2.db;
600
+ const root = db.getRoot();
601
+ if (!root) {
602
+ return;
603
+ }
604
+ const drawConfig = getConfig2();
605
+ const { look, handDrawnSeed, themeVariables } = drawConfig;
606
+ const fontSize = parseFontSize(drawConfig.fontSize)[0] ?? FONT_SIZE_DEFAULT;
607
+ const isHandDrawn = look === "handDrawn";
608
+ const causes = root.children ?? [];
609
+ const padding = drawConfig.ishikawa?.diagramPadding ?? 20;
610
+ const useMaxWidth = drawConfig.ishikawa?.useMaxWidth ?? false;
611
+ const svg = selectSvgElement(id);
612
+ const g = svg.append("g").attr("class", "ishikawa");
613
+ const roughSvg = isHandDrawn ? at.svg(svg.node()) : undefined;
614
+ const roughContext = roughSvg ? {
615
+ roughSvg,
616
+ seed: handDrawnSeed ?? 0,
617
+ lineColor: themeVariables?.lineColor ?? "#333",
618
+ fillColor: themeVariables?.mainBkg ?? "#fff"
619
+ } : undefined;
620
+ const markerId = `ishikawa-arrow-${id}`;
621
+ if (!isHandDrawn) {
622
+ g.append("defs").append("marker").attr("id", markerId).attr("viewBox", "0 0 10 10").attr("refX", 0).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 Z").attr("class", "ishikawa-arrow");
623
+ }
624
+ let spineX = 0;
625
+ let spineY = SPINE_BASE_LENGTH;
626
+ const spineLine = isHandDrawn ? undefined : drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine");
627
+ drawHead(g, spineX, spineY, root.text, fontSize, roughContext);
628
+ if (!causes.length) {
629
+ if (isHandDrawn) {
630
+ drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine", roughContext);
631
+ }
632
+ applyPaddedViewBox(svg, padding, useMaxWidth);
633
+ return;
634
+ }
635
+ spineX -= 20;
636
+ const upperCauses = causes.filter((_, i) => i % 2 === 0);
637
+ const lowerCauses = causes.filter((_, i) => i % 2 === 1);
638
+ const upperStats = sideStats(upperCauses);
639
+ const lowerStats = sideStats(lowerCauses);
640
+ const descendantTotal = upperStats.total + lowerStats.total;
641
+ let upperLen = SPINE_BASE_LENGTH;
642
+ let lowerLen = SPINE_BASE_LENGTH;
643
+ if (descendantTotal > 0) {
644
+ const pool = SPINE_BASE_LENGTH * 2;
645
+ const minLen = SPINE_BASE_LENGTH * 0.3;
646
+ upperLen = Math.max(minLen, pool * (upperStats.total / descendantTotal));
647
+ lowerLen = Math.max(minLen, pool * (lowerStats.total / descendantTotal));
648
+ }
649
+ const minSpacing = fontSize * 2;
650
+ upperLen = Math.max(upperLen, upperStats.max * minSpacing);
651
+ lowerLen = Math.max(lowerLen, lowerStats.max * minSpacing);
652
+ spineY = Math.max(upperLen, SPINE_BASE_LENGTH);
653
+ if (spineLine) {
654
+ spineLine.attr("y1", spineY).attr("y2", spineY);
655
+ }
656
+ g.select(".ishikawa-head-group").attr("transform", `translate(0,${spineY})`);
657
+ const pairCount = Math.ceil(causes.length / 2);
658
+ for (let p = 0;p < pairCount; p++) {
659
+ const pg = g.append("g").attr("class", "ishikawa-pair");
660
+ for (const [cause, dir, len] of [
661
+ [causes[p * 2], -1, upperLen],
662
+ [causes[p * 2 + 1], 1, lowerLen]
663
+ ]) {
664
+ if (cause) {
665
+ drawBranch(pg, cause, spineX, spineY, dir, len, fontSize, roughContext);
666
+ }
667
+ }
668
+ spineX = pg.selectAll("text").nodes().reduce((left, n) => Math.min(left, n.getBBox().x), Infinity);
669
+ }
670
+ if (isHandDrawn) {
671
+ drawLine(g, spineX, spineY, 0, spineY, "ishikawa-spine", roughContext);
672
+ } else {
673
+ spineLine.attr("x1", spineX);
674
+ const markerUrl = `url(#${markerId})`;
675
+ g.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start", markerUrl);
676
+ }
677
+ applyPaddedViewBox(svg, padding, useMaxWidth);
678
+ }, "draw");
679
+ var sideStats = /* @__PURE__ */ __name((nodes) => {
680
+ const countDescendants = /* @__PURE__ */ __name((node) => node.children.reduce((sum, child) => sum + 1 + countDescendants(child), 0), "countDescendants");
681
+ return nodes.reduce((stats, node) => {
682
+ const descendants = countDescendants(node);
683
+ stats.total += descendants;
684
+ stats.max = Math.max(stats.max, descendants);
685
+ return stats;
686
+ }, { total: 0, max: 0 });
687
+ }, "sideStats");
688
+ var drawHead = /* @__PURE__ */ __name((svg, x, y, label, fontSize, roughContext) => {
689
+ const maxChars = Math.max(6, Math.floor(110 / (fontSize * 0.6)));
690
+ const headGroup = svg.append("g").attr("class", "ishikawa-head-group").attr("transform", `translate(${x},${y})`);
691
+ const textEl = drawMultilineText(headGroup, wrapText(label, maxChars), 0, 0, "ishikawa-head-label", "start", fontSize);
692
+ const tb = textEl.node().getBBox();
693
+ const w = Math.max(60, tb.width + 6);
694
+ const h = Math.max(40, tb.height * 2 + 40);
695
+ const headPath = `M 0 ${-h / 2} L 0 ${h / 2} Q ${w * 2.4} 0 0 ${-h / 2} Z`;
696
+ if (roughContext) {
697
+ const roughNode = roughContext.roughSvg.path(headPath, {
698
+ roughness: 1.5,
699
+ seed: roughContext.seed,
700
+ fill: roughContext.fillColor,
701
+ fillStyle: "hachure",
702
+ fillWeight: 2.5,
703
+ hachureGap: 5,
704
+ stroke: roughContext.lineColor,
705
+ strokeWidth: 2
706
+ });
707
+ headGroup.insert(() => roughNode, ":first-child").attr("class", "ishikawa-head");
708
+ } else {
709
+ headGroup.insert("path", ":first-child").attr("class", "ishikawa-head").attr("d", headPath);
710
+ }
711
+ textEl.attr("transform", `translate(${(w - tb.width) / 2 - tb.x + 3},${-tb.y - tb.height / 2})`);
712
+ }, "drawHead");
713
+ var flattenTree = /* @__PURE__ */ __name((children, direction) => {
714
+ const entries = [];
715
+ const yOrder = [];
716
+ const walk = /* @__PURE__ */ __name((nodes, pid, depth) => {
717
+ const ordered = direction === -1 ? [...nodes].reverse() : nodes;
718
+ for (const child of ordered) {
719
+ const idx = entries.length;
720
+ const gc = child.children ?? [];
721
+ entries.push({
722
+ depth,
723
+ text: wrapText(child.text, 15),
724
+ parentIndex: pid,
725
+ childCount: gc.length
726
+ });
727
+ if (depth % 2 === 0) {
728
+ yOrder.push(idx);
729
+ if (gc.length) {
730
+ walk(gc, idx, depth + 1);
731
+ }
732
+ } else {
733
+ if (gc.length) {
734
+ walk(gc, idx, depth + 1);
735
+ }
736
+ yOrder.push(idx);
737
+ }
738
+ }
739
+ }, "walk");
740
+ walk(children, -1, 2);
741
+ return { entries, yOrder };
742
+ }, "flattenTree");
743
+ var drawCauseLabel = /* @__PURE__ */ __name((svg, text, x, y, direction, fontSize, roughContext) => {
744
+ const lg = svg.append("g").attr("class", "ishikawa-label-group");
745
+ const lt = drawMultilineText(lg, text, x, y + 11 * direction, "ishikawa-label cause", "middle", fontSize);
746
+ const tb = lt.node().getBBox();
747
+ if (roughContext) {
748
+ const roughNode = roughContext.roughSvg.rectangle(tb.x - 20, tb.y - 2, tb.width + 40, tb.height + 4, {
749
+ roughness: 1.5,
750
+ seed: roughContext.seed,
751
+ fill: roughContext.fillColor,
752
+ fillStyle: "hachure",
753
+ fillWeight: 2.5,
754
+ hachureGap: 5,
755
+ stroke: roughContext.lineColor,
756
+ strokeWidth: 2
757
+ });
758
+ lg.insert(() => roughNode, ":first-child").attr("class", "ishikawa-label-box");
759
+ } else {
760
+ lg.insert("rect", ":first-child").attr("class", "ishikawa-label-box").attr("x", tb.x - 20).attr("y", tb.y - 2).attr("width", tb.width + 40).attr("height", tb.height + 4);
761
+ }
762
+ }, "drawCauseLabel");
763
+ var drawArrowMarker = /* @__PURE__ */ __name((g, x, y, dx, dy, roughContext) => {
764
+ const len = Math.sqrt(dx * dx + dy * dy);
765
+ if (len === 0) {
766
+ return;
767
+ }
768
+ const ux = dx / len;
769
+ const uy = dy / len;
770
+ const s = 6;
771
+ const px = -uy * s;
772
+ const py = ux * s;
773
+ const tipX = x;
774
+ const tipY = y;
775
+ const d = `M ${tipX} ${tipY} L ${tipX - ux * s * 2 + px} ${tipY - uy * s * 2 + py} L ${tipX - ux * s * 2 - px} ${tipY - uy * s * 2 - py} Z`;
776
+ const roughNode = roughContext.roughSvg.path(d, {
777
+ roughness: 1,
778
+ seed: roughContext.seed,
779
+ fill: roughContext.lineColor,
780
+ fillStyle: "solid",
781
+ stroke: roughContext.lineColor,
782
+ strokeWidth: 1
783
+ });
784
+ g.append(() => roughNode);
785
+ }, "drawArrowMarker");
786
+ var drawBranch = /* @__PURE__ */ __name((svg, node, startX, startY, direction, length, fontSize, roughContext) => {
787
+ const children = node.children ?? [];
788
+ const lineLen = length * (children.length ? 1 : 0.2);
789
+ const dx = -COS_A * lineLen;
790
+ const dy = SIN_A * lineLen * direction;
791
+ const endX = startX + dx;
792
+ const endY = startY + dy;
793
+ drawLine(svg, startX, startY, endX, endY, "ishikawa-branch", roughContext);
794
+ if (roughContext) {
795
+ drawArrowMarker(svg, startX, startY, startX - endX, startY - endY, roughContext);
796
+ }
797
+ drawCauseLabel(svg, node.text, endX, endY, direction, fontSize, roughContext);
798
+ if (!children.length) {
799
+ return;
800
+ }
801
+ const { entries, yOrder } = flattenTree(children, direction);
802
+ const entryCount = entries.length;
803
+ const ys = new Array(entryCount);
804
+ for (const [slot, entryIdx] of yOrder.entries()) {
805
+ ys[entryIdx] = startY + dy * ((slot + 1) / (entryCount + 1));
806
+ }
807
+ const bones = /* @__PURE__ */ new Map;
808
+ bones.set(-1, {
809
+ x0: startX,
810
+ y0: startY,
811
+ x1: endX,
812
+ y1: endY,
813
+ childCount: children.length,
814
+ childrenDrawn: 0
815
+ });
816
+ const diagonalX = -COS_A;
817
+ const diagonalY = SIN_A * direction;
818
+ const oddLabel = direction < 0 ? "ishikawa-label up" : "ishikawa-label down";
819
+ for (const [i, e] of entries.entries()) {
820
+ const y = ys[i];
821
+ const par = bones.get(e.parentIndex);
822
+ const grp = svg.append("g").attr("class", "ishikawa-sub-group");
823
+ let bx0 = 0;
824
+ let by0 = 0;
825
+ let bx1 = 0;
826
+ if (e.depth % 2 === 0) {
827
+ const dyP = par.y1 - par.y0;
828
+ bx0 = lerp(par.x0, par.x1, dyP ? (y - par.y0) / dyP : 0.5);
829
+ by0 = y;
830
+ bx1 = bx0 - (e.childCount > 0 ? BONE_BASE + e.childCount * BONE_PER_CHILD : BONE_STUB);
831
+ drawLine(grp, bx0, y, bx1, y, "ishikawa-sub-branch", roughContext);
832
+ if (roughContext) {
833
+ drawArrowMarker(grp, bx0, y, 1, 0, roughContext);
834
+ }
835
+ drawMultilineText(grp, e.text, bx1, y, "ishikawa-label align", "end", fontSize);
836
+ } else {
837
+ const k = par.childrenDrawn++;
838
+ bx0 = lerp(par.x0, par.x1, (par.childCount - k) / (par.childCount + 1));
839
+ by0 = par.y0;
840
+ bx1 = bx0 + diagonalX * ((y - by0) / diagonalY);
841
+ drawLine(grp, bx0, by0, bx1, y, "ishikawa-sub-branch", roughContext);
842
+ if (roughContext) {
843
+ drawArrowMarker(grp, bx0, by0, bx0 - bx1, by0 - y, roughContext);
844
+ }
845
+ drawMultilineText(grp, e.text, bx1, y, oddLabel, "end", fontSize);
846
+ }
847
+ if (e.childCount > 0) {
848
+ bones.set(i, {
849
+ x0: bx0,
850
+ y0: by0,
851
+ x1: bx1,
852
+ y1: y,
853
+ childCount: e.childCount,
854
+ childrenDrawn: 0
855
+ });
856
+ }
857
+ }
858
+ }, "drawBranch");
859
+ var splitLines = /* @__PURE__ */ __name((text) => text.split(/<br\s*\/?>|\n/), "splitLines");
860
+ var wrapText = /* @__PURE__ */ __name((text, maxChars) => {
861
+ if (text.length <= maxChars) {
862
+ return text;
863
+ }
864
+ const lines = [];
865
+ for (const word of text.split(/\s+/)) {
866
+ const last = lines.length - 1;
867
+ if (last >= 0 && lines[last].length + 1 + word.length <= maxChars) {
868
+ lines[last] += " " + word;
869
+ } else {
870
+ lines.push(word);
871
+ }
872
+ }
873
+ return lines.join(`
874
+ `);
875
+ }, "wrapText");
876
+ var drawMultilineText = /* @__PURE__ */ __name((g, text, x, y, cls, anchor, fontSize) => {
877
+ const lines = splitLines(text);
878
+ const lh = fontSize * 1.05;
879
+ const el = g.append("text").attr("class", cls).attr("text-anchor", anchor).attr("x", x).attr("y", y - (lines.length - 1) * lh / 2);
880
+ for (const [i, line] of lines.entries()) {
881
+ el.append("tspan").attr("x", x).attr("dy", i === 0 ? 0 : lh).text(line);
882
+ }
883
+ return el;
884
+ }, "drawMultilineText");
885
+ var lerp = /* @__PURE__ */ __name((a, b, t) => a + (b - a) * t, "lerp");
886
+ var drawLine = /* @__PURE__ */ __name((g, x1, y1, x2, y2, cls, roughContext) => {
887
+ if (roughContext) {
888
+ const roughNode = roughContext.roughSvg.line(x1, y1, x2, y2, {
889
+ roughness: 1.5,
890
+ seed: roughContext.seed,
891
+ stroke: roughContext.lineColor,
892
+ strokeWidth: 2
893
+ });
894
+ g.append(() => roughNode).attr("class", cls);
895
+ return;
896
+ }
897
+ return g.append("line").attr("class", cls).attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2);
898
+ }, "drawLine");
899
+ var renderer = { draw };
900
+ var getStyles = /* @__PURE__ */ __name((options) => `
901
+ .ishikawa .ishikawa-spine,
902
+ .ishikawa .ishikawa-branch,
903
+ .ishikawa .ishikawa-sub-branch {
904
+ stroke: ${options.lineColor};
905
+ stroke-width: 2;
906
+ fill: none;
907
+ }
908
+
909
+ .ishikawa .ishikawa-sub-branch {
910
+ stroke-width: 1;
911
+ }
912
+
913
+ .ishikawa .ishikawa-arrow {
914
+ fill: ${options.lineColor};
915
+ }
916
+
917
+ .ishikawa .ishikawa-head {
918
+ fill: ${options.mainBkg};
919
+ stroke: ${options.lineColor};
920
+ stroke-width: 2;
921
+ }
922
+
923
+ .ishikawa .ishikawa-label-box {
924
+ fill: ${options.mainBkg};
925
+ stroke: ${options.lineColor};
926
+ stroke-width: 2;
927
+ }
928
+
929
+ .ishikawa text {
930
+ font-family: ${options.fontFamily};
931
+ font-size: ${options.fontSize};
932
+ fill: ${options.textColor};
933
+ }
934
+
935
+ .ishikawa .ishikawa-head-label {
936
+ font-weight: 600;
937
+ text-anchor: middle;
938
+ dominant-baseline: middle;
939
+ font-size: 14px;
940
+ }
941
+
942
+ .ishikawa .ishikawa-label {
943
+ text-anchor: end;
944
+ }
945
+
946
+ .ishikawa .ishikawa-label.cause {
947
+ text-anchor: middle;
948
+ dominant-baseline: middle;
949
+ }
950
+
951
+ .ishikawa .ishikawa-label.align {
952
+ text-anchor: end;
953
+ dominant-baseline: middle;
954
+ }
955
+
956
+ .ishikawa .ishikawa-label.up {
957
+ dominant-baseline: baseline;
958
+ }
959
+
960
+ .ishikawa .ishikawa-label.down {
961
+ dominant-baseline: hanging;
962
+ }
963
+ `, "getStyles");
964
+ var ishikawaStyles_default = getStyles;
965
+ var diagram = {
966
+ parser: ishikawa_default,
967
+ get db() {
968
+ return new IshikawaDB;
969
+ },
970
+ renderer,
971
+ styles: ishikawaStyles_default
972
+ };
973
+ export {
974
+ diagram
975
+ };