rookery-agent 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (670) hide show
  1. package/README.md +467 -367
  2. package/docs/migration.md +88 -88
  3. package/docs/updates.md +112 -0
  4. package/package.json +13 -3
  5. package/packages/cli/dist/commands/config.js +2 -2
  6. package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
  7. package/packages/cli/dist/commands/doctor.js +13 -9
  8. package/packages/cli/dist/commands/doctor.js.map +1 -1
  9. package/packages/cli/dist/commands/memory.js +1 -1
  10. package/packages/cli/dist/commands/org.d.ts +2 -2
  11. package/packages/cli/dist/commands/org.d.ts.map +1 -1
  12. package/packages/cli/dist/commands/org.js +19 -17
  13. package/packages/cli/dist/commands/org.js.map +1 -1
  14. package/packages/cli/dist/commands/serve.js +1 -1
  15. package/packages/cli/dist/commands/serve.js.map +1 -1
  16. package/packages/cli/dist/commands/shared.d.ts.map +1 -1
  17. package/packages/cli/dist/commands/shared.js +2 -1
  18. package/packages/cli/dist/commands/shared.js.map +1 -1
  19. package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
  20. package/packages/cli/dist/commands/tasks.js +25 -11
  21. package/packages/cli/dist/commands/tasks.js.map +1 -1
  22. package/packages/cli/dist/commands/tools.js +1 -1
  23. package/packages/cli/dist/commands/tools.js.map +1 -1
  24. package/packages/cli/dist/index.js +13 -13
  25. package/packages/cli/dist/index.js.map +1 -1
  26. package/packages/cli/dist/repl.d.ts +12 -0
  27. package/packages/cli/dist/repl.d.ts.map +1 -1
  28. package/packages/cli/dist/repl.js +170 -16
  29. package/packages/cli/dist/repl.js.map +1 -1
  30. package/packages/cli/dist/tui/App.d.ts +7 -3
  31. package/packages/cli/dist/tui/App.d.ts.map +1 -1
  32. package/packages/cli/dist/tui/App.js +182 -16
  33. package/packages/cli/dist/tui/App.js.map +1 -1
  34. package/packages/cli/dist/tui/commands.d.ts +7 -0
  35. package/packages/cli/dist/tui/commands.d.ts.map +1 -1
  36. package/packages/cli/dist/tui/commands.js +70 -8
  37. package/packages/cli/dist/tui/commands.js.map +1 -1
  38. package/packages/cli/dist/tui/components/AssignmentsView.js +4 -4
  39. package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
  40. package/packages/cli/dist/tui/components/Banner.d.ts +11 -2
  41. package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -1
  42. package/packages/cli/dist/tui/components/Banner.js +7 -10
  43. package/packages/cli/dist/tui/components/Banner.js.map +1 -1
  44. package/packages/cli/dist/tui/components/CodeBlock.js +2 -2
  45. package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -1
  46. package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -1
  47. package/packages/cli/dist/tui/components/InputBox.js +4 -4
  48. package/packages/cli/dist/tui/components/InputBox.js.map +1 -1
  49. package/packages/cli/dist/tui/components/Logo.d.ts +56 -0
  50. package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -0
  51. package/packages/cli/dist/tui/components/Logo.js +50 -0
  52. package/packages/cli/dist/tui/components/Logo.js.map +1 -0
  53. package/packages/cli/dist/tui/components/Markdown.js +8 -8
  54. package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
  55. package/packages/cli/dist/tui/components/Message.d.ts +1 -1
  56. package/packages/cli/dist/tui/components/Message.d.ts.map +1 -1
  57. package/packages/cli/dist/tui/components/Message.js +5 -4
  58. package/packages/cli/dist/tui/components/Message.js.map +1 -1
  59. package/packages/cli/dist/tui/components/QuestionView.d.ts +29 -0
  60. package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -0
  61. package/packages/cli/dist/tui/components/QuestionView.js +53 -0
  62. package/packages/cli/dist/tui/components/QuestionView.js.map +1 -0
  63. package/packages/cli/dist/tui/components/SlashPalette.d.ts +5 -2
  64. package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
  65. package/packages/cli/dist/tui/components/SlashPalette.js +2 -2
  66. package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
  67. package/packages/cli/dist/tui/components/StatusLine.d.ts +0 -2
  68. package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
  69. package/packages/cli/dist/tui/components/StatusLine.js +8 -5
  70. package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
  71. package/packages/cli/dist/tui/components/ToolGroup.js +2 -2
  72. package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
  73. package/packages/cli/dist/tui/components/WatchView.d.ts +21 -0
  74. package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -0
  75. package/packages/cli/dist/tui/components/WatchView.js +36 -0
  76. package/packages/cli/dist/tui/components/WatchView.js.map +1 -0
  77. package/packages/cli/dist/tui/history.d.ts +20 -0
  78. package/packages/cli/dist/tui/history.d.ts.map +1 -0
  79. package/packages/cli/dist/tui/history.js +105 -0
  80. package/packages/cli/dist/tui/history.js.map +1 -0
  81. package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
  82. package/packages/cli/dist/tui/hooks/useSlash.js +3 -2
  83. package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
  84. package/packages/cli/dist/tui/hooks/useTurn.d.ts +58 -1
  85. package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
  86. package/packages/cli/dist/tui/hooks/useTurn.js +214 -36
  87. package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
  88. package/packages/cli/dist/tui/hooks/useWatch.d.ts +52 -0
  89. package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -0
  90. package/packages/cli/dist/tui/hooks/useWatch.js +145 -0
  91. package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -0
  92. package/packages/cli/dist/tui/inkTheme.d.ts +19 -0
  93. package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -0
  94. package/packages/cli/dist/tui/inkTheme.js +81 -0
  95. package/packages/cli/dist/tui/inkTheme.js.map +1 -0
  96. package/packages/cli/dist/tui/theme.d.ts +39 -29
  97. package/packages/cli/dist/tui/theme.d.ts.map +1 -1
  98. package/packages/cli/dist/tui/theme.js +35 -25
  99. package/packages/cli/dist/tui/theme.js.map +1 -1
  100. package/packages/cli/dist/tui/types.d.ts +56 -3
  101. package/packages/cli/dist/tui/types.d.ts.map +1 -1
  102. package/packages/cli/dist/tui/types.js +85 -0
  103. package/packages/cli/dist/tui/types.js.map +1 -1
  104. package/packages/cli/dist/ui/modelNames.d.ts +51 -0
  105. package/packages/cli/dist/ui/modelNames.d.ts.map +1 -0
  106. package/packages/cli/dist/ui/modelNames.js +134 -0
  107. package/packages/cli/dist/ui/modelNames.js.map +1 -0
  108. package/packages/cli/dist/ui/render.d.ts.map +1 -1
  109. package/packages/cli/dist/ui/render.js +17 -8
  110. package/packages/cli/dist/ui/render.js.map +1 -1
  111. package/packages/cli/dist/ui/speech.js +5 -0
  112. package/packages/cli/dist/ui/speech.js.map +1 -1
  113. package/packages/cli/dist/ui/theme.d.ts +33 -9
  114. package/packages/cli/dist/ui/theme.d.ts.map +1 -1
  115. package/packages/cli/dist/ui/theme.js +33 -9
  116. package/packages/cli/dist/ui/theme.js.map +1 -1
  117. package/packages/cli/package.json +1 -1
  118. package/packages/core/dist/agents/persona.d.ts.map +1 -1
  119. package/packages/core/dist/agents/persona.js +5 -2
  120. package/packages/core/dist/agents/persona.js.map +1 -1
  121. package/packages/core/dist/computer/accessibility.d.ts +78 -0
  122. package/packages/core/dist/computer/accessibility.d.ts.map +1 -0
  123. package/packages/core/dist/computer/accessibility.js +270 -0
  124. package/packages/core/dist/computer/accessibility.js.map +1 -0
  125. package/packages/core/dist/computer/assemblies.d.ts +17 -0
  126. package/packages/core/dist/computer/assemblies.d.ts.map +1 -0
  127. package/packages/core/dist/computer/assemblies.js +55 -0
  128. package/packages/core/dist/computer/assemblies.js.map +1 -0
  129. package/packages/core/dist/computer/browser-init.d.ts +9 -0
  130. package/packages/core/dist/computer/browser-init.d.ts.map +1 -0
  131. package/packages/core/dist/computer/browser-init.js +133 -0
  132. package/packages/core/dist/computer/browser-init.js.map +1 -0
  133. package/packages/core/dist/computer/cursor.d.ts +30 -0
  134. package/packages/core/dist/computer/cursor.d.ts.map +1 -0
  135. package/packages/core/dist/computer/cursor.js +30 -0
  136. package/packages/core/dist/computer/cursor.js.map +1 -0
  137. package/packages/core/dist/computer/mcp-server.js +524 -82
  138. package/packages/core/dist/computer/mcp-server.js.map +1 -1
  139. package/packages/core/dist/computer/powershell.d.ts +4 -0
  140. package/packages/core/dist/computer/powershell.d.ts.map +1 -1
  141. package/packages/core/dist/computer/powershell.js +471 -81
  142. package/packages/core/dist/computer/powershell.js.map +1 -1
  143. package/packages/core/dist/computer/screen-text.d.ts +82 -0
  144. package/packages/core/dist/computer/screen-text.d.ts.map +1 -0
  145. package/packages/core/dist/computer/screen-text.js +243 -0
  146. package/packages/core/dist/computer/screen-text.js.map +1 -0
  147. package/packages/core/dist/computer/sketch.d.ts +66 -0
  148. package/packages/core/dist/computer/sketch.d.ts.map +1 -0
  149. package/packages/core/dist/computer/sketch.js +540 -0
  150. package/packages/core/dist/computer/sketch.js.map +1 -0
  151. package/packages/core/dist/computer/tools.d.ts +8 -8
  152. package/packages/core/dist/computer/tools.d.ts.map +1 -1
  153. package/packages/core/dist/computer/tools.js +186 -31
  154. package/packages/core/dist/computer/tools.js.map +1 -1
  155. package/packages/core/dist/computer/validation.d.ts +555 -0
  156. package/packages/core/dist/computer/validation.d.ts.map +1 -0
  157. package/packages/core/dist/computer/validation.js +111 -0
  158. package/packages/core/dist/computer/validation.js.map +1 -0
  159. package/packages/core/dist/computer/windows-cursor.d.ts +14 -0
  160. package/packages/core/dist/computer/windows-cursor.d.ts.map +1 -0
  161. package/packages/core/dist/computer/windows-cursor.js +713 -0
  162. package/packages/core/dist/computer/windows-cursor.js.map +1 -0
  163. package/packages/core/dist/config.d.ts +34 -1
  164. package/packages/core/dist/config.d.ts.map +1 -1
  165. package/packages/core/dist/config.js +362 -11
  166. package/packages/core/dist/config.js.map +1 -1
  167. package/packages/core/dist/cron/scheduler.d.ts +59 -6
  168. package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
  169. package/packages/core/dist/cron/scheduler.js +295 -27
  170. package/packages/core/dist/cron/scheduler.js.map +1 -1
  171. package/packages/core/dist/cron/store.d.ts +19 -1
  172. package/packages/core/dist/cron/store.d.ts.map +1 -1
  173. package/packages/core/dist/cron/store.js +36 -8
  174. package/packages/core/dist/cron/store.js.map +1 -1
  175. package/packages/core/dist/external/claude-code.d.ts +4 -0
  176. package/packages/core/dist/external/claude-code.d.ts.map +1 -0
  177. package/packages/core/dist/external/claude-code.js +111 -0
  178. package/packages/core/dist/external/claude-code.js.map +1 -0
  179. package/packages/core/dist/external/discovery.d.ts +33 -0
  180. package/packages/core/dist/external/discovery.d.ts.map +1 -0
  181. package/packages/core/dist/external/discovery.js +144 -0
  182. package/packages/core/dist/external/discovery.js.map +1 -0
  183. package/packages/core/dist/external/homes.d.ts +26 -0
  184. package/packages/core/dist/external/homes.d.ts.map +1 -0
  185. package/packages/core/dist/external/homes.js +49 -0
  186. package/packages/core/dist/external/homes.js.map +1 -0
  187. package/packages/core/dist/external/shared.d.ts +201 -0
  188. package/packages/core/dist/external/shared.d.ts.map +1 -0
  189. package/packages/core/dist/external/shared.js +308 -0
  190. package/packages/core/dist/external/shared.js.map +1 -0
  191. package/packages/core/dist/gateway/policy.d.ts +117 -2
  192. package/packages/core/dist/gateway/policy.d.ts.map +1 -1
  193. package/packages/core/dist/gateway/policy.js +286 -6
  194. package/packages/core/dist/gateway/policy.js.map +1 -1
  195. package/packages/core/dist/index.d.ts +38 -12
  196. package/packages/core/dist/index.d.ts.map +1 -1
  197. package/packages/core/dist/index.js +66 -12
  198. package/packages/core/dist/index.js.map +1 -1
  199. package/packages/core/dist/memory/db.d.ts +1 -1
  200. package/packages/core/dist/memory/db.d.ts.map +1 -1
  201. package/packages/core/dist/memory/db.js +878 -1
  202. package/packages/core/dist/memory/db.js.map +1 -1
  203. package/packages/core/dist/memory/dream/admission.d.ts +124 -0
  204. package/packages/core/dist/memory/dream/admission.d.ts.map +1 -0
  205. package/packages/core/dist/memory/dream/admission.js +116 -0
  206. package/packages/core/dist/memory/dream/admission.js.map +1 -0
  207. package/packages/core/dist/memory/dream/candidate.d.ts +152 -0
  208. package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -0
  209. package/packages/core/dist/memory/dream/candidate.js +547 -0
  210. package/packages/core/dist/memory/dream/candidate.js.map +1 -0
  211. package/packages/core/dist/memory/dream/evaluate.d.ts +394 -0
  212. package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -0
  213. package/packages/core/dist/memory/dream/evaluate.js +1032 -0
  214. package/packages/core/dist/memory/dream/evaluate.js.map +1 -0
  215. package/packages/core/dist/memory/dream/frame.d.ts +61 -0
  216. package/packages/core/dist/memory/dream/frame.d.ts.map +1 -0
  217. package/packages/core/dist/memory/dream/frame.js +292 -0
  218. package/packages/core/dist/memory/dream/frame.js.map +1 -0
  219. package/packages/core/dist/memory/dream/label.d.ts +370 -0
  220. package/packages/core/dist/memory/dream/label.d.ts.map +1 -0
  221. package/packages/core/dist/memory/dream/label.js +439 -0
  222. package/packages/core/dist/memory/dream/label.js.map +1 -0
  223. package/packages/core/dist/memory/dream/measure.d.ts +114 -0
  224. package/packages/core/dist/memory/dream/measure.d.ts.map +1 -0
  225. package/packages/core/dist/memory/dream/measure.js +205 -0
  226. package/packages/core/dist/memory/dream/measure.js.map +1 -0
  227. package/packages/core/dist/memory/dream/policy.d.ts +21 -0
  228. package/packages/core/dist/memory/dream/policy.d.ts.map +1 -0
  229. package/packages/core/dist/memory/dream/policy.js +157 -0
  230. package/packages/core/dist/memory/dream/policy.js.map +1 -0
  231. package/packages/core/dist/memory/dream/probe.d.ts +202 -0
  232. package/packages/core/dist/memory/dream/probe.d.ts.map +1 -0
  233. package/packages/core/dist/memory/dream/probe.js +671 -0
  234. package/packages/core/dist/memory/dream/probe.js.map +1 -0
  235. package/packages/core/dist/memory/dream/promote.d.ts +312 -0
  236. package/packages/core/dist/memory/dream/promote.d.ts.map +1 -0
  237. package/packages/core/dist/memory/dream/promote.js +528 -0
  238. package/packages/core/dist/memory/dream/promote.js.map +1 -0
  239. package/packages/core/dist/memory/dream/score.d.ts +103 -0
  240. package/packages/core/dist/memory/dream/score.d.ts.map +1 -0
  241. package/packages/core/dist/memory/dream/score.js +334 -0
  242. package/packages/core/dist/memory/dream/score.js.map +1 -0
  243. package/packages/core/dist/memory/dream/slots.d.ts +193 -0
  244. package/packages/core/dist/memory/dream/slots.d.ts.map +1 -0
  245. package/packages/core/dist/memory/dream/slots.js +0 -0
  246. package/packages/core/dist/memory/dream/slots.js.map +1 -0
  247. package/packages/core/dist/memory/dream/trajectory.d.ts +262 -0
  248. package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -0
  249. package/packages/core/dist/memory/dream/trajectory.js +366 -0
  250. package/packages/core/dist/memory/dream/trajectory.js.map +1 -0
  251. package/packages/core/dist/memory/extractor.d.ts +7 -0
  252. package/packages/core/dist/memory/extractor.d.ts.map +1 -1
  253. package/packages/core/dist/memory/extractor.js +35 -12
  254. package/packages/core/dist/memory/extractor.js.map +1 -1
  255. package/packages/core/dist/memory/gate.d.ts +43 -7
  256. package/packages/core/dist/memory/gate.d.ts.map +1 -1
  257. package/packages/core/dist/memory/gate.js +91 -4
  258. package/packages/core/dist/memory/gate.js.map +1 -1
  259. package/packages/core/dist/memory/recall.d.ts +57 -0
  260. package/packages/core/dist/memory/recall.d.ts.map +1 -1
  261. package/packages/core/dist/memory/recall.js +60 -123
  262. package/packages/core/dist/memory/recall.js.map +1 -1
  263. package/packages/core/dist/memory/sleep.d.ts +131 -4
  264. package/packages/core/dist/memory/sleep.d.ts.map +1 -1
  265. package/packages/core/dist/memory/sleep.js +2384 -65
  266. package/packages/core/dist/memory/sleep.js.map +1 -1
  267. package/packages/core/dist/memory/store.d.ts +564 -10
  268. package/packages/core/dist/memory/store.d.ts.map +1 -1
  269. package/packages/core/dist/memory/store.js +1673 -102
  270. package/packages/core/dist/memory/store.js.map +1 -1
  271. package/packages/core/dist/org/controller.d.ts +268 -4
  272. package/packages/core/dist/org/controller.d.ts.map +1 -1
  273. package/packages/core/dist/org/controller.js +2298 -248
  274. package/packages/core/dist/org/controller.js.map +1 -1
  275. package/packages/core/dist/org/ponytail.d.ts +1 -1
  276. package/packages/core/dist/org/ponytail.js +1 -1
  277. package/packages/core/dist/org/project-mcp.d.ts +3 -3
  278. package/packages/core/dist/org/prompts.d.ts +44 -30
  279. package/packages/core/dist/org/prompts.d.ts.map +1 -1
  280. package/packages/core/dist/org/prompts.js +209 -92
  281. package/packages/core/dist/org/prompts.js.map +1 -1
  282. package/packages/core/dist/org/questions.d.ts +104 -0
  283. package/packages/core/dist/org/questions.d.ts.map +1 -0
  284. package/packages/core/dist/org/questions.js +136 -0
  285. package/packages/core/dist/org/questions.js.map +1 -0
  286. package/packages/core/dist/org/review.d.ts +100 -0
  287. package/packages/core/dist/org/review.d.ts.map +1 -0
  288. package/packages/core/dist/org/review.js +256 -0
  289. package/packages/core/dist/org/review.js.map +1 -0
  290. package/packages/core/dist/org/store.d.ts +311 -2
  291. package/packages/core/dist/org/store.d.ts.map +1 -1
  292. package/packages/core/dist/org/store.js +981 -13
  293. package/packages/core/dist/org/store.js.map +1 -1
  294. package/packages/core/dist/org/tools.d.ts +33 -3
  295. package/packages/core/dist/org/tools.d.ts.map +1 -1
  296. package/packages/core/dist/org/tools.js +380 -67
  297. package/packages/core/dist/org/tools.js.map +1 -1
  298. package/packages/core/dist/providers/catalogue.d.ts +1 -1
  299. package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
  300. package/packages/core/dist/providers/catalogue.js +2 -2
  301. package/packages/core/dist/providers/catalogue.js.map +1 -1
  302. package/packages/core/dist/providers/claude-code.d.ts +19 -3
  303. package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
  304. package/packages/core/dist/providers/claude-code.js +501 -40
  305. package/packages/core/dist/providers/claude-code.js.map +1 -1
  306. package/packages/core/dist/providers/claude-tui.d.ts +288 -0
  307. package/packages/core/dist/providers/claude-tui.d.ts.map +1 -0
  308. package/packages/core/dist/providers/claude-tui.js +1118 -0
  309. package/packages/core/dist/providers/claude-tui.js.map +1 -0
  310. package/packages/core/dist/providers/codex-auth.d.ts +15 -0
  311. package/packages/core/dist/providers/codex-auth.d.ts.map +1 -0
  312. package/packages/core/dist/providers/codex-auth.js +127 -0
  313. package/packages/core/dist/providers/codex-auth.js.map +1 -0
  314. package/packages/core/dist/providers/codex-bridge.d.ts +58 -0
  315. package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -0
  316. package/packages/core/dist/providers/codex-bridge.js +375 -0
  317. package/packages/core/dist/providers/codex-bridge.js.map +1 -0
  318. package/packages/core/dist/providers/codex-translate.d.ts +75 -0
  319. package/packages/core/dist/providers/codex-translate.d.ts.map +1 -0
  320. package/packages/core/dist/providers/codex-translate.js +383 -0
  321. package/packages/core/dist/providers/codex-translate.js.map +1 -0
  322. package/packages/core/dist/providers/model-gateway.d.ts +56 -0
  323. package/packages/core/dist/providers/model-gateway.d.ts.map +1 -0
  324. package/packages/core/dist/providers/model-gateway.js +119 -0
  325. package/packages/core/dist/providers/model-gateway.js.map +1 -0
  326. package/packages/core/dist/providers/process.d.ts +3 -1
  327. package/packages/core/dist/providers/process.d.ts.map +1 -1
  328. package/packages/core/dist/providers/process.js +3 -3
  329. package/packages/core/dist/providers/process.js.map +1 -1
  330. package/packages/core/dist/providers/profiles.d.ts +11 -0
  331. package/packages/core/dist/providers/profiles.d.ts.map +1 -0
  332. package/packages/core/dist/providers/profiles.js +28 -0
  333. package/packages/core/dist/providers/profiles.js.map +1 -0
  334. package/packages/core/dist/providers/provider-catalog.d.ts +72 -0
  335. package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -0
  336. package/packages/core/dist/providers/provider-catalog.js +144 -0
  337. package/packages/core/dist/providers/provider-catalog.js.map +1 -0
  338. package/packages/core/dist/providers/quota.d.ts +40 -1
  339. package/packages/core/dist/providers/quota.d.ts.map +1 -1
  340. package/packages/core/dist/providers/quota.js +288 -25
  341. package/packages/core/dist/providers/quota.js.map +1 -1
  342. package/packages/core/dist/providers/registry.d.ts +46 -3
  343. package/packages/core/dist/providers/registry.d.ts.map +1 -1
  344. package/packages/core/dist/providers/registry.js +148 -13
  345. package/packages/core/dist/providers/registry.js.map +1 -1
  346. package/packages/core/dist/providers/router.d.ts +28 -0
  347. package/packages/core/dist/providers/router.d.ts.map +1 -0
  348. package/packages/core/dist/providers/router.js +88 -0
  349. package/packages/core/dist/providers/router.js.map +1 -0
  350. package/packages/core/dist/providers/user-settings-guard.d.ts +12 -0
  351. package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -0
  352. package/packages/core/dist/providers/user-settings-guard.js +130 -0
  353. package/packages/core/dist/providers/user-settings-guard.js.map +1 -0
  354. package/packages/core/dist/runtime.d.ts +193 -7
  355. package/packages/core/dist/runtime.d.ts.map +1 -1
  356. package/packages/core/dist/runtime.js +1676 -219
  357. package/packages/core/dist/runtime.js.map +1 -1
  358. package/packages/core/dist/skills/builtin.d.ts +34 -0
  359. package/packages/core/dist/skills/builtin.d.ts.map +1 -0
  360. package/packages/core/dist/skills/builtin.js +305 -0
  361. package/packages/core/dist/skills/builtin.js.map +1 -0
  362. package/packages/core/dist/skills/shelf.d.ts +30 -0
  363. package/packages/core/dist/skills/shelf.d.ts.map +1 -0
  364. package/packages/core/dist/skills/shelf.js +159 -0
  365. package/packages/core/dist/skills/shelf.js.map +1 -0
  366. package/packages/core/dist/skills/store.d.ts +66 -4
  367. package/packages/core/dist/skills/store.d.ts.map +1 -1
  368. package/packages/core/dist/skills/store.js +105 -18
  369. package/packages/core/dist/skills/store.js.map +1 -1
  370. package/packages/core/dist/skills/suggest.d.ts +21 -0
  371. package/packages/core/dist/skills/suggest.d.ts.map +1 -0
  372. package/packages/core/dist/skills/suggest.js +150 -0
  373. package/packages/core/dist/skills/suggest.js.map +1 -0
  374. package/packages/core/dist/tools/catalog.d.ts +1 -3
  375. package/packages/core/dist/tools/catalog.d.ts.map +1 -1
  376. package/packages/core/dist/tools/catalog.js +38 -26
  377. package/packages/core/dist/tools/catalog.js.map +1 -1
  378. package/packages/core/dist/tools/hub.d.ts +136 -10
  379. package/packages/core/dist/tools/hub.d.ts.map +1 -1
  380. package/packages/core/dist/tools/hub.js +418 -24
  381. package/packages/core/dist/tools/hub.js.map +1 -1
  382. package/packages/core/dist/turns/journal.d.ts +78 -0
  383. package/packages/core/dist/turns/journal.d.ts.map +1 -0
  384. package/packages/core/dist/turns/journal.js +104 -0
  385. package/packages/core/dist/turns/journal.js.map +1 -0
  386. package/packages/core/dist/types.d.ts +1776 -12
  387. package/packages/core/dist/types.d.ts.map +1 -1
  388. package/packages/core/dist/types.js.map +1 -1
  389. package/packages/core/dist/util/blocks.d.ts +41 -0
  390. package/packages/core/dist/util/blocks.d.ts.map +1 -0
  391. package/packages/core/dist/util/blocks.js +175 -0
  392. package/packages/core/dist/util/blocks.js.map +1 -0
  393. package/packages/core/dist/util/queue.d.ts +12 -0
  394. package/packages/core/dist/util/queue.d.ts.map +1 -1
  395. package/packages/core/dist/util/queue.js +16 -0
  396. package/packages/core/dist/util/queue.js.map +1 -1
  397. package/packages/core/dist/util/time.d.ts +39 -0
  398. package/packages/core/dist/util/time.d.ts.map +1 -0
  399. package/packages/core/dist/util/time.js +71 -0
  400. package/packages/core/dist/util/time.js.map +1 -0
  401. package/packages/core/package.json +1 -1
  402. package/packages/server/dist/auth.d.ts +14 -1
  403. package/packages/server/dist/auth.d.ts.map +1 -1
  404. package/packages/server/dist/auth.js +19 -0
  405. package/packages/server/dist/auth.js.map +1 -1
  406. package/packages/server/dist/context.d.ts +35 -1
  407. package/packages/server/dist/context.d.ts.map +1 -1
  408. package/packages/server/dist/context.js +39 -10
  409. package/packages/server/dist/context.js.map +1 -1
  410. package/packages/server/dist/gateways/attachments.d.ts +32 -0
  411. package/packages/server/dist/gateways/attachments.d.ts.map +1 -0
  412. package/packages/server/dist/gateways/attachments.js +167 -0
  413. package/packages/server/dist/gateways/attachments.js.map +1 -0
  414. package/packages/server/dist/gateways/markdown.d.ts +9 -0
  415. package/packages/server/dist/gateways/markdown.d.ts.map +1 -0
  416. package/packages/server/dist/gateways/markdown.js +170 -0
  417. package/packages/server/dist/gateways/markdown.js.map +1 -0
  418. package/packages/server/dist/gateways/push.d.ts +1 -1
  419. package/packages/server/dist/gateways/push.d.ts.map +1 -1
  420. package/packages/server/dist/gateways/push.js +420 -13
  421. package/packages/server/dist/gateways/push.js.map +1 -1
  422. package/packages/server/dist/gateways/telegram-api.d.ts +70 -1
  423. package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
  424. package/packages/server/dist/gateways/telegram-api.js +140 -1
  425. package/packages/server/dist/gateways/telegram-api.js.map +1 -1
  426. package/packages/server/dist/gateways/telegram.d.ts +181 -1
  427. package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
  428. package/packages/server/dist/gateways/telegram.js +1572 -78
  429. package/packages/server/dist/gateways/telegram.js.map +1 -1
  430. package/packages/server/dist/gateways/threads.d.ts +84 -0
  431. package/packages/server/dist/gateways/threads.d.ts.map +1 -0
  432. package/packages/server/dist/gateways/threads.js +289 -0
  433. package/packages/server/dist/gateways/threads.js.map +1 -0
  434. package/packages/server/dist/index.d.ts +2 -1
  435. package/packages/server/dist/index.d.ts.map +1 -1
  436. package/packages/server/dist/index.js +2 -1
  437. package/packages/server/dist/index.js.map +1 -1
  438. package/packages/server/dist/listeners/imap.d.ts +13 -0
  439. package/packages/server/dist/listeners/imap.d.ts.map +1 -0
  440. package/packages/server/dist/listeners/imap.js +0 -0
  441. package/packages/server/dist/listeners/imap.js.map +1 -0
  442. package/packages/server/dist/listeners/registry.d.ts +18 -0
  443. package/packages/server/dist/listeners/registry.d.ts.map +1 -0
  444. package/packages/server/dist/listeners/registry.js +88 -0
  445. package/packages/server/dist/listeners/registry.js.map +1 -0
  446. package/packages/server/dist/listeners/types.d.ts +55 -0
  447. package/packages/server/dist/listeners/types.d.ts.map +1 -0
  448. package/packages/server/dist/listeners/types.js +2 -0
  449. package/packages/server/dist/listeners/types.js.map +1 -0
  450. package/packages/server/dist/main.js +15 -1
  451. package/packages/server/dist/main.js.map +1 -1
  452. package/packages/server/dist/routes/chat.d.ts +7 -3
  453. package/packages/server/dist/routes/chat.d.ts.map +1 -1
  454. package/packages/server/dist/routes/chat.js +8 -17
  455. package/packages/server/dist/routes/chat.js.map +1 -1
  456. package/packages/server/dist/routes/config.d.ts.map +1 -1
  457. package/packages/server/dist/routes/config.js +66 -7
  458. package/packages/server/dist/routes/config.js.map +1 -1
  459. package/packages/server/dist/routes/cron.d.ts.map +1 -1
  460. package/packages/server/dist/routes/cron.js +65 -8
  461. package/packages/server/dist/routes/cron.js.map +1 -1
  462. package/packages/server/dist/routes/dream.d.ts +22 -0
  463. package/packages/server/dist/routes/dream.d.ts.map +1 -0
  464. package/packages/server/dist/routes/dream.js +152 -0
  465. package/packages/server/dist/routes/dream.js.map +1 -0
  466. package/packages/server/dist/routes/hooks.d.ts +18 -0
  467. package/packages/server/dist/routes/hooks.d.ts.map +1 -0
  468. package/packages/server/dist/routes/hooks.js +62 -0
  469. package/packages/server/dist/routes/hooks.js.map +1 -0
  470. package/packages/server/dist/routes/listeners.d.ts +10 -0
  471. package/packages/server/dist/routes/listeners.d.ts.map +1 -0
  472. package/packages/server/dist/routes/listeners.js +12 -0
  473. package/packages/server/dist/routes/listeners.js.map +1 -0
  474. package/packages/server/dist/routes/memories.d.ts.map +1 -1
  475. package/packages/server/dist/routes/memories.js +55 -3
  476. package/packages/server/dist/routes/memories.js.map +1 -1
  477. package/packages/server/dist/routes/org.d.ts.map +1 -1
  478. package/packages/server/dist/routes/org.js +289 -49
  479. package/packages/server/dist/routes/org.js.map +1 -1
  480. package/packages/server/dist/routes/profile.d.ts.map +1 -1
  481. package/packages/server/dist/routes/profile.js +6 -3
  482. package/packages/server/dist/routes/profile.js.map +1 -1
  483. package/packages/server/dist/routes/providers.d.ts.map +1 -1
  484. package/packages/server/dist/routes/providers.js +66 -7
  485. package/packages/server/dist/routes/providers.js.map +1 -1
  486. package/packages/server/dist/routes/questions.d.ts +45 -0
  487. package/packages/server/dist/routes/questions.d.ts.map +1 -0
  488. package/packages/server/dist/routes/questions.js +73 -0
  489. package/packages/server/dist/routes/questions.js.map +1 -0
  490. package/packages/server/dist/routes/sessions.d.ts.map +1 -1
  491. package/packages/server/dist/routes/sessions.js +26 -6
  492. package/packages/server/dist/routes/sessions.js.map +1 -1
  493. package/packages/server/dist/routes/sleep.d.ts.map +1 -1
  494. package/packages/server/dist/routes/sleep.js +71 -2
  495. package/packages/server/dist/routes/sleep.js.map +1 -1
  496. package/packages/server/dist/routes/terminals.d.ts +25 -0
  497. package/packages/server/dist/routes/terminals.d.ts.map +1 -0
  498. package/packages/server/dist/routes/terminals.js +35 -0
  499. package/packages/server/dist/routes/terminals.js.map +1 -0
  500. package/packages/server/dist/routes/tools.d.ts.map +1 -1
  501. package/packages/server/dist/routes/tools.js +140 -6
  502. package/packages/server/dist/routes/tools.js.map +1 -1
  503. package/packages/server/dist/routes/updates.d.ts +10 -0
  504. package/packages/server/dist/routes/updates.d.ts.map +1 -0
  505. package/packages/server/dist/routes/updates.js +22 -0
  506. package/packages/server/dist/routes/updates.js.map +1 -0
  507. package/packages/server/dist/routes/ws.d.ts +11 -5
  508. package/packages/server/dist/routes/ws.d.ts.map +1 -1
  509. package/packages/server/dist/routes/ws.js +168 -28
  510. package/packages/server/dist/routes/ws.js.map +1 -1
  511. package/packages/server/dist/schemas.d.ts +1177 -215
  512. package/packages/server/dist/schemas.d.ts.map +1 -1
  513. package/packages/server/dist/schemas.js +317 -12
  514. package/packages/server/dist/schemas.js.map +1 -1
  515. package/packages/server/dist/server.d.ts +7 -1
  516. package/packages/server/dist/server.d.ts.map +1 -1
  517. package/packages/server/dist/server.js +210 -3
  518. package/packages/server/dist/server.js.map +1 -1
  519. package/packages/server/dist/services/stream.d.ts +94 -5
  520. package/packages/server/dist/services/stream.d.ts.map +1 -1
  521. package/packages/server/dist/services/stream.js +9 -20
  522. package/packages/server/dist/services/stream.js.map +1 -1
  523. package/packages/server/dist/services/stt.d.ts +65 -0
  524. package/packages/server/dist/services/stt.d.ts.map +1 -0
  525. package/packages/server/dist/services/stt.js +306 -0
  526. package/packages/server/dist/services/stt.js.map +1 -0
  527. package/packages/server/dist/services/turns.d.ts +54 -0
  528. package/packages/server/dist/services/turns.d.ts.map +1 -0
  529. package/packages/server/dist/services/turns.js +186 -0
  530. package/packages/server/dist/services/turns.js.map +1 -0
  531. package/packages/server/dist/services/updates.d.ts +99 -0
  532. package/packages/server/dist/services/updates.d.ts.map +1 -0
  533. package/packages/server/dist/services/updates.js +316 -0
  534. package/packages/server/dist/services/updates.js.map +1 -0
  535. package/packages/server/package.json +1 -1
  536. package/packages/web/dist/app-icon.svg +2 -0
  537. package/packages/web/dist/apple-touch-icon.png +0 -0
  538. package/packages/web/dist/assets/abnfDiagram-O67JEVCF-D7YyFndQ.js +1 -0
  539. package/packages/web/dist/assets/arc-C_Zgk2dJ.js +1 -0
  540. package/packages/web/dist/assets/architectureDiagram-NJMV4G6O-eI0adu1B.js +36 -0
  541. package/packages/web/dist/assets/blockDiagram-BEXU5L5S-WAoOFUA9.js +140 -0
  542. package/packages/web/dist/assets/c4Diagram-YGBWAQC7-DE8Zyhng.js +38 -0
  543. package/packages/web/dist/assets/channel-egZxcyUK.js +1 -0
  544. package/packages/web/dist/assets/chunk-2Q5K7J3B-bnqLP2XD.js +1 -0
  545. package/packages/web/dist/assets/chunk-3FUC2YCW-Ck1_SVe0.js +2 -0
  546. package/packages/web/dist/assets/chunk-5VM5RSS4-hDmC41gD.js +15 -0
  547. package/packages/web/dist/assets/chunk-GTNCS2PH-PoWvfCrT.js +88 -0
  548. package/packages/web/dist/assets/chunk-GWA4HPMP-D3V0IG43.js +1 -0
  549. package/packages/web/dist/assets/chunk-JWPE2WC7-BryfpHM5.js +1 -0
  550. package/packages/web/dist/assets/chunk-NETBCI7D-8ic1iEdT.js +1 -0
  551. package/packages/web/dist/assets/chunk-WEXAMYUT-nM8tmQT2.js +1 -0
  552. package/packages/web/dist/assets/chunk-XXDRQBXY-Do28F482.js +1 -0
  553. package/packages/web/dist/assets/classDiagram-v2-NBCMYWYE-Bop9oNNO.js +217 -0
  554. package/packages/web/dist/assets/cose-bilkent-JH36ORCC-a7f_bpnt.js +1 -0
  555. package/packages/web/dist/assets/cynefin-OW5HDTMX-DnArcis_.js +178 -0
  556. package/packages/web/dist/assets/cynefinDiagram-VND7K2PF-vEuTb1GD.js +62 -0
  557. package/packages/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
  558. package/packages/web/dist/assets/dagre-6A5THRUB-BgG4MynJ.js +4 -0
  559. package/packages/web/dist/assets/diagram-22UHCM2B-DRCQpafv.js +200 -0
  560. package/packages/web/dist/assets/diagram-3UASUU5V-BKgmAXde.js +24 -0
  561. package/packages/web/dist/assets/diagram-ATOU4E4O-B6Hsy36X.js +3 -0
  562. package/packages/web/dist/assets/diagram-CDSNMT55-JflyfyoB.js +30 -0
  563. package/packages/web/dist/assets/diagram-MLGK6HIB-Dd2QPJjT.js +24 -0
  564. package/packages/web/dist/assets/diagram-MPIPVDR6-DE5QU60x.js +41 -0
  565. package/packages/web/dist/assets/draco_decoder-C32yEggz.wasm +0 -0
  566. package/packages/web/dist/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
  567. package/packages/web/dist/assets/draco_decoder-fzg4nYZr.js +34 -0
  568. package/packages/web/dist/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
  569. package/packages/web/dist/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
  570. package/packages/web/dist/assets/ebnfDiagram-ZINNZB2B-D7AQ741b.js +1 -0
  571. package/packages/web/dist/assets/elk-276RUBZZ-CeewBVLF.js +27 -0
  572. package/packages/web/dist/assets/erDiagram-OPXOYQCR-mLLYkZ5c.js +99 -0
  573. package/packages/web/dist/assets/flowDiagram-KWPJA3E3-DtpSpsQN.js +213 -0
  574. package/packages/web/dist/assets/ganttDiagram-FUAMR5RP-1_lh-3ky.js +292 -0
  575. package/packages/web/dist/assets/gitGraphDiagram-X574FWY7-DoPXZuT5.js +106 -0
  576. package/packages/web/dist/assets/graph-Bn3Yngep.js +1 -0
  577. package/packages/web/dist/assets/index-Cw2Opmx7.js +648 -0
  578. package/packages/web/dist/assets/index-j0zBRCgT.css +32 -0
  579. package/packages/web/dist/assets/infoDiagram-VRGFBTTK-DQpRGGiD.js +2 -0
  580. package/packages/web/dist/assets/ishikawaDiagram-OU5B5YK6-gH5C9Q2e.js +70 -0
  581. package/packages/web/dist/assets/journeyDiagram-ZHPQQLJL-Bg-oeFjb.js +139 -0
  582. package/packages/web/dist/assets/kanban-definition-PNTS6WVX-BnpI4VH8.js +89 -0
  583. package/packages/web/dist/assets/katex-C5jXJg4s.js +257 -0
  584. package/packages/web/dist/assets/mermaid.core-BwBKxlRA.js +313 -0
  585. package/packages/web/dist/assets/mindmap-definition-NLK3R4M7-NBnnxEoO.js +96 -0
  586. package/packages/web/dist/assets/pegDiagram-GJSIUBJH-RrXXbIvO.js +1 -0
  587. package/packages/web/dist/assets/pieDiagram-5QR66LMP-B27q6Gso.js +39 -0
  588. package/packages/web/dist/assets/quadrantDiagram-O4NWA36T-DGDsdur2.js +7 -0
  589. package/packages/web/dist/assets/railroadDiagram-XR7U4H2S-GdjkE3mI.js +1 -0
  590. package/packages/web/dist/assets/requirementDiagram-PLB6GJNP-DjK0GfgO.js +84 -0
  591. package/packages/web/dist/assets/sankeyDiagram-IPEJSGJF-BG_AIkwF.js +40 -0
  592. package/packages/web/dist/assets/scene-D4LPicHk.js +4620 -0
  593. package/packages/web/dist/assets/sequenceDiagram-PO4LG4MO-CIQwUb4y.js +169 -0
  594. package/packages/web/dist/assets/sizeCapture-INFHLROL-bpIoPxdJ.js +1 -0
  595. package/packages/web/dist/assets/stateDiagram-v2-GCMORJYK-8hYXvPPv.js +291 -0
  596. package/packages/web/dist/assets/swimlanes-2SLR337P-gfflUMF9.js +1 -0
  597. package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-9wdzGXU-.js +8 -0
  598. package/packages/web/dist/assets/timeline-definition-EJHVYXUP-PHMNoGTZ.js +120 -0
  599. package/packages/web/dist/assets/usecaseDiagram-POWQR4AR-B2j5iteO.js +370 -0
  600. package/packages/web/dist/assets/vennDiagram-UO4OBE2U-BzxtZ-_2.js +34 -0
  601. package/packages/web/dist/assets/wardleyDiagram-VNRHLVJA-DL7YbMpY.js +78 -0
  602. package/packages/web/dist/assets/xychartDiagram-PMCCYNJV-CisgP1cT.js +7 -0
  603. package/packages/web/dist/draco/draco_decoder.js +33 -0
  604. package/packages/web/dist/draco/draco_decoder.wasm +0 -0
  605. package/packages/web/dist/draco/draco_wasm_wrapper.js +116 -0
  606. package/packages/web/dist/favicon-16.png +0 -0
  607. package/packages/web/dist/favicon-32.png +0 -0
  608. package/packages/web/dist/favicon-48.png +0 -0
  609. package/packages/web/dist/favicon.ico +0 -0
  610. package/packages/web/dist/favicon.svg +1 -1
  611. package/packages/web/dist/icon-192.png +0 -0
  612. package/packages/web/dist/icon-512.png +0 -0
  613. package/packages/web/dist/index.html +12 -4
  614. package/packages/web/dist/logo-light.svg +1 -1
  615. package/packages/web/dist/logo-mono.svg +2 -0
  616. package/packages/web/dist/logo-stacked-light.svg +2 -0
  617. package/packages/web/dist/logo-stacked.svg +2 -0
  618. package/packages/web/dist/logo-white.svg +2 -0
  619. package/packages/web/dist/logo.svg +1 -1
  620. package/packages/web/dist/mark-light.svg +1 -1
  621. package/packages/web/dist/mark-mono.svg +2 -0
  622. package/packages/web/dist/mark-small-light.svg +2 -0
  623. package/packages/web/dist/mark-small.svg +2 -0
  624. package/packages/web/dist/mark-white.svg +2 -0
  625. package/packages/web/dist/mark.svg +1 -1
  626. package/packages/web/dist/models/LICENSE.txt +5 -0
  627. package/packages/web/dist/models/brain.glb +0 -0
  628. package/packages/web/dist/site.webmanifest +23 -0
  629. package/packages/web/dist/wordmark-light.svg +2 -0
  630. package/packages/web/dist/wordmark.svg +2 -0
  631. package/packages/web/package.json +1 -1
  632. package/scripts/rookery.mjs +204 -122
  633. package/scripts/updater.mjs +227 -0
  634. package/packages/cli/dist/tui/components/Wordmark.d.ts +0 -35
  635. package/packages/cli/dist/tui/components/Wordmark.d.ts.map +0 -1
  636. package/packages/cli/dist/tui/components/Wordmark.js +0 -81
  637. package/packages/cli/dist/tui/components/Wordmark.js.map +0 -1
  638. package/packages/core/dist/agents/orchestrator.d.ts +0 -24
  639. package/packages/core/dist/agents/orchestrator.d.ts.map +0 -1
  640. package/packages/core/dist/agents/orchestrator.js +0 -88
  641. package/packages/core/dist/agents/orchestrator.js.map +0 -1
  642. package/packages/core/dist/agents/roles.d.ts +0 -21
  643. package/packages/core/dist/agents/roles.d.ts.map +0 -1
  644. package/packages/core/dist/agents/roles.js +0 -81
  645. package/packages/core/dist/agents/roles.js.map +0 -1
  646. package/packages/core/dist/agents/team.d.ts +0 -105
  647. package/packages/core/dist/agents/team.d.ts.map +0 -1
  648. package/packages/core/dist/agents/team.js +0 -623
  649. package/packages/core/dist/agents/team.js.map +0 -1
  650. package/packages/core/dist/providers/codex.d.ts +0 -10
  651. package/packages/core/dist/providers/codex.d.ts.map +0 -1
  652. package/packages/core/dist/providers/codex.js +0 -375
  653. package/packages/core/dist/providers/codex.js.map +0 -1
  654. package/packages/core/dist/tools/browser.d.ts +0 -20
  655. package/packages/core/dist/tools/browser.d.ts.map +0 -1
  656. package/packages/core/dist/tools/browser.js +0 -72
  657. package/packages/core/dist/tools/browser.js.map +0 -1
  658. package/packages/server/dist/routes/agents.d.ts +0 -5
  659. package/packages/server/dist/routes/agents.d.ts.map +0 -1
  660. package/packages/server/dist/routes/agents.js +0 -6
  661. package/packages/server/dist/routes/agents.js.map +0 -1
  662. package/packages/server/dist/routes/team.d.ts +0 -11
  663. package/packages/server/dist/routes/team.d.ts.map +0 -1
  664. package/packages/server/dist/routes/team.js +0 -36
  665. package/packages/server/dist/routes/team.js.map +0 -1
  666. package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +0 -1163
  667. package/packages/web/dist/assets/index-IBSTzK7-.js +0 -1255
  668. package/packages/web/dist/assets/index-qUXUui7W.css +0 -1
  669. package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +0 -4
  670. package/packages/web/dist/assets/three.module-cmFfBtHS.js +0 -4228
