elanous 0.2.20 → 0.2.22

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 (456) hide show
  1. package/apps/pwa/out/404/index.html +1 -1
  2. package/apps/pwa/out/404.html +1 -1
  3. package/apps/pwa/out/_next/static/aBi6EyMtLsrl7J8eH4kF7/_buildManifest.js +1 -0
  4. package/apps/pwa/out/_next/static/chunks/088d8e8a.8069543d082bec12.js +160 -0
  5. package/apps/pwa/out/_next/static/chunks/1109.78a7a3288c0259d9.js +148 -0
  6. package/apps/pwa/out/_next/static/chunks/115.1c6690b8604f81c4.js +32 -0
  7. package/apps/pwa/out/_next/static/chunks/119fc678.6f591cdb84ca5791.js +1 -0
  8. package/apps/pwa/out/_next/static/chunks/1262.76a3f08e67c5f816.js +309 -0
  9. package/apps/pwa/out/_next/static/chunks/1307-08b716476f1d50af.js +1 -0
  10. package/apps/pwa/out/_next/static/chunks/1358d292.5c87f12cad6eaa91.js +122 -0
  11. package/apps/pwa/out/_next/static/chunks/1438.27a1a7b8f2308004.js +149 -0
  12. package/apps/pwa/out/_next/static/chunks/1442.02d85cd88f4c1eac.js +79 -0
  13. package/apps/pwa/out/_next/static/chunks/1501-1aad662d82ba43f7.js +1 -0
  14. package/apps/pwa/out/_next/static/chunks/1584.9e2dd53da6e6d4b1.js +24 -0
  15. package/apps/pwa/out/_next/static/chunks/1586.b989b0614afb77e6.js +1 -0
  16. package/apps/pwa/out/_next/static/chunks/1609.2ad355062870151f.js +1 -0
  17. package/apps/pwa/out/_next/static/chunks/1612-f6df0fc0eed7157b.js +1 -0
  18. package/apps/pwa/out/_next/static/chunks/1923.37f1d5fe7ebe3860.js +27 -0
  19. package/apps/pwa/out/_next/static/chunks/1948.5f35b39eef222a94.js +5 -0
  20. package/apps/pwa/out/_next/static/chunks/1993.3fd074a2a246234e.js +1 -0
  21. package/apps/pwa/out/_next/static/chunks/2140.d2daf9ee96e295d1.js +1 -0
  22. package/apps/pwa/out/_next/static/chunks/2212.0359851457473efc.js +1 -0
  23. package/apps/pwa/out/_next/static/chunks/224.583e562365a52f74.js +1 -0
  24. package/apps/pwa/out/_next/static/chunks/2328.0f37465646bafa7d.js +36 -0
  25. package/apps/pwa/out/_next/static/chunks/2372.bf71372184991937.js +286 -0
  26. package/apps/pwa/out/_next/static/chunks/{2489-ff55a35b202c0f94.js → 2489-d238d3e2eb5b2bf5.js} +1 -1
  27. package/apps/pwa/out/_next/static/chunks/2549-a8515c86f9e8cb96.js +1 -0
  28. package/apps/pwa/out/_next/static/chunks/2655.72cc6a97276c5acc.js +1 -0
  29. package/apps/pwa/out/_next/static/chunks/2743-ef6e8c3ced74cce5.js +1 -0
  30. package/apps/pwa/out/_next/static/chunks/2840-5458ad50c49cac6a.js +1 -0
  31. package/apps/pwa/out/_next/static/chunks/2856.f75d5baef7f49b74.js +1 -0
  32. package/apps/pwa/out/_next/static/chunks/3344.0de4b0ec5a454b7a.js +1 -0
  33. package/apps/pwa/out/_next/static/chunks/335.a13f339e97893437.js +94 -0
  34. package/apps/pwa/out/_next/static/chunks/3394.646348f34b2500be.js +1 -0
  35. package/apps/pwa/out/_next/static/chunks/3443.6276909b53d72d53.js +1 -0
  36. package/apps/pwa/out/_next/static/chunks/3495.abd4254d808bf2dc.js +1 -0
  37. package/apps/pwa/out/_next/static/chunks/3522-1de1319d028ac89c.js +25 -0
  38. package/apps/pwa/out/_next/static/chunks/3721.ba5b82db0d9a5572.js +1 -0
  39. package/apps/pwa/out/_next/static/chunks/3857-5985236d9307f676.js +1 -0
  40. package/apps/pwa/out/_next/static/chunks/3919.9ff7dc25afefee33.js +74 -0
  41. package/apps/pwa/out/_next/static/chunks/3998.bd9a69d9b50e9bd2.js +1 -0
  42. package/apps/pwa/out/_next/static/chunks/4003.ab6db1dc266576c9.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/4216.e8ac94b9fe6b96ab.js +1 -0
  44. package/apps/pwa/out/_next/static/chunks/4327.c44dc2b55cb43ee5.js +34 -0
  45. package/apps/pwa/out/_next/static/chunks/4401.94257d497b6d26bc.js +1 -0
  46. package/apps/pwa/out/_next/static/chunks/4559.17ca2cdbaa8d414f.js +115 -0
  47. package/apps/pwa/out/_next/static/chunks/4588.ad3364cb7fb97ada.js +86 -0
  48. package/apps/pwa/out/_next/static/chunks/4706.97e734bd4c9816ca.js +1 -0
  49. package/apps/pwa/out/_next/static/chunks/4982.6e44352f751b9a1b.js +77 -0
  50. package/apps/pwa/out/_next/static/chunks/5342.49c5c5a530e62b50.js +1 -0
  51. package/apps/pwa/out/_next/static/chunks/5360-08a80abdf3a4da99.js +1 -0
  52. package/apps/pwa/out/_next/static/chunks/5431.66c58ab1327ee0b7.js +1 -0
  53. package/apps/pwa/out/_next/static/chunks/5633-d6852385000738ef.js +1 -0
  54. package/apps/pwa/out/_next/static/chunks/5717.bcfcb96e701b82e0.js +90 -0
  55. package/apps/pwa/out/_next/static/chunks/5755-30d102586789bf7f.js +1 -0
  56. package/apps/pwa/out/_next/static/chunks/5957.3f1a4012388dd962.js +1 -0
  57. package/apps/pwa/out/_next/static/chunks/5977-5b9e8a45a5b0c823.js +1 -0
  58. package/apps/pwa/out/_next/static/chunks/602.9bf02ac8e9502598.js +1 -0
  59. package/apps/pwa/out/_next/static/chunks/6020.3a1b347e2d2dfacc.js +8 -0
  60. package/apps/pwa/out/_next/static/chunks/{6158.af2e93b7adff709b.js → 6158.566c890adc06a459.js} +1 -1
  61. package/apps/pwa/out/_next/static/chunks/6375.fce1d174ba6d0324.js +64 -0
  62. package/apps/pwa/out/_next/static/chunks/6546.92a828aef441271f.js +1 -0
  63. package/apps/pwa/out/_next/static/chunks/658.957fdb0a8c6c6c8e.js +287 -0
  64. package/apps/pwa/out/_next/static/chunks/6706.323590aabb8b1293.js +226 -0
  65. package/apps/pwa/out/_next/static/chunks/6747.b67947f293a4c02d.js +1 -0
  66. package/apps/pwa/out/_next/static/chunks/6767.8e6c5f6e744fcd9f.js +38 -0
  67. package/apps/pwa/out/_next/static/chunks/6868.000b24a3045c5574.js +1 -0
  68. package/apps/pwa/out/_next/static/chunks/6946.bba74e9c96050f30.js +1 -0
  69. package/apps/pwa/out/_next/static/chunks/7033.a558f1b2f6912a53.js +1 -0
  70. package/apps/pwa/out/_next/static/chunks/7065.46029c26c53eac50.js +1 -0
  71. package/apps/pwa/out/_next/static/chunks/7087.6fae577d09249bc1.js +1 -0
  72. package/apps/pwa/out/_next/static/chunks/7175-350f4ce2873bc038.js +1 -0
  73. package/apps/pwa/out/_next/static/chunks/722.de8d9801e0f6d414.js +41 -0
  74. package/apps/pwa/out/_next/static/chunks/7497.57981e9d7a75a52a.js +24 -0
  75. package/apps/pwa/out/_next/static/chunks/7630.2b9a68659053ff4e.js +193 -0
  76. package/apps/pwa/out/_next/static/chunks/7672.4af122ad892117c7.js +1 -0
  77. package/apps/pwa/out/_next/static/chunks/771.6ab889a233e7dae7.js +1 -0
  78. package/apps/pwa/out/_next/static/chunks/7899.597af4a9996c907f.js +1 -0
  79. package/apps/pwa/out/_next/static/chunks/79b78388.663188133449d707.js +1 -0
  80. package/apps/pwa/out/_next/static/chunks/8096.f7da0776cfde6300.js +1 -0
  81. package/apps/pwa/out/_next/static/chunks/8194.484f51e273d9abd2.js +217 -0
  82. package/apps/pwa/out/_next/static/chunks/8769.815ca69879f608b4.js +104 -0
  83. package/apps/pwa/out/_next/static/chunks/8857-aa1cc4ac90af4d40.js +1 -0
  84. package/apps/pwa/out/_next/static/chunks/88729267.9c6c000157c83f2f.js +62 -0
  85. package/apps/pwa/out/_next/static/chunks/8f835b4f.048eeb02299e3e12.js +1 -0
  86. package/apps/pwa/out/_next/static/chunks/9068.5f2764fccf86c1b2.js +93 -0
  87. package/apps/pwa/out/_next/static/chunks/9247-55bcfbb0e8057f59.js +1 -0
  88. package/apps/pwa/out/_next/static/chunks/9451.ebfb0dcc9c02250f.js +23 -0
  89. package/apps/pwa/out/_next/static/chunks/9559.e648369b1d57cf9a.js +62 -0
  90. package/apps/pwa/out/_next/static/chunks/9832.2ab2e818013574c7.js +1 -0
  91. package/apps/pwa/out/_next/static/chunks/a9f2b54d-40c16bd0efdb04b8.js +1 -0
  92. package/apps/pwa/out/_next/static/chunks/app/approvals/{page-c855c24de7db74fe.js → page-88459e0903da2803.js} +1 -1
  93. package/apps/pwa/out/_next/static/chunks/app/autopilot/{page-85b316bb4235980b.js → page-d85c43f46f58716b.js} +1 -1
  94. package/apps/pwa/out/_next/static/chunks/app/board/{page-9b2b26a33cb2cd42.js → page-4e645600579ae952.js} +1 -1
  95. package/apps/pwa/out/_next/static/chunks/app/botlab/{page-c9955fde67b1bcb5.js → page-87edbfd19117823b.js} +1 -1
  96. package/apps/pwa/out/_next/static/chunks/app/bots/page-7f0c2b7801ac6a54.js +1 -0
  97. package/apps/pwa/out/_next/static/chunks/app/ceo/page-bf1f030a9d1adffd.js +1 -0
  98. package/apps/pwa/out/_next/static/chunks/app/chat/{page-4ba4abe096b6c2a8.js → page-cbaf66b1e1804adf.js} +1 -1
  99. package/apps/pwa/out/_next/static/chunks/app/consult/{page-575d4a8b4f7becb2.js → page-80ed511e02c81412.js} +1 -1
  100. package/apps/pwa/out/_next/static/chunks/app/control/{page-f5d56ff5f45ad164.js → page-9f5610caaa06178c.js} +1 -1
  101. package/apps/pwa/out/_next/static/chunks/app/decisions/{page-2260e9eef0357421.js → page-ec8f3575e339de74.js} +1 -1
  102. package/apps/pwa/out/_next/static/chunks/app/design-check/page-86d753e460f1a989.js +1 -0
  103. package/apps/pwa/out/_next/static/chunks/app/editor/page-4166a7d51cf0a57d.js +1 -0
  104. package/apps/pwa/out/_next/static/chunks/app/exec/{page-466bf0ee16ad1432.js → page-2a19c5cd3b562580.js} +1 -1
  105. package/apps/pwa/out/_next/static/chunks/app/field/{page-a23bc71713bcc08f.js → page-b6a09cde2e07521a.js} +1 -1
  106. package/apps/pwa/out/_next/static/chunks/app/inside/page-f7eae1518ca0c353.js +1 -0
  107. package/apps/pwa/out/_next/static/chunks/app/intake/page-456a8573ad811381.js +1 -0
  108. package/apps/pwa/out/_next/static/chunks/app/layout-8462d6a543cbb2d9.js +1 -0
  109. package/apps/pwa/out/_next/static/chunks/app/live/page-2974cdfb87c0f9c9.js +1 -0
  110. package/apps/pwa/out/_next/static/chunks/app/live-run/page-f927ffa25f3c86d1.js +1 -0
  111. package/apps/pwa/out/_next/static/chunks/app/loops/{page-35bfec2e631d3eae.js → page-abd86cd832aaa011.js} +1 -1
  112. package/apps/pwa/out/_next/static/chunks/app/market/page-79daf68f6256adaa.js +1 -0
  113. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/{page-f9ccb1b1adbea14d.js → page-8c3f168fc3f91939.js} +1 -1
  114. package/apps/pwa/out/_next/static/chunks/app/morning/{page-ec102c9b8b691e37.js → page-786fb4504d0f2fa9.js} +1 -1
  115. package/apps/pwa/out/_next/static/chunks/app/not-found-75209f14597dcb8f.js +1 -0
  116. package/apps/pwa/out/_next/static/chunks/app/observatory/page-bf30affe3a85af7e.js +1 -0
  117. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/page-1187a44b7515434b.js +1 -0
  118. package/apps/pwa/out/_next/static/chunks/app/ops/release/page-3d0910185a66ed54.js +1 -0
  119. package/apps/pwa/out/_next/static/chunks/app/ops/seats/page-f401ee1dd5a26e25.js +1 -0
  120. package/apps/pwa/out/_next/static/chunks/app/outputs/page-5dfe7604fd842784.js +1 -0
  121. package/apps/pwa/out/_next/static/chunks/app/page-76cf838050a8d681.js +1 -0
  122. package/apps/pwa/out/_next/static/chunks/app/reflection/{page-db03ae3589a81c9e.js → page-7ec8e289b4c14df6.js} +1 -1
  123. package/apps/pwa/out/_next/static/chunks/app/scheduler/{page-4a6463b97f0ad94f.js → page-8c8ac17d52be2a79.js} +1 -1
  124. package/apps/pwa/out/_next/static/chunks/app/sessions/{page-75bffecc9aa1004e.js → page-d359ab048d63a9d9.js} +1 -1
  125. package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-b8b345c880bf78d1.js +1 -0
  126. package/apps/pwa/out/_next/static/chunks/app/settings/{page-31d5b875760bb62d.js → page-f151cc10ad026940.js} +1 -1
  127. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-9875f103057da433.js +1 -0
  128. package/apps/pwa/out/_next/static/chunks/app/setup/page-9789328af9a9aa62.js +1 -0
  129. package/apps/pwa/out/_next/static/chunks/app/share/{page-46d5201d2207a511.js → page-bf495a1e284f4e00.js} +1 -1
  130. package/apps/pwa/out/_next/static/chunks/app/showroom/page-a263d94bca4be22a.js +1 -0
  131. package/apps/pwa/out/_next/static/chunks/app/tasks/page-3962eab8ec58d16e.js +1 -0
  132. package/apps/pwa/out/_next/static/chunks/app/term/{page-cf0a4b4abead71ea.js → page-9abcfac07e02a542.js} +1 -1
  133. package/apps/pwa/out/_next/static/chunks/app/today/page-bee49f927c333abb.js +1 -0
  134. package/apps/pwa/out/_next/static/chunks/app/trace/page-bac2d56dcb02d955.js +1 -0
  135. package/apps/pwa/out/_next/static/chunks/app/vault/page-937cbcc13176295c.js +1 -0
  136. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-d09495594f7f480d.js +1 -0
  137. package/apps/pwa/out/_next/static/chunks/app/workflows/{page-0acc8e198f7b0dfb.js → page-69cb93d1a2e57e0e.js} +1 -1
  138. package/apps/pwa/out/_next/static/chunks/app/workspace/{page-34882c84f84021c5.js → page-72ec543928d67c3e.js} +1 -1
  139. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-82906eeda0186a7b.js +1 -0
  140. package/apps/pwa/out/_next/static/chunks/d70879db.c66c56a95a91efc6.js +66 -0
  141. package/apps/pwa/out/_next/static/chunks/f8626309.a4e5d362b1d55e59.js +1 -0
  142. package/apps/pwa/out/_next/static/chunks/webpack-f2b4016b9b981bc8.js +1 -0
  143. package/apps/pwa/out/_next/static/css/{d3427996da11e480.css → b9d8151e48998417.css} +1 -1
  144. package/apps/pwa/out/_next/static/css/f2bd5257e6af88d8.css +1 -0
  145. package/apps/pwa/out/approvals/index.html +1 -1
  146. package/apps/pwa/out/approvals/index.txt +14 -14
  147. package/apps/pwa/out/autopilot/index.html +1 -1
  148. package/apps/pwa/out/autopilot/index.txt +14 -14
  149. package/apps/pwa/out/board/index.html +1 -1
  150. package/apps/pwa/out/board/index.txt +14 -14
  151. package/apps/pwa/out/botlab/index.html +1 -1
  152. package/apps/pwa/out/botlab/index.txt +14 -14
  153. package/apps/pwa/out/bots/index.html +1 -1
  154. package/apps/pwa/out/bots/index.txt +14 -14
  155. package/apps/pwa/out/ceo/index.html +1 -1
  156. package/apps/pwa/out/ceo/index.txt +14 -14
  157. package/apps/pwa/out/chat/index.html +1 -1
  158. package/apps/pwa/out/chat/index.txt +14 -14
  159. package/apps/pwa/out/consult/index.html +1 -1
  160. package/apps/pwa/out/consult/index.txt +14 -14
  161. package/apps/pwa/out/control/index.html +1 -1
  162. package/apps/pwa/out/control/index.txt +14 -14
  163. package/apps/pwa/out/decisions/index.html +1 -1
  164. package/apps/pwa/out/decisions/index.txt +14 -14
  165. package/apps/pwa/out/design-check/index.html +1 -1
  166. package/apps/pwa/out/design-check/index.txt +14 -14
  167. package/apps/pwa/out/editor/index.html +1 -1
  168. package/apps/pwa/out/editor/index.txt +15 -15
  169. package/apps/pwa/out/exec/index.html +1 -1
  170. package/apps/pwa/out/exec/index.txt +14 -14
  171. package/apps/pwa/out/field/index.html +1 -1
  172. package/apps/pwa/out/field/index.txt +14 -14
  173. package/apps/pwa/out/healthz +1 -1
  174. package/apps/pwa/out/index.html +1 -1
  175. package/apps/pwa/out/index.txt +14 -14
  176. package/apps/pwa/out/inside/index.html +1 -1
  177. package/apps/pwa/out/inside/index.txt +15 -15
  178. package/apps/pwa/out/intake/index.html +1 -1
  179. package/apps/pwa/out/intake/index.txt +14 -14
  180. package/apps/pwa/out/live/index.html +1 -1
  181. package/apps/pwa/out/live/index.txt +14 -14
  182. package/apps/pwa/out/live-run/index.html +1 -0
  183. package/apps/pwa/out/live-run/index.txt +35 -0
  184. package/apps/pwa/out/loops/index.html +1 -1
  185. package/apps/pwa/out/loops/index.txt +14 -14
  186. package/apps/pwa/out/market/index.html +1 -1
  187. package/apps/pwa/out/market/index.txt +14 -14
  188. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  189. package/apps/pwa/out/missions/placeholder/index.txt +14 -14
  190. package/apps/pwa/out/morning/index.html +1 -1
  191. package/apps/pwa/out/morning/index.txt +14 -14
  192. package/apps/pwa/out/observatory/index.html +1 -1
  193. package/apps/pwa/out/observatory/index.txt +14 -14
  194. package/apps/pwa/out/ops/checklist/index.html +1 -1
  195. package/apps/pwa/out/ops/checklist/index.txt +14 -14
  196. package/apps/pwa/out/ops/release/index.html +1 -1
  197. package/apps/pwa/out/ops/release/index.txt +14 -14
  198. package/apps/pwa/out/ops/seats/index.html +1 -1
  199. package/apps/pwa/out/ops/seats/index.txt +14 -14
  200. package/apps/pwa/out/outputs/index.html +1 -1
  201. package/apps/pwa/out/outputs/index.txt +14 -14
  202. package/apps/pwa/out/reflection/index.html +1 -1
  203. package/apps/pwa/out/reflection/index.txt +15 -15
  204. package/apps/pwa/out/scheduler/index.html +1 -1
  205. package/apps/pwa/out/scheduler/index.txt +14 -14
  206. package/apps/pwa/out/sessions/index.html +1 -1
  207. package/apps/pwa/out/sessions/index.txt +14 -14
  208. package/apps/pwa/out/settings/devices/index.html +1 -1
  209. package/apps/pwa/out/settings/devices/index.txt +14 -14
  210. package/apps/pwa/out/settings/index.html +1 -1
  211. package/apps/pwa/out/settings/index.txt +14 -14
  212. package/apps/pwa/out/setup/done/index.html +1 -1
  213. package/apps/pwa/out/setup/done/index.txt +14 -14
  214. package/apps/pwa/out/setup/index.html +1 -1
  215. package/apps/pwa/out/setup/index.txt +14 -14
  216. package/apps/pwa/out/share/index.html +1 -1
  217. package/apps/pwa/out/share/index.txt +14 -14
  218. package/apps/pwa/out/showroom/index.html +1 -1
  219. package/apps/pwa/out/showroom/index.txt +14 -14
  220. package/apps/pwa/out/tasks/index.html +1 -1
  221. package/apps/pwa/out/tasks/index.txt +14 -14
  222. package/apps/pwa/out/term/index.html +1 -1
  223. package/apps/pwa/out/term/index.txt +14 -14
  224. package/apps/pwa/out/today/index.html +1 -1
  225. package/apps/pwa/out/today/index.txt +14 -14
  226. package/apps/pwa/out/trace/index.html +1 -1
  227. package/apps/pwa/out/trace/index.txt +14 -14
  228. package/apps/pwa/out/vault/index.html +1 -1
  229. package/apps/pwa/out/vault/index.txt +14 -14
  230. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  231. package/apps/pwa/out/workflows/chat-ui/index.txt +14 -14
  232. package/apps/pwa/out/workflows/index.html +1 -1
  233. package/apps/pwa/out/workflows/index.txt +14 -14
  234. package/apps/pwa/out/workspace/index.html +1 -1
  235. package/apps/pwa/out/workspace/index.txt +14 -14
  236. package/apps/pwa/out/worktrees/index.html +1 -1
  237. package/apps/pwa/out/worktrees/index.txt +14 -14
  238. package/graphs/catalog/catalog.yaml +1 -1
  239. package/graphs/drafts/recipes.yaml +6 -6
  240. package/graphs/implement-loop.yaml +277 -5
  241. package/graphs/test-diet/recipes.yaml +3 -0
  242. package/graphs/test-diet/test-diet.yaml +3 -1
  243. package/package.json +1 -1
  244. package/scripts/coord-channel-watch.sh +31 -4
  245. package/scripts/docs-lint.ts +4 -1
  246. package/scripts/f-session-monitor.ts +69 -0
  247. package/scripts/hq/standby-snapshot.ts +7 -3
  248. package/scripts/knowledge-compress.ts +11 -0
  249. package/scripts/marketing/generate-ax-brief.ts +18 -1
  250. package/scripts/measure-nl-routing-corpus.ts +11 -3
  251. package/scripts/nightly-docops.ts +90 -3
  252. package/scripts/release-loop/gate-node.ts +5 -5
  253. package/scripts/release-loop/shard-plan.ts +50 -5
  254. package/scripts/research-coo-admin-dates.ts +39 -0
  255. package/scripts/rhythm/daily.ts +2 -1
  256. package/scripts/skills/public-check.ts +7 -2
  257. package/scripts/smart-merge/resync-shadow.ts +5 -3
  258. package/scripts/test-diet/lib.ts +81 -1
  259. package/scripts/test-diet/node.ts +48 -2
  260. package/scripts/verify-coo-admin-evidence.ts +83 -0
  261. package/src/acp/client.ts +4 -2
  262. package/src/agent/run-context.ts +4 -0
  263. package/src/agent-env/profile.ts +25 -5
  264. package/src/agent-mission/driver.ts +26 -12
  265. package/src/agent-mission/supervisor-metrics.ts +17 -2
  266. package/src/agent-substrate/acp-reviewer.ts +12 -5
  267. package/src/agent-substrate/pr-reviewer.ts +11 -4
  268. package/src/agent-substrate/review-intent.ts +102 -3
  269. package/src/autopilot/build/llm-conflict-merge.ts +22 -8
  270. package/src/autopilot/pr-manager.ts +18 -8
  271. package/src/away/release-watch.ts +47 -8
  272. package/src/briefing/brief-items.ts +104 -11
  273. package/src/browser-cdp/client.ts +10 -5
  274. package/src/chat/index.ts +1 -0
  275. package/src/cli/brief-cli.ts +20 -2
  276. package/src/cli/config-classify.ts +83 -0
  277. package/src/cli/control-cli.ts +14 -0
  278. package/src/cli/decisions-cli.ts +26 -16
  279. package/src/cli/logs-model-input.ts +1 -1
  280. package/src/cli/ops-cli.ts +11 -0
  281. package/src/cli/ops-overview-cli.ts +50 -0
  282. package/src/cli/pod-cli.ts +1 -0
  283. package/src/cli/pr-cli.ts +65 -8
  284. package/src/cli/release-cli.ts +21 -4
  285. package/src/cli/tasks-cli.ts +214 -1
  286. package/src/connectors/types.ts +6 -6
  287. package/src/context-bus/context-now-surfaces.ts +18 -0
  288. package/src/context-bus/coord-events.ts +32 -4
  289. package/src/context-bus/long-term-memory.ts +23 -6
  290. package/src/context-bus/nightly-condense.ts +169 -21
  291. package/src/control/control-status.ts +87 -0
  292. package/src/control-plane/light-member.ts +5 -3
  293. package/src/control-plane/member.ts +172 -7
  294. package/src/core-turn/run-goal-loop.ts +22 -1
  295. package/src/dashboard/index.ts +40 -4
  296. package/src/dashboard/slash-runtime/dashboard-handlers.ts +9 -0
  297. package/src/decisions/decision-cards.ts +20 -1
  298. package/src/decisions/decision-ledger.ts +11 -8
  299. package/src/decisions/web-push-decision-cards.ts +19 -3
  300. package/src/discord-self-message.ts +2 -2
  301. package/src/domains/coo-admin-dates.evidence.json +876 -0
  302. package/src/domains/coo-admin-tool.ts +48 -14
  303. package/src/domains/ops-status.ts +53 -0
  304. package/src/domains/outbound-alert.ts +24 -1
  305. package/src/esc-abort-gate.ts +3 -1
  306. package/src/exec-requests/planner.ts +6 -0
  307. package/src/graph-kinds/registry.ts +6 -6
  308. package/src/graph-runner/graph-cli.ts +91 -2
  309. package/src/graph-runner/graph-run-api.ts +20 -0
  310. package/src/graph-runner/graph-tick.ts +73 -12
  311. package/src/graph-runner/runner.ts +43 -11
  312. package/src/graph-unify/wf-to-graph.ts +79 -0
  313. package/src/graph-wizard/archetypes.ts +88 -0
  314. package/src/graph-wizard/generate.ts +577 -0
  315. package/src/graph-wizard/saved-steps.ts +120 -0
  316. package/src/graph-wizard/steps.ts +206 -0
  317. package/src/harness/harness-cli-command.ts +186 -32
  318. package/src/harness/harness-queue.ts +58 -14
  319. package/src/harness/launch-advice.ts +23 -0
  320. package/src/index.ts +43 -11
  321. package/src/intake-plane/digest.ts +18 -11
  322. package/src/knowledge/conclusion-compress.ts +93 -0
  323. package/src/knowledge/know-find.ts +9 -2
  324. package/src/knowledge/query.ts +20 -0
  325. package/src/llm.ts +26 -16
  326. package/src/loops/neighbor-runtime.ts +88 -0
  327. package/src/loops/orchestrator/author-depth.ts +29 -11
  328. package/src/loops/orchestrator/overlap.ts +7 -1
  329. package/src/loops/orchestrator/resync-shadow.ts +1 -1
  330. package/src/loops/orchestrator/tick.ts +35 -2
  331. package/src/loops/orchestrator/traffic.ts +2 -0
  332. package/src/loops/registry.ts +5 -0
  333. package/src/market/publish.ts +17 -1
  334. package/src/maturity/feature-maturity.ts +4 -2
  335. package/src/mss/logging/redaction.ts +17 -0
  336. package/src/nexus/api/draft-metrics.ts +128 -0
  337. package/src/nexus/api/graph-peer-edit.ts +77 -0
  338. package/src/nexus/api/graph-wizard-api.ts +61 -0
  339. package/src/nexus/api/graphs-api.ts +193 -17
  340. package/src/nexus/api/harness-traversal.ts +205 -0
  341. package/src/nexus/api/http-server.ts +122 -6
  342. package/src/nexus/api/plugins-market.ts +24 -0
  343. package/src/nexus/index.ts +3 -2
  344. package/src/nexus/outbound/router.ts +28 -8
  345. package/src/oauth/claude-pty-maturity.ts +24 -0
  346. package/src/oauth/fallback-chain.ts +27 -14
  347. package/src/onboarding/first-run.ts +3 -0
  348. package/src/ops/overview-collect.ts +345 -0
  349. package/src/ops/overview-seat-era.ts +90 -0
  350. package/src/ops/overview.ts +223 -0
  351. package/src/plugins/maker/market-bundle.ts +9 -0
  352. package/src/plugins/maker/plugin-maker.ts +9 -3
  353. package/src/plugins/maker/wizard-generate.ts +73 -9
  354. package/src/policy/llm-policy.ts +11 -6
  355. package/src/release-loop/checklist-board.ts +27 -0
  356. package/src/release-loop/checklist.ts +38 -0
  357. package/src/release-loop/gate-shards.ts +7 -2
  358. package/src/seat-address/seat-address.ts +1 -0
  359. package/src/seat-loop/seat-loop.ts +174 -20
  360. package/src/seat-loop/seat-report.ts +29 -1
  361. package/src/self-dev/ask-launch-flow.ts +4 -2
  362. package/src/self-dev/ask-launch-io.ts +3 -1
  363. package/src/self-dev/dev-cli.ts +90 -8
  364. package/src/self-dev/dev-pipeline.ts +20 -1
  365. package/src/self-dev/draft-sweep.ts +45 -8
  366. package/src/self-dev/graph-journey-nodes.ts +157 -0
  367. package/src/self-dev/graph-journey-route.ts +105 -0
  368. package/src/self-dev/launch-preflight.ts +43 -3
  369. package/src/self-dev/orchestrate.ts +3 -0
  370. package/src/self-dev/release-path-guard.ts +7 -4
  371. package/src/self-dev/review-provider-fallback.ts +83 -0
  372. package/src/self-dev/run-supervisor.ts +5 -1
  373. package/src/self-implement/frozen-merges.ts +23 -0
  374. package/src/self-implement/goal-author.ts +14 -0
  375. package/src/self-implement/harness-policy-gates.ts +7 -5
  376. package/src/self-implement/heal-intake.ts +3 -0
  377. package/src/self-implement/host-regate.ts +28 -14
  378. package/src/self-implement/l8-merge-queue.ts +80 -8
  379. package/src/self-implement/orchestrator.ts +84 -28
  380. package/src/self-implement/seams.ts +8 -3
  381. package/src/self-implement/self-implement-cli.ts +4 -0
  382. package/src/self-implement/self-implement-runtime.ts +12 -0
  383. package/src/session-runtime/index.ts +5 -3
  384. package/src/shell-env-bootstrap.ts +35 -6
  385. package/src/steward/triage.ts +25 -8
  386. package/src/storage/file-lock.ts +33 -4
  387. package/src/task-agent/card-evidence.ts +6 -0
  388. package/src/task-agent/completion-evidence.ts +31 -3
  389. package/src/task-agent/cover.ts +61 -0
  390. package/src/task-agent/live-moves.ts +126 -3
  391. package/src/task-agent/parent-host.ts +315 -0
  392. package/src/task-agent/shadow.ts +19 -4
  393. package/src/task-agent/task-hand.ts +11 -2
  394. package/src/task-orchestrator/surfaces/pod-command-job.ts +41 -6
  395. package/src/task-orchestrator/surfaces/pod-gate-deps.ts +123 -0
  396. package/src/task-orchestrator/surfaces/pod-pool.ts +138 -15
  397. package/src/task-orchestrator/surfaces/self-implement-pod.ts +39 -6
  398. package/src/task-orchestrator/surfaces/self-implement.ts +7 -0
  399. package/src/telegram-commands.ts +8 -0
  400. package/src/telegram-project-command.ts +6 -0
  401. package/src/telegram.ts +2 -2
  402. package/src/tool-runtime/browser-runtime.ts +87 -3
  403. package/src/tool-runtime/index.ts +1 -0
  404. package/src/typecheck-ratchet.ts +2 -1
  405. package/src/user-config.ts +55 -8
  406. package/src/version/packed-revision.json +1 -1
  407. package/src/workflow-runtime/executor.ts +24 -2
  408. package/src/workflow-runtime/triggers/registry.ts +27 -0
  409. package/src/workflow-runtime/triggers/schedule-source.ts +30 -3
  410. package/apps/pwa/out/_next/static/Bam1YziK2iH9bN4K0utGk/_buildManifest.js +0 -1
  411. package/apps/pwa/out/_next/static/chunks/1307-77fad80cf54477c6.js +0 -1
  412. package/apps/pwa/out/_next/static/chunks/1612-f60c0c93ec773f81.js +0 -1
  413. package/apps/pwa/out/_next/static/chunks/1844-9ec4b1d12f6e80eb.js +0 -1
  414. package/apps/pwa/out/_next/static/chunks/1866-e7a6999f25548b30.js +0 -1
  415. package/apps/pwa/out/_next/static/chunks/1948.15f356b15a625597.js +0 -5
  416. package/apps/pwa/out/_next/static/chunks/2116-6429c188eb846ab8.js +0 -1
  417. package/apps/pwa/out/_next/static/chunks/224-e7be8f762fe74986.js +0 -1
  418. package/apps/pwa/out/_next/static/chunks/2549-89c518a4c8ed4d00.js +0 -1
  419. package/apps/pwa/out/_next/static/chunks/2957-96ffab3d521fb08f.js +0 -1
  420. package/apps/pwa/out/_next/static/chunks/3857-995ea9f5ef33d71e.js +0 -1
  421. package/apps/pwa/out/_next/static/chunks/5360-be1f1d8f9fcc9755.js +0 -1
  422. package/apps/pwa/out/_next/static/chunks/5755-ea7ed88eb956f47b.js +0 -1
  423. package/apps/pwa/out/_next/static/chunks/5977-94ed6f78e9814b2b.js +0 -1
  424. package/apps/pwa/out/_next/static/chunks/7748-6e51bfe927019f5c.js +0 -25
  425. package/apps/pwa/out/_next/static/chunks/9247-c1753a059e7bac08.js +0 -1
  426. package/apps/pwa/out/_next/static/chunks/a9f2b54d-33c0689b70ed8cf3.js +0 -1
  427. package/apps/pwa/out/_next/static/chunks/app/bots/page-7a852956c74015a3.js +0 -1
  428. package/apps/pwa/out/_next/static/chunks/app/ceo/page-c5a5c621be0e04ae.js +0 -1
  429. package/apps/pwa/out/_next/static/chunks/app/design-check/page-7c058069c5e7fa63.js +0 -1
  430. package/apps/pwa/out/_next/static/chunks/app/editor/page-dc5da0b8a2edb8a4.js +0 -1
  431. package/apps/pwa/out/_next/static/chunks/app/inside/page-ed4a6f799f005d09.js +0 -1
  432. package/apps/pwa/out/_next/static/chunks/app/intake/page-9cd565005b93aca6.js +0 -1
  433. package/apps/pwa/out/_next/static/chunks/app/layout-55f0f40c6db95f15.js +0 -1
  434. package/apps/pwa/out/_next/static/chunks/app/live/page-474cb5888ea0e8f3.js +0 -1
  435. package/apps/pwa/out/_next/static/chunks/app/market/page-9ca21f9ad3208a61.js +0 -1
  436. package/apps/pwa/out/_next/static/chunks/app/not-found-a9c2cfa8dda922a5.js +0 -1
  437. package/apps/pwa/out/_next/static/chunks/app/observatory/page-6da35144878feb6d.js +0 -1
  438. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/page-f6055495e9ed7ea8.js +0 -1
  439. package/apps/pwa/out/_next/static/chunks/app/ops/release/page-25204694fa9984a5.js +0 -1
  440. package/apps/pwa/out/_next/static/chunks/app/ops/seats/page-a60e035f151d84d3.js +0 -1
  441. package/apps/pwa/out/_next/static/chunks/app/outputs/page-189c587f36874538.js +0 -1
  442. package/apps/pwa/out/_next/static/chunks/app/page-c56634bde705a65d.js +0 -1
  443. package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-a8d2fe0c669e0de4.js +0 -1
  444. package/apps/pwa/out/_next/static/chunks/app/setup/done/page-c26fa10aac6c21c4.js +0 -1
  445. package/apps/pwa/out/_next/static/chunks/app/setup/page-68793c6e10331d66.js +0 -1
  446. package/apps/pwa/out/_next/static/chunks/app/showroom/page-d81c07a7b4f618ae.js +0 -1
  447. package/apps/pwa/out/_next/static/chunks/app/tasks/page-be1c4e8697f22360.js +0 -1
  448. package/apps/pwa/out/_next/static/chunks/app/today/page-a4717e2c4bf7a28f.js +0 -1
  449. package/apps/pwa/out/_next/static/chunks/app/trace/page-0fd895fab9b62c1b.js +0 -1
  450. package/apps/pwa/out/_next/static/chunks/app/vault/page-8b6c1454a8e8f306.js +0 -1
  451. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-c6e4364d9de8f717.js +0 -1
  452. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-0506a1e0e4bdb2f5.js +0 -1
  453. package/apps/pwa/out/_next/static/chunks/webpack-c260571513bf43c2.js +0 -1
  454. package/apps/pwa/out/_next/static/css/c23d959d3ee15e57.css +0 -1
  455. /package/apps/pwa/out/_next/static/{Bam1YziK2iH9bN4K0utGk → aBi6EyMtLsrl7J8eH4kF7}/_ssgManifest.js +0 -0
  456. /package/skills/project-onboarding/{skill.md → SKILL.md} +0 -0
