@bkm016/basalt 0.1.20 → 0.1.21

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 (619) hide show
  1. package/{chunk-1tbv5t08.js → chunk-03b5jh31.js} +1 -1
  2. package/{chunk-3sg32v3n.js → chunk-0x0459qp.js} +1 -1
  3. package/{chunk-nszq2z0w.js → chunk-16yz5ebn.js} +1 -1
  4. package/chunk-1kdd7xry.js +2 -0
  5. package/{chunk-cks36jdh.js → chunk-225dyk1y.js} +2 -2
  6. package/{chunk-v7da0aqn.js → chunk-2fymxwe7.js} +2 -2
  7. package/{chunk-mde2dd79.js → chunk-2m2sa0bp.js} +1 -1
  8. package/{chunk-fgjw0r6g.js → chunk-35y6nf6k.js} +4 -4
  9. package/chunk-3qxq264t.js +2 -0
  10. package/{chunk-cwrf78vs.js → chunk-3s8rpc1w.js} +2 -2
  11. package/{chunk-wj09qkyw.js → chunk-3t8wz9w8.js} +2 -2
  12. package/{chunk-gg3kfa12.js → chunk-43qf44t8.js} +2 -2
  13. package/chunk-49hsqsht.js +2 -0
  14. package/chunk-4fj91gt1.js +4 -0
  15. package/{chunk-tb3zsqe8.js → chunk-51a0843g.js} +1 -1
  16. package/{chunk-51pfvmhh.js → chunk-5h59tby8.js} +69 -69
  17. package/{chunk-bkhsva5n.js → chunk-5m51j40e.js} +3 -3
  18. package/{chunk-2fts9k52.js → chunk-5mt8xxex.js} +2 -2
  19. package/{chunk-5e7yegea.js → chunk-85sjfyjd.js} +1 -1
  20. package/chunk-97ntcrm7.js +2 -0
  21. package/{chunk-0bgg0hdd.js → chunk-9t3v8c3m.js} +1 -1
  22. package/{chunk-7kz9435k.js → chunk-9w1m9av8.js} +3 -3
  23. package/{chunk-d2f0hq8z.js → chunk-9x28stv0.js} +1 -1
  24. package/{chunk-c5pg2875.js → chunk-ak95r8mq.js} +254 -250
  25. package/{chunk-a1vdrgsh.js → chunk-bn1aaewd.js} +4 -4
  26. package/{chunk-agb771ak.js → chunk-c5ydt3vq.js} +2 -2
  27. package/{chunk-y83tnkr3.js → chunk-cjh5h31t.js} +2 -2
  28. package/{chunk-p0e82mee.js → chunk-cr0tqn6j.js} +2 -2
  29. package/{chunk-np2xnt1g.js → chunk-e8xywvv4.js} +2 -2
  30. package/{chunk-w6nc3jn7.js → chunk-ewaskman.js} +1 -1
  31. package/{chunk-w045zk55.js → chunk-feyt85gg.js} +1 -1
  32. package/{chunk-s8m4svhf.js → chunk-ftg4b5pa.js} +1 -1
  33. package/{chunk-s819vmwh.js → chunk-g6cc7ac1.js} +2 -2
  34. package/{chunk-5ja0vsam.js → chunk-gdx1j9c5.js} +3 -3
  35. package/{chunk-h2pp8mnh.js → chunk-h00wjps7.js} +1 -1
  36. package/{chunk-4dgqcp6q.js → chunk-h1fwdz4h.js} +1 -1
  37. package/{chunk-6en06hkk.js → chunk-hhxtc9jn.js} +1 -1
  38. package/chunk-hrn2ss1a.js +2 -0
  39. package/chunk-jhwb962k.js +15 -0
  40. package/{chunk-11xxfc0x.js → chunk-jpwr1sd2.js} +1 -1
  41. package/chunk-jy07y4pv.js +7 -0
  42. package/{chunk-0g8rtf05.js → chunk-k9x1r69s.js} +8 -8
  43. package/chunk-kb5h9rmb.js +2 -0
  44. package/{chunk-eps1epfr.js → chunk-kgnd32hn.js} +2 -2
  45. package/{chunk-w9fdcchk.js → chunk-kka12j10.js} +1 -1
  46. package/{chunk-1gaj43fx.js → chunk-kypdthjg.js} +1 -1
  47. package/{chunk-30bbdzma.js → chunk-m9386732.js} +12 -12
  48. package/{chunk-qxpx8dn6.js → chunk-np123myw.js} +3 -3
  49. package/chunk-ntntwtxn.js +5 -0
  50. package/{chunk-29g01nrz.js → chunk-qn70tm91.js} +5 -5
  51. package/{chunk-yk29stq0.js → chunk-qtgc74er.js} +2 -2
  52. package/{chunk-tp885r8h.js → chunk-qz6ybxjg.js} +9 -9
  53. package/chunk-r36b12zb.js +2 -0
  54. package/{chunk-as2mwf79.js → chunk-re8n2te5.js} +1 -1
  55. package/{chunk-y3vap4a1.js → chunk-rpbxbb92.js} +1 -1
  56. package/chunk-rqrjzz73.js +2 -0
  57. package/{chunk-tpetsqzt.js → chunk-scy1p7x2.js} +3 -3
  58. package/{chunk-svx7mz0w.js → chunk-sq5ppnr3.js} +3 -3
  59. package/{chunk-e3bgzeb3.js → chunk-syhhzr1j.js} +2 -2
  60. package/chunk-tmq8ktys.js +3 -0
  61. package/{chunk-sm9fpy18.js → chunk-ttv805sb.js} +8 -8
  62. package/{chunk-eyyxqb6y.js → chunk-v878x8zr.js} +2 -2
  63. package/{chunk-a2z1cy84.js → chunk-ve1b6vg6.js} +1 -1
  64. package/chunk-w3n8wm44.js +2 -0
  65. package/{chunk-z9p2ry9w.js → chunk-w3skxmvx.js} +2 -2
  66. package/chunk-wxzk086k.js +2 -0
  67. package/chunk-y8mf9tcj.js +25 -0
  68. package/{chunk-ewr51fwc.js → chunk-z4g2q36h.js} +1 -1
  69. package/compiled.js +8 -8
  70. package/package.json +1 -1
  71. package/ui-test-worker.js +16 -16
  72. package/web/{chunk-mbpv2w5h.js → chunk-07dd0jed.js} +2 -2
  73. package/web/chunk-07dd0jed.js.br +0 -0
  74. package/web/chunk-07dd0jed.js.gz +0 -0
  75. package/web/{chunk-d7f85w1y.js → chunk-0hvyq55w.js} +1 -1
  76. package/web/chunk-0hvyq55w.js.br +0 -0
  77. package/web/chunk-0hvyq55w.js.gz +0 -0
  78. package/web/{chunk-ahdca62g.js → chunk-0q5drhbk.js} +1 -1
  79. package/web/chunk-0q5drhbk.js.br +0 -0
  80. package/web/chunk-0q5drhbk.js.gz +0 -0
  81. package/web/{chunk-zthww0ws.js → chunk-0w6ta3ps.js} +1 -1
  82. package/web/chunk-0w6ta3ps.js.br +0 -0
  83. package/web/chunk-0w6ta3ps.js.gz +0 -0
  84. package/web/{chunk-aw9bwd4w.js → chunk-16b5anw4.js} +2 -2
  85. package/web/chunk-16b5anw4.js.br +0 -0
  86. package/web/chunk-16b5anw4.js.gz +0 -0
  87. package/web/{chunk-53cg6pxm.js → chunk-21d8pzcm.js} +2 -2
  88. package/web/chunk-21d8pzcm.js.br +0 -0
  89. package/web/{chunk-53cg6pxm.js.gz → chunk-21d8pzcm.js.gz} +0 -0
  90. package/web/{chunk-72st75n7.js → chunk-2c4affp1.js} +3 -3
  91. package/web/chunk-2c4affp1.js.br +0 -0
  92. package/web/chunk-2c4affp1.js.gz +0 -0
  93. package/web/{chunk-1ghnag5v.js → chunk-2dykyq1n.js} +1 -1
  94. package/web/chunk-2dykyq1n.js.br +0 -0
  95. package/web/chunk-2dykyq1n.js.gz +0 -0
  96. package/web/{chunk-znrsm604.js → chunk-2h2w244w.js} +17 -17
  97. package/web/chunk-2h2w244w.js.br +0 -0
  98. package/web/chunk-2h2w244w.js.gz +0 -0
  99. package/web/{chunk-kdegb6pd.js → chunk-2hd51wb6.js} +5 -5
  100. package/web/chunk-2hd51wb6.js.br +0 -0
  101. package/web/chunk-2hd51wb6.js.gz +0 -0
  102. package/web/{chunk-2rnnvxa5.js → chunk-2tc6krye.js} +3 -3
  103. package/web/chunk-2tc6krye.js.br +0 -0
  104. package/web/chunk-2tc6krye.js.gz +0 -0
  105. package/web/{chunk-7h59ac2b.js → chunk-2w27acew.js} +1 -1
  106. package/web/chunk-2w27acew.js.br +0 -0
  107. package/web/chunk-2w27acew.js.gz +0 -0
  108. package/web/{chunk-gbcf0rdk.js → chunk-2w4rdnhj.js} +1 -1
  109. package/web/chunk-2w4rdnhj.js.br +0 -0
  110. package/web/chunk-2w4rdnhj.js.gz +0 -0
  111. package/web/{chunk-gj6bdv1y.js → chunk-31vxes2p.js} +9 -9
  112. package/web/chunk-31vxes2p.js.br +0 -0
  113. package/web/chunk-31vxes2p.js.gz +0 -0
  114. package/web/chunk-32qd2y5h.js +1 -0
  115. package/web/chunk-32qd2y5h.js.br +0 -0
  116. package/web/chunk-32qd2y5h.js.gz +0 -0
  117. package/web/{chunk-qx5ab39c.js → chunk-39kaz6fa.js} +2 -2
  118. package/web/chunk-39kaz6fa.js.br +0 -0
  119. package/web/chunk-39kaz6fa.js.gz +0 -0
  120. package/web/{chunk-mj8dzc8q.js → chunk-3d3y4tep.js} +5 -5
  121. package/web/chunk-3d3y4tep.js.br +0 -0
  122. package/web/chunk-3d3y4tep.js.gz +0 -0
  123. package/web/chunk-4makcmpw.js +1 -0
  124. package/web/chunk-4makcmpw.js.br +0 -0
  125. package/web/chunk-4makcmpw.js.gz +0 -0
  126. package/web/{chunk-1ps9fj5n.js → chunk-4zftsyq2.js} +2 -2
  127. package/web/chunk-4zftsyq2.js.br +0 -0
  128. package/web/chunk-4zftsyq2.js.gz +0 -0
  129. package/web/{chunk-bks2k04k.js → chunk-50wrjr22.js} +1 -1
  130. package/web/chunk-50wrjr22.js.br +0 -0
  131. package/web/chunk-50wrjr22.js.gz +0 -0
  132. package/web/{chunk-mhzqgzh0.js → chunk-55kw8p9r.js} +1 -1
  133. package/web/chunk-55kw8p9r.js.br +0 -0
  134. package/web/chunk-55kw8p9r.js.gz +0 -0
  135. package/web/{chunk-gpjytpyw.js → chunk-56tqa12m.js} +2 -2
  136. package/web/chunk-56tqa12m.js.br +0 -0
  137. package/web/chunk-56tqa12m.js.gz +0 -0
  138. package/web/{chunk-wbxz2bjb.js → chunk-595tqsv5.js} +1 -1
  139. package/web/chunk-595tqsv5.js.br +0 -0
  140. package/web/chunk-595tqsv5.js.gz +0 -0
  141. package/web/chunk-5h193k2c.js +1 -0
  142. package/web/chunk-5h193k2c.js.br +0 -0
  143. package/web/chunk-5h193k2c.js.gz +0 -0
  144. package/web/{chunk-k4pknkvp.js → chunk-5nbmnchg.js} +1 -1
  145. package/web/chunk-5nbmnchg.js.br +0 -0
  146. package/web/chunk-5nbmnchg.js.gz +0 -0
  147. package/web/{chunk-gk1bc3c3.js → chunk-5vc1wkwb.js} +1 -1
  148. package/web/chunk-5vc1wkwb.js.br +0 -0
  149. package/web/chunk-5vc1wkwb.js.gz +0 -0
  150. package/web/{chunk-tgeeggkh.js → chunk-5wgdprjp.js} +1 -1
  151. package/web/chunk-5wgdprjp.js.br +0 -0
  152. package/web/chunk-5wgdprjp.js.gz +0 -0
  153. package/web/{chunk-esckazz2.js → chunk-60fbfw70.js} +1 -1
  154. package/web/chunk-60fbfw70.js.br +0 -0
  155. package/web/chunk-60fbfw70.js.gz +0 -0
  156. package/web/{chunk-v5p2fds9.js → chunk-62z94rt2.js} +4 -4
  157. package/web/chunk-62z94rt2.js.br +0 -0
  158. package/web/chunk-62z94rt2.js.gz +0 -0
  159. package/web/chunk-67khfy00.css +1 -0
  160. package/web/chunk-67khfy00.css.br +0 -0
  161. package/web/chunk-67khfy00.css.gz +0 -0
  162. package/web/chunk-6bt2t0xt.js +8 -0
  163. package/web/chunk-6bt2t0xt.js.br +0 -0
  164. package/web/chunk-6bt2t0xt.js.gz +0 -0
  165. package/web/{chunk-h1c0m3g4.js → chunk-780qvh05.js} +3 -3
  166. package/web/chunk-780qvh05.js.br +0 -0
  167. package/web/chunk-780qvh05.js.gz +0 -0
  168. package/web/{chunk-k6fwzn0z.js → chunk-78t5dqea.js} +1 -1
  169. package/web/chunk-78t5dqea.js.br +0 -0
  170. package/web/chunk-78t5dqea.js.gz +0 -0
  171. package/web/chunk-7edmyret.js +1 -0
  172. package/web/chunk-7edmyret.js.br +0 -0
  173. package/web/chunk-7edmyret.js.gz +0 -0
  174. package/web/{chunk-cmhxtckb.js → chunk-7remkcff.js} +1 -1
  175. package/web/chunk-7remkcff.js.br +0 -0
  176. package/web/chunk-7remkcff.js.gz +0 -0
  177. package/web/chunk-7s062q01.js +1 -0
  178. package/web/chunk-7s062q01.js.br +0 -0
  179. package/web/chunk-7s062q01.js.gz +0 -0
  180. package/web/chunk-82zwwy0b.js +1 -0
  181. package/web/chunk-82zwwy0b.js.br +0 -0
  182. package/web/chunk-82zwwy0b.js.gz +0 -0
  183. package/web/{chunk-wa8wr2y9.js → chunk-8c6h952g.js} +9 -9
  184. package/web/chunk-8c6h952g.js.br +0 -0
  185. package/web/chunk-8c6h952g.js.gz +0 -0
  186. package/web/chunk-8wgev3hd.js +1 -0
  187. package/web/chunk-8wgev3hd.js.br +0 -0
  188. package/web/chunk-8wgev3hd.js.gz +0 -0
  189. package/web/chunk-9vcbnf1m.js +1 -0
  190. package/web/chunk-9vcbnf1m.js.br +0 -0
  191. package/web/chunk-9vcbnf1m.js.gz +0 -0
  192. package/web/{chunk-kedjfh66.js → chunk-abahqsws.js} +1 -1
  193. package/web/chunk-abahqsws.js.br +0 -0
  194. package/web/chunk-abahqsws.js.gz +0 -0
  195. package/web/{chunk-vhpzp7zd.js → chunk-acv6gk2b.js} +1 -1
  196. package/web/chunk-acv6gk2b.js.br +0 -0
  197. package/web/chunk-acv6gk2b.js.gz +0 -0
  198. package/web/{chunk-bg0qgabv.js → chunk-ajpzsx51.js} +1 -1
  199. package/web/chunk-ajpzsx51.js.br +0 -0
  200. package/web/chunk-ajpzsx51.js.gz +0 -0
  201. package/web/chunk-b1b9txvk.js +1 -0
  202. package/web/chunk-b1b9txvk.js.br +0 -0
  203. package/web/chunk-b1b9txvk.js.gz +0 -0
  204. package/web/{chunk-qjg6dw46.js → chunk-b83bzjcx.js} +73 -73
  205. package/web/chunk-b83bzjcx.js.br +0 -0
  206. package/web/chunk-b83bzjcx.js.gz +0 -0
  207. package/web/{chunk-v6snw1sw.js → chunk-c1zhat04.js} +1 -1
  208. package/web/chunk-c1zhat04.js.br +0 -0
  209. package/web/chunk-c1zhat04.js.gz +0 -0
  210. package/web/{chunk-186rp10x.js → chunk-c37hhmtd.js} +1 -1
  211. package/web/chunk-c37hhmtd.js.br +0 -0
  212. package/web/chunk-c37hhmtd.js.gz +0 -0
  213. package/web/{chunk-wvqcbp4a.js → chunk-c69t0ysj.js} +1 -1
  214. package/web/chunk-c69t0ysj.js.br +0 -0
  215. package/web/chunk-c69t0ysj.js.gz +0 -0
  216. package/web/chunk-caz85hz4.js +1 -0
  217. package/web/chunk-caz85hz4.js.br +0 -0
  218. package/web/chunk-caz85hz4.js.gz +0 -0
  219. package/web/{chunk-6n1ha6ta.js → chunk-cbtpaf3e.js} +1 -1
  220. package/web/chunk-cbtpaf3e.js.br +0 -0
  221. package/web/chunk-cbtpaf3e.js.gz +0 -0
  222. package/web/{chunk-dmhezjv3.js → chunk-d1gga18f.js} +4 -4
  223. package/web/chunk-d1gga18f.js.br +0 -0
  224. package/web/chunk-d1gga18f.js.gz +0 -0
  225. package/web/{chunk-q0srq8g5.js → chunk-d4kjy2qn.js} +1 -1
  226. package/web/chunk-d4kjy2qn.js.br +0 -0
  227. package/web/chunk-d4kjy2qn.js.gz +0 -0
  228. package/web/{chunk-v2bkkhb8.js → chunk-dbv8qpen.js} +41 -41
  229. package/web/chunk-dbv8qpen.js.br +0 -0
  230. package/web/chunk-dbv8qpen.js.gz +0 -0
  231. package/web/{chunk-37hmswdk.js → chunk-e6r1sb5r.js} +5 -5
  232. package/web/chunk-e6r1sb5r.js.br +0 -0
  233. package/web/chunk-e6r1sb5r.js.gz +0 -0
  234. package/web/chunk-ep5qff8m.js +1 -0
  235. package/web/chunk-ep5qff8m.js.br +0 -0
  236. package/web/chunk-ep5qff8m.js.gz +0 -0
  237. package/web/{chunk-c28crzwk.js → chunk-ex66t805.js} +1 -1
  238. package/web/chunk-ex66t805.js.br +0 -0
  239. package/web/chunk-ex66t805.js.gz +0 -0
  240. package/web/chunk-fb8qtyqg.js +1 -0
  241. package/web/chunk-fb8qtyqg.js.br +0 -0
  242. package/web/chunk-fb8qtyqg.js.gz +0 -0
  243. package/web/{chunk-vpbnyz43.js → chunk-fbzhgaak.js} +1 -1
  244. package/web/chunk-fbzhgaak.js.br +0 -0
  245. package/web/chunk-fbzhgaak.js.gz +0 -0
  246. package/web/{chunk-9n1nsdqs.js → chunk-ffwyfdg4.js} +1 -1
  247. package/web/chunk-ffwyfdg4.js.br +0 -0
  248. package/web/chunk-ffwyfdg4.js.gz +0 -0
  249. package/web/{chunk-0tcmnvab.js → chunk-fsz1msjr.js} +1 -1
  250. package/web/chunk-fsz1msjr.js.br +0 -0
  251. package/web/chunk-fsz1msjr.js.gz +0 -0
  252. package/web/{chunk-nb58m79v.js → chunk-fztzcy7c.js} +1 -1
  253. package/web/chunk-fztzcy7c.js.br +0 -0
  254. package/web/chunk-fztzcy7c.js.gz +0 -0
  255. package/web/chunk-g4st8a4e.js +1 -0
  256. package/web/chunk-g4st8a4e.js.br +0 -0
  257. package/web/chunk-g4st8a4e.js.gz +0 -0
  258. package/web/{chunk-82q4e8ff.js → chunk-gs41j1vb.js} +1 -1
  259. package/web/chunk-gs41j1vb.js.br +0 -0
  260. package/web/chunk-gs41j1vb.js.gz +0 -0
  261. package/web/{chunk-dmzvhbpn.js → chunk-gt4dzb4b.js} +3 -3
  262. package/web/chunk-gt4dzb4b.js.br +0 -0
  263. package/web/chunk-gt4dzb4b.js.gz +0 -0
  264. package/web/{chunk-1yvcxpp2.js → chunk-h4g8j133.js} +4 -4
  265. package/web/chunk-h4g8j133.js.br +0 -0
  266. package/web/chunk-h4g8j133.js.gz +0 -0
  267. package/web/chunk-ht3cek8b.js +1 -0
  268. package/web/chunk-ht3cek8b.js.br +2 -0
  269. package/web/chunk-ht3cek8b.js.gz +0 -0
  270. package/web/{chunk-3fd6mgf0.js → chunk-hw4f79k8.js} +1 -1
  271. package/web/chunk-hw4f79k8.js.br +0 -0
  272. package/web/chunk-hw4f79k8.js.gz +0 -0
  273. package/web/{chunk-js940jjj.js → chunk-j2y3wkxc.js} +4 -4
  274. package/web/chunk-j2y3wkxc.js.br +0 -0
  275. package/web/chunk-j2y3wkxc.js.gz +0 -0
  276. package/web/{chunk-vh2prc6k.js → chunk-j7sfcfxr.js} +1 -1
  277. package/web/chunk-j7sfcfxr.js.br +0 -0
  278. package/web/chunk-j7sfcfxr.js.gz +0 -0
  279. package/web/{chunk-ye7vge7s.js → chunk-jge5e8c4.js} +1 -1
  280. package/web/chunk-jge5e8c4.js.br +0 -0
  281. package/web/chunk-jge5e8c4.js.gz +0 -0
  282. package/web/chunk-jyjgvcac.js +2 -0
  283. package/web/chunk-jyjgvcac.js.br +0 -0
  284. package/web/chunk-jyjgvcac.js.gz +0 -0
  285. package/web/chunk-k9bzz441.js +1 -0
  286. package/web/chunk-k9bzz441.js.br +0 -0
  287. package/web/chunk-k9bzz441.js.gz +0 -0
  288. package/web/{chunk-e2z3kdhw.js → chunk-keway722.js} +3 -3
  289. package/web/chunk-keway722.js.br +0 -0
  290. package/web/chunk-keway722.js.gz +0 -0
  291. package/web/{chunk-ezj5rjqr.js → chunk-kr7shpnb.js} +1 -1
  292. package/web/chunk-kr7shpnb.js.br +0 -0
  293. package/web/chunk-kr7shpnb.js.gz +0 -0
  294. package/web/chunk-kv5swske.js +1 -0
  295. package/web/chunk-kv5swske.js.br +0 -0
  296. package/web/chunk-kv5swske.js.gz +0 -0
  297. package/web/{chunk-a8qe7kvz.js → chunk-kx2k462h.js} +1 -1
  298. package/web/chunk-kx2k462h.js.br +0 -0
  299. package/web/chunk-kx2k462h.js.gz +0 -0
  300. package/web/{chunk-recfg8af.js → chunk-m5b7hny2.js} +1 -1
  301. package/web/chunk-m5b7hny2.js.br +0 -0
  302. package/web/chunk-m5b7hny2.js.gz +0 -0
  303. package/web/{chunk-vxadngbp.js → chunk-m7kypzvp.js} +1 -1
  304. package/web/chunk-m7kypzvp.js.br +0 -0
  305. package/web/chunk-m7kypzvp.js.gz +0 -0
  306. package/web/{chunk-mwfrxgbs.js → chunk-n00se8nk.js} +1 -1
  307. package/web/chunk-n00se8nk.js.br +0 -0
  308. package/web/chunk-n00se8nk.js.gz +0 -0
  309. package/web/{chunk-hqt1f3fm.js → chunk-ngdj0r7w.js} +1 -1
  310. package/web/chunk-ngdj0r7w.js.br +0 -0
  311. package/web/chunk-ngdj0r7w.js.gz +0 -0
  312. package/web/{chunk-zbzgd8kn.js → chunk-p6ma361e.js} +1 -1
  313. package/web/chunk-p6ma361e.js.br +0 -0
  314. package/web/chunk-p6ma361e.js.gz +0 -0
  315. package/web/{chunk-1ratg1jd.js → chunk-pvhz0gqy.js} +1 -1
  316. package/web/chunk-pvhz0gqy.js.br +0 -0
  317. package/web/chunk-pvhz0gqy.js.gz +0 -0
  318. package/web/chunk-q96eky9v.js +1 -0
  319. package/web/chunk-q96eky9v.js.br +0 -0
  320. package/web/chunk-q96eky9v.js.gz +0 -0
  321. package/web/{chunk-1cwyy3gh.js → chunk-qcgs1mft.js} +1 -1
  322. package/web/chunk-qcgs1mft.js.br +0 -0
  323. package/web/chunk-qcgs1mft.js.gz +0 -0
  324. package/web/{chunk-hwxj58j5.js → chunk-qh24q7c0.js} +1 -1
  325. package/web/chunk-qh24q7c0.js.br +0 -0
  326. package/web/chunk-qh24q7c0.js.gz +0 -0
  327. package/web/chunk-r1xksxab.js +1 -0
  328. package/web/chunk-r1xksxab.js.br +0 -0
  329. package/web/chunk-r1xksxab.js.gz +0 -0
  330. package/web/{chunk-fjrgg82c.js → chunk-rsc5k5he.js} +4 -4
  331. package/web/chunk-rsc5k5he.js.br +0 -0
  332. package/web/chunk-rsc5k5he.js.gz +0 -0
  333. package/web/{chunk-apr33amc.js → chunk-s7a2f62f.js} +1 -1
  334. package/web/chunk-s7a2f62f.js.br +0 -0
  335. package/web/chunk-s7a2f62f.js.gz +0 -0
  336. package/web/{chunk-0h0whn75.js → chunk-sac6fn9n.js} +1 -1
  337. package/web/chunk-sac6fn9n.js.br +0 -0
  338. package/web/chunk-sac6fn9n.js.gz +0 -0
  339. package/web/{chunk-6a3wt5c5.js → chunk-t0xjx21h.js} +3 -3
  340. package/web/chunk-t0xjx21h.js.br +0 -0
  341. package/web/chunk-t0xjx21h.js.gz +0 -0
  342. package/web/{chunk-tg3f9xmp.js → chunk-v7ck87jf.js} +1 -1
  343. package/web/chunk-v7ck87jf.js.br +0 -0
  344. package/web/chunk-v7ck87jf.js.gz +0 -0
  345. package/web/{chunk-jmnzcm1f.js → chunk-vvk9nche.js} +4 -4
  346. package/web/chunk-vvk9nche.js.br +0 -0
  347. package/web/chunk-vvk9nche.js.gz +0 -0
  348. package/web/chunk-vxtfen72.js +1 -0
  349. package/web/chunk-vxtfen72.js.br +0 -0
  350. package/web/chunk-vxtfen72.js.gz +0 -0
  351. package/web/{chunk-81xbfpbq.js → chunk-w5c2r59n.js} +1 -1
  352. package/web/chunk-w5c2r59n.js.br +0 -0
  353. package/web/chunk-w5c2r59n.js.gz +0 -0
  354. package/web/{chunk-08w40agf.js → chunk-wh0vt2vd.js} +7 -7
  355. package/web/chunk-wh0vt2vd.js.br +0 -0
  356. package/web/chunk-wh0vt2vd.js.gz +0 -0
  357. package/web/chunk-xe7fj72r.js +1 -0
  358. package/web/chunk-xe7fj72r.js.br +0 -0
  359. package/web/chunk-xe7fj72r.js.gz +0 -0
  360. package/web/{chunk-59h87pvn.js → chunk-yarsp7h7.js} +1 -1
  361. package/web/chunk-yarsp7h7.js.br +0 -0
  362. package/web/chunk-yarsp7h7.js.gz +0 -0
  363. package/web/{chunk-x2hxq5yr.js → chunk-yw5wyz1q.js} +1 -1
  364. package/web/chunk-yw5wyz1q.js.br +0 -0
  365. package/web/chunk-yw5wyz1q.js.gz +0 -0
  366. package/web/chunk-z3ea4vhk.js +1 -0
  367. package/web/chunk-z3ea4vhk.js.br +0 -0
  368. package/web/chunk-z3ea4vhk.js.gz +0 -0
  369. package/web/{chunk-6pbhqbv0.js → chunk-z7adzvfz.js} +1 -1
  370. package/web/chunk-z7adzvfz.js.br +0 -0
  371. package/web/chunk-z7adzvfz.js.gz +0 -0
  372. package/web/{chunk-mh3nkkpx.js → chunk-zb01zmms.js} +6 -6
  373. package/web/chunk-zb01zmms.js.br +0 -0
  374. package/web/chunk-zb01zmms.js.gz +0 -0
  375. package/web/index.html +1 -1
  376. package/web/index.html.br +0 -0
  377. package/web/index.html.gz +0 -0
  378. package/worker.js +1 -1
  379. package/chunk-0wwd4q6h.js +0 -5
  380. package/chunk-204c01mz.js +0 -25
  381. package/chunk-4wc2gbhe.js +0 -2
  382. package/chunk-5tsfqsmf.js +0 -2
  383. package/chunk-6hatfwsq.js +0 -2
  384. package/chunk-78ky455y.js +0 -4
  385. package/chunk-8mqaq042.js +0 -2
  386. package/chunk-g9hsrrj5.js +0 -2
  387. package/chunk-gpceyezp.js +0 -2
  388. package/chunk-h4n0gg11.js +0 -2
  389. package/chunk-jzya0e5n.js +0 -7
  390. package/chunk-ncb0tyaw.js +0 -2
  391. package/chunk-tpeg9fkd.js +0 -2
  392. package/chunk-v0mw006s.js +0 -15
  393. package/chunk-ys2fds2x.js +0 -3
  394. package/chunk-yshdvnsp.js +0 -2
  395. package/web/chunk-08w40agf.js.br +0 -0
  396. package/web/chunk-08w40agf.js.gz +0 -0
  397. package/web/chunk-0bfypmyv.js +0 -1
  398. package/web/chunk-0bfypmyv.js.br +0 -2
  399. package/web/chunk-0bfypmyv.js.gz +0 -0
  400. package/web/chunk-0h0whn75.js.br +0 -0
  401. package/web/chunk-0h0whn75.js.gz +0 -0
  402. package/web/chunk-0pzs9k06.js +0 -1
  403. package/web/chunk-0pzs9k06.js.br +0 -0
  404. package/web/chunk-0pzs9k06.js.gz +0 -0
  405. package/web/chunk-0tcmnvab.js.br +0 -0
  406. package/web/chunk-0tcmnvab.js.gz +0 -0
  407. package/web/chunk-186rp10x.js.br +0 -0
  408. package/web/chunk-186rp10x.js.gz +0 -0
  409. package/web/chunk-1cwyy3gh.js.br +0 -0
  410. package/web/chunk-1cwyy3gh.js.gz +0 -0
  411. package/web/chunk-1ecsxh85.js +0 -1
  412. package/web/chunk-1ecsxh85.js.br +0 -0
  413. package/web/chunk-1ecsxh85.js.gz +0 -0
  414. package/web/chunk-1ghnag5v.js.br +0 -0
  415. package/web/chunk-1ghnag5v.js.gz +0 -0
  416. package/web/chunk-1ps9fj5n.js.br +0 -0
  417. package/web/chunk-1ps9fj5n.js.gz +0 -0
  418. package/web/chunk-1ratg1jd.js.br +0 -0
  419. package/web/chunk-1ratg1jd.js.gz +0 -0
  420. package/web/chunk-1yvcxpp2.js.br +0 -0
  421. package/web/chunk-1yvcxpp2.js.gz +0 -0
  422. package/web/chunk-2r3w0pt0.js +0 -8
  423. package/web/chunk-2r3w0pt0.js.br +0 -0
  424. package/web/chunk-2r3w0pt0.js.gz +0 -0
  425. package/web/chunk-2rnnvxa5.js.br +0 -0
  426. package/web/chunk-2rnnvxa5.js.gz +0 -0
  427. package/web/chunk-2stffcvc.js +0 -1
  428. package/web/chunk-2stffcvc.js.br +0 -0
  429. package/web/chunk-2stffcvc.js.gz +0 -0
  430. package/web/chunk-2svqgkqw.js +0 -1
  431. package/web/chunk-2svqgkqw.js.br +0 -0
  432. package/web/chunk-2svqgkqw.js.gz +0 -0
  433. package/web/chunk-37hmswdk.js.br +0 -0
  434. package/web/chunk-37hmswdk.js.gz +0 -0
  435. package/web/chunk-3fd6mgf0.js.br +0 -0
  436. package/web/chunk-3fd6mgf0.js.gz +0 -0
  437. package/web/chunk-53cg6pxm.js.br +0 -0
  438. package/web/chunk-59h87pvn.js.br +0 -0
  439. package/web/chunk-59h87pvn.js.gz +0 -0
  440. package/web/chunk-6a3wt5c5.js.br +0 -0
  441. package/web/chunk-6a3wt5c5.js.gz +0 -0
  442. package/web/chunk-6n1ha6ta.js.br +0 -0
  443. package/web/chunk-6n1ha6ta.js.gz +0 -0
  444. package/web/chunk-6pbhqbv0.js.br +0 -0
  445. package/web/chunk-6pbhqbv0.js.gz +0 -0
  446. package/web/chunk-72st75n7.js.br +0 -0
  447. package/web/chunk-72st75n7.js.gz +0 -0
  448. package/web/chunk-7h59ac2b.js.br +0 -0
  449. package/web/chunk-7h59ac2b.js.gz +0 -0
  450. package/web/chunk-81xbfpbq.js.br +0 -0
  451. package/web/chunk-81xbfpbq.js.gz +0 -0
  452. package/web/chunk-82q4e8ff.js.br +0 -0
  453. package/web/chunk-82q4e8ff.js.gz +0 -0
  454. package/web/chunk-89e8629e.js +0 -1
  455. package/web/chunk-89e8629e.js.br +0 -0
  456. package/web/chunk-89e8629e.js.gz +0 -0
  457. package/web/chunk-9n1nsdqs.js.br +0 -0
  458. package/web/chunk-9n1nsdqs.js.gz +0 -0
  459. package/web/chunk-a8qe7kvz.js.br +0 -0
  460. package/web/chunk-a8qe7kvz.js.gz +0 -0
  461. package/web/chunk-ahdca62g.js.br +0 -0
  462. package/web/chunk-ahdca62g.js.gz +0 -0
  463. package/web/chunk-apr33amc.js.br +0 -0
  464. package/web/chunk-apr33amc.js.gz +0 -0
  465. package/web/chunk-aw9bwd4w.js.br +0 -0
  466. package/web/chunk-aw9bwd4w.js.gz +0 -0
  467. package/web/chunk-bg0qgabv.js.br +0 -0
  468. package/web/chunk-bg0qgabv.js.gz +0 -0
  469. package/web/chunk-bks2k04k.js.br +0 -0
  470. package/web/chunk-bks2k04k.js.gz +0 -0
  471. package/web/chunk-c28crzwk.js.br +0 -0
  472. package/web/chunk-c28crzwk.js.gz +0 -0
  473. package/web/chunk-cmhxtckb.js.br +0 -0
  474. package/web/chunk-cmhxtckb.js.gz +0 -0
  475. package/web/chunk-d7f85w1y.js.br +0 -0
  476. package/web/chunk-d7f85w1y.js.gz +0 -0
  477. package/web/chunk-dmhezjv3.js.br +0 -0
  478. package/web/chunk-dmhezjv3.js.gz +0 -0
  479. package/web/chunk-dmzvhbpn.js.br +0 -0
  480. package/web/chunk-dmzvhbpn.js.gz +0 -0
  481. package/web/chunk-e2z3kdhw.js.br +0 -0
  482. package/web/chunk-e2z3kdhw.js.gz +0 -0
  483. package/web/chunk-eqmghkwh.js +0 -1
  484. package/web/chunk-eqmghkwh.js.br +0 -0
  485. package/web/chunk-eqmghkwh.js.gz +0 -0
  486. package/web/chunk-esckazz2.js.br +0 -0
  487. package/web/chunk-esckazz2.js.gz +0 -0
  488. package/web/chunk-ezj5rjqr.js.br +0 -0
  489. package/web/chunk-ezj5rjqr.js.gz +0 -0
  490. package/web/chunk-fjrgg82c.js.br +0 -0
  491. package/web/chunk-fjrgg82c.js.gz +0 -0
  492. package/web/chunk-gbcf0rdk.js.br +0 -0
  493. package/web/chunk-gbcf0rdk.js.gz +0 -0
  494. package/web/chunk-gj6bdv1y.js.br +0 -0
  495. package/web/chunk-gj6bdv1y.js.gz +0 -0
  496. package/web/chunk-gk1bc3c3.js.br +0 -0
  497. package/web/chunk-gk1bc3c3.js.gz +0 -0
  498. package/web/chunk-gpjytpyw.js.br +0 -0
  499. package/web/chunk-gpjytpyw.js.gz +0 -0
  500. package/web/chunk-h1c0m3g4.js.br +0 -0
  501. package/web/chunk-h1c0m3g4.js.gz +0 -0
  502. package/web/chunk-h1qv0cpd.css +0 -1
  503. package/web/chunk-h1qv0cpd.css.br +0 -0
  504. package/web/chunk-h1qv0cpd.css.gz +0 -0
  505. package/web/chunk-hq7e5xgd.js +0 -1
  506. package/web/chunk-hq7e5xgd.js.br +0 -0
  507. package/web/chunk-hq7e5xgd.js.gz +0 -0
  508. package/web/chunk-hqt1f3fm.js.br +0 -0
  509. package/web/chunk-hqt1f3fm.js.gz +0 -0
  510. package/web/chunk-hwxj58j5.js.br +0 -0
  511. package/web/chunk-hwxj58j5.js.gz +0 -0
  512. package/web/chunk-hxzb25a8.js +0 -1
  513. package/web/chunk-hxzb25a8.js.br +0 -0
  514. package/web/chunk-hxzb25a8.js.gz +0 -0
  515. package/web/chunk-jmnzcm1f.js.br +0 -0
  516. package/web/chunk-jmnzcm1f.js.gz +0 -0
  517. package/web/chunk-js940jjj.js.br +0 -0
  518. package/web/chunk-js940jjj.js.gz +0 -0
  519. package/web/chunk-jy9vkfbf.js +0 -1
  520. package/web/chunk-jy9vkfbf.js.br +0 -0
  521. package/web/chunk-jy9vkfbf.js.gz +0 -0
  522. package/web/chunk-k4pknkvp.js.br +0 -0
  523. package/web/chunk-k4pknkvp.js.gz +0 -0
  524. package/web/chunk-k6fwzn0z.js.br +0 -0
  525. package/web/chunk-k6fwzn0z.js.gz +0 -0
  526. package/web/chunk-kdegb6pd.js.br +0 -0
  527. package/web/chunk-kdegb6pd.js.gz +0 -0
  528. package/web/chunk-kedjfh66.js.br +0 -0
  529. package/web/chunk-kedjfh66.js.gz +0 -0
  530. package/web/chunk-mbpv2w5h.js.br +0 -0
  531. package/web/chunk-mbpv2w5h.js.gz +0 -0
  532. package/web/chunk-mh3nkkpx.js.br +0 -0
  533. package/web/chunk-mh3nkkpx.js.gz +0 -0
  534. package/web/chunk-mhzqgzh0.js.br +0 -0
  535. package/web/chunk-mhzqgzh0.js.gz +0 -0
  536. package/web/chunk-mj8dzc8q.js.br +0 -0
  537. package/web/chunk-mj8dzc8q.js.gz +0 -0
  538. package/web/chunk-mwfrxgbs.js.br +0 -0
  539. package/web/chunk-mwfrxgbs.js.gz +0 -0
  540. package/web/chunk-nb58m79v.js.br +0 -0
  541. package/web/chunk-nb58m79v.js.gz +0 -0
  542. package/web/chunk-nsna2v2r.js +0 -1
  543. package/web/chunk-nsna2v2r.js.br +0 -0
  544. package/web/chunk-nsna2v2r.js.gz +0 -0
  545. package/web/chunk-nxdp58nf.js +0 -1
  546. package/web/chunk-nxdp58nf.js.br +0 -0
  547. package/web/chunk-nxdp58nf.js.gz +0 -0
  548. package/web/chunk-nytgs01h.js +0 -1
  549. package/web/chunk-nytgs01h.js.br +0 -0
  550. package/web/chunk-nytgs01h.js.gz +0 -0
  551. package/web/chunk-pkxn54jm.js +0 -1
  552. package/web/chunk-pkxn54jm.js.br +0 -0
  553. package/web/chunk-pkxn54jm.js.gz +0 -0
  554. package/web/chunk-q0srq8g5.js.br +0 -0
  555. package/web/chunk-q0srq8g5.js.gz +0 -0
  556. package/web/chunk-qjg6dw46.js.br +0 -0
  557. package/web/chunk-qjg6dw46.js.gz +0 -0
  558. package/web/chunk-qjjxevxe.js +0 -1
  559. package/web/chunk-qjjxevxe.js.br +0 -0
  560. package/web/chunk-qjjxevxe.js.gz +0 -0
  561. package/web/chunk-qx5ab39c.js.br +0 -0
  562. package/web/chunk-qx5ab39c.js.gz +0 -0
  563. package/web/chunk-recfg8af.js.br +0 -0
  564. package/web/chunk-recfg8af.js.gz +0 -0
  565. package/web/chunk-tg3f9xmp.js.br +0 -0
  566. package/web/chunk-tg3f9xmp.js.gz +0 -0
  567. package/web/chunk-tgeeggkh.js.br +0 -0
  568. package/web/chunk-tgeeggkh.js.gz +0 -0
  569. package/web/chunk-v2bkkhb8.js.br +0 -0
  570. package/web/chunk-v2bkkhb8.js.gz +0 -0
  571. package/web/chunk-v5p2fds9.js.br +0 -0
  572. package/web/chunk-v5p2fds9.js.gz +0 -0
  573. package/web/chunk-v6snw1sw.js.br +0 -0
  574. package/web/chunk-v6snw1sw.js.gz +0 -0
  575. package/web/chunk-veadbga2.js +0 -1
  576. package/web/chunk-veadbga2.js.br +0 -2
  577. package/web/chunk-veadbga2.js.gz +0 -0
  578. package/web/chunk-vh2prc6k.js.br +0 -0
  579. package/web/chunk-vh2prc6k.js.gz +0 -0
  580. package/web/chunk-vhpzp7zd.js.br +0 -0
  581. package/web/chunk-vhpzp7zd.js.gz +0 -0
  582. package/web/chunk-vpbnyz43.js.br +0 -0
  583. package/web/chunk-vpbnyz43.js.gz +0 -0
  584. package/web/chunk-vxadngbp.js.br +0 -3
  585. package/web/chunk-vxadngbp.js.gz +0 -0
  586. package/web/chunk-wa8wr2y9.js.br +0 -0
  587. package/web/chunk-wa8wr2y9.js.gz +0 -0
  588. package/web/chunk-wbxz2bjb.js.br +0 -0
  589. package/web/chunk-wbxz2bjb.js.gz +0 -0
  590. package/web/chunk-wgzatts8.js +0 -1
  591. package/web/chunk-wgzatts8.js.br +0 -0
  592. package/web/chunk-wgzatts8.js.gz +0 -0
  593. package/web/chunk-whczyxqw.js +0 -1
  594. package/web/chunk-whczyxqw.js.br +0 -0
  595. package/web/chunk-whczyxqw.js.gz +0 -0
  596. package/web/chunk-wmzz2crn.js +0 -1
  597. package/web/chunk-wmzz2crn.js.br +0 -0
  598. package/web/chunk-wmzz2crn.js.gz +0 -0
  599. package/web/chunk-wvqcbp4a.js.br +0 -0
  600. package/web/chunk-wvqcbp4a.js.gz +0 -0
  601. package/web/chunk-x2hxq5yr.js.br +0 -0
  602. package/web/chunk-x2hxq5yr.js.gz +0 -0
  603. package/web/chunk-x8bnp6vr.js +0 -1
  604. package/web/chunk-x8bnp6vr.js.br +0 -0
  605. package/web/chunk-x8bnp6vr.js.gz +0 -0
  606. package/web/chunk-xvmzsftt.js +0 -2
  607. package/web/chunk-xvmzsftt.js.br +0 -0
  608. package/web/chunk-xvmzsftt.js.gz +0 -0
  609. package/web/chunk-ye7vge7s.js.br +0 -0
  610. package/web/chunk-ye7vge7s.js.gz +0 -0
  611. package/web/chunk-zbzgd8kn.js.br +0 -0
  612. package/web/chunk-zbzgd8kn.js.gz +0 -0
  613. package/web/chunk-zhwqscat.js +0 -1
  614. package/web/chunk-zhwqscat.js.br +0 -0
  615. package/web/chunk-zhwqscat.js.gz +0 -0
  616. package/web/chunk-znrsm604.js.br +0 -0
  617. package/web/chunk-znrsm604.js.gz +0 -0
  618. package/web/chunk-zthww0ws.js.br +0 -0
  619. package/web/chunk-zthww0ws.js.gz +0 -0