@@ -0,0 +1,370 @@
1
+ import{g as fl}from"./chunk-XXDRQBXY-Do28F482.js";import{s as pl}from"./chunk-WEXAMYUT-nM8tmQT2.js";import{g as Ba,s as Vs,a as Ga,b as Ys,t as gl,q as ml,_ as u,D as Vt,l as Tl,c as Wa,p as El,r as yl,u as Al,j as Sl,A as Ol,O as Rl,C as Ll,L as Il,E as Nl,I as bl,aI as vl,k as _l}from"./mermaid.core-BwBKxlRA.js";import"./index-Cw2Opmx7.js";var ja=typeof global=="object"&&global&&global.Object===Object&&global,Cl=typeof self=="object"&&self&&self.Object===Object&&self,be=ja||Cl||Function("return this")(),he=be.Symbol,Ka=Object.prototype,kl=Ka.hasOwnProperty,wl=Ka.toString,Wt=he?he.toStringTag:void 0;function xl(t){var e=kl.call(t,Wt),n=t[Wt];try{t[Wt]=void 0;var s=!0}catch{}var r=wl.call(t);return s&&(e?t[Wt]=n:delete t[Wt]),r}var Ml=Object.prototype,$l=Ml.toString;function Pl(t){return $l.call(t)}var Ul="[object Null]",Dl="[object Undefined]",ai=he?he.toStringTag:void 0;function rt(t){return t==null?t===void 0?Dl:Ul:ai&&ai in Object(t)?xl(t):Pl(t)}function Ee(t){return t!=null&&typeof t=="object"}var Fl="[object Symbol]";function rs(t){return typeof t=="symbol"||Ee(t)&&rt(t)==Fl}function is(t,e){for(var n=-1,s=t==null?0:t.length,r=Array(s);++n<s;)r[n]=e(t[n],n,t);return r}var v=Array.isArray,oi=he?he.prototype:void 0,ci=oi?oi.toString:void 0;function za(t){if(typeof t=="string")return t;if(v(t))return is(t,za)+"";if(rs(t))return ci?ci.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Bl=/\s/;function Gl(t){for(var e=t.length;e--&&Bl.test(t.charAt(e)););return e}var Wl=/^\s+/;function jl(t){return t&&t.slice(0,Gl(t)+1).replace(Wl,"")}function ue(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var li=NaN,Kl=/^[-+]0x[0-9a-f]+$/i,zl=/^0b[01]+$/i,Hl=/^0o[0-7]+$/i,Vl=parseInt;function Yl(t){if(typeof t=="number")return t;if(rs(t))return li;if(ue(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=ue(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=jl(t);var n=zl.test(t);return n||Hl.test(t)?Vl(t.slice(2),n?2:8):Kl.test(t)?li:+t}var hi=1/0,Xl=17976931348623157e292;function ql(t){if(!t)return t===0?t:0;if(t=Yl(t),t===hi||t===-hi){var e=t<0?-1:1;return e*Xl}return t===t?t:0}function as(t){var e=ql(t),n=e%1;return e===e?n?e-n:e:0}function un(t){return t}var Jl="[object AsyncFunction]",Zl="[object Function]",Ql="[object GeneratorFunction]",eh="[object Proxy]";function je(t){if(!ue(t))return!1;var e=rt(t);return e==Zl||e==Ql||e==Jl||e==eh}var $s=be["__core-js_shared__"],ui=(function(){var t=/[^.]+$/.exec($s&&$s.keys&&$s.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function th(t){return!!ui&&ui in t}var nh=Function.prototype,sh=nh.toString;function mt(t){if(t!=null){try{return sh.call(t)}catch{}try{return t+""}catch{}}return""}var rh=/[\\^$.*+?()[\]{}|]/g,ih=/^\[object .+?Constructor\]$/,ah=Function.prototype,oh=Object.prototype,ch=ah.toString,lh=oh.hasOwnProperty,hh=RegExp("^"+ch.call(lh).replace(rh,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function uh(t){if(!ue(t)||th(t))return!1;var e=je(t)?hh:ih;return e.test(mt(t))}function dh(t,e){return t==null?void 0:t[e]}function Tt(t,e){var n=dh(t,e);return uh(n)?n:void 0}var Xs=Tt(be,"WeakMap"),di=Object.create,fh=(function(){function t(){}return function(e){if(!ue(e))return{};if(di)return di(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}})();function ph(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}function W(){}function gh(t,e){var n=-1,s=t.length;for(e||(e=Array(s));++n<s;)e[n]=t[n];return e}var mh=800,Th=16,Eh=Date.now;function yh(t){var e=0,n=0;return function(){var s=Eh(),r=Th-(s-n);if(n=s,r>0){if(++e>=mh)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function Ah(t){return function(){return t}}var Wn=(function(){try{var t=Tt(Object,"defineProperty");return t({},"",{}),t}catch{}})(),Sh=Wn?function(t,e){return Wn(t,"toString",{configurable:!0,enumerable:!1,value:Ah(e),writable:!0})}:un,Oh=yh(Sh);function Ha(t,e){for(var n=-1,s=t==null?0:t.length;++n<s&&e(t[n],n,t)!==!1;);return t}function Va(t,e,n,s){for(var r=t.length,i=n+-1;++i<r;)if(e(t[i],i,t))return i;return-1}function Rh(t){return t!==t}function Lh(t,e,n){for(var s=n-1,r=t.length;++s<r;)if(t[s]===e)return s;return-1}function Ar(t,e,n){return e===e?Lh(t,e,n):Va(t,Rh,n)}function Ya(t,e){var n=t==null?0:t.length;return!!n&&Ar(t,e,0)>-1}var Ih=9007199254740991,Nh=/^(?:0|[1-9]\d*)$/;function os(t,e){var n=typeof t;return e=e??Ih,!!e&&(n=="number"||n!="symbol"&&Nh.test(t))&&t>-1&&t%1==0&&t<e}function Sr(t,e,n){e=="__proto__"&&Wn?Wn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function dn(t,e){return t===e||t!==t&&e!==e}var bh=Object.prototype,vh=bh.hasOwnProperty;function cs(t,e,n){var s=t[e];(!(vh.call(t,e)&&dn(s,n))||n===void 0&&!(e in t))&&Sr(t,e,n)}function fn(t,e,n,s){var r=!n;n||(n={});for(var i=-1,a=e.length;++i<a;){var o=e[i],c=void 0;c===void 0&&(c=t[o]),r?Sr(n,o,c):cs(n,o,c)}return n}var fi=Math.max;function _h(t,e,n){return e=fi(e===void 0?t.length-1:e,0),function(){for(var s=arguments,r=-1,i=fi(s.length-e,0),a=Array(i);++r<i;)a[r]=s[e+r];r=-1;for(var o=Array(e+1);++r<e;)o[r]=s[r];return o[e]=n(a),ph(t,this,o)}}function Or(t,e){return Oh(_h(t,e,un),t+"")}var Ch=9007199254740991;function Rr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ch}function ve(t){return t!=null&&Rr(t.length)&&!je(t)}function Xa(t,e,n){if(!ue(n))return!1;var s=typeof e;return(s=="number"?ve(n)&&os(e,n.length):s=="string"&&e in n)?dn(n[e],t):!1}function kh(t){return Or(function(e,n){var s=-1,r=n.length,i=r>1?n[r-1]:void 0,a=r>2?n[2]:void 0;for(i=t.length>3&&typeof i=="function"?(r--,i):void 0,a&&Xa(n[0],n[1],a)&&(i=r<3?void 0:i,r=1),e=Object(e);++s<r;){var o=n[s];o&&t(e,o,s,i)}return e})}var wh=Object.prototype;function pn(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||wh;return t===n}function xh(t,e){for(var n=-1,s=Array(t);++n<t;)s[n]=e(n);return s}var Mh="[object Arguments]";function pi(t){return Ee(t)&&rt(t)==Mh}var qa=Object.prototype,$h=qa.hasOwnProperty,Ph=qa.propertyIsEnumerable,ls=pi((function(){return arguments})())?pi:function(t){return Ee(t)&&$h.call(t,"callee")&&!Ph.call(t,"callee")};function Uh(){return!1}var Ja=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gi=Ja&&typeof module=="object"&&module&&!module.nodeType&&module,Dh=gi&&gi.exports===Ja,mi=Dh?be.Buffer:void 0,Fh=mi?mi.isBuffer:void 0,rn=Fh||Uh,Bh="[object Arguments]",Gh="[object Array]",Wh="[object Boolean]",jh="[object Date]",Kh="[object Error]",zh="[object Function]",Hh="[object Map]",Vh="[object Number]",Yh="[object Object]",Xh="[object RegExp]",qh="[object Set]",Jh="[object String]",Zh="[object WeakMap]",Qh="[object ArrayBuffer]",eu="[object DataView]",tu="[object Float32Array]",nu="[object Float64Array]",su="[object Int8Array]",ru="[object Int16Array]",iu="[object Int32Array]",au="[object Uint8Array]",ou="[object Uint8ClampedArray]",cu="[object Uint16Array]",lu="[object Uint32Array]",w={};w[tu]=w[nu]=w[su]=w[ru]=w[iu]=w[au]=w[ou]=w[cu]=w[lu]=!0;w[Bh]=w[Gh]=w[Qh]=w[Wh]=w[eu]=w[jh]=w[Kh]=w[zh]=w[Hh]=w[Vh]=w[Yh]=w[Xh]=w[qh]=w[Jh]=w[Zh]=!1;function hu(t){return Ee(t)&&Rr(t.length)&&!!w[rt(t)]}function hs(t){return function(e){return t(e)}}var Za=typeof exports=="object"&&exports&&!exports.nodeType&&exports,tn=Za&&typeof module=="object"&&module&&!module.nodeType&&module,uu=tn&&tn.exports===Za,Ps=uu&&ja.process,Qe=(function(){try{var t=tn&&tn.require&&tn.require("util").types;return t||Ps&&Ps.binding&&Ps.binding("util")}catch{}})(),Ti=Qe&&Qe.isTypedArray,Lr=Ti?hs(Ti):hu,du=Object.prototype,fu=du.hasOwnProperty;function Qa(t,e){var n=v(t),s=!n&&ls(t),r=!n&&!s&&rn(t),i=!n&&!s&&!r&&Lr(t),a=n||s||r||i,o=a?xh(t.length,String):[],c=o.length;for(var l in t)(e||fu.call(t,l))&&!(a&&(l=="length"||r&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||os(l,c)))&&o.push(l);return o}function eo(t,e){return function(n){return t(e(n))}}var pu=eo(Object.keys,Object),gu=Object.prototype,mu=gu.hasOwnProperty;function to(t){if(!pn(t))return pu(t);var e=[];for(var n in Object(t))mu.call(t,n)&&n!="constructor"&&e.push(n);return e}function de(t){return ve(t)?Qa(t):to(t)}var Tu=Object.prototype,Eu=Tu.hasOwnProperty,qs=kh(function(t,e){if(pn(e)||ve(e)){fn(e,de(e),t);return}for(var n in e)Eu.call(e,n)&&cs(t,n,e[n])});function yu(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var Au=Object.prototype,Su=Au.hasOwnProperty;function Ou(t){if(!ue(t))return yu(t);var e=pn(t),n=[];for(var s in t)s=="constructor"&&(e||!Su.call(t,s))||n.push(s);return n}function Ir(t){return ve(t)?Qa(t,!0):Ou(t)}var Ru=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lu=/^\w*$/;function Nr(t,e){if(v(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||rs(t)?!0:Lu.test(t)||!Ru.test(t)||e!=null&&t in Object(e)}var an=Tt(Object,"create");function Iu(){this.__data__=an?an(null):{},this.size=0}function Nu(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var bu="__lodash_hash_undefined__",vu=Object.prototype,_u=vu.hasOwnProperty;function Cu(t){var e=this.__data__;if(an){var n=e[t];return n===bu?void 0:n}return _u.call(e,t)?e[t]:void 0}var ku=Object.prototype,wu=ku.hasOwnProperty;function xu(t){var e=this.__data__;return an?e[t]!==void 0:wu.call(e,t)}var Mu="__lodash_hash_undefined__";function $u(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=an&&e===void 0?Mu:e,this}function dt(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}dt.prototype.clear=Iu;dt.prototype.delete=Nu;dt.prototype.get=Cu;dt.prototype.has=xu;dt.prototype.set=$u;function Pu(){this.__data__=[],this.size=0}function us(t,e){for(var n=t.length;n--;)if(dn(t[n][0],e))return n;return-1}var Uu=Array.prototype,Du=Uu.splice;function Fu(t){var e=this.__data__,n=us(e,t);if(n<0)return!1;var s=e.length-1;return n==s?e.pop():Du.call(e,n,1),--this.size,!0}function Bu(t){var e=this.__data__,n=us(e,t);return n<0?void 0:e[n][1]}function Gu(t){return us(this.__data__,t)>-1}function Wu(t,e){var n=this.__data__,s=us(n,t);return s<0?(++this.size,n.push([t,e])):n[s][1]=e,this}function Ke(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}Ke.prototype.clear=Pu;Ke.prototype.delete=Fu;Ke.prototype.get=Bu;Ke.prototype.has=Gu;Ke.prototype.set=Wu;var on=Tt(be,"Map");function ju(){this.size=0,this.__data__={hash:new dt,map:new(on||Ke),string:new dt}}function Ku(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ds(t,e){var n=t.__data__;return Ku(e)?n[typeof e=="string"?"string":"hash"]:n.map}function zu(t){var e=ds(this,t).delete(t);return this.size-=e?1:0,e}function Hu(t){return ds(this,t).get(t)}function Vu(t){return ds(this,t).has(t)}function Yu(t,e){var n=ds(this,t),s=n.size;return n.set(t,e),this.size+=n.size==s?0:1,this}function ze(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}ze.prototype.clear=ju;ze.prototype.delete=zu;ze.prototype.get=Hu;ze.prototype.has=Vu;ze.prototype.set=Yu;var Xu="Expected a function";function br(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Xu);var n=function(){var s=arguments,r=e?e.apply(this,s):s[0],i=n.cache;if(i.has(r))return i.get(r);var a=t.apply(this,s);return n.cache=i.set(r,a)||i,a};return n.cache=new(br.Cache||ze),n}br.Cache=ze;var qu=500;function Ju(t){var e=br(t,function(s){return n.size===qu&&n.clear(),s}),n=e.cache;return e}var Zu=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qu=/\\(\\)?/g,ed=Ju(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Zu,function(n,s,r,i){e.push(r?i.replace(Qu,"$1"):s||n)}),e});function td(t){return t==null?"":za(t)}function fs(t,e){return v(t)?t:Nr(t,e)?[t]:ed(td(t))}function gn(t){if(typeof t=="string"||rs(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function vr(t,e){e=fs(e,t);for(var n=0,s=e.length;t!=null&&n<s;)t=t[gn(e[n++])];return n&&n==s?t:void 0}function nd(t,e,n){var s=t==null?void 0:vr(t,e);return s===void 0?n:s}function _r(t,e){for(var n=-1,s=e.length,r=t.length;++n<s;)t[r+n]=e[n];return t}var Ei=he?he.isConcatSpreadable:void 0;function sd(t){return v(t)||ls(t)||!!(Ei&&t&&t[Ei])}function Cr(t,e,n,s,r){var i=-1,a=t.length;for(n||(n=sd),r||(r=[]);++i<a;){var o=t[i];n(o)?_r(r,o):s||(r[r.length]=o)}return r}function Te(t){var e=t==null?0:t.length;return e?Cr(t):[]}var no=eo(Object.getPrototypeOf,Object);function so(t,e,n){var s=-1,r=t.length;e<0&&(e=-e>r?0:r+e),n=n>r?r:n,n<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var i=Array(r);++s<r;)i[s]=t[s+e];return i}function rd(t,e,n,s){var r=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++r]);++r<i;)n=e(n,t[r],r,t);return n}function id(){this.__data__=new Ke,this.size=0}function ad(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function od(t){return this.__data__.get(t)}function cd(t){return this.__data__.has(t)}var ld=200;function hd(t,e){var n=this.__data__;if(n instanceof Ke){var s=n.__data__;if(!on||s.length<ld-1)return s.push([t,e]),this.size=++n.size,this;n=this.__data__=new ze(s)}return n.set(t,e),this.size=n.size,this}function Ie(t){var e=this.__data__=new Ke(t);this.size=e.size}Ie.prototype.clear=id;Ie.prototype.delete=ad;Ie.prototype.get=od;Ie.prototype.has=cd;Ie.prototype.set=hd;function ud(t,e){return t&&fn(e,de(e),t)}function dd(t,e){return t&&fn(e,Ir(e),t)}var ro=typeof exports=="object"&&exports&&!exports.nodeType&&exports,yi=ro&&typeof module=="object"&&module&&!module.nodeType&&module,fd=yi&&yi.exports===ro,Ai=fd?be.Buffer:void 0,Si=Ai?Ai.allocUnsafe:void 0;function pd(t,e){var n=t.length,s=Si?Si(n):new t.constructor(n);return t.copy(s),s}function kr(t,e){for(var n=-1,s=t==null?0:t.length,r=0,i=[];++n<s;){var a=t[n];e(a,n,t)&&(i[r++]=a)}return i}function io(){return[]}var gd=Object.prototype,md=gd.propertyIsEnumerable,Oi=Object.getOwnPropertySymbols,wr=Oi?function(t){return t==null?[]:(t=Object(t),kr(Oi(t),function(e){return md.call(t,e)}))}:io;function Td(t,e){return fn(t,wr(t),e)}var Ed=Object.getOwnPropertySymbols,ao=Ed?function(t){for(var e=[];t;)_r(e,wr(t)),t=no(t);return e}:io;function yd(t,e){return fn(t,ao(t),e)}function oo(t,e,n){var s=e(t);return v(t)?s:_r(s,n(t))}function Js(t){return oo(t,de,wr)}function Ad(t){return oo(t,Ir,ao)}var Zs=Tt(be,"DataView"),Qs=Tt(be,"Promise"),It=Tt(be,"Set"),Ri="[object Map]",Sd="[object Object]",Li="[object Promise]",Ii="[object Set]",Ni="[object WeakMap]",bi="[object DataView]",Od=mt(Zs),Rd=mt(on),Ld=mt(Qs),Id=mt(It),Nd=mt(Xs),ce=rt;(Zs&&ce(new Zs(new ArrayBuffer(1)))!=bi||on&&ce(new on)!=Ri||Qs&&ce(Qs.resolve())!=Li||It&&ce(new It)!=Ii||Xs&&ce(new Xs)!=Ni)&&(ce=function(t){var e=rt(t),n=e==Sd?t.constructor:void 0,s=n?mt(n):"";if(s)switch(s){case Od:return bi;case Rd:return Ri;case Ld:return Li;case Id:return Ii;case Nd:return Ni}return e});var bd=Object.prototype,vd=bd.hasOwnProperty;function _d(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&vd.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var jn=be.Uint8Array;function Cd(t){var e=new t.constructor(t.byteLength);return new jn(e).set(new jn(t)),e}function kd(t,e){var n=t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}var wd=/\w*$/;function xd(t){var e=new t.constructor(t.source,wd.exec(t));return e.lastIndex=t.lastIndex,e}var vi=he?he.prototype:void 0,_i=vi?vi.valueOf:void 0;function Md(t){return _i?Object(_i.call(t)):{}}function $d(t,e){var n=t.buffer;return new t.constructor(n,t.byteOffset,t.length)}var Pd="[object Boolean]",Ud="[object Date]",Dd="[object Map]",Fd="[object Number]",Bd="[object RegExp]",Gd="[object Set]",Wd="[object String]",jd="[object Symbol]",Kd="[object ArrayBuffer]",zd="[object DataView]",Hd="[object Float32Array]",Vd="[object Float64Array]",Yd="[object Int8Array]",Xd="[object Int16Array]",qd="[object Int32Array]",Jd="[object Uint8Array]",Zd="[object Uint8ClampedArray]",Qd="[object Uint16Array]",ef="[object Uint32Array]";function tf(t,e,n){var s=t.constructor;switch(e){case Kd:return Cd(t);case Pd:case Ud:return new s(+t);case zd:return kd(t);case Hd:case Vd:case Yd:case Xd:case qd:case Jd:case Zd:case Qd:case ef:return $d(t);case Dd:return new s;case Fd:case Wd:return new s(t);case Bd:return xd(t);case Gd:return new s;case jd:return Md(t)}}function nf(t){return typeof t.constructor=="function"&&!pn(t)?fh(no(t)):{}}var sf="[object Map]";function rf(t){return Ee(t)&&ce(t)==sf}var Ci=Qe&&Qe.isMap,af=Ci?hs(Ci):rf,of="[object Set]";function cf(t){return Ee(t)&&ce(t)==of}var ki=Qe&&Qe.isSet,lf=ki?hs(ki):cf,hf=2,co="[object Arguments]",uf="[object Array]",df="[object Boolean]",ff="[object Date]",pf="[object Error]",lo="[object Function]",gf="[object GeneratorFunction]",mf="[object Map]",Tf="[object Number]",ho="[object Object]",Ef="[object RegExp]",yf="[object Set]",Af="[object String]",Sf="[object Symbol]",Of="[object WeakMap]",Rf="[object ArrayBuffer]",Lf="[object DataView]",If="[object Float32Array]",Nf="[object Float64Array]",bf="[object Int8Array]",vf="[object Int16Array]",_f="[object Int32Array]",Cf="[object Uint8Array]",kf="[object Uint8ClampedArray]",wf="[object Uint16Array]",xf="[object Uint32Array]",C={};C[co]=C[uf]=C[Rf]=C[Lf]=C[df]=C[ff]=C[If]=C[Nf]=C[bf]=C[vf]=C[_f]=C[mf]=C[Tf]=C[ho]=C[Ef]=C[yf]=C[Af]=C[Sf]=C[Cf]=C[kf]=C[wf]=C[xf]=!0;C[pf]=C[lo]=C[Of]=!1;function Cn(t,e,n,s,r,i){var a,o=e&hf;if(a!==void 0)return a;if(!ue(t))return t;var c=v(t);if(c)return a=_d(t),gh(t,a);var l=ce(t),d=l==lo||l==gf;if(rn(t))return pd(t);if(l==ho||l==co||d&&!r)return a=d?{}:nf(t),o?yd(t,dd(a,t)):Td(t,ud(a,t));if(!C[l])return r?t:{};a=tf(t,l),i||(i=new Ie);var h=i.get(t);if(h)return h;i.set(t,a),lf(t)?t.forEach(function(g){a.add(Cn(g,e,n,g,t,i))}):af(t)&&t.forEach(function(g,T){a.set(T,Cn(g,e,n,T,t,i))});var f=Js,p=c?void 0:f(t);return Ha(p||t,function(g,T){p&&(T=g,g=t[T]),cs(a,T,Cn(g,e,n,T,t,i))}),a}var Mf=4;function H(t){return Cn(t,Mf)}function mn(t){for(var e=-1,n=t==null?0:t.length,s=0,r=[];++e<n;){var i=t[e];i&&(r[s++]=i)}return r}var $f="__lodash_hash_undefined__";function Pf(t){return this.__data__.set(t,$f),this}function Uf(t){return this.__data__.has(t)}function xt(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new ze;++e<n;)this.add(t[e])}xt.prototype.add=xt.prototype.push=Pf;xt.prototype.has=Uf;function uo(t,e){for(var n=-1,s=t==null?0:t.length;++n<s;)if(e(t[n],n,t))return!0;return!1}function xr(t,e){return t.has(e)}var Df=1,Ff=2;function fo(t,e,n,s,r,i){var a=n&Df,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))return!1;var l=i.get(t),d=i.get(e);if(l&&d)return l==e&&d==t;var h=-1,f=!0,p=n&Ff?new xt:void 0;for(i.set(t,e),i.set(e,t);++h<o;){var g=t[h],T=e[h];if(s)var L=a?s(T,g,h,e,t,i):s(g,T,h,t,e,i);if(L!==void 0){if(L)continue;f=!1;break}if(p){if(!uo(e,function(y,E){if(!xr(p,E)&&(g===y||r(g,y,n,s,i)))return p.push(E)})){f=!1;break}}else if(!(g===T||r(g,T,n,s,i))){f=!1;break}}return i.delete(t),i.delete(e),f}function Bf(t){var e=-1,n=Array(t.size);return t.forEach(function(s,r){n[++e]=[r,s]}),n}function Mr(t){var e=-1,n=Array(t.size);return t.forEach(function(s){n[++e]=s}),n}var Gf=1,Wf=2,jf="[object Boolean]",Kf="[object Date]",zf="[object Error]",Hf="[object Map]",Vf="[object Number]",Yf="[object RegExp]",Xf="[object Set]",qf="[object String]",Jf="[object Symbol]",Zf="[object ArrayBuffer]",Qf="[object DataView]",wi=he?he.prototype:void 0,Us=wi?wi.valueOf:void 0;function ep(t,e,n,s,r,i,a){switch(n){case Qf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Zf:return!(t.byteLength!=e.byteLength||!i(new jn(t),new jn(e)));case jf:case Kf:case Vf:return dn(+t,+e);case zf:return t.name==e.name&&t.message==e.message;case Yf:case qf:return t==e+"";case Hf:var o=Bf;case Xf:var c=s&Gf;if(o||(o=Mr),t.size!=e.size&&!c)return!1;var l=a.get(t);if(l)return l==e;s|=Wf,a.set(t,e);var d=fo(o(t),o(e),s,r,i,a);return a.delete(t),d;case Jf:if(Us)return Us.call(t)==Us.call(e)}return!1}var tp=1,np=Object.prototype,sp=np.hasOwnProperty;function rp(t,e,n,s,r,i){var a=n&tp,o=Js(t),c=o.length,l=Js(e),d=l.length;if(c!=d&&!a)return!1;for(var h=c;h--;){var f=o[h];if(!(a?f in e:sp.call(e,f)))return!1}var p=i.get(t),g=i.get(e);if(p&&g)return p==e&&g==t;var T=!0;i.set(t,e),i.set(e,t);for(var L=a;++h<c;){f=o[h];var y=t[f],E=e[f];if(s)var m=a?s(E,y,f,e,t,i):s(y,E,f,t,e,i);if(!(m===void 0?y===E||r(y,E,n,s,i):m)){T=!1;break}L||(L=f=="constructor")}if(T&&!L){var A=t.constructor,_=e.constructor;A!=_&&"constructor"in t&&"constructor"in e&&!(typeof A=="function"&&A instanceof A&&typeof _=="function"&&_ instanceof _)&&(T=!1)}return i.delete(t),i.delete(e),T}var ip=1,xi="[object Arguments]",Mi="[object Array]",Ln="[object Object]",ap=Object.prototype,$i=ap.hasOwnProperty;function op(t,e,n,s,r,i){var a=v(t),o=v(e),c=a?Mi:ce(t),l=o?Mi:ce(e);c=c==xi?Ln:c,l=l==xi?Ln:l;var d=c==Ln,h=l==Ln,f=c==l;if(f&&rn(t)){if(!rn(e))return!1;a=!0,d=!1}if(f&&!d)return i||(i=new Ie),a||Lr(t)?fo(t,e,n,s,r,i):ep(t,e,c,n,s,r,i);if(!(n&ip)){var p=d&&$i.call(t,"__wrapped__"),g=h&&$i.call(e,"__wrapped__");if(p||g){var T=p?t.value():t,L=g?e.value():e;return i||(i=new Ie),r(T,L,n,s,i)}}return f?(i||(i=new Ie),rp(t,e,n,s,r,i)):!1}function $r(t,e,n,s,r){return t===e?!0:t==null||e==null||!Ee(t)&&!Ee(e)?t!==t&&e!==e:op(t,e,n,s,$r,r)}var cp=1,lp=2;function hp(t,e,n,s){var r=n.length,i=r;if(t==null)return!i;for(t=Object(t);r--;){var a=n[r];if(a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++r<i;){a=n[r];var o=a[0],c=t[o],l=a[1];if(a[2]){if(c===void 0&&!(o in t))return!1}else{var d=new Ie,h;if(!(h===void 0?$r(l,c,cp|lp,s,d):h))return!1}}return!0}function po(t){return t===t&&!ue(t)}function up(t){for(var e=de(t),n=e.length;n--;){var s=e[n],r=t[s];e[n]=[s,r,po(r)]}return e}function go(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function dp(t){var e=up(t);return e.length==1&&e[0][2]?go(e[0][0],e[0][1]):function(n){return n===t||hp(n,t,e)}}function fp(t,e){return t!=null&&e in Object(t)}function mo(t,e,n){e=fs(e,t);for(var s=-1,r=e.length,i=!1;++s<r;){var a=gn(e[s]);if(!(i=t!=null&&n(t,a)))break;t=t[a]}return i||++s!=r?i:(r=t==null?0:t.length,!!r&&Rr(r)&&os(a,r)&&(v(t)||ls(t)))}function pp(t,e){return t!=null&&mo(t,e,fp)}var gp=1,mp=2;function Tp(t,e){return Nr(t)&&po(e)?go(gn(t),e):function(n){var s=nd(n,t);return s===void 0&&s===e?pp(n,t):$r(e,s,gp|mp)}}function Ep(t){return function(e){return e==null?void 0:e[t]}}function yp(t){return function(e){return vr(e,t)}}function Ap(t){return Nr(t)?Ep(gn(t)):yp(t)}function _e(t){return typeof t=="function"?t:t==null?un:typeof t=="object"?v(t)?Tp(t[0],t[1]):dp(t):Ap(t)}function Sp(t,e,n,s){for(var r=-1,i=t==null?0:t.length;++r<i;){var a=t[r];e(s,a,n(a),t)}return s}function Op(t){return function(e,n,s){for(var r=-1,i=Object(e),a=s(e),o=a.length;o--;){var c=a[++r];if(n(i[c],c,i)===!1)break}return e}}var Rp=Op();function Lp(t,e){return t&&Rp(t,e,de)}function Ip(t,e){return function(n,s){if(n==null)return n;if(!ve(n))return t(n,s);for(var r=n.length,i=-1,a=Object(n);++i<r&&s(a[i],i,a)!==!1;);return n}}var Et=Ip(Lp);function Np(t,e,n,s){return Et(t,function(r,i,a){e(s,r,n(r),a)}),s}function bp(t,e){return function(n,s){var r=v(n)?Sp:Np,i=e?e():{};return r(n,t,_e(s),i)}}var To=Object.prototype,vp=To.hasOwnProperty,Pr=Or(function(t,e){t=Object(t);var n=-1,s=e.length,r=s>2?e[2]:void 0;for(r&&Xa(e[0],e[1],r)&&(s=1);++n<s;)for(var i=e[n],a=Ir(i),o=-1,c=a.length;++o<c;){var l=a[o],d=t[l];(d===void 0||dn(d,To[l])&&!vp.call(t,l))&&(t[l]=i[l])}return t});function Pi(t){return Ee(t)&&ve(t)}var _p=200;function Cp(t,e,n,s){var r=-1,i=Ya,a=!0,o=t.length,c=[],l=e.length;if(!o)return c;e.length>=_p&&(i=xr,a=!1,e=new xt(e));e:for(;++r<o;){var d=t[r],h=d;if(d=d!==0?d:0,a&&h===h){for(var f=l;f--;)if(e[f]===h)continue e;c.push(d)}else i(e,h,s)||c.push(d)}return c}var ps=Or(function(t,e){return Pi(t)?Cp(t,Cr(e,1,Pi,!0)):[]});function ft(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function z(t,e,n){var s=t==null?0:t.length;return s?(e=e===void 0?1:as(e),so(t,e<0?0:e,s)):[]}function cn(t,e,n){var s=t==null?0:t.length;return s?(e=e===void 0?1:as(e),e=s-e,so(t,0,e<0?0:e)):[]}function kp(t){return typeof t=="function"?t:un}function N(t,e){var n=v(t)?Ha:Et;return n(t,kp(e))}function wp(t,e){for(var n=-1,s=t==null?0:t.length;++n<s;)if(!e(t[n],n,t))return!1;return!0}function xp(t,e){var n=!0;return Et(t,function(s,r,i){return n=!!e(s,r,i),n}),n}function Ne(t,e,n){var s=v(t)?wp:xp;return s(t,_e(e))}function Eo(t,e){var n=[];return Et(t,function(s,r,i){e(s,r,i)&&n.push(s)}),n}function fe(t,e){var n=v(t)?kr:Eo;return n(t,_e(e))}function Mp(t){return function(e,n,s){var r=Object(e);if(!ve(e)){var i=_e(n);e=de(e),n=function(o){return i(r[o],o,r)}}var a=t(e,n,s);return a>-1?r[i?e[a]:a]:void 0}}var $p=Math.max;function Pp(t,e,n){var s=t==null?0:t.length;if(!s)return-1;var r=n==null?0:as(n);return r<0&&(r=$p(s+r,0)),Va(t,_e(e),r)}var Mt=Mp(Pp);function ye(t){return t&&t.length?t[0]:void 0}function Up(t,e){var n=-1,s=ve(t)?Array(t.length):[];return Et(t,function(r,i,a){s[++n]=e(r,i,a)}),s}function S(t,e){var n=v(t)?is:Up;return n(t,_e(e))}function le(t,e){return Cr(S(t,e))}var Dp=Object.prototype,Fp=Dp.hasOwnProperty,Bp=bp(function(t,e,n){Fp.call(t,n)?t[n].push(e):Sr(t,n,[e])}),Gp=Object.prototype,Wp=Gp.hasOwnProperty;function jp(t,e){return t!=null&&Wp.call(t,e)}function R(t,e){return t!=null&&mo(t,e,jp)}var Kp="[object String]";function Ae(t){return typeof t=="string"||!v(t)&&Ee(t)&&rt(t)==Kp}function zp(t,e){return is(e,function(n){return t[n]})}function B(t){return t==null?[]:zp(t,de(t))}var Hp=Math.max;function te(t,e,n,s){t=ve(t)?t:B(t),n=n?as(n):0;var r=t.length;return n<0&&(n=Hp(r+n,0)),Ae(t)?n<=r&&t.indexOf(e,n)>-1:!!r&&Ar(t,e,n)>-1}function Ui(t,e,n){var s=t==null?0:t.length;if(!s)return-1;var r=0;return Ar(t,e,r)}var Vp="[object Map]",Yp="[object Set]",Xp=Object.prototype,qp=Xp.hasOwnProperty;function k(t){if(t==null)return!0;if(ve(t)&&(v(t)||typeof t=="string"||typeof t.splice=="function"||rn(t)||Lr(t)||ls(t)))return!t.length;var e=ce(t);if(e==Vp||e==Yp)return!t.size;if(pn(t))return!to(t).length;for(var n in t)if(qp.call(t,n))return!1;return!0}var Jp="[object RegExp]";function Zp(t){return Ee(t)&&rt(t)==Jp}var Di=Qe&&Qe.isRegExp,et=Di?hs(Di):Zp;function Fe(t){return t===void 0}var Qp="Expected a function";function eg(t){if(typeof t!="function")throw new TypeError(Qp);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function tg(t,e,n,s){if(!ue(t))return t;e=fs(e,t);for(var r=-1,i=e.length,a=i-1,o=t;o!=null&&++r<i;){var c=gn(e[r]),l=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(r!=a){var d=o[c];l=void 0,l===void 0&&(l=ue(d)?d:os(e[r+1])?[]:{})}cs(o,c,l),o=o[c]}return t}function ng(t,e,n){for(var s=-1,r=e.length,i={};++s<r;){var a=e[s],o=vr(t,a);n(o,a)&&tg(i,fs(a,t),o)}return i}function sg(t,e){if(t==null)return{};var n=is(Ad(t),function(s){return[s]});return e=_e(e),ng(t,n,function(s,r){return e(s,r[0])})}function rg(t,e,n,s,r){return r(t,function(i,a,o){n=s?(s=!1,i):e(n,i,a,o)}),n}function ne(t,e,n){var s=v(t)?rd:rg,r=arguments.length<3;return s(t,_e(e),n,r,Et)}function gs(t,e){var n=v(t)?kr:Eo;return n(t,eg(_e(e)))}function ig(t,e){var n;return Et(t,function(s,r,i){return n=e(s,r,i),!n}),!!n}function ag(t,e,n){var s=v(t)?uo:ig;return s(t,_e(e))}var og=1/0,cg=It&&1/Mr(new It([,-0]))[1]==og?function(t){return new It(t)}:W,lg=200;function hg(t,e,n){var s=-1,r=Ya,i=t.length,a=!0,o=[],c=o;if(i>=lg){var l=cg(t);if(l)return Mr(l);a=!1,r=xr,c=new xt}else c=o;e:for(;++s<i;){var d=t[s],h=d;if(d=d!==0?d:0,a&&h===h){for(var f=c.length;f--;)if(c[f]===h)continue e;o.push(d)}else r(c,h,n)||(c!==o&&c.push(h),o.push(d))}return o}function Ur(t){return t&&t.length?hg(t):[]}function er(t){console&&console.error&&console.error(`Error: ${t}`)}function yo(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function Ao(t){const e=new Date().getTime(),n=t();return{time:new Date().getTime()-e,value:n}}function So(t){function e(){}e.prototype=t;const n=new e;function s(){return typeof n.bar}return s(),s(),t}var Oo=typeof global=="object"&&global&&global.Object===Object&&global,ug=typeof self=="object"&&self&&self.Object===Object&&self,He=Oo||ug||Function("return this")(),tt=He.Symbol,Ro=Object.prototype,dg=Ro.hasOwnProperty,fg=Ro.toString,jt=tt?tt.toStringTag:void 0;function pg(t){var e=dg.call(t,jt),n=t[jt];try{t[jt]=void 0;var s=!0}catch{}var r=fg.call(t);return s&&(e?t[jt]=n:delete t[jt]),r}var gg=Object.prototype,mg=gg.toString;function Tg(t){return mg.call(t)}var Eg="[object Null]",yg="[object Undefined]",Fi=tt?tt.toStringTag:void 0;function it(t){return t==null?t===void 0?yg:Eg:Fi&&Fi in Object(t)?pg(t):Tg(t)}function nt(t){return t!=null&&typeof t=="object"}var Ag="[object Symbol]";function ms(t){return typeof t=="symbol"||nt(t)&&it(t)==Ag}function Ts(t,e){for(var n=-1,s=t==null?0:t.length,r=Array(s);++n<s;)r[n]=e(t[n],n,t);return r}var Q=Array.isArray,Bi=tt?tt.prototype:void 0,Gi=Bi?Bi.toString:void 0;function Lo(t){if(typeof t=="string")return t;if(Q(t))return Ts(t,Lo)+"";if(ms(t))return Gi?Gi.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Sg=/\s/;function Og(t){for(var e=t.length;e--&&Sg.test(t.charAt(e)););return e}var Rg=/^\s+/;function Lg(t){return t&&t.slice(0,Og(t)+1).replace(Rg,"")}function Be(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Wi=NaN,Ig=/^[-+]0x[0-9a-f]+$/i,Ng=/^0b[01]+$/i,bg=/^0o[0-7]+$/i,vg=parseInt;function _g(t){if(typeof t=="number")return t;if(ms(t))return Wi;if(Be(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Be(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Lg(t);var n=Ng.test(t);return n||bg.test(t)?vg(t.slice(2),n?2:8):Ig.test(t)?Wi:+t}var ji=1/0,Cg=17976931348623157e292;function kg(t){if(!t)return t===0?t:0;if(t=_g(t),t===ji||t===-ji){var e=t<0?-1:1;return e*Cg}return t===t?t:0}function wg(t){var e=kg(t),n=e%1;return e===e?n?e-n:e:0}function Es(t){return t}var xg="[object AsyncFunction]",Mg="[object Function]",$g="[object GeneratorFunction]",Pg="[object Proxy]";function Io(t){if(!Be(t))return!1;var e=it(t);return e==Mg||e==$g||e==xg||e==Pg}var Ds=He["__core-js_shared__"],Ki=(function(){var t=/[^.]+$/.exec(Ds&&Ds.keys&&Ds.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function Ug(t){return!!Ki&&Ki in t}var Dg=Function.prototype,Fg=Dg.toString;function yt(t){if(t!=null){try{return Fg.call(t)}catch{}try{return t+""}catch{}}return""}var Bg=/[\\^$.*+?()[\]{}|]/g,Gg=/^\[object .+?Constructor\]$/,Wg=Function.prototype,jg=Object.prototype,Kg=Wg.toString,zg=jg.hasOwnProperty,Hg=RegExp("^"+Kg.call(zg).replace(Bg,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Vg(t){if(!Be(t)||Ug(t))return!1;var e=Io(t)?Hg:Gg;return e.test(yt(t))}function Yg(t,e){return t==null?void 0:t[e]}function At(t,e){var n=Yg(t,e);return Vg(n)?n:void 0}var tr=At(He,"WeakMap");function Xg(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var qg=800,Jg=16,Zg=Date.now;function Qg(t){var e=0,n=0;return function(){var s=Zg(),r=Jg-(s-n);if(n=s,r>0){if(++e>=qg)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function em(t){return function(){return t}}var Kn=(function(){try{var t=At(Object,"defineProperty");return t({},"",{}),t}catch{}})(),tm=Kn?function(t,e){return Kn(t,"toString",{configurable:!0,enumerable:!1,value:em(e),writable:!0})}:Es,nm=Qg(tm);function sm(t,e){for(var n=-1,s=t==null?0:t.length;++n<s&&e(t[n],n,t)!==!1;);return t}function rm(t,e,n,s){for(var r=t.length,i=n+-1;++i<r;)if(e(t[i],i,t))return i;return-1}function im(t){return t!==t}function am(t,e,n){for(var s=n-1,r=t.length;++s<r;)if(t[s]===e)return s;return-1}function om(t,e,n){return e===e?am(t,e,n):rm(t,im,n)}var cm=9007199254740991,lm=/^(?:0|[1-9]\d*)$/;function ys(t,e){var n=typeof t;return e=e??cm,!!e&&(n=="number"||n!="symbol"&&lm.test(t))&&t>-1&&t%1==0&&t<e}function No(t,e,n){e=="__proto__"&&Kn?Kn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function As(t,e){return t===e||t!==t&&e!==e}var hm=Object.prototype,um=hm.hasOwnProperty;function Dr(t,e,n){var s=t[e];(!(um.call(t,e)&&As(s,n))||n===void 0&&!(e in t))&&No(t,e,n)}function dm(t,e,n,s){var r=!n;n||(n={});for(var i=-1,a=e.length;++i<a;){var o=e[i],c=void 0;c===void 0&&(c=t[o]),r?No(n,o,c):Dr(n,o,c)}return n}var zi=Math.max;function fm(t,e,n){return e=zi(e===void 0?t.length-1:e,0),function(){for(var s=arguments,r=-1,i=zi(s.length-e,0),a=Array(i);++r<i;)a[r]=s[e+r];r=-1;for(var o=Array(e+1);++r<e;)o[r]=s[r];return o[e]=n(a),Xg(t,this,o)}}function pm(t,e){return nm(fm(t,e,Es),t+"")}var gm=9007199254740991;function Fr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=gm}function St(t){return t!=null&&Fr(t.length)&&!Io(t)}function mm(t,e,n){if(!Be(n))return!1;var s=typeof e;return(s=="number"?St(n)&&ys(e,n.length):s=="string"&&e in n)?As(n[e],t):!1}function Tm(t){return pm(function(e,n){var s=-1,r=n.length,i=r>1?n[r-1]:void 0,a=r>2?n[2]:void 0;for(i=t.length>3&&typeof i=="function"?(r--,i):void 0,a&&mm(n[0],n[1],a)&&(i=r<3?void 0:i,r=1),e=Object(e);++s<r;){var o=n[s];o&&t(e,o,s,i)}return e})}var Em=Object.prototype;function Br(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Em;return t===n}function ym(t,e){for(var n=-1,s=Array(t);++n<t;)s[n]=e(n);return s}var Am="[object Arguments]";function Hi(t){return nt(t)&&it(t)==Am}var bo=Object.prototype,Sm=bo.hasOwnProperty,Om=bo.propertyIsEnumerable,vo=Hi((function(){return arguments})())?Hi:function(t){return nt(t)&&Sm.call(t,"callee")&&!Om.call(t,"callee")};function Rm(){return!1}var _o=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Vi=_o&&typeof module=="object"&&module&&!module.nodeType&&module,Lm=Vi&&Vi.exports===_o,Yi=Lm?He.Buffer:void 0,Im=Yi?Yi.isBuffer:void 0,nr=Im||Rm,Nm="[object Arguments]",bm="[object Array]",vm="[object Boolean]",_m="[object Date]",Cm="[object Error]",km="[object Function]",wm="[object Map]",xm="[object Number]",Mm="[object Object]",$m="[object RegExp]",Pm="[object Set]",Um="[object String]",Dm="[object WeakMap]",Fm="[object ArrayBuffer]",Bm="[object DataView]",Gm="[object Float32Array]",Wm="[object Float64Array]",jm="[object Int8Array]",Km="[object Int16Array]",zm="[object Int32Array]",Hm="[object Uint8Array]",Vm="[object Uint8ClampedArray]",Ym="[object Uint16Array]",Xm="[object Uint32Array]",x={};x[Gm]=x[Wm]=x[jm]=x[Km]=x[zm]=x[Hm]=x[Vm]=x[Ym]=x[Xm]=!0;x[Nm]=x[bm]=x[Fm]=x[vm]=x[Bm]=x[_m]=x[Cm]=x[km]=x[wm]=x[xm]=x[Mm]=x[$m]=x[Pm]=x[Um]=x[Dm]=!1;function qm(t){return nt(t)&&Fr(t.length)&&!!x[it(t)]}function Co(t){return function(e){return t(e)}}var ko=typeof exports=="object"&&exports&&!exports.nodeType&&exports,nn=ko&&typeof module=="object"&&module&&!module.nodeType&&module,Jm=nn&&nn.exports===ko,Fs=Jm&&Oo.process,zn=(function(){try{var t=nn&&nn.require&&nn.require("util").types;return t||Fs&&Fs.binding&&Fs.binding("util")}catch{}})(),Xi=zn&&zn.isTypedArray,wo=Xi?Co(Xi):qm,Zm=Object.prototype,Qm=Zm.hasOwnProperty;function xo(t,e){var n=Q(t),s=!n&&vo(t),r=!n&&!s&&nr(t),i=!n&&!s&&!r&&wo(t),a=n||s||r||i,o=a?ym(t.length,String):[],c=o.length;for(var l in t)(e||Qm.call(t,l))&&!(a&&(l=="length"||r&&(l=="offset"||l=="parent")||i&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||ys(l,c)))&&o.push(l);return o}function Mo(t,e){return function(n){return t(e(n))}}var eT=Mo(Object.keys,Object),tT=Object.prototype,nT=tT.hasOwnProperty;function sT(t){if(!Br(t))return eT(t);var e=[];for(var n in Object(t))nT.call(t,n)&&n!="constructor"&&e.push(n);return e}function Tn(t){return St(t)?xo(t):sT(t)}var rT=Object.prototype,iT=rT.hasOwnProperty,Ce=Tm(function(t,e){if(Br(e)||St(e)){dm(e,Tn(e),t);return}for(var n in e)iT.call(e,n)&&Dr(t,n,e[n])});function aT(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var oT=Object.prototype,cT=oT.hasOwnProperty;function lT(t){if(!Be(t))return aT(t);var e=Br(t),n=[];for(var s in t)s=="constructor"&&(e||!cT.call(t,s))||n.push(s);return n}function hT(t){return St(t)?xo(t,!0):lT(t)}var uT=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,dT=/^\w*$/;function Gr(t,e){if(Q(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||ms(t)?!0:dT.test(t)||!uT.test(t)||e!=null&&t in Object(e)}var ln=At(Object,"create");function fT(){this.__data__=ln?ln(null):{},this.size=0}function pT(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var gT="__lodash_hash_undefined__",mT=Object.prototype,TT=mT.hasOwnProperty;function ET(t){var e=this.__data__;if(ln){var n=e[t];return n===gT?void 0:n}return TT.call(e,t)?e[t]:void 0}var yT=Object.prototype,AT=yT.hasOwnProperty;function ST(t){var e=this.__data__;return ln?e[t]!==void 0:AT.call(e,t)}var OT="__lodash_hash_undefined__";function RT(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ln&&e===void 0?OT:e,this}function pt(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}pt.prototype.clear=fT;pt.prototype.delete=pT;pt.prototype.get=ET;pt.prototype.has=ST;pt.prototype.set=RT;function LT(){this.__data__=[],this.size=0}function Ss(t,e){for(var n=t.length;n--;)if(As(t[n][0],e))return n;return-1}var IT=Array.prototype,NT=IT.splice;function bT(t){var e=this.__data__,n=Ss(e,t);if(n<0)return!1;var s=e.length-1;return n==s?e.pop():NT.call(e,n,1),--this.size,!0}function vT(t){var e=this.__data__,n=Ss(e,t);return n<0?void 0:e[n][1]}function _T(t){return Ss(this.__data__,t)>-1}function CT(t,e){var n=this.__data__,s=Ss(n,t);return s<0?(++this.size,n.push([t,e])):n[s][1]=e,this}function Ve(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}Ve.prototype.clear=LT;Ve.prototype.delete=bT;Ve.prototype.get=vT;Ve.prototype.has=_T;Ve.prototype.set=CT;var hn=At(He,"Map");function kT(){this.size=0,this.__data__={hash:new pt,map:new(hn||Ve),string:new pt}}function wT(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Os(t,e){var n=t.__data__;return wT(e)?n[typeof e=="string"?"string":"hash"]:n.map}function xT(t){var e=Os(this,t).delete(t);return this.size-=e?1:0,e}function MT(t){return Os(this,t).get(t)}function $T(t){return Os(this,t).has(t)}function PT(t,e){var n=Os(this,t),s=n.size;return n.set(t,e),this.size+=n.size==s?0:1,this}function Ye(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var s=t[e];this.set(s[0],s[1])}}Ye.prototype.clear=kT;Ye.prototype.delete=xT;Ye.prototype.get=MT;Ye.prototype.has=$T;Ye.prototype.set=PT;var UT="Expected a function";function Wr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(UT);var n=function(){var s=arguments,r=e?e.apply(this,s):s[0],i=n.cache;if(i.has(r))return i.get(r);var a=t.apply(this,s);return n.cache=i.set(r,a)||i,a};return n.cache=new(Wr.Cache||Ye),n}Wr.Cache=Ye;var DT=500;function FT(t){var e=Wr(t,function(s){return n.size===DT&&n.clear(),s}),n=e.cache;return e}var BT=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,GT=/\\(\\)?/g,WT=FT(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(BT,function(n,s,r,i){e.push(r?i.replace(GT,"$1"):s||n)}),e});function jT(t){return t==null?"":Lo(t)}function Rs(t,e){return Q(t)?t:Gr(t,e)?[t]:WT(jT(t))}function En(t){if(typeof t=="string"||ms(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function jr(t,e){e=Rs(e,t);for(var n=0,s=e.length;t!=null&&n<s;)t=t[En(e[n++])];return n&&n==s?t:void 0}function KT(t,e,n){var s=t==null?void 0:jr(t,e);return s===void 0?n:s}function $o(t,e){for(var n=-1,s=e.length,r=t.length;++n<s;)t[r+n]=e[n];return t}var zT=Mo(Object.getPrototypeOf,Object);function HT(){this.__data__=new Ve,this.size=0}function VT(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function YT(t){return this.__data__.get(t)}function XT(t){return this.__data__.has(t)}var qT=200;function JT(t,e){var n=this.__data__;if(n instanceof Ve){var s=n.__data__;if(!hn||s.length<qT-1)return s.push([t,e]),this.size=++n.size,this;n=this.__data__=new Ye(s)}return n.set(t,e),this.size=n.size,this}function De(t){var e=this.__data__=new Ve(t);this.size=e.size}De.prototype.clear=HT;De.prototype.delete=VT;De.prototype.get=YT;De.prototype.has=XT;De.prototype.set=JT;function ZT(t,e){for(var n=-1,s=t==null?0:t.length,r=0,i=[];++n<s;){var a=t[n];e(a,n,t)&&(i[r++]=a)}return i}function Po(){return[]}var QT=Object.prototype,eE=QT.propertyIsEnumerable,qi=Object.getOwnPropertySymbols,Uo=qi?function(t){return t==null?[]:(t=Object(t),ZT(qi(t),function(e){return eE.call(t,e)}))}:Po,tE=Object.getOwnPropertySymbols,nE=tE?function(t){for(var e=[];t;)$o(e,Uo(t)),t=zT(t);return e}:Po;function Do(t,e,n){var s=e(t);return Q(t)?s:$o(s,n(t))}function Ji(t){return Do(t,Tn,Uo)}function sE(t){return Do(t,hT,nE)}var sr=At(He,"DataView"),rr=At(He,"Promise"),ir=At(He,"Set"),Zi="[object Map]",rE="[object Object]",Qi="[object Promise]",ea="[object Set]",ta="[object WeakMap]",na="[object DataView]",iE=yt(sr),aE=yt(hn),oE=yt(rr),cE=yt(ir),lE=yt(tr),Ze=it;(sr&&Ze(new sr(new ArrayBuffer(1)))!=na||hn&&Ze(new hn)!=Zi||rr&&Ze(rr.resolve())!=Qi||ir&&Ze(new ir)!=ea||tr&&Ze(new tr)!=ta)&&(Ze=function(t){var e=it(t),n=e==rE?t.constructor:void 0,s=n?yt(n):"";if(s)switch(s){case iE:return na;case aE:return Zi;case oE:return Qi;case cE:return ea;case lE:return ta}return e});var sa=He.Uint8Array,hE="__lodash_hash_undefined__";function uE(t){return this.__data__.set(t,hE),this}function dE(t){return this.__data__.has(t)}function Hn(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Ye;++e<n;)this.add(t[e])}Hn.prototype.add=Hn.prototype.push=uE;Hn.prototype.has=dE;function Fo(t,e){for(var n=-1,s=t==null?0:t.length;++n<s;)if(e(t[n],n,t))return!0;return!1}function fE(t,e){return t.has(e)}var pE=1,gE=2;function Bo(t,e,n,s,r,i){var a=n&pE,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))return!1;var l=i.get(t),d=i.get(e);if(l&&d)return l==e&&d==t;var h=-1,f=!0,p=n&gE?new Hn:void 0;for(i.set(t,e),i.set(e,t);++h<o;){var g=t[h],T=e[h];if(s)var L=a?s(T,g,h,e,t,i):s(g,T,h,t,e,i);if(L!==void 0){if(L)continue;f=!1;break}if(p){if(!Fo(e,function(y,E){if(!fE(p,E)&&(g===y||r(g,y,n,s,i)))return p.push(E)})){f=!1;break}}else if(!(g===T||r(g,T,n,s,i))){f=!1;break}}return i.delete(t),i.delete(e),f}function mE(t){var e=-1,n=Array(t.size);return t.forEach(function(s,r){n[++e]=[r,s]}),n}function TE(t){var e=-1,n=Array(t.size);return t.forEach(function(s){n[++e]=s}),n}var EE=1,yE=2,AE="[object Boolean]",SE="[object Date]",OE="[object Error]",RE="[object Map]",LE="[object Number]",IE="[object RegExp]",NE="[object Set]",bE="[object String]",vE="[object Symbol]",_E="[object ArrayBuffer]",CE="[object DataView]",ra=tt?tt.prototype:void 0,Bs=ra?ra.valueOf:void 0;function kE(t,e,n,s,r,i,a){switch(n){case CE:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case _E:return!(t.byteLength!=e.byteLength||!i(new sa(t),new sa(e)));case AE:case SE:case LE:return As(+t,+e);case OE:return t.name==e.name&&t.message==e.message;case IE:case bE:return t==e+"";case RE:var o=mE;case NE:var c=s&EE;if(o||(o=TE),t.size!=e.size&&!c)return!1;var l=a.get(t);if(l)return l==e;s|=yE,a.set(t,e);var d=Bo(o(t),o(e),s,r,i,a);return a.delete(t),d;case vE:if(Bs)return Bs.call(t)==Bs.call(e)}return!1}var wE=1,xE=Object.prototype,ME=xE.hasOwnProperty;function $E(t,e,n,s,r,i){var a=n&wE,o=Ji(t),c=o.length,l=Ji(e),d=l.length;if(c!=d&&!a)return!1;for(var h=c;h--;){var f=o[h];if(!(a?f in e:ME.call(e,f)))return!1}var p=i.get(t),g=i.get(e);if(p&&g)return p==e&&g==t;var T=!0;i.set(t,e),i.set(e,t);for(var L=a;++h<c;){f=o[h];var y=t[f],E=e[f];if(s)var m=a?s(E,y,f,e,t,i):s(y,E,f,t,e,i);if(!(m===void 0?y===E||r(y,E,n,s,i):m)){T=!1;break}L||(L=f=="constructor")}if(T&&!L){var A=t.constructor,_=e.constructor;A!=_&&"constructor"in t&&"constructor"in e&&!(typeof A=="function"&&A instanceof A&&typeof _=="function"&&_ instanceof _)&&(T=!1)}return i.delete(t),i.delete(e),T}var PE=1,ia="[object Arguments]",aa="[object Array]",In="[object Object]",UE=Object.prototype,oa=UE.hasOwnProperty;function DE(t,e,n,s,r,i){var a=Q(t),o=Q(e),c=a?aa:Ze(t),l=o?aa:Ze(e);c=c==ia?In:c,l=l==ia?In:l;var d=c==In,h=l==In,f=c==l;if(f&&nr(t)){if(!nr(e))return!1;a=!0,d=!1}if(f&&!d)return i||(i=new De),a||wo(t)?Bo(t,e,n,s,r,i):kE(t,e,c,n,s,r,i);if(!(n&PE)){var p=d&&oa.call(t,"__wrapped__"),g=h&&oa.call(e,"__wrapped__");if(p||g){var T=p?t.value():t,L=g?e.value():e;return i||(i=new De),r(T,L,n,s,i)}}return f?(i||(i=new De),$E(t,e,n,s,r,i)):!1}function Kr(t,e,n,s,r){return t===e?!0:t==null||e==null||!nt(t)&&!nt(e)?t!==t&&e!==e:DE(t,e,n,s,Kr,r)}var FE=1,BE=2;function GE(t,e,n,s){var r=n.length,i=r;if(t==null)return!i;for(t=Object(t);r--;){var a=n[r];if(a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++r<i;){a=n[r];var o=a[0],c=t[o],l=a[1];if(a[2]){if(c===void 0&&!(o in t))return!1}else{var d=new De,h;if(!(h===void 0?Kr(l,c,FE|BE,s,d):h))return!1}}return!0}function Go(t){return t===t&&!Be(t)}function WE(t){for(var e=Tn(t),n=e.length;n--;){var s=e[n],r=t[s];e[n]=[s,r,Go(r)]}return e}function Wo(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function jE(t){var e=WE(t);return e.length==1&&e[0][2]?Wo(e[0][0],e[0][1]):function(n){return n===t||GE(n,t,e)}}function KE(t,e){return t!=null&&e in Object(t)}function zE(t,e,n){e=Rs(e,t);for(var s=-1,r=e.length,i=!1;++s<r;){var a=En(e[s]);if(!(i=t!=null&&n(t,a)))break;t=t[a]}return i||++s!=r?i:(r=t==null?0:t.length,!!r&&Fr(r)&&ys(a,r)&&(Q(t)||vo(t)))}function HE(t,e){return t!=null&&zE(t,e,KE)}var VE=1,YE=2;function XE(t,e){return Gr(t)&&Go(e)?Wo(En(t),e):function(n){var s=KT(n,t);return s===void 0&&s===e?HE(n,t):Kr(e,s,VE|YE)}}function qE(t){return function(e){return e==null?void 0:e[t]}}function JE(t){return function(e){return jr(e,t)}}function ZE(t){return Gr(t)?qE(En(t)):JE(t)}function Ls(t){return typeof t=="function"?t:t==null?Es:typeof t=="object"?Q(t)?XE(t[0],t[1]):jE(t):ZE(t)}function QE(t){return function(e,n,s){for(var r=-1,i=Object(e),a=s(e),o=a.length;o--;){var c=a[++r];if(n(i[c],c,i)===!1)break}return e}}var ey=QE();function ty(t,e){return t&&ey(t,e,Tn)}function ny(t,e){return function(n,s){if(n==null)return n;if(!St(n))return t(n,s);for(var r=n.length,i=-1,a=Object(n);++i<r&&s(a[i],i,a)!==!1;);return n}}var Is=ny(ty);function sy(t){return typeof t=="function"?t:Es}function ry(t,e){var n=Q(t)?sm:Is;return n(t,sy(e))}function iy(t,e){for(var n=-1,s=t==null?0:t.length;++n<s;)if(!e(t[n],n,t))return!1;return!0}function ay(t,e){var n=!0;return Is(t,function(s,r,i){return n=!!e(s,r,i),n}),n}function oy(t,e,n){var s=Q(t)?iy:ay;return s(t,Ls(e))}function cy(t,e){var n=-1,s=St(t)?Array(t.length):[];return Is(t,function(r,i,a){s[++n]=e(r,i,a)}),s}function jo(t,e){var n=Q(t)?Ts:cy;return n(t,Ls(e))}var ly="[object String]";function Vn(t){return typeof t=="string"||!Q(t)&&nt(t)&&it(t)==ly}function hy(t,e){return Ts(e,function(n){return t[n]})}function uy(t){return t==null?[]:hy(t,Tn(t))}var dy=Math.max;function fy(t,e,n,s){t=St(t)?t:uy(t),n=n?wg(n):0;var r=t.length;return n<0&&(n=dy(r+n,0)),Vn(t)?n<=r&&t.indexOf(e,n)>-1:!!r&&om(t,e,n)>-1}var py="[object RegExp]";function gy(t){return nt(t)&&it(t)==py}var ca=zn&&zn.isRegExp,my=ca?Co(ca):gy;function Ty(t,e,n,s){if(!Be(t))return t;e=Rs(e,t);for(var r=-1,i=e.length,a=i-1,o=t;o!=null&&++r<i;){var c=En(e[r]),l=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(r!=a){var d=o[c];l=void 0,l===void 0&&(l=Be(d)?d:ys(e[r+1])?[]:{})}Dr(o,c,l),o=o[c]}return t}function Ey(t,e,n){for(var s=-1,r=e.length,i={};++s<r;){var a=e[s],o=jr(t,a);n(o,a)&&Ty(i,Rs(a,t),o)}return i}function ke(t,e){if(t==null)return{};var n=Ts(sE(t),function(s){return[s]});return e=Ls(e),Ey(t,n,function(s,r){return e(s,r[0])})}function yy(t,e){var n;return Is(t,function(s,r,i){return n=e(s,r,i),!n}),!!n}function Ay(t,e,n){var s=Q(t)?Fo:yy;return s(t,Ls(e))}function Sy(t){return Oy(t)?t.LABEL:t.name}function Oy(t){return Vn(t.LABEL)&&t.LABEL!==""}class we{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),ry(this.definition,n=>{n.accept(e)})}}class se extends we{constructor(e){super([]),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class $t extends we{constructor(e){super(e.definition),this.orgText="",Ce(this,ke(e,n=>n!==void 0))}}class ee extends we{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Ce(this,ke(e,n=>n!==void 0))}}class Z extends we{constructor(e){super(e.definition),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}}class xe extends we{constructor(e){super(e.definition),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}}class Me extends we{constructor(e){super(e.definition),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}}class G extends we{constructor(e){super(e.definition),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}}class Se extends we{constructor(e){super(e.definition),this.idx=1,Ce(this,ke(e,n=>n!==void 0))}}class Oe extends we{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,Ce(this,ke(e,n=>n!==void 0))}}class ${constructor(e){this.idx=1,Ce(this,ke(e,n=>n!==void 0))}accept(e){e.visit(this)}}function Ry(t){return jo(t,kn)}function kn(t){function e(n){return jo(n,kn)}if(t instanceof se){const n={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return Vn(t.label)&&(n.label=t.label),n}else{if(t instanceof ee)return{type:"Alternative",definition:e(t.definition)};if(t instanceof Z)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof xe)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof Me)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:kn(new $({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof Se)return{type:"RepetitionWithSeparator",idx:t.idx,separator:kn(new $({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof G)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof Oe)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof $){const n={type:"Terminal",name:t.terminalType.name,label:Sy(t.terminalType),idx:t.idx};Vn(t.label)&&(n.terminalLabel=t.label);const s=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=my(s)?s.source:s),n}else{if(t instanceof $t)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}}class Pt{visit(e){const n=e;switch(n.constructor){case se:return this.visitNonTerminal(n);case ee:return this.visitAlternative(n);case Z:return this.visitOption(n);case xe:return this.visitRepetitionMandatory(n);case Me:return this.visitRepetitionMandatoryWithSeparator(n);case Se:return this.visitRepetitionWithSeparator(n);case G:return this.visitRepetition(n);case Oe:return this.visitAlternation(n);case $:return this.visitTerminal(n);case $t:return this.visitRule(n);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 Ly(t){return t instanceof ee||t instanceof Z||t instanceof G||t instanceof xe||t instanceof Me||t instanceof Se||t instanceof $||t instanceof $t}function Yn(t,e=[]){return t instanceof Z||t instanceof G||t instanceof Se?!0:t instanceof Oe?Ay(t.definition,s=>Yn(s,e)):t instanceof se&&fy(e,t)?!1:t instanceof we?(t instanceof se&&e.push(t),oy(t.definition,s=>Yn(s,e))):!1}function Iy(t){return t instanceof Oe}function Le(t){if(t instanceof se)return"SUBRULE";if(t instanceof Z)return"OPTION";if(t instanceof Oe)return"OR";if(t instanceof xe)return"AT_LEAST_ONE";if(t instanceof Me)return"AT_LEAST_ONE_SEP";if(t instanceof Se)return"MANY_SEP";if(t instanceof G)return"MANY";if(t instanceof $)return"CONSUME";throw Error("non exhaustive match")}class Ns{walk(e,n=[]){N(e.definition,(s,r)=>{const i=z(e.definition,r+1);if(s instanceof se)this.walkProdRef(s,i,n);else if(s instanceof $)this.walkTerminal(s,i,n);else if(s instanceof ee)this.walkFlat(s,i,n);else if(s instanceof Z)this.walkOption(s,i,n);else if(s instanceof xe)this.walkAtLeastOne(s,i,n);else if(s instanceof Me)this.walkAtLeastOneSep(s,i,n);else if(s instanceof Se)this.walkManySep(s,i,n);else if(s instanceof G)this.walkMany(s,i,n);else if(s instanceof Oe)this.walkOr(s,i,n);else throw Error("non exhaustive match")})}walkTerminal(e,n,s){}walkProdRef(e,n,s){}walkFlat(e,n,s){const r=n.concat(s);this.walk(e,r)}walkOption(e,n,s){const r=n.concat(s);this.walk(e,r)}walkAtLeastOne(e,n,s){const r=[new Z({definition:e.definition})].concat(n,s);this.walk(e,r)}walkAtLeastOneSep(e,n,s){const r=la(e,n,s);this.walk(e,r)}walkMany(e,n,s){const r=[new Z({definition:e.definition})].concat(n,s);this.walk(e,r)}walkManySep(e,n,s){const r=la(e,n,s);this.walk(e,r)}walkOr(e,n,s){const r=n.concat(s);N(e.definition,i=>{const a=new ee({definition:[i]});this.walk(a,r)})}}function la(t,e,n){return[new Z({definition:[new $({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}function yn(t){if(t instanceof se)return yn(t.referencedRule);if(t instanceof $)return vy(t);if(Ly(t))return Ny(t);if(Iy(t))return by(t);throw Error("non exhaustive match")}function Ny(t){let e=[];const n=t.definition;let s=0,r=n.length>s,i,a=!0;for(;r&&a;)i=n[s],a=Yn(i),e=e.concat(yn(i)),s=s+1,r=n.length>s;return Ur(e)}function by(t){const e=S(t.definition,n=>yn(n));return Ur(Te(e))}function vy(t){return[t.terminalType]}const Ko="_~IN~_";class _y extends Ns{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,n,s){}walkProdRef(e,n,s){const r=ky(e.referencedRule,e.idx)+this.topProd.name,i=n.concat(s),a=new ee({definition:i}),o=yn(a);this.follows[r]=o}}function Cy(t){const e={};return N(t,n=>{const s=new _y(n).startWalking();qs(e,s)}),e}function ky(t,e){return t.name+e+Ko}function I(t){return t.charCodeAt(0)}function Gs(t,e){Array.isArray(t)?t.forEach(function(n){e.push(n)}):e.push(t)}function Kt(t,e){if(t[e]===!0)throw"duplicate flag "+e;t[e],t[e]=!0}function Rt(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function wy(){throw Error("Internal Error - Should never get here!")}function ha(t){return t.type==="Character"}const Xn=[];for(let t=I("0");t<=I("9");t++)Xn.push(t);const qn=[I("_")].concat(Xn);for(let t=I("a");t<=I("z");t++)qn.push(t);for(let t=I("A");t<=I("Z");t++)qn.push(t);const ua=[I(" "),I("\f"),I(`
2
+ `),I("\r"),I(" "),I("\v"),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I(" "),I("\u2028"),I("\u2029"),I(" "),I(" "),I(" "),I("\uFEFF")],xy=/[0-9a-fA-F]/,Nn=/[0-9]/,My=/[1-9]/;class $y{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("/");const n=this.disjunction();this.consumeChar("/");const s={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Kt(s,"global");break;case"i":Kt(s,"ignoreCase");break;case"m":Kt(s,"multiLine");break;case"u":Kt(s,"unicode");break;case"y":Kt(s,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:s,value:n,loc:this.loc(0)}}disjunction(){const e=[],n=this.idx;for(e.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(n)}}alternative(){const e=[],n=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(n)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const 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 n;switch(this.popChar()){case"=":n="Lookahead";break;case"!":n="NegativeLookahead";break;case"<":{switch(this.popChar()){case"=":n="Lookbehind";break;case"!":n="NegativeLookbehind"}break}}Rt(n);const s=this.disjunction();return this.consumeChar(")"),{type:n,value:s,loc:this.loc(e)}}return wy()}quantifier(e=!1){let n;const s=this.idx;switch(this.popChar()){case"*":n={atLeast:0,atMost:1/0};break;case"+":n={atLeast:1,atMost:1/0};break;case"?":n={atLeast:0,atMost:1};break;case"{":const r=this.integerIncludingZero();switch(this.popChar()){case"}":n={atLeast:r,atMost:r};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),n={atLeast:r,atMost:i}):n={atLeast:r,atMost:1/0},this.consumeChar("}");break}if(e===!0&&n===void 0)return;Rt(n);break}if(!(e===!0&&n===void 0)&&Rt(n))return this.peekChar(0)==="?"?(this.consumeChar("?"),n.greedy=!1):n.greedy=!0,n.type="Quantifier",n.loc=this.loc(s),n}atom(){let e;const n=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()),Rt(e))return e.loc=this.loc(n),this.isQuantifier()&&(e.quantifier=this.quantifier()),e}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[I(`
3
+ `),I("\r"),I("\u2028"),I("\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,n=!1;switch(this.popChar()){case"d":e=Xn;break;case"D":e=Xn,n=!0;break;case"s":e=ua;break;case"S":e=ua,n=!0;break;case"w":e=qn;break;case"W":e=qn,n=!0;break}if(Rt(e))return{type:"Set",value:e,complement:n}}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=I("\f");break;case"n":e=I(`
4
+ `);break;case"r":e=I("\r");break;case"t":e=I(" ");break;case"v":e=I("\v");break}if(Rt(e))return{type:"Character",value:e}}controlLetterEscapeAtom(){this.consumeChar("c");const 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:I("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){const e=this.popChar();return{type:"Character",value:I(e)}}classPatternCharacterAtom(){switch(this.peekChar()){case`
5
+ `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:const e=this.popChar();return{type:"Character",value:I(e)}}}characterClass(){const e=[];let n=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),n=!0);this.isClassAtom();){const s=this.classAtom();if(s.type,ha(s)&&this.isRangeDash()){this.consumeChar("-");const r=this.classAtom();if(r.type,ha(r)){if(r.value<s.value)throw Error("Range out of order in character class");e.push({from:s.value,to:r.value})}else Gs(s.value,e),e.push(I("-")),Gs(r.value,e)}else Gs(s.value,e)}return this.consumeChar("]"),{type:"Set",complement:n,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:I("\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}const n=this.disjunction();this.consumeChar(")");const s={type:"Group",capturing:e,value:n};return e&&(s.idx=this.groupIdx),s}positiveInteger(){let e=this.popChar();if(My.test(e)===!1)throw Error("Expecting a positive integer");for(;Nn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Nn.test(e)===!1)throw Error("Expecting an integer");for(;Nn.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){const 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:I(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 Nn.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case`
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(){const e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
9
+ `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let n="";for(let r=0;r<e;r++){const i=this.popChar();if(xy.test(i)===!1)throw Error("Expecting a HexDecimal digits");n+=i}return{type:"Character",value:parseInt(n,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){const 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 zr{visitChildren(e){for(const n in e){const s=e[n];e.hasOwnProperty(n)&&(s.type!==void 0?this.visit(s):Array.isArray(s)&&s.forEach(r=>{this.visit(r)},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){}}let wn={};const Py=new $y;function bs(t){const e=t.toString();if(wn.hasOwnProperty(e))return wn[e];{const n=Py.pattern(e);return wn[e]=n,n}}function Uy(){wn={}}const zo="Complement Sets are not supported for first char optimization",Jn=`Unable to use "first char" lexer optimizations:
10
+ `;function Dy(t,e=!1){try{const n=bs(t);return ar(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===zo)e&&yo(`${Jn} Unable to optimize: < ${t.toString()} >
11
+ Complement Sets cannot be automatically optimized.
12
+ This will disable the lexer's first char optimizations.
13
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let s="";e&&(s=`
14
+ This will disable the lexer's first char optimizations.
15
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),er(`${Jn}
16
+ Failed parsing: < ${t.toString()} >
17
+ Using the @chevrotain/regexp-to-ast library
18
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+s)}}return[]}function ar(t,e,n){switch(t.type){case"Disjunction":for(let r=0;r<t.value.length;r++)ar(t.value[r],e,n);break;case"Alternative":const s=t.value;for(let r=0;r<s.length;r++){const i=s[r];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const a=i;switch(a.type){case"Character":bn(a.value,e,n);break;case"Set":if(a.complement===!0)throw Error(zo);N(a.value,c=>{if(typeof c=="number")bn(c,e,n);else{const l=c;if(n===!0)for(let d=l.from;d<=l.to;d++)bn(d,e,n);else{for(let d=l.from;d<=l.to&&d<Xt;d++)bn(d,e,n);if(l.to>=Xt){const d=l.from>=Xt?l.from:Xt,h=l.to,f=st(d),p=st(h);for(let g=f;g<=p;g++)e[g]=g}}}});break;case"Group":ar(a.value,e,n);break;default:throw Error("Non Exhaustive Match")}const o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type==="Group"&&or(a)===!1||a.type!=="Group"&&o===!1)break}break;default:throw Error("non exhaustive match!")}return B(e)}function bn(t,e,n){const s=st(t);e[s]=s,n===!0&&Fy(t,e)}function Fy(t,e){const n=String.fromCharCode(t),s=n.toUpperCase();if(s!==n){const r=st(s.charCodeAt(0));e[r]=r}else{const r=n.toLowerCase();if(r!==n){const i=st(r.charCodeAt(0));e[i]=i}}}function da(t,e){return Mt(t.value,n=>{if(typeof n=="number")return te(e,n);{const s=n;return Mt(e,r=>s.from<=r&&r<=s.to)!==void 0}})}function or(t){const e=t.quantifier;return e&&e.atLeast===0?!0:t.value?v(t.value)?Ne(t.value,or):or(t.value):!1}class By extends zr{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){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){te(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?da(e,this.targetCharCodes)===void 0&&(this.found=!0):da(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function Hr(t,e){if(e instanceof RegExp){const n=bs(e),s=new By(t);return s.visit(n),s.found}else return Mt(e,n=>te(t,n.charCodeAt(0)))!==void 0}const gt="PATTERN",Yt="defaultMode",vn="modes";function Gy(t,e){e=Pr(e,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
19
+ `],tracer:(E,m)=>m()});const n=e.tracer;n("initCharCodeToOptimizedIndexMap",()=>{uA()});let s;n("Reject Lexer.NA",()=>{s=gs(t,E=>E[gt]===Y.NA)});let r=!1,i;n("Transform Patterns",()=>{r=!1,i=S(s,E=>{const m=E[gt];if(et(m)){const A=m.source;return A.length===1&&A!=="^"&&A!=="$"&&A!=="."&&!m.ignoreCase?A:A.length===2&&A[0]==="\\"&&!te(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],A[1])?A[1]:fa(m)}else{if(je(m))return r=!0,{exec:m};if(typeof m=="object")return r=!0,m;if(typeof m=="string"){if(m.length===1)return m;{const A=m.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),_=new RegExp(A);return fa(_)}}else throw Error("non exhaustive match")}})});let a,o,c,l,d;n("misc mapping",()=>{a=S(s,E=>E.tokenTypeIdx),o=S(s,E=>{const m=E.GROUP;if(m!==Y.SKIPPED){if(Ae(m))return m;if(Fe(m))return!1;throw Error("non exhaustive match")}}),c=S(s,E=>{const m=E.LONGER_ALT;if(m)return v(m)?S(m,_=>Ui(s,_)):[Ui(s,m)]}),l=S(s,E=>E.PUSH_MODE),d=S(s,E=>R(E,"POP_MODE"))});let h;n("Line Terminator Handling",()=>{const E=Yo(e.lineTerminatorCharacters);h=S(s,m=>!1),e.positionTracking!=="onlyOffset"&&(h=S(s,m=>R(m,"LINE_BREAKS")?!!m.LINE_BREAKS:Vo(m,E)===!1&&Hr(E,m.PATTERN)))});let f,p,g,T;n("Misc Mapping #2",()=>{f=S(s,Ho),p=S(i,cA),g=ne(s,(E,m)=>{const A=m.GROUP;return Ae(A)&&A!==Y.SKIPPED&&(E[A]=[]),E},{}),T=S(i,(E,m)=>({pattern:i[m],longerAlt:c[m],canLineTerminator:h[m],isCustom:f[m],short:p[m],group:o[m],push:l[m],pop:d[m],tokenTypeIdx:a[m],tokenType:s[m]}))});let L=!0,y=[];return e.safeMode||n("First Char Optimization",()=>{y=ne(s,(E,m,A)=>{if(typeof m.PATTERN=="string"){const _=m.PATTERN.charCodeAt(0),pe=st(_);Ws(E,pe,T[A])}else if(v(m.START_CHARS_HINT)){let _;N(m.START_CHARS_HINT,pe=>{const Xe=typeof pe=="string"?pe.charCodeAt(0):pe,ot=st(Xe);_!==ot&&(_=ot,Ws(E,ot,T[A]))})}else if(et(m.PATTERN))if(m.PATTERN.unicode)L=!1,e.ensureOptimizations&&er(`${Jn} Unable to analyze < ${m.PATTERN.toString()} > pattern.
20
+ The regexp unicode flag is not currently supported by the regexp-to-ast library.
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{const _=Dy(m.PATTERN,e.ensureOptimizations);k(_)&&(L=!1),N(_,pe=>{Ws(E,pe,T[A])})}else e.ensureOptimizations&&er(`${Jn} TokenType: <${m.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
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`),L=!1;return E},[])}),{emptyGroups:g,patternIdxToConfig:T,charCodeToPatternIdxToConfig:y,hasCustom:r,canBeOptimized:L}}function Wy(t,e){let n=[];const s=Ky(t);n=n.concat(s.errors);const r=zy(s.valid),i=r.valid;return n=n.concat(r.errors),n=n.concat(jy(i)),n=n.concat(Qy(i)),n=n.concat(eA(i,e)),n=n.concat(tA(i)),n}function jy(t){let e=[];const n=fe(t,s=>et(s[gt]));return e=e.concat(Vy(n)),e=e.concat(qy(n)),e=e.concat(Jy(n)),e=e.concat(Zy(n)),e=e.concat(Yy(n)),e}function Ky(t){const e=fe(t,r=>!R(r,gt)),n=S(e,r=>({message:"Token Type: ->"+r.name+"<- missing static 'PATTERN' property",type:D.MISSING_PATTERN,tokenTypes:[r]})),s=ps(t,e);return{errors:n,valid:s}}function zy(t){const e=fe(t,r=>{const i=r[gt];return!et(i)&&!je(i)&&!R(i,"exec")&&!Ae(i)}),n=S(e,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:D.INVALID_PATTERN,tokenTypes:[r]})),s=ps(t,e);return{errors:n,valid:s}}const Hy=/[^\\][$]/;function Vy(t){class e extends zr{constructor(){super(...arguments),this.found=!1}visitEndAnchor(i){this.found=!0}}const n=fe(t,r=>{const i=r.PATTERN;try{const a=bs(i),o=new e;return o.visit(a),o.found}catch{return Hy.test(i.source)}});return S(n,r=>({message:`Unexpected RegExp Anchor Error:
25
+ Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
26
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:D.EOI_ANCHOR_FOUND,tokenTypes:[r]}))}function Yy(t){const e=fe(t,s=>s.PATTERN.test(""));return S(e,s=>({message:"Token Type: ->"+s.name+"<- static 'PATTERN' must not match an empty string",type:D.EMPTY_MATCH_PATTERN,tokenTypes:[s]}))}const Xy=/[^\\[][\^]|^\^/;function qy(t){class e extends zr{constructor(){super(...arguments),this.found=!1}visitStartAnchor(i){this.found=!0}}const n=fe(t,r=>{const i=r.PATTERN;try{const a=bs(i),o=new e;return o.visit(a),o.found}catch{return Xy.test(i.source)}});return S(n,r=>({message:`Unexpected RegExp Anchor Error:
27
+ Token Type: ->`+r.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
28
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:D.SOI_ANCHOR_FOUND,tokenTypes:[r]}))}function Jy(t){const e=fe(t,s=>{const r=s[gt];return r instanceof RegExp&&(r.multiline||r.global)});return S(e,s=>({message:"Token Type: ->"+s.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:D.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[s]}))}function Zy(t){const e=[];let n=S(t,i=>ne(t,(a,o)=>(i.PATTERN.source===o.PATTERN.source&&!te(e,o)&&o.PATTERN!==Y.NA&&(e.push(o),a.push(o)),a),[]));n=mn(n);const s=fe(n,i=>i.length>1);return S(s,i=>{const a=S(i,c=>c.name);return{message:`The same RegExp pattern ->${ye(i).PATTERN}<-has been used in all of the following Token Types: ${a.join(", ")} <-`,type:D.DUPLICATE_PATTERNS_FOUND,tokenTypes:i}})}function Qy(t){const e=fe(t,s=>{if(!R(s,"GROUP"))return!1;const r=s.GROUP;return r!==Y.SKIPPED&&r!==Y.NA&&!Ae(r)});return S(e,s=>({message:"Token Type: ->"+s.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:D.INVALID_GROUP_TYPE_FOUND,tokenTypes:[s]}))}function eA(t,e){const n=fe(t,r=>r.PUSH_MODE!==void 0&&!te(e,r.PUSH_MODE));return S(n,r=>({message:`Token Type: ->${r.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${r.PUSH_MODE}<-which does not exist`,type:D.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[r]}))}function tA(t){const e=[],n=ne(t,(s,r,i)=>{const a=r.PATTERN;return a===Y.NA||(Ae(a)?s.push({str:a,idx:i,tokenType:r}):et(a)&&sA(a)&&s.push({str:a.source,idx:i,tokenType:r})),s},[]);return N(t,(s,r)=>{N(n,({str:i,idx:a,tokenType:o})=>{if(r<a&&nA(i,s.PATTERN)){const c=`Token: ->${o.name}<- can never be matched.
29
+ Because it appears AFTER the Token Type ->${s.name}<-in the lexer's definition.
30
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:c,type:D.UNREACHABLE_PATTERN,tokenTypes:[s,o]})}})}),e}function nA(t,e){if(et(e)){if(rA(e))return!1;const n=e.exec(t);return n!==null&&n.index===0}else{if(je(e))return e(t,0,[],{});if(R(e,"exec"))return e.exec(t,0,[],{});if(typeof e=="string")return e===t;throw Error("non exhaustive match")}}function sA(t){return Mt([".","\\","[","]","|","^","$","(",")","?","*","+","{"],n=>t.source.indexOf(n)!==-1)===void 0}function rA(t){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(t.source)}function fa(t){const e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}function iA(t,e,n){const s=[];return R(t,Yt)||s.push({message:"A MultiMode Lexer cannot be initialized without a <"+Yt+`> property in its definition
31
+ `,type:D.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),R(t,vn)||s.push({message:"A MultiMode Lexer cannot be initialized without a <"+vn+`> property in its definition
32
+ `,type:D.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),R(t,vn)&&R(t,Yt)&&!R(t.modes,t.defaultMode)&&s.push({message:`A MultiMode Lexer cannot be initialized with a ${Yt}: <${t.defaultMode}>which does not exist
33
+ `,type:D.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),R(t,vn)&&N(t.modes,(r,i)=>{N(r,(a,o)=>{if(Fe(a))s.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${i}> at index: <${o}>
34
+ `,type:D.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if(R(a,"LONGER_ALT")){const c=v(a.LONGER_ALT)?a.LONGER_ALT:[a.LONGER_ALT];N(c,l=>{!Fe(l)&&!te(r,l)&&s.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${l.name}> on token <${a.name}> outside of mode <${i}>
35
+ `,type:D.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),s}function aA(t,e,n){const s=[];let r=!1;const i=mn(Te(B(t.modes))),a=gs(i,c=>c[gt]===Y.NA),o=Yo(n);return e&&N(a,c=>{const l=Vo(c,o);if(l!==!1){const h={message:hA(c,l),type:l.issue,tokenType:c};s.push(h)}else R(c,"LINE_BREAKS")?c.LINE_BREAKS===!0&&(r=!0):Hr(o,c.PATTERN)&&(r=!0)}),e&&!r&&s.push({message:`Warning: No LINE_BREAKS Found.
36
+ This Lexer has been defined to track line and column information,
37
+ But none of the Token Types can be identified as matching a line terminator.
38
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
39
+ for details.`,type:D.NO_LINE_BREAKS_FLAGS}),s}function oA(t){const e={},n=de(t);return N(n,s=>{const r=t[s];if(v(r))e[s]=[];else throw Error("non exhaustive match")}),e}function Ho(t){const e=t.PATTERN;if(et(e))return!1;if(je(e))return!0;if(R(e,"exec"))return!0;if(Ae(e))return!1;throw Error("non exhaustive match")}function cA(t){return Ae(t)&&t.length===1?t.charCodeAt(0):!1}const lA={test:function(t){const e=t.length;for(let n=this.lastIndex;n<e;n++){const s=t.charCodeAt(n);if(s===10)return this.lastIndex=n+1,!0;if(s===13)return t.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function Vo(t,e){if(R(t,"LINE_BREAKS"))return!1;if(et(t.PATTERN)){try{Hr(e,t.PATTERN)}catch(n){return{issue:D.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}else{if(Ae(t.PATTERN))return!1;if(Ho(t))return{issue:D.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function hA(t,e){if(e.issue===D.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
40
+ The problem is in the <${t.name}> Token Type
41
+ Root cause: ${e.errMsg}.
42
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===D.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
43
+ The problem is in the <${t.name}> Token Type
44
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}function Yo(t){return S(t,n=>Ae(n)?n.charCodeAt(0):n)}function Ws(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}const Xt=256;let xn=[];function st(t){return t<Xt?t:xn[t]}function uA(){if(k(xn)){xn=new Array(65536);for(let t=0;t<65536;t++)xn[t]=t>255?255+~~(t/255):t}}function An(t,e){const n=t.tokenTypeIdx;return n===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[n]===!0}function Zn(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}let pa=1;const Xo={};function Sn(t){const e=dA(t);fA(e),gA(e),pA(e),N(e,n=>{n.isParent=n.categoryMatches.length>0})}function dA(t){let e=H(t),n=t,s=!0;for(;s;){n=mn(Te(S(n,i=>i.CATEGORIES)));const r=ps(n,e);e=e.concat(r),k(r)?s=!1:n=r}return e}function fA(t){N(t,e=>{Jo(e)||(Xo[pa]=e,e.tokenTypeIdx=pa++),ga(e)&&!v(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),ga(e)||(e.CATEGORIES=[]),mA(e)||(e.categoryMatches=[]),TA(e)||(e.categoryMatchesMap={})})}function pA(t){N(t,e=>{e.categoryMatches=[],N(e.categoryMatchesMap,(n,s)=>{e.categoryMatches.push(Xo[s].tokenTypeIdx)})})}function gA(t){N(t,e=>{qo([],e)})}function qo(t,e){N(t,n=>{e.categoryMatchesMap[n.tokenTypeIdx]=!0}),N(e.CATEGORIES,n=>{const s=t.concat(e);te(s,n)||qo(s,n)})}function Jo(t){return R(t,"tokenTypeIdx")}function ga(t){return R(t,"CATEGORIES")}function mA(t){return R(t,"categoryMatches")}function TA(t){return R(t,"categoryMatchesMap")}function EA(t){return R(t,"tokenTypeIdx")}const yA={buildUnableToPopLexerModeMessage(t){return`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(t,e,n,s,r,i){return`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${n} characters.`}};var D;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(D||(D={}));const qt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
45
+ `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:yA,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(qt);class Y{constructor(e,n=qt){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(r,i)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;const a=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${a}--> <${r}>`);const{time:o,value:c}=Ao(i),l=o>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&l(`${a}<-- <${r}> time: ${o}ms`),this.traceInitIndent--,c}else return i()},typeof n=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
46
+ a boolean 2nd argument is no longer supported`);this.config=qs({},qt,n);const s=this.config.traceInitPerf;s===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof s=="number"&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let r,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===qt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=lA;else if(this.config.lineTerminatorCharacters===qt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
47
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(n.safeMode&&n.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),v(e)?r={modes:{defaultMode:H(e)},defaultMode:Yt}:(i=!1,r=H(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(iA(r,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(aA(r,this.trackStartLines,this.config.lineTerminatorCharacters))})),r.modes=r.modes?r.modes:{},N(r.modes,(o,c)=>{r.modes[c]=gs(o,l=>Fe(l))});const a=de(r.modes);if(N(r.modes,(o,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Wy(o,a))}),k(this.lexerDefinitionErrors)){Sn(o);let l;this.TRACE_INIT("analyzeTokenTypes",()=>{l=Gy(o,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:n.positionTracking,ensureOptimizations:n.ensureOptimizations,safeMode:n.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=l.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=l.charCodeToPatternIdxToConfig,this.emptyGroups=qs({},this.emptyGroups,l.emptyGroups),this.hasCustom=l.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=l.canBeOptimized}})}),this.defaultMode=r.defaultMode,!k(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const c=S(this.lexerDefinitionErrors,l=>l.message).join(`-----------------------
48
+ `);throw new Error(`Errors detected in definition of Lexer:
49
+ `+c)}N(this.lexerDefinitionWarning,o=>{yo(o.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=W),this.trackStartLines===!1&&(this.computeNewColumn=un),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=W),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const o=ne(this.canModeBeOptimized,(c,l,d)=>(l===!1&&c.push(d),c),[]);if(n.ensureOptimizations&&!k(o))throw Error(`Lexer Modes: < ${o.join(", ")} > cannot be optimized.
50
+ Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
51
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Uy()}),this.TRACE_INIT("toFastProperties",()=>{So(this)})})}tokenize(e,n=this.defaultMode){if(!k(this.lexerDefinitionErrors)){const r=S(this.lexerDefinitionErrors,i=>i.message).join(`-----------------------
52
+ `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
53
+ `+r)}return this.tokenizeInternal(e,n)}tokenizeInternal(e,n){let s,r,i,a,o,c,l,d,h,f,p,g,T,L,y;const E=e,m=E.length;let A=0,_=0;const pe=this.hasCustom?0:Math.floor(e.length/10),Xe=new Array(pe),ot=[];let Ut=this.trackStartLines?1:void 0,Re=this.trackStartLines?1:void 0;const Dt=oA(this.emptyGroups),ul=this.trackStartLines,ws=this.config.lineTerminatorsPattern;let Rn=0,qe=[],Ft=[];const Bt=[],ni=[];Object.freeze(ni);let Gt=!1;const dl=J=>{if(Bt.length===1&&J.tokenType.PUSH_MODE===void 0){const re=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(J);ot.push({offset:J.startOffset,line:J.startLine,column:J.startColumn,length:J.image.length,message:re})}else{Bt.pop();const re=ft(Bt);qe=this.patternIdxToConfig[re],Ft=this.charCodeToPatternIdxToConfig[re],Rn=qe.length;const xs=this.canModeBeOptimized[re]&&this.config.safeMode===!1;Ft&&xs?Gt=!0:Gt=!1}};function si(J){Bt.push(J),Ft=this.charCodeToPatternIdxToConfig[J],qe=this.patternIdxToConfig[J],Rn=qe.length,Rn=qe.length;const re=this.canModeBeOptimized[J]&&this.config.safeMode===!1;Ft&&re?Gt=!0:Gt=!1}si.call(this,n);let ge;const ri=this.config.recoveryEnabled;for(;A<m;){c=null,h=-1;const J=E.charCodeAt(A);let re;if(Gt){const X=st(J),ie=Ft[X];re=ie!==void 0?ie:ni}else re=qe;const xs=re.length;for(s=0;s<xs;s++){ge=re[s];const X=ge.pattern;l=null;const ie=ge.short;if(ie!==!1?J===ie&&(h=1,c=X):ge.isCustom===!0?(y=X.exec(E,A,Xe,Dt),y!==null?(c=y[0],h=c.length,y.payload!==void 0&&(l=y.payload)):c=null):(X.lastIndex=A,h=this.matchLength(X,e,A)),h!==-1){if(o=ge.longerAlt,o!==void 0){c=e.substring(A,A+h);const Je=o.length;for(i=0;i<Je;i++){const $e=qe[o[i]],ct=$e.pattern;if(d=null,$e.isCustom===!0?(y=ct.exec(E,A,Xe,Dt),y!==null?(a=y[0],y.payload!==void 0&&(d=y.payload)):a=null):(ct.lastIndex=A,a=this.match(ct,e,A)),a&&a.length>c.length){c=a,h=a.length,l=d,ge=$e;break}}}break}}if(h!==-1){if(f=ge.group,f!==void 0&&(c=c!==null?c:e.substring(A,A+h),p=ge.tokenTypeIdx,g=this.createTokenInstance(c,A,p,ge.tokenType,Ut,Re,h),this.handlePayload(g,l),f===!1?_=this.addToken(Xe,_,g):Dt[f].push(g)),ul===!0&&ge.canLineTerminator===!0){let X=0,ie,Je;ws.lastIndex=0;do c=c!==null?c:e.substring(A,A+h),ie=ws.test(c),ie===!0&&(Je=ws.lastIndex-1,X++);while(ie===!0);X!==0?(Ut=Ut+X,Re=h-Je,this.updateTokenEndLineColumnLocation(g,f,Je,X,Ut,Re,h)):Re=this.computeNewColumn(Re,h)}else Re=this.computeNewColumn(Re,h);A=A+h,this.handleModes(ge,dl,si,g)}else{const X=A,ie=Ut,Je=Re;let $e=ri===!1;for(;$e===!1&&A<m;)for(A++,r=0;r<Rn;r++){const ct=qe[r],Ms=ct.pattern,ii=ct.short;if(ii!==!1?E.charCodeAt(A)===ii&&($e=!0):ct.isCustom===!0?$e=Ms.exec(E,A,Xe,Dt)!==null:(Ms.lastIndex=A,$e=Ms.exec(e)!==null),$e===!0)break}if(T=A-X,Re=this.computeNewColumn(Re,T),L=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(E,X,T,ie,Je,ft(Bt)),ot.push({offset:X,line:ie,column:Je,length:T,message:L}),ri===!1)break}}return this.hasCustom||(Xe.length=_),{tokens:Xe,groups:Dt,errors:ot}}handleModes(e,n,s,r){if(e.pop===!0){const i=e.push;n(r),i!==void 0&&s.call(this,i)}else e.push!==void 0&&s.call(this,e.push)}updateTokenEndLineColumnLocation(e,n,s,r,i,a,o){let c,l;n!==void 0&&(c=s===o-1,l=c?-1:0,r===1&&c===!0||(e.endLine=i+l,e.endColumn=a-1+-l))}computeNewColumn(e,n){return e+n}createOffsetOnlyToken(e,n,s,r){return{image:e,startOffset:n,tokenTypeIdx:s,tokenType:r}}createStartOnlyToken(e,n,s,r,i,a){return{image:e,startOffset:n,startLine:i,startColumn:a,tokenTypeIdx:s,tokenType:r}}createFullToken(e,n,s,r,i,a,o){return{image:e,startOffset:n,endOffset:n+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:s,tokenType:r}}addTokenUsingPush(e,n,s){return e.push(s),n}addTokenUsingMemberAccess(e,n,s){return e[n]=s,n++,n}handlePayloadNoCustom(e,n){}handlePayloadWithCustom(e,n){n!==null&&(e.payload=n)}match(e,n,s){return e.test(n)===!0?n.substring(s,e.lastIndex):null}matchLength(e,n,s){return e.test(n)===!0?e.lastIndex-s:-1}}Y.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.";Y.NA=/NOT_APPLICABLE/;function sn(t){return Zo(t)?t.LABEL:t.name}function Zo(t){return Ae(t.LABEL)&&t.LABEL!==""}const AA="parent",ma="categories",Ta="label",Ea="group",ya="push_mode",Aa="pop_mode",Sa="longer_alt",Oa="line_breaks",Ra="start_chars_hint";function O(t){return SA(t)}function SA(t){const e=t.pattern,n={};if(n.name=t.name,Fe(e)||(n.PATTERN=e),R(t,AA))throw`The parent property is no longer supported.
54
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return R(t,ma)&&(n.CATEGORIES=t[ma]),Sn([n]),R(t,Ta)&&(n.LABEL=t[Ta]),R(t,Ea)&&(n.GROUP=t[Ea]),R(t,Aa)&&(n.POP_MODE=t[Aa]),R(t,ya)&&(n.PUSH_MODE=t[ya]),R(t,Sa)&&(n.LONGER_ALT=t[Sa]),R(t,Oa)&&(n.LINE_BREAKS=t[Oa]),R(t,Ra)&&(n.START_CHARS_HINT=t[Ra]),n}const Ge=O({name:"EOF",pattern:Y.NA});Sn([Ge]);function Vr(t,e,n,s,r,i,a,o){return{image:e,startOffset:n,endOffset:s,startLine:r,endLine:i,startColumn:a,endColumn:o,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function Qo(t,e){return An(t,e)}const ec={buildMismatchTokenMessage({expected:t,actual:e,previous:n,ruleName:s}){return`Expecting ${Zo(t)?`--> ${sn(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${e.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:t,ruleName:e}){return"Redundant input, expecting EOF but found: "+t.image},buildNoViableAltMessage({expectedPathsPerAlt:t,actual:e,previous:n,customUserDescription:s,ruleName:r}){const i="Expecting: ",o=`
55
+ but found: '`+ye(e).image+"'";if(s)return i+s+o;{const c=ne(t,(f,p)=>f.concat(p),[]),l=S(c,f=>`[${S(f,p=>sn(p)).join(", ")}]`),h=`one of these possible Token sequences:
56
+ ${S(l,(f,p)=>` ${p+1}. ${f}`).join(`
57
+ `)}`;return i+h+o}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:n,ruleName:s}){const r="Expecting: ",a=`
58
+ but found: '`+ye(e).image+"'";if(n)return r+n+a;{const c=`expecting at least one iteration which starts with one of these possible Token sequences::
59
+ <${S(t,l=>`[${S(l,d=>sn(d)).join(",")}]`).join(" ,")}>`;return r+c+a}}};Object.freeze(ec);const OA={buildRuleNotFoundError(t,e){return"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
60
+ inside top level rule: ->`+t.name+"<-"}},ut={buildDuplicateFoundError(t,e){function n(d){return d instanceof $?d.terminalType.name:d instanceof se?d.nonTerminalName:""}const s=t.name,r=ye(e),i=r.idx,a=Le(r),o=n(r),c=i>0;let l=`->${a}${c?i:""}<- ${o?`with argument: ->${o}<-`:""}
61
+ appears more than once (${e.length} times) in the top level rule: ->${s}<-.
62
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
63
+ `;return l=l.replace(/[ \t]+/g," "),l=l.replace(/\s\s+/g,`
64
+ `),l},buildNamespaceConflictError(t){return`Namespace conflict found in grammar.
65
+ The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.name}>.
66
+ To resolve this make sure each Terminal and Non-Terminal names are unique
67
+ This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
68
+ and Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(t){const e=S(t.prefixPath,r=>sn(r)).join(", "),n=t.alternation.idx===0?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix
69
+ in <OR${n}> inside <${t.topLevelRule.name}> Rule,
70
+ <${e}> may appears as a prefix path in all these alternatives.
71
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
72
+ For Further details.`},buildAlternationAmbiguityError(t){const e=t.alternation.idx===0?"":t.alternation.idx,n=t.prefixPath.length===0;let s=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${t.topLevelRule.name}> Rule,
73
+ `;if(n)s+=`These alternatives are all empty (match no tokens), making them indistinguishable.
74
+ Only the last alternative may be empty.
75
+ `;else{const r=S(t.prefixPath,i=>sn(i)).join(", ");s+=`<${r}> may appears as a prefix path in all these alternatives.
76
+ `}return s+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
77
+ For Further details.`,s},buildEmptyRepetitionError(t){let e=Le(t.repetition);return t.repetition.idx!==0&&(e+=t.repetition.idx),`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
78
+ This could lead to an infinite loop.`},buildTokenNameError(t){return"deprecated"},buildEmptyAlternationError(t){return`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
79
+ Only the last alternative may be an empty alternative.`},buildTooManyAlternativesError(t){return`An Alternation cannot have more than 256 alternatives:
80
+ <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
81
+ has ${t.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(t){const e=t.topLevelRule.name,n=S(t.leftRecursionPath,i=>i.name),s=`${e} --> ${n.concat([e]).join(" --> ")}`;return`Left Recursion found in grammar.
82
+ rule: <${e}> can be invoked from itself (directly or indirectly)
83
+ without consuming any Tokens. The grammar path that causes this is:
84
+ ${s}
85
+ To fix this refactor your grammar to remove the left recursion.
86
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(t){return"deprecated"},buildDuplicateRuleNameError(t){let e;return t.topLevelRule instanceof $t?e=t.topLevelRule.name:e=t.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};function RA(t,e){const n=new LA(t,e);return n.resolveRefs(),n.errors}class LA extends Pt{constructor(e,n){super(),this.nameToTopRule=e,this.errMsgProvider=n,this.errors=[]}resolveRefs(){N(B(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const n=this.nameToTopRule[e.nonTerminalName];if(n)e.referencedRule=n;else{const s=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:s,type:q.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class IA extends Ns{constructor(e,n){super(),this.topProd=e,this.path=n,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=H(this.path.ruleStack).reverse(),this.occurrenceStack=H(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,n=[]){this.found||super.walk(e,n)}walkProdRef(e,n,s){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const r=n.concat(s);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){k(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class NA extends IA{constructor(e,n){super(e,n),this.path=n,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,n,s){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const r=n.concat(s),i=new ee({definition:r});this.possibleTokTypes=yn(i),this.found=!0}}}class vs extends Ns{constructor(e,n){super(),this.topRule=e,this.occurrence=n,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class bA extends vs{walkMany(e,n,s){if(e.idx===this.occurrence){const r=ye(n.concat(s));this.result.isEndOfRule=r===void 0,r instanceof $&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkMany(e,n,s)}}class La extends vs{walkManySep(e,n,s){if(e.idx===this.occurrence){const r=ye(n.concat(s));this.result.isEndOfRule=r===void 0,r instanceof $&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkManySep(e,n,s)}}class vA extends vs{walkAtLeastOne(e,n,s){if(e.idx===this.occurrence){const r=ye(n.concat(s));this.result.isEndOfRule=r===void 0,r instanceof $&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkAtLeastOne(e,n,s)}}class Ia extends vs{walkAtLeastOneSep(e,n,s){if(e.idx===this.occurrence){const r=ye(n.concat(s));this.result.isEndOfRule=r===void 0,r instanceof $&&(this.result.token=r.terminalType,this.result.occurrence=r.idx)}else super.walkAtLeastOneSep(e,n,s)}}function cr(t,e,n=[]){n=H(n);let s=[],r=0;function i(o){return o.concat(z(t,r+1))}function a(o){const c=cr(i(o),e,n);return s.concat(c)}for(;n.length<e&&r<t.length;){const o=t[r];if(o instanceof ee)return a(o.definition);if(o instanceof se)return a(o.definition);if(o instanceof Z)s=a(o.definition);else if(o instanceof xe){const c=o.definition.concat([new G({definition:o.definition})]);return a(c)}else if(o instanceof Me){const c=[new ee({definition:o.definition}),new G({definition:[new $({terminalType:o.separator})].concat(o.definition)})];return a(c)}else if(o instanceof Se){const c=o.definition.concat([new G({definition:[new $({terminalType:o.separator})].concat(o.definition)})]);s=a(c)}else if(o instanceof G){const c=o.definition.concat([new G({definition:o.definition})]);s=a(c)}else{if(o instanceof Oe)return N(o.definition,c=>{k(c.definition)===!1&&(s=a(c.definition))}),s;if(o instanceof $)n.push(o.terminalType);else throw Error("non exhaustive match")}r++}return s.push({partialPath:n,suffixDef:z(t,r)}),s}function tc(t,e,n,s){const r="EXIT_NONE_TERMINAL",i=[r],a="EXIT_ALTERNATIVE";let o=!1;const c=e.length,l=c-s-1,d=[],h=[];for(h.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!k(h);){const f=h.pop();if(f===a){o&&ft(h).idx<=l&&h.pop();continue}const p=f.def,g=f.idx,T=f.ruleStack,L=f.occurrenceStack;if(k(p))continue;const y=p[0];if(y===r){const E={idx:g,def:z(p),ruleStack:cn(T),occurrenceStack:cn(L)};h.push(E)}else if(y instanceof $)if(g<c-1){const E=g+1,m=e[E];if(n(m,y.terminalType)){const A={idx:E,def:z(p),ruleStack:T,occurrenceStack:L};h.push(A)}}else if(g===c-1)d.push({nextTokenType:y.terminalType,nextTokenOccurrence:y.idx,ruleStack:T,occurrenceStack:L}),o=!0;else throw Error("non exhaustive match");else if(y instanceof se){const E=H(T);E.push(y.nonTerminalName);const m=H(L);m.push(y.idx);const A={idx:g,def:y.definition.concat(i,z(p)),ruleStack:E,occurrenceStack:m};h.push(A)}else if(y instanceof Z){const E={idx:g,def:z(p),ruleStack:T,occurrenceStack:L};h.push(E),h.push(a);const m={idx:g,def:y.definition.concat(z(p)),ruleStack:T,occurrenceStack:L};h.push(m)}else if(y instanceof xe){const E=new G({definition:y.definition,idx:y.idx}),m=y.definition.concat([E],z(p)),A={idx:g,def:m,ruleStack:T,occurrenceStack:L};h.push(A)}else if(y instanceof Me){const E=new $({terminalType:y.separator}),m=new G({definition:[E].concat(y.definition),idx:y.idx}),A=y.definition.concat([m],z(p)),_={idx:g,def:A,ruleStack:T,occurrenceStack:L};h.push(_)}else if(y instanceof Se){const E={idx:g,def:z(p),ruleStack:T,occurrenceStack:L};h.push(E),h.push(a);const m=new $({terminalType:y.separator}),A=new G({definition:[m].concat(y.definition),idx:y.idx}),_=y.definition.concat([A],z(p)),pe={idx:g,def:_,ruleStack:T,occurrenceStack:L};h.push(pe)}else if(y instanceof G){const E={idx:g,def:z(p),ruleStack:T,occurrenceStack:L};h.push(E),h.push(a);const m=new G({definition:y.definition,idx:y.idx}),A=y.definition.concat([m],z(p)),_={idx:g,def:A,ruleStack:T,occurrenceStack:L};h.push(_)}else if(y instanceof Oe)for(let E=y.definition.length-1;E>=0;E--){const m=y.definition[E],A={idx:g,def:m.definition.concat(z(p)),ruleStack:T,occurrenceStack:L};h.push(A),h.push(a)}else if(y instanceof ee)h.push({idx:g,def:y.definition.concat(z(p)),ruleStack:T,occurrenceStack:L});else if(y instanceof $t)h.push(_A(y,g,T,L));else throw Error("non exhaustive match")}return d}function _A(t,e,n,s){const r=H(n);r.push(t.name);const i=H(s);return i.push(1),{idx:e,def:t.definition,ruleStack:r,occurrenceStack:i}}var U;(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(U||(U={}));function nc(t){if(t instanceof Z||t==="Option")return U.OPTION;if(t instanceof G||t==="Repetition")return U.REPETITION;if(t instanceof xe||t==="RepetitionMandatory")return U.REPETITION_MANDATORY;if(t instanceof Me||t==="RepetitionMandatoryWithSeparator")return U.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof Se||t==="RepetitionWithSeparator")return U.REPETITION_WITH_SEPARATOR;if(t instanceof Oe||t==="Alternation")return U.ALTERNATION;throw Error("non exhaustive match")}function CA(t,e,n,s,r,i){const a=Yr(t,e,n),o=ic(a)?Zn:An;return i(a,s,o,r)}function kA(t,e,n,s,r,i){const a=Xr(t,e,r,n),o=ic(a)?Zn:An;return i(a[0],o,s)}function wA(t,e,n,s){const r=t.length,i=Ne(t,a=>Ne(a,o=>o.length===1));if(e)return function(a){const o=S(a,c=>c.GATE);for(let c=0;c<r;c++){const l=t[c],d=l.length,h=o[c];if(!(h!==void 0&&h.call(this)===!1))e:for(let f=0;f<d;f++){const p=l[f],g=p.length;for(let T=0;T<g;T++){const L=this.LA(T+1);if(n(L,p[T])===!1)continue e}return c}}};if(i&&!s){const a=S(t,c=>Te(c)),o=ne(a,(c,l,d)=>(N(l,h=>{R(c,h.tokenTypeIdx)||(c[h.tokenTypeIdx]=d),N(h.categoryMatches,f=>{R(c,f)||(c[f]=d)})}),c),{});return function(){const c=this.LA(1);return o[c.tokenTypeIdx]}}else return function(){for(let a=0;a<r;a++){const o=t[a],c=o.length;e:for(let l=0;l<c;l++){const d=o[l],h=d.length;for(let f=0;f<h;f++){const p=this.LA(f+1);if(n(p,d[f])===!1)continue e}return a}}}}function xA(t,e,n){const s=Ne(t,i=>i.length===1),r=t.length;if(s&&!n){const i=Te(t);if(i.length===1&&k(i[0].categoryMatches)){const o=i[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===o}}else{const a=ne(i,(o,c,l)=>(o[c.tokenTypeIdx]=!0,N(c.categoryMatches,d=>{o[d]=!0}),o),[]);return function(){const o=this.LA(1);return a[o.tokenTypeIdx]===!0}}}else return function(){e:for(let i=0;i<r;i++){const a=t[i],o=a.length;for(let c=0;c<o;c++){const l=this.LA(c+1);if(e(l,a[c])===!1)continue e}return!0}return!1}}class MA extends Ns{constructor(e,n,s){super(),this.topProd=e,this.targetOccurrence=n,this.targetProdType=s}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,n,s,r){return e.idx===this.targetOccurrence&&this.targetProdType===n?(this.restDef=s.concat(r),!0):!1}walkOption(e,n,s){this.checkIsTarget(e,U.OPTION,n,s)||super.walkOption(e,n,s)}walkAtLeastOne(e,n,s){this.checkIsTarget(e,U.REPETITION_MANDATORY,n,s)||super.walkOption(e,n,s)}walkAtLeastOneSep(e,n,s){this.checkIsTarget(e,U.REPETITION_MANDATORY_WITH_SEPARATOR,n,s)||super.walkOption(e,n,s)}walkMany(e,n,s){this.checkIsTarget(e,U.REPETITION,n,s)||super.walkOption(e,n,s)}walkManySep(e,n,s){this.checkIsTarget(e,U.REPETITION_WITH_SEPARATOR,n,s)||super.walkOption(e,n,s)}}class sc extends Pt{constructor(e,n,s){super(),this.targetOccurrence=e,this.targetProdType=n,this.targetRef=s,this.result=[]}checkIsTarget(e,n){e.idx===this.targetOccurrence&&this.targetProdType===n&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,U.OPTION)}visitRepetition(e){this.checkIsTarget(e,U.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,U.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,U.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,U.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,U.ALTERNATION)}}function Na(t){const e=new Array(t);for(let n=0;n<t;n++)e[n]=[];return e}function js(t){let e=[""];for(let n=0;n<t.length;n++){const s=t[n],r=[];for(let i=0;i<e.length;i++){const a=e[i];r.push(a+"_"+s.tokenTypeIdx);for(let o=0;o<s.categoryMatches.length;o++){const c="_"+s.categoryMatches[o];r.push(a+c)}}e=r}return e}function $A(t,e,n){for(let s=0;s<t.length;s++){if(s===n)continue;const r=t[s];for(let i=0;i<e.length;i++){const a=e[i];if(r[a]===!0)return!1}}return!0}function rc(t,e){const n=S(t,a=>cr([a],1)),s=Na(n.length),r=S(n,a=>{const o={};return N(a,c=>{const l=js(c.partialPath);N(l,d=>{o[d]=!0})}),o});let i=n;for(let a=1;a<=e;a++){const o=i;i=Na(o.length);for(let c=0;c<o.length;c++){const l=o[c];for(let d=0;d<l.length;d++){const h=l[d].partialPath,f=l[d].suffixDef,p=js(h);if($A(r,p,c)||k(f)||h.length===e){const T=s[c];if(lr(T,h)===!1){T.push(h);for(let L=0;L<p.length;L++){const y=p[L];r[c][y]=!0}}}else{const T=cr(f,a+1,h);i[c]=i[c].concat(T),N(T,L=>{const y=js(L.partialPath);N(y,E=>{r[c][E]=!0})})}}}}return s}function Yr(t,e,n,s){const r=new sc(t,U.ALTERNATION,s);return e.accept(r),rc(r.result,n)}function Xr(t,e,n,s){const r=new sc(t,n);e.accept(r);const i=r.result,o=new MA(e,t,n).startWalking(),c=new ee({definition:i}),l=new ee({definition:o});return rc([c,l],s)}function lr(t,e){e:for(let n=0;n<t.length;n++){const s=t[n];if(s.length===e.length){for(let r=0;r<s.length;r++){const i=e[r],a=s[r];if((i===a||a.categoryMatchesMap[i.tokenTypeIdx]!==void 0)===!1)continue e}return!0}}return!1}function PA(t,e){return t.length<e.length&&Ne(t,(n,s)=>{const r=e[s];return n===r||r.categoryMatchesMap[n.tokenTypeIdx]})}function ic(t){return Ne(t,e=>Ne(e,n=>Ne(n,s=>k(s.categoryMatches))))}function UA(t){const e=t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName});return S(e,n=>Object.assign({type:q.CUSTOM_LOOKAHEAD_VALIDATION},n))}function DA(t,e,n,s){const r=le(t,c=>FA(c,n)),i=JA(t,e,n),a=le(t,c=>VA(c,n)),o=le(t,c=>WA(c,t,s,n));return r.concat(i,a,o)}function FA(t,e){const n=new GA;t.accept(n);const s=n.allProductions,r=Bp(s,BA),i=sg(r,o=>o.length>1);return S(B(i),o=>{const c=ye(o),l=e.buildDuplicateFoundError(t,o),d=Le(c),h={message:l,type:q.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:d,occurrence:c.idx},f=ac(c);return f&&(h.parameter=f),h})}function BA(t){return`${Le(t)}_#_${t.idx}_#_${ac(t)}`}function ac(t){return t instanceof $?t.terminalType.name:t instanceof se?t.nonTerminalName:""}class GA extends Pt{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 WA(t,e,n,s){const r=[];if(ne(e,(a,o)=>o.name===t.name?a+1:a,0)>1){const a=s.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});r.push({message:a,type:q.DUPLICATE_RULE_NAME,ruleName:t.name})}return r}function jA(t,e,n){const s=[];let r;return te(e,t)||(r=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,s.push({message:r,type:q.INVALID_RULE_OVERRIDE,ruleName:t})),s}function oc(t,e,n,s=[]){const r=[],i=Mn(e.definition);if(k(i))return[];{const a=t.name;te(i,t)&&r.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:s}),type:q.LEFT_RECURSION,ruleName:a});const c=ps(i,s.concat([t])),l=le(c,d=>{const h=H(s);return h.push(d),oc(t,d,n,h)});return r.concat(l)}}function Mn(t){let e=[];if(k(t))return e;const n=ye(t);if(n instanceof se)e.push(n.referencedRule);else if(n instanceof ee||n instanceof Z||n instanceof xe||n instanceof Me||n instanceof Se||n instanceof G)e=e.concat(Mn(n.definition));else if(n instanceof Oe)e=Te(S(n.definition,i=>Mn(i.definition)));else if(!(n instanceof $))throw Error("non exhaustive match");const s=Yn(n),r=t.length>1;if(s&&r){const i=z(t);return e.concat(Mn(i))}else return e}class qr extends Pt{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function KA(t,e){const n=new qr;t.accept(n);const s=n.alternations;return le(s,i=>{const a=cn(i.definition);return le(a,(o,c)=>{const l=tc([o],[],An,1);return k(l)?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:i,emptyChoiceIdx:c}),type:q.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:i.idx,alternative:c+1}]:[]})})}function zA(t,e,n){const s=new qr;t.accept(s);let r=s.alternations;return r=gs(r,a=>a.ignoreAmbiguities===!0),le(r,a=>{const o=a.idx,c=a.maxLookahead||e,l=Yr(o,t,c,a),d=XA(l,a,t,n),h=qA(l,a,t,n);return d.concat(h)})}class HA extends Pt{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 VA(t,e){const n=new qr;t.accept(n);const s=n.alternations;return le(s,i=>i.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:i}),type:q.TOO_MANY_ALTS,ruleName:t.name,occurrence:i.idx}]:[])}function YA(t,e,n){const s=[];return N(t,r=>{const i=new HA;r.accept(i);const a=i.allProductions;N(a,o=>{const c=nc(o),l=o.maxLookahead||e,d=o.idx,f=Xr(d,r,c,l)[0];if(k(Te(f))){const p=n.buildEmptyRepetitionError({topLevelRule:r,repetition:o});s.push({message:p,type:q.NO_NON_EMPTY_LOOKAHEAD,ruleName:r.name})}})}),s}function XA(t,e,n,s){const r=[],i=ne(t,(o,c,l)=>(e.definition[l].ignoreAmbiguities===!0||N(c,d=>{const h=[l];N(t,(f,p)=>{l!==p&&lr(f,d)&&e.definition[p].ignoreAmbiguities!==!0&&h.push(p)}),h.length>1&&!lr(r,d)&&(r.push(d),o.push({alts:h,path:d}))}),o),[]);return S(i,o=>{const c=S(o.alts,d=>d+1);return{message:s.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:c,prefixPath:o.path}),type:q.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:o.alts}})}function qA(t,e,n,s){const r=ne(t,(a,o,c)=>{const l=S(o,d=>({idx:c,path:d}));return a.concat(l)},[]);return mn(le(r,a=>{if(e.definition[a.idx].ignoreAmbiguities===!0)return[];const c=a.idx,l=a.path,d=fe(r,f=>e.definition[f.idx].ignoreAmbiguities!==!0&&f.idx<c&&PA(f.path,l));return S(d,f=>{const p=[f.idx+1,c+1],g=e.idx===0?"":e.idx;return{message:s.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:p,prefixPath:f.path}),type:q.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:g,alternatives:p}})}))}function JA(t,e,n){const s=[],r=S(e,i=>i.name);return N(t,i=>{const a=i.name;if(te(r,a)){const o=n.buildNamespaceConflictError(i);s.push({message:o,type:q.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:a})}}),s}function ZA(t){const e=Pr(t,{errMsgProvider:OA}),n={};return N(t.rules,s=>{n[s.name]=s}),RA(n,e.errMsgProvider)}function QA(t){return t=Pr(t,{errMsgProvider:ut}),DA(t.rules,t.tokenTypes,t.errMsgProvider,t.grammarName)}const cc="MismatchedTokenException",lc="NoViableAltException",hc="EarlyExitException",uc="NotAllInputParsedException",dc=[cc,lc,hc,uc];Object.freeze(dc);function Qn(t){return te(dc,t.name)}class _s extends Error{constructor(e,n){super(e),this.token=n,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class fc extends _s{constructor(e,n,s){super(e,n),this.previousToken=s,this.name=cc}}class eS extends _s{constructor(e,n,s){super(e,n),this.previousToken=s,this.name=lc}}class tS extends _s{constructor(e,n){super(e,n),this.name=uc}}class nS extends _s{constructor(e,n,s){super(e,n),this.previousToken=s,this.name=hc}}const Ks={},pc="InRuleRecoveryException";class sS extends Error{constructor(e){super(e),this.name=pc}}class rS{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=R(e,"recoveryEnabled")?e.recoveryEnabled:We.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=iS)}getTokenToInsert(e){const n=Vr(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return n.isInsertedInRecovery=!0,n}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,n,s,r){const i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[];let c=!1;const l=this.LA(1);let d=this.LA(1);const h=()=>{const f=this.LA(0),p=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:l,previous:f,ruleName:this.getCurrRuleFullName()}),g=new fc(p,l,this.LA(0));g.resyncedTokens=cn(o),this.SAVE_ERROR(g)};for(;!c;)if(this.tokenMatcher(d,r)){h();return}else if(s.call(this)){h(),e.apply(this,n);return}else this.tokenMatcher(d,i)?c=!0:(d=this.SKIP_TOKEN(),this.addToResyncTokens(d,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,n,s){return!(s===!1||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,n)))}getFollowsForInRuleRecovery(e,n){const s=this.getCurrentGrammarPath(e,n);return this.getNextPossibleTokenTypes(s)}tryInRuleRecovery(e,n){if(this.canRecoverWithSingleTokenInsertion(e,n))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){const s=this.SKIP_TOKEN();return this.consumeToken(),s}throw new sS("sad sad panda")}canPerformInRuleRecovery(e,n){return this.canRecoverWithSingleTokenInsertion(e,n)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,n){if(!this.canTokenTypeBeInsertedInRecovery(e)||k(n))return!1;const s=this.LA(1);return Mt(n,i=>this.tokenMatcher(s,i))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){const n=this.getCurrFollowKey(),s=this.getFollowSetFromFollowKey(n);return te(s,e)}findReSyncTokenType(){const e=this.flattenFollowSet();let n=this.LA(1),s=2;for(;;){const r=Mt(e,i=>Qo(n,i));if(r!==void 0)return r;n=this.LA(s),s++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return Ks;const e=this.getLastExplicitRuleShortName(),n=this.getLastExplicitRuleOccurrenceIndex(),s=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:n,inRule:this.shortRuleNameToFullName(s)}}buildFullFollowKeyStack(){const e=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK;return S(e,(s,r)=>r===0?Ks:{ruleName:this.shortRuleNameToFullName(s),idxInCallingRule:n[r],inRule:this.shortRuleNameToFullName(e[r-1])})}flattenFollowSet(){const e=S(this.buildFullFollowKeyStack(),n=>this.getFollowSetFromFollowKey(n));return Te(e)}getFollowSetFromFollowKey(e){if(e===Ks)return[Ge];const n=e.ruleName+e.idxInCallingRule+Ko+e.inRule;return this.resyncFollows[n]}addToResyncTokens(e,n){return this.tokenMatcher(e,Ge)||n.push(e),n}reSyncTo(e){const n=[];let s=this.LA(1);for(;this.tokenMatcher(s,e)===!1;)s=this.SKIP_TOKEN(),this.addToResyncTokens(s,n);return cn(n)}attemptInRepetitionRecovery(e,n,s,r,i,a,o){}getCurrentGrammarPath(e,n){const s=this.getHumanReadableRuleStack(),r=H(this.RULE_OCCURRENCE_STACK);return{ruleStack:s,occurrenceStack:r,lastTok:e,lastTokOccurrence:n}}getHumanReadableRuleStack(){return S(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}}function iS(t,e,n,s,r,i,a){const o=this.getKeyForAutomaticLookahead(s,r);let c=this.firstAfterRepMap[o];if(c===void 0){const f=this.getCurrRuleFullName(),p=this.getGAstProductions()[f];c=new i(p,r).startWalking(),this.firstAfterRepMap[o]=c}let l=c.token,d=c.occurrence;const h=c.isEndOfRule;this.RULE_STACK.length===1&&h&&l===void 0&&(l=Ge,d=1),!(l===void 0||d===void 0)&&this.shouldInRepetitionRecoveryBeTried(l,d,a)&&this.tryInRepetitionRecovery(t,e,n,l)}const aS=4,at=8,gc=1<<at,mc=2<<at,hr=3<<at,ur=4<<at,dr=5<<at,$n=6<<at;function zs(t,e,n){return n|e|t}class oS{constructor(e){var n;this.maxLookahead=(n=e==null?void 0:e.maxLookahead)!==null&&n!==void 0?n:We.maxLookahead}validate(e){const n=this.validateNoLeftRecursion(e.rules);if(k(n)){const s=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...n,...s,...r,...i]}return n}validateNoLeftRecursion(e){return le(e,n=>oc(n,n,ut))}validateEmptyOrAlternatives(e){return le(e,n=>KA(n,ut))}validateAmbiguousAlternationAlternatives(e,n){return le(e,s=>zA(s,n,ut))}validateSomeNonEmptyLookaheadPath(e,n){return YA(e,n,ut)}buildLookaheadForAlternation(e){return CA(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,wA)}buildLookaheadForOptional(e){return kA(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,nc(e.prodType),xA)}}class cS{initLooksAhead(e){this.dynamicTokensEnabled=R(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:We.dynamicTokensEnabled,this.maxLookahead=R(e,"maxLookahead")?e.maxLookahead:We.maxLookahead,this.lookaheadStrategy=R(e,"lookaheadStrategy")?e.lookaheadStrategy:new oS({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){N(e,n=>{this.TRACE_INIT(`${n.name} Rule Lookahead`,()=>{const{alternation:s,repetition:r,option:i,repetitionMandatory:a,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:c}=hS(n);N(s,l=>{const d=l.idx===0?"":l.idx;this.TRACE_INIT(`${Le(l)}${d}`,()=>{const h=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:l.idx,rule:n,maxLookahead:l.maxLookahead||this.maxLookahead,hasPredicates:l.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),f=zs(this.fullRuleNameToShort[n.name],gc,l.idx);this.setLaFuncCache(f,h)})}),N(r,l=>{this.computeLookaheadFunc(n,l.idx,hr,"Repetition",l.maxLookahead,Le(l))}),N(i,l=>{this.computeLookaheadFunc(n,l.idx,mc,"Option",l.maxLookahead,Le(l))}),N(a,l=>{this.computeLookaheadFunc(n,l.idx,ur,"RepetitionMandatory",l.maxLookahead,Le(l))}),N(o,l=>{this.computeLookaheadFunc(n,l.idx,$n,"RepetitionMandatoryWithSeparator",l.maxLookahead,Le(l))}),N(c,l=>{this.computeLookaheadFunc(n,l.idx,dr,"RepetitionWithSeparator",l.maxLookahead,Le(l))})})})}computeLookaheadFunc(e,n,s,r,i,a){this.TRACE_INIT(`${a}${n===0?"":n}`,()=>{const o=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:n,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),c=zs(this.fullRuleNameToShort[e.name],s,n);this.setLaFuncCache(c,o)})}getKeyForAutomaticLookahead(e,n){const s=this.getLastExplicitRuleShortName();return zs(s,e,n)}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,n){this.lookAheadFuncsCache.set(e,n)}}class lS extends Pt{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)}}const _n=new lS;function hS(t){_n.reset(),t.accept(_n);const e=_n.dslMethods;return _n.reset(),e}function ba(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}function va(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function uS(t,e,n){t.children[n]===void 0?t.children[n]=[e]:t.children[n].push(e)}function dS(t,e,n){t.children[e]===void 0?t.children[e]=[n]:t.children[e].push(n)}const fS="name";function Tc(t,e){Object.defineProperty(t,fS,{enumerable:!1,configurable:!0,writable:!1,value:e})}function pS(t,e){const n=de(t),s=n.length;for(let r=0;r<s;r++){const i=n[r],a=t[i],o=a.length;for(let c=0;c<o;c++){const l=a[c];l.tokenTypeIdx===void 0&&this[l.name](l.children,e)}}}function gS(t,e){const n=function(){};Tc(n,t+"BaseSemantics");const s={visit:function(r,i){if(v(r)&&(r=r[0]),!Fe(r))return this[r.name](r.children,i)},validateVisitor:function(){const r=TS(this,e);if(!k(r)){const i=S(r,a=>a.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
87
+ ${i.join(`
88
+
89
+ `).replace(/\n/g,`
90
+ `)}`)}}};return n.prototype=s,n.prototype.constructor=n,n._RULE_NAMES=e,n}function mS(t,e,n){const s=function(){};Tc(s,t+"BaseSemanticsWithDefaults");const r=Object.create(n.prototype);return N(e,i=>{r[i]=pS}),s.prototype=r,s.prototype.constructor=s,s}var fr;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(fr||(fr={}));function TS(t,e){return ES(t,e)}function ES(t,e){const n=fe(e,r=>je(t[r])===!1),s=S(n,r=>({msg:`Missing visitor method: <${r}> on ${t.constructor.name} CST Visitor.`,type:fr.MISSING_METHOD,methodName:r}));return mn(s)}class yS{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=R(e,"nodeLocationTracking")?e.nodeLocationTracking:We.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=W,this.cstFinallyStateUpdate=W,this.cstPostTerminal=W,this.cstPostNonTerminal=W,this.cstPostRule=W;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=va,this.setNodeLocationFromNode=va,this.cstPostRule=W,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=ba,this.setNodeLocationFromNode=ba,this.cstPostRule=W,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=W,this.setNodeLocationFromNode=W,this.cstPostRule=W,this.setInitialNodeLocation=W;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){const n=this.LA(1);e.location={startOffset:n.startOffset,startLine:n.startLine,startColumn:n.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){const n={name:e,children:Object.create(null)};this.setInitialNodeLocation(n),this.CST_STACK.push(n)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){const n=this.LA(0),s=e.location;s.startOffset<=n.startOffset?(s.endOffset=n.endOffset,s.endLine=n.endLine,s.endColumn=n.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)}cstPostRuleOnlyOffset(e){const n=this.LA(0),s=e.location;s.startOffset<=n.startOffset?s.endOffset=n.endOffset:s.startOffset=NaN}cstPostTerminal(e,n){const s=this.CST_STACK[this.CST_STACK.length-1];uS(s,n,e),this.setNodeLocationFromToken(s.location,n)}cstPostNonTerminal(e,n){const s=this.CST_STACK[this.CST_STACK.length-1];dS(s,n,e),this.setNodeLocationFromNode(s.location,e.location)}getBaseCstVisitorConstructor(){if(Fe(this.baseCstVisitorConstructor)){const e=gS(this.className,de(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Fe(this.baseCstVisitorWithDefaultsConstructor)){const e=mS(this.className,de(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){const e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){const e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}}class AS{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):ts}LA(e){const n=this.currIdx+e;return n<0||this.tokVectorLength<=n?ts:this.tokVector[n]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}}class SS{ACTION(e){return e.call(this)}consume(e,n,s){return this.consumeInternal(n,e,s)}subrule(e,n,s){return this.subruleInternal(n,e,s)}option(e,n){return this.optionInternal(n,e)}or(e,n){return this.orInternal(n,e)}many(e,n){return this.manyInternal(e,n)}atLeastOne(e,n){return this.atLeastOneInternal(e,n)}CONSUME(e,n){return this.consumeInternal(e,0,n)}CONSUME1(e,n){return this.consumeInternal(e,1,n)}CONSUME2(e,n){return this.consumeInternal(e,2,n)}CONSUME3(e,n){return this.consumeInternal(e,3,n)}CONSUME4(e,n){return this.consumeInternal(e,4,n)}CONSUME5(e,n){return this.consumeInternal(e,5,n)}CONSUME6(e,n){return this.consumeInternal(e,6,n)}CONSUME7(e,n){return this.consumeInternal(e,7,n)}CONSUME8(e,n){return this.consumeInternal(e,8,n)}CONSUME9(e,n){return this.consumeInternal(e,9,n)}SUBRULE(e,n){return this.subruleInternal(e,0,n)}SUBRULE1(e,n){return this.subruleInternal(e,1,n)}SUBRULE2(e,n){return this.subruleInternal(e,2,n)}SUBRULE3(e,n){return this.subruleInternal(e,3,n)}SUBRULE4(e,n){return this.subruleInternal(e,4,n)}SUBRULE5(e,n){return this.subruleInternal(e,5,n)}SUBRULE6(e,n){return this.subruleInternal(e,6,n)}SUBRULE7(e,n){return this.subruleInternal(e,7,n)}SUBRULE8(e,n){return this.subruleInternal(e,8,n)}SUBRULE9(e,n){return this.subruleInternal(e,9,n)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,n,s=ns){if(te(this.definedRulesNames,e)){const a={message:ut.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:q.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);const r=this.defineRule(e,n,s);return this[e]=r,r}OVERRIDE_RULE(e,n,s=ns){const r=jA(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);const i=this.defineRule(e,n,s);return this[e]=i,i}BACKTRACK(e,n){return function(){this.isBackTrackingStack.push(1);const s=this.saveRecogState();try{return e.apply(this,n),!0}catch(r){if(Qn(r))return!1;throw r}finally{this.reloadRecogState(s),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Ry(B(this.gastProductionsCache))}}class OS{initRecognizerEngine(e,n){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Zn,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},R(n,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
91
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
92
+ For Further details.`);if(v(e)){if(k(e))throw Error(`A Token Vocabulary cannot be empty.
93
+ Note that the first argument for the parser constructor
94
+ is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
95
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
96
+ For Further details.`)}if(v(e))this.tokensMap=ne(e,(i,a)=>(i[a.name]=a,i),{});else if(R(e,"modes")&&Ne(Te(B(e.modes)),EA)){const i=Te(B(e.modes)),a=Ur(i);this.tokensMap=ne(a,(o,c)=>(o[c.name]=c,o),{})}else if(ue(e))this.tokensMap=H(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Ge;const s=R(e,"modes")?Te(B(e.modes)):B(e),r=Ne(s,i=>k(i.categoryMatches));this.tokenMatcher=r?Zn:An,Sn(B(this.tokensMap))}defineRule(e,n,s){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
97
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=R(s,"resyncEnabled")?s.resyncEnabled:ns.resyncEnabled,i=R(s,"recoveryValueFunc")?s.recoveryValueFunc:ns.recoveryValueFunc,a=this.ruleShortNameIdx<<aS+at;this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return this.outputCst===!0?o=function(...d){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),n.apply(this,d);const h=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(h),h}catch(h){return this.invokeRuleCatch(h,r,i)}finally{this.ruleFinallyStateUpdate()}}:o=function(...d){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),n.apply(this,d)}catch(h){return this.invokeRuleCatch(h,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(o,{ruleName:e,originalGrammarAction:n})}invokeRuleCatch(e,n,s){const r=this.RULE_STACK.length===1,i=n&&!this.isBackTracking()&&this.recoveryEnabled;if(Qn(e)){const a=e;if(i){const o=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(o))if(a.resyncedTokens=this.reSyncTo(o),this.outputCst){const c=this.CST_STACK[this.CST_STACK.length-1];return c.recoveredNode=!0,c}else return s(e);else{if(this.outputCst){const c=this.CST_STACK[this.CST_STACK.length-1];c.recoveredNode=!0,a.partialCstResult=c}throw a}}else{if(r)return this.moveToTerminatedState(),s(e);throw a}}else throw e}optionInternal(e,n){const s=this.getKeyForAutomaticLookahead(mc,n);return this.optionInternalLogic(e,n,s)}optionInternalLogic(e,n,s){let r=this.getLaFuncFromCache(s),i;if(typeof e!="function"){i=e.DEF;const a=e.GATE;if(a!==void 0){const o=r;r=()=>a.call(this)&&o.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,n){const s=this.getKeyForAutomaticLookahead(ur,e);return this.atLeastOneInternalLogic(e,n,s)}atLeastOneInternalLogic(e,n,s){let r=this.getLaFuncFromCache(s),i;if(typeof n!="function"){i=n.DEF;const a=n.GATE;if(a!==void 0){const o=r;r=()=>a.call(this)&&o.call(this)}}else i=n;if(r.call(this)===!0){let a=this.doSingleRepetition(i);for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,U.REPETITION_MANDATORY,n.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,n],r,ur,e,vA)}atLeastOneSepFirstInternal(e,n){const s=this.getKeyForAutomaticLookahead($n,e);this.atLeastOneSepFirstInternalLogic(e,n,s)}atLeastOneSepFirstInternalLogic(e,n,s){const r=n.DEF,i=n.SEP;if(this.getLaFuncFromCache(s).call(this)===!0){r.call(this);const o=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,o,r,Ia],o,$n,e,Ia)}else throw this.raiseEarlyExitException(e,U.REPETITION_MANDATORY_WITH_SEPARATOR,n.ERR_MSG)}manyInternal(e,n){const s=this.getKeyForAutomaticLookahead(hr,e);return this.manyInternalLogic(e,n,s)}manyInternalLogic(e,n,s){let r=this.getLaFuncFromCache(s),i;if(typeof n!="function"){i=n.DEF;const o=n.GATE;if(o!==void 0){const c=r;r=()=>o.call(this)&&c.call(this)}}else i=n;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,n],r,hr,e,bA,a)}manySepFirstInternal(e,n){const s=this.getKeyForAutomaticLookahead(dr,e);this.manySepFirstInternalLogic(e,n,s)}manySepFirstInternalLogic(e,n,s){const r=n.DEF,i=n.SEP;if(this.getLaFuncFromCache(s).call(this)===!0){r.call(this);const o=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,o,r,La],o,dr,e,La)}}repetitionSepSecondInternal(e,n,s,r,i){for(;s();)this.CONSUME(n),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,s,r,i],s,$n,e,i)}doSingleRepetition(e){const n=this.getLexerPosition();return e.call(this),this.getLexerPosition()>n}orInternal(e,n){const s=this.getKeyForAutomaticLookahead(gc,n),r=v(e)?e:e.DEF,a=this.getLaFuncFromCache(s).call(this,r);if(a!==void 0)return r[a].ALT.call(this);this.raiseNoAltException(n,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){const e=this.LA(1),n=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new tS(n,e))}}subruleInternal(e,n,s){let r;try{const i=s!==void 0?s.ARGS:void 0;return this.subruleIdx=n,r=e.apply(this,i),this.cstPostNonTerminal(r,s!==void 0&&s.LABEL!==void 0?s.LABEL:e.ruleName),r}catch(i){throw this.subruleInternalError(i,s,e.ruleName)}}subruleInternalError(e,n,s){throw Qn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,n!==void 0&&n.LABEL!==void 0?n.LABEL:s),delete e.partialCstResult),e}consumeInternal(e,n,s){let r;try{const i=this.LA(1);this.tokenMatcher(i,e)===!0?(this.consumeToken(),r=i):this.consumeInternalError(e,i,s)}catch(i){r=this.consumeInternalRecovery(e,n,i)}return this.cstPostTerminal(s!==void 0&&s.LABEL!==void 0?s.LABEL:e.name,r),r}consumeInternalError(e,n,s){let r;const i=this.LA(0);throw s!==void 0&&s.ERR_MSG?r=s.ERR_MSG:r=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:n,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new fc(r,n,i))}consumeInternalRecovery(e,n,s){if(this.recoveryEnabled&&s.name==="MismatchedTokenException"&&!this.isBackTracking()){const r=this.getFollowsForInRuleRecovery(e,n);try{return this.tryInRuleRecovery(e,r)}catch(i){throw i.name===pc?s:i}}else throw s}saveRecogState(){const e=this.errors,n=H(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:n,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,n,s){this.RULE_OCCURRENCE_STACK.push(s),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(n)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){const e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ge)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}}class RS{initErrorHandler(e){this._errors=[],this.errorMessageProvider=R(e,"errorMessageProvider")?e.errorMessageProvider:We.errorMessageProvider}SAVE_ERROR(e){if(Qn(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:H(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return H(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,n,s){const r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],o=Xr(e,i,n,this.maxLookahead)[0],c=[];for(let d=1;d<=this.maxLookahead;d++)c.push(this.LA(d));const l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:o,actual:c,previous:this.LA(0),customUserDescription:s,ruleName:r});throw this.SAVE_ERROR(new nS(l,this.LA(1),this.LA(0)))}raiseNoAltException(e,n){const s=this.getCurrRuleFullName(),r=this.getGAstProductions()[s],i=Yr(e,r,this.maxLookahead),a=[];for(let l=1;l<=this.maxLookahead;l++)a.push(this.LA(l));const o=this.LA(0),c=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:n,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new eS(c,this.LA(1),o))}}class LS{initContentAssist(){}computeContentAssist(e,n){const s=this.gastProductionsCache[e];if(Fe(s))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return tc([s],n,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){const n=ye(e.ruleStack),r=this.getGAstProductions()[n];return new NA(r,e).startWalking()}}const Cs={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Cs);const _a=!0,Ca=Math.pow(2,at)-1,Ec=O({name:"RECORDING_PHASE_TOKEN",pattern:Y.NA});Sn([Ec]);const yc=Vr(Ec,`This IToken indicates the Parser is in Recording Phase
98
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(yc);const IS={name:`This CSTNode indicates the Parser is in Recording Phase
99
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};class NS{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){const n=e>0?e:"";this[`CONSUME${n}`]=function(s,r){return this.consumeInternalRecord(s,e,r)},this[`SUBRULE${n}`]=function(s,r){return this.subruleInternalRecord(s,e,r)},this[`OPTION${n}`]=function(s){return this.optionInternalRecord(s,e)},this[`OR${n}`]=function(s){return this.orInternalRecord(s,e)},this[`MANY${n}`]=function(s){this.manyInternalRecord(e,s)},this[`MANY_SEP${n}`]=function(s){this.manySepFirstInternalRecord(e,s)},this[`AT_LEAST_ONE${n}`]=function(s){this.atLeastOneInternalRecord(e,s)},this[`AT_LEAST_ONE_SEP${n}`]=function(s){this.atLeastOneSepFirstInternalRecord(e,s)}}this.consume=function(e,n,s){return this.consumeInternalRecord(n,e,s)},this.subrule=function(e,n,s){return this.subruleInternalRecord(n,e,s)},this.option=function(e,n){return this.optionInternalRecord(n,e)},this.or=function(e,n){return this.orInternalRecord(n,e)},this.many=function(e,n){this.manyInternalRecord(e,n)},this.atLeastOne=function(e,n){this.atLeastOneInternalRecord(e,n)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const e=this;for(let n=0;n<10;n++){const s=n>0?n:"";delete e[`CONSUME${s}`],delete e[`SUBRULE${s}`],delete e[`OPTION${s}`],delete e[`OR${s}`],delete e[`MANY${s}`],delete e[`MANY_SEP${s}`],delete e[`AT_LEAST_ONE${s}`],delete e[`AT_LEAST_ONE_SEP${s}`]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,n){return()=>!0}LA_RECORD(e){return ts}topLevelRuleRecord(e,n){try{const s=new $t({definition:[],name:e});return s.name=e,this.recordingProdStack.push(s),n.call(this),this.recordingProdStack.pop(),s}catch(s){if(s.KNOWN_RECORDER_ERROR!==!0)try{s.message=s.message+`
100
+ This error was thrown during the "grammar recording phase" For more info see:
101
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw s}throw s}}optionInternalRecord(e,n){return zt.call(this,Z,e,n)}atLeastOneInternalRecord(e,n){zt.call(this,xe,n,e)}atLeastOneSepFirstInternalRecord(e,n){zt.call(this,Me,n,e,_a)}manyInternalRecord(e,n){zt.call(this,G,n,e)}manySepFirstInternalRecord(e,n){zt.call(this,Se,n,e,_a)}orInternalRecord(e,n){return bS.call(this,e,n)}subruleInternalRecord(e,n,s){if(es(n),!e||R(e,"ruleName")===!1){const o=new Error(`<SUBRULE${ka(n)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
102
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}const r=ft(this.recordingProdStack),i=e.ruleName,a=new se({idx:n,nonTerminalName:i,label:s==null?void 0:s.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?IS:Cs}consumeInternalRecord(e,n,s){if(es(n),!Jo(e)){const a=new Error(`<CONSUME${ka(n)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
103
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw a.KNOWN_RECORDER_ERROR=!0,a}const r=ft(this.recordingProdStack),i=new $({idx:n,terminalType:e,label:s==null?void 0:s.LABEL});return r.definition.push(i),yc}}function zt(t,e,n,s=!1){es(n);const r=ft(this.recordingProdStack),i=je(e)?e:e.DEF,a=new t({definition:[],idx:n});return s&&(a.separator=e.SEP),R(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(a),i.call(this),r.definition.push(a),this.recordingProdStack.pop(),Cs}function bS(t,e){es(e);const n=ft(this.recordingProdStack),s=v(t)===!1,r=s===!1?t:t.DEF,i=new Oe({definition:[],idx:e,ignoreAmbiguities:s&&t.IGNORE_AMBIGUITIES===!0});R(t,"MAX_LOOKAHEAD")&&(i.maxLookahead=t.MAX_LOOKAHEAD);const a=ag(r,o=>je(o.GATE));return i.hasPredicates=a,n.definition.push(i),N(r,o=>{const c=new ee({definition:[]});i.definition.push(c),R(o,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=o.IGNORE_AMBIGUITIES:R(o,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),o.ALT.call(this),this.recordingProdStack.pop()}),Cs}function ka(t){return t===0?"":`${t}`}function es(t){if(t<0||t>Ca){const e=new Error(`Invalid DSL Method idx value: <${t}>
104
+ Idx value must be a none negative value smaller than ${Ca+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}class vS{initPerformanceTracer(e){if(R(e,"traceInitPerf")){const n=e.traceInitPerf,s=typeof n=="number";this.traceInitMaxIdent=s?n:1/0,this.traceInitPerf=s?n>0:n}else this.traceInitMaxIdent=0,this.traceInitPerf=We.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,n){if(this.traceInitPerf===!0){this.traceInitIndent++;const s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);const{time:r,value:i}=Ao(n),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}else return n()}}function _S(t,e){e.forEach(n=>{const s=n.prototype;Object.getOwnPropertyNames(s).forEach(r=>{if(r==="constructor")return;const i=Object.getOwnPropertyDescriptor(s,r);i&&(i.get||i.set)?Object.defineProperty(t.prototype,r,i):t.prototype[r]=n.prototype[r]})})}const ts=Vr(Ge,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(ts);const We=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ec,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ns=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var q;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(q||(q={}));class On{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const n=this.className;this.TRACE_INIT("toFastProps",()=>{So(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),N(this.definedRulesNames,r=>{const a=this[r].originalGrammarAction;let o;this.TRACE_INIT(`${r} Rule`,()=>{o=this.topLevelRuleRecord(r,a)}),this.gastProductionsCache[r]=o})}finally{this.disableRecording()}});let s=[];if(this.TRACE_INIT("Grammar Resolving",()=>{s=ZA({rules:B(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(s)}),this.TRACE_INIT("Grammar Validations",()=>{if(k(s)&&this.skipValidations===!1){const r=QA({rules:B(this.gastProductionsCache),tokenTypes:B(this.tokensMap),errMsgProvider:ut,grammarName:n}),i=UA({lookaheadStrategy:this.lookaheadStrategy,rules:B(this.gastProductionsCache),tokenTypes:B(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(r,i)}}),k(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const r=Cy(B(this.gastProductionsCache));this.resyncFollows=r}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var r,i;(i=(r=this.lookaheadStrategy).initialize)===null||i===void 0||i.call(r,{rules:B(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(B(this.gastProductionsCache))})),!On.DEFER_DEFINITION_ERRORS_HANDLING&&!k(this.definitionErrors))throw e=S(this.definitionErrors,r=>r.message),new Error(`Parser Definition Errors detected:
105
+ ${e.join(`
106
+ -------------------------------
107
+ `)}`)})}constructor(e,n){this.definitionErrors=[],this.selfAnalysisDone=!1;const s=this;if(s.initErrorHandler(n),s.initLexerAdapter(),s.initLooksAhead(n),s.initRecognizerEngine(e,n),s.initRecoverable(n),s.initTreeBuilder(n),s.initContentAssist(),s.initGastRecorder(n),s.initPerformanceTracer(n),R(n,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
108
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
109
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
110
+ For further details.`);this.skipValidations=R(n,"skipValidations")?n.skipValidations:We.skipValidations}}On.DEFER_DEFINITION_ERRORS_HANDLING=!1;_S(On,[rS,cS,yS,AS,OS,SS,RS,LS,NS,vS]);class CS extends On{constructor(e,n=We){const s=H(n);s.outputCst=!0,super(e,s)}}function Ac(t,e){const n=t.lexer.tokenize(e);if(n.errors.length>0){const r=n.errors[0],i=Number.isFinite(r.offset)?r.offset:e.length,a=i+(Number.isFinite(r.length)?r.length:0);throw new Error(`Error lexing ${t.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${i},${a})`)}t.parser.input=n.tokens;const s=t.entry();if(t.parser.errors.length>0)throw new Error(`Error parsing ${t.diagramType} diagram: ${t.parser.errors[0].message}`);t.visit(s)}u(Ac,"runChevrotainParse");var M={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},kS="LR",wS=Rl.usecase,Jr=u(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:kS,relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(wS)}),"createModel"),xS=u(t=>{if(!(t.actors instanceof Map)||!(t.useCases instanceof Map)||!(t.systemBoundaries instanceof Map)||!Array.isArray(t.relationships)||!(t.notes instanceof Map)||!(t.jsonNodes instanceof Map)||!(t.classDefs instanceof Map)||!(t.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(t.direction)||!Number.isSafeInteger(t.relationshipCounter)||t.relationshipCounter<0||!Number.isSafeInteger(t.noteCounter)||t.noteCounter<0||typeof t.accTitle!="string"||typeof t.accDescription!="string"||!t.config)throw new Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),b=Jr(),MS=u(()=>structuredClone(b.config),"getConfig"),$S=u(()=>b.ast,"getAST"),PS=u(t=>{const e=structuredClone(t);xS(e);const n=Ga(),s=Ba();try{Ys(e.accTitle),Vs(e.accDescription),b=e}catch(r){throw Ys(n),Vs(s),r}},"commit"),US=u(()=>{b=Jr(),Ol()},"clear"),DS=u(()=>b.actors,"getActors"),FS=u(t=>b.actors.get(t),"getActor"),BS=u(()=>b.useCases,"getUseCases"),GS=u(t=>b.useCases.get(t),"getUseCase"),WS=u(()=>b.systemBoundaries,"getSystemBoundaries"),jS=u(t=>b.systemBoundaries.get(t),"getSystemBoundary"),KS=u(()=>b.relationships,"getRelationships"),zS=u(()=>b.notes,"getNotes"),HS=u(t=>b.notes.get(t),"getNote"),VS=u(()=>b.jsonNodes,"getJsonNodes"),YS=u(t=>b.jsonNodes.get(t),"getJsonNode"),XS=u(()=>b.classDefs,"getClassDefs"),qS=u(t=>b.classDefs.get(t),"getClassDef"),Sc=u(()=>b.direction,"getDirection"),lt=u(t=>{const e=new Map;for(const n of["default",...t]){const s=b.classDefs.get(n);if(s)for(const r of s.styles){const i=r.trim(),a=i.indexOf(":"),o=(a===-1?i:i.slice(0,a)).trim();o&&e.set(o,i)}}return[...e.values()]},"getCompiledStyles"),JS=u(t=>t.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),wa=u(t=>typeof t=="string"?t:t===null?"null":String(t),"displayJsonScalar"),ZS=u((t,e,n=s=>s)=>{const s=[],r=u((a,o,c)=>{s.push({key:n(a),accessibleKey:n(o),value:n(c)})},"append"),i=u((a,o,c)=>{if(Array.isArray(a)){if(a.length===0){r(o,o,"[]");return}if(a.every(d=>d===null||["string","number","boolean"].includes(typeof d))){for(const[d,h]of a.entries())r(d===0?o:"",o,wa(h));return}for(const[d,h]of a.entries())i(h,`${o}[${d}]`,`${c}/${d}`);return}if(a!==null&&typeof a=="object"){const l=a,d=e[c]??Object.keys(l);if(d.length===0){r(o,o,"{}");return}for(const h of d){const f=o?`${o}.${h}`:h;i(l[h],f,`${c}/${JS(h)}`)}return}r(o,o,wa(a))},"visit");return i(t,"",""),s},"flattenJsonRows"),QS=u(t=>{switch(t.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),eO=u(t=>t.shape==="ellipse"?t.business?"usecaseBusiness":"usecaseEllipse":t.shape,"useCaseShape"),tO=u(t=>{switch(t){case M.SOLID_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case M.BACK_ARROW:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case M.CIRCLE_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case M.CROSS_ARROW:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case M.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case M.CROSS_ARROW_REVERSED:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case M.LINE_SOLID:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),nO=u(t=>{switch(t.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:t.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...tO(t.arrowType),pattern:"solid",...t.label?{label:t.label}:{},...t.labelType?{labelType:t.labelType}:{}}}},"relationshipVisuals"),sO=u(t=>t.animate||t.animation?[`edge-animation-${t.animation??"fast"}`]:[],"animationClasses"),Ht=u((...t)=>t.filter(e=>!!e).join(" "),"classNames"),rO=u(()=>{var c,l,d;const t=Wa(),e={...b.config,...t.usecase},n=u(h=>Sl(h,t),"sanitize"),s=u(h=>{var f,p,g,T;return n(((f=b.actors.get(h))==null?void 0:f.label)??((p=b.useCases.get(h))==null?void 0:p.label)??((g=b.jsonNodes.get(h))==null?void 0:g.id)??((T=b.notes.get(h))==null?void 0:T.label)??h)},"endpointLabel"),r=[],i=[];let a=0,o=0;for(const h of b.actors.values())r.push({id:h.id,label:n(h.label),labelType:h.labelType,shape:QS(h),isGroup:!1,padding:10,look:t.look,colorIndex:a++,cssClasses:Ht("default","usecase-actor",`usecase-actor-${h.type}`,h.business&&"usecase-business",...h.classes),cssStyles:[...h.styles],cssCompiledStyles:lt(h.classes),actorType:h.type,business:h.business,...h.icon?{icon:h.icon}:{},...h.stereotype?{stereotype:n(h.stereotype)}:{},...h.parentId?{parentId:h.parentId}:{}});for(const h of b.useCases.values())r.push({id:h.id,label:n(h.label),labelType:h.labelType,shape:eO(h),isGroup:!1,padding:h.shape==="ellipse"?20:10,look:t.look,colorIndex:a++,cssClasses:Ht("default","usecase-element",`usecase-${h.shape}`,h.business&&"usecase-business",...h.classes),cssStyles:[...h.styles],cssCompiledStyles:lt(h.classes),business:h.business,...h.stereotype?{stereotype:n(h.stereotype)}:{},...h.parentId?{parentId:h.parentId}:{}});for(const h of b.notes.values())r.push({id:h.id,label:n(h.label),labelType:h.labelType,shape:"note",isGroup:!1,padding:10,look:t.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:lt([]),noteTarget:h.target,noteTargetLabel:n(((c=b.actors.get(h.target))==null?void 0:c.label)??((l=b.useCases.get(h.target))==null?void 0:l.label)??((d=b.jsonNodes.get(h.target))==null?void 0:d.id)??h.target)});for(const h of b.jsonNodes.values())r.push({id:h.id,label:n(h.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:t.look,cssClasses:Ht("default","usecase-json-table",...h.classes),cssStyles:[...h.styles],cssCompiledStyles:lt(h.classes),jsonRows:ZS(h.value,h.propertyOrder,n)});for(const h of b.systemBoundaries.values())r.push({id:h.id,label:n(h.label),labelType:h.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:t.look,colorIndex:o++,cssClasses:Ht("default","system-boundary",`system-boundary-${h.type}`,...h.classes),cssStyles:[...h.styles],cssCompiledStyles:lt(h.classes),boundaryType:h.type});for(const h of b.relationships){const{label:f,...p}=nO(h);i.push({id:h.id,start:h.source,end:h.target,source:h.source,target:h.target,sourceLabel:s(h.source),targetLabel:s(h.target),type:"edge",relationshipType:h.type,internal:!1,...p,...f!==void 0?{label:n(f)}:{},labelpos:"c",classes:Ht("default","relationship",`relationship-${h.type}`,...h.classes,...sO(h)),style:[...h.styles],cssCompiledStyles:lt(h.classes),animate:h.animate,...h.animation?{animation:h.animation}:{},look:t.look,thickness:"normal",minlen:h.minlen,isUserDefinedId:h.explicitId})}for(const h of b.notes.values())i.push({id:`${h.id}-edge`,start:h.id,end:h.target,source:h.id,target:h.target,type:"edge",relationshipType:"note",sourceLabel:s(h.id),targetLabel:s(h.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:lt([]),animate:!1,look:t.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(const h of r)h.wrappingWidth??(h.wrappingWidth=e.wrappingWidth),!h.isGroup&&!h.shape.startsWith("usecaseActor")&&(h.minWidth??(h.minWidth=e.minNodeWidth)),(h.shape==="usecaseEllipse"||h.shape==="usecaseBusiness")&&(h.spreadPorts=!0);return{nodes:r,edges:i,config:t,type:"usecase",layoutAlgorithm:"dagre",direction:Sc(),nodeSpacing:e.nodeSpacing,rankSpacing:e.rankSpacing,actorFontSize:e.actorFontSize,actorFontFamily:e.actorFontFamily,actorFontWeight:e.actorFontWeight,usecaseFontSize:e.usecaseFontSize,usecaseFontFamily:e.usecaseFontFamily,usecaseFontWeight:e.usecaseFontWeight,diagramPadding:e.diagramPadding,useMaxWidth:e.useMaxWidth,markers:["point","circle","cross","extension"]}},"getData"),ss={getConfig:MS,createModel:Jr,commit:PS,getAST:$S,clear:US,setDiagramTitle:ml,getDiagramTitle:gl,setAccTitle:Ys,getAccTitle:Ga,setAccDescription:Vs,getAccDescription:Ba,getActors:DS,getActor:FS,getUseCases:BS,getUseCase:GS,getSystemBoundaries:WS,getSystemBoundary:jS,getRelationships:KS,getNotes:zS,getNote:HS,getJsonNodes:VS,getJsonNode:YS,getClassDefs:XS,getClassDef:qS,getDirection:Sc,getData:rO};function Ot(t,e,n){const s=[n];return s.index=e,s.input=t,s}u(Ot,"customMatch");var iO=u((t,e)=>{if(t[e]!=='"'||t[e+1]!=="`")return null;for(let n=e+2;n<t.length-1;n++)if(t[n]==="`"&&t[n+1]==='"')return Ot(t,e,t.slice(e,n+2));return null},"matchMarkdownString"),aO=u((t,e)=>{if(t[e]!=="%"||t[e+1]!=="%")return null;for(let s=e-1;s>=0;s--){const r=t[s];if(r===`
111
+ `||r==="\r")break;if(r!==" "&&r!==" ")return null}let n=e+2;for(;n<t.length&&t[n]!==`
112
+ `&&t[n]!=="\r";)n++;return Ot(t,e,t.slice(e,n))},"matchComment"),Oc=u((t,e)=>{for(let n=e-1;n>=0;n--){const s=t[n];if(s===`
113
+ `||s==="\r")return!0;if(s!==" "&&s!==" ")return!1}return!0},"isIndentedLineStart"),Rc=u((t,e,n)=>{if(!Oc(t,e))return null;const s=n.exec(t.slice(e));return s?Ot(t,e,s[0]):null},"matchAccessibilityLine"),oO=u((t,e)=>{if(!Oc(t,e))return null;const n=/^accDescr[\t ]*{/.exec(t.slice(e));if(!n)return null;const s=t.indexOf("}",e+n[0].length);return s===-1?null:Ot(t,e,t.slice(e,s+1))},"matchAccDescrBlock"),cO=u((t,e)=>{if(t[e]!=="{")return null;let n=0,s=!1,r=!1;for(let i=e;i<t.length;i++){const a=t[i];if(s){r?r=!1:a==="\\"?r=!0:a==='"'&&(s=!1);continue}if(a==='"')s=!0;else if(a==="{")n++;else if(a==="}"&&--n===0)return Ot(t,e,t.slice(e,i+1))}return null},"matchJsonObject"),lO=u((t,e)=>{const n=t.indexOf(">>",e);if(n===-1||/[\n\r]/.test(t.slice(e,n)))return null;const s=t.slice(e,n);return s.trim()?Ot(t,e,s):null},"matchStereotypeText"),j=O({name:"LABEL_TEXT",pattern:Y.NA}),Nt=O({name:"WORD",pattern:Y.NA,categories:j}),Zr=O({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:j}),P=O({name:"IDENTIFIER",pattern:/\w+/,longer_alt:Zr,categories:Nt}),hO=O({name:"HWS",pattern:/[\t ]+/,group:Y.SKIPPED}),Ue=O({name:"MARKDOWN_STRING",pattern:iO,start_chars_hint:['"'],line_breaks:!0}),uO=O({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),pr=O({name:"COMMENT",pattern:aO,start_chars_hint:["%"],line_breaks:!1}),Pe=O({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),Lc=O({name:"ACC_DESCR_BLOCK",pattern:oO,start_chars_hint:["a"],line_breaks:!0}),dO=/^accTitle[\t ]*:[^\n\r]*/,fO=/^accDescr[\t ]*:[^\n\r]*/,Ic=O({name:"ACC_TITLE_LINE",pattern:u((t,e)=>Rc(t,e,dO),"pattern"),start_chars_hint:["a"],line_breaks:!1}),Nc=O({name:"ACC_DESCR_LINE",pattern:u((t,e)=>Rc(t,e,fO),"pattern"),start_chars_hint:["a"],line_breaks:!1}),bc=O({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),Qr=O({name:"JSON_OBJECT_LITERAL",pattern:cO,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),vc=O({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),F=u((t,e)=>O({name:t,pattern:e,longer_alt:P,categories:Nt}),"keyword"),_c=F("USECASE",/usecase-beta/),gr=F("ACTOR",/actor/),Cc=F("SYSTEM_BOUNDARY",/systemBoundary/),kc=F("END",/end/),wc=F("DIRECTION",/direction/),xc=F("TD",/TD/),Mc=F("TB",/TB/),$c=F("BT",/BT/),Pc=F("LR",/LR/),Uc=F("RL",/RL/),Dc=F("NOTE",/note/),Fc=F("FOR",/for/),pO=F("JSON",/json/),Bc=F("CLASS_DEF",/classDef/),Gc=F("CLASS",/class/),Wc=F("STYLE",/style/),jc=F("INCLUDE",/include/i),Kc=F("EXTEND",/extend/i),zc=F("TRUE",/true/),Hc=F("FALSE",/false/),Vc=O({name:"GENERALIZATION",pattern:/--\|>/}),Yc=O({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),Xc=O({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),ei=O({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),ti=O({name:"STEREOTYPE_TEXT",pattern:lO,line_breaks:!1}),qc=O({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),Jc=O({name:"CLASS_SEPARATOR",pattern:/:::/}),Pn=O({name:"FORWARD_SOLID",pattern:/--+>/}),Zc=O({name:"BACKWARD_SOLID",pattern:/<--+/}),Un=O({name:"FORWARD_CIRCLE",pattern:/--o/}),Qc=O({name:"BACKWARD_CIRCLE",pattern:/o--/}),Dn=O({name:"FORWARD_CROSS",pattern:/--x/}),el=O({name:"BACKWARD_CROSS",pattern:/x--/}),ae=O({name:"MARKERLESS_SOLID",pattern:/--+/}),mr=O({name:"METADATA_START",pattern:/@{/}),Fn=O({name:"AT",pattern:/@/,categories:j}),tl=O({name:"LBRACE",pattern:/{/}),Tr=O({name:"RBRACE",pattern:/}/}),Bn=O({name:"LBRACKET",pattern:/\[/}),Gn=O({name:"RBRACKET",pattern:/]/}),Jt=O({name:"LPAREN",pattern:/\(/}),Zt=O({name:"RPAREN",pattern:/\)/}),me=O({name:"COMMA",pattern:/,/,categories:j}),Qt=O({name:"COLON",pattern:/:/,categories:j}),nl=O({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:j}),oe=O({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),Er=O({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:j}),sl=O({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:j}),rl=O({name:"DASH",pattern:/-/,categories:j}),il=O({name:"DOT",pattern:/\./,categories:j}),al=O({name:"PERCENT",pattern:/%/,categories:j}),ol=O({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:j}),gO=O({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:j}),mO=O({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:j}),cl=[j,Nt,hO,Ue,uO,pr,Pe,Lc,Ic,Nc,bc,_c,gr,Cc,kc,wc,xc,Mc,$c,Pc,Uc,Dc,Fc,pO,Bc,Gc,Wc,jc,Kc,zc,Hc,Vc,Yc,Xc,Jc,Pn,Zc,Un,Qc,Dn,el,ae,mr,Fn,tl,Tr,Bn,Gn,Jt,Zt,me,Qt,nl,oe,Er,P,Zr,sl,rl,il,al,ol,gO,mO],TO={defaultMode:"defaultMode",modes:{defaultMode:[...cl],jsonBody:[Qr,vc],stereotype:[ei,ti,qc]}},EO=[...cl,Qr,vc,ei,ti,qc],yO=new Y(TO),xa=u(t=>Qo(t,j)||t.tokenType===oe||t.tokenType===Ue,"isLabelToken"),AO={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},bt,SO=(bt=class extends CS{constructor(){super(EO,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(_c),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:u(()=>this.isStatementStart(),"GATE"),ALT:u(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:u(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:u(()=>this.isMetadataAssignment(),"GATE"),ALT:u(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:u(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:u(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:u(()=>this.CONSUME(Pe),"ALT")},{ALT:u(()=>this.CONSUME(Ge),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(Pe)}),this.RULE("commentLine",()=>{this.CONSUME(pr),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(Ic),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:u(()=>this.CONSUME(Nc),"ALT")},{ALT:u(()=>this.CONSUME(Lc),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(gr),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:u(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(me),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:u(()=>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:u(()=>{this.CONSUME(P),this.OPTION(()=>{this.CONSUME(Jt),this.SUBRULE(this.nodeLabel),this.CONSUME(Zt)})},"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(gr),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(me),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:u(()=>{this.CONSUME(P),this.OPTION(()=>{this.OR2([{ALT:u(()=>{this.CONSUME(Jt),this.SUBRULE(this.nodeLabel),this.CONSUME(Zt)},"ALT")},{ALT:u(()=>{this.CONSUME(Bn),this.SUBRULE2(this.nodeLabel),this.CONSUME(Gn)},"ALT")}])})},"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"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:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"ALT")},{ALT:u(()=>this.AT_LEAST_ONE(()=>this.CONSUME(j)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:u(()=>this.LA(1).tokenType===P&&this.LA(2).tokenType===Fn,"GATE"),DEF:u(()=>{this.CONSUME(P),this.CONSUME(Fn)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:u(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(Pn)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(Zc),this.OPTION({GATE:u(()=>this.LA(0).image==="<--"&&this.hasLabeledRight([ae]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(ae)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(ae),this.OPTION({GATE:u(()=>this.LA(0).image==="--"&&this.hasLabeledRight([Pn,ae,Un,Dn]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:u(()=>this.CONSUME(Pn),"ALT")},{ALT:u(()=>this.CONSUME2(ae),"ALT")},{ALT:u(()=>this.CONSUME(Un),"ALT")},{ALT:u(()=>this.CONSUME(Dn),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(Un)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(Qc),this.OPTION({GATE:u(()=>this.hasLabeledRight([ae]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(ae)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(Dn)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(el),this.OPTION({GATE:u(()=>this.hasLabeledRight([ae]),"GATE"),DEF:u(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(ae)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"ALT")},{ALT:u(()=>this.AT_LEAST_ONE(()=>this.CONSUME(j)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:u(()=>{this.CONSUME(Yc),this.CONSUME(Qt),this.OR2([{ALT:u(()=>this.CONSUME(jc),"ALT")},{ALT:u(()=>this.CONSUME(Kc),"ALT")}])},"ALT")},{ALT:u(()=>this.CONSUME(Vc),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(mr),this.MANY(()=>this.CONSUME(Pe)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(me)),this.MANY3(()=>this.CONSUME2(Pe))}),this.CONSUME(Tr)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:u(()=>this.CONSUME(P),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")}]),this.CONSUME(Qt),this.OR2([{ALT:u(()=>this.CONSUME2(P),"ALT")},{ALT:u(()=>this.CONSUME2(oe),"ALT")},{ALT:u(()=>this.CONSUME(zc),"ALT")},{ALT:u(()=>this.CONSUME(Hc),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:u(()=>{this.CONSUME(me),this.MANY(()=>this.CONSUME(Pe))},"ALT")},{ALT:u(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(Pe)),this.OPTION(()=>this.CONSUME2(me)),this.MANY2(()=>this.CONSUME3(Pe))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(Cc),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(kc),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:u(()=>{this.CONSUME(P),this.OPTION(()=>{this.OR2([{ALT:u(()=>{this.CONSUME(Jt),this.SUBRULE(this.nodeLabel),this.CONSUME(Zt)},"ALT")},{ALT:u(()=>{this.CONSUME(Bn),this.SUBRULE2(this.nodeLabel),this.CONSUME(Gn)},"ALT")}])})},"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:u(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:u(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:u(()=>{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:u(()=>this.CONSUME(P),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Ue),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(Dc),this.CONSUME(Fc),this.CONSUME(P),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(Xc),this.CONSUME(ti),this.CONSUME(ei)}),this.RULE("classSuffix",()=>{this.CONSUME(Jc),this.CONSUME(P),this.MANY(()=>{this.CONSUME(me),this.CONSUME2(P)})}),this.RULE("jsonStatement",()=>{this.CONSUME(bc),this.CONSUME(Qr),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(wc),this.OR([{ALT:u(()=>this.CONSUME(xc),"ALT")},{ALT:u(()=>this.CONSUME(Mc),"ALT")},{ALT:u(()=>this.CONSUME($c),"ALT")},{ALT:u(()=>this.CONSUME(Pc),"ALT")},{ALT:u(()=>this.CONSUME(Uc),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(Bc),this.CONSUME(P),this.MANY(()=>{this.CONSUME(me),this.CONSUME2(P)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(Gc),this.CONSUME(P),this.MANY(()=>{this.CONSUME(me),this.CONSUME2(P)}),this.CONSUME3(P),this.MANY2(()=>{this.CONSUME2(me),this.CONSUME4(P)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(Wc),this.CONSUME(P),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(me),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:u(()=>this.CONSUME(Nt),"ALT")},{ALT:u(()=>this.CONSUME(Er),"ALT")},{ALT:u(()=>{this.CONSUME(ae),this.CONSUME2(Nt)},"ALT")}]),this.CONSUME(Qt),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:u(()=>this.CONSUME(Nt),"ALT")},{ALT:u(()=>this.CONSUME(oe),"ALT")},{ALT:u(()=>this.CONSUME(Zr),"ALT")},{ALT:u(()=>this.CONSUME(nl),"ALT")},{ALT:u(()=>this.CONSUME(Er),"ALT")},{ALT:u(()=>this.CONSUME(sl),"ALT")},{ALT:u(()=>this.CONSUME(rl),"ALT")},{ALT:u(()=>this.CONSUME(il),"ALT")},{ALT:u(()=>this.CONSUME(al),"ALT")},{ALT:u(()=>this.CONSUME(ol),"ALT")},{ALT:u(()=>this.CONSUME(Qt),"ALT")},{ALT:u(()=>this.CONSUME(Jt),"ALT")},{ALT:u(()=>this.CONSUME(Zt),"ALT")},{ALT:u(()=>this.CONSUME(Bn),"ALT")},{ALT:u(()=>this.CONSUME(Gn),"ALT")},{ALT:u(()=>this.CONSUME(tl),"ALT")},{ALT:u(()=>this.CONSUME(Tr),"ALT")},{ALT:u(()=>this.CONSUME(Fn),"ALT")},{ALT:u(()=>this.CONSUME(ae),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){const e=this.LA(1).tokenType;return(e===P||e===oe||e===Ue)&&this.LA(2).tokenType===mr}isStatementStart(){const e=this.LA(1).tokenType;return e!==Ge&&e!==Pe&&e!==pr}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===P&&AO[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!xa(this.LA(1)))return!1;for(let n=2;;n++){const s=this.LA(n);if(e.includes(s.tokenType))return!0;if(!xa(s))return!1}}},u(bt,"UsecaseParser"),bt),en=new SO,vt,Ma=(vt=class extends Error{constructor(e,n,s){super(`${e} (line ${n}, column ${s})`),this.line=n,this.column=s,this.name="UsecaseJsonError"}},u(vt,"UsecaseJsonError"),vt),yr=u((t,e,n,s)=>{let r=n,i=s;const a=Math.min(Math.max(e,0),t.length);for(let o=0;o<a;o++){const c=t[o];c==="\r"?(r++,i=1):c===`
114
+ `?(o===0||t[o-1]!=="\r")&&(r++,i=1):i++}return{line:r,column:i}},"locationAtOffset"),OO=u((t,e,n,s)=>{const r=/\bposition (\d+)\b/u.exec(t);if(r)return yr(e,Number.parseInt(r[1],10),n,s);const i=/\bline (\d+) column (\d+)\b/u.exec(t);if(i){const a=Number.parseInt(i[1],10),o=Number.parseInt(i[2],10);return{line:n+a-1,column:a===1?s+o-1:o}}if(/unexpected end|end of json input/iu.test(t))return yr(e,e.length,n,s)},"locationFromErrorMessage"),_t,K=(_t=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}},u(_t,"JsonWalkError"),_t),Ct,$a=(Ct=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new K(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();const n=this.text[this.offset];if(n==="{")this.collectObject(e);else if(n==="[")this.collectArray(e);else if(n==='"')this.readString(!1);else if(n==="t")this.consumeLiteral("true");else if(n==="f")this.consumeLiteral("false");else if(n==="n")this.consumeLiteral("null");else if(n==="-"||n>="0"&&n<="9")this.consumeNumber();else throw new K(this.offset)}collectObject(e){this.offset++;const n=[],s=new Set;if(this.propertyOrder[e]=n,this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}for(;this.offset<this.text.length;){if(this.text[this.offset]!=='"')throw new K(this.offset);const r=this.readString(!0),i=`${e}/${r.replaceAll("~","~0").replaceAll("/","~1")}`;if(s.has(r)?this.deletePointerSubtree(i):(s.add(r),n.push(r)),this.skipWhitespace(),this.text[this.offset]!==":")throw new K(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),this.text[this.offset]==="}"){this.offset++;return}if(this.text[this.offset]!==",")throw new K(this.offset);this.offset++,this.skipWhitespace()}throw new K(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}let n=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${n}`),n++,this.skipWhitespace(),this.text[this.offset]==="]"){this.offset++;return}if(this.text[this.offset]!==",")throw new K(this.offset);this.offset++,this.skipWhitespace()}throw new K(this.offset)}readString(e){this.offset++;let n="";for(;this.offset<this.text.length;){const s=this.offset,r=this.text[this.offset++];if(r==='"')return n;if(r.charCodeAt(0)<32)throw new K(s);if(r!=="\\"){e&&(n+=r);continue}const i=this.offset,a=this.text[this.offset++];switch(a){case'"':case"\\":case"/":e&&(n+=a);break;case"b":e&&(n+="\b");break;case"f":e&&(n+="\f");break;case"n":e&&(n+=`
115
+ `);break;case"r":e&&(n+="\r");break;case"t":e&&(n+=" ");break;case"u":{const o=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(o))throw new K(this.offset);e&&(n+=String.fromCharCode(Number.parseInt(o,16))),this.offset+=4;break}default:throw new K(i)}}throw new K(this.offset)}consumeLiteral(e){let n=0;for(const s of e){if(this.text[this.offset+n]!==s)throw new K(this.offset+n);n++}this.offset+=e.length}consumeNumber(){if(this.text[this.offset]==="-"&&this.offset++,this.text[this.offset]==="0")this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new K(this.offset);if(this.text[this.offset]==="."){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new K(this.offset);for(;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++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new K(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){const e=this.text[this.offset];if(e!==" "&&e!==" "&&e!==`
116
+ `&&e!=="\r")return;this.offset++}}deletePointerSubtree(e){const n=`${e}/`;for(const s of Object.keys(this.propertyOrder))(s===e||s.startsWith(n))&&delete this.propertyOrder[s]}},u(Ct,"PropertyOrderCollector"),Ct);function ll(t,e,n){let s;try{s=JSON.parse(t)}catch(r){const i=r instanceof Error?r.message:String(r);let a=OO(i,t,e,n);if(!a){let o=0;try{new $a(t).collect()}catch(c){c instanceof K&&(o=c.offset)}a=yr(t,o,e,n)}throw new Ma(`Invalid JSON: ${i}`,a.line,a.column)}if(typeof s!="object"||s===null||Array.isArray(s))throw new Ma("JSON value must have an object root",e,n);return{value:s,propertyOrder:new $a(t).collect()}}u(ll,"parseOrderedJsonObject");var RO=u(t=>({shape:t.type==="normal"?"actor":t.type==="hollow"?"actor-hollow":t.type==="awesome"?"actor-awesome":"actor-icon",...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"actor",actorType:t.type,business:t.business,labelType:t.labelType,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"actorNode"),LO=u(t=>({shape:t.shape,...t.label===t.id?{}:{label:t.label},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"usecase",useCaseShape:t.shape,business:t.business,labelType:t.labelType,...t.stereotype?{stereotype:t.stereotype}:{},...t.parentId?{parentId:t.parentId}:{}}}),"useCaseNode"),IO=u(t=>({label:t.label,shape:"note",attrs:{kind:"note",target:t.target,labelType:t.labelType}}),"noteNode"),NO=u(t=>({label:t.id,shape:"json-table",...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"json",value:t.value,propertyOrder:t.propertyOrder,labelType:"text"}}),"jsonNode"),bO=u(t=>({id:t.id,source:t.source,target:t.target,...t.label?{label:t.label}:{},...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{relationshipType:t.type,arrowType:t.arrowType,minlen:t.minlen,explicitId:t.explicitId,animate:t.animate,...t.animation?{animation:t.animation}:{},...t.labelType?{labelType:t.labelType}:{}}}),"relationshipEdge"),vO=u(t=>({id:`${t.id}-edge`,source:t.id,target:t.target,attrs:{relationshipType:"note",arrowType:M.LINE_SOLID,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),_O=u((t,e,n,s)=>{const r={};for(const c of t.getActors().values())r[c.id]=RO(c);for(const c of t.getUseCases().values())r[c.id]=LO(c);for(const c of t.getNotes().values())r[c.id]=IO(c);for(const c of t.getJsonNodes().values())r[c.id]=NO(c);const i={};for(const c of t.getSystemBoundaries().values())i[c.id]={...c.label===c.id?{}:{title:c.label},nodes:[...c.members],...c.classes.length?{classes:[...c.classes]}:{},...c.styles.length?{styles:[...c.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:c.type,labelType:c.labelType}};const a={};for(const c of t.getClassDefs().values())a[c.id]={styles:[...c.styles]};const o=t.getDirection();return{version:1,diagramType:"usecase",source:e,header:{keyword:"usecase",direction:o==="TD"?"TB":o,span:n},...t.getAccTitle()?{accTitle:t.getAccTitle()}:{},...t.getAccDescription()?{accDescr:t.getAccDescription()}:{},nodes:r,edges:[...t.getRelationships().map(bO),...[...t.getNotes().values()].map(vO)],groups:i,classDefs:a,statements:s}},"buildUsecaseGraphAST"),V=u(t=>`line ${t.line}, column ${t.column} [${t.span[0]},${t.span[1]})`,"locationText"),Pa=u(t=>t===void 0?"":` (label "${t}")`,"labelSuffix"),ht=u(t=>t.generated?t.label:void 0,"generatedFrom"),Hs=u((t,e)=>{for(const n of e)t.includes(n)||t.push(n)},"pushUnique"),kt,CO=(kt=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()}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,n,s,r){this.metadataAssignments.push({target:e,targetLocation:n,metadata:s,statement:r})}addClassDef(e,n){this.classDefinitions.push({ids:e,styles:n})}addClassAssignment(e,n){this.classAssignments.push({targets:e,classes:n})}addStyleAssignment(e,n,s){this.styleAssignments.push({target:e,location:n,styles:s})}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){const n=new Map,s=new Map,r=new Map,i=new Map;for(const l of this.relationshipDrafts)this.recordFirst(i,l.source.id,l.source.location.span[0]),this.recordFirst(i,l.target.id,l.target.location.span[0]);for(const l of this.elements)this.recordFirst(i,l.id,l.location.span[0]);for(const l of this.boundaries)this.recordFirst(i,l.id,l.location.span[0]);for(const l of this.jsonDrafts)this.recordFirst(i,l.id,l.location.span[0]);const a=[...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,d)=>l.offset-d.offset);for(const l of a)l.type==="element"?this.collectElement(l.value,n,s):l.type==="boundary"?this.collectBoundary(l.value,n,r):l.type==="json"?this.registerUnique(n,l.value.id,"json",l.value.location,!1):this.registerUnique(n,l.value.explicitId,"edge",l.value.explicitIdLocation,!1);this.materializeElements(s,i),this.materializeBoundaries(r,i),this.materializeJson(i);const o=this.materializeRelationships(n,s,i);this.reorderElements(s,i),this.applyMetadataAssignments(n,s,r,o),this.validateAndRefreshElements(s),this.refreshBoundaries(r,s),this.materializeNotes(n),this.applyClassDefinitions(),this.applyClassesAndStyles(n,o),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...n].map(([l,d])=>[l,d.kind]));const c=_O(this,this.source,e,this.statements);return this.model.ast=c,this.db.commit(this.model),c}collectElement(e,n,s){const r=n.get(e.id),i=ht({generated:e.generated,label:e.label.text});r&&r.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and ${e.kind}`,e.location,r.location,i,ht(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,ht(r));const a=s.get(e.id);if(!a){const o={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(o,e.metadata),s.set(e.id,o),n.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??(a.shape=e.shape),a.parentId??(a.parentId=e.parentId),a.parentLocation??(a.parentLocation=e.parentLocation),a.stereotype??(a.stereotype=e.stereotype),a.stereotypeLocation??(a.stereotypeLocation=e.stereotype?e.location:void 0),Hs(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,n,s){const r=n.get(e.id),i=ht({generated:e.generated,label:e.label.text});r&&r.kind!=="boundary"&&this.conflict(`ID '${e.id}' is declared as both ${r.kind} and boundary`,e.location,r.location,i,ht(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,ht(r));const a=s.get(e.id);if(a){(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),Hs(a.classes,e.classes);return}s.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),n.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,n){for(const s of[...e.values()].sort((r,i)=>(n.get(r.id)??0)-(n.get(i.id)??0)))this.setElementModel(s)}materializeBoundaries(e,n){for(const s of[...e.values()].sort((r,i)=>(n.get(r.id)??0)-(n.get(i.id)??0)))this.model.systemBoundaries.set(s.id,{id:s.id,label:s.label.text,labelType:s.label.type,type:s.type??"rect",members:[],classes:[...s.classes],styles:[...s.styles]})}materializeJson(e){for(const n of[...this.jsonDrafts].sort((s,r)=>(e.get(s.id)??0)-(e.get(r.id)??0)))this.model.jsonNodes.set(n.id,{id:n.id,value:n.value,propertyOrder:n.propertyOrder,classes:[...n.classes],styles:[]})}materializeRelationships(e,n,s){const r=new Map;let i=0;for(const a of this.relationshipDrafts){const o=this.resolveEndpoint(a.source,e,n,s),c=this.resolveEndpoint(a.target,e,n,s);this.validateRelationship(a,o,c,e);const l=a.explicitId??`edge-${i++}`,d={id:l,explicitId:!!a.explicitId,source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(d),r.set(l,{draft:a,relationship:d})}return this.model.relationshipCounter=i,r}resolveEndpoint(e,n,s,r){if(e.classesOnReference&&!e.declaration)throw new Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${V(e.location)}`);const i=n.get(e.id);return i?i.kind:(s.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),n.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(r,e.id,e.location.span[0]),"usecase")}reorderElements(e,n){const s=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(const i of[...e.values()].sort((a,o)=>(n.get(a.id)??0)-(n.get(o.id)??0))){!s.has(i.id)&&!r.has(i.id)&&this.setElementModel(i);const a=s.get(i.id)??this.model.actors.get(i.id),o=r.get(i.id)??this.model.useCases.get(i.id);a?this.model.actors.set(i.id,a):o&&this.model.useCases.set(i.id,o)}}applyMetadataAssignments(e,n,s,r){for(const i of this.metadataAssignments){const a=e.get(i.target);if(!a){const o=this.inferMetadataKind(i.metadata);throw new Error(`Metadata target '${i.target}' is unresolved${o?` (metadata implies ${o})`:""} at ${V(i.targetLocation)}`)}if(a.kind==="actor"||a.kind==="usecase")this.applyStandaloneElementMetadata(n.get(i.target),i.metadata);else if(a.kind==="boundary"){const o=s.get(i.target);for(const c of i.metadata.properties)(c.key!=="type"||c.value!=="rect"&&c.value!=="package")&&this.invalidMetadata(i.target,a.kind,c),o.type=c.value}else if(a.kind==="edge"){const o=r.get(i.target);if(!o)throw new Error(`Metadata target '${i.target}' is not an explicit edge at ${V(i.targetLocation)}`);i.statement.kind="edgeMetadata",i.statement.edges=[{id:i.target,span:i.statement.span,idSpan:i.targetLocation.span,...i.statement.metadata?{metadata:i.statement.metadata}:{}}],delete i.statement.nodes;for(const c of i.metadata.properties)c.key==="animate"&&typeof c.value=="boolean"?o.relationship.animate=c.value:c.key==="animation"&&(c.value==="fast"||c.value==="slow")?(o.relationship.animation=c.value,o.relationship.animate=!0):this.invalidMetadata(i.target,a.kind,c)}else for(const o of i.metadata.properties)this.invalidMetadata(i.target,a.kind,o)}for(const{relationship:i}of r.values())i.animation&&(i.animate=!0)}applyStandaloneElementMetadata(e,n){for(const s of n.properties)e.kind==="actor"?this.applyActorProperty(e,s,!0):s.key==="business"&&typeof s.value=="boolean"?e.business=s.value:this.invalidMetadata(e.id,e.kind,s)}applyDeclarationMetadata(e,n){if(n)for(const s of n.properties)e.kind==="actor"?this.applyActorProperty(e,s,!1):s.key==="business"&&typeof s.value=="boolean"?(e.business!==void 0&&e.business!==s.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,s.location,e.location),e.business=s.value):this.invalidMetadata(e.id,e.kind,s)}applyActorProperty(e,n,s){n.key==="type"&&(n.value==="normal"||n.value==="hollow"||n.value==="awesome")?(!s&&e.actorType!==void 0&&e.actorType!==n.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,n.location,e.location),e.actorType=n.value):n.key==="icon"&&typeof n.value=="string"?(!s&&e.icon!==void 0&&e.icon!==n.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,n.location,e.location),e.icon=n.value):n.key==="business"&&typeof n.value=="boolean"?(!s&&e.business!==void 0&&e.business!==n.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}validateAndRefreshElements(e){for(const n of e.values()){const s=n.icon?"icon":n.actorType??"normal";if(n.kind==="actor"){if(n.icon&&n.actorType&&n.actorType!=="normal")throw new Error(`Actor '${n.id}' cannot combine icon with type '${n.actorType}' at ${V(n.location)}`);if(n.business&&(s==="icon"||s==="awesome"))throw new Error(`Business actor '${n.id}' must use normal or hollow geometry at ${V(n.location)}`)}else if((n.shape??"ellipse")==="rect"&&n.business)throw new Error(`Rectangular use case '${n.id}' cannot be a business use case at ${V(n.location)}`);this.setElementModel(n)}}refreshBoundaries(e,n){for(const s of e.values())s.members.length=0;for(const s of[...this.elements].sort((r,i)=>r.location.span[0]-i.location.span[0])){if(!s.parentId)continue;const r=e.get(s.parentId);if(!r)throw new Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${V(s.parentLocation??s.location)}`);r.members.includes(s.id)||r.members.push(s.id)}for(const s of n.values())if(s.parentId&&!e.has(s.parentId))throw new Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${V(s.parentLocation??s.location)}`);for(const s of e.values()){const r=this.model.systemBoundaries.get(s.id);r.type=s.type??"rect",r.members=[...s.members],r.classes=[...s.classes],r.styles=[...s.styles]}}materializeNotes(e){let n=0;for(const s of this.noteDrafts){const r=e.get(s.target);if(!r)throw new Error(`Note target '${s.target}' is unresolved at ${V(s.targetLocation)}`);r.kind!=="actor"&&r.kind!=="usecase"&&this.conflict(`Note target '${s.target}' must be an actor or use case, not ${r.kind}`,s.targetLocation,r.location);const i=`note-${n++}`;this.model.notes.set(i,{id:i,target:s.target,label:s.label.text,labelType:s.label.type})}this.model.noteCounter=n}applyClassDefinitions(){for(const e of this.classDefinitions)for(const n of e.ids)this.model.classDefs.set(n,{id:n,styles:[...e.styles]})}applyClassesAndStyles(e,n){for(const s of this.classAssignments)for(const r of s.targets)Hs(this.getStylable(r.id,e,n,r.location).classes,s.classes);for(const s of this.styleAssignments)this.getStylable(s.target,e,n,s.location).styles.push(...s.styles)}getStylable(e,n,s,r){var o,c;const i=(o=n.get(e))==null?void 0:o.kind,a=i==="actor"?this.model.actors.get(e):i==="usecase"?this.model.useCases.get(e):i==="boundary"?this.model.systemBoundaries.get(e):i==="json"?this.model.jsonNodes.get(e):i==="edge"?(c=s.get(e))==null?void 0:c.relationship:void 0;if(!a)throw new Error(`Class/style target '${e}' is unresolved or anonymous at ${V(r)}`);return a}validateRelationship(e,n,s,r){const i=u(a=>a==="actor"||a==="usecase"||a==="json","allowed");if(i(n)||this.conflict(`Relationship source '${e.source.id}' cannot be ${n}`,e.source.location,r.get(e.source.id).location),i(s)||this.conflict(`Relationship target '${e.target.id}' cannot be ${s}`,e.target.location,r.get(e.target.id).location),(e.type==="include"||e.type==="extend")&&(n!=="usecase"||s!=="usecase"))throw new Error(`${e.type} relationship requires use-case endpoints at ${V(e.location)}`);if(e.type==="generalization"&&(n!=="actor"&&n!=="usecase"||n!==s))throw new Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${V(e.location)}`);if(e.type==="association"&&(n==="json"||s==="json")&&![0,1,2].includes(e.arrowType))throw new Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${V(e.location)}`)}setElementModel(e){var n,s;if(e.kind==="actor"){const r=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:r,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:((n=this.model.actors.get(e.id))==null?void 0:n.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:((s=this.model.useCases.get(e.id))==null?void 0:s.styles)??[]})}inferMetadataKind(e){const n=new Set(["actor","usecase","boundary","edge"]);for(const s of e.properties)if(s.key==="icon")n.clear(),n.add("actor");else if(s.key==="animate"||s.key==="animation")n.clear(),n.add("edge");else if(s.key==="type")n.clear(),s.value==="rect"||s.value==="package"?n.add("boundary"):(s.value==="normal"||s.value==="hollow"||s.value==="awesome")&&n.add("actor");else if(s.key==="business")n.delete("boundary"),n.delete("edge");else return;return n.size===1?[...n][0]:void 0}invalidMetadata(e,n,s){throw new Error(`Metadata property '${s.key}' is invalid for ${n} '${e}' at ${V(s.location)}`)}registerUnique(e,n,s,r,i){const a=e.get(n);a&&this.conflict(`ID '${n}' is declared more than once (${a.kind} and ${s})`,r,a.location,void 0,ht(a)),e.set(n,{kind:s,location:r,generated:i})}recordFirst(e,n,s){const r=e.get(n);(r===void 0||s<r)&&e.set(n,s)}conflict(e,n,s,r,i){throw new Error(`${e} at ${V(n)}${Pa(r)}; previous declaration at ${V(s)}${Pa(i)}`)}},u(kt,"UsecaseModelBuilder"),kt),kO=en.getBaseCstVisitorConstructor(),wt,wO=(wt=class extends kO{constructor(){super(),this.builder=new CO(ss),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}build(e,n){this.source=n,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(n),this.visit(e)}start(e){const n=this.tokens(e,"USECASE")[0],s=[];for(const r of this.nodes(e,"line"))s.push(this.visit(r));this.builder.setStatements(s),this.builder.finalize(this.tokenSpan(n))}line(e){const n=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(n,this.visit(n))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){const n=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(n.slice(n.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){const n=this.tokens(e,"ACC_DESCR_LINE")[0],s=this.tokens(e,"ACC_DESCR_BLOCK")[0],r=n?n.image.slice(n.image.indexOf(":")+1).trim():s.image.slice(s.image.indexOf("{")+1,s.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(r),{kind:"accDescr",span:[0,0]}}actorStatement(e){const n=this.nodes(e,"actorItem"),s=n.map(l=>this.visit(l)),r=this.nodes(e,"relationTail")[0],i=s.map((l,d)=>this.actorOccurrence(n[d],l,!0));for(const l of s)this.builder.addElement(this.actorDraft(l));if(!r)return{kind:"node",span:[0,0],nodes:i};const a=this.visit(r);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));const o=this.relationshipDraft(s[0],a,this.nodeLocation(r));this.builder.addRelationship(o);const c=o.explicitId??`edge-${this.anonymousEdge++}`;return i.push(this.entityOccurrence(this.nodes(r.children,"entityName")[0],a.target,a.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:i,edges:[{id:c,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}actorItem(e){const n=this.visit(this.nodes(e,"actorName")[0]),s=this.nodes(e,"metadata")[0],r=this.nodes(e,"stereotype")[0],i=this.nodes(e,"classSuffix")[0],a=i?this.visit(i):{classes:[],spans:[]};return{...n,...s?{metadata:this.visit(s)}:{},...r?{stereotype:this.visit(r)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){const n=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(n){const i=this.nodes(e,"nodeLabel")[0],a=i?this.visit(i):this.tokenLabel(n);return{id:n.image,label:a,location:this.tokenLocation(n),generated:!1,classes:[],classSpans:[]}}const r=this.tokenLabel(s);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(s),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){const n=this.nodes(e,"actorItem"),s=n.map(r=>this.visit(r));for(const r of s)this.builder.addElement(this.actorDraft(r));return{kind:"node",span:[0,0],nodes:s.map((r,i)=>this.actorOccurrence(n[i],r,!0))}}entityStatement(e){const n=this.nodes(e,"entityName"),s=this.visit(n[0]),r=this.nodes(e,"relationTail")[0];if(!r)return s.explicitDeclaration=!0,s.shape??(s.shape="ellipse"),this.builder.addElement(this.entityDraft(s)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(n[0],s,!0)]};s.explicitDeclaration&&this.builder.addElement(this.entityDraft(s));const i=this.visit(r);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));const a={source:this.endpoint(s),target:this.endpoint(i.target),location:this.nodeLocation(r),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(a);const o=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(n[0],s,s.explicitDeclaration),this.entityOccurrence(this.nodes(r.children,"entityName")[0],i.target,i.target.explicitDeclaration)],edges:[{id:o,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){const n=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],r=this.nodes(e,"nodeLabel")[0],i=this.nodes(e,"useCaseMetadata")[0],a=this.nodes(e,"stereotype")[0],o=this.nodes(e,"classSuffix")[0],c=o?this.visit(o):{classes:[],spans:[]};if(n){const d=r?this.visit(r):this.tokenLabel(n),h=r?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:n.image,label:d,location:this.tokenLocation(n),generated:!1,...h?{shape:h}:{},...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:c.classes,classSpans:c.spans,explicitDeclaration:!!(h||i||a)}}const l=this.tokenLabel(s);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(s),generated:!0,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:c.classes,classSpans:c.spans,explicitDeclaration:!!(i||a)}}nodeLabel(e){const n=this.allTokens(e);if(n.length===1&&(n[0].tokenType.name==="PLAIN_STRING"||n[0].tokenType.name==="MARKDOWN_STRING"))return this.tokenLabel(n[0]);const s=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return{text:this.source.slice(s[0],s[1]),type:"text",span:s}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){const n=this.tokens(e,"IDENTIFIER")[0];return{...n?{explicitId:n.image,explicitIdLocation:this.tokenLocation(n)}:{},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:M.SOLID_ARROW,minlen:1};const n=this.tokens(e,"INCLUDE").length?"include":"extend",s=this.tokens(e,n==="include"?"INCLUDE":"EXTEND")[0];return{type:n,arrowType:M.SOLID_ARROW,label:{text:n,type:"text",span:this.tokenSpan(s)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(n=>this.visit(n)),location:this.ctxLocation(e)}}metadataProperty(e){const n=this.allTokens(e).filter(o=>o.tokenType.name!=="COLON"),s=n[0],r=n[1],i=r.tokenType.name==="TRUE"?!0:r.tokenType.name==="FALSE"?!1:this.decodePlain(r),a=[s.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(s),value:i,span:a,keySpan:this.contentSpan(s),valueSpan:this.contentSpan(r),location:this.tokenLocation(s)}}metadataSeparator(e){}systemBoundaryStatement(e){const n=this.visit(this.nodes(e,"systemBoundaryName")[0]),s=this.nodes(e,"classSuffix")[0],r=s?this.visit(s):{classes:[],spans:[]};n.classes=r.classes,this.builder.addBoundary(n);const i=this.parentBoundary;this.parentBoundary={id:n.id,location:n.location};const a=this.nodes(e,"systemBoundaryContent")[0],o=a?this.visit(a):[];this.parentBoundary=i;const c=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],d=l?this.visit(l):void 0,h={kind:"group",span:[0,0],group:n.id,idSpan:n.location.span,titleSpan:n.label.span,endSpan:this.tokenSpan(c),classSpans:r.spans,...d?{metadata:d.properties.map(({key:f,span:p,keySpan:g,valueSpan:T})=>({key:f,span:p,keySpan:g,valueSpan:T}))}:{},...o.length?{children:o}:{}};return d&&this.builder.addMetadataAssignment(n.id,n.location,d,h),h}systemBoundaryName(e){const n=this.tokens(e,"IDENTIFIER")[0];if(n){const i=this.nodes(e,"nodeLabel")[0];return{id:n.image,label:i?this.visit(i):this.tokenLabel(n),location:this.tokenLocation(n),generated:!1,classes:[]}}const s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],r=this.tokenLabel(s);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(s),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((s,r)=>{var i,a;return(((i=s.location)==null?void 0:i.startOffset)??0)-(((a=r.location)==null?void 0:a.startOffset)??0)}).map(s=>this.wrap(s,this.visit(s)))}boundaryElement(e){const n=this.nodes(e,"actorDeclarationOnly")[0];if(n)return this.visit(n);const s=this.nodes(e,"entityName")[0],r=this.visit(s);return r.explicitDeclaration=!0,r.shape??(r.shape="ellipse"),this.builder.addElement(this.entityDraft(r)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s,r,!0)]}}metadataAssignmentStatement(e){const n=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),s=this.visit(this.nodes(e,"metadata")[0]),r={kind:"metadata",span:[0,0],nodes:[{id:n.id,span:n.location.span,idSpan:n.location.span}],metadata:s.properties.map(({key:i,span:a,keySpan:o,valueSpan:c})=>({key:i,span:a,keySpan:o,valueSpan:c}))};return this.builder.addMetadataAssignment(n.id,n.location,s,r),r}metadataAssignmentTarget(e){const n=this.allTokens(e)[0],s=this.tokenLabel(n);return{id:n.tokenType.name==="IDENTIFIER"?n.image:this.generateId(s.text),location:this.tokenLocation(n)}}noteStatement(e){const n=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:n.image,targetLocation:this.tokenLocation(n),label:s,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:s.span,nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}stereotype(e){const n=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:n.image.trim(),span:this.tokenSpan(n)}}classSuffix(e){const n=this.tokens(e,"IDENTIFIER");return{classes:n.map(s=>s.image),spans:n.map(s=>this.tokenSpan(s))}}jsonStatement(e){const n=this.tokens(e,"JSON_DECLARATION_START")[0],s=this.tokens(e,"JSON_OBJECT_LITERAL")[0],r=/^json[\t ]+(\w+)/.exec(n.image),i=r[1],a=r[0].length-i.length,o={span:[n.startOffset+a,n.startOffset+a+i.length],line:n.startLine??1,column:(n.startColumn??1)+a},c=ll(s.image,s.startLine??1,s.startColumn??1),l=this.nodes(e,"classSuffix")[0],d=l?this.visit(l):{classes:[],spans:[]},h={id:i,value:c.value,propertyOrder:c.propertyOrder,location:o,classes:d.classes};return this.builder.addJson(h),{kind:"json",span:[0,0],nodes:[{id:i,span:o.span,idSpan:o.span,defines:!0,classSpans:d.spans}],classSpans:d.spans}}directionStatement(e){const n=this.allTokens(e).find(s=>["TD","TB","BT","RL","LR"].includes(s.tokenType.name));return this.builder.setDirection(n.image),{kind:"direction",span:[0,0]}}classDefStatement(e){const n=this.tokens(e,"IDENTIFIER"),s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(n.map(r=>r.image),s),{kind:"classDef",span:[0,0],ref:n[0].image,refSpan:this.tokenSpan(n[0])}}classStatement(e){const n=this.tokens(e,"IDENTIFIER");let s=1;for(;s<n.length&&this.source.slice((n[s-1].endOffset??n[s-1].startOffset)+1,n[s].startOffset).includes(",");s++);const r=n.slice(0,s).map(a=>({id:a.image,location:this.tokenLocation(a)})),i=n.slice(s).map(a=>a.image);return this.builder.addClassAssignment(r,i),{kind:"classAssign",span:[0,0],ref:i[0],refSpan:this.tokenSpan(n[s]),nodes:r.map(({id:a,location:o})=>({id:a,span:o.span,idSpan:o.span}))}}styleStatement(e){const n=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(n.image,this.tokenLocation(n),s),{kind:"style",span:[0,0],nodes:[{id:n.image,span:this.tokenSpan(n),idSpan:this.tokenSpan(n)}]}}styles(e){return this.nodes(e,"styleValue").map(n=>this.visit(n))}styleValue(e){const n=this.allTokens(e),s=[n[0].startOffset,(n.at(-1).endOffset??n.at(-1).startOffset)+1];return this.source.slice(s[0],s[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(n=>n.image).join("")}forwardSolidOperator(e){const n=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:M.SOLID_ARROW,minlen:this.solidMinlen(n)}}backwardSolidOperator(e){const n=this.tokens(e,"BACKWARD_SOLID")[0],s=this.nodes(e,"edgeLabel")[0],r=s?this.tokens(e,"MARKERLESS_SOLID").at(-1):n;return{type:"association",arrowType:M.BACK_ARROW,minlen:this.solidMinlen(r),...s?{label:this.visit(s)}:{}}}markerlessSolidOperator(e){const n=this.nodes(e,"edgeLabel")[0],s=this.allTokens(e);if(!n)return{type:"association",arrowType:M.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};const r=s.at(-1),i=r.tokenType.name==="FORWARD_SOLID"?M.SOLID_ARROW:r.tokenType.name==="FORWARD_CIRCLE"?M.CIRCLE_ARROW:r.tokenType.name==="FORWARD_CROSS"?M.CROSS_ARROW:M.LINE_SOLID;return{type:"association",arrowType:i,label:this.visit(n),minlen:i===M.SOLID_ARROW||i===M.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(e){return{type:"association",arrowType:M.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){const n=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:M.CIRCLE_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:M.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){const n=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:M.CROSS_ARROW_REVERSED,minlen:1,...n?{label:this.visit(n)}:{}}}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,n=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:n,classesOnReference:e.classes.length>0}}relationshipDraft(e,n,s){return{source:this.endpoint(e,!0),target:this.endpoint(n.target),location:s,...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow}}actorOccurrence(e,n,s){return{id:n.id,span:this.nodeSpan(e),idSpan:n.location.span,labelSpan:n.label.span,...s?{defines:!0}:{},...n.stereotype?{stereotypeSpan:n.stereotype.span}:{},...n.metadata?{metadata:n.metadata.properties.map(({key:r,span:i,keySpan:a,valueSpan:o})=>({key:r,span:i,keySpan:a,valueSpan:o}))}:{},...n.classSpans.length?{classSpans:n.classSpans}:{}}}entityOccurrence(e,n,s){return this.actorOccurrence(e,n,s)}wrap(e,n){if(n.kind==="blank"||n.kind==="comment")return n;n.span=this.nodeSpan(e);for(const s of n.edges??[])s.span=n.span;return n}tokenLabel(e){const n=e.tokenType.name==="MARKDOWN_STRING"?"markdown":"text",s=n==="markdown"?2:e.tokenType.name==="PLAIN_STRING"?1:0,r=this.tokenSpan(e,s);return{text:this.source.slice(r[0],r[1]),type:n,span:r}}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){var n;return Math.max(1,(((n=e.image.match(/-/g))==null?void 0:n.length)??2)-1)}nodeLocation(e){const n=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:n.startLine??1,column:n.startColumn??1}}ctxLocation(e){const n=this.allTokens(e).filter(i=>i.tokenType.name!=="NEWLINE"&&i.tokenType.name!=="EOF"),s=n[0],r=n.at(-1);return{span:[s.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:s.startLine??1,column:s.startColumn??1}}tokenLocation(e){const n=e.tokenType.name==="PLAIN_STRING"?1:e.tokenType.name==="MARKDOWN_STRING"?2:0;return{span:this.tokenSpan(e,n),line:e.startLine??1,column:(e.startColumn??1)+n}}nodeSpan(e){const n=this.allTokens(e.children).filter(i=>i.tokenType.name!=="NEWLINE"&&i.tokenType.name!=="EOF"),s=n[0],r=n.at(-1);if(!s||!r)throw new Error("Usecase CST node has no source token");return[s.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(e,n=0){return[e.startOffset+n,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-n)]}nodes(e,n){return(e[n]??[]).filter(s=>"children"in s)}tokens(e,n){return(e[n]??[]).filter(s=>"tokenTypeIdx"in s)}firstNode(e,...n){for(const s of n){const r=this.nodes(e,s)[0];if(r)return r}throw new Error(`Usecase CST is missing one of: ${n.join(", ")}`)}allTokens(e){const n=[];for(const s of Object.values(e))for(const r of s)"tokenTypeIdx"in r?n.push(r):n.push(...this.allTokens(r.children));return n.sort((s,r)=>s.startOffset-r.startOffset)}},u(wt,"UsecaseVisitor"),wt),xO=new wO,MO={parse:u(async t=>{ss.clear(),en.input=[];try{Ac({diagramType:"usecase",lexer:yO,parser:en,entry:u(()=>en.start(),"entry"),visit:u(e=>xO.build(e,t),"visit")},t)}catch(e){ss.clear();const n=en.errors[0];if(n){const{token:s}=n,r=Number.isFinite(s.startOffset)?s.startOffset:t.length,i=typeof s.endOffset=="number"&&Number.isFinite(s.endOffset)?s.endOffset+1:r,a=s.startLine??t.slice(0,r).split(/\r\n|\r|\n/).length,o=Math.max(t.lastIndexOf(`
117
+ `,r-1),t.lastIndexOf("\r",r-1)),c=s.startColumn??r-o,l=e instanceof Error?e.message:String(e);throw new Error(`${l} at line ${a}, column ${c} [${r},${i})`)}throw e}},"parse")},$O=["point","circle","cross","extension"],hl={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Ua=u((t,e)=>{const[n,s]=[t,e].map(r=>r.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${n}-${s}`},"usecaseDomId"),PO=u(t=>`usecase-${t.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),ks=u((t,e)=>e!=="markdown"?t:vl(t).map(n=>n.map(s=>s.content).join(" ")).join(`
118
+ `),"getAccessibleLabel"),UO=u(t=>{const e=ks(t.label??t.id,t.labelType);if(hl[t.shape]){const s=t.actorType&&t.actorType!=="normal"?`${t.actorType} `:"",r=t.business?"business ":"",i=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${r}${s}actor ${e}${i}`}if(t.shape==="note")return`Note for ${t.noteTargetLabel??t.noteTarget??""}: ${e}`;if(t.shape==="usecaseJsonTable"){const s=(t.jsonRows??[]).map(r=>`${r.accessibleKey}: ${r.value}`).join("; ");return s?`${e}: ${s}`:e}const n=t.stereotype?`, stereotype ${t.stereotype}`:"";return`${t.business?"business ":""}use case ${e}${n}`},"getUsecaseNodeAccessibleName"),DO=u(t=>`${t.boundaryType} system boundary ${ks(t.label??t.id,t.labelType)}`,"getUsecaseBoundaryAccessibleName"),FO=u(t=>t.relationshipType==="note"?"":`${t.relationshipType==="association"&&t.label?`association ${ks(t.label,t.labelType)}`:t.relationshipType} from ${t.sourceLabel} to ${t.targetLabel}`,"getUsecaseEdgeAccessibleName"),Lt=u(t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),Da=u(t=>t.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),BO=u((t,e)=>{var n;t.diagramId=e,t.markers=[...$O];for(const s of t.nodes){const r=s;if(r.domId=PO(s.id),s.label!==void 0&&s.labelType==="text"&&(s.label=Lt(s.label)),s.stereotype&&(s.stereotype=Lt(s.stereotype)),!s.isGroup&&s.shape==="usecaseJsonTable"&&(s.jsonRows=(n=s.jsonRows)==null?void 0:n.map(i=>({...i,key:Lt(i.key),value:Lt(i.value)}))),!s.isGroup&&(s.shape==="usecaseEllipse"||s.shape==="rect")&&s.stereotype){const i=s.label??Lt(s.id);s.label=`«${Da(s.stereotype)}»<br/>${s.labelType==="text"?Da(i):i}`,s.labelType="markdown",r.hasFoldedStereotype=!0,delete s.stereotype}}for(const s of t.edges)s.label!==void 0&&s.labelType==="text"&&(s.label=Lt(s.label));return t},"prepareUsecaseLayoutData"),GO=u((t,e,n)=>{var r;for(const i of e.nodes){const a=typeof i.domId=="string"?i.domId:Ua(e.diagramId,i.id),o=t.select(`#${a}`),c=i.isGroup?"boundary":hl[i.shape]?"actor":i.shape==="note"?"note":i.shape==="usecaseJsonTable"?"json":"usecase",l=n.nodes.get(i.id)??i.id;if(o.attr("data-usecase-id",i.id).attr("data-usecase-kind",c).attr("role","img").attr("aria-label",l),!i.isGroup&&(i.shape==="usecaseEllipse"||i.shape==="rect")&&"hasFoldedStereotype"in i&&i.hasFoldedStereotype===!0){const d=o.node(),h=d==null?void 0:d.querySelector(".nodeLabel"),f=(h==null?void 0:h.querySelector("p"))??h,p=f==null?void 0:f.firstChild;if(f&&(p==null?void 0:p.nodeType)===3){const g=f.ownerDocument.createElement("span");g.className="usecase-stereotype",f.insertBefore(g,p),g.appendChild(p)}else(r=d==null?void 0:d.querySelector(".label tspan tspan, .label tspan"))==null||r.classList.add("usecase-stereotype")}}const s=new Map(e.edges.map(i=>[i.id,i]));t.selectAll('path[data-et="edge"]').each(function(){const i=s.get(this.getAttribute("data-id")??"");if(!i)return;const a=_l(this);a.attr("id",Ua(e.diagramId,i.id)).attr("data-usecase-id",i.id).attr("data-usecase-kind",i.internal?"note-connector":"relationship"),i.internal?a.attr("aria-hidden","true"):a.attr("role","img").attr("aria-label",n.edges.get(i.id)??i.id)})},"annotateUsecaseElements"),Fa=u((t,e)=>{t.style("--mermaid-usecase-actor-font-size",`${e.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",e.actorFontFamily).style("--mermaid-usecase-actor-font-weight",e.actorFontWeight).style("--mermaid-usecase-font-size",`${e.usecaseFontSize}px`).style("--mermaid-usecase-font-family",e.usecaseFontFamily).style("--mermaid-usecase-font-weight",e.usecaseFontWeight)},"applyUsecaseFonts"),WO=u(async(t,e,n,s)=>{var h;Tl.info("Drawing usecase diagram (unified)",e);const{layout:r}=Wa(),i=s.db,a=i.getData(),o=new Map(a.nodes.map(f=>[f.id,ks(f.label??f.id,f.labelType)])),c={nodes:new Map(a.nodes.map(f=>[f.id,f.isGroup?DO(f):UO(f.shape==="note"?{...f,noteTargetLabel:o.get(f.noteTarget??"")}:f)])),edges:new Map(a.edges.map(f=>[f.id,FO({...f,sourceLabel:o.get(f.source)??f.sourceLabel,targetLabel:o.get(f.target)??f.targetLabel})]))},l=fl(e,a.config.securityLevel);a.layoutAlgorithm=El(r),BO(a,e),Fa(l,a),await yl(a,l),GO(l,a,c);const d=a.diagramPadding;Al.insertTitle(l,"usecaseDiagramTitleText",0,((h=i.getDiagramTitle)==null?void 0:h.call(i))??""),pl(l,d,"usecaseDiagram",a.useMaxWidth),Fa(l,a)},"draw"),jO={draw:WO},KO=u(t=>({actorBkg:t.usecaseActorBkg??t.actorBkg??t.mainBkg,actorBorder:t.usecaseActorBorder??t.actorBorder??t.primaryColor,bkg:t.usecaseBkg??t.mainBkg,border:t.usecaseBorder??t.nodeBorder??t.primaryColor,boundaryBkg:t.usecaseBoundaryBkg??t.clusterBkg,boundaryBorder:t.usecaseBoundaryBorder??t.clusterBorder,includeLine:t.usecaseIncludeLine??t.lineColor,extendLine:t.usecaseExtendLine??t.lineColor}),"roleColors"),zO=u(t=>{var l;const{theme:e,bkgColorArray:n,borderColorArray:s}=t;if(!Ll(e,s))return"";const r=((l=Il().usecase)==null?void 0:l.colorScheme)==="rotate",i=Vt(t.look),a=i==="handDrawn",o=Nl(n);let c="";for(let d=0;d<bl(s);d++){const h=s[d],f=o?`fill: ${n[d%n.length]};`:"",p=`[data-look="${i}"][data-color-id="color-${d}"]`;c+=`
119
+
120
+ & ${p}.system-boundary rect.boundary-body,
121
+ & ${p}.system-boundary rect.boundary-tab,
122
+ & ${p}.system-boundary .boundary-body path,
123
+ & ${p}.system-boundary .boundary-tab path {
124
+ stroke: ${h};
125
+ ${f}
126
+ }
127
+ `,r&&(c+=`
128
+
129
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
130
+ the business variant.
131
+
132
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
133
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
134
+ fill stroked in the background colour, with no class to tell them apart. Stroking
135
+ both repaints the fill lines as border colour and the shape collapses into a solid
136
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
137
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
138
+ & ${p}.usecase-element ellipse,
139
+ & ${p}.usecase-element rect {
140
+ stroke: ${h};
141
+ ${f}
142
+ }
143
+
144
+ /* The business marker is a single classed path, so it can be reached safely by name --
145
+ without it the marker keeps the uniform border beside a palette-coloured body. No
146
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
147
+ & ${p}.usecase-element .usecase-business-marker {
148
+ stroke: ${h};
149
+ }
150
+
151
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
152
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
153
+ winning and a hollow actor stays hollow. Same reason as above for not descending
154
+ into the handDrawn paths. */
155
+ & ${p}.usecase-actor .usecase-actor-shape,
156
+ & ${p}.usecase-actor .usecase-actor-hollow,
157
+ & ${p}.usecase-actor .usecase-actor-awesome,
158
+ & ${p}.usecase-actor .usecase-actor-icon {
159
+ stroke: ${h};
160
+ ${f}
161
+ }
162
+ ${a?"":`
163
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
164
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
165
+ and a value set directly on the child always beats one inherited from the parent,
166
+ whatever the parent rule's specificity. So name the children too.
167
+
168
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
169
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
170
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
171
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
172
+ & ${p}.usecase-actor .usecase-actor-glyph path,
173
+ & ${p}.usecase-actor .usecase-actor-glyph circle {
174
+ stroke: ${h};
175
+ }
176
+ `}
177
+ `)}return c},"genColor"),HO=u(t=>{const e=KO(t),n=Vt(t.look)==="handDrawn";return`
178
+ ${zO(t)}
179
+ & .usecase-actor {
180
+ color: ${t.actorTextColor??t.primaryTextColor};
181
+ }
182
+
183
+ & .usecase-actor-shape,
184
+ & .usecase-actor-hollow,
185
+ & .usecase-actor-awesome,
186
+ & .usecase-actor-icon {
187
+ fill: ${e.actorBkg};
188
+ stroke: ${e.actorBorder};
189
+ stroke-width: 2px;
190
+ }
191
+ ${n?"":`
192
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
193
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
194
+ the glyph's own paths, and a value set directly on a child always beats one inherited
195
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
196
+ without this every actor renders in the node border colour rather than the actor
197
+ colour the rule above asks for.
198
+
199
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
200
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
201
+ depend on which stylesheet is concatenated last.
202
+
203
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
204
+ & .node.usecase-actor .usecase-actor-glyph path,
205
+ & .node.usecase-actor .usecase-actor-glyph circle {
206
+ stroke: ${e.actorBorder};
207
+ }
208
+ `}
209
+ & .usecase-actor .nodeLabel,
210
+ & .actor-label {
211
+ color: ${t.actorTextColor??t.primaryTextColor};
212
+ fill: ${t.actorTextColor??t.primaryTextColor};
213
+ font-family: var(--mermaid-usecase-actor-font-family, ${t.fontFamily});
214
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
215
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
216
+ }
217
+
218
+ & .usecase-element ellipse,
219
+ & .usecase-element rect,
220
+ & .usecase-business ellipse,
221
+ & .usecase-business rect {
222
+ fill: ${e.bkg};
223
+ stroke: ${e.border};
224
+ stroke-width: 2px;
225
+ }
226
+ ${n?"":`
227
+ /* The same interception the actor glyph hits, one element down: neo ships
228
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
229
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
230
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
231
+ equivalent neo rule and is already correct; restating it here costs nothing and means
232
+ the two forms cannot drift apart again.
233
+
234
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
235
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
236
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
237
+ exists. */
238
+ & [data-look="${Vt(t.look)}"].node.usecase-element ellipse,
239
+ & [data-look="${Vt(t.look)}"].node.usecase-element rect {
240
+ fill: ${e.bkg};
241
+ stroke: ${e.border};
242
+ }
243
+
244
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
245
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
246
+ & [data-look="${Vt(t.look)}"].node.usecase-element .usecase-business-marker {
247
+ stroke: ${e.border};
248
+ }
249
+ `}
250
+ & .usecase-element .nodeLabel,
251
+ & .usecase-label {
252
+ color: ${t.primaryTextColor};
253
+ fill: ${t.primaryTextColor};
254
+ font-family: var(--mermaid-usecase-font-family, ${t.fontFamily});
255
+ font-size: var(--mermaid-usecase-font-size, 12px);
256
+ font-weight: var(--mermaid-usecase-font-weight, normal);
257
+ }
258
+
259
+ & .usecase-stereotype,
260
+ & .usecase-business-marker {
261
+ color: ${t.primaryTextColor};
262
+ fill: ${t.primaryTextColor};
263
+ stroke: ${e.border};
264
+ }
265
+
266
+ & .system-boundary rect.boundary-body,
267
+ & .system-boundary rect.boundary-tab,
268
+ & .system-boundary-package-tab {
269
+ fill: ${e.boundaryBkg};
270
+ stroke: ${e.boundaryBorder};
271
+ stroke-width: 1px;
272
+ }
273
+
274
+ & .system-boundary-title text {
275
+ fill: ${t.titleColor??t.primaryTextColor};
276
+ }
277
+
278
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
279
+ 'color' on the span, and that has to stay inheritable by its children. */
280
+ & .system-boundary-title span {
281
+ color: ${t.titleColor??t.primaryTextColor};
282
+ }
283
+
284
+ & .usecase-note {
285
+ fill: ${t.noteBkgColor};
286
+ stroke: ${t.noteBorderColor};
287
+ color: ${t.noteTextColor};
288
+ }
289
+
290
+ & .usecase-note .nodeLabel {
291
+ color: ${t.noteTextColor};
292
+ fill: ${t.noteTextColor};
293
+ }
294
+
295
+ & .usecase-json-table,
296
+ & .usecase-json-table rect,
297
+ & .usecase-json-cell {
298
+ fill: ${t.mainBkg};
299
+ stroke: ${t.nodeBorder??t.primaryColor};
300
+ }
301
+
302
+ & .usecase-json-title,
303
+ & .usecase-json-key,
304
+ & .usecase-json-value {
305
+ color: ${t.primaryTextColor};
306
+ fill: ${t.primaryTextColor};
307
+ }
308
+
309
+ & .relationship {
310
+ fill: none;
311
+ stroke: ${t.lineColor};
312
+ }
313
+
314
+ & .relationship-include,
315
+ & .relationship-extend,
316
+ & .relationship-note {
317
+ stroke-dasharray: 3;
318
+ }
319
+
320
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
321
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
322
+ & .relationship-include {
323
+ stroke: ${e.includeLine};
324
+ }
325
+
326
+ & .relationship-extend {
327
+ stroke: ${e.extendLine};
328
+ }
329
+
330
+ & .relationship.edge-animation-fast,
331
+ & .relationship.edge-animation-slow {
332
+ stroke-linecap: round;
333
+ }
334
+
335
+ & .edgeLabel,
336
+ & .edgeLabel p {
337
+ background-color: ${t.edgeLabelBackground};
338
+ }
339
+
340
+ & .labelBkg {
341
+ background-color: ${t.edgeLabelBackground};
342
+ padding: 0 2px;
343
+ }
344
+
345
+ & .edgeLabel .label rect {
346
+ fill: ${t.edgeLabelBackground};
347
+ }
348
+
349
+ & .relationship-label,
350
+ & .edgeLabel {
351
+ color: ${t.primaryTextColor};
352
+ fill: ${t.primaryTextColor};
353
+ font-family: ${t.fontFamily};
354
+ font-size: 10px;
355
+ font-weight: normal;
356
+ }
357
+
358
+ & .marker,
359
+ & .marker.point,
360
+ & .marker.circle,
361
+ & .marker.cross {
362
+ fill: ${t.lineColor};
363
+ stroke: ${t.lineColor};
364
+ }
365
+
366
+ & .marker.extension {
367
+ fill: ${t.mainBkg};
368
+ stroke: ${t.lineColor};
369
+ }
370
+ `},"getStyles"),VO=HO,ZO={parser:MO,db:ss,renderer:jO,styles:VO};export{ZO as diagram};