@maggioli-rd/aicore-agent-chat 1.2.0 → 2.0.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 (146) hide show
  1. package/README.md +36 -18
  2. package/dist/aicore-agent-chat.js +164 -53
  3. package/dist/aicore-agent-chat.js.map +1 -1
  4. package/dist/bundle/a2ui-C-LAbJcp.js +87 -0
  5. package/dist/bundle/abnfDiagram-S7VZAUFO-DxkzIS8G.js +1 -0
  6. package/dist/bundle/architecture-WOLXFQ4H-BXMyXdT1.js +1 -0
  7. package/dist/bundle/architectureDiagram-YGSQEFNW-BmsDn6Ho.js +36 -0
  8. package/dist/bundle/backstage-Bfl3Tyo5.js +86 -0
  9. package/dist/bundle/blockDiagram-APKKGZFW-bG_MVPzT.js +140 -0
  10. package/dist/bundle/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
  11. package/dist/bundle/c4Diagram-KJ2TOQU5-BVad-wQe.js +38 -0
  12. package/dist/bundle/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  13. package/dist/bundle/chunk-5VM5RSS4-CwNG0iBi.js +15 -0
  14. package/dist/bundle/chunk-6MUBBAK2-CeH4cZO-.js +2 -0
  15. package/dist/bundle/chunk-AXFCVDMN-D0Vqm50X.js +62 -0
  16. package/dist/bundle/chunk-BG4553SI-DUBI9JbR.js +127 -0
  17. package/dist/bundle/chunk-DQASFODM-DBWVlIjs.js +10 -0
  18. package/dist/bundle/chunk-DUW6YSOI-ChybIQ82.js +1 -0
  19. package/dist/bundle/chunk-HFQBQIA3-D2xPptW8.js +1 -0
  20. package/dist/bundle/chunk-J5ZVWO5B-DHB__t6z.js +1 -0
  21. package/dist/bundle/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  22. package/dist/bundle/chunk-KQLB2F66-BRGnyo9e.js +1 -0
  23. package/dist/bundle/chunk-KS47KZWR-DV3Gxewa.js +1 -0
  24. package/dist/bundle/chunk-LEVMRMFU-BdDTT4pw.js +1 -0
  25. package/dist/bundle/chunk-M57EVK23-BRqFqW5o.js +1 -0
  26. package/dist/bundle/chunk-NGNAAXSQ-DreF1ykJ.js +214 -0
  27. package/dist/bundle/chunk-OY52VR5R-BamrP8d_.js +88 -0
  28. package/dist/bundle/chunk-QB3YPZ4I-BqUUL29j.js +213 -0
  29. package/dist/bundle/chunk-R3KSYZAL-gmtEjdKU.js +1 -0
  30. package/dist/bundle/chunk-STOXU5M4-DdqxXfKq.js +72 -0
  31. package/dist/bundle/chunk-TU62E6Q5-B4GgWjUW.js +1 -0
  32. package/dist/bundle/chunk-X4PVCEUW-BcN5Aq5G.js +1 -0
  33. package/dist/bundle/chunk-XXDRQBXY-BIvjAdC_.js +1 -0
  34. package/dist/bundle/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  35. package/dist/bundle/classDiagram-v2-L25IHNXF-Dw7so3mk.js +217 -0
  36. package/dist/bundle/cose-bilkent-JH36ORCC-DUvnuVrm.js +1 -0
  37. package/dist/bundle/cynefin-EF2NZ3EQ-CcVPiRLN.js +1 -0
  38. package/dist/bundle/cynefinDiagram-L36ESFBY-eO6Z3Kvn.js +62 -0
  39. package/dist/bundle/cytoscape.esm-CsT4DLSP.js +321 -0
  40. package/dist/bundle/d3-hierarchy-i5r04UUG.js +1 -0
  41. package/dist/bundle/d3-scale-BEO6F4Sh.js +1 -0
  42. package/dist/bundle/d3-scale-chromatic-DhHjp77O.js +1 -0
  43. package/dist/bundle/d3-selection-CBFxn8wf.js +1 -0
  44. package/dist/bundle/d3-shape-v1Y4qR5e.js +1 -0
  45. package/dist/bundle/dagre-SPEB5RXH-ByBZqBaT.js +4 -0
  46. package/dist/bundle/diagram-3B7GL73J-BkQkIpxz.js +200 -0
  47. package/dist/bundle/diagram-DNEMPZML-DYthXzRv.js +24 -0
  48. package/dist/bundle/diagram-L3MUGCDN-D4DIzfHH.js +41 -0
  49. package/dist/bundle/diagram-LA4NIPWU-C2P-hZD1.js +24 -0
  50. package/dist/bundle/diagram-MHCOC4E2-BwauFnTV.js +3 -0
  51. package/dist/bundle/diagram-XPFHEONP-DC_v3Llc.js +30 -0
  52. package/dist/bundle/dist-CwuaKeLF.js +1 -0
  53. package/dist/bundle/ebnfDiagram-UZSYDL2S-CmwGlC8L.js +1 -0
  54. package/dist/bundle/elk-XV6XMXQE-CTlty3p3.js +27 -0
  55. package/dist/bundle/erDiagram-EYBAPDEH-Bu6phvJH.js +99 -0
  56. package/dist/bundle/eventmodeling-K75KTNOO-B1q0nOJE.js +1 -0
  57. package/dist/bundle/flowDiagram-MALGAFMO-D9D_AzXh.js +1 -0
  58. package/dist/bundle/ganttDiagram-23REXITY-COK7rxO4.js +292 -0
  59. package/dist/bundle/gitGraph-VSP46ZUC-DS7S_jKI.js +1 -0
  60. package/dist/bundle/gitGraphDiagram-STJD7YCW-DhVK8Hqh.js +106 -0
  61. package/dist/bundle/graphlib-Bgy7WbC7.js +1 -0
  62. package/dist/bundle/info-OHQRW6UA-BjEWvFlW.js +1 -0
  63. package/dist/bundle/infoDiagram-KBXO4MBG-Dg3zWdHP.js +2 -0
  64. package/dist/bundle/ishikawaDiagram-M35NCXHK-C2g8ghrV.js +70 -0
  65. package/dist/bundle/journeyDiagram-OPLOXDXO-DMZkL-i1.js +139 -0
  66. package/dist/bundle/kanban-definition-BZKZHSQY-Dr43IiJD.js +89 -0
  67. package/dist/bundle/katex-rAoShGnF.js +257 -0
  68. package/dist/bundle/math-Cx-Q-b8s.js +262 -0
  69. package/dist/bundle/mermaid-DaDuEHir.js +43 -0
  70. package/dist/bundle/mermaid-parser.core-Bv_Zx_ZE.js +6 -0
  71. package/dist/bundle/mindmap-definition-I2QAS2VK-BXCWJ_1R.js +98 -0
  72. package/dist/bundle/packet-JDAUHWVQ-CgB2qE5t.js +1 -0
  73. package/dist/bundle/pegDiagram-FD4XPPHP-CR58gOgF.js +1 -0
  74. package/dist/bundle/pie-XZMESJXO-CvXWTfIG.js +1 -0
  75. package/dist/bundle/pieDiagram-J4AKIIQI-D0GhbNJg.js +39 -0
  76. package/dist/bundle/quadrantDiagram-XTYBLID2-BKBEdwvC.js +7 -0
  77. package/dist/bundle/radar-ABXABTNO-8V_xx_AB.js +1 -0
  78. package/dist/bundle/railroad-I3PHUGI6-Bvb0GUva.js +1 -0
  79. package/dist/bundle/railroad-abnf-LNEFI6M7-D8xGcObq.js +1 -0
  80. package/dist/bundle/railroad-ebnf-DWYD2UWJ-Ch8wBawI.js +1 -0
  81. package/dist/bundle/railroad-peg-JR7BVNR7-CGndbjed.js +1 -0
  82. package/dist/bundle/railroadDiagram-MRQ6NCDL-DvqHkO2C.js +1 -0
  83. package/dist/bundle/requirementDiagram-Y7LWUY3S-bCLAM9sl.js +84 -0
  84. package/dist/bundle/rolldown-runtime-BNaE-Ejt.js +1 -0
  85. package/dist/bundle/rough.esm-Dy-Kn_BL.js +1 -0
  86. package/dist/bundle/sankeyDiagram-WGJFYUXA-8ehuPvHQ.js +40 -0
  87. package/dist/bundle/sequenceDiagram-5NDRBG5M-Cdg1YzMw.js +169 -0
  88. package/dist/bundle/sizeCapture-INFHLROL-Ct7XApxm.js +1 -0
  89. package/dist/bundle/stateDiagram-v2-FJ4FJNEA-B69v2YYC.js +291 -0
  90. package/dist/bundle/swimlanes-UMQ2AFYF-C_qI6rnK.js +1 -0
  91. package/dist/bundle/swimlanesDiagram-OMPLPG4O-CS11qSCX.js +8 -0
  92. package/dist/bundle/timeline-definition-SEUHKTQE-BCU0-H8D.js +120 -0
  93. package/dist/bundle/treeView-D4JQ5SDB-CpjURS-c.js +1 -0
  94. package/dist/bundle/treemap-SAJKECNS-CFFTaiIN.js +1 -0
  95. package/dist/bundle/usecaseDiagram-AFA6YXN4-46V1jsea.js +476 -0
  96. package/dist/bundle/vega-eBn1AexV.js +33 -0
  97. package/dist/bundle/vennDiagram-NNMJR3RB-q4Q4x2Q6.js +34 -0
  98. package/dist/bundle/wardley-7MLQ67FV-DhnATL7b.js +1 -0
  99. package/dist/bundle/wardleyDiagram-S7YFUSEH-BHIufnZW.js +78 -0
  100. package/dist/bundle/xychartDiagram-GGNKY7IX-CxAjpN3O.js +7 -0
  101. package/dist/chunks/a2ui-Da_YceSP.js +961 -0
  102. package/dist/chunks/a2ui-Da_YceSP.js.map +1 -0
  103. package/dist/chunks/backstage-TkKENlNl.js +1008 -0
  104. package/dist/chunks/backstage-TkKENlNl.js.map +1 -0
  105. package/dist/chunks/{core-Db3hnKpM.js → core-4PRAI1Mt.js} +60 -5
  106. package/dist/chunks/core-4PRAI1Mt.js.map +1 -0
  107. package/dist/chunks/math-D5IXRTov.js +86 -0
  108. package/dist/chunks/math-D5IXRTov.js.map +1 -0
  109. package/dist/chunks/mermaid-j9RNkOnL.js +197 -0
  110. package/dist/chunks/mermaid-j9RNkOnL.js.map +1 -0
  111. package/dist/chunks/rich-CdNA4NuG.js +156 -0
  112. package/dist/chunks/rich-CdNA4NuG.js.map +1 -0
  113. package/dist/chunks/sanitize-COLQzplk.js +240 -0
  114. package/dist/chunks/sanitize-COLQzplk.js.map +1 -0
  115. package/dist/chunks/{src-CYXMXds2.js → src-PkQozp4M.js} +725 -146
  116. package/dist/chunks/src-PkQozp4M.js.map +1 -0
  117. package/dist/chunks/vega-B07F6TI4.js +301 -0
  118. package/dist/chunks/vega-B07F6TI4.js.map +1 -0
  119. package/dist/core.js +1 -1
  120. package/dist/define.js +3 -3
  121. package/dist/index.js +3 -3
  122. package/dist/types/core/session.d.ts +31 -0
  123. package/dist/types/element/backstage/index.d.ts +10 -0
  124. package/dist/types/element/backstage/log.d.ts +13 -0
  125. package/dist/types/element/backstage/map.d.ts +12 -0
  126. package/dist/types/element/backstage/timing.d.ts +51 -0
  127. package/dist/types/element/i18n.d.ts +69 -6
  128. package/dist/types/element/icons.d.ts +3 -0
  129. package/dist/types/element/index.d.ts +15 -5
  130. package/dist/types/element/markdown.d.ts +6 -3
  131. package/dist/types/element/rich/a2ui-format.d.ts +45 -0
  132. package/dist/types/element/rich/a2ui-icons.d.ts +1 -0
  133. package/dist/types/element/rich/a2ui-views.d.ts +37 -0
  134. package/dist/types/element/rich/a2ui.d.ts +2 -0
  135. package/dist/types/element/rich/index.d.ts +72 -0
  136. package/dist/types/element/rich/math.d.ts +4 -0
  137. package/dist/types/element/rich/mermaid.d.ts +2 -0
  138. package/dist/types/element/rich/vega.d.ts +2 -0
  139. package/dist/types/element/sanitize.d.ts +34 -0
  140. package/dist/types/element/styles.d.ts +1 -1
  141. package/dist/types/element/team.d.ts +14 -0
  142. package/dist/types/index.d.ts +1 -0
  143. package/dist/types/jsx.d.ts +1 -1
  144. package/package.json +9 -3
  145. package/dist/chunks/core-Db3hnKpM.js.map +0 -1
  146. package/dist/chunks/src-CYXMXds2.js.map +0 -1
