@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,575 @@
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 {
22
+ setupViewPortForSVG
23
+ } from "./markdown-6r4svars.js";
24
+ import"./markdown-v14td68x.js";
25
+ import"./markdown-dz3z5w30.js";
26
+ import {
27
+ selectSvgElement
28
+ } from "./markdown-6zz8efx2.js";
29
+ import {
30
+ isLabelStyle,
31
+ styles2String
32
+ } from "./markdown-c9k0fvp1.js";
33
+ import {
34
+ cleanAndMerge
35
+ } from "./markdown-ff5wvb43.js";
36
+ import"./markdown-pzgd8z3s.js";
37
+ import {
38
+ clear,
39
+ configureSvgSize,
40
+ defaultConfig_default,
41
+ getAccDescription,
42
+ getAccTitle,
43
+ getConfig,
44
+ getDiagramTitle,
45
+ getThemeVariables3,
46
+ setAccDescription,
47
+ setAccTitle,
48
+ setDiagramTitle
49
+ } from "./markdown-92n37gd4.js";
50
+ import {
51
+ log,
52
+ select_default
53
+ } from "./markdown-xw8dsk8b.js";
54
+ import {
55
+ __name
56
+ } from "./markdown-1s5vwkf2.js";
57
+ import {
58
+ format,
59
+ hierarchy,
60
+ ordinal,
61
+ treemap_default
62
+ } from "./markdown-dy5sgjhc.js";
63
+ import"./markdown-809k7q41.js";
64
+
65
+ // node_modules/mermaid/dist/chunks/mermaid.core/diagram-Q27KOJAE.mjs
66
+ var TreeMapDB = class {
67
+ constructor() {
68
+ this.nodes = [];
69
+ this.levels = /* @__PURE__ */ new Map;
70
+ this.outerNodes = [];
71
+ this.classes = /* @__PURE__ */ new Map;
72
+ this.setAccTitle = setAccTitle;
73
+ this.getAccTitle = getAccTitle;
74
+ this.setDiagramTitle = setDiagramTitle;
75
+ this.getDiagramTitle = getDiagramTitle;
76
+ this.getAccDescription = getAccDescription;
77
+ this.setAccDescription = setAccDescription;
78
+ }
79
+ static {
80
+ __name(this, "TreeMapDB");
81
+ }
82
+ getNodes() {
83
+ return this.nodes;
84
+ }
85
+ getConfig() {
86
+ const defaultConfig = defaultConfig_default;
87
+ const userConfig = getConfig();
88
+ return cleanAndMerge({
89
+ ...defaultConfig.treemap,
90
+ ...userConfig.treemap ?? {}
91
+ });
92
+ }
93
+ addNode(node, level) {
94
+ this.nodes.push(node);
95
+ this.levels.set(node, level);
96
+ if (level === 0) {
97
+ this.outerNodes.push(node);
98
+ this.root ??= node;
99
+ }
100
+ }
101
+ getRoot() {
102
+ return { name: "", children: this.outerNodes };
103
+ }
104
+ addClass(id, _style) {
105
+ const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };
106
+ const styles = _style.replace(/\\,/g, "§§§").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
107
+ if (styles) {
108
+ styles.forEach((s) => {
109
+ if (isLabelStyle(s)) {
110
+ if (styleClass?.textStyles) {
111
+ styleClass.textStyles.push(s);
112
+ } else {
113
+ styleClass.textStyles = [s];
114
+ }
115
+ }
116
+ if (styleClass?.styles) {
117
+ styleClass.styles.push(s);
118
+ } else {
119
+ styleClass.styles = [s];
120
+ }
121
+ });
122
+ }
123
+ this.classes.set(id, styleClass);
124
+ }
125
+ getClasses() {
126
+ return this.classes;
127
+ }
128
+ getStylesForClass(classSelector) {
129
+ return this.classes.get(classSelector)?.styles ?? [];
130
+ }
131
+ clear() {
132
+ clear();
133
+ this.nodes = [];
134
+ this.levels = /* @__PURE__ */ new Map;
135
+ this.outerNodes = [];
136
+ this.classes = /* @__PURE__ */ new Map;
137
+ this.root = undefined;
138
+ }
139
+ };
140
+ function buildHierarchy(items) {
141
+ if (!items.length) {
142
+ return [];
143
+ }
144
+ const root = [];
145
+ const stack = [];
146
+ items.forEach((item) => {
147
+ const node = {
148
+ name: item.name,
149
+ children: item.type === "Leaf" ? undefined : []
150
+ };
151
+ node.classSelector = item?.classSelector;
152
+ if (item?.cssCompiledStyles) {
153
+ node.cssCompiledStyles = item.cssCompiledStyles;
154
+ }
155
+ if (item.type === "Leaf" && item.value !== undefined) {
156
+ node.value = item.value;
157
+ }
158
+ while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
159
+ stack.pop();
160
+ }
161
+ if (stack.length === 0) {
162
+ root.push(node);
163
+ } else {
164
+ const parent = stack[stack.length - 1].node;
165
+ if (parent.children) {
166
+ parent.children.push(node);
167
+ } else {
168
+ parent.children = [node];
169
+ }
170
+ }
171
+ if (item.type !== "Leaf") {
172
+ stack.push({ node, level: item.level });
173
+ }
174
+ });
175
+ return root;
176
+ }
177
+ __name(buildHierarchy, "buildHierarchy");
178
+ var populate = /* @__PURE__ */ __name((ast, db) => {
179
+ populateCommonDb(ast, db);
180
+ const items = [];
181
+ for (const row of ast.TreemapRows ?? []) {
182
+ if (row.$type === "ClassDefStatement") {
183
+ db.addClass(row.className ?? "", row.styleText ?? "");
184
+ }
185
+ }
186
+ for (const row of ast.TreemapRows ?? []) {
187
+ const item = row.item;
188
+ if (!item) {
189
+ continue;
190
+ }
191
+ const level = row.indent ? parseInt(row.indent) : 0;
192
+ const name = getItemName(item);
193
+ const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
194
+ const cssCompiledStyles = styles.length > 0 ? styles : undefined;
195
+ const itemData = {
196
+ level,
197
+ name,
198
+ type: item.$type,
199
+ value: item.value,
200
+ classSelector: item.classSelector,
201
+ cssCompiledStyles
202
+ };
203
+ items.push(itemData);
204
+ }
205
+ const hierarchyNodes = buildHierarchy(items);
206
+ const addNodesRecursively = /* @__PURE__ */ __name((nodes, level) => {
207
+ for (const node of nodes) {
208
+ db.addNode(node, level);
209
+ if (node.children && node.children.length > 0) {
210
+ addNodesRecursively(node.children, level + 1);
211
+ }
212
+ }
213
+ }, "addNodesRecursively");
214
+ addNodesRecursively(hierarchyNodes, 0);
215
+ }, "populate");
216
+ var getItemName = /* @__PURE__ */ __name((item) => {
217
+ return item.name ? String(item.name) : "";
218
+ }, "getItemName");
219
+ var parser = {
220
+ parser: { yy: undefined },
221
+ parse: /* @__PURE__ */ __name(async (text) => {
222
+ try {
223
+ const parseFunc = parse;
224
+ const ast = await parseFunc("treemap", text);
225
+ log.debug("Treemap AST:", ast);
226
+ const db = parser.parser?.yy;
227
+ if (!(db instanceof TreeMapDB)) {
228
+ throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");
229
+ }
230
+ populate(ast, db);
231
+ } catch (error) {
232
+ log.error("Error parsing treemap:", error);
233
+ throw error;
234
+ }
235
+ }, "parse")
236
+ };
237
+ var DEFAULT_INNER_PADDING = 10;
238
+ var SECTION_INNER_PADDING = 10;
239
+ var SECTION_HEADER_HEIGHT = 25;
240
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
241
+ const treemapDb = diagram2.db;
242
+ const config = treemapDb.getConfig();
243
+ const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;
244
+ const title = treemapDb.getDiagramTitle();
245
+ const root = treemapDb.getRoot();
246
+ const { themeVariables } = getConfig();
247
+ if (!root) {
248
+ return;
249
+ }
250
+ const titleHeight = title ? 30 : 0;
251
+ const svg = selectSvgElement(id);
252
+ const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;
253
+ const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;
254
+ const svgWidth = width;
255
+ const svgHeight = height + titleHeight;
256
+ svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
257
+ configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
258
+ let valueFormat;
259
+ try {
260
+ const formatStr = config.valueFormat || ",";
261
+ if (formatStr === "$0,0") {
262
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format(",")(value), "valueFormat");
263
+ } else if (formatStr.startsWith("$") && formatStr.includes(",")) {
264
+ const precision = /\.\d+/.exec(formatStr);
265
+ const precisionStr = precision ? precision[0] : "";
266
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format("," + precisionStr)(value), "valueFormat");
267
+ } else if (formatStr.startsWith("$")) {
268
+ const restOfFormat = formatStr.substring(1);
269
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format(restOfFormat || "")(value), "valueFormat");
270
+ } else {
271
+ valueFormat = format(formatStr);
272
+ }
273
+ } catch (error) {
274
+ log.error("Error creating format function:", error);
275
+ valueFormat = format(",");
276
+ }
277
+ const colorScale = ordinal().range([
278
+ "transparent",
279
+ themeVariables.cScale0,
280
+ themeVariables.cScale1,
281
+ themeVariables.cScale2,
282
+ themeVariables.cScale3,
283
+ themeVariables.cScale4,
284
+ themeVariables.cScale5,
285
+ themeVariables.cScale6,
286
+ themeVariables.cScale7,
287
+ themeVariables.cScale8,
288
+ themeVariables.cScale9,
289
+ themeVariables.cScale10,
290
+ themeVariables.cScale11
291
+ ]);
292
+ const colorScalePeer = ordinal().range([
293
+ "transparent",
294
+ themeVariables.cScalePeer0,
295
+ themeVariables.cScalePeer1,
296
+ themeVariables.cScalePeer2,
297
+ themeVariables.cScalePeer3,
298
+ themeVariables.cScalePeer4,
299
+ themeVariables.cScalePeer5,
300
+ themeVariables.cScalePeer6,
301
+ themeVariables.cScalePeer7,
302
+ themeVariables.cScalePeer8,
303
+ themeVariables.cScalePeer9,
304
+ themeVariables.cScalePeer10,
305
+ themeVariables.cScalePeer11
306
+ ]);
307
+ const colorScaleLabel = ordinal().range([
308
+ themeVariables.cScaleLabel0,
309
+ themeVariables.cScaleLabel1,
310
+ themeVariables.cScaleLabel2,
311
+ themeVariables.cScaleLabel3,
312
+ themeVariables.cScaleLabel4,
313
+ themeVariables.cScaleLabel5,
314
+ themeVariables.cScaleLabel6,
315
+ themeVariables.cScaleLabel7,
316
+ themeVariables.cScaleLabel8,
317
+ themeVariables.cScaleLabel9,
318
+ themeVariables.cScaleLabel10,
319
+ themeVariables.cScaleLabel11
320
+ ]);
321
+ if (title) {
322
+ svg.append("text").attr("x", svgWidth / 2).attr("y", titleHeight / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
323
+ }
324
+ const g = svg.append("g").attr("transform", `translate(0, ${titleHeight})`).attr("class", "treemapContainer");
325
+ const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
326
+ const treemapLayout = treemap_default().size([width, height]).paddingTop((d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);
327
+ const treemapData = treemapLayout(hierarchyRoot);
328
+ const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);
329
+ const sections = g.selectAll(".treemapSection").data(branchNodes).enter().append("g").attr("class", "treemapSection").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
330
+ sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", SECTION_HEADER_HEIGHT).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (d) => {
331
+ if (d.depth === 0) {
332
+ return "display: none;";
333
+ }
334
+ return "";
335
+ });
336
+ sections.append("clipPath").attr("id", (_d, i) => `clip-section-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr("height", SECTION_HEADER_HEIGHT);
337
+ sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", (_d, i) => {
338
+ return `treemapSection section${i}`;
339
+ }).attr("fill", (d) => colorScale(d.data.name)).attr("fill-opacity", 0.6).attr("stroke", (d) => colorScalePeer(d.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (d) => {
340
+ if (d.depth === 0) {
341
+ return "display: none;";
342
+ }
343
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
344
+ return styles.nodeStyles + ";" + styles.borderStyles.join(";");
345
+ });
346
+ sections.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", SECTION_HEADER_HEIGHT / 2).attr("dominant-baseline", "middle").text((d) => d.depth === 0 ? "" : d.data.name).attr("font-weight", "bold").attr("clip-path", (_d, i) => `url(#clip-section-${id}-${i})`).attr("style", (d) => {
347
+ if (d.depth === 0) {
348
+ return "display: none;";
349
+ }
350
+ const labelStyles = "dominant-baseline: middle; font-size: 12px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
351
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
352
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
353
+ }).each(function(d) {
354
+ if (d.depth === 0) {
355
+ return;
356
+ }
357
+ const self = select_default(this);
358
+ const originalText = d.data.name;
359
+ self.text(originalText);
360
+ const totalHeaderWidth = d.x1 - d.x0;
361
+ const labelXPosition = 6;
362
+ let spaceForTextContent;
363
+ if (config.showValues !== false && d.value) {
364
+ const valueEndsAtXRelative = totalHeaderWidth - 10;
365
+ const estimatedValueTextActualWidth = 30;
366
+ const gapBetweenLabelAndValue = 10;
367
+ const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;
368
+ spaceForTextContent = labelMustEndBeforeX - labelXPosition;
369
+ } else {
370
+ const labelOwnRightPadding = 6;
371
+ spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;
372
+ }
373
+ const minimumWidthToDisplay = 15;
374
+ const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);
375
+ const textNode = self.node();
376
+ const currentTextContentLength = textNode.getComputedTextLength();
377
+ if (currentTextContentLength > actualAvailableWidth) {
378
+ const ellipsis = "...";
379
+ let currentTruncatedText = originalText;
380
+ while (currentTruncatedText.length > 0) {
381
+ currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);
382
+ if (currentTruncatedText.length === 0) {
383
+ self.text(ellipsis);
384
+ if (textNode.getComputedTextLength() > actualAvailableWidth) {
385
+ self.text("");
386
+ }
387
+ break;
388
+ }
389
+ self.text(currentTruncatedText + ellipsis);
390
+ if (textNode.getComputedTextLength() <= actualAvailableWidth) {
391
+ break;
392
+ }
393
+ }
394
+ }
395
+ });
396
+ if (config.showValues !== false) {
397
+ sections.append("text").attr("class", "treemapSectionValue").attr("x", (d) => d.x1 - d.x0 - 10).attr("y", SECTION_HEADER_HEIGHT / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((d) => d.value ? valueFormat(d.value) : "").attr("font-style", "italic").attr("style", (d) => {
398
+ if (d.depth === 0) {
399
+ return "display: none;";
400
+ }
401
+ const labelStyles = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
402
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
403
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
404
+ });
405
+ }
406
+ const leafNodes = treemapData.leaves();
407
+ const isComplexTreemap = leafNodes.length > 20;
408
+ const baseLabelFontSize = isComplexTreemap ? 16 : 38;
409
+ const baseValueFontSize = isComplexTreemap ? 14 : 28;
410
+ const minLabelFontSize = isComplexTreemap ? 4 : 8;
411
+ const minValueFontSize = isComplexTreemap ? 4 : 6;
412
+ const labelPadding = isComplexTreemap ? 2 : 4;
413
+ const minDisplayThreshold = isComplexTreemap ? 8 : 10;
414
+ const spacingBetweenLabelAndValue = isComplexTreemap ? 1 : 2;
415
+ const cell = g.selectAll(".treemapLeafGroup").data(leafNodes).enter().append("g").attr("class", (d, i) => {
416
+ return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : ""}x`;
417
+ }).attr("transform", (d) => `translate(${d.x0},${d.y0})`);
418
+ cell.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", "treemapLeaf").attr("fill", (d) => {
419
+ return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
420
+ }).attr("style", (d) => {
421
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
422
+ return styles.nodeStyles;
423
+ }).attr("fill-opacity", 0.3).attr("stroke", (d) => {
424
+ return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
425
+ }).attr("stroke-width", 3);
426
+ cell.append("clipPath").attr("id", (_d, i) => `clip-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr("height", (d) => Math.max(0, d.y1 - d.y0 - 4));
427
+ const leafLabels = cell.append("text").attr("class", "treemapLabel").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", (d) => (d.y1 - d.y0) / 2).attr("style", (d) => {
428
+ const labelStyles = `text-anchor: middle; dominant-baseline: middle; font-size: ${baseLabelFontSize}px;fill:` + colorScaleLabel(d.data.name) + ";";
429
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
430
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
431
+ }).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);
432
+ leafLabels.each(function(d) {
433
+ const self = select_default(this);
434
+ const nodeWidth = d.x1 - d.x0;
435
+ const nodeHeight = d.y1 - d.y0;
436
+ const textNode = self.node();
437
+ const availableWidth = nodeWidth - 2 * labelPadding;
438
+ const availableHeight = nodeHeight - 2 * labelPadding;
439
+ if (availableWidth < minDisplayThreshold || availableHeight < minDisplayThreshold) {
440
+ self.style("display", "none");
441
+ return;
442
+ }
443
+ let currentLabelFontSize = parseInt(self.style("font-size"), 10);
444
+ const valueScaleFactor = 0.6;
445
+ while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {
446
+ currentLabelFontSize--;
447
+ self.style("font-size", `${currentLabelFontSize}px`);
448
+ }
449
+ let prospectiveValueFontSize = Math.max(minValueFontSize, Math.min(baseValueFontSize, Math.round(currentLabelFontSize * valueScaleFactor)));
450
+ let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
451
+ while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {
452
+ currentLabelFontSize--;
453
+ prospectiveValueFontSize = Math.max(minValueFontSize, Math.min(baseValueFontSize, Math.round(currentLabelFontSize * valueScaleFactor)));
454
+ if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {
455
+ break;
456
+ }
457
+ self.style("font-size", `${currentLabelFontSize}px`);
458
+ combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
459
+ if (prospectiveValueFontSize <= minValueFontSize && combinedHeight > availableHeight) {}
460
+ }
461
+ self.style("font-size", `${currentLabelFontSize}px`);
462
+ if (isComplexTreemap) {
463
+ if (currentLabelFontSize < minLabelFontSize || availableHeight < minLabelFontSize) {
464
+ self.style("display", "none");
465
+ }
466
+ } else {
467
+ if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {
468
+ self.style("display", "none");
469
+ }
470
+ }
471
+ });
472
+ if (config.showValues !== false) {
473
+ const leafValues = cell.append("text").attr("class", "treemapValue").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", function(d) {
474
+ return (d.y1 - d.y0) / 2;
475
+ }).attr("style", (d) => {
476
+ const labelStyles = `text-anchor: middle; dominant-baseline: hanging; font-size: ${baseValueFontSize}px;fill:` + colorScaleLabel(d.data.name) + ";";
477
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
478
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
479
+ }).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : "");
480
+ leafValues.each(function(d) {
481
+ const valueTextElement = select_default(this);
482
+ const parentCellNode = this.parentNode;
483
+ if (!parentCellNode) {
484
+ valueTextElement.style("display", "none");
485
+ return;
486
+ }
487
+ const labelElement = select_default(parentCellNode).select(".treemapLabel");
488
+ if (labelElement.empty() || labelElement.style("display") === "none") {
489
+ valueTextElement.style("display", "none");
490
+ return;
491
+ }
492
+ const finalLabelFontSize = parseFloat(labelElement.style("font-size"));
493
+ const valueScaleFactor = 0.6;
494
+ const actualValueFontSize = Math.max(minValueFontSize, Math.min(baseValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor)));
495
+ valueTextElement.style("font-size", `${actualValueFontSize}px`);
496
+ const labelCenterY = (d.y1 - d.y0) / 2;
497
+ const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;
498
+ valueTextElement.attr("y", valueTopActualY);
499
+ const nodeWidth = d.x1 - d.x0;
500
+ const nodeTotalHeight = d.y1 - d.y0;
501
+ const cellBottomPadding = 4;
502
+ const maxValueBottomY = nodeTotalHeight - cellBottomPadding;
503
+ const availableWidthForValue = nodeWidth - 2 * labelPadding;
504
+ if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {
505
+ valueTextElement.style("display", "none");
506
+ } else {
507
+ valueTextElement.style("display", null);
508
+ }
509
+ });
510
+ }
511
+ const diagramPadding = config.diagramPadding ?? 8;
512
+ setupViewPortForSVG(svg, diagramPadding, "flowchart", config?.useMaxWidth || false);
513
+ }, "draw");
514
+ var getClasses = /* @__PURE__ */ __name(function(_text, diagramObj) {
515
+ return diagramObj.db.getClasses();
516
+ }, "getClasses");
517
+ var renderer = { draw, getClasses };
518
+ var defaultTreemapStyleOptions = {
519
+ sectionStrokeColor: "black",
520
+ sectionStrokeWidth: "1",
521
+ sectionFillColor: "#efefef",
522
+ leafStrokeColor: "black",
523
+ leafStrokeWidth: "1",
524
+ leafFillColor: "#efefef",
525
+ labelFontSize: "12px",
526
+ valueFontSize: "10px",
527
+ titleFontSize: "14px"
528
+ };
529
+ var getStyles = /* @__PURE__ */ __name(({
530
+ treemap: treemap2
531
+ } = {}) => {
532
+ const defaultThemeVariables = getThemeVariables3();
533
+ const currentConfig = getConfig();
534
+ const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
535
+ const options = cleanAndMerge(defaultTreemapStyleOptions, treemap2);
536
+ const titleColor = options.titleColor ?? themeVariables.titleColor;
537
+ const labelColor = options.labelColor ?? themeVariables.textColor;
538
+ const valueColor = options.valueColor ?? themeVariables.textColor;
539
+ return `
540
+ .treemapNode.section {
541
+ stroke: ${options.sectionStrokeColor};
542
+ stroke-width: ${options.sectionStrokeWidth};
543
+ fill: ${options.sectionFillColor};
544
+ }
545
+ .treemapNode.leaf {
546
+ stroke: ${options.leafStrokeColor};
547
+ stroke-width: ${options.leafStrokeWidth};
548
+ fill: ${options.leafFillColor};
549
+ }
550
+ .treemapLabel {
551
+ fill: ${labelColor};
552
+ font-size: ${options.labelFontSize};
553
+ }
554
+ .treemapValue {
555
+ fill: ${valueColor};
556
+ font-size: ${options.valueFontSize};
557
+ }
558
+ .treemapTitle {
559
+ fill: ${titleColor};
560
+ font-size: ${options.titleFontSize};
561
+ }
562
+ `;
563
+ }, "getStyles");
564
+ var styles_default = getStyles;
565
+ var diagram = {
566
+ parser,
567
+ get db() {
568
+ return new TreeMapDB;
569
+ },
570
+ renderer,
571
+ styles: styles_default
572
+ };
573
+ export {
574
+ diagram
575
+ };