@@ -1,10 +1,10 @@
1
- import{t,a,B,S,j,A,R,I,L,D,P,M,u,h,F,Xo,De,Te,Ee,ln,ze,Ue}from"./chunk-v2bkkhb8.js";import{Fe}from"./chunk-1ghnag5v.js";import{Le}from"./chunk-vhpzp7zd.js";function tt(e){if(console&&console.error)console.error(`Error: ${e}`)}function Tt(e){if(console&&console.warn)console.warn(`Warning: ${e}`)}function gt(e){let s=new Date().getTime(),n=e();return{time:new Date().getTime()-s,value:n}}function At(e){function s(){}s.prototype=e;let n=new s;function i(){return typeof n.bar}return i(),i(),e;(0,eval)(e)}function $r(e){if(Gr(e))return e.LABEL;else return e.name}function Gr(e){return typeof e.LABEL==="string"&&e.LABEL!==""}class Se{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach((s)=>{s.accept(e)})}}class G extends Se{constructor(e){super([]);this.idx=1,Object.assign(this,ke(e))}set definition(e){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(e){e.visit(this)}}class de extends Se{constructor(e){super(e.definition);this.orgText="",Object.assign(this,ke(e))}}class W extends Se{constructor(e){super(e.definition);this.ignoreAmbiguities=!1,Object.assign(this,ke(e))}}class K extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class Z extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class Q extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class U extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class q extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class J extends Se{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,ke(e))}}class v{constructor(e){this.idx=1,Object.assign(this,ke(e))}accept(e){e.visit(this)}}function Gt(e){return e.map(st)}function st(e){function s(n){return n.map(st)}if(e instanceof G){let n={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(typeof e.label==="string")n.label=e.label;return n}else if(e instanceof W)return{type:"Alternative",definition:s(e.definition)};else if(e instanceof K)return{type:"Option",idx:e.idx,definition:s(e.definition)};else if(e instanceof Z)return{type:"RepetitionMandatory",idx:e.idx,definition:s(e.definition)};else if(e instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:st(new v({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof q)return{type:"RepetitionWithSeparator",idx:e.idx,separator:st(new v({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof U)return{type:"Repetition",idx:e.idx,definition:s(e.definition)};else if(e instanceof J)return{type:"Alternation",idx:e.idx,definition:s(e.definition)};else if(e instanceof v){let n={type:"Terminal",name:e.terminalType.name,label:$r(e.terminalType),idx:e.idx};if(typeof e.label==="string")n.terminalLabel=e.label;let i=e.terminalType.PATTERN;if(e.terminalType.PATTERN)n.pattern=i instanceof RegExp?i.source:i;return n}else if(e instanceof de)return{type:"Rule",name:e.name,orgText:e.orgText,definition:s(e.definition)};else throw Error("non exhaustive match")}function ke(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}class pe{visit(e){let s=e;switch(s.constructor){case G:return this.visitNonTerminal(s);case W:return this.visitAlternative(s);case K:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case q:return this.visitRepetitionWithSeparator(s);case U:return this.visitRepetition(s);case J:return this.visitAlternation(s);case v:return this.visitTerminal(s);case de:return this.visitRule(s);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 xs(e){return e instanceof W||e instanceof K||e instanceof U||e instanceof Z||e instanceof Q||e instanceof q||e instanceof v||e instanceof de}function We(e,s=[]){if(e instanceof K||e instanceof U||e instanceof q)return!0;if(e instanceof J)return e.definition.some((i)=>We(i,s));else if(e instanceof G&&s.includes(e))return!1;else if(e instanceof Se){if(e instanceof G)s.push(e);return e.definition.every((i)=>We(i,s))}else return!1}function vs(e){return e instanceof J}function fe(e){if(e instanceof G)return"SUBRULE";else if(e instanceof K)return"OPTION";else if(e instanceof J)return"OR";else if(e instanceof Z)return"AT_LEAST_ONE";else if(e instanceof Q)return"AT_LEAST_ONE_SEP";else if(e instanceof q)return"MANY_SEP";else if(e instanceof U)return"MANY";else if(e instanceof v)return"CONSUME";else throw Error("non exhaustive match")}class Be{walk(e,s=[]){e.definition.forEach((n,i)=>{let r=e.definition.slice(i+1);if(n instanceof G)this.walkProdRef(n,r,s);else if(n instanceof v)this.walkTerminal(n,r,s);else if(n instanceof W)this.walkFlat(n,r,s);else if(n instanceof K)this.walkOption(n,r,s);else if(n instanceof Z)this.walkAtLeastOne(n,r,s);else if(n instanceof Q)this.walkAtLeastOneSep(n,r,s);else if(n instanceof q)this.walkManySep(n,r,s);else if(n instanceof U)this.walkMany(n,r,s);else if(n instanceof J)this.walkOr(n,r,s);else throw Error("non exhaustive match")})}walkTerminal(e,s,n){}walkProdRef(e,s,n){}walkFlat(e,s,n){let i=s.concat(n);this.walk(e,i)}walkOption(e,s,n){let i=s.concat(n);this.walk(e,i)}walkAtLeastOne(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkAtLeastOneSep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkMany(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkManySep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkOr(e,s,n){let i=s.concat(n);e.definition.forEach((r)=>{let o=new W({definition:[r]});this.walk(o,i)})}}function Nn(e,s,n){return[new K({definition:[new v({terminalType:e.separator})].concat(e.definition)})].concat(s,n)}function je(e){if(e instanceof G)return je(e.referencedRule);else if(e instanceof v)return Kr(e);else if(xs(e))return Wr(e);else if(vs(e))return jr(e);else throw Error("non exhaustive match")}function Wr(e){let s=[],n=e.definition,i=0,r=n.length>i,o,c=!0;while(r&&c)o=n[i],c=We(o),s=s.concat(je(o)),i=i+1,r=n.length>i;return[...new Set(s)]}function jr(e){let s=e.definition.map((n)=>je(n));return[...new Set(s.flat())]}function Kr(e){return[e.terminalType]}var Wt="_~IN~_";class In extends Be{constructor(e){super();this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,s,n){}walkProdRef(e,s,n){let i=Vr(e.referencedRule,e.idx)+this.topProd.name,r=s.concat(n),o=new W({definition:r}),c=je(o);this.follows[i]=c}}function kn(e){let s={};return e.forEach((n)=>{let i=new In(n).startWalking();Object.assign(s,i)}),s}function Vr(e,s){return e.name+s+Wt}function k(e){return e.charCodeAt(0)}function jt(e,s){if(Array.isArray(e))e.forEach(function(n){s.push(n)});else s.push(e)}function nt(e,s){if(e[s]===!0)throw"duplicate flag "+s;let n=e[s];e[s]=!0}function Ke(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function St(){throw Error("Internal Error - Should never get here!")}function Ms(e){return e.type==="Character"}var Rt=[];for(let e=k("0");e<=k("9");e++)Rt.push(e);var yt=[k("_")].concat(Rt);for(let e=k("a");e<=k("z");e++)yt.push(e);for(let e=k("A");e<=k("Z");e++)yt.push(e);var ws=[k(" "),k("\f"),k(`
2
- `),k("\r"),k("\t"),k("\v"),k("\t"),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k(" "),k("\u2028"),k("\u2029"),k(" "),k(" "),k(" "),k("\uFEFF")];var zr=/[0-9a-fA-F]/,Kt=/[0-9]/,Hr=/[1-9]/;class Vt{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 s=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(n,"global");break;case"i":nt(n,"ignoreCase");break;case"m":nt(n,"multiLine");break;case"u":nt(n,"unicode");break;case"y":nt(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:s,loc:this.loc(0)}}disjunction(){let e=[],s=this.idx;e.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(s)}}alternative(){let e=[],s=this.idx;while(this.isTerm())e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return 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"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ke(s);let n=this.disjunction();return this.consumeChar(")"),{type:s,value:n,loc:this.loc(e)}}return St()}quantifier(e=!1){let s=void 0,n=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:i,atMost:i};break;case",":let r;if(this.isDigit())r=this.integerIncludingZero(),s={atLeast:i,atMost:r};else s={atLeast:i,atMost:1/0};this.consumeChar("}");break}if(e===!0&&s===void 0)return;Ke(s);break}if(e===!0&&s===void 0)return;if(Ke(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(n),s}}atom(){let e,s=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter())e=this.patternCharacter();if(Ke(e)){if(e.loc=this.loc(s),this.isQuantifier())e.quantifier=this.quantifier();return e}return St()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[k(`
3
- `),k("\r"),k("\u2028"),k("\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,s=!1;switch(this.popChar()){case"d":e=Rt;break;case"D":e=Rt,s=!0;break;case"s":e=ws;break;case"S":e=ws,s=!0;break;case"w":e=yt;break;case"W":e=yt,s=!0;break}if(Ke(e))return{type:"Set",value:e,complement:s};return St()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=k("\f");break;case"n":e=k(`
4
- `);break;case"r":e=k("\r");break;case"t":e=k("\t");break;case"v":e=k("\v");break}if(Ke(e))return{type:"Character",value:e};return St()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:k("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:k(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
- `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:k(e)}}}characterClass(){let e=[],s=!1;if(this.consumeChar("["),this.peekChar(0)==="^")this.consumeChar("^"),s=!0;while(this.isClassAtom()){let n=this.classAtom(),i=n.type==="Character";if(Ms(n)&&this.isRangeDash()){this.consumeChar("-");let r=this.classAtom(),o=r.type==="Character";if(Ms(r)){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else jt(n.value,e),e.push(k("-")),jt(r.value,e)}else jt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:s,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
6
- `: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:k("\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;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let s=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:s};if(e)n.idx=this.groupIdx;return n}positiveInteger(){let e=this.popChar();if(Hr.test(e)===!1)throw Error("Expecting a positive integer");while(Kt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Kt.test(e)===!1)throw Error("Expecting an integer");while(Kt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
7
- `: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:k(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 Kt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
1
+ import{t,a,B,S,j,A,R,I,L,D,P,N,u,h,F,Xo,De,Te,Ee,ln,ze,Ue}from"./chunk-dbv8qpen.js";import{Fe}from"./chunk-2dykyq1n.js";import{Le}from"./chunk-acv6gk2b.js";function tt(e){if(console&&console.error)console.error(`Error: ${e}`)}function Tt(e){if(console&&console.warn)console.warn(`Warning: ${e}`)}function gt(e){let s=new Date().getTime(),n=e();return{time:new Date().getTime()-s,value:n}}function At(e){function s(){}s.prototype=e;let n=new s;function i(){return typeof n.bar}return i(),i(),e;(0,eval)(e)}function $r(e){if(Gr(e))return e.LABEL;else return e.name}function Gr(e){return typeof e.LABEL==="string"&&e.LABEL!==""}class Se{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach((s)=>{s.accept(e)})}}class G extends Se{constructor(e){super([]);this.idx=1,Object.assign(this,ke(e))}set definition(e){}get definition(){if(this.referencedRule!==void 0)return this.referencedRule.definition;return[]}accept(e){e.visit(this)}}class de extends Se{constructor(e){super(e.definition);this.orgText="",Object.assign(this,ke(e))}}class W extends Se{constructor(e){super(e.definition);this.ignoreAmbiguities=!1,Object.assign(this,ke(e))}}class K extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class Z extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class Q extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class U extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class q extends Se{constructor(e){super(e.definition);this.idx=1,Object.assign(this,ke(e))}}class J extends Se{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,ke(e))}}class M{constructor(e){this.idx=1,Object.assign(this,ke(e))}accept(e){e.visit(this)}}function Gt(e){return e.map(st)}function st(e){function s(n){return n.map(st)}if(e instanceof G){let n={type:"NonTerminal",name:e.nonTerminalName,idx:e.idx};if(typeof e.label==="string")n.label=e.label;return n}else if(e instanceof W)return{type:"Alternative",definition:s(e.definition)};else if(e instanceof K)return{type:"Option",idx:e.idx,definition:s(e.definition)};else if(e instanceof Z)return{type:"RepetitionMandatory",idx:e.idx,definition:s(e.definition)};else if(e instanceof Q)return{type:"RepetitionMandatoryWithSeparator",idx:e.idx,separator:st(new M({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof q)return{type:"RepetitionWithSeparator",idx:e.idx,separator:st(new M({terminalType:e.separator})),definition:s(e.definition)};else if(e instanceof U)return{type:"Repetition",idx:e.idx,definition:s(e.definition)};else if(e instanceof J)return{type:"Alternation",idx:e.idx,definition:s(e.definition)};else if(e instanceof M){let n={type:"Terminal",name:e.terminalType.name,label:$r(e.terminalType),idx:e.idx};if(typeof e.label==="string")n.terminalLabel=e.label;let i=e.terminalType.PATTERN;if(e.terminalType.PATTERN)n.pattern=i instanceof RegExp?i.source:i;return n}else if(e instanceof de)return{type:"Rule",name:e.name,orgText:e.orgText,definition:s(e.definition)};else throw Error("non exhaustive match")}function ke(e){return Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))}class pe{visit(e){let s=e;switch(s.constructor){case G:return this.visitNonTerminal(s);case W:return this.visitAlternative(s);case K:return this.visitOption(s);case Z:return this.visitRepetitionMandatory(s);case Q:return this.visitRepetitionMandatoryWithSeparator(s);case q:return this.visitRepetitionWithSeparator(s);case U:return this.visitRepetition(s);case J:return this.visitAlternation(s);case M:return this.visitTerminal(s);case de:return this.visitRule(s);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 xs(e){return e instanceof W||e instanceof K||e instanceof U||e instanceof Z||e instanceof Q||e instanceof q||e instanceof M||e instanceof de}function We(e,s=[]){if(e instanceof K||e instanceof U||e instanceof q)return!0;if(e instanceof J)return e.definition.some((i)=>We(i,s));else if(e instanceof G&&s.includes(e))return!1;else if(e instanceof Se){if(e instanceof G)s.push(e);return e.definition.every((i)=>We(i,s))}else return!1}function vs(e){return e instanceof J}function fe(e){if(e instanceof G)return"SUBRULE";else if(e instanceof K)return"OPTION";else if(e instanceof J)return"OR";else if(e instanceof Z)return"AT_LEAST_ONE";else if(e instanceof Q)return"AT_LEAST_ONE_SEP";else if(e instanceof q)return"MANY_SEP";else if(e instanceof U)return"MANY";else if(e instanceof M)return"CONSUME";else throw Error("non exhaustive match")}class Be{walk(e,s=[]){e.definition.forEach((n,i)=>{let r=e.definition.slice(i+1);if(n instanceof G)this.walkProdRef(n,r,s);else if(n instanceof M)this.walkTerminal(n,r,s);else if(n instanceof W)this.walkFlat(n,r,s);else if(n instanceof K)this.walkOption(n,r,s);else if(n instanceof Z)this.walkAtLeastOne(n,r,s);else if(n instanceof Q)this.walkAtLeastOneSep(n,r,s);else if(n instanceof q)this.walkManySep(n,r,s);else if(n instanceof U)this.walkMany(n,r,s);else if(n instanceof J)this.walkOr(n,r,s);else throw Error("non exhaustive match")})}walkTerminal(e,s,n){}walkProdRef(e,s,n){}walkFlat(e,s,n){let i=s.concat(n);this.walk(e,i)}walkOption(e,s,n){let i=s.concat(n);this.walk(e,i)}walkAtLeastOne(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkAtLeastOneSep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkMany(e,s,n){let i=[new K({definition:e.definition})].concat(s,n);this.walk(e,i)}walkManySep(e,s,n){let i=Nn(e,s,n);this.walk(e,i)}walkOr(e,s,n){let i=s.concat(n);e.definition.forEach((r)=>{let o=new W({definition:[r]});this.walk(o,i)})}}function Nn(e,s,n){return[new K({definition:[new M({terminalType:e.separator})].concat(e.definition)})].concat(s,n)}function je(e){if(e instanceof G)return je(e.referencedRule);else if(e instanceof M)return Kr(e);else if(xs(e))return Wr(e);else if(vs(e))return jr(e);else throw Error("non exhaustive match")}function Wr(e){let s=[],n=e.definition,i=0,r=n.length>i,o,c=!0;while(r&&c)o=n[i],c=We(o),s=s.concat(je(o)),i=i+1,r=n.length>i;return[...new Set(s)]}function jr(e){let s=e.definition.map((n)=>je(n));return[...new Set(s.flat())]}function Kr(e){return[e.terminalType]}var Wt="_~IN~_";class In extends Be{constructor(e){super();this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,s,n){}walkProdRef(e,s,n){let i=Vr(e.referencedRule,e.idx)+this.topProd.name,r=s.concat(n),o=new W({definition:r}),c=je(o);this.follows[i]=c}}function kn(e){let s={};return e.forEach((n)=>{let i=new In(n).startWalking();Object.assign(s,i)}),s}function Vr(e,s){return e.name+s+Wt}function C(e){return e.charCodeAt(0)}function jt(e,s){if(Array.isArray(e))e.forEach(function(n){s.push(n)});else s.push(e)}function nt(e,s){if(e[s]===!0)throw"duplicate flag "+s;let n=e[s];e[s]=!0}function Ke(e){if(e===void 0)throw Error("Internal Error - Should never get here!");return!0}function St(){throw Error("Internal Error - Should never get here!")}function Ms(e){return e.type==="Character"}var Rt=[];for(let e=C("0");e<=C("9");e++)Rt.push(e);var yt=[C("_")].concat(Rt);for(let e=C("a");e<=C("z");e++)yt.push(e);for(let e=C("A");e<=C("Z");e++)yt.push(e);var ws=[C(" "),C("\f"),C(`
2
+ `),C("\r"),C("\t"),C("\v"),C("\t"),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C(" "),C("\u2028"),C("\u2029"),C(" "),C(" "),C(" "),C("\uFEFF")];var zr=/[0-9a-fA-F]/,Kt=/[0-9]/,Hr=/[1-9]/;class Vt{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 s=this.disjunction();this.consumeChar("/");let n={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};while(this.isRegExpFlag())switch(this.popChar()){case"g":nt(n,"global");break;case"i":nt(n,"ignoreCase");break;case"m":nt(n,"multiLine");break;case"u":nt(n,"unicode");break;case"y":nt(n,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:s,loc:this.loc(0)}}disjunction(){let e=[],s=this.idx;e.push(this.alternative());while(this.peekChar()==="|")this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(s)}}alternative(){let e=[],s=this.idx;while(this.isTerm())e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(s)}}term(){if(this.isAssertion())return this.assertion();else return 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"(":this.consumeChar("?");let s;switch(this.popChar()){case"=":s="Lookahead";break;case"!":s="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":s="Lookbehind";break;case"!":s="NegativeLookbehind"}break}}Ke(s);let n=this.disjunction();return this.consumeChar(")"),{type:s,value:n,loc:this.loc(e)}}return St()}quantifier(e=!1){let s=void 0,n=this.idx;switch(this.popChar()){case"*":s={atLeast:0,atMost:1/0};break;case"+":s={atLeast:1,atMost:1/0};break;case"?":s={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":s={atLeast:i,atMost:i};break;case",":let r;if(this.isDigit())r=this.integerIncludingZero(),s={atLeast:i,atMost:r};else s={atLeast:i,atMost:1/0};this.consumeChar("}");break}if(e===!0&&s===void 0)return;Ke(s);break}if(e===!0&&s===void 0)return;if(Ke(s)){if(this.peekChar(0)==="?")this.consumeChar("?"),s.greedy=!1;else s.greedy=!0;return s.type="Quantifier",s.loc=this.loc(n),s}}atom(){let e,s=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group();break}if(e===void 0&&this.isPatternCharacter())e=this.patternCharacter();if(Ke(e)){if(e.loc=this.loc(s),this.isQuantifier())e.quantifier=this.quantifier();return e}return St()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[C(`
3
+ `),C("\r"),C("\u2028"),C("\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,s=!1;switch(this.popChar()){case"d":e=Rt;break;case"D":e=Rt,s=!0;break;case"s":e=ws;break;case"S":e=ws,s=!0;break;case"w":e=yt;break;case"W":e=yt,s=!0;break}if(Ke(e))return{type:"Set",value:e,complement:s};return St()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=C("\f");break;case"n":e=C(`
4
+ `);break;case"r":e=C("\r");break;case"t":e=C("\t");break;case"v":e=C("\v");break}if(Ke(e))return{type:"Character",value:e};return St()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:C("\x00")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){let e=this.popChar();return{type:"Character",value:C(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:let e=this.popChar();return{type:"Character",value:C(e)}}}characterClass(){let e=[],s=!1;if(this.consumeChar("["),this.peekChar(0)==="^")this.consumeChar("^"),s=!0;while(this.isClassAtom()){let n=this.classAtom(),i=n.type==="Character";if(Ms(n)&&this.isRangeDash()){this.consumeChar("-");let r=this.classAtom(),o=r.type==="Character";if(Ms(r)){if(r.value<n.value)throw Error("Range out of order in character class");e.push({from:n.value,to:r.value})}else jt(n.value,e),e.push(C("-")),jt(r.value,e)}else jt(n.value,e)}return this.consumeChar("]"),{type:"Set",complement:s,value:e}}classAtom(){switch(this.peekChar()){case"]":case`
6
+ `: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:C("\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;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),e=!1;break;default:this.groupIdx++;break}let s=this.disjunction();this.consumeChar(")");let n={type:"Group",capturing:e,value:s};if(e)n.idx=this.groupIdx;return n}positiveInteger(){let e=this.popChar();if(Hr.test(e)===!1)throw Error("Expecting a positive integer");while(Kt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Kt.test(e)===!1)throw Error("Expecting an integer");while(Kt.test(this.peekChar(0)))e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case`
7
+ `: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:C(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 Kt.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
8
8
  `: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 this.quantifier(!0)!==void 0}catch(s){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
9
9
  `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let s="";for(let i=0;i<e;i++){let r=this.popChar();if(zr.test(r)===!1)throw Error("Expecting a HexDecimal digits");s+=r}return{type:"Character",value:parseInt(s,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(e!==void 0&&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 Ve{visitChildren(e){for(let s in e){let n=e[s];if(e.hasOwnProperty(s)){if(n.type!==void 0)this.visit(n);else if(Array.isArray(n))n.forEach((i)=>{this.visit(i)},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);break}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){}}var zt={},Xr=new Vt;function He(e){let s=e.toString();if(zt.hasOwnProperty(s))return zt[s];else{let n=Xr.pattern(s);return zt[s]=n,n}}function Cn(){zt={}}var _n="Complement Sets are not supported for first char optimization",Ot=`Unable to use "first char" lexer optimizations:
10
10
  `;function xn(e,s=!1){try{let n=He(e);return Us(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===_n){if(s)Tt(`${Ot} Unable to optimize: < ${e.toString()} >
@@ -15,13 +15,13 @@ import{t,a,B,S,j,A,R,I,L,D,P,M,u,h,F,Xo,De,Te,Ee,ln,ze,Ue}from"./chunk-v2bkkhb8.
15
15
  See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`;tt(`${Ot}
16
16
  Failed parsing: < ${e.toString()} >
17
17
  Using the @chevrotain/regexp-to-ast library
18
- Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+i)}}return[]}function Us(e,s,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)Us(e.value[r],s,n);break;case"Alternative":let i=e.value;for(let r=0;r<i.length;r++){let o=i[r];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let c=o;switch(c.type){case"Character":Ht(c.value,s,n);break;case"Set":if(c.complement===!0)throw Error(_n);c.value.forEach((l)=>{if(typeof l==="number")Ht(l,s,n);else{let p=l;if(n===!0)for(let f=p.from;f<=p.to;f++)Ht(f,s,n);else{for(let f=p.from;f<=p.to&&f<it;f++)Ht(f,s,n);if(p.to>=it){let f=p.from>=it?p.from:it,m=p.to,T=Ce(f),g=Ce(m);for(let _=T;_<=g;_++)s[_]=_}}}});break;case"Group":Us(c.value,s,n);break;default:throw Error("Non Exhaustive Match")}let d=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&Ps(c)===!1||c.type!=="Group"&&d===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Ht(e,s,n){let i=Ce(e);if(s[i]=i,n===!0)Yr(e,s)}function Yr(e,s){let n=String.fromCharCode(e),i=n.toUpperCase();if(i!==n){let r=Ce(i.charCodeAt(0));s[r]=r}else{let r=n.toLowerCase();if(r!==n){let o=Ce(r.charCodeAt(0));s[o]=o}}}function bn(e,s){return e.value.find((n)=>{if(typeof n==="number")return s.includes(n);else{let i=n;return s.find((r)=>i.from<=r&&r<=i.to)!==void 0}})}function Ps(e){let s=e.quantifier;if(s&&s.atLeast===0)return!0;if(!e.value)return!1;return Array.isArray(e.value)?e.value.every(Ps):Ps(e.value)}class vn extends Ve{constructor(e){super();this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found===!0)return;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){if(this.targetCharCodes.includes(e.value))this.found=!0}visitSet(e){if(e.complement){if(bn(e,this.targetCharCodes)===void 0)this.found=!0}else if(bn(e,this.targetCharCodes)!==void 0)this.found=!0}}function Xt(e,s){if(s instanceof RegExp){let n=He(s),i=new vn(e);return i.visit(n),i.found}else{for(let n of s){let i=n.charCodeAt(0);if(e.includes(i))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",Yt="modes",Jt=0,Lt=1,Zt=2,Qt=3;function wn(e,s){s=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
19
- `],tracer:(O,E)=>E()},s);let n=s.tracer;n("initCharCodeToOptimizedIndexMap",()=>{ma()});let i;n("Reject Lexer.NA",()=>{i=e.filter((O)=>O[Xe]!==z.NA)});let r=!1,o;n("Transform Patterns",()=>{r=!1,o=i.map((O)=>{let E=O[Xe];if(E instanceof RegExp){let b=E.source;if(b.length===1&&b!=="^"&&b!=="$"&&b!=="."&&!E.ignoreCase)return b;else if(b.length===2&&b[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(b[1]))return b[1];else return Mn(E)}else if(typeof E==="function")return r=!0,{exec:E};else if(typeof E==="object")return r=!0,E;else if(typeof E==="string")if(E.length===1)return E;else{let b=E.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(b);return Mn(te)}else throw Error("non exhaustive match")})});let c,d,l,p,f;n("misc mapping",()=>{c=i.map((O)=>O.tokenTypeIdx),d=i.map((O)=>{let E=O.GROUP;if(E===z.SKIPPED)return;else if(typeof E==="string")return E;else if(E===void 0)return!1;else throw Error("non exhaustive match")}),l=i.map((O)=>{let E=O.LONGER_ALT;if(E)return Array.isArray(E)?E.map((te)=>i.indexOf(te)):[i.indexOf(E)]}),p=i.map((O)=>O.PUSH_MODE),f=i.map((O)=>Object.hasOwn(O,"POP_MODE"))});let m;n("Line Terminator Handling",()=>{let O=Gn(s.lineTerminatorCharacters);if(m=i.map((E)=>!1),s.positionTracking!=="onlyOffset")m=i.map((E)=>{if(Object.hasOwn(E,"LINE_BREAKS"))return!!E.LINE_BREAKS;else return $n(E,O)===!1&&Xt(O,E.PATTERN)})});let T,g,_,x;n("Misc Mapping #2",()=>{T=i.map(Fn),g=o.map(pa),_=i.reduce((O,E)=>{let b=E.GROUP;if(typeof b==="string"&&b!==z.SKIPPED)O[b]=[];return O},{}),x=o.map((O,E)=>{let b=d[E]===void 0&&l[E]===void 0?qr(i[E].PATTERN):void 0;return{pattern:o[E],asciiClass:b,longerAlt:l[E],canLineTerminator:m[E],matchType:b!==void 0?Qt:g[E]!==!1?Jt:T[E]?Lt:Zt,short:g[E],group:d[E],push:p[E],pop:f[E],tokenTypeIdx:c[E],tokenType:i[E]}})});let C=!0,N=[];if(!s.safeMode)n("First Char Optimization",()=>{N=i.reduce((O,E,b)=>{if(typeof E.PATTERN==="string"){let te=E.PATTERN.charCodeAt(0),oe=Ce(te);Ds(O,oe,x[b])}else if(Array.isArray(E.START_CHARS_HINT)){let te;E.START_CHARS_HINT.forEach((oe)=>{let pt=typeof oe==="string"?oe.charCodeAt(0):oe,be=Ce(pt);if(te!==be)te=be,Ds(O,be,x[b])})}else if(E.PATTERN instanceof RegExp)if(E.PATTERN.unicode){if(C=!1,s.ensureOptimizations)tt(`${Ot} Unable to analyze < ${E.PATTERN.toString()} > pattern.
18
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+i)}}return[]}function Us(e,s,n){switch(e.type){case"Disjunction":for(let r=0;r<e.value.length;r++)Us(e.value[r],s,n);break;case"Alternative":let i=e.value;for(let r=0;r<i.length;r++){let o=i[r];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}let c=o;switch(c.type){case"Character":Ht(c.value,s,n);break;case"Set":if(c.complement===!0)throw Error(_n);c.value.forEach((l)=>{if(typeof l==="number")Ht(l,s,n);else{let p=l;if(n===!0)for(let f=p.from;f<=p.to;f++)Ht(f,s,n);else{for(let f=p.from;f<=p.to&&f<it;f++)Ht(f,s,n);if(p.to>=it){let f=p.from>=it?p.from:it,m=p.to,T=Ce(f),g=Ce(m);for(let x=T;x<=g;x++)s[x]=x}}}});break;case"Group":Us(c.value,s,n);break;default:throw Error("Non Exhaustive Match")}let d=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&Ps(c)===!1||c.type!=="Group"&&d===!1)break}break;default:throw Error("non exhaustive match!")}return Object.values(s)}function Ht(e,s,n){let i=Ce(e);if(s[i]=i,n===!0)Yr(e,s)}function Yr(e,s){let n=String.fromCharCode(e),i=n.toUpperCase();if(i!==n){let r=Ce(i.charCodeAt(0));s[r]=r}else{let r=n.toLowerCase();if(r!==n){let o=Ce(r.charCodeAt(0));s[o]=o}}}function bn(e,s){return e.value.find((n)=>{if(typeof n==="number")return s.includes(n);else{let i=n;return s.find((r)=>i.from<=r&&r<=i.to)!==void 0}})}function Ps(e){let s=e.quantifier;if(s&&s.atLeast===0)return!0;if(!e.value)return!1;return Array.isArray(e.value)?e.value.every(Ps):Ps(e.value)}class vn extends Ve{constructor(e){super();this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found===!0)return;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){if(this.targetCharCodes.includes(e.value))this.found=!0}visitSet(e){if(e.complement){if(bn(e,this.targetCharCodes)===void 0)this.found=!0}else if(bn(e,this.targetCharCodes)!==void 0)this.found=!0}}function Xt(e,s){if(s instanceof RegExp){let n=He(s),i=new vn(e);return i.visit(n),i.found}else{for(let n of s){let i=n.charCodeAt(0);if(e.includes(i))return!0}return!1}}var Xe="PATTERN",rt="defaultMode",Yt="modes",Jt=0,Lt=1,Zt=2,Qt=3;function wn(e,s){s=Object.assign({safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
19
+ `],tracer:(O,E)=>E()},s);let n=s.tracer;n("initCharCodeToOptimizedIndexMap",()=>{ma()});let i;n("Reject Lexer.NA",()=>{i=e.filter((O)=>O[Xe]!==z.NA)});let r=!1,o;n("Transform Patterns",()=>{r=!1,o=i.map((O)=>{let E=O[Xe];if(E instanceof RegExp){let _=E.source;if(_.length===1&&_!=="^"&&_!=="$"&&_!=="."&&!E.ignoreCase)return _;else if(_.length===2&&_[0]==="\\"&&!["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"].includes(_[1]))return _[1];else return Mn(E)}else if(typeof E==="function")return r=!0,{exec:E};else if(typeof E==="object")return r=!0,E;else if(typeof E==="string")if(E.length===1)return E;else{let _=E.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),te=new RegExp(_);return Mn(te)}else throw Error("non exhaustive match")})});let c,d,l,p,f;n("misc mapping",()=>{c=i.map((O)=>O.tokenTypeIdx),d=i.map((O)=>{let E=O.GROUP;if(E===z.SKIPPED)return;else if(typeof E==="string")return E;else if(E===void 0)return!1;else throw Error("non exhaustive match")}),l=i.map((O)=>{let E=O.LONGER_ALT;if(E)return Array.isArray(E)?E.map((te)=>i.indexOf(te)):[i.indexOf(E)]}),p=i.map((O)=>O.PUSH_MODE),f=i.map((O)=>Object.hasOwn(O,"POP_MODE"))});let m;n("Line Terminator Handling",()=>{let O=Gn(s.lineTerminatorCharacters);if(m=i.map((E)=>!1),s.positionTracking!=="onlyOffset")m=i.map((E)=>{if(Object.hasOwn(E,"LINE_BREAKS"))return!!E.LINE_BREAKS;else return $n(E,O)===!1&&Xt(O,E.PATTERN)})});let T,g,x,v;n("Misc Mapping #2",()=>{T=i.map(Fn),g=o.map(pa),x=i.reduce((O,E)=>{let _=E.GROUP;if(typeof _==="string"&&_!==z.SKIPPED)O[_]=[];return O},{}),v=o.map((O,E)=>{let _=d[E]===void 0&&l[E]===void 0?qr(i[E].PATTERN):void 0;return{pattern:o[E],asciiClass:_,longerAlt:l[E],canLineTerminator:m[E],matchType:_!==void 0?Qt:g[E]!==!1?Jt:T[E]?Lt:Zt,short:g[E],group:d[E],push:p[E],pop:f[E],tokenTypeIdx:c[E],tokenType:i[E]}})});let b=!0,k=[];if(!s.safeMode)n("First Char Optimization",()=>{k=i.reduce((O,E,_)=>{if(typeof E.PATTERN==="string"){let te=E.PATTERN.charCodeAt(0),oe=Ce(te);Ds(O,oe,v[_])}else if(Array.isArray(E.START_CHARS_HINT)){let te;E.START_CHARS_HINT.forEach((oe)=>{let pt=typeof oe==="string"?oe.charCodeAt(0):oe,be=Ce(pt);if(te!==be)te=be,Ds(O,be,v[_])})}else if(E.PATTERN instanceof RegExp)if(E.PATTERN.unicode){if(b=!1,s.ensureOptimizations)tt(`${Ot} Unable to analyze < ${E.PATTERN.toString()} > pattern.
20
20
  The regexp unicode flag is not currently supported by the regexp-to-ast library.
21
21
  This will disable the lexer's first char optimizations.
22
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(E.PATTERN,s.ensureOptimizations);if(te.length===0)C=!1;te.forEach((oe)=>{Ds(O,oe,x[b])})}else{if(s.ensureOptimizations)tt(`${Ot} TokenType: <${E.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
22
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`)}else{let te=xn(E.PATTERN,s.ensureOptimizations);if(te.length===0)b=!1;te.forEach((oe)=>{Ds(O,oe,v[_])})}else{if(s.ensureOptimizations)tt(`${Ot} TokenType: <${E.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
23
23
  This will disable the lexer's first char optimizations.
24
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`);C=!1}return O},[])});return{emptyGroups:_,patternIdxToConfig:x,charCodeToPatternIdxToConfig:N,hasCustom:r,canBeOptimized:C}}function qr(e){var s,n;if(!(e instanceof RegExp)||e.flags!=="")return;let i;try{i=He(e)}catch(d){return}if(i.value.value.length!==1||i.value.value[0].value.length!==1)return;let r=i.value.value[0].value[0],o;while(r.type==="Group"){if(r.capturing||r.quantifier!==void 0&&o!==void 0||r.value.value.length!==1||r.value.value[0].value.length!==1)return;o=(s=r.quantifier)!==null&&s!==void 0?s:o,r=r.value.value[0].value[0]}if(r.type!=="Set"||r.complement||r.quantifier!==void 0&&o!==void 0)return;if(o=(n=r.quantifier)!==null&&n!==void 0?n:o,(o===null||o===void 0?void 0:o.atLeast)!==1||o.atMost!==1/0||!o.greedy)return;let c=new Uint8Array(128);for(let d of r.value){let l=typeof d==="number"?d:d.from,p=typeof d==="number"?d:d.to;if(l<0||p>=c.length)return;c.fill(1,l,p+1)}return c}function Un(e,s){let n=[],i=Zr(e);n=n.concat(i.errors);let r=Qr(i.valid),o=r.valid;return n=n.concat(r.errors),n=n.concat(Jr(o)),n=n.concat(oa(o)),n=n.concat(la(o,s)),n=n.concat(ca(o)),n}function Jr(e){let s=[],n=e.filter((i)=>i[Xe]instanceof RegExp);return s=s.concat(ta(n)),s=s.concat(ia(n)),s=s.concat(ra(n)),s=s.concat(aa(n)),s=s.concat(sa(n)),s}function Zr(e){let s=e.filter((r)=>!Object.hasOwn(r,Xe)),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}function Qr(e){let s=e.filter((r)=>{let o=r[Xe];return!(o instanceof RegExp)&&typeof o!=="function"&&!Object.hasOwn(o,"exec")&&typeof o!=="string"}),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}var ea=/[^\\][$]/;function ta(e){class s extends Ve{constructor(){super(...arguments);this.found=!1}visitEndAnchor(r){this.found=!0}}return e.filter((r)=>{let o=r.PATTERN;try{let c=He(o),d=new s;return d.visit(c),d.found}catch(c){return ea.test(o.source)}}).map((r)=>({message:`Unexpected RegExp Anchor Error:
24
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`);b=!1}return O},[])});return{emptyGroups:x,patternIdxToConfig:v,charCodeToPatternIdxToConfig:k,hasCustom:r,canBeOptimized:b}}function qr(e){var s,n;if(!(e instanceof RegExp)||e.flags!=="")return;let i;try{i=He(e)}catch(d){return}if(i.value.value.length!==1||i.value.value[0].value.length!==1)return;let r=i.value.value[0].value[0],o;while(r.type==="Group"){if(r.capturing||r.quantifier!==void 0&&o!==void 0||r.value.value.length!==1||r.value.value[0].value.length!==1)return;o=(s=r.quantifier)!==null&&s!==void 0?s:o,r=r.value.value[0].value[0]}if(r.type!=="Set"||r.complement||r.quantifier!==void 0&&o!==void 0)return;if(o=(n=r.quantifier)!==null&&n!==void 0?n:o,(o===null||o===void 0?void 0:o.atLeast)!==1||o.atMost!==1/0||!o.greedy)return;let c=new Uint8Array(128);for(let d of r.value){let l=typeof d==="number"?d:d.from,p=typeof d==="number"?d:d.to;if(l<0||p>=c.length)return;c.fill(1,l,p+1)}return c}function Un(e,s){let n=[],i=Zr(e);n=n.concat(i.errors);let r=Qr(i.valid),o=r.valid;return n=n.concat(r.errors),n=n.concat(Jr(o)),n=n.concat(oa(o)),n=n.concat(la(o,s)),n=n.concat(ca(o)),n}function Jr(e){let s=[],n=e.filter((i)=>i[Xe]instanceof RegExp);return s=s.concat(ta(n)),s=s.concat(ia(n)),s=s.concat(ra(n)),s=s.concat(aa(n)),s=s.concat(sa(n)),s}function Zr(e){let s=e.filter((r)=>!Object.hasOwn(r,Xe)),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}function Qr(e){let s=e.filter((r)=>{let o=r[Xe];return!(o instanceof RegExp)&&typeof o!=="function"&&!Object.hasOwn(o,"exec")&&typeof o!=="string"}),n=s.map((r)=>({message:"Token Type: ->"+r.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[r]})),i=e.filter((r)=>!s.includes(r));return{errors:n,valid:i}}var ea=/[^\\][$]/;function ta(e){class s extends Ve{constructor(){super(...arguments);this.found=!1}visitEndAnchor(r){this.found=!0}}return e.filter((r)=>{let o=r.PATTERN;try{let c=He(o),d=new s;return d.visit(c),d.found}catch(c){return ea.test(o.source)}}).map((r)=>({message:`Unexpected RegExp Anchor Error:
25
25
  Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
26
26
  See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.EOI_ANCHOR_FOUND,tokenTypes:[r]}))}function sa(e){return e.filter((i)=>i.PATTERN.test("")).map((i)=>({message:"Token Type: ->"+i.name+"<- static 'PATTERN' must not match an empty string",type:V.EMPTY_MATCH_PATTERN,tokenTypes:[i]}))}var na=/[^\\[][\^]|^\^/;function ia(e){class s extends Ve{constructor(){super(...arguments);this.found=!1}visitStartAnchor(r){this.found=!0}}return e.filter((r)=>{let o=r.PATTERN;try{let c=He(o),d=new s;return d.visit(c),d.found}catch(c){return na.test(o.source)}}).map((r)=>({message:`Unexpected RegExp Anchor Error:
27
27
  Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
@@ -50,14 +50,14 @@ a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Nt,
50
50
  Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
51
51
  Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Cn()}),this.TRACE_INIT("toFastProperties",()=>{At(this)})})}tokenize(e,s=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let i=this.lexerDefinitionErrors.map((r)=>r.message).join(`-----------------------
52
52
  `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
53
- `+i)}return this.tokenizeInternal(e,s)}tokenizeInternal(e,s){let n,i,r,o,c,d,l,p,f,m,T,g,_,x,C,N=e,O=N.length,E=0,b=0,te=this.hasCustom?0:Math.floor(e.length/10),oe=Array(te),pt=[],be=this.trackStartLines?1:void 0,Ie=this.trackStartLines?1:void 0,et={};for(let se=0;se<this.cachedGroupKeys.length;se++)et[this.cachedGroupKeys[se]]=[];let Fr=this.trackStartLines,Is=this.config.lineTerminatorsPattern,ks=0,Ge=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,Br=(se)=>{if(mt.length===1&&se.tokenType.PUSH_MODE===void 0){let Ae=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(se);pt.push({offset:se.startOffset,line:se.startLine,column:se.startColumn,length:se.image.length,message:Ae})}else{mt.pop();let Ae=mt.at(-1);Ge=this.patternIdxToConfig[Ae],ft=this.charCodeToPatternIdxToConfig[Ae],ks=Ge.length;let Cs=this.canModeBeOptimized[Ae]&&this.config.safeMode===!1;if(ft&&Cs)Et=!0;else Et=!1}};function On(se){mt.push(se),ft=this.charCodeToPatternIdxToConfig[se],Ge=this.patternIdxToConfig[se],ks=Ge.length;let Ae=this.canModeBeOptimized[se]&&this.config.safeMode===!1;if(ft&&Ae)Et=!0;else Et=!1}On.call(this,s);let ge,Ln=this.config.recoveryEnabled;while(E<O){d=null,f=-1;let se=N.charCodeAt(E),Ae;if(Et){let re=Ce(se),ue=ft[re];Ae=ue!==void 0?ue:yn}else Ae=Ge;let Cs=Ae.length;for(n=0;n<Cs;n++){ge=Ae[n];let re=ge.pattern;switch(l=null,ge.matchType){case Jt:if(se===ge.short)f=1,d=re;break;case Lt:if(C=re.exec(N,E,oe,et),C!==null){if(d=C[0],f=d.length,C.payload!==void 0)l=C.payload}else d=null;break;case Qt:{let ue=ge.asciiClass;if(ue[se]!==1){re.lastIndex=0;break}let ce=E+1;while(ue[N.charCodeAt(ce)]===1)ce++;f=ce-E,re.lastIndex=ce;break}case Zt:re.lastIndex=E,f=this.matchLength(re,e,E);break}if(f!==-1){if(c=ge.longerAlt,c!==void 0){d=e.substring(E,E+f);let ue=c.length;for(r=0;r<ue;r++){let ce=Ge[c[r]],_e=ce.pattern;if(p=null,ce.matchType===Lt)if(C=_e.exec(N,E,oe,et),C!==null){if(o=C[0],C.payload!==void 0)p=C.payload}else o=null;else _e.lastIndex=E,o=this.match(_e,e,E);if(o&&o.length>d.length){d=o,f=o.length,l=p,ge=ce;break}}}break}}if(f!==-1){if(m=ge.group,m!==void 0)if(d=d!==null?d:e.substring(E,E+f),T=ge.tokenTypeIdx,g=this.createTokenInstance(d,E,T,ge.tokenType,be,Ie,f),this.handlePayload(g,l),m===!1)b=this.addToken(oe,b,g);else et[m].push(g);if(Fr===!0&&ge.canLineTerminator===!0){let re=0,ue,ce;Is.lastIndex=0;do if(d=d!==null?d:e.substring(E,E+f),ue=Is.test(d),ue===!0)ce=Is.lastIndex-1,re++;while(ue===!0);if(re!==0)be=be+re,Ie=f-ce,this.updateTokenEndLineColumnLocation(g,m,ce,re,be,Ie,f);else Ie=this.computeNewColumn(Ie,f)}else Ie=this.computeNewColumn(Ie,f);E=E+f,this.handleModes(ge,Br,On,g)}else{let re=E,ue=be,ce=Ie,_e=Ln===!1;while(_e===!1&&E<O){E++;for(i=0;i<ks;i++){let bs=Ge[i],_s=bs.pattern;switch(bs.matchType){case Jt:if(N.charCodeAt(E)===bs.short)_e=!0;break;case Lt:_e=_s.exec(N,E,oe,et)!==null;break;case Qt:case Zt:_s.lastIndex=E,_e=_s.exec(e)!==null;break}if(_e===!0)break}}if(_=E-re,Ie=this.computeNewColumn(Ie,_),x=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,re,_,ue,ce,mt.at(-1)),pt.push({offset:re,line:ue,column:ce,length:_,message:x}),Ln===!1)break}}if(!this.hasCustom)oe.length=b;return{tokens:oe,groups:et,errors:pt}}handleModes(e,s,n,i){if(e.pop===!0){let r=e.push;if(s(i),r!==void 0)n.call(this,r)}else if(e.push!==void 0)n.call(this,e.push)}updateTokenEndLineColumnLocation(e,s,n,i,r,o,c){let d,l;if(s!==void 0){if(d=n===c-1,l=d?-1:0,!(i===1&&d===!0))e.endLine=r+l,e.endColumn=o-1+-l}}computeNewColumn(e,s){return e+s}createOffsetOnlyToken(e,s,n,i){return{image:e,startOffset:s,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,s,n,i,r,o){return{image:e,startOffset:s,startLine:r,startColumn:o,tokenTypeIdx:n,tokenType:i}}createFullToken(e,s,n,i,r,o,c){return{image:e,startOffset:s,endOffset:s+c-1,startLine:r,endLine:r,startColumn:o,endColumn:o+c-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,s,n){return e.push(n),s}addTokenUsingMemberAccess(e,s,n){return e[s]=n,s++,s}handlePayloadNoCustom(e,s){}handlePayloadWithCustom(e,s){if(s!==null)e.payload=s}match(e,s,n){if(e.test(s)===!0)return s.substring(n,e.lastIndex);return null}matchLength(e,s,n){if(e.test(s)===!0)return e.lastIndex-n;return-1}}z.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.";z.NA=/NOT_APPLICABLE/;function Ye(e){if($s(e))return e.LABEL;else return e.name}function $s(e){return typeof e.LABEL==="string"&&e.LABEL!==""}var ya="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function y(e){return Oa(e)}function Oa(e){let s=e.pattern,n={};if(n.name=e.name,s!==void 0)n.PATTERN=s;if(Object.hasOwn(e,ya))throw`The parent property is no longer supported.
53
+ `+i)}return this.tokenizeInternal(e,s)}tokenizeInternal(e,s){let n,i,r,o,c,d,l,p,f,m,T,g,x,v,b,k=e,O=k.length,E=0,_=0,te=this.hasCustom?0:Math.floor(e.length/10),oe=Array(te),pt=[],be=this.trackStartLines?1:void 0,Ie=this.trackStartLines?1:void 0,et={};for(let se=0;se<this.cachedGroupKeys.length;se++)et[this.cachedGroupKeys[se]]=[];let Fr=this.trackStartLines,Is=this.config.lineTerminatorsPattern,ks=0,Ge=[],ft=[],mt=[],yn=[];Object.freeze(yn);let Et=!1,Br=(se)=>{if(mt.length===1&&se.tokenType.PUSH_MODE===void 0){let Ae=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(se);pt.push({offset:se.startOffset,line:se.startLine,column:se.startColumn,length:se.image.length,message:Ae})}else{mt.pop();let Ae=mt.at(-1);Ge=this.patternIdxToConfig[Ae],ft=this.charCodeToPatternIdxToConfig[Ae],ks=Ge.length;let Cs=this.canModeBeOptimized[Ae]&&this.config.safeMode===!1;if(ft&&Cs)Et=!0;else Et=!1}};function On(se){mt.push(se),ft=this.charCodeToPatternIdxToConfig[se],Ge=this.patternIdxToConfig[se],ks=Ge.length;let Ae=this.canModeBeOptimized[se]&&this.config.safeMode===!1;if(ft&&Ae)Et=!0;else Et=!1}On.call(this,s);let ge,Ln=this.config.recoveryEnabled;while(E<O){d=null,f=-1;let se=k.charCodeAt(E),Ae;if(Et){let re=Ce(se),ue=ft[re];Ae=ue!==void 0?ue:yn}else Ae=Ge;let Cs=Ae.length;for(n=0;n<Cs;n++){ge=Ae[n];let re=ge.pattern;switch(l=null,ge.matchType){case Jt:if(se===ge.short)f=1,d=re;break;case Lt:if(b=re.exec(k,E,oe,et),b!==null){if(d=b[0],f=d.length,b.payload!==void 0)l=b.payload}else d=null;break;case Qt:{let ue=ge.asciiClass;if(ue[se]!==1){re.lastIndex=0;break}let ce=E+1;while(ue[k.charCodeAt(ce)]===1)ce++;f=ce-E,re.lastIndex=ce;break}case Zt:re.lastIndex=E,f=this.matchLength(re,e,E);break}if(f!==-1){if(c=ge.longerAlt,c!==void 0){d=e.substring(E,E+f);let ue=c.length;for(r=0;r<ue;r++){let ce=Ge[c[r]],_e=ce.pattern;if(p=null,ce.matchType===Lt)if(b=_e.exec(k,E,oe,et),b!==null){if(o=b[0],b.payload!==void 0)p=b.payload}else o=null;else _e.lastIndex=E,o=this.match(_e,e,E);if(o&&o.length>d.length){d=o,f=o.length,l=p,ge=ce;break}}}break}}if(f!==-1){if(m=ge.group,m!==void 0)if(d=d!==null?d:e.substring(E,E+f),T=ge.tokenTypeIdx,g=this.createTokenInstance(d,E,T,ge.tokenType,be,Ie,f),this.handlePayload(g,l),m===!1)_=this.addToken(oe,_,g);else et[m].push(g);if(Fr===!0&&ge.canLineTerminator===!0){let re=0,ue,ce;Is.lastIndex=0;do if(d=d!==null?d:e.substring(E,E+f),ue=Is.test(d),ue===!0)ce=Is.lastIndex-1,re++;while(ue===!0);if(re!==0)be=be+re,Ie=f-ce,this.updateTokenEndLineColumnLocation(g,m,ce,re,be,Ie,f);else Ie=this.computeNewColumn(Ie,f)}else Ie=this.computeNewColumn(Ie,f);E=E+f,this.handleModes(ge,Br,On,g)}else{let re=E,ue=be,ce=Ie,_e=Ln===!1;while(_e===!1&&E<O){E++;for(i=0;i<ks;i++){let bs=Ge[i],_s=bs.pattern;switch(bs.matchType){case Jt:if(k.charCodeAt(E)===bs.short)_e=!0;break;case Lt:_e=_s.exec(k,E,oe,et)!==null;break;case Qt:case Zt:_s.lastIndex=E,_e=_s.exec(e)!==null;break}if(_e===!0)break}}if(x=E-re,Ie=this.computeNewColumn(Ie,x),v=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(k,re,x,ue,ce,mt.at(-1)),pt.push({offset:re,line:ue,column:ce,length:x,message:v}),Ln===!1)break}}if(!this.hasCustom)oe.length=_;return{tokens:oe,groups:et,errors:pt}}handleModes(e,s,n,i){if(e.pop===!0){let r=e.push;if(s(i),r!==void 0)n.call(this,r)}else if(e.push!==void 0)n.call(this,e.push)}updateTokenEndLineColumnLocation(e,s,n,i,r,o,c){let d,l;if(s!==void 0){if(d=n===c-1,l=d?-1:0,!(i===1&&d===!0))e.endLine=r+l,e.endColumn=o-1+-l}}computeNewColumn(e,s){return e+s}createOffsetOnlyToken(e,s,n,i){return{image:e,startOffset:s,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(e,s,n,i,r,o){return{image:e,startOffset:s,startLine:r,startColumn:o,tokenTypeIdx:n,tokenType:i}}createFullToken(e,s,n,i,r,o,c){return{image:e,startOffset:s,endOffset:s+c-1,startLine:r,endLine:r,startColumn:o,endColumn:o+c-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(e,s,n){return e.push(n),s}addTokenUsingMemberAccess(e,s,n){return e[s]=n,s++,s}handlePayloadNoCustom(e,s){}handlePayloadWithCustom(e,s){if(s!==null)e.payload=s}match(e,s,n){if(e.test(s)===!0)return s.substring(n,e.lastIndex);return null}matchLength(e,s,n){if(e.test(s)===!0)return e.lastIndex-n;return-1}}z.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.";z.NA=/NOT_APPLICABLE/;function Ye(e){if($s(e))return e.LABEL;else return e.name}function $s(e){return typeof e.LABEL==="string"&&e.LABEL!==""}var ya="parent",Hn="categories",Xn="label",Yn="group",qn="push_mode",Jn="pop_mode",Zn="longer_alt",Qn="line_breaks",ei="start_chars_hint";function y(e){return Oa(e)}function Oa(e){let s=e.pattern,n={};if(n.name=e.name,s!==void 0)n.PATTERN=s;if(Object.hasOwn(e,ya))throw`The parent property is no longer supported.
54
54
  See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;if(Object.hasOwn(e,Hn))n.CATEGORIES=e[Hn];if(ve([n]),Object.hasOwn(e,Xn))n.LABEL=e[Xn];if(Object.hasOwn(e,Yn))n.GROUP=e[Yn];if(Object.hasOwn(e,Jn))n.POP_MODE=e[Jn];if(Object.hasOwn(e,qn))n.PUSH_MODE=e[qn];if(Object.hasOwn(e,Zn))n.LONGER_ALT=e[Zn];if(Object.hasOwn(e,Qn))n.LINE_BREAKS=e[Qn];if(Object.hasOwn(e,ei))n.START_CHARS_HINT=e[ei];return n}var me=y({name:"EOF",pattern:z.NA});ve([me]);function qe(e,s,n,i,r,o,c,d){return{image:s,startOffset:n,endOffset:i,startLine:r,endLine:o,startColumn:c,endColumn:d,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function It(e,s){return xe(e,s)}var es={buildMismatchTokenMessage({expected:e,actual:s,previous:n,ruleName:i}){return`Expecting ${$s(e)?`--> ${Ye(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${s.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:s}){return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:s,previous:n,customUserDescription:i,ruleName:r}){let d=`
55
55
  but found: '`+s[0].image+"'";if(i)return"Expecting: "+i+d;else return`Expecting: one of these possible Token sequences:
56
56
  ${e.reduce((T,g)=>T.concat(g),[]).map((T)=>`[${T.map((g)=>Ye(g)).join(", ")}]`).map((T,g)=>` ${g+1}. ${T}`).join(`
57
57
  `)}`+d},buildEarlyExitMessage({expectedIterationPaths:e,actual:s,customUserDescription:n,ruleName:i}){let c=`
58
58
  but found: '`+s[0].image+"'";if(n)return"Expecting: "+n+c;else return`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
59
59
  <${e.map((p)=>`[${p.map((f)=>Ye(f)).join(",")}]`).join(" ,")}>`+c}};Object.freeze(es);var ti={buildRuleNotFoundError(e,s){return"Invalid grammar, reference to a rule which is not defined: ->"+s.nonTerminalName+`<-
60
- inside top level rule: ->`+e.name+"<-"}},Oe={buildDuplicateFoundError(e,s){function n(f){if(f instanceof v)return f.terminalType.name;else if(f instanceof G)return f.nonTerminalName;else return""}let i=e.name,r=s[0],o=r.idx,c=fe(r),d=n(r),l=o>0,p=`->${c}${l?o:""}<- ${d?`with argument: ->${d}<-`:""}
60
+ inside top level rule: ->`+e.name+"<-"}},Oe={buildDuplicateFoundError(e,s){function n(f){if(f instanceof M)return f.terminalType.name;else if(f instanceof G)return f.nonTerminalName;else return""}let i=e.name,r=s[0],o=r.idx,c=fe(r),d=n(r),l=o>0,p=`->${c}${l?o:""}<- ${d?`with argument: ->${d}<-`:""}
61
61
  appears more than once (${s.length} times) in the top level rule: ->${i}<-.
62
62
  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
63
63
  `;return p=p.replace(/[ \t]+/g," "),p=p.replace(/\s\s+/g,`
@@ -83,7 +83,7 @@ rule: <${s}> can be invoked from itself (directly or indirectly)
83
83
  without consuming any Tokens. The grammar path that causes this is:
84
84
  ${i}
85
85
  To fix this refactor your grammar to remove the left recursion.
86
- see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let s;if(e.topLevelRule instanceof de)s=e.topLevelRule.name;else s=e.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${e.grammarName}<-`}};function si(e,s){let n=new ni(e,s);return n.resolveRefs(),n.errors}class ni extends pe{constructor(e,s){super();this.nameToTopRule=e,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((e)=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let s=this.nameToTopRule[e.nonTerminalName];if(!s){let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:ne.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}else e.referencedRule=s}}class ii extends Be{constructor(e,s){super();this.topProd=e,this.path=s,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,s=[]){if(!this.found)super.walk(e,s)}walkProdRef(e,s,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=s.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Gs extends ii{constructor(e,s){super(e,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,s,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=s.concat(n),r=new W({definition:i});this.possibleTokTypes=je(r),this.found=!0}}}class kt extends Be{constructor(e,s){super();this.topRule=e,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Ws extends kt{walkMany(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof v)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkMany(e,s,n)}}class ts extends kt{walkManySep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof v)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkManySep(e,s,n)}}class js extends kt{walkAtLeastOne(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof v)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOne(e,s,n)}}class ss extends kt{walkAtLeastOneSep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof v)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOneSep(e,s,n)}}function ns(e,s,n=[]){n=[...n];let i=[],r=0;function o(d){return d.concat(e.slice(r+1))}function c(d){let l=ns(o(d),s,n);return i.concat(l)}while(n.length<s&&r<e.length){let d=e[r];if(d instanceof W)return c(d.definition);else if(d instanceof G)return c(d.definition);else if(d instanceof K)i=c(d.definition);else if(d instanceof Z){let l=d.definition.concat([new U({definition:d.definition})]);return c(l)}else if(d instanceof Q){let l=[new W({definition:d.definition}),new U({definition:[new v({terminalType:d.separator})].concat(d.definition)})];return c(l)}else if(d instanceof q){let l=d.definition.concat([new U({definition:[new v({terminalType:d.separator})].concat(d.definition)})]);i=c(l)}else if(d instanceof U){let l=d.definition.concat([new U({definition:d.definition})]);i=c(l)}else if(d instanceof J)return d.definition.forEach((l)=>{if(l.definition.length!==0)i=c(l.definition)}),i;else if(d instanceof v)n.push(d.terminalType);else throw Error("non exhaustive match");r++}return i.push({partialPath:n,suffixDef:e.slice(r)}),i}function ri(e,s,n,i){let o=["EXIT_NONE_TERMINAL"],c="EXIT_ALTERNATIVE",d=!1,l=s.length,p=l-i-1,f=[],m=[];m.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let T=m.pop();if(T==="EXIT_ALTERNATIVE"){if(d&&m.at(-1).idx<=p)m.pop();continue}let{def:g,idx:_,ruleStack:x,occurrenceStack:C}=T;if(g.length===0)continue;let N=g[0];if(N==="EXIT_NONE_TERMINAL"){let O={idx:_,def:g.slice(1),ruleStack:x.slice(0,-1),occurrenceStack:C.slice(0,-1)};m.push(O)}else if(N instanceof v)if(_<l-1){let O=_+1,E=s[O];if(n(E,N.terminalType)){let b={idx:O,def:g.slice(1),ruleStack:x,occurrenceStack:C};m.push(b)}}else if(_===l-1)f.push({nextTokenType:N.terminalType,nextTokenOccurrence:N.idx,ruleStack:x,occurrenceStack:C}),d=!0;else throw Error("non exhaustive match");else if(N instanceof G){let O=[...x];O.push(N.nonTerminalName);let E=[...C];E.push(N.idx);let b={idx:_,def:N.definition.concat(o,g.slice(1)),ruleStack:O,occurrenceStack:E};m.push(b)}else if(N instanceof K){let O={idx:_,def:g.slice(1),ruleStack:x,occurrenceStack:C};m.push(O),m.push("EXIT_ALTERNATIVE");let E={idx:_,def:N.definition.concat(g.slice(1)),ruleStack:x,occurrenceStack:C};m.push(E)}else if(N instanceof Z){let O=new U({definition:N.definition,idx:N.idx}),E=N.definition.concat([O],g.slice(1)),b={idx:_,def:E,ruleStack:x,occurrenceStack:C};m.push(b)}else if(N instanceof Q){let O=new v({terminalType:N.separator}),E=new U({definition:[O].concat(N.definition),idx:N.idx}),b=N.definition.concat([E],g.slice(1)),te={idx:_,def:b,ruleStack:x,occurrenceStack:C};m.push(te)}else if(N instanceof q){let O={idx:_,def:g.slice(1),ruleStack:x,occurrenceStack:C};m.push(O),m.push("EXIT_ALTERNATIVE");let E=new v({terminalType:N.separator}),b=new U({definition:[E].concat(N.definition),idx:N.idx}),te=N.definition.concat([b],g.slice(1)),oe={idx:_,def:te,ruleStack:x,occurrenceStack:C};m.push(oe)}else if(N instanceof U){let O={idx:_,def:g.slice(1),ruleStack:x,occurrenceStack:C};m.push(O),m.push("EXIT_ALTERNATIVE");let E=new U({definition:N.definition,idx:N.idx}),b=N.definition.concat([E],g.slice(1)),te={idx:_,def:b,ruleStack:x,occurrenceStack:C};m.push(te)}else if(N instanceof J)for(let O=N.definition.length-1;O>=0;O--){let E=N.definition[O],b={idx:_,def:E.definition.concat(g.slice(1)),ruleStack:x,occurrenceStack:C};m.push(b),m.push("EXIT_ALTERNATIVE")}else if(N instanceof W)m.push({idx:_,def:N.definition.concat(g.slice(1)),ruleStack:x,occurrenceStack:C});else if(N instanceof de)m.push(La(N,_,x,C));else throw Error("non exhaustive match")}return f}function La(e,s,n,i){let r=[...n];r.push(e.name);let o=[...i];return o.push(1),{idx:s,def:e.definition,ruleStack:r,occurrenceStack:o}}var H;(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"})(H||(H={}));function is(e){if(e instanceof K||e==="Option")return H.OPTION;else if(e instanceof U||e==="Repetition")return H.REPETITION;else if(e instanceof Z||e==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(e instanceof Q||e==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(e instanceof q||e==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(e instanceof J||e==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function oi(e,s,n,i,r,o){let c=Ct(e,s,n),d=fi(c)?at:xe;return o(c,i,d,r)}function li(e,s,n,i,r,o){let c=bt(e,s,r,n),d=fi(c)?at:xe;return o(c[0],d,i)}function ci(e,s,n,i){let r=e.length,o=e.every((c)=>c.every((d)=>d.length===1));if(s)return function(c){let d=c.map((l)=>l.GATE);for(let l=0;l<r;l++){let p=e[l],f=p.length,m=d[l];if(m!==void 0&&m.call(this)===!1)continue;e:for(let T=0;T<f;T++){let g=p[T],_=g.length;for(let x=0;x<_;x++){let C=this.LA_FAST(x+1);if(n(C,g[x])===!1)continue e}return l}}return};else if(o&&!i){let d=e.map((l)=>l.flat()).reduce((l,p,f)=>(p.forEach((m)=>{if(!(m.tokenTypeIdx in l))l[m.tokenTypeIdx]=f;m.categoryMatches.forEach((T)=>{if(!Object.hasOwn(l,T))l[T]=f})}),l),{});return function(){let l=this.LA_FAST(1);return d[l.tokenTypeIdx]}}else return function(){for(let c=0;c<r;c++){let d=e[c],l=d.length;e:for(let p=0;p<l;p++){let f=d[p],m=f.length;for(let T=0;T<m;T++){let g=this.LA_FAST(T+1);if(n(g,f[T])===!1)continue e}return c}}return}}function hi(e,s,n){let i=e.every((o)=>o.length===1),r=e.length;if(i&&!n){let o=e.flat();if(o.length===1&&o[0].categoryMatches.length===0){let d=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===d}}else{let c=o.reduce((d,l,p)=>(d[l.tokenTypeIdx]=!0,l.categoryMatches.forEach((f)=>{d[f]=!0}),d),[]);return function(){let d=this.LA_FAST(1);return c[d.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<r;o++){let c=e[o],d=c.length;for(let l=0;l<d;l++){let p=this.LA_FAST(l+1);if(s(p,c[l])===!1)continue e}return!0}return!1}}class ui extends Be{constructor(e,s,n){super();this.topProd=e,this.targetOccurrence=s,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,s,n,i){if(e.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=n.concat(i),!0;return!1}walkOption(e,s,n){if(!this.checkIsTarget(e,H.OPTION,s,n))super.walkOption(e,s,n)}walkAtLeastOne(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY,s,n))super.walkOption(e,s,n)}walkAtLeastOneSep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}walkMany(e,s,n){if(!this.checkIsTarget(e,H.REPETITION,s,n))super.walkOption(e,s,n)}walkManySep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}}class Vs extends pe{constructor(e,s,n){super();this.targetOccurrence=e,this.targetProdType=s,this.targetRef=n,this.result=[]}checkIsTarget(e,s){if(e.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||e===this.targetRef))this.result=e.definition}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}}function ai(e){let s=Array(e);for(let n=0;n<e;n++)s[n]=[];return s}function Ks(e){let s=[""];for(let n=0;n<e.length;n++){let i=e[n],r=[];for(let o=0;o<s.length;o++){let c=s[o];r.push(c+"_"+i.tokenTypeIdx);for(let d=0;d<i.categoryMatches.length;d++){let l="_"+i.categoryMatches[d];r.push(c+l)}}s=r}return s}function Na(e,s,n){for(let i=0;i<e.length;i++){if(i===n)continue;let r=e[i];for(let o=0;o<s.length;o++){let c=s[o];if(r[c]===!0)return!1}}return!0}function di(e,s){let n=e.map((c)=>ns([c],1)),i=ai(n.length),r=n.map((c)=>{let d={};return c.forEach((l)=>{Ks(l.partialPath).forEach((f)=>{d[f]=!0})}),d}),o=n;for(let c=1;c<=s;c++){let d=o;o=ai(d.length);for(let l=0;l<d.length;l++){let p=d[l];for(let f=0;f<p.length;f++){let m=p[f].partialPath,T=p[f].suffixDef,g=Ks(m);if(Na(r,g,l)||T.length===0||m.length===s){let x=i[l];if(rs(x,m)===!1){x.push(m);for(let C=0;C<g.length;C++){let N=g[C];r[l][N]=!0}}}else{let x=ns(T,c+1,m);o[l]=o[l].concat(x),x.forEach((C)=>{Ks(C.partialPath).forEach((O)=>{r[l][O]=!0})})}}}}return i}function Ct(e,s,n,i){let r=new Vs(e,H.ALTERNATION,i);return s.accept(r),di(r.result,n)}function bt(e,s,n,i){let r=new Vs(e,n);s.accept(r);let o=r.result,d=new ui(s,e,n).startWalking(),l=new W({definition:o}),p=new W({definition:d});return di([l,p],i)}function rs(e,s){e:for(let n=0;n<e.length;n++){let i=e[n];if(i.length!==s.length)continue;for(let r=0;r<i.length;r++){let o=s[r],c=i[r];if((o===c||c.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function pi(e,s){return e.length<s.length&&e.every((n,i)=>{let r=s[i];return n===r||r.categoryMatchesMap[n.tokenTypeIdx]})}function fi(e){return e.every((s)=>s.every((n)=>n.every((i)=>i.categoryMatches.length===0)))}function mi(e){return e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map((n)=>Object.assign({type:ne.CUSTOM_LOOKAHEAD_VALIDATION},n))}function Ei(e,s,n,i){let r=e.flatMap((l)=>Ia(l,n)),o=va(e,s,n),c=e.flatMap((l)=>ba(l,n)),d=e.flatMap((l)=>Ca(l,e,i,n));return r.concat(o,c,d)}function Ia(e,s){let n=new gi;e.accept(n);let i=n.allProductions,r=Object.groupBy(i,ka),o=Object.fromEntries(Object.entries(r).filter(([d,l])=>l.length>1));return Object.values(o).map((d)=>{let l=d[0],p=s.buildDuplicateFoundError(e,d),f=fe(l),m={message:p,type:ne.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:f,occurrence:l.idx},T=Ti(l);if(T)m.parameter=T;return m})}function ka(e){return`${fe(e)}_#_${e.idx}_#_${Ti(e)}`}function Ti(e){if(e instanceof v)return e.terminalType.name;else if(e instanceof G)return e.nonTerminalName;else return""}class gi extends pe{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)}}function Ca(e,s,n,i){let r=[];if(s.reduce((c,d)=>{if(d.name===e.name)return c+1;return c},0)>1){let c=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});r.push({message:c,type:ne.DUPLICATE_RULE_NAME,ruleName:e.name})}return r}function Ai(e,s,n){let i=[],r;if(!s.includes(e))r=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,i.push({message:r,type:ne.INVALID_RULE_OVERRIDE,ruleName:e});return i}function zs(e,s,n,i=[]){let r=[],o=as(s.definition);if(o.length===0)return[];else{let c=e.name;if(o.includes(e))r.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:i}),type:ne.LEFT_RECURSION,ruleName:c});let l=i.concat([e]),f=o.filter((m)=>!l.includes(m)).flatMap((m)=>{let T=[...i];return T.push(m),zs(e,m,n,T)});return r.concat(f)}}function as(e){let s=[];if(e.length===0)return s;let n=e[0];if(n instanceof G)s.push(n.referencedRule);else if(n instanceof W||n instanceof K||n instanceof Z||n instanceof Q||n instanceof q||n instanceof U)s=s.concat(as(n.definition));else if(n instanceof J)s=n.definition.map((o)=>as(o.definition)).flat();else if(n instanceof v);else throw Error("non exhaustive match");let i=We(n),r=e.length>1;if(i&&r){let o=e.slice(1);return s.concat(as(o))}else return s}class os extends pe{constructor(){super(...arguments);this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Si(e,s){let n=new os;return e.accept(n),n.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((d,l)=>{if(ri([d],[],xe,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:l}),type:ne.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:l+1}];else return[]}))}function Ri(e,s,n){let i=new os;e.accept(i);let r=i.alternations;return r=r.filter((c)=>c.ignoreAmbiguities!==!0),r.flatMap((c)=>{let d=c.idx,l=c.maxLookahead||s,p=Ct(d,e,l,c),f=_a(p,c,e,n),m=xa(p,c,e,n);return f.concat(m)})}class yi extends pe{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)}}function ba(e,s){let n=new os;return e.accept(n),n.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:ne.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}];else return[]})}function Oi(e,s,n){let i=[];return e.forEach((r)=>{let o=new yi;r.accept(o),o.allProductions.forEach((d)=>{let l=is(d),p=d.maxLookahead||s,f=d.idx;if(bt(f,r,l,p)[0].flat().length===0){let g=n.buildEmptyRepetitionError({topLevelRule:r,repetition:d});i.push({message:g,type:ne.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),i}function _a(e,s,n,i){let r=[];return e.reduce((d,l,p)=>{if(s.definition[p].ignoreAmbiguities===!0)return d;return l.forEach((f)=>{let m=[p];if(e.forEach((T,g)=>{if(p!==g&&rs(T,f)&&s.definition[g].ignoreAmbiguities!==!0)m.push(g)}),m.length>1&&!rs(r,f))r.push(f),d.push({alts:m,path:f})}),d},[]).map((d)=>{let l=d.alts.map((f)=>f+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:l,prefixPath:d.path}),type:ne.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:s.idx,alternatives:d.alts}})}function xa(e,s,n,i){let r=e.reduce((c,d,l)=>{let p=d.map((f)=>({idx:l,path:f}));return c.concat(p)},[]);return r.flatMap((c)=>{if(s.definition[c.idx].ignoreAmbiguities===!0)return[];let{idx:l,path:p}=c;return r.filter((T)=>s.definition[T.idx].ignoreAmbiguities!==!0&&T.idx<l&&pi(T.path,p)).map((T)=>{let g=[T.idx+1,l+1],_=s.idx===0?"":s.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:g,prefixPath:T.path}),type:ne.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:_,alternatives:g}})})}function va(e,s,n){let i=[],r=s.map((o)=>o.name);return e.forEach((o)=>{let c=o.name;if(r.includes(c)){let d=n.buildNamespaceConflictError(o);i.push({message:d,type:ne.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:c})}}),i}function Li(e){let s=Object.assign({errMsgProvider:ti},e),n={};return e.rules.forEach((i)=>{n[i.name]=i}),si(n,s.errMsgProvider)}function Ni(e){var s;let n=(s=e.errMsgProvider)!==null&&s!==void 0?s:Oe;return Ei(e.rules,e.tokenTypes,n,e.grammarName)}var Ii=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(Ii);function $e(e){return Ii.includes(e.name)}class _t extends Error{constructor(e,s){super(e);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="MismatchedTokenException"}}class ls extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="NoViableAltException"}}class cs extends _t{constructor(e,s){super(e,s);this.name="NotAllInputParsedException"}}class hs extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="EarlyExitException"}}var Hs={},Xs="InRuleRecoveryException";class ki extends Error{constructor(e){super(e);this.name=Xs}}class Ys{initRecoverable(e){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:he.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=Ma}getTokenToInsert(e){let s=qe(e,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,s,n,i){let r=this.findReSyncTokenType(),o=this.exportLexerState(),c=[],d=!1,l=this.LA_FAST(1),p=this.LA_FAST(1),f=()=>{let m=this.LA(0),T=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:m,ruleName:this.getCurrRuleFullName()}),g=new ot(T,l,this.LA(0));g.resyncedTokens=c.slice(0,-1),this.SAVE_ERROR(g)};while(!d)if(this.tokenMatcher(p,i)){f();return}else if(n.call(this)){f(),e.apply(this,s);return}else if(this.tokenMatcher(p,r))d=!0;else p=this.SKIP_TOKEN(),this.addToResyncTokens(p,c);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,s,n){if(n===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),e))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,s)))return!1;return!0}getNextPossibleTokenTypes(e){let s=e.ruleStack[0],i=this.getGAstProductions()[s];return new Gs(i,e).startWalking()}getFollowsForInRuleRecovery(e,s){let n=this.getCurrentGrammarPath(e,s);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,s){if(this.canRecoverWithSingleTokenInsertion(e,s))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new ki("sad sad panda")}canPerformInRuleRecovery(e,s){return this.canRecoverWithSingleTokenInsertion(e,s)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,s){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(s.length===0)return!1;let n=this.LA_FAST(1);return s.find((r)=>this.tokenMatcher(n,r))!==void 0}canRecoverWithSingleTokenDeletion(e){if(!this.canTokenTypeBeDeletedInRecovery(e))return!1;return this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),s=this.LA_FAST(1),n=2;while(!0){let i=e.find((r)=>It(s,r));if(i!==void 0)return i;s=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Hs;let e=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=Array(n);for(let r=0;r<n;r++)if(r===0)i[r]=Hs;else i[r]={ruleName:this.shortRuleNameToFullName(e[r]),idxInCallingRule:s[r],inRule:this.shortRuleNameToFullName(e[r-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(e){if(e===Hs)return[me];let s=e.ruleName+e.idxInCallingRule+Wt+e.inRule;return this.resyncFollows[s]}addToResyncTokens(e,s){if(!this.tokenMatcher(e,me))s.push(e);return s}reSyncTo(e){let s=[],n=this.LA_FAST(1);while(this.tokenMatcher(n,e)===!1)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,s);return s.slice(0,-1)}attemptInRepetitionRecovery(e,s,n,i,r,o,c){}getCurrentGrammarPath(e,s){let n=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:s}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,s=Array(e);for(let n=0;n<e;n++)s[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return s}}function Ma(e,s,n,i,r,o,c){var d,l,p;let f=i|r,m=(d=(l=this.firstAfterRepMap)[p=this.currRuleShortName])!==null&&d!==void 0?d:l[p]=[],T=m[f];if(T===void 0){let C=this.getCurrRuleFullName(),N=this.getGAstProductions()[C];T=new o(N,r).startWalking(),m[f]=T}let g=T.token,_=T.occurrence,x=T.isEndOfRule;if(this.RULE_STACK_IDX===0&&x&&g===void 0)g=me,_=1;if(g===void 0||_===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(g,_,c))this.tryInRepetitionRecovery(e,s,n,g)}var us=256,ds=512,xt=768,vt=1024,Mt=1280,lt=1536;class ps{constructor(e){var s;this.maxLookahead=(s=e===null||e===void 0?void 0:e.maxLookahead)!==null&&s!==void 0?s:he.maxLookahead}validate(e){let s=this.validateNoLeftRecursion(e.rules);if(s.length===0){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),r=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...s,...n,...i,...r]}return s}validateNoLeftRecursion(e){return e.flatMap((s)=>zs(s,s,Oe))}validateEmptyOrAlternatives(e){return e.flatMap((s)=>Si(s,Oe))}validateAmbiguousAlternationAlternatives(e,s){return e.flatMap((n)=>Ri(n,s,Oe))}validateSomeNonEmptyLookaheadPath(e,s){return Oi(e,s,Oe)}buildLookaheadForAlternation(e){return oi(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,ci)}buildLookaheadForOptional(e){return li(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,is(e.prodType),hi)}}class qs{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:he.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:he.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new ps({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:r,repetitionMandatory:o,repetitionMandatoryWithSeparator:c,repetitionWithSeparator:d}=wa(s);n.forEach((l)=>{let p=l.idx===0?"":l.idx;this.TRACE_INIT(`${fe(l)}${p}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:s,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],us|l.idx,f)})}),i.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,xt,"Repetition",l.maxLookahead,fe(l))}),r.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,ds,"Option",l.maxLookahead,fe(l))}),o.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,vt,"RepetitionMandatory",l.maxLookahead,fe(l))}),c.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,lt,"RepetitionMandatoryWithSeparator",l.maxLookahead,fe(l))}),d.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,Mt,"RepetitionWithSeparator",l.maxLookahead,fe(l))})})})}computeLookaheadFunc(e,s,n,i,r,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let c=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:e,maxLookahead:r||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|s,c)})}setLaFuncCache(e,s,n){let i=this.lookAheadFuncsCache[e];if(i===void 0)i=[],this.lookAheadFuncsCache[e]=i;i[s]=n}}class Ci extends pe{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)}}var fs=new Ci;function wa(e){fs.reset(),e.accept(fs);let s=fs.dslMethods;return fs.reset(),s}function Js(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.endOffset=s.endOffset;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset}function Zs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.startColumn=s.startColumn,e.startLine=s.startLine,e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine}function bi(e,s,n){if(e.children[n]===void 0)e.children[n]=[s];else e.children[n].push(s)}function _i(e,s,n){if(e.children[s]===void 0)e.children[s]=[n];else e.children[s].push(n)}function Qs(e,s){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Ua(e,s){let n=Object.keys(e),i=n.length;for(let r=0;r<i;r++){let o=n[r],c=e[o],d=c.length;for(let l=0;l<d;l++){let p=c[l];if(p.tokenTypeIdx===void 0)this[p.name](p.children,s)}}}function xi(e,s){let n=function(){};Qs(n,e+"BaseSemantics");let i={visit:function(r,o){if(Array.isArray(r))r=r[0];if(r===void 0)return;return this[r.name](r.children,o)},validateVisitor:function(){let r=Pa(this,s);if(r.length!==0){let o=r.map((c)=>c.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
86
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){return"deprecated"},buildDuplicateRuleNameError(e){let s;if(e.topLevelRule instanceof de)s=e.topLevelRule.name;else s=e.topLevelRule;return`Duplicate definition, rule: ->${s}<- is already defined in the grammar: ->${e.grammarName}<-`}};function si(e,s){let n=new ni(e,s);return n.resolveRefs(),n.errors}class ni extends pe{constructor(e,s){super();this.nameToTopRule=e,this.errMsgProvider=s,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach((e)=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let s=this.nameToTopRule[e.nonTerminalName];if(!s){let n=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:n,type:ne.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}else e.referencedRule=s}}class ii extends Be{constructor(e,s){super();this.topProd=e,this.path=s,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,s=[]){if(!this.found)super.walk(e,s)}walkProdRef(e,s,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=s.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){if(this.ruleStack.length===0)this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0;else this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop()}}class Gs extends ii{constructor(e,s){super(e,s);this.path=s,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,s,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let i=s.concat(n),r=new W({definition:i});this.possibleTokTypes=je(r),this.found=!0}}}class kt extends Be{constructor(e,s){super();this.topRule=e,this.occurrence=s,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Ws extends kt{walkMany(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof M)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkMany(e,s,n)}}class ts extends kt{walkManySep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof M)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkManySep(e,s,n)}}class js extends kt{walkAtLeastOne(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof M)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOne(e,s,n)}}class ss extends kt{walkAtLeastOneSep(e,s,n){if(e.idx===this.occurrence){let i=s.concat(n)[0];if(this.result.isEndOfRule=i===void 0,i instanceof M)this.result.token=i.terminalType,this.result.occurrence=i.idx}else super.walkAtLeastOneSep(e,s,n)}}function ns(e,s,n=[]){n=[...n];let i=[],r=0;function o(d){return d.concat(e.slice(r+1))}function c(d){let l=ns(o(d),s,n);return i.concat(l)}while(n.length<s&&r<e.length){let d=e[r];if(d instanceof W)return c(d.definition);else if(d instanceof G)return c(d.definition);else if(d instanceof K)i=c(d.definition);else if(d instanceof Z){let l=d.definition.concat([new U({definition:d.definition})]);return c(l)}else if(d instanceof Q){let l=[new W({definition:d.definition}),new U({definition:[new M({terminalType:d.separator})].concat(d.definition)})];return c(l)}else if(d instanceof q){let l=d.definition.concat([new U({definition:[new M({terminalType:d.separator})].concat(d.definition)})]);i=c(l)}else if(d instanceof U){let l=d.definition.concat([new U({definition:d.definition})]);i=c(l)}else if(d instanceof J)return d.definition.forEach((l)=>{if(l.definition.length!==0)i=c(l.definition)}),i;else if(d instanceof M)n.push(d.terminalType);else throw Error("non exhaustive match");r++}return i.push({partialPath:n,suffixDef:e.slice(r)}),i}function ri(e,s,n,i){let o=["EXIT_NONE_TERMINAL"],c="EXIT_ALTERNATIVE",d=!1,l=s.length,p=l-i-1,f=[],m=[];m.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});while(m.length!==0){let T=m.pop();if(T==="EXIT_ALTERNATIVE"){if(d&&m.at(-1).idx<=p)m.pop();continue}let{def:g,idx:x,ruleStack:v,occurrenceStack:b}=T;if(g.length===0)continue;let k=g[0];if(k==="EXIT_NONE_TERMINAL"){let O={idx:x,def:g.slice(1),ruleStack:v.slice(0,-1),occurrenceStack:b.slice(0,-1)};m.push(O)}else if(k instanceof M)if(x<l-1){let O=x+1,E=s[O];if(n(E,k.terminalType)){let _={idx:O,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(_)}}else if(x===l-1)f.push({nextTokenType:k.terminalType,nextTokenOccurrence:k.idx,ruleStack:v,occurrenceStack:b}),d=!0;else throw Error("non exhaustive match");else if(k instanceof G){let O=[...v];O.push(k.nonTerminalName);let E=[...b];E.push(k.idx);let _={idx:x,def:k.definition.concat(o,g.slice(1)),ruleStack:O,occurrenceStack:E};m.push(_)}else if(k instanceof K){let O={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(O),m.push("EXIT_ALTERNATIVE");let E={idx:x,def:k.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};m.push(E)}else if(k instanceof Z){let O=new U({definition:k.definition,idx:k.idx}),E=k.definition.concat([O],g.slice(1)),_={idx:x,def:E,ruleStack:v,occurrenceStack:b};m.push(_)}else if(k instanceof Q){let O=new M({terminalType:k.separator}),E=new U({definition:[O].concat(k.definition),idx:k.idx}),_=k.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};m.push(te)}else if(k instanceof q){let O={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(O),m.push("EXIT_ALTERNATIVE");let E=new M({terminalType:k.separator}),_=new U({definition:[E].concat(k.definition),idx:k.idx}),te=k.definition.concat([_],g.slice(1)),oe={idx:x,def:te,ruleStack:v,occurrenceStack:b};m.push(oe)}else if(k instanceof U){let O={idx:x,def:g.slice(1),ruleStack:v,occurrenceStack:b};m.push(O),m.push("EXIT_ALTERNATIVE");let E=new U({definition:k.definition,idx:k.idx}),_=k.definition.concat([E],g.slice(1)),te={idx:x,def:_,ruleStack:v,occurrenceStack:b};m.push(te)}else if(k instanceof J)for(let O=k.definition.length-1;O>=0;O--){let E=k.definition[O],_={idx:x,def:E.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b};m.push(_),m.push("EXIT_ALTERNATIVE")}else if(k instanceof W)m.push({idx:x,def:k.definition.concat(g.slice(1)),ruleStack:v,occurrenceStack:b});else if(k instanceof de)m.push(La(k,x,v,b));else throw Error("non exhaustive match")}return f}function La(e,s,n,i){let r=[...n];r.push(e.name);let o=[...i];return o.push(1),{idx:s,def:e.definition,ruleStack:r,occurrenceStack:o}}var H;(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"})(H||(H={}));function is(e){if(e instanceof K||e==="Option")return H.OPTION;else if(e instanceof U||e==="Repetition")return H.REPETITION;else if(e instanceof Z||e==="RepetitionMandatory")return H.REPETITION_MANDATORY;else if(e instanceof Q||e==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;else if(e instanceof q||e==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;else if(e instanceof J||e==="Alternation")return H.ALTERNATION;else throw Error("non exhaustive match")}function oi(e,s,n,i,r,o){let c=Ct(e,s,n),d=fi(c)?at:xe;return o(c,i,d,r)}function li(e,s,n,i,r,o){let c=bt(e,s,r,n),d=fi(c)?at:xe;return o(c[0],d,i)}function ci(e,s,n,i){let r=e.length,o=e.every((c)=>c.every((d)=>d.length===1));if(s)return function(c){let d=c.map((l)=>l.GATE);for(let l=0;l<r;l++){let p=e[l],f=p.length,m=d[l];if(m!==void 0&&m.call(this)===!1)continue;e:for(let T=0;T<f;T++){let g=p[T],x=g.length;for(let v=0;v<x;v++){let b=this.LA_FAST(v+1);if(n(b,g[v])===!1)continue e}return l}}return};else if(o&&!i){let d=e.map((l)=>l.flat()).reduce((l,p,f)=>(p.forEach((m)=>{if(!(m.tokenTypeIdx in l))l[m.tokenTypeIdx]=f;m.categoryMatches.forEach((T)=>{if(!Object.hasOwn(l,T))l[T]=f})}),l),{});return function(){let l=this.LA_FAST(1);return d[l.tokenTypeIdx]}}else return function(){for(let c=0;c<r;c++){let d=e[c],l=d.length;e:for(let p=0;p<l;p++){let f=d[p],m=f.length;for(let T=0;T<m;T++){let g=this.LA_FAST(T+1);if(n(g,f[T])===!1)continue e}return c}}return}}function hi(e,s,n){let i=e.every((o)=>o.length===1),r=e.length;if(i&&!n){let o=e.flat();if(o.length===1&&o[0].categoryMatches.length===0){let d=o[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===d}}else{let c=o.reduce((d,l,p)=>(d[l.tokenTypeIdx]=!0,l.categoryMatches.forEach((f)=>{d[f]=!0}),d),[]);return function(){let d=this.LA_FAST(1);return c[d.tokenTypeIdx]===!0}}}else return function(){e:for(let o=0;o<r;o++){let c=e[o],d=c.length;for(let l=0;l<d;l++){let p=this.LA_FAST(l+1);if(s(p,c[l])===!1)continue e}return!0}return!1}}class ui extends Be{constructor(e,s,n){super();this.topProd=e,this.targetOccurrence=s,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,s,n,i){if(e.idx===this.targetOccurrence&&this.targetProdType===s)return this.restDef=n.concat(i),!0;return!1}walkOption(e,s,n){if(!this.checkIsTarget(e,H.OPTION,s,n))super.walkOption(e,s,n)}walkAtLeastOne(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY,s,n))super.walkOption(e,s,n)}walkAtLeastOneSep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}walkMany(e,s,n){if(!this.checkIsTarget(e,H.REPETITION,s,n))super.walkOption(e,s,n)}walkManySep(e,s,n){if(!this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,s,n))super.walkOption(e,s,n)}}class Vs extends pe{constructor(e,s,n){super();this.targetOccurrence=e,this.targetProdType=s,this.targetRef=n,this.result=[]}checkIsTarget(e,s){if(e.idx===this.targetOccurrence&&this.targetProdType===s&&(this.targetRef===void 0||e===this.targetRef))this.result=e.definition}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}}function ai(e){let s=Array(e);for(let n=0;n<e;n++)s[n]=[];return s}function Ks(e){let s=[""];for(let n=0;n<e.length;n++){let i=e[n],r=[];for(let o=0;o<s.length;o++){let c=s[o];r.push(c+"_"+i.tokenTypeIdx);for(let d=0;d<i.categoryMatches.length;d++){let l="_"+i.categoryMatches[d];r.push(c+l)}}s=r}return s}function Na(e,s,n){for(let i=0;i<e.length;i++){if(i===n)continue;let r=e[i];for(let o=0;o<s.length;o++){let c=s[o];if(r[c]===!0)return!1}}return!0}function di(e,s){let n=e.map((c)=>ns([c],1)),i=ai(n.length),r=n.map((c)=>{let d={};return c.forEach((l)=>{Ks(l.partialPath).forEach((f)=>{d[f]=!0})}),d}),o=n;for(let c=1;c<=s;c++){let d=o;o=ai(d.length);for(let l=0;l<d.length;l++){let p=d[l];for(let f=0;f<p.length;f++){let m=p[f].partialPath,T=p[f].suffixDef,g=Ks(m);if(Na(r,g,l)||T.length===0||m.length===s){let v=i[l];if(rs(v,m)===!1){v.push(m);for(let b=0;b<g.length;b++){let k=g[b];r[l][k]=!0}}}else{let v=ns(T,c+1,m);o[l]=o[l].concat(v),v.forEach((b)=>{Ks(b.partialPath).forEach((O)=>{r[l][O]=!0})})}}}}return i}function Ct(e,s,n,i){let r=new Vs(e,H.ALTERNATION,i);return s.accept(r),di(r.result,n)}function bt(e,s,n,i){let r=new Vs(e,n);s.accept(r);let o=r.result,d=new ui(s,e,n).startWalking(),l=new W({definition:o}),p=new W({definition:d});return di([l,p],i)}function rs(e,s){e:for(let n=0;n<e.length;n++){let i=e[n];if(i.length!==s.length)continue;for(let r=0;r<i.length;r++){let o=s[r],c=i[r];if((o===c||c.categoryMatchesMap[o.tokenTypeIdx]!==void 0)===!1)continue e}return!0}return!1}function pi(e,s){return e.length<s.length&&e.every((n,i)=>{let r=s[i];return n===r||r.categoryMatchesMap[n.tokenTypeIdx]})}function fi(e){return e.every((s)=>s.every((n)=>n.every((i)=>i.categoryMatches.length===0)))}function mi(e){return e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map((n)=>Object.assign({type:ne.CUSTOM_LOOKAHEAD_VALIDATION},n))}function Ei(e,s,n,i){let r=e.flatMap((l)=>Ia(l,n)),o=va(e,s,n),c=e.flatMap((l)=>ba(l,n)),d=e.flatMap((l)=>Ca(l,e,i,n));return r.concat(o,c,d)}function Ia(e,s){let n=new gi;e.accept(n);let i=n.allProductions,r=Object.groupBy(i,ka),o=Object.fromEntries(Object.entries(r).filter(([d,l])=>l.length>1));return Object.values(o).map((d)=>{let l=d[0],p=s.buildDuplicateFoundError(e,d),f=fe(l),m={message:p,type:ne.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:f,occurrence:l.idx},T=Ti(l);if(T)m.parameter=T;return m})}function ka(e){return`${fe(e)}_#_${e.idx}_#_${Ti(e)}`}function Ti(e){if(e instanceof M)return e.terminalType.name;else if(e instanceof G)return e.nonTerminalName;else return""}class gi extends pe{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)}}function Ca(e,s,n,i){let r=[];if(s.reduce((c,d)=>{if(d.name===e.name)return c+1;return c},0)>1){let c=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});r.push({message:c,type:ne.DUPLICATE_RULE_NAME,ruleName:e.name})}return r}function Ai(e,s,n){let i=[],r;if(!s.includes(e))r=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,i.push({message:r,type:ne.INVALID_RULE_OVERRIDE,ruleName:e});return i}function zs(e,s,n,i=[]){let r=[],o=as(s.definition);if(o.length===0)return[];else{let c=e.name;if(o.includes(e))r.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:i}),type:ne.LEFT_RECURSION,ruleName:c});let l=i.concat([e]),f=o.filter((m)=>!l.includes(m)).flatMap((m)=>{let T=[...i];return T.push(m),zs(e,m,n,T)});return r.concat(f)}}function as(e){let s=[];if(e.length===0)return s;let n=e[0];if(n instanceof G)s.push(n.referencedRule);else if(n instanceof W||n instanceof K||n instanceof Z||n instanceof Q||n instanceof q||n instanceof U)s=s.concat(as(n.definition));else if(n instanceof J)s=n.definition.map((o)=>as(o.definition)).flat();else if(n instanceof M);else throw Error("non exhaustive match");let i=We(n),r=e.length>1;if(i&&r){let o=e.slice(1);return s.concat(as(o))}else return s}class os extends pe{constructor(){super(...arguments);this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Si(e,s){let n=new os;return e.accept(n),n.alternations.flatMap((o)=>o.definition.slice(0,-1).flatMap((d,l)=>{if(ri([d],[],xe,1).length===0)return[{message:s.buildEmptyAlternationError({topLevelRule:e,alternation:o,emptyChoiceIdx:l}),type:ne.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:o.idx,alternative:l+1}];else return[]}))}function Ri(e,s,n){let i=new os;e.accept(i);let r=i.alternations;return r=r.filter((c)=>c.ignoreAmbiguities!==!0),r.flatMap((c)=>{let d=c.idx,l=c.maxLookahead||s,p=Ct(d,e,l,c),f=_a(p,c,e,n),m=xa(p,c,e,n);return f.concat(m)})}class yi extends pe{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)}}function ba(e,s){let n=new os;return e.accept(n),n.alternations.flatMap((o)=>{if(o.definition.length>255)return[{message:s.buildTooManyAlternativesError({topLevelRule:e,alternation:o}),type:ne.TOO_MANY_ALTS,ruleName:e.name,occurrence:o.idx}];else return[]})}function Oi(e,s,n){let i=[];return e.forEach((r)=>{let o=new yi;r.accept(o),o.allProductions.forEach((d)=>{let l=is(d),p=d.maxLookahead||s,f=d.idx;if(bt(f,r,l,p)[0].flat().length===0){let g=n.buildEmptyRepetitionError({topLevelRule:r,repetition:d});i.push({message:g,type:ne.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),i}function _a(e,s,n,i){let r=[];return e.reduce((d,l,p)=>{if(s.definition[p].ignoreAmbiguities===!0)return d;return l.forEach((f)=>{let m=[p];if(e.forEach((T,g)=>{if(p!==g&&rs(T,f)&&s.definition[g].ignoreAmbiguities!==!0)m.push(g)}),m.length>1&&!rs(r,f))r.push(f),d.push({alts:m,path:f})}),d},[]).map((d)=>{let l=d.alts.map((f)=>f+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:l,prefixPath:d.path}),type:ne.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:s.idx,alternatives:d.alts}})}function xa(e,s,n,i){let r=e.reduce((c,d,l)=>{let p=d.map((f)=>({idx:l,path:f}));return c.concat(p)},[]);return r.flatMap((c)=>{if(s.definition[c.idx].ignoreAmbiguities===!0)return[];let{idx:l,path:p}=c;return r.filter((T)=>s.definition[T.idx].ignoreAmbiguities!==!0&&T.idx<l&&pi(T.path,p)).map((T)=>{let g=[T.idx+1,l+1],x=s.idx===0?"":s.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:s,ambiguityIndices:g,prefixPath:T.path}),type:ne.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:x,alternatives:g}})})}function va(e,s,n){let i=[],r=s.map((o)=>o.name);return e.forEach((o)=>{let c=o.name;if(r.includes(c)){let d=n.buildNamespaceConflictError(o);i.push({message:d,type:ne.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:c})}}),i}function Li(e){let s=Object.assign({errMsgProvider:ti},e),n={};return e.rules.forEach((i)=>{n[i.name]=i}),si(n,s.errMsgProvider)}function Ni(e){var s;let n=(s=e.errMsgProvider)!==null&&s!==void 0?s:Oe;return Ei(e.rules,e.tokenTypes,n,e.grammarName)}var Ii=["MismatchedTokenException","NoViableAltException","EarlyExitException","NotAllInputParsedException"];Object.freeze(Ii);function $e(e){return Ii.includes(e.name)}class _t extends Error{constructor(e,s){super(e);if(this.token=s,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}}class ot extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="MismatchedTokenException"}}class ls extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="NoViableAltException"}}class cs extends _t{constructor(e,s){super(e,s);this.name="NotAllInputParsedException"}}class hs extends _t{constructor(e,s,n){super(e,s);this.previousToken=n,this.name="EarlyExitException"}}var Hs={},Xs="InRuleRecoveryException";class ki extends Error{constructor(e){super(e);this.name=Xs}}class Ys{initRecoverable(e){if(this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,"recoveryEnabled")?e.recoveryEnabled:he.recoveryEnabled,this.recoveryEnabled)this.attemptInRepetitionRecovery=Ma}getTokenToInsert(e){let s=qe(e,"",-1,-1,-1,-1,-1,-1);return s.isInsertedInRecovery=!0,s}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,s,n,i){let r=this.findReSyncTokenType(),o=this.exportLexerState(),c=[],d=!1,l=this.LA_FAST(1),p=this.LA_FAST(1),f=()=>{let m=this.LA(0),T=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:m,ruleName:this.getCurrRuleFullName()}),g=new ot(T,l,this.LA(0));g.resyncedTokens=c.slice(0,-1),this.SAVE_ERROR(g)};while(!d)if(this.tokenMatcher(p,i)){f();return}else if(n.call(this)){f(),e.apply(this,s);return}else if(this.tokenMatcher(p,r))d=!0;else p=this.SKIP_TOKEN(),this.addToResyncTokens(p,c);this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(e,s,n){if(n===!1)return!1;if(this.tokenMatcher(this.LA_FAST(1),e))return!1;if(this.isBackTracking())return!1;if(this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,s)))return!1;return!0}getNextPossibleTokenTypes(e){let s=e.ruleStack[0],i=this.getGAstProductions()[s];return new Gs(i,e).startWalking()}getFollowsForInRuleRecovery(e,s){let n=this.getCurrentGrammarPath(e,s);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,s){if(this.canRecoverWithSingleTokenInsertion(e,s))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new ki("sad sad panda")}canPerformInRuleRecovery(e,s){return this.canRecoverWithSingleTokenInsertion(e,s)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,s){if(!this.canTokenTypeBeInsertedInRecovery(e))return!1;if(s.length===0)return!1;let n=this.LA_FAST(1);return s.find((r)=>this.tokenMatcher(n,r))!==void 0}canRecoverWithSingleTokenDeletion(e){if(!this.canTokenTypeBeDeletedInRecovery(e))return!1;return this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let s=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(s).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),s=this.LA_FAST(1),n=2;while(!0){let i=e.find((r)=>It(s,r));if(i!==void 0)return i;s=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return Hs;let e=this.currRuleShortName,s=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:s,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,s=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=Array(n);for(let r=0;r<n;r++)if(r===0)i[r]=Hs;else i[r]={ruleName:this.shortRuleNameToFullName(e[r]),idxInCallingRule:s[r],inRule:this.shortRuleNameToFullName(e[r-1])};return i}flattenFollowSet(){return this.buildFullFollowKeyStack().map((s)=>this.getFollowSetFromFollowKey(s)).flat()}getFollowSetFromFollowKey(e){if(e===Hs)return[me];let s=e.ruleName+e.idxInCallingRule+Wt+e.inRule;return this.resyncFollows[s]}addToResyncTokens(e,s){if(!this.tokenMatcher(e,me))s.push(e);return s}reSyncTo(e){let s=[],n=this.LA_FAST(1);while(this.tokenMatcher(n,e)===!1)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,s);return s.slice(0,-1)}attemptInRepetitionRecovery(e,s,n,i,r,o,c){}getCurrentGrammarPath(e,s){let n=this.getHumanReadableRuleStack(),i=this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1);return{ruleStack:n,occurrenceStack:i,lastTok:e,lastTokOccurrence:s}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,s=Array(e);for(let n=0;n<e;n++)s[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return s}}function Ma(e,s,n,i,r,o,c){var d,l,p;let f=i|r,m=(d=(l=this.firstAfterRepMap)[p=this.currRuleShortName])!==null&&d!==void 0?d:l[p]=[],T=m[f];if(T===void 0){let b=this.getCurrRuleFullName(),k=this.getGAstProductions()[b];T=new o(k,r).startWalking(),m[f]=T}let g=T.token,x=T.occurrence,v=T.isEndOfRule;if(this.RULE_STACK_IDX===0&&v&&g===void 0)g=me,x=1;if(g===void 0||x===void 0)return;if(this.shouldInRepetitionRecoveryBeTried(g,x,c))this.tryInRepetitionRecovery(e,s,n,g)}var us=256,ds=512,xt=768,vt=1024,Mt=1280,lt=1536;class ps{constructor(e){var s;this.maxLookahead=(s=e===null||e===void 0?void 0:e.maxLookahead)!==null&&s!==void 0?s:he.maxLookahead}validate(e){let s=this.validateNoLeftRecursion(e.rules);if(s.length===0){let n=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),r=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...s,...n,...i,...r]}return s}validateNoLeftRecursion(e){return e.flatMap((s)=>zs(s,s,Oe))}validateEmptyOrAlternatives(e){return e.flatMap((s)=>Si(s,Oe))}validateAmbiguousAlternationAlternatives(e,s){return e.flatMap((n)=>Ri(n,s,Oe))}validateSomeNonEmptyLookaheadPath(e,s){return Oi(e,s,Oe)}buildLookaheadForAlternation(e){return oi(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,ci)}buildLookaheadForOptional(e){return li(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,is(e.prodType),hi)}}class qs{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:he.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,"maxLookahead")?e.maxLookahead:he.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,"lookaheadStrategy")?e.lookaheadStrategy:new ps({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach((s)=>{this.TRACE_INIT(`${s.name} Rule Lookahead`,()=>{let{alternation:n,repetition:i,option:r,repetitionMandatory:o,repetitionMandatoryWithSeparator:c,repetitionWithSeparator:d}=wa(s);n.forEach((l)=>{let p=l.idx===0?"":l.idx;this.TRACE_INIT(`${fe(l)}${p}`,()=>{let f=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:s,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[s.name],us|l.idx,f)})}),i.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,xt,"Repetition",l.maxLookahead,fe(l))}),r.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,ds,"Option",l.maxLookahead,fe(l))}),o.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,vt,"RepetitionMandatory",l.maxLookahead,fe(l))}),c.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,lt,"RepetitionMandatoryWithSeparator",l.maxLookahead,fe(l))}),d.forEach((l)=>{this.computeLookaheadFunc(s,l.idx,Mt,"RepetitionWithSeparator",l.maxLookahead,fe(l))})})})}computeLookaheadFunc(e,s,n,i,r,o){this.TRACE_INIT(`${o}${s===0?"":s}`,()=>{let c=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:s,rule:e,maxLookahead:r||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|s,c)})}setLaFuncCache(e,s,n){let i=this.lookAheadFuncsCache[e];if(i===void 0)i=[],this.lookAheadFuncsCache[e]=i;i[s]=n}}class Ci extends pe{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)}}var fs=new Ci;function wa(e){fs.reset(),e.accept(fs);let s=fs.dslMethods;return fs.reset(),s}function Js(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.endOffset=s.endOffset;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset}function Zs(e,s){if(e.startOffset===-1)e.startOffset=s.startOffset,e.startColumn=s.startColumn,e.startLine=s.startLine,e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine;else if(e.endOffset<s.endOffset===!0)e.endOffset=s.endOffset,e.endColumn=s.endColumn,e.endLine=s.endLine}function bi(e,s,n){if(e.children[n]===void 0)e.children[n]=[s];else e.children[n].push(s)}function _i(e,s,n){if(e.children[s]===void 0)e.children[s]=[n];else e.children[s].push(n)}function Qs(e,s){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:s})}function Ua(e,s){let n=Object.keys(e),i=n.length;for(let r=0;r<i;r++){let o=n[r],c=e[o],d=c.length;for(let l=0;l<d;l++){let p=c[l];if(p.tokenTypeIdx===void 0)this[p.name](p.children,s)}}}function xi(e,s){let n=function(){};Qs(n,e+"BaseSemantics");let i={visit:function(r,o){if(Array.isArray(r))r=r[0];if(r===void 0)return;return this[r.name](r.children,o)},validateVisitor:function(){let r=Pa(this,s);if(r.length!==0){let o=r.map((c)=>c.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
87
87
  ${o.join(`
88
88
 
89
89
  `).replace(/\n/g,`
@@ -100,20 +100,20 @@ Make sure that all grammar rule definitions are done before 'performSelfAnalysis
100
100
  This error was thrown during the "grammar recording phase" For more info see:
101
101
  https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch(i){throw n}throw n}}optionInternalRecord(e,s){return wt.call(this,K,e,s)}atLeastOneInternalRecord(e,s){wt.call(this,Z,s,e)}atLeastOneSepFirstInternalRecord(e,s){wt.call(this,Q,s,e,Mi)}manyInternalRecord(e,s){wt.call(this,U,s,e)}manySepFirstInternalRecord(e,s){wt.call(this,q,s,e,Mi)}orInternalRecord(e,s){return Ba.call(this,e,s)}subruleInternalRecord(e,s,n){if(ms(s),!e||!Object.hasOwn(e,"ruleName")){let c=Error(`<SUBRULE${Ui(s)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
102
102
  inside top level rule: <${this.recordingProdStack[0].name}>`);throw c.KNOWN_RECORDER_ERROR=!0,c}let i=this.recordingProdStack.at(-1),r=e.ruleName,o=new G({idx:s,nonTerminalName:r,label:n===null||n===void 0?void 0:n.LABEL,referencedRule:void 0});return i.definition.push(o),this.outputCst?Fa:Es}consumeInternalRecord(e,s,n){if(ms(s),!Fs(e)){let o=Error(`<CONSUME${Ui(s)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
103
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let i=this.recordingProdStack.at(-1),r=new v({idx:s,terminalType:e,label:n===null||n===void 0?void 0:n.LABEL});return i.definition.push(r),Di}}function wt(e,s,n,i=!1){ms(n);let r=this.recordingProdStack.at(-1),o=typeof s==="function"?s:s.DEF,c=new e({definition:[],idx:n});if(i)c.separator=s.SEP;if(Object.hasOwn(s,"MAX_LOOKAHEAD"))c.maxLookahead=s.MAX_LOOKAHEAD;return this.recordingProdStack.push(c),o.call(this),r.definition.push(c),this.recordingProdStack.pop(),Es}function Ba(e,s){ms(s);let n=this.recordingProdStack.at(-1),i=Array.isArray(e)===!1,r=i===!1?e:e.DEF,o=new J({definition:[],idx:s,ignoreAmbiguities:i&&e.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(e,"MAX_LOOKAHEAD"))o.maxLookahead=e.MAX_LOOKAHEAD;let c=r.some((d)=>typeof d.GATE==="function");return o.hasPredicates=c,n.definition.push(o),r.forEach((d)=>{let l=new W({definition:[]});if(o.definition.push(l),Object.hasOwn(d,"IGNORE_AMBIGUITIES"))l.ignoreAmbiguities=d.IGNORE_AMBIGUITIES;else if(Object.hasOwn(d,"GATE"))l.ignoreAmbiguities=!0;this.recordingProdStack.push(l),d.ALT.call(this),this.recordingProdStack.pop()}),Es}function Ui(e){return e===0?"":`${e}`}function ms(e){if(e<0||e>wi){let s=Error(`Invalid DSL Method idx value: <${e}>
103
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}let i=this.recordingProdStack.at(-1),r=new M({idx:s,terminalType:e,label:n===null||n===void 0?void 0:n.LABEL});return i.definition.push(r),Di}}function wt(e,s,n,i=!1){ms(n);let r=this.recordingProdStack.at(-1),o=typeof s==="function"?s:s.DEF,c=new e({definition:[],idx:n});if(i)c.separator=s.SEP;if(Object.hasOwn(s,"MAX_LOOKAHEAD"))c.maxLookahead=s.MAX_LOOKAHEAD;return this.recordingProdStack.push(c),o.call(this),r.definition.push(c),this.recordingProdStack.pop(),Es}function Ba(e,s){ms(s);let n=this.recordingProdStack.at(-1),i=Array.isArray(e)===!1,r=i===!1?e:e.DEF,o=new J({definition:[],idx:s,ignoreAmbiguities:i&&e.IGNORE_AMBIGUITIES===!0});if(Object.hasOwn(e,"MAX_LOOKAHEAD"))o.maxLookahead=e.MAX_LOOKAHEAD;let c=r.some((d)=>typeof d.GATE==="function");return o.hasPredicates=c,n.definition.push(o),r.forEach((d)=>{let l=new W({definition:[]});if(o.definition.push(l),Object.hasOwn(d,"IGNORE_AMBIGUITIES"))l.ignoreAmbiguities=d.IGNORE_AMBIGUITIES;else if(Object.hasOwn(d,"GATE"))l.ignoreAmbiguities=!0;this.recordingProdStack.push(l),d.ALT.call(this),this.recordingProdStack.pop()}),Es}function Ui(e){return e===0?"":`${e}`}function ms(e){if(e<0||e>wi){let s=Error(`Invalid DSL Method idx value: <${e}>
104
104
  Idx value must be a none negative value smaller than ${wi+1}`);throw s.KNOWN_RECORDER_ERROR=!0,s}}class cn{initPerformanceTracer(e){if(Object.hasOwn(e,"traceInitPerf")){let s=e.traceInitPerf,n=typeof s==="number";this.traceInitMaxIdent=n?s:1/0,this.traceInitPerf=n?s>0:s}else this.traceInitMaxIdent=0,this.traceInitPerf=he.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,s){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join("\t");if(this.traceInitIndent<this.traceInitMaxIdent)console.log(`${n}--> <${e}>`);let{time:i,value:r}=gt(s),o=i>10?console.warn:console.log;if(this.traceInitIndent<this.traceInitMaxIdent)o(`${n}<-- <${e}> time: ${i}ms`);return this.traceInitIndent--,r}else return s()}}function Fi(e,s){s.forEach((n)=>{let i=n.prototype;Object.getOwnPropertyNames(i).forEach((r)=>{if(r==="constructor")return;let o=Object.getOwnPropertyDescriptor(i,r);if(o&&(o.get||o.set))Object.defineProperty(e.prototype,r,o);else e.prototype[r]=n.prototype[r]})})}var Me=qe(me,"",-1,-1,-1,-1,-1,-1);Object.freeze(Me);var he=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:es,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ct=Object.freeze({recoveryValueFunc:()=>{return},resyncEnabled:!0}),ne;(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"})(ne||(ne={}));class Ut{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let s=this.className;this.TRACE_INIT("toFastProps",()=>{At(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),this.definedRulesNames.forEach((i)=>{let o=this[i].originalGrammarAction,c;this.TRACE_INIT(`${i} Rule`,()=>{c=this.topLevelRuleRecord(i,o)}),this.gastProductionsCache[i]=c})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Li({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(n.length===0&&this.skipValidations===!1){let i=Ni({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:Oe,grammarName:s}),r=mi({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:s});this.definitionErrors=this.definitionErrors.concat(i,r)}}),this.definitionErrors.length===0){if(this.recoveryEnabled)this.TRACE_INIT("computeAllProdsFollows",()=>{let i=kn(Object.values(this.gastProductionsCache));this.resyncFollows=i});this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,r;(r=(i=this.lookaheadStrategy).initialize)===null||r===void 0||r.call(i,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})}if(!Ut.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw e=this.definitionErrors.map((i)=>i.message),Error(`Parser Definition Errors detected:
105
105
  ${e.join(`
106
106
  -------------------------------
107
107
  `)}`)})}constructor(e,s){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(s),n.initLexerAdapter(),n.initLooksAhead(s),n.initRecognizerEngine(e,s),n.initRecoverable(s),n.initTreeBuilder(s),n.initGastRecorder(s),n.initPerformanceTracer(s),Object.hasOwn(s,"ignoredIssues"))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
108
108
  Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
109
109
  See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
110
- For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:he.skipValidations}}Ut.DEFER_DEFINITION_ERRORS_HANDLING=!1;Fi(Ut,[Ys,qs,tn,sn,rn,nn,an,on,cn]);class Ts extends Ut{constructor(e,s=he){let n=Object.assign({},s);n.outputCst=!0;super(e,n)}}var ut=t((e)=>e!==void 0&&e>=0,"isKnownLocation");function Hi(e,s){let n=e.lexer.tokenize(s);if(n.errors.length>0){let r=n.errors[0],o=ut(r.offset)?r.offset:s.length,c=o+(ut(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${o},${c})`)}e.parser.input=n.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)}t(Hi,"runChevrotainParse");var X={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ga="LR",Wa=B.usecase,Tn=t(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ga,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Wa)}),"createModel"),ja=t((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||typeof e.accTitle!=="string"||typeof e.accDescription!=="string"||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),w=Tn(),Ka=t(()=>structuredClone(w.config),"getConfig"),Va=t(()=>w.ast,"getAST"),za=t((e)=>{let s=structuredClone(e);ja(s);let n=I(),i=D();try{R(s.accTitle),L(s.accDescription),w=s}catch(r){throw R(n),L(i),r}},"commit"),Ha=t(()=>{w=Tn(),A()},"clear"),Xa=t(()=>w.actors,"getActors"),Ya=t((e)=>w.actors.get(e),"getActor"),qa=t(()=>w.useCases,"getUseCases"),Ja=t((e)=>w.useCases.get(e),"getUseCase"),Za=t(()=>w.systemBoundaries,"getSystemBoundaries"),Qa=t((e)=>w.systemBoundaries.get(e),"getSystemBoundary"),eo=t(()=>w.relationships,"getRelationships"),to=t(()=>w.notes,"getNotes"),so=t((e)=>w.notes.get(e),"getNote"),no=t(()=>w.jsonNodes,"getJsonNodes"),io=t((e)=>w.jsonNodes.get(e),"getJsonNode"),ro=t(()=>w.classDefs,"getClassDefs"),ao=t((e)=>w.classDefs.get(e),"getClassDef"),Xi=t(()=>w.direction,"getDirection"),Je=t((e)=>{let s=new Map;for(let n of["default",...e]){let i=w.classDefs.get(n);if(!i)continue;for(let r of i.styles){let o=r.trim(),c=o.indexOf(":"),d=(c===-1?o:o.slice(0,c)).trim();if(d)s.set(d,o)}}return[...s.values()]},"getCompiledStyles"),oo=t((e)=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Bi=t((e)=>typeof e==="string"?e:e===null?"null":String(e),"displayJsonScalar"),lo=t((e,s,n=(i)=>i)=>{let i=[],r=t((c,d,l)=>{i.push({key:n(c),accessibleKey:n(d),value:n(l)})},"append"),o=t((c,d,l)=>{if(Array.isArray(c)){if(c.length===0){r(d,d,"[]");return}if(c.every((f)=>f===null||["string","number","boolean"].includes(typeof f))){for(let[f,m]of c.entries())r(f===0?d:"",d,Bi(m));return}for(let[f,m]of c.entries())o(m,`${d}[${f}]`,`${l}/${f}`);return}if(c!==null&&typeof c==="object"){let p=c,f=s[l]??Object.keys(p);if(f.length===0){r(d,d,"{}");return}for(let m of f){let T=d?`${d}.${m}`:m;o(p[m],T,`${l}/${oo(m)}`)}return}r(d,d,Bi(c))},"visit");return o(e,"",""),i},"flattenJsonRows"),co=t((e)=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),ho=t((e)=>{if(e.shape==="ellipse")return e.business?"usecaseBusiness":"usecaseEllipse";return e.shape},"useCaseShape"),uo=t((e)=>{switch(e){case X.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case X.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case X.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case X.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case X.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case X.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case X.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),po=t((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{...uo(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),fo=t((e)=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),Pt=t((...e)=>e.filter((s)=>Boolean(s)).join(" "),"classNames"),mo=t(()=>{let e=u(),s={...w.config,...e.usecase},n=t((l)=>j(l,e),"sanitize"),i=t((l)=>n(w.actors.get(l)?.label??w.useCases.get(l)?.label??w.jsonNodes.get(l)?.id??w.notes.get(l)?.label??l),"endpointLabel"),r=[],o=[],c=0,d=0;for(let l of w.actors.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:co(l),isGroup:!1,padding:10,look:e.look,colorIndex:c++,cssClasses:Pt("default","usecase-actor",`usecase-actor-${l.type}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),actorType:l.type,business:l.business,...l.icon?{icon:l.icon}:{},...l.stereotype?{stereotype:n(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of w.useCases.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:ho(l),isGroup:!1,padding:l.shape==="ellipse"?20:10,look:e.look,colorIndex:c++,cssClasses:Pt("default","usecase-element",`usecase-${l.shape}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),business:l.business,...l.stereotype?{stereotype:n(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of w.notes.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:l.target,noteTargetLabel:n(w.actors.get(l.target)?.label??w.useCases.get(l.target)?.label??w.jsonNodes.get(l.target)?.id??l.target)});for(let l of w.jsonNodes.values())r.push({id:l.id,label:n(l.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:Pt("default","usecase-json-table",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),jsonRows:lo(l.value,l.propertyOrder,n)});for(let l of w.systemBoundaries.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:d++,cssClasses:Pt("default","system-boundary",`system-boundary-${l.type}`,...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),boundaryType:l.type});for(let l of w.relationships){let{label:p,...f}=po(l);o.push({id:l.id,start:l.source,end:l.target,source:l.source,target:l.target,sourceLabel:i(l.source),targetLabel:i(l.target),type:"edge",relationshipType:l.type,internal:!1,...f,...p!==void 0?{label:n(p)}:{},labelpos:"c",classes:Pt("default","relationship",`relationship-${l.type}`,...l.classes,...fo(l)),style:[...l.styles],cssCompiledStyles:Je(l.classes),animate:l.animate,...l.animation?{animation:l.animation}:{},look:e.look,thickness:"normal",minlen:l.minlen,isUserDefinedId:l.explicitId})}for(let l of w.notes.values())o.push({id:`${l.id}-edge`,start:l.id,end:l.target,source:l.id,target:l.target,type:"edge",relationshipType:"note",sourceLabel:i(l.id),targetLabel:i(l.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let l of r){if(l.wrappingWidth??=s.wrappingWidth,!l.isGroup&&!l.shape.startsWith("usecaseActor"))l.minWidth??=s.minNodeWidth;if(l.shape==="usecaseEllipse"||l.shape==="usecaseBusiness")l.spreadPorts=!0}return{nodes:r,edges:o,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:Xi(),nodeSpacing:s.nodeSpacing,rankSpacing:s.rankSpacing,actorFontSize:s.actorFontSize,actorFontFamily:s.actorFontFamily,actorFontWeight:s.actorFontWeight,usecaseFontSize:s.usecaseFontSize,usecaseFontFamily:s.usecaseFontFamily,usecaseFontWeight:s.usecaseFontWeight,diagramPadding:s.diagramPadding,useMaxWidth:s.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ls={getConfig:Ka,createModel:Tn,commit:za,getAST:Va,clear:Ha,setDiagramTitle:P,getDiagramTitle:M,setAccTitle:R,getAccTitle:I,setAccDescription:L,getAccDescription:D,getActors:Xa,getActor:Ya,getUseCases:qa,getUseCase:Ja,getSystemBoundaries:Za,getSystemBoundary:Qa,getRelationships:eo,getNotes:to,getNote:so,getJsonNodes:no,getJsonNode:io,getClassDefs:ro,getClassDef:ao,getDirection:Xi,getData:mo};function Qe(e,s,n){let i=[n];return i.index=s,i.input=e,i}t(Qe,"customMatch");var Eo=t((e,s)=>{if(e[s]!=='"'||e[s+1]!=="`")return null;for(let n=s+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]==='"')return Qe(e,s,e.slice(s,n+2));return null},"matchMarkdownString"),To=t((e,s)=>{if(e[s]!=="%"||e[s+1]!=="%")return null;for(let i=s-1;i>=0;i--){let r=e[i];if(r===`
110
+ For further details.`);this.skipValidations=Object.hasOwn(s,"skipValidations")?s.skipValidations:he.skipValidations}}Ut.DEFER_DEFINITION_ERRORS_HANDLING=!1;Fi(Ut,[Ys,qs,tn,sn,rn,nn,an,on,cn]);class Ts extends Ut{constructor(e,s=he){let n=Object.assign({},s);n.outputCst=!0;super(e,n)}}var ut=t((e)=>e!==void 0&&e>=0,"isKnownLocation");function Hi(e,s){let n=e.lexer.tokenize(s);if(n.errors.length>0){let r=n.errors[0],o=ut(r.offset)?r.offset:s.length,c=o+(ut(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${o},${c})`)}e.parser.input=n.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)}t(Hi,"runChevrotainParse");var X={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},Ga="LR",Wa=B.usecase,Tn=t(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:Ga,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(Wa)}),"createModel"),ja=t((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||typeof e.accTitle!=="string"||typeof e.accDescription!=="string"||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),w=Tn(),Ka=t(()=>structuredClone(w.config),"getConfig"),Va=t(()=>w.ast,"getAST"),za=t((e)=>{let s=structuredClone(e);ja(s);let n=I(),i=D();try{R(s.accTitle),L(s.accDescription),w=s}catch(r){throw R(n),L(i),r}},"commit"),Ha=t(()=>{w=Tn(),A()},"clear"),Xa=t(()=>w.actors,"getActors"),Ya=t((e)=>w.actors.get(e),"getActor"),qa=t(()=>w.useCases,"getUseCases"),Ja=t((e)=>w.useCases.get(e),"getUseCase"),Za=t(()=>w.systemBoundaries,"getSystemBoundaries"),Qa=t((e)=>w.systemBoundaries.get(e),"getSystemBoundary"),eo=t(()=>w.relationships,"getRelationships"),to=t(()=>w.notes,"getNotes"),so=t((e)=>w.notes.get(e),"getNote"),no=t(()=>w.jsonNodes,"getJsonNodes"),io=t((e)=>w.jsonNodes.get(e),"getJsonNode"),ro=t(()=>w.classDefs,"getClassDefs"),ao=t((e)=>w.classDefs.get(e),"getClassDef"),Xi=t(()=>w.direction,"getDirection"),Je=t((e)=>{let s=new Map;for(let n of["default",...e]){let i=w.classDefs.get(n);if(!i)continue;for(let r of i.styles){let o=r.trim(),c=o.indexOf(":"),d=(c===-1?o:o.slice(0,c)).trim();if(d)s.set(d,o)}}return[...s.values()]},"getCompiledStyles"),oo=t((e)=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),Bi=t((e)=>typeof e==="string"?e:e===null?"null":String(e),"displayJsonScalar"),lo=t((e,s,n=(i)=>i)=>{let i=[],r=t((c,d,l)=>{i.push({key:n(c),accessibleKey:n(d),value:n(l)})},"append"),o=t((c,d,l)=>{if(Array.isArray(c)){if(c.length===0){r(d,d,"[]");return}if(c.every((f)=>f===null||["string","number","boolean"].includes(typeof f))){for(let[f,m]of c.entries())r(f===0?d:"",d,Bi(m));return}for(let[f,m]of c.entries())o(m,`${d}[${f}]`,`${l}/${f}`);return}if(c!==null&&typeof c==="object"){let p=c,f=s[l]??Object.keys(p);if(f.length===0){r(d,d,"{}");return}for(let m of f){let T=d?`${d}.${m}`:m;o(p[m],T,`${l}/${oo(m)}`)}return}r(d,d,Bi(c))},"visit");return o(e,"",""),i},"flattenJsonRows"),co=t((e)=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),ho=t((e)=>{if(e.shape==="ellipse")return e.business?"usecaseBusiness":"usecaseEllipse";return e.shape},"useCaseShape"),uo=t((e)=>{switch(e){case X.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case X.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case X.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case X.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case X.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case X.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case X.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),po=t((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{...uo(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),fo=t((e)=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),Pt=t((...e)=>e.filter((s)=>Boolean(s)).join(" "),"classNames"),mo=t(()=>{let e=u(),s={...w.config,...e.usecase},n=t((l)=>j(l,e),"sanitize"),i=t((l)=>n(w.actors.get(l)?.label??w.useCases.get(l)?.label??w.jsonNodes.get(l)?.id??w.notes.get(l)?.label??l),"endpointLabel"),r=[],o=[],c=0,d=0;for(let l of w.actors.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:co(l),isGroup:!1,padding:10,look:e.look,colorIndex:c++,cssClasses:Pt("default","usecase-actor",`usecase-actor-${l.type}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),actorType:l.type,business:l.business,...l.icon?{icon:l.icon}:{},...l.stereotype?{stereotype:n(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of w.useCases.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:ho(l),isGroup:!1,padding:l.shape==="ellipse"?20:10,look:e.look,colorIndex:c++,cssClasses:Pt("default","usecase-element",`usecase-${l.shape}`,l.business&&"usecase-business",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),business:l.business,...l.stereotype?{stereotype:n(l.stereotype)}:{},...l.parentId?{parentId:l.parentId}:{}});for(let l of w.notes.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:Je([]),noteTarget:l.target,noteTargetLabel:n(w.actors.get(l.target)?.label??w.useCases.get(l.target)?.label??w.jsonNodes.get(l.target)?.id??l.target)});for(let l of w.jsonNodes.values())r.push({id:l.id,label:n(l.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:Pt("default","usecase-json-table",...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),jsonRows:lo(l.value,l.propertyOrder,n)});for(let l of w.systemBoundaries.values())r.push({id:l.id,label:n(l.label),labelType:l.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:d++,cssClasses:Pt("default","system-boundary",`system-boundary-${l.type}`,...l.classes),cssStyles:[...l.styles],cssCompiledStyles:Je(l.classes),boundaryType:l.type});for(let l of w.relationships){let{label:p,...f}=po(l);o.push({id:l.id,start:l.source,end:l.target,source:l.source,target:l.target,sourceLabel:i(l.source),targetLabel:i(l.target),type:"edge",relationshipType:l.type,internal:!1,...f,...p!==void 0?{label:n(p)}:{},labelpos:"c",classes:Pt("default","relationship",`relationship-${l.type}`,...l.classes,...fo(l)),style:[...l.styles],cssCompiledStyles:Je(l.classes),animate:l.animate,...l.animation?{animation:l.animation}:{},look:e.look,thickness:"normal",minlen:l.minlen,isUserDefinedId:l.explicitId})}for(let l of w.notes.values())o.push({id:`${l.id}-edge`,start:l.id,end:l.target,source:l.id,target:l.target,type:"edge",relationshipType:"note",sourceLabel:i(l.id),targetLabel:i(l.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:Je([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let l of r){if(l.wrappingWidth??=s.wrappingWidth,!l.isGroup&&!l.shape.startsWith("usecaseActor"))l.minWidth??=s.minNodeWidth;if(l.shape==="usecaseEllipse"||l.shape==="usecaseBusiness")l.spreadPorts=!0}return{nodes:r,edges:o,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:Xi(),nodeSpacing:s.nodeSpacing,rankSpacing:s.rankSpacing,actorFontSize:s.actorFontSize,actorFontFamily:s.actorFontFamily,actorFontWeight:s.actorFontWeight,usecaseFontSize:s.usecaseFontSize,usecaseFontFamily:s.usecaseFontFamily,usecaseFontWeight:s.usecaseFontWeight,diagramPadding:s.diagramPadding,useMaxWidth:s.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),Ls={getConfig:Ka,createModel:Tn,commit:za,getAST:Va,clear:Ha,setDiagramTitle:P,getDiagramTitle:N,setAccTitle:R,getAccTitle:I,setAccDescription:L,getAccDescription:D,getActors:Xa,getActor:Ya,getUseCases:qa,getUseCase:Ja,getSystemBoundaries:Za,getSystemBoundary:Qa,getRelationships:eo,getNotes:to,getNote:so,getJsonNodes:no,getJsonNode:io,getClassDefs:ro,getClassDef:ao,getDirection:Xi,getData:mo};function Qe(e,s,n){let i=[n];return i.index=s,i.input=e,i}t(Qe,"customMatch");var Eo=t((e,s)=>{if(e[s]!=='"'||e[s+1]!=="`")return null;for(let n=s+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]==='"')return Qe(e,s,e.slice(s,n+2));return null},"matchMarkdownString"),To=t((e,s)=>{if(e[s]!=="%"||e[s+1]!=="%")return null;for(let i=s-1;i>=0;i--){let r=e[i];if(r===`
111
111
  `||r==="\r")break;if(r!==" "&&r!=="\t")return null}let n=s+2;while(n<e.length&&e[n]!==`
112
112
  `&&e[n]!=="\r")n++;return Qe(e,s,e.slice(s,n))},"matchComment"),Yi=t((e,s)=>{for(let n=s-1;n>=0;n--){let i=e[n];if(i===`
113
113
  `||i==="\r")return!0;if(i!==" "&&i!=="\t")return!1}return!0},"isIndentedLineStart"),qi=t((e,s,n)=>{if(!Yi(e,s))return null;let i=n.exec(e.slice(s));return i?Qe(e,s,i[0]):null},"matchAccessibilityLine"),go=t((e,s)=>{if(!Yi(e,s))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(s));if(!n)return null;let i=e.indexOf("}",s+n[0].length);return i===-1?null:Qe(e,s,e.slice(s,i+1))},"matchAccDescrBlock"),Ao=t((e,s)=>{if(e[s]!=="{")return null;let n=0,i=!1,r=!1;for(let o=s;o<e.length;o++){let c=e[o];if(i){if(r)r=!1;else if(c==="\\")r=!0;else if(c==='"')i=!1;continue}if(c==='"')i=!0;else if(c==="{")n++;else if(c==="}"&&--n===0)return Qe(e,s,e.slice(s,o+1))}return null},"matchJsonObject"),So=t((e,s)=>{let n=e.indexOf(">>",s);if(n===-1||/[\n\r]/.test(e.slice(s,n)))return null;let i=e.slice(s,n);return i.trim()?Qe(e,s,i):null},"matchStereotypeText"),ie=y({name:"LABEL_TEXT",pattern:z.NA}),dt=y({name:"WORD",pattern:z.NA,categories:ie}),gn=y({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:ie}),Y=y({name:"IDENTIFIER",pattern:/\w+/,longer_alt:gn,categories:dt}),Ro=y({name:"HWS",pattern:/[\t ]+/,group:z.SKIPPED}),Pe=y({name:"MARKDOWN_STRING",pattern:Eo,start_chars_hint:['"'],line_breaks:!0}),yo=y({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),un=y({name:"COMMENT",pattern:To,start_chars_hint:["%"],line_breaks:!1}),we=y({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Ji=y({name:"ACC_DESCR_BLOCK",pattern:go,start_chars_hint:["a"],line_breaks:!0}),Oo=/^accTitle[\t ]*:[^\n\r]*/,Lo=/^accDescr[\t ]*:[^\n\r]*/,Zi=y({name:"ACC_TITLE_LINE",pattern:t((e,s)=>qi(e,s,Oo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Qi=y({name:"ACC_DESCR_LINE",pattern:t((e,s)=>qi(e,s,Lo),"pattern"),start_chars_hint:["a"],line_breaks:!1}),er=y({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),An=y({name:"JSON_OBJECT_LITERAL",pattern:Ao,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),tr=y({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),ee=t((e,s)=>y({name:e,pattern:s,longer_alt:Y,categories:dt}),"keyword"),sr=ee("USECASE",/usecase-beta/),dn=ee("ACTOR",/actor/),nr=ee("SYSTEM_BOUNDARY",/systemBoundary/),ir=ee("END",/end/),rr=ee("DIRECTION",/direction/),ar=ee("TD",/TD/),or=ee("TB",/TB/),lr=ee("BT",/BT/),cr=ee("LR",/LR/),hr=ee("RL",/RL/),ur=ee("NOTE",/note/),dr=ee("FOR",/for/),No=ee("JSON",/json/),pr=ee("CLASS_DEF",/classDef/),fr=ee("CLASS",/class/),mr=ee("STYLE",/style/),Er=ee("INCLUDE",/include/i),Tr=ee("EXTEND",/extend/i),gr=ee("TRUE",/true/),Ar=ee("FALSE",/false/),Sr=y({name:"GENERALIZATION",pattern:/--\|>/}),Rr=y({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),yr=y({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),Sn=y({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),Rn=y({name:"STEREOTYPE_TEXT",pattern:So,line_breaks:!1}),Or=y({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Lr=y({name:"CLASS_SEPARATOR",pattern:/:::/}),gs=y({name:"FORWARD_SOLID",pattern:/--+>/}),Nr=y({name:"BACKWARD_SOLID",pattern:/<--+/}),As=y({name:"FORWARD_CIRCLE",pattern:/--o/}),Ir=y({name:"BACKWARD_CIRCLE",pattern:/o--/}),Ss=y({name:"FORWARD_CROSS",pattern:/--x/}),kr=y({name:"BACKWARD_CROSS",pattern:/x--/}),Re=y({name:"MARKERLESS_SOLID",pattern:/--+/}),pn=y({name:"METADATA_START",pattern:/@{/}),Rs=y({name:"AT",pattern:/@/,categories:ie}),Cr=y({name:"LBRACE",pattern:/{/}),fn=y({name:"RBRACE",pattern:/}/}),ys=y({name:"LBRACKET",pattern:/\[/}),Os=y({name:"RBRACKET",pattern:/]/}),Dt=y({name:"LPAREN",pattern:/\(/}),Ft=y({name:"RPAREN",pattern:/\)/}),Ne=y({name:"COMMA",pattern:/,/,categories:ie}),Bt=y({name:"COLON",pattern:/:/,categories:ie}),br=y({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:ie}),ye=y({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),mn=y({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:ie}),_r=y({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:ie}),xr=y({name:"DASH",pattern:/-/,categories:ie}),vr=y({name:"DOT",pattern:/\./,categories:ie}),Mr=y({name:"PERCENT",pattern:/%/,categories:ie}),wr=y({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:ie}),Io=y({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:ie}),ko=y({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:ie}),Ur=[ie,dt,Ro,Pe,yo,un,we,Ji,Zi,Qi,er,sr,dn,nr,ir,rr,ar,or,lr,cr,hr,ur,dr,No,pr,fr,mr,Er,Tr,gr,Ar,Sr,Rr,yr,Lr,gs,Nr,As,Ir,Ss,kr,Re,pn,Rs,Cr,fn,ys,Os,Dt,Ft,Ne,Bt,br,ye,mn,Y,gn,_r,xr,vr,Mr,wr,Io,ko],Co={defaultMode:"defaultMode",modes:{defaultMode:[...Ur],jsonBody:[An,tr],stereotype:[Sn,Rn,Or]}},bo=[...Ur,An,tr,Sn,Rn,Or],_o=new z(Co),$i=t((e)=>It(e,ie)||e.tokenType===ye||e.tokenType===Pe,"isLabelToken"),xo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},vo=class extends Ts{static{t(this,"UsecaseParser")}constructor(){super(bo,{nodeLocationTracking:"full"});this.RULE("start",()=>{this.CONSUME(sr),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:t(()=>this.isStatementStart(),"GATE"),ALT:t(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:t(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:t(()=>this.isMetadataAssignment(),"GATE"),ALT:t(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:t(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:t(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:t(()=>this.CONSUME(we),"ALT")},{ALT:t(()=>this.CONSUME(me),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(we)}),this.RULE("commentLine",()=>{this.CONSUME(un),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Zi),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:t(()=>this.CONSUME(Qi),"ALT")},{ALT:t(()=>this.CONSUME(Ji),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:t(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(Ne),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:t(()=>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:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.CONSUME(Dt),this.SUBRULE(this.nodeLabel),this.CONSUME(Ft)})},"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(dn),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(Ne),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:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Dt),this.SUBRULE(this.nodeLabel),this.CONSUME(Ft)},"ALT")},{ALT:t(()=>{this.CONSUME(ys),this.SUBRULE2(this.nodeLabel),this.CONSUME(Os)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"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:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:t(()=>this.LA(1).tokenType===Y&&this.LA(2).tokenType===Rs,"GATE"),DEF:t(()=>{this.CONSUME(Y),this.CONSUME(Rs)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:t(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(gs)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Nr),this.OPTION({GATE:t(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([Re]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Re)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(Re),this.OPTION({GATE:t(()=>this.LA(0).image==="--"&&this.hasLabeledRight([gs,Re,As,Ss]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:t(()=>this.CONSUME(gs),"ALT")},{ALT:t(()=>this.CONSUME2(Re),"ALT")},{ALT:t(()=>this.CONSUME(As),"ALT")},{ALT:t(()=>this.CONSUME(Ss),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(As)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(Ir),this.OPTION({GATE:t(()=>this.hasLabeledRight([Re]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Re)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Ss)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(kr),this.OPTION({GATE:t(()=>this.hasLabeledRight([Re]),"GATE"),DEF:t(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Re)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"ALT")},{ALT:t(()=>this.AT_LEAST_ONE(()=>this.CONSUME(ie)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Rr),this.CONSUME(Bt),this.OR2([{ALT:t(()=>this.CONSUME(Er),"ALT")},{ALT:t(()=>this.CONSUME(Tr),"ALT")}])},"ALT")},{ALT:t(()=>this.CONSUME(Sr),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(pn),this.MANY(()=>this.CONSUME(we)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(Ne)),this.MANY3(()=>this.CONSUME2(we))}),this.CONSUME(fn)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")}]),this.CONSUME(Bt),this.OR2([{ALT:t(()=>this.CONSUME2(Y),"ALT")},{ALT:t(()=>this.CONSUME2(ye),"ALT")},{ALT:t(()=>this.CONSUME(gr),"ALT")},{ALT:t(()=>this.CONSUME(Ar),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Ne),this.MANY(()=>this.CONSUME(we))},"ALT")},{ALT:t(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(we)),this.OPTION(()=>this.CONSUME2(Ne)),this.MANY2(()=>this.CONSUME3(we))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(nr),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(ir),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:t(()=>{this.CONSUME(Y),this.OPTION(()=>{this.OR2([{ALT:t(()=>{this.CONSUME(Dt),this.SUBRULE(this.nodeLabel),this.CONSUME(Ft)},"ALT")},{ALT:t(()=>{this.CONSUME(ys),this.SUBRULE2(this.nodeLabel),this.CONSUME(Os)},"ALT")}])})},"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:t(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:t(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:t(()=>{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:t(()=>this.CONSUME(Y),"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(Pe),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(ur),this.CONSUME(dr),this.CONSUME(Y),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(yr),this.CONSUME(Rn),this.CONSUME(Sn)}),this.RULE("classSuffix",()=>{this.CONSUME(Lr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(Ne),this.CONSUME2(Y)})}),this.RULE("jsonStatement",()=>{this.CONSUME(er),this.CONSUME(An),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(rr),this.OR([{ALT:t(()=>this.CONSUME(ar),"ALT")},{ALT:t(()=>this.CONSUME(or),"ALT")},{ALT:t(()=>this.CONSUME(lr),"ALT")},{ALT:t(()=>this.CONSUME(cr),"ALT")},{ALT:t(()=>this.CONSUME(hr),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(pr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(Ne),this.CONSUME2(Y)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(fr),this.CONSUME(Y),this.MANY(()=>{this.CONSUME(Ne),this.CONSUME2(Y)}),this.CONSUME3(Y),this.MANY2(()=>{this.CONSUME2(Ne),this.CONSUME4(Y)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(mr),this.CONSUME(Y),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(Ne),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>{this.CONSUME(Re),this.CONSUME2(dt)},"ALT")}]),this.CONSUME(Bt),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:t(()=>this.CONSUME(dt),"ALT")},{ALT:t(()=>this.CONSUME(ye),"ALT")},{ALT:t(()=>this.CONSUME(gn),"ALT")},{ALT:t(()=>this.CONSUME(br),"ALT")},{ALT:t(()=>this.CONSUME(mn),"ALT")},{ALT:t(()=>this.CONSUME(_r),"ALT")},{ALT:t(()=>this.CONSUME(xr),"ALT")},{ALT:t(()=>this.CONSUME(vr),"ALT")},{ALT:t(()=>this.CONSUME(Mr),"ALT")},{ALT:t(()=>this.CONSUME(wr),"ALT")},{ALT:t(()=>this.CONSUME(Bt),"ALT")},{ALT:t(()=>this.CONSUME(Dt),"ALT")},{ALT:t(()=>this.CONSUME(Ft),"ALT")},{ALT:t(()=>this.CONSUME(ys),"ALT")},{ALT:t(()=>this.CONSUME(Os),"ALT")},{ALT:t(()=>this.CONSUME(Cr),"ALT")},{ALT:t(()=>this.CONSUME(fn),"ALT")},{ALT:t(()=>this.CONSUME(Rs),"ALT")},{ALT:t(()=>this.CONSUME(Re),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===Y||e===ye||e===Pe)&&this.LA(2).tokenType===pn}isStatementStart(){let e=this.LA(1).tokenType;return e!==me&&e!==we&&e!==un}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===Y&&xo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!$i(this.LA(1)))return!1;for(let s=2;;s++){let n=this.LA(s);if(e.includes(n.tokenType))return!0;if(!$i(n))return!1}}},$t=new vo,Gi=class extends Error{constructor(e,s,n){super(`${e} (line ${s}, column ${n})`);this.line=s,this.column=n,this.name="UsecaseJsonError"}static{t(this,"UsecaseJsonError")}},En=t((e,s,n,i)=>{let r=n,o=i,c=Math.min(Math.max(s,0),e.length);for(let d=0;d<c;d++){let l=e[d];if(l==="\r")r++,o=1;else if(l===`
114
114
  `){if(d===0||e[d-1]!=="\r")r++,o=1}else o++}return{line:r,column:o}},"locationAtOffset"),Mo=t((e,s,n,i)=>{let r=/\bposition (\d+)\b/u.exec(e);if(r)return En(s,Number.parseInt(r[1],10),n,i);let o=/\bline (\d+) column (\d+)\b/u.exec(e);if(o){let c=Number.parseInt(o[1],10),d=Number.parseInt(o[2],10);return{line:n+c-1,column:c===1?i+d-1:d}}if(/unexpected end|end of json input/iu.test(e))return En(s,s.length,n,i);return},"locationFromErrorMessage"),ae=class extends Error{constructor(e){super("Invalid JSON token");this.offset=e}static{t(this,"JsonWalkError")}},Wi=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{t(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new ae(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let s=this.text[this.offset];if(s==="{")this.collectObject(e);else if(s==="[")this.collectArray(e);else if(s==='"')this.readString(!1);else if(s==="t")this.consumeLiteral("true");else if(s==="f")this.consumeLiteral("false");else if(s==="n")this.consumeLiteral("null");else if(s==="-"||s>="0"&&s<="9")this.consumeNumber();else throw new ae(this.offset)}collectObject(e){this.offset++;let s=[],n=new Set;if(this.propertyOrder[e]=s,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}while(this.offset<this.text.length){if(this.text[this.offset]!=='"')throw new ae(this.offset);let i=this.readString(!0),r=`${e}/${i.replaceAll("~","~0").replaceAll("/","~1")}`;if(n.has(i))this.deletePointerSubtree(r);else n.add(i),s.push(i);if(this.skipWhitespace(),this.text[this.offset]!==":")throw new ae(this.offset);if(this.offset++,this.collectValue(r),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new ae(this.offset);this.offset++,this.skipWhitespace()}throw new ae(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let s=0;while(this.offset<this.text.length){if(this.collectValue(`${e}/${s}`),s++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new ae(this.offset);this.offset++,this.skipWhitespace()}throw new ae(this.offset)}readString(e){this.offset++;let s="";while(this.offset<this.text.length){let n=this.offset,i=this.text[this.offset++];if(i==='"')return s;if(i.charCodeAt(0)<32)throw new ae(n);if(i!=="\\"){if(e)s+=i;continue}let r=this.offset,o=this.text[this.offset++];switch(o){case'"':case"\\":case"/":if(e)s+=o;break;case"b":if(e)s+="\b";break;case"f":if(e)s+="\f";break;case"n":if(e)s+=`
115
115
  `;break;case"r":if(e)s+="\r";break;case"t":if(e)s+="\t";break;case"u":{let c=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(c))throw new ae(this.offset);if(e)s+=String.fromCharCode(Number.parseInt(c,16));this.offset+=4;break}default:throw new ae(r)}}throw new ae(this.offset)}consumeLiteral(e){let s=0;for(let n of e){if(this.text[this.offset+s]!==n)throw new ae(this.offset+s);s++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++;else throw new ae(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ae(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}if(this.text[this.offset]==="e"||this.text[this.offset]==="E"){if(this.offset++,this.text[this.offset]==="+"||this.text[this.offset]==="-")this.offset++;if(this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new ae(this.offset);while(this.text[this.offset]>="0"&&this.text[this.offset]<="9")this.offset++}}skipWhitespace(){while(this.offset<this.text.length){let e=this.text[this.offset];if(e!==" "&&e!=="\t"&&e!==`
116
- `&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){let s=`${e}/`;for(let n of Object.keys(this.propertyOrder))if(n===e||n.startsWith(s))delete this.propertyOrder[n]}};function Pr(e,s,n){let i;try{i=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),c=Mo(o,e,s,n);if(!c){let d=0;try{new Wi(e).collect()}catch(l){if(l instanceof ae)d=l.offset}c=En(e,d,s,n)}throw new Gi(`Invalid JSON: ${o}`,c.line,c.column)}if(typeof i!=="object"||i===null||Array.isArray(i))throw new Gi("JSON value must have an object root",s,n);return{value:i,propertyOrder:new Wi(e).collect()}}t(Pr,"parseOrderedJsonObject");var wo=t((e)=>({shape:e.type==="normal"?"actor":e.type==="hollow"?"actor-hollow":e.type==="awesome"?"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"),Uo=t((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"),Po=t((e)=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),Do=t((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"),Fo=t((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"),Bo=t((e)=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:X.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),$o=t((e,s,n,i)=>{let r={};for(let l of e.getActors().values())r[l.id]=wo(l);for(let l of e.getUseCases().values())r[l.id]=Uo(l);for(let l of e.getNotes().values())r[l.id]=Po(l);for(let l of e.getJsonNodes().values())r[l.id]=Do(l);let o={};for(let l of e.getSystemBoundaries().values())o[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};let c={};for(let l of e.getClassDefs().values())c[l.id]={styles:[...l.styles]};let d=e.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:d==="TD"?"TB":d,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:r,edges:[...e.getRelationships().map(Fo),...[...e.getNotes().values()].map(Bo)],groups:o,classDefs:c,statements:i}},"buildUsecaseGraphAST"),le=t((e)=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),ji=t((e)=>e===void 0?"":` (label "${e}")`,"labelSuffix"),Ze=t((e)=>e.generated?e.label:void 0,"generatedFrom"),hn=t((e,s)=>{for(let n of s)if(!e.includes(n))e.push(n)},"pushUnique"),Go=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{t(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,s,n,i){this.metadataAssignments.push({target:e,targetLocation:s,metadata:n,statement:i})}addClassDef(e,s){this.classDefinitions.push({ids:e,styles:s})}addClassAssignment(e,s){this.classAssignments.push({targets:e,classes:s})}addStyleAssignment(e,s,n){this.styleAssignments.push({target:e,location:s,styles:n})}setDirection(e){this.directions.push(e==="TD"?"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 s=new Map,n=new Map,i=new Map,r=new Map;for(let l of this.relationshipDrafts)this.recordFirst(r,l.source.id,l.source.location.span[0]),this.recordFirst(r,l.target.id,l.target.location.span[0]);for(let l of this.elements)this.recordFirst(r,l.id,l.location.span[0]);for(let l of this.boundaries)this.recordFirst(r,l.id,l.location.span[0]);for(let l of this.jsonDrafts)this.recordFirst(r,l.id,l.location.span[0]);let o=[...this.elements.map((l)=>({offset:l.location.span[0],type:"element",value:l})),...this.boundaries.map((l)=>({offset:l.location.span[0],type:"boundary",value:l})),...this.jsonDrafts.map((l)=>({offset:l.location.span[0],type:"json",value:l})),...this.relationshipDrafts.filter((l)=>l.explicitId).map((l)=>({offset:l.explicitIdLocation.span[0],type:"edge",value:l}))].sort((l,p)=>l.offset-p.offset);for(let l of o)if(l.type==="element")this.collectElement(l.value,s,n);else if(l.type==="boundary")this.collectBoundary(l.value,s,i);else if(l.type==="json")this.registerUnique(s,l.value.id,"json",l.value.location,!1);else this.registerUnique(s,l.value.explicitId,"edge",l.value.explicitIdLocation,!1);this.materializeElements(n,r),this.materializeBoundaries(i,r),this.materializeJson(r);let c=this.materializeRelationships(s,n,r);this.reorderElements(n,r),this.applyMetadataAssignments(s,n,i,c),this.validateAndRefreshElements(n),this.refreshBoundaries(i,n),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,c),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([l,p])=>[l,p.kind]));let d=$o(this,this.source,e,this.statements);return this.model.ast=d,this.db.commit(this.model),d}collectElement(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!==e.kind)this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(!o){let c={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(c,e.metadata),n.set(e.id,c),s.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`ID '${e.id}' has conflicting labels`,e.location,o.location);if(e.shape&&o.shape&&e.shape!==o.shape)this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,o.location);if(e.parentId&&o.parentId&&e.parentId!==o.parentId)this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,o.parentLocation??o.location);if(e.stereotype&&o.stereotype&&e.stereotype!==o.stereotype)this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,o.stereotypeLocation??o.location);o.shape??=e.shape,o.parentId??=e.parentId,o.parentLocation??=e.parentLocation,o.stereotype??=e.stereotype,o.stereotypeLocation??=e.stereotype?e.location:void 0,hn(o.classes,e.classes),this.applyDeclarationMetadata(o,e.metadata)}collectBoundary(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!=="boundary")this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(o){if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,o.location);hn(o.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),s.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.setElementModel(n)}materializeBoundaries(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let s of[...this.jsonDrafts].sort((n,i)=>(e.get(n.id)??0)-(e.get(i.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(e,s,n){let i=new Map,r=0;for(let o of this.relationshipDrafts){let c=this.resolveEndpoint(o.source,e,s,n),d=this.resolveEndpoint(o.target,e,s,n);this.validateRelationship(o,c,d,e);let l=o.explicitId??`edge-${r++}`,p={id:l,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(p),i.set(l,{draft:o,relationship:p})}return this.model.relationshipCounter=r,i}resolveEndpoint(e,s,n,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${le(e.location)}`);let r=s.get(e.id);if(r)return r.kind;return n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),s.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,s){let n=new Map(this.model.actors),i=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let r of[...e.values()].sort((o,c)=>(s.get(o.id)??0)-(s.get(c.id)??0))){if(!n.has(r.id)&&!i.has(r.id))this.setElementModel(r);let o=n.get(r.id)??this.model.actors.get(r.id),c=i.get(r.id)??this.model.useCases.get(r.id);if(o)this.model.actors.set(r.id,o);else if(c)this.model.useCases.set(r.id,c)}}applyMetadataAssignments(e,s,n,i){for(let r of this.metadataAssignments){let o=e.get(r.target);if(!o){let c=this.inferMetadataKind(r.metadata);throw Error(`Metadata target '${r.target}' is unresolved${c?` (metadata implies ${c})`:""} at ${le(r.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(r.target),r.metadata);else if(o.kind==="boundary"){let c=n.get(r.target);for(let d of r.metadata.properties){if(d.key!=="type"||d.value!=="rect"&&d.value!=="package")this.invalidMetadata(r.target,o.kind,d);c.type=d.value}}else if(o.kind==="edge"){let c=i.get(r.target);if(!c)throw Error(`Metadata target '${r.target}' is not an explicit edge at ${le(r.targetLocation)}`);r.statement.kind="edgeMetadata",r.statement.edges=[{id:r.target,span:r.statement.span,idSpan:r.targetLocation.span,...r.statement.metadata?{metadata:r.statement.metadata}:{}}],delete r.statement.nodes;for(let d of r.metadata.properties)if(d.key==="animate"&&typeof d.value==="boolean")c.relationship.animate=d.value;else if(d.key==="animation"&&(d.value==="fast"||d.value==="slow"))c.relationship.animation=d.value,c.relationship.animate=!0;else this.invalidMetadata(r.target,o.kind,d)}else for(let c of r.metadata.properties)this.invalidMetadata(r.target,o.kind,c)}for(let{relationship:r}of i.values())if(r.animation)r.animate=!0}applyStandaloneElementMetadata(e,s){for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!0);else if(n.key==="business"&&typeof n.value==="boolean")e.business=n.value;else this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,s){if(!s)return;for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!1);else if(n.key==="business"&&typeof n.value==="boolean"){if(e.business!==void 0&&e.business!==n.value)this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location);e.business=n.value}else this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,s,n){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!n&&e.actorType!==void 0&&e.actorType!==s.value)this.conflict(`Actor '${e.id}' has conflicting type metadata`,s.location,e.location);e.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!n&&e.icon!==void 0&&e.icon!==s.value)this.conflict(`Actor '${e.id}' has conflicting icon metadata`,s.location,e.location);e.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!n&&e.business!==void 0&&e.business!==s.value)this.conflict(`Actor '${e.id}' has conflicting business metadata`,s.location,e.location);e.business=s.value}else this.invalidMetadata(e.id,e.kind,s)}validateAndRefreshElements(e){for(let s of e.values()){let n=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${le(s.location)}`);if(s.business&&(n==="icon"||n==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${le(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${le(s.location)}`);this.setElementModel(s)}}refreshBoundaries(e,s){for(let n of e.values())n.members.length=0;for(let n of[...this.elements].sort((i,r)=>i.location.span[0]-r.location.span[0])){if(!n.parentId)continue;let i=e.get(n.parentId);if(!i)throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${le(n.parentLocation??n.location)}`);if(!i.members.includes(n.id))i.members.push(n.id)}for(let n of s.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${le(n.parentLocation??n.location)}`);for(let n of e.values()){let i=this.model.systemBoundaries.get(n.id);i.type=n.type??"rect",i.members=[...n.members],i.classes=[...n.classes],i.styles=[...n.styles]}}materializeNotes(e){let s=0;for(let n of this.noteDrafts){let i=e.get(n.target);if(!i)throw Error(`Note target '${n.target}' is unresolved at ${le(n.targetLocation)}`);if(i.kind!=="actor"&&i.kind!=="usecase")this.conflict(`Note target '${n.target}' must be an actor or use case, not ${i.kind}`,n.targetLocation,i.location);let r=`note-${s++}`;this.model.notes.set(r,{id:r,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let e of this.classDefinitions)for(let s of e.ids)this.model.classDefs.set(s,{id:s,styles:[...e.styles]})}applyClassesAndStyles(e,s){for(let n of this.classAssignments)for(let i of n.targets)hn(this.getStylable(i.id,e,s,i.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,s,n.location).styles.push(...n.styles)}getStylable(e,s,n,i){let r=s.get(e)?.kind,o=r==="actor"?this.model.actors.get(e):r==="usecase"?this.model.useCases.get(e):r==="boundary"?this.model.systemBoundaries.get(e):r==="json"?this.model.jsonNodes.get(e):r==="edge"?n.get(e)?.relationship:void 0;if(!o)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${le(i)}`);return o}validateRelationship(e,s,n,i){let r=t((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!r(s))this.conflict(`Relationship source '${e.source.id}' cannot be ${s}`,e.source.location,i.get(e.source.id).location);if(!r(n))this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,i.get(e.target.id).location);if((e.type==="include"||e.type==="extend")&&(s!=="usecase"||n!=="usecase"))throw Error(`${e.type} relationship requires use-case endpoints at ${le(e.location)}`);if(e.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==n))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${le(e.location)}`);if(e.type==="association"&&(s==="json"||n==="json")&&![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 ${le(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let s=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:s,...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 s=new Set(["actor","usecase","boundary","edge"]);for(let n of e.properties)if(n.key==="icon")s.clear(),s.add("actor");else if(n.key==="animate"||n.key==="animation")s.clear(),s.add("edge");else if(n.key==="type"){if(s.clear(),n.value==="rect"||n.value==="package")s.add("boundary");else if(n.value==="normal"||n.value==="hollow"||n.value==="awesome")s.add("actor")}else if(n.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(e,s,n){throw Error(`Metadata property '${n.key}' is invalid for ${s} '${e}' at ${le(n.location)}`)}registerUnique(e,s,n,i,r){let o=e.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${n})`,i,o.location,void 0,Ze(o));e.set(s,{kind:n,location:i,generated:r})}recordFirst(e,s,n){let i=e.get(s);if(i===void 0||n<i)e.set(s,n)}conflict(e,s,n,i,r){throw Error(`${e} at ${le(s)}${ji(i)}; previous declaration at ${le(n)}${ji(r)}`)}},Wo=$t.getBaseCstVisitorConstructor(),jo=class extends Wo{constructor(){super();this.builder=new Go(Ls),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{t(this,"UsecaseVisitor")}build(e,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(e)}start(e){let s=this.tokens(e,"USECASE")[0],n=[];for(let i of this.nodes(e,"line"))n.push(this.visit(i));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(s))}line(e){let s=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){return}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 s=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let s=this.tokens(e,"ACC_DESCR_LINE")[0],n=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=s?s.image.slice(s.image.indexOf(":")+1).trim():n.image.slice(n.image.indexOf("{")+1,n.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){let s=this.nodes(e,"actorItem"),n=s.map((l)=>this.visit(l)),i=this.nodes(e,"relationTail")[0],r=n.map((l,p)=>this.actorOccurrence(s[p],l,!0));for(let l of n)this.builder.addElement(this.actorDraft(l));if(!i)return{kind:"node",span:[0,0],nodes:r};let o=this.visit(i);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let c=this.relationshipDraft(n[0],o,this.nodeLocation(i));this.builder.addRelationship(c);let d=c.explicitId??`edge-${this.anonymousEdge++}`;return r.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:r,edges:[{id:d,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}actorItem(e){let s=this.visit(this.nodes(e,"actorName")[0]),n=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};return{...s,...n?{metadata:this.visit(n)}:{},...i?{stereotype:this.visit(i)}:{},classes:o.classes,classSpans:o.spans}}actorName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(s){let r=this.nodes(e,"nodeLabel")[0],o=r?this.visit(r):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let s=this.nodes(e,"actorItem"),n=s.map((i)=>this.visit(i));for(let i of n)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:n.map((i,r)=>this.actorOccurrence(s[r],i,!0))}}entityStatement(e){let s=this.nodes(e,"entityName"),n=this.visit(s[0]),i=this.nodes(e,"relationTail")[0];if(!i)return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],n,!0)]};if(n.explicitDeclaration)this.builder.addElement(this.entityDraft(n));let r=this.visit(i);if(r.target.explicitDeclaration)this.builder.addElement(this.entityDraft(r.target));let o={source:this.endpoint(n),target:this.endpoint(r.target),location:this.nodeLocation(i),...r.explicitId?{explicitId:r.explicitId,explicitIdLocation:r.explicitIdLocation}:{},...r.arrow};this.builder.addRelationship(o);let c=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],r.target,r.target.explicitDeclaration)],edges:[{id:c,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],r=this.nodes(e,"useCaseMetadata")[0],o=this.nodes(e,"stereotype")[0],c=this.nodes(e,"classSuffix")[0],d=c?this.visit(c):{classes:[],spans:[]};if(s){let p=i?this.visit(i):this.tokenLabel(s),f=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:p,location:this.tokenLocation(s),generated:!1,...f?{shape:f}:{},...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:d.classes,classSpans:d.spans,explicitDeclaration:Boolean(f||r||o)}}let l=this.tokenLabel(n);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(n),generated:!0,...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:d.classes,classSpans:d.spans,explicitDeclaration:Boolean(r||o)}}nodeLabel(e){let s=this.allTokens(e);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let s=this.tokens(e,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},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:X.SOLID_ARROW,minlen:1};let s=this.tokens(e,"INCLUDE").length?"include":"extend",n=this.tokens(e,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:X.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(e)}}metadataProperty(e){let s=this.allTokens(e).filter((c)=>c.tokenType.name!=="COLON"),n=s[0],i=s[1],r=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),o=[n.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(n),value:r,span:o,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(i),location:this.tokenLocation(n)}}metadataSeparator(e){return}systemBoundaryStatement(e){let s=this.visit(this.nodes(e,"systemBoundaryName")[0]),n=this.nodes(e,"classSuffix")[0],i=n?this.visit(n):{classes:[],spans:[]};s.classes=i.classes,this.builder.addBoundary(s);let r=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(e,"systemBoundaryContent")[0],c=o?this.visit(o):[];this.parentBoundary=r;let d=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],p=l?this.visit(l):void 0,f={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(d),classSpans:i.spans,...p?{metadata:p.properties.map(({key:m,span:T,keySpan:g,valueSpan:_})=>({key:m,span:T,keySpan:g,valueSpan:_}))}:{},...c.length?{children:c}:{}};if(p)this.builder.addMetadataAssignment(s.id,s.location,p,f);return f}systemBoundaryName(e){let s=this.tokens(e,"IDENTIFIER")[0];if(s){let r=this.nodes(e,"nodeLabel")[0];return{id:s.image,label:r?this.visit(r):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((n,i)=>(n.location?.startOffset??0)-(i.location?.startOffset??0)).map((n)=>this.wrap(n,this.visit(n)))}boundaryElement(e){let s=this.nodes(e,"actorDeclarationOnly")[0];if(s)return this.visit(s);let n=this.nodes(e,"entityName")[0],i=this.visit(n);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,i,!0)]}}metadataAssignmentStatement(e){let s=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:n.properties.map(({key:r,span:o,keySpan:c,valueSpan:d})=>({key:r,span:o,keySpan:c,valueSpan:d}))};return this.builder.addMetadataAssignment(s.id,s.location,n,i),i}metadataAssignmentTarget(e){let s=this.allTokens(e)[0],n=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(n.text),location:this.tokenLocation(s)}}noteStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:n,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(e){let s=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(e){let s=this.tokens(e,"IDENTIFIER");return{classes:s.map((n)=>n.image),spans:s.map((n)=>this.tokenSpan(n))}}jsonStatement(e){let s=this.tokens(e,"JSON_DECLARATION_START")[0],n=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(s.image),r=i[1],o=i[0].length-r.length,c={span:[s.startOffset+o,s.startOffset+o+r.length],line:s.startLine??1,column:(s.startColumn??1)+o},d=Pr(n.image,n.startLine??1,n.startColumn??1),l=this.nodes(e,"classSuffix")[0],p=l?this.visit(l):{classes:[],spans:[]},f={id:r,value:d.value,propertyOrder:d.propertyOrder,location:c,classes:p.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:r,span:c.span,idSpan:c.span,defines:!0,classSpans:p.spans}],classSpans:p.spans}}directionStatement(e){let s=this.allTokens(e).find((n)=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(s.map((i)=>i.image),n),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=1;for(;n<s.length;n++)if(!this.source.slice((s[n-1].endOffset??s[n-1].startOffset)+1,s[n].startOffset).includes(","))break;let i=s.slice(0,n).map((o)=>({id:o.image,location:this.tokenLocation(o)})),r=s.slice(n).map((o)=>o.image);return this.builder.addClassAssignment(i,r),{kind:"classAssign",span:[0,0],ref:r[0],refSpan:this.tokenSpan(s[n]),nodes:i.map(({id:o,location:c})=>({id:o,span:c.span,idSpan:c.span}))}}styleStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),n),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(e){return this.nodes(e,"styleValue").map((s)=>this.visit(s))}styleValue(e){let s=this.allTokens(e),n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map((s)=>s.image).join("")}forwardSolidOperator(e){let s=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:X.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(e){let s=this.tokens(e,"BACKWARD_SOLID")[0],n=this.nodes(e,"edgeLabel")[0],i=n?this.tokens(e,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:X.BACK_ARROW,minlen:this.solidMinlen(i),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let s=this.nodes(e,"edgeLabel")[0],n=this.allTokens(e);if(!s)return{type:"association",arrowType:X.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=n.at(-1),r=i.tokenType.name==="FORWARD_SOLID"?X.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?X.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?X.CROSS_ARROW:X.LINE_SOLID;return{type:"association",arrowType:r,label:this.visit(s),minlen:r===X.SOLID_ARROW||r===X.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:X.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:X.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}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,s=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:s,classesOnReference:e.classes.length>0}}relationshipDraft(e,s,n){return{source:this.endpoint(e,!0),target:this.endpoint(s.target),location:n,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(e,s,n){return{id:s.id,span:this.nodeSpan(e),idSpan:s.location.span,labelSpan:s.label.span,...n?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:i,span:r,keySpan:o,valueSpan:c})=>({key:i,span:r,keySpan:o,valueSpan:c}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(e,s,n){return this.actorOccurrence(e,s,n)}wrap(e,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(e);for(let n of s.edges??[])n.span=s.span;return s}tokenLabel(e){let s=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=s==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(e,n);return{text:this.source.slice(i[0],i[1]),type:s,span:i}}decodePlain(e){return e.tokenType.name==="PLAIN_STRING"?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let s=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(e){let s=this.allTokens(e).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let s=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,s),line:e.startLine??1,column:(e.startColumn??1)+s}}nodeSpan(e){let s=this.allTokens(e.children).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);if(!n||!i)throw Error("Usecase CST node has no source token");return[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,s=0){return[e.startOffset+s,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-s)]}nodes(e,s){return(e[s]??[]).filter((n)=>("children"in n))}tokens(e,s){return(e[s]??[]).filter((n)=>("tokenTypeIdx"in n))}firstNode(e,...s){for(let n of s){let i=this.nodes(e,n)[0];if(i)return i}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(e){let s=[];for(let n of Object.values(e))for(let i of n)if("tokenTypeIdx"in i)s.push(i);else s.push(...this.allTokens(i.children));return s.sort((n,i)=>n.startOffset-i.startOffset)}},Ko=new jo,Vo={parse:t(async(e)=>{Ls.clear(),$t.input=[];try{Hi({diagramType:"usecase",lexer:_o,parser:$t,entry:t(()=>$t.start(),"entry"),visit:t((s)=>Ko.build(s,e),"visit")},e)}catch(s){Ls.clear();let n=$t.errors[0];if(n){let{token:i}=n,r=ut(i.startOffset)?i.startOffset:e.length,o=ut(i.endOffset)?i.endOffset+1:r,c=ut(i.startLine)?i.startLine:e.slice(0,r).split(/\r\n|\r|\n/).length,d=Math.max(e.lastIndexOf(`
116
+ `&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){let s=`${e}/`;for(let n of Object.keys(this.propertyOrder))if(n===e||n.startsWith(s))delete this.propertyOrder[n]}};function Pr(e,s,n){let i;try{i=JSON.parse(e)}catch(r){let o=r instanceof Error?r.message:String(r),c=Mo(o,e,s,n);if(!c){let d=0;try{new Wi(e).collect()}catch(l){if(l instanceof ae)d=l.offset}c=En(e,d,s,n)}throw new Gi(`Invalid JSON: ${o}`,c.line,c.column)}if(typeof i!=="object"||i===null||Array.isArray(i))throw new Gi("JSON value must have an object root",s,n);return{value:i,propertyOrder:new Wi(e).collect()}}t(Pr,"parseOrderedJsonObject");var wo=t((e)=>({shape:e.type==="normal"?"actor":e.type==="hollow"?"actor-hollow":e.type==="awesome"?"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"),Uo=t((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"),Po=t((e)=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),Do=t((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"),Fo=t((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"),Bo=t((e)=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:X.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),$o=t((e,s,n,i)=>{let r={};for(let l of e.getActors().values())r[l.id]=wo(l);for(let l of e.getUseCases().values())r[l.id]=Uo(l);for(let l of e.getNotes().values())r[l.id]=Po(l);for(let l of e.getJsonNodes().values())r[l.id]=Do(l);let o={};for(let l of e.getSystemBoundaries().values())o[l.id]={...l.label===l.id?{}:{title:l.label},nodes:[...l.members],...l.classes.length?{classes:[...l.classes]}:{},...l.styles.length?{styles:[...l.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:l.type,labelType:l.labelType}};let c={};for(let l of e.getClassDefs().values())c[l.id]={styles:[...l.styles]};let d=e.getDirection();return{version:1,diagramType:"usecase",source:s,header:{keyword:"usecase",direction:d==="TD"?"TB":d,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:r,edges:[...e.getRelationships().map(Fo),...[...e.getNotes().values()].map(Bo)],groups:o,classDefs:c,statements:i}},"buildUsecaseGraphAST"),le=t((e)=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),ji=t((e)=>e===void 0?"":` (label "${e}")`,"labelSuffix"),Ze=t((e)=>e.generated?e.label:void 0,"generatedFrom"),hn=t((e,s)=>{for(let n of s)if(!e.includes(n))e.push(n)},"pushUnique"),Go=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{t(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,s,n,i){this.metadataAssignments.push({target:e,targetLocation:s,metadata:n,statement:i})}addClassDef(e,s){this.classDefinitions.push({ids:e,styles:s})}addClassAssignment(e,s){this.classAssignments.push({targets:e,classes:s})}addStyleAssignment(e,s,n){this.styleAssignments.push({target:e,location:s,styles:n})}setDirection(e){this.directions.push(e==="TD"?"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 s=new Map,n=new Map,i=new Map,r=new Map;for(let l of this.relationshipDrafts)this.recordFirst(r,l.source.id,l.source.location.span[0]),this.recordFirst(r,l.target.id,l.target.location.span[0]);for(let l of this.elements)this.recordFirst(r,l.id,l.location.span[0]);for(let l of this.boundaries)this.recordFirst(r,l.id,l.location.span[0]);for(let l of this.jsonDrafts)this.recordFirst(r,l.id,l.location.span[0]);let o=[...this.elements.map((l)=>({offset:l.location.span[0],type:"element",value:l})),...this.boundaries.map((l)=>({offset:l.location.span[0],type:"boundary",value:l})),...this.jsonDrafts.map((l)=>({offset:l.location.span[0],type:"json",value:l})),...this.relationshipDrafts.filter((l)=>l.explicitId).map((l)=>({offset:l.explicitIdLocation.span[0],type:"edge",value:l}))].sort((l,p)=>l.offset-p.offset);for(let l of o)if(l.type==="element")this.collectElement(l.value,s,n);else if(l.type==="boundary")this.collectBoundary(l.value,s,i);else if(l.type==="json")this.registerUnique(s,l.value.id,"json",l.value.location,!1);else this.registerUnique(s,l.value.explicitId,"edge",l.value.explicitIdLocation,!1);this.materializeElements(n,r),this.materializeBoundaries(i,r),this.materializeJson(r);let c=this.materializeRelationships(s,n,r);this.reorderElements(n,r),this.applyMetadataAssignments(s,n,i,c),this.validateAndRefreshElements(n),this.refreshBoundaries(i,n),this.materializeNotes(s),this.applyClassDefinitions(),this.applyClassesAndStyles(s,c),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...s].map(([l,p])=>[l,p.kind]));let d=$o(this,this.source,e,this.statements);return this.model.ast=d,this.db.commit(this.model),d}collectElement(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!==e.kind)this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(!o){let c={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(c,e.metadata),n.set(e.id,c),s.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`ID '${e.id}' has conflicting labels`,e.location,o.location);if(e.shape&&o.shape&&e.shape!==o.shape)this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,o.location);if(e.parentId&&o.parentId&&e.parentId!==o.parentId)this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,o.parentLocation??o.location);if(e.stereotype&&o.stereotype&&e.stereotype!==o.stereotype)this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,o.stereotypeLocation??o.location);o.shape??=e.shape,o.parentId??=e.parentId,o.parentLocation??=e.parentLocation,o.stereotype??=e.stereotype,o.stereotypeLocation??=e.stereotype?e.location:void 0,hn(o.classes,e.classes),this.applyDeclarationMetadata(o,e.metadata)}collectBoundary(e,s,n){let i=s.get(e.id),r=Ze({generated:e.generated,label:e.label.text});if(i&&i.kind!=="boundary")this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,r,Ze(i));if(i&&(i.generated||e.generated))this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,r,Ze(i));let o=n.get(e.id);if(o){if(o.label.text!==e.label.text||o.label.type!==e.label.type)this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,o.location);hn(o.classes,e.classes);return}n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),s.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.setElementModel(n)}materializeBoundaries(e,s){for(let n of[...e.values()].sort((i,r)=>(s.get(i.id)??0)-(s.get(r.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??"rect",members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let s of[...this.jsonDrafts].sort((n,i)=>(e.get(n.id)??0)-(e.get(i.id)??0)))this.model.jsonNodes.set(s.id,{id:s.id,value:s.value,propertyOrder:s.propertyOrder,classes:[...s.classes],styles:[]})}materializeRelationships(e,s,n){let i=new Map,r=0;for(let o of this.relationshipDrafts){let c=this.resolveEndpoint(o.source,e,s,n),d=this.resolveEndpoint(o.target,e,s,n);this.validateRelationship(o,c,d,e);let l=o.explicitId??`edge-${r++}`,p={id:l,explicitId:Boolean(o.explicitId),source:o.source.id,target:o.target.id,type:o.type,arrowType:o.arrowType,...o.label?{label:o.label.text,labelType:o.label.type}:{},minlen:o.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(p),i.set(l,{draft:o,relationship:p})}return this.model.relationshipCounter=r,i}resolveEndpoint(e,s,n,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${le(e.location)}`);let r=s.get(e.id);if(r)return r.kind;return n.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),s.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,s){let n=new Map(this.model.actors),i=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let r of[...e.values()].sort((o,c)=>(s.get(o.id)??0)-(s.get(c.id)??0))){if(!n.has(r.id)&&!i.has(r.id))this.setElementModel(r);let o=n.get(r.id)??this.model.actors.get(r.id),c=i.get(r.id)??this.model.useCases.get(r.id);if(o)this.model.actors.set(r.id,o);else if(c)this.model.useCases.set(r.id,c)}}applyMetadataAssignments(e,s,n,i){for(let r of this.metadataAssignments){let o=e.get(r.target);if(!o){let c=this.inferMetadataKind(r.metadata);throw Error(`Metadata target '${r.target}' is unresolved${c?` (metadata implies ${c})`:""} at ${le(r.targetLocation)}`)}if(o.kind==="actor"||o.kind==="usecase")this.applyStandaloneElementMetadata(s.get(r.target),r.metadata);else if(o.kind==="boundary"){let c=n.get(r.target);for(let d of r.metadata.properties){if(d.key!=="type"||d.value!=="rect"&&d.value!=="package")this.invalidMetadata(r.target,o.kind,d);c.type=d.value}}else if(o.kind==="edge"){let c=i.get(r.target);if(!c)throw Error(`Metadata target '${r.target}' is not an explicit edge at ${le(r.targetLocation)}`);r.statement.kind="edgeMetadata",r.statement.edges=[{id:r.target,span:r.statement.span,idSpan:r.targetLocation.span,...r.statement.metadata?{metadata:r.statement.metadata}:{}}],delete r.statement.nodes;for(let d of r.metadata.properties)if(d.key==="animate"&&typeof d.value==="boolean")c.relationship.animate=d.value;else if(d.key==="animation"&&(d.value==="fast"||d.value==="slow"))c.relationship.animation=d.value,c.relationship.animate=!0;else this.invalidMetadata(r.target,o.kind,d)}else for(let c of r.metadata.properties)this.invalidMetadata(r.target,o.kind,c)}for(let{relationship:r}of i.values())if(r.animation)r.animate=!0}applyStandaloneElementMetadata(e,s){for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!0);else if(n.key==="business"&&typeof n.value==="boolean")e.business=n.value;else this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,s){if(!s)return;for(let n of s.properties)if(e.kind==="actor")this.applyActorProperty(e,n,!1);else if(n.key==="business"&&typeof n.value==="boolean"){if(e.business!==void 0&&e.business!==n.value)this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location);e.business=n.value}else this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,s,n){if(s.key==="type"&&(s.value==="normal"||s.value==="hollow"||s.value==="awesome")){if(!n&&e.actorType!==void 0&&e.actorType!==s.value)this.conflict(`Actor '${e.id}' has conflicting type metadata`,s.location,e.location);e.actorType=s.value}else if(s.key==="icon"&&typeof s.value==="string"){if(!n&&e.icon!==void 0&&e.icon!==s.value)this.conflict(`Actor '${e.id}' has conflicting icon metadata`,s.location,e.location);e.icon=s.value}else if(s.key==="business"&&typeof s.value==="boolean"){if(!n&&e.business!==void 0&&e.business!==s.value)this.conflict(`Actor '${e.id}' has conflicting business metadata`,s.location,e.location);e.business=s.value}else this.invalidMetadata(e.id,e.kind,s)}validateAndRefreshElements(e){for(let s of e.values()){let n=s.icon?"icon":s.actorType??"normal";if(s.kind==="actor"){if(s.icon&&s.actorType&&s.actorType!=="normal")throw Error(`Actor '${s.id}' cannot combine icon with type '${s.actorType}' at ${le(s.location)}`);if(s.business&&(n==="icon"||n==="awesome"))throw Error(`Business actor '${s.id}' must use normal or hollow geometry at ${le(s.location)}`)}else if((s.shape??"ellipse")==="rect"&&s.business)throw Error(`Rectangular use case '${s.id}' cannot be a business use case at ${le(s.location)}`);this.setElementModel(s)}}refreshBoundaries(e,s){for(let n of e.values())n.members.length=0;for(let n of[...this.elements].sort((i,r)=>i.location.span[0]-r.location.span[0])){if(!n.parentId)continue;let i=e.get(n.parentId);if(!i)throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${le(n.parentLocation??n.location)}`);if(!i.members.includes(n.id))i.members.push(n.id)}for(let n of s.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${le(n.parentLocation??n.location)}`);for(let n of e.values()){let i=this.model.systemBoundaries.get(n.id);i.type=n.type??"rect",i.members=[...n.members],i.classes=[...n.classes],i.styles=[...n.styles]}}materializeNotes(e){let s=0;for(let n of this.noteDrafts){let i=e.get(n.target);if(!i)throw Error(`Note target '${n.target}' is unresolved at ${le(n.targetLocation)}`);if(i.kind!=="actor"&&i.kind!=="usecase")this.conflict(`Note target '${n.target}' must be an actor or use case, not ${i.kind}`,n.targetLocation,i.location);let r=`note-${s++}`;this.model.notes.set(r,{id:r,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=s}applyClassDefinitions(){for(let e of this.classDefinitions)for(let s of e.ids)this.model.classDefs.set(s,{id:s,styles:[...e.styles]})}applyClassesAndStyles(e,s){for(let n of this.classAssignments)for(let i of n.targets)hn(this.getStylable(i.id,e,s,i.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,s,n.location).styles.push(...n.styles)}getStylable(e,s,n,i){let r=s.get(e)?.kind,o=r==="actor"?this.model.actors.get(e):r==="usecase"?this.model.useCases.get(e):r==="boundary"?this.model.systemBoundaries.get(e):r==="json"?this.model.jsonNodes.get(e):r==="edge"?n.get(e)?.relationship:void 0;if(!o)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${le(i)}`);return o}validateRelationship(e,s,n,i){let r=t((o)=>o==="actor"||o==="usecase"||o==="json","allowed");if(!r(s))this.conflict(`Relationship source '${e.source.id}' cannot be ${s}`,e.source.location,i.get(e.source.id).location);if(!r(n))this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,i.get(e.target.id).location);if((e.type==="include"||e.type==="extend")&&(s!=="usecase"||n!=="usecase"))throw Error(`${e.type} relationship requires use-case endpoints at ${le(e.location)}`);if(e.type==="generalization"&&(s!=="actor"&&s!=="usecase"||s!==n))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${le(e.location)}`);if(e.type==="association"&&(s==="json"||n==="json")&&![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 ${le(e.location)}`)}setElementModel(e){if(e.kind==="actor"){let s=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:s,...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 s=new Set(["actor","usecase","boundary","edge"]);for(let n of e.properties)if(n.key==="icon")s.clear(),s.add("actor");else if(n.key==="animate"||n.key==="animation")s.clear(),s.add("edge");else if(n.key==="type"){if(s.clear(),n.value==="rect"||n.value==="package")s.add("boundary");else if(n.value==="normal"||n.value==="hollow"||n.value==="awesome")s.add("actor")}else if(n.key==="business")s.delete("boundary"),s.delete("edge");else return;return s.size===1?[...s][0]:void 0}invalidMetadata(e,s,n){throw Error(`Metadata property '${n.key}' is invalid for ${s} '${e}' at ${le(n.location)}`)}registerUnique(e,s,n,i,r){let o=e.get(s);if(o)this.conflict(`ID '${s}' is declared more than once (${o.kind} and ${n})`,i,o.location,void 0,Ze(o));e.set(s,{kind:n,location:i,generated:r})}recordFirst(e,s,n){let i=e.get(s);if(i===void 0||n<i)e.set(s,n)}conflict(e,s,n,i,r){throw Error(`${e} at ${le(s)}${ji(i)}; previous declaration at ${le(n)}${ji(r)}`)}},Wo=$t.getBaseCstVisitorConstructor(),jo=class extends Wo{constructor(){super();this.builder=new Go(Ls),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{t(this,"UsecaseVisitor")}build(e,s){this.source=s,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(s),this.visit(e)}start(e){let s=this.tokens(e,"USECASE")[0],n=[];for(let i of this.nodes(e,"line"))n.push(this.visit(i));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(s))}line(e){let s=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(s,this.visit(s))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){return}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 s=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(s.slice(s.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let s=this.tokens(e,"ACC_DESCR_LINE")[0],n=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=s?s.image.slice(s.image.indexOf(":")+1).trim():n.image.slice(n.image.indexOf("{")+1,n.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){let s=this.nodes(e,"actorItem"),n=s.map((l)=>this.visit(l)),i=this.nodes(e,"relationTail")[0],r=n.map((l,p)=>this.actorOccurrence(s[p],l,!0));for(let l of n)this.builder.addElement(this.actorDraft(l));if(!i)return{kind:"node",span:[0,0],nodes:r};let o=this.visit(i);if(o.target.explicitDeclaration)this.builder.addElement(this.entityDraft(o.target));let c=this.relationshipDraft(n[0],o,this.nodeLocation(i));this.builder.addRelationship(c);let d=c.explicitId??`edge-${this.anonymousEdge++}`;return r.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],o.target,o.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:r,edges:[{id:d,span:[0,0],...c.explicitIdLocation?{idSpan:c.explicitIdLocation.span}:{},...c.label?{labelSpan:c.label.span}:{}}]}}actorItem(e){let s=this.visit(this.nodes(e,"actorName")[0]),n=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};return{...s,...n?{metadata:this.visit(n)}:{},...i?{stereotype:this.visit(i)}:{},classes:o.classes,classSpans:o.spans}}actorName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(s){let r=this.nodes(e,"nodeLabel")[0],o=r?this.visit(r):this.tokenLabel(s);return{id:s.image,label:o,location:this.tokenLocation(s),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let s=this.nodes(e,"actorItem"),n=s.map((i)=>this.visit(i));for(let i of n)this.builder.addElement(this.actorDraft(i));return{kind:"node",span:[0,0],nodes:n.map((i,r)=>this.actorOccurrence(s[r],i,!0))}}entityStatement(e){let s=this.nodes(e,"entityName"),n=this.visit(s[0]),i=this.nodes(e,"relationTail")[0];if(!i)return n.explicitDeclaration=!0,n.shape??="ellipse",this.builder.addElement(this.entityDraft(n)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s[0],n,!0)]};if(n.explicitDeclaration)this.builder.addElement(this.entityDraft(n));let r=this.visit(i);if(r.target.explicitDeclaration)this.builder.addElement(this.entityDraft(r.target));let o={source:this.endpoint(n),target:this.endpoint(r.target),location:this.nodeLocation(i),...r.explicitId?{explicitId:r.explicitId,explicitIdLocation:r.explicitIdLocation}:{},...r.arrow};this.builder.addRelationship(o);let c=o.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(s[0],n,n.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],r.target,r.target.explicitDeclaration)],edges:[{id:c,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}entityName(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],r=this.nodes(e,"useCaseMetadata")[0],o=this.nodes(e,"stereotype")[0],c=this.nodes(e,"classSuffix")[0],d=c?this.visit(c):{classes:[],spans:[]};if(s){let p=i?this.visit(i):this.tokenLabel(s),f=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:s.image,label:p,location:this.tokenLocation(s),generated:!1,...f?{shape:f}:{},...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:d.classes,classSpans:d.spans,explicitDeclaration:Boolean(f||r||o)}}let l=this.tokenLabel(n);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(n),generated:!0,...r?{metadata:this.visit(r)}:{},...o?{stereotype:this.visit(o)}:{},classes:d.classes,classSpans:d.spans,explicitDeclaration:Boolean(r||o)}}nodeLabel(e){let s=this.allTokens(e);if(s.length===1&&(s[0].tokenType.name==="PLAIN_STRING"||s[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(s[0]);let n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:"text",span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let s=this.tokens(e,"IDENTIFIER")[0];return{...s?{explicitId:s.image,explicitIdLocation:this.tokenLocation(s)}:{},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:X.SOLID_ARROW,minlen:1};let s=this.tokens(e,"INCLUDE").length?"include":"extend",n=this.tokens(e,s==="include"?"INCLUDE":"EXTEND")[0];return{type:s,arrowType:X.SOLID_ARROW,label:{text:s,type:"text",span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map((s)=>this.visit(s)),location:this.ctxLocation(e)}}metadataProperty(e){let s=this.allTokens(e).filter((c)=>c.tokenType.name!=="COLON"),n=s[0],i=s[1],r=i.tokenType.name==="TRUE"?!0:i.tokenType.name==="FALSE"?!1:this.decodePlain(i),o=[n.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(n),value:r,span:o,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(i),location:this.tokenLocation(n)}}metadataSeparator(e){return}systemBoundaryStatement(e){let s=this.visit(this.nodes(e,"systemBoundaryName")[0]),n=this.nodes(e,"classSuffix")[0],i=n?this.visit(n):{classes:[],spans:[]};s.classes=i.classes,this.builder.addBoundary(s);let r=this.parentBoundary;this.parentBoundary={id:s.id,location:s.location};let o=this.nodes(e,"systemBoundaryContent")[0],c=o?this.visit(o):[];this.parentBoundary=r;let d=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],p=l?this.visit(l):void 0,f={kind:"group",span:[0,0],group:s.id,idSpan:s.location.span,titleSpan:s.label.span,endSpan:this.tokenSpan(d),classSpans:i.spans,...p?{metadata:p.properties.map(({key:m,span:T,keySpan:g,valueSpan:x})=>({key:m,span:T,keySpan:g,valueSpan:x}))}:{},...c.length?{children:c}:{}};if(p)this.builder.addMetadataAssignment(s.id,s.location,p,f);return f}systemBoundaryName(e){let s=this.tokens(e,"IDENTIFIER")[0];if(s){let r=this.nodes(e,"nodeLabel")[0];return{id:s.image,label:r?this.visit(r):this.tokenLabel(s),location:this.tokenLocation(s),generated:!1,classes:[]}}let n=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(n);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((n,i)=>(n.location?.startOffset??0)-(i.location?.startOffset??0)).map((n)=>this.wrap(n,this.visit(n)))}boundaryElement(e){let s=this.nodes(e,"actorDeclarationOnly")[0];if(s)return this.visit(s);let n=this.nodes(e,"entityName")[0],i=this.visit(n);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n,i,!0)]}}metadataAssignmentStatement(e){let s=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),n=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:s.id,span:s.location.span,idSpan:s.location.span}],metadata:n.properties.map(({key:r,span:o,keySpan:c,valueSpan:d})=>({key:r,span:o,keySpan:c,valueSpan:d}))};return this.builder.addMetadataAssignment(s.id,s.location,n,i),i}metadataAssignmentTarget(e){let s=this.allTokens(e)[0],n=this.tokenLabel(s);return{id:s.tokenType.name==="IDENTIFIER"?s.image:this.generateId(n.text),location:this.tokenLocation(s)}}noteStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:s.image,targetLocation:this.tokenLocation(s),label:n,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}stereotype(e){let s=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:s.image.trim(),span:this.tokenSpan(s)}}classSuffix(e){let s=this.tokens(e,"IDENTIFIER");return{classes:s.map((n)=>n.image),spans:s.map((n)=>this.tokenSpan(n))}}jsonStatement(e){let s=this.tokens(e,"JSON_DECLARATION_START")[0],n=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(s.image),r=i[1],o=i[0].length-r.length,c={span:[s.startOffset+o,s.startOffset+o+r.length],line:s.startLine??1,column:(s.startColumn??1)+o},d=Pr(n.image,n.startLine??1,n.startColumn??1),l=this.nodes(e,"classSuffix")[0],p=l?this.visit(l):{classes:[],spans:[]},f={id:r,value:d.value,propertyOrder:d.propertyOrder,location:c,classes:p.classes};return this.builder.addJson(f),{kind:"json",span:[0,0],nodes:[{id:r,span:c.span,idSpan:c.span,defines:!0,classSpans:p.spans}],classSpans:p.spans}}directionStatement(e){let s=this.allTokens(e).find((n)=>["TD","TB","BT","RL","LR"].includes(n.tokenType.name));return this.builder.setDirection(s.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(s.map((i)=>i.image),n),{kind:"classDef",span:[0,0],ref:s[0].image,refSpan:this.tokenSpan(s[0])}}classStatement(e){let s=this.tokens(e,"IDENTIFIER"),n=1;for(;n<s.length;n++)if(!this.source.slice((s[n-1].endOffset??s[n-1].startOffset)+1,s[n].startOffset).includes(","))break;let i=s.slice(0,n).map((o)=>({id:o.image,location:this.tokenLocation(o)})),r=s.slice(n).map((o)=>o.image);return this.builder.addClassAssignment(i,r),{kind:"classAssign",span:[0,0],ref:r[0],refSpan:this.tokenSpan(s[n]),nodes:i.map(({id:o,location:c})=>({id:o,span:c.span,idSpan:c.span}))}}styleStatement(e){let s=this.tokens(e,"IDENTIFIER")[0],n=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(s.image,this.tokenLocation(s),n),{kind:"style",span:[0,0],nodes:[{id:s.image,span:this.tokenSpan(s),idSpan:this.tokenSpan(s)}]}}styles(e){return this.nodes(e,"styleValue").map((s)=>this.visit(s))}styleValue(e){let s=this.allTokens(e),n=[s[0].startOffset,(s.at(-1).endOffset??s.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map((s)=>s.image).join("")}forwardSolidOperator(e){let s=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:X.SOLID_ARROW,minlen:this.solidMinlen(s)}}backwardSolidOperator(e){let s=this.tokens(e,"BACKWARD_SOLID")[0],n=this.nodes(e,"edgeLabel")[0],i=n?this.tokens(e,"MARKERLESS_SOLID").at(-1):s;return{type:"association",arrowType:X.BACK_ARROW,minlen:this.solidMinlen(i),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let s=this.nodes(e,"edgeLabel")[0],n=this.allTokens(e);if(!s)return{type:"association",arrowType:X.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=n.at(-1),r=i.tokenType.name==="FORWARD_SOLID"?X.SOLID_ARROW:i.tokenType.name==="FORWARD_CIRCLE"?X.CIRCLE_ARROW:i.tokenType.name==="FORWARD_CROSS"?X.CROSS_ARROW:X.LINE_SOLID;return{type:"association",arrowType:r,label:this.visit(s),minlen:r===X.SOLID_ARROW||r===X.LINE_SOLID?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:X.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CIRCLE_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:X.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let s=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:X.CROSS_ARROW_REVERSED,minlen:1,...s?{label:this.visit(s)}:{}}}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,s=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:s,classesOnReference:e.classes.length>0}}relationshipDraft(e,s,n){return{source:this.endpoint(e,!0),target:this.endpoint(s.target),location:n,...s.explicitId?{explicitId:s.explicitId,explicitIdLocation:s.explicitIdLocation}:{},...s.arrow}}actorOccurrence(e,s,n){return{id:s.id,span:this.nodeSpan(e),idSpan:s.location.span,labelSpan:s.label.span,...n?{defines:!0}:{},...s.stereotype?{stereotypeSpan:s.stereotype.span}:{},...s.metadata?{metadata:s.metadata.properties.map(({key:i,span:r,keySpan:o,valueSpan:c})=>({key:i,span:r,keySpan:o,valueSpan:c}))}:{},...s.classSpans.length?{classSpans:s.classSpans}:{}}}entityOccurrence(e,s,n){return this.actorOccurrence(e,s,n)}wrap(e,s){if(s.kind==="blank"||s.kind==="comment")return s;s.span=this.nodeSpan(e);for(let n of s.edges??[])n.span=s.span;return s}tokenLabel(e){let s=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",n=s==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,i=this.tokenSpan(e,n);return{text:this.source.slice(i[0],i[1]),type:s,span:i}}decodePlain(e){return e.tokenType.name==="PLAIN_STRING"?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0)}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let s=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:s.startLine??1,column:s.startColumn??1}}ctxLocation(e){let s=this.allTokens(e).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let s=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,s),line:e.startLine??1,column:(e.startColumn??1)+s}}nodeSpan(e){let s=this.allTokens(e.children).filter((r)=>r.tokenType.name!=="NEWLINE"&&r.tokenType.name!=="EOF"),n=s[0],i=s.at(-1);if(!n||!i)throw Error("Usecase CST node has no source token");return[n.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,s=0){return[e.startOffset+s,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-s)]}nodes(e,s){return(e[s]??[]).filter((n)=>("children"in n))}tokens(e,s){return(e[s]??[]).filter((n)=>("tokenTypeIdx"in n))}firstNode(e,...s){for(let n of s){let i=this.nodes(e,n)[0];if(i)return i}throw Error(`Usecase CST is missing one of: ${s.join(", ")}`)}allTokens(e){let s=[];for(let n of Object.values(e))for(let i of n)if("tokenTypeIdx"in i)s.push(i);else s.push(...this.allTokens(i.children));return s.sort((n,i)=>n.startOffset-i.startOffset)}},Ko=new jo,Vo={parse:t(async(e)=>{Ls.clear(),$t.input=[];try{Hi({diagramType:"usecase",lexer:_o,parser:$t,entry:t(()=>$t.start(),"entry"),visit:t((s)=>Ko.build(s,e),"visit")},e)}catch(s){Ls.clear();let n=$t.errors[0];if(n){let{token:i}=n,r=ut(i.startOffset)?i.startOffset:e.length,o=ut(i.endOffset)?i.endOffset+1:r,c=ut(i.startLine)?i.startLine:e.slice(0,r).split(/\r\n|\r|\n/).length,d=Math.max(e.lastIndexOf(`
117
117
  `,r-1),e.lastIndexOf("\r",r-1)),l=ut(i.startColumn)?i.startColumn:r-d,p=s instanceof Error?s.message:String(s);throw Error(`${p} at line ${c}, column ${l} [${r},${o})`)}throw s}},"parse")},zo=["point","circle","cross","extension"],Dr={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Ki=t((e,s)=>{let[n,i]=[e,s].map((r)=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${n}-${i}`},"usecaseDomId"),Ho=t((e)=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),Ns=t((e,s)=>{if(s!=="markdown")return e;return Xo(e).map((n)=>n.map((i)=>i.content).join(" ")).join(`
118
118
  `)},"getAccessibleLabel"),Yo=t((e)=>{let s=Ns(e.label??e.id,e.labelType);if(Dr[e.shape]){let i=e.actorType&&e.actorType!=="normal"?`${e.actorType} `:"",r=e.business?"business ":"",o=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${r}${i}actor ${s}${o}`}if(e.shape==="note")return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${s}`;if(e.shape==="usecaseJsonTable"){let i=(e.jsonRows??[]).map((r)=>`${r.accessibleKey}: ${r.value}`).join("; ");return i?`${s}: ${i}`:s}let n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${s}${n}`},"getUsecaseNodeAccessibleName"),qo=t((e)=>`${e.boundaryType} system boundary ${Ns(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),Jo=t((e)=>{if(e.relationshipType==="note")return"";return`${e.relationshipType==="association"&&e.label?`association ${Ns(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),ht=t((e)=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Vi=t((e)=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),Zo=t((e,s)=>{e.diagramId=s,e.markers=[...zo];for(let n of e.nodes){let i=n;if(i.domId=Ho(n.id),n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);if(n.stereotype)n.stereotype=ht(n.stereotype);if(!n.isGroup&&n.shape==="usecaseJsonTable")n.jsonRows=n.jsonRows?.map((r)=>({...r,key:ht(r.key),value:ht(r.value)}));if(!n.isGroup&&(n.shape==="usecaseEllipse"||n.shape==="rect")&&n.stereotype){let r=n.label??ht(n.id);n.label=`«${Vi(n.stereotype)}»<br/>${n.labelType==="text"?Vi(r):r}`,n.labelType="markdown",i.hasFoldedStereotype=!0,delete n.stereotype}}for(let n of e.edges)if(n.label!==void 0&&n.labelType==="text")n.label=ht(n.label);return e},"prepareUsecaseLayoutData"),Qo=t((e,s,n)=>{for(let r of s.nodes){let o=typeof r.domId==="string"?r.domId:Ki(s.diagramId,r.id),c=e.select(`#${o}`),d=r.isGroup?"boundary":Dr[r.shape]?"actor":r.shape==="note"?"note":r.shape==="usecaseJsonTable"?"json":"usecase",l=n.nodes.get(r.id)??r.id;if(c.attr("data-usecase-id",r.id).attr("data-usecase-kind",d).attr("role","img").attr("aria-label",l),!r.isGroup&&(r.shape==="usecaseEllipse"||r.shape==="rect")&&"hasFoldedStereotype"in r&&r.hasFoldedStereotype===!0){let p=c.node(),f=p?.querySelector(".nodeLabel"),m=f?.querySelector("p")??f,T=m?.firstChild;if(m&&T?.nodeType===3){let g=m.ownerDocument.createElement("span");g.className="usecase-stereotype",m.insertBefore(g,T),g.appendChild(T)}else p?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(s.edges.map((r)=>[r.id,r]));e.selectAll('path[data-et="edge"]').each(function(){let r=i.get(this.getAttribute("data-id")??"");if(!r)return;let o=h(this);if(o.attr("id",Ki(s.diagramId,r.id)).attr("data-usecase-id",r.id).attr("data-usecase-kind",r.internal?"note-connector":"relationship"),r.internal)o.attr("aria-hidden","true");else o.attr("role","img").attr("aria-label",n.edges.get(r.id)??r.id)})},"annotateUsecaseElements"),zi=t((e,s)=>{e.style("--mermaid-usecase-actor-font-size",`${s.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",s.actorFontFamily).style("--mermaid-usecase-actor-font-weight",s.actorFontWeight).style("--mermaid-usecase-font-size",`${s.usecaseFontSize}px`).style("--mermaid-usecase-font-family",s.usecaseFontFamily).style("--mermaid-usecase-font-weight",s.usecaseFontWeight)},"applyUsecaseFonts"),el=t(async(e,s,n,i)=>{a.info("Drawing usecase diagram (unified)",s);let{layout:r}=u(),o=i.db,c=o.getData(),d=new Map(c.nodes.map((m)=>[m.id,Ns(m.label??m.id,m.labelType)])),l={nodes:new Map(c.nodes.map((m)=>[m.id,m.isGroup?qo(m):Yo(m.shape==="note"?{...m,noteTargetLabel:d.get(m.noteTarget??"")}:m)])),edges:new Map(c.edges.map((m)=>[m.id,Jo({...m,sourceLabel:d.get(m.source)??m.sourceLabel,targetLabel:d.get(m.target)??m.targetLabel})]))},p=Fe(s,c.config.securityLevel);c.layoutAlgorithm=Ue(r),Zo(c,s),zi(p,c),await ze(c,p),Qo(p,c,l);let f=c.diagramPadding;F.insertTitle(p,"usecaseDiagramTitleText",0,o.getDiagramTitle?.()??""),Le(p,f,"usecaseDiagram",c.useMaxWidth),zi(p,c)},"draw"),tl={draw:el},sl=t((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"),nl=t((e)=>{let{theme:s,bkgColorArray:n,borderColorArray:i}=e;if(!Te(s,i))return"";let r=S().usecase?.colorScheme==="rotate",o=Ee(e.look),c=o==="handDrawn",d=De(n),l="";for(let p=0;p<ln(i);p++){let f=i[p],m=d?`fill: ${n[p%n.length]};`:"",T=`[data-look="${o}"][data-color-id="color-${p}"]`;if(l+=`
119
119