@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,1954 @@
1
+ import {
2
+ selectSvgElement
3
+ } from "./markdown-6zz8efx2.js";
4
+ import {
5
+ computeDimensionOfText
6
+ } from "./markdown-qx3cngz2.js";
7
+ import"./markdown-yengsms5.js";
8
+ import {
9
+ cleanAndMerge
10
+ } from "./markdown-ff5wvb43.js";
11
+ import"./markdown-pzgd8z3s.js";
12
+ import {
13
+ clear,
14
+ configureSvgSize,
15
+ defaultConfig_default,
16
+ getAccDescription,
17
+ getAccTitle,
18
+ getConfig,
19
+ getDiagramTitle,
20
+ getThemeVariables3,
21
+ sanitizeText,
22
+ setAccDescription,
23
+ setAccTitle,
24
+ setDiagramTitle
25
+ } from "./markdown-92n37gd4.js";
26
+ import {
27
+ log
28
+ } from "./markdown-xw8dsk8b.js";
29
+ import {
30
+ __name
31
+ } from "./markdown-1s5vwkf2.js";
32
+ import {
33
+ band,
34
+ line_default,
35
+ linear
36
+ } from "./markdown-dy5sgjhc.js";
37
+ import"./markdown-809k7q41.js";
38
+
39
+ // node_modules/mermaid/dist/chunks/mermaid.core/xychartDiagram-ELKLHX3M.mjs
40
+ var parser = function() {
41
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
42
+ for (o2 = o2 || {}, l = k.length;l--; o2[k[l]] = v)
43
+ ;
44
+ return o2;
45
+ }, "o"), $V0 = [1, 10, 12, 14, 16, 18, 19, 21, 23], $V1 = [2, 6], $V2 = [1, 3], $V3 = [1, 5], $V4 = [1, 6], $V5 = [1, 7], $V6 = [1, 5, 10, 12, 14, 16, 18, 19, 21, 23, 36, 37, 38], $V7 = [1, 25], $V8 = [1, 26], $V9 = [1, 28], $Va = [1, 29], $Vb = [1, 30], $Vc = [1, 31], $Vd = [1, 32], $Ve = [1, 33], $Vf = [1, 34], $Vg = [1, 35], $Vh = [1, 36], $Vi = [1, 37], $Vj = [1, 43], $Vk = [1, 42], $Vl = [1, 47], $Vm = [1, 50], $Vn = [1, 10, 12, 14, 16, 18, 19, 21, 23, 36, 37, 38], $Vo = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 28, 29, 36, 37, 38], $Vp = [1, 10, 12, 14, 16, 18, 19, 21, 23, 24, 26, 28, 29, 36, 37, 38, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51], $Vq = [1, 65], $Vr = [26, 28];
46
+ var parser2 = {
47
+ trace: /* @__PURE__ */ __name(function trace() {}, "trace"),
48
+ yy: {},
49
+ symbols_: { error: 2, start: 3, eol: 4, XYCHART: 5, chartConfig: 6, document: 7, CHART_ORIENTATION: 8, statement: 9, title: 10, text: 11, X_AXIS: 12, parseXAxis: 13, Y_AXIS: 14, parseYAxis: 15, LINE: 16, plotData: 17, BAR: 18, acc_title: 19, acc_title_value: 20, acc_descr: 21, acc_descr_value: 22, acc_descr_multiline_value: 23, SQUARE_BRACES_START: 24, dataPoints: 25, SQUARE_BRACES_END: 26, dataPoint: 27, COMMA: 28, NUMBER_WITH_DECIMAL: 29, STR: 30, xAxisData: 31, bandData: 32, ARROW_DELIMITER: 33, commaSeparatedTexts: 34, yAxisData: 35, NEWLINE: 36, SEMI: 37, EOF: 38, alphaNum: 39, MD_STR: 40, alphaNumToken: 41, AMP: 42, NUM: 43, ALPHA: 44, PLUS: 45, EQUALS: 46, MULT: 47, DOT: 48, BRKT: 49, MINUS: 50, UNDERSCORE: 51, $accept: 0, $end: 1 },
50
+ terminals_: { 2: "error", 5: "XYCHART", 8: "CHART_ORIENTATION", 10: "title", 12: "X_AXIS", 14: "Y_AXIS", 16: "LINE", 18: "BAR", 19: "acc_title", 20: "acc_title_value", 21: "acc_descr", 22: "acc_descr_value", 23: "acc_descr_multiline_value", 24: "SQUARE_BRACES_START", 26: "SQUARE_BRACES_END", 28: "COMMA", 29: "NUMBER_WITH_DECIMAL", 30: "STR", 33: "ARROW_DELIMITER", 36: "NEWLINE", 37: "SEMI", 38: "EOF", 40: "MD_STR", 42: "AMP", 43: "NUM", 44: "ALPHA", 45: "PLUS", 46: "EQUALS", 47: "MULT", 48: "DOT", 49: "BRKT", 50: "MINUS", 51: "UNDERSCORE" },
51
+ productions_: [0, [3, 2], [3, 3], [3, 2], [3, 1], [6, 1], [7, 0], [7, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 2], [9, 3], [9, 2], [9, 3], [9, 2], [9, 2], [9, 1], [17, 3], [25, 3], [25, 1], [27, 2], [27, 1], [13, 1], [13, 2], [13, 1], [31, 1], [31, 3], [32, 3], [34, 3], [34, 1], [15, 1], [15, 2], [15, 1], [35, 3], [4, 1], [4, 1], [4, 1], [11, 1], [11, 1], [11, 1], [39, 1], [39, 2], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1], [41, 1]],
52
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
53
+ var $0 = $$.length - 1;
54
+ switch (yystate) {
55
+ case 5:
56
+ yy.setOrientation($$[$0]);
57
+ break;
58
+ case 9:
59
+ yy.setDiagramTitle($$[$0].text.trim());
60
+ break;
61
+ case 12:
62
+ yy.setLineData({ text: "", type: "text" }, $$[$0]);
63
+ break;
64
+ case 13:
65
+ yy.setLineData($$[$0 - 1], $$[$0]);
66
+ break;
67
+ case 14:
68
+ yy.setBarData({ text: "", type: "text" }, $$[$0]);
69
+ break;
70
+ case 15:
71
+ yy.setBarData($$[$0 - 1], $$[$0]);
72
+ break;
73
+ case 16:
74
+ this.$ = $$[$0].trim();
75
+ yy.setAccTitle(this.$);
76
+ break;
77
+ case 17:
78
+ case 18:
79
+ this.$ = $$[$0].trim();
80
+ yy.setAccDescription(this.$);
81
+ break;
82
+ case 19:
83
+ this.$ = $$[$0 - 1];
84
+ break;
85
+ case 20:
86
+ case 30:
87
+ this.$ = [$$[$0 - 2], ...$$[$0]];
88
+ break;
89
+ case 21:
90
+ case 31:
91
+ this.$ = [$$[$0]];
92
+ break;
93
+ case 22:
94
+ this.$ = { value: Number($$[$0 - 1]), label: $$[$0] };
95
+ break;
96
+ case 23:
97
+ this.$ = { value: Number($$[$0]), label: "" };
98
+ break;
99
+ case 24:
100
+ yy.setXAxisTitle($$[$0]);
101
+ break;
102
+ case 25:
103
+ yy.setXAxisTitle($$[$0 - 1]);
104
+ break;
105
+ case 26:
106
+ yy.setXAxisTitle({ type: "text", text: "" });
107
+ break;
108
+ case 27:
109
+ yy.setXAxisBand($$[$0]);
110
+ break;
111
+ case 28:
112
+ yy.setXAxisRangeData(Number($$[$0 - 2]), Number($$[$0]));
113
+ break;
114
+ case 29:
115
+ this.$ = $$[$0 - 1];
116
+ break;
117
+ case 32:
118
+ yy.setYAxisTitle($$[$0]);
119
+ break;
120
+ case 33:
121
+ yy.setYAxisTitle($$[$0 - 1]);
122
+ break;
123
+ case 34:
124
+ yy.setYAxisTitle({ type: "text", text: "" });
125
+ break;
126
+ case 35:
127
+ yy.setYAxisRangeData(Number($$[$0 - 2]), Number($$[$0]));
128
+ break;
129
+ case 39:
130
+ this.$ = { text: $$[$0], type: "text" };
131
+ break;
132
+ case 40:
133
+ this.$ = { text: $$[$0], type: "text" };
134
+ break;
135
+ case 41:
136
+ this.$ = { text: $$[$0], type: "markdown" };
137
+ break;
138
+ case 42:
139
+ this.$ = $$[$0];
140
+ break;
141
+ case 43:
142
+ this.$ = $$[$0 - 1] + "" + $$[$0];
143
+ break;
144
+ }
145
+ }, "anonymous"),
146
+ table: [o($V0, $V1, { 3: 1, 4: 2, 7: 4, 5: $V2, 36: $V3, 37: $V4, 38: $V5 }), { 1: [3] }, o($V0, $V1, { 4: 2, 7: 4, 3: 8, 5: $V2, 36: $V3, 37: $V4, 38: $V5 }), o($V0, $V1, { 4: 2, 7: 4, 6: 9, 3: 10, 5: $V2, 8: [1, 11], 36: $V3, 37: $V4, 38: $V5 }), { 1: [2, 4], 9: 12, 10: [1, 13], 12: [1, 14], 14: [1, 15], 16: [1, 16], 18: [1, 17], 19: [1, 18], 21: [1, 19], 23: [1, 20] }, o($V6, [2, 36]), o($V6, [2, 37]), o($V6, [2, 38]), { 1: [2, 1] }, o($V0, $V1, { 4: 2, 7: 4, 3: 21, 5: $V2, 36: $V3, 37: $V4, 38: $V5 }), { 1: [2, 3] }, o($V6, [2, 5]), o($V0, [2, 7], { 4: 22, 36: $V3, 37: $V4, 38: $V5 }), { 11: 23, 30: $V7, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, { 11: 39, 13: 38, 24: $Vj, 29: $Vk, 30: $V7, 31: 40, 32: 41, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, { 11: 45, 15: 44, 29: $Vl, 30: $V7, 35: 46, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, { 11: 49, 17: 48, 24: $Vm, 30: $V7, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, { 11: 52, 17: 51, 24: $Vm, 30: $V7, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, { 20: [1, 53] }, { 22: [1, 54] }, o($Vn, [2, 18]), { 1: [2, 2] }, o($Vn, [2, 8]), o($Vn, [2, 9]), o($Vo, [2, 39], { 41: 55, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }), o($Vo, [2, 40]), o($Vo, [2, 41]), o($Vp, [2, 42]), o($Vp, [2, 44]), o($Vp, [2, 45]), o($Vp, [2, 46]), o($Vp, [2, 47]), o($Vp, [2, 48]), o($Vp, [2, 49]), o($Vp, [2, 50]), o($Vp, [2, 51]), o($Vp, [2, 52]), o($Vp, [2, 53]), o($Vn, [2, 10]), o($Vn, [2, 24], { 32: 41, 31: 56, 24: $Vj, 29: $Vk }), o($Vn, [2, 26]), o($Vn, [2, 27]), { 33: [1, 57] }, { 11: 59, 30: $V7, 34: 58, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, o($Vn, [2, 11]), o($Vn, [2, 32], { 35: 60, 29: $Vl }), o($Vn, [2, 34]), { 33: [1, 61] }, o($Vn, [2, 12]), { 17: 62, 24: $Vm }, { 25: 63, 27: 64, 29: $Vq }, o($Vn, [2, 14]), { 17: 66, 24: $Vm }, o($Vn, [2, 16]), o($Vn, [2, 17]), o($Vp, [2, 43]), o($Vn, [2, 25]), { 29: [1, 67] }, { 26: [1, 68] }, { 26: [2, 31], 28: [1, 69] }, o($Vn, [2, 33]), { 29: [1, 70] }, o($Vn, [2, 13]), { 26: [1, 71] }, { 26: [2, 21], 28: [1, 72] }, o($Vr, [2, 23], { 30: [1, 73] }), o($Vn, [2, 15]), o($Vn, [2, 28]), o($Vn, [2, 29]), { 11: 59, 30: $V7, 34: 74, 39: 24, 40: $V8, 41: 27, 42: $V9, 43: $Va, 44: $Vb, 45: $Vc, 46: $Vd, 47: $Ve, 48: $Vf, 49: $Vg, 50: $Vh, 51: $Vi }, o($Vn, [2, 35]), o($Vn, [2, 19]), { 25: 75, 27: 64, 29: $Vq }, o($Vr, [2, 22]), { 26: [2, 30] }, { 26: [2, 20] }],
147
+ defaultActions: { 8: [2, 1], 10: [2, 3], 21: [2, 2], 74: [2, 30], 75: [2, 20] },
148
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
149
+ if (hash.recoverable) {
150
+ this.trace(str);
151
+ } else {
152
+ var error = new Error(str);
153
+ error.hash = hash;
154
+ throw error;
155
+ }
156
+ }, "parseError"),
157
+ parse: /* @__PURE__ */ __name(function parse(input) {
158
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
159
+ var args = lstack.slice.call(arguments, 1);
160
+ var lexer2 = Object.create(this.lexer);
161
+ var sharedState = { yy: {} };
162
+ for (var k in this.yy) {
163
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
164
+ sharedState.yy[k] = this.yy[k];
165
+ }
166
+ }
167
+ lexer2.setInput(input, sharedState.yy);
168
+ sharedState.yy.lexer = lexer2;
169
+ sharedState.yy.parser = this;
170
+ if (typeof lexer2.yylloc == "undefined") {
171
+ lexer2.yylloc = {};
172
+ }
173
+ var yyloc = lexer2.yylloc;
174
+ lstack.push(yyloc);
175
+ var ranges = lexer2.options && lexer2.options.ranges;
176
+ if (typeof sharedState.yy.parseError === "function") {
177
+ this.parseError = sharedState.yy.parseError;
178
+ } else {
179
+ this.parseError = Object.getPrototypeOf(this).parseError;
180
+ }
181
+ function popStack(n) {
182
+ stack.length = stack.length - 2 * n;
183
+ vstack.length = vstack.length - n;
184
+ lstack.length = lstack.length - n;
185
+ }
186
+ __name(popStack, "popStack");
187
+ function lex() {
188
+ var token;
189
+ token = tstack.pop() || lexer2.lex() || EOF;
190
+ if (typeof token !== "number") {
191
+ if (token instanceof Array) {
192
+ tstack = token;
193
+ token = tstack.pop();
194
+ }
195
+ token = self.symbols_[token] || token;
196
+ }
197
+ return token;
198
+ }
199
+ __name(lex, "lex");
200
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
201
+ while (true) {
202
+ state = stack[stack.length - 1];
203
+ if (this.defaultActions[state]) {
204
+ action = this.defaultActions[state];
205
+ } else {
206
+ if (symbol === null || typeof symbol == "undefined") {
207
+ symbol = lex();
208
+ }
209
+ action = table[state] && table[state][symbol];
210
+ }
211
+ if (typeof action === "undefined" || !action.length || !action[0]) {
212
+ var errStr = "";
213
+ expected = [];
214
+ for (p in table[state]) {
215
+ if (this.terminals_[p] && p > TERROR) {
216
+ expected.push("'" + this.terminals_[p] + "'");
217
+ }
218
+ }
219
+ if (lexer2.showPosition) {
220
+ errStr = "Parse error on line " + (yylineno + 1) + `:
221
+ ` + lexer2.showPosition() + `
222
+ Expecting ` + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
223
+ } else {
224
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
225
+ }
226
+ this.parseError(errStr, {
227
+ text: lexer2.match,
228
+ token: this.terminals_[symbol] || symbol,
229
+ line: lexer2.yylineno,
230
+ loc: yyloc,
231
+ expected
232
+ });
233
+ }
234
+ if (action[0] instanceof Array && action.length > 1) {
235
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
236
+ }
237
+ switch (action[0]) {
238
+ case 1:
239
+ stack.push(symbol);
240
+ vstack.push(lexer2.yytext);
241
+ lstack.push(lexer2.yylloc);
242
+ stack.push(action[1]);
243
+ symbol = null;
244
+ if (!preErrorSymbol) {
245
+ yyleng = lexer2.yyleng;
246
+ yytext = lexer2.yytext;
247
+ yylineno = lexer2.yylineno;
248
+ yyloc = lexer2.yylloc;
249
+ if (recovering > 0) {
250
+ recovering--;
251
+ }
252
+ } else {
253
+ symbol = preErrorSymbol;
254
+ preErrorSymbol = null;
255
+ }
256
+ break;
257
+ case 2:
258
+ len = this.productions_[action[1]][1];
259
+ yyval.$ = vstack[vstack.length - len];
260
+ yyval._$ = {
261
+ first_line: lstack[lstack.length - (len || 1)].first_line,
262
+ last_line: lstack[lstack.length - 1].last_line,
263
+ first_column: lstack[lstack.length - (len || 1)].first_column,
264
+ last_column: lstack[lstack.length - 1].last_column
265
+ };
266
+ if (ranges) {
267
+ yyval._$.range = [
268
+ lstack[lstack.length - (len || 1)].range[0],
269
+ lstack[lstack.length - 1].range[1]
270
+ ];
271
+ }
272
+ r = this.performAction.apply(yyval, [
273
+ yytext,
274
+ yyleng,
275
+ yylineno,
276
+ sharedState.yy,
277
+ action[1],
278
+ vstack,
279
+ lstack
280
+ ].concat(args));
281
+ if (typeof r !== "undefined") {
282
+ return r;
283
+ }
284
+ if (len) {
285
+ stack = stack.slice(0, -1 * len * 2);
286
+ vstack = vstack.slice(0, -1 * len);
287
+ lstack = lstack.slice(0, -1 * len);
288
+ }
289
+ stack.push(this.productions_[action[1]][0]);
290
+ vstack.push(yyval.$);
291
+ lstack.push(yyval._$);
292
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
293
+ stack.push(newState);
294
+ break;
295
+ case 3:
296
+ return true;
297
+ }
298
+ }
299
+ return true;
300
+ }, "parse")
301
+ };
302
+ var lexer = /* @__PURE__ */ function() {
303
+ var lexer2 = {
304
+ EOF: 1,
305
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
306
+ if (this.yy.parser) {
307
+ this.yy.parser.parseError(str, hash);
308
+ } else {
309
+ throw new Error(str);
310
+ }
311
+ }, "parseError"),
312
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
313
+ this.yy = yy || this.yy || {};
314
+ this._input = input;
315
+ this._more = this._backtrack = this.done = false;
316
+ this.yylineno = this.yyleng = 0;
317
+ this.yytext = this.matched = this.match = "";
318
+ this.conditionStack = ["INITIAL"];
319
+ this.yylloc = {
320
+ first_line: 1,
321
+ first_column: 0,
322
+ last_line: 1,
323
+ last_column: 0
324
+ };
325
+ if (this.options.ranges) {
326
+ this.yylloc.range = [0, 0];
327
+ }
328
+ this.offset = 0;
329
+ return this;
330
+ }, "setInput"),
331
+ input: /* @__PURE__ */ __name(function() {
332
+ var ch = this._input[0];
333
+ this.yytext += ch;
334
+ this.yyleng++;
335
+ this.offset++;
336
+ this.match += ch;
337
+ this.matched += ch;
338
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
339
+ if (lines) {
340
+ this.yylineno++;
341
+ this.yylloc.last_line++;
342
+ } else {
343
+ this.yylloc.last_column++;
344
+ }
345
+ if (this.options.ranges) {
346
+ this.yylloc.range[1]++;
347
+ }
348
+ this._input = this._input.slice(1);
349
+ return ch;
350
+ }, "input"),
351
+ unput: /* @__PURE__ */ __name(function(ch) {
352
+ var len = ch.length;
353
+ var lines = ch.split(/(?:\r\n?|\n)/g);
354
+ this._input = ch + this._input;
355
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
356
+ this.offset -= len;
357
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
358
+ this.match = this.match.substr(0, this.match.length - 1);
359
+ this.matched = this.matched.substr(0, this.matched.length - 1);
360
+ if (lines.length - 1) {
361
+ this.yylineno -= lines.length - 1;
362
+ }
363
+ var r = this.yylloc.range;
364
+ this.yylloc = {
365
+ first_line: this.yylloc.first_line,
366
+ last_line: this.yylineno + 1,
367
+ first_column: this.yylloc.first_column,
368
+ 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
369
+ };
370
+ if (this.options.ranges) {
371
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
372
+ }
373
+ this.yyleng = this.yytext.length;
374
+ return this;
375
+ }, "unput"),
376
+ more: /* @__PURE__ */ __name(function() {
377
+ this._more = true;
378
+ return this;
379
+ }, "more"),
380
+ reject: /* @__PURE__ */ __name(function() {
381
+ if (this.options.backtrack_lexer) {
382
+ this._backtrack = true;
383
+ } else {
384
+ 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).
385
+ ` + this.showPosition(), {
386
+ text: "",
387
+ token: null,
388
+ line: this.yylineno
389
+ });
390
+ }
391
+ return this;
392
+ }, "reject"),
393
+ less: /* @__PURE__ */ __name(function(n) {
394
+ this.unput(this.match.slice(n));
395
+ }, "less"),
396
+ pastInput: /* @__PURE__ */ __name(function() {
397
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
398
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
399
+ }, "pastInput"),
400
+ upcomingInput: /* @__PURE__ */ __name(function() {
401
+ var next = this.match;
402
+ if (next.length < 20) {
403
+ next += this._input.substr(0, 20 - next.length);
404
+ }
405
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
406
+ }, "upcomingInput"),
407
+ showPosition: /* @__PURE__ */ __name(function() {
408
+ var pre = this.pastInput();
409
+ var c = new Array(pre.length + 1).join("-");
410
+ return pre + this.upcomingInput() + `
411
+ ` + c + "^";
412
+ }, "showPosition"),
413
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
414
+ var token, lines, backup;
415
+ if (this.options.backtrack_lexer) {
416
+ backup = {
417
+ yylineno: this.yylineno,
418
+ yylloc: {
419
+ first_line: this.yylloc.first_line,
420
+ last_line: this.last_line,
421
+ first_column: this.yylloc.first_column,
422
+ last_column: this.yylloc.last_column
423
+ },
424
+ yytext: this.yytext,
425
+ match: this.match,
426
+ matches: this.matches,
427
+ matched: this.matched,
428
+ yyleng: this.yyleng,
429
+ offset: this.offset,
430
+ _more: this._more,
431
+ _input: this._input,
432
+ yy: this.yy,
433
+ conditionStack: this.conditionStack.slice(0),
434
+ done: this.done
435
+ };
436
+ if (this.options.ranges) {
437
+ backup.yylloc.range = this.yylloc.range.slice(0);
438
+ }
439
+ }
440
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
441
+ if (lines) {
442
+ this.yylineno += lines.length;
443
+ }
444
+ this.yylloc = {
445
+ first_line: this.yylloc.last_line,
446
+ last_line: this.yylineno + 1,
447
+ first_column: this.yylloc.last_column,
448
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
449
+ };
450
+ this.yytext += match[0];
451
+ this.match += match[0];
452
+ this.matches = match;
453
+ this.yyleng = this.yytext.length;
454
+ if (this.options.ranges) {
455
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
456
+ }
457
+ this._more = false;
458
+ this._backtrack = false;
459
+ this._input = this._input.slice(match[0].length);
460
+ this.matched += match[0];
461
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
462
+ if (this.done && this._input) {
463
+ this.done = false;
464
+ }
465
+ if (token) {
466
+ return token;
467
+ } else if (this._backtrack) {
468
+ for (var k in backup) {
469
+ this[k] = backup[k];
470
+ }
471
+ return false;
472
+ }
473
+ return false;
474
+ }, "test_match"),
475
+ next: /* @__PURE__ */ __name(function() {
476
+ if (this.done) {
477
+ return this.EOF;
478
+ }
479
+ if (!this._input) {
480
+ this.done = true;
481
+ }
482
+ var token, match, tempMatch, index;
483
+ if (!this._more) {
484
+ this.yytext = "";
485
+ this.match = "";
486
+ }
487
+ var rules = this._currentRules();
488
+ for (var i = 0;i < rules.length; i++) {
489
+ tempMatch = this._input.match(this.rules[rules[i]]);
490
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
491
+ match = tempMatch;
492
+ index = i;
493
+ if (this.options.backtrack_lexer) {
494
+ token = this.test_match(tempMatch, rules[i]);
495
+ if (token !== false) {
496
+ return token;
497
+ } else if (this._backtrack) {
498
+ match = false;
499
+ continue;
500
+ } else {
501
+ return false;
502
+ }
503
+ } else if (!this.options.flex) {
504
+ break;
505
+ }
506
+ }
507
+ }
508
+ if (match) {
509
+ token = this.test_match(match, rules[index]);
510
+ if (token !== false) {
511
+ return token;
512
+ }
513
+ return false;
514
+ }
515
+ if (this._input === "") {
516
+ return this.EOF;
517
+ } else {
518
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
519
+ ` + this.showPosition(), {
520
+ text: "",
521
+ token: null,
522
+ line: this.yylineno
523
+ });
524
+ }
525
+ }, "next"),
526
+ lex: /* @__PURE__ */ __name(function lex() {
527
+ var r = this.next();
528
+ if (r) {
529
+ return r;
530
+ } else {
531
+ return this.lex();
532
+ }
533
+ }, "lex"),
534
+ begin: /* @__PURE__ */ __name(function begin(condition) {
535
+ this.conditionStack.push(condition);
536
+ }, "begin"),
537
+ popState: /* @__PURE__ */ __name(function popState() {
538
+ var n = this.conditionStack.length - 1;
539
+ if (n > 0) {
540
+ return this.conditionStack.pop();
541
+ } else {
542
+ return this.conditionStack[0];
543
+ }
544
+ }, "popState"),
545
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
546
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
547
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
548
+ } else {
549
+ return this.conditions["INITIAL"].rules;
550
+ }
551
+ }, "_currentRules"),
552
+ topState: /* @__PURE__ */ __name(function topState(n) {
553
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
554
+ if (n >= 0) {
555
+ return this.conditionStack[n];
556
+ } else {
557
+ return "INITIAL";
558
+ }
559
+ }, "topState"),
560
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
561
+ this.begin(condition);
562
+ }, "pushState"),
563
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
564
+ return this.conditionStack.length;
565
+ }, "stateStackSize"),
566
+ options: { "case-insensitive": true },
567
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
568
+ var YYSTATE = YY_START;
569
+ switch ($avoiding_name_collisions) {
570
+ case 0:
571
+ break;
572
+ case 1:
573
+ break;
574
+ case 2:
575
+ this.popState();
576
+ return 36;
577
+ break;
578
+ case 3:
579
+ this.popState();
580
+ return 36;
581
+ break;
582
+ case 4:
583
+ return 36;
584
+ break;
585
+ case 5:
586
+ break;
587
+ case 6:
588
+ return 10;
589
+ break;
590
+ case 7:
591
+ this.pushState("acc_title");
592
+ return 19;
593
+ break;
594
+ case 8:
595
+ this.popState();
596
+ return "acc_title_value";
597
+ break;
598
+ case 9:
599
+ this.pushState("acc_descr");
600
+ return 21;
601
+ break;
602
+ case 10:
603
+ this.popState();
604
+ return "acc_descr_value";
605
+ break;
606
+ case 11:
607
+ this.pushState("acc_descr_multiline");
608
+ break;
609
+ case 12:
610
+ this.popState();
611
+ break;
612
+ case 13:
613
+ return "acc_descr_multiline_value";
614
+ break;
615
+ case 14:
616
+ return 5;
617
+ break;
618
+ case 15:
619
+ return 5;
620
+ break;
621
+ case 16:
622
+ return 8;
623
+ break;
624
+ case 17:
625
+ this.pushState("axis_data");
626
+ return "X_AXIS";
627
+ break;
628
+ case 18:
629
+ this.pushState("axis_data");
630
+ return "Y_AXIS";
631
+ break;
632
+ case 19:
633
+ this.pushState("axis_band_data");
634
+ return 24;
635
+ break;
636
+ case 20:
637
+ return 33;
638
+ break;
639
+ case 21:
640
+ this.pushState("data");
641
+ return 16;
642
+ break;
643
+ case 22:
644
+ this.pushState("data");
645
+ return 18;
646
+ break;
647
+ case 23:
648
+ this.pushState("data_inner");
649
+ return 24;
650
+ break;
651
+ case 24:
652
+ return 29;
653
+ break;
654
+ case 25:
655
+ this.popState();
656
+ return 26;
657
+ break;
658
+ case 26:
659
+ this.popState();
660
+ break;
661
+ case 27:
662
+ this.pushState("string");
663
+ break;
664
+ case 28:
665
+ this.popState();
666
+ break;
667
+ case 29:
668
+ return "STR";
669
+ break;
670
+ case 30:
671
+ return 24;
672
+ break;
673
+ case 31:
674
+ return 26;
675
+ break;
676
+ case 32:
677
+ return 44;
678
+ break;
679
+ case 33:
680
+ return "COLON";
681
+ break;
682
+ case 34:
683
+ return 45;
684
+ break;
685
+ case 35:
686
+ return 28;
687
+ break;
688
+ case 36:
689
+ return 46;
690
+ break;
691
+ case 37:
692
+ return 47;
693
+ break;
694
+ case 38:
695
+ return 49;
696
+ break;
697
+ case 39:
698
+ return 51;
699
+ break;
700
+ case 40:
701
+ return 48;
702
+ break;
703
+ case 41:
704
+ return 42;
705
+ break;
706
+ case 42:
707
+ return 50;
708
+ break;
709
+ case 43:
710
+ return 43;
711
+ break;
712
+ case 44:
713
+ break;
714
+ case 45:
715
+ return 37;
716
+ break;
717
+ case 46:
718
+ return 38;
719
+ break;
720
+ }
721
+ }, "anonymous"),
722
+ rules: [/^(?:%%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:(\r?\n))/i, /^(?:(\r?\n))/i, /^(?:[\n\r]+)/i, /^(?:%%[^\n]*)/i, /^(?:title\b)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:\})/i, /^(?:[^\}]*)/i, /^(?:xychart-beta\b)/i, /^(?:xychart\b)/i, /^(?:(?:vertical|horizontal))/i, /^(?:x-axis\b)/i, /^(?:y-axis\b)/i, /^(?:\[)/i, /^(?:-->)/i, /^(?:line\b)/i, /^(?:bar\b)/i, /^(?:\[)/i, /^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i, /^(?:\])/i, /^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i, /^(?:["])/i, /^(?:["])/i, /^(?:[^"]*)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:[A-Za-z]+)/i, /^(?::)/i, /^(?:\+)/i, /^(?:,)/i, /^(?:=)/i, /^(?:\*)/i, /^(?:#)/i, /^(?:[\_])/i, /^(?:\.)/i, /^(?:&)/i, /^(?:-)/i, /^(?:[0-9]+)/i, /^(?:\s+)/i, /^(?:;)/i, /^(?:$)/i],
723
+ conditions: { data_inner: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: true }, data: { rules: [0, 1, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 23, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: true }, axis_band_data: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 25, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: true }, axis_data: { rules: [0, 1, 2, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: true }, acc_descr_multiline: { rules: [12, 13], inclusive: false }, acc_descr: { rules: [10], inclusive: false }, acc_title: { rules: [8], inclusive: false }, title: { rules: [], inclusive: false }, md_string: { rules: [], inclusive: false }, string: { rules: [28, 29], inclusive: false }, INITIAL: { rules: [0, 1, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18, 21, 22, 26, 27, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46], inclusive: true } }
724
+ };
725
+ return lexer2;
726
+ }();
727
+ parser2.lexer = lexer;
728
+ function Parser() {
729
+ this.yy = {};
730
+ }
731
+ __name(Parser, "Parser");
732
+ Parser.prototype = parser2;
733
+ parser2.Parser = Parser;
734
+ return new Parser;
735
+ }();
736
+ parser.parser = parser;
737
+ var xychart_default = parser;
738
+ function isBarPlot(data) {
739
+ return data.type === "bar";
740
+ }
741
+ __name(isBarPlot, "isBarPlot");
742
+ function isBandAxisData(data) {
743
+ return data.type === "band";
744
+ }
745
+ __name(isBandAxisData, "isBandAxisData");
746
+ function isLinearAxisData(data) {
747
+ return data.type === "linear";
748
+ }
749
+ __name(isLinearAxisData, "isLinearAxisData");
750
+ var TextDimensionCalculatorWithFont = class {
751
+ constructor(parentGroup) {
752
+ this.parentGroup = parentGroup;
753
+ }
754
+ static {
755
+ __name(this, "TextDimensionCalculatorWithFont");
756
+ }
757
+ getMaxDimension(texts, fontSize) {
758
+ if (!this.parentGroup) {
759
+ return {
760
+ width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize,
761
+ height: fontSize
762
+ };
763
+ }
764
+ const dimension = {
765
+ width: 0,
766
+ height: 0
767
+ };
768
+ const elem = this.parentGroup.append("g").attr("visibility", "hidden").attr("font-size", fontSize);
769
+ for (const t of texts) {
770
+ const bbox = computeDimensionOfText(elem, 1, t);
771
+ const width = bbox ? bbox.width : t.length * fontSize;
772
+ const height = bbox ? bbox.height : fontSize;
773
+ dimension.width = Math.max(dimension.width, width);
774
+ dimension.height = Math.max(dimension.height, height);
775
+ }
776
+ elem.remove();
777
+ return dimension;
778
+ }
779
+ };
780
+ var BAR_WIDTH_TO_TICK_WIDTH_RATIO = 0.7;
781
+ var MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL = 0.2;
782
+ var BaseAxis = class {
783
+ constructor(axisConfig, title, textDimensionCalculator, axisThemeConfig) {
784
+ this.axisConfig = axisConfig;
785
+ this.title = title;
786
+ this.textDimensionCalculator = textDimensionCalculator;
787
+ this.axisThemeConfig = axisThemeConfig;
788
+ this.boundingRect = { x: 0, y: 0, width: 0, height: 0 };
789
+ this.axisPosition = "left";
790
+ this.showTitle = false;
791
+ this.showLabel = false;
792
+ this.showTick = false;
793
+ this.showAxisLine = false;
794
+ this.outerPadding = 0;
795
+ this.titleTextHeight = 0;
796
+ this.labelTextHeight = 0;
797
+ this.normalizedLabelRotationInRad = 0;
798
+ this.range = [0, 10];
799
+ this.boundingRect = { x: 0, y: 0, width: 0, height: 0 };
800
+ this.axisPosition = "left";
801
+ this.normalizedLabelRotationInRad = this.axisConfig.labelRotation >= -90 && this.axisConfig.labelRotation <= 90 ? this.axisConfig.labelRotation * Math.PI / 180 : 0;
802
+ }
803
+ static {
804
+ __name(this, "BaseAxis");
805
+ }
806
+ setRange(range) {
807
+ this.range = range;
808
+ if (this.axisPosition === "left" || this.axisPosition === "right") {
809
+ this.boundingRect.height = range[1] - range[0];
810
+ } else {
811
+ this.boundingRect.width = range[1] - range[0];
812
+ }
813
+ this.recalculateScale();
814
+ }
815
+ getRange() {
816
+ return [this.range[0] + this.outerPadding, this.range[1] - this.outerPadding];
817
+ }
818
+ setAxisPosition(axisPosition) {
819
+ this.axisPosition = axisPosition;
820
+ this.setRange(this.range);
821
+ }
822
+ getTickDistance() {
823
+ const range = this.getRange();
824
+ return Math.abs(range[0] - range[1]) / this.getTickValues().length;
825
+ }
826
+ getAxisOuterPadding() {
827
+ return this.outerPadding;
828
+ }
829
+ getLabelDimension() {
830
+ return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map((tick) => tick.toString()), this.axisConfig.labelFontSize);
831
+ }
832
+ recalculateOuterPaddingToDrawBar() {
833
+ if (BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() > this.outerPadding * 2) {
834
+ this.outerPadding = Math.floor(BAR_WIDTH_TO_TICK_WIDTH_RATIO * this.getTickDistance() / 2);
835
+ }
836
+ this.recalculateScale();
837
+ }
838
+ calculateSpaceIfDrawnHorizontally(availableSpace) {
839
+ let availableHeight = availableSpace.height;
840
+ if (this.axisConfig.showAxisLine && availableHeight > this.axisConfig.axisLineWidth) {
841
+ availableHeight -= this.axisConfig.axisLineWidth;
842
+ this.showAxisLine = true;
843
+ }
844
+ if (this.axisConfig.showLabel) {
845
+ const spaceRequired = this.getLabelDimension();
846
+ const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.width;
847
+ this.outerPadding = Math.min(spaceRequired.width / 2, maxPadding);
848
+ let heightRequired = spaceRequired.height;
849
+ if (this.axisPosition === "bottom" && this.normalizedLabelRotationInRad !== 0) {
850
+ heightRequired = Math.max(heightRequired, Math.abs(Math.sin(this.normalizedLabelRotationInRad) * spaceRequired.width) + Math.abs(Math.cos(this.normalizedLabelRotationInRad) * spaceRequired.height));
851
+ }
852
+ heightRequired += this.axisConfig.labelPadding * 2;
853
+ this.labelTextHeight = spaceRequired.height;
854
+ if (heightRequired <= availableHeight) {
855
+ availableHeight -= heightRequired;
856
+ this.showLabel = true;
857
+ }
858
+ }
859
+ if (this.axisConfig.showTick && availableHeight >= this.axisConfig.tickLength) {
860
+ this.showTick = true;
861
+ availableHeight -= this.axisConfig.tickLength;
862
+ }
863
+ if (this.axisConfig.showTitle && this.title) {
864
+ const spaceRequired = this.textDimensionCalculator.getMaxDimension([this.title], this.axisConfig.titleFontSize);
865
+ const heightRequired = spaceRequired.height + this.axisConfig.titlePadding * 2;
866
+ this.titleTextHeight = spaceRequired.height;
867
+ if (heightRequired <= availableHeight) {
868
+ availableHeight -= heightRequired;
869
+ this.showTitle = true;
870
+ }
871
+ }
872
+ this.boundingRect.width = availableSpace.width;
873
+ this.boundingRect.height = availableSpace.height - availableHeight;
874
+ }
875
+ calculateSpaceIfDrawnVertical(availableSpace) {
876
+ let availableWidth = availableSpace.width;
877
+ if (this.axisConfig.showAxisLine && availableWidth > this.axisConfig.axisLineWidth) {
878
+ availableWidth -= this.axisConfig.axisLineWidth;
879
+ this.showAxisLine = true;
880
+ }
881
+ if (this.axisConfig.showLabel) {
882
+ const spaceRequired = this.getLabelDimension();
883
+ const maxPadding = MAX_OUTER_PADDING_PERCENT_FOR_WRT_LABEL * availableSpace.height;
884
+ this.outerPadding = Math.min(spaceRequired.height / 2, maxPadding);
885
+ const widthRequired = spaceRequired.width + this.axisConfig.labelPadding * 2;
886
+ if (widthRequired <= availableWidth) {
887
+ availableWidth -= widthRequired;
888
+ this.showLabel = true;
889
+ }
890
+ }
891
+ if (this.axisConfig.showTick && availableWidth >= this.axisConfig.tickLength) {
892
+ this.showTick = true;
893
+ availableWidth -= this.axisConfig.tickLength;
894
+ }
895
+ if (this.axisConfig.showTitle && this.title) {
896
+ const spaceRequired = this.textDimensionCalculator.getMaxDimension([this.title], this.axisConfig.titleFontSize);
897
+ const widthRequired = spaceRequired.height + this.axisConfig.titlePadding * 2;
898
+ this.titleTextHeight = spaceRequired.height;
899
+ if (widthRequired <= availableWidth) {
900
+ availableWidth -= widthRequired;
901
+ this.showTitle = true;
902
+ }
903
+ }
904
+ this.boundingRect.width = availableSpace.width - availableWidth;
905
+ this.boundingRect.height = availableSpace.height;
906
+ }
907
+ calculateSpace(availableSpace) {
908
+ if (this.axisPosition === "left" || this.axisPosition === "right") {
909
+ this.calculateSpaceIfDrawnVertical(availableSpace);
910
+ } else {
911
+ this.calculateSpaceIfDrawnHorizontally(availableSpace);
912
+ }
913
+ this.recalculateScale();
914
+ return {
915
+ width: this.boundingRect.width,
916
+ height: this.boundingRect.height
917
+ };
918
+ }
919
+ setBoundingBoxXY(point) {
920
+ this.boundingRect.x = point.x;
921
+ this.boundingRect.y = point.y;
922
+ }
923
+ calculateOffsetByRotation(reference) {
924
+ const rotation = this.normalizedLabelRotationInRad;
925
+ if (rotation === 0) {
926
+ return 0;
927
+ }
928
+ return Math.sin(rotation) * this.getLabelDimension()[reference] / 2;
929
+ }
930
+ getDrawableElementsForLeftAxis() {
931
+ const drawableElement = [];
932
+ if (this.showAxisLine) {
933
+ const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2;
934
+ drawableElement.push({
935
+ type: "path",
936
+ groupTexts: ["left-axis", "axisl-line"],
937
+ data: [
938
+ {
939
+ path: `M ${x},${this.boundingRect.y} L ${x},${this.boundingRect.y + this.boundingRect.height} `,
940
+ strokeFill: this.axisThemeConfig.axisLineColor,
941
+ strokeWidth: this.axisConfig.axisLineWidth
942
+ }
943
+ ]
944
+ });
945
+ }
946
+ if (this.showLabel) {
947
+ drawableElement.push({
948
+ type: "text",
949
+ groupTexts: ["left-axis", "label"],
950
+ data: this.getTickValues().map((tick) => ({
951
+ text: tick.toString(),
952
+ x: this.boundingRect.x + this.boundingRect.width - (this.showLabel ? this.axisConfig.labelPadding : 0) - (this.showTick ? this.axisConfig.tickLength : 0) - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0),
953
+ y: this.getScaleValue(tick),
954
+ fill: this.axisThemeConfig.labelColor,
955
+ fontSize: this.axisConfig.labelFontSize,
956
+ rotation: 0,
957
+ verticalPos: "middle",
958
+ horizontalPos: "right"
959
+ }))
960
+ });
961
+ }
962
+ if (this.showTick) {
963
+ const x = this.boundingRect.x + this.boundingRect.width - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
964
+ drawableElement.push({
965
+ type: "path",
966
+ groupTexts: ["left-axis", "ticks"],
967
+ data: this.getTickValues().map((tick) => ({
968
+ path: `M ${x},${this.getScaleValue(tick)} L ${x - this.axisConfig.tickLength},${this.getScaleValue(tick)}`,
969
+ strokeFill: this.axisThemeConfig.tickColor,
970
+ strokeWidth: this.axisConfig.tickWidth
971
+ }))
972
+ });
973
+ }
974
+ if (this.showTitle) {
975
+ drawableElement.push({
976
+ type: "text",
977
+ groupTexts: ["left-axis", "title"],
978
+ data: [
979
+ {
980
+ text: this.title,
981
+ x: this.boundingRect.x + this.axisConfig.titlePadding,
982
+ y: this.boundingRect.y + this.boundingRect.height / 2,
983
+ fill: this.axisThemeConfig.titleColor,
984
+ fontSize: this.axisConfig.titleFontSize,
985
+ rotation: 270,
986
+ verticalPos: "top",
987
+ horizontalPos: "center"
988
+ }
989
+ ]
990
+ });
991
+ }
992
+ return drawableElement;
993
+ }
994
+ getDrawableElementsForBottomAxis() {
995
+ const drawableElement = [];
996
+ if (this.showAxisLine) {
997
+ const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2;
998
+ drawableElement.push({
999
+ type: "path",
1000
+ groupTexts: ["bottom-axis", "axis-line"],
1001
+ data: [
1002
+ {
1003
+ path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`,
1004
+ strokeFill: this.axisThemeConfig.axisLineColor,
1005
+ strokeWidth: this.axisConfig.axisLineWidth
1006
+ }
1007
+ ]
1008
+ });
1009
+ }
1010
+ if (this.showLabel) {
1011
+ drawableElement.push({
1012
+ type: "text",
1013
+ groupTexts: ["bottom-axis", "label"],
1014
+ data: this.getTickValues().map((tick) => ({
1015
+ text: tick.toString(),
1016
+ x: this.getScaleValue(tick) + this.calculateOffsetByRotation("height"),
1017
+ y: this.boundingRect.y + this.axisConfig.labelPadding + (this.showTick ? this.axisConfig.tickLength : 0) + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0) + Math.abs(this.calculateOffsetByRotation("width")),
1018
+ fill: this.axisThemeConfig.labelColor,
1019
+ fontSize: this.axisConfig.labelFontSize,
1020
+ rotation: this.normalizedLabelRotationInRad * 180 / Math.PI,
1021
+ verticalPos: "top",
1022
+ horizontalPos: "center"
1023
+ }))
1024
+ });
1025
+ }
1026
+ if (this.showTick) {
1027
+ const y = this.boundingRect.y + (this.showAxisLine ? this.axisConfig.axisLineWidth : 0);
1028
+ drawableElement.push({
1029
+ type: "path",
1030
+ groupTexts: ["bottom-axis", "ticks"],
1031
+ data: this.getTickValues().map((tick) => ({
1032
+ path: `M ${this.getScaleValue(tick)},${y} L ${this.getScaleValue(tick)},${y + this.axisConfig.tickLength}`,
1033
+ strokeFill: this.axisThemeConfig.tickColor,
1034
+ strokeWidth: this.axisConfig.tickWidth
1035
+ }))
1036
+ });
1037
+ }
1038
+ if (this.showTitle) {
1039
+ drawableElement.push({
1040
+ type: "text",
1041
+ groupTexts: ["bottom-axis", "title"],
1042
+ data: [
1043
+ {
1044
+ text: this.title,
1045
+ x: this.range[0] + (this.range[1] - this.range[0]) / 2,
1046
+ y: this.boundingRect.y + this.boundingRect.height - this.axisConfig.titlePadding - this.titleTextHeight,
1047
+ fill: this.axisThemeConfig.titleColor,
1048
+ fontSize: this.axisConfig.titleFontSize,
1049
+ rotation: 0,
1050
+ verticalPos: "top",
1051
+ horizontalPos: "center"
1052
+ }
1053
+ ]
1054
+ });
1055
+ }
1056
+ return drawableElement;
1057
+ }
1058
+ getDrawableElementsForTopAxis() {
1059
+ const drawableElement = [];
1060
+ if (this.showAxisLine) {
1061
+ const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2;
1062
+ drawableElement.push({
1063
+ type: "path",
1064
+ groupTexts: ["top-axis", "axis-line"],
1065
+ data: [
1066
+ {
1067
+ path: `M ${this.boundingRect.x},${y} L ${this.boundingRect.x + this.boundingRect.width},${y}`,
1068
+ strokeFill: this.axisThemeConfig.axisLineColor,
1069
+ strokeWidth: this.axisConfig.axisLineWidth
1070
+ }
1071
+ ]
1072
+ });
1073
+ }
1074
+ if (this.showLabel) {
1075
+ drawableElement.push({
1076
+ type: "text",
1077
+ groupTexts: ["top-axis", "label"],
1078
+ data: this.getTickValues().map((tick) => ({
1079
+ text: tick.toString(),
1080
+ x: this.getScaleValue(tick),
1081
+ y: this.boundingRect.y + (this.showTitle ? this.titleTextHeight + this.axisConfig.titlePadding * 2 : 0) + this.axisConfig.labelPadding,
1082
+ fill: this.axisThemeConfig.labelColor,
1083
+ fontSize: this.axisConfig.labelFontSize,
1084
+ rotation: 0,
1085
+ verticalPos: "top",
1086
+ horizontalPos: "center"
1087
+ }))
1088
+ });
1089
+ }
1090
+ if (this.showTick) {
1091
+ const y = this.boundingRect.y;
1092
+ drawableElement.push({
1093
+ type: "path",
1094
+ groupTexts: ["top-axis", "ticks"],
1095
+ data: this.getTickValues().map((tick) => ({
1096
+ path: `M ${this.getScaleValue(tick)},${y + this.boundingRect.height - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)} L ${this.getScaleValue(tick)},${y + this.boundingRect.height - this.axisConfig.tickLength - (this.showAxisLine ? this.axisConfig.axisLineWidth : 0)}`,
1097
+ strokeFill: this.axisThemeConfig.tickColor,
1098
+ strokeWidth: this.axisConfig.tickWidth
1099
+ }))
1100
+ });
1101
+ }
1102
+ if (this.showTitle) {
1103
+ drawableElement.push({
1104
+ type: "text",
1105
+ groupTexts: ["top-axis", "title"],
1106
+ data: [
1107
+ {
1108
+ text: this.title,
1109
+ x: this.boundingRect.x + this.boundingRect.width / 2,
1110
+ y: this.boundingRect.y + this.axisConfig.titlePadding,
1111
+ fill: this.axisThemeConfig.titleColor,
1112
+ fontSize: this.axisConfig.titleFontSize,
1113
+ rotation: 0,
1114
+ verticalPos: "top",
1115
+ horizontalPos: "center"
1116
+ }
1117
+ ]
1118
+ });
1119
+ }
1120
+ return drawableElement;
1121
+ }
1122
+ getDrawableElements() {
1123
+ if (this.axisPosition === "left") {
1124
+ return this.getDrawableElementsForLeftAxis();
1125
+ }
1126
+ if (this.axisPosition === "right") {
1127
+ throw Error("Drawing of right axis is not implemented");
1128
+ }
1129
+ if (this.axisPosition === "bottom") {
1130
+ return this.getDrawableElementsForBottomAxis();
1131
+ }
1132
+ if (this.axisPosition === "top") {
1133
+ return this.getDrawableElementsForTopAxis();
1134
+ }
1135
+ return [];
1136
+ }
1137
+ };
1138
+ var BandAxis = class extends BaseAxis {
1139
+ static {
1140
+ __name(this, "BandAxis");
1141
+ }
1142
+ constructor(axisConfig, axisThemeConfig, categories, title, textDimensionCalculator) {
1143
+ super(axisConfig, title, textDimensionCalculator, axisThemeConfig);
1144
+ this.categories = categories;
1145
+ this.scale = band().domain(this.categories).range(this.getRange());
1146
+ }
1147
+ setRange(range) {
1148
+ super.setRange(range);
1149
+ }
1150
+ recalculateScale() {
1151
+ this.scale = band().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(0.5);
1152
+ log.trace("BandAxis axis final categories, range: ", this.categories, this.getRange());
1153
+ }
1154
+ getTickValues() {
1155
+ return this.categories;
1156
+ }
1157
+ getScaleValue(value) {
1158
+ return this.scale(value) ?? this.getRange()[0];
1159
+ }
1160
+ };
1161
+ var LinearAxis = class extends BaseAxis {
1162
+ static {
1163
+ __name(this, "LinearAxis");
1164
+ }
1165
+ constructor(axisConfig, axisThemeConfig, domain, title, textDimensionCalculator) {
1166
+ super(axisConfig, title, textDimensionCalculator, axisThemeConfig);
1167
+ this.domain = domain;
1168
+ this.scale = linear().domain(this.domain).range(this.getRange());
1169
+ }
1170
+ getTickValues() {
1171
+ return this.scale.ticks();
1172
+ }
1173
+ recalculateScale() {
1174
+ const domain = [...this.domain];
1175
+ if (this.axisPosition === "left") {
1176
+ domain.reverse();
1177
+ }
1178
+ this.scale = linear().domain(domain).range(this.getRange());
1179
+ }
1180
+ getScaleValue(value) {
1181
+ return this.scale(value);
1182
+ }
1183
+ };
1184
+ function getAxis(data, axisConfig, axisThemeConfig, tmpSVGGroup2) {
1185
+ const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2);
1186
+ if (isBandAxisData(data)) {
1187
+ return new BandAxis(axisConfig, axisThemeConfig, data.categories, data.title, textDimensionCalculator);
1188
+ }
1189
+ return new LinearAxis(axisConfig, axisThemeConfig, [data.min, data.max], data.title, textDimensionCalculator);
1190
+ }
1191
+ __name(getAxis, "getAxis");
1192
+ var ChartTitle = class {
1193
+ constructor(textDimensionCalculator, chartConfig, chartData, chartThemeConfig) {
1194
+ this.textDimensionCalculator = textDimensionCalculator;
1195
+ this.chartConfig = chartConfig;
1196
+ this.chartData = chartData;
1197
+ this.chartThemeConfig = chartThemeConfig;
1198
+ this.boundingRect = {
1199
+ x: 0,
1200
+ y: 0,
1201
+ width: 0,
1202
+ height: 0
1203
+ };
1204
+ this.showChartTitle = false;
1205
+ }
1206
+ static {
1207
+ __name(this, "ChartTitle");
1208
+ }
1209
+ setBoundingBoxXY(point) {
1210
+ this.boundingRect.x = point.x;
1211
+ this.boundingRect.y = point.y;
1212
+ }
1213
+ calculateSpace(availableSpace) {
1214
+ const titleDimension = this.textDimensionCalculator.getMaxDimension([this.chartData.title], this.chartConfig.titleFontSize);
1215
+ const widthRequired = Math.max(titleDimension.width, availableSpace.width);
1216
+ const heightRequired = titleDimension.height + 2 * this.chartConfig.titlePadding;
1217
+ if (titleDimension.width <= widthRequired && titleDimension.height <= heightRequired && this.chartConfig.showTitle && this.chartData.title) {
1218
+ this.boundingRect.width = widthRequired;
1219
+ this.boundingRect.height = heightRequired;
1220
+ this.showChartTitle = true;
1221
+ }
1222
+ return {
1223
+ width: this.boundingRect.width,
1224
+ height: this.boundingRect.height
1225
+ };
1226
+ }
1227
+ getDrawableElements() {
1228
+ const drawableElem = [];
1229
+ if (this.showChartTitle) {
1230
+ drawableElem.push({
1231
+ groupTexts: ["chart-title"],
1232
+ type: "text",
1233
+ data: [
1234
+ {
1235
+ fontSize: this.chartConfig.titleFontSize,
1236
+ text: this.chartData.title,
1237
+ verticalPos: "middle",
1238
+ horizontalPos: "center",
1239
+ x: this.boundingRect.x + this.boundingRect.width / 2,
1240
+ y: this.boundingRect.y + this.boundingRect.height / 2,
1241
+ fill: this.chartThemeConfig.titleColor,
1242
+ rotation: 0
1243
+ }
1244
+ ]
1245
+ });
1246
+ }
1247
+ return drawableElem;
1248
+ }
1249
+ };
1250
+ function getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) {
1251
+ const textDimensionCalculator = new TextDimensionCalculatorWithFont(tmpSVGGroup2);
1252
+ return new ChartTitle(textDimensionCalculator, chartConfig, chartData, chartThemeConfig);
1253
+ }
1254
+ __name(getChartTitleComponent, "getChartTitleComponent");
1255
+ var LinePlot = class {
1256
+ constructor(plotData, xAxis, yAxis, orientation, plotIndex2) {
1257
+ this.plotData = plotData;
1258
+ this.xAxis = xAxis;
1259
+ this.yAxis = yAxis;
1260
+ this.orientation = orientation;
1261
+ this.plotIndex = plotIndex2;
1262
+ }
1263
+ static {
1264
+ __name(this, "LinePlot");
1265
+ }
1266
+ getDrawableElement() {
1267
+ const finalData = this.plotData.data.map((d) => [
1268
+ this.xAxis.getScaleValue(d[0]),
1269
+ this.yAxis.getScaleValue(d[1])
1270
+ ]);
1271
+ let path;
1272
+ if (this.orientation === "horizontal") {
1273
+ path = line_default().y((d) => d[0]).x((d) => d[1])(finalData);
1274
+ } else {
1275
+ path = line_default().x((d) => d[0]).y((d) => d[1])(finalData);
1276
+ }
1277
+ if (!path) {
1278
+ return [];
1279
+ }
1280
+ const elements = [
1281
+ {
1282
+ groupTexts: ["plot", `line-plot-${this.plotIndex}`],
1283
+ type: "path",
1284
+ data: [
1285
+ {
1286
+ path,
1287
+ strokeFill: this.plotData.strokeFill,
1288
+ strokeWidth: this.plotData.strokeWidth
1289
+ }
1290
+ ]
1291
+ }
1292
+ ];
1293
+ if (this.plotData.pointLabels && this.plotData.pointLabels.length > 0) {
1294
+ const labelOffset = 10;
1295
+ const fontSize = 12;
1296
+ const textData = [];
1297
+ for (const [i, [px, py]] of finalData.entries()) {
1298
+ const label = this.plotData.pointLabels[i];
1299
+ if (!label) {
1300
+ continue;
1301
+ }
1302
+ if (this.orientation === "horizontal") {
1303
+ textData.push({
1304
+ x: py + labelOffset,
1305
+ y: px,
1306
+ text: label,
1307
+ fill: this.plotData.strokeFill,
1308
+ verticalPos: "middle",
1309
+ horizontalPos: "left",
1310
+ fontSize,
1311
+ rotation: 0
1312
+ });
1313
+ } else {
1314
+ textData.push({
1315
+ x: px,
1316
+ y: py - labelOffset,
1317
+ text: label,
1318
+ fill: this.plotData.strokeFill,
1319
+ verticalPos: "middle",
1320
+ horizontalPos: "center",
1321
+ fontSize,
1322
+ rotation: 0
1323
+ });
1324
+ }
1325
+ }
1326
+ if (textData.length > 0) {
1327
+ elements.push({
1328
+ groupTexts: ["plot", `line-plot-${this.plotIndex}`, "labels"],
1329
+ type: "text",
1330
+ data: textData
1331
+ });
1332
+ }
1333
+ }
1334
+ return elements;
1335
+ }
1336
+ };
1337
+ var BarPlot = class {
1338
+ constructor(barData, boundingRect, xAxis, yAxis, orientation, plotIndex2) {
1339
+ this.barData = barData;
1340
+ this.boundingRect = boundingRect;
1341
+ this.xAxis = xAxis;
1342
+ this.yAxis = yAxis;
1343
+ this.orientation = orientation;
1344
+ this.plotIndex = plotIndex2;
1345
+ }
1346
+ static {
1347
+ __name(this, "BarPlot");
1348
+ }
1349
+ getDrawableElement() {
1350
+ const finalData = this.barData.data.map((d) => [
1351
+ this.xAxis.getScaleValue(d[0]),
1352
+ this.yAxis.getScaleValue(d[1])
1353
+ ]);
1354
+ const barPaddingPercent = 0.05;
1355
+ const barWidth = Math.min(this.xAxis.getAxisOuterPadding() * 2, this.xAxis.getTickDistance()) * (1 - barPaddingPercent);
1356
+ const barWidthHalf = barWidth / 2;
1357
+ if (this.orientation === "horizontal") {
1358
+ return [
1359
+ {
1360
+ groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
1361
+ type: "rect",
1362
+ data: finalData.map((data) => ({
1363
+ x: this.boundingRect.x,
1364
+ y: data[0] - barWidthHalf,
1365
+ height: barWidth,
1366
+ width: data[1] - this.boundingRect.x,
1367
+ fill: this.barData.fill,
1368
+ strokeWidth: 0,
1369
+ strokeFill: this.barData.fill
1370
+ }))
1371
+ }
1372
+ ];
1373
+ }
1374
+ return [
1375
+ {
1376
+ groupTexts: ["plot", `bar-plot-${this.plotIndex}`],
1377
+ type: "rect",
1378
+ data: finalData.map((data) => ({
1379
+ x: data[0] - barWidthHalf,
1380
+ y: data[1],
1381
+ width: barWidth,
1382
+ height: this.boundingRect.y + this.boundingRect.height - data[1],
1383
+ fill: this.barData.fill,
1384
+ strokeWidth: 0,
1385
+ strokeFill: this.barData.fill
1386
+ }))
1387
+ }
1388
+ ];
1389
+ }
1390
+ };
1391
+ var BasePlot = class {
1392
+ constructor(chartConfig, chartData, chartThemeConfig) {
1393
+ this.chartConfig = chartConfig;
1394
+ this.chartData = chartData;
1395
+ this.chartThemeConfig = chartThemeConfig;
1396
+ this.boundingRect = {
1397
+ x: 0,
1398
+ y: 0,
1399
+ width: 0,
1400
+ height: 0
1401
+ };
1402
+ }
1403
+ static {
1404
+ __name(this, "BasePlot");
1405
+ }
1406
+ setAxes(xAxis, yAxis) {
1407
+ this.xAxis = xAxis;
1408
+ this.yAxis = yAxis;
1409
+ }
1410
+ setBoundingBoxXY(point) {
1411
+ this.boundingRect.x = point.x;
1412
+ this.boundingRect.y = point.y;
1413
+ }
1414
+ calculateSpace(availableSpace) {
1415
+ this.boundingRect.width = availableSpace.width;
1416
+ this.boundingRect.height = availableSpace.height;
1417
+ return {
1418
+ width: this.boundingRect.width,
1419
+ height: this.boundingRect.height
1420
+ };
1421
+ }
1422
+ getDrawableElements() {
1423
+ if (!(this.xAxis && this.yAxis)) {
1424
+ throw Error("Axes must be passed to render Plots");
1425
+ }
1426
+ const drawableElem = [];
1427
+ for (const [i, plot] of this.chartData.plots.entries()) {
1428
+ switch (plot.type) {
1429
+ case "line":
1430
+ {
1431
+ const linePlot = new LinePlot(plot, this.xAxis, this.yAxis, this.chartConfig.chartOrientation, i);
1432
+ drawableElem.push(...linePlot.getDrawableElement());
1433
+ }
1434
+ break;
1435
+ case "bar":
1436
+ {
1437
+ const barPlot = new BarPlot(plot, this.boundingRect, this.xAxis, this.yAxis, this.chartConfig.chartOrientation, i);
1438
+ drawableElem.push(...barPlot.getDrawableElement());
1439
+ }
1440
+ break;
1441
+ }
1442
+ }
1443
+ return drawableElem;
1444
+ }
1445
+ };
1446
+ function getPlotComponent(chartConfig, chartData, chartThemeConfig) {
1447
+ return new BasePlot(chartConfig, chartData, chartThemeConfig);
1448
+ }
1449
+ __name(getPlotComponent, "getPlotComponent");
1450
+ var Orchestrator = class {
1451
+ constructor(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2) {
1452
+ this.chartConfig = chartConfig;
1453
+ this.chartData = chartData;
1454
+ this.componentStore = {
1455
+ title: getChartTitleComponent(chartConfig, chartData, chartThemeConfig, tmpSVGGroup2),
1456
+ plot: getPlotComponent(chartConfig, chartData, chartThemeConfig),
1457
+ xAxis: getAxis(chartData.xAxis, chartConfig.xAxis, {
1458
+ titleColor: chartThemeConfig.xAxisTitleColor,
1459
+ labelColor: chartThemeConfig.xAxisLabelColor,
1460
+ tickColor: chartThemeConfig.xAxisTickColor,
1461
+ axisLineColor: chartThemeConfig.xAxisLineColor
1462
+ }, tmpSVGGroup2),
1463
+ yAxis: getAxis(chartData.yAxis, chartConfig.yAxis, {
1464
+ titleColor: chartThemeConfig.yAxisTitleColor,
1465
+ labelColor: chartThemeConfig.yAxisLabelColor,
1466
+ tickColor: chartThemeConfig.yAxisTickColor,
1467
+ axisLineColor: chartThemeConfig.yAxisLineColor
1468
+ }, tmpSVGGroup2)
1469
+ };
1470
+ }
1471
+ static {
1472
+ __name(this, "Orchestrator");
1473
+ }
1474
+ calculateVerticalSpace() {
1475
+ let availableWidth = this.chartConfig.width;
1476
+ let availableHeight = this.chartConfig.height;
1477
+ let plotX = 0;
1478
+ let plotY = 0;
1479
+ let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100);
1480
+ let chartHeight = Math.floor(availableHeight * this.chartConfig.plotReservedSpacePercent / 100);
1481
+ let spaceUsed = this.componentStore.plot.calculateSpace({
1482
+ width: chartWidth,
1483
+ height: chartHeight
1484
+ });
1485
+ availableWidth -= spaceUsed.width;
1486
+ availableHeight -= spaceUsed.height;
1487
+ spaceUsed = this.componentStore.title.calculateSpace({
1488
+ width: this.chartConfig.width,
1489
+ height: availableHeight
1490
+ });
1491
+ plotY = spaceUsed.height;
1492
+ availableHeight -= spaceUsed.height;
1493
+ this.componentStore.xAxis.setAxisPosition("bottom");
1494
+ spaceUsed = this.componentStore.xAxis.calculateSpace({
1495
+ width: availableWidth,
1496
+ height: availableHeight
1497
+ });
1498
+ availableHeight -= spaceUsed.height;
1499
+ this.componentStore.yAxis.setAxisPosition("left");
1500
+ spaceUsed = this.componentStore.yAxis.calculateSpace({
1501
+ width: availableWidth,
1502
+ height: availableHeight
1503
+ });
1504
+ plotX = spaceUsed.width;
1505
+ availableWidth -= spaceUsed.width;
1506
+ if (availableWidth > 0) {
1507
+ chartWidth += availableWidth;
1508
+ availableWidth = 0;
1509
+ }
1510
+ if (availableHeight > 0) {
1511
+ chartHeight += availableHeight;
1512
+ availableHeight = 0;
1513
+ }
1514
+ this.componentStore.plot.calculateSpace({
1515
+ width: chartWidth,
1516
+ height: chartHeight
1517
+ });
1518
+ this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY });
1519
+ this.componentStore.xAxis.setRange([plotX, plotX + chartWidth]);
1520
+ this.componentStore.xAxis.setBoundingBoxXY({ x: plotX, y: plotY + chartHeight });
1521
+ this.componentStore.yAxis.setRange([plotY, plotY + chartHeight]);
1522
+ this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: plotY });
1523
+ if (this.chartData.plots.some((p) => isBarPlot(p))) {
1524
+ this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
1525
+ }
1526
+ }
1527
+ calculateHorizontalSpace() {
1528
+ let availableWidth = this.chartConfig.width;
1529
+ let availableHeight = this.chartConfig.height;
1530
+ let titleYEnd = 0;
1531
+ let plotX = 0;
1532
+ let plotY = 0;
1533
+ let chartWidth = Math.floor(availableWidth * this.chartConfig.plotReservedSpacePercent / 100);
1534
+ let chartHeight = Math.floor(availableHeight * this.chartConfig.plotReservedSpacePercent / 100);
1535
+ let spaceUsed = this.componentStore.plot.calculateSpace({
1536
+ width: chartWidth,
1537
+ height: chartHeight
1538
+ });
1539
+ availableWidth -= spaceUsed.width;
1540
+ availableHeight -= spaceUsed.height;
1541
+ spaceUsed = this.componentStore.title.calculateSpace({
1542
+ width: this.chartConfig.width,
1543
+ height: availableHeight
1544
+ });
1545
+ titleYEnd = spaceUsed.height;
1546
+ availableHeight -= spaceUsed.height;
1547
+ this.componentStore.xAxis.setAxisPosition("left");
1548
+ spaceUsed = this.componentStore.xAxis.calculateSpace({
1549
+ width: availableWidth,
1550
+ height: availableHeight
1551
+ });
1552
+ availableWidth -= spaceUsed.width;
1553
+ plotX = spaceUsed.width;
1554
+ this.componentStore.yAxis.setAxisPosition("top");
1555
+ spaceUsed = this.componentStore.yAxis.calculateSpace({
1556
+ width: availableWidth,
1557
+ height: availableHeight
1558
+ });
1559
+ availableHeight -= spaceUsed.height;
1560
+ plotY = titleYEnd + spaceUsed.height;
1561
+ if (availableWidth > 0) {
1562
+ chartWidth += availableWidth;
1563
+ availableWidth = 0;
1564
+ }
1565
+ if (availableHeight > 0) {
1566
+ chartHeight += availableHeight;
1567
+ availableHeight = 0;
1568
+ }
1569
+ this.componentStore.plot.calculateSpace({
1570
+ width: chartWidth,
1571
+ height: chartHeight
1572
+ });
1573
+ this.componentStore.plot.setBoundingBoxXY({ x: plotX, y: plotY });
1574
+ this.componentStore.yAxis.setRange([plotX, plotX + chartWidth]);
1575
+ this.componentStore.yAxis.setBoundingBoxXY({ x: plotX, y: titleYEnd });
1576
+ this.componentStore.xAxis.setRange([plotY, plotY + chartHeight]);
1577
+ this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: plotY });
1578
+ if (this.chartData.plots.some((p) => isBarPlot(p))) {
1579
+ this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
1580
+ }
1581
+ }
1582
+ calculateSpace() {
1583
+ if (this.chartConfig.chartOrientation === "horizontal") {
1584
+ this.calculateHorizontalSpace();
1585
+ } else {
1586
+ this.calculateVerticalSpace();
1587
+ }
1588
+ }
1589
+ getDrawableElement() {
1590
+ this.calculateSpace();
1591
+ const drawableElem = [];
1592
+ this.componentStore.plot.setAxes(this.componentStore.xAxis, this.componentStore.yAxis);
1593
+ for (const component of Object.values(this.componentStore)) {
1594
+ drawableElem.push(...component.getDrawableElements());
1595
+ }
1596
+ return drawableElem;
1597
+ }
1598
+ };
1599
+ var XYChartBuilder = class {
1600
+ static {
1601
+ __name(this, "XYChartBuilder");
1602
+ }
1603
+ static build(config, chartData, chartThemeConfig, tmpSVGGroup2) {
1604
+ const orchestrator = new Orchestrator(config, chartData, chartThemeConfig, tmpSVGGroup2);
1605
+ return orchestrator.getDrawableElement();
1606
+ }
1607
+ };
1608
+ var plotIndex = 0;
1609
+ var tmpSVGGroup;
1610
+ var xyChartConfig = getChartDefaultConfig();
1611
+ var xyChartThemeConfig = getChartDefaultThemeConfig();
1612
+ var xyChartData = getChartDefaultData();
1613
+ var plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim());
1614
+ var hasSetXAxis = false;
1615
+ var hasSetYAxis = false;
1616
+ function getChartDefaultThemeConfig() {
1617
+ const defaultThemeVariables = getThemeVariables3();
1618
+ const config = getConfig();
1619
+ return cleanAndMerge(defaultThemeVariables.xyChart, config.themeVariables.xyChart);
1620
+ }
1621
+ __name(getChartDefaultThemeConfig, "getChartDefaultThemeConfig");
1622
+ function getChartDefaultConfig() {
1623
+ const config = getConfig();
1624
+ return cleanAndMerge(defaultConfig_default.xyChart, config.xyChart);
1625
+ }
1626
+ __name(getChartDefaultConfig, "getChartDefaultConfig");
1627
+ function getChartDefaultData() {
1628
+ return {
1629
+ yAxis: {
1630
+ type: "linear",
1631
+ title: "",
1632
+ min: Infinity,
1633
+ max: -Infinity
1634
+ },
1635
+ xAxis: {
1636
+ type: "band",
1637
+ title: "",
1638
+ categories: []
1639
+ },
1640
+ title: "",
1641
+ plots: []
1642
+ };
1643
+ }
1644
+ __name(getChartDefaultData, "getChartDefaultData");
1645
+ function textSanitizer(text) {
1646
+ const config = getConfig();
1647
+ return sanitizeText(text.trim(), config);
1648
+ }
1649
+ __name(textSanitizer, "textSanitizer");
1650
+ function setTmpSVGG(SVGG) {
1651
+ tmpSVGGroup = SVGG;
1652
+ }
1653
+ __name(setTmpSVGG, "setTmpSVGG");
1654
+ function setOrientation(orientation) {
1655
+ if (orientation === "horizontal") {
1656
+ xyChartConfig.chartOrientation = "horizontal";
1657
+ } else {
1658
+ xyChartConfig.chartOrientation = "vertical";
1659
+ }
1660
+ }
1661
+ __name(setOrientation, "setOrientation");
1662
+ function setXAxisTitle(title) {
1663
+ xyChartData.xAxis.title = textSanitizer(title.text);
1664
+ }
1665
+ __name(setXAxisTitle, "setXAxisTitle");
1666
+ function setXAxisRangeData(min, max) {
1667
+ xyChartData.xAxis = { type: "linear", title: xyChartData.xAxis.title, min, max };
1668
+ hasSetXAxis = true;
1669
+ }
1670
+ __name(setXAxisRangeData, "setXAxisRangeData");
1671
+ function setXAxisBand(categories) {
1672
+ xyChartData.xAxis = {
1673
+ type: "band",
1674
+ title: xyChartData.xAxis.title,
1675
+ categories: categories.map((c) => textSanitizer(c.text))
1676
+ };
1677
+ hasSetXAxis = true;
1678
+ }
1679
+ __name(setXAxisBand, "setXAxisBand");
1680
+ function setYAxisTitle(title) {
1681
+ xyChartData.yAxis.title = textSanitizer(title.text);
1682
+ }
1683
+ __name(setYAxisTitle, "setYAxisTitle");
1684
+ function setYAxisRangeData(min, max) {
1685
+ xyChartData.yAxis = { type: "linear", title: xyChartData.yAxis.title, min, max };
1686
+ hasSetYAxis = true;
1687
+ }
1688
+ __name(setYAxisRangeData, "setYAxisRangeData");
1689
+ function setYAxisRangeFromPlotData(data) {
1690
+ const minValue = Math.min(...data);
1691
+ const maxValue = Math.max(...data);
1692
+ const prevMinValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.min : Infinity;
1693
+ const prevMaxValue = isLinearAxisData(xyChartData.yAxis) ? xyChartData.yAxis.max : -Infinity;
1694
+ xyChartData.yAxis = {
1695
+ type: "linear",
1696
+ title: xyChartData.yAxis.title,
1697
+ min: Math.min(prevMinValue, minValue),
1698
+ max: Math.max(prevMaxValue, maxValue)
1699
+ };
1700
+ }
1701
+ __name(setYAxisRangeFromPlotData, "setYAxisRangeFromPlotData");
1702
+ function transformDataWithoutCategory(data) {
1703
+ let retData = [];
1704
+ if (data.length === 0) {
1705
+ return retData;
1706
+ }
1707
+ if (!hasSetXAxis) {
1708
+ const prevMinValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.min : Infinity;
1709
+ const prevMaxValue = isLinearAxisData(xyChartData.xAxis) ? xyChartData.xAxis.max : -Infinity;
1710
+ setXAxisRangeData(Math.min(prevMinValue, 1), Math.max(prevMaxValue, data.length));
1711
+ }
1712
+ if (isBandAxisData(xyChartData.xAxis) && data.length > xyChartData.xAxis.categories.length) {
1713
+ data = data.slice(0, xyChartData.xAxis.categories.length);
1714
+ }
1715
+ if (!hasSetYAxis) {
1716
+ setYAxisRangeFromPlotData(data);
1717
+ }
1718
+ if (isBandAxisData(xyChartData.xAxis)) {
1719
+ retData = xyChartData.xAxis.categories.map((c, i) => [c, data[i]]);
1720
+ }
1721
+ if (isLinearAxisData(xyChartData.xAxis)) {
1722
+ const min = xyChartData.xAxis.min;
1723
+ const max = xyChartData.xAxis.max;
1724
+ if (data.length === 1) {
1725
+ retData = [[`${min}`, data[0]]];
1726
+ } else {
1727
+ const step = (max - min) / (data.length - 1);
1728
+ retData = data.map((datum, index) => [`${min + index * step}`, datum]);
1729
+ }
1730
+ }
1731
+ return retData;
1732
+ }
1733
+ __name(transformDataWithoutCategory, "transformDataWithoutCategory");
1734
+ function getPlotColorFromPalette(plotIndex2) {
1735
+ return plotColorPalette[plotIndex2 === 0 ? 0 : plotIndex2 % plotColorPalette.length];
1736
+ }
1737
+ __name(getPlotColorFromPalette, "getPlotColorFromPalette");
1738
+ function setLineData(title, data) {
1739
+ const values = data.map((d) => d.value);
1740
+ const labels = data.map((d) => d.label ? textSanitizer(d.label) : "");
1741
+ const plotData = transformDataWithoutCategory(values);
1742
+ const hasAnyLabel = labels.some((l) => l !== "");
1743
+ xyChartData.plots.push({
1744
+ type: "line",
1745
+ strokeFill: getPlotColorFromPalette(plotIndex),
1746
+ strokeWidth: 2,
1747
+ data: plotData,
1748
+ ...hasAnyLabel ? { pointLabels: labels } : {}
1749
+ });
1750
+ plotIndex++;
1751
+ }
1752
+ __name(setLineData, "setLineData");
1753
+ function setBarData(title, data) {
1754
+ const values = data.map((d) => d.value);
1755
+ const plotData = transformDataWithoutCategory(values);
1756
+ xyChartData.plots.push({
1757
+ type: "bar",
1758
+ fill: getPlotColorFromPalette(plotIndex),
1759
+ data: plotData
1760
+ });
1761
+ plotIndex++;
1762
+ }
1763
+ __name(setBarData, "setBarData");
1764
+ function getDrawableElem() {
1765
+ if (xyChartData.plots.length === 0) {
1766
+ throw Error("No Plot to render, please provide a plot with some data");
1767
+ }
1768
+ xyChartData.title = getDiagramTitle();
1769
+ return XYChartBuilder.build(xyChartConfig, xyChartData, xyChartThemeConfig, tmpSVGGroup);
1770
+ }
1771
+ __name(getDrawableElem, "getDrawableElem");
1772
+ function getChartThemeConfig() {
1773
+ return xyChartThemeConfig;
1774
+ }
1775
+ __name(getChartThemeConfig, "getChartThemeConfig");
1776
+ function getChartConfig() {
1777
+ return xyChartConfig;
1778
+ }
1779
+ __name(getChartConfig, "getChartConfig");
1780
+ function getXYChartData() {
1781
+ return xyChartData;
1782
+ }
1783
+ __name(getXYChartData, "getXYChartData");
1784
+ var clear2 = /* @__PURE__ */ __name(function() {
1785
+ clear();
1786
+ plotIndex = 0;
1787
+ xyChartConfig = getChartDefaultConfig();
1788
+ xyChartData = getChartDefaultData();
1789
+ xyChartThemeConfig = getChartDefaultThemeConfig();
1790
+ plotColorPalette = xyChartThemeConfig.plotColorPalette.split(",").map((color) => color.trim());
1791
+ hasSetXAxis = false;
1792
+ hasSetYAxis = false;
1793
+ }, "clear");
1794
+ var xychartDb_default = {
1795
+ getDrawableElem,
1796
+ clear: clear2,
1797
+ setAccTitle,
1798
+ getAccTitle,
1799
+ setDiagramTitle,
1800
+ getDiagramTitle,
1801
+ getAccDescription,
1802
+ setAccDescription,
1803
+ setOrientation,
1804
+ setXAxisTitle,
1805
+ setXAxisRangeData,
1806
+ setXAxisBand,
1807
+ setYAxisTitle,
1808
+ setYAxisRangeData,
1809
+ setLineData,
1810
+ setBarData,
1811
+ setTmpSVGG,
1812
+ getChartThemeConfig,
1813
+ getChartConfig,
1814
+ getXYChartData
1815
+ };
1816
+ var draw = /* @__PURE__ */ __name((txt, id, _version, diagObj) => {
1817
+ const db = diagObj.db;
1818
+ const themeConfig = db.getChartThemeConfig();
1819
+ const chartConfig = db.getChartConfig();
1820
+ const labelData = db.getXYChartData().plots[0].data.map((data) => data[1]);
1821
+ function getDominantBaseLine(horizontalPos) {
1822
+ return horizontalPos === "top" ? "text-before-edge" : "middle";
1823
+ }
1824
+ __name(getDominantBaseLine, "getDominantBaseLine");
1825
+ function getTextAnchor(verticalPos) {
1826
+ return verticalPos === "left" ? "start" : verticalPos === "right" ? "end" : "middle";
1827
+ }
1828
+ __name(getTextAnchor, "getTextAnchor");
1829
+ function getTextTransformation(data) {
1830
+ return `translate(${data.x}, ${data.y}) rotate(${data.rotation || 0})`;
1831
+ }
1832
+ __name(getTextTransformation, "getTextTransformation");
1833
+ log.debug(`Rendering xychart chart
1834
+ ` + txt);
1835
+ const svg = selectSvgElement(id);
1836
+ const group = svg.append("g").attr("class", "main");
1837
+ const background = group.append("rect").attr("width", chartConfig.width).attr("height", chartConfig.height).attr("class", "background");
1838
+ configureSvgSize(svg, chartConfig.height, chartConfig.width, true);
1839
+ svg.attr("viewBox", `0 0 ${chartConfig.width} ${chartConfig.height}`);
1840
+ background.attr("fill", themeConfig.backgroundColor);
1841
+ db.setTmpSVGG(svg.append("g").attr("class", "mermaid-tmp-group"));
1842
+ const shapes = db.getDrawableElem();
1843
+ const groups = {};
1844
+ function getGroup(gList) {
1845
+ let elem = group;
1846
+ let prefix = "";
1847
+ for (const [i] of gList.entries()) {
1848
+ let parent = group;
1849
+ if (i > 0 && groups[prefix]) {
1850
+ parent = groups[prefix];
1851
+ }
1852
+ prefix += gList[i];
1853
+ elem = groups[prefix];
1854
+ if (!elem) {
1855
+ elem = groups[prefix] = parent.append("g").attr("class", gList[i]);
1856
+ }
1857
+ }
1858
+ return elem;
1859
+ }
1860
+ __name(getGroup, "getGroup");
1861
+ for (const shape of shapes) {
1862
+ if (shape.data.length === 0) {
1863
+ continue;
1864
+ }
1865
+ const shapeGroup = getGroup(shape.groupTexts);
1866
+ switch (shape.type) {
1867
+ case "rect":
1868
+ shapeGroup.selectAll("rect").data(shape.data).enter().append("rect").attr("x", (data) => data.x).attr("y", (data) => data.y).attr("width", (data) => data.width).attr("height", (data) => data.height).attr("fill", (data) => data.fill).attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth);
1869
+ if (chartConfig.showDataLabel) {
1870
+ const showDataLabelOutsideBar = chartConfig.showDataLabelOutsideBar;
1871
+ if (chartConfig.chartOrientation === "horizontal") {
1872
+ let fitsHorizontally2 = function(item, fontSize) {
1873
+ const { data, label } = item;
1874
+ const textWidth = fontSize * label.length * charWidthFactor;
1875
+ return textWidth <= data.width - rightMargin;
1876
+ };
1877
+ var fitsHorizontally = fitsHorizontally2;
1878
+ __name(fitsHorizontally2, "fitsHorizontally");
1879
+ const charWidthFactor = 0.7;
1880
+ const rightMargin = 10;
1881
+ const validItems = shape.data.map((d, i) => ({ data: d, label: labelData[i].toString() })).filter((item) => item.data.width > 0 && item.data.height > 0);
1882
+ const candidateFontSizes = validItems.map((item) => {
1883
+ const { data } = item;
1884
+ let fontSize = data.height * 0.7;
1885
+ while (!fitsHorizontally2(item, fontSize) && fontSize > 0) {
1886
+ fontSize -= 1;
1887
+ }
1888
+ return fontSize;
1889
+ });
1890
+ const uniformFontSize = Math.floor(Math.min(...candidateFontSizes));
1891
+ const determineLabelXPosition = /* @__PURE__ */ __name((item) => {
1892
+ if (showDataLabelOutsideBar) {
1893
+ return item.data.x + item.data.width + rightMargin;
1894
+ } else {
1895
+ return item.data.x + item.data.width - rightMargin;
1896
+ }
1897
+ }, "determineLabelXPosition");
1898
+ shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x", determineLabelXPosition).attr("y", (item) => item.data.y + item.data.height / 2).attr("text-anchor", showDataLabelOutsideBar ? "start" : "end").attr("dominant-baseline", "middle").attr("fill", themeConfig.dataLabelColor).attr("font-size", `${uniformFontSize}px`).text((item) => item.label);
1899
+ } else {
1900
+ let fitsInBar2 = function(item, fontSize, yOffset2) {
1901
+ const { data, label } = item;
1902
+ const charWidthFactor = 0.7;
1903
+ const textWidth = fontSize * label.length * charWidthFactor;
1904
+ const centerX = data.x + data.width / 2;
1905
+ const leftEdge = centerX - textWidth / 2;
1906
+ const rightEdge = centerX + textWidth / 2;
1907
+ const horizontalFits = leftEdge >= data.x && rightEdge <= data.x + data.width;
1908
+ const verticalFits = data.y + yOffset2 + fontSize <= data.y + data.height;
1909
+ return horizontalFits && verticalFits;
1910
+ };
1911
+ var fitsInBar = fitsInBar2;
1912
+ __name(fitsInBar2, "fitsInBar");
1913
+ const yOffset = 10;
1914
+ const validItems = shape.data.map((d, i) => ({ data: d, label: labelData[i].toString() })).filter((item) => item.data.width > 0 && item.data.height > 0);
1915
+ const candidateFontSizes = validItems.map((item) => {
1916
+ const { data, label } = item;
1917
+ let fontSize = data.width / (label.length * 0.7);
1918
+ while (!fitsInBar2(item, fontSize, yOffset) && fontSize > 0) {
1919
+ fontSize -= 1;
1920
+ }
1921
+ return fontSize;
1922
+ });
1923
+ const uniformFontSize = Math.floor(Math.min(...candidateFontSizes));
1924
+ const determineLabelYPosition = /* @__PURE__ */ __name((item) => {
1925
+ if (showDataLabelOutsideBar) {
1926
+ return item.data.y - yOffset;
1927
+ } else {
1928
+ return item.data.y + yOffset;
1929
+ }
1930
+ }, "determineLabelYPosition");
1931
+ shapeGroup.selectAll("text").data(validItems).enter().append("text").attr("x", (item) => item.data.x + item.data.width / 2).attr("y", determineLabelYPosition).attr("text-anchor", "middle").attr("dominant-baseline", showDataLabelOutsideBar ? "auto" : "hanging").attr("fill", themeConfig.dataLabelColor).attr("font-size", `${uniformFontSize}px`).text((item) => item.label);
1932
+ }
1933
+ }
1934
+ break;
1935
+ case "text":
1936
+ shapeGroup.selectAll("text").data(shape.data).enter().append("text").attr("x", 0).attr("y", 0).attr("fill", (data) => data.fill).attr("font-size", (data) => data.fontSize).attr("dominant-baseline", (data) => getDominantBaseLine(data.verticalPos)).attr("text-anchor", (data) => getTextAnchor(data.horizontalPos)).attr("transform", (data) => getTextTransformation(data)).text((data) => data.text);
1937
+ break;
1938
+ case "path":
1939
+ shapeGroup.selectAll("path").data(shape.data).enter().append("path").attr("d", (data) => data.path).attr("fill", (data) => data.fill ? data.fill : "none").attr("stroke", (data) => data.strokeFill).attr("stroke-width", (data) => data.strokeWidth);
1940
+ break;
1941
+ }
1942
+ }
1943
+ }, "draw");
1944
+ var xychartRenderer_default = {
1945
+ draw
1946
+ };
1947
+ var diagram = {
1948
+ parser: xychart_default,
1949
+ db: xychartDb_default,
1950
+ renderer: xychartRenderer_default
1951
+ };
1952
+ export {
1953
+ diagram
1954
+ };