@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,1673 @@
1
+ import {
2
+ getIconSVG,
3
+ isIconAvailable
4
+ } from "./markdown-yengsms5.js";
5
+ import {
6
+ decodeEntities
7
+ } from "./markdown-ff5wvb43.js";
8
+ import {
9
+ common_default,
10
+ getConfig,
11
+ hasKatex,
12
+ renderKatexSanitized,
13
+ sanitizeText
14
+ } from "./markdown-92n37gd4.js";
15
+ import {
16
+ log,
17
+ select_default
18
+ } from "./markdown-xw8dsk8b.js";
19
+ import {
20
+ __name
21
+ } from "./markdown-1s5vwkf2.js";
22
+
23
+ // node_modules/mermaid/node_modules/marked/lib/marked.esm.js
24
+ function L() {
25
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
26
+ }
27
+ var T = L();
28
+ function G(l) {
29
+ T = l;
30
+ }
31
+ var E = { exec: () => null };
32
+ function d(l, e = "") {
33
+ let t = typeof l == "string" ? l : l.source, n = { replace: (r, i) => {
34
+ let s = typeof i == "string" ? i : i.source;
35
+ return s = s.replace(m.caret, "$1"), t = t.replace(r, s), n;
36
+ }, getRegex: () => new RegExp(t, e) };
37
+ return n;
38
+ }
39
+ var be = (() => {
40
+ try {
41
+ return !!new RegExp("(?<=1)(?<!1)");
42
+ } catch {
43
+ return false;
44
+ }
45
+ })();
46
+ var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] /, listReplaceTask: /^\[[ xX]\] +/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l) => new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}#`), htmlBeginRegex: (l) => new RegExp(`^ {0,${Math.min(3, l - 1)}}<(?:[a-z].*>|!--)`, "i") };
47
+ var Re = /^(?:[ \t]*(?:\n|$))+/;
48
+ var Te = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
49
+ var Oe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
50
+ var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
51
+ var we = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
52
+ var F = /(?:[*+-]|\d{1,9}[.)])/;
53
+ var ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
54
+ var oe = d(ie).replace(/bull/g, F).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/\|table/g, "").getRegex();
55
+ var ye = d(ie).replace(/bull/g, F).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex();
56
+ var j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
57
+ var Pe = /^[^\n]+/;
58
+ var Q = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
59
+ var Se = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
60
+ var $e = d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, F).getRegex();
61
+ var v = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
62
+ var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
63
+ var _e = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))", "i").replace("comment", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
64
+ var ae = d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
65
+ var Le = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
66
+ var K = { blockquote: Le, code: Te, def: Se, fences: Oe, heading: we, hr: I, html: _e, lheading: oe, list: $e, newline: Re, paragraph: ae, table: E, text: Pe };
67
+ var re = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}\t)[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
68
+ var Me = { ...K, lheading: ye, table: re, paragraph: d(j).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
69
+ var ze = { ...K, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", U).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: E, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
70
+ ]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
71
+ var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
72
+ var Ee = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
73
+ var le = /^( {2,}|\\)\n(?!\s*$)/;
74
+ var Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
75
+ var D = /[\p{P}\p{S}]/u;
76
+ var W = /[\s\p{P}\p{S}]/u;
77
+ var ue = /[^\s\p{P}\p{S}]/u;
78
+ var Ce = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex();
79
+ var pe = /(?!~)[\p{P}\p{S}]/u;
80
+ var Be = /(?!~)[\s\p{P}\p{S}]/u;
81
+ var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
82
+ var ve = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", be ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex();
83
+ var ce = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
84
+ var De = d(ce, "u").replace(/punct/g, D).getRegex();
85
+ var He = d(ce, "u").replace(/punct/g, pe).getRegex();
86
+ var he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
87
+ var Ze = d(he, "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex();
88
+ var Ge = d(he, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, Be).replace(/punct/g, pe).getRegex();
89
+ var Ne = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex();
90
+ var Fe = d(/\\(punct)/, "gu").replace(/punct/g, D).getRegex();
91
+ var je = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
92
+ var Qe = d(U).replace("(?:-->|$)", "-->").getRegex();
93
+ var Ue = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", Qe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
94
+ var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/;
95
+ var Ke = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
96
+ var de = d(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex();
97
+ var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex();
98
+ var We = d("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex();
99
+ var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
100
+ var X = { _backpedal: E, anyPunctuation: Fe, autolink: je, blockSkip: ve, br: le, code: Ee, del: E, emStrongLDelim: De, emStrongRDelimAst: Ze, emStrongRDelimUnd: Ne, escape: Ae, link: Ke, nolink: ke, punctuation: Ce, reflink: de, reflinkSearch: We, tag: Ue, text: Ie, url: E };
101
+ var Xe = { ...X, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
102
+ var N = { ...X, emStrongRDelimAst: Ge, emStrongLDelim: He, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex() };
103
+ var Je = { ...N, br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
104
+ var C = { normal: K, gfm: Me, pedantic: ze };
105
+ var M = { normal: X, gfm: N, breaks: Je, pedantic: Xe };
106
+ var Ve = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
107
+ var ge = (l) => Ve[l];
108
+ function w(l, e) {
109
+ if (e) {
110
+ if (m.escapeTest.test(l))
111
+ return l.replace(m.escapeReplace, ge);
112
+ } else if (m.escapeTestNoEncode.test(l))
113
+ return l.replace(m.escapeReplaceNoEncode, ge);
114
+ return l;
115
+ }
116
+ function J(l) {
117
+ try {
118
+ l = encodeURI(l).replace(m.percentDecode, "%");
119
+ } catch {
120
+ return null;
121
+ }
122
+ return l;
123
+ }
124
+ function V(l, e) {
125
+ let t = l.replace(m.findPipe, (i, s, a) => {
126
+ let o = false, p = s;
127
+ for (;--p >= 0 && a[p] === "\\"; )
128
+ o = !o;
129
+ return o ? "|" : " |";
130
+ }), n = t.split(m.splitPipe), r = 0;
131
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), e)
132
+ if (n.length > e)
133
+ n.splice(e);
134
+ else
135
+ for (;n.length < e; )
136
+ n.push("");
137
+ for (;r < n.length; r++)
138
+ n[r] = n[r].trim().replace(m.slashPipe, "|");
139
+ return n;
140
+ }
141
+ function z(l, e, t) {
142
+ let n = l.length;
143
+ if (n === 0)
144
+ return "";
145
+ let r = 0;
146
+ for (;r < n; ) {
147
+ let i = l.charAt(n - r - 1);
148
+ if (i === e && !t)
149
+ r++;
150
+ else if (i !== e && t)
151
+ r++;
152
+ else
153
+ break;
154
+ }
155
+ return l.slice(0, n - r);
156
+ }
157
+ function fe(l, e) {
158
+ if (l.indexOf(e[1]) === -1)
159
+ return -1;
160
+ let t = 0;
161
+ for (let n = 0;n < l.length; n++)
162
+ if (l[n] === "\\")
163
+ n++;
164
+ else if (l[n] === e[0])
165
+ t++;
166
+ else if (l[n] === e[1] && (t--, t < 0))
167
+ return n;
168
+ return t > 0 ? -2 : -1;
169
+ }
170
+ function me(l, e, t, n, r) {
171
+ let i = e.href, s = e.title || null, a = l[1].replace(r.other.outputLinkReplace, "$1");
172
+ n.state.inLink = true;
173
+ let o = { type: l[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: s, text: a, tokens: n.inlineTokens(a) };
174
+ return n.state.inLink = false, o;
175
+ }
176
+ function Ye(l, e, t) {
177
+ let n = l.match(t.other.indentCodeCompensation);
178
+ if (n === null)
179
+ return e;
180
+ let r = n[1];
181
+ return e.split(`
182
+ `).map((i) => {
183
+ let s = i.match(t.other.beginningSpace);
184
+ if (s === null)
185
+ return i;
186
+ let [a] = s;
187
+ return a.length >= r.length ? i.slice(r.length) : i;
188
+ }).join(`
189
+ `);
190
+ }
191
+ var y = class {
192
+ options;
193
+ rules;
194
+ lexer;
195
+ constructor(e) {
196
+ this.options = e || T;
197
+ }
198
+ space(e) {
199
+ let t = this.rules.block.newline.exec(e);
200
+ if (t && t[0].length > 0)
201
+ return { type: "space", raw: t[0] };
202
+ }
203
+ code(e) {
204
+ let t = this.rules.block.code.exec(e);
205
+ if (t) {
206
+ let n = t[0].replace(this.rules.other.codeRemoveIndent, "");
207
+ return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : z(n, `
208
+ `) };
209
+ }
210
+ }
211
+ fences(e) {
212
+ let t = this.rules.block.fences.exec(e);
213
+ if (t) {
214
+ let n = t[0], r = Ye(n, t[3] || "", this.rules);
215
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: r };
216
+ }
217
+ }
218
+ heading(e) {
219
+ let t = this.rules.block.heading.exec(e);
220
+ if (t) {
221
+ let n = t[2].trim();
222
+ if (this.rules.other.endingHash.test(n)) {
223
+ let r = z(n, "#");
224
+ (this.options.pedantic || !r || this.rules.other.endingSpaceChar.test(r)) && (n = r.trim());
225
+ }
226
+ return { type: "heading", raw: t[0], depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
227
+ }
228
+ }
229
+ hr(e) {
230
+ let t = this.rules.block.hr.exec(e);
231
+ if (t)
232
+ return { type: "hr", raw: z(t[0], `
233
+ `) };
234
+ }
235
+ blockquote(e) {
236
+ let t = this.rules.block.blockquote.exec(e);
237
+ if (t) {
238
+ let n = z(t[0], `
239
+ `).split(`
240
+ `), r = "", i = "", s = [];
241
+ for (;n.length > 0; ) {
242
+ let a = false, o = [], p;
243
+ for (p = 0;p < n.length; p++)
244
+ if (this.rules.other.blockquoteStart.test(n[p]))
245
+ o.push(n[p]), a = true;
246
+ else if (!a)
247
+ o.push(n[p]);
248
+ else
249
+ break;
250
+ n = n.slice(p);
251
+ let u = o.join(`
252
+ `), c = u.replace(this.rules.other.blockquoteSetextReplace, `
253
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
254
+ r = r ? `${r}
255
+ ${u}` : u, i = i ? `${i}
256
+ ${c}` : c;
257
+ let g = this.lexer.state.top;
258
+ if (this.lexer.state.top = true, this.lexer.blockTokens(c, s, true), this.lexer.state.top = g, n.length === 0)
259
+ break;
260
+ let h = s.at(-1);
261
+ if (h?.type === "code")
262
+ break;
263
+ if (h?.type === "blockquote") {
264
+ let R = h, f = R.raw + `
265
+ ` + n.join(`
266
+ `), O = this.blockquote(f);
267
+ s[s.length - 1] = O, r = r.substring(0, r.length - R.raw.length) + O.raw, i = i.substring(0, i.length - R.text.length) + O.text;
268
+ break;
269
+ } else if (h?.type === "list") {
270
+ let R = h, f = R.raw + `
271
+ ` + n.join(`
272
+ `), O = this.list(f);
273
+ s[s.length - 1] = O, r = r.substring(0, r.length - h.raw.length) + O.raw, i = i.substring(0, i.length - R.raw.length) + O.raw, n = f.substring(s.at(-1).raw.length).split(`
274
+ `);
275
+ continue;
276
+ }
277
+ }
278
+ return { type: "blockquote", raw: r, tokens: s, text: i };
279
+ }
280
+ }
281
+ list(e) {
282
+ let t = this.rules.block.list.exec(e);
283
+ if (t) {
284
+ let n = t[1].trim(), r = n.length > 1, i = { type: "list", raw: "", ordered: r, start: r ? +n.slice(0, -1) : "", loose: false, items: [] };
285
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
286
+ let s = this.rules.other.listItemRegex(n), a = false;
287
+ for (;e; ) {
288
+ let p = false, u = "", c = "";
289
+ if (!(t = s.exec(e)) || this.rules.block.hr.test(e))
290
+ break;
291
+ u = t[0], e = e.substring(u.length);
292
+ let g = t[2].split(`
293
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (H) => " ".repeat(3 * H.length)), h = e.split(`
294
+ `, 1)[0], R = !g.trim(), f = 0;
295
+ if (this.options.pedantic ? (f = 2, c = g.trimStart()) : R ? f = t[1].length + 1 : (f = t[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = g.slice(f), f += t[1].length), R && this.rules.other.blankLine.test(h) && (u += h + `
296
+ `, e = e.substring(h.length + 1), p = true), !p) {
297
+ let H = this.rules.other.nextBulletRegex(f), ee = this.rules.other.hrRegex(f), te = this.rules.other.fencesBeginRegex(f), ne = this.rules.other.headingBeginRegex(f), xe = this.rules.other.htmlBeginRegex(f);
298
+ for (;e; ) {
299
+ let Z = e.split(`
300
+ `, 1)[0], A;
301
+ if (h = Z, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), te.test(h) || ne.test(h) || xe.test(h) || H.test(h) || ee.test(h))
302
+ break;
303
+ if (A.search(this.rules.other.nonSpaceChar) >= f || !h.trim())
304
+ c += `
305
+ ` + A.slice(f);
306
+ else {
307
+ if (R || g.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(g) || ne.test(g) || ee.test(g))
308
+ break;
309
+ c += `
310
+ ` + h;
311
+ }
312
+ !R && !h.trim() && (R = true), u += Z + `
313
+ `, e = e.substring(Z.length + 1), g = A.slice(f);
314
+ }
315
+ }
316
+ i.loose || (a ? i.loose = true : this.rules.other.doubleBlankLine.test(u) && (a = true));
317
+ let O = null, Y;
318
+ this.options.gfm && (O = this.rules.other.listIsTask.exec(c), O && (Y = O[0] !== "[ ] ", c = c.replace(this.rules.other.listReplaceTask, ""))), i.items.push({ type: "list_item", raw: u, task: !!O, checked: Y, loose: false, text: c, tokens: [] }), i.raw += u;
319
+ }
320
+ let o = i.items.at(-1);
321
+ if (o)
322
+ o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
323
+ else
324
+ return;
325
+ i.raw = i.raw.trimEnd();
326
+ for (let p = 0;p < i.items.length; p++)
327
+ if (this.lexer.state.top = false, i.items[p].tokens = this.lexer.blockTokens(i.items[p].text, []), !i.loose) {
328
+ let u = i.items[p].tokens.filter((g) => g.type === "space"), c = u.length > 0 && u.some((g) => this.rules.other.anyLine.test(g.raw));
329
+ i.loose = c;
330
+ }
331
+ if (i.loose)
332
+ for (let p = 0;p < i.items.length; p++)
333
+ i.items[p].loose = true;
334
+ return i;
335
+ }
336
+ }
337
+ html(e) {
338
+ let t = this.rules.block.html.exec(e);
339
+ if (t)
340
+ return { type: "html", block: true, raw: t[0], pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: t[0] };
341
+ }
342
+ def(e) {
343
+ let t = this.rules.block.def.exec(e);
344
+ if (t) {
345
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), r = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", i = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
346
+ return { type: "def", tag: n, raw: t[0], href: r, title: i };
347
+ }
348
+ }
349
+ table(e) {
350
+ let t = this.rules.block.table.exec(e);
351
+ if (!t || !this.rules.other.tableDelimiter.test(t[2]))
352
+ return;
353
+ let n = V(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
354
+ `) : [], s = { type: "table", raw: t[0], header: [], align: [], rows: [] };
355
+ if (n.length === r.length) {
356
+ for (let a of r)
357
+ this.rules.other.tableAlignRight.test(a) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? s.align.push("left") : s.align.push(null);
358
+ for (let a = 0;a < n.length; a++)
359
+ s.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: true, align: s.align[a] });
360
+ for (let a of i)
361
+ s.rows.push(V(a, s.header.length).map((o, p) => ({ text: o, tokens: this.lexer.inline(o), header: false, align: s.align[p] })));
362
+ return s;
363
+ }
364
+ }
365
+ lheading(e) {
366
+ let t = this.rules.block.lheading.exec(e);
367
+ if (t)
368
+ return { type: "heading", raw: t[0], depth: t[2].charAt(0) === "=" ? 1 : 2, text: t[1], tokens: this.lexer.inline(t[1]) };
369
+ }
370
+ paragraph(e) {
371
+ let t = this.rules.block.paragraph.exec(e);
372
+ if (t) {
373
+ let n = t[1].charAt(t[1].length - 1) === `
374
+ ` ? t[1].slice(0, -1) : t[1];
375
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
376
+ }
377
+ }
378
+ text(e) {
379
+ let t = this.rules.block.text.exec(e);
380
+ if (t)
381
+ return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
382
+ }
383
+ escape(e) {
384
+ let t = this.rules.inline.escape.exec(e);
385
+ if (t)
386
+ return { type: "escape", raw: t[0], text: t[1] };
387
+ }
388
+ tag(e) {
389
+ let t = this.rules.inline.tag.exec(e);
390
+ if (t)
391
+ return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
392
+ }
393
+ link(e) {
394
+ let t = this.rules.inline.link.exec(e);
395
+ if (t) {
396
+ let n = t[2].trim();
397
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
398
+ if (!this.rules.other.endAngleBracket.test(n))
399
+ return;
400
+ let s = z(n.slice(0, -1), "\\");
401
+ if ((n.length - s.length) % 2 === 0)
402
+ return;
403
+ } else {
404
+ let s = fe(t[2], "()");
405
+ if (s === -2)
406
+ return;
407
+ if (s > -1) {
408
+ let o = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + s;
409
+ t[2] = t[2].substring(0, s), t[0] = t[0].substring(0, o).trim(), t[3] = "";
410
+ }
411
+ }
412
+ let r = t[2], i = "";
413
+ if (this.options.pedantic) {
414
+ let s = this.rules.other.pedanticHrefTitle.exec(r);
415
+ s && (r = s[1], i = s[3]);
416
+ } else
417
+ i = t[3] ? t[3].slice(1, -1) : "";
418
+ return r = r.trim(), this.rules.other.startAngleBracket.test(r) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? r = r.slice(1) : r = r.slice(1, -1)), me(t, { href: r && r.replace(this.rules.inline.anyPunctuation, "$1"), title: i && i.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
419
+ }
420
+ }
421
+ reflink(e, t) {
422
+ let n;
423
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
424
+ let r = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), i = t[r.toLowerCase()];
425
+ if (!i) {
426
+ let s = n[0].charAt(0);
427
+ return { type: "text", raw: s, text: s };
428
+ }
429
+ return me(n, i, n[0], this.lexer, this.rules);
430
+ }
431
+ }
432
+ emStrong(e, t, n = "") {
433
+ let r = this.rules.inline.emStrongLDelim.exec(e);
434
+ if (!r || r[3] && n.match(this.rules.other.unicodeAlphaNumeric))
435
+ return;
436
+ if (!(r[1] || r[2] || "") || !n || this.rules.inline.punctuation.exec(n)) {
437
+ let s = [...r[0]].length - 1, a, o, p = s, u = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
438
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + s);(r = c.exec(t)) != null; ) {
439
+ if (a = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !a)
440
+ continue;
441
+ if (o = [...a].length, r[3] || r[4]) {
442
+ p += o;
443
+ continue;
444
+ } else if ((r[5] || r[6]) && s % 3 && !((s + o) % 3)) {
445
+ u += o;
446
+ continue;
447
+ }
448
+ if (p -= o, p > 0)
449
+ continue;
450
+ o = Math.min(o, o + p + u);
451
+ let g = [...r[0]][0].length, h = e.slice(0, s + r.index + g + o);
452
+ if (Math.min(s, o) % 2) {
453
+ let f = h.slice(1, -1);
454
+ return { type: "em", raw: h, text: f, tokens: this.lexer.inlineTokens(f) };
455
+ }
456
+ let R = h.slice(2, -2);
457
+ return { type: "strong", raw: h, text: R, tokens: this.lexer.inlineTokens(R) };
458
+ }
459
+ }
460
+ }
461
+ codespan(e) {
462
+ let t = this.rules.inline.code.exec(e);
463
+ if (t) {
464
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), r = this.rules.other.nonSpaceChar.test(n), i = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
465
+ return r && i && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
466
+ }
467
+ }
468
+ br(e) {
469
+ let t = this.rules.inline.br.exec(e);
470
+ if (t)
471
+ return { type: "br", raw: t[0] };
472
+ }
473
+ del(e) {
474
+ let t = this.rules.inline.del.exec(e);
475
+ if (t)
476
+ return { type: "del", raw: t[0], text: t[2], tokens: this.lexer.inlineTokens(t[2]) };
477
+ }
478
+ autolink(e) {
479
+ let t = this.rules.inline.autolink.exec(e);
480
+ if (t) {
481
+ let n, r;
482
+ return t[2] === "@" ? (n = t[1], r = "mailto:" + n) : (n = t[1], r = n), { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
483
+ }
484
+ }
485
+ url(e) {
486
+ let t;
487
+ if (t = this.rules.inline.url.exec(e)) {
488
+ let n, r;
489
+ if (t[2] === "@")
490
+ n = t[0], r = "mailto:" + n;
491
+ else {
492
+ let i;
493
+ do
494
+ i = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
495
+ while (i !== t[0]);
496
+ n = t[0], t[1] === "www." ? r = "http://" + t[0] : r = t[0];
497
+ }
498
+ return { type: "link", raw: t[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] };
499
+ }
500
+ }
501
+ inlineText(e) {
502
+ let t = this.rules.inline.text.exec(e);
503
+ if (t) {
504
+ let n = this.lexer.state.inRawBlock;
505
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
506
+ }
507
+ }
508
+ };
509
+ var x = class l {
510
+ tokens;
511
+ options;
512
+ state;
513
+ tokenizer;
514
+ inlineQueue;
515
+ constructor(e) {
516
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
517
+ let t = { other: m, block: C.normal, inline: M.normal };
518
+ this.options.pedantic ? (t.block = C.pedantic, t.inline = M.pedantic) : this.options.gfm && (t.block = C.gfm, this.options.breaks ? t.inline = M.breaks : t.inline = M.gfm), this.tokenizer.rules = t;
519
+ }
520
+ static get rules() {
521
+ return { block: C, inline: M };
522
+ }
523
+ static lex(e, t) {
524
+ return new l(t).lex(e);
525
+ }
526
+ static lexInline(e, t) {
527
+ return new l(t).inlineTokens(e);
528
+ }
529
+ lex(e) {
530
+ e = e.replace(m.carriageReturn, `
531
+ `), this.blockTokens(e, this.tokens);
532
+ for (let t = 0;t < this.inlineQueue.length; t++) {
533
+ let n = this.inlineQueue[t];
534
+ this.inlineTokens(n.src, n.tokens);
535
+ }
536
+ return this.inlineQueue = [], this.tokens;
537
+ }
538
+ blockTokens(e, t = [], n = false) {
539
+ for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));e; ) {
540
+ let r;
541
+ if (this.options.extensions?.block?.some((s) => (r = s.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false))
542
+ continue;
543
+ if (r = this.tokenizer.space(e)) {
544
+ e = e.substring(r.raw.length);
545
+ let s = t.at(-1);
546
+ r.raw.length === 1 && s !== undefined ? s.raw += `
547
+ ` : t.push(r);
548
+ continue;
549
+ }
550
+ if (r = this.tokenizer.code(e)) {
551
+ e = e.substring(r.raw.length);
552
+ let s = t.at(-1);
553
+ s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
554
+ `) ? "" : `
555
+ `) + r.raw, s.text += `
556
+ ` + r.text, this.inlineQueue.at(-1).src = s.text) : t.push(r);
557
+ continue;
558
+ }
559
+ if (r = this.tokenizer.fences(e)) {
560
+ e = e.substring(r.raw.length), t.push(r);
561
+ continue;
562
+ }
563
+ if (r = this.tokenizer.heading(e)) {
564
+ e = e.substring(r.raw.length), t.push(r);
565
+ continue;
566
+ }
567
+ if (r = this.tokenizer.hr(e)) {
568
+ e = e.substring(r.raw.length), t.push(r);
569
+ continue;
570
+ }
571
+ if (r = this.tokenizer.blockquote(e)) {
572
+ e = e.substring(r.raw.length), t.push(r);
573
+ continue;
574
+ }
575
+ if (r = this.tokenizer.list(e)) {
576
+ e = e.substring(r.raw.length), t.push(r);
577
+ continue;
578
+ }
579
+ if (r = this.tokenizer.html(e)) {
580
+ e = e.substring(r.raw.length), t.push(r);
581
+ continue;
582
+ }
583
+ if (r = this.tokenizer.def(e)) {
584
+ e = e.substring(r.raw.length);
585
+ let s = t.at(-1);
586
+ s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith(`
587
+ `) ? "" : `
588
+ `) + r.raw, s.text += `
589
+ ` + r.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
590
+ continue;
591
+ }
592
+ if (r = this.tokenizer.table(e)) {
593
+ e = e.substring(r.raw.length), t.push(r);
594
+ continue;
595
+ }
596
+ if (r = this.tokenizer.lheading(e)) {
597
+ e = e.substring(r.raw.length), t.push(r);
598
+ continue;
599
+ }
600
+ let i = e;
601
+ if (this.options.extensions?.startBlock) {
602
+ let s = 1 / 0, a = e.slice(1), o;
603
+ this.options.extensions.startBlock.forEach((p) => {
604
+ o = p.call({ lexer: this }, a), typeof o == "number" && o >= 0 && (s = Math.min(s, o));
605
+ }), s < 1 / 0 && s >= 0 && (i = e.substring(0, s + 1));
606
+ }
607
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
608
+ let s = t.at(-1);
609
+ n && s?.type === "paragraph" ? (s.raw += (s.raw.endsWith(`
610
+ `) ? "" : `
611
+ `) + r.raw, s.text += `
612
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
613
+ continue;
614
+ }
615
+ if (r = this.tokenizer.text(e)) {
616
+ e = e.substring(r.raw.length);
617
+ let s = t.at(-1);
618
+ s?.type === "text" ? (s.raw += (s.raw.endsWith(`
619
+ `) ? "" : `
620
+ `) + r.raw, s.text += `
621
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : t.push(r);
622
+ continue;
623
+ }
624
+ if (e) {
625
+ let s = "Infinite loop on byte: " + e.charCodeAt(0);
626
+ if (this.options.silent) {
627
+ console.error(s);
628
+ break;
629
+ } else
630
+ throw new Error(s);
631
+ }
632
+ }
633
+ return this.state.top = true, t;
634
+ }
635
+ inline(e, t = []) {
636
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
637
+ }
638
+ inlineTokens(e, t = []) {
639
+ let n = e, r = null;
640
+ if (this.tokens.links) {
641
+ let o = Object.keys(this.tokens.links);
642
+ if (o.length > 0)
643
+ for (;(r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; )
644
+ o.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
645
+ }
646
+ for (;(r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; )
647
+ n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
648
+ let i;
649
+ for (;(r = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; )
650
+ i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
651
+ n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
652
+ let s = false, a = "";
653
+ for (;e; ) {
654
+ s || (a = ""), s = false;
655
+ let o;
656
+ if (this.options.extensions?.inline?.some((u) => (o = u.call({ lexer: this }, e, t)) ? (e = e.substring(o.raw.length), t.push(o), true) : false))
657
+ continue;
658
+ if (o = this.tokenizer.escape(e)) {
659
+ e = e.substring(o.raw.length), t.push(o);
660
+ continue;
661
+ }
662
+ if (o = this.tokenizer.tag(e)) {
663
+ e = e.substring(o.raw.length), t.push(o);
664
+ continue;
665
+ }
666
+ if (o = this.tokenizer.link(e)) {
667
+ e = e.substring(o.raw.length), t.push(o);
668
+ continue;
669
+ }
670
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
671
+ e = e.substring(o.raw.length);
672
+ let u = t.at(-1);
673
+ o.type === "text" && u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
674
+ continue;
675
+ }
676
+ if (o = this.tokenizer.emStrong(e, n, a)) {
677
+ e = e.substring(o.raw.length), t.push(o);
678
+ continue;
679
+ }
680
+ if (o = this.tokenizer.codespan(e)) {
681
+ e = e.substring(o.raw.length), t.push(o);
682
+ continue;
683
+ }
684
+ if (o = this.tokenizer.br(e)) {
685
+ e = e.substring(o.raw.length), t.push(o);
686
+ continue;
687
+ }
688
+ if (o = this.tokenizer.del(e)) {
689
+ e = e.substring(o.raw.length), t.push(o);
690
+ continue;
691
+ }
692
+ if (o = this.tokenizer.autolink(e)) {
693
+ e = e.substring(o.raw.length), t.push(o);
694
+ continue;
695
+ }
696
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
697
+ e = e.substring(o.raw.length), t.push(o);
698
+ continue;
699
+ }
700
+ let p = e;
701
+ if (this.options.extensions?.startInline) {
702
+ let u = 1 / 0, c = e.slice(1), g;
703
+ this.options.extensions.startInline.forEach((h) => {
704
+ g = h.call({ lexer: this }, c), typeof g == "number" && g >= 0 && (u = Math.min(u, g));
705
+ }), u < 1 / 0 && u >= 0 && (p = e.substring(0, u + 1));
706
+ }
707
+ if (o = this.tokenizer.inlineText(p)) {
708
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), s = true;
709
+ let u = t.at(-1);
710
+ u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : t.push(o);
711
+ continue;
712
+ }
713
+ if (e) {
714
+ let u = "Infinite loop on byte: " + e.charCodeAt(0);
715
+ if (this.options.silent) {
716
+ console.error(u);
717
+ break;
718
+ } else
719
+ throw new Error(u);
720
+ }
721
+ }
722
+ return t;
723
+ }
724
+ };
725
+ var P = class {
726
+ options;
727
+ parser;
728
+ constructor(e) {
729
+ this.options = e || T;
730
+ }
731
+ space(e) {
732
+ return "";
733
+ }
734
+ code({ text: e, lang: t, escaped: n }) {
735
+ let r = (t || "").match(m.notSpaceStart)?.[0], i = e.replace(m.endingNewline, "") + `
736
+ `;
737
+ return r ? '<pre><code class="language-' + w(r) + '">' + (n ? i : w(i, true)) + `</code></pre>
738
+ ` : "<pre><code>" + (n ? i : w(i, true)) + `</code></pre>
739
+ `;
740
+ }
741
+ blockquote({ tokens: e }) {
742
+ return `<blockquote>
743
+ ${this.parser.parse(e)}</blockquote>
744
+ `;
745
+ }
746
+ html({ text: e }) {
747
+ return e;
748
+ }
749
+ def(e) {
750
+ return "";
751
+ }
752
+ heading({ tokens: e, depth: t }) {
753
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
754
+ `;
755
+ }
756
+ hr(e) {
757
+ return `<hr>
758
+ `;
759
+ }
760
+ list(e) {
761
+ let { ordered: t, start: n } = e, r = "";
762
+ for (let a = 0;a < e.items.length; a++) {
763
+ let o = e.items[a];
764
+ r += this.listitem(o);
765
+ }
766
+ let i = t ? "ol" : "ul", s = t && n !== 1 ? ' start="' + n + '"' : "";
767
+ return "<" + i + s + `>
768
+ ` + r + "</" + i + `>
769
+ `;
770
+ }
771
+ listitem(e) {
772
+ let t = "";
773
+ if (e.task) {
774
+ let n = this.checkbox({ checked: !!e.checked });
775
+ e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = n + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = n + " " + w(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = true)) : e.tokens.unshift({ type: "text", raw: n + " ", text: n + " ", escaped: true }) : t += n + " ";
776
+ }
777
+ return t += this.parser.parse(e.tokens, !!e.loose), `<li>${t}</li>
778
+ `;
779
+ }
780
+ checkbox({ checked: e }) {
781
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
782
+ }
783
+ paragraph({ tokens: e }) {
784
+ return `<p>${this.parser.parseInline(e)}</p>
785
+ `;
786
+ }
787
+ table(e) {
788
+ let t = "", n = "";
789
+ for (let i = 0;i < e.header.length; i++)
790
+ n += this.tablecell(e.header[i]);
791
+ t += this.tablerow({ text: n });
792
+ let r = "";
793
+ for (let i = 0;i < e.rows.length; i++) {
794
+ let s = e.rows[i];
795
+ n = "";
796
+ for (let a = 0;a < s.length; a++)
797
+ n += this.tablecell(s[a]);
798
+ r += this.tablerow({ text: n });
799
+ }
800
+ return r && (r = `<tbody>${r}</tbody>`), `<table>
801
+ <thead>
802
+ ` + t + `</thead>
803
+ ` + r + `</table>
804
+ `;
805
+ }
806
+ tablerow({ text: e }) {
807
+ return `<tr>
808
+ ${e}</tr>
809
+ `;
810
+ }
811
+ tablecell(e) {
812
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
813
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
814
+ `;
815
+ }
816
+ strong({ tokens: e }) {
817
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
818
+ }
819
+ em({ tokens: e }) {
820
+ return `<em>${this.parser.parseInline(e)}</em>`;
821
+ }
822
+ codespan({ text: e }) {
823
+ return `<code>${w(e, true)}</code>`;
824
+ }
825
+ br(e) {
826
+ return "<br>";
827
+ }
828
+ del({ tokens: e }) {
829
+ return `<del>${this.parser.parseInline(e)}</del>`;
830
+ }
831
+ link({ href: e, title: t, tokens: n }) {
832
+ let r = this.parser.parseInline(n), i = J(e);
833
+ if (i === null)
834
+ return r;
835
+ e = i;
836
+ let s = '<a href="' + e + '"';
837
+ return t && (s += ' title="' + w(t) + '"'), s += ">" + r + "</a>", s;
838
+ }
839
+ image({ href: e, title: t, text: n, tokens: r }) {
840
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
841
+ let i = J(e);
842
+ if (i === null)
843
+ return w(n);
844
+ e = i;
845
+ let s = `<img src="${e}" alt="${n}"`;
846
+ return t && (s += ` title="${w(t)}"`), s += ">", s;
847
+ }
848
+ text(e) {
849
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : ("escaped" in e) && e.escaped ? e.text : w(e.text);
850
+ }
851
+ };
852
+ var $ = class {
853
+ strong({ text: e }) {
854
+ return e;
855
+ }
856
+ em({ text: e }) {
857
+ return e;
858
+ }
859
+ codespan({ text: e }) {
860
+ return e;
861
+ }
862
+ del({ text: e }) {
863
+ return e;
864
+ }
865
+ html({ text: e }) {
866
+ return e;
867
+ }
868
+ text({ text: e }) {
869
+ return e;
870
+ }
871
+ link({ text: e }) {
872
+ return "" + e;
873
+ }
874
+ image({ text: e }) {
875
+ return "" + e;
876
+ }
877
+ br() {
878
+ return "";
879
+ }
880
+ };
881
+ var b = class l2 {
882
+ options;
883
+ renderer;
884
+ textRenderer;
885
+ constructor(e) {
886
+ this.options = e || T, this.options.renderer = this.options.renderer || new P, this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $;
887
+ }
888
+ static parse(e, t) {
889
+ return new l2(t).parse(e);
890
+ }
891
+ static parseInline(e, t) {
892
+ return new l2(t).parseInline(e);
893
+ }
894
+ parse(e, t = true) {
895
+ let n = "";
896
+ for (let r = 0;r < e.length; r++) {
897
+ let i = e[r];
898
+ if (this.options.extensions?.renderers?.[i.type]) {
899
+ let a = i, o = this.options.extensions.renderers[a.type].call({ parser: this }, a);
900
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(a.type)) {
901
+ n += o || "";
902
+ continue;
903
+ }
904
+ }
905
+ let s = i;
906
+ switch (s.type) {
907
+ case "space": {
908
+ n += this.renderer.space(s);
909
+ continue;
910
+ }
911
+ case "hr": {
912
+ n += this.renderer.hr(s);
913
+ continue;
914
+ }
915
+ case "heading": {
916
+ n += this.renderer.heading(s);
917
+ continue;
918
+ }
919
+ case "code": {
920
+ n += this.renderer.code(s);
921
+ continue;
922
+ }
923
+ case "table": {
924
+ n += this.renderer.table(s);
925
+ continue;
926
+ }
927
+ case "blockquote": {
928
+ n += this.renderer.blockquote(s);
929
+ continue;
930
+ }
931
+ case "list": {
932
+ n += this.renderer.list(s);
933
+ continue;
934
+ }
935
+ case "html": {
936
+ n += this.renderer.html(s);
937
+ continue;
938
+ }
939
+ case "def": {
940
+ n += this.renderer.def(s);
941
+ continue;
942
+ }
943
+ case "paragraph": {
944
+ n += this.renderer.paragraph(s);
945
+ continue;
946
+ }
947
+ case "text": {
948
+ let a = s, o = this.renderer.text(a);
949
+ for (;r + 1 < e.length && e[r + 1].type === "text"; )
950
+ a = e[++r], o += `
951
+ ` + this.renderer.text(a);
952
+ t ? n += this.renderer.paragraph({ type: "paragraph", raw: o, text: o, tokens: [{ type: "text", raw: o, text: o, escaped: true }] }) : n += o;
953
+ continue;
954
+ }
955
+ default: {
956
+ let a = 'Token with "' + s.type + '" type was not found.';
957
+ if (this.options.silent)
958
+ return console.error(a), "";
959
+ throw new Error(a);
960
+ }
961
+ }
962
+ }
963
+ return n;
964
+ }
965
+ parseInline(e, t = this.renderer) {
966
+ let n = "";
967
+ for (let r = 0;r < e.length; r++) {
968
+ let i = e[r];
969
+ if (this.options.extensions?.renderers?.[i.type]) {
970
+ let a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
971
+ if (a !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
972
+ n += a || "";
973
+ continue;
974
+ }
975
+ }
976
+ let s = i;
977
+ switch (s.type) {
978
+ case "escape": {
979
+ n += t.text(s);
980
+ break;
981
+ }
982
+ case "html": {
983
+ n += t.html(s);
984
+ break;
985
+ }
986
+ case "link": {
987
+ n += t.link(s);
988
+ break;
989
+ }
990
+ case "image": {
991
+ n += t.image(s);
992
+ break;
993
+ }
994
+ case "strong": {
995
+ n += t.strong(s);
996
+ break;
997
+ }
998
+ case "em": {
999
+ n += t.em(s);
1000
+ break;
1001
+ }
1002
+ case "codespan": {
1003
+ n += t.codespan(s);
1004
+ break;
1005
+ }
1006
+ case "br": {
1007
+ n += t.br(s);
1008
+ break;
1009
+ }
1010
+ case "del": {
1011
+ n += t.del(s);
1012
+ break;
1013
+ }
1014
+ case "text": {
1015
+ n += t.text(s);
1016
+ break;
1017
+ }
1018
+ default: {
1019
+ let a = 'Token with "' + s.type + '" type was not found.';
1020
+ if (this.options.silent)
1021
+ return console.error(a), "";
1022
+ throw new Error(a);
1023
+ }
1024
+ }
1025
+ }
1026
+ return n;
1027
+ }
1028
+ };
1029
+ var S = class {
1030
+ options;
1031
+ block;
1032
+ constructor(e) {
1033
+ this.options = e || T;
1034
+ }
1035
+ static passThroughHooks = new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
1036
+ static passThroughHooksRespectAsync = new Set(["preprocess", "postprocess", "processAllTokens"]);
1037
+ preprocess(e) {
1038
+ return e;
1039
+ }
1040
+ postprocess(e) {
1041
+ return e;
1042
+ }
1043
+ processAllTokens(e) {
1044
+ return e;
1045
+ }
1046
+ emStrongMask(e) {
1047
+ return e;
1048
+ }
1049
+ provideLexer() {
1050
+ return this.block ? x.lex : x.lexInline;
1051
+ }
1052
+ provideParser() {
1053
+ return this.block ? b.parse : b.parseInline;
1054
+ }
1055
+ };
1056
+ var B = class {
1057
+ defaults = L();
1058
+ options = this.setOptions;
1059
+ parse = this.parseMarkdown(true);
1060
+ parseInline = this.parseMarkdown(false);
1061
+ Parser = b;
1062
+ Renderer = P;
1063
+ TextRenderer = $;
1064
+ Lexer = x;
1065
+ Tokenizer = y;
1066
+ Hooks = S;
1067
+ constructor(...e) {
1068
+ this.use(...e);
1069
+ }
1070
+ walkTokens(e, t) {
1071
+ let n = [];
1072
+ for (let r of e)
1073
+ switch (n = n.concat(t.call(this, r)), r.type) {
1074
+ case "table": {
1075
+ let i = r;
1076
+ for (let s of i.header)
1077
+ n = n.concat(this.walkTokens(s.tokens, t));
1078
+ for (let s of i.rows)
1079
+ for (let a of s)
1080
+ n = n.concat(this.walkTokens(a.tokens, t));
1081
+ break;
1082
+ }
1083
+ case "list": {
1084
+ let i = r;
1085
+ n = n.concat(this.walkTokens(i.items, t));
1086
+ break;
1087
+ }
1088
+ default: {
1089
+ let i = r;
1090
+ this.defaults.extensions?.childTokens?.[i.type] ? this.defaults.extensions.childTokens[i.type].forEach((s) => {
1091
+ let a = i[s].flat(1 / 0);
1092
+ n = n.concat(this.walkTokens(a, t));
1093
+ }) : i.tokens && (n = n.concat(this.walkTokens(i.tokens, t)));
1094
+ }
1095
+ }
1096
+ return n;
1097
+ }
1098
+ use(...e) {
1099
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1100
+ return e.forEach((n) => {
1101
+ let r = { ...n };
1102
+ if (r.async = this.defaults.async || r.async || false, n.extensions && (n.extensions.forEach((i) => {
1103
+ if (!i.name)
1104
+ throw new Error("extension name required");
1105
+ if ("renderer" in i) {
1106
+ let s = t.renderers[i.name];
1107
+ s ? t.renderers[i.name] = function(...a) {
1108
+ let o = i.renderer.apply(this, a);
1109
+ return o === false && (o = s.apply(this, a)), o;
1110
+ } : t.renderers[i.name] = i.renderer;
1111
+ }
1112
+ if ("tokenizer" in i) {
1113
+ if (!i.level || i.level !== "block" && i.level !== "inline")
1114
+ throw new Error("extension level must be 'block' or 'inline'");
1115
+ let s = t[i.level];
1116
+ s ? s.unshift(i.tokenizer) : t[i.level] = [i.tokenizer], i.start && (i.level === "block" ? t.startBlock ? t.startBlock.push(i.start) : t.startBlock = [i.start] : i.level === "inline" && (t.startInline ? t.startInline.push(i.start) : t.startInline = [i.start]));
1117
+ }
1118
+ "childTokens" in i && i.childTokens && (t.childTokens[i.name] = i.childTokens);
1119
+ }), r.extensions = t), n.renderer) {
1120
+ let i = this.defaults.renderer || new P(this.defaults);
1121
+ for (let s in n.renderer) {
1122
+ if (!(s in i))
1123
+ throw new Error(`renderer '${s}' does not exist`);
1124
+ if (["options", "parser"].includes(s))
1125
+ continue;
1126
+ let a = s, o = n.renderer[a], p = i[a];
1127
+ i[a] = (...u) => {
1128
+ let c = o.apply(i, u);
1129
+ return c === false && (c = p.apply(i, u)), c || "";
1130
+ };
1131
+ }
1132
+ r.renderer = i;
1133
+ }
1134
+ if (n.tokenizer) {
1135
+ let i = this.defaults.tokenizer || new y(this.defaults);
1136
+ for (let s in n.tokenizer) {
1137
+ if (!(s in i))
1138
+ throw new Error(`tokenizer '${s}' does not exist`);
1139
+ if (["options", "rules", "lexer"].includes(s))
1140
+ continue;
1141
+ let a = s, o = n.tokenizer[a], p = i[a];
1142
+ i[a] = (...u) => {
1143
+ let c = o.apply(i, u);
1144
+ return c === false && (c = p.apply(i, u)), c;
1145
+ };
1146
+ }
1147
+ r.tokenizer = i;
1148
+ }
1149
+ if (n.hooks) {
1150
+ let i = this.defaults.hooks || new S;
1151
+ for (let s in n.hooks) {
1152
+ if (!(s in i))
1153
+ throw new Error(`hook '${s}' does not exist`);
1154
+ if (["options", "block"].includes(s))
1155
+ continue;
1156
+ let a = s, o = n.hooks[a], p = i[a];
1157
+ S.passThroughHooks.has(s) ? i[a] = (u) => {
1158
+ if (this.defaults.async && S.passThroughHooksRespectAsync.has(s))
1159
+ return (async () => {
1160
+ let g = await o.call(i, u);
1161
+ return p.call(i, g);
1162
+ })();
1163
+ let c = o.call(i, u);
1164
+ return p.call(i, c);
1165
+ } : i[a] = (...u) => {
1166
+ if (this.defaults.async)
1167
+ return (async () => {
1168
+ let g = await o.apply(i, u);
1169
+ return g === false && (g = await p.apply(i, u)), g;
1170
+ })();
1171
+ let c = o.apply(i, u);
1172
+ return c === false && (c = p.apply(i, u)), c;
1173
+ };
1174
+ }
1175
+ r.hooks = i;
1176
+ }
1177
+ if (n.walkTokens) {
1178
+ let i = this.defaults.walkTokens, s = n.walkTokens;
1179
+ r.walkTokens = function(a) {
1180
+ let o = [];
1181
+ return o.push(s.call(this, a)), i && (o = o.concat(i.call(this, a))), o;
1182
+ };
1183
+ }
1184
+ this.defaults = { ...this.defaults, ...r };
1185
+ }), this;
1186
+ }
1187
+ setOptions(e) {
1188
+ return this.defaults = { ...this.defaults, ...e }, this;
1189
+ }
1190
+ lexer(e, t) {
1191
+ return x.lex(e, t ?? this.defaults);
1192
+ }
1193
+ parser(e, t) {
1194
+ return b.parse(e, t ?? this.defaults);
1195
+ }
1196
+ parseMarkdown(e) {
1197
+ return (n, r) => {
1198
+ let i = { ...r }, s = { ...this.defaults, ...i }, a = this.onError(!!s.silent, !!s.async);
1199
+ if (this.defaults.async === true && i.async === false)
1200
+ return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1201
+ if (typeof n > "u" || n === null)
1202
+ return a(new Error("marked(): input parameter is undefined or null"));
1203
+ if (typeof n != "string")
1204
+ return a(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1205
+ if (s.hooks && (s.hooks.options = s, s.hooks.block = e), s.async)
1206
+ return (async () => {
1207
+ let o = s.hooks ? await s.hooks.preprocess(n) : n, u = await (s.hooks ? await s.hooks.provideLexer() : e ? x.lex : x.lexInline)(o, s), c = s.hooks ? await s.hooks.processAllTokens(u) : u;
1208
+ s.walkTokens && await Promise.all(this.walkTokens(c, s.walkTokens));
1209
+ let h = await (s.hooks ? await s.hooks.provideParser() : e ? b.parse : b.parseInline)(c, s);
1210
+ return s.hooks ? await s.hooks.postprocess(h) : h;
1211
+ })().catch(a);
1212
+ try {
1213
+ s.hooks && (n = s.hooks.preprocess(n));
1214
+ let p = (s.hooks ? s.hooks.provideLexer() : e ? x.lex : x.lexInline)(n, s);
1215
+ s.hooks && (p = s.hooks.processAllTokens(p)), s.walkTokens && this.walkTokens(p, s.walkTokens);
1216
+ let c = (s.hooks ? s.hooks.provideParser() : e ? b.parse : b.parseInline)(p, s);
1217
+ return s.hooks && (c = s.hooks.postprocess(c)), c;
1218
+ } catch (o) {
1219
+ return a(o);
1220
+ }
1221
+ };
1222
+ }
1223
+ onError(e, t) {
1224
+ return (n) => {
1225
+ if (n.message += `
1226
+ Please report this to https://github.com/markedjs/marked.`, e) {
1227
+ let r = "<p>An error occurred:</p><pre>" + w(n.message + "", true) + "</pre>";
1228
+ return t ? Promise.resolve(r) : r;
1229
+ }
1230
+ if (t)
1231
+ return Promise.reject(n);
1232
+ throw n;
1233
+ };
1234
+ }
1235
+ };
1236
+ var _ = new B;
1237
+ function k(l3, e) {
1238
+ return _.parse(l3, e);
1239
+ }
1240
+ k.options = k.setOptions = function(l3) {
1241
+ return _.setOptions(l3), k.defaults = _.defaults, G(k.defaults), k;
1242
+ };
1243
+ k.getDefaults = L;
1244
+ k.defaults = T;
1245
+ k.use = function(...l3) {
1246
+ return _.use(...l3), k.defaults = _.defaults, G(k.defaults), k;
1247
+ };
1248
+ k.walkTokens = function(l3, e) {
1249
+ return _.walkTokens(l3, e);
1250
+ };
1251
+ k.parseInline = _.parseInline;
1252
+ k.Parser = b;
1253
+ k.parser = b.parse;
1254
+ k.Renderer = P;
1255
+ k.TextRenderer = $;
1256
+ k.Lexer = x;
1257
+ k.lexer = x.lex;
1258
+ k.Tokenizer = y;
1259
+ k.Hooks = S;
1260
+ k.parse = k;
1261
+ var Zt = k.options;
1262
+ var Gt = k.setOptions;
1263
+ var Nt = k.use;
1264
+ var Ft = k.walkTokens;
1265
+ var jt = k.parseInline;
1266
+ var Ut = b.parse;
1267
+ var Kt = x.lex;
1268
+
1269
+ // node_modules/ts-dedent/esm/index.js
1270
+ function dedent(templ) {
1271
+ var values = [];
1272
+ for (var _i = 1;_i < arguments.length; _i++) {
1273
+ values[_i - 1] = arguments[_i];
1274
+ }
1275
+ var strings = Array.from(typeof templ === "string" ? [templ] : templ);
1276
+ strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
1277
+ var indentLengths = strings.reduce(function(arr, str) {
1278
+ var matches = str.match(/\n([\t ]+|(?!\s).)/g);
1279
+ if (matches) {
1280
+ return arr.concat(matches.map(function(match) {
1281
+ var _a, _b;
1282
+ return (_b = (_a = match.match(/[\t ]/g)) === null || _a === undefined ? undefined : _a.length) !== null && _b !== undefined ? _b : 0;
1283
+ }));
1284
+ }
1285
+ return arr;
1286
+ }, []);
1287
+ if (indentLengths.length) {
1288
+ var pattern_1 = new RegExp(`
1289
+ [ ]{`.concat(Math.min.apply(Math, indentLengths), "}"), "g");
1290
+ strings = strings.map(function(str) {
1291
+ return str.replace(pattern_1, `
1292
+ `);
1293
+ });
1294
+ }
1295
+ strings[0] = strings[0].replace(/^\r?\n/, "");
1296
+ var string = strings[0];
1297
+ values.forEach(function(value, i) {
1298
+ var endentations = string.match(/(?:^|\n)( *)$/);
1299
+ var endentation = endentations ? endentations[1] : "";
1300
+ var indentedValue = value;
1301
+ if (typeof value === "string" && value.includes(`
1302
+ `)) {
1303
+ indentedValue = String(value).split(`
1304
+ `).map(function(str, i2) {
1305
+ return i2 === 0 ? str : "".concat(endentation).concat(str);
1306
+ }).join(`
1307
+ `);
1308
+ }
1309
+ string += indentedValue + strings[i + 1];
1310
+ });
1311
+ return string;
1312
+ }
1313
+
1314
+ // node_modules/mermaid/dist/chunks/mermaid.core/chunk-WRU74C26.mjs
1315
+ function preprocessMarkdown(markdown, { markdownAutoWrap }) {
1316
+ const withoutBR = markdown.replace(/<br\/>/g, `
1317
+ `);
1318
+ const withoutMultipleNewlines = withoutBR.replace(/\n{2,}/g, `
1319
+ `);
1320
+ const withoutExtraSpaces = dedent(withoutMultipleNewlines);
1321
+ if (markdownAutoWrap === false) {}
1322
+ return withoutExtraSpaces;
1323
+ }
1324
+ __name(preprocessMarkdown, "preprocessMarkdown");
1325
+ function nonMarkdownToLines(nonMarkdownText) {
1326
+ return nonMarkdownText.split(/\\n|\n|<br\s*\/?>/gi).map((line) => line.trim().match(/<[^>]+>|[^\s<>]+/g)?.map((word) => ({ content: word, type: "normal" })) ?? []);
1327
+ }
1328
+ __name(nonMarkdownToLines, "nonMarkdownToLines");
1329
+ function markdownToLines(markdown, config = {}) {
1330
+ const preprocessedMarkdown = preprocessMarkdown(markdown, config);
1331
+ const nodes = k.lexer(preprocessedMarkdown);
1332
+ const lines = [[]];
1333
+ let currentLine = 0;
1334
+ function processNode(node, parentType = "normal") {
1335
+ if (node.type === "text") {
1336
+ const textLines = node.text.split(`
1337
+ `);
1338
+ textLines.forEach((textLine, index) => {
1339
+ if (index !== 0) {
1340
+ currentLine++;
1341
+ lines.push([]);
1342
+ }
1343
+ textLine.split(" ").forEach((word) => {
1344
+ word = word.replace(/&#39;/g, `'`);
1345
+ if (word) {
1346
+ lines[currentLine].push({ content: word, type: parentType });
1347
+ }
1348
+ });
1349
+ });
1350
+ } else if (node.type === "strong" || node.type === "em") {
1351
+ node.tokens.forEach((contentNode) => {
1352
+ processNode(contentNode, node.type);
1353
+ });
1354
+ } else if (node.type === "html") {
1355
+ lines[currentLine].push({ content: node.text, type: "normal" });
1356
+ }
1357
+ }
1358
+ __name(processNode, "processNode");
1359
+ nodes.forEach((treeNode) => {
1360
+ if (treeNode.type === "paragraph") {
1361
+ treeNode.tokens?.forEach((contentNode) => {
1362
+ processNode(contentNode);
1363
+ });
1364
+ } else if (treeNode.type === "html") {
1365
+ lines[currentLine].push({ content: treeNode.text, type: "normal" });
1366
+ } else {
1367
+ lines[currentLine].push({ content: treeNode.raw, type: "normal" });
1368
+ }
1369
+ });
1370
+ return lines;
1371
+ }
1372
+ __name(markdownToLines, "markdownToLines");
1373
+ function nonMarkdownToHTML(text) {
1374
+ if (!text) {
1375
+ return "";
1376
+ }
1377
+ return `<p>${text.replace(/\\n|\n/g, "<br />")}</p>`;
1378
+ }
1379
+ __name(nonMarkdownToHTML, "nonMarkdownToHTML");
1380
+ function markdownToHTML(markdown, { markdownAutoWrap } = {}) {
1381
+ const nodes = k.lexer(markdown);
1382
+ function output(node) {
1383
+ if (node.type === "text") {
1384
+ if (markdownAutoWrap === false) {
1385
+ return node.text.replace(/\n */g, "<br/>").replace(/ /g, "&nbsp;");
1386
+ }
1387
+ return node.text.replace(/\n */g, "<br/>");
1388
+ } else if (node.type === "strong") {
1389
+ return `<strong>${node.tokens?.map(output).join("")}</strong>`;
1390
+ } else if (node.type === "em") {
1391
+ return `<em>${node.tokens?.map(output).join("")}</em>`;
1392
+ } else if (node.type === "paragraph") {
1393
+ return `<p>${node.tokens?.map(output).join("")}</p>`;
1394
+ } else if (node.type === "space") {
1395
+ return "";
1396
+ } else if (node.type === "html") {
1397
+ return `${node.text}`;
1398
+ } else if (node.type === "escape") {
1399
+ return node.text;
1400
+ }
1401
+ log.warn(`Unsupported markdown: ${node.type}`);
1402
+ return node.raw;
1403
+ }
1404
+ __name(output, "output");
1405
+ return nodes.map(output).join("");
1406
+ }
1407
+ __name(markdownToHTML, "markdownToHTML");
1408
+ function splitTextToChars(text) {
1409
+ if (Intl.Segmenter) {
1410
+ return [...new Intl.Segmenter().segment(text)].map((s) => s.segment);
1411
+ }
1412
+ return [...text];
1413
+ }
1414
+ __name(splitTextToChars, "splitTextToChars");
1415
+ function splitWordToFitWidth(checkFit, word) {
1416
+ const characters = splitTextToChars(word.content);
1417
+ return splitWordToFitWidthRecursion(checkFit, [], characters, word.type);
1418
+ }
1419
+ __name(splitWordToFitWidth, "splitWordToFitWidth");
1420
+ function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) {
1421
+ if (remainingChars.length === 0) {
1422
+ return [
1423
+ { content: usedChars.join(""), type },
1424
+ { content: "", type }
1425
+ ];
1426
+ }
1427
+ const [nextChar, ...rest] = remainingChars;
1428
+ const newWord = [...usedChars, nextChar];
1429
+ if (checkFit([{ content: newWord.join(""), type }])) {
1430
+ return splitWordToFitWidthRecursion(checkFit, newWord, rest, type);
1431
+ }
1432
+ if (usedChars.length === 0 && nextChar) {
1433
+ usedChars.push(nextChar);
1434
+ remainingChars.shift();
1435
+ }
1436
+ return [
1437
+ { content: usedChars.join(""), type },
1438
+ { content: remainingChars.join(""), type }
1439
+ ];
1440
+ }
1441
+ __name(splitWordToFitWidthRecursion, "splitWordToFitWidthRecursion");
1442
+ function splitLineToFitWidth(line, checkFit) {
1443
+ if (line.some(({ content }) => content.includes(`
1444
+ `))) {
1445
+ throw new Error("splitLineToFitWidth does not support newlines in the line");
1446
+ }
1447
+ return splitLineToFitWidthRecursion(line, checkFit);
1448
+ }
1449
+ __name(splitLineToFitWidth, "splitLineToFitWidth");
1450
+ function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) {
1451
+ if (words.length === 0) {
1452
+ if (newLine.length > 0) {
1453
+ lines.push(newLine);
1454
+ }
1455
+ return lines.length > 0 ? lines : [];
1456
+ }
1457
+ let joiner = "";
1458
+ if (words[0].content === " ") {
1459
+ joiner = " ";
1460
+ words.shift();
1461
+ }
1462
+ const nextWord = words.shift() ?? { content: " ", type: "normal" };
1463
+ const lineWithNextWord = [...newLine];
1464
+ if (joiner !== "") {
1465
+ lineWithNextWord.push({ content: joiner, type: "normal" });
1466
+ }
1467
+ lineWithNextWord.push(nextWord);
1468
+ if (checkFit(lineWithNextWord)) {
1469
+ return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord);
1470
+ }
1471
+ if (newLine.length > 0) {
1472
+ lines.push(newLine);
1473
+ words.unshift(nextWord);
1474
+ } else if (nextWord.content) {
1475
+ const [line, rest] = splitWordToFitWidth(checkFit, nextWord);
1476
+ lines.push([line]);
1477
+ if (rest.content) {
1478
+ words.unshift(rest);
1479
+ }
1480
+ }
1481
+ return splitLineToFitWidthRecursion(words, checkFit, lines);
1482
+ }
1483
+ __name(splitLineToFitWidthRecursion, "splitLineToFitWidthRecursion");
1484
+ function applyStyle(dom, styleFn) {
1485
+ if (styleFn) {
1486
+ dom.attr("style", styleFn);
1487
+ }
1488
+ }
1489
+ __name(applyStyle, "applyStyle");
1490
+ var maxSafeSizeForWidth = 16384;
1491
+ async function addHtmlSpan(element, node, width, classes, addBackground = false, config = getConfig()) {
1492
+ const fo = element.append("foreignObject");
1493
+ fo.attr("width", `${Math.min(10 * width, maxSafeSizeForWidth)}px`);
1494
+ fo.attr("height", `${Math.min(10 * width, maxSafeSizeForWidth)}px`);
1495
+ const div = fo.append("xhtml:div");
1496
+ const sanitizedLabel = hasKatex(node.label) ? await renderKatexSanitized(node.label.replace(common_default.lineBreakRegex, `
1497
+ `), config) : sanitizeText(node.label, config);
1498
+ const labelClass = node.isNode ? "nodeLabel" : "edgeLabel";
1499
+ const span = div.append("span");
1500
+ span.html(sanitizedLabel);
1501
+ applyStyle(span, node.labelStyle);
1502
+ span.attr("class", `${labelClass} ${classes}`);
1503
+ applyStyle(div, node.labelStyle);
1504
+ div.style("display", "table-cell");
1505
+ div.style("white-space", "nowrap");
1506
+ div.style("line-height", "1.5");
1507
+ if (width !== Number.POSITIVE_INFINITY) {
1508
+ div.style("max-width", width + "px");
1509
+ div.style("text-align", "center");
1510
+ }
1511
+ div.attr("xmlns", "http://www.w3.org/1999/xhtml");
1512
+ if (addBackground) {
1513
+ div.attr("class", "labelBkg");
1514
+ }
1515
+ let bbox = div.node().getBoundingClientRect();
1516
+ if (bbox.width === width) {
1517
+ div.style("display", "table");
1518
+ div.style("white-space", "break-spaces");
1519
+ div.style("width", width + "px");
1520
+ bbox = div.node().getBoundingClientRect();
1521
+ }
1522
+ return fo.node();
1523
+ }
1524
+ __name(addHtmlSpan, "addHtmlSpan");
1525
+ function createTspan(textElement, lineIndex, lineHeight, centerText = false) {
1526
+ const tspan = textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em");
1527
+ if (centerText) {
1528
+ tspan.attr("text-anchor", "middle");
1529
+ }
1530
+ return tspan;
1531
+ }
1532
+ __name(createTspan, "createTspan");
1533
+ function computeWidthOfText(parentNode, lineHeight, line) {
1534
+ const testElement = parentNode.append("text");
1535
+ const testSpan = createTspan(testElement, 1, lineHeight);
1536
+ updateTextContentAndStyles(testSpan, line);
1537
+ const textLength = testSpan.node().getComputedTextLength();
1538
+ testElement.remove();
1539
+ return textLength;
1540
+ }
1541
+ __name(computeWidthOfText, "computeWidthOfText");
1542
+ function computeDimensionOfText(parentNode, lineHeight, text) {
1543
+ const testElement = parentNode.append("text");
1544
+ const testSpan = createTspan(testElement, 1, lineHeight);
1545
+ updateTextContentAndStyles(testSpan, [{ content: text, type: "normal" }]);
1546
+ const textDimension = testSpan.node()?.getBoundingClientRect();
1547
+ if (textDimension) {
1548
+ testElement.remove();
1549
+ }
1550
+ return textDimension;
1551
+ }
1552
+ __name(computeDimensionOfText, "computeDimensionOfText");
1553
+ function createFormattedText(width, g, structuredText, addBackground = false, centerText = false) {
1554
+ const lineHeight = 1.1;
1555
+ const labelGroup = g.append("g");
1556
+ const bkg = labelGroup.insert("rect").attr("class", "background").attr("style", "stroke: none");
1557
+ const textElement = labelGroup.append("text").attr("y", "-10.1");
1558
+ if (centerText) {
1559
+ textElement.attr("text-anchor", "middle");
1560
+ }
1561
+ let lineIndex = 0;
1562
+ for (const line of structuredText) {
1563
+ const checkWidth = /* @__PURE__ */ __name((line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width, "checkWidth");
1564
+ const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth);
1565
+ for (const preparedLine of linesUnderWidth) {
1566
+ const tspan = createTspan(textElement, lineIndex, lineHeight, centerText);
1567
+ updateTextContentAndStyles(tspan, preparedLine);
1568
+ lineIndex++;
1569
+ }
1570
+ }
1571
+ if (addBackground) {
1572
+ const bbox = textElement.node().getBBox();
1573
+ const padding = 2;
1574
+ bkg.attr("x", bbox.x - padding).attr("y", bbox.y - padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding);
1575
+ return labelGroup.node();
1576
+ } else {
1577
+ return textElement.node();
1578
+ }
1579
+ }
1580
+ __name(createFormattedText, "createFormattedText");
1581
+ function decodeHTMLEntities(text) {
1582
+ const regex = /&(amp|lt|gt);/g;
1583
+ return text.replace(regex, (match, entity) => {
1584
+ switch (entity) {
1585
+ case "amp":
1586
+ return "&";
1587
+ case "lt":
1588
+ return "<";
1589
+ case "gt":
1590
+ return ">";
1591
+ default:
1592
+ return match;
1593
+ }
1594
+ });
1595
+ }
1596
+ __name(decodeHTMLEntities, "decodeHTMLEntities");
1597
+ function updateTextContentAndStyles(tspan, wrappedLine) {
1598
+ tspan.text("");
1599
+ wrappedLine.forEach((word, index) => {
1600
+ const innerTspan = tspan.append("tspan").attr("font-style", word.type === "em" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal");
1601
+ if (index === 0) {
1602
+ innerTspan.text(decodeHTMLEntities(word.content));
1603
+ } else {
1604
+ innerTspan.text(" " + decodeHTMLEntities(word.content));
1605
+ }
1606
+ });
1607
+ }
1608
+ __name(updateTextContentAndStyles, "updateTextContentAndStyles");
1609
+ async function replaceIconSubstring(text, config = {}) {
1610
+ const pendingReplacements = [];
1611
+ text.replace(/(fa[bklrs]?):fa-([\w-]+)/g, (fullMatch, prefix, iconName) => {
1612
+ pendingReplacements.push((async () => {
1613
+ const registeredIconName = `${prefix}:${iconName}`;
1614
+ if (await isIconAvailable(registeredIconName)) {
1615
+ return await getIconSVG(registeredIconName, undefined, { class: "label-icon" });
1616
+ } else {
1617
+ return `<i class='${sanitizeText(fullMatch, config).replace(":", " ")}'></i>`;
1618
+ }
1619
+ })());
1620
+ return fullMatch;
1621
+ });
1622
+ const replacements = await Promise.all(pendingReplacements);
1623
+ return text.replace(/(fa[bklrs]?):fa-([\w-]+)/g, () => replacements.shift() ?? "");
1624
+ }
1625
+ __name(replaceIconSubstring, "replaceIconSubstring");
1626
+ var createText = /* @__PURE__ */ __name(async (el, text = "", {
1627
+ style = "",
1628
+ isTitle = false,
1629
+ classes = "",
1630
+ useHtmlLabels = true,
1631
+ markdown = true,
1632
+ isNode = true,
1633
+ width = 200,
1634
+ addSvgBackground = false
1635
+ } = {}, config) => {
1636
+ log.debug("XYZ createText", text, style, isTitle, classes, useHtmlLabels, isNode, "addSvgBackground: ", addSvgBackground);
1637
+ if (useHtmlLabels) {
1638
+ const htmlText = markdown ? markdownToHTML(text, config) : nonMarkdownToHTML(text);
1639
+ const decodedReplacedText = await replaceIconSubstring(decodeEntities(htmlText), config);
1640
+ const inputForKatex = text.replace(/\\\\/g, "\\");
1641
+ const node = {
1642
+ isNode,
1643
+ label: hasKatex(text) ? inputForKatex : decodedReplacedText,
1644
+ labelStyle: style.replace("fill:", "color:")
1645
+ };
1646
+ const vertexNode = await addHtmlSpan(el, node, width, classes, addSvgBackground, config);
1647
+ return vertexNode;
1648
+ } else {
1649
+ const sanitizeBR = decodeEntities(text.replace(/<br\s*\/?>/g, "<br/>"));
1650
+ const structuredText = markdown ? markdownToLines(sanitizeBR.replace("<br>", "<br/>"), config) : nonMarkdownToLines(sanitizeBR);
1651
+ const svgLabel = createFormattedText(width, el, structuredText, text ? addSvgBackground : false, !isNode);
1652
+ if (isNode) {
1653
+ if (/stroke:/.exec(style)) {
1654
+ style = style.replace("stroke:", "lineColor:");
1655
+ }
1656
+ const nodeLabelTextStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
1657
+ select_default(svgLabel).attr("style", nodeLabelTextStyle);
1658
+ } else {
1659
+ const edgeLabelRectStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/background:/g, "fill:");
1660
+ select_default(svgLabel).select("rect").attr("style", edgeLabelRectStyle.replace(/background:/g, "fill:"));
1661
+ const edgeLabelTextStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
1662
+ select_default(svgLabel).select("text").attr("style", edgeLabelTextStyle);
1663
+ }
1664
+ if (isTitle) {
1665
+ select_default(svgLabel).selectAll("tspan.text-outer-tspan").classed("title-row", true);
1666
+ } else {
1667
+ select_default(svgLabel).selectAll("tspan.text-outer-tspan").classed("row", true);
1668
+ }
1669
+ return svgLabel;
1670
+ }
1671
+ }, "createText");
1672
+
1673
+ export { dedent, computeDimensionOfText, createText };