@@ -0,0 +1,309 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1262],{37933:(e,t,s)=>{s.d(t,{A:()=>a});var i=s(21201),n=s(21930),a=(0,i.K)((e,t)=>{let s;return"sandbox"===t&&(s=(0,n.Ltv)("#i"+e)),("sandbox"===t?(0,n.Ltv)(s.nodes()[0].contentDocument.body):(0,n.Ltv)("body")).select(`[id="${e}"]`)},"getDiagramElement")},58578:(e,t,s)=>{s.d(t,{P:()=>r});var i=s(13333),n=s(78143),a=s(21201),r=(0,a.K)((e,t,s,a)=>{e.attr("class",s);let{width:r,height:c,x:h,y:d}=o(e,t);(0,i.a$)(e,c,r,a);let u=l(h,d,r,c,t);e.attr("viewBox",u),n.R.debug(`viewBox configured: ${u} with padding: ${t}`)},"setupViewPortForSVG"),o=(0,a.K)((e,t)=>{let s=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:s.width+2*t,height:s.height+2*t,x:s.x,y:s.y}},"calculateDimensionsWithPadding"),l=(0,a.K)((e,t,s,i,n)=>`${e-n} ${t-n} ${s} ${i}`,"createViewBox")},81262:(e,t,s)=>{s.d(t,{diagram:()=>nN});var i,n,a,r,o=s(37933),l=s(58578),c=s(17028);s(79033),s(57807),s(30778),s(24200),s(3570),s(26613);var h=s(56638);s(10862);var d=s(23807),u=s(54547),p=s(13333),f=s(78143),m=s(21201);function E(e){function t(){}t.prototype=e;let s=new t;function i(){return typeof s.bar}return i(),i(),e}class T{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}}class g extends T{constructor(e){super([]),this.idx=1,Object.assign(this,b(e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class y extends T{constructor(e){super(e.definition),this.orgText="",Object.assign(this,b(e))}}class A extends T{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,b(e))}}class S extends T{constructor(e){super(e.definition),this.idx=1,Object.assign(this,b(e))}}class L extends T{constructor(e){super(e.definition),this.idx=1,Object.assign(this,b(e))}}class O extends T{constructor(e){super(e.definition),this.idx=1,Object.assign(this,b(e))}}class R extends T{constructor(e){super(e.definition),this.idx=1,Object.assign(this,b(e))}}class k extends T{constructor(e){super(e.definition),this.idx=1,Object.assign(this,b(e))}}class I extends T{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,b(e))}}class N{constructor(e){this.idx=1,Object.assign(this,b(e))}accept(e){e.visit(this)}}function b(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}class C{visit(e){switch(e.constructor){case g:return this.visitNonTerminal(e);case A:return this.visitAlternative(e);case S:return this.visitOption(e);case L:return this.visitRepetitionMandatory(e);case O:return this.visitRepetitionMandatoryWithSeparator(e);case k:return this.visitRepetitionWithSeparator(e);case R:return this.visitRepetition(e);case I:return this.visitAlternation(e);case N:return this.visitTerminal(e);case y:return this.visitRule(e);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function _(e,t=[]){return e instanceof S||e instanceof R||e instanceof k||(e instanceof I?e.definition.some(e=>_(e,t)):!(e instanceof g&&t.includes(e))&&e instanceof T&&(e instanceof g&&t.push(e),e.definition.every(e=>_(e,t))))}function v(e){if(e instanceof g)return"SUBRULE";if(e instanceof S)return"OPTION";if(e instanceof I)return"OR";if(e instanceof L)return"AT_LEAST_ONE";if(e instanceof O)return"AT_LEAST_ONE_SEP";else if(e instanceof k)return"MANY_SEP";else if(e instanceof R)return"MANY";else if(e instanceof N)return"CONSUME";else throw Error("non exhaustive match")}class x{walk(e,t=[]){e.definition.forEach((s,i)=>{let n=e.definition.slice(i+1);if(s instanceof g)this.walkProdRef(s,n,t);else if(s instanceof N)this.walkTerminal(s,n,t);else if(s instanceof A)this.walkFlat(s,n,t);else if(s instanceof S)this.walkOption(s,n,t);else if(s instanceof L)this.walkAtLeastOne(s,n,t);else if(s instanceof O)this.walkAtLeastOneSep(s,n,t);else if(s instanceof k)this.walkManySep(s,n,t);else if(s instanceof R)this.walkMany(s,n,t);else if(s instanceof I)this.walkOr(s,n,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,s){}walkProdRef(e,t,s){}walkFlat(e,t,s){let i=t.concat(s);this.walk(e,i)}walkOption(e,t,s){let i=t.concat(s);this.walk(e,i)}walkAtLeastOne(e,t,s){let i=[new S({definition:e.definition})].concat(t,s);this.walk(e,i)}walkAtLeastOneSep(e,t,s){let i=U(e,t,s);this.walk(e,i)}walkMany(e,t,s){let i=[new S({definition:e.definition})].concat(t,s);this.walk(e,i)}walkManySep(e,t,s){let i=U(e,t,s);this.walk(e,i)}walkOr(e,t,s){let i=t.concat(s);e.definition.forEach(e=>{let t=new A({definition:[e]});this.walk(t,i)})}}function U(e,t,s){return[new S({definition:[new N({terminalType:e.separator})].concat(e.definition)})].concat(t,s)}function M(e){if(e instanceof g)return M(e.referencedRule);if(e instanceof N)return[e.terminalType];if(e instanceof A||e instanceof S||e instanceof R||e instanceof L||e instanceof O||e instanceof k||e instanceof N||e instanceof y)return function(e){let t,s=[],i=e.definition,n=0,a=i.length>n,r=!0;for(;a&&r;)r=_(t=i[n]),s=s.concat(M(t)),n+=1,a=i.length>n;return[...new Set(s)]}(e);if(e instanceof I)return[...new Set(e.definition.map(e=>M(e)).flat())];throw Error("non exhaustive match")}let w="_~IN~_";class P extends x{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,s){}walkProdRef(e,t,s){var i,n;let a=(i=e.referencedRule,n=e.idx,i.name+n+w+this.topProd.name),r=M(new A({definition:t.concat(s)}));this.follows[a]=r}}function D(e){return e.charCodeAt(0)}function $(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function K(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function F(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function B(){throw Error("Internal Error - Should never get here!")}function j(e){return"Character"===e.type}let G=[];for(let e=D("0");e<=D("9");e++)G.push(e);let W=[D("_")].concat(G);for(let e=D("a");e<=D("z");e++)W.push(e);for(let e=D("A");e<=D("Z");e++)W.push(e);let V=[D(" "),D("\f"),D("\n"),D("\r"),D(" "),D("\v"),D(" "),D("\xa0"),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D(" "),D("\u2028"),D("\u2029"),D(" "),D(" "),D(" "),D("\uFEFF")],z=/[0-9a-fA-F]/,H=/[0-9]/,Y=/[1-9]/;class X{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let s={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":K(s,"global");break;case"i":K(s,"ignoreCase");break;case"m":K(s,"multiLine");break;case"u":K(s,"unicode");break;case"y":K(s,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:s,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}}F(t);let s=this.disjunction();return this.consumeChar(")"),{type:t,value:s,loc:this.loc(e)}}return B()}quantifier(e=!1){let t,s=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":t=this.isDigit()?{atLeast:i,atMost:this.integerIncludingZero()}:{atLeast:i,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;F(t)}if((!0!==e||void 0!==t)&&F(t))return"?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(s),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),F(e))?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):B()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[D("\n"),D("\r"),D("\u2028"),D("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case"d":e=G;break;case"D":e=G,t=!0;break;case"s":e=V;break;case"S":e=V,t=!0;break;case"w":e=W;break;case"W":e=W,t=!0}return F(e)?{type:"Set",value:e,complement:t}:B()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=D("\f");break;case"n":e=D("\n");break;case"r":e=D("\r");break;case"t":e=D(" ");break;case"v":e=D("\v")}return F(e)?{type:"Character",value:e}:B()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:D("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:D(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:D(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,j(t)&&this.isRangeDash()){this.consumeChar("-");let s=this.classAtom();if(s.type,j(s)){if(s.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:s.value})}else $(t.value,e),e.push(D("-")),$(s.value,e)}else $(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:D("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;this.consumeChar("("),"?"===this.peekChar(0)?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;let t=this.disjunction();this.consumeChar(")");let s={type:"Group",capturing:e,value:t};return e&&(s.idx=this.groupIdx),s}positiveInteger(){let e=this.popChar();if(!1===Y.test(e))throw Error("Expecting a positive integer");for(;H.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===H.test(e))throw Error("Expecting an integer");for(;H.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:D(e)}}}isRegExpFlag(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}}isRangeDash(){return"-"===this.peekChar()&&this.isClassAtom(1)}isDigit(){return H.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2)||"<"===this.peekChar(2)&&("="===this.peekChar(3)||"!"===this.peekChar(3)));default:return!1}}isQuantifier(){let e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let s=0;s<e;s++){let e=this.popChar();if(!1===z.test(e))throw Error("Expecting a HexDecimal digits");t+=e}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class q{visitChildren(e){for(let t in e){let s=e[t];e.hasOwnProperty(t)&&(void 0!==s.type?this.visit(s):Array.isArray(s)&&s.forEach(e=>{this.visit(e)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}function J(e){console&&console.error&&console.error(`Error: ${e}`)}function Z(e){console&&console.warn&&console.warn(`Warning: ${e}`)}let Q={},ee=new X;function et(e){let t=e.toString();if(Q.hasOwnProperty(t))return Q[t];{let e=ee.pattern(t);return Q[t]=e,e}}let es="Complement Sets are not supported for first char optimization",ei='Unable to use "first char" lexer optimizations:\n';function en(e,t,s){let i=eS(e);t[i]=i,!0===s&&function(e,t){let s=String.fromCharCode(e),i=s.toUpperCase();if(i!==s){let e=eS(i.charCodeAt(0));t[e]=e}else{let e=s.toLowerCase();if(e!==s){let s=eS(e.charCodeAt(0));t[s]=s}}}(e,t)}function ea(e,t){return e.value.find(e=>"number"==typeof e?t.includes(e):void 0!==t.find(t=>e.from<=t&&t<=e.to))}class er extends q{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===ea(e,this.targetCharCodes)&&(this.found=!0):void 0!==ea(e,this.targetCharCodes)&&(this.found=!0)}}function eo(e,t){if(t instanceof RegExp){let s=et(t),i=new er(e);return i.visit(s),i.found}for(let s of t){let t=s.charCodeAt(0);if(e.includes(t))return!0}return!1}let el="PATTERN",ec="defaultMode",eh="modes",ed=/[^\\][$]/,eu=/[^\\[][\^]|^\^/;function ep(e){let t=e.ignoreCase?"iy":"y";return RegExp(`${e.source}`,t)}function ef(e){let t=e.PATTERN;if(t instanceof RegExp)return!1;if("function"==typeof t)return!0;if(Object.hasOwn(t,"exec"))return!0;if("string"==typeof t)return!1;throw Error("non exhaustive match")}function em(e){return"string"==typeof e&&1===e.length&&e.charCodeAt(0)}let eE={test:function(e){let t=e.length;for(let s=this.lastIndex;s<t;s++){let t=e.charCodeAt(s);if(10===t)return this.lastIndex=s+1,!0;if(13===t)return 10===e.charCodeAt(s+1)?this.lastIndex=s+2:this.lastIndex=s+1,!0}return!1},lastIndex:0};function eT(e,t){if(Object.hasOwn(e,"LINE_BREAKS"))return!1;if(e.PATTERN instanceof RegExp){try{eo(t,e.PATTERN)}catch(e){return{issue:i.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if("string"==typeof e.PATTERN)return!1;if(ef(e))return{issue:i.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function eg(e){return e.map(e=>"string"==typeof e?e.charCodeAt(0):e)}function ey(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}let eA=[];function eS(e){return e<256?e:eA[e]}function eL(e){let t=new Date().getTime(),s=e();return{time:new Date().getTime()-t,value:s}}function eO(e,t){let s=e.tokenTypeIdx;return s===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[s]}function eR(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let ek=1,eI={};function eN(e){let t=function(e){let t=[...e],s=e,i=!0;for(;i;){let e=(s=s.map(e=>e.CATEGORIES).flat().filter(Boolean)).filter(e=>!t.includes(e));t=t.concat(e),0===e.length?i=!1:s=e}return t}(e);t.forEach(e=>{var t,s;eb(e)||(eI[ek]=e,e.tokenTypeIdx=ek++),eC(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),eC(e)||(e.CATEGORIES=[]),Object.hasOwn(null!=(t=e)?t:{},"categoryMatches")||(e.categoryMatches=[]),Object.hasOwn(null!=(s=e)?s:{},"categoryMatchesMap")||(e.categoryMatchesMap={})}),t.forEach(e=>{!function e(t,s){t.forEach(e=>{s.categoryMatchesMap[e.tokenTypeIdx]=!0}),s.CATEGORIES.forEach(i=>{let n=t.concat(s);n.includes(i)||e(n,i)})}([],e)}),t.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(eI[t].tokenTypeIdx)})}),t.forEach(e=>{e.isParent=e.categoryMatches.length>0})}function eb(e){return Object.hasOwn(null!=e?e:{},"tokenTypeIdx")}function eC(e){return Object.hasOwn(null!=e?e:{},"CATEGORIES")}function e_(e){return Object.hasOwn(null!=e?e:{},"tokenTypeIdx")}!function(e){e[e.MISSING_PATTERN=0]="MISSING_PATTERN",e[e.INVALID_PATTERN=1]="INVALID_PATTERN",e[e.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",e[e.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",e[e.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",e[e.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",e[e.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",e[e.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",e[e.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",e[e.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",e[e.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",e[e.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",e[e.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"}(i||(i={}));let ev={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:{buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,s,i,n,a)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${s} characters.`},traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(ev);class ex{constructor(e,t=ev){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let s=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);let{time:i,value:n}=eL(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,n}},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=Object.assign({},ev,t);let s=this.config.traceInitPerf;!0===s?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof s&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let s,n=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===ev.lineTerminatorsPattern)this.config.lineTerminatorsPattern=eE;else if(this.config.lineTerminatorCharacters===ev.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?s={modes:{defaultMode:[...e]},defaultMode:ec}:(n=!1,s=Object.assign({},e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e,t,s){let n=[];return Object.hasOwn(e,ec)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+ec+"> property in its definition\n",type:i.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(e,eh)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+eh+"> property in its definition\n",type:i.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(e,eh)&&Object.hasOwn(e,ec)&&!Object.hasOwn(e.modes,e.defaultMode)&&n.push({message:`A MultiMode Lexer cannot be initialized with a ${ec}: <${e.defaultMode}>which does not exist
2
+ `,type:i.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(e,eh)&&Object.keys(e.modes).forEach(t=>{let s=e.modes[t];s.forEach((e,a)=>{void 0===e?n.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${a}>
3
+ `,type:i.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(e,"LONGER_ALT")&&(Array.isArray(e.LONGER_ALT)?e.LONGER_ALT:[e.LONGER_ALT]).forEach(a=>{void 0===a||s.includes(a)||n.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${a.name}> on token <${e.name}> outside of mode <${t}>
4
+ `,type:i.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),n}(s,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(function(e,t,s){let n=[],a=!1,r=Object.values(e.modes||{}).flat().filter(Boolean).filter(e=>e[el]!==ex.NA),o=eg(s);return t&&r.forEach(e=>{let t=eT(e,o);if(!1!==t){let s={message:function(e,t){if(t.issue===i.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
5
+ The problem is in the <${e.name}> Token Type
6
+ Root cause: ${t.errMsg}.
7
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===i.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
8
+ The problem is in the <${e.name}> Token Type
9
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),type:t.issue,tokenType:e};n.push(s)}else Object.hasOwn(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(a=!0):eo(o,e.PATTERN)&&(a=!0)}),t&&!a&&n.push({message:"Warning: No LINE_BREAKS Found.\n This Lexer has been defined to track line and column information,\n But none of the Token Types can be identified as matching a line terminator.\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n for details.",type:i.NO_LINE_BREAKS_FLAGS}),n}(s,this.trackStartLines,this.config.lineTerminatorCharacters))})),s.modes=s.modes?s.modes:{},Object.entries(s.modes).forEach(([e,t])=>{s.modes[e]=t.filter(e=>void 0!==e)});let a=Object.keys(s.modes);if(Object.entries(s.modes).forEach(([e,s])=>{this.TRACE_INIT(`Mode: <${e}> processing`,()=>{if(this.modes.push(e),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(e,t){var s,n;let a=[],r=function(e){let t=e.filter(e=>!Object.hasOwn(e,el));return{errors:t.map(e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:i.MISSING_PATTERN,tokenTypes:[e]})),valid:e.filter(e=>!t.includes(e))}}(e);a=a.concat(r.errors);let o=function(e){let t=e.filter(e=>{let t=e[el];return!(t instanceof RegExp)&&"function"!=typeof t&&!Object.hasOwn(t,"exec")&&"string"!=typeof t});return{errors:t.map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:i.INVALID_PATTERN,tokenTypes:[e]})),valid:e.filter(e=>!t.includes(e))}}(r.valid),l=o.valid;return(a=(a=(a=(a=a.concat(o.errors)).concat(function(e){let t=[],s=e.filter(e=>e[el]instanceof RegExp);return(t=(t=(t=(t=t.concat(function(e){class t extends q{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return e.filter(e=>{let s=e.PATTERN;try{let e=et(s),i=new t;return i.visit(e),i.found}catch(e){return ed.test(s.source)}}).map(e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:i.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}(s))).concat(function(e){class t extends q{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return e.filter(e=>{let s=e.PATTERN;try{let e=et(s),i=new t;return i.visit(e),i.found}catch(e){return eu.test(s.source)}}).map(e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:i.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}(s))).concat(s.filter(e=>{let t=e[el];return t instanceof RegExp&&(t.multiline||t.global)}).map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:i.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]})))).concat(function(e){let t=[],s=e.map(s=>e.reduce((e,i)=>(s.PATTERN.source!==i.PATTERN.source||t.includes(i)||i.PATTERN===ex.NA||(t.push(i),e.push(i)),e),[]));return(s=s.filter(Boolean)).filter(e=>e.length>1).map(e=>{let t=e.map(e=>e.name),s=e[0].PATTERN;return{message:`The same RegExp pattern ->${s}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:i.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}(s))).concat(s.filter(e=>e.PATTERN.test("")).map(e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:i.EMPTY_MATCH_PATTERN,tokenTypes:[e]})))}(l))).concat(l.filter(e=>{if(!Object.hasOwn(e,"GROUP"))return!1;let t=e.GROUP;return t!==ex.SKIPPED&&t!==ex.NA&&"string"!=typeof t}).map(e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:i.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]})))).concat((s=l,n=t,s.filter(e=>void 0!==e.PUSH_MODE&&!n.includes(e.PUSH_MODE)).map(e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:i.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))))).concat(function(e){let t=[],s=e.reduce((e,t,s)=>{var i;let n=t.PATTERN;return n===ex.NA||("string"==typeof n?e.push({str:n,idx:s,tokenType:t}):n instanceof RegExp&&(i=n,void 0===[".","\\","[","]","|","^","$","(",")","?","*","+","{"].find(e=>-1!==i.source.indexOf(e)))&&e.push({str:n.source,idx:s,tokenType:t})),e},[]);return e.forEach((e,n)=>{s.forEach(({str:s,idx:a,tokenType:r})=>{if(n<a&&function(e,t){if(t instanceof RegExp){var s;if(s=t,/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(s.source))return!1;let i=t.exec(e);return null!==i&&0===i.index}if("function"==typeof t)return t(e,0,[],{});if(Object.hasOwn(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(s,e.PATTERN)){let s=`Token: ->${r.name}<- can never be matched.
10
+ Because it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.
11
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:s,type:i.UNREACHABLE_PATTERN,tokenTypes:[e,r]})}})}),t}(l))}(s,a))}),0===this.lexerDefinitionErrors.length){let i;eN(s),this.TRACE_INIT("analyzeTokenTypes",()=>{i=function(e,t){let s,i,n,a,r,o,l,c,h,d,u,p,f=(t=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()},t)).tracer;f("initCharCodeToOptimizedIndexMap",()=>{if(0===eA.length){eA=Array(65536);for(let e=0;e<65536;e++)eA[e]=e>255?255+~~(e/255):e}}),f("Reject Lexer.NA",()=>{s=e.filter(e=>e[el]!==ex.NA)});let m=!1;f("Transform Patterns",()=>{m=!1,i=s.map(e=>{let t=e[el];if(t instanceof RegExp){let e=t.source;return 1!==e.length||"^"===e||"$"===e||"."===e||t.ignoreCase?2!==e.length||"\\"!==e[0]||["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(e[1])?ep(t):e[1]:e}if("function"==typeof t)return m=!0,{exec:t};if("object"==typeof t)return m=!0,t;if("string"==typeof t)if(1===t.length)return t;else return ep(new RegExp(t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")));throw Error("non exhaustive match")})}),f("misc mapping",()=>{n=s.map(e=>e.tokenTypeIdx),a=s.map(e=>{let t=e.GROUP;if(t!==ex.SKIPPED){if("string"==typeof t)return t;if(void 0===t)return!1;throw Error("non exhaustive match")}}),r=s.map(e=>{let t=e.LONGER_ALT;if(t)return Array.isArray(t)?t.map(e=>s.indexOf(e)):[s.indexOf(t)]}),o=s.map(e=>e.PUSH_MODE),l=s.map(e=>Object.hasOwn(e,"POP_MODE"))}),f("Line Terminator Handling",()=>{let e=eg(t.lineTerminatorCharacters);c=s.map(e=>!1),"onlyOffset"!==t.positionTracking&&(c=s.map(t=>Object.hasOwn(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===eT(t,e)&&eo(e,t.PATTERN)))}),f("Misc Mapping #2",()=>{h=s.map(ef),d=i.map(em),u=s.reduce((e,t)=>{let s=t.GROUP;return"string"==typeof s&&s!==ex.SKIPPED&&(e[s]=[]),e},{}),p=i.map((e,t)=>{let u=void 0===a[t]&&void 0===r[t]?function(e){var t,s;let i,n;if(!(e instanceof RegExp)||""!==e.flags)return;try{i=et(e)}catch(e){return}if(1!==i.value.value.length||1!==i.value.value[0].value.length)return;let a=i.value.value[0].value[0];for(;"Group"===a.type;){if(a.capturing||void 0!==a.quantifier&&void 0!==n||1!==a.value.value.length||1!==a.value.value[0].value.length)return;n=null!=(t=a.quantifier)?t:n,a=a.value.value[0].value[0]}if("Set"!==a.type||a.complement||void 0!==a.quantifier&&void 0!==n||(null==(n=null!=(s=a.quantifier)?s:n)?void 0:n.atLeast)!==1||n.atMost!==1/0||!n.greedy)return;let r=new Uint8Array(128);for(let e of a.value){let t="number"==typeof e?e:e.from,s="number"==typeof e?e:e.to;if(t<0||s>=r.length)return;r.fill(1,t,s+1)}return r}(s[t].PATTERN):void 0;return{pattern:i[t],asciiClass:u,longerAlt:r[t],canLineTerminator:c[t],matchType:void 0!==u?3:!1!==d[t]?0:h[t]?1:2,short:d[t],group:a[t],push:o[t],pop:l[t],tokenTypeIdx:n[t],tokenType:s[t]}})});let E=!0,T=[];return t.safeMode||f("First Char Optimization",()=>{T=s.reduce((e,s,i)=>{if("string"==typeof s.PATTERN)ey(e,eS(s.PATTERN.charCodeAt(0)),p[i]);else if(Array.isArray(s.START_CHARS_HINT)){let t;s.START_CHARS_HINT.forEach(s=>{let n=eS("string"==typeof s?s.charCodeAt(0):s);t!==n&&(t=n,ey(e,n,p[i]))})}else if(s.PATTERN instanceof RegExp)if(s.PATTERN.unicode)E=!1,t.ensureOptimizations&&J(`${ei} Unable to analyze < ${s.PATTERN.toString()} > pattern.
12
+ The regexp unicode flag is not currently supported by the regexp-to-ast library.
13
+ This will disable the lexer's first char optimizations.
14
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let n=function(e,t=!1){try{let t=et(e);return function e(t,s,i){switch(t.type){case"Disjunction":for(let n=0;n<t.value.length;n++)e(t.value[n],s,i);break;case"Alternative":let n=t.value;for(let t=0;t<n.length;t++){let a=n[t];switch(a.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}switch(a.type){case"Character":en(a.value,s,i);break;case"Set":if(!0===a.complement)throw Error(es);a.value.forEach(e=>{if("number"==typeof e)en(e,s,i);else if(!0===i)for(let t=e.from;t<=e.to;t++)en(t,s,i);else{for(let t=e.from;t<=e.to&&t<256;t++)en(t,s,i);if(e.to>=256){let t=e.from>=256?e.from:256,i=e.to,n=eS(t),a=eS(i);for(let e=n;e<=a;e++)s[e]=e}}});break;case"Group":e(a.value,s,i);break;default:throw Error("Non Exhaustive Match")}let r=void 0!==a.quantifier&&0===a.quantifier.atLeast;if("Group"===a.type&&!1===function e(t){let s=t.quantifier;return!!s&&0===s.atLeast||!!t.value&&(Array.isArray(t.value)?t.value.every(e):e(t.value))}(a)||"Group"!==a.type&&!1===r)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}(t.value,{},t.flags.ignoreCase)}catch(s){if(s.message===es)t&&Z(`${ei} Unable to optimize: < ${e.toString()} >
15
+ Complement Sets cannot be automatically optimized.
16
+ This will disable the lexer's first char optimizations.
17
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let s="";t&&(s="\n This will disable the lexer's first char optimizations.\n See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),J(`${ei}
18
+ Failed parsing: < ${e.toString()} >
19
+ Using the @chevrotain/regexp-to-ast library
20
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+s)}}return[]}(s.PATTERN,t.ensureOptimizations);0===n.length&&(E=!1),n.forEach(t=>{ey(e,t,p[i])})}else t.ensureOptimizations&&J(`${ei} TokenType: <${s.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
21
+ This will disable the lexer's first char optimizations.
22
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return e},[])}),{emptyGroups:u,patternIdxToConfig:p,charCodeToPatternIdxToConfig:T,hasCustom:m,canBeOptimized:E}}(s,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[e]=i.patternIdxToConfig,this.charCodeToPatternIdxToConfig[e]=i.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,i.emptyGroups),this.hasCustom=i.hasCustom||this.hasCustom,this.canModeBeOptimized[e]=i.canBeOptimized}})}),this.defaultMode=s.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling)throw Error("Errors detected in definition of Lexer:\n"+this.lexerDefinitionErrors.map(e=>e.message).join("-----------------------\n"));this.lexerDefinitionWarning.forEach(e=>{Z(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(n&&(this.handleModes=()=>{}),!1===this.trackStartLines&&(this.computeNewColumn=e=>e),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{let e=Object.entries(this.canModeBeOptimized).reduce((e,[t,s])=>(!1===s&&e.push(t),e),[]);if(t.ensureOptimizations&&e.length>0)throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.
23
+ Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
24
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Q={}}),this.TRACE_INIT("toFastProperties",()=>{E(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0)throw Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+this.lexerDefinitionErrors.map(e=>e.message).join("-----------------------\n"));return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let s,i,n,a,r,o,l,c,h,d,u,p,f,m,E,T,g=e.length,y=0,A=0,S=Array(this.hasCustom?0:Math.floor(e.length/10)),L=[],O=this.trackStartLines?1:void 0,R=this.trackStartLines?1:void 0,k={};for(let e=0;e<this.cachedGroupKeys.length;e++)k[this.cachedGroupKeys[e]]=[];let I=this.trackStartLines,N=this.config.lineTerminatorsPattern,b=0,C=[],_=[],v=[],x=[];Object.freeze(x);let U=!1,M=e=>{if(1===v.length&&void 0===e.tokenType.PUSH_MODE){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);L.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{v.pop();let e=v.at(-1);C=this.patternIdxToConfig[e],_=this.charCodeToPatternIdxToConfig[e],b=C.length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;U=!!_&&!!t}};function w(e){v.push(e),_=this.charCodeToPatternIdxToConfig[e],b=(C=this.patternIdxToConfig[e]).length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;U=!!_&&!!t}w.call(this,t);let P=this.config.recoveryEnabled;for(;y<g;){let t;o=null,h=-1;let D=e.charCodeAt(y);if(U){let e=_[eS(D)];t=void 0!==e?e:x}else t=C;let $=t.length;for(s=0;s<$;s++){let i=(T=t[s]).pattern;switch(l=null,T.matchType){case 0:D===T.short&&(h=1,o=i);break;case 1:null!==(E=i.exec(e,y,S,k))?(h=(o=E[0]).length,void 0!==E.payload&&(l=E.payload)):o=null;break;case 3:{let t=T.asciiClass;if(1!==t[D]){i.lastIndex=0;break}let s=y+1;for(;1===t[e.charCodeAt(s)];)s++;h=s-y,i.lastIndex=s;break}case 2:i.lastIndex=y,h=this.matchLength(i,e,y)}if(-1!==h){if(void 0!==(r=T.longerAlt)){o=e.substring(y,y+h);let t=r.length;for(n=0;n<t;n++){let t=C[r[n]],s=t.pattern;if(c=null,1===t.matchType?null!==(E=s.exec(e,y,S,k))?(a=E[0],void 0!==E.payload&&(c=E.payload)):a=null:(s.lastIndex=y,a=this.match(s,e,y)),a&&a.length>o.length){o=a,h=a.length,l=c,T=t;break}}}break}}if(-1!==h){if(void 0!==(d=T.group)&&(o=null!==o?o:e.substring(y,y+h),u=T.tokenTypeIdx,p=this.createTokenInstance(o,y,u,T.tokenType,O,R,h),this.handlePayload(p,l),!1===d?A=this.addToken(S,A,p):k[d].push(p)),!0===I&&!0===T.canLineTerminator){let t,s,i=0;N.lastIndex=0;do o=null!==o?o:e.substring(y,y+h),!0===(t=N.test(o))&&(s=N.lastIndex-1,i++);while(!0===t);0!==i?(O+=i,R=h-s,this.updateTokenEndLineColumnLocation(p,d,s,i,O,R,h)):R=this.computeNewColumn(R,h)}else R=this.computeNewColumn(R,h);y+=h,this.handleModes(T,M,w,p)}else{let t=y,s=O,n=R,a=!1===P;for(;!1===a&&y<g;)for(y++,i=0;i<b;i++){let t=C[i],s=t.pattern;switch(t.matchType){case 0:e.charCodeAt(y)===t.short&&(a=!0);break;case 1:a=null!==s.exec(e,y,S,k);break;case 3:case 2:s.lastIndex=y,a=null!==s.exec(e)}if(!0===a)break}if(f=y-t,R=this.computeNewColumn(R,f),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(e,t,f,s,n,v.at(-1)),L.push({offset:t,line:s,column:n,length:f,message:m}),!1===P)break}}return this.hasCustom||(S.length=A),{tokens:S,groups:k,errors:L}}handleModes(e,t,s,i){if(!0===e.pop){let n=e.push;t(i),void 0!==n&&s.call(this,n)}else void 0!==e.push&&s.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,s,i,n,a,r){let o,l;void 0!==t&&(l=(o=s===r-1)?-1:0,(1!==i||!0!==o)&&(e.endLine=n+l,e.endColumn=a-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,s,i){return{image:e,startOffset:t,tokenTypeIdx:s,tokenType:i}}createStartOnlyToken(e,t,s,i,n,a){return{image:e,startOffset:t,startLine:n,startColumn:a,tokenTypeIdx:s,tokenType:i}}createFullToken(e,t,s,i,n,a,r){return{image:e,startOffset:t,endOffset:t+r-1,startLine:n,endLine:n,startColumn:a,endColumn:a+r-1,tokenTypeIdx:s,tokenType:i}}addTokenUsingPush(e,t,s){return e.push(s),t}addTokenUsingMemberAccess(e,t,s){return e[t]=s,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}match(e,t,s){return!0===e.test(t)?t.substring(s,e.lastIndex):null}matchLength(e,t,s){return!0===e.test(t)?e.lastIndex-s:-1}}function eU(e){return eM(e)?e.LABEL:e.name}function eM(e){return"string"==typeof e.LABEL&&""!==e.LABEL}ex.SKIPPED="This marks a skipped Token pattern, this means each token identified by it will be consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",ex.NA=/NOT_APPLICABLE/;let ew="categories",eP="label",eD="group",e$="push_mode",eK="pop_mode",eF="longer_alt",eB="line_breaks",ej="start_chars_hint";function eG(e){let t=e.pattern,s={};if(s.name=e.name,void 0!==t&&(s.PATTERN=t),Object.hasOwn(e,"parent"))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";return Object.hasOwn(e,ew)&&(s.CATEGORIES=e[ew]),eN([s]),Object.hasOwn(e,eP)&&(s.LABEL=e[eP]),Object.hasOwn(e,eD)&&(s.GROUP=e[eD]),Object.hasOwn(e,eK)&&(s.POP_MODE=e[eK]),Object.hasOwn(e,e$)&&(s.PUSH_MODE=e[e$]),Object.hasOwn(e,eF)&&(s.LONGER_ALT=e[eF]),Object.hasOwn(e,eB)&&(s.LINE_BREAKS=e[eB]),Object.hasOwn(e,ej)&&(s.START_CHARS_HINT=e[ej]),s}let eW=eG({name:"EOF",pattern:ex.NA});function eV(e,t,s,i,n,a,r,o){return{image:t,startOffset:s,endOffset:i,startLine:n,endLine:a,startColumn:r,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}eN([eW]);let ez={buildMismatchTokenMessage({expected:e,actual:t,previous:s,ruleName:i}){let n=eM(e)?`--> ${eU(e)} <--`:`token of type --> ${e.name} <--`;return`Expecting ${n} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:s,customUserDescription:i,ruleName:n}){let a="Expecting: ",r="\nbut found: '"+t[0].image+"'";if(i)return a+i+r;{let t=e.reduce((e,t)=>e.concat(t),[]).map(e=>`[${e.map(e=>eU(e)).join(", ")}]`).map((e,t)=>` ${t+1}. ${e}`);return a+`one of these possible Token sequences:
25
+ ${t.join("\n")}`+r}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:s,ruleName:i}){let n="Expecting: ",a="\nbut found: '"+t[0].image+"'";if(s)return n+s+a;{let t=e.map(e=>`[${e.map(e=>eU(e)).join(",")}]`);return n+`expecting at least one iteration which starts with one of these possible Token sequences::
26
+ <${t.join(" ,")}>`+a}}};Object.freeze(ez);let eH={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},eY={buildDuplicateFoundError(e,t){let s=e.name,i=t[0],n=i.idx,a=v(i),r=i instanceof N?i.terminalType.name:i instanceof g?i.nonTerminalName:"",o=`->${a}${n>0?n:""}<- ${r?`with argument: ->${r}<-`:""}
27
+ appears more than once (${t.length} times) in the top level rule: ->${s}<-.
28
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
29
+ `;return(o=o.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.
30
+ The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
31
+ To resolve this make sure each Terminal and Non-Terminal names are unique
32
+ This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
33
+ and Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){let t=e.prefixPath.map(e=>eU(e)).join(", "),s=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
34
+ in <OR${s}> inside <${e.topLevelRule.name}> Rule,
35
+ <${t}> may appears as a prefix path in all these alternatives.
36
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
37
+ For Further details.`},buildAlternationAmbiguityError(e){let t=0===e.alternation.idx?"":e.alternation.idx,s=0===e.prefixPath.length,i=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,
38
+ `;if(s)i+=`These alternatives are all empty (match no tokens), making them indistinguishable.
39
+ Only the last alternative may be empty.
40
+ `;else{let t=e.prefixPath.map(e=>eU(e)).join(", ");i+=`<${t}> may appears as a prefix path in all these alternatives.
41
+ `}return i+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
42
+ For Further details.`},buildEmptyRepetitionError(e){let t=v(e.repetition);return 0!==e.repetition.idx&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
43
+ This could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
44
+ Only the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:
45
+ <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
46
+ has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){let t=e.topLevelRule.name,s=e.leftRecursionPath.map(e=>e.name),i=`${t} --> ${s.concat([t]).join(" --\x3e ")}`;return`Left Recursion found in grammar.
47
+ rule: <${t}> can be invoked from itself (directly or indirectly)
48
+ without consuming any Tokens. The grammar path that causes this is:
49
+ ${i}
50
+ To fix this refactor your grammar to remove the left recursion.
51
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof y?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class eX extends C{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:r.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class eq extends x{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,s){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=t.concat(s);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){0===this.ruleStack.length?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class eJ extends eq{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,s){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new A({definition:t.concat(s)});this.possibleTokTypes=M(e),this.found=!0}}}class eZ extends x{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class eQ extends eZ{walkMany(e,t,s){if(e.idx===this.occurrence){let e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,s)}}class e0 extends eZ{walkManySep(e,t,s){if(e.idx===this.occurrence){let e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,s)}}class e1 extends eZ{walkAtLeastOne(e,t,s){if(e.idx===this.occurrence){let e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,s)}}class e2 extends eZ{walkAtLeastOneSep(e,t,s){if(e.idx===this.occurrence){let e=t.concat(s)[0];this.result.isEndOfRule=void 0===e,e instanceof N&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,s)}}function e3(e,t,s=[]){s=[...s];let i=[],n=0;function a(a){let r=e3(a.concat(e.slice(n+1)),t,s);return i.concat(r)}for(;s.length<t&&n<e.length;){let t=e[n];if(t instanceof A)return a(t.definition);if(t instanceof g)return a(t.definition);if(t instanceof S)i=a(t.definition);else if(t instanceof L)return a(t.definition.concat([new R({definition:t.definition})]));else if(t instanceof O)return a([new A({definition:t.definition}),new R({definition:[new N({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof k)i=a(t.definition.concat([new R({definition:[new N({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof R)i=a(t.definition.concat([new R({definition:t.definition})]));else if(t instanceof I)return t.definition.forEach(e=>{0!==e.definition.length&&(i=a(e.definition))}),i;else if(t instanceof N)s.push(t.terminalType);else throw Error("non exhaustive match");n++}return i.push({partialPath:s,suffixDef:e.slice(n)}),i}function e5(e){if(e instanceof S||"Option"===e)return n.OPTION;if(e instanceof R||"Repetition"===e)return n.REPETITION;if(e instanceof L||"RepetitionMandatory"===e)return n.REPETITION_MANDATORY;if(e instanceof O||"RepetitionMandatoryWithSeparator"===e)return n.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof k||"RepetitionWithSeparator"===e)return n.REPETITION_WITH_SEPARATOR;else if(e instanceof I||"Alternation"===e)return n.ALTERNATION;else throw Error("non exhaustive match")}function e6(e,t,s,i){let n=e.length,a=e.every(e=>e.every(e=>1===e.length));if(t)return function(t){let i=t.map(e=>e.GATE);for(let t=0;t<n;t++){let n=e[t],a=n.length,r=i[t];if(void 0===r||!1!==r.call(this))e:for(let e=0;e<a;e++){let i=n[e],a=i.length;for(let e=0;e<a;e++)if(!1===s(this.LA_FAST(e+1),i[e]))continue e;return t}}};if(!a||i)return function(){for(let t=0;t<n;t++){let i=e[t],n=i.length;e:for(let e=0;e<n;e++){let n=i[e],a=n.length;for(let e=0;e<a;e++)if(!1===s(this.LA_FAST(e+1),n[e]))continue e;return t}}};{let t=e.map(e=>e.flat()).reduce((e,t,s)=>(t.forEach(t=>{t.tokenTypeIdx in e||(e[t.tokenTypeIdx]=s),t.categoryMatches.forEach(t=>{Object.hasOwn(e,t)||(e[t]=s)})}),e),{});return function(){return t[this.LA_FAST(1).tokenTypeIdx]}}}function e8(e,t,s){let i=e.every(e=>1===e.length),n=e.length;if(!i||s)return function(){e:for(let s=0;s<n;s++){let i=e[s],n=i.length;for(let e=0;e<n;e++)if(!1===t(this.LA_FAST(e+1),i[e]))continue e;return!0}return!1};{let t=e.flat();if(1===t.length&&0===t[0].categoryMatches.length){let e=t[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===e}}{let e=t.reduce((e,t,s)=>(e[t.tokenTypeIdx]=!0,t.categoryMatches.forEach(t=>{e[t]=!0}),e),[]);return function(){return!0===e[this.LA_FAST(1).tokenTypeIdx]}}}}!function(e){e[e.OPTION=0]="OPTION",e[e.REPETITION=1]="REPETITION",e[e.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",e[e.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",e[e.ALTERNATION=5]="ALTERNATION"}(n||(n={}));class e4 extends x{constructor(e,t,s){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=s}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,s,i){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=s.concat(i),!0)}walkOption(e,t,s){this.checkIsTarget(e,n.OPTION,t,s)||super.walkOption(e,t,s)}walkAtLeastOne(e,t,s){this.checkIsTarget(e,n.REPETITION_MANDATORY,t,s)||super.walkOption(e,t,s)}walkAtLeastOneSep(e,t,s){this.checkIsTarget(e,n.REPETITION_MANDATORY_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}walkMany(e,t,s){this.checkIsTarget(e,n.REPETITION,t,s)||super.walkOption(e,t,s)}walkManySep(e,t,s){this.checkIsTarget(e,n.REPETITION_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}}class e7 extends C{constructor(e,t,s){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=s,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(void 0===this.targetRef||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,n.OPTION)}visitRepetition(e){this.checkIsTarget(e,n.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,n.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,n.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,n.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,n.ALTERNATION)}}function e9(e){let t=Array(e);for(let s=0;s<e;s++)t[s]=[];return t}function te(e){let t=[""];for(let s=0;s<e.length;s++){let i=e[s],n=[];for(let e=0;e<t.length;e++){let s=t[e];n.push(s+"_"+i.tokenTypeIdx);for(let e=0;e<i.categoryMatches.length;e++){let t="_"+i.categoryMatches[e];n.push(s+t)}}t=n}return t}function tt(e,t){let s=e.map(e=>e3([e],1)),i=e9(s.length),n=s.map(e=>{let t={};return e.forEach(e=>{te(e.partialPath).forEach(e=>{t[e]=!0})}),t}),a=s;for(let e=1;e<=t;e++){let s=a;a=e9(s.length);for(let r=0;r<s.length;r++){let o=s[r];for(let s=0;s<o.length;s++){let l=o[s].partialPath,c=o[s].suffixDef,h=te(l);if(function(e,t,s){for(let i=0;i<e.length;i++){if(i===s)continue;let n=e[i];for(let e=0;e<t.length;e++)if(!0===n[t[e]])return!1}return!0}(n,h,r)||0===c.length||l.length===t){let e=i[r];if(!1===tn(e,l)){e.push(l);for(let e=0;e<h.length;e++){let t=h[e];n[r][t]=!0}}}else{let t=e3(c,e+1,l);a[r]=a[r].concat(t),t.forEach(e=>{te(e.partialPath).forEach(e=>{n[r][e]=!0})})}}}}return i}function ts(e,t,s,i){let a=new e7(e,n.ALTERNATION,i);return t.accept(a),tt(a.result,s)}function ti(e,t,s,i){let n=new e7(e,s);t.accept(n);let a=n.result,r=new e4(t,e,s).startWalking();return tt([new A({definition:a}),new A({definition:r})],i)}function tn(e,t){t:for(let s=0;s<e.length;s++){let i=e[s];if(i.length===t.length){for(let e=0;e<i.length;e++){let s=t[e],n=i[e];if(!1==(s===n||void 0!==n.categoryMatchesMap[s.tokenTypeIdx]))continue t}return!0}}return!1}function ta(e){return e.every(e=>e.every(e=>e.every(e=>0===e.categoryMatches.length)))}function tr(e){return`${v(e)}_#_${e.idx}_#_${to(e)}`}function to(e){return e instanceof N?e.terminalType.name:e instanceof g?e.nonTerminalName:""}class tl extends C{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}class tc extends C{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}class th extends C{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}let td="MismatchedTokenException",tu="NoViableAltException",tp="EarlyExitException",tf="NotAllInputParsedException",tm=[td,tu,tp,tf];function tE(e){return tm.includes(e.name)}Object.freeze(tm);class tT extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class tg extends tT{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=td}}class ty extends tT{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=tu}}class tA extends tT{constructor(e,t){super(e,t),this.name=tf}}class tS extends tT{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=tp}}let tL={},tO="InRuleRecoveryException";class tR extends Error{constructor(e){super(e),this.name=tO}}class tk{initRecoverable(e){this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:tJ.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=tI)}getTokenToInsert(e){let t=eV(e,"",-1,-1,-1,-1,-1,-1);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,s,i){let n=this.findReSyncTokenType(),a=this.exportLexerState(),r=[],o=!1,l=this.LA_FAST(1),c=this.LA_FAST(1),h=()=>{let e=this.LA(0),t=new tg(this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:e,ruleName:this.getCurrRuleFullName()}),l,this.LA(0));t.resyncedTokens=r.slice(0,-1),this.SAVE_ERROR(t)};for(;!o;)if(this.tokenMatcher(c,i))return void h();else if(s.call(this)){h(),e.apply(this,t);return}else this.tokenMatcher(c,n)?o=!0:(c=this.SKIP_TOKEN(),this.addToResyncTokens(c,r));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,s){return!(!1===s||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getNextPossibleTokenTypes(e){let t=e.ruleStack[0];return new eJ(this.getGAstProductions()[t],e).startWalking()}getFollowsForInRuleRecovery(e,t){let s=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(s)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new tR("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||0===t.length)return!1;let s=this.LA_FAST(1);return void 0!==t.find(e=>this.tokenMatcher(s,e))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),s=2;for(;;){let i=e.find(e=>eO(t,e));if(void 0!==i)return i;t=this.LA(s),s++}}getCurrFollowKey(){if(0===this.RULE_STACK_IDX)return tL;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),s=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(s)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,s=this.RULE_STACK_IDX+1,i=Array(s);for(let n=0;n<s;n++)0===n?i[n]=tL:i[n]={ruleName:this.shortRuleNameToFullName(e[n]),idxInCallingRule:t[n],inRule:this.shortRuleNameToFullName(e[n-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map(e=>this.getFollowSetFromFollowKey(e)).flat()}getFollowSetFromFollowKey(e){if(e===tL)return[eW];let t=e.ruleName+e.idxInCallingRule+w+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,eW)||t.push(e),t}reSyncTo(e){let t=[],s=this.LA_FAST(1);for(;!1===this.tokenMatcher(s,e);)s=this.SKIP_TOKEN(),this.addToResyncTokens(s,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,s,i,n,a,r){}getCurrentGrammarPath(e,t){let s=this.getHumanReadableRuleStack();return{ruleStack:s,occurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=Array(e);for(let s=0;s<e;s++)t[s]=this.shortRuleNameToFullName(this.RULE_STACK[s]);return t}}function tI(e,t,s,i,n,a,r){var o,l,c;let h=i|n,d=null!=(o=(l=this.firstAfterRepMap)[c=this.currRuleShortName])?o:l[c]=[],u=d[h];if(void 0===u){let e=this.getCurrRuleFullName();u=new a(this.getGAstProductions()[e],n).startWalking(),d[h]=u}let p=u.token,f=u.occurrence,m=u.isEndOfRule;0===this.RULE_STACK_IDX&&m&&void 0===p&&(p=eW,f=1),void 0!==p&&void 0!==f&&this.shouldInRepetitionRecoveryBeTried(p,f,r)&&this.tryInRepetitionRecovery(e,t,s,p)}class tN{constructor(e){var t;this.maxLookahead=null!=(t=null==e?void 0:e.maxLookahead)?t:tJ.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(0===t.length){let s=this.validateEmptyOrAlternatives(e.rules);return[...t,...s,...this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),...this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead)]}return t}validateNoLeftRecursion(e){return e.flatMap(e=>(function e(t,s,i,n=[]){let a=[],o=function e(t){let s=[];if(0===t.length)return s;let i=t[0];if(i instanceof g)s.push(i.referencedRule);else if(i instanceof A||i instanceof S||i instanceof L||i instanceof O||i instanceof k||i instanceof R)s=s.concat(e(i.definition));else if(i instanceof I)s=i.definition.map(t=>e(t.definition)).flat();else if(i instanceof N);else throw Error("non exhaustive match");let n=_(i),a=t.length>1;if(!n||!a)return s;{let i=t.slice(1);return s.concat(e(i))}}(s.definition);if(0===o.length)return[];{let s=t.name;o.includes(t)&&a.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:r.LEFT_RECURSION,ruleName:s});let l=n.concat([t]),c=o.filter(e=>!l.includes(e)).flatMap(s=>{let a=[...n];return a.push(s),e(t,s,i,a)});return a.concat(c)}})(e,e,eY))}validateEmptyOrAlternatives(e){return e.flatMap(e=>(function(e,t){let s=new tc;return e.accept(s),s.alternations.flatMap(s=>s.definition.slice(0,-1).flatMap((i,n)=>0===function(e,t,s,i){let n="EXIT_NONE_TERMINAL",a=[n],r="EXIT_ALTERNATIVE",o=!1,l=t.length,c=l-1-1,h=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});0!==d.length;){let e=d.pop();if(e===r){o&&d.at(-1).idx<=c&&d.pop();continue}let i=e.def,u=e.idx,p=e.ruleStack,f=e.occurrenceStack;if(0===i.length)continue;let m=i[0];if(m===n){let e={idx:u,def:i.slice(1),ruleStack:p.slice(0,-1),occurrenceStack:f.slice(0,-1)};d.push(e)}else if(m instanceof N)if(u<l-1){let e=u+1;if(s(t[e],m.terminalType)){let t={idx:e,def:i.slice(1),ruleStack:p,occurrenceStack:f};d.push(t)}}else if(u===l-1)h.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:p,occurrenceStack:f}),o=!0;else throw Error("non exhaustive match");else if(m instanceof g){let e=[...p];e.push(m.nonTerminalName);let t=[...f];t.push(m.idx);let s={idx:u,def:m.definition.concat(a,i.slice(1)),ruleStack:e,occurrenceStack:t};d.push(s)}else if(m instanceof S){let e={idx:u,def:i.slice(1),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t={idx:u,def:m.definition.concat(i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof L){let e=new R({definition:m.definition,idx:m.idx}),t={idx:u,def:m.definition.concat([e],i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof O){let e=new R({definition:[new N({terminalType:m.separator})].concat(m.definition),idx:m.idx}),t={idx:u,def:m.definition.concat([e],i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof k){let e={idx:u,def:i.slice(1),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t=new R({definition:[new N({terminalType:m.separator})].concat(m.definition),idx:m.idx}),s={idx:u,def:m.definition.concat([t],i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(s)}else if(m instanceof R){let e={idx:u,def:i.slice(1),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t=new R({definition:m.definition,idx:m.idx}),s={idx:u,def:m.definition.concat([t],i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(s)}else if(m instanceof I)for(let e=m.definition.length-1;e>=0;e--){let t={idx:u,def:m.definition[e].definition.concat(i.slice(1)),ruleStack:p,occurrenceStack:f};d.push(t),d.push(r)}else if(m instanceof A)d.push({idx:u,def:m.definition.concat(i.slice(1)),ruleStack:p,occurrenceStack:f});else if(m instanceof y)d.push(function(e,t,s,i){let n=[...s];n.push(e.name);let a=[...i];return a.push(1),{idx:t,def:e.definition,ruleStack:n,occurrenceStack:a}}(m,u,p,f));else throw Error("non exhaustive match")}return h}([i],[],eO,0).length?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:s,emptyChoiceIdx:n}),type:r.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:s.idx,alternative:n+1}]:[]))})(e,eY))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(e=>(function(e,t,s){let i=new tc;e.accept(i);let n=i.alternations;return(n=n.filter(e=>!0!==e.ignoreAmbiguities)).flatMap(i=>{let n=ts(i.idx,e,i.maxLookahead||t,i),a=function(e,t,s,i){let n=[];return e.reduce((s,i,a)=>(!0===t.definition[a].ignoreAmbiguities||i.forEach(i=>{let r=[a];e.forEach((e,s)=>{a!==s&&tn(e,i)&&!0!==t.definition[s].ignoreAmbiguities&&r.push(s)}),r.length>1&&!tn(n,i)&&(n.push(i),s.push({alts:r,path:i}))}),s),[]).map(e=>{let n=e.alts.map(e=>e+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:s,alternation:t,ambiguityIndices:n,prefixPath:e.path}),type:r.AMBIGUOUS_ALTS,ruleName:s.name,occurrence:t.idx,alternatives:e.alts}})}(n,i,e,s),o=function(e,t,s,i){let n=e.reduce((e,t,s)=>{let i=t.map(e=>({idx:s,path:e}));return e.concat(i)},[]);return n.flatMap(e=>{if(!0===t.definition[e.idx].ignoreAmbiguities)return[];let a=e.idx,o=e.path;return n.filter(e=>{var s;return!0!==t.definition[e.idx].ignoreAmbiguities&&e.idx<a&&(s=e.path,s.length<o.length&&s.every((e,t)=>{let s=o[t];return e===s||s.categoryMatchesMap[e.tokenTypeIdx]}))}).map(e=>{let n=[e.idx+1,a+1],o=0===t.idx?"":t.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:s,alternation:t,ambiguityIndices:n,prefixPath:e.path}),type:r.AMBIGUOUS_PREFIX_ALTS,ruleName:s.name,occurrence:o,alternatives:n}})})}(n,i,e,s);return a.concat(o)})})(e,t,eY))}validateSomeNonEmptyLookaheadPath(e,t){let s=[];return e.forEach(e=>{let i=new th;e.accept(i),i.allProductions.forEach(i=>{let n=e5(i),a=i.maxLookahead||t;if(0===ti(i.idx,e,n,a)[0].flat().length){let t=eY.buildEmptyRepetitionError({topLevelRule:e,repetition:i});s.push({message:t,type:r.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),s}buildLookaheadForAlternation(e){return function(e,t,s,i,n,a){let r=ts(e,t,s),o=ta(r)?eR:eO;return a(r,i,o,n)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,e6)}buildLookaheadForOptional(e){return function(e,t,s,i,n,a){let r=ti(e,t,n,s),o=ta(r)?eR:eO;return a(r[0],o,i)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,e5(e.prodType),e8)}}class tb{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:tJ.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:tJ.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new tN({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach(e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:s,option:i,repetitionMandatory:n,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:r}=function(e){t_.reset(),e.accept(t_);let t=t_.dslMethods;return t_.reset(),t}(e);t.forEach(t=>{let s=0===t.idx?"":t.idx;this.TRACE_INIT(`${v(t)}${s}`,()=>{let s=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[e.name],256|t.idx,s)})}),s.forEach(t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,v(t))}),i.forEach(t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,v(t))}),n.forEach(t=>{this.computeLookaheadFunc(e,t.idx,1024,"RepetitionMandatory",t.maxLookahead,v(t))}),a.forEach(t=>{this.computeLookaheadFunc(e,t.idx,1536,"RepetitionMandatoryWithSeparator",t.maxLookahead,v(t))}),r.forEach(t=>{this.computeLookaheadFunc(e,t.idx,1280,"RepetitionWithSeparator",t.maxLookahead,v(t))})})})}computeLookaheadFunc(e,t,s,i,n,a){this.TRACE_INIT(`${a}${0===t?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:n||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],s|t,a)})}setLaFuncCache(e,t,s){let i=this.lookAheadFuncsCache[e];void 0===i&&(i=[],this.lookAheadFuncsCache[e]=i),i[t]=s}}class tC extends C{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}}let t_=new tC;function tv(e,t){-1===e.startOffset?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function tx(e,t){-1===e.startOffset?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function tU(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function tM(e,t){let s=Object.keys(e),i=s.length;for(let n=0;n<i;n++){let i=e[s[n]],a=i.length;for(let e=0;e<a;e++){let s=i[e];void 0===s.tokenTypeIdx&&this[s.name](s.children,t)}}}!function(e){e[e.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",e[e.MISSING_METHOD=1]="MISSING_METHOD"}(a||(a={}));class tw{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,"nodeLocationTracking")?e.nodeLocationTracking:tJ.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=tx,this.setNodeLocationFromNode=tx,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=tv,this.setNodeLocationFromNode=tv,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);else this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{}}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),s=e.location;-1!==s.startOffset&&s.startOffset<=t.startOffset==!0?(s.endOffset=t.endOffset,s.endLine=t.endLine,s.endColumn=t.endColumn):(s.startOffset=-1,s.startLine=-1,s.startColumn=-1)}cstPostRuleOnlyOffset(e){let t=this.LA(0),s=e.location;-1!==s.startOffset&&s.startOffset<=t.startOffset==!0?s.endOffset=t.endOffset:s.startOffset=-1}cstPostTerminal(e,t){let s=this.CST_STACK[this.CST_STACK.length-1];void 0===s.children[e]?s.children[e]=[t]:s.children[e].push(t),this.setNodeLocationFromToken(s.location,t)}cstPostNonTerminal(e,t){let s=this.CST_STACK[this.CST_STACK.length-1];void 0===s.children[t]?s.children[t]=[e]:s.children[t].push(e),this.setNodeLocationFromNode(s.location,e.location)}get currCSTNode(){return this.CST_STACK[this.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(void 0===this.baseCstVisitorConstructor){let e=function(e,t){let s=function(){};return tU(s,e+"BaseSemantics"),s.prototype={visit:function(e,t){if(Array.isArray(e)&&(e=e[0]),void 0!==e)return this[e.name](e.children,t)},validateVisitor:function(){var e,s,i;let n=(e=this,s=t,i=e,s.filter(e=>"function"==typeof i[e]==!1).map(e=>({msg:`Missing visitor method: <${e}> on ${i.constructor.name} CST Visitor.`,type:a.MISSING_METHOD,methodName:e})).filter(Boolean));if(0!==n.length){let e=n.map(e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
52
+ ${e.join("\n\n").replace(/\n/g,"\n ")}`)}}},s.prototype.constructor=s,s._RULE_NAMES=t,s}(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(void 0===this.baseCstVisitorWithDefaultsConstructor){let e=function(e,t,s){let i=function(){};tU(i,e+"BaseSemanticsWithDefaults");let n=Object.create(s.prototype);return t.forEach(e=>{n[e]=tM}),i.prototype=n,i.prototype.constructor=i,i}(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}}class tP{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):tq}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?tq:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}}class tD{ACTION(e){return e.call(this)}consume(e,t,s){return this.consumeInternal(t,e,s)}subrule(e,t,s){return this.subruleInternal(t,e,s)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,s=tZ){if(this.definedRulesNames.includes(e)){let t={message:eY.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:r.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let i=this.defineRule(e,t,s);return this[e]=i,i}OVERRIDE_RULE(e,t,s=tZ){let i=function(e,t,s){let i=[];return t.includes(e)||i.push({message:`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${s}<-as it is not defined in any of the super grammars `,type:r.INVALID_RULE_OVERRIDE,ruleName:e}),i}(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);let n=this.defineRule(e,t,s);return this[e]=n,n}BACKTRACK(e,t){var s;let i=null!=(s=e.coreRule)?s:e;return function(){this.isBackTrackingStack.push(1);let e=this.saveRecogState();try{return i.apply(this,t),!0}catch(e){if(tE(e))return!1;throw e}finally{this.reloadRecogState(e),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Object.values(this.gastProductionsCache).map(function e(t){function s(t){return t.map(e)}if(t instanceof g){let e={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return"string"==typeof t.label&&(e.label=t.label),e}if(t instanceof A)return{type:"Alternative",definition:s(t.definition)};if(t instanceof S)return{type:"Option",idx:t.idx,definition:s(t.definition)};if(t instanceof L)return{type:"RepetitionMandatory",idx:t.idx,definition:s(t.definition)};if(t instanceof O)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:e(new N({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof k)return{type:"RepetitionWithSeparator",idx:t.idx,separator:e(new N({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof R)return{type:"Repetition",idx:t.idx,definition:s(t.definition)};else if(t instanceof I)return{type:"Alternation",idx:t.idx,definition:s(t.definition)};else if(t instanceof N){var i,n;let e={type:"Terminal",name:t.terminalType.name,label:"string"==typeof(n=i=t.terminalType).LABEL&&""!==n.LABEL?i.LABEL:i.name,idx:t.idx};"string"==typeof t.label&&(e.terminalLabel=t.label);let s=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(e.pattern=s instanceof RegExp?s.source:s),e}else if(t instanceof y)return{type:"Rule",name:t.name,orgText:t.orgText,definition:s(t.definition)};else throw Error("non exhaustive match")})}}class t${initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=eR,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n For Further details.");if(Array.isArray(e)){if(0===e.length)throw Error("A Token Vocabulary cannot be empty.\n Note that the first argument for the parser constructor\n is no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n For Further details.")}if(Array.isArray(e))this.tokensMap=e.reduce((e,t)=>(e[t.name]=t,e),{});else if(Object.hasOwn(e,"modes")&&Object.values(e.modes).flat().every(e_)){let t=[...new Set(Object.values(e.modes).flat())];this.tokensMap=t.reduce((e,t)=>(e[t.name]=t,e),{})}else if("object"==typeof e&&null!==e)this.tokensMap=Object.assign({},e);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=eW;let s=(Object.hasOwn(e,"modes")?Object.values(e.modes).flat():Object.values(e)).every(e=>{var t;return(null==(t=e.categoryMatches)?void 0:t.length)==0});this.tokenMatcher=s?eR:eO,eN(Object.values(this.tokensMap))}defineRule(e,t,s){let i;if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
53
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let n=Object.hasOwn(s,"resyncEnabled")?s.resyncEnabled:tZ.resyncEnabled,a=Object.hasOwn(s,"recoveryValueFunc")?s.recoveryValueFunc:tZ.recoveryValueFunc,r=this.ruleShortNameIdx++;return this.shortRuleNameToFull[r]=e,this.fullRuleNameToShort[e]=r,i=!0===this.outputCst?function(...s){try{this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,s);let i=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(i),i}catch(e){return this.invokeRuleCatch(e,n,a)}finally{this.ruleFinallyStateUpdate()}}:function(...s){try{return this.ruleInvocationStateUpdate(r,e,this.subruleIdx),t.apply(this,s)}catch(e){return this.invokeRuleCatch(e,n,a)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...t){this.onBeforeParse(e);try{return i.apply(this,t)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:i})}invokeRuleCatch(e,t,s){let i=0===this.RULE_STACK_IDX,n=t&&!this.isBackTracking()&&this.recoveryEnabled;if(tE(e)){if(n){let t=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(t)){if(e.resyncedTokens=this.reSyncTo(t),!this.outputCst)return s(e);{let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}}if(this.outputCst){let t=this.CST_STACK[this.CST_STACK.length-1];t.recoveredNode=!0,e.partialCstResult=t}throw e}if(i)return this.moveToTerminatedState(),s(e)}throw e}optionInternal(e,t){return this.optionInternalLogic(e,t,512|t)}optionInternalLogic(e,t,s){let i,n=this.currRuleLookaheadFuncs[s];if("function"!=typeof e){i=e.DEF;let t=e.GATE;if(void 0!==t){let e=n;n=()=>t.call(this)&&e.call(this)}}else i=e;if(!0===n.call(this))return i.call(this)}atLeastOneInternal(e,t){return this.atLeastOneInternalLogic(e,t,1024|e)}atLeastOneInternalLogic(e,t,s){let i,a=this.currRuleLookaheadFuncs[s];if("function"!=typeof t){i=t.DEF;let e=t.GATE;if(void 0!==e){let t=a;a=()=>e.call(this)&&t.call(this)}}else i=t;if(!0===a.call(this)){let e=this.doSingleRepetition(i);for(;!0===a.call(this)&&!0===e;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,n.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],a,1024,e,e1)}atLeastOneSepFirstInternal(e,t){this.atLeastOneSepFirstInternalLogic(e,t,1536|e)}atLeastOneSepFirstInternalLogic(e,t,s){let i=t.DEF,a=t.SEP;if(!0===this.currRuleLookaheadFuncs[s].call(this)){i.call(this);let t=()=>this.tokenMatcher(this.LA_FAST(1),a);for(;!0===this.tokenMatcher(this.LA_FAST(1),a);)this.CONSUME(a),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,a,t,i,e2],t,1536,e,e2)}else throw this.raiseEarlyExitException(e,n.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){return this.manyInternalLogic(e,t,768|e)}manyInternalLogic(e,t,s){let i,n=this.currRuleLookaheadFuncs[s];if("function"!=typeof t){i=t.DEF;let e=t.GATE;if(void 0!==e){let t=n;n=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;!0===n.call(this)&&!0===a;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,768,e,eQ,a)}manySepFirstInternal(e,t){this.manySepFirstInternalLogic(e,t,1280|e)}manySepFirstInternalLogic(e,t,s){let i=t.DEF,n=t.SEP;if(!0===this.currRuleLookaheadFuncs[s].call(this)){i.call(this);let t=()=>this.tokenMatcher(this.LA_FAST(1),n);for(;!0===this.tokenMatcher(this.LA_FAST(1),n);)this.CONSUME(n),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,t,i,e0],t,1280,e,e0)}}repetitionSepSecondInternal(e,t,s,i,n){for(;s();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,s,i,n],s,1536,e,n)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let s=256|t,i=Array.isArray(e)?e:e.DEF,n=this.currRuleLookaheadFuncs[s].call(this,i);if(void 0!==n)return i[n].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]),this.cstFinallyStateUpdate()}subruleInternal(e,t,s){let i;try{let n=void 0!==s?s.ARGS:void 0;return this.subruleIdx=t,i=e.coreRule.apply(this,n),this.cstPostNonTerminal(i,void 0!==s&&void 0!==s.LABEL?s.LABEL:e.ruleName),i}catch(t){throw this.subruleInternalError(t,s,e.ruleName)}}subruleInternalError(e,t,s){throw tE(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:s),delete e.partialCstResult),e}consumeInternal(e,t,s){let i;try{let t=this.LA_FAST(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),i=t):this.consumeInternalError(e,t,s)}catch(s){i=this.consumeInternalRecovery(e,t,s)}return this.cstPostTerminal(void 0!==s&&void 0!==s.LABEL?s.LABEL:e.name,i),i}consumeInternalError(e,t,s){let i,n=this.LA(0);throw i=void 0!==s&&s.ERR_MSG?s.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new tg(i,t,n))}consumeInternalRecovery(e,t,s){if(this.recoveryEnabled&&"MismatchedTokenException"===s.name&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(e){if(e.name===tO)throw s;throw e}}throw s}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let e=0;e<t.length;e++)this.RULE_STACK[e]=t[e];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName])}ruleInvocationStateUpdate(e,t,s){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=s,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),eW)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let e=0;e<this.maxLookahead+1;e++)this.tokVector.push(tq)}onAfterParse(e){if(!1===this.isAtEndOfInput()){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new tA(t,e))}for(;this.tokVector.at(-1)===tq;)this.tokVector.pop()}}class tK{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,"errorMessageProvider")?e.errorMessageProvider:tJ.errorMessageProvider}SAVE_ERROR(e){if(tE(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,s){let i=this.getCurrRuleFullName(),n=ti(e,this.getGAstProductions()[i],t,this.maxLookahead)[0],a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let r=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:n,actual:a,previous:this.LA(0),customUserDescription:s,ruleName:i});throw this.SAVE_ERROR(new tS(r,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let s=this.getCurrRuleFullName(),i=ts(e,this.getGAstProductions()[s],this.maxLookahead),n=[];for(let e=1;e<=this.maxLookahead;e++)n.push(this.LA(e));let a=this.LA(0),r=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:n,previous:a,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ty(r,this.LA(1),a))}}let tF={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(tF);let tB=eG({name:"RECORDING_PHASE_TOKEN",pattern:ex.NA});eN([tB]);let tj=eV(tB,"This IToken indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(tj);let tG={name:"This CSTNode indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};class tW{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(t,s){return this.consumeInternalRecord(t,e,s)},this[`SUBRULE${t}`]=function(t,s){return this.subruleInternalRecord(t,e,s)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,s){return this.consumeInternalRecord(t,e,s)},this.subrule=function(e,t,s){return this.subruleInternalRecord(t,e,s)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";delete this[`CONSUME${t}`],delete this[`SUBRULE${t}`],delete this[`OPTION${t}`],delete this[`OR${t}`],delete this[`MANY${t}`],delete this[`MANY_SEP${t}`],delete this[`AT_LEAST_ONE${t}`],delete this[`AT_LEAST_ONE_SEP${t}`]}delete this.consume,delete this.subrule,delete this.option,delete this.or,delete this.many,delete this.atLeastOne,delete this.ACTION,delete this.BACKTRACK,delete this.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return tq}topLevelRuleRecord(e,t){try{let s=new y({definition:[],name:e});return s.name=e,this.recordingProdStack.push(s),t.call(this),this.recordingProdStack.pop(),s}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n This error was thrown during the "grammar recording phase" For more info see:\n https://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(e){}throw e}}optionInternalRecord(e,t){return tV.call(this,S,e,t)}atLeastOneInternalRecord(e,t){tV.call(this,L,t,e)}atLeastOneSepFirstInternalRecord(e,t){tV.call(this,O,t,e,!0)}manyInternalRecord(e,t){tV.call(this,R,t,e)}manySepFirstInternalRecord(e,t){tV.call(this,k,t,e,!0)}orInternalRecord(e,t){return tz.call(this,e,t)}subruleInternalRecord(e,t,s){if(tY(t),!e||!Object.hasOwn(e,"ruleName")){let s=Error(`<SUBRULE${tH(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
54
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=this.recordingProdStack.at(-1),n=new g({idx:t,nonTerminalName:e.ruleName,label:null==s?void 0:s.LABEL,referencedRule:void 0});return i.definition.push(n),this.outputCst?tG:tF}consumeInternalRecord(e,t,s){if(tY(t),!eb(e)){let s=Error(`<CONSUME${tH(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
55
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=this.recordingProdStack.at(-1),n=new N({idx:t,terminalType:e,label:null==s?void 0:s.LABEL});return i.definition.push(n),tj}}function tV(e,t,s,i=!1){tY(s);let n=this.recordingProdStack.at(-1),a="function"==typeof t?t:t.DEF,r=new e({definition:[],idx:s});return i&&(r.separator=t.SEP),Object.hasOwn(t,"MAX_LOOKAHEAD")&&(r.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(r),a.call(this),n.definition.push(r),this.recordingProdStack.pop(),tF}function tz(e,t){tY(t);let s=this.recordingProdStack.at(-1),i=!1===Array.isArray(e),n=!1===i?e:e.DEF,a=new I({definition:[],idx:t,ignoreAmbiguities:i&&!0===e.IGNORE_AMBIGUITIES});return Object.hasOwn(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=n.some(e=>"function"==typeof e.GATE),s.definition.push(a),n.forEach(e=>{let t=new A({definition:[]});a.definition.push(t),Object.hasOwn(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:Object.hasOwn(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),tF}function tH(e){return 0===e?"":`${e}`}function tY(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>
56
+ Idx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}class tX{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let t=e.traceInitPerf,s="number"==typeof t;this.traceInitMaxIdent=s?t:1/0,this.traceInitPerf=s?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=tJ.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let s=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);let{time:i,value:n}=eL(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,n}}}let tq=eV(eW,"",-1,-1,-1,-1,-1,-1);Object.freeze(tq);let tJ=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ez,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),tZ=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});!function(e){e[e.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",e[e.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",e[e.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",e[e.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",e[e.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",e[e.LEFT_RECURSION=5]="LEFT_RECURSION",e[e.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",e[e.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",e[e.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",e[e.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",e[e.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",e[e.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"}(r||(r={}));class tQ{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT("toFastProps",()=>{E(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach(e=>{let t,s=this[e].originalGrammarAction;this.TRACE_INIT(`${e} Rule`,()=>{t=this.topLevelRuleRecord(e,s)}),this.gastProductionsCache[e]=t})}finally{this.disableRecording()}});let s=[];if(this.TRACE_INIT("Grammar Resolving",()=>{s=function(e){let t=Object.assign({errMsgProvider:eH},e),s={};e.rules.forEach(e=>{s[e.name]=e});let i=new eX(s,t.errMsgProvider);return i.resolveRefs(),i.errors}({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(s)}),this.TRACE_INIT("Grammar Validations",()=>{if(0===s.length&&!1===this.skipValidations){var e;let s=function(e){var t;let s=null!=(t=e.errMsgProvider)?t:eY;return function(e,t,s,i){let n=e.flatMap(e=>(function(e,t){let s=new tl;return e.accept(s),Object.values(Object.fromEntries(Object.entries(Object.groupBy(s.allProductions,tr)).filter(([e,t])=>t.length>1))).map(s=>{let i=s[0],n=t.buildDuplicateFoundError(e,s),a=v(i),o={message:n,type:r.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:i.idx},l=to(i);return l&&(o.parameter=l),o})})(e,s)),a=function(e,t,s){let i=[],n=t.map(e=>e.name);return e.forEach(e=>{let t=e.name;if(n.includes(t)){let n=s.buildNamespaceConflictError(e);i.push({message:n,type:r.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),i}(e,t,s),o=e.flatMap(e=>(function(e,t){let s=new tc;return e.accept(s),s.alternations.flatMap(s=>s.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:s}),type:r.TOO_MANY_ALTS,ruleName:e.name,occurrence:s.idx}]:[])})(e,s)),l=e.flatMap(t=>(function(e,t,s,i){let n=[];if(t.reduce((t,s)=>s.name===e.name?t+1:t,0)>1){let t=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:s});n.push({message:t,type:r.DUPLICATE_RULE_NAME,ruleName:e.name})}return n})(t,e,i,s));return n.concat(a,o,l)}(e.rules,e.tokenTypes,s,e.grammarName)}({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:eY,grammarName:t}),i=(e={lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:t}).lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map(e=>Object.assign({type:r.CUSTOM_LOOKAHEAD_VALIDATION},e));this.definitionErrors=this.definitionErrors.concat(s,i)}}),0===this.definitionErrors.length&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{let e=function(e){let t={};return e.forEach(e=>{Object.assign(t,new P(e).startWalking())}),t}(Object.values(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var e,t;null==(t=(e=this.lookaheadStrategy).initialize)||t.call(e,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!tQ.DEFER_DEFINITION_ERRORS_HANDLING&&0!==this.definitionErrors.length)throw e=this.definitionErrors.map(e=>e.message),Error(`Parser Definition Errors detected:
57
+ ${e.join("\n-------------------------------\n")}`)})}constructor(e,t){if(this.definitionErrors=[],this.selfAnalysisDone=!1,this.initErrorHandler(t),this.initLexerAdapter(),this.initLooksAhead(t),this.initRecognizerEngine(e,t),this.initRecoverable(t),this.initTreeBuilder(t),this.initGastRecorder(t),this.initPerformanceTracer(t),Object.hasOwn(t,"ignoredIssues"))throw Error("The <ignoredIssues> IParserConfig property has been deprecated.\n Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n For further details.");this.skipValidations=Object.hasOwn(t,"skipValidations")?t.skipValidations:tJ.skipValidations}}tQ.DEFER_DEFINITION_ERRORS_HANDLING=!1,function(e,t){t.forEach(t=>{let s=t.prototype;Object.getOwnPropertyNames(s).forEach(i=>{if("constructor"===i)return;let n=Object.getOwnPropertyDescriptor(s,i);n&&(n.get||n.set)?Object.defineProperty(e.prototype,i,n):e.prototype[i]=t.prototype[i]})})}(tQ,[tk,tb,tw,tP,t$,tD,tK,tW,tX]);class t0 extends tQ{constructor(e,t=tJ){let s=Object.assign({},t);s.outputCst=!0,super(e,s)}}var t1=s(21930),t2=(0,m.K)(e=>void 0!==e&&e>=0,"isKnownLocation");function t3(e,t){let s=e.lexer.tokenize(t);if(s.errors.length>0){let i=s.errors[0],n=t2(i.offset)?i.offset:t.length,a=n+(t2(i.length)?i.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${i.message} at line ${i.line??1}, column ${i.column??1} [${n},${a})`)}e.parser.input=s.tokens;let i=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(i)}(0,m.K)(t3,"runChevrotainParse");var t5={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},t6=p.UI.usecase,t8=(0,m.K)(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:"LR",relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(t6)}),"createModel"),t4=(0,m.K)(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||"string"!=typeof e.accTitle||"string"!=typeof e.accDescription||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),t7=t8(),t9=(0,m.K)(()=>structuredClone(t7.config),"getConfig"),se=(0,m.K)(()=>t7.ast,"getAST"),st=(0,m.K)(e=>{let t=structuredClone(e);t4(t);let s=(0,p.iN)(),i=(0,p.m7)();try{(0,p.SV)(t.accTitle),(0,p.EI)(t.accDescription),t7=t}catch(e){throw(0,p.SV)(s),(0,p.EI)(i),e}},"commit"),ss=(0,m.K)(()=>{t7=t8(),(0,p.IU)()},"clear"),si=(0,m.K)(()=>t7.actors,"getActors"),sn=(0,m.K)(e=>t7.actors.get(e),"getActor"),sa=(0,m.K)(()=>t7.useCases,"getUseCases"),sr=(0,m.K)(e=>t7.useCases.get(e),"getUseCase"),so=(0,m.K)(()=>t7.systemBoundaries,"getSystemBoundaries"),sl=(0,m.K)(e=>t7.systemBoundaries.get(e),"getSystemBoundary"),sc=(0,m.K)(()=>t7.relationships,"getRelationships"),sh=(0,m.K)(()=>t7.notes,"getNotes"),sd=(0,m.K)(e=>t7.notes.get(e),"getNote"),su=(0,m.K)(()=>t7.jsonNodes,"getJsonNodes"),sp=(0,m.K)(e=>t7.jsonNodes.get(e),"getJsonNode"),sf=(0,m.K)(()=>t7.classDefs,"getClassDefs"),sm=(0,m.K)(e=>t7.classDefs.get(e),"getClassDef"),sE=(0,m.K)(()=>t7.direction,"getDirection"),sT=(0,m.K)(e=>{let t=new Map;for(let s of["default",...e]){let e=t7.classDefs.get(s);if(e)for(let s of e.styles){let e=s.trim(),i=e.indexOf(":"),n=(-1===i?e:e.slice(0,i)).trim();n&&t.set(n,e)}}return[...t.values()]},"getCompiledStyles"),sg=(0,m.K)(e=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),sy=(0,m.K)(e=>"string"==typeof e?e:null===e?"null":String(e),"displayJsonScalar"),sA=(0,m.K)((e,t,s=e=>e)=>{let i=[],n=(0,m.K)((e,t,n)=>{i.push({key:s(e),accessibleKey:s(t),value:s(n)})},"append"),a=(0,m.K)((e,s,i)=>{if(Array.isArray(e)){if(0===e.length)return void n(s,s,"[]");if(e.every(e=>null===e||["string","number","boolean"].includes(typeof e))){for(let[t,i]of e.entries())n(0===t?s:"",s,sy(i));return}for(let[t,n]of e.entries())a(n,`${s}[${t}]`,`${i}/${t}`);return}if(null!==e&&"object"==typeof e){let r=t[i]??Object.keys(e);if(0===r.length)return void n(s,s,"{}");for(let t of r){let n=s?`${s}.${t}`:t;a(e[t],n,`${i}/${sg(t)}`)}return}n(s,s,sy(e))},"visit");return a(e,"",""),i},"flattenJsonRows"),sS=(0,m.K)(e=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),sL=(0,m.K)(e=>"ellipse"===e.shape?e.business?"usecaseBusiness":"usecaseEllipse":e.shape,"useCaseShape"),sO=(0,m.K)(e=>{switch(e){case t5.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case t5.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case t5.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case t5.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case t5.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case t5.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case t5.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),sR=(0,m.K)(e=>{switch(e.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:e.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...sO(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),sk=(0,m.K)(e=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),sI=(0,m.K)((...e)=>e.filter(e=>!!e).join(" "),"classNames"),sN=(0,m.K)(()=>{let e=(0,p.D7)(),t={...t7.config,...e.usecase},s=(0,m.K)(t=>(0,p.jZ)(t,e),"sanitize"),i=(0,m.K)(e=>s(t7.actors.get(e)?.label??t7.useCases.get(e)?.label??t7.jsonNodes.get(e)?.id??t7.notes.get(e)?.label??e),"endpointLabel"),n=[],a=[],r=0,o=0;for(let t of t7.actors.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:sS(t),isGroup:!1,padding:10,look:e.look,colorIndex:r++,cssClasses:sI("default","usecase-actor",`usecase-actor-${t.type}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:sT(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of t7.useCases.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:sL(t),isGroup:!1,padding:"ellipse"===t.shape?20:10,look:e.look,colorIndex:r++,cssClasses:sI("default","usecase-element",`usecase-${t.shape}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:sT(t.classes),business:t.business,...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of t7.notes.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:sT([]),noteTarget:t.target,noteTargetLabel:s(t7.actors.get(t.target)?.label??t7.useCases.get(t.target)?.label??t7.jsonNodes.get(t.target)?.id??t.target)});for(let t of t7.jsonNodes.values())n.push({id:t.id,label:s(t.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:sI("default","usecase-json-table",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:sT(t.classes),jsonRows:sA(t.value,t.propertyOrder,s)});for(let t of t7.systemBoundaries.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:o++,cssClasses:sI("default","system-boundary",`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:sT(t.classes),boundaryType:t.type});for(let t of t7.relationships){let{label:n,...r}=sR(t);a.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:i(t.source),targetLabel:i(t.target),type:"edge",relationshipType:t.type,internal:!1,...r,...void 0!==n?{label:s(n)}:{},labelpos:"c",classes:sI("default","relationship",`relationship-${t.type}`,...t.classes,...sk(t)),style:[...t.styles],cssCompiledStyles:sT(t.classes),animate:t.animate,...t.animation?{animation:t.animation}:{},look:e.look,thickness:"normal",minlen:t.minlen,isUserDefinedId:t.explicitId})}for(let t of t7.notes.values())a.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:"edge",relationshipType:"note",sourceLabel:i(t.id),targetLabel:i(t.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:sT([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let e of n)e.wrappingWidth??=t.wrappingWidth,e.isGroup||e.shape.startsWith("usecaseActor")||(e.minWidth??=t.minNodeWidth),("usecaseEllipse"===e.shape||"usecaseBusiness"===e.shape)&&(e.spreadPorts=!0);return{nodes:n,edges:a,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:sE(),nodeSpacing:t.nodeSpacing,rankSpacing:t.rankSpacing,actorFontSize:t.actorFontSize,actorFontFamily:t.actorFontFamily,actorFontWeight:t.actorFontWeight,usecaseFontSize:t.usecaseFontSize,usecaseFontFamily:t.usecaseFontFamily,usecaseFontWeight:t.usecaseFontWeight,diagramPadding:t.diagramPadding,useMaxWidth:t.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),sb={getConfig:t9,createModel:t8,commit:st,getAST:se,clear:ss,setDiagramTitle:p.ke,getDiagramTitle:p.ab,setAccTitle:p.SV,getAccTitle:p.iN,setAccDescription:p.EI,getAccDescription:p.m7,getActors:si,getActor:sn,getUseCases:sa,getUseCase:sr,getSystemBoundaries:so,getSystemBoundary:sl,getRelationships:sc,getNotes:sh,getNote:sd,getJsonNodes:su,getJsonNode:sp,getClassDefs:sf,getClassDef:sm,getDirection:sE,getData:sN};function sC(e,t,s){let i=[s];return i.index=t,i.input=e,i}(0,m.K)(sC,"customMatch");var s_=(0,m.K)((e,t)=>{if('"'!==e[t]||"`"!==e[t+1])return null;for(let s=t+2;s<e.length-1;s++)if("`"===e[s]&&'"'===e[s+1])return sC(e,t,e.slice(t,s+2));return null},"matchMarkdownString"),sv=(0,m.K)((e,t)=>{if("%"!==e[t]||"%"!==e[t+1])return null;for(let s=t-1;s>=0;s--){let t=e[s];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return null}let s=t+2;for(;s<e.length&&"\n"!==e[s]&&"\r"!==e[s];)s++;return sC(e,t,e.slice(t,s))},"matchComment"),sx=(0,m.K)((e,t)=>{for(let s=t-1;s>=0;s--){let t=e[s];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return!1}return!0},"isIndentedLineStart"),sU=(0,m.K)((e,t,s)=>{if(!sx(e,t))return null;let i=s.exec(e.slice(t));return i?sC(e,t,i[0]):null},"matchAccessibilityLine"),sM=(0,m.K)((e,t)=>{if(!sx(e,t))return null;let s=/^accDescr[\t ]*{/.exec(e.slice(t));if(!s)return null;let i=e.indexOf("}",t+s[0].length);return -1===i?null:sC(e,t,e.slice(t,i+1))},"matchAccDescrBlock"),sw=(0,m.K)((e,t)=>{if("{"!==e[t])return null;let s=0,i=!1,n=!1;for(let a=t;a<e.length;a++){let r=e[a];if(i){n?n=!1:"\\"===r?n=!0:'"'===r&&(i=!1);continue}if('"'===r)i=!0;else if("{"===r)s++;else if("}"===r&&0==--s)return sC(e,t,e.slice(t,a+1))}return null},"matchJsonObject"),sP=(0,m.K)((e,t)=>{let s=e.indexOf(">>",t);if(-1===s||/[\n\r]/.test(e.slice(t,s)))return null;let i=e.slice(t,s);return i.trim()?sC(e,t,i):null},"matchStereotypeText"),sD=eG({name:"LABEL_TEXT",pattern:ex.NA}),s$=eG({name:"WORD",pattern:ex.NA,categories:sD}),sK=eG({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:sD}),sF=eG({name:"IDENTIFIER",pattern:/\w+/,longer_alt:sK,categories:s$}),sB=eG({name:"HWS",pattern:/[\t ]+/,group:ex.SKIPPED}),sj=eG({name:"MARKDOWN_STRING",pattern:s_,start_chars_hint:['"'],line_breaks:!0}),sG=eG({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),sW=eG({name:"COMMENT",pattern:sv,start_chars_hint:["%"],line_breaks:!1}),sV=eG({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),sz=eG({name:"ACC_DESCR_BLOCK",pattern:sM,start_chars_hint:["a"],line_breaks:!0}),sH=/^accTitle[\t ]*:[^\n\r]*/,sY=/^accDescr[\t ]*:[^\n\r]*/,sX=eG({name:"ACC_TITLE_LINE",pattern:(0,m.K)((e,t)=>sU(e,t,sH),"pattern"),start_chars_hint:["a"],line_breaks:!1}),sq=eG({name:"ACC_DESCR_LINE",pattern:(0,m.K)((e,t)=>sU(e,t,sY),"pattern"),start_chars_hint:["a"],line_breaks:!1}),sJ=eG({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),sZ=eG({name:"JSON_OBJECT_LITERAL",pattern:sw,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),sQ=eG({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),s0=(0,m.K)((e,t)=>eG({name:e,pattern:t,longer_alt:sF,categories:s$}),"keyword"),s1=s0("USECASE",/usecase-beta/),s2=s0("ACTOR",/actor/),s3=s0("SYSTEM_BOUNDARY",/systemBoundary/),s5=s0("END",/end/),s6=s0("DIRECTION",/direction/),s8=s0("TD",/TD/),s4=s0("TB",/TB/),s7=s0("BT",/BT/),s9=s0("LR",/LR/),ie=s0("RL",/RL/),it=s0("NOTE",/note/),is=s0("FOR",/for/),ii=s0("JSON",/json/),ia=s0("CLASS_DEF",/classDef/),ir=s0("CLASS",/class/),io=s0("STYLE",/style/),il=s0("INCLUDE",/include/i),ic=s0("EXTEND",/extend/i),ih=s0("TRUE",/true/),id=s0("FALSE",/false/),iu=eG({name:"GENERALIZATION",pattern:/--\|>/}),ip=eG({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),im=eG({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),iE=eG({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),iT=eG({name:"STEREOTYPE_TEXT",pattern:sP,line_breaks:!1}),ig=eG({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),iy=eG({name:"CLASS_SEPARATOR",pattern:/:::/}),iA=eG({name:"FORWARD_SOLID",pattern:/--+>/}),iS=eG({name:"BACKWARD_SOLID",pattern:/<--+/}),iL=eG({name:"FORWARD_CIRCLE",pattern:/--o/}),iO=eG({name:"BACKWARD_CIRCLE",pattern:/o--/}),iR=eG({name:"FORWARD_CROSS",pattern:/--x/}),ik=eG({name:"BACKWARD_CROSS",pattern:/x--/}),iI=eG({name:"MARKERLESS_SOLID",pattern:/--+/}),iN=eG({name:"METADATA_START",pattern:/@{/}),ib=eG({name:"AT",pattern:/@/,categories:sD}),iC=eG({name:"LBRACE",pattern:/{/}),i_=eG({name:"RBRACE",pattern:/}/}),iv=eG({name:"LBRACKET",pattern:/\[/}),ix=eG({name:"RBRACKET",pattern:/]/}),iU=eG({name:"LPAREN",pattern:/\(/}),iM=eG({name:"RPAREN",pattern:/\)/}),iw=eG({name:"COMMA",pattern:/,/,categories:sD}),iP=eG({name:"COLON",pattern:/:/,categories:sD}),iD=eG({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:sD}),i$=eG({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),iK=eG({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:sD}),iF=eG({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:sD}),iB=eG({name:"DASH",pattern:/-/,categories:sD}),ij=eG({name:"DOT",pattern:/\./,categories:sD}),iG=eG({name:"PERCENT",pattern:/%/,categories:sD}),iW=eG({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:sD}),iV=eG({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:sD}),iz=eG({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:sD}),iH=[sD,s$,sB,sj,sG,sW,sV,sz,sX,sq,sJ,s1,s2,s3,s5,s6,s8,s4,s7,s9,ie,it,is,ii,ia,ir,io,il,ic,ih,id,iu,ip,im,iy,iA,iS,iL,iO,iR,ik,iI,iN,ib,iC,i_,iv,ix,iU,iM,iw,iP,iD,i$,iK,sF,sK,iF,iB,ij,iG,iW,iV,iz],iY={defaultMode:"defaultMode",modes:{defaultMode:[...iH],jsonBody:[sZ,sQ],stereotype:[iE,iT,ig]}},iX=[...iH,sZ,sQ,iE,iT,ig],iq=new ex(iY),iJ=(0,m.K)(e=>eO(e,sD)||e.tokenType===i$||e.tokenType===sj,"isLabelToken"),iZ={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},iQ=new class extends t0{static{(0,m.K)(this,"UsecaseParser")}constructor(){super(iX,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(s1),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:(0,m.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:(0,m.K)(()=>this.isStatementStart(),"GATE"),ALT:(0,m.K)(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:(0,m.K)(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:(0,m.K)(()=>this.isMetadataAssignment(),"GATE"),ALT:(0,m.K)(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:(0,m.K)(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:(0,m.K)(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(sV),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(eW),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(sV)}),this.RULE("commentLine",()=>{this.CONSUME(sW),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(sX),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(sq),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sz),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(s2),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:(0,m.K)(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(iw),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:(0,m.K)(()=>{this.CONSUME(sF),this.OPTION(()=>{this.CONSUME(iU),this.SUBRULE(this.nodeLabel),this.CONSUME(iM)})},"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(s2),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(iw),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:(0,m.K)(()=>{this.CONSUME(sF),this.OPTION(()=>{this.OR2([{ALT:(0,m.K)(()=>{this.CONSUME(iU),this.SUBRULE(this.nodeLabel),this.CONSUME(iM)},"ALT")},{ALT:(0,m.K)(()=>{this.CONSUME(iv),this.SUBRULE2(this.nodeLabel),this.CONSUME(ix)},"ALT")}])})},"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")},{ALT:(0,m.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(sD)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:(0,m.K)(()=>this.LA(1).tokenType===sF&&this.LA(2).tokenType===ib,"GATE"),DEF:(0,m.K)(()=>{this.CONSUME(sF),this.CONSUME(ib)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:(0,m.K)(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(iA)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(iS),this.OPTION({GATE:(0,m.K)(()=>"<--"===this.LA(0).image&&this.hasLabeledRight([iI]),"GATE"),DEF:(0,m.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(iI)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(iI),this.OPTION({GATE:(0,m.K)(()=>"--"===this.LA(0).image&&this.hasLabeledRight([iA,iI,iL,iR]),"GATE"),DEF:(0,m.K)(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:(0,m.K)(()=>this.CONSUME(iA),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME2(iI),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iL),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iR),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(iL)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(iO),this.OPTION({GATE:(0,m.K)(()=>this.hasLabeledRight([iI]),"GATE"),DEF:(0,m.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(iI)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(iR)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(ik),this.OPTION({GATE:(0,m.K)(()=>this.hasLabeledRight([iI]),"GATE"),DEF:(0,m.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(iI)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")},{ALT:(0,m.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(sD)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:(0,m.K)(()=>{this.CONSUME(ip),this.CONSUME(iP),this.OR2([{ALT:(0,m.K)(()=>this.CONSUME(il),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ic),"ALT")}])},"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iu),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(iN),this.MANY(()=>this.CONSUME(sV)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(iw)),this.MANY3(()=>this.CONSUME2(sV))}),this.CONSUME(i_)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(sF),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")}]),this.CONSUME(iP),this.OR2([{ALT:(0,m.K)(()=>this.CONSUME2(sF),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME2(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ih),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(id),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:(0,m.K)(()=>{this.CONSUME(iw),this.MANY(()=>this.CONSUME(sV))},"ALT")},{ALT:(0,m.K)(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(sV)),this.OPTION(()=>this.CONSUME2(iw)),this.MANY2(()=>this.CONSUME3(sV))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(s3),this.SUBRULE(this.systemBoundaryName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd),this.SUBRULE(this.systemBoundaryContent),this.CONSUME(s5),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:(0,m.K)(()=>{this.CONSUME(sF),this.OPTION(()=>{this.OR2([{ALT:(0,m.K)(()=>{this.CONSUME(iU),this.SUBRULE(this.nodeLabel),this.CONSUME(iM)},"ALT")},{ALT:(0,m.K)(()=>{this.CONSUME(iv),this.SUBRULE2(this.nodeLabel),this.CONSUME(ix)},"ALT")}])})},"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:(0,m.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:(0,m.K)(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:(0,m.K)(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:(0,m.K)(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(sF),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sj),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(it),this.CONSUME(is),this.CONSUME(sF),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(im),this.CONSUME(iT),this.CONSUME(iE)}),this.RULE("classSuffix",()=>{this.CONSUME(iy),this.CONSUME(sF),this.MANY(()=>{this.CONSUME(iw),this.CONSUME2(sF)})}),this.RULE("jsonStatement",()=>{this.CONSUME(sJ),this.CONSUME(sZ),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(s6),this.OR([{ALT:(0,m.K)(()=>this.CONSUME(s8),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(s4),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(s7),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(s9),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ie),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(ia),this.CONSUME(sF),this.MANY(()=>{this.CONSUME(iw),this.CONSUME2(sF)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(ir),this.CONSUME(sF),this.MANY(()=>{this.CONSUME(iw),this.CONSUME2(sF)}),this.CONSUME3(sF),this.MANY2(()=>{this.CONSUME2(iw),this.CONSUME4(sF)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(io),this.CONSUME(sF),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(iw),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(s$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iK),"ALT")},{ALT:(0,m.K)(()=>{this.CONSUME(iI),this.CONSUME2(s$)},"ALT")}]),this.CONSUME(iP),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:(0,m.K)(()=>this.CONSUME(s$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i$),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(sK),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iD),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iK),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iF),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iB),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ij),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iG),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iW),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iP),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iU),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iM),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iv),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ix),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iC),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(i_),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(ib),"ALT")},{ALT:(0,m.K)(()=>this.CONSUME(iI),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===sF||e===i$||e===sj)&&this.LA(2).tokenType===iN}isStatementStart(){let e=this.LA(1).tokenType;return e!==eW&&e!==sV&&e!==sW}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===sF&&!0===iZ[this.LA(1).image.toLowerCase()]}hasLabeledRight(e){if(!iJ(this.LA(1)))return!1;for(let t=2;;t++){let s=this.LA(t);if(e.includes(s.tokenType))return!0;if(!iJ(s))return!1}}},i0=class extends Error{constructor(e,t,s){super(`${e} (line ${t}, column ${s})`),this.line=t,this.column=s,this.name="UsecaseJsonError"}static{(0,m.K)(this,"UsecaseJsonError")}},i1=(0,m.K)((e,t,s,i)=>{let n=s,a=i,r=Math.min(Math.max(t,0),e.length);for(let t=0;t<r;t++){let s=e[t];"\r"===s?(n++,a=1):"\n"===s?(0===t||"\r"!==e[t-1])&&(n++,a=1):a++}return{line:n,column:a}},"locationAtOffset"),i2=(0,m.K)((e,t,s,i)=>{let n=/\bposition (\d+)\b/u.exec(e);if(n)return i1(t,Number.parseInt(n[1],10),s,i);let a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){let e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:s+e-1,column:1===e?i+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return i1(t,t.length,s,i)},"locationFromErrorMessage"),i3=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}static{(0,m.K)(this,"JsonWalkError")}},i5=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{(0,m.K)(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new i3(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if("{"===t)this.collectObject(e);else if("["===t)this.collectArray(e);else if('"'===t)this.readString(!1);else if("t"===t)this.consumeLiteral("true");else if("f"===t)this.consumeLiteral("false");else if("n"===t)this.consumeLiteral("null");else if("-"===t||t>="0"&&t<="9")this.consumeNumber();else throw new i3(this.offset)}collectObject(e){this.offset++;let t=[],s=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;for(;this.offset<this.text.length&&'"'===this.text[this.offset];){let i=this.readString(!0),n=`${e}/${i.replaceAll("~","~0").replaceAll("/","~1")}`;if(s.has(i)?this.deletePointerSubtree(n):(s.add(i),t.push(i)),this.skipWhitespace(),":"!==this.text[this.offset])break;if(this.offset++,this.collectValue(n),this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new i3(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new i3(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){let s=this.offset,i=this.text[this.offset++];if('"'===i)return t;if(32>i.charCodeAt(0))throw new i3(s);if("\\"!==i){e&&(t+=i);continue}let n=this.offset,a=this.text[this.offset++];switch(a){case'"':case"\\":case"/":e&&(t+=a);break;case"b":e&&(t+="\b");break;case"f":e&&(t+="\f");break;case"n":e&&(t+="\n");break;case"r":e&&(t+="\r");break;case"t":e&&(t+=" ");break;case"u":{let s=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(s))throw new i3(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(s,16))),this.offset+=4;break}default:throw new i3(n)}}throw new i3(this.offset)}consumeLiteral(e){let t=0;for(let s of e){if(this.text[this.offset+t]!==s)throw new i3(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if("-"===this.text[this.offset]&&this.offset++,"0"===this.text[this.offset])this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new i3(this.offset);if("."===this.text[this.offset]){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new i3(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if("e"===this.text[this.offset]||"E"===this.text[this.offset]){if(this.offset++,("+"===this.text[this.offset]||"-"===this.text[this.offset])&&this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new i3(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(" "!==e&&" "!==e&&"\n"!==e&&"\r"!==e)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let s of Object.keys(this.propertyOrder))(s===e||s.startsWith(t))&&delete this.propertyOrder[s]}};function i6(e,t,s){let i;try{i=JSON.parse(e)}catch(a){let i=a instanceof Error?a.message:String(a),n=i2(i,e,t,s);if(!n){let i=0;try{new i5(e).collect()}catch(e){e instanceof i3&&(i=e.offset)}n=i1(e,i,t,s)}throw new i0(`Invalid JSON: ${i}`,n.line,n.column)}if("object"!=typeof i||null===i||Array.isArray(i))throw new i0("JSON value must have an object root",t,s);return{value:i,propertyOrder:new i5(e).collect()}}(0,m.K)(i6,"parseOrderedJsonObject");var i8=(0,m.K)(e=>({shape:"normal"===e.type?"actor":"hollow"===e.type?"actor-hollow":"awesome"===e.type?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),i4=(0,m.K)(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),i7=(0,m.K)(e=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),i9=(0,m.K)(e=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),ne=(0,m.K)(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),nt=(0,m.K)(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:t5.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),ns=(0,m.K)((e,t,s,i)=>{let n={};for(let t of e.getActors().values())n[t.id]=i8(t);for(let t of e.getUseCases().values())n[t.id]=i4(t);for(let t of e.getNotes().values())n[t.id]=i7(t);for(let t of e.getJsonNodes().values())n[t.id]=i9(t);let a={};for(let t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:t.type,labelType:t.labelType}};let r={};for(let t of e.getClassDefs().values())r[t.id]={styles:[...t.styles]};let o=e.getDirection();return{version:1,diagramType:"usecase",source:t,header:{keyword:"usecase",direction:"TD"===o?"TB":o,span:s},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:n,edges:[...e.getRelationships().map(ne),...[...e.getNotes().values()].map(nt)],groups:a,classDefs:r,statements:i}},"buildUsecaseGraphAST"),ni=(0,m.K)(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),nn=(0,m.K)(e=>void 0===e?"":` (label "${e}")`,"labelSuffix"),na=(0,m.K)(e=>e.generated?e.label:void 0,"generatedFrom"),nr=(0,m.K)((e,t)=>{for(let s of t)e.includes(s)||e.push(s)},"pushUnique"),no=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{(0,m.K)(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,s,i){this.metadataAssignments.push({target:e,targetLocation:t,metadata:s,statement:i})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,s){this.styleAssignments.push({target:e,location:t,styles:s})}setDirection(e){this.directions.push("TD"===e?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,s=new Map,i=new Map,n=new Map;for(let e of this.relationshipDrafts)this.recordFirst(n,e.source.id,e.source.location.span[0]),this.recordFirst(n,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(n,e.id,e.location.span[0]);for(let e of[...this.elements.map(e=>({offset:e.location.span[0],type:"element",value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:"boundary",value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:"json",value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:"edge",value:e}))].sort((e,t)=>e.offset-t.offset))"element"===e.type?this.collectElement(e.value,t,s):"boundary"===e.type?this.collectBoundary(e.value,t,i):"json"===e.type?this.registerUnique(t,e.value.id,"json",e.value.location,!1):this.registerUnique(t,e.value.explicitId,"edge",e.value.explicitIdLocation,!1);this.materializeElements(s,n),this.materializeBoundaries(i,n),this.materializeJson(n);let a=this.materializeRelationships(t,s,n);this.reorderElements(s,n),this.applyMetadataAssignments(t,s,i,a),this.validateAndRefreshElements(s),this.refreshBoundaries(i,s),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,a),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let r=ns(this,this.source,e,this.statements);return this.model.ast=r,this.db.commit(this.model),r}collectElement(e,t,s){let i=t.get(e.id),n=na({generated:e.generated,label:e.label.text});i&&i.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,n,na(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,n,na(i));let a=s.get(e.id);if(!a){let i={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(i,e.metadata),s.set(e.id,i),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,nr(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,t,s){let i=t.get(e.id),n=na({generated:e.generated,label:e.label.text});i&&"boundary"!==i.kind&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,n,na(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,n,na(i));let a=s.get(e.id);if(a){(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),nr(a.classes,e.classes);return}s.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.setElementModel(s)}materializeBoundaries(e,t){for(let s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.model.systemBoundaries.set(s.id,{id:s.id,label:s.label.text,labelType:s.label.type,type:s.type??"rect",members:[],classes:[...s.classes],styles:[...s.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,s)=>(e.get(t.id)??0)-(e.get(s.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,s){let i=new Map,n=0;for(let a of this.relationshipDrafts){let r=this.resolveEndpoint(a.source,e,t,s),o=this.resolveEndpoint(a.target,e,t,s);this.validateRelationship(a,r,o,e);let l=a.explicitId??`edge-${n++}`,c={id:l,explicitId:!!a.explicitId,source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(c),i.set(l,{draft:a,relationship:c})}return this.model.relationshipCounter=n,i}resolveEndpoint(e,t,s,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${ni(e.location)}`);let n=t.get(e.id);return n?n.kind:(s.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),t.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(i,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){let s=new Map(this.model.actors),i=new Map(this.model.useCases);for(let n of(this.model.actors.clear(),this.model.useCases.clear(),[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))){s.has(n.id)||i.has(n.id)||this.setElementModel(n);let e=s.get(n.id)??this.model.actors.get(n.id),t=i.get(n.id)??this.model.useCases.get(n.id);e?this.model.actors.set(n.id,e):t&&this.model.useCases.set(n.id,t)}}applyMetadataAssignments(e,t,s,i){for(let n of this.metadataAssignments){let a=e.get(n.target);if(!a){let e=this.inferMetadataKind(n.metadata);throw Error(`Metadata target '${n.target}' is unresolved${e?` (metadata implies ${e})`:""} at ${ni(n.targetLocation)}`)}if("actor"===a.kind||"usecase"===a.kind)this.applyStandaloneElementMetadata(t.get(n.target),n.metadata);else if("boundary"===a.kind){let e=s.get(n.target);for(let t of n.metadata.properties)("type"!==t.key||"rect"!==t.value&&"package"!==t.value)&&this.invalidMetadata(n.target,a.kind,t),e.type=t.value}else if("edge"===a.kind){let e=i.get(n.target);if(!e)throw Error(`Metadata target '${n.target}' is not an explicit edge at ${ni(n.targetLocation)}`);for(let t of(n.statement.kind="edgeMetadata",n.statement.edges=[{id:n.target,span:n.statement.span,idSpan:n.targetLocation.span,...n.statement.metadata?{metadata:n.statement.metadata}:{}}],delete n.statement.nodes,n.metadata.properties))"animate"===t.key&&"boolean"==typeof t.value?e.relationship.animate=t.value:"animation"===t.key&&("fast"===t.value||"slow"===t.value)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(n.target,a.kind,t)}else for(let e of n.metadata.properties)this.invalidMetadata(n.target,a.kind,e)}for(let{relationship:e}of i.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!0):"business"===s.key&&"boolean"==typeof s.value?e.business=s.value:this.invalidMetadata(e.id,e.kind,s)}applyDeclarationMetadata(e,t){if(t)for(let s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!1):"business"===s.key&&"boolean"==typeof s.value?(void 0!==e.business&&e.business!==s.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,s.location,e.location),e.business=s.value):this.invalidMetadata(e.id,e.kind,s)}applyActorProperty(e,t,s){"type"===t.key&&("normal"===t.value||"hollow"===t.value||"awesome"===t.value)?(s||void 0===e.actorType||e.actorType===t.value||this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):"icon"===t.key&&"string"==typeof t.value?(s||void 0===e.icon||e.icon===t.value||this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):"business"===t.key&&"boolean"==typeof t.value?(s||void 0===e.business||e.business===t.value||this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?"icon":t.actorType??"normal";if("actor"===t.kind){if(t.icon&&t.actorType&&"normal"!==t.actorType)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${ni(t.location)}`);if(t.business&&("icon"===e||"awesome"===e))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${ni(t.location)}`)}else if((t.shape??"ellipse")==="rect"&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${ni(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let s=e.get(t.parentId);if(!s)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${ni(t.parentLocation??t.location)}`);s.members.includes(t.id)||s.members.push(t.id)}for(let s of t.values())if(s.parentId&&!e.has(s.parentId))throw Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${ni(s.parentLocation??s.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??"rect",e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let s of this.noteDrafts){let i=e.get(s.target);if(!i)throw Error(`Note target '${s.target}' is unresolved at ${ni(s.targetLocation)}`);"actor"!==i.kind&&"usecase"!==i.kind&&this.conflict(`Note target '${s.target}' must be an actor or use case, not ${i.kind}`,s.targetLocation,i.location);let n=`note-${t++}`;this.model.notes.set(n,{id:n,target:s.target,label:s.label.text,labelType:s.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let s of this.classAssignments)for(let i of s.targets)nr(this.getStylable(i.id,e,t,i.location).classes,s.classes);for(let s of this.styleAssignments)this.getStylable(s.target,e,t,s.location).styles.push(...s.styles)}getStylable(e,t,s,i){let n=t.get(e)?.kind,a="actor"===n?this.model.actors.get(e):"usecase"===n?this.model.useCases.get(e):"boundary"===n?this.model.systemBoundaries.get(e):"json"===n?this.model.jsonNodes.get(e):"edge"===n?s.get(e)?.relationship:void 0;if(!a)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${ni(i)}`);return a}validateRelationship(e,t,s,i){let n=(0,m.K)(e=>"actor"===e||"usecase"===e||"json"===e,"allowed");if(n(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,i.get(e.source.id).location),n(s)||this.conflict(`Relationship target '${e.target.id}' cannot be ${s}`,e.target.location,i.get(e.target.id).location),("include"===e.type||"extend"===e.type)&&("usecase"!==t||"usecase"!==s))throw Error(`${e.type} relationship requires use-case endpoints at ${ni(e.location)}`);if("generalization"===e.type&&("actor"!==t&&"usecase"!==t||t!==s))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${ni(e.location)}`);if("association"===e.type&&("json"===t||"json"===s)&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${ni(e.location)}`)}setElementModel(e){if("actor"===e.kind){let t=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let s of e.properties)if("icon"===s.key)t.clear(),t.add("actor");else if("animate"===s.key||"animation"===s.key)t.clear(),t.add("edge");else if("type"===s.key)t.clear(),"rect"===s.value||"package"===s.value?t.add("boundary"):("normal"===s.value||"hollow"===s.value||"awesome"===s.value)&&t.add("actor");else{if("business"!==s.key)return;t.delete("boundary"),t.delete("edge")}return 1===t.size?[...t][0]:void 0}invalidMetadata(e,t,s){throw Error(`Metadata property '${s.key}' is invalid for ${t} '${e}' at ${ni(s.location)}`)}registerUnique(e,t,s,i,n){let a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${s})`,i,a.location,void 0,na(a)),e.set(t,{kind:s,location:i,generated:n})}recordFirst(e,t,s){let i=e.get(t);(void 0===i||s<i)&&e.set(t,s)}conflict(e,t,s,i,n){throw Error(`${e} at ${ni(t)}${nn(i)}; previous declaration at ${ni(s)}${nn(n)}`)}},nl=iQ.getBaseCstVisitorConstructor(),nc=new class extends nl{constructor(){super(),this.builder=new no(sb),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{(0,m.K)(this,"UsecaseVisitor")}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,"USECASE")[0],s=[];for(let t of this.nodes(e,"line"))s.push(this.visit(t));this.builder.setStatements(s),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){let t=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,"ACC_DESCR_LINE")[0],s=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=t?t.image.slice(t.image.indexOf(":")+1).trim():s.image.slice(s.image.indexOf("{")+1,s.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){let t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e)),i=this.nodes(e,"relationTail")[0],n=s.map((e,s)=>this.actorOccurrence(t[s],e,!0));for(let e of s)this.builder.addElement(this.actorDraft(e));if(!i)return{kind:"node",span:[0,0],nodes:n};let a=this.visit(i);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));let r=this.relationshipDraft(s[0],a,this.nodeLocation(i));this.builder.addRelationship(r);let o=r.explicitId??`edge-${this.anonymousEdge++}`;return n.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],a.target,a.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:n,edges:[{id:o,span:[0,0],...r.explicitIdLocation?{idSpan:r.explicitIdLocation.span}:{},...r.label?{labelSpan:r.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,"actorName")[0]),s=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],n=this.nodes(e,"classSuffix")[0],a=n?this.visit(n):{classes:[],spans:[]};return{...t,...s?{metadata:this.visit(s)}:{},...i?{stereotype:this.visit(i)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(t){let s=this.nodes(e,"nodeLabel")[0],i=s?this.visit(s):this.tokenLabel(t);return{id:t.image,label:i,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(s);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(s),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e));for(let e of s)this.builder.addElement(this.actorDraft(e));return{kind:"node",span:[0,0],nodes:s.map((e,s)=>this.actorOccurrence(t[s],e,!0))}}entityStatement(e){let t=this.nodes(e,"entityName"),s=this.visit(t[0]),i=this.nodes(e,"relationTail")[0];if(!i)return s.explicitDeclaration=!0,s.shape??="ellipse",this.builder.addElement(this.entityDraft(s)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(t[0],s,!0)]};s.explicitDeclaration&&this.builder.addElement(this.entityDraft(s));let n=this.visit(i);n.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(n.target));let a={source:this.endpoint(s),target:this.endpoint(n.target),location:this.nodeLocation(i),...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow};this.builder.addRelationship(a);let r=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(t[0],s,s.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],n.target,n.target.explicitDeclaration)],edges:[{id:r,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],n=this.nodes(e,"useCaseMetadata")[0],a=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};if(t){let s=i?this.visit(i):this.tokenLabel(t),r=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:t.image,label:s,location:this.tokenLocation(t),generated:!1,...r?{shape:r}:{},...n?{metadata:this.visit(n)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(r||n||a)}}let l=this.tokenLabel(s);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(s),generated:!0,...n?{metadata:this.visit(n)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(n||a)}}nodeLabel(e){let t=this.allTokens(e);if(1===t.length&&("PLAIN_STRING"===t[0].tokenType.name||"MARKDOWN_STRING"===t[0].tokenType.name))return this.tokenLabel(t[0]);let s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(s[0],s[1]),type:"text",span:s}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let t=this.tokens(e,"IDENTIFIER")[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:t5.SOLID_ARROW,minlen:1};let t=this.tokens(e,"INCLUDE").length?"include":"extend",s=this.tokens(e,"include"===t?"INCLUDE":"EXTEND")[0];return{type:t,arrowType:t5.SOLID_ARROW,label:{text:t,type:"text",span:this.tokenSpan(s)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>"COLON"!==e.tokenType.name),s=t[0],i=t[1],n="TRUE"===i.tokenType.name||"FALSE"!==i.tokenType.name&&this.decodePlain(i),a=[s.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(s),value:n,span:a,keySpan:this.contentSpan(s),valueSpan:this.contentSpan(i),location:this.tokenLocation(s)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,"systemBoundaryName")[0]),s=this.nodes(e,"classSuffix")[0],i=s?this.visit(s):{classes:[],spans:[]};t.classes=i.classes,this.builder.addBoundary(t);let n=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let a=this.nodes(e,"systemBoundaryContent")[0],r=a?this.visit(a):[];this.parentBoundary=n;let o=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],c=l?this.visit(l):void 0,h={kind:"group",span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(o),classSpans:i.spans,...c?{metadata:c.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))}:{},...r.length?{children:r}:{}};return c&&this.builder.addMetadataAssignment(t.id,t.location,c,h),h}systemBoundaryName(e){let t=this.tokens(e,"IDENTIFIER")[0];if(t){let s=this.nodes(e,"nodeLabel")[0];return{id:t.image,label:s?this.visit(s):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(s);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(s),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,"actorDeclarationOnly")[0];if(t)return this.visit(t);let s=this.nodes(e,"entityName")[0],i=this.visit(s);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s,i,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),s=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:s.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))};return this.builder.addMetadataAssignment(t.id,t.location,s,i),i}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],s=this.tokenLabel(t);return{id:"IDENTIFIER"===t.tokenType.name?t.image:this.generateId(s.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:s,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:s.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,"IDENTIFIER");return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,"JSON_DECLARATION_START")[0],s=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(t.image),n=i[1],a=i[0].length-n.length,r={span:[t.startOffset+a,t.startOffset+a+n.length],line:t.startLine??1,column:(t.startColumn??1)+a},o=i6(s.image,s.startLine??1,s.startColumn??1),l=this.nodes(e,"classSuffix")[0],c=l?this.visit(l):{classes:[],spans:[]},h={id:n,value:o.value,propertyOrder:o.propertyOrder,location:r,classes:c.classes};return this.builder.addJson(h),{kind:"json",span:[0,0],nodes:[{id:n,span:r.span,idSpan:r.span,defines:!0,classSpans:c.spans}],classSpans:c.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>["TD","TB","BT","RL","LR"].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let t=this.tokens(e,"IDENTIFIER"),s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(t.map(e=>e.image),s),{kind:"classDef",span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,"IDENTIFIER"),s=1;for(;s<t.length&&this.source.slice((t[s-1].endOffset??t[s-1].startOffset)+1,t[s].startOffset).includes(",");s++);let i=t.slice(0,s).map(e=>({id:e.image,location:this.tokenLocation(e)})),n=t.slice(s).map(e=>e.image);return this.builder.addClassAssignment(i,n),{kind:"classAssign",span:[0,0],ref:n[0],refSpan:this.tokenSpan(t[s]),nodes:i.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),s),{kind:"style",span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,"styleValue").map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(s[0],s[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(e=>e.image).join("")}forwardSolidOperator(e){let t=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:t5.SOLID_ARROW,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,"BACKWARD_SOLID")[0],s=this.nodes(e,"edgeLabel")[0],i=s?this.tokens(e,"MARKERLESS_SOLID").at(-1):t;return{type:"association",arrowType:t5.BACK_ARROW,minlen:this.solidMinlen(i),...s?{label:this.visit(s)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,"edgeLabel")[0],s=this.allTokens(e);if(!t)return{type:"association",arrowType:t5.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=s.at(-1),n="FORWARD_SOLID"===i.tokenType.name?t5.SOLID_ARROW:"FORWARD_CIRCLE"===i.tokenType.name?t5.CIRCLE_ARROW:"FORWARD_CROSS"===i.tokenType.name?t5.CROSS_ARROW:t5.LINE_SOLID;return{type:"association",arrowType:n,label:this.visit(t),minlen:n===t5.SOLID_ARROW||n===t5.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:t5.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:t5.CIRCLE_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:t5.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:t5.CROSS_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:"actor",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:"usecase",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,s){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:s,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,s){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...s?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,s){return this.actorOccurrence(e,t,s)}wrap(e,t){if("blank"===t.kind||"comment"===t.kind)return t;for(let s of(t.span=this.nodeSpan(e),t.edges??[]))s.span=t.span;return t}tokenLabel(e){let t="MARKDOWN_STRING"===e.tokenType.name?"markdown":"text",s="markdown"===t?2:+("PLAIN_STRING"===e.tokenType.name),i=this.tokenSpan(e,s);return{text:this.source.slice(i[0],i[1]),type:t,span:i}}decodePlain(e){return"PLAIN_STRING"===e.tokenType.name?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,"PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name))}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],i=t.at(-1);return{span:[s.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:s.startLine??1,column:s.startColumn??1}}tokenLocation(e){let t="PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name);return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],i=t.at(-1);if(!s||!i)throw Error("Usecase CST node has no source token");return[s.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>"children"in e)}tokens(e,t){return(e[t]??[]).filter(e=>"tokenTypeIdx"in e)}firstNode(e,...t){for(let s of t){let t=this.nodes(e,s)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(", ")}`)}allTokens(e){let t=[];for(let s of Object.values(e))for(let e of s)"tokenTypeIdx"in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},nh={parse:(0,m.K)(async e=>{sb.clear(),iQ.input=[];try{t3({diagramType:"usecase",lexer:iq,parser:iQ,entry:(0,m.K)(()=>iQ.start(),"entry"),visit:(0,m.K)(t=>nc.build(t,e),"visit")},e)}catch(s){sb.clear();let t=iQ.errors[0];if(t){let{token:i}=t,n=t2(i.startOffset)?i.startOffset:e.length,a=t2(i.endOffset)?i.endOffset+1:n,r=t2(i.startLine)?i.startLine:e.slice(0,n).split(/\r\n|\r|\n/).length,o=Math.max(e.lastIndexOf("\n",n-1),e.lastIndexOf("\r",n-1)),l=t2(i.startColumn)?i.startColumn:n-o,c=s instanceof Error?s.message:String(s);throw Error(`${c} at line ${r}, column ${l} [${n},${a})`)}throw s}},"parse")},nd=["point","circle","cross","extension"],nu={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},np=(0,m.K)((e,t)=>{let[s,i]=[e,t].map(e=>e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${s}-${i}`},"usecaseDomId"),nf=(0,m.K)(e=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),nm=(0,m.K)((e,t)=>"markdown"!==t?e:(0,h.O6)(e).map(e=>e.map(e=>e.content).join(" ")).join("\n"),"getAccessibleLabel"),nE=(0,m.K)(e=>{let t=nm(e.label??e.id,e.labelType);if(nu[e.shape]){let s=e.actorType&&"normal"!==e.actorType?`${e.actorType} `:"",i=e.business?"business ":"",n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${i}${s}actor ${t}${n}`}if("note"===e.shape)return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${t}`;if("usecaseJsonTable"===e.shape){let s=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join("; ");return s?`${t}: ${s}`:t}let s=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${t}${s}`},"getUsecaseNodeAccessibleName"),nT=(0,m.K)(e=>`${e.boundaryType} system boundary ${nm(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),ng=(0,m.K)(e=>{if("note"===e.relationshipType)return"";let t="association"===e.relationshipType&&e.label?`association ${nm(e.label,e.labelType)}`:e.relationshipType;return`${t} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ny=(0,m.K)(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),nA=(0,m.K)(e=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),nS=(0,m.K)((e,t)=>{for(let s of(e.diagramId=t,e.markers=[...nd],e.nodes))if(s.domId=nf(s.id),void 0!==s.label&&"text"===s.labelType&&(s.label=ny(s.label)),s.stereotype&&(s.stereotype=ny(s.stereotype)),s.isGroup||"usecaseJsonTable"!==s.shape||(s.jsonRows=s.jsonRows?.map(e=>({...e,key:ny(e.key),value:ny(e.value)}))),!s.isGroup&&("usecaseEllipse"===s.shape||"rect"===s.shape)&&s.stereotype){let e=s.label??ny(s.id);s.label=`\xab${nA(s.stereotype)}\xbb<br/>${"text"===s.labelType?nA(e):e}`,s.labelType="markdown",s.hasFoldedStereotype=!0,delete s.stereotype}for(let t of e.edges)void 0!==t.label&&"text"===t.labelType&&(t.label=ny(t.label));return e},"prepareUsecaseLayoutData"),nL=(0,m.K)((e,t,s)=>{for(let i of t.nodes){let n="string"==typeof i.domId?i.domId:np(t.diagramId,i.id),a=e.select(`#${n}`),r=i.isGroup?"boundary":nu[i.shape]?"actor":"note"===i.shape?"note":"usecaseJsonTable"===i.shape?"json":"usecase",o=s.nodes.get(i.id)??i.id;if(a.attr("data-usecase-id",i.id).attr("data-usecase-kind",r).attr("role","img").attr("aria-label",o),!i.isGroup&&("usecaseEllipse"===i.shape||"rect"===i.shape)&&"hasFoldedStereotype"in i&&!0===i.hasFoldedStereotype){let e=a.node(),t=e?.querySelector(".nodeLabel"),s=t?.querySelector("p")??t,i=s?.firstChild;if(s&&i?.nodeType===3){let e=s.ownerDocument.createElement("span");e.className="usecase-stereotype",s.insertBefore(e,i),e.appendChild(i)}else e?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(t.edges.map(e=>[e.id,e]));e.selectAll('path[data-et="edge"]').each(function(){let e=i.get(this.getAttribute("data-id")??"");if(!e)return;let n=(0,t1.Ltv)(this);n.attr("id",np(t.diagramId,e.id)).attr("data-usecase-id",e.id).attr("data-usecase-kind",e.internal?"note-connector":"relationship"),e.internal?n.attr("aria-hidden","true"):n.attr("role","img").attr("aria-label",s.edges.get(e.id)??e.id)})},"annotateUsecaseElements"),nO=(0,m.K)((e,t)=>{e.style("--mermaid-usecase-actor-font-size",`${t.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",t.actorFontFamily).style("--mermaid-usecase-actor-font-weight",t.actorFontWeight).style("--mermaid-usecase-font-size",`${t.usecaseFontSize}px`).style("--mermaid-usecase-font-family",t.usecaseFontFamily).style("--mermaid-usecase-font-weight",t.usecaseFontWeight)},"applyUsecaseFonts"),nR=(0,m.K)(async(e,t,s,i)=>{f.R.info("Drawing usecase diagram (unified)",t);let{layout:n}=(0,p.D7)(),a=i.db,r=a.getData(),h=new Map(r.nodes.map(e=>[e.id,nm(e.label??e.id,e.labelType)])),d={nodes:new Map(r.nodes.map(e=>[e.id,e.isGroup?nT(e):nE("note"===e.shape?{...e,noteTargetLabel:h.get(e.noteTarget??"")}:e)])),edges:new Map(r.edges.map(e=>[e.id,ng({...e,sourceLabel:h.get(e.source)??e.sourceLabel,targetLabel:h.get(e.target)??e.targetLabel})]))},m=(0,o.A)(t,r.config.securityLevel);r.layoutAlgorithm=(0,c.q7)(n),nS(r,t),nO(m,r),await (0,c.XX)(r,m),nL(m,r,d);let E=r.diagramPadding;u._K.insertTitle(m,"usecaseDiagramTitleText",0,a.getDiagramTitle?.()??""),(0,l.P)(m,E,"usecaseDiagram",r.useMaxWidth),nO(m,r)},"draw"),nk=(0,m.K)(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),nI=(0,m.K)(e=>{let{theme:t,bkgColorArray:s,borderColorArray:i}=e;if(!(0,d.P1)(t,i))return"";let n=(0,p.zj)().usecase?.colorScheme==="rotate",a=(0,d.rq)(e.look),r="handDrawn"===a,o=(0,d.Ic)(s),l="";for(let e=0;e<(0,d.Hu)(i);e++){let t=i[e],c=o?`fill: ${s[e%s.length]};`:"",h=`[data-look="${a}"][data-color-id="color-${e}"]`;l+=`
58
+
59
+ & ${h}.system-boundary rect.boundary-body,
60
+ & ${h}.system-boundary rect.boundary-tab,
61
+ & ${h}.system-boundary .boundary-body path,
62
+ & ${h}.system-boundary .boundary-tab path {
63
+ stroke: ${t};
64
+ ${c}
65
+ }
66
+ `,n&&(l+=`
67
+
68
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
69
+ the business variant.
70
+
71
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
72
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
73
+ fill stroked in the background colour, with no class to tell them apart. Stroking
74
+ both repaints the fill lines as border colour and the shape collapses into a solid
75
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
76
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
77
+ & ${h}.usecase-element ellipse,
78
+ & ${h}.usecase-element rect {
79
+ stroke: ${t};
80
+ ${c}
81
+ }
82
+
83
+ /* The business marker is a single classed path, so it can be reached safely by name --
84
+ without it the marker keeps the uniform border beside a palette-coloured body. No
85
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
86
+ & ${h}.usecase-element .usecase-business-marker {
87
+ stroke: ${t};
88
+ }
89
+
90
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
91
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
92
+ winning and a hollow actor stays hollow. Same reason as above for not descending
93
+ into the handDrawn paths. */
94
+ & ${h}.usecase-actor .usecase-actor-shape,
95
+ & ${h}.usecase-actor .usecase-actor-hollow,
96
+ & ${h}.usecase-actor .usecase-actor-awesome,
97
+ & ${h}.usecase-actor .usecase-actor-icon {
98
+ stroke: ${t};
99
+ ${c}
100
+ }
101
+ ${r?"":`
102
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
103
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
104
+ and a value set directly on the child always beats one inherited from the parent,
105
+ whatever the parent rule's specificity. So name the children too.
106
+
107
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
108
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
109
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
110
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
111
+ & ${h}.usecase-actor .usecase-actor-glyph path,
112
+ & ${h}.usecase-actor .usecase-actor-glyph circle {
113
+ stroke: ${t};
114
+ }
115
+ `}
116
+ `)}return l},"genColor"),nN={parser:nh,db:sb,renderer:{draw:nR},styles:(0,m.K)(e=>{let t=nk(e),s="handDrawn"===(0,d.rq)(e.look);return`
117
+ ${nI(e)}
118
+ & .usecase-actor {
119
+ color: ${e.actorTextColor??e.primaryTextColor};
120
+ }
121
+
122
+ & .usecase-actor-shape,
123
+ & .usecase-actor-hollow,
124
+ & .usecase-actor-awesome,
125
+ & .usecase-actor-icon {
126
+ fill: ${t.actorBkg};
127
+ stroke: ${t.actorBorder};
128
+ stroke-width: 2px;
129
+ }
130
+ ${s?"":`
131
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
132
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
133
+ the glyph's own paths, and a value set directly on a child always beats one inherited
134
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
135
+ without this every actor renders in the node border colour rather than the actor
136
+ colour the rule above asks for.
137
+
138
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
139
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
140
+ depend on which stylesheet is concatenated last.
141
+
142
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
143
+ & .node.usecase-actor .usecase-actor-glyph path,
144
+ & .node.usecase-actor .usecase-actor-glyph circle {
145
+ stroke: ${t.actorBorder};
146
+ }
147
+ `}
148
+ & .usecase-actor .nodeLabel,
149
+ & .actor-label {
150
+ color: ${e.actorTextColor??e.primaryTextColor};
151
+ fill: ${e.actorTextColor??e.primaryTextColor};
152
+ font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
153
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
154
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
155
+ }
156
+
157
+ & .usecase-element ellipse,
158
+ & .usecase-element rect,
159
+ & .usecase-business ellipse,
160
+ & .usecase-business rect {
161
+ fill: ${t.bkg};
162
+ stroke: ${t.border};
163
+ stroke-width: 2px;
164
+ }
165
+ ${s?"":`
166
+ /* The same interception the actor glyph hits, one element down: neo ships
167
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
168
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
169
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
170
+ equivalent neo rule and is already correct; restating it here costs nothing and means
171
+ the two forms cannot drift apart again.
172
+
173
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
174
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
175
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
176
+ exists. */
177
+ & [data-look="${(0,d.rq)(e.look)}"].node.usecase-element ellipse,
178
+ & [data-look="${(0,d.rq)(e.look)}"].node.usecase-element rect {
179
+ fill: ${t.bkg};
180
+ stroke: ${t.border};
181
+ }
182
+
183
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
184
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
185
+ & [data-look="${(0,d.rq)(e.look)}"].node.usecase-element .usecase-business-marker {
186
+ stroke: ${t.border};
187
+ }
188
+ `}
189
+ & .usecase-element .nodeLabel,
190
+ & .usecase-label {
191
+ color: ${e.primaryTextColor};
192
+ fill: ${e.primaryTextColor};
193
+ font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
194
+ font-size: var(--mermaid-usecase-font-size, 12px);
195
+ font-weight: var(--mermaid-usecase-font-weight, normal);
196
+ }
197
+
198
+ & .usecase-stereotype,
199
+ & .usecase-business-marker {
200
+ color: ${e.primaryTextColor};
201
+ fill: ${e.primaryTextColor};
202
+ stroke: ${t.border};
203
+ }
204
+
205
+ & .system-boundary rect.boundary-body,
206
+ & .system-boundary rect.boundary-tab,
207
+ & .system-boundary-package-tab {
208
+ fill: ${t.boundaryBkg};
209
+ stroke: ${t.boundaryBorder};
210
+ stroke-width: 1px;
211
+ }
212
+
213
+ & .system-boundary-title text {
214
+ fill: ${e.titleColor??e.primaryTextColor};
215
+ }
216
+
217
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
218
+ 'color' on the span, and that has to stay inheritable by its children. */
219
+ & .system-boundary-title span {
220
+ color: ${e.titleColor??e.primaryTextColor};
221
+ }
222
+
223
+ & .usecase-note {
224
+ fill: ${e.noteBkgColor};
225
+ stroke: ${e.noteBorderColor};
226
+ color: ${e.noteTextColor};
227
+ }
228
+
229
+ & .usecase-note .nodeLabel {
230
+ color: ${e.noteTextColor};
231
+ fill: ${e.noteTextColor};
232
+ }
233
+
234
+ & .usecase-json-table,
235
+ & .usecase-json-table rect,
236
+ & .usecase-json-cell {
237
+ fill: ${e.mainBkg};
238
+ stroke: ${e.nodeBorder??e.primaryColor};
239
+ }
240
+
241
+ & .usecase-json-title,
242
+ & .usecase-json-key,
243
+ & .usecase-json-value {
244
+ color: ${e.primaryTextColor};
245
+ fill: ${e.primaryTextColor};
246
+ }
247
+
248
+ & .relationship {
249
+ fill: none;
250
+ stroke: ${e.lineColor};
251
+ }
252
+
253
+ & .relationship-include,
254
+ & .relationship-extend,
255
+ & .relationship-note {
256
+ stroke-dasharray: 3;
257
+ }
258
+
259
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
260
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
261
+ & .relationship-include {
262
+ stroke: ${t.includeLine};
263
+ }
264
+
265
+ & .relationship-extend {
266
+ stroke: ${t.extendLine};
267
+ }
268
+
269
+ & .relationship.edge-animation-fast,
270
+ & .relationship.edge-animation-slow {
271
+ stroke-linecap: round;
272
+ }
273
+
274
+ & .edgeLabel,
275
+ & .edgeLabel p {
276
+ background-color: ${e.edgeLabelBackground};
277
+ }
278
+
279
+ & .labelBkg {
280
+ background-color: ${e.edgeLabelBackground};
281
+ padding: 0 2px;
282
+ }
283
+
284
+ & .edgeLabel .label rect {
285
+ fill: ${e.edgeLabelBackground};
286
+ }
287
+
288
+ & .relationship-label,
289
+ & .edgeLabel {
290
+ color: ${e.primaryTextColor};
291
+ fill: ${e.primaryTextColor};
292
+ font-family: ${e.fontFamily};
293
+ font-size: 10px;
294
+ font-weight: normal;
295
+ }
296
+
297
+ & .marker,
298
+ & .marker.point,
299
+ & .marker.circle,
300
+ & .marker.cross {
301
+ fill: ${e.lineColor};
302
+ stroke: ${e.lineColor};
303
+ }
304
+
305
+ & .marker.extension {
306
+ fill: ${e.mainBkg};
307
+ stroke: ${e.lineColor};
308
+ }
309
+ `},"getStyles")}}}]);