@kw-yeh/vibeflow 4.0.1

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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +146 -0
  3. package/dist/vibeflow.mjs +6103 -0
  4. package/dist/web/404/index.html +1 -0
  5. package/dist/web/404.html +1 -0
  6. package/dist/web/_next/static/-9MMnQDtlhk8JcEq6dTBS/_buildManifest.js +1 -0
  7. package/dist/web/_next/static/-9MMnQDtlhk8JcEq6dTBS/_ssgManifest.js +1 -0
  8. package/dist/web/_next/static/chunks/02e71eac.0250f42685eae210.js +18 -0
  9. package/dist/web/_next/static/chunks/043de7d2.3a6733c82bc2409f.js +160 -0
  10. package/dist/web/_next/static/chunks/1201.011a689cd95a4983.js +1 -0
  11. package/dist/web/_next/static/chunks/1282.d0e740390a16bb90.js +1 -0
  12. package/dist/web/_next/static/chunks/1396.cb165487d4bf0f35.js +1 -0
  13. package/dist/web/_next/static/chunks/167.98f928ccaed44837.js +1 -0
  14. package/dist/web/_next/static/chunks/1672.82392f784373fc1a.js +149 -0
  15. package/dist/web/_next/static/chunks/1776.9ad96593642a32f0.js +36 -0
  16. package/dist/web/_next/static/chunks/1840.fa1f1878af23fd9f.js +41 -0
  17. package/dist/web/_next/static/chunks/1886.22db355b96ff3e38.js +7 -0
  18. package/dist/web/_next/static/chunks/2039.461f2ac8bbfeb1cf.js +90 -0
  19. package/dist/web/_next/static/chunks/2107.2540b21d69c927d0.js +1 -0
  20. package/dist/web/_next/static/chunks/2205.fe6639ba89aebb99.js +1 -0
  21. package/dist/web/_next/static/chunks/2271.8d52a83cf1b02b3e.js +1 -0
  22. package/dist/web/_next/static/chunks/2396.a4c1620b6d217c02.js +1 -0
  23. package/dist/web/_next/static/chunks/260.7db9b90987032402.js +1 -0
  24. package/dist/web/_next/static/chunks/2806.c2a6f6733f2b439b.js +32 -0
  25. package/dist/web/_next/static/chunks/2817.a82d851ccf215c35.js +1 -0
  26. package/dist/web/_next/static/chunks/3082.5086ba86ade06629.js +1 -0
  27. package/dist/web/_next/static/chunks/3110.db844baaab453716.js +287 -0
  28. package/dist/web/_next/static/chunks/3289.04108f17cdf795e3.js +1 -0
  29. package/dist/web/_next/static/chunks/3618.418bfeef9a735cc6.js +148 -0
  30. package/dist/web/_next/static/chunks/3711.7f07235c9e8ae090.js +1 -0
  31. package/dist/web/_next/static/chunks/3746.81e4d62ebdb395eb.js +1 -0
  32. package/dist/web/_next/static/chunks/3846.d63d31d2de9a159c.js +1 -0
  33. package/dist/web/_next/static/chunks/3927.8202e4c7eeb07487.js +74 -0
  34. package/dist/web/_next/static/chunks/39a04069.9dd71f191712d3fa.js +62 -0
  35. package/dist/web/_next/static/chunks/4012.440934d750758d59.js +1 -0
  36. package/dist/web/_next/static/chunks/4109.f1de572405aa3b2b.js +309 -0
  37. package/dist/web/_next/static/chunks/4224.c5c8af77fc9b6c44.js +286 -0
  38. package/dist/web/_next/static/chunks/4270-6c9c75303137e3a5.js +9 -0
  39. package/dist/web/_next/static/chunks/4292.70e0a2a99b20e418.js +1 -0
  40. package/dist/web/_next/static/chunks/4459.814d84742e06267c.js +1 -0
  41. package/dist/web/_next/static/chunks/4485.e209e1d39502d049.js +226 -0
  42. package/dist/web/_next/static/chunks/4802.6f5a5e00488db074.js +1 -0
  43. package/dist/web/_next/static/chunks/5432.3349240a8cd1114c.js +94 -0
  44. package/dist/web/_next/static/chunks/5468.7440c698079f7f79.js +1 -0
  45. package/dist/web/_next/static/chunks/5469.5e1555e411d9c96b.js +1 -0
  46. package/dist/web/_next/static/chunks/5695.45dd981e66074a89.js +1 -0
  47. package/dist/web/_next/static/chunks/5785.01c97ed45f552929.js +8 -0
  48. package/dist/web/_next/static/chunks/59.a9be2f8a75bc42e9.js +1 -0
  49. package/dist/web/_next/static/chunks/5918.7a18726fa96ba97d.js +1 -0
  50. package/dist/web/_next/static/chunks/621.7f06a4c57845924d.js +27 -0
  51. package/dist/web/_next/static/chunks/6232.4ebeb2a3e3fde2f9.js +1 -0
  52. package/dist/web/_next/static/chunks/6390.df979849e0b82b10.js +1 -0
  53. package/dist/web/_next/static/chunks/6747.fe4ace8428cf57b8.js +1 -0
  54. package/dist/web/_next/static/chunks/67584bf0.bcc252f93280fffc.js +1 -0
  55. package/dist/web/_next/static/chunks/6848.18adf63b76b43ce0.js +1 -0
  56. package/dist/web/_next/static/chunks/6863.7c16f1cf40adc214.js +77 -0
  57. package/dist/web/_next/static/chunks/6981.db8f1cd11466723b.js +1 -0
  58. package/dist/web/_next/static/chunks/7045.7cf0eb88acb1ee65.js +1 -0
  59. package/dist/web/_next/static/chunks/7266.5fc4e54a82b394a3.js +23 -0
  60. package/dist/web/_next/static/chunks/7271.3e11a6c675bba517.js +1 -0
  61. package/dist/web/_next/static/chunks/7443.de45a50460ec02b4.js +217 -0
  62. package/dist/web/_next/static/chunks/7449.be3a97c644b086d6.js +86 -0
  63. package/dist/web/_next/static/chunks/7835.eaf45d5554820d67.js +104 -0
  64. package/dist/web/_next/static/chunks/7869.b407f42eca1ddf4d.js +1 -0
  65. package/dist/web/_next/static/chunks/7913.3de14c31f63521fd.js +193 -0
  66. package/dist/web/_next/static/chunks/7915.e23554d5280c643a.js +1 -0
  67. package/dist/web/_next/static/chunks/7992.5dde103489d49ad1.js +24 -0
  68. package/dist/web/_next/static/chunks/8057.16633338493802bd.js +24 -0
  69. package/dist/web/_next/static/chunks/8244.0a0a340eddcff9ce.js +1 -0
  70. package/dist/web/_next/static/chunks/8259.62f5c49f967282f1.js +64 -0
  71. package/dist/web/_next/static/chunks/8372.eb7c979688ab1442.js +62 -0
  72. package/dist/web/_next/static/chunks/8590.c7e1c62b00e799ea.js +1 -0
  73. package/dist/web/_next/static/chunks/8655.1a55ea833e35b289.js +115 -0
  74. package/dist/web/_next/static/chunks/8687.cbb5d2e055f2a05f.js +1 -0
  75. package/dist/web/_next/static/chunks/8704.bb5e916a22041380.js +1 -0
  76. package/dist/web/_next/static/chunks/88492ad4.406f106f686c2ea4.js +82 -0
  77. package/dist/web/_next/static/chunks/898.a636c29260da655a.js +93 -0
  78. package/dist/web/_next/static/chunks/9371.f52b19a630591b42.js +34 -0
  79. package/dist/web/_next/static/chunks/94.c653beceaa62934f.js +1 -0
  80. package/dist/web/_next/static/chunks/9516.3d1f5c6a23f298e9.js +1 -0
  81. package/dist/web/_next/static/chunks/9525.c2f5e990d374aeb6.js +38 -0
  82. package/dist/web/_next/static/chunks/9540.9cc4cb31dd3a0d0a.js +1 -0
  83. package/dist/web/_next/static/chunks/9612.d9f1b4d3209e70dc.js +79 -0
  84. package/dist/web/_next/static/chunks/9759.ddd2794ce95b458c.js +1 -0
  85. package/dist/web/_next/static/chunks/b02c773b.2d61cc590e6c1c58.js +1 -0
  86. package/dist/web/_next/static/chunks/b9dacbaa.d2b59af18cc80870.js +1 -0
  87. package/dist/web/_next/static/chunks/d94f238e.ed1acca9cb2f0773.js +122 -0
  88. package/dist/web/_next/static/chunks/f24717c3.caadd8481abaaae2.js +1 -0
  89. package/dist/web/_next/static/chunks/framework-b92a367cf1ad4bf7.js +1 -0
  90. package/dist/web/_next/static/chunks/main-ec7fd4c371d06729.js +5 -0
  91. package/dist/web/_next/static/chunks/pages/_app-320afeed07d86516.js +1 -0
  92. package/dist/web/_next/static/chunks/pages/_error-8f65b0f8749f42d2.js +1 -0
  93. package/dist/web/_next/static/chunks/pages/home-efefddd4b88b018d.js +11 -0
  94. package/dist/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  95. package/dist/web/_next/static/chunks/webpack-c8aa5df0425f6b7b.js +1 -0
  96. package/dist/web/_next/static/css/edcc6abb24dfd492.css +2 -0
  97. package/dist/web/apple-touch-icon.png +0 -0
  98. package/dist/web/favicon.ico +0 -0
  99. package/dist/web/home/index.html +1 -0
  100. package/dist/web/logo.svg +17 -0
  101. package/package.json +37 -0