@@ -0,0 +1,476 @@
1
+ import{t as e}from"./chunk-XXDRQBXY-BIvjAdC_.js";import{t}from"./chunk-TU62E6Q5-B4GgWjUW.js";import{a as n,i as r}from"./mermaid-DaDuEHir.js";import"./chunk-M57EVK23-BRqFqW5o.js";import"./chunk-DQASFODM-DBWVlIjs.js";import"./chunk-LEVMRMFU-BdDTT4pw.js";import"./chunk-AXFCVDMN-D0Vqm50X.js";import"./chunk-X4PVCEUW-BcN5Aq5G.js";import{i}from"./chunk-STOXU5M4-DdqxXfKq.js";import"./chunk-R3KSYZAL-gmtEjdKU.js";import{a,i as o,o as s,r as c}from"./chunk-J5ZVWO5B-DHB__t6z.js";import{_ as l}from"./chunk-6MUBBAK2-CeH4cZO-.js";import{C as u,H as d,U as f,_ as p,a as m,b as h,f as g,q as _,v as ee,y as v,z as te}from"./chunk-BG4553SI-DUBI9JbR.js";import{n as ne,t as re}from"./d3-selection-CBFxn8wf.js";import{n as y}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";function ie(e){
2
+ /* istanbul ignore else - can't override global.console in node.js */
3
+ console&&console.error&&console.error(`Error: ${e}`)}function b(e){
4
+ /* istanbul ignore else - can't override global.console in node.js*/
5
+ console&&console.warn&&console.warn(`Warning: ${e}`)}function ae(e){let t=(/* @__PURE__ */ new Date()).getTime(),n=e();return{time:(/* @__PURE__ */ new Date()).getTime()-t,value:n}}function oe(e){function t(){}t.prototype=e;let n=new t;function r(){return typeof n.bar}return r(),r(),e}function se(e){return ce(e)?e.LABEL:e.name}function ce(e){return typeof e.LABEL==`string`&&e.LABEL!==``}var x=class{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),this.definition.forEach(t=>{t.accept(e)})}},S=class extends x{constructor(e){super([]),this.idx=1,Object.assign(this,M(e))}set definition(e){}get definition(){return this.referencedRule===void 0?[]:this.referencedRule.definition}accept(e){e.visit(this)}},C=class extends x{constructor(e){super(e.definition),this.orgText=``,Object.assign(this,M(e))}},w=class extends x{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,Object.assign(this,M(e))}},T=class extends x{constructor(e){super(e.definition),this.idx=1,Object.assign(this,M(e))}},E=class extends x{constructor(e){super(e.definition),this.idx=1,Object.assign(this,M(e))}},D=class extends x{constructor(e){super(e.definition),this.idx=1,Object.assign(this,M(e))}},O=class extends x{constructor(e){super(e.definition),this.idx=1,Object.assign(this,M(e))}},k=class extends x{constructor(e){super(e.definition),this.idx=1,Object.assign(this,M(e))}},A=class extends x{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,Object.assign(this,M(e))}},j=class{constructor(e){this.idx=1,Object.assign(this,M(e))}accept(e){e.visit(this)}};function le(e){return e.map(ue)}function ue(e){function t(e){return e.map(ue)}
6
+ /* istanbul ignore else */
7
+ if(e instanceof S){let t={type:`NonTerminal`,name:e.nonTerminalName,idx:e.idx};return typeof e.label==`string`&&(t.label=e.label),t}if(e instanceof w)return{type:`Alternative`,definition:t(e.definition)};if(e instanceof T)return{type:`Option`,idx:e.idx,definition:t(e.definition)};if(e instanceof E)return{type:`RepetitionMandatory`,idx:e.idx,definition:t(e.definition)};if(e instanceof D)return{type:`RepetitionMandatoryWithSeparator`,idx:e.idx,separator:ue(new j({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof k)return{type:`RepetitionWithSeparator`,idx:e.idx,separator:ue(new j({terminalType:e.separator})),definition:t(e.definition)};if(e instanceof O)return{type:`Repetition`,idx:e.idx,definition:t(e.definition)};if(e instanceof A)return{type:`Alternation`,idx:e.idx,definition:t(e.definition)};if(e instanceof j){let t={type:`Terminal`,name:e.terminalType.name,label:se(e.terminalType),idx:e.idx};typeof e.label==`string`&&(t.terminalLabel=e.label);let n=e.terminalType.PATTERN;return e.terminalType.PATTERN&&(t.pattern=n instanceof RegExp?n.source:n),t}if(e instanceof C)return{type:`Rule`,name:e.name,orgText:e.orgText,definition:t(e.definition)};throw Error(`non exhaustive match`)}function M(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var de=class{visit(e){let t=e;switch(t.constructor){case S:return this.visitNonTerminal(t);case w:return this.visitAlternative(t);case T:return this.visitOption(t);case E:return this.visitRepetitionMandatory(t);case D:return this.visitRepetitionMandatoryWithSeparator(t);case k:return this.visitRepetitionWithSeparator(t);case O:return this.visitRepetition(t);case A:return this.visitAlternation(t);case j:return this.visitTerminal(t);case C:return this.visitRule(t);
8
+ /* c8 ignore next 2 */
9
+ default:throw Error(`non exhaustive match`)}}
10
+ /* c8 ignore next */
11
+ visitNonTerminal(e){}
12
+ /* c8 ignore next */
13
+ visitAlternative(e){}
14
+ /* c8 ignore next */
15
+ visitOption(e){}
16
+ /* c8 ignore next */
17
+ visitRepetition(e){}
18
+ /* c8 ignore next */
19
+ visitRepetitionMandatory(e){}
20
+ /* c8 ignore next 3 */
21
+ visitRepetitionMandatoryWithSeparator(e){}
22
+ /* c8 ignore next */
23
+ visitRepetitionWithSeparator(e){}
24
+ /* c8 ignore next */
25
+ visitAlternation(e){}
26
+ /* c8 ignore next */
27
+ visitTerminal(e){}
28
+ /* c8 ignore next */
29
+ visitRule(e){}};function fe(e){return e instanceof w||e instanceof T||e instanceof O||e instanceof E||e instanceof D||e instanceof k||e instanceof j||e instanceof C}function pe(e,t=[]){return e instanceof T||e instanceof O||e instanceof k?!0:e instanceof A?e.definition.some(e=>pe(e,t)):e instanceof S&&t.includes(e)?!1:e instanceof x&&(e instanceof S&&t.push(e),e.definition.every(e=>pe(e,t)))}function me(e){return e instanceof A}function N(e){
30
+ /* istanbul ignore else */
31
+ if(e instanceof S)return`SUBRULE`;if(e instanceof T)return`OPTION`;if(e instanceof A)return`OR`;if(e instanceof E)return`AT_LEAST_ONE`;if(e instanceof D)return`AT_LEAST_ONE_SEP`;if(e instanceof k)return`MANY_SEP`;if(e instanceof O)return`MANY`;if(e instanceof j)return`CONSUME`;throw Error(`non exhaustive match`)}var he=class{walk(e,t=[]){e.definition.forEach((n,r)=>{let i=e.definition.slice(r+1);
32
+ /* istanbul ignore else */
33
+ if(n instanceof S)this.walkProdRef(n,i,t);else if(n instanceof j)this.walkTerminal(n,i,t);else if(n instanceof w)this.walkFlat(n,i,t);else if(n instanceof T)this.walkOption(n,i,t);else if(n instanceof E)this.walkAtLeastOne(n,i,t);else if(n instanceof D)this.walkAtLeastOneSep(n,i,t);else if(n instanceof k)this.walkManySep(n,i,t);else if(n instanceof O)this.walkMany(n,i,t);else if(n instanceof A)this.walkOr(n,i,t);else throw Error(`non exhaustive match`)})}walkTerminal(e,t,n){}walkProdRef(e,t,n){}walkFlat(e,t,n){let r=t.concat(n);this.walk(e,r)}walkOption(e,t,n){let r=t.concat(n);this.walk(e,r)}walkAtLeastOne(e,t,n){let r=[new T({definition:e.definition})].concat(t,n);this.walk(e,r)}walkAtLeastOneSep(e,t,n){let r=ge(e,t,n);this.walk(e,r)}walkMany(e,t,n){let r=[new T({definition:e.definition})].concat(t,n);this.walk(e,r)}walkManySep(e,t,n){let r=ge(e,t,n);this.walk(e,r)}walkOr(e,t,n){let r=t.concat(n);e.definition.forEach(e=>{let t=new w({definition:[e]});this.walk(t,r)})}};function ge(e,t,n){return[new T({definition:[new j({terminalType:e.separator})].concat(e.definition)})].concat(t,n)}function _e(e){
34
+ /* istanbul ignore else */
35
+ if(e instanceof S)return _e(e.referencedRule);if(e instanceof j)return be(e);if(fe(e))return ve(e);if(me(e))return ye(e);throw Error(`non exhaustive match`)}function ve(e){let t=[],n=e.definition,r=0,i=n.length>r,a,o=!0;for(;i&&o;)a=n[r],o=pe(a),t=t.concat(_e(a)),r+=1,i=n.length>r;return[...new Set(t)]}function ye(e){let t=e.definition.map(e=>_e(e));return[...new Set(t.flat())]}function be(e){return[e.terminalType]}var xe=`_~IN~_`,Se=class extends he{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,n){}walkProdRef(e,t,n){let r=we(e.referencedRule,e.idx)+this.topProd.name,i=_e(new w({definition:t.concat(n)}));this.follows[r]=i}};function Ce(e){let t={};return e.forEach(e=>{let n=new Se(e).startWalking();Object.assign(t,n)}),t}function we(e,t){return e.name+t+xe}function P(e){return e.charCodeAt(0)}function Te(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function Ee(e,t){if(e[t]===!0)throw`duplicate flag `+t;e[t],e[t]=!0}function De(e){
36
+ // istanbul ignore next
37
+ if(e===void 0)throw Error(`Internal Error - Should never get here!`);return!0}
38
+ // istanbul ignore next
39
+ function Oe(){throw Error(`Internal Error - Should never get here!`)}function ke(e){return e.type===`Character`}var Ae=[];for(let e=P(`0`);e<=P(`9`);e++)Ae.push(e);var je=[P(`_`)].concat(Ae);for(let e=P(`a`);e<=P(`z`);e++)je.push(e);for(let e=P(`A`);e<=P(`Z`);e++)je.push(e);var Me=[P(` `),P(`\f`),P(`
40
+ `),P(`\r`),P(` `),P(`\v`),P(` `),P(`\xA0`),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(` `),P(`\u2028`),P(`\u2029`),P(` `),P(` `),P(` `),P(``)],Ne=/[0-9a-fA-F]/,Pe=/[0-9]/,Fe=/[1-9]/,Ie=class{constructor(){this.idx=0,this.input=``,this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar(`/`);let t=this.disjunction();this.consumeChar(`/`);let n={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`:Ee(n,`global`);break;case`i`:Ee(n,`ignoreCase`);break;case`m`:Ee(n,`multiLine`);break;case`u`:Ee(n,`unicode`);break;case`y`:Ee(n,`sticky`)}if(this.idx!==this.input.length)throw Error(`Redundant input: `+this.input.substring(this.idx));return{type:`Pattern`,flags:n,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());this.peekChar()===`|`;)this.consumeChar(`|`),e.push(this.alternative());return{type:`Disjunction`,value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:`Alternative`,value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case`^`:return{type:`StartAnchor`,loc:this.loc(e)};case`$`:return{type:`EndAnchor`,loc:this.loc(e)};case`\\`:switch(this.popChar()){case`b`:return{type:`WordBoundary`,loc:this.loc(e)};case`B`:return{type:`NonWordBoundary`,loc:this.loc(e)}}
41
+ /* c8 ignore next */
42
+ throw Error(`Invalid Assertion Escape`);case`(`:this.consumeChar(`?`);let t;switch(this.popChar()){case`=`:t=`Lookahead`;break;case`!`:t=`NegativeLookahead`;break;case`<`:switch(this.popChar()){case`=`:t=`Lookbehind`;break;case`!`:t=`NegativeLookbehind`}}De(t);let n=this.disjunction();return this.consumeChar(`)`),{type:t,value:n,loc:this.loc(e)}}
43
+ // istanbul ignore next
44
+ return Oe()}quantifier(e=!1){let t,n=this.idx;switch(this.popChar()){case`*`:t={atLeast:0,atMost:1/0};break;case`+`:t={atLeast:1,atMost:1/0};break;case`?`:t={atLeast:0,atMost:1};break;case`{`:let n=this.integerIncludingZero();switch(this.popChar()){case`}`:t={atLeast:n,atMost:n};break;case`,`:let e;this.isDigit()?(e=this.integerIncludingZero(),t={atLeast:n,atMost:e}):t={atLeast:n,atMost:1/0},this.consumeChar(`}`)}if(e===!0&&t===void 0)return;De(t)}if((e!==!0||t!==void 0)&&De(t))return this.peekChar(0)===`?`?(this.consumeChar(`?`),t.greedy=!1):t.greedy=!0,t.type=`Quantifier`,t.loc=this.loc(n),t}atom(){let e,t=this.idx;switch(this.peekChar()){case`.`:e=this.dotAll();break;case`\\`:e=this.atomEscape();break;case`[`:e=this.characterClass();break;case`(`:e=this.group()}
45
+ // istanbul ignore next
46
+ return e===void 0&&this.isPatternCharacter()&&(e=this.patternCharacter()),De(e)?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):Oe()}dotAll(){return this.consumeChar(`.`),{type:`Set`,complement:!0,value:[P(`
47
+ `),P(`\r`),P(`\u2028`),P(`\u2029`)]}}atomEscape(){switch(this.consumeChar(`\\`),this.peekChar()){case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:return this.decimalEscapeAtom();case`d`:case`D`:case`s`:case`S`:case`w`:case`W`:return this.characterClassEscape();case`f`:case`n`:case`r`:case`t`:case`v`:return this.controlEscapeAtom();case`c`:return this.controlLetterEscapeAtom();case`0`:return this.nulCharacterAtom();case`x`:return this.hexEscapeSequenceAtom();case`u`:return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:`GroupBackReference`,value:this.positiveInteger()}}characterClassEscape(){let e,t=!1;switch(this.popChar()){case`d`:e=Ae;break;case`D`:e=Ae,t=!0;break;case`s`:e=Me;break;case`S`:e=Me,t=!0;break;case`w`:e=je;break;case`W`:e=je,t=!0}
48
+ // istanbul ignore next
49
+ return De(e)?{type:`Set`,value:e,complement:t}:Oe()}controlEscapeAtom(){let e;switch(this.popChar()){case`f`:e=P(`\f`);break;case`n`:e=P(`
50
+ `);break;case`r`:e=P(`\r`);break;case`t`:e=P(` `);break;case`v`:e=P(`\v`)}
51
+ // istanbul ignore next
52
+ return De(e)?{type:`Character`,value:e}:Oe()}controlLetterEscapeAtom(){this.consumeChar(`c`);let e=this.popChar();if(/[a-zA-Z]/.test(e)===!1)throw Error(`Invalid `);return{type:`Character`,value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar(`0`),{type:`Character`,value:P(`\0`)}}hexEscapeSequenceAtom(){return this.consumeChar(`x`),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar(`u`),this.parseHexDigits(4)}identityEscapeAtom(){return{type:`Character`,value:P(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){
53
+ // istanbul ignore next
54
+ case`
55
+ `:
56
+ // istanbul ignore next
57
+ case`\r`:
58
+ // istanbul ignore next
59
+ case`\u2028`:
60
+ // istanbul ignore next
61
+ case`\u2029`:
62
+ // istanbul ignore next
63
+ case`\\`:
64
+ // istanbul ignore next
65
+ case`]`:throw Error(`TBD`);default:return{type:`Character`,value:P(this.popChar())}}}characterClass(){let e=[],t=!1;for(this.consumeChar(`[`),this.peekChar(0)===`^`&&(this.consumeChar(`^`),t=!0);this.isClassAtom();){let t=this.classAtom();if(t.type,ke(t)&&this.isRangeDash()){this.consumeChar(`-`);let n=this.classAtom();if(n.type,ke(n)){if(n.value<t.value)throw Error(`Range out of order in character class`);e.push({from:t.value,to:n.value})}else Te(t.value,e),e.push(P(`-`)),Te(n.value,e)}else Te(t.value,e)}return this.consumeChar(`]`),{type:`Set`,complement:t,value:e}}classAtom(){switch(this.peekChar()){
66
+ // istanbul ignore next
67
+ case`]`:
68
+ // istanbul ignore next
69
+ case`
70
+ `:
71
+ // istanbul ignore next
72
+ case`\r`:
73
+ // istanbul ignore next
74
+ case`\u2028`:
75
+ // istanbul ignore next
76
+ 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:P(`\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++}let t=this.disjunction();this.consumeChar(`)`);let n={type:`Group`,capturing:e,value:t};return e&&(n.idx=this.groupIdx),n}positiveInteger(){let e=this.popChar();
77
+ // istanbul ignore next - can't ever get here due to previous lookahead checks
78
+ if(Fe.test(e)===!1)throw Error(`Expecting a positive integer`);for(;Pe.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(Pe.test(e)===!1)throw Error(`Expecting an integer`);for(;Pe.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){
79
+ // istanbul ignore next
80
+ case`
81
+ `:
82
+ // istanbul ignore next
83
+ case`\r`:
84
+ // istanbul ignore next
85
+ case`\u2028`:
86
+ // istanbul ignore next
87
+ case`\u2029`:
88
+ // istanbul ignore next
89
+ case`^`:
90
+ // istanbul ignore next
91
+ case`$`:
92
+ // istanbul ignore next
93
+ case`\\`:
94
+ // istanbul ignore next
95
+ case`.`:
96
+ // istanbul ignore next
97
+ case`*`:
98
+ // istanbul ignore next
99
+ case`+`:
100
+ // istanbul ignore next
101
+ case`?`:
102
+ // istanbul ignore next
103
+ case`(`:
104
+ // istanbul ignore next
105
+ case`)`:
106
+ // istanbul ignore next
107
+ case`[`:
108
+ // istanbul ignore next
109
+ case`|`:
110
+ // istanbul ignore next
111
+ throw Error(`TBD`);default:return{type:`Character`,value:P(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 Pe.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case`]`:case`
112
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case`.`:case`\\`:case`[`:case`(`:return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case`^`:case`$`:return!0;case`\\`:switch(this.peekChar(1)){case`b`:case`B`:return!0;default:return!1}case`(`:return this.peekChar(1)===`?`&&(this.peekChar(2)===`=`||this.peekChar(2)===`!`||this.peekChar(2)===`<`&&(this.peekChar(3)===`=`||this.peekChar(3)===`!`));default:return!1}}isQuantifier(){let e=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case`^`:case`$`:case`\\`:case`.`:case`*`:case`+`:case`?`:case`(`:case`)`:case`[`:case`|`:case`/`:case`
113
+ `:case`\r`:case`\u2028`:case`\u2029`:return!1;default:return!0}}parseHexDigits(e){let t=``;for(let n=0;n<e;n++){let e=this.popChar();if(Ne.test(e)===!1)throw Error(`Expecting a HexDecimal digits`);t+=e}return{type:`Character`,value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(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}}},Le=class{visitChildren(e){for(let t in e){let n=e[t];
114
+ /* istanbul ignore else */
115
+ e.hasOwnProperty(t)&&(n.type===void 0?Array.isArray(n)&&n.forEach(e=>{this.visit(e)},this):this.visit(n))}}visit(e){switch(e.type){case`Pattern`:this.visitPattern(e);break;case`Flags`:this.visitFlags(e);break;case`Disjunction`:this.visitDisjunction(e);break;case`Alternative`:this.visitAlternative(e);break;case`StartAnchor`:this.visitStartAnchor(e);break;case`EndAnchor`:this.visitEndAnchor(e);break;case`WordBoundary`:this.visitWordBoundary(e);break;case`NonWordBoundary`:this.visitNonWordBoundary(e);break;case`Lookahead`:this.visitLookahead(e);break;case`NegativeLookahead`:this.visitNegativeLookahead(e);break;case`Lookbehind`:this.visitLookbehind(e);break;case`NegativeLookbehind`:this.visitNegativeLookbehind(e);break;case`Character`:this.visitCharacter(e);break;case`Set`:this.visitSet(e);break;case`Group`:this.visitGroup(e);break;case`GroupBackReference`:this.visitGroupBackReference(e);break;case`Quantifier`:this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}},Re={},ze=new Ie;function Be(e){let t=e.toString();if(Re.hasOwnProperty(t))return Re[t];{let e=ze.pattern(t);return Re[t]=e,e}}function Ve(){Re={}}var He=`Complement Sets are not supported for first char optimization`,Ue=`Unable to use "first char" lexer optimizations:
116
+ `;function We(e,t=!1){try{let t=Be(e);return Ge(t.value,{},t.flags.ignoreCase)}catch(n){
117
+ /* istanbul ignore next */
118
+ if(n.message===He)t&&b(`${Ue}\tUnable to optimize: < ${e.toString()} >\n Complement Sets cannot be automatically optimized.
119
+ This will disable the lexer's first char optimizations.
120
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n=``;t&&(n=`
121
+ This will disable the lexer's first char optimizations.
122
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),ie(`${Ue}\n\tFailed parsing: < ${e.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Ge(e,t,n){switch(e.type){case`Disjunction`:for(let r=0;r<e.value.length;r++)Ge(e.value[r],t,n);break;case`Alternative`:let r=e.value;for(let e=0;e<r.length;e++){let i=r[e];switch(i.type){case`EndAnchor`:case`GroupBackReference`:case`Lookahead`:case`NegativeLookahead`:case`Lookbehind`:case`NegativeLookbehind`:case`StartAnchor`:case`WordBoundary`:case`NonWordBoundary`:continue}let a=i;switch(a.type){case`Character`:Ke(a.value,t,n);break;case`Set`:if(a.complement===!0)throw Error(He);a.value.forEach(e=>{if(typeof e==`number`)Ke(e,t,n);else{let r=e;if(n===!0)for(let e=r.from;e<=r.to;e++)Ke(e,t,n);else{for(let e=r.from;e<=r.to&&e<256;e++)Ke(e,t,n);if(r.to>=256){let e=r.from>=256?r.from:256,n=r.to,i=At(e),a=At(n);for(let e=i;e<=a;e++)t[e]=e}}}});break;case`Group`:Ge(a.value,t,n);break;
123
+ /* istanbul ignore next */
124
+ default:throw Error(`Non Exhaustive Match`)}let o=a.quantifier!==void 0&&a.quantifier.atLeast===0;if(a.type===`Group`&&Ye(a)===!1||a.type!==`Group`&&o===!1)break}break;
125
+ /* istanbul ignore next */
126
+ default:throw Error(`non exhaustive match!`)}return Object.values(t)}function Ke(e,t,n){let r=At(e);t[r]=r,n===!0&&qe(e,t)}function qe(e,t){let n=String.fromCharCode(e),r=n.toUpperCase();
127
+ /* istanbul ignore else */
128
+ if(r!==n){let e=At(r.charCodeAt(0));t[e]=e}else{let e=n.toLowerCase();if(e!==n){let n=At(e.charCodeAt(0));t[n]=n}}}function Je(e,t){return e.value.find(e=>{if(typeof e==`number`)return t.includes(e);{let n=e;return t.find(e=>n.from<=e&&e<=n.to)!==void 0}})}function Ye(e){let t=e.quantifier;return t&&t.atLeast===0?!0:e.value?Array.isArray(e.value)?e.value.every(Ye):Ye(e.value):!1}var Xe=class extends Le{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){this.targetCharCodes.includes(e.value)&&(this.found=!0)}visitSet(e){e.complement?Je(e,this.targetCharCodes)===void 0&&(this.found=!0):Je(e,this.targetCharCodes)!==void 0&&(this.found=!0)}};function Ze(e,t){if(t instanceof RegExp){let n=Be(t),r=new Xe(e);return r.visit(n),r.found}for(let n of t){let t=n.charCodeAt(0);if(e.includes(t))return!0}return!1}var Qe=`PATTERN`,$e=`defaultMode`;function et(e,t){t=Object.assign({safeMode:!1,positionTracking:`full`,lineTerminatorCharacters:[`\r`,`
129
+ `],tracer:(e,t)=>t()},t);let n=t.tracer;n(`initCharCodeToOptimizedIndexMap`,()=>{jt()});let r;n(`Reject Lexer.NA`,()=>{r=e.filter(e=>e[Qe]!==I.NA)});let i=!1,a;n(`Transform Patterns`,()=>{i=!1,a=r.map(e=>{let t=e[Qe];
130
+ /* istanbul ignore else */
131
+ if(t instanceof RegExp){let e=t.source;return e.length===1&&e!==`^`&&e!==`$`&&e!==`.`&&!t.ignoreCase?e:e.length===2&&e[0]===`\\`&&![`d`,`D`,`s`,`S`,`t`,`r`,`n`,`t`,`0`,`c`,`b`,`B`,`f`,`v`,`w`,`W`].includes(e[1])?e[1]:yt(t)}if(typeof t==`function`)return i=!0,{exec:t};if(typeof t==`object`)return i=!0,t;if(typeof t==`string`){if(t.length===1)return t;{let e=t.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`);return yt(new RegExp(e))}}throw Error(`non exhaustive match`)})});let o,s,c,l,u;n(`misc mapping`,()=>{o=r.map(e=>e.tokenTypeIdx),s=r.map(e=>{let t=e.GROUP;
132
+ /* istanbul ignore next */
133
+ if(t!==I.SKIPPED){if(typeof t==`string`)return t;if(t===void 0)return!1;throw Error(`non exhaustive match`)}}),c=r.map(e=>{let t=e.LONGER_ALT;if(t)return Array.isArray(t)?t.map(e=>r.indexOf(e)):[r.indexOf(t)]}),l=r.map(e=>e.PUSH_MODE),u=r.map(e=>Object.hasOwn(e,`POP_MODE`))});let d;n(`Line Terminator Handling`,()=>{let e=Dt(t.lineTerminatorCharacters);d=r.map(e=>!1),t.positionTracking!==`onlyOffset`&&(d=r.map(t=>Object.hasOwn(t,`LINE_BREAKS`)?!!t.LINE_BREAKS:Tt(t,e)===!1&&Ze(e,t.PATTERN)))});let f,p,m,h;n(`Misc Mapping #2`,()=>{f=r.map(St),p=a.map(Ct),m=r.reduce((e,t)=>{let n=t.GROUP;return typeof n==`string`&&n!==I.SKIPPED&&(e[n]=[]),e},{}),h=a.map((e,t)=>{let n=s[t]===void 0&&c[t]===void 0?tt(r[t].PATTERN):void 0;return{pattern:a[t],asciiClass:n,longerAlt:c[t],canLineTerminator:d[t],matchType:n===void 0?p[t]===!1?f[t]?1:2:0:3,short:p[t],group:s[t],push:l[t],pop:u[t],tokenTypeIdx:o[t],tokenType:r[t]}})});let g=!0,_=[];return t.safeMode||n(`First Char Optimization`,()=>{_=r.reduce((e,n,r)=>{if(typeof n.PATTERN==`string`)Ot(e,At(n.PATTERN.charCodeAt(0)),h[r]);else if(Array.isArray(n.START_CHARS_HINT)){let t;n.START_CHARS_HINT.forEach(n=>{let i=At(typeof n==`string`?n.charCodeAt(0):n);
134
+ /* istanbul ignore else */
135
+ t!==i&&(t=i,Ot(e,i,h[r]))})}else if(n.PATTERN instanceof RegExp){if(n.PATTERN.unicode)g=!1,t.ensureOptimizations&&ie(`${Ue}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n The regexp unicode flag is not currently supported by the regexp-to-ast library.
136
+ This will disable the lexer's first char optimizations.
137
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let i=We(n.PATTERN,t.ensureOptimizations);i.length===0&&(g=!1),i.forEach(t=>{Ot(e,t,h[r])})}}else t.ensureOptimizations&&ie(`${Ue}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n This will disable the lexer's first char optimizations.
138
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return e},[])}),{emptyGroups:m,patternIdxToConfig:h,charCodeToPatternIdxToConfig:_,hasCustom:i,canBeOptimized:g}}function tt(e){if(!(e instanceof RegExp)||e.flags!==``)return;let t;try{t=Be(e)}catch{return}if(t.value.value.length!==1||t.value.value[0].value.length!==1)return;let n=t.value.value[0].value[0],r;for(;n.type===`Group`;){if(n.capturing||n.quantifier!==void 0&&r!==void 0||n.value.value.length!==1||n.value.value[0].value.length!==1)return;r=n.quantifier??r,n=n.value.value[0].value[0]}if(n.type!==`Set`||n.complement||n.quantifier!==void 0&&r!==void 0||(r=n.quantifier??r,r?.atLeast!==1||r.atMost!==1/0||!r.greedy))return;let i=/* @__PURE__ */ new Uint8Array(128);for(let e of n.value){let t=typeof e==`number`?e:e.from,n=typeof e==`number`?e:e.to;if(t<0||n>=i.length)return;i.fill(1,t,n+1)}return i}function nt(e,t){let n=[],r=it(e);n=n.concat(r.errors);let i=at(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(rt(a)),n=n.concat(pt(a)),n=n.concat(mt(a,t)),n=n.concat(ht(a)),n}function rt(e){let t=[],n=e.filter(e=>e[Qe]instanceof RegExp);return t=t.concat(st(n)),t=t.concat(ut(n)),t=t.concat(dt(n)),t=t.concat(ft(n)),t=t.concat(ct(n)),t}function it(e){let t=e.filter(e=>!Object.hasOwn(e,Qe));return{errors:t.map(e=>({message:`Token Type: ->`+e.name+`<- missing static 'PATTERN' property`,type:F.MISSING_PATTERN,tokenTypes:[e]})),valid:e.filter(e=>!t.includes(e))}}function at(e){let t=e.filter(e=>{let t=e[Qe];return!(t instanceof RegExp)&&typeof t!=`function`&&!Object.hasOwn(t,`exec`)&&typeof t!=`string`});return{errors:t.map(e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.`,type:F.INVALID_PATTERN,tokenTypes:[e]})),valid:e.filter(e=>!t.includes(e))}}var ot=/[^\\][$]/;function st(e){class t extends Le{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}return e.filter(e=>{let n=e.PATTERN;try{let e=Be(n),r=new t;return r.visit(e),r.found}catch{
139
+ /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/
140
+ return ot.test(n.source)}}).map(e=>({message:`Unexpected RegExp Anchor Error:
141
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
142
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:F.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}function ct(e){return e.filter(e=>e.PATTERN.test(``)).map(e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' must not match an empty string`,type:F.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))}var lt=/[^\\[][\^]|^\^/;function ut(e){class t extends Le{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}return e.filter(e=>{let n=e.PATTERN;try{let e=Be(n),r=new t;return r.visit(e),r.found}catch{
143
+ /* istanbul ignore next - cannot ensure an error in regexp-to-ast*/
144
+ return lt.test(n.source)}}).map(e=>({message:`Unexpected RegExp Anchor Error:
145
+ Token Type: ->`+e.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
146
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:F.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}function dt(e){return e.filter(e=>{let t=e[Qe];return t instanceof RegExp&&(t.multiline||t.global)}).map(e=>({message:`Token Type: ->`+e.name+`<- static 'PATTERN' may NOT contain global('g') or multiline('m')`,type:F.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))}function ft(e){let t=[],n=e.map(n=>e.reduce((e,r)=>(n.PATTERN.source===r.PATTERN.source&&!t.includes(r)&&r.PATTERN!==I.NA&&(t.push(r),e.push(r)),e),[]));return n=n.filter(Boolean),n.filter(e=>e.length>1).map(e=>{let t=e.map(e=>e.name);return{message:`The same RegExp pattern ->${e[0].PATTERN}<-has been used in all of the following Token Types: ${t.join(`, `)} <-`,type:F.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})}function pt(e){return e.filter(e=>{if(!Object.hasOwn(e,`GROUP`))return!1;let t=e.GROUP;return t!==I.SKIPPED&&t!==I.NA&&typeof t!=`string`}).map(e=>({message:`Token Type: ->`+e.name+`<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String`,type:F.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))}function mt(e,t){return e.filter(e=>e.PUSH_MODE!==void 0&&!t.includes(e.PUSH_MODE)).map(e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:F.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))}function ht(e){let t=[],n=e.reduce((e,t,n)=>{let r=t.PATTERN;return r===I.NA||(typeof r==`string`?e.push({str:r,idx:n,tokenType:t}):r instanceof RegExp&&_t(r)&&e.push({str:r.source,idx:n,tokenType:t})),e},[]);return e.forEach((e,r)=>{n.forEach(({str:n,idx:i,tokenType:a})=>{if(r<i&&gt(n,e.PATTERN)){let n=`Token: ->${a.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;t.push({message:n,type:F.UNREACHABLE_PATTERN,tokenTypes:[e,a]})}})}),t}function gt(e,t){if(t instanceof RegExp){if(vt(t))return!1;let n=t.exec(e);return n!==null&&n.index===0}if(typeof t==`function`)return t(e,0,[],{});if(Object.hasOwn(t,`exec`))return t.exec(e,0,[],{});if(typeof t==`string`)return t===e;throw Error(`non exhaustive match`)}function _t(e){return[`.`,`\\`,`[`,`]`,`|`,`^`,`$`,`(`,`)`,`?`,`*`,`+`,`{`].find(t=>e.source.indexOf(t)!==-1)===void 0}function vt(e){return/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source)}function yt(e){let t=e.ignoreCase?`iy`:`y`;return RegExp(`${e.source}`,t)}function bt(e,t,n){let r=[];return Object.hasOwn(e,`defaultMode`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition
147
+ `,type:F.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),Object.hasOwn(e,`modes`)||r.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
148
+ `,type:F.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),Object.hasOwn(e,`modes`)&&Object.hasOwn(e,`defaultMode`)&&!Object.hasOwn(e.modes,e.defaultMode)&&r.push({message:`A MultiMode Lexer cannot be initialized with a ${$e}: <${e.defaultMode}>which does not exist\n`,type:F.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),Object.hasOwn(e,`modes`)&&Object.keys(e.modes).forEach(t=>{let n=e.modes[t];n.forEach((e,i)=>{e===void 0?r.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${t}> at index: <${i}>\n`,type:F.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):Object.hasOwn(e,`LONGER_ALT`)&&(Array.isArray(e.LONGER_ALT)?e.LONGER_ALT:[e.LONGER_ALT]).forEach(i=>{i!==void 0&&!n.includes(i)&&r.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${e.name}> outside of mode <${t}>\n`,type:F.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),r}function xt(e,t,n){let r=[],i=!1,a=Object.values(e.modes||{}).flat().filter(Boolean).filter(e=>e[Qe]!==I.NA),o=Dt(n);return t&&a.forEach(e=>{let t=Tt(e,o);if(t!==!1){let n={message:Et(e,t),type:t.issue,tokenType:e};r.push(n)}else Object.hasOwn(e,`LINE_BREAKS`)?e.LINE_BREAKS===!0&&(i=!0):Ze(o,e.PATTERN)&&(i=!0)}),t&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
149
+ This Lexer has been defined to track line and column information,
150
+ But none of the Token Types can be identified as matching a line terminator.
151
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
152
+ for details.`,type:F.NO_LINE_BREAKS_FLAGS}),r}function St(e){let t=e.PATTERN;
153
+ /* istanbul ignore else */
154
+ if(t instanceof RegExp)return!1;if(typeof t==`function`||Object.hasOwn(t,`exec`))return!0;if(typeof t==`string`)return!1;throw Error(`non exhaustive match`)}function Ct(e){return typeof e==`string`&&e.length===1&&e.charCodeAt(0)}var wt={test:function(e){let t=e.length;for(let n=this.lastIndex;n<t;n++){let t=e.charCodeAt(n);if(t===10)return this.lastIndex=n+1,!0;if(t===13)return this.lastIndex=e.charCodeAt(n+1)===10?n+2:n+1,!0}return!1},lastIndex:0};function Tt(e,t){if(Object.hasOwn(e,`LINE_BREAKS`))return!1;if(e.PATTERN instanceof RegExp){try{Ze(t,e.PATTERN)}catch(e){
155
+ /* istanbul ignore next - to test this we would have to mock <canMatchCharCode> to throw an error */
156
+ return{issue:F.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if(typeof e.PATTERN==`string`)return!1;if(St(e))return{issue:F.CUSTOM_LINE_BREAK};throw Error(`non exhaustive match`)}function Et(e,t){
157
+ /* istanbul ignore else */
158
+ if(t.issue===F.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
159
+ \tThe problem is in the <${e.name}> Token Type\n\t Root cause: ${t.errMsg}.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===F.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
160
+ \tThe problem is in the <${e.name}> Token Type\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error(`non exhaustive match`)}function Dt(e){return e.map(e=>typeof e==`string`?e.charCodeAt(0):e)}function Ot(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}var kt=[];function At(e){return e<256?e:kt[e]}function jt(){if(kt.length===0){kt=Array(65536);for(let e=0;e<65536;e++)kt[e]=e>255?255+~~(e/255):e}}function Mt(e,t){let n=e.tokenTypeIdx;return n===t.tokenTypeIdx||t.isParent===!0&&t.categoryMatchesMap[n]===!0}function Nt(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}var Pt=1,Ft={};function It(e){let t=Lt(e);Rt(t),Bt(t),zt(t),t.forEach(e=>{e.isParent=e.categoryMatches.length>0})}function Lt(e){let t=[...e],n=e,r=!0;for(;r;){n=n.map(e=>e.CATEGORIES).flat().filter(Boolean);let e=n.filter(e=>!t.includes(e));t=t.concat(e),e.length===0?r=!1:n=e}return t}function Rt(e){e.forEach(e=>{Ht(e)||(Ft[Pt]=e,e.tokenTypeIdx=Pt++),Ut(e)&&!Array.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Ut(e)||(e.CATEGORIES=[]),Wt(e)||(e.categoryMatches=[]),Gt(e)||(e.categoryMatchesMap={})})}function zt(e){e.forEach(e=>{e.categoryMatches=[],Object.keys(e.categoryMatchesMap).forEach(t=>{e.categoryMatches.push(Ft[t].tokenTypeIdx)})})}function Bt(e){e.forEach(e=>{Vt([],e)})}function Vt(e,t){e.forEach(e=>{t.categoryMatchesMap[e.tokenTypeIdx]=!0}),t.CATEGORIES.forEach(n=>{let r=e.concat(t);r.includes(n)||Vt(r,n)})}function Ht(e){return Object.hasOwn(e??{},`tokenTypeIdx`)}function Ut(e){return Object.hasOwn(e??{},`CATEGORIES`)}function Wt(e){return Object.hasOwn(e??{},`categoryMatches`)}function Gt(e){return Object.hasOwn(e??{},`categoryMatchesMap`)}function Kt(e){return Object.hasOwn(e??{},`tokenTypeIdx`)}var qt={buildUnableToPopLexerModeMessage(e){return`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`},buildUnexpectedCharactersMessage(e,t,n,r,i,a){return`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${n} characters.`}},F;(function(e){e[e.MISSING_PATTERN=0]=`MISSING_PATTERN`,e[e.INVALID_PATTERN=1]=`INVALID_PATTERN`,e[e.EOI_ANCHOR_FOUND=2]=`EOI_ANCHOR_FOUND`,e[e.UNSUPPORTED_FLAGS_FOUND=3]=`UNSUPPORTED_FLAGS_FOUND`,e[e.DUPLICATE_PATTERNS_FOUND=4]=`DUPLICATE_PATTERNS_FOUND`,e[e.INVALID_GROUP_TYPE_FOUND=5]=`INVALID_GROUP_TYPE_FOUND`,e[e.PUSH_MODE_DOES_NOT_EXIST=6]=`PUSH_MODE_DOES_NOT_EXIST`,e[e.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]=`MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE`,e[e.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]=`MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY`,e[e.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]=`MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST`,e[e.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]=`LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED`,e[e.SOI_ANCHOR_FOUND=11]=`SOI_ANCHOR_FOUND`,e[e.EMPTY_MATCH_PATTERN=12]=`EMPTY_MATCH_PATTERN`,e[e.NO_LINE_BREAKS_FLAGS=13]=`NO_LINE_BREAKS_FLAGS`,e[e.UNREACHABLE_PATTERN=14]=`UNREACHABLE_PATTERN`,e[e.IDENTIFY_TERMINATOR=15]=`IDENTIFY_TERMINATOR`,e[e.CUSTOM_LINE_BREAK=16]=`CUSTOM_LINE_BREAK`,e[e.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]=`MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE`})(F||={});var Jt={deferDefinitionErrorsHandling:!1,positionTracking:`full`,lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
161
+ `,`\r`],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:qt,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Jt);var I=class{constructor(e,t=Jt){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.cachedGroupKeys=[],this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()},typeof t==`boolean`)throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
162
+ a boolean 2nd argument is no longer supported`);this.config=Object.assign({},Jt,t);let n=this.config.traceInitPerf;n===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof n==`number`&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT(`Lexer Constructor`,()=>{let n,r=!0;this.TRACE_INIT(`Lexer Config handling`,()=>{if(this.config.lineTerminatorsPattern===Jt.lineTerminatorsPattern)this.config.lineTerminatorsPattern=wt;else if(this.config.lineTerminatorCharacters===Jt.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
163
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(t.safeMode&&t.ensureOptimizations)throw Error(`"safeMode" and "ensureOptimizations" flags are mutually exclusive.`);this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),Array.isArray(e)?n={modes:{defaultMode:[...e]},defaultMode:$e}:(r=!1,n=Object.assign({},e))}),this.config.skipValidations===!1&&(this.TRACE_INIT(`performRuntimeChecks`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(bt(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT(`performWarningRuntimeChecks`,()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(xt(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},Object.entries(n.modes).forEach(([e,t])=>{n.modes[e]=t.filter(e=>e!==void 0)});let i=Object.keys(n.modes);if(Object.entries(n.modes).forEach(([e,n])=>{this.TRACE_INIT(`Mode: <${e}> processing`,()=>{if(this.modes.push(e),this.config.skipValidations===!1&&this.TRACE_INIT(`validatePatterns`,()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(nt(n,i))}),this.lexerDefinitionErrors.length===0){It(n);let r;this.TRACE_INIT(`analyzeTokenTypes`,()=>{r=et(n,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[e]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[e]=r.charCodeToPatternIdxToConfig,this.emptyGroups=Object.assign({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[e]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,this.cachedGroupKeys=Object.keys(this.emptyGroups),this.lexerDefinitionErrors.length>0&&!this.config.deferDefinitionErrorsHandling){let e=this.lexerDefinitionErrors.map(e=>e.message).join(`-----------------------
164
+ `);throw Error(`Errors detected in definition of Lexer:
165
+ `+e)}this.lexerDefinitionWarning.forEach(e=>{b(e.message)}),this.TRACE_INIT(`Choosing sub-methods implementations`,()=>{if(r&&(this.handleModes=()=>{}),this.trackStartLines===!1&&(this.computeNewColumn=e=>e),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=()=>{}),/full/i.test(this.config.positionTracking))this.createTokenInstance=this.createFullToken;else if(/onlyStart/i.test(this.config.positionTracking))this.createTokenInstance=this.createStartOnlyToken;else if(/onlyOffset/i.test(this.config.positionTracking))this.createTokenInstance=this.createOffsetOnlyToken;else throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT(`Failed Optimization Warnings`,()=>{let e=Object.entries(this.canModeBeOptimized).reduce((e,[t,n])=>(n===!1&&e.push(t),e),[]);if(t.ensureOptimizations&&e.length>0)throw Error(`Lexer Modes: < ${e.join(`, `)} > cannot be optimized.\n Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
166
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT(`clearRegExpParserCache`,()=>{Ve()}),this.TRACE_INIT(`toFastProperties`,()=>{oe(this)})})}tokenize(e,t=this.defaultMode){if(this.lexerDefinitionErrors.length>0){let e=this.lexerDefinitionErrors.map(e=>e.message).join(`-----------------------
167
+ `);throw Error(`Unable to Tokenize because Errors detected in definition of Lexer:
168
+ `+e)}return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=e,ee=_.length,v=0,te=0,ne=this.hasCustom?0:Math.floor(e.length/10),re=Array(ne),y=[],ie=this.trackStartLines?1:void 0,b=this.trackStartLines?1:void 0,ae={};for(let e=0;e<this.cachedGroupKeys.length;e++)ae[this.cachedGroupKeys[e]]=[];let oe=this.trackStartLines,se=this.config.lineTerminatorsPattern,ce=0,x=[],S=[],C=[],w=[];Object.freeze(w);let T=!1,E=e=>{if(C.length===1&&e.tokenType.PUSH_MODE===void 0){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);y.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{C.pop();let e=C.at(-1);x=this.patternIdxToConfig[e],S=this.charCodeToPatternIdxToConfig[e],ce=x.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;T=!!(S&&t)}};function D(e){C.push(e),S=this.charCodeToPatternIdxToConfig[e],x=this.patternIdxToConfig[e],ce=x.length;let t=this.canModeBeOptimized[e]&&this.config.safeMode===!1;T=!!(S&&t)}D.call(this,t);let O,k=this.config.recoveryEnabled;for(;v<ee;){s=null,u=-1;let t=_.charCodeAt(v),ne;if(T){let e=At(t),n=S[e];ne=n===void 0?w:n}else ne=x;let A=ne.length;for(n=0;n<A;n++){O=ne[n];let r=O.pattern;switch(c=null,O.matchType){case 0:t===O.short&&(u=1,s=r);break;case 1:g=r.exec(_,v,re,ae),g===null?s=null:(s=g[0],u=s.length,g.payload!==void 0&&(c=g.payload));break;case 3:{let e=O.asciiClass;if(e[t]!==1){r.lastIndex=0;break}let n=v+1;for(;e[_.charCodeAt(n)]===1;)n++;u=n-v,r.lastIndex=n;break}case 2:r.lastIndex=v,u=this.matchLength(r,e,v)}if(u!==-1){if(o=O.longerAlt,o!==void 0){s=e.substring(v,v+u);let t=o.length;for(i=0;i<t;i++){let t=x[o[i]],n=t.pattern;if(l=null,t.matchType===1?(g=n.exec(_,v,re,ae),g===null?a=null:(a=g[0],g.payload!==void 0&&(l=g.payload))):(n.lastIndex=v,a=this.match(n,e,v)),a&&a.length>s.length){s=a,u=a.length,c=l,O=t;break}}}break}}if(u!==-1){if(d=O.group,d!==void 0&&(s=s===null?e.substring(v,v+u):s,f=O.tokenTypeIdx,p=this.createTokenInstance(s,v,f,O.tokenType,ie,b,u),this.handlePayload(p,c),d===!1?te=this.addToken(re,te,p):ae[d].push(p)),oe===!0&&O.canLineTerminator===!0){let t=0,n,r;se.lastIndex=0;do s=s===null?e.substring(v,v+u):s,n=se.test(s),n===!0&&(r=se.lastIndex-1,t++);while(n===!0);t===0?b=this.computeNewColumn(b,u):(ie+=t,b=u-r,this.updateTokenEndLineColumnLocation(p,d,r,t,ie,b,u))}else b=this.computeNewColumn(b,u);v+=u,this.handleModes(O,E,D,p)}else{let t=v,n=ie,i=b,a=k===!1;for(;a===!1&&v<ee;)for(v++,r=0;r<ce;r++){let t=x[r],n=t.pattern;switch(t.matchType){case 0:_.charCodeAt(v)===t.short&&(a=!0);break;case 1:a=n.exec(_,v,re,ae)!==null;break;case 3:case 2:n.lastIndex=v,a=n.exec(e)!==null}if(a===!0)break}if(m=v-t,b=this.computeNewColumn(b,m),h=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(_,t,m,n,i,C.at(-1)),y.push({offset:t,line:n,column:i,length:m,message:h}),k===!1)break}}return this.hasCustom||(re.length=te),{tokens:re,groups:ae,errors:y}}handleModes(e,t,n,r){if(e.pop===!0){let i=e.push;t(r),i!==void 0&&n.call(this,i)}else e.push!==void 0&&n.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,n,r,i,a,o){let s,c;t!==void 0&&(s=n===o-1,c=s?-1:0,(r!==1||s!==!0)&&(e.endLine=i+c,e.endColumn=a-1+-c))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,n,r){return{image:e,startOffset:t,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(e,t,n,r,i,a){return{image:e,startOffset:t,startLine:i,startColumn:a,tokenTypeIdx:n,tokenType:r}}createFullToken(e,t,n,r,i,a,o){return{image:e,startOffset:t,endOffset:t+o-1,startLine:i,endLine:i,startColumn:a,endColumn:a+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(e,t,n){return e.push(n),t}addTokenUsingMemberAccess(e,t,n){return e[t]=n,t++,t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){t!==null&&(e.payload=t)}match(e,t,n){return e.test(t)===!0?t.substring(n,e.lastIndex):null}matchLength(e,t,n){return e.test(t)===!0?e.lastIndex-n:-1}};I.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.`,I.NA=/NOT_APPLICABLE/;function Yt(e){return Xt(e)?e.LABEL:e.name}function Xt(e){return typeof e.LABEL==`string`&&e.LABEL!==``}var Zt=`parent`,Qt=`categories`,$t=`label`,en=`group`,tn=`push_mode`,nn=`pop_mode`,rn=`longer_alt`,an=`line_breaks`,on=`start_chars_hint`;function L(e){return sn(e)}function sn(e){let t=e.pattern,n={};if(n.name=e.name,t!==void 0&&(n.PATTERN=t),Object.hasOwn(e,Zt))throw`The parent property is no longer supported.
169
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return Object.hasOwn(e,Qt)&&(n.CATEGORIES=e[Qt]),It([n]),Object.hasOwn(e,$t)&&(n.LABEL=e[$t]),Object.hasOwn(e,en)&&(n.GROUP=e[en]),Object.hasOwn(e,nn)&&(n.POP_MODE=e[nn]),Object.hasOwn(e,tn)&&(n.PUSH_MODE=e[tn]),Object.hasOwn(e,rn)&&(n.LONGER_ALT=e[rn]),Object.hasOwn(e,an)&&(n.LINE_BREAKS=e[an]),Object.hasOwn(e,on)&&(n.START_CHARS_HINT=e[on]),n}var R=L({name:`EOF`,pattern:I.NA});It([R]);function cn(e,t,n,r,i,a,o,s){return{image:t,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:o,endColumn:s,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}function ln(e,t){return Mt(e,t)}var un={buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:r}){return`Expecting ${Xt(e)?`--> ${Yt(e)} <--`:`token of type --> ${e.name} <--`} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage({firstRedundant:e,ruleName:t}){return`Redundant input, expecting EOF but found: `+e.image},buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:n,customUserDescription:r,ruleName:i}){let a=`
170
+ but found: '`+t[0].image+`'`;return r?`Expecting: `+r+a:`Expecting: one of these possible Token sequences:\n${e.reduce((e,t)=>e.concat(t),[]).map(e=>`[${e.map(e=>Yt(e)).join(`, `)}]`).map((e,t)=>` ${t+1}. ${e}`).join(`
171
+ `)}`+a},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:n,ruleName:r}){let i=`
172
+ but found: '`+t[0].image+`'`;return n?`Expecting: `+n+i:`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::\n <${e.map(e=>`[${e.map(e=>Yt(e)).join(`,`)}]`).join(` ,`)}>`+i}};Object.freeze(un);var dn={buildRuleNotFoundError(e,t){return`Invalid grammar, reference to a rule which is not defined: ->`+t.nonTerminalName+`<-
173
+ inside top level rule: ->`+e.name+`<-`}},fn={buildDuplicateFoundError(e,t){function n(e){return e instanceof j?e.terminalType.name:e instanceof S?e.nonTerminalName:``}let r=e.name,i=t[0],a=i.idx,o=N(i),s=n(i),c=`->${o}${a>0?a:``}<- ${s?`with argument: ->${s}<-`:``}
174
+ appears more than once (${t.length} times) in the top level rule: ->${r}<-.
175
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
176
+ `;return c=c.replace(/[ \t]+/g,` `),c=c.replace(/\s\s+/g,`
177
+ `),c},buildNamespaceConflictError(e){return`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`},buildAlternationPrefixAmbiguityError(e){let t=e.prefixPath.map(e=>Yt(e)).join(`, `),n=e.alternation.idx===0?``:e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(` ,`)}> due to common lookahead prefix\nin <OR${n}> inside <${e.topLevelRule.name}> Rule,\n<${t}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(e){let t=e.alternation.idx===0?``:e.alternation.idx,n=e.prefixPath.length===0,r=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(` ,`)}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,\n`;if(n)r+=`These alternatives are all empty (match no tokens), making them indistinguishable.
178
+ Only the last alternative may be empty.
179
+ `;else{let t=e.prefixPath.map(e=>Yt(e)).join(`, `);r+=`<${t}> may appears as a prefix path in all these alternatives.\n`}return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
180
+ For Further details.`,r},buildEmptyRepetitionError(e){let t=N(e.repetition);return e.repetition.idx!==0&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError(e){
181
+ /* istanbul ignore next */
182
+ return`deprecated`},buildEmptyAlternationError(e){return`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`},buildTooManyAlternativesError(e){return`An Alternation cannot have more than 256 alternatives:\n<OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.\n has ${e.alternation.definition.length+1} alternatives.`},buildLeftRecursionError(e){let t=e.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${t}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${t} --> ${e.leftRecursionPath.map(e=>e.name).concat([t]).join(` --> `)}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError(e){
183
+ /* istanbul ignore next */
184
+ return`deprecated`},buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof C?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};function pn(e,t){let n=new mn(e,t);return n.resolveRefs(),n.errors}var mn=class extends de{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){Object.values(this.nameToTopRule).forEach(e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){let t=this.nameToTopRule[e.nonTerminalName];if(t)e.referencedRule=t;else{let t=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:t,type:V.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}},hn=class extends he{constructor(e,t){super(),this.topProd=e,this.path=t,this.possibleTokTypes=[],this.nextProductionName=``,this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error(`The path does not start with the walker's top Rule!`);return this.ruleStack=[...this.path.ruleStack].reverse(),this.occurrenceStack=[...this.path.occurrenceStack].reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,n){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let r=t.concat(n);this.updateExpectedNext(),this.walk(e.referencedRule,r)}}updateExpectedNext(){this.ruleStack.length===0?(this.nextProductionName=``,this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}},gn=class extends hn{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName=``,this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,n){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new w({definition:t.concat(n)});this.possibleTokTypes=_e(e),this.found=!0}}},_n=class extends he{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}},vn=class extends _n{walkMany(e,t,n){if(e.idx===this.occurrence){let e=t.concat(n)[0];this.result.isEndOfRule=e===void 0,e instanceof j&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,n)}},yn=class extends _n{walkManySep(e,t,n){if(e.idx===this.occurrence){let e=t.concat(n)[0];this.result.isEndOfRule=e===void 0,e instanceof j&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,n)}},bn=class extends _n{walkAtLeastOne(e,t,n){if(e.idx===this.occurrence){let e=t.concat(n)[0];this.result.isEndOfRule=e===void 0,e instanceof j&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,n)}},xn=class extends _n{walkAtLeastOneSep(e,t,n){if(e.idx===this.occurrence){let e=t.concat(n)[0];this.result.isEndOfRule=e===void 0,e instanceof j&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,n)}};function Sn(e,t,n=[]){n=[...n];let r=[],i=0;function a(t){return t.concat(e.slice(i+1))}function o(e){let i=Sn(a(e),t,n);return r.concat(i)}for(;n.length<t&&i<e.length;){let t=e[i];if(t instanceof w||t instanceof S)return o(t.definition);if(t instanceof T)r=o(t.definition);else if(t instanceof E)return o(t.definition.concat([new O({definition:t.definition})]));else if(t instanceof D)return o([new w({definition:t.definition}),new O({definition:[new j({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof k)r=o(t.definition.concat([new O({definition:[new j({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof O)r=o(t.definition.concat([new O({definition:t.definition})]));else if(t instanceof A)return t.definition.forEach(e=>{e.definition.length!==0&&(r=o(e.definition))}),r;else if(t instanceof j)n.push(t.terminalType);else throw Error(`non exhaustive match`);i++}return r.push({partialPath:n,suffixDef:e.slice(i)}),r}function Cn(e,t,n,r){let i=`EXIT_NONE_TERMINAL`,a=[i],o=`EXIT_ALTERNATIVE`,s=!1,c=t.length,l=c-r-1,u=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});d.length!==0;){let e=d.pop();if(e===o){s&&d.at(-1).idx<=l&&d.pop();continue}let r=e.def,f=e.idx,p=e.ruleStack,m=e.occurrenceStack;if(r.length===0)continue;let h=r[0];
185
+ /* istanbul ignore else */
186
+ if(h===i){let e={idx:f,def:r.slice(1),ruleStack:p.slice(0,-1),occurrenceStack:m.slice(0,-1)};d.push(e)}else if(h instanceof j){
187
+ /* istanbul ignore else */
188
+ if(f<c-1){let e=f+1,i=t[e];if(n(i,h.terminalType)){let t={idx:e,def:r.slice(1),ruleStack:p,occurrenceStack:m};d.push(t)}}else if(f===c-1)u.push({nextTokenType:h.terminalType,nextTokenOccurrence:h.idx,ruleStack:p,occurrenceStack:m}),s=!0;else throw Error(`non exhaustive match`)}else if(h instanceof S){let e=[...p];e.push(h.nonTerminalName);let t=[...m];t.push(h.idx);let n={idx:f,def:h.definition.concat(a,r.slice(1)),ruleStack:e,occurrenceStack:t};d.push(n)}else if(h instanceof T){let e={idx:f,def:r.slice(1),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t={idx:f,def:h.definition.concat(r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof E){let e=new O({definition:h.definition,idx:h.idx}),t={idx:f,def:h.definition.concat([e],r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof D){let e=new O({definition:[new j({terminalType:h.separator})].concat(h.definition),idx:h.idx}),t={idx:f,def:h.definition.concat([e],r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(t)}else if(h instanceof k){let e={idx:f,def:r.slice(1),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new O({definition:[new j({terminalType:h.separator})].concat(h.definition),idx:h.idx}),n={idx:f,def:h.definition.concat([t],r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof O){let e={idx:f,def:r.slice(1),ruleStack:p,occurrenceStack:m};d.push(e),d.push(o);let t=new O({definition:h.definition,idx:h.idx}),n={idx:f,def:h.definition.concat([t],r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(n)}else if(h instanceof A)for(let e=h.definition.length-1;e>=0;e--){let t={idx:f,def:h.definition[e].definition.concat(r.slice(1)),ruleStack:p,occurrenceStack:m};d.push(t),d.push(o)}else if(h instanceof w)d.push({idx:f,def:h.definition.concat(r.slice(1)),ruleStack:p,occurrenceStack:m});else if(h instanceof C)d.push(wn(h,f,p,m));else throw Error(`non exhaustive match`)}return u}function wn(e,t,n,r){let i=[...n];i.push(e.name);let a=[...r];return a.push(1),{idx:t,def:e.definition,ruleStack:i,occurrenceStack:a}}var z;(function(e){e[e.OPTION=0]=`OPTION`,e[e.REPETITION=1]=`REPETITION`,e[e.REPETITION_MANDATORY=2]=`REPETITION_MANDATORY`,e[e.REPETITION_MANDATORY_WITH_SEPARATOR=3]=`REPETITION_MANDATORY_WITH_SEPARATOR`,e[e.REPETITION_WITH_SEPARATOR=4]=`REPETITION_WITH_SEPARATOR`,e[e.ALTERNATION=5]=`ALTERNATION`})(z||={});function Tn(e){
189
+ /* istanbul ignore else */
190
+ if(e instanceof T||e===`Option`)return z.OPTION;if(e instanceof O||e===`Repetition`)return z.REPETITION;if(e instanceof E||e===`RepetitionMandatory`)return z.REPETITION_MANDATORY;if(e instanceof D||e===`RepetitionMandatoryWithSeparator`)return z.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof k||e===`RepetitionWithSeparator`)return z.REPETITION_WITH_SEPARATOR;if(e instanceof A||e===`Alternation`)return z.ALTERNATION;throw Error(`non exhaustive match`)}function En(e,t,n,r,i,a){let o=In(e,t,n);return a(o,r,Bn(o)?Nt:Mt,i)}function Dn(e,t,n,r,i,a){let o=Ln(e,t,i,n),s=Bn(o)?Nt:Mt;return a(o[0],s,r)}function On(e,t,n,r){let i=e.length,a=e.every(e=>e.every(e=>e.length===1));if(t)return function(t){let r=t.map(e=>e.GATE);for(let t=0;t<i;t++){let i=e[t],a=i.length,o=r[t];if(o===void 0||o.call(this)!==!1)nextPath:for(let e=0;e<a;e++){let r=i[e],a=r.length;for(let e=0;e<a;e++)if(n(this.LA_FAST(e+1),r[e])===!1)continue nextPath;return t}}};if(a&&!r){let t=e.map(e=>e.flat()).reduce((e,t,n)=>(t.forEach(t=>{t.tokenTypeIdx in e||(e[t.tokenTypeIdx]=n),t.categoryMatches.forEach(t=>{Object.hasOwn(e,t)||(e[t]=n)})}),e),{});return function(){let e=this.LA_FAST(1);return t[e.tokenTypeIdx]}}return function(){for(let t=0;t<i;t++){let r=e[t],i=r.length;nextPath:for(let e=0;e<i;e++){let i=r[e],a=i.length;for(let e=0;e<a;e++)if(n(this.LA_FAST(e+1),i[e])===!1)continue nextPath;return t}}}}function kn(e,t,n){let r=e.every(e=>e.length===1),i=e.length;if(r&&!n){let t=e.flat();if(t.length===1&&t[0].categoryMatches.length===0){let e=t[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===e}}{let e=t.reduce((e,t,n)=>(e[t.tokenTypeIdx]=!0,t.categoryMatches.forEach(t=>{e[t]=!0}),e),[]);return function(){let t=this.LA_FAST(1);return e[t.tokenTypeIdx]===!0}}}return function(){nextPath:for(let n=0;n<i;n++){let r=e[n],i=r.length;for(let e=0;e<i;e++)if(t(this.LA_FAST(e+1),r[e])===!1)continue nextPath;return!0}return!1}}var An=class extends he{constructor(e,t,n){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,n,r){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=n.concat(r),!0)}walkOption(e,t,n){this.checkIsTarget(e,z.OPTION,t,n)||super.walkOption(e,t,n)}walkAtLeastOne(e,t,n){this.checkIsTarget(e,z.REPETITION_MANDATORY,t,n)||super.walkOption(e,t,n)}walkAtLeastOneSep(e,t,n){this.checkIsTarget(e,z.REPETITION_MANDATORY_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}walkMany(e,t,n){this.checkIsTarget(e,z.REPETITION,t,n)||super.walkOption(e,t,n)}walkManySep(e,t,n){this.checkIsTarget(e,z.REPETITION_WITH_SEPARATOR,t,n)||super.walkOption(e,t,n)}},jn=class extends de{constructor(e,t,n){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=n,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.targetRef===void 0||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,z.OPTION)}visitRepetition(e){this.checkIsTarget(e,z.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,z.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,z.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,z.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,z.ALTERNATION)}};function Mn(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=[];return t}function Nn(e){let t=[``];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e=0;e<t.length;e++){let n=t[e];i.push(n+`_`+r.tokenTypeIdx);for(let e=0;e<r.categoryMatches.length;e++){let t=`_`+r.categoryMatches[e];i.push(n+t)}}t=i}return t}function Pn(e,t,n){for(let r=0;r<e.length;r++){if(r===n)continue;let i=e[r];for(let e=0;e<t.length;e++)if(i[t[e]]===!0)return!1}return!0}function Fn(e,t){let n=e.map(e=>Sn([e],1)),r=Mn(n.length),i=n.map(e=>{let t={};return e.forEach(e=>{Nn(e.partialPath).forEach(e=>{t[e]=!0})}),t}),a=n;for(let e=1;e<=t;e++){let n=a;a=Mn(n.length);for(let o=0;o<n.length;o++){let s=n[o];for(let n=0;n<s.length;n++){let c=s[n].partialPath,l=s[n].suffixDef,u=Nn(c);if(Pn(i,u,o)||l.length===0||c.length===t){let e=r[o];if(Rn(e,c)===!1){e.push(c);for(let e=0;e<u.length;e++){let t=u[e];i[o][t]=!0}}}else{let t=Sn(l,e+1,c);a[o]=a[o].concat(t),t.forEach(e=>{Nn(e.partialPath).forEach(e=>{i[o][e]=!0})})}}}}return r}function In(e,t,n,r){let i=new jn(e,z.ALTERNATION,r);return t.accept(i),Fn(i.result,n)}function Ln(e,t,n,r){let i=new jn(e,n);t.accept(i);let a=i.result,o=new An(t,e,n).startWalking();return Fn([new w({definition:a}),new w({definition:o})],r)}function Rn(e,t){compareOtherPath:for(let n=0;n<e.length;n++){let r=e[n];if(r.length===t.length){for(let e=0;e<r.length;e++){let n=t[e],i=r[e];if(n!==i&&i.categoryMatchesMap[n.tokenTypeIdx]===void 0)continue compareOtherPath}return!0}}return!1}function zn(e,t){return e.length<t.length&&e.every((e,n)=>{let r=t[n];return e===r||r.categoryMatchesMap[e.tokenTypeIdx]})}function Bn(e){return e.every(e=>e.every(e=>e.every(e=>e.categoryMatches.length===0)))}function Vn(e){return e.lookaheadStrategy.validate({rules:e.rules,tokenTypes:e.tokenTypes,grammarName:e.grammarName}).map(e=>Object.assign({type:V.CUSTOM_LOOKAHEAD_VALIDATION},e))}function Hn(e,t,n,r){let i=e.flatMap(e=>Un(e,n)),a=ar(e,t,n),o=e.flatMap(e=>tr(e,n)),s=e.flatMap(t=>qn(t,e,r,n));return i.concat(a,o,s)}function Un(e,t){let n=new Kn;e.accept(n);let r=n.allProductions,i=Object.groupBy(r,Wn),a=Object.fromEntries(Object.entries(i).filter(([e,t])=>t.length>1));return Object.values(a).map(n=>{let r=n[0],i=t.buildDuplicateFoundError(e,n),a=N(r),o={message:i,type:V.DUPLICATE_PRODUCTIONS,ruleName:e.name,dslName:a,occurrence:r.idx},s=Gn(r);return s&&(o.parameter=s),o})}function Wn(e){return`${N(e)}_#_${e.idx}_#_${Gn(e)}`}function Gn(e){return e instanceof j?e.terminalType.name:e instanceof S?e.nonTerminalName:``}var Kn=class extends de{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 qn(e,t,n,r){let i=[];if(t.reduce((t,n)=>n.name===e.name?t+1:t,0)>1){let t=r.buildDuplicateRuleNameError({topLevelRule:e,grammarName:n});i.push({message:t,type:V.DUPLICATE_RULE_NAME,ruleName:e.name})}return i}function Jn(e,t,n){let r=[],i;return t.includes(e)||(i=`Invalid rule override, rule: ->${e}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:V.INVALID_RULE_OVERRIDE,ruleName:e})),r}function Yn(e,t,n,r=[]){let i=[],a=Xn(t.definition);if(a.length===0)return[];{let t=e.name;a.includes(e)&&i.push({message:n.buildLeftRecursionError({topLevelRule:e,leftRecursionPath:r}),type:V.LEFT_RECURSION,ruleName:t});let o=r.concat([e]),s=a.filter(e=>!o.includes(e)).flatMap(t=>{let i=[...r];return i.push(t),Yn(e,t,n,i)});return i.concat(s)}}function Xn(e){let t=[];if(e.length===0)return t;let n=e[0];
191
+ /* istanbul ignore else */
192
+ if(n instanceof S)t.push(n.referencedRule);else if(n instanceof w||n instanceof T||n instanceof E||n instanceof D||n instanceof k||n instanceof O)t=t.concat(Xn(n.definition));else if(n instanceof A)t=n.definition.map(e=>Xn(e.definition)).flat();else if(!(n instanceof j))throw Error(`non exhaustive match`);let r=pe(n),i=e.length>1;if(r&&i){let n=e.slice(1);return t.concat(Xn(n))}return t}var Zn=class extends de{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}};function Qn(e,t){let n=new Zn;return e.accept(n),n.alternations.flatMap(n=>n.definition.slice(0,-1).flatMap((r,i)=>Cn([r],[],Mt,1).length===0?[{message:t.buildEmptyAlternationError({topLevelRule:e,alternation:n,emptyChoiceIdx:i}),type:V.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:n.idx,alternative:i+1}]:[]))}function $n(e,t,n){let r=new Zn;e.accept(r);let i=r.alternations;return i=i.filter(e=>e.ignoreAmbiguities!==!0),i.flatMap(r=>{let i=r.idx,a=In(i,e,r.maxLookahead||t,r),o=rr(a,r,e,n),s=ir(a,r,e,n);return o.concat(s)})}var er=class extends de{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 tr(e,t){let n=new Zn;return e.accept(n),n.alternations.flatMap(n=>n.definition.length>255?[{message:t.buildTooManyAlternativesError({topLevelRule:e,alternation:n}),type:V.TOO_MANY_ALTS,ruleName:e.name,occurrence:n.idx}]:[])}function nr(e,t,n){let r=[];return e.forEach(e=>{let i=new er;e.accept(i),i.allProductions.forEach(i=>{let a=Tn(i),o=i.maxLookahead||t,s=i.idx;if(Ln(s,e,a,o)[0].flat().length===0){let t=n.buildEmptyRepetitionError({topLevelRule:e,repetition:i});r.push({message:t,type:V.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),r}function rr(e,t,n,r){let i=[];return e.reduce((n,r,a)=>(t.definition[a].ignoreAmbiguities===!0||r.forEach(r=>{let o=[a];e.forEach((e,n)=>{a!==n&&Rn(e,r)&&t.definition[n].ignoreAmbiguities!==!0&&o.push(n)}),o.length>1&&!Rn(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]).map(e=>{let i=e.alts.map(e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:V.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:t.idx,alternatives:e.alts}})}function ir(e,t,n,r){let i=e.reduce((e,t,n)=>{let r=t.map(e=>({idx:n,path:e}));return e.concat(r)},[]);return i.flatMap(e=>{if(t.definition[e.idx].ignoreAmbiguities===!0)return[];let a=e.idx,o=e.path;return i.filter(e=>t.definition[e.idx].ignoreAmbiguities!==!0&&e.idx<a&&zn(e.path,o)).map(e=>{let i=[e.idx+1,a+1],o=t.idx===0?``:t.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:t,ambiguityIndices:i,prefixPath:e.path}),type:V.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})})}function ar(e,t,n){let r=[],i=t.map(e=>e.name);return e.forEach(e=>{let t=e.name;if(i.includes(t)){let i=n.buildNamespaceConflictError(e);r.push({message:i,type:V.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),r}function or(e){let t=Object.assign({errMsgProvider:dn},e),n={};return e.rules.forEach(e=>{n[e.name]=e}),pn(n,t.errMsgProvider)}function sr(e){let t=e.errMsgProvider??fn;return Hn(e.rules,e.tokenTypes,t,e.grammarName)}var cr=`MismatchedTokenException`,lr=`NoViableAltException`,ur=`EarlyExitException`,dr=`NotAllInputParsedException`,fr=[cr,lr,ur,dr];Object.freeze(fr);function pr(e){return fr.includes(e.name)}var mr=class extends Error{constructor(e,t){
193
+ /* istanbul ignore next - V8 workaround to remove constructor from stacktrace when typescript target is ES5 */
194
+ super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}},hr=class extends mr{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=cr}},gr=class extends mr{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=lr}},_r=class extends mr{constructor(e,t){super(e,t),this.name=dr}},vr=class extends mr{constructor(e,t,n){super(e,t),this.previousToken=n,this.name=ur}},yr={},br=`InRuleRecoveryException`,xr=class extends Error{constructor(e){super(e),this.name=br}},Sr=class{initRecoverable(e){this.firstAfterRepMap=[],this.resyncFollows={},this.recoveryEnabled=Object.hasOwn(e,`recoveryEnabled`)?e.recoveryEnabled:B.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Cr)}getTokenToInsert(e){let t=cn(e,``,-1,-1,-1,-1,-1,-1);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,n,r){let i=this.findReSyncTokenType(),a=this.exportLexerState(),o=[],s=!1,c=this.LA_FAST(1),l=this.LA_FAST(1),u=()=>{let e=this.LA(0),t=new hr(this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:e,ruleName:this.getCurrRuleFullName()}),c,this.LA(0));t.resyncedTokens=o.slice(0,-1),this.SAVE_ERROR(t)};for(;!s;)if(this.tokenMatcher(l,r)){u();return}else if(n.call(this)){u(),e.apply(this,t);return}else this.tokenMatcher(l,i)?s=!0:(l=this.SKIP_TOKEN(),this.addToResyncTokens(l,o));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,n){return!(n===!1||this.tokenMatcher(this.LA_FAST(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getNextPossibleTokenTypes(e){let t=e.ruleStack[0],n=this.getGAstProductions()[t];return new gn(n,e).startWalking()}getFollowsForInRuleRecovery(e,t){let n=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new xr(`sad sad panda`)}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||t.length===0)return!1;let n=this.LA_FAST(1);return t.find(e=>this.tokenMatcher(n,e))!==void 0}canRecoverWithSingleTokenDeletion(e){return this.canTokenTypeBeDeletedInRecovery(e)?this.tokenMatcher(this.LA(2),e):!1}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return this.getFollowSetFromFollowKey(t).includes(e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA_FAST(1),n=2;for(;;){let r=e.find(e=>ln(t,e));if(r!==void 0)return r;t=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK_IDX===0)return yr;let e=this.currRuleShortName,t=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,r=Array(n);for(let i=0;i<n;i++)i===0?r[i]=yr:r[i]={ruleName:this.shortRuleNameToFullName(e[i]),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])};return r}flattenFollowSet(){return this.buildFullFollowKeyStack().map(e=>this.getFollowSetFromFollowKey(e)).flat()}getFollowSetFromFollowKey(e){if(e===yr)return[R];let t=e.ruleName+e.idxInCallingRule+xe+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,R)||t.push(e),t}reSyncTo(e){let t=[],n=this.LA_FAST(1);for(;this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,t);return t.slice(0,-1)}attemptInRepetitionRecovery(e,t,n,r,i,a,o){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){let e=this.RULE_STACK_IDX+1,t=Array(e);for(let n=0;n<e;n++)t[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return t}};function Cr(e,t,n,r,i,a,o){var s,c;let l=r|i,u=(s=this.firstAfterRepMap)[c=this.currRuleShortName]??(s[c]=[]),d=u[l];if(d===void 0){let e=this.getCurrRuleFullName(),t=this.getGAstProductions()[e];d=new a(t,i).startWalking(),u[l]=d}let f=d.token,p=d.occurrence,m=d.isEndOfRule;this.RULE_STACK_IDX===0&&m&&f===void 0&&(f=R,p=1),f!==void 0&&p!==void 0&&this.shouldInRepetitionRecoveryBeTried(f,p,o)&&this.tryInRepetitionRecovery(e,t,n,f)}var wr=1024,Tr=1280,Er=1536,Dr=class{constructor(e){this.maxLookahead=e?.maxLookahead??B.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);if(t.length===0){let n=this.validateEmptyOrAlternatives(e.rules),r=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...t,...n,...r,...i]}return t}validateNoLeftRecursion(e){return e.flatMap(e=>Yn(e,e,fn))}validateEmptyOrAlternatives(e){return e.flatMap(e=>Qn(e,fn))}validateAmbiguousAlternationAlternatives(e,t){return e.flatMap(e=>$n(e,t,fn))}validateSomeNonEmptyLookaheadPath(e,t){return nr(e,t,fn)}buildLookaheadForAlternation(e){return En(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,On)}buildLookaheadForOptional(e){return Dn(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,Tn(e.prodType),kn)}},Or=class{initLooksAhead(e){this.dynamicTokensEnabled=Object.hasOwn(e,`dynamicTokensEnabled`)?e.dynamicTokensEnabled:B.dynamicTokensEnabled,this.maxLookahead=Object.hasOwn(e,`maxLookahead`)?e.maxLookahead:B.maxLookahead,this.lookaheadStrategy=Object.hasOwn(e,`lookaheadStrategy`)?e.lookaheadStrategy:new Dr({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=[],this.currRuleLookaheadFuncs=[]}preComputeLookaheadFunctions(e){e.forEach(e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{let{alternation:t,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:a,repetitionWithSeparator:o}=Ar(e);t.forEach(t=>{let n=t.idx===0?``:t.idx;this.TRACE_INIT(`${N(t)}${n}`,()=>{let n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled});this.setLaFuncCache(this.fullRuleNameToShort[e.name],256|t.idx,n)})}),n.forEach(t=>{this.computeLookaheadFunc(e,t.idx,768,`Repetition`,t.maxLookahead,N(t))}),r.forEach(t=>{this.computeLookaheadFunc(e,t.idx,512,`Option`,t.maxLookahead,N(t))}),i.forEach(t=>{this.computeLookaheadFunc(e,t.idx,wr,`RepetitionMandatory`,t.maxLookahead,N(t))}),a.forEach(t=>{this.computeLookaheadFunc(e,t.idx,Er,`RepetitionMandatoryWithSeparator`,t.maxLookahead,N(t))}),o.forEach(t=>{this.computeLookaheadFunc(e,t.idx,Tr,`RepetitionWithSeparator`,t.maxLookahead,N(t))})})})}computeLookaheadFunc(e,t,n,r,i,a){this.TRACE_INIT(`${a}${t===0?``:t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r});this.setLaFuncCache(this.fullRuleNameToShort[e.name],n|t,a)})}setLaFuncCache(e,t,n){let r=this.lookAheadFuncsCache[e];r===void 0&&(r=[],this.lookAheadFuncsCache[e]=r),r[t]=n}},kr=new class extends de{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)}};function Ar(e){kr.reset(),e.accept(kr);let t=kr.dslMethods;return kr.reset(),t}function jr(e,t){e.startOffset===-1?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset)}function Mr(e,t){e.startOffset===-1?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function Nr(e,t,n){e.children[n]===void 0?e.children[n]=[t]:e.children[n].push(t)}function Pr(e,t,n){e.children[t]===void 0?e.children[t]=[n]:e.children[t].push(n)}var Fr=`name`;function Ir(e,t){Object.defineProperty(e,Fr,{enumerable:!1,configurable:!0,writable:!1,value:t})}function Lr(e,t){let n=Object.keys(e),r=n.length;for(let i=0;i<r;i++){let r=e[n[i]],a=r.length;for(let e=0;e<a;e++){let n=r[e];n.tokenTypeIdx===void 0&&this[n.name](n.children,t)}}}function Rr(e,t){let n=function(){};return Ir(n,e+`BaseSemantics`),n.prototype={visit:function(e,t){if(Array.isArray(e)&&(e=e[0]),e!==void 0)return this[e.name](e.children,t)},validateVisitor:function(){let e=Vr(this,t);if(e.length!==0){let t=e.map(e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${t.join(`
195
+
196
+ `).replace(/\n/g,`
197
+ `)}`)}}},n.prototype.constructor=n,n._RULE_NAMES=t,n}function zr(e,t,n){let r=function(){};Ir(r,e+`BaseSemanticsWithDefaults`);let i=Object.create(n.prototype);return t.forEach(e=>{i[e]=Lr}),r.prototype=i,r.prototype.constructor=r,r}var Br;(function(e){e[e.REDUNDANT_METHOD=0]=`REDUNDANT_METHOD`,e[e.MISSING_METHOD=1]=`MISSING_METHOD`})(Br||={});function Vr(e,t){return Hr(e,t)}function Hr(e,t){return t.filter(t=>typeof e[t]!=`function`).map(t=>({msg:`Missing visitor method: <${t}> on ${e.constructor.name} CST Visitor.`,type:Br.MISSING_METHOD,methodName:t})).filter(Boolean)}var Ur=class{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=Object.hasOwn(e,`nodeLocationTracking`)?e.nodeLocationTracking:B.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=()=>{},this.cstFinallyStateUpdate=()=>{},this.cstPostTerminal=()=>{},this.cstPostNonTerminal=()=>{},this.cstPostRule=()=>{};else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Mr,this.setNodeLocationFromNode=Mr,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=jr,this.setNodeLocationFromNode=jr,this.cstPostRule=()=>{},this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=()=>{},this.setNodeLocationFromNode=()=>{},this.cstPostRule=()=>{},this.setInitialNodeLocation=()=>{};else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`)}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:-1,endOffset:-1}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA_FAST(1).startOffset,endOffset:-1}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:-1,startLine:-1,startColumn:-1,endOffset:-1,endLine:-1,endColumn:-1}}setInitialNodeLocationFullRegular(e){let t=this.LA_FAST(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:-1,endLine:-1,endColumn:-1}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?(n.endOffset=t.endOffset,n.endLine=t.endLine,n.endColumn=t.endColumn):(n.startOffset=-1,n.startLine=-1,n.startColumn=-1)}cstPostRuleOnlyOffset(e){let t=this.LA(0),n=e.location;n.startOffset!==-1&&n.startOffset<=t.startOffset?n.endOffset=t.endOffset:n.startOffset=-1}cstPostTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Nr(n,t,e),this.setNodeLocationFromToken(n.location,t)}cstPostNonTerminal(e,t){let n=this.CST_STACK[this.CST_STACK.length-1];Pr(n,t,e),this.setNodeLocationFromNode(n.location,e.location)}get currCSTNode(){let e=this;return e.CST_STACK[e.CST_STACK.length-1]}getBaseCstVisitorConstructor(){if(this.baseCstVisitorConstructor===void 0){let e=Rr(this.className,Object.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(this.baseCstVisitorWithDefaultsConstructor===void 0){let e=zr(this.className,Object.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},Wr=class{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.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):si}LA_FAST(e){let t=this.currIdx+e;return this.tokVector[t]}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?si:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},Gr=class{ACTION(e){return e.call(this)}consume(e,t,n){return this.consumeInternal(t,e,n)}subrule(e,t,n){return this.subruleInternal(t,e,n)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,n=ci){if(this.definedRulesNames.includes(e)){let t={message:fn.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:V.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let r=this.defineRule(e,t,n);return this[e]=r,r}OVERRIDE_RULE(e,t,n=ci){let r=Jn(e,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);let i=this.defineRule(e,t,n);return this[e]=i,i}BACKTRACK(e,t){let n=e.coreRule??e;return function(){this.isBackTrackingStack.push(1);let e=this.saveRecogState();try{return n.apply(this,t),!0}catch(e){if(pr(e))return!1;throw e}finally{this.reloadRecogState(e),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return le(Object.values(this.gastProductionsCache))}},Kr=class{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull=[],this.fullRuleNameToShort={},this.ruleShortNameIdx=0,this.tokenMatcher=Nt,this.subruleIdx=0,this.currRuleShortName=-1,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},Object.hasOwn(t,`serializedGrammar`))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
198
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
199
+ For Further details.`);if(Array.isArray(e)){if(e.length===0)throw Error(`A Token Vocabulary cannot be empty.
200
+ Note that the first argument for the parser constructor
201
+ 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.
202
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
203
+ For Further details.`)}if(Array.isArray(e))this.tokensMap=e.reduce((e,t)=>(e[t.name]=t,e),{});else if(Object.hasOwn(e,`modes`)&&Object.values(e.modes).flat().every(Kt)){let t=Object.values(e.modes).flat(),n=[...new Set(t)];this.tokensMap=n.reduce((e,t)=>(e[t.name]=t,e),{})}else if(typeof e==`object`&&e)this.tokensMap=Object.assign({},e);else throw Error(`<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition`);this.tokensMap.EOF=R;let n=(Object.hasOwn(e,`modes`)?Object.values(e.modes).flat():Object.values(e)).every(e=>e.categoryMatches?.length==0);this.tokenMatcher=n?Nt:Mt,It(Object.values(this.tokensMap))}defineRule(e,t,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let r=Object.hasOwn(n,`resyncEnabled`)?n.resyncEnabled:ci.resyncEnabled,i=Object.hasOwn(n,`recoveryValueFunc`)?n.recoveryValueFunc:ci.recoveryValueFunc,a=this.ruleShortNameIdx++;this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a;let o;return o=this.outputCst===!0?function(...n){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n);let r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,n)}catch(e){return this.invokeRuleCatch(e,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...t){this.onBeforeParse(e);try{return o.apply(this,t)}finally{this.onAfterParse(e)}},{ruleName:e,originalGrammarAction:t,coreRule:o})}invokeRuleCatch(e,t,n){let r=this.RULE_STACK_IDX===0,i=t&&!this.isBackTracking()&&this.recoveryEnabled;if(pr(e)){let t=e;if(i){let r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(t.resyncedTokens=this.reSyncTo(r),this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}return n(e)}if(this.outputCst){let e=this.CST_STACK[this.CST_STACK.length-1];e.recoveredNode=!0,t.partialCstResult=e}throw t}if(r)return this.moveToTerminatedState(),n(e);throw t}throw e}optionInternal(e,t){let n=512|t;return this.optionInternalLogic(e,t,n)}optionInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof e!=`function`){i=e.DEF;let t=e.GATE;if(t!==void 0){let e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;if(r.call(this)===!0)return i.call(this)}atLeastOneInternal(e,t){let n=wr|e;return this.atLeastOneInternalLogic(e,t,n)}atLeastOneInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;if(r.call(this)===!0){let e=this.doSingleRepetition(i);for(;r.call(this)===!0&&e===!0;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,z.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],r,wr,e,bn)}atLeastOneSepFirstInternal(e,t){let n=Er|e;this.atLeastOneSepFirstInternalLogic(e,t,n)}atLeastOneSepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,xn],t,Er,e,xn)}else throw this.raiseEarlyExitException(e,z.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let n=768|e;return this.manyInternalLogic(e,t,n)}manyInternalLogic(e,t,n){let r=this.currRuleLookaheadFuncs[n],i;if(typeof t!=`function`){i=t.DEF;let e=t.GATE;if(e!==void 0){let t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;r.call(this)===!0&&a===!0;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],r,768,e,vn,a)}manySepFirstInternal(e,t){let n=Tr|e;this.manySepFirstInternalLogic(e,t,n)}manySepFirstInternalLogic(e,t,n){let r=t.DEF,i=t.SEP;if(this.currRuleLookaheadFuncs[n].call(this)===!0){r.call(this);let t=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;this.tokenMatcher(this.LA_FAST(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,i,t,r,yn],t,Tr,e,yn)}}repetitionSepSecondInternal(e,t,n,r,i){for(;n();)this.CONSUME(t),r.call(this);
204
+ /* istanbul ignore else */
205
+ this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,n,r,i],n,Er,e,i)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let n=256|t,r=Array.isArray(e)?e:e.DEF,i=this.currRuleLookaheadFuncs[n].call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName]),this.cstFinallyStateUpdate()}subruleInternal(e,t,n){let r;try{let i=n===void 0?void 0:n.ARGS;return this.subruleIdx=t,r=e.coreRule.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),r}catch(t){throw this.subruleInternalError(t,n,e.ruleName)}}subruleInternalError(e,t,n){throw pr(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,t!==void 0&&t.LABEL!==void 0?t.LABEL:n),delete e.partialCstResult),e}consumeInternal(e,t,n){let r;try{let t=this.LA_FAST(1);this.tokenMatcher(t,e)===!0?(this.consumeToken(),r=t):this.consumeInternalError(e,t,n)}catch(n){r=this.consumeInternalRecovery(e,t,n)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,r),r}consumeInternalError(e,t,n){let r,i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new hr(r,t,i))}consumeInternalRecovery(e,t,n){if(this.recoveryEnabled&&n.name===`MismatchedTokenException`&&!this.isBackTracking()){let r=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,r)}catch(e){throw e.name===`InRuleRecoveryException`?n:e}}throw n}saveRecogState(){let e=this.errors,t=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState);let t=e.RULE_STACK;for(let e=0;e<t.length;e++)this.RULE_STACK[e]=t[e];this.RULE_STACK_IDX=t.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX],this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[this.currRuleShortName])}ruleInvocationStateUpdate(e,t,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=e,this.currRuleShortName=e,this.currRuleLookaheadFuncs=this.lookAheadFuncsCache[e],this.cstInvocationStateUpdate(t)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){let e=this.currRuleShortName;return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),R)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=-1,this.currRuleLookaheadFuncs=[],this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(e){for(let e=0;e<this.maxLookahead+1;e++)this.tokVector.push(si)}onAfterParse(e){if(this.isAtEndOfInput()===!1){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new _r(t,e))}for(;this.tokVector.at(-1)===si;)this.tokVector.pop()}},qr=class{initErrorHandler(e){this._errors=[],this.errorMessageProvider=Object.hasOwn(e,`errorMessageProvider`)?e.errorMessageProvider:B.errorMessageProvider}SAVE_ERROR(e){if(pr(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(e),e;throw Error(`Trying to save an Error which is not a RecognitionException`)}get errors(){return[...this._errors]}set errors(e){this._errors=e}raiseEarlyExitException(e,t,n){let r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=Ln(e,i,t,this.maxLookahead)[0],o=[];for(let e=1;e<=this.maxLookahead;e++)o.push(this.LA(e));let s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:a,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new vr(s,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let n=this.getCurrRuleFullName(),r=this.getGAstProductions()[n],i=In(e,r,this.maxLookahead),a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:a,previous:o,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new gr(s,this.LA(1),o))}},Jr={description:`This Object indicates the Parser is during Recording Phase`};Object.freeze(Jr);var Yr=!0,Xr=255,Zr=L({name:`RECORDING_PHASE_TOKEN`,pattern:I.NA});It([Zr]);var Qr=cn(Zr,`This IToken indicates the Parser is in Recording Phase
206
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Qr);var $r={name:`This CSTNode indicates the Parser is in Recording Phase
207
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},ei=class{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT(`Enable Recording`,()=>{for(let e=0;e<10;e++){let t=e>0?e:``;this[`CONSUME${t}`]=function(t,n){return this.consumeInternalRecord(t,e,n)},this[`SUBRULE${t}`]=function(t,n){return this.subruleInternalRecord(t,e,n)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,n){return this.consumeInternalRecord(t,e,n)},this.subrule=function(e,t,n){return this.subruleInternalRecord(t,e,n)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT(`Deleting Recording methods`,()=>{let e=this;for(let t=0;t<10;t++){let n=t>0?t:``;delete e[`CONSUME${n}`],delete e[`SUBRULE${n}`],delete e[`OPTION${n}`],delete e[`OR${n}`],delete e[`MANY${n}`],delete e[`MANY_SEP${n}`],delete e[`AT_LEAST_ONE${n}`],delete e[`AT_LEAST_ONE_SEP${n}`]}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,t){return()=>!0}LA_RECORD(e){return si}topLevelRuleRecord(e,t){try{let n=new C({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),t.call(this),this.recordingProdStack.pop(),n}catch(e){if(e.KNOWN_RECORDER_ERROR!==!0)try{e.message+=`
208
+ This error was thrown during the "grammar recording phase" For more info see:
209
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw e}throw e}}optionInternalRecord(e,t){return ti.call(this,T,e,t)}atLeastOneInternalRecord(e,t){ti.call(this,E,t,e)}atLeastOneSepFirstInternalRecord(e,t){ti.call(this,D,t,e,Yr)}manyInternalRecord(e,t){ti.call(this,O,t,e)}manySepFirstInternalRecord(e,t){ti.call(this,k,t,e,Yr)}orInternalRecord(e,t){return ni.call(this,e,t)}subruleInternalRecord(e,t,n){if(ii(t),!e||!Object.hasOwn(e,`ruleName`)){let n=/* @__PURE__ */ Error(`<SUBRULE${ri(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=this.recordingProdStack.at(-1),i=e.ruleName,a=new S({idx:t,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(a),this.outputCst?$r:Jr}consumeInternalRecord(e,t,n){if(ii(t),!Ht(e)){let n=/* @__PURE__ */ Error(`<CONSUME${ri(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}let r=this.recordingProdStack.at(-1),i=new j({idx:t,terminalType:e,label:n?.LABEL});return r.definition.push(i),Qr}};function ti(e,t,n,r=!1){ii(n);let i=this.recordingProdStack.at(-1),a=typeof t==`function`?t:t.DEF,o=new e({definition:[],idx:n});return r&&(o.separator=t.SEP),Object.hasOwn(t,`MAX_LOOKAHEAD`)&&(o.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(o),a.call(this),i.definition.push(o),this.recordingProdStack.pop(),Jr}function ni(e,t){ii(t);let n=this.recordingProdStack.at(-1),r=Array.isArray(e)===!1,i=r===!1?e:e.DEF,a=new A({definition:[],idx:t,ignoreAmbiguities:r&&e.IGNORE_AMBIGUITIES===!0});return Object.hasOwn(e,`MAX_LOOKAHEAD`)&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=i.some(e=>typeof e.GATE==`function`),n.definition.push(a),i.forEach(e=>{let t=new w({definition:[]});a.definition.push(t),Object.hasOwn(e,`IGNORE_AMBIGUITIES`)?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:Object.hasOwn(e,`GATE`)&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),Jr}function ri(e){return e===0?``:`${e}`}function ii(e){if(e<0||e>Xr){let t=/* @__PURE__ */ Error(`Invalid DSL Method idx value: <${e}>\n\tIdx value must be a none negative value smaller than 256`);throw t.KNOWN_RECORDER_ERROR=!0,t}}var ai=class{initPerformanceTracer(e){if(Object.hasOwn(e,`traceInitPerf`)){let t=e.traceInitPerf,n=typeof t==`number`;this.traceInitMaxIdent=n?t:1/0,this.traceInitPerf=n?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=B.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(this.traceInitPerf===!0){this.traceInitIndent++;let n=Array(this.traceInitIndent+1).join(` `);this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${e}>`);let{time:r,value:i}=ae(t),a=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${n}<-- <${e}> time: ${r}ms`),this.traceInitIndent--,i}return t()}};function oi(e,t){t.forEach(t=>{let n=t.prototype;Object.getOwnPropertyNames(n).forEach(r=>{if(r===`constructor`)return;let i=Object.getOwnPropertyDescriptor(n,r);i&&(i.get||i.set)?Object.defineProperty(e.prototype,r,i):e.prototype[r]=t.prototype[r]})})}var si=cn(R,``,-1,-1,-1,-1,-1,-1);Object.freeze(si);var B=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:un,nodeLocationTracking:`none`,traceInitPerf:!1,skipValidations:!1}),ci=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0}),V;(function(e){e[e.INVALID_RULE_NAME=0]=`INVALID_RULE_NAME`,e[e.DUPLICATE_RULE_NAME=1]=`DUPLICATE_RULE_NAME`,e[e.INVALID_RULE_OVERRIDE=2]=`INVALID_RULE_OVERRIDE`,e[e.DUPLICATE_PRODUCTIONS=3]=`DUPLICATE_PRODUCTIONS`,e[e.UNRESOLVED_SUBRULE_REF=4]=`UNRESOLVED_SUBRULE_REF`,e[e.LEFT_RECURSION=5]=`LEFT_RECURSION`,e[e.NONE_LAST_EMPTY_ALT=6]=`NONE_LAST_EMPTY_ALT`,e[e.AMBIGUOUS_ALTS=7]=`AMBIGUOUS_ALTS`,e[e.CONFLICT_TOKENS_RULES_NAMESPACE=8]=`CONFLICT_TOKENS_RULES_NAMESPACE`,e[e.INVALID_TOKEN_NAME=9]=`INVALID_TOKEN_NAME`,e[e.NO_NON_EMPTY_LOOKAHEAD=10]=`NO_NON_EMPTY_LOOKAHEAD`,e[e.AMBIGUOUS_PREFIX_ALTS=11]=`AMBIGUOUS_PREFIX_ALTS`,e[e.TOO_MANY_ALTS=12]=`TOO_MANY_ALTS`,e[e.CUSTOM_LOOKAHEAD_VALIDATION=13]=`CUSTOM_LOOKAHEAD_VALIDATION`})(V||={});var li=class e{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 t;this.selfAnalysisDone=!0;let n=this.className;this.TRACE_INIT(`toFastProps`,()=>{oe(this)}),this.TRACE_INIT(`Grammar Recording`,()=>{try{this.enableRecording(),this.definedRulesNames.forEach(e=>{let t=this[e].originalGrammarAction,n;this.TRACE_INIT(`${e} Rule`,()=>{n=this.topLevelRuleRecord(e,t)}),this.gastProductionsCache[e]=n})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT(`Grammar Resolving`,()=>{r=or({rules:Object.values(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT(`Grammar Validations`,()=>{if(r.length===0&&this.skipValidations===!1){let e=sr({rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),errMsgProvider:fn,grammarName:n}),t=Vn({lookaheadStrategy:this.lookaheadStrategy,rules:Object.values(this.gastProductionsCache),tokenTypes:Object.values(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(e,t)}}),this.definitionErrors.length===0&&(this.recoveryEnabled&&this.TRACE_INIT(`computeAllProdsFollows`,()=>{let e=Ce(Object.values(this.gastProductionsCache));this.resyncFollows=e}),this.TRACE_INIT(`ComputeLookaheadFunctions`,()=>{var e,t;(t=(e=this.lookaheadStrategy).initialize)==null||t.call(e,{rules:Object.values(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Object.values(this.gastProductionsCache))})),!e.DEFER_DEFINITION_ERRORS_HANDLING&&this.definitionErrors.length!==0)throw t=this.definitionErrors.map(e=>e.message),Error(`Parser Definition Errors detected:\n ${t.join(`
210
+ -------------------------------
211
+ `)}`)})}constructor(e,t){this.definitionErrors=[],this.selfAnalysisDone=!1;let n=this;if(n.initErrorHandler(t),n.initLexerAdapter(),n.initLooksAhead(t),n.initRecognizerEngine(e,t),n.initRecoverable(t),n.initTreeBuilder(t),n.initGastRecorder(t),n.initPerformanceTracer(t),Object.hasOwn(t,`ignoredIssues`))throw Error(`The <ignoredIssues> IParserConfig property has been deprecated.
212
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
213
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
214
+ For further details.`);this.skipValidations=Object.hasOwn(t,`skipValidations`)?t.skipValidations:B.skipValidations}};li.DEFER_DEFINITION_ERRORS_HANDLING=!1,oi(li,[Sr,Or,Ur,Wr,Kr,Gr,qr,ei,ai]);var ui=class extends li{constructor(e,t=B){let n=Object.assign({},t);n.outputCst=!0,super(e,n)}},di=/* @__PURE__ */ y(e=>e!==void 0&&e>=0,`isKnownLocation`)
215
+ /* istanbul ignore file - tricky to import some things from this module during testing */
216
+ ;function fi(e,t){let n=e.lexer.tokenize(t);if(n.errors.length>0){let r=n.errors[0],i=di(r.offset)?r.offset:t.length,a=i+(di(r.length)?r.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${r.message} at line ${r.line??1}, column ${r.column??1} [${i},${a})`)}e.parser.input=n.tokens;let r=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(r)}y(fi,`runChevrotainParse`);var H={SOLID_ARROW:0,BACK_ARROW:1,LINE_SOLID:2,CIRCLE_ARROW:3,CROSS_ARROW:4,CIRCLE_ARROW_REVERSED:5,CROSS_ARROW_REVERSED:6},pi=`LR`,mi=g.usecase,hi=/* @__PURE__ */ y(()=>({actors:/* @__PURE__ */ new Map,useCases:/* @__PURE__ */ new Map,systemBoundaries:/* @__PURE__ */ new Map,relationships:[],notes:/* @__PURE__ */ new Map,jsonNodes:/* @__PURE__ */ new Map,classDefs:/* @__PURE__ */ new Map,symbols:/* @__PURE__ */ new Map,direction:pi,relationshipCounter:0,noteCounter:0,accTitle:``,accDescription:``,ast:void 0,config:structuredClone(mi)}),`createModel`),gi=/* @__PURE__ */ y(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||![`TB`,`TD`,`BT`,`RL`,`LR`].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||typeof e.accTitle!=`string`||typeof e.accDescription!=`string`||!e.config)throw Error(`Cannot commit an incomplete usecase model`)},`assertCompleteModel`),U=hi(),_i=/* @__PURE__ */ y(()=>structuredClone(U.config),`getConfig`),vi=/* @__PURE__ */ y(()=>U.ast,`getAST`),yi=/* @__PURE__ */ y(e=>{let t=structuredClone(e);gi(t);let n=ee(),r=p();try{f(t.accTitle),d(t.accDescription),U=t}catch(e){throw f(n),d(r),e}},`commit`),bi=/* @__PURE__ */ y(()=>{U=hi(),m()},`clear`),xi=/* @__PURE__ */ y(()=>U.actors,`getActors`),Si=/* @__PURE__ */ y(e=>U.actors.get(e),`getActor`),Ci=/* @__PURE__ */ y(()=>U.useCases,`getUseCases`),wi=/* @__PURE__ */ y(e=>U.useCases.get(e),`getUseCase`),Ti=/* @__PURE__ */ y(()=>U.systemBoundaries,`getSystemBoundaries`),Ei=/* @__PURE__ */ y(e=>U.systemBoundaries.get(e),`getSystemBoundary`),Di=/* @__PURE__ */ y(()=>U.relationships,`getRelationships`),Oi=/* @__PURE__ */ y(()=>U.notes,`getNotes`),ki=/* @__PURE__ */ y(e=>U.notes.get(e),`getNote`),Ai=/* @__PURE__ */ y(()=>U.jsonNodes,`getJsonNodes`),ji=/* @__PURE__ */ y(e=>U.jsonNodes.get(e),`getJsonNode`),Mi=/* @__PURE__ */ y(()=>U.classDefs,`getClassDefs`),Ni=/* @__PURE__ */ y(e=>U.classDefs.get(e),`getClassDef`),Pi=/* @__PURE__ */ y(()=>U.direction,`getDirection`),Fi=/* @__PURE__ */ y(e=>{let t=/* @__PURE__ */ new Map;for(let n of[`default`,...e]){let e=U.classDefs.get(n);if(e)for(let n of e.styles){let e=n.trim(),r=e.indexOf(`:`),i=(r===-1?e:e.slice(0,r)).trim();i&&t.set(i,e)}}return[...t.values()]},`getCompiledStyles`),Ii=/* @__PURE__ */ y(e=>e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`),`escapeJsonPointerPart`),Li=/* @__PURE__ */ y(e=>typeof e==`string`?e:e===null?`null`:String(e),`displayJsonScalar`),Ri=/* @__PURE__ */ y((e,t,n=e=>e)=>{let r=[],i=/* @__PURE__ */ y((e,t,i)=>{r.push({key:n(e),accessibleKey:n(t),value:n(i)})},`append`),a=/* @__PURE__ */ y((e,n,r)=>{if(Array.isArray(e)){if(e.length===0){i(n,n,`[]`);return}if(e.every(e=>e===null||[`string`,`number`,`boolean`].includes(typeof e))){for(let[t,r]of e.entries())i(t===0?n:``,n,Li(r));return}for(let[t,i]of e.entries())a(i,`${n}[${t}]`,`${r}/${t}`)}else if(typeof e==`object`&&e){let o=e,s=t[r]??Object.keys(o);if(s.length===0){i(n,n,`{}`);return}for(let e of s){let t=n?`${n}.${e}`:e;a(o[e],t,`${r}/${Ii(e)}`)}}else i(n,n,Li(e))},`visit`);return a(e,``,``),r},`flattenJsonRows`),zi=/* @__PURE__ */ y(e=>{switch(e.type){case`hollow`:return`usecaseActorHollow`;case`awesome`:return`usecaseActorAwesome`;case`icon`:return`usecaseActorIcon`;case`normal`:return`usecaseActor`}},`actorShape`),Bi=/* @__PURE__ */ y(e=>e.shape===`ellipse`?e.business?`usecaseBusiness`:`usecaseEllipse`:e.shape,`useCaseShape`),Vi=/* @__PURE__ */ y(e=>{switch(e){case H.SOLID_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_point`};case H.BACK_ARROW:return{arrowTypeStart:`arrow_point`,arrowTypeEnd:`none`};case H.CIRCLE_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_circle`};case H.CROSS_ARROW:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_cross`};case H.CIRCLE_ARROW_REVERSED:return{arrowTypeStart:`arrow_circle`,arrowTypeEnd:`none`};case H.CROSS_ARROW_REVERSED:return{arrowTypeStart:`arrow_cross`,arrowTypeEnd:`none`};case H.LINE_SOLID:return{arrowTypeStart:`none`,arrowTypeEnd:`none`}}},`associationMarkers`),Hi=/* @__PURE__ */ y(e=>{switch(e.type){case`include`:case`extend`:return{arrowTypeStart:`none`,arrowTypeEnd:`arrow_point`,pattern:`dotted`,label:`\xAB${e.type}\xBB`,labelType:`text`};case`generalization`:return{arrowTypeStart:`none`,arrowTypeEnd:`extension`,pattern:`solid`};case`association`:return{...Vi(e.arrowType),pattern:`solid`,...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},`relationshipVisuals`),Ui=/* @__PURE__ */ y(e=>e.animate||e.animation?[`edge-animation-${e.animation??`fast`}`]:[],`animationClasses`),Wi=/* @__PURE__ */ y((...e)=>e.filter(e=>!!e).join(` `),`classNames`),Gi={getConfig:_i,createModel:hi,commit:yi,getAST:vi,clear:bi,setDiagramTitle:_,getDiagramTitle:u,setAccTitle:f,getAccTitle:ee,setAccDescription:d,getAccDescription:p,getActors:xi,getActor:Si,getUseCases:Ci,getUseCase:wi,getSystemBoundaries:Ti,getSystemBoundary:Ei,getRelationships:Di,getNotes:Oi,getNote:ki,getJsonNodes:Ai,getJsonNode:ji,getClassDefs:Mi,getClassDef:Ni,getDirection:Pi,getData:/* @__PURE__ */ y(()=>{let e=h(),t={...U.config,...e.usecase},n=/* @__PURE__ */ y(t=>te(t,e),`sanitize`),r=/* @__PURE__ */ y(e=>n(U.actors.get(e)?.label??U.useCases.get(e)?.label??U.jsonNodes.get(e)?.id??U.notes.get(e)?.label??e),`endpointLabel`),i=[],a=[],o=0,s=0;for(let t of U.actors.values())i.push({id:t.id,label:n(t.label),labelType:t.labelType,shape:zi(t),isGroup:!1,padding:10,look:e.look,colorIndex:o++,cssClasses:Wi(`default`,`usecase-actor`,`usecase-actor-${t.type}`,t.business&&`usecase-business`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Fi(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:n(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of U.useCases.values())i.push({id:t.id,label:n(t.label),labelType:t.labelType,shape:Bi(t),isGroup:!1,padding:t.shape===`ellipse`?20:10,look:e.look,colorIndex:o++,cssClasses:Wi(`default`,`usecase-element`,`usecase-${t.shape}`,t.business&&`usecase-business`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Fi(t.classes),business:t.business,...t.stereotype?{stereotype:n(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of U.notes.values())i.push({id:t.id,label:n(t.label),labelType:t.labelType,shape:`note`,isGroup:!1,padding:10,look:e.look,cssClasses:`default usecase-note`,cssStyles:[],cssCompiledStyles:Fi([]),noteTarget:t.target,noteTargetLabel:n(U.actors.get(t.target)?.label??U.useCases.get(t.target)?.label??U.jsonNodes.get(t.target)?.id??t.target)});for(let t of U.jsonNodes.values())i.push({id:t.id,label:n(t.id),labelType:`text`,shape:`usecaseJsonTable`,isGroup:!1,padding:10,look:e.look,cssClasses:Wi(`default`,`usecase-json-table`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Fi(t.classes),jsonRows:Ri(t.value,t.propertyOrder,n)});for(let t of U.systemBoundaries.values())i.push({id:t.id,label:n(t.label),labelType:t.labelType,shape:`usecaseSystemBoundary`,isGroup:!0,padding:20,look:e.look,colorIndex:s++,cssClasses:Wi(`default`,`system-boundary`,`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:Fi(t.classes),boundaryType:t.type});for(let t of U.relationships){let{label:i,...o}=Hi(t);a.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:r(t.source),targetLabel:r(t.target),type:`edge`,relationshipType:t.type,internal:!1,...o,...i===void 0?{}:{label:n(i)},labelpos:`c`,classes:Wi(`default`,`relationship`,`relationship-${t.type}`,...t.classes,...Ui(t)),style:[...t.styles],cssCompiledStyles:Fi(t.classes),animate:t.animate,...t.animation?{animation:t.animation}:{},look:e.look,thickness:`normal`,minlen:t.minlen,isUserDefinedId:t.explicitId})}for(let t of U.notes.values())a.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:`edge`,relationshipType:`note`,sourceLabel:r(t.id),targetLabel:r(t.target),internal:!0,pattern:`dotted`,arrowTypeStart:`none`,arrowTypeEnd:`none`,labelpos:`c`,classes:`default relationship relationship-note`,style:[],cssCompiledStyles:Fi([]),animate:!1,look:e.look,thickness:`normal`,minlen:1,isUserDefinedId:!1});for(let e of i)e.wrappingWidth??=t.wrappingWidth,!e.isGroup&&!e.shape.startsWith(`usecaseActor`)&&(e.minWidth??=t.minNodeWidth),(e.shape===`usecaseEllipse`||e.shape===`usecaseBusiness`)&&(e.spreadPorts=!0);return{nodes:i,edges:a,config:e,type:`usecase`,layoutAlgorithm:`dagre`,direction:Pi(),nodeSpacing:t.nodeSpacing,rankSpacing:t.rankSpacing,actorFontSize:t.actorFontSize,actorFontFamily:t.actorFontFamily,actorFontWeight:t.actorFontWeight,usecaseFontSize:t.usecaseFontSize,usecaseFontFamily:t.usecaseFontFamily,usecaseFontWeight:t.usecaseFontWeight,diagramPadding:t.diagramPadding,useMaxWidth:t.useMaxWidth,markers:[`point`,`circle`,`cross`,`extension`]}},`getData`)};function Ki(e,t,n){let r=[n];return r.index=t,r.input=e,r}y(Ki,`customMatch`);var qi=/* @__PURE__ */ y((e,t)=>{if(e[t]!==`"`||e[t+1]!=="`")return null;for(let n=t+2;n<e.length-1;n++)if(e[n]==="`"&&e[n+1]===`"`)return Ki(e,t,e.slice(t,n+2));return null},`matchMarkdownString`),Ji=/* @__PURE__ */ y((e,t)=>{if(e[t]!==`%`||e[t+1]!==`%`)return null;for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
217
+ `||t===`\r`)break;if(t!==` `&&t!==` `)return null}let n=t+2;for(;n<e.length&&e[n]!==`
218
+ `&&e[n]!==`\r`;)n++;return Ki(e,t,e.slice(t,n))},`matchComment`),Yi=/* @__PURE__ */ y((e,t)=>{for(let n=t-1;n>=0;n--){let t=e[n];if(t===`
219
+ `||t===`\r`)return!0;if(t!==` `&&t!==` `)return!1}return!0},`isIndentedLineStart`),Xi=/* @__PURE__ */ y((e,t,n)=>{if(!Yi(e,t))return null;let r=n.exec(e.slice(t));return r?Ki(e,t,r[0]):null},`matchAccessibilityLine`),Zi=/* @__PURE__ */ y((e,t)=>{if(!Yi(e,t))return null;let n=/^accDescr[\t ]*{/.exec(e.slice(t));if(!n)return null;let r=e.indexOf(`}`,t+n[0].length);return r===-1?null:Ki(e,t,e.slice(t,r+1))},`matchAccDescrBlock`),Qi=/* @__PURE__ */ y((e,t)=>{if(e[t]!==`{`)return null;let n=0,r=!1,i=!1;for(let a=t;a<e.length;a++){let o=e[a];if(r)i?i=!1:o===`\\`?i=!0:o===`"`&&(r=!1);else if(o===`"`)r=!0;else if(o===`{`)n++;else if(o===`}`&&--n===0)return Ki(e,t,e.slice(t,a+1))}return null},`matchJsonObject`),$i=/* @__PURE__ */ y((e,t)=>{let n=e.indexOf(`>>`,t);if(n===-1||/[\n\r]/.test(e.slice(t,n)))return null;let r=e.slice(t,n);return r.trim()?Ki(e,t,r):null},`matchStereotypeText`),W=L({name:`LABEL_TEXT`,pattern:I.NA}),ea=L({name:`WORD`,pattern:I.NA,categories:W}),ta=L({name:`NUMBER`,pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:W}),G=L({name:`IDENTIFIER`,pattern:/\w+/,longer_alt:ta,categories:ea}),na=L({name:`HWS`,pattern:/[\t ]+/,group:I.SKIPPED}),K=L({name:`MARKDOWN_STRING`,pattern:qi,start_chars_hint:[`"`],line_breaks:!0}),ra=L({name:`UNCLOSED_MARKDOWN_STRING`,pattern:/"`[^]*/,line_breaks:!0}),ia=L({name:`COMMENT`,pattern:Ji,start_chars_hint:[`%`],line_breaks:!1}),q=L({name:`NEWLINE`,pattern:/\r\n|\n|\r/,line_breaks:!0}),aa=L({name:`ACC_DESCR_BLOCK`,pattern:Zi,start_chars_hint:[`a`],line_breaks:!0}),oa=/^accTitle[\t ]*:[^\n\r]*/,sa=/^accDescr[\t ]*:[^\n\r]*/,ca=L({name:`ACC_TITLE_LINE`,pattern:/* @__PURE__ */ y((e,t)=>Xi(e,t,oa),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),la=L({name:`ACC_DESCR_LINE`,pattern:/* @__PURE__ */ y((e,t)=>Xi(e,t,sa),`pattern`),start_chars_hint:[`a`],line_breaks:!1}),ua=L({name:`JSON_DECLARATION_START`,pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:`jsonBody`}),da=L({name:`JSON_OBJECT_LITERAL`,pattern:Qi,start_chars_hint:[`{`],line_breaks:!0,pop_mode:!0}),fa=L({name:`UNCLOSED_JSON_OBJECT_LITERAL`,pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),J=/* @__PURE__ */ y((e,t)=>L({name:e,pattern:t,longer_alt:G,categories:ea}),`keyword`),pa=J(`USECASE`,/usecase-beta/),ma=J(`ACTOR`,/actor/),ha=J(`SYSTEM_BOUNDARY`,/systemBoundary/),ga=J(`END`,/end/),_a=J(`DIRECTION`,/direction/),va=J(`TD`,/TD/),ya=J(`TB`,/TB/),ba=J(`BT`,/BT/),xa=J(`LR`,/LR/),Sa=J(`RL`,/RL/),Ca=J(`NOTE`,/note/),wa=J(`FOR`,/for/),Ta=J(`JSON`,/json/),Ea=J(`CLASS_DEF`,/classDef/),Da=J(`CLASS`,/class/),Oa=J(`STYLE`,/style/),ka=J(`INCLUDE`,/include/i),Aa=J(`EXTEND`,/extend/i),ja=J(`TRUE`,/true/),Ma=J(`FALSE`,/false/),Na=L({name:`GENERALIZATION`,pattern:/--\|>/}),Pa=L({name:`DEPENDENCY_ARROW`,pattern:/\.\.>/}),Fa=L({name:`STEREOTYPE_START`,pattern:/<</,push_mode:`stereotype`}),Ia=L({name:`STEREOTYPE_END`,pattern:/>>/,pop_mode:!0}),La=L({name:`STEREOTYPE_TEXT`,pattern:$i,line_breaks:!1}),Ra=L({name:`UNCLOSED_STEREOTYPE_TEXT`,pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),za=L({name:`CLASS_SEPARATOR`,pattern:/:::/}),Ba=L({name:`FORWARD_SOLID`,pattern:/--+>/}),Va=L({name:`BACKWARD_SOLID`,pattern:/<--+/}),Ha=L({name:`FORWARD_CIRCLE`,pattern:/--o/}),Ua=L({name:`BACKWARD_CIRCLE`,pattern:/o--/}),Wa=L({name:`FORWARD_CROSS`,pattern:/--x/}),Ga=L({name:`BACKWARD_CROSS`,pattern:/x--/}),Y=L({name:`MARKERLESS_SOLID`,pattern:/--+/}),Ka=L({name:`METADATA_START`,pattern:/@{/}),qa=L({name:`AT`,pattern:/@/,categories:W}),Ja=L({name:`LBRACE`,pattern:/{/}),Ya=L({name:`RBRACE`,pattern:/}/}),Xa=L({name:`LBRACKET`,pattern:/\[/}),Za=L({name:`RBRACKET`,pattern:/]/}),Qa=L({name:`LPAREN`,pattern:/\(/}),$a=L({name:`RPAREN`,pattern:/\)/}),X=L({name:`COMMA`,pattern:/,/,categories:W}),eo=L({name:`COLON`,pattern:/:/,categories:W}),to=L({name:`HASH_COLOR`,pattern:/#[\dA-Fa-f]+/,categories:W}),Z=L({name:`PLAIN_STRING`,pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),no=L({name:`CSS_IDENTIFIER`,pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:W}),ro=L({name:`CSS_ESCAPED_COMMA`,pattern:/\\,/,categories:W}),io=L({name:`DASH`,pattern:/-/,categories:W}),ao=L({name:`DOT`,pattern:/\./,categories:W}),oo=L({name:`PERCENT`,pattern:/%/,categories:W}),so=L({name:`CSS_PUNCTUATION`,pattern:/[!#$&*+/=?^_|~]/,categories:W}),co=[W,ea,na,K,ra,ia,q,aa,ca,la,ua,pa,ma,ha,ga,_a,va,ya,ba,xa,Sa,Ca,wa,Ta,Ea,Da,Oa,ka,Aa,ja,Ma,Na,Pa,Fa,za,Ba,Va,Ha,Ua,Wa,Ga,Y,Ka,qa,Ja,Ya,Xa,Za,Qa,$a,X,eo,to,Z,no,G,ta,ro,io,ao,oo,so,L({name:`LABEL_PUNCTUATION`,pattern:/[;<>\\`]/,categories:W}),L({name:`LABEL_SYMBOL`,pattern:/[^\t\n\r !-~]+/,categories:W})],lo={defaultMode:`defaultMode`,modes:{defaultMode:[...co],jsonBody:[da,fa],stereotype:[Ia,La,Ra]}},uo=[...co,da,fa,Ia,La,Ra],fo=new I(lo),po=/* @__PURE__ */ y(e=>ln(e,W)||e.tokenType===Z||e.tokenType===K,`isLabelToken`),mo={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},ho=new class extends ui{static{y(this,`UsecaseParser`)}constructor(){super(uo,{nodeLocationTracking:`full`}),this.RULE(`start`,()=>{this.CONSUME(pa),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE(`line`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.commentLine),`ALT`)},{GATE:/* @__PURE__ */ y(()=>this.isStatementStart(),`GATE`),ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.statement),`ALT`)}])}),this.RULE(`statement`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.accTitleStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.accDescrStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.directionStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.actorStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.systemBoundaryStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.noteStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.jsonStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.classDefStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.classStatement),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.styleStatement),`ALT`)},{GATE:/* @__PURE__ */ y(()=>this.isMetadataAssignment(),`GATE`),ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.metadataAssignmentStatement),`ALT`)},{GATE:/* @__PURE__ */ y(()=>!this.isForbiddenPlantUmlStatement(),`GATE`),ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.entityStatement),`ALT`)}])}),this.RULE(`lineEnd`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(q),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(R),`ALT`)}])}),this.RULE(`blankLine`,()=>{this.CONSUME(q)}),this.RULE(`commentLine`,()=>{this.CONSUME(ia),this.SUBRULE(this.lineEnd)}),this.RULE(`accTitleStatement`,()=>{this.CONSUME(ca),this.SUBRULE(this.lineEnd)}),this.RULE(`accDescrStatement`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(la),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(aa),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`actorStatement`,()=>{this.CONSUME(ma),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(X),this.SUBRULE2(this.actorItem)}),`ALT`)},{ALT:/* @__PURE__ */ y(()=>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:/* @__PURE__ */ y(()=>{this.CONSUME(G),this.OPTION(()=>{this.CONSUME(Qa),this.SUBRULE(this.nodeLabel),this.CONSUME($a)})},`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`ALT`)}])}),this.RULE(`actorDeclarationOnly`,()=>{this.CONSUME(ma),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(X),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:/* @__PURE__ */ y(()=>{this.CONSUME(G),this.OPTION(()=>{this.OR2([{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Qa),this.SUBRULE(this.nodeLabel),this.CONSUME($a)},`ALT`)},{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Xa),this.SUBRULE2(this.nodeLabel),this.CONSUME(Za)},`ALT`)}])})},`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`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:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.AT_LEAST_ONE(()=>this.CONSUME(W)),`ALT`)}])}),this.RULE(`useCaseMetadata`,()=>{this.SUBRULE(this.metadata)}),this.RULE(`relationTail`,()=>{this.OPTION({GATE:/* @__PURE__ */ y(()=>this.LA(1).tokenType===G&&this.LA(2).tokenType===qa,`GATE`),DEF:/* @__PURE__ */ y(()=>{this.CONSUME(G),this.CONSUME(qa)},`DEF`)}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE(`arrow`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.semanticRelation),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.forwardSolidOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.backwardSolidOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.markerlessSolidOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.forwardCircleOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.backwardCircleOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.forwardCrossOperator),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.backwardCrossOperator),`ALT`)}])}),this.RULE(`forwardSolidOperator`,()=>{this.CONSUME(Ba)}),this.RULE(`backwardSolidOperator`,()=>{this.CONSUME(Va),this.OPTION({GATE:/* @__PURE__ */ y(()=>this.LA(0).image===`<--`&&this.hasLabeledRight([Y]),`GATE`),DEF:/* @__PURE__ */ y(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Y)},`DEF`)})}),this.RULE(`markerlessSolidOperator`,()=>{this.CONSUME(Y),this.OPTION({GATE:/* @__PURE__ */ y(()=>this.LA(0).image===`--`&&this.hasLabeledRight([Ba,Y,Ha,Wa]),`GATE`),DEF:/* @__PURE__ */ y(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Ba),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME2(Y),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Ha),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Wa),`ALT`)}])},`DEF`)})}),this.RULE(`forwardCircleOperator`,()=>{this.CONSUME(Ha)}),this.RULE(`backwardCircleOperator`,()=>{this.CONSUME(Ua),this.OPTION({GATE:/* @__PURE__ */ y(()=>this.hasLabeledRight([Y]),`GATE`),DEF:/* @__PURE__ */ y(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Y)},`DEF`)})}),this.RULE(`forwardCrossOperator`,()=>{this.CONSUME(Wa)}),this.RULE(`backwardCrossOperator`,()=>{this.CONSUME(Ga),this.OPTION({GATE:/* @__PURE__ */ y(()=>this.hasLabeledRight([Y]),`GATE`),DEF:/* @__PURE__ */ y(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(Y)},`DEF`)})}),this.RULE(`edgeLabel`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.AT_LEAST_ONE(()=>this.CONSUME(W)),`ALT`)}])}),this.RULE(`semanticRelation`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Pa),this.CONSUME(eo),this.OR2([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ka),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Aa),`ALT`)}])},`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Na),`ALT`)}])}),this.RULE(`metadata`,()=>{this.CONSUME(Ka),this.MANY(()=>this.CONSUME(q)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(X)),this.MANY3(()=>this.CONSUME2(q))}),this.CONSUME(Ya)}),this.RULE(`metadataProperty`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(G),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)}]),this.CONSUME(eo),this.OR2([{ALT:/* @__PURE__ */ y(()=>this.CONSUME2(G),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME2(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ja),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Ma),`ALT`)}])}),this.RULE(`metadataSeparator`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(X),this.MANY(()=>this.CONSUME(q))},`ALT`)},{ALT:/* @__PURE__ */ y(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(q)),this.OPTION(()=>this.CONSUME2(X)),this.MANY2(()=>this.CONSUME3(q))},`ALT`)}])}),this.RULE(`systemBoundaryStatement`,()=>{this.CONSUME(ha),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(ga),this.SUBRULE2(this.lineEnd)}),this.RULE(`systemBoundaryName`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(G),this.OPTION(()=>{this.OR2([{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Qa),this.SUBRULE(this.nodeLabel),this.CONSUME($a)},`ALT`)},{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Xa),this.SUBRULE2(this.nodeLabel),this.CONSUME(Za)},`ALT`)}])})},`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`ALT`)}])}),this.RULE(`systemBoundaryContent`,()=>{this.MANY(()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.blankLine),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.commentLine),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.boundaryElement),`ALT`)}])})}),this.RULE(`boundaryElement`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.SUBRULE(this.actorDeclarationOnly),`ALT`)},{ALT:/* @__PURE__ */ y(()=>{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:/* @__PURE__ */ y(()=>this.CONSUME(G),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(K),`ALT`)}])}),this.RULE(`noteStatement`,()=>{this.CONSUME(Ca),this.CONSUME(wa),this.CONSUME(G),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE(`stereotype`,()=>{this.CONSUME(Fa),this.CONSUME(La),this.CONSUME(Ia)}),this.RULE(`classSuffix`,()=>{this.CONSUME(za),this.CONSUME(G),this.MANY(()=>{this.CONSUME(X),this.CONSUME2(G)})}),this.RULE(`jsonStatement`,()=>{this.CONSUME(ua),this.CONSUME(da),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE(`directionStatement`,()=>{this.CONSUME(_a),this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(va),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ya),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ba),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(xa),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Sa),`ALT`)}]),this.SUBRULE(this.lineEnd)}),this.RULE(`classDefStatement`,()=>{this.CONSUME(Ea),this.CONSUME(G),this.MANY(()=>{this.CONSUME(X),this.CONSUME2(G)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`classStatement`,()=>{this.CONSUME(Da),this.CONSUME(G),this.MANY(()=>{this.CONSUME(X),this.CONSUME2(G)}),this.CONSUME3(G),this.MANY2(()=>{this.CONSUME2(X),this.CONSUME4(G)}),this.SUBRULE(this.lineEnd)}),this.RULE(`styleStatement`,()=>{this.CONSUME(Oa),this.CONSUME(G),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE(`styles`,()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(X),this.SUBRULE2(this.styleValue)})}),this.RULE(`styleValue`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ea),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(no),`ALT`)},{ALT:/* @__PURE__ */ y(()=>{this.CONSUME(Y),this.CONSUME2(ea)},`ALT`)}]),this.CONSUME(eo),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE(`styleComponent`,()=>{this.OR([{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ea),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Z),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ta),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(to),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(no),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ro),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(io),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(ao),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(oo),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(so),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(eo),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Qa),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME($a),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Xa),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Za),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Ja),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Ya),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(qa),`ALT`)},{ALT:/* @__PURE__ */ y(()=>this.CONSUME(Y),`ALT`)}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===G||e===Z||e===K)&&this.LA(2).tokenType===Ka}isStatementStart(){let e=this.LA(1).tokenType;return e!==R&&e!==q&&e!==ia}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===G&&mo[this.LA(1).image.toLowerCase()]===!0}hasLabeledRight(e){if(!po(this.LA(1)))return!1;for(let t=2;;t++){let n=this.LA(t);if(e.includes(n.tokenType))return!0;if(!po(n))return!1}}},go=class extends Error{constructor(e,t,n){super(`${e} (line ${t}, column ${n})`),this.line=t,this.column=n,this.name=`UsecaseJsonError`}static{y(this,`UsecaseJsonError`)}},_o=/* @__PURE__ */ y((e,t,n,r)=>{let i=n,a=r,o=Math.min(Math.max(t,0),e.length);for(let t=0;t<o;t++){let n=e[t];n===`\r`?(i++,a=1):n===`
220
+ `?(t===0||e[t-1]!==`\r`)&&(i++,a=1):a++}return{line:i,column:a}},`locationAtOffset`),vo=/* @__PURE__ */ y((e,t,n,r)=>{let i=/\bposition (\d+)\b/u.exec(e);if(i)return _o(t,Number.parseInt(i[1],10),n,r);let a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){let e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:n+e-1,column:e===1?r+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return _o(t,t.length,n,r)},`locationFromErrorMessage`),Q=class extends Error{constructor(e){super(`Invalid JSON token`),this.offset=e}static{y(this,`JsonWalkError`)}},yo=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{y(this,`PropertyOrderCollector`)}collect(){if(this.skipWhitespace(),this.collectValue(``),this.skipWhitespace(),this.offset!==this.text.length)throw new Q(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if(t===`{`)this.collectObject(e);else if(t===`[`)this.collectArray(e);else if(t===`"`)this.readString(!1);else if(t===`t`)this.consumeLiteral(`true`);else if(t===`f`)this.consumeLiteral(`false`);else if(t===`n`)this.consumeLiteral(`null`);else if(t===`-`||t>=`0`&&t<=`9`)this.consumeNumber();else throw new Q(this.offset)}collectObject(e){this.offset++;let t=[],n=/* @__PURE__ */ new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),this.text[this.offset]===`}`)this.offset++;else{for(;this.offset<this.text.length;){if(this.text[this.offset]!==`"`)throw new Q(this.offset);let r=this.readString(!0),i=`${e}/${r.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`;if(n.has(r)?this.deletePointerSubtree(i):(n.add(r),t.push(r)),this.skipWhitespace(),this.text[this.offset]!==`:`)throw new Q(this.offset);if(this.offset++,this.collectValue(i),this.skipWhitespace(),this.text[this.offset]===`}`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}}collectArray(e){if(this.offset++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),this.text[this.offset]===`]`){this.offset++;return}if(this.text[this.offset]!==`,`)throw new Q(this.offset);this.offset++,this.skipWhitespace()}throw new Q(this.offset)}readString(e){this.offset++;let t=``;for(;this.offset<this.text.length;){let n=this.offset,r=this.text[this.offset++];if(r===`"`)return t;if(r.charCodeAt(0)<32)throw new Q(n);if(r!==`\\`){e&&(t+=r);continue}let i=this.offset,a=this.text[this.offset++];switch(a){case`"`:case`\\`:case`/`:e&&(t+=a);break;case`b`:e&&(t+=`\b`);break;case`f`:e&&(t+=`\f`);break;case`n`:e&&(t+=`
221
+ `);break;case`r`:e&&(t+=`\r`);break;case`t`:e&&(t+=` `);break;case`u`:{let n=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(n))throw new Q(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(n,16))),this.offset+=4;break}default:throw new Q(i)}}throw new Q(this.offset)}consumeLiteral(e){let t=0;for(let n of e){if(this.text[this.offset+t]!==n)throw new Q(this.offset+t);t++}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 Q(this.offset);if(this.text[this.offset]===`.`){if(this.offset++,this.text[this.offset]<`0`||this.text[this.offset]>`9`)throw new Q(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 Q(this.offset);for(;this.text[this.offset]>=`0`&&this.text[this.offset]<=`9`;)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(e!==` `&&e!==` `&&e!==`
222
+ `&&e!==`\r`)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let n of Object.keys(this.propertyOrder))(n===e||n.startsWith(t))&&delete this.propertyOrder[n]}};function bo(e,t,n){let r;try{r=JSON.parse(e)}catch(r){let i=r instanceof Error?r.message:String(r),a=vo(i,e,t,n);if(!a){let r=0;try{new yo(e).collect()}catch(e){e instanceof Q&&(r=e.offset)}a=_o(e,r,t,n)}throw new go(`Invalid JSON: ${i}`,a.line,a.column)}if(typeof r!=`object`||!r||Array.isArray(r))throw new go(`JSON value must have an object root`,t,n);return{value:r,propertyOrder:new yo(e).collect()}}y(bo,`parseOrderedJsonObject`);var xo=/* @__PURE__ */ y(e=>({shape:e.type===`normal`?`actor`:e.type===`hollow`?`actor-hollow`:e.type===`awesome`?`actor-awesome`:`actor-icon`,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`actor`,actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),`actorNode`),So=/* @__PURE__ */ y(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`usecase`,useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),`useCaseNode`),Co=/* @__PURE__ */ y(e=>({label:e.label,shape:`note`,attrs:{kind:`note`,target:e.target,labelType:e.labelType}}),`noteNode`),wo=/* @__PURE__ */ y(e=>({label:e.id,shape:`json-table`,...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:`json`,value:e.value,propertyOrder:e.propertyOrder,labelType:`text`}}),`jsonNode`),To=/* @__PURE__ */ y(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),`relationshipEdge`),Eo=/* @__PURE__ */ y(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:`note`,arrowType:H.LINE_SOLID,pattern:`dotted`,minlen:1,explicitId:!1,animate:!1,internal:!0}}),`noteEdge`),Do=/* @__PURE__ */ y((e,t,n,r)=>{let i={};for(let t of e.getActors().values())i[t.id]=xo(t);for(let t of e.getUseCases().values())i[t.id]=So(t);for(let t of e.getNotes().values())i[t.id]=Co(t);for(let t of e.getJsonNodes().values())i[t.id]=wo(t);let a={};for(let t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:`systemBoundary`,boundaryType:t.type,labelType:t.labelType}};let o={};for(let t of e.getClassDefs().values())o[t.id]={styles:[...t.styles]};let s=e.getDirection();return{version:1,diagramType:`usecase`,source:t,header:{keyword:`usecase`,direction:s===`TD`?`TB`:s,span:n},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:i,edges:[...e.getRelationships().map(To),...[...e.getNotes().values()].map(Eo)],groups:a,classDefs:o,statements:r}},`buildUsecaseGraphAST`),$=/* @__PURE__ */ y(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,`locationText`),Oo=/* @__PURE__ */ y(e=>e===void 0?``:` (label "${e}")`,`labelSuffix`),ko=/* @__PURE__ */ y(e=>e.generated?e.label:void 0,`generatedFrom`),Ao=/* @__PURE__ */ y((e,t)=>{for(let n of t)e.includes(n)||e.push(n)},`pushUnique`),jo=class{constructor(e){this.db=e,this.source=``,this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{y(this,`UsecaseModelBuilder`)}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,n,r){this.metadataAssignments.push({target:e,targetLocation:t,metadata:n,statement:r})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,n){this.styleAssignments.push({target:e,location:t,styles:n})}setDirection(e){this.directions.push(e===`TD`?`TB`:e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let e of this.relationshipDrafts)this.recordFirst(i,e.source.id,e.source.location.span[0]),this.recordFirst(i,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(i,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(i,e.id,e.location.span[0]);let a=[...this.elements.map(e=>({offset:e.location.span[0],type:`element`,value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:`boundary`,value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:`json`,value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:`edge`,value:e}))].sort((e,t)=>e.offset-t.offset);for(let e of a)e.type===`element`?this.collectElement(e.value,t,n):e.type===`boundary`?this.collectBoundary(e.value,t,r):e.type===`json`?this.registerUnique(t,e.value.id,`json`,e.value.location,!1):this.registerUnique(t,e.value.explicitId,`edge`,e.value.explicitIdLocation,!1);this.materializeElements(n,i),this.materializeBoundaries(r,i),this.materializeJson(i);let o=this.materializeRelationships(t,n,i);this.reorderElements(n,i),this.applyMetadataAssignments(t,n,r,o),this.validateAndRefreshElements(n),this.refreshBoundaries(r,n),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,o),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let s=Do(this,this.source,e,this.statements);return this.model.ast=s,this.db.commit(this.model),s}collectElement(e,t,n){let r=t.get(e.id),i=ko({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,ko(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,ko(r));let a=n.get(e.id);if(a)(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,Ao(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata);else{let r={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(r,e.metadata),n.set(e.id,r),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text})}}collectBoundary(e,t,n){let r=t.get(e.id),i=ko({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,ko(r)),r&&(r.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,r.location,i,ko(r));let a=n.get(e.id);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),Ao(a.classes,e.classes)):(n.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:`boundary`,location:e.location,generated:e.generated,label:e.label.text}))}materializeElements(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.setElementModel(n)}materializeBoundaries(e,t){for(let n of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0)))this.model.systemBoundaries.set(n.id,{id:n.id,label:n.label.text,labelType:n.label.type,type:n.type??`rect`,members:[],classes:[...n.classes],styles:[...n.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,n)=>(e.get(t.id)??0)-(e.get(n.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,n){let r=/* @__PURE__ */ new Map,i=0;for(let a of this.relationshipDrafts){let o=this.resolveEndpoint(a.source,e,t,n),s=this.resolveEndpoint(a.target,e,t,n);this.validateRelationship(a,o,s,e);let c=a.explicitId??`edge-${i++}`,l={id:c,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(l),r.set(c,{draft:a,relationship:l})}return this.model.relationshipCounter=i,r}resolveEndpoint(e,t,n,r){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${$(e.location)}`);let i=t.get(e.id);return i?i.kind:(n.set(e.id,{kind:`usecase`,id:e.id,label:e.label,location:e.location,generated:e.generated,shape:`ellipse`,classes:[]}),t.set(e.id,{kind:`usecase`,location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(r,e.id,e.location.span[0]),`usecase`)}reorderElements(e,t){let n=new Map(this.model.actors),r=new Map(this.model.useCases);this.model.actors.clear(),this.model.useCases.clear();for(let i of[...e.values()].sort((e,n)=>(t.get(e.id)??0)-(t.get(n.id)??0))){!n.has(i.id)&&!r.has(i.id)&&this.setElementModel(i);let e=n.get(i.id)??this.model.actors.get(i.id),t=r.get(i.id)??this.model.useCases.get(i.id);e?this.model.actors.set(i.id,e):t&&this.model.useCases.set(i.id,t)}}applyMetadataAssignments(e,t,n,r){for(let i of this.metadataAssignments){let a=e.get(i.target);if(!a){let e=this.inferMetadataKind(i.metadata);throw Error(`Metadata target '${i.target}' is unresolved${e?` (metadata implies ${e})`:``} at ${$(i.targetLocation)}`)}if(a.kind===`actor`||a.kind===`usecase`)this.applyStandaloneElementMetadata(t.get(i.target),i.metadata);else if(a.kind===`boundary`){let e=n.get(i.target);for(let t of i.metadata.properties)(t.key!==`type`||t.value!==`rect`&&t.value!==`package`)&&this.invalidMetadata(i.target,a.kind,t),e.type=t.value}else if(a.kind===`edge`){let e=r.get(i.target);if(!e)throw Error(`Metadata target '${i.target}' is not an explicit edge at ${$(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(let t of i.metadata.properties)t.key===`animate`&&typeof t.value==`boolean`?e.relationship.animate=t.value:t.key===`animation`&&(t.value===`fast`||t.value===`slow`)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(i.target,a.kind,t)}else for(let e of i.metadata.properties)this.invalidMetadata(i.target,a.kind,e)}for(let{relationship:e}of r.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!0):n.key===`business`&&typeof n.value==`boolean`?e.business=n.value:this.invalidMetadata(e.id,e.kind,n)}applyDeclarationMetadata(e,t){if(t)for(let n of t.properties)e.kind===`actor`?this.applyActorProperty(e,n,!1):n.key===`business`&&typeof n.value==`boolean`?(e.business!==void 0&&e.business!==n.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,n.location,e.location),e.business=n.value):this.invalidMetadata(e.id,e.kind,n)}applyActorProperty(e,t,n){t.key===`type`&&(t.value===`normal`||t.value===`hollow`||t.value===`awesome`)?(!n&&e.actorType!==void 0&&e.actorType!==t.value&&this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):t.key===`icon`&&typeof t.value==`string`?(!n&&e.icon!==void 0&&e.icon!==t.value&&this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):t.key===`business`&&typeof t.value==`boolean`?(!n&&e.business!==void 0&&e.business!==t.value&&this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?`icon`:t.actorType??`normal`;if(t.kind===`actor`){if(t.icon&&t.actorType&&t.actorType!==`normal`)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${$(t.location)}`);if(t.business&&(e===`icon`||e===`awesome`))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${$(t.location)}`)}else if((t.shape??`ellipse`)===`rect`&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${$(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let n=e.get(t.parentId);if(!n)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${$(t.parentLocation??t.location)}`);n.members.includes(t.id)||n.members.push(t.id)}for(let n of t.values())if(n.parentId&&!e.has(n.parentId))throw Error(`Parent boundary '${n.parentId}' for '${n.id}' is unresolved at ${$(n.parentLocation??n.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??`rect`,e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let n of this.noteDrafts){let r=e.get(n.target);if(!r)throw Error(`Note target '${n.target}' is unresolved at ${$(n.targetLocation)}`);r.kind!==`actor`&&r.kind!==`usecase`&&this.conflict(`Note target '${n.target}' must be an actor or use case, not ${r.kind}`,n.targetLocation,r.location);let i=`note-${t++}`;this.model.notes.set(i,{id:i,target:n.target,label:n.label.text,labelType:n.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let n of this.classAssignments)for(let r of n.targets)Ao(this.getStylable(r.id,e,t,r.location).classes,n.classes);for(let n of this.styleAssignments)this.getStylable(n.target,e,t,n.location).styles.push(...n.styles)}getStylable(e,t,n,r){let i=t.get(e)?.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`?n.get(e)?.relationship:void 0;if(!a)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${$(r)}`);return a}validateRelationship(e,t,n,r){let i=/* @__PURE__ */ y(e=>e===`actor`||e===`usecase`||e===`json`,`allowed`);if(i(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,r.get(e.source.id).location),i(n)||this.conflict(`Relationship target '${e.target.id}' cannot be ${n}`,e.target.location,r.get(e.target.id).location),(e.type===`include`||e.type===`extend`)&&(t!==`usecase`||n!==`usecase`))throw Error(`${e.type} relationship requires use-case endpoints at ${$(e.location)}`);if(e.type===`generalization`&&(t!==`actor`&&t!==`usecase`||t!==n))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${$(e.location)}`);if(e.type===`association`&&(t===`json`||n===`json`)&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${$(e.location)}`)}setElementModel(e){if(e.kind===`actor`){let t=e.icon?`icon`:e.actorType??`normal`;this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??`ellipse`,business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=/* @__PURE__ */ new Set([`actor`,`usecase`,`boundary`,`edge`]);for(let n of e.properties)if(n.key===`icon`)t.clear(),t.add(`actor`);else if(n.key===`animate`||n.key===`animation`)t.clear(),t.add(`edge`);else if(n.key===`type`)t.clear(),n.value===`rect`||n.value===`package`?t.add(`boundary`):(n.value===`normal`||n.value===`hollow`||n.value===`awesome`)&&t.add(`actor`);else if(n.key===`business`)t.delete(`boundary`),t.delete(`edge`);else return;return t.size===1?[...t][0]:void 0}invalidMetadata(e,t,n){throw Error(`Metadata property '${n.key}' is invalid for ${t} '${e}' at ${$(n.location)}`)}registerUnique(e,t,n,r,i){let a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${n})`,r,a.location,void 0,ko(a)),e.set(t,{kind:n,location:r,generated:i})}recordFirst(e,t,n){let r=e.get(t);(r===void 0||n<r)&&e.set(t,n)}conflict(e,t,n,r,i){throw Error(`${e} at ${$(t)}${Oo(r)}; previous declaration at ${$(n)}${Oo(i)}`)}},Mo=ho.getBaseCstVisitorConstructor(),No=new class extends Mo{constructor(){super(),this.builder=new jo(Gi),this.source=``,this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{y(this,`UsecaseVisitor`)}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,`USECASE`)[0],n=[];for(let t of this.nodes(e,`line`))n.push(this.visit(t));this.builder.setStatements(n),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,`blankLine`,`commentLine`,`statement`);return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,`accTitleStatement`,`accDescrStatement`,`directionStatement`,`actorStatement`,`systemBoundaryStatement`,`noteStatement`,`jsonStatement`,`classDefStatement`,`classStatement`,`styleStatement`,`metadataAssignmentStatement`,`entityStatement`))}lineEnd(e){}blankLine(e){return{kind:`blank`,span:this.tokenSpan(this.tokens(e,`NEWLINE`)[0])}}commentLine(e){return{kind:`comment`,span:this.tokenSpan(this.tokens(e,`COMMENT`)[0])}}accTitleStatement(e){let t=this.tokens(e,`ACC_TITLE_LINE`)[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(`:`)+1).trim()),{kind:`accTitle`,span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,`ACC_DESCR_LINE`)[0],n=this.tokens(e,`ACC_DESCR_BLOCK`)[0],r=t?t.image.slice(t.image.indexOf(`:`)+1).trim():n.image.slice(n.image.indexOf(`{`)+1,n.image.lastIndexOf(`}`)).trim();return this.builder.setAccDescription(r),{kind:`accDescr`,span:[0,0]}}actorStatement(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e)),r=this.nodes(e,`relationTail`)[0],i=n.map((e,n)=>this.actorOccurrence(t[n],e,!0));for(let e of n)this.builder.addElement(this.actorDraft(e));if(!r)return{kind:`node`,span:[0,0],nodes:i};let a=this.visit(r);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));let o=this.relationshipDraft(n[0],a,this.nodeLocation(r));this.builder.addRelationship(o);let s=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:s,span:[0,0],...o.explicitIdLocation?{idSpan:o.explicitIdLocation.span}:{},...o.label?{labelSpan:o.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,`actorName`)[0]),n=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{...t,...n?{metadata:this.visit(n)}:{},...r?{stereotype:this.visit(r)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0],r=n?this.visit(n):this.tokenLabel(t);return{id:t.image,label:r,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,`actorItem`),n=t.map(e=>this.visit(e));for(let e of n)this.builder.addElement(this.actorDraft(e));return{kind:`node`,span:[0,0],nodes:n.map((e,n)=>this.actorOccurrence(t[n],e,!0))}}entityStatement(e){let t=this.nodes(e,`entityName`),n=this.visit(t[0]),r=this.nodes(e,`relationTail`)[0];if(!r)return n.explicitDeclaration=!0,n.shape??=`ellipse`,this.builder.addElement(this.entityDraft(n)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,!0)]};n.explicitDeclaration&&this.builder.addElement(this.entityDraft(n));let i=this.visit(r);i.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(i.target));let a={source:this.endpoint(n),target:this.endpoint(i.target),location:this.nodeLocation(r),...i.explicitId?{explicitId:i.explicitId,explicitIdLocation:i.explicitIdLocation}:{},...i.arrow};this.builder.addRelationship(a);let o=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:`edge`,span:[0,0],nodes:[this.entityOccurrence(t[0],n,n.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){let t=this.tokens(e,`IDENTIFIER`)[0],n=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],s=o?this.visit(o):{classes:[],spans:[]};if(t){let n=r?this.visit(r):this.tokenLabel(t),o=r?this.tokens(e,`LBRACKET`).length?`rect`:`ellipse`:void 0;return{id:t.image,label:n,location:this.tokenLocation(t),generated:!1,...o?{shape:o}:{},...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(o||i||a)}}let c=this.tokenLabel(n);return{id:this.generateId(c.text),label:c,location:this.tokenLocation(n),generated:!0,...i?{metadata:this.visit(i)}:{},...a?{stereotype:this.visit(a)}:{},classes:s.classes,classSpans:s.spans,explicitDeclaration:!!(i||a)}}nodeLabel(e){let t=this.allTokens(e);if(t.length===1&&(t[0].tokenType.name===`PLAIN_STRING`||t[0].tokenType.name===`MARKDOWN_STRING`))return this.tokenLabel(t[0]);let n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(n[0],n[1]),type:`text`,span:n}}useCaseMetadata(e){return this.visit(this.nodes(e,`metadata`)[0])}relationTail(e){let t=this.tokens(e,`IDENTIFIER`)[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,`arrow`)[0]),target:this.visit(this.nodes(e,`entityName`)[0])}}arrow(e){return this.visit(this.firstNode(e,`semanticRelation`,`forwardSolidOperator`,`backwardSolidOperator`,`markerlessSolidOperator`,`forwardCircleOperator`,`backwardCircleOperator`,`forwardCrossOperator`,`backwardCrossOperator`))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,`GENERALIZATION`).length)return{type:`generalization`,arrowType:H.SOLID_ARROW,minlen:1};let t=this.tokens(e,`INCLUDE`).length?`include`:`extend`,n=this.tokens(e,t===`include`?`INCLUDE`:`EXTEND`)[0];return{type:t,arrowType:H.SOLID_ARROW,label:{text:t,type:`text`,span:this.tokenSpan(n)},minlen:1}}metadata(e){return{properties:this.nodes(e,`metadataProperty`).map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`COLON`),n=t[0],r=t[1],i=r.tokenType.name===`TRUE`||r.tokenType.name!==`FALSE`&&this.decodePlain(r),a=[n.startOffset,(r.endOffset??r.startOffset)+1];return{key:this.decodePlain(n),value:i,span:a,keySpan:this.contentSpan(n),valueSpan:this.contentSpan(r),location:this.tokenLocation(n)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,`systemBoundaryName`)[0]),n=this.nodes(e,`classSuffix`)[0],r=n?this.visit(n):{classes:[],spans:[]};t.classes=r.classes,this.builder.addBoundary(t);let i=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let a=this.nodes(e,`systemBoundaryContent`)[0],o=a?this.visit(a):[];this.parentBoundary=i;let s=this.tokens(e,`END`)[0],c=this.nodes(e,`metadata`)[0],l=c?this.visit(c):void 0,u={kind:`group`,span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(s),classSpans:r.spans,...l?{metadata:l.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...o.length?{children:o}:{}};return l&&this.builder.addMetadataAssignment(t.id,t.location,l,u),u}systemBoundaryName(e){let t=this.tokens(e,`IDENTIFIER`)[0];if(t){let n=this.nodes(e,`nodeLabel`)[0];return{id:t.image,label:n?this.visit(n):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let n=this.tokens(e,`PLAIN_STRING`)[0]??this.tokens(e,`MARKDOWN_STRING`)[0],r=this.tokenLabel(n);return{id:this.generateId(r.text),label:r,location:this.tokenLocation(n),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,`blankLine`),...this.nodes(e,`commentLine`),...this.nodes(e,`boundaryElement`)].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,`actorDeclarationOnly`)[0];if(t)return this.visit(t);let n=this.nodes(e,`entityName`)[0],r=this.visit(n);return r.explicitDeclaration=!0,r.shape??=`ellipse`,this.builder.addElement(this.entityDraft(r)),{kind:`node`,span:[0,0],nodes:[this.entityOccurrence(n,r,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,`metadataAssignmentTarget`)[0]),n=this.visit(this.nodes(e,`metadata`)[0]),r={kind:`metadata`,span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:n.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))};return this.builder.addMetadataAssignment(t.id,t.location,n,r),r}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],n=this.tokenLabel(t);return{id:t.tokenType.name===`IDENTIFIER`?t.image:this.generateId(n.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`nodeLabel`)[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:n,location:this.ctxLocation(e)}),{kind:`note`,span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:n.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,`STEREOTYPE_TEXT`)[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,`IDENTIFIER`);return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,`JSON_DECLARATION_START`)[0],n=this.tokens(e,`JSON_OBJECT_LITERAL`)[0],r=/^json[\t ]+(\w+)/.exec(t.image),i=r[1],a=r[0].length-i.length,o={span:[t.startOffset+a,t.startOffset+a+i.length],line:t.startLine??1,column:(t.startColumn??1)+a},s=bo(n.image,n.startLine??1,n.startColumn??1),c=this.nodes(e,`classSuffix`)[0],l=c?this.visit(c):{classes:[],spans:[]},u={id:i,value:s.value,propertyOrder:s.propertyOrder,location:o,classes:l.classes};return this.builder.addJson(u),{kind:`json`,span:[0,0],nodes:[{id:i,span:o.span,idSpan:o.span,defines:!0,classSpans:l.spans}],classSpans:l.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>[`TD`,`TB`,`BT`,`RL`,`LR`].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:`direction`,span:[0,0]}}classDefStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addClassDef(t.map(e=>e.image),n),{kind:`classDef`,span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,`IDENTIFIER`),n=1;for(;n<t.length&&this.source.slice((t[n-1].endOffset??t[n-1].startOffset)+1,t[n].startOffset).includes(`,`);n++);let r=t.slice(0,n).map(e=>({id:e.image,location:this.tokenLocation(e)})),i=t.slice(n).map(e=>e.image);return this.builder.addClassAssignment(r,i),{kind:`classAssign`,span:[0,0],ref:i[0],refSpan:this.tokenSpan(t[n]),nodes:r.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,`IDENTIFIER`)[0],n=this.visit(this.nodes(e,`styles`)[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),n),{kind:`style`,span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,`styleValue`).map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),n=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(n[0],n[1]).replaceAll(`\\,`,`,`)}styleComponent(e){return this.allTokens(e).map(e=>e.image).join(``)}forwardSolidOperator(e){let t=this.tokens(e,`FORWARD_SOLID`)[0];return{type:`association`,arrowType:H.SOLID_ARROW,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,`BACKWARD_SOLID`)[0],n=this.nodes(e,`edgeLabel`)[0],r=n?this.tokens(e,`MARKERLESS_SOLID`).at(-1):t;return{type:`association`,arrowType:H.BACK_ARROW,minlen:this.solidMinlen(r),...n?{label:this.visit(n)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,`edgeLabel`)[0],n=this.allTokens(e);if(!t)return{type:`association`,arrowType:H.LINE_SOLID,minlen:this.solidMinlen(this.tokens(e,`MARKERLESS_SOLID`)[0])};let r=n.at(-1),i=r.tokenType.name===`FORWARD_SOLID`?H.SOLID_ARROW:r.tokenType.name===`FORWARD_CIRCLE`?H.CIRCLE_ARROW:r.tokenType.name===`FORWARD_CROSS`?H.CROSS_ARROW:H.LINE_SOLID;return{type:`association`,arrowType:i,label:this.visit(t),minlen:i===H.SOLID_ARROW||i===H.LINE_SOLID?this.solidMinlen(r):1}}forwardCircleOperator(e){return{type:`association`,arrowType:H.CIRCLE_ARROW,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:H.CIRCLE_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:`association`,arrowType:H.CROSS_ARROW,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,`edgeLabel`)[0];return{type:`association`,arrowType:H.CROSS_ARROW_REVERSED,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:`actor`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:`usecase`,label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,n){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:n,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,n){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...n?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:n,valueSpan:r})=>({key:e,span:t,keySpan:n,valueSpan:r}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,n){return this.actorOccurrence(e,t,n)}wrap(e,t){if(t.kind===`blank`||t.kind===`comment`)return t;t.span=this.nodeSpan(e);for(let e of t.edges??[])e.span=t.span;return t}tokenLabel(e){let t=e.tokenType.name===`MARKDOWN_STRING`?`markdown`:`text`,n=t===`markdown`?2:+(e.tokenType.name===`PLAIN_STRING`),r=this.tokenSpan(e,n);return{text:this.source.slice(r[0],r[1]),type:t,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){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);return{span:[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)],line:n.startLine??1,column:n.startColumn??1}}tokenLocation(e){let t=e.tokenType.name===`PLAIN_STRING`?1:e.tokenType.name===`MARKDOWN_STRING`?2:0;return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>e.tokenType.name!==`NEWLINE`&&e.tokenType.name!==`EOF`),n=t[0],r=t.at(-1);if(!n||!r)throw Error(`Usecase CST node has no source token`);return[n.startOffset,Math.min(this.source.length,(r.endOffset??r.startOffset+r.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>`children`in e)}tokens(e,t){return(e[t]??[]).filter(e=>`tokenTypeIdx`in e)}firstNode(e,...t){for(let n of t){let t=this.nodes(e,n)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(`, `)}`)}allTokens(e){let t=[];for(let n of Object.values(e))for(let e of n)`tokenTypeIdx`in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},Po={parse:/* @__PURE__ */ y(async e=>{Gi.clear(),ho.input=[];try{fi({diagramType:`usecase`,lexer:fo,parser:ho,entry:/* @__PURE__ */ y(()=>ho.start(),`entry`),visit:/* @__PURE__ */ y(t=>No.build(t,e),`visit`)},e)}catch(t){Gi.clear();let n=ho.errors[0];if(n){let{token:r}=n,i=di(r.startOffset)?r.startOffset:e.length,a=di(r.endOffset)?r.endOffset+1:i,o=di(r.startLine)?r.startLine:e.slice(0,i).split(/\r\n|\r|\n/).length,s=Math.max(e.lastIndexOf(`
223
+ `,i-1),e.lastIndexOf(`\r`,i-1)),c=di(r.startColumn)?r.startColumn:i-s,l=t instanceof Error?t.message:String(t);throw Error(`${l} at line ${o}, column ${c} [${i},${a})`)}throw t}},`parse`)},Fo=[`point`,`circle`,`cross`,`extension`],Io={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},Lo=/* @__PURE__ */ y((e,t)=>{let[n,r]=[e,t].map(e=>e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`);return`usecase-${n}-${r}`},`usecaseDomId`),Ro=/* @__PURE__ */ y(e=>`usecase-${e.replace(/[^\w-]+/g,`_`).replace(/^_+|_+$/g,``)||`element`}`,`usecaseNodeDomId`),zo=/* @__PURE__ */ y((e,t)=>t===`markdown`?i(e).map(e=>e.map(e=>e.content).join(` `)).join(`
224
+ `):e,`getAccessibleLabel`),Bo=/* @__PURE__ */ y(e=>{let t=zo(e.label??e.id,e.labelType);if(Io[e.shape]){let n=e.actorType&&e.actorType!==`normal`?`${e.actorType} `:``;return`${e.business?`business `:``}${n}actor ${t}${e.stereotype?`, stereotype ${e.stereotype}`:``}`}if(e.shape===`note`)return`Note for ${e.noteTargetLabel??e.noteTarget??``}: ${t}`;if(e.shape===`usecaseJsonTable`){let n=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join(`; `);return n?`${t}: ${n}`:t}let n=e.stereotype?`, stereotype ${e.stereotype}`:``;return`${e.business?`business `:``}use case ${t}${n}`},`getUsecaseNodeAccessibleName`),Vo=/* @__PURE__ */ y(e=>`${e.boundaryType} system boundary ${zo(e.label??e.id,e.labelType)}`,`getUsecaseBoundaryAccessibleName`),Ho=/* @__PURE__ */ y(e=>e.relationshipType===`note`?``:`${e.relationshipType===`association`&&e.label?`association ${zo(e.label,e.labelType)}`:e.relationshipType} from ${e.sourceLabel} to ${e.targetLabel}`,`getUsecaseEdgeAccessibleName`),Uo=/* @__PURE__ */ y(e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),`escapePlainLabel`),Wo=/* @__PURE__ */ y(e=>e.replace(/([*[\\\]_`])/g,`\\$1`),`escapeMarkdownMarkers`),Go=/* @__PURE__ */ y((e,t)=>{e.diagramId=t,e.markers=[...Fo];for(let t of e.nodes){let e=t;if(e.domId=Ro(t.id),t.label!==void 0&&t.labelType===`text`&&(t.label=Uo(t.label)),t.stereotype&&=Uo(t.stereotype),!t.isGroup&&t.shape===`usecaseJsonTable`&&(t.jsonRows=t.jsonRows?.map(e=>({...e,key:Uo(e.key),value:Uo(e.value)}))),!t.isGroup&&(t.shape===`usecaseEllipse`||t.shape===`rect`)&&t.stereotype){let n=t.label??Uo(t.id);t.label=`\xAB${Wo(t.stereotype)}\xBB<br/>${t.labelType===`text`?Wo(n):n}`,t.labelType=`markdown`,e.hasFoldedStereotype=!0,delete t.stereotype}}for(let t of e.edges)t.label!==void 0&&t.labelType===`text`&&(t.label=Uo(t.label));return e},`prepareUsecaseLayoutData`),Ko=/* @__PURE__ */ y((e,t,n)=>{for(let r of t.nodes){let i=typeof r.domId==`string`?r.domId:Lo(t.diagramId,r.id),a=e.select(`#${i}`),o=r.isGroup?`boundary`:Io[r.shape]?`actor`:r.shape===`note`?`note`:r.shape===`usecaseJsonTable`?`json`:`usecase`,s=n.nodes.get(r.id)??r.id;if(a.attr(`data-usecase-id`,r.id).attr(`data-usecase-kind`,o).attr(`role`,`img`).attr(`aria-label`,s),!r.isGroup&&(r.shape===`usecaseEllipse`||r.shape===`rect`)&&`hasFoldedStereotype`in r&&r.hasFoldedStereotype===!0){let e=a.node(),t=e?.querySelector(`.nodeLabel`),n=t?.querySelector(`p`)??t,r=n?.firstChild;if(n&&r?.nodeType===3){let e=n.ownerDocument.createElement(`span`);e.className=`usecase-stereotype`,n.insertBefore(e,r),e.appendChild(r)}else e?.querySelector(`.label tspan tspan, .label tspan`)?.classList.add(`usecase-stereotype`)}}let r=new Map(t.edges.map(e=>[e.id,e]));e.selectAll(`path[data-et="edge"]`).each(function(){let e=r.get(this.getAttribute(`data-id`)??``);if(!e)return;let i=re(this);i.attr(`id`,Lo(t.diagramId,e.id)).attr(`data-usecase-id`,e.id).attr(`data-usecase-kind`,e.internal?`note-connector`:`relationship`),e.internal?i.attr(`aria-hidden`,`true`):i.attr(`role`,`img`).attr(`aria-label`,n.edges.get(e.id)??e.id)})},`annotateUsecaseElements`),qo=/* @__PURE__ */ y((e,t)=>{e.style(`--mermaid-usecase-actor-font-size`,`${t.actorFontSize}px`).style(`--mermaid-usecase-actor-font-family`,t.actorFontFamily).style(`--mermaid-usecase-actor-font-weight`,t.actorFontWeight).style(`--mermaid-usecase-font-size`,`${t.usecaseFontSize}px`).style(`--mermaid-usecase-font-family`,t.usecaseFontFamily).style(`--mermaid-usecase-font-weight`,t.usecaseFontWeight)},`applyUsecaseFonts`),Jo={draw:/* @__PURE__ */ y(async(i,a,o,s)=>{ne.info(`Drawing usecase diagram (unified)`,a);let{layout:c}=h(),u=s.db,d=u.getData(),f=new Map(d.nodes.map(e=>[e.id,zo(e.label??e.id,e.labelType)])),p={nodes:new Map(d.nodes.map(e=>[e.id,e.isGroup?Vo(e):Bo(e.shape===`note`?{...e,noteTargetLabel:f.get(e.noteTarget??``)}:e)])),edges:new Map(d.edges.map(e=>[e.id,Ho({...e,sourceLabel:f.get(e.source)??e.sourceLabel,targetLabel:f.get(e.target)??e.targetLabel})]))},m=e(a,d.config.securityLevel);d.layoutAlgorithm=r(c),Go(d,a),qo(m,d),await n(d,m),Ko(m,d,p);let g=d.diagramPadding;l.insertTitle(m,`usecaseDiagramTitleText`,0,u.getDiagramTitle?.()??``),t(m,g,`usecaseDiagram`,d.useMaxWidth),qo(m,d)},`draw`)},Yo=/* @__PURE__ */ y(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),`roleColors`),Xo=/* @__PURE__ */ y(e=>{let{theme:t,bkgColorArray:n,borderColorArray:r}=e;if(!o(t,r))return``;let i=v().usecase?.colorScheme===`rotate`,l=s(e.look),u=l===`handDrawn`,d=c(n),f=``;for(let e=0;e<a(r);e++){let t=r[e],a=d?`fill: ${n[e%n.length]};`:``,o=`[data-look="${l}"][data-color-id="color-${e}"]`;f+=`
225
+
226
+ & ${o}.system-boundary rect.boundary-body,
227
+ & ${o}.system-boundary rect.boundary-tab,
228
+ & ${o}.system-boundary .boundary-body path,
229
+ & ${o}.system-boundary .boundary-tab path {
230
+ stroke: ${t};
231
+ ${a}
232
+ }
233
+ `,i&&(f+=`
234
+
235
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
236
+ the business variant.
237
+
238
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
239
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
240
+ fill stroked in the background colour, with no class to tell them apart. Stroking
241
+ both repaints the fill lines as border colour and the shape collapses into a solid
242
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
243
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
244
+ & ${o}.usecase-element ellipse,
245
+ & ${o}.usecase-element rect {
246
+ stroke: ${t};
247
+ ${a}
248
+ }
249
+
250
+ /* The business marker is a single classed path, so it can be reached safely by name --
251
+ without it the marker keeps the uniform border beside a palette-coloured body. No
252
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
253
+ & ${o}.usecase-element .usecase-business-marker {
254
+ stroke: ${t};
255
+ }
256
+
257
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
258
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
259
+ winning and a hollow actor stays hollow. Same reason as above for not descending
260
+ into the handDrawn paths. */
261
+ & ${o}.usecase-actor .usecase-actor-shape,
262
+ & ${o}.usecase-actor .usecase-actor-hollow,
263
+ & ${o}.usecase-actor .usecase-actor-awesome,
264
+ & ${o}.usecase-actor .usecase-actor-icon {
265
+ stroke: ${t};
266
+ ${a}
267
+ }
268
+ ${u?``:`
269
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
270
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
271
+ and a value set directly on the child always beats one inherited from the parent,
272
+ whatever the parent rule's specificity. So name the children too.
273
+
274
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
275
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
276
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
277
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
278
+ & ${o}.usecase-actor .usecase-actor-glyph path,
279
+ & ${o}.usecase-actor .usecase-actor-glyph circle {
280
+ stroke: ${t};
281
+ }
282
+ `}
283
+ `)}return f},`genColor`),Zo={parser:Po,db:Gi,renderer:Jo,styles:/* @__PURE__ */ y(e=>{let t=Yo(e),n=s(e.look)===`handDrawn`;return`
284
+ ${Xo(e)}
285
+ & .usecase-actor {
286
+ color: ${e.actorTextColor??e.primaryTextColor};
287
+ }
288
+
289
+ & .usecase-actor-shape,
290
+ & .usecase-actor-hollow,
291
+ & .usecase-actor-awesome,
292
+ & .usecase-actor-icon {
293
+ fill: ${t.actorBkg};
294
+ stroke: ${t.actorBorder};
295
+ stroke-width: 2px;
296
+ }
297
+ ${n?``:`
298
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
299
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
300
+ the glyph's own paths, and a value set directly on a child always beats one inherited
301
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
302
+ without this every actor renders in the node border colour rather than the actor
303
+ colour the rule above asks for.
304
+
305
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
306
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
307
+ depend on which stylesheet is concatenated last.
308
+
309
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
310
+ & .node.usecase-actor .usecase-actor-glyph path,
311
+ & .node.usecase-actor .usecase-actor-glyph circle {
312
+ stroke: ${t.actorBorder};
313
+ }
314
+ `}
315
+ & .usecase-actor .nodeLabel,
316
+ & .actor-label {
317
+ color: ${e.actorTextColor??e.primaryTextColor};
318
+ fill: ${e.actorTextColor??e.primaryTextColor};
319
+ font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
320
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
321
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
322
+ }
323
+
324
+ & .usecase-element ellipse,
325
+ & .usecase-element rect,
326
+ & .usecase-business ellipse,
327
+ & .usecase-business rect {
328
+ fill: ${t.bkg};
329
+ stroke: ${t.border};
330
+ stroke-width: 2px;
331
+ }
332
+ ${n?``:`
333
+ /* The same interception the actor glyph hits, one element down: neo ships
334
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
335
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
336
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
337
+ equivalent neo rule and is already correct; restating it here costs nothing and means
338
+ the two forms cannot drift apart again.
339
+
340
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
341
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
342
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
343
+ exists. */
344
+ & [data-look="${s(e.look)}"].node.usecase-element ellipse,
345
+ & [data-look="${s(e.look)}"].node.usecase-element rect {
346
+ fill: ${t.bkg};
347
+ stroke: ${t.border};
348
+ }
349
+
350
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
351
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
352
+ & [data-look="${s(e.look)}"].node.usecase-element .usecase-business-marker {
353
+ stroke: ${t.border};
354
+ }
355
+ `}
356
+ & .usecase-element .nodeLabel,
357
+ & .usecase-label {
358
+ color: ${e.primaryTextColor};
359
+ fill: ${e.primaryTextColor};
360
+ font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
361
+ font-size: var(--mermaid-usecase-font-size, 12px);
362
+ font-weight: var(--mermaid-usecase-font-weight, normal);
363
+ }
364
+
365
+ & .usecase-stereotype,
366
+ & .usecase-business-marker {
367
+ color: ${e.primaryTextColor};
368
+ fill: ${e.primaryTextColor};
369
+ stroke: ${t.border};
370
+ }
371
+
372
+ & .system-boundary rect.boundary-body,
373
+ & .system-boundary rect.boundary-tab,
374
+ & .system-boundary-package-tab {
375
+ fill: ${t.boundaryBkg};
376
+ stroke: ${t.boundaryBorder};
377
+ stroke-width: 1px;
378
+ }
379
+
380
+ & .system-boundary-title text {
381
+ fill: ${e.titleColor??e.primaryTextColor};
382
+ }
383
+
384
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
385
+ 'color' on the span, and that has to stay inheritable by its children. */
386
+ & .system-boundary-title span {
387
+ color: ${e.titleColor??e.primaryTextColor};
388
+ }
389
+
390
+ & .usecase-note {
391
+ fill: ${e.noteBkgColor};
392
+ stroke: ${e.noteBorderColor};
393
+ color: ${e.noteTextColor};
394
+ }
395
+
396
+ & .usecase-note .nodeLabel {
397
+ color: ${e.noteTextColor};
398
+ fill: ${e.noteTextColor};
399
+ }
400
+
401
+ & .usecase-json-table,
402
+ & .usecase-json-table rect,
403
+ & .usecase-json-cell {
404
+ fill: ${e.mainBkg};
405
+ stroke: ${e.nodeBorder??e.primaryColor};
406
+ }
407
+
408
+ & .usecase-json-title,
409
+ & .usecase-json-key,
410
+ & .usecase-json-value {
411
+ color: ${e.primaryTextColor};
412
+ fill: ${e.primaryTextColor};
413
+ }
414
+
415
+ & .relationship {
416
+ fill: none;
417
+ stroke: ${e.lineColor};
418
+ }
419
+
420
+ & .relationship-include,
421
+ & .relationship-extend,
422
+ & .relationship-note {
423
+ stroke-dasharray: 3;
424
+ }
425
+
426
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
427
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
428
+ & .relationship-include {
429
+ stroke: ${t.includeLine};
430
+ }
431
+
432
+ & .relationship-extend {
433
+ stroke: ${t.extendLine};
434
+ }
435
+
436
+ & .relationship.edge-animation-fast,
437
+ & .relationship.edge-animation-slow {
438
+ stroke-linecap: round;
439
+ }
440
+
441
+ & .edgeLabel,
442
+ & .edgeLabel p {
443
+ background-color: ${e.edgeLabelBackground};
444
+ }
445
+
446
+ & .labelBkg {
447
+ background-color: ${e.edgeLabelBackground};
448
+ padding: 0 2px;
449
+ }
450
+
451
+ & .edgeLabel .label rect {
452
+ fill: ${e.edgeLabelBackground};
453
+ }
454
+
455
+ & .relationship-label,
456
+ & .edgeLabel {
457
+ color: ${e.primaryTextColor};
458
+ fill: ${e.primaryTextColor};
459
+ font-family: ${e.fontFamily};
460
+ font-size: 10px;
461
+ font-weight: normal;
462
+ }
463
+
464
+ & .marker,
465
+ & .marker.point,
466
+ & .marker.circle,
467
+ & .marker.cross {
468
+ fill: ${e.lineColor};
469
+ stroke: ${e.lineColor};
470
+ }
471
+
472
+ & .marker.extension {
473
+ fill: ${e.mainBkg};
474
+ stroke: ${e.lineColor};
475
+ }
476
+ `},`getStyles`)};export{Zo as diagram};