@@ -0,0 +1,309 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4109],{4109:(e,t,s)=>{s.d(t,{diagram:()=>aV});var i,n,a,r,o,l,h,c,d,u=s(98204),p=s(14569),f=s(33280);s(13080),s(64299),s(37064),s(83860),s(60833),s(99980);var m=s(96137);s(41329);var T=s(94698),A=s(58959),E=s(95631),g=s(5218),y=s(14528),L=s(95482),S=s(32814),R=s(13761),N=s(35706),O=s(2391),k=s(470);let I=function(e){return(0,k.A)(e,4)};function C(e){function t(){}t.prototype=e;let s=new t;function i(){return typeof s.bar}return i(),i(),e}let b=function(e,t,s){var i=-1,n=e.length;t<0&&(t=-t>n?0:n+t),(s=s>n?n:s)<0&&(s+=n),n=t>s?0:s-t>>>0,t>>>=0;for(var a=Array(n);++i<n;)a[i]=e[i+t];return a};var v=s(58989);let _=function(e,t,s){var i=null==e?0:e.length;return i?b(e,(t=s||void 0===t?1:(0,v.A)(t))<0?0:t,i):[]};var x=s(87405),U=s(76357),M=s(95547),w=s(28903),P=s(99674),D=s(86645),$=s(68852),K=Object.prototype.hasOwnProperty,F=(0,w.A)(function(e,t){if((0,D.A)(t)||(0,P.A)(t))return void(0,M.A)(t,(0,$.A)(t),e);for(var s in t)K.call(t,s)&&(0,U.A)(e,s,t[s])}),B=s(40960),G=s(26963),W=s(99695),j=s(55945);let z=function(e,t){if(null==e)return{};var s=(0,B.A)((0,j.A)(e),function(e){return[e]});return t=(0,G.A)(t),(0,W.A)(e,s,function(e,s){return t(e,s[0])})};var V=s(6748),H=s(71660),Y=s(48507),X=s(4137),J=X.A&&X.A.isRegExp,q=J?(0,Y.A)(J):function(e){return(0,H.A)(e)&&"[object RegExp]"==(0,V.A)(e)};class Z{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),(0,L.A)(this.definition,t=>{t.accept(e)})}}class Q extends Z{constructor(e){super([]),this.idx=1,F(this,z(e,e=>void 0!==e))}set definition(e){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class ee extends Z{constructor(e){super(e.definition),this.orgText="",F(this,z(e,e=>void 0!==e))}}class et extends Z{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,F(this,z(e,e=>void 0!==e))}}class es extends Z{constructor(e){super(e.definition),this.idx=1,F(this,z(e,e=>void 0!==e))}}class ei extends Z{constructor(e){super(e.definition),this.idx=1,F(this,z(e,e=>void 0!==e))}}class en extends Z{constructor(e){super(e.definition),this.idx=1,F(this,z(e,e=>void 0!==e))}}class ea extends Z{constructor(e){super(e.definition),this.idx=1,F(this,z(e,e=>void 0!==e))}}class er extends Z{constructor(e){super(e.definition),this.idx=1,F(this,z(e,e=>void 0!==e))}}class eo extends Z{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,F(this,z(e,e=>void 0!==e))}}class el{constructor(e){this.idx=1,F(this,z(e,e=>void 0!==e))}accept(e){e.visit(this)}}class eh{visit(e){switch(e.constructor){case Q:return this.visitNonTerminal(e);case et:return this.visitAlternative(e);case es:return this.visitOption(e);case ei:return this.visitRepetitionMandatory(e);case en:return this.visitRepetitionMandatoryWithSeparator(e);case er:return this.visitRepetitionWithSeparator(e);case ea:return this.visitRepetition(e);case eo:return this.visitAlternation(e);case el:return this.visitTerminal(e);case ee:return this.visitRule(e);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}var ec=s(9426),ed=s(47578);let eu=function(e,t){var s;return(0,ed.A)(e,function(e,i,n){return!(s=t(e,i,n))}),!!s};var ep=s(32674),ef=s(64244);let em=function(e,t,s){var i=(0,ep.A)(e)?ec.A:eu;return s&&(0,ef.A)(e,t,s)&&(t=void 0),i(e,(0,G.A)(t,3))};var eT=s(46303),eA=Math.max;let eE=function(e,t,s,i){e=(0,P.A)(e)?e:(0,S.A)(e),s=s&&!i?(0,v.A)(s):0;var n=e.length;return s<0&&(s=eA(n+s,0)),(0,x.A)(e)?s<=n&&e.indexOf(t,s)>-1:!!n&&(0,eT.A)(e,t,s)>-1},eg=function(e,t){for(var s=-1,i=null==e?0:e.length;++s<i;)if(!t(e[s],s,e))return!1;return!0},ey=function(e,t){var s=!0;return(0,ed.A)(e,function(e,i,n){return s=!!t(e,i,n)}),s},eL=function(e,t,s){var i=(0,ep.A)(e)?eg:ey;return s&&(0,ef.A)(e,t,s)&&(t=void 0),i(e,(0,G.A)(t,3))};function eS(e,t=[]){return e instanceof es||e instanceof ea||e instanceof er||(e instanceof eo?em(e.definition,e=>eS(e,t)):!(e instanceof Q&&eE(t,e))&&e instanceof Z&&(e instanceof Q&&t.push(e),eL(e.definition,e=>eS(e,t))))}function eR(e){if(e instanceof Q)return"SUBRULE";if(e instanceof es)return"OPTION";if(e instanceof eo)return"OR";if(e instanceof ei)return"AT_LEAST_ONE";if(e instanceof en)return"AT_LEAST_ONE_SEP";else if(e instanceof er)return"MANY_SEP";else if(e instanceof ea)return"MANY";else if(e instanceof el)return"CONSUME";else throw Error("non exhaustive match")}class eN{walk(e,t=[]){(0,L.A)(e.definition,(s,i)=>{let n=_(e.definition,i+1);if(s instanceof Q)this.walkProdRef(s,n,t);else if(s instanceof el)this.walkTerminal(s,n,t);else if(s instanceof et)this.walkFlat(s,n,t);else if(s instanceof es)this.walkOption(s,n,t);else if(s instanceof ei)this.walkAtLeastOne(s,n,t);else if(s instanceof en)this.walkAtLeastOneSep(s,n,t);else if(s instanceof er)this.walkManySep(s,n,t);else if(s instanceof ea)this.walkMany(s,n,t);else if(s instanceof eo)this.walkOr(s,n,t);else throw Error("non exhaustive match")})}walkTerminal(e,t,s){}walkProdRef(e,t,s){}walkFlat(e,t,s){let i=t.concat(s);this.walk(e,i)}walkOption(e,t,s){let i=t.concat(s);this.walk(e,i)}walkAtLeastOne(e,t,s){let i=[new es({definition:e.definition})].concat(t,s);this.walk(e,i)}walkAtLeastOneSep(e,t,s){let i=eO(e,t,s);this.walk(e,i)}walkMany(e,t,s){let i=[new es({definition:e.definition})].concat(t,s);this.walk(e,i)}walkManySep(e,t,s){let i=eO(e,t,s);this.walk(e,i)}walkOr(e,t,s){let i=t.concat(s);(0,L.A)(e.definition,e=>{let t=new et({definition:[e]});this.walk(t,i)})}}function eO(e,t,s){return[new es({definition:[new el({terminalType:e.separator})].concat(e.definition)})].concat(t,s)}var ek=s(20153);let eI=function(e){return e&&e.length?(0,ek.A)(e):[]};var eC=s(91218);function eb(e){if(e instanceof Q)return eb(e.referencedRule);if(e instanceof el)return[e.terminalType];if(e instanceof et||e instanceof es||e instanceof ea||e instanceof ei||e instanceof en||e instanceof er||e instanceof el||e instanceof ee)return function(e){let t,s=[],i=e.definition,n=0,a=i.length>n,r=!0;for(;a&&r;)r=eS(t=i[n]),s=s.concat(eb(t)),n+=1,a=i.length>n;return eI(s)}(e);if(e instanceof eo){var t;let s;return t=e,s=(0,N.A)(t.definition,e=>eb(e)),eI((0,eC.A)(s))}throw Error("non exhaustive match")}let ev="_~IN~_";class e_ extends eN{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,t,s){}walkProdRef(e,t,s){var i,n;let a=(i=e.referencedRule,n=e.idx,i.name+n+ev+this.topProd.name),r=eb(new et({definition:t.concat(s)}));this.follows[a]=r}}var ex=s(45544);function eU(e){return e.charCodeAt(0)}function eM(e,t){Array.isArray(e)?e.forEach(function(e){t.push(e)}):t.push(e)}function ew(e,t){if(!0===e[t])throw"duplicate flag "+t;e[t],e[t]=!0}function eP(e){if(void 0===e)throw Error("Internal Error - Should never get here!");return!0}function eD(){throw Error("Internal Error - Should never get here!")}function e$(e){return"Character"===e.type}let eK=[];for(let e=eU("0");e<=eU("9");e++)eK.push(e);let eF=[eU("_")].concat(eK);for(let e=eU("a");e<=eU("z");e++)eF.push(e);for(let e=eU("A");e<=eU("Z");e++)eF.push(e);let eB=[eU(" "),eU("\f"),eU("\n"),eU("\r"),eU(" "),eU("\v"),eU(" "),eU("\xa0"),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU(" "),eU("\u2028"),eU("\u2029"),eU(" "),eU(" "),eU(" "),eU("\uFEFF")],eG=/[0-9a-fA-F]/,eW=/[0-9]/,ej=/[1-9]/;class ez{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(e){this.idx=e.idx,this.input=e.input,this.groupIdx=e.groupIdx}pattern(e){this.idx=0,this.input=e,this.groupIdx=0,this.consumeChar("/");let t=this.disjunction();this.consumeChar("/");let s={type:"Flags",loc:{begin:this.idx,end:e.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":ew(s,"global");break;case"i":ew(s,"ignoreCase");break;case"m":ew(s,"multiLine");break;case"u":ew(s,"unicode");break;case"y":ew(s,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:s,value:t,loc:this.loc(0)}}disjunction(){let e=[],t=this.idx;for(e.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),e.push(this.alternative());return{type:"Disjunction",value:e,loc:this.loc(t)}}alternative(){let e=[],t=this.idx;for(;this.isTerm();)e.push(this.term());return{type:"Alternative",value:e,loc:this.loc(t)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){let e=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(e)};case"$":return{type:"EndAnchor",loc:this.loc(e)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(e)};case"B":return{type:"NonWordBoundary",loc:this.loc(e)}}throw Error("Invalid Assertion Escape");case"(":let t;switch(this.consumeChar("?"),this.popChar()){case"=":t="Lookahead";break;case"!":t="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":t="Lookbehind";break;case"!":t="NegativeLookbehind"}}eP(t);let s=this.disjunction();return this.consumeChar(")"),{type:t,value:s,loc:this.loc(e)}}return eD()}quantifier(e=!1){let t,s=this.idx;switch(this.popChar()){case"*":t={atLeast:0,atMost:1/0};break;case"+":t={atLeast:1,atMost:1/0};break;case"?":t={atLeast:0,atMost:1};break;case"{":let i=this.integerIncludingZero();switch(this.popChar()){case"}":t={atLeast:i,atMost:i};break;case",":t=this.isDigit()?{atLeast:i,atMost:this.integerIncludingZero()}:{atLeast:i,atMost:1/0},this.consumeChar("}")}if(!0===e&&void 0===t)return;eP(t)}if((!0!==e||void 0!==t)&&eP(t))return"?"===this.peekChar(0)?(this.consumeChar("?"),t.greedy=!1):t.greedy=!0,t.type="Quantifier",t.loc=this.loc(s),t}atom(){let e,t=this.idx;switch(this.peekChar()){case".":e=this.dotAll();break;case"\\":e=this.atomEscape();break;case"[":e=this.characterClass();break;case"(":e=this.group()}return(void 0===e&&this.isPatternCharacter()&&(e=this.patternCharacter()),eP(e))?(e.loc=this.loc(t),this.isQuantifier()&&(e.quantifier=this.quantifier()),e):eD()}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[eU("\n"),eU("\r"),eU("\u2028"),eU("\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=eK;break;case"D":e=eK,t=!0;break;case"s":e=eB;break;case"S":e=eB,t=!0;break;case"w":e=eF;break;case"W":e=eF,t=!0}return eP(e)?{type:"Set",value:e,complement:t}:eD()}controlEscapeAtom(){let e;switch(this.popChar()){case"f":e=eU("\f");break;case"n":e=eU("\n");break;case"r":e=eU("\r");break;case"t":e=eU(" ");break;case"v":e=eU("\v")}return eP(e)?{type:"Character",value:e}:eD()}controlLetterEscapeAtom(){this.consumeChar("c");let e=this.popChar();if(!1===/[a-zA-Z]/.test(e))throw Error("Invalid ");return{type:"Character",value:e.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:eU("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:eU(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:eU(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,e$(t)&&this.isRangeDash()){this.consumeChar("-");let s=this.classAtom();if(s.type,e$(s)){if(s.value<t.value)throw Error("Range out of order in character class");e.push({from:t.value,to:s.value})}else eM(t.value,e),e.push(eU("-")),eM(s.value,e)}else eM(t.value,e)}return this.consumeChar("]"),{type:"Set",complement:t,value:e}}classAtom(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}}classEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:eU("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let e=!0;this.consumeChar("("),"?"===this.peekChar(0)?(this.consumeChar("?"),this.consumeChar(":"),e=!1):this.groupIdx++;let t=this.disjunction();this.consumeChar(")");let s={type:"Group",capturing:e,value:t};return e&&(s.idx=this.groupIdx),s}positiveInteger(){let e=this.popChar();if(!1===ej.test(e))throw Error("Expecting a positive integer");for(;eW.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}integerIncludingZero(){let e=this.popChar();if(!1===eW.test(e))throw Error("Expecting an integer");for(;eW.test(this.peekChar(0));)e+=this.popChar();return parseInt(e,10)}patternCharacter(){let e=this.popChar();switch(e){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:eU(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 eW.test(this.peekChar(0))}isClassAtom(e=0){switch(this.peekChar(e)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}isTerm(){return this.isAtom()||this.isAssertion()}isAtom(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}}isAssertion(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return"?"===this.peekChar(1)&&("="===this.peekChar(2)||"!"===this.peekChar(2)||"<"===this.peekChar(2)&&("="===this.peekChar(3)||"!"===this.peekChar(3)));default:return!1}}isQuantifier(){let e=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(e)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(e){let t="";for(let s=0;s<e;s++){let e=this.popChar();if(!1===eG.test(e))throw Error("Expecting a HexDecimal digits");t+=e}return{type:"Character",value:parseInt(t,16)}}peekChar(e=0){return this.input[this.idx+e]}popChar(){let e=this.peekChar(0);return this.consumeChar(void 0),e}consumeChar(e){if(void 0!==e&&this.input[this.idx]!==e)throw Error("Expected: '"+e+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++}loc(e){return{begin:e,end:this.idx}}}class eV{visitChildren(e){for(let t in e){let s=e[t];e.hasOwnProperty(t)&&(void 0!==s.type?this.visit(s):Array.isArray(s)&&s.forEach(e=>{this.visit(e)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Lookbehind":this.visitLookbehind(e);break;case"NegativeLookbehind":this.visitNegativeLookbehind(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitLookbehind(e){}visitNegativeLookbehind(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}var eH=s(8754),eY=s(11100),eX=s(94274);let eJ=function(e){if("function"!=typeof e)throw TypeError("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}},eq=function(e,t){return((0,ep.A)(e)?eY.A:eX.A)(e,eJ((0,G.A)(t,3)))};var eZ=s(76080),eQ=Math.max;let e0=function(e,t,s){var i=null==e?0:e.length;if(!i)return -1;var n=null==s?0:(0,v.A)(s);return n<0&&(n=eQ(i+n,0)),(0,eT.A)(e,t,n)};var e1=s(25042),e2=s(45738),e6=s(24957),e5=s(31975),e4=s(16779),e3=s(63783);let e9=function(e,t,s,i){var n=-1,a=e5.A,r=!0,o=e.length,l=[],h=t.length;if(!o)return l;s&&(t=(0,B.A)(t,(0,Y.A)(s))),i?(a=e4.A,r=!1):t.length>=200&&(a=e3.A,r=!1,t=new e6.A(t));e:for(;++n<o;){var c=e[n],d=null==s?c:s(c);if(c=i||0!==c?c:0,r&&d==d){for(var u=h;u--;)if(t[u]===d)continue e;l.push(c)}else a(t,d,i)||l.push(c)}return l};var e8=s(73283),e7=s(64470),te=s(80785),tt=(0,e7.A)(function(e,t){return(0,te.A)(e)?e9(e,(0,e8.A)(t,1,te.A,!0)):[]});let ts=function(e){for(var t=-1,s=null==e?0:e.length,i=0,n=[];++t<s;){var a=e[t];a&&(n[i++]=a)}return n},ti=function(e){return e&&e.length?e[0]:void 0};var tn=s(40912);function ta(e){console&&console.error&&console.error(`Error: ${e}`)}function tr(e){console&&console.warn&&console.warn(`Warning: ${e}`)}let to={},tl=new ez;function th(e){let t=e.toString();if(to.hasOwnProperty(t))return to[t];{let e=tl.pattern(t);return to[t]=e,e}}let tc="Complement Sets are not supported for first char optimization",td='Unable to use "first char" lexer optimizations:\n';function tu(e,t,s){let i=tb(e);t[i]=i,!0===s&&function(e,t){let s=String.fromCharCode(e),i=s.toUpperCase();if(i!==s){let e=tb(i.charCodeAt(0));t[e]=e}else{let e=s.toLowerCase();if(e!==s){let s=tb(e.charCodeAt(0));t[s]=s}}}(e,t)}function tp(e,t){return(0,tn.A)(e.value,e=>"number"==typeof e?eE(t,e):void 0!==(0,tn.A)(t,t=>e.from<=t&&t<=e.to))}class tf extends eV{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(!0!==this.found){switch(e.type){case"Lookahead":this.visitLookahead(e);return;case"NegativeLookahead":this.visitNegativeLookahead(e);return;case"Lookbehind":this.visitLookbehind(e);return;case"NegativeLookbehind":this.visitNegativeLookbehind(e);return}super.visitChildren(e)}}visitCharacter(e){eE(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?void 0===tp(e,this.targetCharCodes)&&(this.found=!0):void 0!==tp(e,this.targetCharCodes)&&(this.found=!0)}}function tm(e,t){if(!(t instanceof RegExp))return void 0!==(0,tn.A)(t,t=>eE(e,t.charCodeAt(0)));{let s=th(t),i=new tf(e);return i.visit(s),i.found}}let tT="PATTERN",tA="defaultMode",tE="modes",tg=/[^\\][$]/,ty=/[^\\[][\^]|^\^/;function tL(e){let t=e.ignoreCase?"iy":"y";return RegExp(`${e.source}`,t)}function tS(e){let t=e.PATTERN;if(q(t))return!1;if((0,eZ.A)(t))return!0;if((0,O.A)(t,"exec"))return!0;if((0,x.A)(t))return!1;throw Error("non exhaustive match")}function tR(e){return!!(0,x.A)(e)&&1===e.length&&e.charCodeAt(0)}let tN={test:function(e){let t=e.length;for(let s=this.lastIndex;s<t;s++){let t=e.charCodeAt(s);if(10===t)return this.lastIndex=s+1,!0;if(13===t)return 10===e.charCodeAt(s+1)?this.lastIndex=s+2:this.lastIndex=s+1,!0}return!1},lastIndex:0};function tO(e,t){if((0,O.A)(e,"LINE_BREAKS"))return!1;if(q(e.PATTERN)){try{tm(t,e.PATTERN)}catch(e){return{issue:l.IDENTIFY_TERMINATOR,errMsg:e.message}}return!1}if((0,x.A)(e.PATTERN))return!1;if(tS(e))return{issue:l.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function tk(e){return(0,N.A)(e,e=>(0,x.A)(e)?e.charCodeAt(0):e)}function tI(e,t,s){void 0===e[t]?e[t]=[s]:e[t].push(s)}let tC=[];function tb(e){return e<256?e:tC[e]}var tv=s(82628),t_=s(53766),tx=s(96620);function tU(e){let t=new Date().getTime(),s=e();return{time:new Date().getTime()-t,value:s}}function tM(e,t){let s=e.tokenTypeIdx;return s===t.tokenTypeIdx||!0===t.isParent&&!0===t.categoryMatchesMap[s]}function tw(e,t){return e.tokenTypeIdx===t.tokenTypeIdx}let tP=1,tD={};function t$(e){var t,s,i;let n=function(e){let t=I(e),s=e,i=!0;for(;i;){let e=tt(s=ts((0,eC.A)((0,N.A)(s,e=>e.CATEGORIES))),t);t=t.concat(e),(0,R.A)(e)?i=!1:s=e}return t}(e);t=n,(0,L.A)(t,e=>{var t,s;tK(e)||(tD[tP]=e,e.tokenTypeIdx=tP++),tF(e)&&!(0,ep.A)(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),tF(e)||(e.CATEGORIES=[]),t=e,(0,O.A)(t,"categoryMatches")||(e.categoryMatches=[]),s=e,(0,O.A)(s,"categoryMatchesMap")||(e.categoryMatchesMap={})}),s=n,(0,L.A)(s,e=>{!function e(t,s){(0,L.A)(t,e=>{s.categoryMatchesMap[e.tokenTypeIdx]=!0}),(0,L.A)(s.CATEGORIES,i=>{let n=t.concat(s);eE(n,i)||e(n,i)})}([],e)}),i=n,(0,L.A)(i,e=>{e.categoryMatches=[],(0,L.A)(e.categoryMatchesMap,(t,s)=>{e.categoryMatches.push(tD[s].tokenTypeIdx)})}),(0,L.A)(n,e=>{e.isParent=e.categoryMatches.length>0})}function tK(e){return(0,O.A)(e,"tokenTypeIdx")}function tF(e){return(0,O.A)(e,"CATEGORIES")}function tB(e){return(0,O.A)(e,"tokenTypeIdx")}(i=l||(l={}))[i.MISSING_PATTERN=0]="MISSING_PATTERN",i[i.INVALID_PATTERN=1]="INVALID_PATTERN",i[i.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",i[i.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",i[i.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",i[i.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",i[i.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",i[i.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",i[i.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",i[i.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",i[i.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",i[i.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",i[i.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",i[i.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",i[i.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",i[i.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",i[i.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",i[i.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";let tG={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:{buildUnableToPopLexerModeMessage:e=>`Unable to pop Lexer Mode after encountering Token ->${e.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(e,t,s,i,n,a)=>`unexpected character: ->${e.charAt(t)}<- at offset: ${t}, skipped ${s} characters.`},traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(tG);class tW{constructor(e,t=tG){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(e,t)=>{if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let s=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);let{time:i,value:n}=tU(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,n}},"boolean"==typeof t)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=F({},tG,t);const s=this.config.traceInitPerf;!0===s?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof s&&(this.traceInitMaxIdent=s,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let s,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===tG.lineTerminatorsPattern)this.config.lineTerminatorsPattern=tN;else if(this.config.lineTerminatorCharacters===tG.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(t.safeMode&&t.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),(0,ep.A)(e)?s={modes:{defaultMode:I(e)},defaultMode:tA}:(i=!1,s=I(e))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{var e;let t;this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat((e=s,this.trackStartLines,this.config.lineTerminatorCharacters,t=[],(0,O.A)(e,tA)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+tA+"> property in its definition\n",type:l.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),(0,O.A)(e,tE)||t.push({message:"A MultiMode Lexer cannot be initialized without a <"+tE+"> property in its definition\n",type:l.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),(0,O.A)(e,tE)&&(0,O.A)(e,tA)&&!(0,O.A)(e.modes,e.defaultMode)&&t.push({message:`A MultiMode Lexer cannot be initialized with a ${tA}: <${e.defaultMode}>which does not exist
2
+ `,type:l.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),(0,O.A)(e,tE)&&(0,L.A)(e.modes,(e,s)=>{(0,L.A)(e,(i,n)=>{if((0,ex.A)(i))t.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${s}> at index: <${n}>
3
+ `,type:l.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED});else if((0,O.A)(i,"LONGER_ALT")){let n=(0,ep.A)(i.LONGER_ALT)?i.LONGER_ALT:[i.LONGER_ALT];(0,L.A)(n,n=>{(0,ex.A)(n)||eE(e,n)||t.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${n.name}> on token <${i.name}> outside of mode <${s}>
4
+ `,type:l.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})}})}),t))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{var e,t,i;let n,a,r,o;this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat((e=s,t=this.trackStartLines,i=this.config.lineTerminatorCharacters,n=[],a=!1,r=eq(ts((0,eC.A)((0,S.A)(e.modes))),e=>e[tT]===tW.NA),o=tk(i),t&&(0,L.A)(r,e=>{let t=tO(e,o);if(!1!==t){let s={message:function(e,t){if(t.issue===l.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
5
+ The problem is in the <${e.name}> Token Type
6
+ Root cause: ${t.errMsg}.
7
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(t.issue===l.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
8
+ The problem is in the <${e.name}> Token Type
9
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(e,t),type:t.issue,tokenType:e};n.push(s)}else(0,O.A)(e,"LINE_BREAKS")?!0===e.LINE_BREAKS&&(a=!0):tm(o,e.PATTERN)&&(a=!0)}),t&&!a&&n.push({message:"Warning: No LINE_BREAKS Found.\n This Lexer has been defined to track line and column information,\n But none of the Token Types can be identified as matching a line terminator.\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n for details.",type:l.NO_LINE_BREAKS_FLAGS}),n))})),s.modes=s.modes?s.modes:{},(0,L.A)(s.modes,(e,t)=>{s.modes[t]=eq(e,e=>(0,ex.A)(e))});let n=(0,$.A)(s.modes);if((0,L.A)(s.modes,(e,s)=>{this.TRACE_INIT(`Mode: <${s}> processing`,()=>{if(this.modes.push(s),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{var t,s,i,a,r,o,h,c,d,u;let p,f,m,T,A,E,g,y,S,R,k,I,C,b,v,_,U;this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat((p=[],t=e,A=(0,e2.A)(t,e=>!(0,O.A)(e,tT)),f={errors:(0,N.A)(A,e=>({message:"Token Type: ->"+e.name+"<- missing static 'PATTERN' property",type:l.MISSING_PATTERN,tokenTypes:[e]})),valid:tt(t,A)},p=p.concat(f.errors),s=f.valid,E=(0,e2.A)(s,e=>{let t=e[tT];return!q(t)&&!(0,eZ.A)(t)&&!(0,O.A)(t,"exec")&&!(0,x.A)(t)}),T=(m={errors:(0,N.A)(E,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:l.INVALID_PATTERN,tokenTypes:[e]})),valid:tt(s,E)}).valid,p=(p=(p=(p=(p=p.concat(m.errors)).concat((i=T,g=[],y=(0,e2.A)(i,e=>q(e[tT])),(g=(g=(g=(g=g.concat(function(e){class t extends eV{constructor(){super(...arguments),this.found=!1}visitEndAnchor(e){this.found=!0}}let s=(0,e2.A)(e,e=>{let s=e.PATTERN;try{let e=th(s),i=new t;return i.visit(e),i.found}catch(e){return tg.test(s.source)}});return(0,N.A)(s,e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:l.EOI_ANCHOR_FOUND,tokenTypes:[e]}))}(y))).concat(function(e){class t extends eV{constructor(){super(...arguments),this.found=!1}visitStartAnchor(e){this.found=!0}}let s=(0,e2.A)(e,e=>{let s=e.PATTERN;try{let e=th(s),i=new t;return i.visit(e),i.found}catch(e){return ty.test(s.source)}});return(0,N.A)(s,e=>({message:"Unexpected RegExp Anchor Error:\n Token Type: ->"+e.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.",type:l.SOI_ANCHOR_FOUND,tokenTypes:[e]}))}(y))).concat((a=y,S=(0,e2.A)(a,e=>{let t=e[tT];return t instanceof RegExp&&(t.multiline||t.global)}),(0,N.A)(S,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:l.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[e]}))))).concat((r=y,R=[],k=ts(k=(0,N.A)(r,e=>(0,e1.A)(r,(t,s)=>(e.PATTERN.source!==s.PATTERN.source||eE(R,s)||s.PATTERN===tW.NA||(R.push(s),t.push(s)),t),[]))),I=(0,e2.A)(k,e=>e.length>1),(0,N.A)(I,e=>{let t=(0,N.A)(e,e=>e.name),s=ti(e).PATTERN;return{message:`The same RegExp pattern ->${s}<-has been used in all of the following Token Types: ${t.join(", ")} <-`,type:l.DUPLICATE_PATTERNS_FOUND,tokenTypes:e}})))).concat((o=y,C=(0,e2.A)(o,e=>e.PATTERN.test("")),(0,N.A)(C,e=>({message:"Token Type: ->"+e.name+"<- static 'PATTERN' must not match an empty string",type:l.EMPTY_MATCH_PATTERN,tokenTypes:[e]}))))))).concat((h=T,b=(0,e2.A)(h,e=>{if(!(0,O.A)(e,"GROUP"))return!1;let t=e.GROUP;return t!==tW.SKIPPED&&t!==tW.NA&&!(0,x.A)(t)}),(0,N.A)(b,e=>({message:"Token Type: ->"+e.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:l.INVALID_GROUP_TYPE_FOUND,tokenTypes:[e]}))))).concat((c=T,d=n,v=(0,e2.A)(c,e=>void 0!==e.PUSH_MODE&&!eE(d,e.PUSH_MODE)),(0,N.A)(v,e=>({message:`Token Type: ->${e.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${e.PUSH_MODE}<-which does not exist`,type:l.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[e]}))))).concat((u=T,_=[],U=(0,e1.A)(u,(e,t,s)=>{var i;let n=t.PATTERN;return n===tW.NA||((0,x.A)(n)?e.push({str:n,idx:s,tokenType:t}):q(n)&&(i=n,void 0===(0,tn.A)([".","\\","[","]","|","^","$","(",")","?","*","+","{"],e=>-1!==i.source.indexOf(e)))&&e.push({str:n.source,idx:s,tokenType:t})),e},[]),(0,L.A)(u,(e,t)=>{(0,L.A)(U,({str:s,idx:i,tokenType:n})=>{if(t<i&&function(e,t){if(q(t)){var s;if(s=t,/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(s.source))return!1;let i=t.exec(e);return null!==i&&0===i.index}if((0,eZ.A)(t))return t(e,0,[],{});if((0,O.A)(t,"exec"))return t.exec(e,0,[],{});if("string"==typeof t)return t===e;throw Error("non exhaustive match")}(s,e.PATTERN)){let t=`Token: ->${n.name}<- can never be matched.
10
+ Because it appears AFTER the Token Type ->${e.name}<-in the lexer's definition.
11
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;_.push({message:t,type:l.UNREACHABLE_PATTERN,tokenTypes:[e,n]})}})}),_))))}),(0,R.A)(this.lexerDefinitionErrors)){let i;t$(e),this.TRACE_INIT("analyzeTokenTypes",()=>{var s;let n,a,r,o,l,h,c,d,u,p,f,m,T,A,E,g;s={lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:t.positionTracking,ensureOptimizations:t.ensureOptimizations,safeMode:t.safeMode,tracer:this.TRACE_INIT},(T=(s=(0,eH.A)(s,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(e,t)=>t()})).tracer)("initCharCodeToOptimizedIndexMap",()=>{if((0,R.A)(tC)){tC=Array(65536);for(let e=0;e<65536;e++)tC[e]=e>255?255+~~(e/255):e}}),T("Reject Lexer.NA",()=>{n=eq(e,e=>e[tT]===tW.NA)}),A=!1,T("Transform Patterns",()=>{A=!1,a=(0,N.A)(n,e=>{let t=e[tT];if(q(t)){let e=t.source;return 1!==e.length||"^"===e||"$"===e||"."===e||t.ignoreCase?2!==e.length||"\\"!==e[0]||eE(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],e[1])?tL(t):e[1]:e}if((0,eZ.A)(t))return A=!0,{exec:t};if("object"==typeof t)return A=!0,t;if("string"==typeof t)if(1===t.length)return t;else return tL(new RegExp(t.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")));throw Error("non exhaustive match")})}),T("misc mapping",()=>{r=(0,N.A)(n,e=>e.tokenTypeIdx),o=(0,N.A)(n,e=>{let t=e.GROUP;if(t!==tW.SKIPPED){if((0,x.A)(t))return t;if((0,ex.A)(t))return!1;throw Error("non exhaustive match")}}),l=(0,N.A)(n,e=>{let t=e.LONGER_ALT;if(t)return(0,ep.A)(t)?(0,N.A)(t,e=>e0(n,e)):[e0(n,t)]}),h=(0,N.A)(n,e=>e.PUSH_MODE),c=(0,N.A)(n,e=>(0,O.A)(e,"POP_MODE"))}),T("Line Terminator Handling",()=>{let e=tk(s.lineTerminatorCharacters);d=(0,N.A)(n,e=>!1),"onlyOffset"!==s.positionTracking&&(d=(0,N.A)(n,t=>(0,O.A)(t,"LINE_BREAKS")?!!t.LINE_BREAKS:!1===tO(t,e)&&tm(e,t.PATTERN)))}),T("Misc Mapping #2",()=>{u=(0,N.A)(n,tS),p=(0,N.A)(a,tR),f=(0,e1.A)(n,(e,t)=>{let s=t.GROUP;return(0,x.A)(s)&&s!==tW.SKIPPED&&(e[s]=[]),e},{}),m=(0,N.A)(a,(e,t)=>({pattern:a[t],longerAlt:l[t],canLineTerminator:d[t],isCustom:u[t],short:p[t],group:o[t],push:h[t],pop:c[t],tokenTypeIdx:r[t],tokenType:n[t]}))}),E=!0,g=[],s.safeMode||T("First Char Optimization",()=>{g=(0,e1.A)(n,(e,t,i)=>{if("string"==typeof t.PATTERN)tI(e,tb(t.PATTERN.charCodeAt(0)),m[i]);else if((0,ep.A)(t.START_CHARS_HINT)){let s;(0,L.A)(t.START_CHARS_HINT,t=>{let n=tb("string"==typeof t?t.charCodeAt(0):t);s!==n&&(s=n,tI(e,n,m[i]))})}else if(q(t.PATTERN))if(t.PATTERN.unicode)E=!1,s.ensureOptimizations&&ta(`${td} Unable to analyze < ${t.PATTERN.toString()} > pattern.
12
+ The regexp unicode flag is not currently supported by the regexp-to-ast library.
13
+ This will disable the lexer's first char optimizations.
14
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{let n=function(e,t=!1){try{let t=th(e);return function e(t,s,i){switch(t.type){case"Disjunction":for(let n=0;n<t.value.length;n++)e(t.value[n],s,i);break;case"Alternative":let n=t.value;for(let t=0;t<n.length;t++){let a=n[t];switch(a.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}switch(a.type){case"Character":tu(a.value,s,i);break;case"Set":if(!0===a.complement)throw Error(tc);(0,L.A)(a.value,e=>{if("number"==typeof e)tu(e,s,i);else if(!0===i)for(let t=e.from;t<=e.to;t++)tu(t,s,i);else{for(let t=e.from;t<=e.to&&t<256;t++)tu(t,s,i);if(e.to>=256){let t=e.from>=256?e.from:256,i=e.to,n=tb(t),a=tb(i);for(let e=n;e<=a;e++)s[e]=e}}});break;case"Group":e(a.value,s,i);break;default:throw Error("Non Exhaustive Match")}let r=void 0!==a.quantifier&&0===a.quantifier.atLeast;if("Group"===a.type&&!1===function e(t){let s=t.quantifier;return!!s&&0===s.atLeast||!!t.value&&((0,ep.A)(t.value)?eL(t.value,e):e(t.value))}(a)||"Group"!==a.type&&!1===r)break}break;default:throw Error("non exhaustive match!")}return(0,S.A)(s)}(t.value,{},t.flags.ignoreCase)}catch(s){if(s.message===tc)t&&tr(`${td} Unable to optimize: < ${e.toString()} >
15
+ Complement Sets cannot be automatically optimized.
16
+ This will disable the lexer's first char optimizations.
17
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let s="";t&&(s="\n This will disable the lexer's first char optimizations.\n See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),ta(`${td}
18
+ Failed parsing: < ${e.toString()} >
19
+ Using the @chevrotain/regexp-to-ast library
20
+ Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+s)}}return[]}(t.PATTERN,s.ensureOptimizations);(0,R.A)(n)&&(E=!1),(0,L.A)(n,t=>{tI(e,t,m[i])})}else s.ensureOptimizations&&ta(`${td} TokenType: <${t.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
21
+ This will disable the lexer's first char optimizations.
22
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return e},[])}),i={emptyGroups:f,patternIdxToConfig:m,charCodeToPatternIdxToConfig:g,hasCustom:A,canBeOptimized:E}}),this.patternIdxToConfig[s]=i.patternIdxToConfig,this.charCodeToPatternIdxToConfig[s]=i.charCodeToPatternIdxToConfig,this.emptyGroups=F({},this.emptyGroups,i.emptyGroups),this.hasCustom=i.hasCustom||this.hasCustom,this.canModeBeOptimized[s]=i.canBeOptimized}})}),this.defaultMode=s.defaultMode,!(0,R.A)(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling)throw Error("Errors detected in definition of Lexer:\n"+(0,N.A)(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n"));(0,L.A)(this.lexerDefinitionWarning,e=>{tr(e.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=tv.A),!1===this.trackStartLines&&(this.computeNewColumn=t_.A),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=tv.A),/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=(0,e1.A)(this.canModeBeOptimized,(e,t,s)=>(!1===t&&e.push(s),e),[]);if(t.ensureOptimizations&&!(0,R.A)(e))throw Error(`Lexer Modes: < ${e.join(", ")} > cannot be optimized.
23
+ Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
24
+ Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{to={}}),this.TRACE_INIT("toFastProperties",()=>{C(this)})})}tokenize(e,t=this.defaultMode){if(!(0,R.A)(this.lexerDefinitionErrors))throw Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+(0,N.A)(this.lexerDefinitionErrors,e=>e.message).join("-----------------------\n"));return this.tokenizeInternal(e,t)}tokenizeInternal(e,t){var s;let i,n,a,r,o,l,h,c,d,u,p,f,m,T,A,E,g,y,S=e.length,R=0,N=0,O=Array(this.hasCustom?0:Math.floor(e.length/10)),k=[],I=this.trackStartLines?1:void 0,C=this.trackStartLines?1:void 0,b=(s=this.emptyGroups,g={},y=(0,$.A)(s),(0,L.A)(y,e=>{let t=s[e];if((0,ep.A)(t))g[e]=[];else throw Error("non exhaustive match")}),g),v=this.trackStartLines,_=this.config.lineTerminatorsPattern,x=0,U=[],M=[],w=[],P=[];Object.freeze(P);let D=!1,K=e=>{if(1===w.length&&void 0===e.tokenType.PUSH_MODE){let t=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(e);k.push({offset:e.startOffset,line:e.startLine,column:e.startColumn,length:e.image.length,message:t})}else{w.pop();let e=(0,tx.A)(w);U=this.patternIdxToConfig[e],M=this.charCodeToPatternIdxToConfig[e],x=U.length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;D=!!M&&!!t}};function F(e){w.push(e),M=this.charCodeToPatternIdxToConfig[e],x=(U=this.patternIdxToConfig[e]).length,x=U.length;let t=this.canModeBeOptimized[e]&&!1===this.config.safeMode;D=!!M&&!!t}F.call(this,t);let B=this.config.recoveryEnabled;for(;R<S;){let t;l=null,d=-1;let s=e.charCodeAt(R);if(D){let e=M[tb(s)];t=void 0!==e?e:P}else t=U;let g=t.length;for(i=0;i<g;i++){let n=(E=t[i]).pattern;h=null;let u=E.short;if(!1!==u?s===u&&(d=1,l=n):!0===E.isCustom?null!==(A=n.exec(e,R,O,b))?(d=(l=A[0]).length,void 0!==A.payload&&(h=A.payload)):l=null:(n.lastIndex=R,d=this.matchLength(n,e,R)),-1!==d){if(void 0!==(o=E.longerAlt)){l=e.substring(R,R+d);let t=o.length;for(a=0;a<t;a++){let t=U[o[a]],s=t.pattern;if(c=null,!0===t.isCustom?null!==(A=s.exec(e,R,O,b))?(r=A[0],void 0!==A.payload&&(c=A.payload)):r=null:(s.lastIndex=R,r=this.match(s,e,R)),r&&r.length>l.length){l=r,d=r.length,h=c,E=t;break}}}break}}if(-1!==d){if(void 0!==(u=E.group)&&(l=null!==l?l:e.substring(R,R+d),p=E.tokenTypeIdx,f=this.createTokenInstance(l,R,p,E.tokenType,I,C,d),this.handlePayload(f,h),!1===u?N=this.addToken(O,N,f):b[u].push(f)),!0===v&&!0===E.canLineTerminator){let t,s,i=0;_.lastIndex=0;do l=null!==l?l:e.substring(R,R+d),!0===(t=_.test(l))&&(s=_.lastIndex-1,i++);while(!0===t);0!==i?(I+=i,C=d-s,this.updateTokenEndLineColumnLocation(f,u,s,i,I,C,d)):C=this.computeNewColumn(C,d)}else C=this.computeNewColumn(C,d);R+=d,this.handleModes(E,K,F,f)}else{let t=R,s=I,i=C,a=!1===B;for(;!1===a&&R<S;)for(R++,n=0;n<x;n++){let t=U[n],s=t.pattern,i=t.short;if(!1!==i?e.charCodeAt(R)===i&&(a=!0):!0===t.isCustom?a=null!==s.exec(e,R,O,b):(s.lastIndex=R,a=null!==s.exec(e)),!0===a)break}if(m=R-t,C=this.computeNewColumn(C,m),T=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(e,t,m,s,i,(0,tx.A)(w)),k.push({offset:t,line:s,column:i,length:m,message:T}),!1===B)break}}return this.hasCustom||(O.length=N),{tokens:O,groups:b,errors:k}}handleModes(e,t,s,i){if(!0===e.pop){let n=e.push;t(i),void 0!==n&&s.call(this,n)}else void 0!==e.push&&s.call(this,e.push)}updateTokenEndLineColumnLocation(e,t,s,i,n,a,r){let o,l;void 0!==t&&(l=(o=s===r-1)?-1:0,(1!==i||!0!==o)&&(e.endLine=n+l,e.endColumn=a-1+-l))}computeNewColumn(e,t){return e+t}createOffsetOnlyToken(e,t,s,i){return{image:e,startOffset:t,tokenTypeIdx:s,tokenType:i}}createStartOnlyToken(e,t,s,i,n,a){return{image:e,startOffset:t,startLine:n,startColumn:a,tokenTypeIdx:s,tokenType:i}}createFullToken(e,t,s,i,n,a,r){return{image:e,startOffset:t,endOffset:t+r-1,startLine:n,endLine:n,startColumn:a,endColumn:a+r-1,tokenTypeIdx:s,tokenType:i}}addTokenUsingPush(e,t,s){return e.push(s),t}addTokenUsingMemberAccess(e,t,s){return e[t]=s,++t}handlePayloadNoCustom(e,t){}handlePayloadWithCustom(e,t){null!==t&&(e.payload=t)}match(e,t,s){return!0===e.test(t)?t.substring(s,e.lastIndex):null}matchLength(e,t,s){return!0===e.test(t)?e.lastIndex-s:-1}}function tj(e){return tz(e)?e.LABEL:e.name}function tz(e){return(0,x.A)(e.LABEL)&&""!==e.LABEL}tW.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.",tW.NA=/NOT_APPLICABLE/;let tV="categories",tH="label",tY="group",tX="push_mode",tJ="pop_mode",tq="longer_alt",tZ="line_breaks",tQ="start_chars_hint";function t0(e){let t=e.pattern,s={};if(s.name=e.name,(0,ex.A)(t)||(s.PATTERN=t),(0,O.A)(e,"parent"))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";return(0,O.A)(e,tV)&&(s.CATEGORIES=e[tV]),t$([s]),(0,O.A)(e,tH)&&(s.LABEL=e[tH]),(0,O.A)(e,tY)&&(s.GROUP=e[tY]),(0,O.A)(e,tJ)&&(s.POP_MODE=e[tJ]),(0,O.A)(e,tX)&&(s.PUSH_MODE=e[tX]),(0,O.A)(e,tq)&&(s.LONGER_ALT=e[tq]),(0,O.A)(e,tZ)&&(s.LINE_BREAKS=e[tZ]),(0,O.A)(e,tQ)&&(s.START_CHARS_HINT=e[tQ]),s}let t1=t0({name:"EOF",pattern:tW.NA});function t2(e,t,s,i,n,a,r,o){return{image:t,startOffset:s,endOffset:i,startLine:n,endLine:a,startColumn:r,endColumn:o,tokenTypeIdx:e.tokenTypeIdx,tokenType:e}}t$([t1]);let t6={buildMismatchTokenMessage({expected:e,actual:t,previous:s,ruleName:i}){let n=tz(e)?`--> ${tj(e)} <--`:`token of type --> ${e.name} <--`;return`Expecting ${n} but found --> '${t.image}' <--`},buildNotAllInputParsedMessage:({firstRedundant:e,ruleName:t})=>"Redundant input, expecting EOF but found: "+e.image,buildNoViableAltMessage({expectedPathsPerAlt:e,actual:t,previous:s,customUserDescription:i,ruleName:n}){let a="Expecting: ",r="\nbut found: '"+ti(t).image+"'";if(i)return a+i+r;{let t=(0,e1.A)(e,(e,t)=>e.concat(t),[]),s=(0,N.A)(t,e=>`[${(0,N.A)(e,e=>tj(e)).join(", ")}]`),i=(0,N.A)(s,(e,t)=>` ${t+1}. ${e}`);return a+`one of these possible Token sequences:
25
+ ${i.join("\n")}`+r}},buildEarlyExitMessage({expectedIterationPaths:e,actual:t,customUserDescription:s,ruleName:i}){let n="Expecting: ",a="\nbut found: '"+ti(t).image+"'";if(s)return n+s+a;{let t=(0,N.A)(e,e=>`[${(0,N.A)(e,e=>tj(e)).join(",")}]`);return n+`expecting at least one iteration which starts with one of these possible Token sequences::
26
+ <${t.join(" ,")}>`+a}}};Object.freeze(t6);let t5={buildRuleNotFoundError:(e,t)=>"Invalid grammar, reference to a rule which is not defined: ->"+t.nonTerminalName+"<-\ninside top level rule: ->"+e.name+"<-"},t4={buildDuplicateFoundError(e,t){let s=e.name,i=ti(t),n=i.idx,a=eR(i),r=i instanceof el?i.terminalType.name:i instanceof Q?i.nonTerminalName:"",o=`->${a}${n>0?n:""}<- ${r?`with argument: ->${r}<-`:""}
27
+ appears more than once (${t.length} times) in the top level rule: ->${s}<-.
28
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
29
+ `;return(o=o.replace(/[ \t]+/g," ")).replace(/\s\s+/g,"\n")},buildNamespaceConflictError:e=>`Namespace conflict found in grammar.
30
+ The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${e.name}>.
31
+ To resolve this make sure each Terminal and Non-Terminal names are unique
32
+ This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
33
+ and Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(e){let t=(0,N.A)(e.prefixPath,e=>tj(e)).join(", "),s=0===e.alternation.idx?"":e.alternation.idx;return`Ambiguous alternatives: <${e.ambiguityIndices.join(" ,")}> due to common lookahead prefix
34
+ in <OR${s}> inside <${e.topLevelRule.name}> Rule,
35
+ <${t}> may appears as a prefix path in all these alternatives.
36
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
37
+ For Further details.`},buildAlternationAmbiguityError(e){let t=0===e.alternation.idx?"":e.alternation.idx,s=0===e.prefixPath.length,i=`Ambiguous Alternatives Detected: <${e.ambiguityIndices.join(" ,")}> in <OR${t}> inside <${e.topLevelRule.name}> Rule,
38
+ `;if(s)i+=`These alternatives are all empty (match no tokens), making them indistinguishable.
39
+ Only the last alternative may be empty.
40
+ `;else{let t=(0,N.A)(e.prefixPath,e=>tj(e)).join(", ");i+=`<${t}> may appears as a prefix path in all these alternatives.
41
+ `}return i+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
42
+ For Further details.`},buildEmptyRepetitionError(e){let t=eR(e.repetition);return 0!==e.repetition.idx&&(t+=e.repetition.idx),`The repetition <${t}> within Rule <${e.topLevelRule.name}> can never consume any tokens.
43
+ This could lead to an infinite loop.`},buildTokenNameError:e=>"deprecated",buildEmptyAlternationError:e=>`Ambiguous empty alternative: <${e.emptyChoiceIdx+1}> in <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
44
+ Only the last alternative may be an empty alternative.`,buildTooManyAlternativesError:e=>`An Alternation cannot have more than 256 alternatives:
45
+ <OR${e.alternation.idx}> inside <${e.topLevelRule.name}> Rule.
46
+ has ${e.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(e){let t=e.topLevelRule.name,s=(0,N.A)(e.leftRecursionPath,e=>e.name),i=`${t} --> ${s.concat([t]).join(" --\x3e ")}`;return`Left Recursion found in grammar.
47
+ rule: <${t}> can be invoked from itself (directly or indirectly)
48
+ without consuming any Tokens. The grammar path that causes this is:
49
+ ${i}
50
+ To fix this refactor your grammar to remove the left recursion.
51
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:e=>"deprecated",buildDuplicateRuleNameError(e){let t;return t=e.topLevelRule instanceof ee?e.topLevelRule.name:e.topLevelRule,`Duplicate definition, rule: ->${t}<- is already defined in the grammar: ->${e.grammarName}<-`}};class t3 extends eh{constructor(e,t){super(),this.nameToTopRule=e,this.errMsgProvider=t,this.errors=[]}resolveRefs(){(0,L.A)((0,S.A)(this.nameToTopRule),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:d.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}let t9=function(e,t){return(0,e8.A)((0,N.A)(e,t),1)};var t8=s(96526);let t7=function(e,t,s,i){for(var n=-1,a=null==e?0:e.length;++n<a;){var r=e[n];t(i,r,s(r),e)}return i},se=function(e,t,s,i){return(0,ed.A)(e,function(e,n,a){t(i,e,s(e),a)}),i};var st=Object.prototype.hasOwnProperty,ss=(n=function(e,t,s){st.call(e,s)?e[s].push(t):(0,t8.A)(e,s,[t])},function(e,t){return((0,ep.A)(e)?t7:se)(e,n,(0,G.A)(t,2),{})});let si=function(e,t,s){var i=null==e?0:e.length;return i?b(e,0,(t=i-(t=s||void 0===t?1:(0,v.A)(t)))<0?0:t):[]};class sn extends eN{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=I(this.path.ruleStack).reverse(),this.occurrenceStack=I(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,t=[]){this.found||super.walk(e,t)}walkProdRef(e,t,s){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){let i=t.concat(s);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){(0,R.A)(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class sa extends sn{constructor(e,t){super(e,t),this.path=t,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,t,s){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){let e=new et({definition:t.concat(s)});this.possibleTokTypes=eb(e),this.found=!0}}}class sr extends eN{constructor(e,t){super(),this.topRule=e,this.occurrence=t,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class so extends sr{walkMany(e,t,s){if(e.idx===this.occurrence){let e=ti(t.concat(s));this.result.isEndOfRule=void 0===e,e instanceof el&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkMany(e,t,s)}}class sl extends sr{walkManySep(e,t,s){if(e.idx===this.occurrence){let e=ti(t.concat(s));this.result.isEndOfRule=void 0===e,e instanceof el&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkManySep(e,t,s)}}class sh extends sr{walkAtLeastOne(e,t,s){if(e.idx===this.occurrence){let e=ti(t.concat(s));this.result.isEndOfRule=void 0===e,e instanceof el&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOne(e,t,s)}}class sc extends sr{walkAtLeastOneSep(e,t,s){if(e.idx===this.occurrence){let e=ti(t.concat(s));this.result.isEndOfRule=void 0===e,e instanceof el&&(this.result.token=e.terminalType,this.result.occurrence=e.idx)}else super.walkAtLeastOneSep(e,t,s)}}function sd(e,t,s=[]){s=I(s);let i=[],n=0;function a(a){let r=sd(a.concat(_(e,n+1)),t,s);return i.concat(r)}for(;s.length<t&&n<e.length;){let t=e[n];if(t instanceof et)return a(t.definition);if(t instanceof Q)return a(t.definition);if(t instanceof es)i=a(t.definition);else if(t instanceof ei)return a(t.definition.concat([new ea({definition:t.definition})]));else if(t instanceof en)return a([new et({definition:t.definition}),new ea({definition:[new el({terminalType:t.separator})].concat(t.definition)})]);else if(t instanceof er)i=a(t.definition.concat([new ea({definition:[new el({terminalType:t.separator})].concat(t.definition)})]));else if(t instanceof ea)i=a(t.definition.concat([new ea({definition:t.definition})]));else if(t instanceof eo)return(0,L.A)(t.definition,e=>{!1===(0,R.A)(e.definition)&&(i=a(e.definition))}),i;else if(t instanceof el)s.push(t.terminalType);else throw Error("non exhaustive match");n++}return i.push({partialPath:s,suffixDef:_(e,n)}),i}function su(e,t,s,i){let n="EXIT_NONE_TERMINAL",a=[n],r="EXIT_ALTERNATIVE",o=!1,l=t.length,h=l-i-1,c=[],d=[];for(d.push({idx:-1,def:e,ruleStack:[],occurrenceStack:[]});!(0,R.A)(d);){let e=d.pop();if(e===r){o&&(0,tx.A)(d).idx<=h&&d.pop();continue}let i=e.def,u=e.idx,p=e.ruleStack,f=e.occurrenceStack;if((0,R.A)(i))continue;let m=i[0];if(m===n){let e={idx:u,def:_(i),ruleStack:si(p),occurrenceStack:si(f)};d.push(e)}else if(m instanceof el)if(u<l-1){let e=u+1;if(s(t[e],m.terminalType)){let t={idx:e,def:_(i),ruleStack:p,occurrenceStack:f};d.push(t)}}else if(u===l-1)c.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:p,occurrenceStack:f}),o=!0;else throw Error("non exhaustive match");else if(m instanceof Q){let e=I(p);e.push(m.nonTerminalName);let t=I(f);t.push(m.idx);let s={idx:u,def:m.definition.concat(a,_(i)),ruleStack:e,occurrenceStack:t};d.push(s)}else if(m instanceof es){let e={idx:u,def:_(i),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t={idx:u,def:m.definition.concat(_(i)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof ei){let e=new ea({definition:m.definition,idx:m.idx}),t={idx:u,def:m.definition.concat([e],_(i)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof en){let e=new ea({definition:[new el({terminalType:m.separator})].concat(m.definition),idx:m.idx}),t={idx:u,def:m.definition.concat([e],_(i)),ruleStack:p,occurrenceStack:f};d.push(t)}else if(m instanceof er){let e={idx:u,def:_(i),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t=new ea({definition:[new el({terminalType:m.separator})].concat(m.definition),idx:m.idx}),s={idx:u,def:m.definition.concat([t],_(i)),ruleStack:p,occurrenceStack:f};d.push(s)}else if(m instanceof ea){let e={idx:u,def:_(i),ruleStack:p,occurrenceStack:f};d.push(e),d.push(r);let t=new ea({definition:m.definition,idx:m.idx}),s={idx:u,def:m.definition.concat([t],_(i)),ruleStack:p,occurrenceStack:f};d.push(s)}else if(m instanceof eo)for(let e=m.definition.length-1;e>=0;e--){let t={idx:u,def:m.definition[e].definition.concat(_(i)),ruleStack:p,occurrenceStack:f};d.push(t),d.push(r)}else if(m instanceof et)d.push({idx:u,def:m.definition.concat(_(i)),ruleStack:p,occurrenceStack:f});else if(m instanceof ee)d.push(function(e,t,s,i){let n=I(s);n.push(e.name);let a=I(i);return a.push(1),{idx:t,def:e.definition,ruleStack:n,occurrenceStack:a}}(m,u,p,f));else throw Error("non exhaustive match")}return c}function sp(e){if(e instanceof es||"Option"===e)return h.OPTION;if(e instanceof ea||"Repetition"===e)return h.REPETITION;if(e instanceof ei||"RepetitionMandatory"===e)return h.REPETITION_MANDATORY;if(e instanceof en||"RepetitionMandatoryWithSeparator"===e)return h.REPETITION_MANDATORY_WITH_SEPARATOR;if(e instanceof er||"RepetitionWithSeparator"===e)return h.REPETITION_WITH_SEPARATOR;else if(e instanceof eo||"Alternation"===e)return h.ALTERNATION;else throw Error("non exhaustive match")}function sf(e,t,s,i){let n=e.length,a=eL(e,e=>eL(e,e=>1===e.length));if(t)return function(t){let i=(0,N.A)(t,e=>e.GATE);for(let t=0;t<n;t++){let n=e[t],a=n.length,r=i[t];if(void 0===r||!1!==r.call(this))t:for(let e=0;e<a;e++){let i=n[e],a=i.length;for(let e=0;e<a;e++)if(!1===s(this.LA(e+1),i[e]))continue t;return t}}};if(!a||i)return function(){for(let t=0;t<n;t++){let i=e[t],n=i.length;t:for(let e=0;e<n;e++){let n=i[e],a=n.length;for(let e=0;e<a;e++)if(!1===s(this.LA(e+1),n[e]))continue t;return t}}};{let t=(0,N.A)(e,e=>(0,eC.A)(e)),s=(0,e1.A)(t,(e,t,s)=>((0,L.A)(t,t=>{(0,O.A)(e,t.tokenTypeIdx)||(e[t.tokenTypeIdx]=s),(0,L.A)(t.categoryMatches,t=>{(0,O.A)(e,t)||(e[t]=s)})}),e),{});return function(){return s[this.LA(1).tokenTypeIdx]}}}function sm(e,t,s){let i=eL(e,e=>1===e.length),n=e.length;if(!i||s)return function(){t:for(let s=0;s<n;s++){let i=e[s],n=i.length;for(let e=0;e<n;e++)if(!1===t(this.LA(e+1),i[e]))continue t;return!0}return!1};{let t=(0,eC.A)(e);if(1===t.length&&(0,R.A)(t[0].categoryMatches)){let e=t[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===e}}{let e=(0,e1.A)(t,(e,t,s)=>(e[t.tokenTypeIdx]=!0,(0,L.A)(t.categoryMatches,t=>{e[t]=!0}),e),[]);return function(){return!0===e[this.LA(1).tokenTypeIdx]}}}}(a=h||(h={}))[a.OPTION=0]="OPTION",a[a.REPETITION=1]="REPETITION",a[a.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",a[a.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",a[a.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",a[a.ALTERNATION=5]="ALTERNATION";class sT extends eN{constructor(e,t,s){super(),this.topProd=e,this.targetOccurrence=t,this.targetProdType=s}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,t,s,i){return e.idx===this.targetOccurrence&&this.targetProdType===t&&(this.restDef=s.concat(i),!0)}walkOption(e,t,s){this.checkIsTarget(e,h.OPTION,t,s)||super.walkOption(e,t,s)}walkAtLeastOne(e,t,s){this.checkIsTarget(e,h.REPETITION_MANDATORY,t,s)||super.walkOption(e,t,s)}walkAtLeastOneSep(e,t,s){this.checkIsTarget(e,h.REPETITION_MANDATORY_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}walkMany(e,t,s){this.checkIsTarget(e,h.REPETITION,t,s)||super.walkOption(e,t,s)}walkManySep(e,t,s){this.checkIsTarget(e,h.REPETITION_WITH_SEPARATOR,t,s)||super.walkOption(e,t,s)}}class sA extends eh{constructor(e,t,s){super(),this.targetOccurrence=e,this.targetProdType=t,this.targetRef=s,this.result=[]}checkIsTarget(e,t){e.idx===this.targetOccurrence&&this.targetProdType===t&&(void 0===this.targetRef||e===this.targetRef)&&(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,h.OPTION)}visitRepetition(e){this.checkIsTarget(e,h.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,h.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,h.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,h.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,h.ALTERNATION)}}function sE(e){let t=Array(e);for(let s=0;s<e;s++)t[s]=[];return t}function sg(e){let t=[""];for(let s=0;s<e.length;s++){let i=e[s],n=[];for(let e=0;e<t.length;e++){let s=t[e];n.push(s+"_"+i.tokenTypeIdx);for(let e=0;e<i.categoryMatches.length;e++){let t="_"+i.categoryMatches[e];n.push(s+t)}}t=n}return t}function sy(e,t){let s=(0,N.A)(e,e=>sd([e],1)),i=sE(s.length),n=(0,N.A)(s,e=>{let t={};return(0,L.A)(e,e=>{let s=sg(e.partialPath);(0,L.A)(s,e=>{t[e]=!0})}),t}),a=s;for(let e=1;e<=t;e++){let s=a;a=sE(s.length);for(let r=0;r<s.length;r++){let o=s[r];for(let s=0;s<o.length;s++){let l=o[s].partialPath,h=o[s].suffixDef,c=sg(l);if(function(e,t,s){for(let i=0;i<e.length;i++){if(i===s)continue;let n=e[i];for(let e=0;e<t.length;e++)if(!0===n[t[e]])return!1}return!0}(n,c,r)||(0,R.A)(h)||l.length===t){let e=i[r];if(!1===sR(e,l)){e.push(l);for(let e=0;e<c.length;e++){let t=c[e];n[r][t]=!0}}}else{let t=sd(h,e+1,l);a[r]=a[r].concat(t),(0,L.A)(t,e=>{let t=sg(e.partialPath);(0,L.A)(t,e=>{n[r][e]=!0})})}}}}return i}function sL(e,t,s,i){let n=new sA(e,h.ALTERNATION,i);return t.accept(n),sy(n.result,s)}function sS(e,t,s,i){let n=new sA(e,s);t.accept(n);let a=n.result,r=new sT(t,e,s).startWalking();return sy([new et({definition:a}),new et({definition:r})],i)}function sR(e,t){s:for(let s=0;s<e.length;s++){let i=e[s];if(i.length===t.length){for(let e=0;e<i.length;e++){let s=t[e],n=i[e];if(!1==(s===n||void 0!==n.categoryMatchesMap[s.tokenTypeIdx]))continue s}return!0}}return!1}function sN(e){return eL(e,e=>eL(e,e=>eL(e,e=>(0,R.A)(e.categoryMatches))))}function sO(e){return`${eR(e)}_#_${e.idx}_#_${sk(e)}`}function sk(e){return e instanceof el?e.terminalType.name:e instanceof Q?e.nonTerminalName:""}class sI extends eh{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}class sC extends eh{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}class sb extends eh{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}let sv="MismatchedTokenException",s_="NoViableAltException",sx="EarlyExitException",sU="NotAllInputParsedException",sM=[sv,s_,sx,sU];function sw(e){return eE(sM,e.name)}Object.freeze(sM);class sP extends Error{constructor(e,t){super(e),this.token=t,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class sD extends sP{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=sv}}class s$ extends sP{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=s_}}class sK extends sP{constructor(e,t){super(e,t),this.name=sU}}class sF extends sP{constructor(e,t,s){super(e,t),this.previousToken=s,this.name=sx}}let sB={},sG="InRuleRecoveryException";class sW extends Error{constructor(e){super(e),this.name=sG}}class sj{initRecoverable(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=(0,O.A)(e,"recoveryEnabled")?e.recoveryEnabled:ih.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=sz)}getTokenToInsert(e){let t=t2(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return t.isInsertedInRecovery=!0,t}canTokenTypeBeInsertedInRecovery(e){return!0}canTokenTypeBeDeletedInRecovery(e){return!0}tryInRepetitionRecovery(e,t,s,i){let n=this.findReSyncTokenType(),a=this.exportLexerState(),r=[],o=!1,l=this.LA(1),h=this.LA(1),c=()=>{let e=this.LA(0),t=new sD(this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:l,previous:e,ruleName:this.getCurrRuleFullName()}),l,this.LA(0));t.resyncedTokens=si(r),this.SAVE_ERROR(t)};for(;!o;)if(this.tokenMatcher(h,i))return void c();else if(s.call(this)){c(),e.apply(this,t);return}else this.tokenMatcher(h,n)?o=!0:(h=this.SKIP_TOKEN(),this.addToResyncTokens(h,r));this.importLexerState(a)}shouldInRepetitionRecoveryBeTried(e,t,s){return!(!1===s||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,t)))}getFollowsForInRuleRecovery(e,t){let s=this.getCurrentGrammarPath(e,t);return this.getNextPossibleTokenTypes(s)}tryInRuleRecovery(e,t){if(this.canRecoverWithSingleTokenInsertion(e,t))return this.getTokenToInsert(e);if(this.canRecoverWithSingleTokenDeletion(e)){let e=this.SKIP_TOKEN();return this.consumeToken(),e}throw new sW("sad sad panda")}canPerformInRuleRecovery(e,t){return this.canRecoverWithSingleTokenInsertion(e,t)||this.canRecoverWithSingleTokenDeletion(e)}canRecoverWithSingleTokenInsertion(e,t){if(!this.canTokenTypeBeInsertedInRecovery(e)||(0,R.A)(t))return!1;let s=this.LA(1);return void 0!==(0,tn.A)(t,e=>this.tokenMatcher(s,e))}canRecoverWithSingleTokenDeletion(e){return!!this.canTokenTypeBeDeletedInRecovery(e)&&this.tokenMatcher(this.LA(2),e)}isInCurrentRuleReSyncSet(e){let t=this.getCurrFollowKey();return eE(this.getFollowSetFromFollowKey(t),e)}findReSyncTokenType(){let e=this.flattenFollowSet(),t=this.LA(1),s=2;for(;;){let i=(0,tn.A)(e,e=>tM(t,e));if(void 0!==i)return i;t=this.LA(s),s++}}getCurrFollowKey(){if(1===this.RULE_STACK.length)return sB;let e=this.getLastExplicitRuleShortName(),t=this.getLastExplicitRuleOccurrenceIndex(),s=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:t,inRule:this.shortRuleNameToFullName(s)}}buildFullFollowKeyStack(){let e=this.RULE_STACK,t=this.RULE_OCCURRENCE_STACK;return(0,N.A)(e,(s,i)=>0===i?sB:{ruleName:this.shortRuleNameToFullName(s),idxInCallingRule:t[i],inRule:this.shortRuleNameToFullName(e[i-1])})}flattenFollowSet(){let e=(0,N.A)(this.buildFullFollowKeyStack(),e=>this.getFollowSetFromFollowKey(e));return(0,eC.A)(e)}getFollowSetFromFollowKey(e){if(e===sB)return[t1];let t=e.ruleName+e.idxInCallingRule+ev+e.inRule;return this.resyncFollows[t]}addToResyncTokens(e,t){return this.tokenMatcher(e,t1)||t.push(e),t}reSyncTo(e){let t=[],s=this.LA(1);for(;!1===this.tokenMatcher(s,e);)s=this.SKIP_TOKEN(),this.addToResyncTokens(s,t);return si(t)}attemptInRepetitionRecovery(e,t,s,i,n,a,r){}getCurrentGrammarPath(e,t){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:I(this.RULE_OCCURRENCE_STACK),lastTok:e,lastTokOccurrence:t}}getHumanReadableRuleStack(){return(0,N.A)(this.RULE_STACK,e=>this.shortRuleNameToFullName(e))}}function sz(e,t,s,i,n,a,r){let o=this.getKeyForAutomaticLookahead(i,n),l=this.firstAfterRepMap[o];if(void 0===l){let e=this.getCurrRuleFullName();l=new a(this.getGAstProductions()[e],n).startWalking(),this.firstAfterRepMap[o]=l}let h=l.token,c=l.occurrence,d=l.isEndOfRule;1===this.RULE_STACK.length&&d&&void 0===h&&(h=t1,c=1),void 0!==h&&void 0!==c&&this.shouldInRepetitionRecoveryBeTried(h,c,r)&&this.tryInRepetitionRecovery(e,t,s,h)}class sV{constructor(e){var t;this.maxLookahead=null!=(t=null==e?void 0:e.maxLookahead)?t:ih.maxLookahead}validate(e){let t=this.validateNoLeftRecursion(e.rules);return(0,R.A)(t)?[...t,...this.validateEmptyOrAlternatives(e.rules),...this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),...this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead)]:t}validateNoLeftRecursion(e){return t9(e,e=>(function e(t,s,i,n=[]){let a=[],r=function e(t){let s=[];if((0,R.A)(t))return s;let i=ti(t);if(i instanceof Q)s.push(i.referencedRule);else if(i instanceof et||i instanceof es||i instanceof ei||i instanceof en||i instanceof er||i instanceof ea)s=s.concat(e(i.definition));else if(i instanceof eo)s=(0,eC.A)((0,N.A)(i.definition,t=>e(t.definition)));else if(i instanceof el);else throw Error("non exhaustive match");let n=eS(i),a=t.length>1;if(!n||!a)return s;{let i=_(t);return s.concat(e(i))}}(s.definition);if((0,R.A)(r))return[];{let s=t.name;eE(r,t)&&a.push({message:i.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:d.LEFT_RECURSION,ruleName:s});let o=t9(tt(r,n.concat([t])),s=>{let a=I(n);return a.push(s),e(t,s,i,a)});return a.concat(o)}})(e,e,t4))}validateEmptyOrAlternatives(e){return t9(e,e=>{let t;return t=new sC,e.accept(t),t9(t.alternations,t=>t9(si(t.definition),(s,i)=>{let n=su([s],[],tM,1);return(0,R.A)(n)?[{message:t4.buildEmptyAlternationError({topLevelRule:e,alternation:t,emptyChoiceIdx:i}),type:d.NONE_LAST_EMPTY_ALT,ruleName:e.name,occurrence:t.idx,alternative:i+1}]:[]}))})}validateAmbiguousAlternationAlternatives(e,t){return t9(e,e=>{let s;return s=new sC,e.accept(s),t9(eq(s.alternations,e=>!0===e.ignoreAmbiguities),s=>{var i,n,a,r,o,l,h,c;let u,p,f,m=sL(s.idx,e,s.maxLookahead||t,s),T=(i=m,n=s,a=e,r=t4,u=[],p=(0,e1.A)(i,(e,t,s)=>(!0===n.definition[s].ignoreAmbiguities||(0,L.A)(t,t=>{let a=[s];(0,L.A)(i,(e,i)=>{s!==i&&sR(e,t)&&!0!==n.definition[i].ignoreAmbiguities&&a.push(i)}),a.length>1&&!sR(u,t)&&(u.push(t),e.push({alts:a,path:t}))}),e),[]),(0,N.A)(p,e=>{let t=(0,N.A)(e.alts,e=>e+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:a,alternation:n,ambiguityIndices:t,prefixPath:e.path}),type:d.AMBIGUOUS_ALTS,ruleName:a.name,occurrence:n.idx,alternatives:e.alts}})),A=(o=m,l=s,h=e,c=t4,ts(t9(f=(0,e1.A)(o,(e,t,s)=>{let i=(0,N.A)(t,e=>({idx:s,path:e}));return e.concat(i)},[]),e=>{if(!0===l.definition[e.idx].ignoreAmbiguities)return[];let t=e.idx,s=e.path,i=(0,e2.A)(f,e=>{var i;return!0!==l.definition[e.idx].ignoreAmbiguities&&e.idx<t&&(i=e.path,i.length<s.length&&eL(i,(e,t)=>{let i=s[t];return e===i||i.categoryMatchesMap[e.tokenTypeIdx]}))});return(0,N.A)(i,e=>{let s=[e.idx+1,t+1],i=0===l.idx?"":l.idx;return{message:c.buildAlternationPrefixAmbiguityError({topLevelRule:h,alternation:l,ambiguityIndices:s,prefixPath:e.path}),type:d.AMBIGUOUS_PREFIX_ALTS,ruleName:h.name,occurrence:i,alternatives:s}})})));return T.concat(A)})})}validateSomeNonEmptyLookaheadPath(e,t){let s;return s=[],(0,L.A)(e,e=>{let i=new sb;e.accept(i);let n=i.allProductions;(0,L.A)(n,i=>{let n=sp(i),a=i.maxLookahead||t,r=sS(i.idx,e,n,a)[0];if((0,R.A)((0,eC.A)(r))){let t=t4.buildEmptyRepetitionError({topLevelRule:e,repetition:i});s.push({message:t,type:d.NO_NON_EMPTY_LOOKAHEAD,ruleName:e.name})}})}),s}buildLookaheadForAlternation(e){var t,s,i,n,a;let r,o;return t=e.prodOccurrence,s=e.rule,i=e.maxLookahead,n=e.hasPredicates,a=e.dynamicTokensEnabled,o=sN(r=sL(t,s,i))?tw:tM,sf(r,n,o,a)}buildLookaheadForOptional(e){var t,s,i,n,a;let r,o;return t=e.prodOccurrence,s=e.rule,i=e.maxLookahead,n=e.dynamicTokensEnabled,a=sp(e.prodType),o=sN(r=sS(t,s,a,i))?tw:tM,sm(r[0],o,n)}}class sH{initLooksAhead(e){this.dynamicTokensEnabled=(0,O.A)(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ih.dynamicTokensEnabled,this.maxLookahead=(0,O.A)(e,"maxLookahead")?e.maxLookahead:ih.maxLookahead,this.lookaheadStrategy=(0,O.A)(e,"lookaheadStrategy")?e.lookaheadStrategy:new sV({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(e){(0,L.A)(e,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{var t;let s,{alternation:i,repetition:n,option:a,repetitionMandatory:r,repetitionMandatoryWithSeparator:o,repetitionWithSeparator:l}=(t=e,sX.reset(),t.accept(sX),s=sX.dslMethods,sX.reset(),s);(0,L.A)(i,t=>{let s=0===t.idx?"":t.idx;this.TRACE_INIT(`${eR(t)}${s}`,()=>{var s;let i=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:t.idx,rule:e,maxLookahead:t.maxLookahead||this.maxLookahead,hasPredicates:t.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),n=(s=this.fullRuleNameToShort[e.name],256|t.idx|s);this.setLaFuncCache(n,i)})}),(0,L.A)(n,t=>{this.computeLookaheadFunc(e,t.idx,768,"Repetition",t.maxLookahead,eR(t))}),(0,L.A)(a,t=>{this.computeLookaheadFunc(e,t.idx,512,"Option",t.maxLookahead,eR(t))}),(0,L.A)(r,t=>{this.computeLookaheadFunc(e,t.idx,1024,"RepetitionMandatory",t.maxLookahead,eR(t))}),(0,L.A)(o,t=>{this.computeLookaheadFunc(e,t.idx,1536,"RepetitionMandatoryWithSeparator",t.maxLookahead,eR(t))}),(0,L.A)(l,t=>{this.computeLookaheadFunc(e,t.idx,1280,"RepetitionWithSeparator",t.maxLookahead,eR(t))})})})}computeLookaheadFunc(e,t,s,i,n,a){this.TRACE_INIT(`${a}${0===t?"":t}`,()=>{let a=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:t,rule:e,maxLookahead:n||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),r=t|s|this.fullRuleNameToShort[e.name];this.setLaFuncCache(r,a)})}getKeyForAutomaticLookahead(e,t){return t|e|this.getLastExplicitRuleShortName()}getLaFuncFromCache(e){return this.lookAheadFuncsCache.get(e)}setLaFuncCache(e,t){this.lookAheadFuncsCache.set(e,t)}}class sY extends eh{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(e){this.dslMethods.option.push(e)}visitRepetitionWithSeparator(e){this.dslMethods.repetitionWithSeparator.push(e)}visitRepetitionMandatory(e){this.dslMethods.repetitionMandatory.push(e)}visitRepetitionMandatoryWithSeparator(e){this.dslMethods.repetitionMandatoryWithSeparator.push(e)}visitRepetition(e){this.dslMethods.repetition.push(e)}visitAlternation(e){this.dslMethods.alternation.push(e)}}let sX=new sY;function sJ(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.endOffset=t.endOffset):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset)}function sq(e,t){!0===isNaN(e.startOffset)?(e.startOffset=t.startOffset,e.startColumn=t.startColumn,e.startLine=t.startLine,e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine):e.endOffset<t.endOffset==!0&&(e.endOffset=t.endOffset,e.endColumn=t.endColumn,e.endLine=t.endLine)}function sZ(e,t){Object.defineProperty(e,"name",{enumerable:!1,configurable:!0,writable:!1,value:t})}function sQ(e,t){let s=(0,$.A)(e),i=s.length;for(let n=0;n<i;n++){let i=e[s[n]],a=i.length;for(let e=0;e<a;e++){let s=i[e];void 0===s.tokenTypeIdx&&this[s.name](s.children,t)}}}(r=c||(c={}))[r.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",r[r.MISSING_METHOD=1]="MISSING_METHOD";class s0{initTreeBuilder(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=(0,O.A)(e,"nodeLocationTracking")?e.nodeLocationTracking:ih.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=sq,this.setNodeLocationFromNode=sq,this.cstPostRule=tv.A,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=tv.A,this.setNodeLocationFromNode=tv.A,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=sJ,this.setNodeLocationFromNode=sJ,this.cstPostRule=tv.A,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=tv.A,this.setNodeLocationFromNode=tv.A,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=tv.A,this.setNodeLocationFromNode=tv.A,this.cstPostRule=tv.A,this.setInitialNodeLocation=tv.A;else throw Error(`Invalid <nodeLocationTracking> config option: "${e.nodeLocationTracking}"`);else this.cstInvocationStateUpdate=tv.A,this.cstFinallyStateUpdate=tv.A,this.cstPostTerminal=tv.A,this.cstPostNonTerminal=tv.A,this.cstPostRule=tv.A}setInitialNodeLocationOnlyOffsetRecovery(e){e.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(e){let t=this.LA(1);e.location={startOffset:t.startOffset,startLine:t.startLine,startColumn:t.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(e){let t={name:e,children:Object.create(null)};this.setInitialNodeLocation(t),this.CST_STACK.push(t)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(e){let t=this.LA(0),s=e.location;s.startOffset<=t.startOffset==!0?(s.endOffset=t.endOffset,s.endLine=t.endLine,s.endColumn=t.endColumn):(s.startOffset=NaN,s.startLine=NaN,s.startColumn=NaN)}cstPostRuleOnlyOffset(e){let t=this.LA(0),s=e.location;s.startOffset<=t.startOffset==!0?s.endOffset=t.endOffset:s.startOffset=NaN}cstPostTerminal(e,t){let s=this.CST_STACK[this.CST_STACK.length-1];void 0===s.children[e]?s.children[e]=[t]:s.children[e].push(t),this.setNodeLocationFromToken(s.location,t)}cstPostNonTerminal(e,t){let s=this.CST_STACK[this.CST_STACK.length-1];void 0===s.children[t]?s.children[t]=[e]:s.children[t].push(e),this.setNodeLocationFromNode(s.location,e.location)}getBaseCstVisitorConstructor(){if((0,ex.A)(this.baseCstVisitorConstructor)){var e,t;let s,i=(e=this.className,t=(0,$.A)(this.gastProductionsCache),sZ(s=function(){},e+"BaseSemantics"),s.prototype={visit:function(e,t){if((0,ep.A)(e)&&(e=e[0]),!(0,ex.A)(e))return this[e.name](e.children,t)},validateVisitor:function(){var e,s,i,n;let a,r=(e=this,s=t,i=e,n=s,a=(0,e2.A)(n,e=>!1===(0,eZ.A)(i[e])),ts((0,N.A)(a,e=>({msg:`Missing visitor method: <${e}> on ${i.constructor.name} CST Visitor.`,type:c.MISSING_METHOD,methodName:e}))));if(!(0,R.A)(r)){let e=(0,N.A)(r,e=>e.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
52
+ ${e.join("\n\n").replace(/\n/g,"\n ")}`)}}},s.prototype.constructor=s,s._RULE_NAMES=t,s);return this.baseCstVisitorConstructor=i,i}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if((0,ex.A)(this.baseCstVisitorWithDefaultsConstructor)){var e,t,s;let i,n,a=(e=this.className,t=(0,$.A)(this.gastProductionsCache),s=this.getBaseCstVisitorConstructor(),sZ(i=function(){},e+"BaseSemanticsWithDefaults"),n=Object.create(s.prototype),(0,L.A)(t,e=>{n[e]=sQ}),i.prototype=n,i.prototype.constructor=i,i);return this.baseCstVisitorWithDefaultsConstructor=a,a}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-1]}getPreviousExplicitRuleShortName(){let e=this.RULE_STACK;return e[e.length-2]}getLastExplicitRuleOccurrenceIndex(){let e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]}}class s1{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(e){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):il}LA(e){let t=this.currIdx+e;return t<0||this.tokVectorLength<=t?il:this.tokVector[t]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(e){this.currIdx=e}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}}class s2{ACTION(e){return e.call(this)}consume(e,t,s){return this.consumeInternal(t,e,s)}subrule(e,t,s){return this.subruleInternal(t,e,s)}option(e,t){return this.optionInternal(t,e)}or(e,t){return this.orInternal(t,e)}many(e,t){return this.manyInternal(e,t)}atLeastOne(e,t){return this.atLeastOneInternal(e,t)}CONSUME(e,t){return this.consumeInternal(e,0,t)}CONSUME1(e,t){return this.consumeInternal(e,1,t)}CONSUME2(e,t){return this.consumeInternal(e,2,t)}CONSUME3(e,t){return this.consumeInternal(e,3,t)}CONSUME4(e,t){return this.consumeInternal(e,4,t)}CONSUME5(e,t){return this.consumeInternal(e,5,t)}CONSUME6(e,t){return this.consumeInternal(e,6,t)}CONSUME7(e,t){return this.consumeInternal(e,7,t)}CONSUME8(e,t){return this.consumeInternal(e,8,t)}CONSUME9(e,t){return this.consumeInternal(e,9,t)}SUBRULE(e,t){return this.subruleInternal(e,0,t)}SUBRULE1(e,t){return this.subruleInternal(e,1,t)}SUBRULE2(e,t){return this.subruleInternal(e,2,t)}SUBRULE3(e,t){return this.subruleInternal(e,3,t)}SUBRULE4(e,t){return this.subruleInternal(e,4,t)}SUBRULE5(e,t){return this.subruleInternal(e,5,t)}SUBRULE6(e,t){return this.subruleInternal(e,6,t)}SUBRULE7(e,t){return this.subruleInternal(e,7,t)}SUBRULE8(e,t){return this.subruleInternal(e,8,t)}SUBRULE9(e,t){return this.subruleInternal(e,9,t)}OPTION(e){return this.optionInternal(e,0)}OPTION1(e){return this.optionInternal(e,1)}OPTION2(e){return this.optionInternal(e,2)}OPTION3(e){return this.optionInternal(e,3)}OPTION4(e){return this.optionInternal(e,4)}OPTION5(e){return this.optionInternal(e,5)}OPTION6(e){return this.optionInternal(e,6)}OPTION7(e){return this.optionInternal(e,7)}OPTION8(e){return this.optionInternal(e,8)}OPTION9(e){return this.optionInternal(e,9)}OR(e){return this.orInternal(e,0)}OR1(e){return this.orInternal(e,1)}OR2(e){return this.orInternal(e,2)}OR3(e){return this.orInternal(e,3)}OR4(e){return this.orInternal(e,4)}OR5(e){return this.orInternal(e,5)}OR6(e){return this.orInternal(e,6)}OR7(e){return this.orInternal(e,7)}OR8(e){return this.orInternal(e,8)}OR9(e){return this.orInternal(e,9)}MANY(e){this.manyInternal(0,e)}MANY1(e){this.manyInternal(1,e)}MANY2(e){this.manyInternal(2,e)}MANY3(e){this.manyInternal(3,e)}MANY4(e){this.manyInternal(4,e)}MANY5(e){this.manyInternal(5,e)}MANY6(e){this.manyInternal(6,e)}MANY7(e){this.manyInternal(7,e)}MANY8(e){this.manyInternal(8,e)}MANY9(e){this.manyInternal(9,e)}MANY_SEP(e){this.manySepFirstInternal(0,e)}MANY_SEP1(e){this.manySepFirstInternal(1,e)}MANY_SEP2(e){this.manySepFirstInternal(2,e)}MANY_SEP3(e){this.manySepFirstInternal(3,e)}MANY_SEP4(e){this.manySepFirstInternal(4,e)}MANY_SEP5(e){this.manySepFirstInternal(5,e)}MANY_SEP6(e){this.manySepFirstInternal(6,e)}MANY_SEP7(e){this.manySepFirstInternal(7,e)}MANY_SEP8(e){this.manySepFirstInternal(8,e)}MANY_SEP9(e){this.manySepFirstInternal(9,e)}AT_LEAST_ONE(e){this.atLeastOneInternal(0,e)}AT_LEAST_ONE1(e){return this.atLeastOneInternal(1,e)}AT_LEAST_ONE2(e){this.atLeastOneInternal(2,e)}AT_LEAST_ONE3(e){this.atLeastOneInternal(3,e)}AT_LEAST_ONE4(e){this.atLeastOneInternal(4,e)}AT_LEAST_ONE5(e){this.atLeastOneInternal(5,e)}AT_LEAST_ONE6(e){this.atLeastOneInternal(6,e)}AT_LEAST_ONE7(e){this.atLeastOneInternal(7,e)}AT_LEAST_ONE8(e){this.atLeastOneInternal(8,e)}AT_LEAST_ONE9(e){this.atLeastOneInternal(9,e)}AT_LEAST_ONE_SEP(e){this.atLeastOneSepFirstInternal(0,e)}AT_LEAST_ONE_SEP1(e){this.atLeastOneSepFirstInternal(1,e)}AT_LEAST_ONE_SEP2(e){this.atLeastOneSepFirstInternal(2,e)}AT_LEAST_ONE_SEP3(e){this.atLeastOneSepFirstInternal(3,e)}AT_LEAST_ONE_SEP4(e){this.atLeastOneSepFirstInternal(4,e)}AT_LEAST_ONE_SEP5(e){this.atLeastOneSepFirstInternal(5,e)}AT_LEAST_ONE_SEP6(e){this.atLeastOneSepFirstInternal(6,e)}AT_LEAST_ONE_SEP7(e){this.atLeastOneSepFirstInternal(7,e)}AT_LEAST_ONE_SEP8(e){this.atLeastOneSepFirstInternal(8,e)}AT_LEAST_ONE_SEP9(e){this.atLeastOneSepFirstInternal(9,e)}RULE(e,t,s=ic){if(eE(this.definedRulesNames,e)){let t={message:t4.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),type:d.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(t)}this.definedRulesNames.push(e);let i=this.defineRule(e,t,s);return this[e]=i,i}OVERRIDE_RULE(e,t,s=ic){var i,n;let a,r,o=(i=this.definedRulesNames,n=this.className,r=[],eE(i,e)||(a=`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:a,type:d.INVALID_RULE_OVERRIDE,ruleName:e})),r);this.definitionErrors=this.definitionErrors.concat(o);let l=this.defineRule(e,t,s);return this[e]=l,l}BACKTRACK(e,t){return function(){this.isBackTrackingStack.push(1);let s=this.saveRecogState();try{return e.apply(this,t),!0}catch(e){if(sw(e))return!1;throw e}finally{this.reloadRecogState(s),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){var e;return e=(0,S.A)(this.gastProductionsCache),(0,N.A)(e,function e(t){function s(t){return(0,N.A)(t,e)}if(t instanceof Q){let e={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return(0,x.A)(t.label)&&(e.label=t.label),e}if(t instanceof et)return{type:"Alternative",definition:s(t.definition)};if(t instanceof es)return{type:"Option",idx:t.idx,definition:s(t.definition)};if(t instanceof ei)return{type:"RepetitionMandatory",idx:t.idx,definition:s(t.definition)};if(t instanceof en)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:e(new el({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof er)return{type:"RepetitionWithSeparator",idx:t.idx,separator:e(new el({terminalType:t.separator})),definition:s(t.definition)};else if(t instanceof ea)return{type:"Repetition",idx:t.idx,definition:s(t.definition)};else if(t instanceof eo)return{type:"Alternation",idx:t.idx,definition:s(t.definition)};else if(t instanceof el){var i,n;let e={type:"Terminal",name:t.terminalType.name,label:(n=i=t.terminalType,(0,x.A)(n.LABEL)&&""!==n.LABEL)?i.LABEL:i.name,idx:t.idx};(0,x.A)(t.label)&&(e.terminalLabel=t.label);let s=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(e.pattern=q(s)?s.source:s),e}else if(t instanceof ee)return{type:"Rule",name:t.name,orgText:t.orgText,definition:s(t.definition)};else throw Error("non exhaustive match")})}}var s6=s(62667);class s5{initRecognizerEngine(e,t){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=tw,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},(0,O.A)(t,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n For Further details.");if((0,ep.A)(e)){if((0,R.A)(e))throw Error("A Token Vocabulary cannot be empty.\n Note that the first argument for the parser constructor\n is no longer a Token vector (since v4.0).");if("number"==typeof e[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n For Further details.")}if((0,ep.A)(e))this.tokensMap=(0,e1.A)(e,(e,t)=>(e[t.name]=t,e),{});else if((0,O.A)(e,"modes")&&eL((0,eC.A)((0,S.A)(e.modes)),tB)){let t=eI((0,eC.A)((0,S.A)(e.modes)));this.tokensMap=(0,e1.A)(t,(e,t)=>(e[t.name]=t,e),{})}else if((0,s6.A)(e))this.tokensMap=I(e);else throw Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=t1;let s=eL((0,O.A)(e,"modes")?(0,eC.A)((0,S.A)(e.modes)):(0,S.A)(e),e=>(0,R.A)(e.categoryMatches));this.tokenMatcher=s?tw:tM,t$((0,S.A)(this.tokensMap))}defineRule(e,t,s){if(this.selfAnalysisDone)throw Error(`Grammar rule <${e}> may not be defined after the 'performSelfAnalysis' method has been called'
53
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);let i=(0,O.A)(s,"resyncEnabled")?s.resyncEnabled:ic.resyncEnabled,n=(0,O.A)(s,"recoveryValueFunc")?s.recoveryValueFunc:ic.recoveryValueFunc,a=this.ruleShortNameIdx<<12;return this.ruleShortNameIdx++,this.shortRuleNameToFull[a]=e,this.fullRuleNameToShort[e]=a,Object.assign(!0===this.outputCst?function(...s){try{this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,s);let i=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(i),i}catch(e){return this.invokeRuleCatch(e,i,n)}finally{this.ruleFinallyStateUpdate()}}:function(...s){try{return this.ruleInvocationStateUpdate(a,e,this.subruleIdx),t.apply(this,s)}catch(e){return this.invokeRuleCatch(e,i,n)}finally{this.ruleFinallyStateUpdate()}},{ruleName:e,originalGrammarAction:t})}invokeRuleCatch(e,t,s){let i=1===this.RULE_STACK.length,n=t&&!this.isBackTracking()&&this.recoveryEnabled;if(sw(e)){if(n){let t=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(t)){if(e.resyncedTokens=this.reSyncTo(t),!this.outputCst)return s(e);{let e=this.CST_STACK[this.CST_STACK.length-1];return e.recoveredNode=!0,e}}if(this.outputCst){let t=this.CST_STACK[this.CST_STACK.length-1];t.recoveredNode=!0,e.partialCstResult=t}throw e}if(i)return this.moveToTerminatedState(),s(e)}throw e}optionInternal(e,t){let s=this.getKeyForAutomaticLookahead(512,t);return this.optionInternalLogic(e,t,s)}optionInternalLogic(e,t,s){let i,n=this.getLaFuncFromCache(s);if("function"!=typeof e){i=e.DEF;let t=e.GATE;if(void 0!==t){let e=n;n=()=>t.call(this)&&e.call(this)}}else i=e;if(!0===n.call(this))return i.call(this)}atLeastOneInternal(e,t){let s=this.getKeyForAutomaticLookahead(1024,e);return this.atLeastOneInternalLogic(e,t,s)}atLeastOneInternalLogic(e,t,s){let i,n=this.getLaFuncFromCache(s);if("function"!=typeof t){i=t.DEF;let e=t.GATE;if(void 0!==e){let t=n;n=()=>e.call(this)&&t.call(this)}}else i=t;if(!0===n.call(this)){let e=this.doSingleRepetition(i);for(;!0===n.call(this)&&!0===e;)e=this.doSingleRepetition(i)}else throw this.raiseEarlyExitException(e,h.REPETITION_MANDATORY,t.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,t],n,1024,e,sh)}atLeastOneSepFirstInternal(e,t){let s=this.getKeyForAutomaticLookahead(1536,e);this.atLeastOneSepFirstInternalLogic(e,t,s)}atLeastOneSepFirstInternalLogic(e,t,s){let i=t.DEF,n=t.SEP;if(!0===this.getLaFuncFromCache(s).call(this)){i.call(this);let t=()=>this.tokenMatcher(this.LA(1),n);for(;!0===this.tokenMatcher(this.LA(1),n);)this.CONSUME(n),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,t,i,sc],t,1536,e,sc)}else throw this.raiseEarlyExitException(e,h.REPETITION_MANDATORY_WITH_SEPARATOR,t.ERR_MSG)}manyInternal(e,t){let s=this.getKeyForAutomaticLookahead(768,e);return this.manyInternalLogic(e,t,s)}manyInternalLogic(e,t,s){let i,n=this.getLaFuncFromCache(s);if("function"!=typeof t){i=t.DEF;let e=t.GATE;if(void 0!==e){let t=n;n=()=>e.call(this)&&t.call(this)}}else i=t;let a=!0;for(;!0===n.call(this)&&!0===a;)a=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[e,t],n,768,e,so,a)}manySepFirstInternal(e,t){let s=this.getKeyForAutomaticLookahead(1280,e);this.manySepFirstInternalLogic(e,t,s)}manySepFirstInternalLogic(e,t,s){let i=t.DEF,n=t.SEP;if(!0===this.getLaFuncFromCache(s).call(this)){i.call(this);let t=()=>this.tokenMatcher(this.LA(1),n);for(;!0===this.tokenMatcher(this.LA(1),n);)this.CONSUME(n),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,n,t,i,sl],t,1280,e,sl)}}repetitionSepSecondInternal(e,t,s,i,n){for(;s();)this.CONSUME(t),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,t,s,i,n],s,1536,e,n)}doSingleRepetition(e){let t=this.getLexerPosition();return e.call(this),this.getLexerPosition()>t}orInternal(e,t){let s=this.getKeyForAutomaticLookahead(256,t),i=(0,ep.A)(e)?e:e.DEF,n=this.getLaFuncFromCache(s).call(this,i);if(void 0!==n)return i[n].ALT.call(this);this.raiseNoAltException(t,e.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),0===this.RULE_STACK.length&&!1===this.isAtEndOfInput()){let e=this.LA(1),t=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new sK(t,e))}}subruleInternal(e,t,s){let i;try{let n=void 0!==s?s.ARGS:void 0;return this.subruleIdx=t,i=e.apply(this,n),this.cstPostNonTerminal(i,void 0!==s&&void 0!==s.LABEL?s.LABEL:e.ruleName),i}catch(t){throw this.subruleInternalError(t,s,e.ruleName)}}subruleInternalError(e,t,s){throw sw(e)&&void 0!==e.partialCstResult&&(this.cstPostNonTerminal(e.partialCstResult,void 0!==t&&void 0!==t.LABEL?t.LABEL:s),delete e.partialCstResult),e}consumeInternal(e,t,s){let i;try{let t=this.LA(1);!0===this.tokenMatcher(t,e)?(this.consumeToken(),i=t):this.consumeInternalError(e,t,s)}catch(s){i=this.consumeInternalRecovery(e,t,s)}return this.cstPostTerminal(void 0!==s&&void 0!==s.LABEL?s.LABEL:e.name,i),i}consumeInternalError(e,t,s){let i,n=this.LA(0);throw i=void 0!==s&&s.ERR_MSG?s.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:t,previous:n,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new sD(i,t,n))}consumeInternalRecovery(e,t,s){if(this.recoveryEnabled&&"MismatchedTokenException"===s.name&&!this.isBackTracking()){let i=this.getFollowsForInRuleRecovery(e,t);try{return this.tryInRuleRecovery(e,i)}catch(e){if(e.name===sG)throw s;throw e}}throw s}saveRecogState(){let e=this.errors,t=I(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:t,CST_STACK:this.CST_STACK}}reloadRecogState(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK}ruleInvocationStateUpdate(e,t,s){this.RULE_OCCURRENCE_STACK.push(s),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(t)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){let e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]}shortRuleNameToFullName(e){return this.shortRuleNameToFull[e]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),t1)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}}class s4{initErrorHandler(e){this._errors=[],this.errorMessageProvider=(0,O.A)(e,"errorMessageProvider")?e.errorMessageProvider:ih.errorMessageProvider}SAVE_ERROR(e){if(sw(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:I(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return I(this._errors)}set errors(e){this._errors=e}raiseEarlyExitException(e,t,s){let i=this.getCurrRuleFullName(),n=sS(e,this.getGAstProductions()[i],t,this.maxLookahead)[0],a=[];for(let e=1;e<=this.maxLookahead;e++)a.push(this.LA(e));let r=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:n,actual:a,previous:this.LA(0),customUserDescription:s,ruleName:i});throw this.SAVE_ERROR(new sF(r,this.LA(1),this.LA(0)))}raiseNoAltException(e,t){let s=this.getCurrRuleFullName(),i=sL(e,this.getGAstProductions()[s],this.maxLookahead),n=[];for(let e=1;e<=this.maxLookahead;e++)n.push(this.LA(e));let a=this.LA(0),r=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:n,previous:a,customUserDescription:t,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new s$(r,this.LA(1),a))}}class s3{initContentAssist(){}computeContentAssist(e,t){let s=this.gastProductionsCache[e];if((0,ex.A)(s))throw Error(`Rule ->${e}<- does not exist in this grammar.`);return su([s],t,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(e){let t=ti(e.ruleStack);return new sa(this.getGAstProductions()[t],e).startWalking()}}let s9={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(s9);let s8=t0({name:"RECORDING_PHASE_TOKEN",pattern:tW.NA});t$([s8]);let s7=t2(s8,"This IToken indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(s7);let ie={name:"This CSTNode indicates the Parser is in Recording Phase\n See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};class it{initGastRecorder(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";this[`CONSUME${t}`]=function(t,s){return this.consumeInternalRecord(t,e,s)},this[`SUBRULE${t}`]=function(t,s){return this.subruleInternalRecord(t,e,s)},this[`OPTION${t}`]=function(t){return this.optionInternalRecord(t,e)},this[`OR${t}`]=function(t){return this.orInternalRecord(t,e)},this[`MANY${t}`]=function(t){this.manyInternalRecord(e,t)},this[`MANY_SEP${t}`]=function(t){this.manySepFirstInternalRecord(e,t)},this[`AT_LEAST_ONE${t}`]=function(t){this.atLeastOneInternalRecord(e,t)},this[`AT_LEAST_ONE_SEP${t}`]=function(t){this.atLeastOneSepFirstInternalRecord(e,t)}}this.consume=function(e,t,s){return this.consumeInternalRecord(t,e,s)},this.subrule=function(e,t,s){return this.subruleInternalRecord(t,e,s)},this.option=function(e,t){return this.optionInternalRecord(t,e)},this.or=function(e,t){return this.orInternalRecord(t,e)},this.many=function(e,t){this.manyInternalRecord(e,t)},this.atLeastOne=function(e,t){this.atLeastOneInternalRecord(e,t)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{for(let e=0;e<10;e++){let t=e>0?e:"";delete this[`CONSUME${t}`],delete this[`SUBRULE${t}`],delete this[`OPTION${t}`],delete this[`OR${t}`],delete this[`MANY${t}`],delete this[`MANY_SEP${t}`],delete this[`AT_LEAST_ONE${t}`],delete this[`AT_LEAST_ONE_SEP${t}`]}delete this.consume,delete this.subrule,delete this.option,delete this.or,delete this.many,delete this.atLeastOne,delete this.ACTION,delete this.BACKTRACK,delete this.LA})}ACTION_RECORD(e){}BACKTRACK_RECORD(e,t){return()=>!0}LA_RECORD(e){return il}topLevelRuleRecord(e,t){try{let s=new ee({definition:[],name:e});return s.name=e,this.recordingProdStack.push(s),t.call(this),this.recordingProdStack.pop(),s}catch(e){if(!0!==e.KNOWN_RECORDER_ERROR)try{e.message=e.message+'\n This error was thrown during the "grammar recording phase" For more info see:\n https://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(e){}throw e}}optionInternalRecord(e,t){return is.call(this,es,e,t)}atLeastOneInternalRecord(e,t){is.call(this,ei,t,e)}atLeastOneSepFirstInternalRecord(e,t){is.call(this,en,t,e,!0)}manyInternalRecord(e,t){is.call(this,ea,t,e)}manySepFirstInternalRecord(e,t){is.call(this,er,t,e,!0)}orInternalRecord(e,t){return ii.call(this,e,t)}subruleInternalRecord(e,t,s){if(ir(t),!e||!1===(0,O.A)(e,"ruleName")){let s=Error(`<SUBRULE${ia(t)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(e)}>
54
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=(0,tx.A)(this.recordingProdStack),n=new Q({idx:t,nonTerminalName:e.ruleName,label:null==s?void 0:s.LABEL,referencedRule:void 0});return i.definition.push(n),this.outputCst?ie:s9}consumeInternalRecord(e,t,s){if(ir(t),!tK(e)){let s=Error(`<CONSUME${ia(t)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(e)}>
55
+ inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}let i=(0,tx.A)(this.recordingProdStack),n=new el({idx:t,terminalType:e,label:null==s?void 0:s.LABEL});return i.definition.push(n),s7}}function is(e,t,s,i=!1){ir(s);let n=(0,tx.A)(this.recordingProdStack),a=(0,eZ.A)(t)?t:t.DEF,r=new e({definition:[],idx:s});return i&&(r.separator=t.SEP),(0,O.A)(t,"MAX_LOOKAHEAD")&&(r.maxLookahead=t.MAX_LOOKAHEAD),this.recordingProdStack.push(r),a.call(this),n.definition.push(r),this.recordingProdStack.pop(),s9}function ii(e,t){ir(t);let s=(0,tx.A)(this.recordingProdStack),i=!1===(0,ep.A)(e),n=!1===i?e:e.DEF,a=new eo({definition:[],idx:t,ignoreAmbiguities:i&&!0===e.IGNORE_AMBIGUITIES});return(0,O.A)(e,"MAX_LOOKAHEAD")&&(a.maxLookahead=e.MAX_LOOKAHEAD),a.hasPredicates=em(n,e=>(0,eZ.A)(e.GATE)),s.definition.push(a),(0,L.A)(n,e=>{let t=new et({definition:[]});a.definition.push(t),(0,O.A)(e,"IGNORE_AMBIGUITIES")?t.ignoreAmbiguities=e.IGNORE_AMBIGUITIES:(0,O.A)(e,"GATE")&&(t.ignoreAmbiguities=!0),this.recordingProdStack.push(t),e.ALT.call(this),this.recordingProdStack.pop()}),s9}function ia(e){return 0===e?"":`${e}`}function ir(e){if(e<0||e>255){let t=Error(`Invalid DSL Method idx value: <${e}>
56
+ Idx value must be a none negative value smaller than ${256}`);throw t.KNOWN_RECORDER_ERROR=!0,t}}class io{initPerformanceTracer(e){if((0,O.A)(e,"traceInitPerf")){let t=e.traceInitPerf,s="number"==typeof t;this.traceInitMaxIdent=s?t:1/0,this.traceInitPerf=s?t>0:t}else this.traceInitMaxIdent=0,this.traceInitPerf=ih.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(e,t){if(!0!==this.traceInitPerf)return t();{this.traceInitIndent++;let s=Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${e}>`);let{time:i,value:n}=tU(t),a=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&a(`${s}<-- <${e}> time: ${i}ms`),this.traceInitIndent--,n}}}let il=t2(t1,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(il);let ih=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:t6,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ic=Object.freeze({recoveryValueFunc:()=>void 0,resyncEnabled:!0});(o=d||(d={}))[o.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",o[o.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",o[o.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",o[o.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",o[o.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",o[o.LEFT_RECURSION=5]="LEFT_RECURSION",o[o.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",o[o.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",o[o.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",o[o.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",o[o.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",o[o.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",o[o.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",o[o.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class id{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;let t=this.className;this.TRACE_INIT("toFastProps",()=>{C(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),(0,L.A)(this.definedRulesNames,e=>{let t,s=this[e].originalGrammarAction;this.TRACE_INIT(`${e} Rule`,()=>{t=this.topLevelRuleRecord(e,s)}),this.gastProductionsCache[e]=t})}finally{this.disableRecording()}});let s=[];if(this.TRACE_INIT("Grammar Resolving",()=>{var e;let t,i,n;e={rules:(0,S.A)(this.gastProductionsCache)},i=(0,eH.A)(e,{errMsgProvider:t5}),n={},(0,L.A)(e.rules,e=>{n[e.name]=e}),(t=new t3(n,i.errMsgProvider)).resolveRefs(),s=t.errors,this.definitionErrors=this.definitionErrors.concat(s)}),this.TRACE_INIT("Grammar Validations",()=>{if((0,R.A)(s)&&!1===this.skipValidations){var e,i,n,a,r,o,l,h,c;let s,u,p,f,m,T,A,E=(e={rules:(0,S.A)(this.gastProductionsCache),tokenTypes:(0,S.A)(this.tokensMap),errMsgProvider:t4,grammarName:t},i=(e=(0,eH.A)(e,{errMsgProvider:t4})).rules,n=e.tokenTypes,a=e.errMsgProvider,r=e.grammarName,p=t9(i,e=>{var t,s;let i,n;return t=e,s=a,i=new sI,t.accept(i),n=z(ss(i.allProductions,sO),e=>e.length>1),(0,N.A)((0,S.A)(n),e=>{let i=ti(e),n=s.buildDuplicateFoundError(t,e),a=eR(i),r={message:n,type:d.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:a,occurrence:i.idx},o=sk(i);return o&&(r.parameter=o),r})}),l=i,h=n,c=a,s=[],u=(0,N.A)(h,e=>e.name),(0,L.A)(l,e=>{let t=e.name;if(eE(u,t)){let i=c.buildNamespaceConflictError(e);s.push({message:i,type:d.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:t})}}),f=s,m=t9(i,e=>{var t,s;let i;return t=e,s=a,i=new sC,t.accept(i),t9(i.alternations,e=>e.definition.length>255?[{message:s.buildTooManyAlternativesError({topLevelRule:t,alternation:e}),type:d.TOO_MANY_ALTS,ruleName:t.name,occurrence:e.idx}]:[])}),T=t9(i,e=>(function(e,t,s,i){let n=[];if((0,e1.A)(t,(t,s)=>s.name===e.name?t+1:t,0)>1){let t=i.buildDuplicateRuleNameError({topLevelRule:e,grammarName:s});n.push({message:t,type:d.DUPLICATE_RULE_NAME,ruleName:e.name})}return n})(e,i,r,a)),p.concat(f,m,T)),g=(A=(o={lookaheadStrategy:this.lookaheadStrategy,rules:(0,S.A)(this.gastProductionsCache),tokenTypes:(0,S.A)(this.tokensMap),grammarName:t}).lookaheadStrategy.validate({rules:o.rules,tokenTypes:o.tokenTypes,grammarName:o.grammarName}),(0,N.A)(A,e=>Object.assign({type:d.CUSTOM_LOOKAHEAD_VALIDATION},e)));this.definitionErrors=this.definitionErrors.concat(E,g)}}),(0,R.A)(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{var e;let t,s=(e=(0,S.A)(this.gastProductionsCache),t={},(0,L.A)(e,e=>{F(t,new e_(e).startWalking())}),t);this.resyncFollows=s}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var e,t;null==(t=(e=this.lookaheadStrategy).initialize)||t.call(e,{rules:(0,S.A)(this.gastProductionsCache)}),this.preComputeLookaheadFunctions((0,S.A)(this.gastProductionsCache))})),!id.DEFER_DEFINITION_ERRORS_HANDLING&&!(0,R.A)(this.definitionErrors))throw e=(0,N.A)(this.definitionErrors,e=>e.message),Error(`Parser Definition Errors detected:
57
+ ${e.join("\n-------------------------------\n")}`)})}constructor(e,t){if(this.definitionErrors=[],this.selfAnalysisDone=!1,this.initErrorHandler(t),this.initLexerAdapter(),this.initLooksAhead(t),this.initRecognizerEngine(e,t),this.initRecoverable(t),this.initTreeBuilder(t),this.initContentAssist(),this.initGastRecorder(t),this.initPerformanceTracer(t),(0,O.A)(t,"ignoredIssues"))throw Error("The <ignoredIssues> IParserConfig property has been deprecated.\n Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n For further details.");this.skipValidations=(0,O.A)(t,"skipValidations")?t.skipValidations:ih.skipValidations}}id.DEFER_DEFINITION_ERRORS_HANDLING=!1,[sj,sH,s0,s1,s5,s2,s4,s3,it,io].forEach(e=>{let t=e.prototype;Object.getOwnPropertyNames(t).forEach(s=>{if("constructor"===s)return;let i=Object.getOwnPropertyDescriptor(t,s);i&&(i.get||i.set)?Object.defineProperty(id.prototype,s,i):id.prototype[s]=e.prototype[s]})});class iu extends id{constructor(e,t=ih){const s=I(t);s.outputCst=!0,super(e,s)}}var ip=s(60830);function im(e,t){let s=e.lexer.tokenize(t);if(s.errors.length>0){let i=s.errors[0],n=Number.isFinite(i.offset)?i.offset:t.length,a=n+(Number.isFinite(i.length)?i.length:0);throw Error(`Error lexing ${e.diagramType} diagram: ${i.message} at line ${i.line??1}, column ${i.column??1} [${n},${a})`)}e.parser.input=s.tokens;let i=e.entry();if(e.parser.errors.length>0)throw Error(`Error parsing ${e.diagramType} diagram: ${e.parser.errors[0].message}`);e.visit(i)}(0,y.K)(im,"runChevrotainParse");var iT=E.UI.usecase,iA=(0,y.K)(()=>({actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,symbols:new Map,direction:"LR",relationshipCounter:0,noteCounter:0,accTitle:"",accDescription:"",ast:void 0,config:structuredClone(iT)}),"createModel"),iE=(0,y.K)(e=>{if(!(e.actors instanceof Map)||!(e.useCases instanceof Map)||!(e.systemBoundaries instanceof Map)||!Array.isArray(e.relationships)||!(e.notes instanceof Map)||!(e.jsonNodes instanceof Map)||!(e.classDefs instanceof Map)||!(e.symbols instanceof Map)||!["TB","TD","BT","RL","LR"].includes(e.direction)||!Number.isSafeInteger(e.relationshipCounter)||e.relationshipCounter<0||!Number.isSafeInteger(e.noteCounter)||e.noteCounter<0||"string"!=typeof e.accTitle||"string"!=typeof e.accDescription||!e.config)throw Error("Cannot commit an incomplete usecase model")},"assertCompleteModel"),ig=iA(),iy=(0,y.K)(()=>structuredClone(ig.config),"getConfig"),iL=(0,y.K)(()=>ig.ast,"getAST"),iS=(0,y.K)(e=>{let t=structuredClone(e);iE(t);let s=(0,E.iN)(),i=(0,E.m7)();try{(0,E.SV)(t.accTitle),(0,E.EI)(t.accDescription),ig=t}catch(e){throw(0,E.SV)(s),(0,E.EI)(i),e}},"commit"),iR=(0,y.K)(()=>{ig=iA(),(0,E.IU)()},"clear"),iN=(0,y.K)(()=>ig.actors,"getActors"),iO=(0,y.K)(e=>ig.actors.get(e),"getActor"),ik=(0,y.K)(()=>ig.useCases,"getUseCases"),iI=(0,y.K)(e=>ig.useCases.get(e),"getUseCase"),iC=(0,y.K)(()=>ig.systemBoundaries,"getSystemBoundaries"),ib=(0,y.K)(e=>ig.systemBoundaries.get(e),"getSystemBoundary"),iv=(0,y.K)(()=>ig.relationships,"getRelationships"),i_=(0,y.K)(()=>ig.notes,"getNotes"),ix=(0,y.K)(e=>ig.notes.get(e),"getNote"),iU=(0,y.K)(()=>ig.jsonNodes,"getJsonNodes"),iM=(0,y.K)(e=>ig.jsonNodes.get(e),"getJsonNode"),iw=(0,y.K)(()=>ig.classDefs,"getClassDefs"),iP=(0,y.K)(e=>ig.classDefs.get(e),"getClassDef"),iD=(0,y.K)(()=>ig.direction,"getDirection"),i$=(0,y.K)(e=>{let t=new Map;for(let s of["default",...e]){let e=ig.classDefs.get(s);if(e)for(let s of e.styles){let e=s.trim(),i=e.indexOf(":"),n=(-1===i?e:e.slice(0,i)).trim();n&&t.set(n,e)}}return[...t.values()]},"getCompiledStyles"),iK=(0,y.K)(e=>e.replaceAll("~","~0").replaceAll("/","~1"),"escapeJsonPointerPart"),iF=(0,y.K)(e=>"string"==typeof e?e:null===e?"null":String(e),"displayJsonScalar"),iB=(0,y.K)((e,t,s=e=>e)=>{let i=[],n=(0,y.K)((e,t,n)=>{i.push({key:s(e),accessibleKey:s(t),value:s(n)})},"append"),a=(0,y.K)((e,s,i)=>{if(Array.isArray(e)){if(0===e.length)return void n(s,s,"[]");if(e.every(e=>null===e||["string","number","boolean"].includes(typeof e))){for(let[t,i]of e.entries())n(0===t?s:"",s,iF(i));return}for(let[t,n]of e.entries())a(n,`${s}[${t}]`,`${i}/${t}`);return}if(null!==e&&"object"==typeof e){let r=t[i]??Object.keys(e);if(0===r.length)return void n(s,s,"{}");for(let t of r){let n=s?`${s}.${t}`:t;a(e[t],n,`${i}/${iK(t)}`)}return}n(s,s,iF(e))},"visit");return a(e,"",""),i},"flattenJsonRows"),iG=(0,y.K)(e=>{switch(e.type){case"hollow":return"usecaseActorHollow";case"awesome":return"usecaseActorAwesome";case"icon":return"usecaseActorIcon";case"normal":return"usecaseActor"}},"actorShape"),iW=(0,y.K)(e=>"ellipse"===e.shape?e.business?"usecaseBusiness":"usecaseEllipse":e.shape,"useCaseShape"),ij=(0,y.K)(e=>{switch(e){case 0:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point"};case 1:return{arrowTypeStart:"arrow_point",arrowTypeEnd:"none"};case 3:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_circle"};case 4:return{arrowTypeStart:"none",arrowTypeEnd:"arrow_cross"};case 5:return{arrowTypeStart:"arrow_circle",arrowTypeEnd:"none"};case 6:return{arrowTypeStart:"arrow_cross",arrowTypeEnd:"none"};case 2:return{arrowTypeStart:"none",arrowTypeEnd:"none"}}},"associationMarkers"),iz=(0,y.K)(e=>{switch(e.type){case"include":case"extend":return{arrowTypeStart:"none",arrowTypeEnd:"arrow_point",pattern:"dotted",label:e.type,labelType:"text"};case"generalization":return{arrowTypeStart:"none",arrowTypeEnd:"extension",pattern:"solid"};case"association":return{...ij(e.arrowType),pattern:"solid",...e.label?{label:e.label}:{},...e.labelType?{labelType:e.labelType}:{}}}},"relationshipVisuals"),iV=(0,y.K)(e=>e.animate||e.animation?[`edge-animation-${e.animation??"fast"}`]:[],"animationClasses"),iH=(0,y.K)((...e)=>e.filter(e=>!!e).join(" "),"classNames"),iY=(0,y.K)(()=>{let e=(0,E.D7)(),t={...ig.config,...e.usecase},s=(0,y.K)(t=>(0,E.jZ)(t,e),"sanitize"),i=(0,y.K)(e=>s(ig.actors.get(e)?.label??ig.useCases.get(e)?.label??ig.jsonNodes.get(e)?.id??ig.notes.get(e)?.label??e),"endpointLabel"),n=[],a=[],r=0,o=0;for(let t of ig.actors.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:iG(t),isGroup:!1,padding:10,look:e.look,colorIndex:r++,cssClasses:iH("default","usecase-actor",`usecase-actor-${t.type}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:i$(t.classes),actorType:t.type,business:t.business,...t.icon?{icon:t.icon}:{},...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of ig.useCases.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:iW(t),isGroup:!1,padding:"ellipse"===t.shape?20:10,look:e.look,colorIndex:r++,cssClasses:iH("default","usecase-element",`usecase-${t.shape}`,t.business&&"usecase-business",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:i$(t.classes),business:t.business,...t.stereotype?{stereotype:s(t.stereotype)}:{},...t.parentId?{parentId:t.parentId}:{}});for(let t of ig.notes.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"note",isGroup:!1,padding:10,look:e.look,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:i$([]),noteTarget:t.target,noteTargetLabel:s(ig.actors.get(t.target)?.label??ig.useCases.get(t.target)?.label??ig.jsonNodes.get(t.target)?.id??t.target)});for(let t of ig.jsonNodes.values())n.push({id:t.id,label:s(t.id),labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,look:e.look,cssClasses:iH("default","usecase-json-table",...t.classes),cssStyles:[...t.styles],cssCompiledStyles:i$(t.classes),jsonRows:iB(t.value,t.propertyOrder,s)});for(let t of ig.systemBoundaries.values())n.push({id:t.id,label:s(t.label),labelType:t.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,look:e.look,colorIndex:o++,cssClasses:iH("default","system-boundary",`system-boundary-${t.type}`,...t.classes),cssStyles:[...t.styles],cssCompiledStyles:i$(t.classes),boundaryType:t.type});for(let t of ig.relationships){let{label:n,...r}=iz(t);a.push({id:t.id,start:t.source,end:t.target,source:t.source,target:t.target,sourceLabel:i(t.source),targetLabel:i(t.target),type:"edge",relationshipType:t.type,internal:!1,...r,...void 0!==n?{label:s(n)}:{},labelpos:"c",classes:iH("default","relationship",`relationship-${t.type}`,...t.classes,...iV(t)),style:[...t.styles],cssCompiledStyles:i$(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 ig.notes.values())a.push({id:`${t.id}-edge`,start:t.id,end:t.target,source:t.id,target:t.target,type:"edge",relationshipType:"note",sourceLabel:i(t.id),targetLabel:i(t.target),internal:!0,pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",labelpos:"c",classes:"default relationship relationship-note",style:[],cssCompiledStyles:i$([]),animate:!1,look:e.look,thickness:"normal",minlen:1,isUserDefinedId:!1});for(let e of n)e.wrappingWidth??=t.wrappingWidth,e.isGroup||e.shape.startsWith("usecaseActor")||(e.minWidth??=t.minNodeWidth),("usecaseEllipse"===e.shape||"usecaseBusiness"===e.shape)&&(e.spreadPorts=!0);return{nodes:n,edges:a,config:e,type:"usecase",layoutAlgorithm:"dagre",direction:iD(),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"),iX={getConfig:iy,createModel:iA,commit:iS,getAST:iL,clear:iR,setDiagramTitle:E.ke,getDiagramTitle:E.ab,setAccTitle:E.SV,getAccTitle:E.iN,setAccDescription:E.EI,getAccDescription:E.m7,getActors:iN,getActor:iO,getUseCases:ik,getUseCase:iI,getSystemBoundaries:iC,getSystemBoundary:ib,getRelationships:iv,getNotes:i_,getNote:ix,getJsonNodes:iU,getJsonNode:iM,getClassDefs:iw,getClassDef:iP,getDirection:iD,getData:iY};function iJ(e,t,s){let i=[s];return i.index=t,i.input=e,i}(0,y.K)(iJ,"customMatch");var iq=(0,y.K)((e,t)=>{if('"'!==e[t]||"`"!==e[t+1])return null;for(let s=t+2;s<e.length-1;s++)if("`"===e[s]&&'"'===e[s+1])return iJ(e,t,e.slice(t,s+2));return null},"matchMarkdownString"),iZ=(0,y.K)((e,t)=>{if("%"!==e[t]||"%"!==e[t+1])return null;for(let s=t-1;s>=0;s--){let t=e[s];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return null}let s=t+2;for(;s<e.length&&"\n"!==e[s]&&"\r"!==e[s];)s++;return iJ(e,t,e.slice(t,s))},"matchComment"),iQ=(0,y.K)((e,t)=>{for(let s=t-1;s>=0;s--){let t=e[s];if("\n"===t||"\r"===t)break;if(" "!==t&&" "!==t)return!1}return!0},"isIndentedLineStart"),i0=(0,y.K)((e,t,s)=>{if(!iQ(e,t))return null;let i=s.exec(e.slice(t));return i?iJ(e,t,i[0]):null},"matchAccessibilityLine"),i1=(0,y.K)((e,t)=>{if(!iQ(e,t))return null;let s=/^accDescr[\t ]*{/.exec(e.slice(t));if(!s)return null;let i=e.indexOf("}",t+s[0].length);return -1===i?null:iJ(e,t,e.slice(t,i+1))},"matchAccDescrBlock"),i2=(0,y.K)((e,t)=>{if("{"!==e[t])return null;let s=0,i=!1,n=!1;for(let a=t;a<e.length;a++){let r=e[a];if(i){n?n=!1:"\\"===r?n=!0:'"'===r&&(i=!1);continue}if('"'===r)i=!0;else if("{"===r)s++;else if("}"===r&&0==--s)return iJ(e,t,e.slice(t,a+1))}return null},"matchJsonObject"),i6=(0,y.K)((e,t)=>{let s=e.indexOf(">>",t);if(-1===s||/[\n\r]/.test(e.slice(t,s)))return null;let i=e.slice(t,s);return i.trim()?iJ(e,t,i):null},"matchStereotypeText"),i5=t0({name:"LABEL_TEXT",pattern:tW.NA}),i4=t0({name:"WORD",pattern:tW.NA,categories:i5}),i3=t0({name:"NUMBER",pattern:/(?:\d+\.\d+|\d+|\.\d+)(?:[A-Za-z]+)?/,categories:i5}),i9=t0({name:"IDENTIFIER",pattern:/\w+/,longer_alt:i3,categories:i4}),i8=t0({name:"HWS",pattern:/[\t ]+/,group:tW.SKIPPED}),i7=t0({name:"MARKDOWN_STRING",pattern:iq,start_chars_hint:['"'],line_breaks:!0}),ne=t0({name:"UNCLOSED_MARKDOWN_STRING",pattern:/"`[^]*/,line_breaks:!0}),nt=t0({name:"COMMENT",pattern:iZ,start_chars_hint:["%"],line_breaks:!1}),ns=t0({name:"NEWLINE",pattern:/\r\n|\n|\r/,line_breaks:!0}),ni=t0({name:"ACC_DESCR_BLOCK",pattern:i1,start_chars_hint:["a"],line_breaks:!0}),nn=/^accTitle[\t ]*:[^\n\r]*/,na=/^accDescr[\t ]*:[^\n\r]*/,nr=t0({name:"ACC_TITLE_LINE",pattern:(0,y.K)((e,t)=>i0(e,t,nn),"pattern"),start_chars_hint:["a"],line_breaks:!1}),no=t0({name:"ACC_DESCR_LINE",pattern:(0,y.K)((e,t)=>i0(e,t,na),"pattern"),start_chars_hint:["a"],line_breaks:!1}),nl=t0({name:"JSON_DECLARATION_START",pattern:/json[\t ]+\w+[\t ]*@[\t ]*(?={)/,push_mode:"jsonBody"}),nh=t0({name:"JSON_OBJECT_LITERAL",pattern:i2,start_chars_hint:["{"],line_breaks:!0,pop_mode:!0}),nc=t0({name:"UNCLOSED_JSON_OBJECT_LITERAL",pattern:/{[^]*/,line_breaks:!0,pop_mode:!0}),nd=(0,y.K)((e,t)=>t0({name:e,pattern:t,longer_alt:i9,categories:i4}),"keyword"),nu=nd("USECASE",/usecase-beta/),np=nd("ACTOR",/actor/),nf=nd("SYSTEM_BOUNDARY",/systemBoundary/),nm=nd("END",/end/),nT=nd("DIRECTION",/direction/),nA=nd("TD",/TD/),nE=nd("TB",/TB/),ng=nd("BT",/BT/),ny=nd("LR",/LR/),nL=nd("RL",/RL/),nS=nd("NOTE",/note/),nR=nd("FOR",/for/),nN=nd("JSON",/json/),nO=nd("CLASS_DEF",/classDef/),nk=nd("CLASS",/class/),nI=nd("STYLE",/style/),nC=nd("INCLUDE",/include/i),nb=nd("EXTEND",/extend/i),nv=nd("TRUE",/true/),n_=nd("FALSE",/false/),nx=t0({name:"GENERALIZATION",pattern:/--\|>/}),nU=t0({name:"DEPENDENCY_ARROW",pattern:/\.\.>/}),nM=t0({name:"STEREOTYPE_START",pattern:/<</,push_mode:"stereotype"}),nw=t0({name:"STEREOTYPE_END",pattern:/>>/,pop_mode:!0}),nP=t0({name:"STEREOTYPE_TEXT",pattern:i6,line_breaks:!1}),nD=t0({name:"UNCLOSED_STEREOTYPE_TEXT",pattern:/[^\n\r]+/,line_breaks:!1,pop_mode:!0}),n$=t0({name:"CLASS_SEPARATOR",pattern:/:::/}),nK=t0({name:"FORWARD_SOLID",pattern:/--+>/}),nF=t0({name:"BACKWARD_SOLID",pattern:/<--+/}),nB=t0({name:"FORWARD_CIRCLE",pattern:/--o/}),nG=t0({name:"BACKWARD_CIRCLE",pattern:/o--/}),nW=t0({name:"FORWARD_CROSS",pattern:/--x/}),nj=t0({name:"BACKWARD_CROSS",pattern:/x--/}),nz=t0({name:"MARKERLESS_SOLID",pattern:/--+/}),nV=t0({name:"METADATA_START",pattern:/@{/}),nH=t0({name:"AT",pattern:/@/,categories:i5}),nY=t0({name:"LBRACE",pattern:/{/}),nX=t0({name:"RBRACE",pattern:/}/}),nJ=t0({name:"LBRACKET",pattern:/\[/}),nq=t0({name:"RBRACKET",pattern:/]/}),nZ=t0({name:"LPAREN",pattern:/\(/}),nQ=t0({name:"RPAREN",pattern:/\)/}),n0=t0({name:"COMMA",pattern:/,/,categories:i5}),n1=t0({name:"COLON",pattern:/:/,categories:i5}),n2=t0({name:"HASH_COLOR",pattern:/#[\dA-Fa-f]+/,categories:i5}),n6=t0({name:"PLAIN_STRING",pattern:/"[^\n\r"]*"|'[^\n\r']*'/}),n5=t0({name:"CSS_IDENTIFIER",pattern:/--[A-Z_a-z][\w-]*|[A-Z_a-z]\w*(?:-\w+)+/,categories:i5}),n4=t0({name:"CSS_ESCAPED_COMMA",pattern:/\\,/,categories:i5}),n3=t0({name:"DASH",pattern:/-/,categories:i5}),n9=t0({name:"DOT",pattern:/\./,categories:i5}),n8=t0({name:"PERCENT",pattern:/%/,categories:i5}),n7=t0({name:"CSS_PUNCTUATION",pattern:/[!#$&*+/=?^_|~]/,categories:i5}),ae=t0({name:"LABEL_PUNCTUATION",pattern:/[;<>\\`]/,categories:i5}),at=t0({name:"LABEL_SYMBOL",pattern:/[^\t\n\r !-~]+/,categories:i5}),as=[i5,i4,i8,i7,ne,nt,ns,ni,nr,no,nl,nu,np,nf,nm,nT,nA,nE,ng,ny,nL,nS,nR,nN,nO,nk,nI,nC,nb,nv,n_,nx,nU,nM,n$,nK,nF,nB,nG,nW,nj,nz,nV,nH,nY,nX,nJ,nq,nZ,nQ,n0,n1,n2,n6,n5,i9,i3,n4,n3,n9,n8,n7,ae,at],ai={defaultMode:"defaultMode",modes:{defaultMode:[...as],jsonBody:[nh,nc],stereotype:[nw,nP,nD]}},an=[...as,nh,nc,nw,nP,nD],aa=new tW(ai),ar=(0,y.K)(e=>tM(e,i5)||e.tokenType===n6||e.tokenType===i7,"isLabelToken"),ao={allowmixing:!0,newpage:!0,package:!0,rectangle:!0,skinparam:!0},al=new class extends iu{static{(0,y.K)(this,"UsecaseParser")}constructor(){super(an,{nodeLocationTracking:"full"}),this.RULE("start",()=>{this.CONSUME(nu),this.SUBRULE(this.lineEnd),this.MANY(()=>this.SUBRULE(this.line))}),this.RULE("line",()=>{this.OR([{ALT:(0,y.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{GATE:(0,y.K)(()=>this.isStatementStart(),"GATE"),ALT:(0,y.K)(()=>this.SUBRULE(this.statement),"ALT")}])}),this.RULE("statement",()=>{this.OR([{ALT:(0,y.K)(()=>this.SUBRULE(this.accTitleStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.accDescrStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.directionStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.actorStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.systemBoundaryStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.noteStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.jsonStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.classDefStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.classStatement),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.styleStatement),"ALT")},{GATE:(0,y.K)(()=>this.isMetadataAssignment(),"GATE"),ALT:(0,y.K)(()=>this.SUBRULE(this.metadataAssignmentStatement),"ALT")},{GATE:(0,y.K)(()=>!this.isForbiddenPlantUmlStatement(),"GATE"),ALT:(0,y.K)(()=>this.SUBRULE(this.entityStatement),"ALT")}])}),this.RULE("lineEnd",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(ns),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(t1),"ALT")}])}),this.RULE("blankLine",()=>{this.CONSUME(ns)}),this.RULE("commentLine",()=>{this.CONSUME(nt),this.SUBRULE(this.lineEnd)}),this.RULE("accTitleStatement",()=>{this.CONSUME(nr),this.SUBRULE(this.lineEnd)}),this.RULE("accDescrStatement",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(no),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(ni),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("actorStatement",()=>{this.CONSUME(np),this.SUBRULE(this.actorItem),this.OPTION(()=>{this.OR([{ALT:(0,y.K)(()=>this.AT_LEAST_ONE(()=>{this.CONSUME(n0),this.SUBRULE2(this.actorItem)}),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.relationTail),"ALT")}])}),this.SUBRULE(this.lineEnd)}),this.RULE("actorItem",()=>{this.SUBRULE(this.actorName),this.OPTION(()=>this.SUBRULE(this.metadata)),this.OPTION2(()=>this.SUBRULE(this.stereotype)),this.OPTION3(()=>this.SUBRULE(this.classSuffix))}),this.RULE("actorName",()=>{this.OR([{ALT:(0,y.K)(()=>{this.CONSUME(i9),this.OPTION(()=>{this.CONSUME(nZ),this.SUBRULE(this.nodeLabel),this.CONSUME(nQ)})},"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")}])}),this.RULE("actorDeclarationOnly",()=>{this.CONSUME(np),this.SUBRULE(this.actorItem),this.MANY(()=>{this.CONSUME(n0),this.SUBRULE2(this.actorItem)}),this.SUBRULE(this.lineEnd)}),this.RULE("entityStatement",()=>{this.SUBRULE(this.entityName),this.OPTION(()=>this.SUBRULE(this.relationTail)),this.SUBRULE(this.lineEnd)}),this.RULE("entityName",()=>{this.OR([{ALT:(0,y.K)(()=>{this.CONSUME(i9),this.OPTION(()=>{this.OR2([{ALT:(0,y.K)(()=>{this.CONSUME(nZ),this.SUBRULE(this.nodeLabel),this.CONSUME(nQ)},"ALT")},{ALT:(0,y.K)(()=>{this.CONSUME(nJ),this.SUBRULE2(this.nodeLabel),this.CONSUME(nq)},"ALT")}])})},"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")}]),this.OPTION2(()=>this.SUBRULE(this.useCaseMetadata)),this.OPTION3(()=>this.SUBRULE(this.stereotype)),this.OPTION4(()=>this.SUBRULE(this.classSuffix))}),this.RULE("nodeLabel",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")},{ALT:(0,y.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(i5)),"ALT")}])}),this.RULE("useCaseMetadata",()=>{this.SUBRULE(this.metadata)}),this.RULE("relationTail",()=>{this.OPTION({GATE:(0,y.K)(()=>this.LA(1).tokenType===i9&&this.LA(2).tokenType===nH,"GATE"),DEF:(0,y.K)(()=>{this.CONSUME(i9),this.CONSUME(nH)},"DEF")}),this.SUBRULE(this.arrow),this.SUBRULE(this.entityName)}),this.RULE("arrow",()=>{this.OR([{ALT:(0,y.K)(()=>this.SUBRULE(this.semanticRelation),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.forwardSolidOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.backwardSolidOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.markerlessSolidOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.forwardCircleOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.backwardCircleOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.forwardCrossOperator),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.backwardCrossOperator),"ALT")}])}),this.RULE("forwardSolidOperator",()=>{this.CONSUME(nK)}),this.RULE("backwardSolidOperator",()=>{this.CONSUME(nF),this.OPTION({GATE:(0,y.K)(()=>"<--"===this.LA(0).image&&this.hasLabeledRight([nz]),"GATE"),DEF:(0,y.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(nz)},"DEF")})}),this.RULE("markerlessSolidOperator",()=>{this.CONSUME(nz),this.OPTION({GATE:(0,y.K)(()=>"--"===this.LA(0).image&&this.hasLabeledRight([nK,nz,nB,nW]),"GATE"),DEF:(0,y.K)(()=>{this.SUBRULE(this.edgeLabel),this.OR([{ALT:(0,y.K)(()=>this.CONSUME(nK),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME2(nz),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nB),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nW),"ALT")}])},"DEF")})}),this.RULE("forwardCircleOperator",()=>{this.CONSUME(nB)}),this.RULE("backwardCircleOperator",()=>{this.CONSUME(nG),this.OPTION({GATE:(0,y.K)(()=>this.hasLabeledRight([nz]),"GATE"),DEF:(0,y.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(nz)},"DEF")})}),this.RULE("forwardCrossOperator",()=>{this.CONSUME(nW)}),this.RULE("backwardCrossOperator",()=>{this.CONSUME(nj),this.OPTION({GATE:(0,y.K)(()=>this.hasLabeledRight([nz]),"GATE"),DEF:(0,y.K)(()=>{this.SUBRULE(this.edgeLabel),this.CONSUME(nz)},"DEF")})}),this.RULE("edgeLabel",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")},{ALT:(0,y.K)(()=>this.AT_LEAST_ONE(()=>this.CONSUME(i5)),"ALT")}])}),this.RULE("semanticRelation",()=>{this.OR([{ALT:(0,y.K)(()=>{this.CONSUME(nU),this.CONSUME(n1),this.OR2([{ALT:(0,y.K)(()=>this.CONSUME(nC),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nb),"ALT")}])},"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nx),"ALT")}])}),this.RULE("metadata",()=>{this.CONSUME(nV),this.MANY(()=>this.CONSUME(ns)),this.OPTION(()=>{this.SUBRULE(this.metadataProperty),this.MANY2(()=>{this.SUBRULE(this.metadataSeparator),this.SUBRULE2(this.metadataProperty)}),this.OPTION2(()=>this.CONSUME(n0)),this.MANY3(()=>this.CONSUME2(ns))}),this.CONSUME(nX)}),this.RULE("metadataProperty",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(i9),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")}]),this.CONSUME(n1),this.OR2([{ALT:(0,y.K)(()=>this.CONSUME2(i9),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME2(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nv),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n_),"ALT")}])}),this.RULE("metadataSeparator",()=>{this.OR([{ALT:(0,y.K)(()=>{this.CONSUME(n0),this.MANY(()=>this.CONSUME(ns))},"ALT")},{ALT:(0,y.K)(()=>{this.AT_LEAST_ONE(()=>this.CONSUME2(ns)),this.OPTION(()=>this.CONSUME2(n0)),this.MANY2(()=>this.CONSUME3(ns))},"ALT")}])}),this.RULE("systemBoundaryStatement",()=>{this.CONSUME(nf),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(nm),this.SUBRULE2(this.lineEnd)}),this.RULE("systemBoundaryName",()=>{this.OR([{ALT:(0,y.K)(()=>{this.CONSUME(i9),this.OPTION(()=>{this.OR2([{ALT:(0,y.K)(()=>{this.CONSUME(nZ),this.SUBRULE(this.nodeLabel),this.CONSUME(nQ)},"ALT")},{ALT:(0,y.K)(()=>{this.CONSUME(nJ),this.SUBRULE2(this.nodeLabel),this.CONSUME(nq)},"ALT")}])})},"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")}])}),this.RULE("systemBoundaryContent",()=>{this.MANY(()=>{this.OR([{ALT:(0,y.K)(()=>this.SUBRULE(this.blankLine),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.commentLine),"ALT")},{ALT:(0,y.K)(()=>this.SUBRULE(this.boundaryElement),"ALT")}])})}),this.RULE("boundaryElement",()=>{this.OR([{ALT:(0,y.K)(()=>this.SUBRULE(this.actorDeclarationOnly),"ALT")},{ALT:(0,y.K)(()=>{this.SUBRULE(this.entityName),this.SUBRULE(this.lineEnd)},"ALT")}])}),this.RULE("metadataAssignmentStatement",()=>{this.SUBRULE(this.metadataAssignmentTarget),this.SUBRULE(this.metadata),this.SUBRULE(this.lineEnd)}),this.RULE("metadataAssignmentTarget",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(i9),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i7),"ALT")}])}),this.RULE("noteStatement",()=>{this.CONSUME(nS),this.CONSUME(nR),this.CONSUME(i9),this.SUBRULE(this.nodeLabel),this.SUBRULE(this.lineEnd)}),this.RULE("stereotype",()=>{this.CONSUME(nM),this.CONSUME(nP),this.CONSUME(nw)}),this.RULE("classSuffix",()=>{this.CONSUME(n$),this.CONSUME(i9),this.MANY(()=>{this.CONSUME(n0),this.CONSUME2(i9)})}),this.RULE("jsonStatement",()=>{this.CONSUME(nl),this.CONSUME(nh),this.OPTION(()=>this.SUBRULE(this.classSuffix)),this.SUBRULE(this.lineEnd)}),this.RULE("directionStatement",()=>{this.CONSUME(nT),this.OR([{ALT:(0,y.K)(()=>this.CONSUME(nA),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nE),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(ng),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(ny),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nL),"ALT")}]),this.SUBRULE(this.lineEnd)}),this.RULE("classDefStatement",()=>{this.CONSUME(nO),this.CONSUME(i9),this.MANY(()=>{this.CONSUME(n0),this.CONSUME2(i9)}),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("classStatement",()=>{this.CONSUME(nk),this.CONSUME(i9),this.MANY(()=>{this.CONSUME(n0),this.CONSUME2(i9)}),this.CONSUME3(i9),this.MANY2(()=>{this.CONSUME2(n0),this.CONSUME4(i9)}),this.SUBRULE(this.lineEnd)}),this.RULE("styleStatement",()=>{this.CONSUME(nI),this.CONSUME(i9),this.SUBRULE(this.styles),this.SUBRULE(this.lineEnd)}),this.RULE("styles",()=>{this.SUBRULE(this.styleValue),this.MANY(()=>{this.CONSUME(n0),this.SUBRULE2(this.styleValue)})}),this.RULE("styleValue",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(i4),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n5),"ALT")},{ALT:(0,y.K)(()=>{this.CONSUME(nz),this.CONSUME2(i4)},"ALT")}]),this.CONSUME(n1),this.AT_LEAST_ONE(()=>this.SUBRULE(this.styleComponent))}),this.RULE("styleComponent",()=>{this.OR([{ALT:(0,y.K)(()=>this.CONSUME(i4),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n6),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(i3),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n2),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n5),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n4),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n3),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n9),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n8),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n7),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(n1),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nZ),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nQ),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nJ),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nq),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nY),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nX),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nH),"ALT")},{ALT:(0,y.K)(()=>this.CONSUME(nz),"ALT")}])}),this.performSelfAnalysis()}isMetadataAssignment(){let e=this.LA(1).tokenType;return(e===i9||e===n6||e===i7)&&this.LA(2).tokenType===nV}isStatementStart(){let e=this.LA(1).tokenType;return e!==t1&&e!==ns&&e!==nt}isForbiddenPlantUmlStatement(){return this.LA(1).tokenType===i9&&!0===ao[this.LA(1).image.toLowerCase()]}hasLabeledRight(e){if(!ar(this.LA(1)))return!1;for(let t=2;;t++){let s=this.LA(t);if(e.includes(s.tokenType))return!0;if(!ar(s))return!1}}},ah=class extends Error{constructor(e,t,s){super(`${e} (line ${t}, column ${s})`),this.line=t,this.column=s,this.name="UsecaseJsonError"}static{(0,y.K)(this,"UsecaseJsonError")}},ac=(0,y.K)((e,t,s,i)=>{let n=s,a=i,r=Math.min(Math.max(t,0),e.length);for(let t=0;t<r;t++){let s=e[t];"\r"===s?(n++,a=1):"\n"===s?(0===t||"\r"!==e[t-1])&&(n++,a=1):a++}return{line:n,column:a}},"locationAtOffset"),ad=(0,y.K)((e,t,s,i)=>{let n=/\bposition (\d+)\b/u.exec(e);if(n)return ac(t,Number.parseInt(n[1],10),s,i);let a=/\bline (\d+) column (\d+)\b/u.exec(e);if(a){let e=Number.parseInt(a[1],10),t=Number.parseInt(a[2],10);return{line:s+e-1,column:1===e?i+t-1:t}}if(/unexpected end|end of json input/iu.test(e))return ac(t,t.length,s,i)},"locationFromErrorMessage"),au=class extends Error{constructor(e){super("Invalid JSON token"),this.offset=e}static{(0,y.K)(this,"JsonWalkError")}},ap=class{constructor(e){this.text=e,this.offset=0,this.propertyOrder={}}static{(0,y.K)(this,"PropertyOrderCollector")}collect(){if(this.skipWhitespace(),this.collectValue(""),this.skipWhitespace(),this.offset!==this.text.length)throw new au(this.offset);return this.propertyOrder}collectValue(e){this.skipWhitespace();let t=this.text[this.offset];if("{"===t)this.collectObject(e);else if("["===t)this.collectArray(e);else if('"'===t)this.readString(!1);else if("t"===t)this.consumeLiteral("true");else if("f"===t)this.consumeLiteral("false");else if("n"===t)this.consumeLiteral("null");else if("-"===t||t>="0"&&t<="9")this.consumeNumber();else throw new au(this.offset)}collectObject(e){this.offset++;let t=[],s=new Set;if(this.propertyOrder[e]=t,this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;for(;this.offset<this.text.length&&'"'===this.text[this.offset];){let i=this.readString(!0),n=`${e}/${i.replaceAll("~","~0").replaceAll("/","~1")}`;if(s.has(i)?this.deletePointerSubtree(n):(s.add(i),t.push(i)),this.skipWhitespace(),":"!==this.text[this.offset])break;if(this.offset++,this.collectValue(n),this.skipWhitespace(),"}"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new au(this.offset)}collectArray(e){if(this.offset++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;let t=0;for(;this.offset<this.text.length;){if(this.collectValue(`${e}/${t}`),t++,this.skipWhitespace(),"]"===this.text[this.offset])return void this.offset++;if(","!==this.text[this.offset])break;this.offset++,this.skipWhitespace()}throw new au(this.offset)}readString(e){this.offset++;let t="";for(;this.offset<this.text.length;){let s=this.offset,i=this.text[this.offset++];if('"'===i)return t;if(32>i.charCodeAt(0))throw new au(s);if("\\"!==i){e&&(t+=i);continue}let n=this.offset,a=this.text[this.offset++];switch(a){case'"':case"\\":case"/":e&&(t+=a);break;case"b":e&&(t+="\b");break;case"f":e&&(t+="\f");break;case"n":e&&(t+="\n");break;case"r":e&&(t+="\r");break;case"t":e&&(t+=" ");break;case"u":{let s=this.text.slice(this.offset,this.offset+4);if(!/^[\dA-Fa-f]{4}$/u.test(s))throw new au(this.offset);e&&(t+=String.fromCharCode(Number.parseInt(s,16))),this.offset+=4;break}default:throw new au(n)}}throw new au(this.offset)}consumeLiteral(e){let t=0;for(let s of e){if(this.text[this.offset+t]!==s)throw new au(this.offset+t);t++}this.offset+=e.length}consumeNumber(){if("-"===this.text[this.offset]&&this.offset++,"0"===this.text[this.offset])this.offset++;else if(this.text[this.offset]>="1"&&this.text[this.offset]<="9")for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++;else throw new au(this.offset);if("."===this.text[this.offset]){if(this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new au(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}if("e"===this.text[this.offset]||"E"===this.text[this.offset]){if(this.offset++,("+"===this.text[this.offset]||"-"===this.text[this.offset])&&this.offset++,this.text[this.offset]<"0"||this.text[this.offset]>"9")throw new au(this.offset);for(;this.text[this.offset]>="0"&&this.text[this.offset]<="9";)this.offset++}}skipWhitespace(){for(;this.offset<this.text.length;){let e=this.text[this.offset];if(" "!==e&&" "!==e&&"\n"!==e&&"\r"!==e)return;this.offset++}}deletePointerSubtree(e){let t=`${e}/`;for(let s of Object.keys(this.propertyOrder))(s===e||s.startsWith(t))&&delete this.propertyOrder[s]}};function af(e,t,s){let i;try{i=JSON.parse(e)}catch(a){let i=a instanceof Error?a.message:String(a),n=ad(i,e,t,s);if(!n){let i=0;try{new ap(e).collect()}catch(e){e instanceof au&&(i=e.offset)}n=ac(e,i,t,s)}throw new ah(`Invalid JSON: ${i}`,n.line,n.column)}if("object"!=typeof i||null===i||Array.isArray(i))throw new ah("JSON value must have an object root",t,s);return{value:i,propertyOrder:new ap(e).collect()}}(0,y.K)(af,"parseOrderedJsonObject");var am=(0,y.K)(e=>({shape:"normal"===e.type?"actor":"hollow"===e.type?"actor-hollow":"awesome"===e.type?"actor-awesome":"actor-icon",...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"actor",actorType:e.type,business:e.business,labelType:e.labelType,...e.icon?{icon:e.icon}:{},...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"actorNode"),aT=(0,y.K)(e=>({shape:e.shape,...e.label===e.id?{}:{label:e.label},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"usecase",useCaseShape:e.shape,business:e.business,labelType:e.labelType,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{}}}),"useCaseNode"),aA=(0,y.K)(e=>({label:e.label,shape:"note",attrs:{kind:"note",target:e.target,labelType:e.labelType}}),"noteNode"),aE=(0,y.K)(e=>({label:e.id,shape:"json-table",...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{kind:"json",value:e.value,propertyOrder:e.propertyOrder,labelType:"text"}}),"jsonNode"),ag=(0,y.K)(e=>({id:e.id,source:e.source,target:e.target,...e.label?{label:e.label}:{},...e.classes.length?{classes:[...e.classes]}:{},...e.styles.length?{styles:[...e.styles]}:{},attrs:{relationshipType:e.type,arrowType:e.arrowType,minlen:e.minlen,explicitId:e.explicitId,animate:e.animate,...e.animation?{animation:e.animation}:{},...e.labelType?{labelType:e.labelType}:{}}}),"relationshipEdge"),ay=(0,y.K)(e=>({id:`${e.id}-edge`,source:e.id,target:e.target,attrs:{relationshipType:"note",arrowType:2,pattern:"dotted",minlen:1,explicitId:!1,animate:!1,internal:!0}}),"noteEdge"),aL=(0,y.K)((e,t,s,i)=>{let n={};for(let t of e.getActors().values())n[t.id]=am(t);for(let t of e.getUseCases().values())n[t.id]=aT(t);for(let t of e.getNotes().values())n[t.id]=aA(t);for(let t of e.getJsonNodes().values())n[t.id]=aE(t);let a={};for(let t of e.getSystemBoundaries().values())a[t.id]={...t.label===t.id?{}:{title:t.label},nodes:[...t.members],...t.classes.length?{classes:[...t.classes]}:{},...t.styles.length?{styles:[...t.styles]}:{},attrs:{kind:"systemBoundary",boundaryType:t.type,labelType:t.labelType}};let r={};for(let t of e.getClassDefs().values())r[t.id]={styles:[...t.styles]};let o=e.getDirection();return{version:1,diagramType:"usecase",source:t,header:{keyword:"usecase",direction:"TD"===o?"TB":o,span:s},...e.getAccTitle()?{accTitle:e.getAccTitle()}:{},...e.getAccDescription()?{accDescr:e.getAccDescription()}:{},nodes:n,edges:[...e.getRelationships().map(ag),...[...e.getNotes().values()].map(ay)],groups:a,classDefs:r,statements:i}},"buildUsecaseGraphAST"),aS=(0,y.K)(e=>`line ${e.line}, column ${e.column} [${e.span[0]},${e.span[1]})`,"locationText"),aR=(0,y.K)(e=>void 0===e?"":` (label "${e}")`,"labelSuffix"),aN=(0,y.K)(e=>e.generated?e.label:void 0,"generatedFrom"),aO=(0,y.K)((e,t)=>{for(let s of t)e.includes(s)||e.push(s)},"pushUnique"),ak=class{constructor(e){this.db=e,this.source="",this.statements=[],this.elements=[],this.boundaries=[],this.jsonDrafts=[],this.relationshipDrafts=[],this.noteDrafts=[],this.metadataAssignments=[],this.classAssignments=[],this.styleAssignments=[],this.classDefinitions=[],this.directions=[],this.model=e.createModel()}static{(0,y.K)(this,"UsecaseModelBuilder")}reset(e){this.model=this.db.createModel(),this.source=e,this.statements=[],this.elements.length=0,this.boundaries.length=0,this.jsonDrafts.length=0,this.relationshipDrafts.length=0,this.noteDrafts.length=0,this.metadataAssignments.length=0,this.classAssignments.length=0,this.styleAssignments.length=0,this.classDefinitions.length=0,this.directions.length=0}addElement(e){this.elements.push(e)}addBoundary(e){this.boundaries.push(e)}addJson(e){this.jsonDrafts.push(e)}addRelationship(e){this.relationshipDrafts.push(e)}addNote(e){this.noteDrafts.push(e)}addMetadataAssignment(e,t,s,i){this.metadataAssignments.push({target:e,targetLocation:t,metadata:s,statement:i})}addClassDef(e,t){this.classDefinitions.push({ids:e,styles:t})}addClassAssignment(e,t){this.classAssignments.push({targets:e,classes:t})}addStyleAssignment(e,t,s){this.styleAssignments.push({target:e,location:t,styles:s})}setDirection(e){this.directions.push("TD"===e?"TB":e)}setAccTitle(e){this.model.accTitle=e}setAccDescription(e){this.model.accDescription=e}setStatements(e){this.statements=e}getActors(){return this.model.actors}getUseCases(){return this.model.useCases}getSystemBoundaries(){return this.model.systemBoundaries}getRelationships(){return this.model.relationships}getNotes(){return this.model.notes}getJsonNodes(){return this.model.jsonNodes}getClassDefs(){return this.model.classDefs}getDirection(){return this.model.direction}getAccTitle(){return this.model.accTitle}getAccDescription(){return this.model.accDescription}finalize(e){let t=new Map,s=new Map,i=new Map,n=new Map;for(let e of this.relationshipDrafts)this.recordFirst(n,e.source.id,e.source.location.span[0]),this.recordFirst(n,e.target.id,e.target.location.span[0]);for(let e of this.elements)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.boundaries)this.recordFirst(n,e.id,e.location.span[0]);for(let e of this.jsonDrafts)this.recordFirst(n,e.id,e.location.span[0]);for(let e of[...this.elements.map(e=>({offset:e.location.span[0],type:"element",value:e})),...this.boundaries.map(e=>({offset:e.location.span[0],type:"boundary",value:e})),...this.jsonDrafts.map(e=>({offset:e.location.span[0],type:"json",value:e})),...this.relationshipDrafts.filter(e=>e.explicitId).map(e=>({offset:e.explicitIdLocation.span[0],type:"edge",value:e}))].sort((e,t)=>e.offset-t.offset))"element"===e.type?this.collectElement(e.value,t,s):"boundary"===e.type?this.collectBoundary(e.value,t,i):"json"===e.type?this.registerUnique(t,e.value.id,"json",e.value.location,!1):this.registerUnique(t,e.value.explicitId,"edge",e.value.explicitIdLocation,!1);this.materializeElements(s,n),this.materializeBoundaries(i,n),this.materializeJson(n);let a=this.materializeRelationships(t,s,n);this.reorderElements(s,n),this.applyMetadataAssignments(t,s,i,a),this.validateAndRefreshElements(s),this.refreshBoundaries(i,s),this.materializeNotes(t),this.applyClassDefinitions(),this.applyClassesAndStyles(t,a),this.model.direction=this.directions.at(-1)??this.model.direction,this.model.symbols=new Map([...t].map(([e,t])=>[e,t.kind]));let r=aL(this,this.source,e,this.statements);return this.model.ast=r,this.db.commit(this.model),r}collectElement(e,t,s){let i=t.get(e.id),n=aN({generated:e.generated,label:e.label.text});i&&i.kind!==e.kind&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and ${e.kind}`,e.location,i.location,n,aN(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,n,aN(i));let a=s.get(e.id);if(!a){let i={kind:e.kind,id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],...e.parentId?{parentId:e.parentId,parentLocation:e.parentLocation}:{},...e.shape?{shape:e.shape}:{},...e.stereotype?{stereotype:e.stereotype,stereotypeLocation:e.location}:{}};this.applyDeclarationMetadata(i,e.metadata),s.set(e.id,i),t.set(e.id,{kind:e.kind,location:e.location,generated:e.generated,label:e.label.text});return}(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`ID '${e.id}' has conflicting labels`,e.location,a.location),e.shape&&a.shape&&e.shape!==a.shape&&this.conflict(`Use case '${e.id}' has conflicting shapes`,e.location,a.location),e.parentId&&a.parentId&&e.parentId!==a.parentId&&this.conflict(`Element '${e.id}' belongs to more than one system boundary`,e.parentLocation??e.location,a.parentLocation??a.location),e.stereotype&&a.stereotype&&e.stereotype!==a.stereotype&&this.conflict(`Element '${e.id}' has conflicting stereotypes`,e.location,a.stereotypeLocation??a.location),a.shape??=e.shape,a.parentId??=e.parentId,a.parentLocation??=e.parentLocation,a.stereotype??=e.stereotype,a.stereotypeLocation??=e.stereotype?e.location:void 0,aO(a.classes,e.classes),this.applyDeclarationMetadata(a,e.metadata)}collectBoundary(e,t,s){let i=t.get(e.id),n=aN({generated:e.generated,label:e.label.text});i&&"boundary"!==i.kind&&this.conflict(`ID '${e.id}' is declared as both ${i.kind} and boundary`,e.location,i.location,n,aN(i)),i&&(i.generated||e.generated)&&this.conflict(`Generated ID '${e.id}' collides with another declaration`,e.location,i.location,n,aN(i));let a=s.get(e.id);if(a){(a.label.text!==e.label.text||a.label.type!==e.label.type)&&this.conflict(`Boundary '${e.id}' has conflicting titles`,e.location,a.location),aO(a.classes,e.classes);return}s.set(e.id,{id:e.id,label:e.label,location:e.location,generated:e.generated,classes:[...e.classes],styles:[],members:[]}),t.set(e.id,{kind:"boundary",location:e.location,generated:e.generated,label:e.label.text})}materializeElements(e,t){for(let s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.setElementModel(s)}materializeBoundaries(e,t){for(let s of[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))this.model.systemBoundaries.set(s.id,{id:s.id,label:s.label.text,labelType:s.label.type,type:s.type??"rect",members:[],classes:[...s.classes],styles:[...s.styles]})}materializeJson(e){for(let t of[...this.jsonDrafts].sort((t,s)=>(e.get(t.id)??0)-(e.get(s.id)??0)))this.model.jsonNodes.set(t.id,{id:t.id,value:t.value,propertyOrder:t.propertyOrder,classes:[...t.classes],styles:[]})}materializeRelationships(e,t,s){let i=new Map,n=0;for(let a of this.relationshipDrafts){let r=this.resolveEndpoint(a.source,e,t,s),o=this.resolveEndpoint(a.target,e,t,s);this.validateRelationship(a,r,o,e);let l=a.explicitId??`edge-${n++}`,h={id:l,explicitId:!!a.explicitId,source:a.source.id,target:a.target.id,type:a.type,arrowType:a.arrowType,...a.label?{label:a.label.text,labelType:a.label.type}:{},minlen:a.minlen,classes:[],styles:[],animate:!1};this.model.relationships.push(h),i.set(l,{draft:a,relationship:h})}return this.model.relationshipCounter=n,i}resolveEndpoint(e,t,s,i){if(e.classesOnReference&&!e.declaration)throw Error(`Relationship endpoint '${e.id}' uses ::: without declaring the node at ${aS(e.location)}`);let n=t.get(e.id);return n?n.kind:(s.set(e.id,{kind:"usecase",id:e.id,label:e.label,location:e.location,generated:e.generated,shape:"ellipse",classes:[]}),t.set(e.id,{kind:"usecase",location:e.location,generated:e.generated,label:e.label.text}),this.recordFirst(i,e.id,e.location.span[0]),"usecase")}reorderElements(e,t){let s=new Map(this.model.actors),i=new Map(this.model.useCases);for(let n of(this.model.actors.clear(),this.model.useCases.clear(),[...e.values()].sort((e,s)=>(t.get(e.id)??0)-(t.get(s.id)??0)))){s.has(n.id)||i.has(n.id)||this.setElementModel(n);let e=s.get(n.id)??this.model.actors.get(n.id),t=i.get(n.id)??this.model.useCases.get(n.id);e?this.model.actors.set(n.id,e):t&&this.model.useCases.set(n.id,t)}}applyMetadataAssignments(e,t,s,i){for(let n of this.metadataAssignments){let a=e.get(n.target);if(!a){let e=this.inferMetadataKind(n.metadata);throw Error(`Metadata target '${n.target}' is unresolved${e?` (metadata implies ${e})`:""} at ${aS(n.targetLocation)}`)}if("actor"===a.kind||"usecase"===a.kind)this.applyStandaloneElementMetadata(t.get(n.target),n.metadata);else if("boundary"===a.kind){let e=s.get(n.target);for(let t of n.metadata.properties)("type"!==t.key||"rect"!==t.value&&"package"!==t.value)&&this.invalidMetadata(n.target,a.kind,t),e.type=t.value}else if("edge"===a.kind){let e=i.get(n.target);if(!e)throw Error(`Metadata target '${n.target}' is not an explicit edge at ${aS(n.targetLocation)}`);for(let t of(n.statement.kind="edgeMetadata",n.statement.edges=[{id:n.target,span:n.statement.span,idSpan:n.targetLocation.span,...n.statement.metadata?{metadata:n.statement.metadata}:{}}],delete n.statement.nodes,n.metadata.properties))"animate"===t.key&&"boolean"==typeof t.value?e.relationship.animate=t.value:"animation"===t.key&&("fast"===t.value||"slow"===t.value)?(e.relationship.animation=t.value,e.relationship.animate=!0):this.invalidMetadata(n.target,a.kind,t)}else for(let e of n.metadata.properties)this.invalidMetadata(n.target,a.kind,e)}for(let{relationship:e}of i.values())e.animation&&(e.animate=!0)}applyStandaloneElementMetadata(e,t){for(let s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!0):"business"===s.key&&"boolean"==typeof s.value?e.business=s.value:this.invalidMetadata(e.id,e.kind,s)}applyDeclarationMetadata(e,t){if(t)for(let s of t.properties)"actor"===e.kind?this.applyActorProperty(e,s,!1):"business"===s.key&&"boolean"==typeof s.value?(void 0!==e.business&&e.business!==s.value&&this.conflict(`Use case '${e.id}' has conflicting business metadata`,s.location,e.location),e.business=s.value):this.invalidMetadata(e.id,e.kind,s)}applyActorProperty(e,t,s){"type"===t.key&&("normal"===t.value||"hollow"===t.value||"awesome"===t.value)?(s||void 0===e.actorType||e.actorType===t.value||this.conflict(`Actor '${e.id}' has conflicting type metadata`,t.location,e.location),e.actorType=t.value):"icon"===t.key&&"string"==typeof t.value?(s||void 0===e.icon||e.icon===t.value||this.conflict(`Actor '${e.id}' has conflicting icon metadata`,t.location,e.location),e.icon=t.value):"business"===t.key&&"boolean"==typeof t.value?(s||void 0===e.business||e.business===t.value||this.conflict(`Actor '${e.id}' has conflicting business metadata`,t.location,e.location),e.business=t.value):this.invalidMetadata(e.id,e.kind,t)}validateAndRefreshElements(e){for(let t of e.values()){let e=t.icon?"icon":t.actorType??"normal";if("actor"===t.kind){if(t.icon&&t.actorType&&"normal"!==t.actorType)throw Error(`Actor '${t.id}' cannot combine icon with type '${t.actorType}' at ${aS(t.location)}`);if(t.business&&("icon"===e||"awesome"===e))throw Error(`Business actor '${t.id}' must use normal or hollow geometry at ${aS(t.location)}`)}else if((t.shape??"ellipse")==="rect"&&t.business)throw Error(`Rectangular use case '${t.id}' cannot be a business use case at ${aS(t.location)}`);this.setElementModel(t)}}refreshBoundaries(e,t){for(let t of e.values())t.members.length=0;for(let t of[...this.elements].sort((e,t)=>e.location.span[0]-t.location.span[0])){if(!t.parentId)continue;let s=e.get(t.parentId);if(!s)throw Error(`Parent boundary '${t.parentId}' for '${t.id}' is unresolved at ${aS(t.parentLocation??t.location)}`);s.members.includes(t.id)||s.members.push(t.id)}for(let s of t.values())if(s.parentId&&!e.has(s.parentId))throw Error(`Parent boundary '${s.parentId}' for '${s.id}' is unresolved at ${aS(s.parentLocation??s.location)}`);for(let t of e.values()){let e=this.model.systemBoundaries.get(t.id);e.type=t.type??"rect",e.members=[...t.members],e.classes=[...t.classes],e.styles=[...t.styles]}}materializeNotes(e){let t=0;for(let s of this.noteDrafts){let i=e.get(s.target);if(!i)throw Error(`Note target '${s.target}' is unresolved at ${aS(s.targetLocation)}`);"actor"!==i.kind&&"usecase"!==i.kind&&this.conflict(`Note target '${s.target}' must be an actor or use case, not ${i.kind}`,s.targetLocation,i.location);let n=`note-${t++}`;this.model.notes.set(n,{id:n,target:s.target,label:s.label.text,labelType:s.label.type})}this.model.noteCounter=t}applyClassDefinitions(){for(let e of this.classDefinitions)for(let t of e.ids)this.model.classDefs.set(t,{id:t,styles:[...e.styles]})}applyClassesAndStyles(e,t){for(let s of this.classAssignments)for(let i of s.targets)aO(this.getStylable(i.id,e,t,i.location).classes,s.classes);for(let s of this.styleAssignments)this.getStylable(s.target,e,t,s.location).styles.push(...s.styles)}getStylable(e,t,s,i){let n=t.get(e)?.kind,a="actor"===n?this.model.actors.get(e):"usecase"===n?this.model.useCases.get(e):"boundary"===n?this.model.systemBoundaries.get(e):"json"===n?this.model.jsonNodes.get(e):"edge"===n?s.get(e)?.relationship:void 0;if(!a)throw Error(`Class/style target '${e}' is unresolved or anonymous at ${aS(i)}`);return a}validateRelationship(e,t,s,i){let n=(0,y.K)(e=>"actor"===e||"usecase"===e||"json"===e,"allowed");if(n(t)||this.conflict(`Relationship source '${e.source.id}' cannot be ${t}`,e.source.location,i.get(e.source.id).location),n(s)||this.conflict(`Relationship target '${e.target.id}' cannot be ${s}`,e.target.location,i.get(e.target.id).location),("include"===e.type||"extend"===e.type)&&("usecase"!==t||"usecase"!==s))throw Error(`${e.type} relationship requires use-case endpoints at ${aS(e.location)}`);if("generalization"===e.type&&("actor"!==t&&"usecase"!==t||t!==s))throw Error(`Generalization requires actor-to-actor or use-case-to-use-case endpoints at ${aS(e.location)}`);if("association"===e.type&&("json"===t||"json"===s)&&![0,1,2].includes(e.arrowType))throw Error(`JSON relationship '${e.source.id}' to '${e.target.id}' permits only point, reversed-point, or markerless solid association at ${aS(e.location)}`)}setElementModel(e){if("actor"===e.kind){let t=e.icon?"icon":e.actorType??"normal";this.model.useCases.delete(e.id),this.model.actors.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,type:t,...e.icon?{icon:e.icon}:{},business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.actors.get(e.id)?.styles??[]})}else this.model.actors.delete(e.id),this.model.useCases.set(e.id,{id:e.id,label:e.label.text,labelType:e.label.type,shape:e.shape??"ellipse",business:e.business??!1,...e.stereotype?{stereotype:e.stereotype}:{},...e.parentId?{parentId:e.parentId}:{},classes:[...e.classes],styles:this.model.useCases.get(e.id)?.styles??[]})}inferMetadataKind(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let s of e.properties)if("icon"===s.key)t.clear(),t.add("actor");else if("animate"===s.key||"animation"===s.key)t.clear(),t.add("edge");else if("type"===s.key)t.clear(),"rect"===s.value||"package"===s.value?t.add("boundary"):("normal"===s.value||"hollow"===s.value||"awesome"===s.value)&&t.add("actor");else{if("business"!==s.key)return;t.delete("boundary"),t.delete("edge")}return 1===t.size?[...t][0]:void 0}invalidMetadata(e,t,s){throw Error(`Metadata property '${s.key}' is invalid for ${t} '${e}' at ${aS(s.location)}`)}registerUnique(e,t,s,i,n){let a=e.get(t);a&&this.conflict(`ID '${t}' is declared more than once (${a.kind} and ${s})`,i,a.location,void 0,aN(a)),e.set(t,{kind:s,location:i,generated:n})}recordFirst(e,t,s){let i=e.get(t);(void 0===i||s<i)&&e.set(t,s)}conflict(e,t,s,i,n){throw Error(`${e} at ${aS(t)}${aR(i)}; previous declaration at ${aS(s)}${aR(n)}`)}},aI=al.getBaseCstVisitorConstructor(),aC=new class extends aI{constructor(){super(),this.builder=new ak(iX),this.source="",this.anonymousEdge=0,this.anonymousNote=0,this.validateVisitor()}static{(0,y.K)(this,"UsecaseVisitor")}build(e,t){this.source=t,this.parentBoundary=void 0,this.anonymousEdge=0,this.anonymousNote=0,this.builder.reset(t),this.visit(e)}start(e){let t=this.tokens(e,"USECASE")[0],s=[];for(let t of this.nodes(e,"line"))s.push(this.visit(t));this.builder.setStatements(s),this.builder.finalize(this.tokenSpan(t))}line(e){let t=this.firstNode(e,"blankLine","commentLine","statement");return this.wrap(t,this.visit(t))}statement(e){return this.visit(this.firstNode(e,"accTitleStatement","accDescrStatement","directionStatement","actorStatement","systemBoundaryStatement","noteStatement","jsonStatement","classDefStatement","classStatement","styleStatement","metadataAssignmentStatement","entityStatement"))}lineEnd(e){}blankLine(e){return{kind:"blank",span:this.tokenSpan(this.tokens(e,"NEWLINE")[0])}}commentLine(e){return{kind:"comment",span:this.tokenSpan(this.tokens(e,"COMMENT")[0])}}accTitleStatement(e){let t=this.tokens(e,"ACC_TITLE_LINE")[0].image;return this.builder.setAccTitle(t.slice(t.indexOf(":")+1).trim()),{kind:"accTitle",span:[0,0]}}accDescrStatement(e){let t=this.tokens(e,"ACC_DESCR_LINE")[0],s=this.tokens(e,"ACC_DESCR_BLOCK")[0],i=t?t.image.slice(t.image.indexOf(":")+1).trim():s.image.slice(s.image.indexOf("{")+1,s.image.lastIndexOf("}")).trim();return this.builder.setAccDescription(i),{kind:"accDescr",span:[0,0]}}actorStatement(e){let t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e)),i=this.nodes(e,"relationTail")[0],n=s.map((e,s)=>this.actorOccurrence(t[s],e,!0));for(let e of s)this.builder.addElement(this.actorDraft(e));if(!i)return{kind:"node",span:[0,0],nodes:n};let a=this.visit(i);a.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(a.target));let r=this.relationshipDraft(s[0],a,this.nodeLocation(i));this.builder.addRelationship(r);let o=r.explicitId??`edge-${this.anonymousEdge++}`;return n.push(this.entityOccurrence(this.nodes(i.children,"entityName")[0],a.target,a.target.explicitDeclaration)),{kind:"edge",span:[0,0],nodes:n,edges:[{id:o,span:[0,0],...r.explicitIdLocation?{idSpan:r.explicitIdLocation.span}:{},...r.label?{labelSpan:r.label.span}:{}}]}}actorItem(e){let t=this.visit(this.nodes(e,"actorName")[0]),s=this.nodes(e,"metadata")[0],i=this.nodes(e,"stereotype")[0],n=this.nodes(e,"classSuffix")[0],a=n?this.visit(n):{classes:[],spans:[]};return{...t,...s?{metadata:this.visit(s)}:{},...i?{stereotype:this.visit(i)}:{},classes:a.classes,classSpans:a.spans}}actorName(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0];if(t){let s=this.nodes(e,"nodeLabel")[0],i=s?this.visit(s):this.tokenLabel(t);return{id:t.image,label:i,location:this.tokenLocation(t),generated:!1,classes:[],classSpans:[]}}let i=this.tokenLabel(s);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(s),generated:!0,classes:[],classSpans:[]}}actorDeclarationOnly(e){let t=this.nodes(e,"actorItem"),s=t.map(e=>this.visit(e));for(let e of s)this.builder.addElement(this.actorDraft(e));return{kind:"node",span:[0,0],nodes:s.map((e,s)=>this.actorOccurrence(t[s],e,!0))}}entityStatement(e){let t=this.nodes(e,"entityName"),s=this.visit(t[0]),i=this.nodes(e,"relationTail")[0];if(!i)return s.explicitDeclaration=!0,s.shape??="ellipse",this.builder.addElement(this.entityDraft(s)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(t[0],s,!0)]};s.explicitDeclaration&&this.builder.addElement(this.entityDraft(s));let n=this.visit(i);n.target.explicitDeclaration&&this.builder.addElement(this.entityDraft(n.target));let a={source:this.endpoint(s),target:this.endpoint(n.target),location:this.nodeLocation(i),...n.explicitId?{explicitId:n.explicitId,explicitIdLocation:n.explicitIdLocation}:{},...n.arrow};this.builder.addRelationship(a);let r=a.explicitId??`edge-${this.anonymousEdge++}`;return{kind:"edge",span:[0,0],nodes:[this.entityOccurrence(t[0],s,s.explicitDeclaration),this.entityOccurrence(this.nodes(i.children,"entityName")[0],n.target,n.target.explicitDeclaration)],edges:[{id:r,span:[0,0],...a.explicitIdLocation?{idSpan:a.explicitIdLocation.span}:{},...a.label?{labelSpan:a.label.span}:{}}]}}entityName(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.nodes(e,"nodeLabel")[0],n=this.nodes(e,"useCaseMetadata")[0],a=this.nodes(e,"stereotype")[0],r=this.nodes(e,"classSuffix")[0],o=r?this.visit(r):{classes:[],spans:[]};if(t){let s=i?this.visit(i):this.tokenLabel(t),r=i?this.tokens(e,"LBRACKET").length?"rect":"ellipse":void 0;return{id:t.image,label:s,location:this.tokenLocation(t),generated:!1,...r?{shape:r}:{},...n?{metadata:this.visit(n)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(r||n||a)}}let l=this.tokenLabel(s);return{id:this.generateId(l.text),label:l,location:this.tokenLocation(s),generated:!0,...n?{metadata:this.visit(n)}:{},...a?{stereotype:this.visit(a)}:{},classes:o.classes,classSpans:o.spans,explicitDeclaration:!!(n||a)}}nodeLabel(e){let t=this.allTokens(e);if(1===t.length&&("PLAIN_STRING"===t[0].tokenType.name||"MARKDOWN_STRING"===t[0].tokenType.name))return this.tokenLabel(t[0]);let s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return{text:this.source.slice(s[0],s[1]),type:"text",span:s}}useCaseMetadata(e){return this.visit(this.nodes(e,"metadata")[0])}relationTail(e){let t=this.tokens(e,"IDENTIFIER")[0];return{...t?{explicitId:t.image,explicitIdLocation:this.tokenLocation(t)}:{},arrow:this.visit(this.nodes(e,"arrow")[0]),target:this.visit(this.nodes(e,"entityName")[0])}}arrow(e){return this.visit(this.firstNode(e,"semanticRelation","forwardSolidOperator","backwardSolidOperator","markerlessSolidOperator","forwardCircleOperator","backwardCircleOperator","forwardCrossOperator","backwardCrossOperator"))}edgeLabel(e){return this.nodeLabel(e)}semanticRelation(e){if(this.tokens(e,"GENERALIZATION").length)return{type:"generalization",arrowType:0,minlen:1};let t=this.tokens(e,"INCLUDE").length?"include":"extend",s=this.tokens(e,"include"===t?"INCLUDE":"EXTEND")[0];return{type:t,arrowType:0,label:{text:t,type:"text",span:this.tokenSpan(s)},minlen:1}}metadata(e){return{properties:this.nodes(e,"metadataProperty").map(e=>this.visit(e)),location:this.ctxLocation(e)}}metadataProperty(e){let t=this.allTokens(e).filter(e=>"COLON"!==e.tokenType.name),s=t[0],i=t[1],n="TRUE"===i.tokenType.name||"FALSE"!==i.tokenType.name&&this.decodePlain(i),a=[s.startOffset,(i.endOffset??i.startOffset)+1];return{key:this.decodePlain(s),value:n,span:a,keySpan:this.contentSpan(s),valueSpan:this.contentSpan(i),location:this.tokenLocation(s)}}metadataSeparator(e){}systemBoundaryStatement(e){let t=this.visit(this.nodes(e,"systemBoundaryName")[0]),s=this.nodes(e,"classSuffix")[0],i=s?this.visit(s):{classes:[],spans:[]};t.classes=i.classes,this.builder.addBoundary(t);let n=this.parentBoundary;this.parentBoundary={id:t.id,location:t.location};let a=this.nodes(e,"systemBoundaryContent")[0],r=a?this.visit(a):[];this.parentBoundary=n;let o=this.tokens(e,"END")[0],l=this.nodes(e,"metadata")[0],h=l?this.visit(l):void 0,c={kind:"group",span:[0,0],group:t.id,idSpan:t.location.span,titleSpan:t.label.span,endSpan:this.tokenSpan(o),classSpans:i.spans,...h?{metadata:h.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))}:{},...r.length?{children:r}:{}};return h&&this.builder.addMetadataAssignment(t.id,t.location,h,c),c}systemBoundaryName(e){let t=this.tokens(e,"IDENTIFIER")[0];if(t){let s=this.nodes(e,"nodeLabel")[0];return{id:t.image,label:s?this.visit(s):this.tokenLabel(t),location:this.tokenLocation(t),generated:!1,classes:[]}}let s=this.tokens(e,"PLAIN_STRING")[0]??this.tokens(e,"MARKDOWN_STRING")[0],i=this.tokenLabel(s);return{id:this.generateId(i.text),label:i,location:this.tokenLocation(s),generated:!0,classes:[]}}systemBoundaryContent(e){return[...this.nodes(e,"blankLine"),...this.nodes(e,"commentLine"),...this.nodes(e,"boundaryElement")].sort((e,t)=>(e.location?.startOffset??0)-(t.location?.startOffset??0)).map(e=>this.wrap(e,this.visit(e)))}boundaryElement(e){let t=this.nodes(e,"actorDeclarationOnly")[0];if(t)return this.visit(t);let s=this.nodes(e,"entityName")[0],i=this.visit(s);return i.explicitDeclaration=!0,i.shape??="ellipse",this.builder.addElement(this.entityDraft(i)),{kind:"node",span:[0,0],nodes:[this.entityOccurrence(s,i,!0)]}}metadataAssignmentStatement(e){let t=this.visit(this.nodes(e,"metadataAssignmentTarget")[0]),s=this.visit(this.nodes(e,"metadata")[0]),i={kind:"metadata",span:[0,0],nodes:[{id:t.id,span:t.location.span,idSpan:t.location.span}],metadata:s.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))};return this.builder.addMetadataAssignment(t.id,t.location,s,i),i}metadataAssignmentTarget(e){let t=this.allTokens(e)[0],s=this.tokenLabel(t);return{id:"IDENTIFIER"===t.tokenType.name?t.image:this.generateId(s.text),location:this.tokenLocation(t)}}noteStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"nodeLabel")[0]);return this.builder.addNote({target:t.image,targetLocation:this.tokenLocation(t),label:s,location:this.ctxLocation(e)}),{kind:"note",span:[0,0],ref:`note-${this.anonymousNote++}`,refSpan:s.span,nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}stereotype(e){let t=this.tokens(e,"STEREOTYPE_TEXT")[0];return{value:t.image.trim(),span:this.tokenSpan(t)}}classSuffix(e){let t=this.tokens(e,"IDENTIFIER");return{classes:t.map(e=>e.image),spans:t.map(e=>this.tokenSpan(e))}}jsonStatement(e){let t=this.tokens(e,"JSON_DECLARATION_START")[0],s=this.tokens(e,"JSON_OBJECT_LITERAL")[0],i=/^json[\t ]+(\w+)/.exec(t.image),n=i[1],a=i[0].length-n.length,r={span:[t.startOffset+a,t.startOffset+a+n.length],line:t.startLine??1,column:(t.startColumn??1)+a},o=af(s.image,s.startLine??1,s.startColumn??1),l=this.nodes(e,"classSuffix")[0],h=l?this.visit(l):{classes:[],spans:[]},c={id:n,value:o.value,propertyOrder:o.propertyOrder,location:r,classes:h.classes};return this.builder.addJson(c),{kind:"json",span:[0,0],nodes:[{id:n,span:r.span,idSpan:r.span,defines:!0,classSpans:h.spans}],classSpans:h.spans}}directionStatement(e){let t=this.allTokens(e).find(e=>["TD","TB","BT","RL","LR"].includes(e.tokenType.name));return this.builder.setDirection(t.image),{kind:"direction",span:[0,0]}}classDefStatement(e){let t=this.tokens(e,"IDENTIFIER"),s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addClassDef(t.map(e=>e.image),s),{kind:"classDef",span:[0,0],ref:t[0].image,refSpan:this.tokenSpan(t[0])}}classStatement(e){let t=this.tokens(e,"IDENTIFIER"),s=1;for(;s<t.length&&this.source.slice((t[s-1].endOffset??t[s-1].startOffset)+1,t[s].startOffset).includes(",");s++);let i=t.slice(0,s).map(e=>({id:e.image,location:this.tokenLocation(e)})),n=t.slice(s).map(e=>e.image);return this.builder.addClassAssignment(i,n),{kind:"classAssign",span:[0,0],ref:n[0],refSpan:this.tokenSpan(t[s]),nodes:i.map(({id:e,location:t})=>({id:e,span:t.span,idSpan:t.span}))}}styleStatement(e){let t=this.tokens(e,"IDENTIFIER")[0],s=this.visit(this.nodes(e,"styles")[0]);return this.builder.addStyleAssignment(t.image,this.tokenLocation(t),s),{kind:"style",span:[0,0],nodes:[{id:t.image,span:this.tokenSpan(t),idSpan:this.tokenSpan(t)}]}}styles(e){return this.nodes(e,"styleValue").map(e=>this.visit(e))}styleValue(e){let t=this.allTokens(e),s=[t[0].startOffset,(t.at(-1).endOffset??t.at(-1).startOffset)+1];return this.source.slice(s[0],s[1]).replaceAll("\\,",",")}styleComponent(e){return this.allTokens(e).map(e=>e.image).join("")}forwardSolidOperator(e){let t=this.tokens(e,"FORWARD_SOLID")[0];return{type:"association",arrowType:0,minlen:this.solidMinlen(t)}}backwardSolidOperator(e){let t=this.tokens(e,"BACKWARD_SOLID")[0],s=this.nodes(e,"edgeLabel")[0],i=s?this.tokens(e,"MARKERLESS_SOLID").at(-1):t;return{type:"association",arrowType:1,minlen:this.solidMinlen(i),...s?{label:this.visit(s)}:{}}}markerlessSolidOperator(e){let t=this.nodes(e,"edgeLabel")[0],s=this.allTokens(e);if(!t)return{type:"association",arrowType:2,minlen:this.solidMinlen(this.tokens(e,"MARKERLESS_SOLID")[0])};let i=s.at(-1),n="FORWARD_SOLID"===i.tokenType.name?0:"FORWARD_CIRCLE"===i.tokenType.name?3:"FORWARD_CROSS"===i.tokenType.name?4:2;return{type:"association",arrowType:n,label:this.visit(t),minlen:0===n||2===n?this.solidMinlen(i):1}}forwardCircleOperator(e){return{type:"association",arrowType:3,minlen:1}}backwardCircleOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:5,minlen:1,...t?{label:this.visit(t)}:{}}}forwardCrossOperator(e){return{type:"association",arrowType:4,minlen:1}}backwardCrossOperator(e){let t=this.nodes(e,"edgeLabel")[0];return{type:"association",arrowType:6,minlen:1,...t?{label:this.visit(t)}:{}}}actorDraft(e){return{id:e.id,kind:"actor",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}entityDraft(e){return{id:e.id,kind:"usecase",label:e.label,location:e.location,generated:e.generated,...this.parentBoundary?{parentId:this.parentBoundary.id,parentLocation:this.parentBoundary.location}:{},...e.shape?{shape:e.shape}:{},...e.metadata?{metadata:e.metadata}:{},...e.stereotype?{stereotype:e.stereotype.value,stereotypeSpan:e.stereotype.span}:{},classes:e.classes}}endpoint(e,t=e.explicitDeclaration??!0){return{id:e.id,label:e.label,location:e.location,generated:e.generated,declaration:t,classesOnReference:e.classes.length>0}}relationshipDraft(e,t,s){return{source:this.endpoint(e,!0),target:this.endpoint(t.target),location:s,...t.explicitId?{explicitId:t.explicitId,explicitIdLocation:t.explicitIdLocation}:{},...t.arrow}}actorOccurrence(e,t,s){return{id:t.id,span:this.nodeSpan(e),idSpan:t.location.span,labelSpan:t.label.span,...s?{defines:!0}:{},...t.stereotype?{stereotypeSpan:t.stereotype.span}:{},...t.metadata?{metadata:t.metadata.properties.map(({key:e,span:t,keySpan:s,valueSpan:i})=>({key:e,span:t,keySpan:s,valueSpan:i}))}:{},...t.classSpans.length?{classSpans:t.classSpans}:{}}}entityOccurrence(e,t,s){return this.actorOccurrence(e,t,s)}wrap(e,t){if("blank"===t.kind||"comment"===t.kind)return t;for(let s of(t.span=this.nodeSpan(e),t.edges??[]))s.span=t.span;return t}tokenLabel(e){let t="MARKDOWN_STRING"===e.tokenType.name?"markdown":"text",s="markdown"===t?2:+("PLAIN_STRING"===e.tokenType.name),i=this.tokenSpan(e,s);return{text:this.source.slice(i[0],i[1]),type:t,span:i}}decodePlain(e){return"PLAIN_STRING"===e.tokenType.name?e.image.slice(1,-1):e.image}contentSpan(e){return this.tokenSpan(e,"PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name))}generateId(e){return e.replace(/\W/g,"_")}solidMinlen(e){return Math.max(1,(e.image.match(/-/g)?.length??2)-1)}nodeLocation(e){let t=this.allTokens(e.children)[0];return{span:this.nodeSpan(e),line:t.startLine??1,column:t.startColumn??1}}ctxLocation(e){let t=this.allTokens(e).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],i=t.at(-1);return{span:[s.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)],line:s.startLine??1,column:s.startColumn??1}}tokenLocation(e){let t="PLAIN_STRING"===e.tokenType.name?1:2*("MARKDOWN_STRING"===e.tokenType.name);return{span:this.tokenSpan(e,t),line:e.startLine??1,column:(e.startColumn??1)+t}}nodeSpan(e){let t=this.allTokens(e.children).filter(e=>"NEWLINE"!==e.tokenType.name&&"EOF"!==e.tokenType.name),s=t[0],i=t.at(-1);if(!s||!i)throw Error("Usecase CST node has no source token");return[s.startOffset,Math.min(this.source.length,(i.endOffset??i.startOffset+i.image.length-1)+1)]}tokenSpan(e,t=0){return[e.startOffset+t,Math.min(this.source.length,(e.endOffset??e.startOffset+e.image.length-1)+1-t)]}nodes(e,t){return(e[t]??[]).filter(e=>"children"in e)}tokens(e,t){return(e[t]??[]).filter(e=>"tokenTypeIdx"in e)}firstNode(e,...t){for(let s of t){let t=this.nodes(e,s)[0];if(t)return t}throw Error(`Usecase CST is missing one of: ${t.join(", ")}`)}allTokens(e){let t=[];for(let s of Object.values(e))for(let e of s)"tokenTypeIdx"in e?t.push(e):t.push(...this.allTokens(e.children));return t.sort((e,t)=>e.startOffset-t.startOffset)}},ab={parse:(0,y.K)(async e=>{iX.clear(),al.input=[];try{im({diagramType:"usecase",lexer:aa,parser:al,entry:(0,y.K)(()=>al.start(),"entry"),visit:(0,y.K)(t=>aC.build(t,e),"visit")},e)}catch(s){iX.clear();let t=al.errors[0];if(t){let{token:i}=t,n=Number.isFinite(i.startOffset)?i.startOffset:e.length,a="number"==typeof i.endOffset&&Number.isFinite(i.endOffset)?i.endOffset+1:n,r=i.startLine??e.slice(0,n).split(/\r\n|\r|\n/).length,o=Math.max(e.lastIndexOf("\n",n-1),e.lastIndexOf("\r",n-1)),l=i.startColumn??n-o,h=s instanceof Error?s.message:String(s);throw Error(`${h} at line ${r}, column ${l} [${n},${a})`)}throw s}},"parse")},av=["point","circle","cross","extension"],a_={usecaseActor:!0,usecaseActorHollow:!0,usecaseActorAwesome:!0,usecaseActorIcon:!0},ax=(0,y.K)((e,t)=>{let[s,i]=[e,t].map(e=>e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element");return`usecase-${s}-${i}`},"usecaseDomId"),aU=(0,y.K)(e=>`usecase-${e.replace(/[^\w-]+/g,"_").replace(/^_+|_+$/g,"")||"element"}`,"usecaseNodeDomId"),aM=(0,y.K)((e,t)=>"markdown"!==t?e:(0,m.O6)(e).map(e=>e.map(e=>e.content).join(" ")).join("\n"),"getAccessibleLabel"),aw=(0,y.K)(e=>{let t=aM(e.label??e.id,e.labelType);if(a_[e.shape]){let s=e.actorType&&"normal"!==e.actorType?`${e.actorType} `:"",i=e.business?"business ":"",n=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${i}${s}actor ${t}${n}`}if("note"===e.shape)return`Note for ${e.noteTargetLabel??e.noteTarget??""}: ${t}`;if("usecaseJsonTable"===e.shape){let s=(e.jsonRows??[]).map(e=>`${e.accessibleKey}: ${e.value}`).join("; ");return s?`${t}: ${s}`:t}let s=e.stereotype?`, stereotype ${e.stereotype}`:"";return`${e.business?"business ":""}use case ${t}${s}`},"getUsecaseNodeAccessibleName"),aP=(0,y.K)(e=>`${e.boundaryType} system boundary ${aM(e.label??e.id,e.labelType)}`,"getUsecaseBoundaryAccessibleName"),aD=(0,y.K)(e=>{if("note"===e.relationshipType)return"";let t="association"===e.relationshipType&&e.label?`association ${aM(e.label,e.labelType)}`:e.relationshipType;return`${t} from ${e.sourceLabel} to ${e.targetLabel}`},"getUsecaseEdgeAccessibleName"),a$=(0,y.K)(e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),"escapePlainLabel"),aK=(0,y.K)(e=>e.replace(/([*[\\\]_`])/g,"\\$1"),"escapeMarkdownMarkers"),aF=(0,y.K)((e,t)=>{for(let s of(e.diagramId=t,e.markers=[...av],e.nodes))if(s.domId=aU(s.id),void 0!==s.label&&"text"===s.labelType&&(s.label=a$(s.label)),s.stereotype&&(s.stereotype=a$(s.stereotype)),s.isGroup||"usecaseJsonTable"!==s.shape||(s.jsonRows=s.jsonRows?.map(e=>({...e,key:a$(e.key),value:a$(e.value)}))),!s.isGroup&&("usecaseEllipse"===s.shape||"rect"===s.shape)&&s.stereotype){let e=s.label??a$(s.id);s.label=`\xab${aK(s.stereotype)}\xbb<br/>${"text"===s.labelType?aK(e):e}`,s.labelType="markdown",s.hasFoldedStereotype=!0,delete s.stereotype}for(let t of e.edges)void 0!==t.label&&"text"===t.labelType&&(t.label=a$(t.label));return e},"prepareUsecaseLayoutData"),aB=(0,y.K)((e,t,s)=>{for(let i of t.nodes){let n="string"==typeof i.domId?i.domId:ax(t.diagramId,i.id),a=e.select(`#${n}`),r=i.isGroup?"boundary":a_[i.shape]?"actor":"note"===i.shape?"note":"usecaseJsonTable"===i.shape?"json":"usecase",o=s.nodes.get(i.id)??i.id;if(a.attr("data-usecase-id",i.id).attr("data-usecase-kind",r).attr("role","img").attr("aria-label",o),!i.isGroup&&("usecaseEllipse"===i.shape||"rect"===i.shape)&&"hasFoldedStereotype"in i&&!0===i.hasFoldedStereotype){let e=a.node(),t=e?.querySelector(".nodeLabel"),s=t?.querySelector("p")??t,i=s?.firstChild;if(s&&i?.nodeType===3){let e=s.ownerDocument.createElement("span");e.className="usecase-stereotype",s.insertBefore(e,i),e.appendChild(i)}else e?.querySelector(".label tspan tspan, .label tspan")?.classList.add("usecase-stereotype")}}let i=new Map(t.edges.map(e=>[e.id,e]));e.selectAll('path[data-et="edge"]').each(function(){let e=i.get(this.getAttribute("data-id")??"");if(!e)return;let n=(0,ip.Ltv)(this);n.attr("id",ax(t.diagramId,e.id)).attr("data-usecase-id",e.id).attr("data-usecase-kind",e.internal?"note-connector":"relationship"),e.internal?n.attr("aria-hidden","true"):n.attr("role","img").attr("aria-label",s.edges.get(e.id)??e.id)})},"annotateUsecaseElements"),aG=(0,y.K)((e,t)=>{e.style("--mermaid-usecase-actor-font-size",`${t.actorFontSize}px`).style("--mermaid-usecase-actor-font-family",t.actorFontFamily).style("--mermaid-usecase-actor-font-weight",t.actorFontWeight).style("--mermaid-usecase-font-size",`${t.usecaseFontSize}px`).style("--mermaid-usecase-font-family",t.usecaseFontFamily).style("--mermaid-usecase-font-weight",t.usecaseFontWeight)},"applyUsecaseFonts"),aW=(0,y.K)(async(e,t,s,i)=>{g.R.info("Drawing usecase diagram (unified)",t);let{layout:n}=(0,E.D7)(),a=i.db,r=a.getData(),o=new Map(r.nodes.map(e=>[e.id,aM(e.label??e.id,e.labelType)])),l={nodes:new Map(r.nodes.map(e=>[e.id,e.isGroup?aP(e):aw("note"===e.shape?{...e,noteTargetLabel:o.get(e.noteTarget??"")}:e)])),edges:new Map(r.edges.map(e=>[e.id,aD({...e,sourceLabel:o.get(e.source)??e.sourceLabel,targetLabel:o.get(e.target)??e.targetLabel})]))},h=(0,u.A)(t,r.config.securityLevel);r.layoutAlgorithm=(0,f.q7)(n),aF(r,t),aG(h,r),await (0,f.XX)(r,h),aB(h,r,l);let c=r.diagramPadding;A._K.insertTitle(h,"usecaseDiagramTitleText",0,a.getDiagramTitle?.()??""),(0,p.P)(h,c,"usecaseDiagram",r.useMaxWidth),aG(h,r)},"draw"),aj=(0,y.K)(e=>({actorBkg:e.usecaseActorBkg??e.actorBkg??e.mainBkg,actorBorder:e.usecaseActorBorder??e.actorBorder??e.primaryColor,bkg:e.usecaseBkg??e.mainBkg,border:e.usecaseBorder??e.nodeBorder??e.primaryColor,boundaryBkg:e.usecaseBoundaryBkg??e.clusterBkg,boundaryBorder:e.usecaseBoundaryBorder??e.clusterBorder,includeLine:e.usecaseIncludeLine??e.lineColor,extendLine:e.usecaseExtendLine??e.lineColor}),"roleColors"),az=(0,y.K)(e=>{let{theme:t,bkgColorArray:s,borderColorArray:i}=e;if(!(0,T.P1)(t,i))return"";let n=(0,E.zj)().usecase?.colorScheme==="rotate",a=(0,T.rq)(e.look),r="handDrawn"===a,o=(0,T.Ic)(s),l="";for(let e=0;e<(0,T.Hu)(i);e++){let t=i[e],h=o?`fill: ${s[e%s.length]};`:"",c=`[data-look="${a}"][data-color-id="color-${e}"]`;l+=`
58
+
59
+ & ${c}.system-boundary rect.boundary-body,
60
+ & ${c}.system-boundary rect.boundary-tab,
61
+ & ${c}.system-boundary .boundary-body path,
62
+ & ${c}.system-boundary .boundary-tab path {
63
+ stroke: ${t};
64
+ ${h}
65
+ }
66
+ `,n&&(l+=`
67
+
68
+ /* Use case bodies -- \`.usecase-element\` covers the ellipse form, the \`[Rect]\` form and
69
+ the business variant.
70
+
71
+ Element selectors only, never a bare \`path\`. Under the handDrawn look roughjs draws
72
+ the body as a *pair* of paths, an outline stroked in the border colour and a hachure
73
+ fill stroked in the background colour, with no class to tell them apart. Stroking
74
+ both repaints the fill lines as border colour and the shape collapses into a solid
75
+ block -- which is what \`.usecase-element path\` did. So handDrawn bodies keep the
76
+ theme's uniform colours, exactly as handDrawn flowchart nodes do. */
77
+ & ${c}.usecase-element ellipse,
78
+ & ${c}.usecase-element rect {
79
+ stroke: ${t};
80
+ ${h}
81
+ }
82
+
83
+ /* The business marker is a single classed path, so it can be reached safely by name --
84
+ without it the marker keeps the uniform border beside a palette-coloured body. No
85
+ \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
86
+ & ${c}.usecase-element .usecase-business-marker {
87
+ stroke: ${t};
88
+ }
89
+
90
+ /* Actor glyphs, mirroring the uniform rule further down. The fill goes on the glyph
91
+ group, never on its children, so the hollow variant's own \`fill="none"\` keeps
92
+ winning and a hollow actor stays hollow. Same reason as above for not descending
93
+ into the handDrawn paths. */
94
+ & ${c}.usecase-actor .usecase-actor-shape,
95
+ & ${c}.usecase-actor .usecase-actor-hollow,
96
+ & ${c}.usecase-actor .usecase-actor-awesome,
97
+ & ${c}.usecase-actor .usecase-actor-icon {
98
+ stroke: ${t};
99
+ ${h}
100
+ }
101
+ ${r?"":`
102
+ /* The group rule above reaches the glyph by inheritance, which the neo look breaks: it
103
+ ships a \`[data-look="neo"].node path { stroke }\` rule that hits the glyph's own paths,
104
+ and a value set directly on the child always beats one inherited from the parent,
105
+ whatever the parent rule's specificity. So name the children too.
106
+
107
+ Emitted for every look *except* handDrawn, where roughjs draws the glyph as an
108
+ outline path plus a hachure fill path stroked in the fill colour, indistinguishable
109
+ in CSS -- stroking both turns a hollow actor into a solid disc. Deliberately no
110
+ \`fill\` either way, so the hollow variant's own \`fill="none"\` keeps winning. */
111
+ & ${c}.usecase-actor .usecase-actor-glyph path,
112
+ & ${c}.usecase-actor .usecase-actor-glyph circle {
113
+ stroke: ${t};
114
+ }
115
+ `}
116
+ `)}return l},"genColor"),aV={parser:ab,db:iX,renderer:{draw:aW},styles:(0,y.K)(e=>{let t=aj(e),s="handDrawn"===(0,T.rq)(e.look);return`
117
+ ${az(e)}
118
+ & .usecase-actor {
119
+ color: ${e.actorTextColor??e.primaryTextColor};
120
+ }
121
+
122
+ & .usecase-actor-shape,
123
+ & .usecase-actor-hollow,
124
+ & .usecase-actor-awesome,
125
+ & .usecase-actor-icon {
126
+ fill: ${t.actorBkg};
127
+ stroke: ${t.actorBorder};
128
+ stroke-width: 2px;
129
+ }
130
+ ${s?"":`
131
+ /* The rule above colours the glyph group and lets its children inherit, which the neo
132
+ look breaks: it ships a \`[data-look="neo"].node path { stroke }\` rule that lands on
133
+ the glyph's own paths, and a value set directly on a child always beats one inherited
134
+ from its parent, whatever the parent rule's specificity. Since neo is the default look,
135
+ without this every actor renders in the node border colour rather than the actor
136
+ colour the rule above asks for.
137
+
138
+ \`.node\` is in the selector to outrank that neo rule rather than tie with it: both
139
+ would otherwise be one attribute plus one class plus one element, leaving the winner to
140
+ depend on which stylesheet is concatenated last.
141
+
142
+ Stroke only: the hollow variant's own \`fill="none"\` has to keep winning. */
143
+ & .node.usecase-actor .usecase-actor-glyph path,
144
+ & .node.usecase-actor .usecase-actor-glyph circle {
145
+ stroke: ${t.actorBorder};
146
+ }
147
+ `}
148
+ & .usecase-actor .nodeLabel,
149
+ & .actor-label {
150
+ color: ${e.actorTextColor??e.primaryTextColor};
151
+ fill: ${e.actorTextColor??e.primaryTextColor};
152
+ font-family: var(--mermaid-usecase-actor-font-family, ${e.fontFamily});
153
+ font-size: var(--mermaid-usecase-actor-font-size, 14px);
154
+ font-weight: var(--mermaid-usecase-actor-font-weight, normal);
155
+ }
156
+
157
+ & .usecase-element ellipse,
158
+ & .usecase-element rect,
159
+ & .usecase-business ellipse,
160
+ & .usecase-business rect {
161
+ fill: ${t.bkg};
162
+ stroke: ${t.border};
163
+ stroke-width: 2px;
164
+ }
165
+ ${s?"":`
166
+ /* The same interception the actor glyph hits, one element down: neo ships
167
+ \`[data-look="neo"].node rect { stroke: nodeBorder }\`, which outranks the plain
168
+ \`.usecase-element rect\` above, so a use case written in the \`[Rect]\` form kept the node
169
+ border colour while its ellipse siblings took the role colour. An \`<ellipse>\` has no
170
+ equivalent neo rule and is already correct; restating it here costs nothing and means
171
+ the two forms cannot drift apart again.
172
+
173
+ Qualified with \`[data-look]\` *and* \`.node\` to land strictly above that rule rather than
174
+ tie with it -- on a tie the later stylesheet would win, which is how neo took this in
175
+ the first place. Skipped under handDrawn, where roughjs draws paths and neither element
176
+ exists. */
177
+ & [data-look="${(0,T.rq)(e.look)}"].node.usecase-element ellipse,
178
+ & [data-look="${(0,T.rq)(e.look)}"].node.usecase-element rect {
179
+ fill: ${t.bkg};
180
+ stroke: ${t.border};
181
+ }
182
+
183
+ /* The business marker is a \`<path>\`, so it loses to \`[data-look="neo"].node path\` the same
184
+ way. No \`fill\`: the marker is drawn with \`fill="none"\` and has to stay that way. */
185
+ & [data-look="${(0,T.rq)(e.look)}"].node.usecase-element .usecase-business-marker {
186
+ stroke: ${t.border};
187
+ }
188
+ `}
189
+ & .usecase-element .nodeLabel,
190
+ & .usecase-label {
191
+ color: ${e.primaryTextColor};
192
+ fill: ${e.primaryTextColor};
193
+ font-family: var(--mermaid-usecase-font-family, ${e.fontFamily});
194
+ font-size: var(--mermaid-usecase-font-size, 12px);
195
+ font-weight: var(--mermaid-usecase-font-weight, normal);
196
+ }
197
+
198
+ & .usecase-stereotype,
199
+ & .usecase-business-marker {
200
+ color: ${e.primaryTextColor};
201
+ fill: ${e.primaryTextColor};
202
+ stroke: ${t.border};
203
+ }
204
+
205
+ & .system-boundary rect.boundary-body,
206
+ & .system-boundary rect.boundary-tab,
207
+ & .system-boundary-package-tab {
208
+ fill: ${t.boundaryBkg};
209
+ stroke: ${t.boundaryBorder};
210
+ stroke-width: 1px;
211
+ }
212
+
213
+ & .system-boundary-title text {
214
+ fill: ${e.titleColor??e.primaryTextColor};
215
+ }
216
+
217
+ /* Only the span, never the <p> inside it: the renderer puts a user-supplied
218
+ 'color' on the span, and that has to stay inheritable by its children. */
219
+ & .system-boundary-title span {
220
+ color: ${e.titleColor??e.primaryTextColor};
221
+ }
222
+
223
+ & .usecase-note {
224
+ fill: ${e.noteBkgColor};
225
+ stroke: ${e.noteBorderColor};
226
+ color: ${e.noteTextColor};
227
+ }
228
+
229
+ & .usecase-note .nodeLabel {
230
+ color: ${e.noteTextColor};
231
+ fill: ${e.noteTextColor};
232
+ }
233
+
234
+ & .usecase-json-table,
235
+ & .usecase-json-table rect,
236
+ & .usecase-json-cell {
237
+ fill: ${e.mainBkg};
238
+ stroke: ${e.nodeBorder??e.primaryColor};
239
+ }
240
+
241
+ & .usecase-json-title,
242
+ & .usecase-json-key,
243
+ & .usecase-json-value {
244
+ color: ${e.primaryTextColor};
245
+ fill: ${e.primaryTextColor};
246
+ }
247
+
248
+ & .relationship {
249
+ fill: none;
250
+ stroke: ${e.lineColor};
251
+ }
252
+
253
+ & .relationship-include,
254
+ & .relationship-extend,
255
+ & .relationship-note {
256
+ stroke-dasharray: 3;
257
+ }
258
+
259
+ /* Include and extend are both dashed, which is a weak distinction at small sizes. The
260
+ tokens default to \`lineColor\`, so a theme that does not set them is unchanged. */
261
+ & .relationship-include {
262
+ stroke: ${t.includeLine};
263
+ }
264
+
265
+ & .relationship-extend {
266
+ stroke: ${t.extendLine};
267
+ }
268
+
269
+ & .relationship.edge-animation-fast,
270
+ & .relationship.edge-animation-slow {
271
+ stroke-linecap: round;
272
+ }
273
+
274
+ & .edgeLabel,
275
+ & .edgeLabel p {
276
+ background-color: ${e.edgeLabelBackground};
277
+ }
278
+
279
+ & .labelBkg {
280
+ background-color: ${e.edgeLabelBackground};
281
+ padding: 0 2px;
282
+ }
283
+
284
+ & .edgeLabel .label rect {
285
+ fill: ${e.edgeLabelBackground};
286
+ }
287
+
288
+ & .relationship-label,
289
+ & .edgeLabel {
290
+ color: ${e.primaryTextColor};
291
+ fill: ${e.primaryTextColor};
292
+ font-family: ${e.fontFamily};
293
+ font-size: 10px;
294
+ font-weight: normal;
295
+ }
296
+
297
+ & .marker,
298
+ & .marker.point,
299
+ & .marker.circle,
300
+ & .marker.cross {
301
+ fill: ${e.lineColor};
302
+ stroke: ${e.lineColor};
303
+ }
304
+
305
+ & .marker.extension {
306
+ fill: ${e.mainBkg};
307
+ stroke: ${e.lineColor};
308
+ }
309
+ `},"getStyles")}},14569:(e,t,s)=>{s.d(t,{P:()=>r});var i=s(95631),n=s(5218),a=s(14528),r=(0,a.K)((e,t,s,a)=>{e.attr("class",s);let{width:r,height:h,x:c,y:d}=o(e,t);(0,i.a$)(e,h,r,a);let u=l(c,d,r,h,t);e.attr("viewBox",u),n.R.debug(`viewBox configured: ${u} with padding: ${t}`)},"setupViewPortForSVG"),o=(0,a.K)((e,t)=>{let s=e.node()?.getBBox()||{width:0,height:0,x:0,y:0};return{width:s.width+2*t,height:s.height+2*t,x:s.x,y:s.y}},"calculateDimensionsWithPadding"),l=(0,a.K)((e,t,s,i,n)=>`${e-n} ${t-n} ${s} ${i}`,"createViewBox")},98204:(e,t,s)=>{s.d(t,{A:()=>a});var i=s(14528),n=s(60830),a=(0,i.K)((e,t)=>{let s;return"sandbox"===t&&(s=(0,n.Ltv)("#i"+e)),("sandbox"===t?(0,n.Ltv)(s.nodes()[0].contentDocument.body):(0,n.Ltv)("body")).select(`[id="${e}"]`)},"getDiagramElement")}}]);