@tom2012/cc-web 2026.5.15-b → 2026.5.15-d

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 (106) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/tracks/ccweb-train-adapter.d.ts +1 -1
  3. package/backend/dist/tracks/ccweb-train-adapter.d.ts.map +1 -1
  4. package/backend/dist/tracks/train-loader.d.ts +2 -2
  5. package/backend/dist/tracks/train-loader.js +2 -2
  6. package/backend/dist/tracks/train-loader.js.map +1 -1
  7. package/backend/dist/tracks/types-train.d.ts +2 -2
  8. package/backend/dist/tracks/types-train.d.ts.map +1 -1
  9. package/backend/dist/tracks/types-train.js +1 -1
  10. package/backend/dist/tracks/types.d.ts +1 -1
  11. package/backend/dist/tracks/types.js +1 -1
  12. package/backend/package-lock.json +20 -6
  13. package/backend/package.json +2 -2
  14. package/backend/vendor/{@train-lang/adapter-spec → @tom2012/train-adapter-spec}/dist/index.d.ts +2 -2
  15. package/backend/vendor/{@train-lang/adapter-spec → @tom2012/train-adapter-spec}/dist/index.js +2 -2
  16. package/backend/vendor/{@train-lang/adapter-spec → @tom2012/train-adapter-spec}/package.json +1 -1
  17. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/index.d.ts +1 -1
  18. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/index.js +1 -1
  19. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/interpreter.d.ts +1 -1
  20. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/interpreter.d.ts.map +1 -1
  21. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/prompt-composer.d.ts +1 -1
  22. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/prompt-composer.d.ts.map +1 -1
  23. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/type-descriptor.d.ts +1 -1
  24. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/type-descriptor.d.ts.map +1 -1
  25. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/validation.d.ts +1 -1
  26. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/validation.d.ts.map +1 -1
  27. package/backend/vendor/{@train-lang/core → @tom2012/train-core}/package.json +2 -2
  28. package/frontend/dist/assets/{ChatOverlay-59ZxvtRP.js → ChatOverlay-puY33gKb.js} +1 -1
  29. package/frontend/dist/assets/{GraphPreview-sbpMfB9C.js → GraphPreview-BKQ1V6GR.js} +1 -1
  30. package/frontend/dist/assets/{MobilePage-Dcx6MXJq.js → MobilePage-ChUggP8V.js} +3 -3
  31. package/frontend/dist/assets/{OfficePreview-pFRYqbUT.js → OfficePreview-CZYwcNi7.js} +2 -2
  32. package/frontend/dist/assets/{PdfPreview-YuE4294t.js → PdfPreview-BNvQMy_v.js} +1 -1
  33. package/frontend/dist/assets/{ProjectPage-99jMQxFL.js → ProjectPage-D-fFSy_0.js} +4 -4
  34. package/frontend/dist/assets/{SettingsPage-lBTzzVSA.js → SettingsPage-BWOLxVe5.js} +1 -1
  35. package/frontend/dist/assets/{SkillHubPage-Ba16r6gG.js → SkillHubPage-CbejKbIq.js} +1 -1
  36. package/frontend/dist/assets/{TrackEditor-BHghiFPX.js → TrackEditor-mCRxHZAu.js} +3 -3
  37. package/frontend/dist/assets/{chevron-down-D8NwXKSN.js → chevron-down-CMkdg3Dp.js} +1 -1
  38. package/frontend/dist/assets/{cssMode-JswmrBJm.js → cssMode-CMqWoI8y.js} +1 -1
  39. package/frontend/dist/assets/{editor.main-DxKJbewY.js → editor.main-D97712kV.js} +7 -7
  40. package/frontend/dist/assets/{freemarker2-DSk3lXcG.js → freemarker2-CjXLVpN6.js} +1 -1
  41. package/frontend/dist/assets/{handlebars-3L3xIxMF.js → handlebars-pbz4-Y1I.js} +1 -1
  42. package/frontend/dist/assets/{html-jGWDYvg4.js → html-BO0llOdh.js} +1 -1
  43. package/frontend/dist/assets/{htmlMode-BNn43R0H.js → htmlMode-D3EjM_im.js} +1 -1
  44. package/frontend/dist/assets/{index-DzYcaccz.js → index-8QKCaq3m.js} +1 -1
  45. package/frontend/dist/assets/{index-CcOfgS18.js → index-CGXM64mM.js} +2 -2
  46. package/frontend/dist/assets/{index-DbB1EvuS.js → index-DtgCtEAE.js} +1 -1
  47. package/frontend/dist/assets/{index-BWlHiqbD.js → index-x6PSyNuH.js} +1 -1
  48. package/frontend/dist/assets/{javascript-DrTQenPf.js → javascript-BaE8fRqt.js} +1 -1
  49. package/frontend/dist/assets/{jsonMode-BJqz4hx6.js → jsonMode-SVPhJeDM.js} +1 -1
  50. package/frontend/dist/assets/{jszip.min-Dn7y6lhP.js → jszip.min-aS3HRvu3.js} +1 -1
  51. package/frontend/dist/assets/{liquid-51VrCPM1.js → liquid-CF5zFz4c.js} +1 -1
  52. package/frontend/dist/assets/{mdx-B9MBogQu.js → mdx-YmZpSoaS.js} +1 -1
  53. package/frontend/dist/assets/{python-B4lxjc3U.js → python-7Bw2lal1.js} +1 -1
  54. package/frontend/dist/assets/{razor-Df88ZAwt.js → razor-C3MrOljC.js} +1 -1
  55. package/frontend/dist/assets/{select-BCKg8P7d.js → select-CkZj27gP.js} +1 -1
  56. package/frontend/dist/assets/{tsMode-BHae3zIH.js → tsMode-DHTilQIY.js} +1 -1
  57. package/frontend/dist/assets/{typescript-Bv6gAW_5.js → typescript-BGFRgumN.js} +1 -1
  58. package/frontend/dist/assets/{user-CGd4Ayhq.js → user-CDFN7caY.js} +1 -1
  59. package/frontend/dist/assets/{xml-C70S0rct.js → xml-lQsFWQQ_.js} +1 -1
  60. package/frontend/dist/assets/{yaml-BZVXvTCX.js → yaml-D-rU01Th.js} +1 -1
  61. package/frontend/dist/index.html +1 -1
  62. package/package.json +1 -1
  63. /package/backend/vendor/{@train-lang/adapter-spec → @tom2012/train-adapter-spec}/dist/index.d.ts.map +0 -0
  64. /package/backend/vendor/{@train-lang/adapter-spec → @tom2012/train-adapter-spec}/dist/index.js.map +0 -0
  65. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast-cache.d.ts +0 -0
  66. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast-cache.d.ts.map +0 -0
  67. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast-cache.js +0 -0
  68. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast-cache.js.map +0 -0
  69. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast.d.ts +0 -0
  70. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast.d.ts.map +0 -0
  71. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast.js +0 -0
  72. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/ast.js.map +0 -0
  73. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builder.d.ts +0 -0
  74. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builder.d.ts.map +0 -0
  75. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builder.js +0 -0
  76. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builder.js.map +0 -0
  77. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builtins.d.ts +0 -0
  78. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builtins.d.ts.map +0 -0
  79. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builtins.js +0 -0
  80. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/builtins.js.map +0 -0
  81. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/index.d.ts.map +0 -0
  82. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/index.js.map +0 -0
  83. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/interpreter.js +0 -0
  84. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/interpreter.js.map +0 -0
  85. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/lexer.d.ts +0 -0
  86. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/lexer.d.ts.map +0 -0
  87. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/lexer.js +0 -0
  88. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/lexer.js.map +0 -0
  89. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/module-loader.d.ts +0 -0
  90. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/module-loader.d.ts.map +0 -0
  91. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/module-loader.js +0 -0
  92. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/module-loader.js.map +0 -0
  93. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/parser.d.ts +0 -0
  94. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/parser.d.ts.map +0 -0
  95. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/parser.js +0 -0
  96. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/parser.js.map +0 -0
  97. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/prompt-composer.js +0 -0
  98. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/prompt-composer.js.map +0 -0
  99. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/runtime.d.ts +0 -0
  100. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/runtime.d.ts.map +0 -0
  101. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/runtime.js +0 -0
  102. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/runtime.js.map +0 -0
  103. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/type-descriptor.js +0 -0
  104. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/type-descriptor.js.map +0 -0
  105. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/validation.js +0 -0
  106. /package/backend/vendor/{@train-lang/core → @tom2012/train-core}/dist/validation.js.map +0 -0
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-DxKJbewY.js","assets/index-CcOfgS18.js","assets/index-BmPb0Wl1.css","assets/editor-B5EY1bb8.css","assets/index-BWlHiqbD.js"])))=>i.map(i=>d[i]);
2
- var t=Object.defineProperty,e=(e,n,i)=>((e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i)(e,"symbol"!=typeof n?n+"":n,i);import{c as n,r as i,j as r,aD as s,a as o,B as a,_ as c}from"./index-CcOfgS18.js";
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-D97712kV.js","assets/index-CGXM64mM.js","assets/index-BmPb0Wl1.css","assets/editor-B5EY1bb8.css","assets/index-x6PSyNuH.js"])))=>i.map(i=>d[i]);
2
+ var t=Object.defineProperty,e=(e,n,r)=>((e,n,r)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r)(e,"symbol"!=typeof n?n+"":n,r);import{c as n,r,j as i,aD as s,a as o,B as a,_ as c}from"./index-CGXM64mM.js";
3
3
  /**
4
4
  * @license lucide-react v0.309.0 - ISC
5
5
  *
@@ -11,4 +11,4 @@ var t=Object.defineProperty,e=(e,n,i)=>((e,n,i)=>n in e?t(e,n,{enumerable:!0,con
11
11
  *
12
12
  * This source code is licensed under the ISC license.
13
13
  * See the LICENSE file in the root directory of this source tree.
14
- */var p="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,m=p||f||Function("return this")(),E=m.Symbol,g=Object.prototype,T=g.hasOwnProperty,S=g.toString,L=E?E.toStringTag:void 0;var O=Object.prototype.toString;var R=E?E.toStringTag:void 0;function A(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":R&&R in Object(t)?function(t){var e=T.call(t,L),n=t[L];try{t[L]=void 0;var i=!0}catch(s){}var r=S.call(t);return i&&(e?t[L]=n:delete t[L]),r}(t):function(t){return O.call(t)}(t)}function v(t){return null!=t&&"object"==typeof t}function y(t){return"symbol"==typeof t||v(t)&&"[object Symbol]"==A(t)}function N(t,e){for(var n=-1,i=null==t?0:t.length,r=Array(i);++n<i;)r[n]=e(t[n],n,t);return r}var I=Array.isArray,C=E?E.prototype:void 0,x=C?C.toString:void 0;function k(t){if("string"==typeof t)return t;if(I(t))return N(t,k)+"";if(y(t))return x?x.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}var _=/\s/;var U=/^\s+/;function b(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&_.test(t.charAt(e)););return e}(t)+1).replace(U,""):t}function M(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var P=/^[-+]0x[0-9a-f]+$/i,w=/^0b[01]+$/i,D=/^0o[0-7]+$/i,F=parseInt;var B=1/0;function j(t){return t?(t=function(t){if("number"==typeof t)return t;if(y(t))return NaN;if(M(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=M(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=b(t);var n=w.test(t);return n||D.test(t)?F(t.slice(2),n?2:8):P.test(t)?NaN:+t}(t))===B||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function $(t){var e=j(t),n=e%1;return e==e?n?e-n:e:0}function K(t){return t}function G(t){if(!M(t))return!1;var e=A(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var z,W=m["__core-js_shared__"],V=(z=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var H=Function.prototype.toString;function Y(t){if(null!=t){try{return H.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var X=/^\[object .+?Constructor\]$/,q=Function.prototype,Z=Object.prototype,Q=q.toString,J=Z.hasOwnProperty,tt=RegExp("^"+Q.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function et(t){return!(!M(t)||(e=t,V&&V in e))&&(G(t)?tt:X).test(Y(t));var e}function nt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return et(n)?n:void 0}var it=nt(m,"WeakMap"),rt=Object.create,st=function(){function t(){}return function(e){if(!M(e))return{};if(rt)return rt(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function ot(){}var at=Date.now;var ct,ht,ut,lt=function(){try{var t=nt(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),dt=lt?function(t,e){return lt(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:K,pt=(ct=dt,ht=0,ut=0,function(){var t=at(),e=16-(t-ut);if(ut=t,e>0){if(++ht>=800)return arguments[0]}else ht=0;return ct.apply(void 0,arguments)});function ft(t,e){for(var n=-1,i=null==t?0:t.length;++n<i&&!1!==e(t[n],n,t););return t}function mt(t,e,n,i){for(var r=t.length,s=n+-1;++s<r;)if(e(t[s],s,t))return s;return-1}function Et(t){return t!=t}function gt(t,e,n){return e==e?function(t,e,n){for(var i=n-1,r=t.length;++i<r;)if(t[i]===e)return i;return-1}(t,e,n):mt(t,Et,n)}function Tt(t,e){return!!(null==t?0:t.length)&&gt(t,e,0)>-1}var St=/^(?:0|[1-9]\d*)$/;function Lt(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&St.test(t))&&t>-1&&t%1==0&&t<e}function Ot(t,e,n){"__proto__"==e&&lt?lt(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function Rt(t,e){return t===e||t!=t&&e!=e}var At=Object.prototype.hasOwnProperty;function vt(t,e,n){var i=t[e];At.call(t,e)&&Rt(i,n)&&(void 0!==n||e in t)||Ot(t,e,n)}function yt(t,e,n,i){var r=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=void 0;void 0===c&&(c=t[a]),r?Ot(n,a,c):vt(n,a,c)}return n}var Nt=Math.max;function It(t,e){return pt(function(t,e,n){return e=Nt(void 0===e?t.length-1:e,0),function(){for(var i=arguments,r=-1,s=Nt(i.length-e,0),o=Array(s);++r<s;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=n(o),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,a)}}(t,e,K),t+"")}function Ct(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function xt(t){return null!=t&&Ct(t.length)&&!G(t)}function kt(t,e,n){if(!M(n))return!1;var i=typeof e;return!!("number"==i?xt(n)&&Lt(e,n.length):"string"==i&&e in n)&&Rt(n[e],t)}var _t=Object.prototype;function Ut(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_t)}function bt(t){return v(t)&&"[object Arguments]"==A(t)}var Mt=Object.prototype,Pt=Mt.hasOwnProperty,wt=Mt.propertyIsEnumerable,Dt=bt(function(){return arguments}())?bt:function(t){return v(t)&&Pt.call(t,"callee")&&!wt.call(t,"callee")};var Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,jt=Bt&&Bt.exports===Ft?m.Buffer:void 0,$t=(jt?jt.isBuffer:void 0)||function(){return!1},Kt={};function Gt(t){return function(e){return t(e)}}Kt["[object Float32Array]"]=Kt["[object Float64Array]"]=Kt["[object Int8Array]"]=Kt["[object Int16Array]"]=Kt["[object Int32Array]"]=Kt["[object Uint8Array]"]=Kt["[object Uint8ClampedArray]"]=Kt["[object Uint16Array]"]=Kt["[object Uint32Array]"]=!0,Kt["[object Arguments]"]=Kt["[object Array]"]=Kt["[object ArrayBuffer]"]=Kt["[object Boolean]"]=Kt["[object DataView]"]=Kt["[object Date]"]=Kt["[object Error]"]=Kt["[object Function]"]=Kt["[object Map]"]=Kt["[object Number]"]=Kt["[object Object]"]=Kt["[object RegExp]"]=Kt["[object Set]"]=Kt["[object String]"]=Kt["[object WeakMap]"]=!1;var zt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Vt=Wt&&Wt.exports===zt&&p.process,Ht=function(){try{var t=Wt&&Wt.require&&Wt.require("util").types;return t||Vt&&Vt.binding&&Vt.binding("util")}catch(e){}}(),Yt=Ht&&Ht.isTypedArray,Xt=Yt?Gt(Yt):function(t){return v(t)&&Ct(t.length)&&!!Kt[A(t)]},qt=Object.prototype.hasOwnProperty;function Zt(t,e){var n=I(t),i=!n&&Dt(t),r=!n&&!i&&$t(t),s=!n&&!i&&!r&&Xt(t),o=n||i||r||s,a=o?function(t,e){for(var n=-1,i=Array(t);++n<t;)i[n]=e(n);return i}(t.length,String):[],c=a.length;for(var h in t)!e&&!qt.call(t,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Lt(h,c))||a.push(h);return a}function Qt(t,e){return function(n){return t(e(n))}}var Jt=Qt(Object.keys,Object),te=Object.prototype.hasOwnProperty;function ee(t){if(!Ut(t))return Jt(t);var e=[];for(var n in Object(t))te.call(t,n)&&"constructor"!=n&&e.push(n);return e}function ne(t){return xt(t)?Zt(t):ee(t)}var ie,re=Object.prototype.hasOwnProperty,se=(ie=function(t,e){if(Ut(e)||xt(e))yt(e,ne(e),t);else for(var n in e)re.call(e,n)&&vt(t,n,e[n])},It(function(t,e){var n=-1,i=e.length,r=i>1?e[i-1]:void 0,s=i>2?e[2]:void 0;for(r=ie.length>3&&"function"==typeof r?(i--,r):void 0,s&&kt(e[0],e[1],s)&&(r=i<3?void 0:r,i=1),t=Object(t);++n<i;){var o=e[n];o&&ie(t,o,n,r)}return t}));var oe=Object.prototype.hasOwnProperty;function ae(t){if(!M(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Ut(t),n=[];for(var i in t)("constructor"!=i||!e&&oe.call(t,i))&&n.push(i);return n}function ce(t){return xt(t)?Zt(t,!0):ae(t)}var he=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ue=/^\w*$/;function le(t,e){if(I(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!y(t))||(ue.test(t)||!he.test(t)||null!=e&&t in Object(e))}var de=nt(Object,"create");var pe=Object.prototype.hasOwnProperty;var fe=Object.prototype.hasOwnProperty;function me(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}function Ee(t,e){for(var n=t.length;n--;)if(Rt(t[n][0],e))return n;return-1}me.prototype.clear=function(){this.__data__=de?de(null):{},this.size=0},me.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},me.prototype.get=function(t){var e=this.__data__;if(de){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return pe.call(e,t)?e[t]:void 0},me.prototype.has=function(t){var e=this.__data__;return de?void 0!==e[t]:fe.call(e,t)},me.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=de&&void 0===e?"__lodash_hash_undefined__":e,this};var ge=Array.prototype.splice;function Te(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Te.prototype.clear=function(){this.__data__=[],this.size=0},Te.prototype.delete=function(t){var e=this.__data__,n=Ee(e,t);return!(n<0)&&(n==e.length-1?e.pop():ge.call(e,n,1),--this.size,!0)},Te.prototype.get=function(t){var e=this.__data__,n=Ee(e,t);return n<0?void 0:e[n][1]},Te.prototype.has=function(t){return Ee(this.__data__,t)>-1},Te.prototype.set=function(t,e){var n=this.__data__,i=Ee(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this};var Se=nt(m,"Map");function Le(t,e){var n,i,r=t.__data__;return("string"==(i=typeof(n=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function Oe(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var i=t[e];this.set(i[0],i[1])}}Oe.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(Se||Te),string:new me}},Oe.prototype.delete=function(t){var e=Le(this,t).delete(t);return this.size-=e?1:0,e},Oe.prototype.get=function(t){return Le(this,t).get(t)},Oe.prototype.has=function(t){return Le(this,t).has(t)},Oe.prototype.set=function(t,e){var n=Le(this,t),i=n.size;return n.set(t,e),this.size+=n.size==i?0:1,this};function Re(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var i=arguments,r=e?e.apply(this,i):i[0],s=n.cache;if(s.has(r))return s.get(r);var o=t.apply(this,i);return n.cache=s.set(r,o)||s,o};return n.cache=new(Re.Cache||Oe),n}Re.Cache=Oe;var Ae=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ve=/\\(\\)?/g,ye=function(t){var e=Re(t,function(t){return 500===n.size&&n.clear(),t}),n=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Ae,function(t,n,i,r){e.push(i?r.replace(ve,"$1"):n||t)}),e});function Ne(t,e){return I(t)?t:le(t,e)?[t]:ye(function(t){return null==t?"":k(t)}(t))}function Ie(t){if("string"==typeof t||y(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ce(t,e){for(var n=0,i=(e=Ne(e,t)).length;null!=t&&n<i;)t=t[Ie(e[n++])];return n&&n==i?t:void 0}function xe(t,e){for(var n=-1,i=e.length,r=t.length;++n<i;)t[r+n]=e[n];return t}var ke=E?E.isConcatSpreadable:void 0;function _e(t){return I(t)||Dt(t)||!!(ke&&t&&t[ke])}function Ue(t,e,n,i,r){var s=-1,o=t.length;for(n||(n=_e),r||(r=[]);++s<o;){var a=t[s];n(a)?xe(r,a):i||(r[r.length]=a)}return r}function be(t){return(null==t?0:t.length)?Ue(t):[]}var Me=Qt(Object.getPrototypeOf,Object);function Pe(t,e,n){var i=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(n=n>r?r:n)<0&&(n+=r),r=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(r);++i<r;)s[i]=t[i+e];return s}function we(t,e,n,i){var r=-1,s=null==t?0:t.length;for(i&&s&&(n=t[++r]);++r<s;)n=e(n,t[r],r,t);return n}function De(t){var e=this.__data__=new Te(t);this.size=e.size}De.prototype.clear=function(){this.__data__=new Te,this.size=0},De.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},De.prototype.get=function(t){return this.__data__.get(t)},De.prototype.has=function(t){return this.__data__.has(t)},De.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Te){var i=n.__data__;if(!Se||i.length<199)return i.push([t,e]),this.size=++n.size,this;n=this.__data__=new Oe(i)}return n.set(t,e),this.size=n.size,this};var Fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Fe&&"object"==typeof module&&module&&!module.nodeType&&module,je=Be&&Be.exports===Fe?m.Buffer:void 0,$e=je?je.allocUnsafe:void 0;function Ke(t,e){for(var n=-1,i=null==t?0:t.length,r=0,s=[];++n<i;){var o=t[n];e(o,n,t)&&(s[r++]=o)}return s}function Ge(){return[]}var ze=Object.prototype.propertyIsEnumerable,We=Object.getOwnPropertySymbols,Ve=We?function(t){return null==t?[]:(t=Object(t),Ke(We(t),function(e){return ze.call(t,e)}))}:Ge;var He=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)xe(e,Ve(t)),t=Me(t);return e}:Ge;function Ye(t,e,n){var i=e(t);return I(t)?i:xe(i,n(t))}function Xe(t){return Ye(t,ne,Ve)}var qe=nt(m,"DataView"),Ze=nt(m,"Promise"),Qe=nt(m,"Set"),Je="[object Map]",tn="[object Promise]",en="[object Set]",nn="[object WeakMap]",rn="[object DataView]",sn=Y(qe),on=Y(Se),an=Y(Ze),cn=Y(Qe),hn=Y(it),un=A;(qe&&un(new qe(new ArrayBuffer(1)))!=rn||Se&&un(new Se)!=Je||Ze&&un(Ze.resolve())!=tn||Qe&&un(new Qe)!=en||it&&un(new it)!=nn)&&(un=function(t){var e=A(t),n="[object Object]"==e?t.constructor:void 0,i=n?Y(n):"";if(i)switch(i){case sn:return rn;case on:return Je;case an:return tn;case cn:return en;case hn:return nn}return e});var ln=Object.prototype.hasOwnProperty;var dn=m.Uint8Array;var pn=/\w*$/;var fn=E?E.prototype:void 0,mn=fn?fn.valueOf:void 0;function En(t,e,n){var i,r,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new dn(a).set(new dn(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(r=t).buffer,new r.constructor(s,r.byteOffset,r.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,pn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return i=t,mn?Object(mn.call(i)):{}}}var gn=Ht&&Ht.isMap,Tn=gn?Gt(gn):function(t){return v(t)&&"[object Map]"==un(t)};var Sn=Ht&&Ht.isSet,Ln=Sn?Gt(Sn):function(t){return v(t)&&"[object Set]"==un(t)},On="[object Arguments]",Rn="[object Function]",An="[object Object]",vn={};function yn(t,e,n,i,r,s){var o,a=2&e;if(void 0!==o)return o;if(!M(t))return t;var c=I(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&ln.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,i=t.length;for(e||(e=Array(i));++n<i;)e[n]=t[n];return e}(t,o);var h=un(t),u=h==Rn||"[object GeneratorFunction]"==h;if($t(t))return function(t){var e=t.length,n=$e?$e(e):new t.constructor(e);return t.copy(n),n}(t);if(h==An||h==On||u&&!r)return o=u?{}:function(t){return"function"!=typeof t.constructor||Ut(t)?{}:st(Me(t))}(t),a?function(t,e){return yt(t,He(t),e)}(t,function(t,e){return t&&yt(e,ce(e),t)}(o,t)):function(t,e){return yt(t,Ve(t),e)}(t,function(t,e){return t&&yt(e,ne(e),t)}(o,t));if(!vn[h])return r?t:{};o=En(t,h),s||(s=new De);var l=s.get(t);if(l)return l;s.set(t,o),Ln(t)?t.forEach(function(i){o.add(yn(i,e,n,i,t,s))}):Tn(t)&&t.forEach(function(i,r){o.set(r,yn(i,e,n,r,t,s))});var d=c?void 0:Xe(t);return ft(d||t,function(i,r){d&&(i=t[r=i]),vt(o,r,yn(i,e,n,r,t,s))}),o}vn[On]=vn["[object Array]"]=vn["[object ArrayBuffer]"]=vn["[object DataView]"]=vn["[object Boolean]"]=vn["[object Date]"]=vn["[object Float32Array]"]=vn["[object Float64Array]"]=vn["[object Int8Array]"]=vn["[object Int16Array]"]=vn["[object Int32Array]"]=vn["[object Map]"]=vn["[object Number]"]=vn[An]=vn["[object RegExp]"]=vn["[object Set]"]=vn["[object String]"]=vn["[object Symbol]"]=vn["[object Uint8Array]"]=vn["[object Uint8ClampedArray]"]=vn["[object Uint16Array]"]=vn["[object Uint32Array]"]=!0,vn["[object Error]"]=vn[Rn]=vn["[object WeakMap]"]=!1;function Nn(t){return yn(t,4)}function In(t){for(var e=-1,n=null==t?0:t.length,i=0,r=[];++e<n;){var s=t[e];s&&(r[i++]=s)}return r}function Cn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Oe;++e<n;)this.add(t[e])}function xn(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(e(t[n],n,t))return!0;return!1}function kn(t,e){return t.has(e)}Cn.prototype.add=Cn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Cn.prototype.has=function(t){return this.__data__.has(t)};function _n(t,e,n,i,r,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var h=s.get(t),u=s.get(e);if(h&&u)return h==e&&u==t;var l=-1,d=!0,p=2&n?new Cn:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var f=t[l],m=e[l];if(i)var E=o?i(m,f,l,e,t,s):i(f,m,l,t,e,s);if(void 0!==E){if(E)continue;d=!1;break}if(p){if(!xn(e,function(t,e){if(!kn(p,e)&&(f===t||r(f,t,n,i,s)))return p.push(e)})){d=!1;break}}else if(f!==m&&!r(f,m,n,i,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function Un(t){var e=-1,n=Array(t.size);return t.forEach(function(t,i){n[++e]=[i,t]}),n}function bn(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var Mn=E?E.prototype:void 0,Pn=Mn?Mn.valueOf:void 0;var wn=Object.prototype.hasOwnProperty;var Dn="[object Arguments]",Fn="[object Array]",Bn="[object Object]",jn=Object.prototype.hasOwnProperty;function $n(t,e,n,i,r,s){var o=I(t),a=I(e),c=o?Fn:un(t),h=a?Fn:un(e),u=(c=c==Dn?Bn:c)==Bn,l=(h=h==Dn?Bn:h)==Bn,d=c==h;if(d&&$t(t)){if(!$t(e))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new De),o||Xt(t)?_n(t,e,n,i,r,s):function(t,e,n,i,r,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new dn(t),new dn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Rt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Un;case"[object Set]":var c=1&i;if(a||(a=bn),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;i|=2,o.set(t,e);var u=_n(a(t),a(e),i,r,s,o);return o.delete(t),u;case"[object Symbol]":if(Pn)return Pn.call(t)==Pn.call(e)}return!1}(t,e,c,n,i,r,s);if(!(1&n)){var p=u&&jn.call(t,"__wrapped__"),f=l&&jn.call(e,"__wrapped__");if(p||f){var m=p?t.value():t,E=f?e.value():e;return s||(s=new De),r(m,E,n,i,s)}}return!!d&&(s||(s=new De),function(t,e,n,i,r,s){var o=1&n,a=Xe(t),c=a.length;if(c!=Xe(e).length&&!o)return!1;for(var h=c;h--;){var u=a[h];if(!(o?u in e:wn.call(e,u)))return!1}var l=s.get(t),d=s.get(e);if(l&&d)return l==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<c;){var m=t[u=a[h]],E=e[u];if(i)var g=o?i(E,m,u,e,t,s):i(m,E,u,t,e,s);if(!(void 0===g?m===E||r(m,E,n,i,s):g)){p=!1;break}f||(f="constructor"==u)}if(p&&!f){var T=t.constructor,S=e.constructor;T==S||!("constructor"in t)||!("constructor"in e)||"function"==typeof T&&T instanceof T&&"function"==typeof S&&S instanceof S||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,i,r,s))}function Kn(t,e,n,i,r){return t===e||(null==t||null==e||!v(t)&&!v(e)?t!=t&&e!=e:$n(t,e,n,i,Kn,r))}function Gn(t){return t==t&&!M(t)}function zn(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}function Wn(t){var e=function(t){for(var e=ne(t),n=e.length;n--;){var i=e[n],r=t[i];e[n]=[i,r,Gn(r)]}return e}(t);return 1==e.length&&e[0][2]?zn(e[0][0],e[0][1]):function(n){return n===t||function(t,e,n,i){var r=n.length,s=r;if(null==t)return!s;for(t=Object(t);r--;){var o=n[r];if(o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++r<s;){var a=(o=n[r])[0],c=t[a],h=o[1];if(o[2]){if(void 0===c&&!(a in t))return!1}else if(!Kn(h,c,3,i,new De))return!1}return!0}(n,0,e)}}function Vn(t,e){return null!=t&&e in Object(t)}function Hn(t,e,n){for(var i=-1,r=(e=Ne(e,t)).length,s=!1;++i<r;){var o=Ie(e[i]);if(!(s=null!=t&&n(t,o)))break;t=t[o]}return s||++i!=r?s:!!(r=null==t?0:t.length)&&Ct(r)&&Lt(o,r)&&(I(t)||Dt(t))}function Yn(t,e){return le(t)&&Gn(e)?zn(Ie(t),e):function(n){var i=function(t,e,n){var i=null==t?void 0:Ce(t,e);return void 0===i?n:i}(n,t);return void 0===i&&i===e?function(t,e){return null!=t&&Hn(t,e,Vn)}(n,t):Kn(e,i,3)}}function Xn(t){return le(t)?(e=Ie(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return Ce(e,t)}}(t);var e}function qn(t){return"function"==typeof t?t:null==t?K:"object"==typeof t?I(t)?Yn(t[0],t[1]):Wn(t):Xn(t)}function Zn(t,e,n,i){for(var r=-1,s=null==t?0:t.length;++r<s;){var o=t[r];e(i,o,n(o),t)}return i}var Qn=function(t,e,n){for(var i=-1,r=Object(t),s=n(t),o=s.length;o--;){var a=s[++i];if(!1===e(r[a],a,r))break}return t};var Jn,ti=(Jn=function(t,e){return t&&Qn(t,e,ne)},function(t,e){if(null==t)return t;if(!xt(t))return Jn(t,e);for(var n=t.length,i=-1,r=Object(t);++i<n&&!1!==e(r[i],i,r););return t});function ei(t,e,n,i){return ti(t,function(t,r,s){e(i,t,n(t),s)}),i}var ni=Object.prototype,ii=ni.hasOwnProperty,ri=It(function(t,e){t=Object(t);var n=-1,i=e.length,r=i>2?e[2]:void 0;for(r&&kt(e[0],e[1],r)&&(i=1);++n<i;)for(var s=e[n],o=ce(s),a=-1,c=o.length;++a<c;){var h=o[a],u=t[h];(void 0===u||Rt(u,ni[h])&&!ii.call(t,h))&&(t[h]=s[h])}return t});function si(t){return v(t)&&xt(t)}var oi=It(function(t,e){return si(t)?function(t,e,n,i){var r=-1,s=Tt,o=!0,a=t.length,c=[],h=e.length;if(!a)return c;e.length>=200&&(s=kn,o=!1,e=new Cn(e));t:for(;++r<a;){var u=t[r],l=u;if(u=0!==u?u:0,o&&l==l){for(var d=h;d--;)if(e[d]===l)continue t;c.push(u)}else s(e,l,i)||c.push(u)}return c}(t,Ue(e,0,si,!0)):[]});function ai(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}function ci(t,e,n){var i=null==t?0:t.length;return i?Pe(t,(e=void 0===e?1:$(e))<0?0:e,i):[]}function hi(t,e,n){var i=null==t?0:t.length;return i?Pe(t,0,(e=i-(e=void 0===e?1:$(e)))<0?0:e):[]}function ui(t,e){var n;return(I(t)?ft:ti)(t,"function"==typeof(n=e)?n:K)}function li(t,e){for(var n=-1,i=null==t?0:t.length;++n<i;)if(!e(t[n],n,t))return!1;return!0}function di(t,e){var n=!0;return ti(t,function(t,i,r){return n=!!e(t,i,r)}),n}function pi(t,e,n){return(I(t)?li:di)(t,qn(e))}function fi(t,e){var n=[];return ti(t,function(t,i,r){e(t,i,r)&&n.push(t)}),n}function mi(t,e){return(I(t)?Ke:fi)(t,qn(e))}var Ei=Math.max;var gi,Ti=(gi=function(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var r=null==n?0:$(n);return r<0&&(r=Ei(i+r,0)),mt(t,qn(e),r)},function(t,e,n){var i=Object(t);if(!xt(t)){var r=qn(e);t=ne(t),e=function(t){return r(i[t],t,i)}}var s=gi(t,e,n);return s>-1?i[r?t[s]:s]:void 0});function Si(t){return t&&t.length?t[0]:void 0}function Li(t,e){var n=-1,i=xt(t)?Array(t.length):[];return ti(t,function(t,r,s){i[++n]=e(t,r,s)}),i}function Oi(t,e){return(I(t)?N:Li)(t,qn(e))}function Ri(t,e){return Ue(Oi(t,e))}var Ai,vi,yi=Object.prototype.hasOwnProperty,Ni=(Ai=function(t,e,n){yi.call(t,n)?t[n].push(e):Ot(t,n,[e])},function(t,e){var n=I(t)?Zn:ei,i=vi?vi():{};return n(t,Ai,qn(e),i)}),Ii=Object.prototype.hasOwnProperty;function Ci(t,e){return null!=t&&Ii.call(t,e)}function xi(t,e){return null!=t&&Hn(t,e,Ci)}function ki(t){return"string"==typeof t||!I(t)&&v(t)&&"[object String]"==A(t)}function _i(t){return null==t?[]:function(t,e){return N(e,function(e){return t[e]})}(t,ne(t))}var Ui=Math.max;function bi(t,e,n,i){t=xt(t)?t:_i(t),n=n?$(n):0;var r=t.length;return n<0&&(n=Ui(r+n,0)),ki(t)?n<=r&&t.indexOf(e,n)>-1:!!r&&gt(t,e,n)>-1}function Mi(t,e,n){if(!(null==t?0:t.length))return-1;return gt(t,e,0)}var Pi=Object.prototype.hasOwnProperty;function wi(t){if(null==t)return!0;if(xt(t)&&(I(t)||"string"==typeof t||"function"==typeof t.splice||$t(t)||Xt(t)||Dt(t)))return!t.length;var e=un(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Ut(t))return!ee(t).length;for(var n in t)if(Pi.call(t,n))return!1;return!0}var Di=Ht&&Ht.isRegExp,Fi=Di?Gt(Di):function(t){return v(t)&&"[object RegExp]"==A(t)};function Bi(t){return void 0===t}function ji(t,e,n,i){if(!M(t))return t;for(var r=-1,s=(e=Ne(e,t)).length,o=s-1,a=t;null!=a&&++r<s;){var c=Ie(e[r]),h=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return t;if(r!=o){var u=a[c];void 0===(h=void 0)&&(h=M(u)?u:Lt(e[r+1])?[]:{})}vt(a,c,h),a=a[c]}return t}function $i(t,e){if(null==t)return{};var n=N(function(t){return Ye(t,ce,He)}(t),function(t){return[t]});return e=qn(e),function(t,e,n){for(var i=-1,r=e.length,s={};++i<r;){var o=e[i],a=Ce(t,o);n(a,o)&&ji(s,Ne(o,t),a)}return s}(t,n,function(t,n){return e(t,n[0])})}function Ki(t,e,n,i,r){return r(t,function(t,r,s){n=i?(i=!1,t):e(n,t,r,s)}),n}function Gi(t,e,n){var i=I(t)?we:Ki,r=arguments.length<3;return i(t,qn(e),n,r,ti)}function zi(t,e){return(I(t)?Ke:fi)(t,function(t){if("function"!=typeof t)throw new TypeError("Expected a function");return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}(qn(e)))}function Wi(t,e){var n;return ti(t,function(t,i,r){return!(n=e(t,i,r))}),!!n}function Vi(t,e,n){return(I(t)?xn:Wi)(t,qn(e))}var Hi=Qe&&1/bn(new Qe([,-0]))[1]==1/0?function(t){return new Qe(t)}:ot;function Yi(t){return t&&t.length?function(t,e,n){var i=-1,r=Tt,s=t.length,o=!0,a=[],c=a;if(s>=200){var h=Hi(t);if(h)return bn(h);o=!1,r=kn,c=new Cn}else c=a;t:for(;++i<s;){var u=t[i],l=u;if(u=0!==u?u:0,o&&l==l){for(var d=c.length;d--;)if(c[d]===l)continue t;a.push(u)}else r(c,l,n)||(c!==a&&c.push(l),a.push(u))}return a}(t):[]}function Xi(t){console&&console.error&&console.error(`Error: ${t}`)}function qi(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function Zi(t){const e=(new Date).getTime(),n=t();return{time:(new Date).getTime()-e,value:n}}function Qi(t){function e(){}e.prototype=t;const n=new e;function i(){return typeof n.bar}return i(),i(),t}function Ji(t){return ki((e=t).LABEL)&&""!==e.LABEL?t.LABEL:t.name;var e}class tr{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),ui(this.definition,e=>{e.accept(t)})}}class er extends tr{constructor(t){super([]),this.idx=1,se(this,$i(t,t=>void 0!==t))}set definition(t){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(t){t.visit(this)}}class nr extends tr{constructor(t){super(t.definition),this.orgText="",se(this,$i(t,t=>void 0!==t))}}class ir extends tr{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,se(this,$i(t,t=>void 0!==t))}}class rr extends tr{constructor(t){super(t.definition),this.idx=1,se(this,$i(t,t=>void 0!==t))}}class sr extends tr{constructor(t){super(t.definition),this.idx=1,se(this,$i(t,t=>void 0!==t))}}class or extends tr{constructor(t){super(t.definition),this.idx=1,se(this,$i(t,t=>void 0!==t))}}class ar extends tr{constructor(t){super(t.definition),this.idx=1,se(this,$i(t,t=>void 0!==t))}}class cr extends tr{constructor(t){super(t.definition),this.idx=1,se(this,$i(t,t=>void 0!==t))}}class hr extends tr{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,se(this,$i(t,t=>void 0!==t))}}class ur{constructor(t){this.idx=1,se(this,$i(t,t=>void 0!==t))}accept(t){t.visit(this)}}function lr(t){function e(t){return Oi(t,lr)}if(t instanceof er){const e={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return ki(t.label)&&(e.label=t.label),e}if(t instanceof ir)return{type:"Alternative",definition:e(t.definition)};if(t instanceof rr)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof sr)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof or)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:lr(new ur({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof cr)return{type:"RepetitionWithSeparator",idx:t.idx,separator:lr(new ur({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ar)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof hr)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof ur){const e={type:"Terminal",name:t.terminalType.name,label:Ji(t.terminalType),idx:t.idx};ki(t.label)&&(e.terminalLabel=t.label);const n=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(e.pattern=Fi(n)?n.source:n),e}if(t instanceof nr)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}class dr{visit(t){const e=t;switch(e.constructor){case er:return this.visitNonTerminal(e);case ir:return this.visitAlternative(e);case rr:return this.visitOption(e);case sr:return this.visitRepetitionMandatory(e);case or:return this.visitRepetitionMandatoryWithSeparator(e);case cr:return this.visitRepetitionWithSeparator(e);case ar:return this.visitRepetition(e);case hr:return this.visitAlternation(e);case ur:return this.visitTerminal(e);case nr:return this.visitRule(e);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}}function pr(t,e=[]){return!!(t instanceof rr||t instanceof ar||t instanceof cr)||(t instanceof hr?Vi(t.definition,t=>pr(t,e)):!(t instanceof er&&bi(e,t))&&(t instanceof tr&&(t instanceof er&&e.push(t),pi(t.definition,t=>pr(t,e)))))}function fr(t){if(t instanceof er)return"SUBRULE";if(t instanceof rr)return"OPTION";if(t instanceof hr)return"OR";if(t instanceof sr)return"AT_LEAST_ONE";if(t instanceof or)return"AT_LEAST_ONE_SEP";if(t instanceof cr)return"MANY_SEP";if(t instanceof ar)return"MANY";if(t instanceof ur)return"CONSUME";throw Error("non exhaustive match")}class mr{walk(t,e=[]){ui(t.definition,(n,i)=>{const r=ci(t.definition,i+1);if(n instanceof er)this.walkProdRef(n,r,e);else if(n instanceof ur)this.walkTerminal(n,r,e);else if(n instanceof ir)this.walkFlat(n,r,e);else if(n instanceof rr)this.walkOption(n,r,e);else if(n instanceof sr)this.walkAtLeastOne(n,r,e);else if(n instanceof or)this.walkAtLeastOneSep(n,r,e);else if(n instanceof cr)this.walkManySep(n,r,e);else if(n instanceof ar)this.walkMany(n,r,e);else{if(!(n instanceof hr))throw Error("non exhaustive match");this.walkOr(n,r,e)}})}walkTerminal(t,e,n){}walkProdRef(t,e,n){}walkFlat(t,e,n){const i=e.concat(n);this.walk(t,i)}walkOption(t,e,n){const i=e.concat(n);this.walk(t,i)}walkAtLeastOne(t,e,n){const i=[new rr({definition:t.definition})].concat(e,n);this.walk(t,i)}walkAtLeastOneSep(t,e,n){const i=Er(t,e,n);this.walk(t,i)}walkMany(t,e,n){const i=[new rr({definition:t.definition})].concat(e,n);this.walk(t,i)}walkManySep(t,e,n){const i=Er(t,e,n);this.walk(t,i)}walkOr(t,e,n){const i=e.concat(n);ui(t.definition,t=>{const e=new ir({definition:[t]});this.walk(e,i)})}}function Er(t,e,n){return[new rr({definition:[new ur({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}function gr(t){if(t instanceof er)return gr(t.referencedRule);if(t instanceof ur)return[t.terminalType];if(function(t){return t instanceof ir||t instanceof rr||t instanceof ar||t instanceof sr||t instanceof or||t instanceof cr||t instanceof ur||t instanceof nr}(t))return function(t){let e=[];const n=t.definition;let i,r=0,s=n.length>r,o=!0;for(;s&&o;)i=n[r],o=pr(i),e=e.concat(gr(i)),r+=1,s=n.length>r;return Yi(e)}(t);if(function(t){return t instanceof hr}(t))return function(t){const e=Oi(t.definition,t=>gr(t));return Yi(be(e))}(t);throw Error("non exhaustive match")}const Tr="_~IN~_";class Sr extends mr{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,e,n){}walkProdRef(t,e,n){const i=(r=t.referencedRule,s=t.idx,r.name+s+Tr+this.topProd.name);var r,s;const o=e.concat(n),a=gr(new ir({definition:o}));this.follows[i]=a}}function Lr(t){return t.charCodeAt(0)}function Or(t,e){Array.isArray(t)?t.forEach(function(t){e.push(t)}):e.push(t)}function Rr(t,e){if(!0===t[e])throw"duplicate flag "+e;t[e],t[e]=!0}function Ar(t){if(void 0===t)throw Error("Internal Error - Should never get here!");return!0}function vr(t){return"Character"===t.type}const yr=[];for(let ah=Lr("0");ah<=Lr("9");ah++)yr.push(ah);const Nr=[Lr("_")].concat(yr);for(let ah=Lr("a");ah<=Lr("z");ah++)Nr.push(ah);for(let ah=Lr("A");ah<=Lr("Z");ah++)Nr.push(ah);const Ir=[Lr(" "),Lr("\f"),Lr("\n"),Lr("\r"),Lr("\t"),Lr("\v"),Lr("\t"),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr(" "),Lr("\u2028"),Lr("\u2029"),Lr(" "),Lr(" "),Lr(" "),Lr("\ufeff")],Cr=/[0-9a-fA-F]/,xr=/[0-9]/,kr=/[1-9]/;class _r{visitChildren(t){for(const e in t){const n=t[e];t.hasOwnProperty(e)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach(t=>{this.visit(t)},this))}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Lookbehind":this.visitLookbehind(t);break;case"NegativeLookbehind":this.visitNegativeLookbehind(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t)}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitLookbehind(t){}visitNegativeLookbehind(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}}let Ur={};const br=new class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");const e=this.disjunction();this.consumeChar("/");const n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Rr(n,"global");break;case"i":Rr(n,"ignoreCase");break;case"m":Rr(n,"multiLine");break;case"u":Rr(n,"unicode");break;case"y":Rr(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:e,loc:this.loc(0)}}disjunction(){const t=[],e=this.idx;for(t.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(e)}}alternative(){const t=[],e=this.idx;for(;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(e)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":let e;switch(this.consumeChar("?"),this.popChar()){case"=":e="Lookahead";break;case"!":e="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":e="Lookbehind";break;case"!":e="NegativeLookbehind"}}Ar(e);const n=this.disjunction();return this.consumeChar(")"),{type:e,value:n,loc:this.loc(t)}}return function(){throw Error("Internal Error - Should never get here!")}()}quantifier(t=!1){let e;const n=this.idx;switch(this.popChar()){case"*":e={atLeast:0,atMost:1/0};break;case"+":e={atLeast:1,atMost:1/0};break;case"?":e={atLeast:0,atMost:1};break;case"{":const n=this.integerIncludingZero();switch(this.popChar()){case"}":e={atLeast:n,atMost:n};break;case",":let t;this.isDigit()?(t=this.integerIncludingZero(),e={atLeast:n,atMost:t}):e={atLeast:n,atMost:1/0},this.consumeChar("}")}if(!0===t&&void 0===e)return;Ar(e)}if(!0!==t||void 0!==e)return Ar(e)?("?"===this.peekChar(0)?(this.consumeChar("?"),e.greedy=!1):e.greedy=!0,e.type="Quantifier",e.loc=this.loc(n),e):void 0}atom(){let t;const e=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group()}if(void 0===t&&this.isPatternCharacter()&&(t=this.patternCharacter()),Ar(t))return t.loc=this.loc(e),this.isQuantifier()&&(t.quantifier=this.quantifier()),t}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[Lr("\n"),Lr("\r"),Lr("\u2028"),Lr("\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 t,e=!1;switch(this.popChar()){case"d":t=yr;break;case"D":t=yr,e=!0;break;case"s":t=Ir;break;case"S":t=Ir,e=!0;break;case"w":t=Nr;break;case"W":t=Nr,e=!0}if(Ar(t))return{type:"Set",value:t,complement:e}}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=Lr("\f");break;case"n":t=Lr("\n");break;case"r":t=Lr("\r");break;case"t":t=Lr("\t");break;case"v":t=Lr("\v")}if(Ar(t))return{type:"Character",value:t}}controlLetterEscapeAtom(){this.consumeChar("c");const t=this.popChar();if(!1===/[a-zA-Z]/.test(t))throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:Lr("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:Lr(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:Lr(this.popChar())}}}characterClass(){const t=[];let e=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),e=!0);this.isClassAtom();){const e=this.classAtom();if(e.type,vr(e)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,vr(n)){if(n.value<e.value)throw Error("Range out of order in character class");t.push({from:e.value,to:n.value})}else Or(e.value,t),t.push(Lr("-")),Or(n.value,t)}else Or(e.value,t)}return this.consumeChar("]"),{type:"Set",complement:e,value:t}}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:Lr("\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 t=!0;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),t=!1;else this.groupIdx++;const e=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:t,value:e};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if(!1===kr.test(t))throw Error("Expecting a positive integer");for(;xr.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(!1===xr.test(t))throw Error("Expecting an integer");for(;xr.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){const t=this.popChar();switch(t){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:Lr(t)}}}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 xr.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){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(){const t=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(t)}}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(t){let e="";for(let n=0;n<t;n++){const t=this.popChar();if(!1===Cr.test(t))throw Error("Expecting a HexDecimal digits");e+=t}return{type:"Character",value:parseInt(e,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){const t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(void 0!==t&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}};function Mr(t){const e=t.toString();if(Ur.hasOwnProperty(e))return Ur[e];{const t=br.pattern(e);return Ur[e]=t,t}}const Pr="Complement Sets are not supported for first char optimization",wr='Unable to use "first char" lexer optimizations:\n';function Dr(t,e=!1){try{const e=Mr(t);return Fr(e.value,{},e.flags.ignoreCase)}catch(n){if(n.message===Pr)e&&qi(`${wr}\tUnable to optimize: < ${t.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";e&&(n="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Xi(`${wr}\n\tFailed parsing: < ${t.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Fr(t,e,n){switch(t.type){case"Disjunction":for(let r=0;r<t.value.length;r++)Fr(t.value[r],e,n);break;case"Alternative":const i=t.value;for(let t=0;t<i.length;t++){const r=i[t];switch(r.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const s=r;switch(s.type){case"Character":Br(s.value,e,n);break;case"Set":if(!0===s.complement)throw Error(Pr);ui(s.value,t=>{if("number"==typeof t)Br(t,e,n);else{const i=t;if(!0===n)for(let t=i.from;t<=i.to;t++)Br(t,e,n);else{for(let t=i.from;t<=i.to&&t<ss;t++)Br(t,e,n);if(i.to>=ss){const t=i.from>=ss?i.from:ss,n=i.to,r=as(t),s=as(n);for(let i=r;i<=s;i++)e[i]=i}}}});break;case"Group":Fr(s.value,e,n);break;default:throw Error("Non Exhaustive Match")}const o=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===$r(s)||"Group"!==s.type&&!1===o)break}break;default:throw Error("non exhaustive match!")}return _i(e)}function Br(t,e,n){const i=as(t);e[i]=i,!0===n&&function(t,e){const n=String.fromCharCode(t),i=n.toUpperCase();if(i!==n){const t=as(i.charCodeAt(0));e[t]=t}else{const t=n.toLowerCase();if(t!==n){const n=as(t.charCodeAt(0));e[n]=n}}}(t,e)}function jr(t,e){return Ti(t.value,t=>{if("number"==typeof t)return bi(e,t);{const n=t;return void 0!==Ti(e,t=>n.from<=t&&t<=n.to)}})}function $r(t){const e=t.quantifier;return!(!e||0!==e.atLeast)||!!t.value&&(I(t.value)?pi(t.value,$r):$r(t.value))}class Kr extends _r{constructor(t){super(),this.targetCharCodes=t,this.found=!1}visitChildren(t){if(!0!==this.found){switch(t.type){case"Lookahead":return void this.visitLookahead(t);case"NegativeLookahead":return void this.visitNegativeLookahead(t);case"Lookbehind":return void this.visitLookbehind(t);case"NegativeLookbehind":return void this.visitNegativeLookbehind(t)}super.visitChildren(t)}}visitCharacter(t){bi(this.targetCharCodes,t.value)&&(this.found=!0)}visitSet(t){t.complement?void 0===jr(t,this.targetCharCodes)&&(this.found=!0):void 0!==jr(t,this.targetCharCodes)&&(this.found=!0)}}function Gr(t,e){if(e instanceof RegExp){const n=Mr(e),i=new Kr(t);return i.visit(n),i.found}return void 0!==Ti(e,e=>bi(t,e.charCodeAt(0)))}const zr="PATTERN",Wr="defaultMode",Vr="modes";function Hr(t,e){const n=(e=ri(e,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(t,e)=>e()})).tracer;let i;n("initCharCodeToOptimizedIndexMap",()=>{!function(){if(wi(os)){os=new Array(65536);for(let t=0;t<65536;t++)os[t]=t>255?255+~~(t/255):t}}()}),n("Reject Lexer.NA",()=>{i=zi(t,t=>t[zr]===Os.NA)});let r,s,o,a,c,h,u,l,d,p,f,m=!1;n("Transform Patterns",()=>{m=!1,r=Oi(i,t=>{const e=t[zr];if(Fi(e)){const t=e.source;return 1!==t.length||"^"===t||"$"===t||"."===t||e.ignoreCase?2!==t.length||"\\"!==t[0]||bi(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],t[1])?Zr(e):t[1]:t}if(G(e))return m=!0,{exec:e};if("object"==typeof e)return m=!0,e;if("string"==typeof e){if(1===e.length)return e;{const t=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&");return Zr(new RegExp(t))}}throw Error("non exhaustive match")})}),n("misc mapping",()=>{s=Oi(i,t=>t.tokenTypeIdx),o=Oi(i,t=>{const e=t.GROUP;if(e!==Os.SKIPPED){if(ki(e))return e;if(Bi(e))return!1;throw Error("non exhaustive match")}}),a=Oi(i,t=>{const e=t.LONGER_ALT;if(e){return I(e)?Oi(e,t=>Mi(i,t)):[Mi(i,e)]}}),c=Oi(i,t=>t.PUSH_MODE),h=Oi(i,t=>xi(t,"POP_MODE"))}),n("Line Terminator Handling",()=>{const t=is(e.lineTerminatorCharacters);u=Oi(i,t=>!1),"onlyOffset"!==e.positionTracking&&(u=Oi(i,e=>xi(e,"LINE_BREAKS")?!!e.LINE_BREAKS:!1===ns(e,t)&&Gr(t,e.PATTERN)))}),n("Misc Mapping #2",()=>{l=Oi(i,Jr),d=Oi(r,ts),p=Gi(i,(t,e)=>{const n=e.GROUP;return ki(n)&&n!==Os.SKIPPED&&(t[n]=[]),t},{}),f=Oi(r,(t,e)=>({pattern:r[e],longerAlt:a[e],canLineTerminator:u[e],isCustom:l[e],short:d[e],group:o[e],push:c[e],pop:h[e],tokenTypeIdx:s[e],tokenType:i[e]}))});let E=!0,g=[];return e.safeMode||n("First Char Optimization",()=>{g=Gi(i,(t,n,i)=>{if("string"==typeof n.PATTERN){const e=as(n.PATTERN.charCodeAt(0));rs(t,e,f[i])}else if(I(n.START_CHARS_HINT)){let e;ui(n.START_CHARS_HINT,n=>{const r=as("string"==typeof n?n.charCodeAt(0):n);e!==r&&(e=r,rs(t,r,f[i]))})}else if(Fi(n.PATTERN))if(n.PATTERN.unicode)E=!1,e.ensureOptimizations&&Xi(`${wr}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const r=Dr(n.PATTERN,e.ensureOptimizations);wi(r)&&(E=!1),ui(r,e=>{rs(t,e,f[i])})}else e.ensureOptimizations&&Xi(`${wr}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return t},[])}),{emptyGroups:p,patternIdxToConfig:f,charCodeToPatternIdxToConfig:g,hasCustom:m,canBeOptimized:E}}function Yr(t,e){let n=[];const i=function(t){const e=mi(t,t=>!xi(t,zr)),n=Oi(e,t=>({message:"Token Type: ->"+t.name+"<- missing static 'PATTERN' property",type:Ts.MISSING_PATTERN,tokenTypes:[t]})),i=oi(t,e);return{errors:n,valid:i}}(t);n=n.concat(i.errors);const r=function(t){const e=mi(t,t=>{const e=t[zr];return!(Fi(e)||G(e)||xi(e,"exec")||ki(e))}),n=Oi(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:Ts.INVALID_PATTERN,tokenTypes:[t]})),i=oi(t,e);return{errors:n,valid:i}}(i.valid),s=r.valid;return n=n.concat(r.errors),n=n.concat(function(t){let e=[];const n=mi(t,t=>Fi(t[zr]));return e=e.concat(function(t){class e extends _r{constructor(){super(...arguments),this.found=!1}visitEndAnchor(t){this.found=!0}}const n=mi(t,t=>{const n=t.PATTERN;try{const t=Mr(n),i=new e;return i.visit(t),i.found}catch(i){return Xr.test(n.source)}}),i=Oi(n,t=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Ts.EOI_ANCHOR_FOUND,tokenTypes:[t]}));return i}(n)),e=e.concat(function(t){class e extends _r{constructor(){super(...arguments),this.found=!1}visitStartAnchor(t){this.found=!0}}const n=mi(t,t=>{const n=t.PATTERN;try{const t=Mr(n),i=new e;return i.visit(t),i.found}catch(i){return qr.test(n.source)}}),i=Oi(n,t=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Ts.SOI_ANCHOR_FOUND,tokenTypes:[t]}));return i}(n)),e=e.concat(function(t){const e=mi(t,t=>{const e=t[zr];return e instanceof RegExp&&(e.multiline||e.global)}),n=Oi(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:Ts.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}));return n}(n)),e=e.concat(function(t){const e=[];let n=Oi(t,n=>Gi(t,(t,i)=>(n.PATTERN.source!==i.PATTERN.source||bi(e,i)||i.PATTERN===Os.NA||(e.push(i),t.push(i)),t),[]));n=In(n);const i=Oi(mi(n,t=>t.length>1),t=>{const e=Oi(t,t=>t.name);return{message:`The same RegExp pattern ->${Si(t).PATTERN}<-has been used in all of the following Token Types: ${e.join(", ")} <-`,type:Ts.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}});return i}(n)),e=e.concat(function(t){const e=mi(t,t=>t.PATTERN.test("")),n=Oi(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:Ts.EMPTY_MATCH_PATTERN,tokenTypes:[t]}));return n}(n)),e}(s)),n=n.concat(function(t){const e=mi(t,t=>{if(!xi(t,"GROUP"))return!1;const e=t.GROUP;return e!==Os.SKIPPED&&e!==Os.NA&&!ki(e)}),n=Oi(e,t=>({message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:Ts.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}));return n}(s)),n=n.concat(function(t,e){const n=mi(t,t=>void 0!==t.PUSH_MODE&&!bi(e,t.PUSH_MODE)),i=Oi(n,t=>({message:`Token Type: ->${t.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${t.PUSH_MODE}<-which does not exist`,type:Ts.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}));return i}(s,e)),n=n.concat(function(t){const e=[],n=Gi(t,(t,e,n)=>{const i=e.PATTERN;return i===Os.NA||(ki(i)?t.push({str:i,idx:n,tokenType:e}):Fi(i)&&(r=i,void 0===Ti([".","\\","[","]","|","^","$","(",")","?","*","+","{"],t=>-1!==r.source.indexOf(t)))&&t.push({str:i.source,idx:n,tokenType:e})),t;var r},[]);return ui(t,(t,i)=>{ui(n,({str:n,idx:r,tokenType:s})=>{if(i<r&&function(t,e){if(Fi(e)){if(/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source))return!1;const n=e.exec(t);return null!==n&&0===n.index}if(G(e))return e(t,0,[],{});if(xi(e,"exec"))return e.exec(t,0,[],{});if("string"==typeof e)return e===t;throw Error("non exhaustive match")}(n,t.PATTERN)){const n=`Token: ->${s.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${t.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:n,type:Ts.UNREACHABLE_PATTERN,tokenTypes:[t,s]})}})}),e}(s)),n}const Xr=/[^\\][$]/;const qr=/[^\\[][\^]|^\^/;function Zr(t){const e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}function Qr(t,e,n){const i=[];let r=!1;const s=zi(In(be(_i(t.modes))),t=>t[zr]===Os.NA),o=is(n);return e&&ui(s,t=>{const e=ns(t,o);if(!1!==e){const n=function(t,e){if(e.issue===Ts.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${t.name}> Token Type\n\t Root cause: ${e.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===Ts.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${t.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(t,e),r={message:n,type:e.issue,tokenType:t};i.push(r)}else xi(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(r=!0):Gr(o,t.PATTERN)&&(r=!0)}),e&&!r&&i.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:Ts.NO_LINE_BREAKS_FLAGS}),i}function Jr(t){const e=t.PATTERN;if(Fi(e))return!1;if(G(e))return!0;if(xi(e,"exec"))return!0;if(ki(e))return!1;throw Error("non exhaustive match")}function ts(t){return!(!ki(t)||1!==t.length)&&t.charCodeAt(0)}const es={test:function(t){const e=t.length;for(let n=this.lastIndex;n<e;n++){const e=t.charCodeAt(n);if(10===e)return this.lastIndex=n+1,!0;if(13===e)return 10===t.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function ns(t,e){if(xi(t,"LINE_BREAKS"))return!1;if(Fi(t.PATTERN)){try{Gr(e,t.PATTERN)}catch(n){return{issue:Ts.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}if(ki(t.PATTERN))return!1;if(Jr(t))return{issue:Ts.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function is(t){return Oi(t,t=>ki(t)?t.charCodeAt(0):t)}function rs(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}const ss=256;let os=[];function as(t){return t<ss?t:os[t]}function cs(t,e){const n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function hs(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}let us=1;const ls={};function ds(t){const e=function(t){let e=Nn(t),n=t,i=!0;for(;i;){n=In(be(Oi(n,t=>t.CATEGORIES)));const t=oi(n,e);e=e.concat(t),wi(t)?i=!1:n=t}return e}(t);!function(t){ui(t,t=>{fs(t)||(ls[us]=t,t.tokenTypeIdx=us++),ms(t)&&!I(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),ms(t)||(t.CATEGORIES=[]),xi(t,"categoryMatches")||(t.categoryMatches=[]),function(t){return xi(t,"categoryMatchesMap")}(t)||(t.categoryMatchesMap={})})}(e),function(t){ui(t,t=>{ps([],t)})}(e),function(t){ui(t,t=>{t.categoryMatches=[],ui(t.categoryMatchesMap,(e,n)=>{t.categoryMatches.push(ls[n].tokenTypeIdx)})})}(e),ui(e,t=>{t.isParent=t.categoryMatches.length>0})}function ps(t,e){ui(t,t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),ui(e.CATEGORIES,n=>{const i=t.concat(e);bi(i,n)||ps(i,n)})}function fs(t){return xi(t,"tokenTypeIdx")}function ms(t){return xi(t,"CATEGORIES")}function Es(t){return xi(t,"tokenTypeIdx")}const gs={buildUnableToPopLexerModeMessage:t=>`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(t,e,n,i,r,s)=>`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${n} characters.`};var Ts,Ss;(Ss=Ts||(Ts={}))[Ss.MISSING_PATTERN=0]="MISSING_PATTERN",Ss[Ss.INVALID_PATTERN=1]="INVALID_PATTERN",Ss[Ss.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",Ss[Ss.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",Ss[Ss.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",Ss[Ss.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",Ss[Ss.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",Ss[Ss.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",Ss[Ss.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",Ss[Ss.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",Ss[Ss.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",Ss[Ss.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",Ss[Ss.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",Ss[Ss.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",Ss[Ss.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",Ss[Ss.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",Ss[Ss.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",Ss[Ss.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";const Ls={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:gs,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Ls);class Os{constructor(t,e=Ls){if(this.lexerDefinition=t,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=(t,e)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${t}>`);const{time:i,value:r}=Zi(e),s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${i}ms`),this.traceInitIndent--,r}return e()},"boolean"==typeof e)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=se({},Ls,e);const n=this.config.traceInitPerf;!0===n?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof n&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,i=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Ls.lineTerminatorsPattern)this.config.lineTerminatorsPattern=es;else if(this.config.lineTerminatorCharacters===Ls.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(e.safeMode&&e.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),I(t)?n={modes:{defaultMode:Nn(t)},defaultMode:Wr}:(i=!1,n=Nn(t))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(t){const e=[];return xi(t,Wr)||e.push({message:"A MultiMode Lexer cannot be initialized without a <"+Wr+"> property in its definition\n",type:Ts.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),xi(t,Vr)||e.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:Ts.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),xi(t,Vr)&&xi(t,Wr)&&!xi(t.modes,t.defaultMode)&&e.push({message:`A MultiMode Lexer cannot be initialized with a ${Wr}: <${t.defaultMode}>which does not exist\n`,type:Ts.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),xi(t,Vr)&&ui(t.modes,(t,n)=>{ui(t,(i,r)=>{Bi(i)?e.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${r}>\n`,type:Ts.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):xi(i,"LONGER_ALT")&&ui(I(i.LONGER_ALT)?i.LONGER_ALT:[i.LONGER_ALT],r=>{Bi(r)||bi(t,r)||e.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${r.name}> on token <${i.name}> outside of mode <${n}>\n`,type:Ts.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),e}(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Qr(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},ui(n.modes,(t,e)=>{n.modes[e]=zi(t,t=>Bi(t))});const r=ne(n.modes);if(ui(n.modes,(t,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Yr(t,r))}),wi(this.lexerDefinitionErrors)){let i;ds(t),this.TRACE_INIT("analyzeTokenTypes",()=>{i=Hr(t,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:e.positionTracking,ensureOptimizations:e.ensureOptimizations,safeMode:e.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=i.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=i.charCodeToPatternIdxToConfig,this.emptyGroups=se({},this.emptyGroups,i.emptyGroups),this.hasCustom=i.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=i.canBeOptimized}})}),this.defaultMode=n.defaultMode,!wi(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const t=Oi(this.lexerDefinitionErrors,t=>t.message).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+t)}ui(this.lexerDefinitionWarning,t=>{qi(t.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(i&&(this.handleModes=ot),!1===this.trackStartLines&&(this.computeNewColumn=K),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=ot),/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))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const t=Gi(this.canModeBeOptimized,(t,e,n)=>(!1===e&&t.push(n),t),[]);if(e.ensureOptimizations&&!wi(t))throw Error(`Lexer Modes: < ${t.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Ur={}}),this.TRACE_INIT("toFastProperties",()=>{Qi(this)})})}tokenize(t,e=this.defaultMode){if(!wi(this.lexerDefinitionErrors)){const t=Oi(this.lexerDefinitionErrors,t=>t.message).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+t)}return this.tokenizeInternal(t,e)}tokenizeInternal(t,e){let n,i,r,s,o,a,c,h,u,l,d,p,f,m,E;const g=t,T=g.length;let S=0,L=0;const O=this.hasCustom?0:Math.floor(t.length/10),R=new Array(O),A=[];let v=this.trackStartLines?1:void 0,y=this.trackStartLines?1:void 0;const N=function(t){const e={};return ui(ne(t),n=>{const i=t[n];if(!I(i))throw Error("non exhaustive match");e[n]=[]}),e}(this.emptyGroups),C=this.trackStartLines,x=this.config.lineTerminatorsPattern;let k=0,_=[],U=[];const b=[],M=[];Object.freeze(M);let P=!1;const w=t=>{if(1===b.length&&void 0===t.tokenType.PUSH_MODE){const e=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(t);A.push({offset:t.startOffset,line:t.startLine,column:t.startColumn,length:t.image.length,message:e})}else{b.pop();const t=ai(b);_=this.patternIdxToConfig[t],U=this.charCodeToPatternIdxToConfig[t],k=_.length;const e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;P=!(!U||!e)}};function D(t){b.push(t),U=this.charCodeToPatternIdxToConfig[t],_=this.patternIdxToConfig[t],k=_.length,k=_.length;const e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;P=!(!U||!e)}let F;D.call(this,e);const B=this.config.recoveryEnabled;for(;S<T;){a=null,u=-1;const e=g.charCodeAt(S);let O;if(P){const t=as(e),n=U[t];O=void 0!==n?n:M}else O=_;const I=O.length;for(n=0;n<I;n++){F=O[n];const i=F.pattern;c=null;const l=F.short;if(!1!==l?e===l&&(u=1,a=i):!0===F.isCustom?(E=i.exec(g,S,R,N),null!==E?(a=E[0],u=a.length,void 0!==E.payload&&(c=E.payload)):a=null):(i.lastIndex=S,u=this.matchLength(i,t,S)),-1!==u){if(o=F.longerAlt,void 0!==o){a=t.substring(S,S+u);const e=o.length;for(r=0;r<e;r++){const e=_[o[r]],n=e.pattern;if(h=null,!0===e.isCustom?(E=n.exec(g,S,R,N),null!==E?(s=E[0],void 0!==E.payload&&(h=E.payload)):s=null):(n.lastIndex=S,s=this.match(n,t,S)),s&&s.length>a.length){a=s,u=s.length,c=h,F=e;break}}}break}}if(-1!==u){if(l=F.group,void 0!==l&&(a=null!==a?a:t.substring(S,S+u),d=F.tokenTypeIdx,p=this.createTokenInstance(a,S,d,F.tokenType,v,y,u),this.handlePayload(p,c),!1===l?L=this.addToken(R,L,p):N[l].push(p)),!0===C&&!0===F.canLineTerminator){let e,n,i=0;x.lastIndex=0;do{a=null!==a?a:t.substring(S,S+u),e=x.test(a),!0===e&&(n=x.lastIndex-1,i++)}while(!0===e);0!==i?(v+=i,y=u-n,this.updateTokenEndLineColumnLocation(p,l,n,i,v,y,u)):y=this.computeNewColumn(y,u)}else y=this.computeNewColumn(y,u);S+=u,this.handleModes(F,w,D,p)}else{const e=S,n=v,r=y;let s=!1===B;for(;!1===s&&S<T;)for(S++,i=0;i<k;i++){const e=_[i],n=e.pattern,r=e.short;if(!1!==r?g.charCodeAt(S)===r&&(s=!0):!0===e.isCustom?s=null!==n.exec(g,S,R,N):(n.lastIndex=S,s=null!==n.exec(t)),!0===s)break}if(f=S-e,y=this.computeNewColumn(y,f),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(g,e,f,n,r,ai(b)),A.push({offset:e,line:n,column:r,length:f,message:m}),!1===B)break}}return this.hasCustom||(R.length=L),{tokens:R,groups:N,errors:A}}handleModes(t,e,n,i){if(!0===t.pop){const r=t.push;e(i),void 0!==r&&n.call(this,r)}else void 0!==t.push&&n.call(this,t.push)}updateTokenEndLineColumnLocation(t,e,n,i,r,s,o){let a,c;void 0!==e&&(a=n===o-1,c=a?-1:0,1===i&&!0===a||(t.endLine=r+c,t.endColumn=s-1-c))}computeNewColumn(t,e){return t+e}createOffsetOnlyToken(t,e,n,i){return{image:t,startOffset:e,tokenTypeIdx:n,tokenType:i}}createStartOnlyToken(t,e,n,i,r,s){return{image:t,startOffset:e,startLine:r,startColumn:s,tokenTypeIdx:n,tokenType:i}}createFullToken(t,e,n,i,r,s,o){return{image:t,startOffset:e,endOffset:e+o-1,startLine:r,endLine:r,startColumn:s,endColumn:s+o-1,tokenTypeIdx:n,tokenType:i}}addTokenUsingPush(t,e,n){return t.push(n),e}addTokenUsingMemberAccess(t,e,n){return t[e]=n,++e}handlePayloadNoCustom(t,e){}handlePayloadWithCustom(t,e){null!==e&&(t.payload=e)}match(t,e,n){return!0===t.test(e)?e.substring(n,t.lastIndex):null}matchLength(t,e,n){return!0===t.test(e)?t.lastIndex-n:-1}}function Rs(t){return As(t)?t.LABEL:t.name}function As(t){return ki(t.LABEL)&&""!==t.LABEL}Os.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.",Os.NA=/NOT_APPLICABLE/;const vs="parent",ys="categories",Ns="label",Is="group",Cs="push_mode",xs="pop_mode",ks="longer_alt",_s="line_breaks",Us="start_chars_hint";function bs(t){return function(t){const e=t.pattern,n={};n.name=t.name,Bi(e)||(n.PATTERN=e);if(xi(t,vs))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";xi(t,ys)&&(n.CATEGORIES=t[ys]);ds([n]),xi(t,Ns)&&(n.LABEL=t[Ns]);xi(t,Is)&&(n.GROUP=t[Is]);xi(t,xs)&&(n.POP_MODE=t[xs]);xi(t,Cs)&&(n.PUSH_MODE=t[Cs]);xi(t,ks)&&(n.LONGER_ALT=t[ks]);xi(t,_s)&&(n.LINE_BREAKS=t[_s]);xi(t,Us)&&(n.START_CHARS_HINT=t[Us]);return n}(t)}const Ms=bs({name:"EOF",pattern:Os.NA});function Ps(t,e,n,i,r,s,o,a){return{image:e,startOffset:n,endOffset:i,startLine:r,endLine:s,startColumn:o,endColumn:a,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}ds([Ms]);const ws={buildMismatchTokenMessage:({expected:t,actual:e,previous:n,ruleName:i})=>`Expecting ${As(t)?`--\x3e ${Rs(t)} <--`:`token of type --\x3e ${t.name} <--`} but found --\x3e '${e.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:t,ruleName:e})=>"Redundant input, expecting EOF but found: "+t.image,buildNoViableAltMessage({expectedPathsPerAlt:t,actual:e,previous:n,customUserDescription:i,ruleName:r}){const s="Expecting: ",o="\nbut found: '"+Si(e).image+"'";if(i)return s+i+o;{const e=Oi(Gi(t,(t,e)=>t.concat(e),[]),t=>`[${Oi(t,t=>Rs(t)).join(", ")}]`);return s+`one of these possible Token sequences:\n${Oi(e,(t,e)=>` ${e+1}. ${t}`).join("\n")}`+o}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:n,ruleName:i}){const r="Expecting: ",s="\nbut found: '"+Si(e).image+"'";if(n)return r+n+s;return r+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${Oi(t,t=>`[${Oi(t,t=>Rs(t)).join(",")}]`).join(" ,")}>`+s}};Object.freeze(ws);const Ds={buildRuleNotFoundError:(t,e)=>"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"},Fs={buildDuplicateFoundError(t,e){const n=t.name,i=Si(e),r=i.idx,s=fr(i),o=(a=i)instanceof ur?a.terminalType.name:a instanceof er?a.nonTerminalName:"";var a;let c=`->${s}${r>0?r:""}<- ${o?`with argument: ->${o}<-`:""}\n appears more than once (${e.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:t=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(t){const e=Oi(t.prefixPath,t=>Rs(t)).join(", "),n=0===t.alternation.idx?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${t.topLevelRule.name}> Rule,\n<${e}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(t){const e=0===t.alternation.idx?"":t.alternation.idx,n=0===t.prefixPath.length;let i=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${t.topLevelRule.name}> Rule,\n`;if(n)i+="These alternatives are all empty (match no tokens), making them indistinguishable.\nOnly the last alternative may be empty.\n";else{i+=`<${Oi(t.prefixPath,t=>Rs(t)).join(", ")}> may appears as a prefix path in all these alternatives.\n`}return i+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",i},buildEmptyRepetitionError(t){let e=fr(t.repetition);0!==t.repetition.idx&&(e+=t.repetition.idx);return`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:t=>"deprecated",buildEmptyAlternationError:t=>`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:t=>`An Alternation cannot have more than 256 alternatives:\n<OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.\n has ${t.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(t){const e=t.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${e}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${e} --\x3e ${Oi(t.leftRecursionPath,t=>t.name).concat([e]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:t=>"deprecated",buildDuplicateRuleNameError(t){let e;e=t.topLevelRule instanceof nr?t.topLevelRule.name:t.topLevelRule;return`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};class Bs extends dr{constructor(t,e){super(),this.nameToTopRule=t,this.errMsgProvider=e,this.errors=[]}resolveRefs(){ui(_i(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){const e=this.nameToTopRule[t.nonTerminalName];if(e)t.referencedRule=e;else{const e=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:e,type:ha.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}}class js extends mr{constructor(t,e){super(),this.topProd=t,this.path=e,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=Nn(this.path.ruleStack).reverse(),this.occurrenceStack=Nn(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,e=[]){this.found||super.walk(t,e)}walkProdRef(t,e,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){const i=e.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,i)}}updateExpectedNext(){wi(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class $s extends js{constructor(t,e){super(t,e),this.path=e,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,e,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){const t=e.concat(n),i=new ir({definition:t});this.possibleTokTypes=gr(i),this.found=!0}}}class Ks extends mr{constructor(t,e){super(),this.topRule=t,this.occurrence=e,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Gs extends Ks{walkMany(t,e,n){if(t.idx===this.occurrence){const t=Si(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ur&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkMany(t,e,n)}}class zs extends Ks{walkManySep(t,e,n){if(t.idx===this.occurrence){const t=Si(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ur&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkManySep(t,e,n)}}class Ws extends Ks{walkAtLeastOne(t,e,n){if(t.idx===this.occurrence){const t=Si(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ur&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkAtLeastOne(t,e,n)}}class Vs extends Ks{walkAtLeastOneSep(t,e,n){if(t.idx===this.occurrence){const t=Si(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ur&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkAtLeastOneSep(t,e,n)}}function Hs(t,e,n=[]){n=Nn(n);let i=[],r=0;function s(s){const o=Hs(s.concat(ci(t,r+1)),e,n);return i.concat(o)}for(;n.length<e&&r<t.length;){const e=t[r];if(e instanceof ir)return s(e.definition);if(e instanceof er)return s(e.definition);if(e instanceof rr)i=s(e.definition);else{if(e instanceof sr){return s(e.definition.concat([new ar({definition:e.definition})]))}if(e instanceof or){return s([new ir({definition:e.definition}),new ar({definition:[new ur({terminalType:e.separator})].concat(e.definition)})])}if(e instanceof cr){const t=e.definition.concat([new ar({definition:[new ur({terminalType:e.separator})].concat(e.definition)})]);i=s(t)}else if(e instanceof ar){const t=e.definition.concat([new ar({definition:e.definition})]);i=s(t)}else{if(e instanceof hr)return ui(e.definition,t=>{!1===wi(t.definition)&&(i=s(t.definition))}),i;if(!(e instanceof ur))throw Error("non exhaustive match");n.push(e.terminalType)}}r++}return i.push({partialPath:n,suffixDef:ci(t,r)}),i}function Ys(t,e,n,i){const r="EXIT_NONE_TERMINAL",s=[r],o="EXIT_ALTERNATIVE";let a=!1;const c=e.length,h=c-i-1,u=[],l=[];for(l.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!wi(l);){const t=l.pop();if(t===o){a&&ai(l).idx<=h&&l.pop();continue}const i=t.def,d=t.idx,p=t.ruleStack,f=t.occurrenceStack;if(wi(i))continue;const m=i[0];if(m===r){const t={idx:d,def:ci(i),ruleStack:hi(p),occurrenceStack:hi(f)};l.push(t)}else if(m instanceof ur)if(d<c-1){const t=d+1;if(n(e[t],m.terminalType)){const e={idx:t,def:ci(i),ruleStack:p,occurrenceStack:f};l.push(e)}}else{if(d!==c-1)throw Error("non exhaustive match");u.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:p,occurrenceStack:f}),a=!0}else if(m instanceof er){const t=Nn(p);t.push(m.nonTerminalName);const e=Nn(f);e.push(m.idx);const n={idx:d,def:m.definition.concat(s,ci(i)),ruleStack:t,occurrenceStack:e};l.push(n)}else if(m instanceof rr){const t={idx:d,def:ci(i),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e={idx:d,def:m.definition.concat(ci(i)),ruleStack:p,occurrenceStack:f};l.push(e)}else if(m instanceof sr){const t=new ar({definition:m.definition,idx:m.idx}),e={idx:d,def:m.definition.concat([t],ci(i)),ruleStack:p,occurrenceStack:f};l.push(e)}else if(m instanceof or){const t=new ur({terminalType:m.separator}),e=new ar({definition:[t].concat(m.definition),idx:m.idx}),n={idx:d,def:m.definition.concat([e],ci(i)),ruleStack:p,occurrenceStack:f};l.push(n)}else if(m instanceof cr){const t={idx:d,def:ci(i),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e=new ur({terminalType:m.separator}),n=new ar({definition:[e].concat(m.definition),idx:m.idx}),r={idx:d,def:m.definition.concat([n],ci(i)),ruleStack:p,occurrenceStack:f};l.push(r)}else if(m instanceof ar){const t={idx:d,def:ci(i),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e=new ar({definition:m.definition,idx:m.idx}),n={idx:d,def:m.definition.concat([e],ci(i)),ruleStack:p,occurrenceStack:f};l.push(n)}else if(m instanceof hr)for(let e=m.definition.length-1;e>=0;e--){const t={idx:d,def:m.definition[e].definition.concat(ci(i)),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o)}else if(m instanceof ir)l.push({idx:d,def:m.definition.concat(ci(i)),ruleStack:p,occurrenceStack:f});else{if(!(m instanceof nr))throw Error("non exhaustive match");l.push(Xs(m,d,p,f))}}return u}function Xs(t,e,n,i){const r=Nn(n);r.push(t.name);const s=Nn(i);return s.push(1),{idx:e,def:t.definition,ruleStack:r,occurrenceStack:s}}var qs,Zs;function Qs(t){if(t instanceof rr||"Option"===t)return qs.OPTION;if(t instanceof ar||"Repetition"===t)return qs.REPETITION;if(t instanceof sr||"RepetitionMandatory"===t)return qs.REPETITION_MANDATORY;if(t instanceof or||"RepetitionMandatoryWithSeparator"===t)return qs.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof cr||"RepetitionWithSeparator"===t)return qs.REPETITION_WITH_SEPARATOR;if(t instanceof hr||"Alternation"===t)return qs.ALTERNATION;throw Error("non exhaustive match")}function Js(t,e,n,i){const r=t.length,s=pi(t,t=>pi(t,t=>1===t.length));if(e)return function(e){const i=Oi(e,t=>t.GATE);for(let s=0;s<r;s++){const e=t[s],r=e.length,o=i[s];if(void 0===o||!1!==o.call(this))t:for(let t=0;t<r;t++){const i=e[t],r=i.length;for(let t=0;t<r;t++){const e=this.LA_FAST(t+1);if(!1===n(e,i[t]))continue t}return s}}};if(s&&!i){const e=Gi(Oi(t,t=>be(t)),(t,e,n)=>(ui(e,e=>{xi(t,e.tokenTypeIdx)||(t[e.tokenTypeIdx]=n),ui(e.categoryMatches,e=>{xi(t,e)||(t[e]=n)})}),t),{});return function(){const t=this.LA_FAST(1);return e[t.tokenTypeIdx]}}return function(){for(let e=0;e<r;e++){const i=t[e],r=i.length;t:for(let t=0;t<r;t++){const r=i[t],s=r.length;for(let t=0;t<s;t++){const e=this.LA_FAST(t+1);if(!1===n(e,r[t]))continue t}return e}}}}function to(t,e,n){const i=pi(t,t=>1===t.length),r=t.length;if(i&&!n){const e=be(t);if(1===e.length&&wi(e[0].categoryMatches)){const t=e[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===t}}{const t=Gi(e,(t,e,n)=>(t[e.tokenTypeIdx]=!0,ui(e.categoryMatches,e=>{t[e]=!0}),t),[]);return function(){const e=this.LA_FAST(1);return!0===t[e.tokenTypeIdx]}}}return function(){t:for(let n=0;n<r;n++){const i=t[n],r=i.length;for(let t=0;t<r;t++){const n=this.LA_FAST(t+1);if(!1===e(n,i[t]))continue t}return!0}return!1}}(Zs=qs||(qs={}))[Zs.OPTION=0]="OPTION",Zs[Zs.REPETITION=1]="REPETITION",Zs[Zs.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",Zs[Zs.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",Zs[Zs.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",Zs[Zs.ALTERNATION=5]="ALTERNATION";class eo extends mr{constructor(t,e,n){super(),this.topProd=t,this.targetOccurrence=e,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,e,n,i){return t.idx===this.targetOccurrence&&this.targetProdType===e&&(this.restDef=n.concat(i),!0)}walkOption(t,e,n){this.checkIsTarget(t,qs.OPTION,e,n)||super.walkOption(t,e,n)}walkAtLeastOne(t,e,n){this.checkIsTarget(t,qs.REPETITION_MANDATORY,e,n)||super.walkOption(t,e,n)}walkAtLeastOneSep(t,e,n){this.checkIsTarget(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR,e,n)||super.walkOption(t,e,n)}walkMany(t,e,n){this.checkIsTarget(t,qs.REPETITION,e,n)||super.walkOption(t,e,n)}walkManySep(t,e,n){this.checkIsTarget(t,qs.REPETITION_WITH_SEPARATOR,e,n)||super.walkOption(t,e,n)}}class no extends dr{constructor(t,e,n){super(),this.targetOccurrence=t,this.targetProdType=e,this.targetRef=n,this.result=[]}checkIsTarget(t,e){t.idx!==this.targetOccurrence||this.targetProdType!==e||void 0!==this.targetRef&&t!==this.targetRef||(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,qs.OPTION)}visitRepetition(t){this.checkIsTarget(t,qs.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,qs.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,qs.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,qs.ALTERNATION)}}function io(t){const e=new Array(t);for(let n=0;n<t;n++)e[n]=[];return e}function ro(t){let e=[""];for(let n=0;n<t.length;n++){const i=t[n],r=[];for(let t=0;t<e.length;t++){const n=e[t];r.push(n+"_"+i.tokenTypeIdx);for(let t=0;t<i.categoryMatches.length;t++){const e="_"+i.categoryMatches[t];r.push(n+e)}}e=r}return e}function so(t,e,n){for(let i=0;i<t.length;i++){if(i===n)continue;const r=t[i];for(let t=0;t<e.length;t++){if(!0===r[e[t]])return!1}}return!0}function oo(t,e){const n=Oi(t,t=>Hs([t],1)),i=io(n.length),r=Oi(n,t=>{const e={};return ui(t,t=>{ui(ro(t.partialPath),t=>{e[t]=!0})}),e});let s=n;for(let o=1;o<=e;o++){const t=s;s=io(t.length);for(let n=0;n<t.length;n++){const a=t[n];for(let t=0;t<a.length;t++){const c=a[t].partialPath,h=a[t].suffixDef,u=ro(c);if(so(r,u,n)||wi(h)||c.length===e){const t=i[n];if(!1===ho(t,c)){t.push(c);for(let t=0;t<u.length;t++){const e=u[t];r[n][e]=!0}}}else{const t=Hs(h,o+1,c);s[n]=s[n].concat(t),ui(t,t=>{ui(ro(t.partialPath),t=>{r[n][t]=!0})})}}}}return i}function ao(t,e,n,i){const r=new no(t,qs.ALTERNATION,i);return e.accept(r),oo(r.result,n)}function co(t,e,n,i){const r=new no(t,n);e.accept(r);const s=r.result,o=new eo(e,t,n).startWalking();return oo([new ir({definition:s}),new ir({definition:o})],i)}function ho(t,e){t:for(let n=0;n<t.length;n++){const i=t[n];if(i.length===e.length){for(let t=0;t<i.length;t++){const n=e[t],r=i[t];if(!1===(n===r||void 0!==r.categoryMatchesMap[n.tokenTypeIdx]))continue t}return!0}}return!1}function uo(t){return pi(t,t=>pi(t,t=>pi(t,t=>wi(t.categoryMatches))))}function lo(t,e,n,i){const r=Ri(t,t=>function(t,e){const n=new mo;t.accept(n);const i=n.allProductions,r=Ni(i,po),s=Oi(_i($i(r,t=>t.length>1)),n=>{const i=Si(n),r=e.buildDuplicateFoundError(t,n),s=fr(i),o={message:r,type:ha.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:s,occurrence:i.idx},a=fo(i);return a&&(o.parameter=a),o});return s}(t,n)),s=function(t,e,n){const i=[],r=Oi(e,t=>t.name);return ui(t,t=>{const e=t.name;if(bi(r,e)){const r=n.buildNamespaceConflictError(t);i.push({message:r,type:ha.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:e})}}),i}(t,e,n),o=Ri(t,t=>function(t,e){const n=new To;t.accept(n);const i=Ri(n.alternations,n=>n.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:n}),type:ha.TOO_MANY_ALTS,ruleName:t.name,occurrence:n.idx}]:[]);return i}(t,n)),a=Ri(t,e=>function(t,e,n,i){const r=[],s=Gi(e,(e,n)=>n.name===t.name?e+1:e,0);if(s>1){const e=i.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});r.push({message:e,type:ha.DUPLICATE_RULE_NAME,ruleName:t.name})}return r}(e,t,i,n));return r.concat(s,o,a)}function po(t){return`${fr(t)}_#_${t.idx}_#_${fo(t)}`}function fo(t){return t instanceof ur?t.terminalType.name:t instanceof er?t.nonTerminalName:""}class mo extends dr{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function Eo(t,e,n,i=[]){const r=[],s=go(e.definition);if(wi(s))return[];{const e=t.name;bi(s,t)&&r.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:i}),type:ha.LEFT_RECURSION,ruleName:e});const o=Ri(oi(s,i.concat([t])),e=>{const r=Nn(i);return r.push(e),Eo(t,e,n,r)});return r.concat(o)}}function go(t){let e=[];if(wi(t))return e;const n=Si(t);if(n instanceof er)e.push(n.referencedRule);else if(n instanceof ir||n instanceof rr||n instanceof sr||n instanceof or||n instanceof cr||n instanceof ar)e=e.concat(go(n.definition));else if(n instanceof hr)e=be(Oi(n.definition,t=>go(t.definition)));else if(!(n instanceof ur))throw Error("non exhaustive match");const i=pr(n),r=t.length>1;if(i&&r){const n=ci(t);return e.concat(go(n))}return e}class To extends dr{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function So(t,e,n){const i=new To;t.accept(i);let r=i.alternations;r=zi(r,t=>!0===t.ignoreAmbiguities);const s=Ri(r,i=>{const r=i.idx,s=i.maxLookahead||e,o=ao(r,t,s,i),a=function(t,e,n,i){const r=[],s=Gi(t,(n,i,s)=>(!0===e.definition[s].ignoreAmbiguities||ui(i,i=>{const o=[s];ui(t,(t,n)=>{s!==n&&ho(t,i)&&!0!==e.definition[n].ignoreAmbiguities&&o.push(n)}),o.length>1&&!ho(r,i)&&(r.push(i),n.push({alts:o,path:i}))}),n),[]),o=Oi(s,t=>{const r=Oi(t.alts,t=>t+1);return{message:i.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:r,prefixPath:t.path}),type:ha.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:t.alts}});return o}(o,i,t,n),c=function(t,e,n,i){const r=Gi(t,(t,e,n)=>{const i=Oi(e,t=>({idx:n,path:t}));return t.concat(i)},[]),s=In(Ri(r,t=>{if(!0===e.definition[t.idx].ignoreAmbiguities)return[];const s=t.idx,o=t.path;return Oi(mi(r,t=>{return!0!==e.definition[t.idx].ignoreAmbiguities&&t.idx<s&&(n=t.path,i=o,n.length<i.length&&pi(n,(t,e)=>{const n=i[e];return t===n||n.categoryMatchesMap[t.tokenTypeIdx]}));var n,i}),t=>{const r=[t.idx+1,s+1],o=0===e.idx?"":e.idx;return{message:i.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:r,prefixPath:t.path}),type:ha.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:r}})}));return s}(o,i,t,n);return a.concat(c)});return s}class Lo extends dr{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function Oo(t){const e=ri(t,{errMsgProvider:Ds}),n={};return ui(t.rules,t=>{n[t.name]=t}),function(t,e){const n=new Bs(t,e);return n.resolveRefs(),n.errors}(n,e.errMsgProvider)}const Ro="MismatchedTokenException",Ao="NoViableAltException",vo="EarlyExitException",yo="NotAllInputParsedException",No=[Ro,Ao,vo,yo];function Io(t){return bi(No,t.name)}Object.freeze(No);class Co extends Error{constructor(t,e){super(t),this.token=e,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class xo extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=Ro}}class ko extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=Ao}}class _o extends Co{constructor(t,e){super(t,e),this.name=yo}}class Uo extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=vo}}const bo={},Mo="InRuleRecoveryException";class Po extends Error{constructor(t){super(t),this.name=Mo}}function wo(t,e,n,i,r,s,o){const a=this.getKeyForAutomaticLookahead(i,r);let c=this.firstAfterRepMap[a];if(void 0===c){const t=this.getCurrRuleFullName();c=new s(this.getGAstProductions()[t],r).startWalking(),this.firstAfterRepMap[a]=c}let h=c.token,u=c.occurrence;const l=c.isEndOfRule;0===this.RULE_STACK_IDX&&l&&void 0===h&&(h=Ms,u=1),void 0!==h&&void 0!==u&&this.shouldInRepetitionRecoveryBeTried(h,u,o)&&this.tryInRepetitionRecovery(t,e,n,h)}const Do=1024,Fo=1280,Bo=1536;function jo(t,e,n){return n|e|t}class $o{constructor(t){var e;this.maxLookahead=null!==(e=null==t?void 0:t.maxLookahead)&&void 0!==e?e:aa.maxLookahead}validate(t){const e=this.validateNoLeftRecursion(t.rules);if(wi(e)){const n=this.validateEmptyOrAlternatives(t.rules),i=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),r=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...e,...n,...i,...r]}return e}validateNoLeftRecursion(t){return Ri(t,t=>Eo(t,t,Fs))}validateEmptyOrAlternatives(t){return Ri(t,t=>function(t,e){const n=new To;return t.accept(n),Ri(n.alternations,n=>Ri(hi(n.definition),(i,r)=>wi(Ys([i],[],cs,1))?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:n,emptyChoiceIdx:r}),type:ha.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:n.idx,alternative:r+1}]:[]))}(t,Fs))}validateAmbiguousAlternationAlternatives(t,e){return Ri(t,t=>So(t,e,Fs))}validateSomeNonEmptyLookaheadPath(t,e){return function(t,e,n){const i=[];return ui(t,t=>{const r=new Lo;t.accept(r),ui(r.allProductions,r=>{const s=Qs(r),o=r.maxLookahead||e;if(wi(be(co(r.idx,t,s,o)[0]))){const e=n.buildEmptyRepetitionError({topLevelRule:t,repetition:r});i.push({message:e,type:ha.NO_NON_EMPTY_LOOKAHEAD,ruleName:t.name})}})}),i}(t,e,Fs)}buildLookaheadForAlternation(t){return function(t,e,n,i,r,s){const o=ao(t,e,n);return s(o,i,uo(o)?hs:cs,r)}(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,Js)}buildLookaheadForOptional(t){return function(t,e,n,i,r,s){const o=co(t,e,r,n),a=uo(o)?hs:cs;return s(o[0],a,i)}(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,Qs(t.prodType),to)}}const Ko=new class extends dr{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}};function Go(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset)}function zo(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function Wo(t,e){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:e})}function Vo(t,e){const n=ne(t),i=n.length;for(let r=0;r<i;r++){const i=t[n[r]],s=i.length;for(let t=0;t<s;t++){const n=i[t];void 0===n.tokenTypeIdx&&this[n.name](n.children,e)}}}function Ho(t,e){const n=function(){};Wo(n,t+"BaseSemantics");const i={visit:function(t,e){if(I(t)&&(t=t[0]),!Bi(t))return this[t.name](t.children,e)},validateVisitor:function(){const t=function(t,e){const n=function(t,e){const n=mi(e,e=>!1===G(t[e])),i=Oi(n,e=>({msg:`Missing visitor method: <${e}> on ${t.constructor.name} CST Visitor.`,type:Yo.MISSING_METHOD,methodName:e}));return In(i)}(t,e);return n}(this,e);if(!wi(t)){const e=Oi(t,t=>t.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${e.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(n.prototype=i).constructor=n,n._RULE_NAMES=e,n}var Yo,Xo;(Xo=Yo||(Yo={}))[Xo.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",Xo[Xo.MISSING_METHOD=1]="MISSING_METHOD";const qo={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(qo);const Zo=!0,Qo=Math.pow(2,8)-1,Jo=bs({name:"RECORDING_PHASE_TOKEN",pattern:Os.NA});ds([Jo]);const ta=Ps(Jo,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(ta);const ea={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function na(t,e,n,i=!1){sa(n);const r=ai(this.recordingProdStack),s=G(e)?e:e.DEF,o=new t({definition:[],idx:n});return i&&(o.separator=e.SEP),xi(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(o),s.call(this),r.definition.push(o),this.recordingProdStack.pop(),qo}function ia(t,e){sa(e);const n=ai(this.recordingProdStack),i=!1===I(t),r=!1===i?t:t.DEF,s=new hr({definition:[],idx:e,ignoreAmbiguities:i&&!0===t.IGNORE_AMBIGUITIES});xi(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD);const o=Vi(r,t=>G(t.GATE));return s.hasPredicates=o,n.definition.push(s),ui(r,t=>{const e=new ir({definition:[]});s.definition.push(e),xi(t,"IGNORE_AMBIGUITIES")?e.ignoreAmbiguities=t.IGNORE_AMBIGUITIES:xi(t,"GATE")&&(e.ignoreAmbiguities=!0),this.recordingProdStack.push(e),t.ALT.call(this),this.recordingProdStack.pop()}),qo}function ra(t){return 0===t?"":`${t}`}function sa(t){if(t<0||t>Qo){const e=new Error(`Invalid DSL Method idx value: <${t}>\n\tIdx value must be a none negative value smaller than ${Qo+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}const oa=Ps(Ms,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(oa);const aa=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ws,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ca=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ha,ua,la;(ua=ha||(ha={}))[ua.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",ua[ua.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",ua[ua.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",ua[ua.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",ua[ua.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",ua[ua.LEFT_RECURSION=5]="LEFT_RECURSION",ua[ua.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",ua[ua.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",ua[ua.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",ua[ua.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",ua[ua.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",ua[ua.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",ua[ua.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",ua[ua.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class da{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;const e=this.className;this.TRACE_INIT("toFastProps",()=>{Qi(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),ui(this.definedRulesNames,t=>{const e=this[t].originalGrammarAction;let n;this.TRACE_INIT(`${t} Rule`,()=>{n=this.topLevelRuleRecord(t,e)}),this.gastProductionsCache[t]=n})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Oo({rules:_i(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(wi(n)&&!1===this.skipValidations){const n=(t={rules:_i(this.gastProductionsCache),tokenTypes:_i(this.tokensMap),errMsgProvider:Fs,grammarName:e},lo((t=ri(t,{errMsgProvider:Fs})).rules,t.tokenTypes,t.errMsgProvider,t.grammarName)),i=function(t){return Oi(t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}),t=>Object.assign({type:ha.CUSTOM_LOOKAHEAD_VALIDATION},t))}({lookaheadStrategy:this.lookaheadStrategy,rules:_i(this.gastProductionsCache),tokenTypes:_i(this.tokensMap),grammarName:e});this.definitionErrors=this.definitionErrors.concat(n,i)}var t}),wi(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const t=function(t){const e={};return ui(t,t=>{const n=new Sr(t).startWalking();se(e,n)}),e}(_i(this.gastProductionsCache));this.resyncFollows=t}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var t,e;null===(e=(t=this.lookaheadStrategy).initialize)||void 0===e||e.call(t,{rules:_i(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(_i(this.gastProductionsCache))})),!da.DEFER_DEFINITION_ERRORS_HANDLING&&!wi(this.definitionErrors))throw t=Oi(this.definitionErrors,t=>t.message),new Error(`Parser Definition Errors detected:\n ${t.join("\n-------------------------------\n")}`)})}constructor(t,e){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(e),n.initLexerAdapter(),n.initLooksAhead(e),n.initRecognizerEngine(t,e),n.initRecoverable(e),n.initTreeBuilder(e),n.initContentAssist(),n.initGastRecorder(e),n.initPerformanceTracer(e),xi(e,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=xi(e,"skipValidations")?e.skipValidations:aa.skipValidations}}da.DEFER_DEFINITION_ERRORS_HANDLING=!1,la=da,[class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=xi(t,"recoveryEnabled")?t.recoveryEnabled:aa.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=wo)}getTokenToInsert(t){const e=Ps(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return e.isInsertedInRecovery=!0,e}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,e,n,i){const r=this.findReSyncTokenType(),s=this.exportLexerState(),o=[];let a=!1;const c=this.LA_FAST(1);let h=this.LA_FAST(1);const u=()=>{const t=this.LA(0),e=this.errorMessageProvider.buildMismatchTokenMessage({expected:i,actual:c,previous:t,ruleName:this.getCurrRuleFullName()}),n=new xo(e,c,this.LA(0));n.resyncedTokens=hi(o),this.SAVE_ERROR(n)};for(;!a;){if(this.tokenMatcher(h,i))return void u();if(n.call(this))return u(),void t.apply(this,e);this.tokenMatcher(h,r)?a=!0:(h=this.SKIP_TOKEN(),this.addToResyncTokens(h,o))}this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,e,n){return!1!==n&&!this.tokenMatcher(this.LA_FAST(1),t)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,e))}getFollowsForInRuleRecovery(t,e){const n=this.getCurrentGrammarPath(t,e);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,e){if(this.canRecoverWithSingleTokenInsertion(t,e))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){const t=this.SKIP_TOKEN();return this.consumeToken(),t}throw new Po("sad sad panda")}canPerformInRuleRecovery(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,e){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(wi(e))return!1;const n=this.LA_FAST(1);return void 0!==Ti(e,t=>this.tokenMatcher(n,t))}canRecoverWithSingleTokenDeletion(t){return!!this.canTokenTypeBeDeletedInRecovery(t)&&this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){const e=this.getCurrFollowKey();return bi(this.getFollowSetFromFollowKey(e),t)}findReSyncTokenType(){const t=this.flattenFollowSet();let e=this.LA_FAST(1),n=2;for(;;){const i=Ti(t,t=>cs(e,t));if(void 0!==i)return i;e=this.LA(n),n++}}getCurrFollowKey(){if(0===this.RULE_STACK_IDX)return bo;const t=this.currRuleShortName,e=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:e,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const t=this.RULE_STACK,e=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,i=new Array(n);for(let r=0;r<n;r++)i[r]=0===r?bo:{ruleName:this.shortRuleNameToFullName(t[r]),idxInCallingRule:e[r],inRule:this.shortRuleNameToFullName(t[r-1])};return i}flattenFollowSet(){return be(Oi(this.buildFullFollowKeyStack(),t=>this.getFollowSetFromFollowKey(t)))}getFollowSetFromFollowKey(t){if(t===bo)return[Ms];const e=t.ruleName+t.idxInCallingRule+Tr+t.inRule;return this.resyncFollows[e]}addToResyncTokens(t,e){return this.tokenMatcher(t,Ms)||e.push(t),e}reSyncTo(t){const e=[];let n=this.LA_FAST(1);for(;!1===this.tokenMatcher(n,t);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,e);return hi(e)}attemptInRepetitionRecovery(t,e,n,i,r,s,o){}getCurrentGrammarPath(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1),lastTok:t,lastTokOccurrence:e}}getHumanReadableRuleStack(){const t=this.RULE_STACK_IDX+1,e=new Array(t);for(let n=0;n<t;n++)e[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return e}},class{initLooksAhead(t){this.dynamicTokensEnabled=xi(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:aa.dynamicTokensEnabled,this.maxLookahead=xi(t,"maxLookahead")?t.maxLookahead:aa.maxLookahead,this.lookaheadStrategy=xi(t,"lookaheadStrategy")?t.lookaheadStrategy:new $o({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){ui(t,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{const{alternation:e,repetition:n,option:i,repetitionMandatory:r,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:o}=function(t){Ko.reset(),t.accept(Ko);const e=Ko.dslMethods;return Ko.reset(),e}(t);ui(e,e=>{const n=0===e.idx?"":e.idx;this.TRACE_INIT(`${fr(e)}${n}`,()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:e.idx,rule:t,maxLookahead:e.maxLookahead||this.maxLookahead,hasPredicates:e.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),i=jo(this.fullRuleNameToShort[t.name],256,e.idx);this.setLaFuncCache(i,n)})}),ui(n,e=>{this.computeLookaheadFunc(t,e.idx,768,"Repetition",e.maxLookahead,fr(e))}),ui(i,e=>{this.computeLookaheadFunc(t,e.idx,512,"Option",e.maxLookahead,fr(e))}),ui(r,e=>{this.computeLookaheadFunc(t,e.idx,Do,"RepetitionMandatory",e.maxLookahead,fr(e))}),ui(s,e=>{this.computeLookaheadFunc(t,e.idx,Bo,"RepetitionMandatoryWithSeparator",e.maxLookahead,fr(e))}),ui(o,e=>{this.computeLookaheadFunc(t,e.idx,Fo,"RepetitionWithSeparator",e.maxLookahead,fr(e))})})})}computeLookaheadFunc(t,e,n,i,r,s){this.TRACE_INIT(`${s}${0===e?"":e}`,()=>{const s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:e,rule:t,maxLookahead:r||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:i}),o=jo(this.fullRuleNameToShort[t.name],n,e);this.setLaFuncCache(o,s)})}getKeyForAutomaticLookahead(t,e){return jo(this.currRuleShortName,t,e)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,e){this.lookAheadFuncsCache.set(t,e)}},class{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=xi(t,"nodeLocationTracking")?t.nodeLocationTracking:aa.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=zo,this.setNodeLocationFromNode=zo,this.cstPostRule=ot,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Go,this.setNodeLocationFromNode=Go,this.cstPostRule=ot,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`);this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=ot,this.setInitialNodeLocation=ot}else this.cstInvocationStateUpdate=ot,this.cstFinallyStateUpdate=ot,this.cstPostTerminal=ot,this.cstPostNonTerminal=ot,this.cstPostRule=ot}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(t){const e=this.LA_FAST(1);t.location={startOffset:e.startOffset,startLine:e.startLine,startColumn:e.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(t){const e={name:t,children:Object.create(null)};this.setInitialNodeLocation(e),this.CST_STACK.push(e)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){const e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==1?(n.endOffset=e.endOffset,n.endLine=e.endLine,n.endColumn=e.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(t){const e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==1?n.endOffset=e.endOffset:n.startOffset=NaN}cstPostTerminal(t,e){const n=this.CST_STACK[this.CST_STACK.length-1];var i,r,s;r=e,s=t,void 0===(i=n).children[s]?i.children[s]=[r]:i.children[s].push(r),this.setNodeLocationFromToken(n.location,e)}cstPostNonTerminal(t,e){const n=this.CST_STACK[this.CST_STACK.length-1];!function(t,e,n){void 0===t.children[e]?t.children[e]=[n]:t.children[e].push(n)}(n,e,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(Bi(this.baseCstVisitorConstructor)){const t=Ho(this.className,ne(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Bi(this.baseCstVisitorWithDefaultsConstructor)){const t=function(t,e,n){const i=function(){};Wo(i,t+"BaseSemanticsWithDefaults");const r=Object.create(n.prototype);return ui(e,t=>{r[t]=Vo}),(i.prototype=r).constructor=i,i}(this.className,ne(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):oa}LA_FAST(t){const e=this.currIdx+t;return this.tokVector[e]}LA(t){const e=this.currIdx+t;return e<0||this.tokVectorLength<=e?oa:this.tokVector[e]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},class{initRecognizerEngine(t,e){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=hs,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},xi(e,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(I(t)){if(wi(t))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof t[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(I(t))this.tokensMap=Gi(t,(t,e)=>(t[e.name]=e,t),{});else if(xi(t,"modes")&&pi(be(_i(t.modes)),Es)){const e=Yi(be(_i(t.modes)));this.tokensMap=Gi(e,(t,e)=>(t[e.name]=e,t),{})}else{if(!M(t))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=Nn(t)}this.tokensMap.EOF=Ms;const n=pi(xi(t,"modes")?be(_i(t.modes)):_i(t),t=>wi(t.categoryMatches));this.tokenMatcher=n?hs:cs,ds(_i(this.tokensMap))}defineRule(t,e,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const i=xi(n,"resyncEnabled")?n.resyncEnabled:ca.resyncEnabled,r=xi(n,"recoveryValueFunc")?n.recoveryValueFunc:ca.recoveryValueFunc,s=this.ruleShortNameIdx<<12;let o;return this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s,o=!0===this.outputCst?function(...n){try{this.ruleInvocationStateUpdate(s,t,this.subruleIdx),e.apply(this,n);const i=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(i),i}catch(o){return this.invokeRuleCatch(o,i,r)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(s,t,this.subruleIdx),e.apply(this,n)}catch(o){return this.invokeRuleCatch(o,i,r)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...e){this.onBeforeParse(t);try{return o.apply(this,e)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:e,coreRule:o})}invokeRuleCatch(t,e,n){const i=0===this.RULE_STACK_IDX,r=e&&!this.isBackTracking()&&this.recoveryEnabled;if(Io(t)){const e=t;if(r){const i=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(i)){if(e.resyncedTokens=this.reSyncTo(i),this.outputCst){const t=this.CST_STACK[this.CST_STACK.length-1];return t.recoveredNode=!0,t}return n(t)}if(this.outputCst){const t=this.CST_STACK[this.CST_STACK.length-1];t.recoveredNode=!0,e.partialCstResult=t}throw e}if(i)return this.moveToTerminatedState(),n(t);throw e}throw t}optionInternal(t,e){const n=this.getKeyForAutomaticLookahead(512,e);return this.optionInternalLogic(t,e,n)}optionInternalLogic(t,e,n){let i,r=this.getLaFuncFromCache(n);if("function"!=typeof t){i=t.DEF;const e=t.GATE;if(void 0!==e){const t=r;r=()=>e.call(this)&&t.call(this)}}else i=t;if(!0===r.call(this))return i.call(this)}atLeastOneInternal(t,e){const n=this.getKeyForAutomaticLookahead(Do,t);return this.atLeastOneInternalLogic(t,e,n)}atLeastOneInternalLogic(t,e,n){let i,r=this.getLaFuncFromCache(n);if("function"!=typeof e){i=e.DEF;const t=e.GATE;if(void 0!==t){const e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;if(!0!==r.call(this))throw this.raiseEarlyExitException(t,qs.REPETITION_MANDATORY,e.ERR_MSG);{let t=this.doSingleRepetition(i);for(;!0===r.call(this)&&!0===t;)t=this.doSingleRepetition(i)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],r,Do,t,Ws)}atLeastOneSepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead(Bo,t);this.atLeastOneSepFirstInternalLogic(t,e,n)}atLeastOneSepFirstInternalLogic(t,e,n){const i=e.DEF,r=e.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR,e.ERR_MSG);{i.call(this);const e=()=>this.tokenMatcher(this.LA_FAST(1),r);for(;!0===this.tokenMatcher(this.LA_FAST(1),r);)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,r,e,i,Vs],e,Bo,t,Vs)}}manyInternal(t,e){const n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,e,n)}manyInternalLogic(t,e,n){let i,r=this.getLaFuncFromCache(n);if("function"!=typeof e){i=e.DEF;const t=e.GATE;if(void 0!==t){const e=r;r=()=>t.call(this)&&e.call(this)}}else i=e;let s=!0;for(;!0===r.call(this)&&!0===s;)s=this.doSingleRepetition(i);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],r,768,t,Gs,s)}manySepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead(Fo,t);this.manySepFirstInternalLogic(t,e,n)}manySepFirstInternalLogic(t,e,n){const i=e.DEF,r=e.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){i.call(this);const e=()=>this.tokenMatcher(this.LA_FAST(1),r);for(;!0===this.tokenMatcher(this.LA_FAST(1),r);)this.CONSUME(r),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,r,e,i,zs],e,Fo,t,zs)}}repetitionSepSecondInternal(t,e,n,i,r){for(;n();)this.CONSUME(e),i.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,i,r],n,Bo,t,r)}doSingleRepetition(t){const e=this.getLexerPosition();return t.call(this),this.getLexerPosition()>e}orInternal(t,e){const n=this.getKeyForAutomaticLookahead(256,e),i=I(t)?t:t.DEF,r=this.getLaFuncFromCache(n).call(this,i);if(void 0!==r)return i[r].ALT.call(this);this.raiseNoAltException(e,t.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(t,e,n){let i;try{const r=void 0!==n?n.ARGS:void 0;return this.subruleIdx=e,i=t.coreRule.apply(this,r),this.cstPostNonTerminal(i,void 0!==n&&void 0!==n.LABEL?n.LABEL:t.ruleName),i}catch(r){throw this.subruleInternalError(r,n,t.ruleName)}}subruleInternalError(t,e,n){throw Io(t)&&void 0!==t.partialCstResult&&(this.cstPostNonTerminal(t.partialCstResult,void 0!==e&&void 0!==e.LABEL?e.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,e,n){let i;try{const e=this.LA_FAST(1);!0===this.tokenMatcher(e,t)?(this.consumeToken(),i=e):this.consumeInternalError(t,e,n)}catch(r){i=this.consumeInternalRecovery(t,e,r)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:t.name,i),i}consumeInternalError(t,e,n){let i;const r=this.LA(0);throw i=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:e,previous:r,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new xo(i,e,r))}consumeInternalRecovery(t,e,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;{const r=this.getFollowsForInRuleRecovery(t,e);try{return this.tryInRuleRecovery(t,r)}catch(i){throw i.name===Mo?n:i}}}saveRecogState(){const t=this.errors,e=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:e,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);const e=t.RULE_STACK;for(let n=0;n<e.length;n++)this.RULE_STACK[n]=e[n];this.RULE_STACK_IDX=e.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(t,e,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.cstInvocationStateUpdate(e)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ms)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(t){for(let e=0;e<this.maxLookahead+1;e++)this.tokVector.push(oa)}onAfterParse(t){if(!1===this.isAtEndOfInput()){const t=this.LA(1),e=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new _o(e,t))}for(;this.tokVector.at(-1)===oa;)this.tokVector.pop()}},class{ACTION(t){return t.call(this)}consume(t,e,n){return this.consumeInternal(e,t,n)}subrule(t,e,n){return this.subruleInternal(e,t,n)}option(t,e){return this.optionInternal(e,t)}or(t,e){return this.orInternal(e,t)}many(t,e){return this.manyInternal(t,e)}atLeastOne(t,e){return this.atLeastOneInternal(t,e)}CONSUME(t,e){return this.consumeInternal(t,0,e)}CONSUME1(t,e){return this.consumeInternal(t,1,e)}CONSUME2(t,e){return this.consumeInternal(t,2,e)}CONSUME3(t,e){return this.consumeInternal(t,3,e)}CONSUME4(t,e){return this.consumeInternal(t,4,e)}CONSUME5(t,e){return this.consumeInternal(t,5,e)}CONSUME6(t,e){return this.consumeInternal(t,6,e)}CONSUME7(t,e){return this.consumeInternal(t,7,e)}CONSUME8(t,e){return this.consumeInternal(t,8,e)}CONSUME9(t,e){return this.consumeInternal(t,9,e)}SUBRULE(t,e){return this.subruleInternal(t,0,e)}SUBRULE1(t,e){return this.subruleInternal(t,1,e)}SUBRULE2(t,e){return this.subruleInternal(t,2,e)}SUBRULE3(t,e){return this.subruleInternal(t,3,e)}SUBRULE4(t,e){return this.subruleInternal(t,4,e)}SUBRULE5(t,e){return this.subruleInternal(t,5,e)}SUBRULE6(t,e){return this.subruleInternal(t,6,e)}SUBRULE7(t,e){return this.subruleInternal(t,7,e)}SUBRULE8(t,e){return this.subruleInternal(t,8,e)}SUBRULE9(t,e){return this.subruleInternal(t,9,e)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,e,n=ca){if(bi(this.definedRulesNames,t)){const e={message:Fs.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:ha.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(e)}this.definedRulesNames.push(t);const i=this.defineRule(t,e,n);return this[t]=i,i}OVERRIDE_RULE(t,e,n=ca){const i=function(t,e,n){const i=[];let r;return bi(e,t)||(r=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,i.push({message:r,type:ha.INVALID_RULE_OVERRIDE,ruleName:t})),i}(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(i);const r=this.defineRule(t,e,n);return this[t]=r,r}BACKTRACK(t,e){var n;const i=null!==(n=t.coreRule)&&void 0!==n?n:t;return function(){this.isBackTrackingStack.push(1);const t=this.saveRecogState();try{return i.apply(this,e),!0}catch(n){if(Io(n))return!1;throw n}finally{this.reloadRecogState(t),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Oi(_i(this.gastProductionsCache),lr)}},class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=xi(t,"errorMessageProvider")?t.errorMessageProvider:aa.errorMessageProvider}SAVE_ERROR(t){if(Io(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return Nn(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,e,n){const i=this.getCurrRuleFullName(),r=co(t,this.getGAstProductions()[i],e,this.maxLookahead)[0],s=[];for(let a=1;a<=this.maxLookahead;a++)s.push(this.LA(a));const o=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:r,actual:s,previous:this.LA(0),customUserDescription:n,ruleName:i});throw this.SAVE_ERROR(new Uo(o,this.LA(1),this.LA(0)))}raiseNoAltException(t,e){const n=this.getCurrRuleFullName(),i=ao(t,this.getGAstProductions()[n],this.maxLookahead),r=[];for(let a=1;a<=this.maxLookahead;a++)r.push(this.LA(a));const s=this.LA(0),o=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:i,actual:r,previous:s,customUserDescription:e,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ko(o,this.LA(1),s))}},class{initContentAssist(){}computeContentAssist(t,e){const n=this.gastProductionsCache[t];if(Bi(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return Ys([n],e,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){const e=Si(t.ruleStack),n=this.getGAstProductions()[e];return new $s(n,t).startWalking()}},class{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){const e=t>0?t:"";this[`CONSUME${e}`]=function(e,n){return this.consumeInternalRecord(e,t,n)},this[`SUBRULE${e}`]=function(e,n){return this.subruleInternalRecord(e,t,n)},this[`OPTION${e}`]=function(e){return this.optionInternalRecord(e,t)},this[`OR${e}`]=function(e){return this.orInternalRecord(e,t)},this[`MANY${e}`]=function(e){this.manyInternalRecord(t,e)},this[`MANY_SEP${e}`]=function(e){this.manySepFirstInternalRecord(t,e)},this[`AT_LEAST_ONE${e}`]=function(e){this.atLeastOneInternalRecord(t,e)},this[`AT_LEAST_ONE_SEP${e}`]=function(e){this.atLeastOneSepFirstInternalRecord(t,e)}}this.consume=function(t,e,n){return this.consumeInternalRecord(e,t,n)},this.subrule=function(t,e,n){return this.subruleInternalRecord(e,t,n)},this.option=function(t,e){return this.optionInternalRecord(e,t)},this.or=function(t,e){return this.orInternalRecord(e,t)},this.many=function(t,e){this.manyInternalRecord(t,e)},this.atLeastOne=function(t,e){this.atLeastOneInternalRecord(t,e)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const t=this;for(let e=0;e<10;e++){const n=e>0?e:"";delete t[`CONSUME${n}`],delete t[`SUBRULE${n}`],delete t[`OPTION${n}`],delete t[`OR${n}`],delete t[`MANY${n}`],delete t[`MANY_SEP${n}`],delete t[`AT_LEAST_ONE${n}`],delete t[`AT_LEAST_ONE_SEP${n}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,e){return()=>!0}LA_RECORD(t){return oa}topLevelRuleRecord(t,e){try{const n=new nr({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),e.call(this),this.recordingProdStack.pop(),n}catch(n){if(!0!==n.KNOWN_RECORDER_ERROR)try{n.message=n.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(i){throw n}throw n}}optionInternalRecord(t,e){return na.call(this,rr,t,e)}atLeastOneInternalRecord(t,e){na.call(this,sr,e,t)}atLeastOneSepFirstInternalRecord(t,e){na.call(this,or,e,t,Zo)}manyInternalRecord(t,e){na.call(this,ar,e,t)}manySepFirstInternalRecord(t,e){na.call(this,cr,e,t,Zo)}orInternalRecord(t,e){return ia.call(this,t,e)}subruleInternalRecord(t,e,n){if(sa(e),!t||!1===xi(t,"ruleName")){const n=new Error(`<SUBRULE${ra(e)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const i=ai(this.recordingProdStack),r=t.ruleName,s=new er({idx:e,nonTerminalName:r,label:null==n?void 0:n.LABEL,referencedRule:void 0});return i.definition.push(s),this.outputCst?ea:qo}consumeInternalRecord(t,e,n){if(sa(e),!fs(t)){const n=new Error(`<CONSUME${ra(e)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const i=ai(this.recordingProdStack),r=new ur({idx:e,terminalType:t,label:null==n?void 0:n.LABEL});return i.definition.push(r),ta}},class{initPerformanceTracer(t){if(xi(t,"traceInitPerf")){const e=t.traceInitPerf,n="number"==typeof e;this.traceInitMaxIdent=n?e:1/0,this.traceInitPerf=n?e>0:e}else this.traceInitMaxIdent=0,this.traceInitPerf=aa.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,e){if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${t}>`);const{time:i,value:r}=Zi(e),s=i>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${i}ms`),this.traceInitIndent--,r}return e()}}].forEach(t=>{const e=t.prototype;Object.getOwnPropertyNames(e).forEach(n=>{if("constructor"===n)return;const i=Object.getOwnPropertyDescriptor(e,n);i&&(i.get||i.set)?Object.defineProperty(la.prototype,n,i):la.prototype[n]=t.prototype[n]})});class pa extends da{constructor(t,e=aa){const n=Nn(e);n.outputCst=!0,super(t,n)}}const fa=bs({name:"Whitespace",pattern:/[ \t\r\n]+/,group:Os.SKIPPED}),ma=bs({name:"LineComment",pattern:/\/\/[^\n]*/,group:Os.SKIPPED}),Ea=bs({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:Os.SKIPPED}),ga=bs({name:"Identifier",pattern:/[A-Za-z_][A-Za-z0-9_]*/}),Ta=(t,e)=>bs({name:t,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),longer_alt:ga}),Sa=Ta("Import","import"),La=Ta("Export","export"),Oa=Ta("From","from"),Ra=Ta("As","as"),Aa=Ta("Const","const"),va=Ta("Var","var"),ya=Ta("Let","let"),Na=Ta("Func","func"),Ia=Ta("Fai","fai"),Ca=Ta("Return","return"),xa=Ta("If","if"),ka=Ta("Else","else"),_a=Ta("For","for"),Ua=Ta("In","in"),ba=Ta("While","while"),Ma=Ta("Break","break"),Pa=Ta("Continue","continue"),wa=Ta("Try","try"),Da=Ta("Catch","catch"),Fa=Ta("True","true"),Ba=Ta("False","false"),ja=Ta("Null","null"),$a=Ta("KwEnum","enum"),Ka=Ta("KwArray","array"),Ga=Ta("KwObject","object"),za=bs({name:"FloatLit",pattern:/[0-9]+\.[0-9]+/}),Wa=bs({name:"IntLit",pattern:/[0-9]+/}),Va=bs({name:"StringLit",pattern:/"(?:[^"\\]|\\.)*"/}),Ha=bs({name:"Arrow",pattern:/->/}),Ya=bs({name:"FatArrow",pattern:/=>/}),Xa=bs({name:"EqEq",pattern:/==/}),qa=bs({name:"NotEq",pattern:/!=/}),Za=bs({name:"LtEq",pattern:/<=/}),Qa=bs({name:"GtEq",pattern:/>=/}),Ja=bs({name:"AndAnd",pattern:/&&/}),tc=bs({name:"OrOr",pattern:/\|\|/}),ec=bs({name:"PlusEq",pattern:/\+=/}),nc=bs({name:"MinusEq",pattern:/-=/}),ic=bs({name:"StarEq",pattern:/\*=/}),rc=bs({name:"SlashEq",pattern:/\/=/}),sc=bs({name:"PercentEq",pattern:/%=/}),oc=bs({name:"Spread",pattern:/\.\.\./}),ac=bs({name:"LCurly",pattern:/\{/}),cc=bs({name:"RCurly",pattern:/\}/}),hc=bs({name:"LParen",pattern:/\(/}),uc=bs({name:"RParen",pattern:/\)/}),lc=bs({name:"LBracket",pattern:/\[/}),dc=bs({name:"RBracket",pattern:/\]/}),pc=bs({name:"LAngle",pattern:/</}),fc=bs({name:"RAngle",pattern:/>/}),mc=bs({name:"Comma",pattern:/,/}),Ec=bs({name:"Colon",pattern:/:/}),gc=bs({name:"Semicolon",pattern:/;/}),Tc=bs({name:"Dot",pattern:/\./}),Sc=bs({name:"Question",pattern:/\?/}),Lc=bs({name:"AtName",pattern:/@[A-Za-z_][A-Za-z0-9_.\-]*/}),Oc=bs({name:"Plus",pattern:/\+/}),Rc=bs({name:"Dash",pattern:/-/}),Ac=bs({name:"Star",pattern:/\*/}),vc=bs({name:"Slash",pattern:/\//}),yc=bs({name:"Percent",pattern:/%/}),Nc=bs({name:"Bang",pattern:/!/}),Ic=bs({name:"Pipe",pattern:/\|/}),Cc=bs({name:"Equals",pattern:/=/}),xc=[fa,ma,Ea,Ha,Ya,Xa,qa,Za,Qa,Ja,tc,ec,nc,ic,rc,sc,oc,Sa,La,Oa,Ra,Aa,va,ya,Na,Ia,Ca,xa,ka,_a,ba,Ma,Pa,wa,Da,Fa,Ba,ja,$a,Ka,Ga,Ua,za,Wa,Va,ga,ac,cc,hc,uc,lc,dc,pc,fc,mc,Ec,gc,Tc,Sc,Lc,Oc,Rc,Ac,vc,yc,Nc,Ic,Cc],kc=new Os(xc,{positionTracking:"full",ensureOptimizations:!1});const _c=new class extends pa{constructor(){super(xc,{recoveryEnabled:!1}),e(this,"program",this.RULE("program",()=>{this.MANY(()=>this.SUBRULE(this.topLevel))})),e(this,"exprEntry",this.RULE("exprEntry",()=>{this.SUBRULE(this.expr)})),e(this,"topLevel",this.RULE("topLevel",()=>{this.OR([{ALT:()=>this.SUBRULE(this.importDecl)},{ALT:()=>this.SUBRULE(this.constDecl)},{ALT:()=>this.SUBRULE(this.varDecl)},{GATE:()=>this.isRuntimeAnnotation(),ALT:()=>this.SUBRULE(this.runtimeAnnotation)},{GATE:()=>this.isAnnotatedFuncOrFai(),ALT:()=>this.SUBRULE(this.annotatedDecl)},{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)},{ALT:()=>this.SUBRULE(this.exportDecl)}])})),e(this,"importDecl",this.RULE("importDecl",()=>{this.CONSUME(Sa),this.SUBRULE(this.importClause),this.CONSUME(Oa),this.CONSUME(Va),this.OPTION(()=>this.CONSUME(Lc))})),e(this,"importClause",this.RULE("importClause",()=>{this.OR([{ALT:()=>this.SUBRULE(this.namedImports)},{ALT:()=>this.SUBRULE(this.namespaceImport)}])})),e(this,"namedImports",this.RULE("namedImports",()=>{this.CONSUME(ac),this.SUBRULE(this.importSpec),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.importSpec)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"importSpec",this.RULE("importSpec",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)})})),e(this,"namespaceImport",this.RULE("namespaceImport",()=>{this.CONSUME(Ac),this.CONSUME(Ra),this.CONSUME(ga)})),e(this,"runtimeAnnotation",this.RULE("runtimeAnnotation",()=>{this.CONSUME(Lc),this.OPTION(()=>{this.CONSUME(hc),this.OPTION2(()=>this.SUBRULE(this.annoArgList)),this.CONSUME(uc)})})),e(this,"declAnnotation",this.RULE("declAnnotation",()=>{this.CONSUME(Lc),this.OPTION(()=>{this.CONSUME(hc),this.OPTION2(()=>this.SUBRULE(this.annoArgList)),this.CONSUME(uc)})})),e(this,"annoArgList",this.RULE("annoArgList",()=>{this.SUBRULE(this.annoArg),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.annoArg)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"annoArg",this.RULE("annoArg",()=>{this.OR([{GATE:()=>this.LA(1).tokenType===ga&&this.LA(2).tokenType===Cc,ALT:()=>{this.CONSUME(ga),this.CONSUME(Cc),this.SUBRULE(this.literal)}},{ALT:()=>this.SUBRULE2(this.literal)}])})),e(this,"annotatedDecl",this.RULE("annotatedDecl",()=>{this.AT_LEAST_ONE(()=>this.SUBRULE(this.declAnnotation)),this.OR([{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)}])})),e(this,"constDecl",this.RULE("constDecl",()=>{this.CONSUME(Aa),this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot),this.CONSUME(Cc),this.SUBRULE(this.expr)})),e(this,"varDecl",this.RULE("varDecl",()=>{this.CONSUME(va),this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot),this.OPTION(()=>{this.CONSUME(Cc),this.SUBRULE(this.expr)})})),e(this,"funcDecl",this.RULE("funcDecl",()=>{this.CONSUME(Na),this.CONSUME(ga),this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.paramList)),this.CONSUME(uc),this.OPTION2(()=>{this.CONSUME(Ha),this.SUBRULE(this.typeAnnot)}),this.SUBRULE(this.block)})),e(this,"faiDecl",this.RULE("faiDecl",()=>{this.CONSUME(Ia),this.CONSUME(ga),this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.faiParamList)),this.CONSUME(uc),this.CONSUME(Ha),this.SUBRULE(this.faiOutputList),this.SUBRULE(this.block)})),e(this,"exportDecl",this.RULE("exportDecl",()=>{this.CONSUME(La),this.OR([{ALT:()=>this.SUBRULE(this.exportNames)},{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)}])})),e(this,"exportNames",this.RULE("exportNames",()=>{this.OR([{ALT:()=>{this.SUBRULE(this.exportSpec)}},{ALT:()=>{this.CONSUME(ac),this.SUBRULE2(this.exportSpec),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE3(this.exportSpec)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)}}])})),e(this,"exportSpec",this.RULE("exportSpec",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)})})),e(this,"paramList",this.RULE("paramList",()=>{this.SUBRULE(this.param),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.param)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"param",this.RULE("param",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})})),e(this,"faiParamList",this.RULE("faiParamList",()=>{this.SUBRULE(this.faiParam),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.faiParam)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"faiParam",this.RULE("faiParam",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"faiOutputList",this.RULE("faiOutputList",()=>{this.SUBRULE(this.faiOutput),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.faiOutput)})})),e(this,"faiOutput",this.RULE("faiOutput",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"typeAnnot",this.RULE("typeAnnot",()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumType)},{ALT:()=>this.SUBRULE(this.arrayType)},{ALT:()=>this.SUBRULE(this.objectType)},{ALT:()=>this.SUBRULE(this.scalarType)}])})),e(this,"scalarType",this.RULE("scalarType",()=>{this.CONSUME(ga),this.OPTION(()=>this.SUBRULE(this.typeConstraint))})),e(this,"enumType",this.RULE("enumType",()=>{this.CONSUME($a),this.CONSUME(Ec),this.CONSUME(ga),this.MANY(()=>{this.CONSUME(Ic),this.CONSUME2(ga)})})),e(this,"arrayType",this.RULE("arrayType",()=>{this.CONSUME(Ka),this.CONSUME(pc),this.SUBRULE(this.typeAnnot),this.CONSUME(fc),this.OPTION(()=>this.SUBRULE(this.namedConstraint))})),e(this,"objectType",this.RULE("objectType",()=>{this.CONSUME(Ga),this.CONSUME(ac),this.SUBRULE(this.objectTypeField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.objectTypeField)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"objectTypeField",this.RULE("objectTypeField",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"typeConstraint",this.RULE("typeConstraint",()=>{this.OR([{GATE:()=>this.isRangeConstraint(),ALT:()=>this.SUBRULE(this.rangeConstraint)},{ALT:()=>this.SUBRULE(this.namedConstraint)}])})),e(this,"rangeConstraint",this.RULE("rangeConstraint",()=>{this.SUBRULE(this.numberLit),this.CONSUME(Rc),this.SUBRULE2(this.numberLit)})),e(this,"namedConstraint",this.RULE("namedConstraint",()=>{this.CONSUME(ga),this.CONSUME(Cc),this.OR([{ALT:()=>this.SUBRULE(this.numberLit)},{ALT:()=>this.CONSUME(Va)}])})),e(this,"numberLit",this.RULE("numberLit",()=>{this.OR([{ALT:()=>this.CONSUME(Wa)},{ALT:()=>this.CONSUME(za)}])})),e(this,"block",this.RULE("block",()=>{this.CONSUME(ac),this.MANY(()=>this.SUBRULE(this.stmt)),this.CONSUME(cc)})),e(this,"stmt",this.RULE("stmt",()=>{this.OR([{ALT:()=>this.SUBRULE(this.letDecl)},{ALT:()=>this.SUBRULE(this.ifStmt)},{ALT:()=>this.SUBRULE(this.forStmt)},{ALT:()=>this.SUBRULE(this.whileStmt)},{ALT:()=>this.SUBRULE(this.tryStmt)},{ALT:()=>this.SUBRULE(this.breakStmt)},{ALT:()=>this.SUBRULE(this.continueStmt)},{ALT:()=>this.SUBRULE(this.returnStmt)},{GATE:()=>this.isAssignment(),ALT:()=>this.SUBRULE(this.assignment)},{ALT:()=>this.SUBRULE(this.exprStmt)}]),this.OPTION(()=>this.CONSUME(gc))})),e(this,"letDecl",this.RULE("letDecl",()=>{this.CONSUME(ya),this.SUBRULE(this.letTarget),this.OPTION(()=>{this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)}),this.OPTION2(()=>{this.CONSUME(Cc),this.SUBRULE(this.expr)})})),e(this,"letTarget",this.RULE("letTarget",()=>{this.OR([{ALT:()=>this.CONSUME(ga)},{ALT:()=>this.SUBRULE(this.objectDestruct)},{ALT:()=>this.SUBRULE(this.arrayDestruct)}])})),e(this,"objectDestruct",this.RULE("objectDestruct",()=>{this.CONSUME(ac),this.SUBRULE(this.destructField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.destructField)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"destructField",this.RULE("destructField",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ec),this.CONSUME2(ga)})})),e(this,"arrayDestruct",this.RULE("arrayDestruct",()=>{this.CONSUME(lc),this.CONSUME(ga),this.MANY(()=>{this.CONSUME(mc),this.CONSUME2(ga)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(dc)})),e(this,"assignment",this.RULE("assignment",()=>{this.SUBRULE(this.lvalue),this.SUBRULE(this.assignOp),this.SUBRULE(this.expr)})),e(this,"lvalue",this.RULE("lvalue",()=>{this.CONSUME(ga),this.MANY(()=>this.SUBRULE(this.lvalueSuffix))})),e(this,"lvalueSuffix",this.RULE("lvalueSuffix",()=>{this.OR([{ALT:()=>{this.CONSUME(Tc),this.CONSUME(ga)}},{ALT:()=>{this.CONSUME(lc),this.SUBRULE(this.expr),this.CONSUME(dc)}}])})),e(this,"assignOp",this.RULE("assignOp",()=>{this.OR([{ALT:()=>this.CONSUME(Cc)},{ALT:()=>this.CONSUME(ec)},{ALT:()=>this.CONSUME(nc)},{ALT:()=>this.CONSUME(ic)},{ALT:()=>this.CONSUME(rc)},{ALT:()=>this.CONSUME(sc)}])})),e(this,"ifStmt",this.RULE("ifStmt",()=>{this.CONSUME(xa),this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc),this.SUBRULE(this.block),this.MANY({GATE:()=>this.LA(1).tokenType===ka&&this.LA(2).tokenType===xa,DEF:()=>{this.CONSUME(ka),this.CONSUME2(xa),this.CONSUME2(hc),this.SUBRULE2(this.expr),this.CONSUME2(uc),this.SUBRULE2(this.block)}}),this.OPTION(()=>{this.CONSUME3(ka),this.SUBRULE3(this.block)})})),e(this,"forStmt",this.RULE("forStmt",()=>{this.CONSUME(_a),this.CONSUME(ga),this.CONSUME(Ua),this.SUBRULE(this.expr),this.SUBRULE(this.block)})),e(this,"whileStmt",this.RULE("whileStmt",()=>{this.CONSUME(ba),this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc),this.SUBRULE(this.block)})),e(this,"tryStmt",this.RULE("tryStmt",()=>{this.CONSUME(wa),this.SUBRULE(this.block),this.AT_LEAST_ONE(()=>this.SUBRULE(this.catchClause))})),e(this,"catchClause",this.RULE("catchClause",()=>{this.CONSUME(Da),this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)}),this.SUBRULE(this.block)})),e(this,"breakStmt",this.RULE("breakStmt",()=>{this.CONSUME(Ma)})),e(this,"continueStmt",this.RULE("continueStmt",()=>{this.CONSUME(Pa)})),e(this,"returnStmt",this.RULE("returnStmt",()=>{this.CONSUME(Ca),this.OPTION({GATE:()=>this.canStartExpression(),DEF:()=>this.SUBRULE(this.expr)})})),e(this,"exprStmt",this.RULE("exprStmt",()=>{this.SUBRULE(this.expr)})),e(this,"expr",this.RULE("expr",()=>{this.SUBRULE(this.ternaryExpr)})),e(this,"ternaryExpr",this.RULE("ternaryExpr",()=>{this.SUBRULE(this.logicalOrExpr),this.OPTION(()=>{this.CONSUME(Sc),this.SUBRULE(this.expr),this.CONSUME(Ec),this.SUBRULE2(this.expr)})})),e(this,"logicalOrExpr",this.RULE("logicalOrExpr",()=>{this.SUBRULE(this.logicalAndExpr),this.MANY(()=>{this.CONSUME(tc),this.SUBRULE2(this.logicalAndExpr)})})),e(this,"logicalAndExpr",this.RULE("logicalAndExpr",()=>{this.SUBRULE(this.equalityExpr),this.MANY(()=>{this.CONSUME(Ja),this.SUBRULE2(this.equalityExpr)})})),e(this,"equalityExpr",this.RULE("equalityExpr",()=>{this.SUBRULE(this.comparisonExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Xa)},{ALT:()=>this.CONSUME(qa)}]),this.SUBRULE2(this.comparisonExpr)})})),e(this,"comparisonExpr",this.RULE("comparisonExpr",()=>{this.SUBRULE(this.additiveExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(pc)},{ALT:()=>this.CONSUME(Za)},{ALT:()=>this.CONSUME(fc)},{ALT:()=>this.CONSUME(Qa)}]),this.SUBRULE2(this.additiveExpr)})})),e(this,"additiveExpr",this.RULE("additiveExpr",()=>{this.SUBRULE(this.multiplicativeExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Oc)},{ALT:()=>this.CONSUME(Rc)}]),this.SUBRULE2(this.multiplicativeExpr)})})),e(this,"multiplicativeExpr",this.RULE("multiplicativeExpr",()=>{this.SUBRULE(this.unaryExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Ac)},{ALT:()=>this.CONSUME(vc)},{ALT:()=>this.CONSUME(yc)}]),this.SUBRULE2(this.unaryExpr)})})),e(this,"unaryExpr",this.RULE("unaryExpr",()=>{this.OPTION(()=>{this.OR([{ALT:()=>this.CONSUME(Rc)},{ALT:()=>this.CONSUME(Nc)}])}),this.SUBRULE(this.postfixExpr)})),e(this,"postfixExpr",this.RULE("postfixExpr",()=>{this.SUBRULE(this.primaryExpr),this.MANY(()=>this.SUBRULE(this.postfixSuffix))})),e(this,"postfixSuffix",this.RULE("postfixSuffix",()=>{this.OR([{ALT:()=>{this.CONSUME(Tc),this.CONSUME(ga)}},{ALT:()=>{this.CONSUME(lc),this.SUBRULE(this.expr),this.CONSUME(dc)}},{ALT:()=>{this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.argList)),this.CONSUME(uc)}}])})),e(this,"argList",this.RULE("argList",()=>{this.SUBRULE(this.expr),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.expr)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"primaryExpr",this.RULE("primaryExpr",()=>{this.OR([{ALT:()=>this.SUBRULE(this.literal)},{ALT:()=>this.CONSUME(ga)},{ALT:()=>this.SUBRULE(this.arrayLit)},{ALT:()=>this.SUBRULE(this.objectLit)},{ALT:()=>{this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc)}}])})),e(this,"literal",this.RULE("literal",()=>{this.OR([{ALT:()=>this.CONSUME(Wa)},{ALT:()=>this.CONSUME(za)},{ALT:()=>this.CONSUME(Va)},{ALT:()=>this.CONSUME(Fa)},{ALT:()=>this.CONSUME(Ba)},{ALT:()=>this.CONSUME(ja)}])})),e(this,"arrayLit",this.RULE("arrayLit",()=>{this.CONSUME(lc),this.OPTION(()=>{this.SUBRULE(this.expr),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.expr)}),this.OPTION2(()=>this.CONSUME2(mc))}),this.CONSUME(dc)})),e(this,"objectLit",this.RULE("objectLit",()=>{this.CONSUME(ac),this.OPTION(()=>{this.SUBRULE(this.objectLitField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.objectLitField)}),this.OPTION2(()=>this.CONSUME2(mc))}),this.CONSUME(cc)})),e(this,"objectLitField",this.RULE("objectLitField",()=>{this.OR([{GATE:()=>this.LA(1).tokenType===Va,ALT:()=>{this.CONSUME(Va),this.CONSUME(Ec),this.SUBRULE(this.expr)}},{ALT:()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME2(Ec),this.SUBRULE2(this.expr)})}}])})),this.performSelfAnalysis()}isRuntimeAnnotation(){const t=this.LA(1);return t.tokenType===Lc&&"@runtime"===t.image}isAnnotatedFuncOrFai(){let t=1;for(;this.LA(t).tokenType===Lc;)if(t++,this.LA(t).tokenType===hc){let e=1;for(t++;e>0&&this.LA(t).tokenType!==Ms;){const n=this.LA(t).tokenType;n===hc?e++:n===uc&&e--,t++}}const e=this.LA(t).tokenType;return e===Na||e===Ia}isRangeConstraint(){const t=this.LA(1).tokenType;return t===Wa||t===za}isAssignment(){if(this.LA(1).tokenType!==ga)return!1;let t=2,e=0;for(;;){const n=this.LA(t).tokenType;if(n===Ms)return!1;if(0===e){if(n===Cc||n===ec||n===nc||n===ic||n===rc||n===sc)return!0;if(n===gc||n===cc||n===ac||n===mc||n===uc)return!1;if(n===Tc||n===ga){t++;continue}if(n===lc||n===hc){e++,t++;continue}return!1}if(n===lc||n===hc?e++:n!==dc&&n!==uc||e--,t++,e<0)return!1}}canStartExpression(){const t=this.LA(1).tokenType;return t===Wa||t===za||t===Va||t===Fa||t===Ba||t===ja||t===ga||t===hc||t===lc||t===ac||t===Rc||t===Nc}};const Uc=_c.getBaseCstVisitorConstructor();function bc(t){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:t.endLine??0,endColumn:t.endColumn??0,startOffset:t.startOffset,endOffset:t.endOffset??t.startOffset}}function Mc(t){const e=t.location;return e?{startLine:e.startLine??0,startColumn:e.startColumn??0,endLine:e.endLine??0,endColumn:e.endColumn??0,startOffset:e.startOffset,endOffset:e.endOffset??e.startOffset}:{startLine:0,startColumn:0,endLine:0,endColumn:0,startOffset:0,endOffset:0}}function Pc(t){return wc(t.slice(1,-1))}function wc(t){return t.replace(/\\(.)/g,(t,e)=>{switch(e){case"n":return"\n";case"t":return"\t";case"r":return"\r";case"\\":return"\\";case'"':return'"';case"'":return"'";case"$":return"$";default:return e}})}function Dc(t){const e=t.image.slice(1,-1),n=bc(t),i=function(t){const e=[];let n="",i=0,r=0;const s=t=>{e.push({kind:"chunk",source:n,startInBody:i,endInBody:t}),n="",i=t};for(;r<t.length;)if("$"===t[r]&&"{"===t[r+1]){s(r);let o=1,a=r+2;for(;a<t.length&&o>0;){const e=t[a];if("{"===e)o++;else if("}"===e&&(o--,0===o))break;a++}if(0!==o){n+=t.slice(r),i=r,r=t.length;break}const c=t.slice(r+2,a);e.push({kind:"expr",source:c,startInBody:r,endInBody:a+1}),i=a+1,r=a+1}else"\\"===t[r]&&r+1<t.length?(n+=t.slice(r,r+2),r+=2):(n+=t[r],r++);return(e.some(t=>"expr"===t.kind)||0===e.length||n.length>0)&&s(t.length),e}(e);if(!i.some(t=>"expr"===t.kind)){return{kind:"StringLit",value:wc(i.map(t=>t.source).join("")),range:n}}const r=t.startOffset+1;return{kind:"TemplateString",parts:i.map(t=>{if("chunk"===t.kind)return{kind:"TemplateChunk",value:wc(t.source),range:Fc(n,r,t.startInBody,t.endInBody)};const e=function(t){const e=kc.tokenize(t);return _c.input=e.tokens,{cst:_c.exprEntry(),lexErrors:e.errors,parseErrors:_c.errors}}(t.source);if(e.lexErrors.length>0||e.parseErrors.length>0||!e.cst)return{kind:"TemplateChunk",value:"${"+t.source+"}",range:Fc(n,r,t.startInBody,t.endInBody)};return{kind:"TemplateExpr",expr:Hc.visit(e.cst),range:Fc(n,r,t.startInBody,t.endInBody)}}),range:n}}function Fc(t,e,n,i){return{startLine:t.startLine,startColumn:t.startColumn,endLine:t.endLine,endColumn:t.endColumn,startOffset:e+n,endOffset:e+i}}function Bc(t){return t.startsWith("@")?t.slice(1):t}function jc(t,e){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:e.endLine??0,endColumn:e.endColumn??0,startOffset:t.startOffset,endOffset:e.endOffset??e.startOffset}}function $c(t,e){return{startLine:t.startLine,startColumn:t.startColumn,endLine:e.endLine,endColumn:e.endColumn,startOffset:t.startOffset,endOffset:e.endOffset}}function Kc(t,e){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:e.endLine,endColumn:e.endColumn,startOffset:t.startOffset,endOffset:e.endOffset}}function Gc(t){if(0===t.length)return{startLine:0,startColumn:0,endLine:0,endColumn:0,startOffset:0,endOffset:0};return $c(t[0].range,t[t.length-1].range)}function zc(t){const e=t.children;let n;for(const i of Object.keys(e)){const t=e[i];for(const e of t){let t;t="image"in e?e:zc(e),t&&(!n||t.startOffset<n.startOffset)&&(n=t)}}return n}function Wc(t,e){let n=t[0];for(let i=0;i<e.length;i++){const r=t[i+1];n={kind:"BinaryExpr",op:e[i],left:n,right:r,range:$c(n.range,r.range)}}return n}function Vc(t,e){const n=[];for(const[i,r]of e){const e=t[i]??[];for(const t of e)n.push({offset:t.startOffset,op:r})}return n.sort((t,e)=>t.offset-e.offset),n.map(t=>t.op)}const Hc=new class extends Uc{constructor(){super(),this.validateVisitor()}exprEntry(t){return this.visit(t.expr[0])}program(t,e){const n=t.$cstNode??void 0,i=(t.topLevel??[]).map(t=>this.visit(t));return{kind:"Program",items:i,range:n?Mc(n):Gc(i)}}topLevel(t){if(t.importDecl)return this.visit(t.importDecl[0]);if(t.runtimeAnnotation)return this.visit(t.runtimeAnnotation[0]);if(t.constDecl)return this.visit(t.constDecl[0]);if(t.varDecl)return this.visit(t.varDecl[0]);if(t.annotatedDecl)return this.visit(t.annotatedDecl[0]);if(t.funcDecl)return this.visit(t.funcDecl[0]);if(t.faiDecl)return this.visit(t.faiDecl[0]);if(t.exportDecl)return this.visit(t.exportDecl[0]);throw new Error("unreachable: topLevel had no matching alternative")}importDecl(t){var e;const n=this.visit(t.importClause[0]),i=t.StringLit[0],r=null==(e=t.AtName)?void 0:e[0],s=t.Import[0],o=r??i;return{kind:"Import",clause:n,source:Pc(i.image),version:r?r.image.slice(1):null,range:jc(s,o)}}importClause(t){return t.namedImports?this.visit(t.namedImports[0]):this.visit(t.namespaceImport[0])}namedImports(t){return{kind:"NamedImports",specs:(t.importSpec??[]).map(t=>this.visit(t)),range:jc(t.LCurly[0],t.RCurly[0])}}importSpec(t){const e=t.Identifier;return{kind:"ImportSpec",name:e[0].image,alias:e.length>1?e[1].image:null,range:jc(e[0],e[e.length-1])}}namespaceImport(t){const e=t.Star[0],n=t.Identifier[0];return{kind:"NamespaceImport",alias:n.image,range:jc(e,n)}}runtimeAnnotation(t){var e,n;const i=t.AtName[0],r=null==(e=t.annoArgList)?void 0:e[0],s=r?this.visit(r):[],o=(null==(n=t.RParen)?void 0:n[0])??i;return{kind:"RuntimeAnnotation",name:Bc(i.image),args:s,range:jc(i,o)}}declAnnotation(t){var e,n;const i=t.AtName[0],r=null==(e=t.annoArgList)?void 0:e[0],s=r?this.visit(r):[],o=(null==(n=t.RParen)?void 0:n[0])??i;return{kind:"Annotation",name:Bc(i.image),args:s,range:jc(i,o)}}annoArgList(t){return(t.annoArg??[]).map(t=>this.visit(t))}annoArg(t){var e;const n=null==(e=t.Identifier)?void 0:e[0],i=t.literal[0],r=this.visit(i),s=n??zc(i),o=r.range;return{kind:"AnnotationArg",key:n?n.image:null,value:r,range:{startLine:(null==s?void 0:s.startLine)??o.startLine,startColumn:(null==s?void 0:s.startColumn)??o.startColumn,endLine:o.endLine,endColumn:o.endColumn,startOffset:(null==s?void 0:s.startOffset)??o.startOffset,endOffset:o.endOffset}}}annotatedDecl(t){const e=(t.declAnnotation??[]).map(t=>this.visit(t));let n;return n=t.funcDecl?this.visit(t.funcDecl[0]):this.visit(t.faiDecl[0]),{...n,annotations:e}}constDecl(t){const e=t.Const[0],n=t.Identifier[0],i=this.visit(t.typeAnnot[0]),r=this.visit(t.expr[0]);return{kind:"ConstDecl",name:n.image,type:i,value:r,range:Kc(e,r.range)}}varDecl(t){const e=t.Var[0],n=t.Identifier[0],i=this.visit(t.typeAnnot[0]),r=t.expr?this.visit(t.expr[0]):null,s=(null==r?void 0:r.range)??i.range;return{kind:"VarDecl",name:n.image,type:i,init:r,range:Kc(e,s)}}funcDecl(t){const e=t.Func[0],n=t.Identifier[0],i=t.paramList?this.visit(t.paramList[0]):[],r=t.typeAnnot?this.visit(t.typeAnnot[0]):null,s=this.visit(t.block[0]);return{kind:"FuncDecl",annotations:[],name:n.image,params:i,returnType:r,body:s,range:Kc(e,s.range)}}faiDecl(t){const e=t.Fai[0],n=t.Identifier[0],i=t.faiParamList?this.visit(t.faiParamList[0]):[],r=this.visit(t.faiOutputList[0]),s=this.visit(t.block[0]);return{kind:"FaiDecl",annotations:[],name:n.image,params:i,outputs:r,body:s,range:Kc(e,s.range)}}exportDecl(t){const e=t.Export[0];let n;return n=t.exportNames?this.visit(t.exportNames[0]):t.funcDecl?this.visit(t.funcDecl[0]):this.visit(t.faiDecl[0]),{kind:"ExportDecl",target:n,range:Kc(e,n.range)}}exportNames(t){const e=(t.exportSpec??[]).map(t=>this.visit(t));if(0===e.length)return{kind:"ExportNames",specs:[],range:Gc([])};return{kind:"ExportNames",specs:e,range:$c(e[0].range,e[e.length-1].range)}}exportSpec(t){const e=t.Identifier;return{kind:"ExportSpec",name:e[0].image,alias:e.length>1?e[1].image:null,range:jc(e[0],e[e.length-1])}}paramList(t){return(t.param??[]).map(t=>this.visit(t))}param(t){const e=t.Identifier[0],n=t.typeAnnot?this.visit(t.typeAnnot[0]):null,i=(null==n?void 0:n.range)??bc(e);return{kind:"Param",name:e.image,type:n,range:Kc(e,i)}}faiParamList(t){return(t.faiParam??[]).map(t=>this.visit(t))}faiParam(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"FaiParam",name:e.image,type:n,range:Kc(e,n.range)}}faiOutputList(t){return t.faiOutput.map(t=>this.visit(t))}faiOutput(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"FaiOutput",name:e.image,type:n,range:Kc(e,n.range)}}typeAnnot(t){return t.enumType?this.visit(t.enumType[0]):t.arrayType?this.visit(t.arrayType[0]):t.objectType?this.visit(t.objectType[0]):this.visit(t.scalarType[0])}scalarType(t){const e=t.Identifier[0],n=t.typeConstraint?this.visit(t.typeConstraint[0]):null,i=(null==n?void 0:n.range)??bc(e);return{kind:"ScalarType",name:e.image,constraint:n,range:Kc(e,i)}}enumType(t){const e=t.KwEnum[0];return{kind:"EnumType",variants:t.Identifier.map(t=>t.image),range:jc(e,t.Identifier.at(-1))}}arrayType(t){const e=t.KwArray[0],n=this.visit(t.typeAnnot[0]),i=t.RAngle[0],r=t.namedConstraint?this.visit(t.namedConstraint[0]):null;return{kind:"ArrayType",element:n,constraint:r,range:Kc(e,(null==r?void 0:r.range)??bc(i))}}objectType(t){const e=t.KwObject[0],n=t.RCurly[0];return{kind:"ObjectType",fields:(t.objectTypeField??[]).map(t=>this.visit(t)),range:jc(e,n)}}objectTypeField(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"ObjectTypeField",name:e.image,type:n,range:Kc(e,n.range)}}typeConstraint(t){return t.rangeConstraint?this.visit(t.rangeConstraint[0]):this.visit(t.namedConstraint[0])}rangeConstraint(t){const e=t.numberLit.map(t=>this.visit(t));return{kind:"RangeConstraint",min:e[0].value,max:e[1].value,range:$c(e[0].range,e[1].range)}}namedConstraint(t){const e=t.Identifier[0];let n,i;if(t.numberLit){const e=this.visit(t.numberLit[0]);n=e.value,i=e.range}else{const e=t.StringLit[0];n=Pc(e.image),i=bc(e)}return{kind:"NamedConstraint",key:e.image,value:n,range:Kc(e,i)}}numberLit(t){if(t.IntLit){const e=t.IntLit[0];return{value:Number.parseInt(e.image,10),range:bc(e)}}const e=t.FloatLit[0];return{value:Number.parseFloat(e.image),range:bc(e)}}block(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"Block",stmts:(t.stmt??[]).map(t=>this.visit(t)),range:jc(e,n)}}stmt(t){if(t.letDecl)return this.visit(t.letDecl[0]);if(t.ifStmt)return this.visit(t.ifStmt[0]);if(t.forStmt)return this.visit(t.forStmt[0]);if(t.whileStmt)return this.visit(t.whileStmt[0]);if(t.tryStmt)return this.visit(t.tryStmt[0]);if(t.breakStmt)return this.visit(t.breakStmt[0]);if(t.continueStmt)return this.visit(t.continueStmt[0]);if(t.returnStmt)return this.visit(t.returnStmt[0]);if(t.assignment)return this.visit(t.assignment[0]);if(t.exprStmt)return this.visit(t.exprStmt[0]);throw new Error("unreachable: stmt had no matching alternative")}letDecl(t){const e=t.Let[0],n=this.visit(t.letTarget[0]),i=t.typeAnnot?this.visit(t.typeAnnot[0]):null,r=t.expr?this.visit(t.expr[0]):null;return{kind:"LetDecl",target:n,type:i,init:r,range:Kc(e,(null==r?void 0:r.range)??(null==i?void 0:i.range)??n.range)}}letTarget(t){if(t.Identifier){const e=t.Identifier[0];return{kind:"IdentTarget",name:e.image,range:bc(e)}}return t.objectDestruct?this.visit(t.objectDestruct[0]):this.visit(t.arrayDestruct[0])}objectDestruct(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"ObjectDestruct",fields:(t.destructField??[]).map(t=>this.visit(t)),range:jc(e,n)}}destructField(t){const e=t.Identifier,n=e[0].image;return{kind:"DestructField",source:n,local:e.length>1?e[1].image:n,range:jc(e[0],e[e.length-1])}}arrayDestruct(t){const e=t.LBracket[0],n=t.RBracket[0];return{kind:"ArrayDestruct",names:t.Identifier.map(t=>t.image),range:jc(e,n)}}assignment(t){const e=this.visit(t.lvalue[0]),n=this.visit(t.assignOp[0]),i=this.visit(t.expr[0]);return{kind:"Assignment",target:e,op:n,value:i,range:$c(e.range,i.range)}}lvalue(t){const e=t.Identifier[0],n=(t.lvalueSuffix??[]).map(t=>this.visit(t)),i=n.length>0?n[n.length-1].range:bc(e);return{kind:"LValue",base:e.image,suffixes:n,range:Kc(e,i)}}lvalueSuffix(t){if(t.Dot){const e=t.Dot[0],n=t.Identifier[0];return{kind:"MemberSuffix",name:n.image,range:jc(e,n)}}const e=t.LBracket[0],n=t.RBracket[0];return{kind:"IndexSuffix",index:this.visit(t.expr[0]),range:jc(e,n)}}assignOp(t){return t.Equals?"=":t.PlusEq?"+=":t.MinusEq?"-=":t.StarEq?"*=":t.SlashEq?"/=":"%="}ifStmt(t){var e;const n=t.If[0],i=t.expr,r=t.block,s=this.visit(i[0]),o=this.visit(r[0]),a=[];for(let u=1;u<i.length;u++){const t=this.visit(i[u]),e=this.visit(r[u]);a.push({kind:"ElseIf",cond:t,body:e,range:$c(t.range,e.range)})}let c=null;r.length>i.length&&(c=this.visit(r[r.length-1]));const h=(null==c?void 0:c.range)??(null==(e=a.at(-1))?void 0:e.range)??o.range;return{kind:"IfStmt",cond:s,then:o,elifs:a,otherwise:c,range:Kc(n,h)}}forStmt(t){const e=t.For[0],n=t.Identifier[0].image,i=this.visit(t.expr[0]),r=this.visit(t.block[0]);return{kind:"ForStmt",binding:n,iterable:i,body:r,range:Kc(e,r.range)}}whileStmt(t){const e=t.While[0],n=this.visit(t.expr[0]),i=this.visit(t.block[0]);return{kind:"WhileStmt",cond:n,body:i,range:Kc(e,i.range)}}tryStmt(t){var e;const n=t.Try[0],i=this.visit(t.block[0]),r=t.catchClause.map(t=>this.visit(t)),s=(null==(e=r.at(-1))?void 0:e.range)??i.range;return{kind:"TryStmt",body:i,catches:r,range:Kc(n,s)}}catchClause(t){const e=t.Catch[0],n=t.Identifier,i=n[0].image,r=n.length>1?n[1].image:null,s=this.visit(t.block[0]);return{kind:"CatchClause",errorType:i,binding:r,body:s,range:Kc(e,s.range)}}breakStmt(t){return{kind:"BreakStmt",range:bc(t.Break[0])}}continueStmt(t){return{kind:"ContinueStmt",range:bc(t.Continue[0])}}returnStmt(t){const e=t.Return[0],n=t.expr?this.visit(t.expr[0]):null;return{kind:"ReturnStmt",value:n,range:n?Kc(e,n.range):bc(e)}}exprStmt(t){const e=this.visit(t.expr[0]);return{kind:"ExprStmt",expr:e,range:e.range}}expr(t){return this.visit(t.ternaryExpr[0])}ternaryExpr(t){const e=this.visit(t.logicalOrExpr[0]);if(!t.expr)return e;const[n,i]=t.expr,r=this.visit(n),s=this.visit(i);return{kind:"TernaryExpr",cond:e,then:r,otherwise:s,range:$c(e.range,s.range)}}logicalOrExpr(t){return Wc(t.logicalAndExpr.map(t=>this.visit(t)),(t.OrOr??[]).map(()=>"||"))}logicalAndExpr(t){return Wc(t.equalityExpr.map(t=>this.visit(t)),(t.AndAnd??[]).map(()=>"&&"))}equalityExpr(t){return Wc(t.comparisonExpr.map(t=>this.visit(t)),Vc(t,[["EqEq","=="],["NotEq","!="]]))}comparisonExpr(t){return Wc(t.additiveExpr.map(t=>this.visit(t)),Vc(t,[["LAngle","<"],["LtEq","<="],["RAngle",">"],["GtEq",">="]]))}additiveExpr(t){return Wc(t.multiplicativeExpr.map(t=>this.visit(t)),Vc(t,[["Plus","+"],["Dash","-"]]))}multiplicativeExpr(t){return Wc(t.unaryExpr.map(t=>this.visit(t)),Vc(t,[["Star","*"],["Slash","/"],["Percent","%"]]))}unaryExpr(t){const e=this.visit(t.postfixExpr[0]);if(t.Dash){return{kind:"UnaryExpr",op:"-",operand:e,range:Kc(t.Dash[0],e.range)}}if(t.Bang){return{kind:"UnaryExpr",op:"!",operand:e,range:Kc(t.Bang[0],e.range)}}return e}postfixExpr(t){let e=this.visit(t.primaryExpr[0]);const n=t.postfixSuffix??[];for(const i of n){const t=this.visit(i);e="member"===t.tag?{kind:"MemberExpr",object:e,property:t.name,range:$c(e.range,t.range)}:"index"===t.tag?{kind:"IndexExpr",object:e,index:t.index,range:$c(e.range,t.range)}:{kind:"CallExpr",callee:e,args:t.args,range:$c(e.range,t.range)}}return e}postfixSuffix(t){if(t.Dot){const e=t.Dot[0],n=t.Identifier[0];return{tag:"member",name:n.image,range:jc(e,n)}}if(t.LBracket){const e=t.LBracket[0],n=t.RBracket[0];return{tag:"index",index:this.visit(t.expr[0]),range:jc(e,n)}}const e=t.LParen[0],n=t.RParen[0];return{tag:"call",args:t.argList?this.visit(t.argList[0]):[],range:jc(e,n)}}argList(t){return t.expr.map(t=>this.visit(t))}primaryExpr(t){if(t.literal)return this.visit(t.literal[0]);if(t.Identifier){const e=t.Identifier[0];return{kind:"IdentExpr",name:e.image,range:bc(e)}}return t.arrayLit?this.visit(t.arrayLit[0]):t.objectLit?this.visit(t.objectLit[0]):this.visit(t.expr[0])}literal(t){if(t.IntLit){const e=t.IntLit[0];return{kind:"IntLit",value:Number.parseInt(e.image,10),range:bc(e)}}if(t.FloatLit){const e=t.FloatLit[0];return{kind:"FloatLit",value:Number.parseFloat(e.image),range:bc(e)}}if(t.StringLit){return Dc(t.StringLit[0])}if(t.True){return{kind:"BoolLit",value:!0,range:bc(t.True[0])}}if(t.False){return{kind:"BoolLit",value:!1,range:bc(t.False[0])}}return{kind:"NullLit",range:bc(t.Null[0])}}arrayLit(t){const e=t.LBracket[0],n=t.RBracket[0];return{kind:"ArrayLit",elements:t.expr?t.expr.map(t=>this.visit(t)):[],range:jc(e,n)}}objectLit(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"ObjectLit",fields:(t.objectLitField??[]).map(t=>this.visit(t)),range:jc(e,n)}}objectLitField(t){if(t.StringLit){const e=t.StringLit[0],n=this.visit(t.expr[0]);return{kind:"ObjectLitField",key:Pc(e.image),shorthand:!1,value:n,range:Kc(e,n.range)}}const e=t.Identifier[0];if(t.expr){const n=this.visit(t.expr[0]);return{kind:"ObjectLitField",key:e.image,shorthand:!1,value:n,range:Kc(e,n.range)}}return{kind:"ObjectLitField",key:e.image,shorthand:!0,value:{kind:"IdentExpr",name:e.image,range:bc(e)},range:bc(e)}}};function Yc(t){const e=function(t){const e=kc.tokenize(t);return _c.input=e.tokens,{cst:_c.program(),lexErrors:e.errors,parseErrors:_c.errors}}(t);return{ast:e.lexErrors.length>0||e.parseErrors.length>0||!e.cst?null:(n=e.cst,n?Hc.visit(n):null),lexErrors:e.lexErrors,parseErrors:e.parseErrors};var n}function Xc(t){return`(${t.params.map(t=>t.name).join(", ")})`}function qc(t){return`(${t.params.map(t=>t.name).join(", ")}) → ${t.outputs.map(t=>t.name).join(", ")}`}function Zc(t){switch(t){case"fai":return r.jsx(s,{className:"h-3.5 w-3.5 text-purple-500 dark:text-purple-400"});case"func":return r.jsx(u,{className:"h-3.5 w-3.5 text-blue-500 dark:text-blue-400"});case"const":return r.jsx(l,{className:"h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400"});case"var":return r.jsx(d,{className:"h-3.5 w-3.5 text-amber-500 dark:text-amber-400"});case"export":return r.jsx(h,{className:"h-3.5 w-3.5 text-pink-500 dark:text-pink-400"});case"import":return r.jsx(h,{className:"h-3.5 w-3.5 rotate-180 text-cyan-500 dark:text-cyan-400"})}}function Qc({source:t,parseResult:e,onJump:n}){const s=i.useMemo(()=>{const n=e??Yc(t);return n.ast&&0===n.lexErrors.length&&0===n.parseErrors.length?function(t){const e=[];for(const n of t.items)switch(n.kind){case"Import":{const t=n;e.push({kind:"import",name:t.source,line:t.range.startLine,column:t.range.startColumn});break}case"ConstDecl":{const t=n;e.push({kind:"const",name:t.name,line:t.range.startLine,column:t.range.startColumn});break}case"VarDecl":{const t=n;e.push({kind:"var",name:t.name,line:t.range.startLine,column:t.range.startColumn});break}case"FuncDecl":{const t=n;e.push({kind:"func",name:t.name,signature:Xc(t),line:t.range.startLine,column:t.range.startColumn});break}case"FaiDecl":{const t=n;e.push({kind:"fai",name:t.name,signature:qc(t),line:t.range.startLine,column:t.range.startColumn});break}case"ExportDecl":{const t=n.target;if("ExportNames"===t.kind)for(const n of t.specs)e.push({kind:"export",name:n.alias??n.name,line:n.range.startLine,column:n.range.startColumn});else if("FuncDecl"===t.kind){const n=t;e.push({kind:"func",name:`export ${n.name}`,signature:Xc(n),line:n.range.startLine,column:n.range.startColumn})}else if("FaiDecl"===t.kind){const n=t;e.push({kind:"fai",name:`export ${n.name}`,signature:qc(n),line:n.range.startLine,column:n.range.startColumn})}break}}return e}(n.ast):function(t){const e=[],n=t.split(/\r?\n/),i=/^(import|export|const|var|fai|func)\s+([A-Za-z_]\w*)/;for(let r=0;r<n.length;r++){const t=i.exec(n[r]??"");if(!t)continue;const s=t[1],o=t[2]??"";o&&e.push({kind:s,name:o,line:r+1,column:1})}return e}(t)},[t,e]);return r.jsxs("div",{className:"h-full flex flex-col bg-muted/30",children:[r.jsxs("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b border-border",children:["大纲 (",s.length,")"]}),r.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[0===s.length&&r.jsx("p",{className:"px-3 py-4 text-xs text-muted-foreground text-center",children:"(空)"}),s.map((t,e)=>r.jsxs("button",{className:"\n w-full flex items-center gap-2 px-3 py-1.5\n text-xs text-left hover:bg-accent\n transition-colors\n ",onClick:()=>n(t.line,t.column),title:`${t.kind} ${t.name}${t.signature??""} (行 ${t.line})`,children:[Zc(t.kind),r.jsxs("span",{className:"font-mono truncate flex-1",children:[t.name,t.signature&&r.jsx("span",{className:"text-muted-foreground ml-1",children:t.signature})]}),r.jsx("span",{className:"text-muted-foreground tabular-nums",children:t.line})]},`${t.kind}-${t.name}-${e}`))]})]})}const Jc=["import","export","from","as","const","var","let","func","fai","return","if","else","for","in","while","break","continue","try","catch"],th=["int","float","bool","string","prompt","any","enum","array","object"],eh=["true","false","null"],nh=["__ccweb_ask_user","len","push","concat","range","log","JSON","math","str"];let ih=!1;const rh=i.lazy(async()=>{const[t,e]=await Promise.all([c(()=>import("./editor.main-DxKJbewY.js").then(t=>t.e),__vite__mapDeps([0,1,2,3])),c(()=>import("./index-BWlHiqbD.js"),__vite__mapDeps([4,1,2]))]),n=t.default??t;return e.loader.config({monaco:n}),{default:e.default}});function sh(t,e){var n,i,r,s;const o=[];for(const a of t){const t=a,e=t.line??1,n=t.column??1,i=t.length??1;o.push({line:e,column:n,endLine:e,endColumn:n+i,message:t.message??"lex error"})}for(const a of e){const t=a,e=(null==(n=t.token)?void 0:n.startLine)??1,c=(null==(i=t.token)?void 0:i.startColumn)??1,h=(null==(s=null==(r=t.token)?void 0:r.image)?void 0:s.length)??1;o.push({line:e,column:c,endLine:e,endColumn:c+h,message:`${t.name??"ParseError"}: ${t.message??""}`})}return o}function oh({filename:t,initialSource:e,onCancel:n,onSave:s}){const{resolved:c}=o(),[h,u]=i.useState(e),[l,d]=i.useState(!1),[p,f]=i.useState(()=>Yc(e)),m=i.useMemo(()=>sh(p.lexErrors,p.parseErrors),[p]),E=i.useRef(null),g=i.useRef(null),T=i.useRef(null),S=i.useCallback(t=>{try{const e=Yc(t);f(e);const n=sh(e.lexErrors,e.parseErrors),i=g.current,r=E.current;if(i&&r){const t=r.getModel();t&&i.editor.setModelMarkers(t,"train-parser",n.map(t=>({startLineNumber:t.line,startColumn:t.column,endLineNumber:t.endLine,endColumn:t.endColumn,message:t.message,severity:i.MarkerSeverity.Error})))}}catch(e){f({ast:null,lexErrors:[],parseErrors:[{message:`parser crashed: ${e.message}`,name:"ParserCrash",token:{startLine:1,startColumn:1,image:""}}]})}},[]);i.useEffect(()=>(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(h),250),()=>{T.current&&clearTimeout(T.current)}),[h,S]);const L=i.useCallback(async()=>{if(!l){d(!0);try{await s(h)}finally{d(!1)}}},[l,h,s]);return r.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("span",{className:"text-sm font-mono text-muted-foreground truncate flex-1",children:t}),m.length>0?r.jsxs("span",{className:"text-xs text-red-600 dark:text-red-400",children:[m.length," 个问题"]}):r.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"语法正确"}),r.jsx(a,{onClick:n,variant:"ghost",size:"sm",children:"取消"}),r.jsx(a,{onClick:L,size:"sm",disabled:l,children:l?"保存中…":"保存"})]}),r.jsxs("div",{className:"flex gap-2 flex-1 min-h-0",children:[r.jsx("div",{className:"flex-1 min-w-0 rounded-md border border-border overflow-hidden",children:r.jsx(i.Suspense,{fallback:r.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"加载编辑器…"}),children:r.jsx(rh,{height:"100%",defaultLanguage:"train",language:"train",value:h,onChange:t=>u(t??""),onMount:(t,e)=>{E.current=t,g.current=e,function(t){ih||(ih=!0,t.languages.register({id:"train",extensions:[".tr"],aliases:["train","tr"]}),t.languages.setLanguageConfiguration("train",{comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}]}),t.languages.setMonarchTokensProvider("train",{defaultToken:"",keywords:Jc,typeKeywords:th,literals:eh,builtins:nh,operators:["=","==","!=","<=",">=","<",">","&&","||","+","-","*","/","%","!","?","??","->","=>","+=","-=","*=","/=","%="],symbols:/[=<>!?:&|+\-*\/%~^@]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4})/,tokenizer:{root:[[/@[A-Za-z_][\w.\-]*/,"annotation"],[/[A-Za-z_]\w*/,{cases:{"@keywords":"keyword","@typeKeywords":"type","@literals":"keyword.constant","@builtins":"predefined","@default":"identifier"}}],{include:"@whitespace"},[/\d*\.\d+([eE][\-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F_]+/,"number.hex"],[/0[bB][01_]+/,"number.binary"],[/0[oO][0-7_]+/,"number.octal"],[/\d+([eE][\-+]?\d+)?/,"number"],[/"([^"\\$]|\\.|\$(?!\{))*"/,"string"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/[,;.]/,"delimiter"]],string:[[/[^\\"$]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/\$\{/,{token:"string.interpolation.open",bracket:"@open",next:"@interpolation"}],[/\$/,"string"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]],interpolation:[[/\}/,{token:"string.interpolation.close",bracket:"@close",next:"@pop"}],{include:"root"}],whitespace:[[/[ \t\r\n]+/,""],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]]}}))}(e),e.editor.setModelLanguage(t.getModel(),"train"),t.addCommand(e.KeyMod.CtrlCmd|e.KeyCode.KeyS,()=>{L()}),S(h)},theme:"dark"===c?"vs-dark":"vs",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",tabSize:2,insertSpaces:!0,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})})}),r.jsx("div",{className:"w-56 flex-shrink-0 rounded-md border border-border overflow-hidden",children:r.jsx(Qc,{parseResult:p,source:h,onJump:(t,e)=>{const n=E.current;n&&(n.revealLineInCenter(t),n.setPosition({lineNumber:t,column:e}),n.focus())}})})]}),r.jsx("p",{className:"text-xs text-muted-foreground flex-shrink-0",children:".tr 源码 · train-lang DSL · Cmd/Ctrl+S 保存 · 实时语法检查 + AST 大纲"})]})}export{oh as TrackEditor};
14
+ */var p="object"==typeof global&&global&&global.Object===Object&&global,f="object"==typeof self&&self&&self.Object===Object&&self,m=p||f||Function("return this")(),E=m.Symbol,g=Object.prototype,T=g.hasOwnProperty,S=g.toString,L=E?E.toStringTag:void 0;var O=Object.prototype.toString;var R=E?E.toStringTag:void 0;function A(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":R&&R in Object(t)?function(t){var e=T.call(t,L),n=t[L];try{t[L]=void 0;var r=!0}catch(s){}var i=S.call(t);return r&&(e?t[L]=n:delete t[L]),i}(t):function(t){return O.call(t)}(t)}function v(t){return null!=t&&"object"==typeof t}function y(t){return"symbol"==typeof t||v(t)&&"[object Symbol]"==A(t)}function N(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var I=Array.isArray,C=E?E.prototype:void 0,x=C?C.toString:void 0;function k(t){if("string"==typeof t)return t;if(I(t))return N(t,k)+"";if(y(t))return x?x.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}var _=/\s/;var U=/^\s+/;function b(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&_.test(t.charAt(e)););return e}(t)+1).replace(U,""):t}function M(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}var P=/^[-+]0x[0-9a-f]+$/i,w=/^0b[01]+$/i,D=/^0o[0-7]+$/i,F=parseInt;var B=1/0;function j(t){return t?(t=function(t){if("number"==typeof t)return t;if(y(t))return NaN;if(M(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=M(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=b(t);var n=w.test(t);return n||D.test(t)?F(t.slice(2),n?2:8):P.test(t)?NaN:+t}(t))===B||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function $(t){var e=j(t),n=e%1;return e==e?n?e-n:e:0}function K(t){return t}function G(t){if(!M(t))return!1;var e=A(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var z,W=m["__core-js_shared__"],V=(z=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"";var H=Function.prototype.toString;function Y(t){if(null!=t){try{return H.call(t)}catch(e){}try{return t+""}catch(e){}}return""}var X=/^\[object .+?Constructor\]$/,q=Function.prototype,Z=Object.prototype,Q=q.toString,J=Z.hasOwnProperty,tt=RegExp("^"+Q.call(J).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function et(t){return!(!M(t)||(e=t,V&&V in e))&&(G(t)?tt:X).test(Y(t));var e}function nt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return et(n)?n:void 0}var rt=nt(m,"WeakMap"),it=Object.create,st=function(){function t(){}return function(e){if(!M(e))return{};if(it)return it(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function ot(){}var at=Date.now;var ct,ht,ut,lt=function(){try{var t=nt(Object,"defineProperty");return t({},"",{}),t}catch(e){}}(),dt=lt?function(t,e){return lt(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:K,pt=(ct=dt,ht=0,ut=0,function(){var t=at(),e=16-(t-ut);if(ut=t,e>0){if(++ht>=800)return arguments[0]}else ht=0;return ct.apply(void 0,arguments)});function ft(t,e){for(var n=-1,r=null==t?0:t.length;++n<r&&!1!==e(t[n],n,t););return t}function mt(t,e,n,r){for(var i=t.length,s=n+-1;++s<i;)if(e(t[s],s,t))return s;return-1}function Et(t){return t!=t}function gt(t,e,n){return e==e?function(t,e,n){for(var r=n-1,i=t.length;++r<i;)if(t[r]===e)return r;return-1}(t,e,n):mt(t,Et,n)}function Tt(t,e){return!!(null==t?0:t.length)&&gt(t,e,0)>-1}var St=/^(?:0|[1-9]\d*)$/;function Lt(t,e){var n=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==n||"symbol"!=n&&St.test(t))&&t>-1&&t%1==0&&t<e}function Ot(t,e,n){"__proto__"==e&&lt?lt(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function Rt(t,e){return t===e||t!=t&&e!=e}var At=Object.prototype.hasOwnProperty;function vt(t,e,n){var r=t[e];At.call(t,e)&&Rt(r,n)&&(void 0!==n||e in t)||Ot(t,e,n)}function yt(t,e,n,r){var i=!n;n||(n={});for(var s=-1,o=e.length;++s<o;){var a=e[s],c=void 0;void 0===c&&(c=t[a]),i?Ot(n,a,c):vt(n,a,c)}return n}var Nt=Math.max;function It(t,e){return pt(function(t,e,n){return e=Nt(void 0===e?t.length-1:e,0),function(){for(var r=arguments,i=-1,s=Nt(r.length-e,0),o=Array(s);++i<s;)o[i]=r[e+i];i=-1;for(var a=Array(e+1);++i<e;)a[i]=r[i];return a[e]=n(o),function(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}(t,this,a)}}(t,e,K),t+"")}function Ct(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function xt(t){return null!=t&&Ct(t.length)&&!G(t)}function kt(t,e,n){if(!M(n))return!1;var r=typeof e;return!!("number"==r?xt(n)&&Lt(e,n.length):"string"==r&&e in n)&&Rt(n[e],t)}var _t=Object.prototype;function Ut(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_t)}function bt(t){return v(t)&&"[object Arguments]"==A(t)}var Mt=Object.prototype,Pt=Mt.hasOwnProperty,wt=Mt.propertyIsEnumerable,Dt=bt(function(){return arguments}())?bt:function(t){return v(t)&&Pt.call(t,"callee")&&!wt.call(t,"callee")};var Ft="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bt=Ft&&"object"==typeof module&&module&&!module.nodeType&&module,jt=Bt&&Bt.exports===Ft?m.Buffer:void 0,$t=(jt?jt.isBuffer:void 0)||function(){return!1},Kt={};function Gt(t){return function(e){return t(e)}}Kt["[object Float32Array]"]=Kt["[object Float64Array]"]=Kt["[object Int8Array]"]=Kt["[object Int16Array]"]=Kt["[object Int32Array]"]=Kt["[object Uint8Array]"]=Kt["[object Uint8ClampedArray]"]=Kt["[object Uint16Array]"]=Kt["[object Uint32Array]"]=!0,Kt["[object Arguments]"]=Kt["[object Array]"]=Kt["[object ArrayBuffer]"]=Kt["[object Boolean]"]=Kt["[object DataView]"]=Kt["[object Date]"]=Kt["[object Error]"]=Kt["[object Function]"]=Kt["[object Map]"]=Kt["[object Number]"]=Kt["[object Object]"]=Kt["[object RegExp]"]=Kt["[object Set]"]=Kt["[object String]"]=Kt["[object WeakMap]"]=!1;var zt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Wt=zt&&"object"==typeof module&&module&&!module.nodeType&&module,Vt=Wt&&Wt.exports===zt&&p.process,Ht=function(){try{var t=Wt&&Wt.require&&Wt.require("util").types;return t||Vt&&Vt.binding&&Vt.binding("util")}catch(e){}}(),Yt=Ht&&Ht.isTypedArray,Xt=Yt?Gt(Yt):function(t){return v(t)&&Ct(t.length)&&!!Kt[A(t)]},qt=Object.prototype.hasOwnProperty;function Zt(t,e){var n=I(t),r=!n&&Dt(t),i=!n&&!r&&$t(t),s=!n&&!r&&!i&&Xt(t),o=n||r||i||s,a=o?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=a.length;for(var h in t)!e&&!qt.call(t,h)||o&&("length"==h||i&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Lt(h,c))||a.push(h);return a}function Qt(t,e){return function(n){return t(e(n))}}var Jt=Qt(Object.keys,Object),te=Object.prototype.hasOwnProperty;function ee(t){if(!Ut(t))return Jt(t);var e=[];for(var n in Object(t))te.call(t,n)&&"constructor"!=n&&e.push(n);return e}function ne(t){return xt(t)?Zt(t):ee(t)}var re,ie=Object.prototype.hasOwnProperty,se=(re=function(t,e){if(Ut(e)||xt(e))yt(e,ne(e),t);else for(var n in e)ie.call(e,n)&&vt(t,n,e[n])},It(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,s=r>2?e[2]:void 0;for(i=re.length>3&&"function"==typeof i?(r--,i):void 0,s&&kt(e[0],e[1],s)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var o=e[n];o&&re(t,o,n,i)}return t}));var oe=Object.prototype.hasOwnProperty;function ae(t){if(!M(t))return function(t){var e=[];if(null!=t)for(var n in Object(t))e.push(n);return e}(t);var e=Ut(t),n=[];for(var r in t)("constructor"!=r||!e&&oe.call(t,r))&&n.push(r);return n}function ce(t){return xt(t)?Zt(t,!0):ae(t)}var he=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ue=/^\w*$/;function le(t,e){if(I(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!y(t))||(ue.test(t)||!he.test(t)||null!=e&&t in Object(e))}var de=nt(Object,"create");var pe=Object.prototype.hasOwnProperty;var fe=Object.prototype.hasOwnProperty;function me(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Ee(t,e){for(var n=t.length;n--;)if(Rt(t[n][0],e))return n;return-1}me.prototype.clear=function(){this.__data__=de?de(null):{},this.size=0},me.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},me.prototype.get=function(t){var e=this.__data__;if(de){var n=e[t];return"__lodash_hash_undefined__"===n?void 0:n}return pe.call(e,t)?e[t]:void 0},me.prototype.has=function(t){var e=this.__data__;return de?void 0!==e[t]:fe.call(e,t)},me.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=de&&void 0===e?"__lodash_hash_undefined__":e,this};var ge=Array.prototype.splice;function Te(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Te.prototype.clear=function(){this.__data__=[],this.size=0},Te.prototype.delete=function(t){var e=this.__data__,n=Ee(e,t);return!(n<0)&&(n==e.length-1?e.pop():ge.call(e,n,1),--this.size,!0)},Te.prototype.get=function(t){var e=this.__data__,n=Ee(e,t);return n<0?void 0:e[n][1]},Te.prototype.has=function(t){return Ee(this.__data__,t)>-1},Te.prototype.set=function(t,e){var n=this.__data__,r=Ee(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var Se=nt(m,"Map");function Le(t,e){var n,r,i=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof e?"string":"hash"]:i.map}function Oe(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Oe.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(Se||Te),string:new me}},Oe.prototype.delete=function(t){var e=Le(this,t).delete(t);return this.size-=e?1:0,e},Oe.prototype.get=function(t){return Le(this,t).get(t)},Oe.prototype.has=function(t){return Le(this,t).has(t)},Oe.prototype.set=function(t,e){var n=Le(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function Re(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var o=t.apply(this,r);return n.cache=s.set(i,o)||s,o};return n.cache=new(Re.Cache||Oe),n}Re.Cache=Oe;var Ae=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ve=/\\(\\)?/g,ye=function(t){var e=Re(t,function(t){return 500===n.size&&n.clear(),t}),n=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Ae,function(t,n,r,i){e.push(r?i.replace(ve,"$1"):n||t)}),e});function Ne(t,e){return I(t)?t:le(t,e)?[t]:ye(function(t){return null==t?"":k(t)}(t))}function Ie(t){if("string"==typeof t||y(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ce(t,e){for(var n=0,r=(e=Ne(e,t)).length;null!=t&&n<r;)t=t[Ie(e[n++])];return n&&n==r?t:void 0}function xe(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var ke=E?E.isConcatSpreadable:void 0;function _e(t){return I(t)||Dt(t)||!!(ke&&t&&t[ke])}function Ue(t,e,n,r,i){var s=-1,o=t.length;for(n||(n=_e),i||(i=[]);++s<o;){var a=t[s];n(a)?xe(i,a):r||(i[i.length]=a)}return i}function be(t){return(null==t?0:t.length)?Ue(t):[]}var Me=Qt(Object.getPrototypeOf,Object);function Pe(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(i);++r<i;)s[r]=t[r+e];return s}function we(t,e,n,r){var i=-1,s=null==t?0:t.length;for(r&&s&&(n=t[++i]);++i<s;)n=e(n,t[i],i,t);return n}function De(t){var e=this.__data__=new Te(t);this.size=e.size}De.prototype.clear=function(){this.__data__=new Te,this.size=0},De.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},De.prototype.get=function(t){return this.__data__.get(t)},De.prototype.has=function(t){return this.__data__.has(t)},De.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Te){var r=n.__data__;if(!Se||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Oe(r)}return n.set(t,e),this.size=n.size,this};var Fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Be=Fe&&"object"==typeof module&&module&&!module.nodeType&&module,je=Be&&Be.exports===Fe?m.Buffer:void 0,$e=je?je.allocUnsafe:void 0;function Ke(t,e){for(var n=-1,r=null==t?0:t.length,i=0,s=[];++n<r;){var o=t[n];e(o,n,t)&&(s[i++]=o)}return s}function Ge(){return[]}var ze=Object.prototype.propertyIsEnumerable,We=Object.getOwnPropertySymbols,Ve=We?function(t){return null==t?[]:(t=Object(t),Ke(We(t),function(e){return ze.call(t,e)}))}:Ge;var He=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)xe(e,Ve(t)),t=Me(t);return e}:Ge;function Ye(t,e,n){var r=e(t);return I(t)?r:xe(r,n(t))}function Xe(t){return Ye(t,ne,Ve)}var qe=nt(m,"DataView"),Ze=nt(m,"Promise"),Qe=nt(m,"Set"),Je="[object Map]",tn="[object Promise]",en="[object Set]",nn="[object WeakMap]",rn="[object DataView]",sn=Y(qe),on=Y(Se),an=Y(Ze),cn=Y(Qe),hn=Y(rt),un=A;(qe&&un(new qe(new ArrayBuffer(1)))!=rn||Se&&un(new Se)!=Je||Ze&&un(Ze.resolve())!=tn||Qe&&un(new Qe)!=en||rt&&un(new rt)!=nn)&&(un=function(t){var e=A(t),n="[object Object]"==e?t.constructor:void 0,r=n?Y(n):"";if(r)switch(r){case sn:return rn;case on:return Je;case an:return tn;case cn:return en;case hn:return nn}return e});var ln=Object.prototype.hasOwnProperty;var dn=m.Uint8Array;var pn=/\w*$/;var fn=E?E.prototype:void 0,mn=fn?fn.valueOf:void 0;function En(t,e,n){var r,i,s,o,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(o=t).constructor(o.byteLength),new dn(a).set(new dn(o)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return s=(i=t).buffer,new i.constructor(s,i.byteOffset,i.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t){var e=t.buffer;return new t.constructor(e,t.byteOffset,t.length)}(t);case"[object Map]":case"[object Set]":return new c;case"[object Number]":case"[object String]":return new c(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,pn.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return r=t,mn?Object(mn.call(r)):{}}}var gn=Ht&&Ht.isMap,Tn=gn?Gt(gn):function(t){return v(t)&&"[object Map]"==un(t)};var Sn=Ht&&Ht.isSet,Ln=Sn?Gt(Sn):function(t){return v(t)&&"[object Set]"==un(t)},On="[object Arguments]",Rn="[object Function]",An="[object Object]",vn={};function yn(t,e,n,r,i,s){var o,a=2&e;if(void 0!==o)return o;if(!M(t))return t;var c=I(t);if(c)return o=function(t){var e=t.length,n=new t.constructor(e);return e&&"string"==typeof t[0]&&ln.call(t,"index")&&(n.index=t.index,n.input=t.input),n}(t),function(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}(t,o);var h=un(t),u=h==Rn||"[object GeneratorFunction]"==h;if($t(t))return function(t){var e=t.length,n=$e?$e(e):new t.constructor(e);return t.copy(n),n}(t);if(h==An||h==On||u&&!i)return o=u?{}:function(t){return"function"!=typeof t.constructor||Ut(t)?{}:st(Me(t))}(t),a?function(t,e){return yt(t,He(t),e)}(t,function(t,e){return t&&yt(e,ce(e),t)}(o,t)):function(t,e){return yt(t,Ve(t),e)}(t,function(t,e){return t&&yt(e,ne(e),t)}(o,t));if(!vn[h])return i?t:{};o=En(t,h),s||(s=new De);var l=s.get(t);if(l)return l;s.set(t,o),Ln(t)?t.forEach(function(r){o.add(yn(r,e,n,r,t,s))}):Tn(t)&&t.forEach(function(r,i){o.set(i,yn(r,e,n,i,t,s))});var d=c?void 0:Xe(t);return ft(d||t,function(r,i){d&&(r=t[i=r]),vt(o,i,yn(r,e,n,i,t,s))}),o}vn[On]=vn["[object Array]"]=vn["[object ArrayBuffer]"]=vn["[object DataView]"]=vn["[object Boolean]"]=vn["[object Date]"]=vn["[object Float32Array]"]=vn["[object Float64Array]"]=vn["[object Int8Array]"]=vn["[object Int16Array]"]=vn["[object Int32Array]"]=vn["[object Map]"]=vn["[object Number]"]=vn[An]=vn["[object RegExp]"]=vn["[object Set]"]=vn["[object String]"]=vn["[object Symbol]"]=vn["[object Uint8Array]"]=vn["[object Uint8ClampedArray]"]=vn["[object Uint16Array]"]=vn["[object Uint32Array]"]=!0,vn["[object Error]"]=vn[Rn]=vn["[object WeakMap]"]=!1;function Nn(t){return yn(t,4)}function In(t){for(var e=-1,n=null==t?0:t.length,r=0,i=[];++e<n;){var s=t[e];s&&(i[r++]=s)}return i}function Cn(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Oe;++e<n;)this.add(t[e])}function xn(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function kn(t,e){return t.has(e)}Cn.prototype.add=Cn.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Cn.prototype.has=function(t){return this.__data__.has(t)};function _n(t,e,n,r,i,s){var o=1&n,a=t.length,c=e.length;if(a!=c&&!(o&&c>a))return!1;var h=s.get(t),u=s.get(e);if(h&&u)return h==e&&u==t;var l=-1,d=!0,p=2&n?new Cn:void 0;for(s.set(t,e),s.set(e,t);++l<a;){var f=t[l],m=e[l];if(r)var E=o?r(m,f,l,e,t,s):r(f,m,l,t,e,s);if(void 0!==E){if(E)continue;d=!1;break}if(p){if(!xn(e,function(t,e){if(!kn(p,e)&&(f===t||i(f,t,n,r,s)))return p.push(e)})){d=!1;break}}else if(f!==m&&!i(f,m,n,r,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function Un(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function bn(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var Mn=E?E.prototype:void 0,Pn=Mn?Mn.valueOf:void 0;var wn=Object.prototype.hasOwnProperty;var Dn="[object Arguments]",Fn="[object Array]",Bn="[object Object]",jn=Object.prototype.hasOwnProperty;function $n(t,e,n,r,i,s){var o=I(t),a=I(e),c=o?Fn:un(t),h=a?Fn:un(e),u=(c=c==Dn?Bn:c)==Bn,l=(h=h==Dn?Bn:h)==Bn,d=c==h;if(d&&$t(t)){if(!$t(e))return!1;o=!0,u=!1}if(d&&!u)return s||(s=new De),o||Xt(t)?_n(t,e,n,r,i,s):function(t,e,n,r,i,s,o){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!s(new dn(t),new dn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Rt(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Un;case"[object Set]":var c=1&r;if(a||(a=bn),t.size!=e.size&&!c)return!1;var h=o.get(t);if(h)return h==e;r|=2,o.set(t,e);var u=_n(a(t),a(e),r,i,s,o);return o.delete(t),u;case"[object Symbol]":if(Pn)return Pn.call(t)==Pn.call(e)}return!1}(t,e,c,n,r,i,s);if(!(1&n)){var p=u&&jn.call(t,"__wrapped__"),f=l&&jn.call(e,"__wrapped__");if(p||f){var m=p?t.value():t,E=f?e.value():e;return s||(s=new De),i(m,E,n,r,s)}}return!!d&&(s||(s=new De),function(t,e,n,r,i,s){var o=1&n,a=Xe(t),c=a.length;if(c!=Xe(e).length&&!o)return!1;for(var h=c;h--;){var u=a[h];if(!(o?u in e:wn.call(e,u)))return!1}var l=s.get(t),d=s.get(e);if(l&&d)return l==e&&d==t;var p=!0;s.set(t,e),s.set(e,t);for(var f=o;++h<c;){var m=t[u=a[h]],E=e[u];if(r)var g=o?r(E,m,u,e,t,s):r(m,E,u,t,e,s);if(!(void 0===g?m===E||i(m,E,n,r,s):g)){p=!1;break}f||(f="constructor"==u)}if(p&&!f){var T=t.constructor,S=e.constructor;T==S||!("constructor"in t)||!("constructor"in e)||"function"==typeof T&&T instanceof T&&"function"==typeof S&&S instanceof S||(p=!1)}return s.delete(t),s.delete(e),p}(t,e,n,r,i,s))}function Kn(t,e,n,r,i){return t===e||(null==t||null==e||!v(t)&&!v(e)?t!=t&&e!=e:$n(t,e,n,r,Kn,i))}function Gn(t){return t==t&&!M(t)}function zn(t,e){return function(n){return null!=n&&(n[t]===e&&(void 0!==e||t in Object(n)))}}function Wn(t){var e=function(t){for(var e=ne(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Gn(i)]}return e}(t);return 1==e.length&&e[0][2]?zn(e[0][0],e[0][1]):function(n){return n===t||function(t,e,n,r){var i=n.length,s=i;if(null==t)return!s;for(t=Object(t);i--;){var o=n[i];if(o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){var a=(o=n[i])[0],c=t[a],h=o[1];if(o[2]){if(void 0===c&&!(a in t))return!1}else if(!Kn(h,c,3,r,new De))return!1}return!0}(n,0,e)}}function Vn(t,e){return null!=t&&e in Object(t)}function Hn(t,e,n){for(var r=-1,i=(e=Ne(e,t)).length,s=!1;++r<i;){var o=Ie(e[r]);if(!(s=null!=t&&n(t,o)))break;t=t[o]}return s||++r!=i?s:!!(i=null==t?0:t.length)&&Ct(i)&&Lt(o,i)&&(I(t)||Dt(t))}function Yn(t,e){return le(t)&&Gn(e)?zn(Ie(t),e):function(n){var r=function(t,e,n){var r=null==t?void 0:Ce(t,e);return void 0===r?n:r}(n,t);return void 0===r&&r===e?function(t,e){return null!=t&&Hn(t,e,Vn)}(n,t):Kn(e,r,3)}}function Xn(t){return le(t)?(e=Ie(t),function(t){return null==t?void 0:t[e]}):function(t){return function(e){return Ce(e,t)}}(t);var e}function qn(t){return"function"==typeof t?t:null==t?K:"object"==typeof t?I(t)?Yn(t[0],t[1]):Wn(t):Xn(t)}function Zn(t,e,n,r){for(var i=-1,s=null==t?0:t.length;++i<s;){var o=t[i];e(r,o,n(o),t)}return r}var Qn=function(t,e,n){for(var r=-1,i=Object(t),s=n(t),o=s.length;o--;){var a=s[++r];if(!1===e(i[a],a,i))break}return t};var Jn,tr=(Jn=function(t,e){return t&&Qn(t,e,ne)},function(t,e){if(null==t)return t;if(!xt(t))return Jn(t,e);for(var n=t.length,r=-1,i=Object(t);++r<n&&!1!==e(i[r],r,i););return t});function er(t,e,n,r){return tr(t,function(t,i,s){e(r,t,n(t),s)}),r}var nr=Object.prototype,rr=nr.hasOwnProperty,ir=It(function(t,e){t=Object(t);var n=-1,r=e.length,i=r>2?e[2]:void 0;for(i&&kt(e[0],e[1],i)&&(r=1);++n<r;)for(var s=e[n],o=ce(s),a=-1,c=o.length;++a<c;){var h=o[a],u=t[h];(void 0===u||Rt(u,nr[h])&&!rr.call(t,h))&&(t[h]=s[h])}return t});function sr(t){return v(t)&&xt(t)}var or=It(function(t,e){return sr(t)?function(t,e,n,r){var i=-1,s=Tt,o=!0,a=t.length,c=[],h=e.length;if(!a)return c;e.length>=200&&(s=kn,o=!1,e=new Cn(e));t:for(;++i<a;){var u=t[i],l=u;if(u=0!==u?u:0,o&&l==l){for(var d=h;d--;)if(e[d]===l)continue t;c.push(u)}else s(e,l,r)||c.push(u)}return c}(t,Ue(e,0,sr,!0)):[]});function ar(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}function cr(t,e,n){var r=null==t?0:t.length;return r?Pe(t,(e=void 0===e?1:$(e))<0?0:e,r):[]}function hr(t,e,n){var r=null==t?0:t.length;return r?Pe(t,0,(e=r-(e=void 0===e?1:$(e)))<0?0:e):[]}function ur(t,e){var n;return(I(t)?ft:tr)(t,"function"==typeof(n=e)?n:K)}function lr(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function dr(t,e){var n=!0;return tr(t,function(t,r,i){return n=!!e(t,r,i)}),n}function pr(t,e,n){return(I(t)?lr:dr)(t,qn(e))}function fr(t,e){var n=[];return tr(t,function(t,r,i){e(t,r,i)&&n.push(t)}),n}function mr(t,e){return(I(t)?Ke:fr)(t,qn(e))}var Er=Math.max;var gr,Tr=(gr=function(t,e,n){var r=null==t?0:t.length;if(!r)return-1;var i=null==n?0:$(n);return i<0&&(i=Er(r+i,0)),mt(t,qn(e),i)},function(t,e,n){var r=Object(t);if(!xt(t)){var i=qn(e);t=ne(t),e=function(t){return i(r[t],t,r)}}var s=gr(t,e,n);return s>-1?r[i?t[s]:s]:void 0});function Sr(t){return t&&t.length?t[0]:void 0}function Lr(t,e){var n=-1,r=xt(t)?Array(t.length):[];return tr(t,function(t,i,s){r[++n]=e(t,i,s)}),r}function Or(t,e){return(I(t)?N:Lr)(t,qn(e))}function Rr(t,e){return Ue(Or(t,e))}var Ar,vr,yr=Object.prototype.hasOwnProperty,Nr=(Ar=function(t,e,n){yr.call(t,n)?t[n].push(e):Ot(t,n,[e])},function(t,e){var n=I(t)?Zn:er,r=vr?vr():{};return n(t,Ar,qn(e),r)}),Ir=Object.prototype.hasOwnProperty;function Cr(t,e){return null!=t&&Ir.call(t,e)}function xr(t,e){return null!=t&&Hn(t,e,Cr)}function kr(t){return"string"==typeof t||!I(t)&&v(t)&&"[object String]"==A(t)}function _r(t){return null==t?[]:function(t,e){return N(e,function(e){return t[e]})}(t,ne(t))}var Ur=Math.max;function br(t,e,n,r){t=xt(t)?t:_r(t),n=n?$(n):0;var i=t.length;return n<0&&(n=Ur(i+n,0)),kr(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&gt(t,e,n)>-1}function Mr(t,e,n){if(!(null==t?0:t.length))return-1;return gt(t,e,0)}var Pr=Object.prototype.hasOwnProperty;function wr(t){if(null==t)return!0;if(xt(t)&&(I(t)||"string"==typeof t||"function"==typeof t.splice||$t(t)||Xt(t)||Dt(t)))return!t.length;var e=un(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Ut(t))return!ee(t).length;for(var n in t)if(Pr.call(t,n))return!1;return!0}var Dr=Ht&&Ht.isRegExp,Fr=Dr?Gt(Dr):function(t){return v(t)&&"[object RegExp]"==A(t)};function Br(t){return void 0===t}function jr(t,e,n,r){if(!M(t))return t;for(var i=-1,s=(e=Ne(e,t)).length,o=s-1,a=t;null!=a&&++i<s;){var c=Ie(e[i]),h=n;if("__proto__"===c||"constructor"===c||"prototype"===c)return t;if(i!=o){var u=a[c];void 0===(h=void 0)&&(h=M(u)?u:Lt(e[i+1])?[]:{})}vt(a,c,h),a=a[c]}return t}function $r(t,e){if(null==t)return{};var n=N(function(t){return Ye(t,ce,He)}(t),function(t){return[t]});return e=qn(e),function(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var o=e[r],a=Ce(t,o);n(a,o)&&jr(s,Ne(o,t),a)}return s}(t,n,function(t,n){return e(t,n[0])})}function Kr(t,e,n,r,i){return i(t,function(t,i,s){n=r?(r=!1,t):e(n,t,i,s)}),n}function Gr(t,e,n){var r=I(t)?we:Kr,i=arguments.length<3;return r(t,qn(e),n,i,tr)}function zr(t,e){return(I(t)?Ke:fr)(t,function(t){if("function"!=typeof t)throw new TypeError("Expected a function");return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}(qn(e)))}function Wr(t,e){var n;return tr(t,function(t,r,i){return!(n=e(t,r,i))}),!!n}function Vr(t,e,n){return(I(t)?xn:Wr)(t,qn(e))}var Hr=Qe&&1/bn(new Qe([,-0]))[1]==1/0?function(t){return new Qe(t)}:ot;function Yr(t){return t&&t.length?function(t,e,n){var r=-1,i=Tt,s=t.length,o=!0,a=[],c=a;if(s>=200){var h=Hr(t);if(h)return bn(h);o=!1,i=kn,c=new Cn}else c=a;t:for(;++r<s;){var u=t[r],l=u;if(u=0!==u?u:0,o&&l==l){for(var d=c.length;d--;)if(c[d]===l)continue t;a.push(u)}else i(c,l,n)||(c!==a&&c.push(l),a.push(u))}return a}(t):[]}function Xr(t){console&&console.error&&console.error(`Error: ${t}`)}function qr(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function Zr(t){const e=(new Date).getTime(),n=t();return{time:(new Date).getTime()-e,value:n}}function Qr(t){function e(){}e.prototype=t;const n=new e;function r(){return typeof n.bar}return r(),r(),t}function Jr(t){return kr((e=t).LABEL)&&""!==e.LABEL?t.LABEL:t.name;var e}class ti{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){this._definition=t}accept(t){t.visit(this),ur(this.definition,e=>{e.accept(t)})}}class ei extends ti{constructor(t){super([]),this.idx=1,se(this,$r(t,t=>void 0!==t))}set definition(t){}get definition(){return void 0!==this.referencedRule?this.referencedRule.definition:[]}accept(t){t.visit(this)}}class ni extends ti{constructor(t){super(t.definition),this.orgText="",se(this,$r(t,t=>void 0!==t))}}class ri extends ti{constructor(t){super(t.definition),this.ignoreAmbiguities=!1,se(this,$r(t,t=>void 0!==t))}}class ii extends ti{constructor(t){super(t.definition),this.idx=1,se(this,$r(t,t=>void 0!==t))}}class si extends ti{constructor(t){super(t.definition),this.idx=1,se(this,$r(t,t=>void 0!==t))}}class oi extends ti{constructor(t){super(t.definition),this.idx=1,se(this,$r(t,t=>void 0!==t))}}class ai extends ti{constructor(t){super(t.definition),this.idx=1,se(this,$r(t,t=>void 0!==t))}}class ci extends ti{constructor(t){super(t.definition),this.idx=1,se(this,$r(t,t=>void 0!==t))}}class hi extends ti{get definition(){return this._definition}set definition(t){this._definition=t}constructor(t){super(t.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,se(this,$r(t,t=>void 0!==t))}}class ui{constructor(t){this.idx=1,se(this,$r(t,t=>void 0!==t))}accept(t){t.visit(this)}}function li(t){function e(t){return Or(t,li)}if(t instanceof ei){const e={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return kr(t.label)&&(e.label=t.label),e}if(t instanceof ri)return{type:"Alternative",definition:e(t.definition)};if(t instanceof ii)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof si)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof oi)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:li(new ui({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ci)return{type:"RepetitionWithSeparator",idx:t.idx,separator:li(new ui({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ai)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof hi)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof ui){const e={type:"Terminal",name:t.terminalType.name,label:Jr(t.terminalType),idx:t.idx};kr(t.label)&&(e.terminalLabel=t.label);const n=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(e.pattern=Fr(n)?n.source:n),e}if(t instanceof ni)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}class di{visit(t){const e=t;switch(e.constructor){case ei:return this.visitNonTerminal(e);case ri:return this.visitAlternative(e);case ii:return this.visitOption(e);case si:return this.visitRepetitionMandatory(e);case oi:return this.visitRepetitionMandatoryWithSeparator(e);case ci:return this.visitRepetitionWithSeparator(e);case ai:return this.visitRepetition(e);case hi:return this.visitAlternation(e);case ui:return this.visitTerminal(e);case ni:return this.visitRule(e);default:throw Error("non exhaustive match")}}visitNonTerminal(t){}visitAlternative(t){}visitOption(t){}visitRepetition(t){}visitRepetitionMandatory(t){}visitRepetitionMandatoryWithSeparator(t){}visitRepetitionWithSeparator(t){}visitAlternation(t){}visitTerminal(t){}visitRule(t){}}function pi(t,e=[]){return!!(t instanceof ii||t instanceof ai||t instanceof ci)||(t instanceof hi?Vr(t.definition,t=>pi(t,e)):!(t instanceof ei&&br(e,t))&&(t instanceof ti&&(t instanceof ei&&e.push(t),pr(t.definition,t=>pi(t,e)))))}function fi(t){if(t instanceof ei)return"SUBRULE";if(t instanceof ii)return"OPTION";if(t instanceof hi)return"OR";if(t instanceof si)return"AT_LEAST_ONE";if(t instanceof oi)return"AT_LEAST_ONE_SEP";if(t instanceof ci)return"MANY_SEP";if(t instanceof ai)return"MANY";if(t instanceof ui)return"CONSUME";throw Error("non exhaustive match")}class mi{walk(t,e=[]){ur(t.definition,(n,r)=>{const i=cr(t.definition,r+1);if(n instanceof ei)this.walkProdRef(n,i,e);else if(n instanceof ui)this.walkTerminal(n,i,e);else if(n instanceof ri)this.walkFlat(n,i,e);else if(n instanceof ii)this.walkOption(n,i,e);else if(n instanceof si)this.walkAtLeastOne(n,i,e);else if(n instanceof oi)this.walkAtLeastOneSep(n,i,e);else if(n instanceof ci)this.walkManySep(n,i,e);else if(n instanceof ai)this.walkMany(n,i,e);else{if(!(n instanceof hi))throw Error("non exhaustive match");this.walkOr(n,i,e)}})}walkTerminal(t,e,n){}walkProdRef(t,e,n){}walkFlat(t,e,n){const r=e.concat(n);this.walk(t,r)}walkOption(t,e,n){const r=e.concat(n);this.walk(t,r)}walkAtLeastOne(t,e,n){const r=[new ii({definition:t.definition})].concat(e,n);this.walk(t,r)}walkAtLeastOneSep(t,e,n){const r=Ei(t,e,n);this.walk(t,r)}walkMany(t,e,n){const r=[new ii({definition:t.definition})].concat(e,n);this.walk(t,r)}walkManySep(t,e,n){const r=Ei(t,e,n);this.walk(t,r)}walkOr(t,e,n){const r=e.concat(n);ur(t.definition,t=>{const e=new ri({definition:[t]});this.walk(e,r)})}}function Ei(t,e,n){return[new ii({definition:[new ui({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}function gi(t){if(t instanceof ei)return gi(t.referencedRule);if(t instanceof ui)return[t.terminalType];if(function(t){return t instanceof ri||t instanceof ii||t instanceof ai||t instanceof si||t instanceof oi||t instanceof ci||t instanceof ui||t instanceof ni}(t))return function(t){let e=[];const n=t.definition;let r,i=0,s=n.length>i,o=!0;for(;s&&o;)r=n[i],o=pi(r),e=e.concat(gi(r)),i+=1,s=n.length>i;return Yr(e)}(t);if(function(t){return t instanceof hi}(t))return function(t){const e=Or(t.definition,t=>gi(t));return Yr(be(e))}(t);throw Error("non exhaustive match")}const Ti="_~IN~_";class Si extends mi{constructor(t){super(),this.topProd=t,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(t,e,n){}walkProdRef(t,e,n){const r=(i=t.referencedRule,s=t.idx,i.name+s+Ti+this.topProd.name);var i,s;const o=e.concat(n),a=gi(new ri({definition:o}));this.follows[r]=a}}function Li(t){return t.charCodeAt(0)}function Oi(t,e){Array.isArray(t)?t.forEach(function(t){e.push(t)}):e.push(t)}function Ri(t,e){if(!0===t[e])throw"duplicate flag "+e;t[e],t[e]=!0}function Ai(t){if(void 0===t)throw Error("Internal Error - Should never get here!");return!0}function vi(t){return"Character"===t.type}const yi=[];for(let ah=Li("0");ah<=Li("9");ah++)yi.push(ah);const Ni=[Li("_")].concat(yi);for(let ah=Li("a");ah<=Li("z");ah++)Ni.push(ah);for(let ah=Li("A");ah<=Li("Z");ah++)Ni.push(ah);const Ii=[Li(" "),Li("\f"),Li("\n"),Li("\r"),Li("\t"),Li("\v"),Li("\t"),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li(" "),Li("\u2028"),Li("\u2029"),Li(" "),Li(" "),Li(" "),Li("\ufeff")],Ci=/[0-9a-fA-F]/,xi=/[0-9]/,ki=/[1-9]/;class _i{visitChildren(t){for(const e in t){const n=t[e];t.hasOwnProperty(e)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach(t=>{this.visit(t)},this))}}visit(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Lookbehind":this.visitLookbehind(t);break;case"NegativeLookbehind":this.visitNegativeLookbehind(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t)}this.visitChildren(t)}visitPattern(t){}visitFlags(t){}visitDisjunction(t){}visitAlternative(t){}visitStartAnchor(t){}visitEndAnchor(t){}visitWordBoundary(t){}visitNonWordBoundary(t){}visitLookahead(t){}visitNegativeLookahead(t){}visitLookbehind(t){}visitNegativeLookbehind(t){}visitCharacter(t){}visitSet(t){}visitGroup(t){}visitGroupBackReference(t){}visitQuantifier(t){}}let Ui={};const bi=new class{constructor(){this.idx=0,this.input="",this.groupIdx=0}saveState(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}}restoreState(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx}pattern(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");const e=this.disjunction();this.consumeChar("/");const n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};for(;this.isRegExpFlag();)switch(this.popChar()){case"g":Ri(n,"global");break;case"i":Ri(n,"ignoreCase");break;case"m":Ri(n,"multiLine");break;case"u":Ri(n,"unicode");break;case"y":Ri(n,"sticky")}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:n,value:e,loc:this.loc(0)}}disjunction(){const t=[],e=this.idx;for(t.push(this.alternative());"|"===this.peekChar();)this.consumeChar("|"),t.push(this.alternative());return{type:"Disjunction",value:t,loc:this.loc(e)}}alternative(){const t=[],e=this.idx;for(;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(e)}}term(){return this.isAssertion()?this.assertion():this.atom()}assertion(){const t=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(t)};case"$":return{type:"EndAnchor",loc:this.loc(t)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(t)};case"B":return{type:"NonWordBoundary",loc:this.loc(t)}}throw Error("Invalid Assertion Escape");case"(":let e;switch(this.consumeChar("?"),this.popChar()){case"=":e="Lookahead";break;case"!":e="NegativeLookahead";break;case"<":switch(this.popChar()){case"=":e="Lookbehind";break;case"!":e="NegativeLookbehind"}}Ai(e);const n=this.disjunction();return this.consumeChar(")"),{type:e,value:n,loc:this.loc(t)}}return function(){throw Error("Internal Error - Should never get here!")}()}quantifier(t=!1){let e;const n=this.idx;switch(this.popChar()){case"*":e={atLeast:0,atMost:1/0};break;case"+":e={atLeast:1,atMost:1/0};break;case"?":e={atLeast:0,atMost:1};break;case"{":const n=this.integerIncludingZero();switch(this.popChar()){case"}":e={atLeast:n,atMost:n};break;case",":let t;this.isDigit()?(t=this.integerIncludingZero(),e={atLeast:n,atMost:t}):e={atLeast:n,atMost:1/0},this.consumeChar("}")}if(!0===t&&void 0===e)return;Ai(e)}if(!0!==t||void 0!==e)return Ai(e)?("?"===this.peekChar(0)?(this.consumeChar("?"),e.greedy=!1):e.greedy=!0,e.type="Quantifier",e.loc=this.loc(n),e):void 0}atom(){let t;const e=this.idx;switch(this.peekChar()){case".":t=this.dotAll();break;case"\\":t=this.atomEscape();break;case"[":t=this.characterClass();break;case"(":t=this.group()}if(void 0===t&&this.isPatternCharacter()&&(t=this.patternCharacter()),Ai(t))return t.loc=this.loc(e),this.isQuantifier()&&(t.quantifier=this.quantifier()),t}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[Li("\n"),Li("\r"),Li("\u2028"),Li("\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 t,e=!1;switch(this.popChar()){case"d":t=yi;break;case"D":t=yi,e=!0;break;case"s":t=Ii;break;case"S":t=Ii,e=!0;break;case"w":t=Ni;break;case"W":t=Ni,e=!0}if(Ai(t))return{type:"Set",value:t,complement:e}}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=Li("\f");break;case"n":t=Li("\n");break;case"r":t=Li("\r");break;case"t":t=Li("\t");break;case"v":t=Li("\v")}if(Ai(t))return{type:"Character",value:t}}controlLetterEscapeAtom(){this.consumeChar("c");const t=this.popChar();if(!1===/[a-zA-Z]/.test(t))throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:Li("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:Li(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:Li(this.popChar())}}}characterClass(){const t=[];let e=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),e=!0);this.isClassAtom();){const e=this.classAtom();if(e.type,vi(e)&&this.isRangeDash()){this.consumeChar("-");const n=this.classAtom();if(n.type,vi(n)){if(n.value<e.value)throw Error("Range out of order in character class");t.push({from:e.value,to:n.value})}else Oi(e.value,t),t.push(Li("-")),Oi(n.value,t)}else Oi(e.value,t)}return this.consumeChar("]"),{type:"Set",complement:e,value:t}}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:Li("\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 t=!0;if(this.consumeChar("("),"?"===this.peekChar(0))this.consumeChar("?"),this.consumeChar(":"),t=!1;else this.groupIdx++;const e=this.disjunction();this.consumeChar(")");const n={type:"Group",capturing:t,value:e};return t&&(n.idx=this.groupIdx),n}positiveInteger(){let t=this.popChar();if(!1===ki.test(t))throw Error("Expecting a positive integer");for(;xi.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(!1===xi.test(t))throw Error("Expecting an integer");for(;xi.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){const t=this.popChar();switch(t){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:Li(t)}}}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 xi.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){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(){const t=this.saveState();try{return void 0!==this.quantifier(!0)}catch(e){return!1}finally{this.restoreState(t)}}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(t){let e="";for(let n=0;n<t;n++){const t=this.popChar();if(!1===Ci.test(t))throw Error("Expecting a HexDecimal digits");e+=t}return{type:"Character",value:parseInt(e,16)}}peekChar(t=0){return this.input[this.idx+t]}popChar(){const t=this.peekChar(0);return this.consumeChar(void 0),t}consumeChar(t){if(void 0!==t&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' 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(t){return{begin:t,end:this.idx}}};function Mi(t){const e=t.toString();if(Ui.hasOwnProperty(e))return Ui[e];{const t=bi.pattern(e);return Ui[e]=t,t}}const Pi="Complement Sets are not supported for first char optimization",wi='Unable to use "first char" lexer optimizations:\n';function Di(t,e=!1){try{const e=Mi(t);return Fi(e.value,{},e.flags.ignoreCase)}catch(n){if(n.message===Pi)e&&qr(`${wi}\tUnable to optimize: < ${t.toString()} >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let n="";e&&(n="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Xr(`${wi}\n\tFailed parsing: < ${t.toString()} >\n\tUsing the @chevrotain/regexp-to-ast library\n\tPlease open an issue at: https://github.com/chevrotain/chevrotain/issues`+n)}}return[]}function Fi(t,e,n){switch(t.type){case"Disjunction":for(let i=0;i<t.value.length;i++)Fi(t.value[i],e,n);break;case"Alternative":const r=t.value;for(let t=0;t<r.length;t++){const i=r[t];switch(i.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"Lookbehind":case"NegativeLookbehind":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const s=i;switch(s.type){case"Character":Bi(s.value,e,n);break;case"Set":if(!0===s.complement)throw Error(Pi);ur(s.value,t=>{if("number"==typeof t)Bi(t,e,n);else{const r=t;if(!0===n)for(let t=r.from;t<=r.to;t++)Bi(t,e,n);else{for(let t=r.from;t<=r.to&&t<ss;t++)Bi(t,e,n);if(r.to>=ss){const t=r.from>=ss?r.from:ss,n=r.to,i=as(t),s=as(n);for(let r=i;r<=s;r++)e[r]=r}}}});break;case"Group":Fi(s.value,e,n);break;default:throw Error("Non Exhaustive Match")}const o=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===$i(s)||"Group"!==s.type&&!1===o)break}break;default:throw Error("non exhaustive match!")}return _r(e)}function Bi(t,e,n){const r=as(t);e[r]=r,!0===n&&function(t,e){const n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){const t=as(r.charCodeAt(0));e[t]=t}else{const t=n.toLowerCase();if(t!==n){const n=as(t.charCodeAt(0));e[n]=n}}}(t,e)}function ji(t,e){return Tr(t.value,t=>{if("number"==typeof t)return br(e,t);{const n=t;return void 0!==Tr(e,t=>n.from<=t&&t<=n.to)}})}function $i(t){const e=t.quantifier;return!(!e||0!==e.atLeast)||!!t.value&&(I(t.value)?pr(t.value,$i):$i(t.value))}class Ki extends _i{constructor(t){super(),this.targetCharCodes=t,this.found=!1}visitChildren(t){if(!0!==this.found){switch(t.type){case"Lookahead":return void this.visitLookahead(t);case"NegativeLookahead":return void this.visitNegativeLookahead(t);case"Lookbehind":return void this.visitLookbehind(t);case"NegativeLookbehind":return void this.visitNegativeLookbehind(t)}super.visitChildren(t)}}visitCharacter(t){br(this.targetCharCodes,t.value)&&(this.found=!0)}visitSet(t){t.complement?void 0===ji(t,this.targetCharCodes)&&(this.found=!0):void 0!==ji(t,this.targetCharCodes)&&(this.found=!0)}}function Gi(t,e){if(e instanceof RegExp){const n=Mi(e),r=new Ki(t);return r.visit(n),r.found}return void 0!==Tr(e,e=>br(t,e.charCodeAt(0)))}const zi="PATTERN",Wi="defaultMode",Vi="modes";function Hi(t,e){const n=(e=ir(e,{debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:(t,e)=>e()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",()=>{!function(){if(wr(os)){os=new Array(65536);for(let t=0;t<65536;t++)os[t]=t>255?255+~~(t/255):t}}()}),n("Reject Lexer.NA",()=>{r=zr(t,t=>t[zi]===Os.NA)});let i,s,o,a,c,h,u,l,d,p,f,m=!1;n("Transform Patterns",()=>{m=!1,i=Or(r,t=>{const e=t[zi];if(Fr(e)){const t=e.source;return 1!==t.length||"^"===t||"$"===t||"."===t||e.ignoreCase?2!==t.length||"\\"!==t[0]||br(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],t[1])?Zi(e):t[1]:t}if(G(e))return m=!0,{exec:e};if("object"==typeof e)return m=!0,e;if("string"==typeof e){if(1===e.length)return e;{const t=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&");return Zi(new RegExp(t))}}throw Error("non exhaustive match")})}),n("misc mapping",()=>{s=Or(r,t=>t.tokenTypeIdx),o=Or(r,t=>{const e=t.GROUP;if(e!==Os.SKIPPED){if(kr(e))return e;if(Br(e))return!1;throw Error("non exhaustive match")}}),a=Or(r,t=>{const e=t.LONGER_ALT;if(e){return I(e)?Or(e,t=>Mr(r,t)):[Mr(r,e)]}}),c=Or(r,t=>t.PUSH_MODE),h=Or(r,t=>xr(t,"POP_MODE"))}),n("Line Terminator Handling",()=>{const t=rs(e.lineTerminatorCharacters);u=Or(r,t=>!1),"onlyOffset"!==e.positionTracking&&(u=Or(r,e=>xr(e,"LINE_BREAKS")?!!e.LINE_BREAKS:!1===ns(e,t)&&Gi(t,e.PATTERN)))}),n("Misc Mapping #2",()=>{l=Or(r,Ji),d=Or(i,ts),p=Gr(r,(t,e)=>{const n=e.GROUP;return kr(n)&&n!==Os.SKIPPED&&(t[n]=[]),t},{}),f=Or(i,(t,e)=>({pattern:i[e],longerAlt:a[e],canLineTerminator:u[e],isCustom:l[e],short:d[e],group:o[e],push:c[e],pop:h[e],tokenTypeIdx:s[e],tokenType:r[e]}))});let E=!0,g=[];return e.safeMode||n("First Char Optimization",()=>{g=Gr(r,(t,n,r)=>{if("string"==typeof n.PATTERN){const e=as(n.PATTERN.charCodeAt(0));is(t,e,f[r])}else if(I(n.START_CHARS_HINT)){let e;ur(n.START_CHARS_HINT,n=>{const i=as("string"==typeof n?n.charCodeAt(0):n);e!==i&&(e=i,is(t,i,f[r]))})}else if(Fr(n.PATTERN))if(n.PATTERN.unicode)E=!1,e.ensureOptimizations&&Xr(`${wi}\tUnable to analyze < ${n.PATTERN.toString()} > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const i=Di(n.PATTERN,e.ensureOptimizations);wr(i)&&(E=!1),ur(i,e=>{is(t,e,f[r])})}else e.ensureOptimizations&&Xr(`${wi}\tTokenType: <${n.name}> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return t},[])}),{emptyGroups:p,patternIdxToConfig:f,charCodeToPatternIdxToConfig:g,hasCustom:m,canBeOptimized:E}}function Yi(t,e){let n=[];const r=function(t){const e=mr(t,t=>!xr(t,zi)),n=Or(e,t=>({message:"Token Type: ->"+t.name+"<- missing static 'PATTERN' property",type:Ts.MISSING_PATTERN,tokenTypes:[t]})),r=or(t,e);return{errors:n,valid:r}}(t);n=n.concat(r.errors);const i=function(t){const e=mr(t,t=>{const e=t[zi];return!(Fr(e)||G(e)||xr(e,"exec")||kr(e))}),n=Or(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:Ts.INVALID_PATTERN,tokenTypes:[t]})),r=or(t,e);return{errors:n,valid:r}}(r.valid),s=i.valid;return n=n.concat(i.errors),n=n.concat(function(t){let e=[];const n=mr(t,t=>Fr(t[zi]));return e=e.concat(function(t){class e extends _i{constructor(){super(...arguments),this.found=!1}visitEndAnchor(t){this.found=!0}}const n=mr(t,t=>{const n=t.PATTERN;try{const t=Mi(n),r=new e;return r.visit(t),r.found}catch(r){return Xi.test(n.source)}}),r=Or(n,t=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Ts.EOI_ANCHOR_FOUND,tokenTypes:[t]}));return r}(n)),e=e.concat(function(t){class e extends _i{constructor(){super(...arguments),this.found=!1}visitStartAnchor(t){this.found=!0}}const n=mr(t,t=>{const n=t.PATTERN;try{const t=Mi(n),r=new e;return r.visit(t),r.found}catch(r){return qi.test(n.source)}}),r=Or(n,t=>({message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:Ts.SOI_ANCHOR_FOUND,tokenTypes:[t]}));return r}(n)),e=e.concat(function(t){const e=mr(t,t=>{const e=t[zi];return e instanceof RegExp&&(e.multiline||e.global)}),n=Or(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:Ts.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}));return n}(n)),e=e.concat(function(t){const e=[];let n=Or(t,n=>Gr(t,(t,r)=>(n.PATTERN.source!==r.PATTERN.source||br(e,r)||r.PATTERN===Os.NA||(e.push(r),t.push(r)),t),[]));n=In(n);const r=Or(mr(n,t=>t.length>1),t=>{const e=Or(t,t=>t.name);return{message:`The same RegExp pattern ->${Sr(t).PATTERN}<-has been used in all of the following Token Types: ${e.join(", ")} <-`,type:Ts.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}});return r}(n)),e=e.concat(function(t){const e=mr(t,t=>t.PATTERN.test("")),n=Or(e,t=>({message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:Ts.EMPTY_MATCH_PATTERN,tokenTypes:[t]}));return n}(n)),e}(s)),n=n.concat(function(t){const e=mr(t,t=>{if(!xr(t,"GROUP"))return!1;const e=t.GROUP;return e!==Os.SKIPPED&&e!==Os.NA&&!kr(e)}),n=Or(e,t=>({message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:Ts.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}));return n}(s)),n=n.concat(function(t,e){const n=mr(t,t=>void 0!==t.PUSH_MODE&&!br(e,t.PUSH_MODE)),r=Or(n,t=>({message:`Token Type: ->${t.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${t.PUSH_MODE}<-which does not exist`,type:Ts.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}));return r}(s,e)),n=n.concat(function(t){const e=[],n=Gr(t,(t,e,n)=>{const r=e.PATTERN;return r===Os.NA||(kr(r)?t.push({str:r,idx:n,tokenType:e}):Fr(r)&&(i=r,void 0===Tr([".","\\","[","]","|","^","$","(",")","?","*","+","{"],t=>-1!==i.source.indexOf(t)))&&t.push({str:r.source,idx:n,tokenType:e})),t;var i},[]);return ur(t,(t,r)=>{ur(n,({str:n,idx:i,tokenType:s})=>{if(r<i&&function(t,e){if(Fr(e)){if(/(\(\?=)|(\(\?!)|(\(\?<=)|(\(\?<!)/.test(e.source))return!1;const n=e.exec(t);return null!==n&&0===n.index}if(G(e))return e(t,0,[],{});if(xr(e,"exec"))return e.exec(t,0,[],{});if("string"==typeof e)return e===t;throw Error("non exhaustive match")}(n,t.PATTERN)){const n=`Token: ->${s.name}<- can never be matched.\nBecause it appears AFTER the Token Type ->${t.name}<-in the lexer's definition.\nSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:n,type:Ts.UNREACHABLE_PATTERN,tokenTypes:[t,s]})}})}),e}(s)),n}const Xi=/[^\\][$]/;const qi=/[^\\[][\^]|^\^/;function Zi(t){const e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}function Qi(t,e,n){const r=[];let i=!1;const s=zr(In(be(_r(t.modes))),t=>t[zi]===Os.NA),o=rs(n);return e&&ur(s,t=>{const e=ns(t,o);if(!1!==e){const n=function(t,e){if(e.issue===Ts.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <${t.name}> Token Type\n\t Root cause: ${e.errMsg}.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(e.issue===Ts.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <${t.name}> Token Type\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(t,e),i={message:n,type:e.issue,tokenType:t};r.push(i)}else xr(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(i=!0):Gi(o,t.PATTERN)&&(i=!0)}),e&&!i&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:Ts.NO_LINE_BREAKS_FLAGS}),r}function Ji(t){const e=t.PATTERN;if(Fr(e))return!1;if(G(e))return!0;if(xr(e,"exec"))return!0;if(kr(e))return!1;throw Error("non exhaustive match")}function ts(t){return!(!kr(t)||1!==t.length)&&t.charCodeAt(0)}const es={test:function(t){const e=t.length;for(let n=this.lastIndex;n<e;n++){const e=t.charCodeAt(n);if(10===e)return this.lastIndex=n+1,!0;if(13===e)return 10===t.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function ns(t,e){if(xr(t,"LINE_BREAKS"))return!1;if(Fr(t.PATTERN)){try{Gi(e,t.PATTERN)}catch(n){return{issue:Ts.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}if(kr(t.PATTERN))return!1;if(Ji(t))return{issue:Ts.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function rs(t){return Or(t,t=>kr(t)?t.charCodeAt(0):t)}function is(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}const ss=256;let os=[];function as(t){return t<ss?t:os[t]}function cs(t,e){const n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function hs(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}let us=1;const ls={};function ds(t){const e=function(t){let e=Nn(t),n=t,r=!0;for(;r;){n=In(be(Or(n,t=>t.CATEGORIES)));const t=or(n,e);e=e.concat(t),wr(t)?r=!1:n=t}return e}(t);!function(t){ur(t,t=>{fs(t)||(ls[us]=t,t.tokenTypeIdx=us++),ms(t)&&!I(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),ms(t)||(t.CATEGORIES=[]),xr(t,"categoryMatches")||(t.categoryMatches=[]),function(t){return xr(t,"categoryMatchesMap")}(t)||(t.categoryMatchesMap={})})}(e),function(t){ur(t,t=>{ps([],t)})}(e),function(t){ur(t,t=>{t.categoryMatches=[],ur(t.categoryMatchesMap,(e,n)=>{t.categoryMatches.push(ls[n].tokenTypeIdx)})})}(e),ur(e,t=>{t.isParent=t.categoryMatches.length>0})}function ps(t,e){ur(t,t=>{e.categoryMatchesMap[t.tokenTypeIdx]=!0}),ur(e.CATEGORIES,n=>{const r=t.concat(e);br(r,n)||ps(r,n)})}function fs(t){return xr(t,"tokenTypeIdx")}function ms(t){return xr(t,"CATEGORIES")}function Es(t){return xr(t,"tokenTypeIdx")}const gs={buildUnableToPopLexerModeMessage:t=>`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(t,e,n,r,i,s)=>`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${n} characters.`};var Ts,Ss;(Ss=Ts||(Ts={}))[Ss.MISSING_PATTERN=0]="MISSING_PATTERN",Ss[Ss.INVALID_PATTERN=1]="INVALID_PATTERN",Ss[Ss.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",Ss[Ss.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",Ss[Ss.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",Ss[Ss.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",Ss[Ss.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",Ss[Ss.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",Ss[Ss.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",Ss[Ss.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",Ss[Ss.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",Ss[Ss.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",Ss[Ss.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",Ss[Ss.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",Ss[Ss.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",Ss[Ss.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",Ss[Ss.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",Ss[Ss.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE";const Ls={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:gs,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(Ls);class Os{constructor(t,e=Ls){if(this.lexerDefinition=t,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=(t,e)=>{if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${t}>`);const{time:r,value:i}=Zr(e),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${r}ms`),this.traceInitIndent--,i}return e()},"boolean"==typeof e)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=se({},Ls,e);const n=this.config.traceInitPerf;!0===n?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof n&&(this.traceInitMaxIdent=n,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let n,r=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===Ls.lineTerminatorsPattern)this.config.lineTerminatorsPattern=es;else if(this.config.lineTerminatorCharacters===Ls.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(e.safeMode&&e.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),I(t)?n={modes:{defaultMode:Nn(t)},defaultMode:Wi}:(r=!1,n=Nn(t))}),!1===this.config.skipValidations&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(t){const e=[];return xr(t,Wi)||e.push({message:"A MultiMode Lexer cannot be initialized without a <"+Wi+"> property in its definition\n",type:Ts.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),xr(t,Vi)||e.push({message:"A MultiMode Lexer cannot be initialized without a <modes> property in its definition\n",type:Ts.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),xr(t,Vi)&&xr(t,Wi)&&!xr(t.modes,t.defaultMode)&&e.push({message:`A MultiMode Lexer cannot be initialized with a ${Wi}: <${t.defaultMode}>which does not exist\n`,type:Ts.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),xr(t,Vi)&&ur(t.modes,(t,n)=>{ur(t,(r,i)=>{Br(r)?e.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${n}> at index: <${i}>\n`,type:Ts.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):xr(r,"LONGER_ALT")&&ur(I(r.LONGER_ALT)?r.LONGER_ALT:[r.LONGER_ALT],i=>{Br(i)||br(t,i)||e.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${i.name}> on token <${r.name}> outside of mode <${n}>\n`,type:Ts.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),e}(n,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Qi(n,this.trackStartLines,this.config.lineTerminatorCharacters))})),n.modes=n.modes?n.modes:{},ur(n.modes,(t,e)=>{n.modes[e]=zr(t,t=>Br(t))});const i=ne(n.modes);if(ur(n.modes,(t,n)=>{this.TRACE_INIT(`Mode: <${n}> processing`,()=>{if(this.modes.push(n),!1===this.config.skipValidations&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(Yi(t,i))}),wr(this.lexerDefinitionErrors)){let r;ds(t),this.TRACE_INIT("analyzeTokenTypes",()=>{r=Hi(t,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:e.positionTracking,ensureOptimizations:e.ensureOptimizations,safeMode:e.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[n]=r.patternIdxToConfig,this.charCodeToPatternIdxToConfig[n]=r.charCodeToPatternIdxToConfig,this.emptyGroups=se({},this.emptyGroups,r.emptyGroups),this.hasCustom=r.hasCustom||this.hasCustom,this.canModeBeOptimized[n]=r.canBeOptimized}})}),this.defaultMode=n.defaultMode,!wr(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const t=Or(this.lexerDefinitionErrors,t=>t.message).join("-----------------------\n");throw new Error("Errors detected in definition of Lexer:\n"+t)}ur(this.lexerDefinitionWarning,t=>{qr(t.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(r&&(this.handleModes=ot),!1===this.trackStartLines&&(this.computeNewColumn=K),!1===this.trackEndLines&&(this.updateTokenEndLineColumnLocation=ot),/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))throw Error(`Invalid <positionTracking> config option: "${this.config.positionTracking}"`);this.createTokenInstance=this.createOffsetOnlyToken}this.hasCustom?(this.addToken=this.addTokenUsingPush,this.handlePayload=this.handlePayloadWithCustom):(this.addToken=this.addTokenUsingMemberAccess,this.handlePayload=this.handlePayloadNoCustom)}),this.TRACE_INIT("Failed Optimization Warnings",()=>{const t=Gr(this.canModeBeOptimized,(t,e,n)=>(!1===e&&t.push(n),t),[]);if(e.ensureOptimizations&&!wr(t))throw Error(`Lexer Modes: < ${t.join(", ")} > cannot be optimized.\n\t Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.\n\t Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Ui={}}),this.TRACE_INIT("toFastProperties",()=>{Qr(this)})})}tokenize(t,e=this.defaultMode){if(!wr(this.lexerDefinitionErrors)){const t=Or(this.lexerDefinitionErrors,t=>t.message).join("-----------------------\n");throw new Error("Unable to Tokenize because Errors detected in definition of Lexer:\n"+t)}return this.tokenizeInternal(t,e)}tokenizeInternal(t,e){let n,r,i,s,o,a,c,h,u,l,d,p,f,m,E;const g=t,T=g.length;let S=0,L=0;const O=this.hasCustom?0:Math.floor(t.length/10),R=new Array(O),A=[];let v=this.trackStartLines?1:void 0,y=this.trackStartLines?1:void 0;const N=function(t){const e={};return ur(ne(t),n=>{const r=t[n];if(!I(r))throw Error("non exhaustive match");e[n]=[]}),e}(this.emptyGroups),C=this.trackStartLines,x=this.config.lineTerminatorsPattern;let k=0,_=[],U=[];const b=[],M=[];Object.freeze(M);let P=!1;const w=t=>{if(1===b.length&&void 0===t.tokenType.PUSH_MODE){const e=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(t);A.push({offset:t.startOffset,line:t.startLine,column:t.startColumn,length:t.image.length,message:e})}else{b.pop();const t=ar(b);_=this.patternIdxToConfig[t],U=this.charCodeToPatternIdxToConfig[t],k=_.length;const e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;P=!(!U||!e)}};function D(t){b.push(t),U=this.charCodeToPatternIdxToConfig[t],_=this.patternIdxToConfig[t],k=_.length,k=_.length;const e=this.canModeBeOptimized[t]&&!1===this.config.safeMode;P=!(!U||!e)}let F;D.call(this,e);const B=this.config.recoveryEnabled;for(;S<T;){a=null,u=-1;const e=g.charCodeAt(S);let O;if(P){const t=as(e),n=U[t];O=void 0!==n?n:M}else O=_;const I=O.length;for(n=0;n<I;n++){F=O[n];const r=F.pattern;c=null;const l=F.short;if(!1!==l?e===l&&(u=1,a=r):!0===F.isCustom?(E=r.exec(g,S,R,N),null!==E?(a=E[0],u=a.length,void 0!==E.payload&&(c=E.payload)):a=null):(r.lastIndex=S,u=this.matchLength(r,t,S)),-1!==u){if(o=F.longerAlt,void 0!==o){a=t.substring(S,S+u);const e=o.length;for(i=0;i<e;i++){const e=_[o[i]],n=e.pattern;if(h=null,!0===e.isCustom?(E=n.exec(g,S,R,N),null!==E?(s=E[0],void 0!==E.payload&&(h=E.payload)):s=null):(n.lastIndex=S,s=this.match(n,t,S)),s&&s.length>a.length){a=s,u=s.length,c=h,F=e;break}}}break}}if(-1!==u){if(l=F.group,void 0!==l&&(a=null!==a?a:t.substring(S,S+u),d=F.tokenTypeIdx,p=this.createTokenInstance(a,S,d,F.tokenType,v,y,u),this.handlePayload(p,c),!1===l?L=this.addToken(R,L,p):N[l].push(p)),!0===C&&!0===F.canLineTerminator){let e,n,r=0;x.lastIndex=0;do{a=null!==a?a:t.substring(S,S+u),e=x.test(a),!0===e&&(n=x.lastIndex-1,r++)}while(!0===e);0!==r?(v+=r,y=u-n,this.updateTokenEndLineColumnLocation(p,l,n,r,v,y,u)):y=this.computeNewColumn(y,u)}else y=this.computeNewColumn(y,u);S+=u,this.handleModes(F,w,D,p)}else{const e=S,n=v,i=y;let s=!1===B;for(;!1===s&&S<T;)for(S++,r=0;r<k;r++){const e=_[r],n=e.pattern,i=e.short;if(!1!==i?g.charCodeAt(S)===i&&(s=!0):!0===e.isCustom?s=null!==n.exec(g,S,R,N):(n.lastIndex=S,s=null!==n.exec(t)),!0===s)break}if(f=S-e,y=this.computeNewColumn(y,f),m=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(g,e,f,n,i,ar(b)),A.push({offset:e,line:n,column:i,length:f,message:m}),!1===B)break}}return this.hasCustom||(R.length=L),{tokens:R,groups:N,errors:A}}handleModes(t,e,n,r){if(!0===t.pop){const i=t.push;e(r),void 0!==i&&n.call(this,i)}else void 0!==t.push&&n.call(this,t.push)}updateTokenEndLineColumnLocation(t,e,n,r,i,s,o){let a,c;void 0!==e&&(a=n===o-1,c=a?-1:0,1===r&&!0===a||(t.endLine=i+c,t.endColumn=s-1-c))}computeNewColumn(t,e){return t+e}createOffsetOnlyToken(t,e,n,r){return{image:t,startOffset:e,tokenTypeIdx:n,tokenType:r}}createStartOnlyToken(t,e,n,r,i,s){return{image:t,startOffset:e,startLine:i,startColumn:s,tokenTypeIdx:n,tokenType:r}}createFullToken(t,e,n,r,i,s,o){return{image:t,startOffset:e,endOffset:e+o-1,startLine:i,endLine:i,startColumn:s,endColumn:s+o-1,tokenTypeIdx:n,tokenType:r}}addTokenUsingPush(t,e,n){return t.push(n),e}addTokenUsingMemberAccess(t,e,n){return t[e]=n,++e}handlePayloadNoCustom(t,e){}handlePayloadWithCustom(t,e){null!==e&&(t.payload=e)}match(t,e,n){return!0===t.test(e)?e.substring(n,t.lastIndex):null}matchLength(t,e,n){return!0===t.test(e)?t.lastIndex-n:-1}}function Rs(t){return As(t)?t.LABEL:t.name}function As(t){return kr(t.LABEL)&&""!==t.LABEL}Os.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.",Os.NA=/NOT_APPLICABLE/;const vs="parent",ys="categories",Ns="label",Is="group",Cs="push_mode",xs="pop_mode",ks="longer_alt",_s="line_breaks",Us="start_chars_hint";function bs(t){return function(t){const e=t.pattern,n={};n.name=t.name,Br(e)||(n.PATTERN=e);if(xr(t,vs))throw"The parent property is no longer supported.\nSee: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.";xr(t,ys)&&(n.CATEGORIES=t[ys]);ds([n]),xr(t,Ns)&&(n.LABEL=t[Ns]);xr(t,Is)&&(n.GROUP=t[Is]);xr(t,xs)&&(n.POP_MODE=t[xs]);xr(t,Cs)&&(n.PUSH_MODE=t[Cs]);xr(t,ks)&&(n.LONGER_ALT=t[ks]);xr(t,_s)&&(n.LINE_BREAKS=t[_s]);xr(t,Us)&&(n.START_CHARS_HINT=t[Us]);return n}(t)}const Ms=bs({name:"EOF",pattern:Os.NA});function Ps(t,e,n,r,i,s,o,a){return{image:e,startOffset:n,endOffset:r,startLine:i,endLine:s,startColumn:o,endColumn:a,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}ds([Ms]);const ws={buildMismatchTokenMessage:({expected:t,actual:e,previous:n,ruleName:r})=>`Expecting ${As(t)?`--\x3e ${Rs(t)} <--`:`token of type --\x3e ${t.name} <--`} but found --\x3e '${e.image}' <--`,buildNotAllInputParsedMessage:({firstRedundant:t,ruleName:e})=>"Redundant input, expecting EOF but found: "+t.image,buildNoViableAltMessage({expectedPathsPerAlt:t,actual:e,previous:n,customUserDescription:r,ruleName:i}){const s="Expecting: ",o="\nbut found: '"+Sr(e).image+"'";if(r)return s+r+o;{const e=Or(Gr(t,(t,e)=>t.concat(e),[]),t=>`[${Or(t,t=>Rs(t)).join(", ")}]`);return s+`one of these possible Token sequences:\n${Or(e,(t,e)=>` ${e+1}. ${t}`).join("\n")}`+o}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:n,ruleName:r}){const i="Expecting: ",s="\nbut found: '"+Sr(e).image+"'";if(n)return i+n+s;return i+`expecting at least one iteration which starts with one of these possible Token sequences::\n <${Or(t,t=>`[${Or(t,t=>Rs(t)).join(",")}]`).join(" ,")}>`+s}};Object.freeze(ws);const Ds={buildRuleNotFoundError:(t,e)=>"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+"<-\ninside top level rule: ->"+t.name+"<-"},Fs={buildDuplicateFoundError(t,e){const n=t.name,r=Sr(e),i=r.idx,s=fi(r),o=(a=r)instanceof ui?a.terminalType.name:a instanceof ei?a.nonTerminalName:"";var a;let c=`->${s}${i>0?i:""}<- ${o?`with argument: ->${o}<-`:""}\n appears more than once (${e.length} times) in the top level rule: ->${n}<-. \n For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES \n `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,"\n"),c},buildNamespaceConflictError:t=>`Namespace conflict found in grammar.\nThe grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.name}>.\nTo resolve this make sure each Terminal and Non-Terminal names are unique\nThis is easy to accomplish by using the convention that Terminal names start with an uppercase letter\nand Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(t){const e=Or(t.prefixPath,t=>Rs(t)).join(", "),n=0===t.alternation.idx?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix\nin <OR${n}> inside <${t.topLevelRule.name}> Rule,\n<${e}> may appears as a prefix path in all these alternatives.\nSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX\nFor Further details.`},buildAlternationAmbiguityError(t){const e=0===t.alternation.idx?"":t.alternation.idx,n=0===t.prefixPath.length;let r=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${e}> inside <${t.topLevelRule.name}> Rule,\n`;if(n)r+="These alternatives are all empty (match no tokens), making them indistinguishable.\nOnly the last alternative may be empty.\n";else{r+=`<${Or(t.prefixPath,t=>Rs(t)).join(", ")}> may appears as a prefix path in all these alternatives.\n`}return r+="See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES\nFor Further details.",r},buildEmptyRepetitionError(t){let e=fi(t.repetition);0!==t.repetition.idx&&(e+=t.repetition.idx);return`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.\nThis could lead to an infinite loop.`},buildTokenNameError:t=>"deprecated",buildEmptyAlternationError:t=>`Ambiguous empty alternative: <${t.emptyChoiceIdx+1}> in <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.\nOnly the last alternative may be an empty alternative.`,buildTooManyAlternativesError:t=>`An Alternation cannot have more than 256 alternatives:\n<OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.\n has ${t.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(t){const e=t.topLevelRule.name;return`Left Recursion found in grammar.\nrule: <${e}> can be invoked from itself (directly or indirectly)\nwithout consuming any Tokens. The grammar path that causes this is: \n ${`${e} --\x3e ${Or(t.leftRecursionPath,t=>t.name).concat([e]).join(" --\x3e ")}`}\n To fix this refactor your grammar to remove the left recursion.\nsee: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:t=>"deprecated",buildDuplicateRuleNameError(t){let e;e=t.topLevelRule instanceof ni?t.topLevelRule.name:t.topLevelRule;return`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};class Bs extends di{constructor(t,e){super(),this.nameToTopRule=t,this.errMsgProvider=e,this.errors=[]}resolveRefs(){ur(_r(this.nameToTopRule),t=>{this.currTopLevel=t,t.accept(this)})}visitNonTerminal(t){const e=this.nameToTopRule[t.nonTerminalName];if(e)t.referencedRule=e;else{const e=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,t);this.errors.push({message:e,type:ha.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:t.nonTerminalName})}}}class js extends mi{constructor(t,e){super(),this.topProd=t,this.path=e,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=Nn(this.path.ruleStack).reverse(),this.occurrenceStack=Nn(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(t,e=[]){this.found||super.walk(t,e)}walkProdRef(t,e,n){if(t.referencedRule.name===this.nextProductionName&&t.idx===this.nextProductionOccurrence){const r=e.concat(n);this.updateExpectedNext(),this.walk(t.referencedRule,r)}}updateExpectedNext(){wr(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class $s extends js{constructor(t,e){super(t,e),this.path=e,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(t,e,n){if(this.isAtEndOfPath&&t.terminalType.name===this.nextTerminalName&&t.idx===this.nextTerminalOccurrence&&!this.found){const t=e.concat(n),r=new ri({definition:t});this.possibleTokTypes=gi(r),this.found=!0}}}class Ks extends mi{constructor(t,e){super(),this.topRule=t,this.occurrence=e,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Gs extends Ks{walkMany(t,e,n){if(t.idx===this.occurrence){const t=Sr(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ui&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkMany(t,e,n)}}class zs extends Ks{walkManySep(t,e,n){if(t.idx===this.occurrence){const t=Sr(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ui&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkManySep(t,e,n)}}class Ws extends Ks{walkAtLeastOne(t,e,n){if(t.idx===this.occurrence){const t=Sr(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ui&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkAtLeastOne(t,e,n)}}class Vs extends Ks{walkAtLeastOneSep(t,e,n){if(t.idx===this.occurrence){const t=Sr(e.concat(n));this.result.isEndOfRule=void 0===t,t instanceof ui&&(this.result.token=t.terminalType,this.result.occurrence=t.idx)}else super.walkAtLeastOneSep(t,e,n)}}function Hs(t,e,n=[]){n=Nn(n);let r=[],i=0;function s(s){const o=Hs(s.concat(cr(t,i+1)),e,n);return r.concat(o)}for(;n.length<e&&i<t.length;){const e=t[i];if(e instanceof ri)return s(e.definition);if(e instanceof ei)return s(e.definition);if(e instanceof ii)r=s(e.definition);else{if(e instanceof si){return s(e.definition.concat([new ai({definition:e.definition})]))}if(e instanceof oi){return s([new ri({definition:e.definition}),new ai({definition:[new ui({terminalType:e.separator})].concat(e.definition)})])}if(e instanceof ci){const t=e.definition.concat([new ai({definition:[new ui({terminalType:e.separator})].concat(e.definition)})]);r=s(t)}else if(e instanceof ai){const t=e.definition.concat([new ai({definition:e.definition})]);r=s(t)}else{if(e instanceof hi)return ur(e.definition,t=>{!1===wr(t.definition)&&(r=s(t.definition))}),r;if(!(e instanceof ui))throw Error("non exhaustive match");n.push(e.terminalType)}}i++}return r.push({partialPath:n,suffixDef:cr(t,i)}),r}function Ys(t,e,n,r){const i="EXIT_NONE_TERMINAL",s=[i],o="EXIT_ALTERNATIVE";let a=!1;const c=e.length,h=c-r-1,u=[],l=[];for(l.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!wr(l);){const t=l.pop();if(t===o){a&&ar(l).idx<=h&&l.pop();continue}const r=t.def,d=t.idx,p=t.ruleStack,f=t.occurrenceStack;if(wr(r))continue;const m=r[0];if(m===i){const t={idx:d,def:cr(r),ruleStack:hr(p),occurrenceStack:hr(f)};l.push(t)}else if(m instanceof ui)if(d<c-1){const t=d+1;if(n(e[t],m.terminalType)){const e={idx:t,def:cr(r),ruleStack:p,occurrenceStack:f};l.push(e)}}else{if(d!==c-1)throw Error("non exhaustive match");u.push({nextTokenType:m.terminalType,nextTokenOccurrence:m.idx,ruleStack:p,occurrenceStack:f}),a=!0}else if(m instanceof ei){const t=Nn(p);t.push(m.nonTerminalName);const e=Nn(f);e.push(m.idx);const n={idx:d,def:m.definition.concat(s,cr(r)),ruleStack:t,occurrenceStack:e};l.push(n)}else if(m instanceof ii){const t={idx:d,def:cr(r),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e={idx:d,def:m.definition.concat(cr(r)),ruleStack:p,occurrenceStack:f};l.push(e)}else if(m instanceof si){const t=new ai({definition:m.definition,idx:m.idx}),e={idx:d,def:m.definition.concat([t],cr(r)),ruleStack:p,occurrenceStack:f};l.push(e)}else if(m instanceof oi){const t=new ui({terminalType:m.separator}),e=new ai({definition:[t].concat(m.definition),idx:m.idx}),n={idx:d,def:m.definition.concat([e],cr(r)),ruleStack:p,occurrenceStack:f};l.push(n)}else if(m instanceof ci){const t={idx:d,def:cr(r),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e=new ui({terminalType:m.separator}),n=new ai({definition:[e].concat(m.definition),idx:m.idx}),i={idx:d,def:m.definition.concat([n],cr(r)),ruleStack:p,occurrenceStack:f};l.push(i)}else if(m instanceof ai){const t={idx:d,def:cr(r),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o);const e=new ai({definition:m.definition,idx:m.idx}),n={idx:d,def:m.definition.concat([e],cr(r)),ruleStack:p,occurrenceStack:f};l.push(n)}else if(m instanceof hi)for(let e=m.definition.length-1;e>=0;e--){const t={idx:d,def:m.definition[e].definition.concat(cr(r)),ruleStack:p,occurrenceStack:f};l.push(t),l.push(o)}else if(m instanceof ri)l.push({idx:d,def:m.definition.concat(cr(r)),ruleStack:p,occurrenceStack:f});else{if(!(m instanceof ni))throw Error("non exhaustive match");l.push(Xs(m,d,p,f))}}return u}function Xs(t,e,n,r){const i=Nn(n);i.push(t.name);const s=Nn(r);return s.push(1),{idx:e,def:t.definition,ruleStack:i,occurrenceStack:s}}var qs,Zs;function Qs(t){if(t instanceof ii||"Option"===t)return qs.OPTION;if(t instanceof ai||"Repetition"===t)return qs.REPETITION;if(t instanceof si||"RepetitionMandatory"===t)return qs.REPETITION_MANDATORY;if(t instanceof oi||"RepetitionMandatoryWithSeparator"===t)return qs.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof ci||"RepetitionWithSeparator"===t)return qs.REPETITION_WITH_SEPARATOR;if(t instanceof hi||"Alternation"===t)return qs.ALTERNATION;throw Error("non exhaustive match")}function Js(t,e,n,r){const i=t.length,s=pr(t,t=>pr(t,t=>1===t.length));if(e)return function(e){const r=Or(e,t=>t.GATE);for(let s=0;s<i;s++){const e=t[s],i=e.length,o=r[s];if(void 0===o||!1!==o.call(this))t:for(let t=0;t<i;t++){const r=e[t],i=r.length;for(let t=0;t<i;t++){const e=this.LA_FAST(t+1);if(!1===n(e,r[t]))continue t}return s}}};if(s&&!r){const e=Gr(Or(t,t=>be(t)),(t,e,n)=>(ur(e,e=>{xr(t,e.tokenTypeIdx)||(t[e.tokenTypeIdx]=n),ur(e.categoryMatches,e=>{xr(t,e)||(t[e]=n)})}),t),{});return function(){const t=this.LA_FAST(1);return e[t.tokenTypeIdx]}}return function(){for(let e=0;e<i;e++){const r=t[e],i=r.length;t:for(let t=0;t<i;t++){const i=r[t],s=i.length;for(let t=0;t<s;t++){const e=this.LA_FAST(t+1);if(!1===n(e,i[t]))continue t}return e}}}}function to(t,e,n){const r=pr(t,t=>1===t.length),i=t.length;if(r&&!n){const e=be(t);if(1===e.length&&wr(e[0].categoryMatches)){const t=e[0].tokenTypeIdx;return function(){return this.LA_FAST(1).tokenTypeIdx===t}}{const t=Gr(e,(t,e,n)=>(t[e.tokenTypeIdx]=!0,ur(e.categoryMatches,e=>{t[e]=!0}),t),[]);return function(){const e=this.LA_FAST(1);return!0===t[e.tokenTypeIdx]}}}return function(){t:for(let n=0;n<i;n++){const r=t[n],i=r.length;for(let t=0;t<i;t++){const n=this.LA_FAST(t+1);if(!1===e(n,r[t]))continue t}return!0}return!1}}(Zs=qs||(qs={}))[Zs.OPTION=0]="OPTION",Zs[Zs.REPETITION=1]="REPETITION",Zs[Zs.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",Zs[Zs.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",Zs[Zs.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",Zs[Zs.ALTERNATION=5]="ALTERNATION";class eo extends mi{constructor(t,e,n){super(),this.topProd=t,this.targetOccurrence=e,this.targetProdType=n}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(t,e,n,r){return t.idx===this.targetOccurrence&&this.targetProdType===e&&(this.restDef=n.concat(r),!0)}walkOption(t,e,n){this.checkIsTarget(t,qs.OPTION,e,n)||super.walkOption(t,e,n)}walkAtLeastOne(t,e,n){this.checkIsTarget(t,qs.REPETITION_MANDATORY,e,n)||super.walkOption(t,e,n)}walkAtLeastOneSep(t,e,n){this.checkIsTarget(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR,e,n)||super.walkOption(t,e,n)}walkMany(t,e,n){this.checkIsTarget(t,qs.REPETITION,e,n)||super.walkOption(t,e,n)}walkManySep(t,e,n){this.checkIsTarget(t,qs.REPETITION_WITH_SEPARATOR,e,n)||super.walkOption(t,e,n)}}class no extends di{constructor(t,e,n){super(),this.targetOccurrence=t,this.targetProdType=e,this.targetRef=n,this.result=[]}checkIsTarget(t,e){t.idx!==this.targetOccurrence||this.targetProdType!==e||void 0!==this.targetRef&&t!==this.targetRef||(this.result=t.definition)}visitOption(t){this.checkIsTarget(t,qs.OPTION)}visitRepetition(t){this.checkIsTarget(t,qs.REPETITION)}visitRepetitionMandatory(t){this.checkIsTarget(t,qs.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(t){this.checkIsTarget(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(t){this.checkIsTarget(t,qs.REPETITION_WITH_SEPARATOR)}visitAlternation(t){this.checkIsTarget(t,qs.ALTERNATION)}}function ro(t){const e=new Array(t);for(let n=0;n<t;n++)e[n]=[];return e}function io(t){let e=[""];for(let n=0;n<t.length;n++){const r=t[n],i=[];for(let t=0;t<e.length;t++){const n=e[t];i.push(n+"_"+r.tokenTypeIdx);for(let t=0;t<r.categoryMatches.length;t++){const e="_"+r.categoryMatches[t];i.push(n+e)}}e=i}return e}function so(t,e,n){for(let r=0;r<t.length;r++){if(r===n)continue;const i=t[r];for(let t=0;t<e.length;t++){if(!0===i[e[t]])return!1}}return!0}function oo(t,e){const n=Or(t,t=>Hs([t],1)),r=ro(n.length),i=Or(n,t=>{const e={};return ur(t,t=>{ur(io(t.partialPath),t=>{e[t]=!0})}),e});let s=n;for(let o=1;o<=e;o++){const t=s;s=ro(t.length);for(let n=0;n<t.length;n++){const a=t[n];for(let t=0;t<a.length;t++){const c=a[t].partialPath,h=a[t].suffixDef,u=io(c);if(so(i,u,n)||wr(h)||c.length===e){const t=r[n];if(!1===ho(t,c)){t.push(c);for(let t=0;t<u.length;t++){const e=u[t];i[n][e]=!0}}}else{const t=Hs(h,o+1,c);s[n]=s[n].concat(t),ur(t,t=>{ur(io(t.partialPath),t=>{i[n][t]=!0})})}}}}return r}function ao(t,e,n,r){const i=new no(t,qs.ALTERNATION,r);return e.accept(i),oo(i.result,n)}function co(t,e,n,r){const i=new no(t,n);e.accept(i);const s=i.result,o=new eo(e,t,n).startWalking();return oo([new ri({definition:s}),new ri({definition:o})],r)}function ho(t,e){t:for(let n=0;n<t.length;n++){const r=t[n];if(r.length===e.length){for(let t=0;t<r.length;t++){const n=e[t],i=r[t];if(!1===(n===i||void 0!==i.categoryMatchesMap[n.tokenTypeIdx]))continue t}return!0}}return!1}function uo(t){return pr(t,t=>pr(t,t=>pr(t,t=>wr(t.categoryMatches))))}function lo(t,e,n,r){const i=Rr(t,t=>function(t,e){const n=new mo;t.accept(n);const r=n.allProductions,i=Nr(r,po),s=Or(_r($r(i,t=>t.length>1)),n=>{const r=Sr(n),i=e.buildDuplicateFoundError(t,n),s=fi(r),o={message:i,type:ha.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:s,occurrence:r.idx},a=fo(r);return a&&(o.parameter=a),o});return s}(t,n)),s=function(t,e,n){const r=[],i=Or(e,t=>t.name);return ur(t,t=>{const e=t.name;if(br(i,e)){const i=n.buildNamespaceConflictError(t);r.push({message:i,type:ha.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:e})}}),r}(t,e,n),o=Rr(t,t=>function(t,e){const n=new To;t.accept(n);const r=Rr(n.alternations,n=>n.definition.length>255?[{message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:n}),type:ha.TOO_MANY_ALTS,ruleName:t.name,occurrence:n.idx}]:[]);return r}(t,n)),a=Rr(t,e=>function(t,e,n,r){const i=[],s=Gr(e,(e,n)=>n.name===t.name?e+1:e,0);if(s>1){const e=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});i.push({message:e,type:ha.DUPLICATE_RULE_NAME,ruleName:t.name})}return i}(e,t,r,n));return i.concat(s,o,a)}function po(t){return`${fi(t)}_#_${t.idx}_#_${fo(t)}`}function fo(t){return t instanceof ui?t.terminalType.name:t instanceof ei?t.nonTerminalName:""}class mo extends di{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(t){this.allProductions.push(t)}visitOption(t){this.allProductions.push(t)}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}visitAlternation(t){this.allProductions.push(t)}visitTerminal(t){this.allProductions.push(t)}}function Eo(t,e,n,r=[]){const i=[],s=go(e.definition);if(wr(s))return[];{const e=t.name;br(s,t)&&i.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:ha.LEFT_RECURSION,ruleName:e});const o=Rr(or(s,r.concat([t])),e=>{const i=Nn(r);return i.push(e),Eo(t,e,n,i)});return i.concat(o)}}function go(t){let e=[];if(wr(t))return e;const n=Sr(t);if(n instanceof ei)e.push(n.referencedRule);else if(n instanceof ri||n instanceof ii||n instanceof si||n instanceof oi||n instanceof ci||n instanceof ai)e=e.concat(go(n.definition));else if(n instanceof hi)e=be(Or(n.definition,t=>go(t.definition)));else if(!(n instanceof ui))throw Error("non exhaustive match");const r=pi(n),i=t.length>1;if(r&&i){const n=cr(t);return e.concat(go(n))}return e}class To extends di{constructor(){super(...arguments),this.alternations=[]}visitAlternation(t){this.alternations.push(t)}}function So(t,e,n){const r=new To;t.accept(r);let i=r.alternations;i=zr(i,t=>!0===t.ignoreAmbiguities);const s=Rr(i,r=>{const i=r.idx,s=r.maxLookahead||e,o=ao(i,t,s,r),a=function(t,e,n,r){const i=[],s=Gr(t,(n,r,s)=>(!0===e.definition[s].ignoreAmbiguities||ur(r,r=>{const o=[s];ur(t,(t,n)=>{s!==n&&ho(t,r)&&!0!==e.definition[n].ignoreAmbiguities&&o.push(n)}),o.length>1&&!ho(i,r)&&(i.push(r),n.push({alts:o,path:r}))}),n),[]),o=Or(s,t=>{const i=Or(t.alts,t=>t+1);return{message:r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:i,prefixPath:t.path}),type:ha.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:t.alts}});return o}(o,r,t,n),c=function(t,e,n,r){const i=Gr(t,(t,e,n)=>{const r=Or(e,t=>({idx:n,path:t}));return t.concat(r)},[]),s=In(Rr(i,t=>{if(!0===e.definition[t.idx].ignoreAmbiguities)return[];const s=t.idx,o=t.path;return Or(mr(i,t=>{return!0!==e.definition[t.idx].ignoreAmbiguities&&t.idx<s&&(n=t.path,r=o,n.length<r.length&&pr(n,(t,e)=>{const n=r[e];return t===n||n.categoryMatchesMap[t.tokenTypeIdx]}));var n,r}),t=>{const i=[t.idx+1,s+1],o=0===e.idx?"":e.idx;return{message:r.buildAlternationPrefixAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:i,prefixPath:t.path}),type:ha.AMBIGUOUS_PREFIX_ALTS,ruleName:n.name,occurrence:o,alternatives:i}})}));return s}(o,r,t,n);return a.concat(c)});return s}class Lo extends di{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(t){this.allProductions.push(t)}visitRepetitionMandatory(t){this.allProductions.push(t)}visitRepetitionMandatoryWithSeparator(t){this.allProductions.push(t)}visitRepetition(t){this.allProductions.push(t)}}function Oo(t){const e=ir(t,{errMsgProvider:Ds}),n={};return ur(t.rules,t=>{n[t.name]=t}),function(t,e){const n=new Bs(t,e);return n.resolveRefs(),n.errors}(n,e.errMsgProvider)}const Ro="MismatchedTokenException",Ao="NoViableAltException",vo="EarlyExitException",yo="NotAllInputParsedException",No=[Ro,Ao,vo,yo];function Io(t){return br(No,t.name)}Object.freeze(No);class Co extends Error{constructor(t,e){super(t),this.token=e,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class xo extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=Ro}}class ko extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=Ao}}class _o extends Co{constructor(t,e){super(t,e),this.name=yo}}class Uo extends Co{constructor(t,e,n){super(t,e),this.previousToken=n,this.name=vo}}const bo={},Mo="InRuleRecoveryException";class Po extends Error{constructor(t){super(t),this.name=Mo}}function wo(t,e,n,r,i,s,o){const a=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[a];if(void 0===c){const t=this.getCurrRuleFullName();c=new s(this.getGAstProductions()[t],i).startWalking(),this.firstAfterRepMap[a]=c}let h=c.token,u=c.occurrence;const l=c.isEndOfRule;0===this.RULE_STACK_IDX&&l&&void 0===h&&(h=Ms,u=1),void 0!==h&&void 0!==u&&this.shouldInRepetitionRecoveryBeTried(h,u,o)&&this.tryInRepetitionRecovery(t,e,n,h)}const Do=1024,Fo=1280,Bo=1536;function jo(t,e,n){return n|e|t}class $o{constructor(t){var e;this.maxLookahead=null!==(e=null==t?void 0:t.maxLookahead)&&void 0!==e?e:aa.maxLookahead}validate(t){const e=this.validateNoLeftRecursion(t.rules);if(wr(e)){const n=this.validateEmptyOrAlternatives(t.rules),r=this.validateAmbiguousAlternationAlternatives(t.rules,this.maxLookahead),i=this.validateSomeNonEmptyLookaheadPath(t.rules,this.maxLookahead);return[...e,...n,...r,...i]}return e}validateNoLeftRecursion(t){return Rr(t,t=>Eo(t,t,Fs))}validateEmptyOrAlternatives(t){return Rr(t,t=>function(t,e){const n=new To;return t.accept(n),Rr(n.alternations,n=>Rr(hr(n.definition),(r,i)=>wr(Ys([r],[],cs,1))?[{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:n,emptyChoiceIdx:i}),type:ha.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:n.idx,alternative:i+1}]:[]))}(t,Fs))}validateAmbiguousAlternationAlternatives(t,e){return Rr(t,t=>So(t,e,Fs))}validateSomeNonEmptyLookaheadPath(t,e){return function(t,e,n){const r=[];return ur(t,t=>{const i=new Lo;t.accept(i),ur(i.allProductions,i=>{const s=Qs(i),o=i.maxLookahead||e;if(wr(be(co(i.idx,t,s,o)[0]))){const e=n.buildEmptyRepetitionError({topLevelRule:t,repetition:i});r.push({message:e,type:ha.NO_NON_EMPTY_LOOKAHEAD,ruleName:t.name})}})}),r}(t,e,Fs)}buildLookaheadForAlternation(t){return function(t,e,n,r,i,s){const o=ao(t,e,n);return s(o,r,uo(o)?hs:cs,i)}(t.prodOccurrence,t.rule,t.maxLookahead,t.hasPredicates,t.dynamicTokensEnabled,Js)}buildLookaheadForOptional(t){return function(t,e,n,r,i,s){const o=co(t,e,i,n),a=uo(o)?hs:cs;return s(o[0],a,r)}(t.prodOccurrence,t.rule,t.maxLookahead,t.dynamicTokensEnabled,Qs(t.prodType),to)}}const Ko=new class extends di{constructor(){super(...arguments),this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}reset(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}}visitOption(t){this.dslMethods.option.push(t)}visitRepetitionWithSeparator(t){this.dslMethods.repetitionWithSeparator.push(t)}visitRepetitionMandatory(t){this.dslMethods.repetitionMandatory.push(t)}visitRepetitionMandatoryWithSeparator(t){this.dslMethods.repetitionMandatoryWithSeparator.push(t)}visitRepetition(t){this.dslMethods.repetition.push(t)}visitAlternation(t){this.dslMethods.alternation.push(t)}};function Go(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset)}function zo(t,e){!0===isNaN(t.startOffset)?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset==!0&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function Wo(t,e){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:e})}function Vo(t,e){const n=ne(t),r=n.length;for(let i=0;i<r;i++){const r=t[n[i]],s=r.length;for(let t=0;t<s;t++){const n=r[t];void 0===n.tokenTypeIdx&&this[n.name](n.children,e)}}}function Ho(t,e){const n=function(){};Wo(n,t+"BaseSemantics");const r={visit:function(t,e){if(I(t)&&(t=t[0]),!Br(t))return this[t.name](t.children,e)},validateVisitor:function(){const t=function(t,e){const n=function(t,e){const n=mr(e,e=>!1===G(t[e])),r=Or(n,e=>({msg:`Missing visitor method: <${e}> on ${t.constructor.name} CST Visitor.`,type:Yo.MISSING_METHOD,methodName:e}));return In(r)}(t,e);return n}(this,e);if(!wr(t)){const e=Or(t,t=>t.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:\n\t${e.join("\n\n").replace(/\n/g,"\n\t")}`)}}};return(n.prototype=r).constructor=n,n._RULE_NAMES=e,n}var Yo,Xo;(Xo=Yo||(Yo={}))[Xo.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",Xo[Xo.MISSING_METHOD=1]="MISSING_METHOD";const qo={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(qo);const Zo=!0,Qo=Math.pow(2,8)-1,Jo=bs({name:"RECORDING_PHASE_TOKEN",pattern:Os.NA});ds([Jo]);const ta=Ps(Jo,"This IToken indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",-1,-1,-1,-1,-1,-1);Object.freeze(ta);const ea={name:"This CSTNode indicates the Parser is in Recording Phase\n\tSee: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details",children:{}};function na(t,e,n,r=!1){sa(n);const i=ar(this.recordingProdStack),s=G(e)?e:e.DEF,o=new t({definition:[],idx:n});return r&&(o.separator=e.SEP),xr(e,"MAX_LOOKAHEAD")&&(o.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(o),s.call(this),i.definition.push(o),this.recordingProdStack.pop(),qo}function ra(t,e){sa(e);const n=ar(this.recordingProdStack),r=!1===I(t),i=!1===r?t:t.DEF,s=new hi({definition:[],idx:e,ignoreAmbiguities:r&&!0===t.IGNORE_AMBIGUITIES});xr(t,"MAX_LOOKAHEAD")&&(s.maxLookahead=t.MAX_LOOKAHEAD);const o=Vr(i,t=>G(t.GATE));return s.hasPredicates=o,n.definition.push(s),ur(i,t=>{const e=new ri({definition:[]});s.definition.push(e),xr(t,"IGNORE_AMBIGUITIES")?e.ignoreAmbiguities=t.IGNORE_AMBIGUITIES:xr(t,"GATE")&&(e.ignoreAmbiguities=!0),this.recordingProdStack.push(e),t.ALT.call(this),this.recordingProdStack.pop()}),qo}function ia(t){return 0===t?"":`${t}`}function sa(t){if(t<0||t>Qo){const e=new Error(`Invalid DSL Method idx value: <${t}>\n\tIdx value must be a none negative value smaller than ${Qo+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}const oa=Ps(Ms,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(oa);const aa=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:ws,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),ca=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var ha,ua,la;(ua=ha||(ha={}))[ua.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",ua[ua.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",ua[ua.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",ua[ua.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",ua[ua.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",ua[ua.LEFT_RECURSION=5]="LEFT_RECURSION",ua[ua.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",ua[ua.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",ua[ua.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",ua[ua.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",ua[ua.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",ua[ua.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",ua[ua.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",ua[ua.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION";class da{static performSelfAnalysis(t){throw Error("The **static** `performSelfAnalysis` method has been deprecated.\t\nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let t;this.selfAnalysisDone=!0;const e=this.className;this.TRACE_INIT("toFastProps",()=>{Qr(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),ur(this.definedRulesNames,t=>{const e=this[t].originalGrammarAction;let n;this.TRACE_INIT(`${t} Rule`,()=>{n=this.topLevelRuleRecord(t,e)}),this.gastProductionsCache[t]=n})}finally{this.disableRecording()}});let n=[];if(this.TRACE_INIT("Grammar Resolving",()=>{n=Oo({rules:_r(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(n)}),this.TRACE_INIT("Grammar Validations",()=>{if(wr(n)&&!1===this.skipValidations){const n=(t={rules:_r(this.gastProductionsCache),tokenTypes:_r(this.tokensMap),errMsgProvider:Fs,grammarName:e},lo((t=ir(t,{errMsgProvider:Fs})).rules,t.tokenTypes,t.errMsgProvider,t.grammarName)),r=function(t){return Or(t.lookaheadStrategy.validate({rules:t.rules,tokenTypes:t.tokenTypes,grammarName:t.grammarName}),t=>Object.assign({type:ha.CUSTOM_LOOKAHEAD_VALIDATION},t))}({lookaheadStrategy:this.lookaheadStrategy,rules:_r(this.gastProductionsCache),tokenTypes:_r(this.tokensMap),grammarName:e});this.definitionErrors=this.definitionErrors.concat(n,r)}var t}),wr(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const t=function(t){const e={};return ur(t,t=>{const n=new Si(t).startWalking();se(e,n)}),e}(_r(this.gastProductionsCache));this.resyncFollows=t}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var t,e;null===(e=(t=this.lookaheadStrategy).initialize)||void 0===e||e.call(t,{rules:_r(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(_r(this.gastProductionsCache))})),!da.DEFER_DEFINITION_ERRORS_HANDLING&&!wr(this.definitionErrors))throw t=Or(this.definitionErrors,t=>t.message),new Error(`Parser Definition Errors detected:\n ${t.join("\n-------------------------------\n")}`)})}constructor(t,e){this.definitionErrors=[],this.selfAnalysisDone=!1;const n=this;if(n.initErrorHandler(e),n.initLexerAdapter(),n.initLooksAhead(e),n.initRecognizerEngine(t,e),n.initRecoverable(e),n.initTreeBuilder(e),n.initContentAssist(),n.initGastRecorder(e),n.initPerformanceTracer(e),xr(e,"ignoredIssues"))throw new Error("The <ignoredIssues> IParserConfig property has been deprecated.\n\tPlease use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.\n\tSee: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES\n\tFor further details.");this.skipValidations=xr(e,"skipValidations")?e.skipValidations:aa.skipValidations}}da.DEFER_DEFINITION_ERRORS_HANDLING=!1,la=da,[class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=xr(t,"recoveryEnabled")?t.recoveryEnabled:aa.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=wo)}getTokenToInsert(t){const e=Ps(t,"",NaN,NaN,NaN,NaN,NaN,NaN);return e.isInsertedInRecovery=!0,e}canTokenTypeBeInsertedInRecovery(t){return!0}canTokenTypeBeDeletedInRecovery(t){return!0}tryInRepetitionRecovery(t,e,n,r){const i=this.findReSyncTokenType(),s=this.exportLexerState(),o=[];let a=!1;const c=this.LA_FAST(1);let h=this.LA_FAST(1);const u=()=>{const t=this.LA(0),e=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:t,ruleName:this.getCurrRuleFullName()}),n=new xo(e,c,this.LA(0));n.resyncedTokens=hr(o),this.SAVE_ERROR(n)};for(;!a;){if(this.tokenMatcher(h,r))return void u();if(n.call(this))return u(),void t.apply(this,e);this.tokenMatcher(h,i)?a=!0:(h=this.SKIP_TOKEN(),this.addToResyncTokens(h,o))}this.importLexerState(s)}shouldInRepetitionRecoveryBeTried(t,e,n){return!1!==n&&!this.tokenMatcher(this.LA_FAST(1),t)&&!this.isBackTracking()&&!this.canPerformInRuleRecovery(t,this.getFollowsForInRuleRecovery(t,e))}getFollowsForInRuleRecovery(t,e){const n=this.getCurrentGrammarPath(t,e);return this.getNextPossibleTokenTypes(n)}tryInRuleRecovery(t,e){if(this.canRecoverWithSingleTokenInsertion(t,e))return this.getTokenToInsert(t);if(this.canRecoverWithSingleTokenDeletion(t)){const t=this.SKIP_TOKEN();return this.consumeToken(),t}throw new Po("sad sad panda")}canPerformInRuleRecovery(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,e){if(!this.canTokenTypeBeInsertedInRecovery(t))return!1;if(wr(e))return!1;const n=this.LA_FAST(1);return void 0!==Tr(e,t=>this.tokenMatcher(n,t))}canRecoverWithSingleTokenDeletion(t){return!!this.canTokenTypeBeDeletedInRecovery(t)&&this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){const e=this.getCurrFollowKey();return br(this.getFollowSetFromFollowKey(e),t)}findReSyncTokenType(){const t=this.flattenFollowSet();let e=this.LA_FAST(1),n=2;for(;;){const r=Tr(t,t=>cs(e,t));if(void 0!==r)return r;e=this.LA(n),n++}}getCurrFollowKey(){if(0===this.RULE_STACK_IDX)return bo;const t=this.currRuleShortName,e=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(t),idxInCallingRule:e,inRule:this.shortRuleNameToFullName(n)}}buildFullFollowKeyStack(){const t=this.RULE_STACK,e=this.RULE_OCCURRENCE_STACK,n=this.RULE_STACK_IDX+1,r=new Array(n);for(let i=0;i<n;i++)r[i]=0===i?bo:{ruleName:this.shortRuleNameToFullName(t[i]),idxInCallingRule:e[i],inRule:this.shortRuleNameToFullName(t[i-1])};return r}flattenFollowSet(){return be(Or(this.buildFullFollowKeyStack(),t=>this.getFollowSetFromFollowKey(t)))}getFollowSetFromFollowKey(t){if(t===bo)return[Ms];const e=t.ruleName+t.idxInCallingRule+Ti+t.inRule;return this.resyncFollows[e]}addToResyncTokens(t,e){return this.tokenMatcher(t,Ms)||e.push(t),e}reSyncTo(t){const e=[];let n=this.LA_FAST(1);for(;!1===this.tokenMatcher(n,t);)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,e);return hr(e)}attemptInRepetitionRecovery(t,e,n,r,i,s,o){}getCurrentGrammarPath(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1),lastTok:t,lastTokOccurrence:e}}getHumanReadableRuleStack(){const t=this.RULE_STACK_IDX+1,e=new Array(t);for(let n=0;n<t;n++)e[n]=this.shortRuleNameToFullName(this.RULE_STACK[n]);return e}},class{initLooksAhead(t){this.dynamicTokensEnabled=xr(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:aa.dynamicTokensEnabled,this.maxLookahead=xr(t,"maxLookahead")?t.maxLookahead:aa.maxLookahead,this.lookaheadStrategy=xr(t,"lookaheadStrategy")?t.lookaheadStrategy:new $o({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){ur(t,t=>{this.TRACE_INIT(`${t.name} Rule Lookahead`,()=>{const{alternation:e,repetition:n,option:r,repetitionMandatory:i,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:o}=function(t){Ko.reset(),t.accept(Ko);const e=Ko.dslMethods;return Ko.reset(),e}(t);ur(e,e=>{const n=0===e.idx?"":e.idx;this.TRACE_INIT(`${fi(e)}${n}`,()=>{const n=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:e.idx,rule:t,maxLookahead:e.maxLookahead||this.maxLookahead,hasPredicates:e.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),r=jo(this.fullRuleNameToShort[t.name],256,e.idx);this.setLaFuncCache(r,n)})}),ur(n,e=>{this.computeLookaheadFunc(t,e.idx,768,"Repetition",e.maxLookahead,fi(e))}),ur(r,e=>{this.computeLookaheadFunc(t,e.idx,512,"Option",e.maxLookahead,fi(e))}),ur(i,e=>{this.computeLookaheadFunc(t,e.idx,Do,"RepetitionMandatory",e.maxLookahead,fi(e))}),ur(s,e=>{this.computeLookaheadFunc(t,e.idx,Bo,"RepetitionMandatoryWithSeparator",e.maxLookahead,fi(e))}),ur(o,e=>{this.computeLookaheadFunc(t,e.idx,Fo,"RepetitionWithSeparator",e.maxLookahead,fi(e))})})})}computeLookaheadFunc(t,e,n,r,i,s){this.TRACE_INIT(`${s}${0===e?"":e}`,()=>{const s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:e,rule:t,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),o=jo(this.fullRuleNameToShort[t.name],n,e);this.setLaFuncCache(o,s)})}getKeyForAutomaticLookahead(t,e){return jo(this.currRuleShortName,t,e)}getLaFuncFromCache(t){return this.lookAheadFuncsCache.get(t)}setLaFuncCache(t,e){this.lookAheadFuncsCache.set(t,e)}},class{initTreeBuilder(t){if(this.CST_STACK=[],this.outputCst=t.outputCst,this.nodeLocationTracking=xr(t,"nodeLocationTracking")?t.nodeLocationTracking:aa.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=zo,this.setNodeLocationFromNode=zo,this.cstPostRule=ot,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Go,this.setNodeLocationFromNode=Go,this.cstPostRule=ot,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else{if(!/none/i.test(this.nodeLocationTracking))throw Error(`Invalid <nodeLocationTracking> config option: "${t.nodeLocationTracking}"`);this.setNodeLocationFromToken=ot,this.setNodeLocationFromNode=ot,this.cstPostRule=ot,this.setInitialNodeLocation=ot}else this.cstInvocationStateUpdate=ot,this.cstFinallyStateUpdate=ot,this.cstPostTerminal=ot,this.cstPostNonTerminal=ot,this.cstPostRule=ot}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA_FAST(1).startOffset,endOffset:NaN}}setInitialNodeLocationFullRecovery(t){t.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}}setInitialNodeLocationFullRegular(t){const e=this.LA_FAST(1);t.location={startOffset:e.startOffset,startLine:e.startLine,startColumn:e.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}}cstInvocationStateUpdate(t){const e={name:t,children:Object.create(null)};this.setInitialNodeLocation(e),this.CST_STACK.push(e)}cstFinallyStateUpdate(){this.CST_STACK.pop()}cstPostRuleFull(t){const e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==1?(n.endOffset=e.endOffset,n.endLine=e.endLine,n.endColumn=e.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)}cstPostRuleOnlyOffset(t){const e=this.LA(0),n=t.location;n.startOffset<=e.startOffset==1?n.endOffset=e.endOffset:n.startOffset=NaN}cstPostTerminal(t,e){const n=this.CST_STACK[this.CST_STACK.length-1];var r,i,s;i=e,s=t,void 0===(r=n).children[s]?r.children[s]=[i]:r.children[s].push(i),this.setNodeLocationFromToken(n.location,e)}cstPostNonTerminal(t,e){const n=this.CST_STACK[this.CST_STACK.length-1];!function(t,e,n){void 0===t.children[e]?t.children[e]=[n]:t.children[e].push(n)}(n,e,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(Br(this.baseCstVisitorConstructor)){const t=Ho(this.className,ne(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Br(this.baseCstVisitorWithDefaultsConstructor)){const t=function(t,e,n){const r=function(){};Wo(r,t+"BaseSemanticsWithDefaults");const i=Object.create(n.prototype);return ur(e,t=>{i[t]=Vo}),(r.prototype=i).constructor=r,r}(this.className,ne(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getPreviousExplicitRuleShortName(){return this.RULE_STACK[this.RULE_STACK_IDX-1]}getLastExplicitRuleOccurrenceIndex(){return this.RULE_OCCURRENCE_STACK[this.RULE_OCCURRENCE_STACK_IDX]}},class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(!0!==this.selfAnalysisDone)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=t,this.tokVectorLength=t.length}get input(){return this.tokVector}SKIP_TOKEN(){return this.currIdx<=this.tokVectorLength-2?(this.consumeToken(),this.LA_FAST(1)):oa}LA_FAST(t){const e=this.currIdx+t;return this.tokVector[e]}LA(t){const e=this.currIdx+t;return e<0||this.tokVectorLength<=e?oa:this.tokVector[e]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVectorLength-1}getLexerPosition(){return this.exportLexerState()}},class{initRecognizerEngine(t,e){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=hs,this.subruleIdx=0,this.currRuleShortName=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK=[],this.RULE_OCCURRENCE_STACK_IDX=-1,this.gastProductionsCache={},xr(e,"serializedGrammar"))throw Error("The Parser's configuration can no longer contain a <serializedGrammar> property.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0\n\tFor Further details.");if(I(t)){if(wr(t))throw Error("A Token Vocabulary cannot be empty.\n\tNote that the first argument for the parser constructor\n\tis no longer a Token vector (since v4.0).");if("number"==typeof t[0].startOffset)throw Error("The Parser constructor no longer accepts a token vector as the first argument.\n\tSee: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0\n\tFor Further details.")}if(I(t))this.tokensMap=Gr(t,(t,e)=>(t[e.name]=e,t),{});else if(xr(t,"modes")&&pr(be(_r(t.modes)),Es)){const e=Yr(be(_r(t.modes)));this.tokensMap=Gr(e,(t,e)=>(t[e.name]=e,t),{})}else{if(!M(t))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=Nn(t)}this.tokensMap.EOF=Ms;const n=pr(xr(t,"modes")?be(_r(t.modes)):_r(t),t=>wr(t.categoryMatches));this.tokenMatcher=n?hs:cs,ds(_r(this.tokensMap))}defineRule(t,e,n){if(this.selfAnalysisDone)throw Error(`Grammar rule <${t}> may not be defined after the 'performSelfAnalysis' method has been called'\nMake sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=xr(n,"resyncEnabled")?n.resyncEnabled:ca.resyncEnabled,i=xr(n,"recoveryValueFunc")?n.recoveryValueFunc:ca.recoveryValueFunc,s=this.ruleShortNameIdx<<12;let o;return this.ruleShortNameIdx++,this.shortRuleNameToFull[s]=t,this.fullRuleNameToShort[t]=s,o=!0===this.outputCst?function(...n){try{this.ruleInvocationStateUpdate(s,t,this.subruleIdx),e.apply(this,n);const r=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(r),r}catch(o){return this.invokeRuleCatch(o,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...n){try{return this.ruleInvocationStateUpdate(s,t,this.subruleIdx),e.apply(this,n)}catch(o){return this.invokeRuleCatch(o,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(function(...e){this.onBeforeParse(t);try{return o.apply(this,e)}finally{this.onAfterParse(t)}},{ruleName:t,originalGrammarAction:e,coreRule:o})}invokeRuleCatch(t,e,n){const r=0===this.RULE_STACK_IDX,i=e&&!this.isBackTracking()&&this.recoveryEnabled;if(Io(t)){const e=t;if(i){const r=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(r)){if(e.resyncedTokens=this.reSyncTo(r),this.outputCst){const t=this.CST_STACK[this.CST_STACK.length-1];return t.recoveredNode=!0,t}return n(t)}if(this.outputCst){const t=this.CST_STACK[this.CST_STACK.length-1];t.recoveredNode=!0,e.partialCstResult=t}throw e}if(r)return this.moveToTerminatedState(),n(t);throw e}throw t}optionInternal(t,e){const n=this.getKeyForAutomaticLookahead(512,e);return this.optionInternalLogic(t,e,n)}optionInternalLogic(t,e,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof t){r=t.DEF;const e=t.GATE;if(void 0!==e){const t=i;i=()=>e.call(this)&&t.call(this)}}else r=t;if(!0===i.call(this))return r.call(this)}atLeastOneInternal(t,e){const n=this.getKeyForAutomaticLookahead(Do,t);return this.atLeastOneInternalLogic(t,e,n)}atLeastOneInternalLogic(t,e,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof e){r=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else r=e;if(!0!==i.call(this))throw this.raiseEarlyExitException(t,qs.REPETITION_MANDATORY,e.ERR_MSG);{let t=this.doSingleRepetition(r);for(;!0===i.call(this)&&!0===t;)t=this.doSingleRepetition(r)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],i,Do,t,Ws)}atLeastOneSepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead(Bo,t);this.atLeastOneSepFirstInternalLogic(t,e,n)}atLeastOneSepFirstInternalLogic(t,e,n){const r=e.DEF,i=e.SEP;if(!0!==this.getLaFuncFromCache(n).call(this))throw this.raiseEarlyExitException(t,qs.REPETITION_MANDATORY_WITH_SEPARATOR,e.ERR_MSG);{r.call(this);const e=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;!0===this.tokenMatcher(this.LA_FAST(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,e,r,Vs],e,Bo,t,Vs)}}manyInternal(t,e){const n=this.getKeyForAutomaticLookahead(768,t);return this.manyInternalLogic(t,e,n)}manyInternalLogic(t,e,n){let r,i=this.getLaFuncFromCache(n);if("function"!=typeof e){r=e.DEF;const t=e.GATE;if(void 0!==t){const e=i;i=()=>t.call(this)&&e.call(this)}}else r=e;let s=!0;for(;!0===i.call(this)&&!0===s;)s=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],i,768,t,Gs,s)}manySepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead(Fo,t);this.manySepFirstInternalLogic(t,e,n)}manySepFirstInternalLogic(t,e,n){const r=e.DEF,i=e.SEP;if(!0===this.getLaFuncFromCache(n).call(this)){r.call(this);const e=()=>this.tokenMatcher(this.LA_FAST(1),i);for(;!0===this.tokenMatcher(this.LA_FAST(1),i);)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,e,r,zs],e,Fo,t,zs)}}repetitionSepSecondInternal(t,e,n,r,i){for(;n();)this.CONSUME(e),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,r,i],n,Bo,t,i)}doSingleRepetition(t){const e=this.getLexerPosition();return t.call(this),this.getLexerPosition()>e}orInternal(t,e){const n=this.getKeyForAutomaticLookahead(256,e),r=I(t)?t:t.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(void 0!==i)return r[i].ALT.call(this);this.raiseNoAltException(e,t.ERR_MSG)}ruleFinallyStateUpdate(){this.RULE_STACK_IDX--,this.RULE_OCCURRENCE_STACK_IDX--,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX]),this.cstFinallyStateUpdate()}subruleInternal(t,e,n){let r;try{const i=void 0!==n?n.ARGS:void 0;return this.subruleIdx=e,r=t.coreRule.apply(this,i),this.cstPostNonTerminal(r,void 0!==n&&void 0!==n.LABEL?n.LABEL:t.ruleName),r}catch(i){throw this.subruleInternalError(i,n,t.ruleName)}}subruleInternalError(t,e,n){throw Io(t)&&void 0!==t.partialCstResult&&(this.cstPostNonTerminal(t.partialCstResult,void 0!==e&&void 0!==e.LABEL?e.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,e,n){let r;try{const e=this.LA_FAST(1);!0===this.tokenMatcher(e,t)?(this.consumeToken(),r=e):this.consumeInternalError(t,e,n)}catch(i){r=this.consumeInternalRecovery(t,e,i)}return this.cstPostTerminal(void 0!==n&&void 0!==n.LABEL?n.LABEL:t.name,r),r}consumeInternalError(t,e,n){let r;const i=this.LA(0);throw r=void 0!==n&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:e,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new xo(r,e,i))}consumeInternalRecovery(t,e,n){if(!this.recoveryEnabled||"MismatchedTokenException"!==n.name||this.isBackTracking())throw n;{const i=this.getFollowsForInRuleRecovery(t,e);try{return this.tryInRuleRecovery(t,i)}catch(r){throw r.name===Mo?n:r}}}saveRecogState(){const t=this.errors,e=this.RULE_STACK.slice(0,this.RULE_STACK_IDX+1);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:e,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState);const e=t.RULE_STACK;for(let n=0;n<e.length;n++)this.RULE_STACK[n]=e[n];this.RULE_STACK_IDX=e.length-1,this.RULE_STACK_IDX>=0&&(this.currRuleShortName=this.RULE_STACK[this.RULE_STACK_IDX])}ruleInvocationStateUpdate(t,e,n){this.RULE_OCCURRENCE_STACK[++this.RULE_OCCURRENCE_STACK_IDX]=n,this.RULE_STACK[++this.RULE_STACK_IDX]=t,this.currRuleShortName=t,this.cstInvocationStateUpdate(e)}isBackTracking(){return 0!==this.isBackTrackingStack.length}getCurrRuleFullName(){const t=this.currRuleShortName;return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Ms)}reset(){this.resetLexerState(),this.subruleIdx=0,this.currRuleShortName=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK_IDX=-1,this.RULE_OCCURRENCE_STACK_IDX=-1,this.CST_STACK=[]}onBeforeParse(t){for(let e=0;e<this.maxLookahead+1;e++)this.tokVector.push(oa)}onAfterParse(t){if(!1===this.isAtEndOfInput()){const t=this.LA(1),e=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new _o(e,t))}for(;this.tokVector.at(-1)===oa;)this.tokVector.pop()}},class{ACTION(t){return t.call(this)}consume(t,e,n){return this.consumeInternal(e,t,n)}subrule(t,e,n){return this.subruleInternal(e,t,n)}option(t,e){return this.optionInternal(e,t)}or(t,e){return this.orInternal(e,t)}many(t,e){return this.manyInternal(t,e)}atLeastOne(t,e){return this.atLeastOneInternal(t,e)}CONSUME(t,e){return this.consumeInternal(t,0,e)}CONSUME1(t,e){return this.consumeInternal(t,1,e)}CONSUME2(t,e){return this.consumeInternal(t,2,e)}CONSUME3(t,e){return this.consumeInternal(t,3,e)}CONSUME4(t,e){return this.consumeInternal(t,4,e)}CONSUME5(t,e){return this.consumeInternal(t,5,e)}CONSUME6(t,e){return this.consumeInternal(t,6,e)}CONSUME7(t,e){return this.consumeInternal(t,7,e)}CONSUME8(t,e){return this.consumeInternal(t,8,e)}CONSUME9(t,e){return this.consumeInternal(t,9,e)}SUBRULE(t,e){return this.subruleInternal(t,0,e)}SUBRULE1(t,e){return this.subruleInternal(t,1,e)}SUBRULE2(t,e){return this.subruleInternal(t,2,e)}SUBRULE3(t,e){return this.subruleInternal(t,3,e)}SUBRULE4(t,e){return this.subruleInternal(t,4,e)}SUBRULE5(t,e){return this.subruleInternal(t,5,e)}SUBRULE6(t,e){return this.subruleInternal(t,6,e)}SUBRULE7(t,e){return this.subruleInternal(t,7,e)}SUBRULE8(t,e){return this.subruleInternal(t,8,e)}SUBRULE9(t,e){return this.subruleInternal(t,9,e)}OPTION(t){return this.optionInternal(t,0)}OPTION1(t){return this.optionInternal(t,1)}OPTION2(t){return this.optionInternal(t,2)}OPTION3(t){return this.optionInternal(t,3)}OPTION4(t){return this.optionInternal(t,4)}OPTION5(t){return this.optionInternal(t,5)}OPTION6(t){return this.optionInternal(t,6)}OPTION7(t){return this.optionInternal(t,7)}OPTION8(t){return this.optionInternal(t,8)}OPTION9(t){return this.optionInternal(t,9)}OR(t){return this.orInternal(t,0)}OR1(t){return this.orInternal(t,1)}OR2(t){return this.orInternal(t,2)}OR3(t){return this.orInternal(t,3)}OR4(t){return this.orInternal(t,4)}OR5(t){return this.orInternal(t,5)}OR6(t){return this.orInternal(t,6)}OR7(t){return this.orInternal(t,7)}OR8(t){return this.orInternal(t,8)}OR9(t){return this.orInternal(t,9)}MANY(t){this.manyInternal(0,t)}MANY1(t){this.manyInternal(1,t)}MANY2(t){this.manyInternal(2,t)}MANY3(t){this.manyInternal(3,t)}MANY4(t){this.manyInternal(4,t)}MANY5(t){this.manyInternal(5,t)}MANY6(t){this.manyInternal(6,t)}MANY7(t){this.manyInternal(7,t)}MANY8(t){this.manyInternal(8,t)}MANY9(t){this.manyInternal(9,t)}MANY_SEP(t){this.manySepFirstInternal(0,t)}MANY_SEP1(t){this.manySepFirstInternal(1,t)}MANY_SEP2(t){this.manySepFirstInternal(2,t)}MANY_SEP3(t){this.manySepFirstInternal(3,t)}MANY_SEP4(t){this.manySepFirstInternal(4,t)}MANY_SEP5(t){this.manySepFirstInternal(5,t)}MANY_SEP6(t){this.manySepFirstInternal(6,t)}MANY_SEP7(t){this.manySepFirstInternal(7,t)}MANY_SEP8(t){this.manySepFirstInternal(8,t)}MANY_SEP9(t){this.manySepFirstInternal(9,t)}AT_LEAST_ONE(t){this.atLeastOneInternal(0,t)}AT_LEAST_ONE1(t){return this.atLeastOneInternal(1,t)}AT_LEAST_ONE2(t){this.atLeastOneInternal(2,t)}AT_LEAST_ONE3(t){this.atLeastOneInternal(3,t)}AT_LEAST_ONE4(t){this.atLeastOneInternal(4,t)}AT_LEAST_ONE5(t){this.atLeastOneInternal(5,t)}AT_LEAST_ONE6(t){this.atLeastOneInternal(6,t)}AT_LEAST_ONE7(t){this.atLeastOneInternal(7,t)}AT_LEAST_ONE8(t){this.atLeastOneInternal(8,t)}AT_LEAST_ONE9(t){this.atLeastOneInternal(9,t)}AT_LEAST_ONE_SEP(t){this.atLeastOneSepFirstInternal(0,t)}AT_LEAST_ONE_SEP1(t){this.atLeastOneSepFirstInternal(1,t)}AT_LEAST_ONE_SEP2(t){this.atLeastOneSepFirstInternal(2,t)}AT_LEAST_ONE_SEP3(t){this.atLeastOneSepFirstInternal(3,t)}AT_LEAST_ONE_SEP4(t){this.atLeastOneSepFirstInternal(4,t)}AT_LEAST_ONE_SEP5(t){this.atLeastOneSepFirstInternal(5,t)}AT_LEAST_ONE_SEP6(t){this.atLeastOneSepFirstInternal(6,t)}AT_LEAST_ONE_SEP7(t){this.atLeastOneSepFirstInternal(7,t)}AT_LEAST_ONE_SEP8(t){this.atLeastOneSepFirstInternal(8,t)}AT_LEAST_ONE_SEP9(t){this.atLeastOneSepFirstInternal(9,t)}RULE(t,e,n=ca){if(br(this.definedRulesNames,t)){const e={message:Fs.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:ha.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(e)}this.definedRulesNames.push(t);const r=this.defineRule(t,e,n);return this[t]=r,r}OVERRIDE_RULE(t,e,n=ca){const r=function(t,e,n){const r=[];let i;return br(e,t)||(i=`Invalid rule override, rule: ->${t}<- cannot be overridden in the grammar: ->${n}<-as it is not defined in any of the super grammars `,r.push({message:i,type:ha.INVALID_RULE_OVERRIDE,ruleName:t})),r}(t,this.definedRulesNames,this.className);this.definitionErrors=this.definitionErrors.concat(r);const i=this.defineRule(t,e,n);return this[t]=i,i}BACKTRACK(t,e){var n;const r=null!==(n=t.coreRule)&&void 0!==n?n:t;return function(){this.isBackTrackingStack.push(1);const t=this.saveRecogState();try{return r.apply(this,e),!0}catch(n){if(Io(n))return!1;throw n}finally{this.reloadRecogState(t),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return Or(_r(this.gastProductionsCache),li)}},class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=xr(t,"errorMessageProvider")?t.errorMessageProvider:aa.errorMessageProvider}SAVE_ERROR(t){if(Io(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:this.RULE_OCCURRENCE_STACK.slice(0,this.RULE_OCCURRENCE_STACK_IDX+1)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return Nn(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,e,n){const r=this.getCurrRuleFullName(),i=co(t,this.getGAstProductions()[r],e,this.maxLookahead)[0],s=[];for(let a=1;a<=this.maxLookahead;a++)s.push(this.LA(a));const o=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:s,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new Uo(o,this.LA(1),this.LA(0)))}raiseNoAltException(t,e){const n=this.getCurrRuleFullName(),r=ao(t,this.getGAstProductions()[n],this.maxLookahead),i=[];for(let a=1;a<=this.maxLookahead;a++)i.push(this.LA(a));const s=this.LA(0),o=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:s,customUserDescription:e,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new ko(o,this.LA(1),s))}},class{initContentAssist(){}computeContentAssist(t,e){const n=this.gastProductionsCache[t];if(Br(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return Ys([n],e,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){const e=Sr(t.ruleStack),n=this.getGAstProductions()[e];return new $s(n,t).startWalking()}},class{initGastRecorder(t){this.recordingProdStack=[],this.RECORDING_PHASE=!1}enableRecording(){this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",()=>{for(let t=0;t<10;t++){const e=t>0?t:"";this[`CONSUME${e}`]=function(e,n){return this.consumeInternalRecord(e,t,n)},this[`SUBRULE${e}`]=function(e,n){return this.subruleInternalRecord(e,t,n)},this[`OPTION${e}`]=function(e){return this.optionInternalRecord(e,t)},this[`OR${e}`]=function(e){return this.orInternalRecord(e,t)},this[`MANY${e}`]=function(e){this.manyInternalRecord(t,e)},this[`MANY_SEP${e}`]=function(e){this.manySepFirstInternalRecord(t,e)},this[`AT_LEAST_ONE${e}`]=function(e){this.atLeastOneInternalRecord(t,e)},this[`AT_LEAST_ONE_SEP${e}`]=function(e){this.atLeastOneSepFirstInternalRecord(t,e)}}this.consume=function(t,e,n){return this.consumeInternalRecord(e,t,n)},this.subrule=function(t,e,n){return this.subruleInternalRecord(e,t,n)},this.option=function(t,e){return this.optionInternalRecord(e,t)},this.or=function(t,e){return this.orInternalRecord(e,t)},this.many=function(t,e){this.manyInternalRecord(t,e)},this.atLeastOne=function(t,e){this.atLeastOneInternalRecord(t,e)},this.ACTION=this.ACTION_RECORD,this.BACKTRACK=this.BACKTRACK_RECORD,this.LA=this.LA_RECORD})}disableRecording(){this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",()=>{const t=this;for(let e=0;e<10;e++){const n=e>0?e:"";delete t[`CONSUME${n}`],delete t[`SUBRULE${n}`],delete t[`OPTION${n}`],delete t[`OR${n}`],delete t[`MANY${n}`],delete t[`MANY_SEP${n}`],delete t[`AT_LEAST_ONE${n}`],delete t[`AT_LEAST_ONE_SEP${n}`]}delete t.consume,delete t.subrule,delete t.option,delete t.or,delete t.many,delete t.atLeastOne,delete t.ACTION,delete t.BACKTRACK,delete t.LA})}ACTION_RECORD(t){}BACKTRACK_RECORD(t,e){return()=>!0}LA_RECORD(t){return oa}topLevelRuleRecord(t,e){try{const n=new ni({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),e.call(this),this.recordingProdStack.pop(),n}catch(n){if(!0!==n.KNOWN_RECORDER_ERROR)try{n.message=n.message+'\n\t This error was thrown during the "grammar recording phase" For more info see:\n\thttps://chevrotain.io/docs/guide/internals.html#grammar-recording'}catch(r){throw n}throw n}}optionInternalRecord(t,e){return na.call(this,ii,t,e)}atLeastOneInternalRecord(t,e){na.call(this,si,e,t)}atLeastOneSepFirstInternalRecord(t,e){na.call(this,oi,e,t,Zo)}manyInternalRecord(t,e){na.call(this,ai,e,t)}manySepFirstInternalRecord(t,e){na.call(this,ci,e,t,Zo)}orInternalRecord(t,e){return ra.call(this,t,e)}subruleInternalRecord(t,e,n){if(sa(e),!t||!1===xr(t,"ruleName")){const n=new Error(`<SUBRULE${ia(e)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=ar(this.recordingProdStack),i=t.ruleName,s=new ei({idx:e,nonTerminalName:i,label:null==n?void 0:n.LABEL,referencedRule:void 0});return r.definition.push(s),this.outputCst?ea:qo}consumeInternalRecord(t,e,n){if(sa(e),!fs(t)){const n=new Error(`<CONSUME${ia(e)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>\n inside top level rule: <${this.recordingProdStack[0].name}>`);throw n.KNOWN_RECORDER_ERROR=!0,n}const r=ar(this.recordingProdStack),i=new ui({idx:e,terminalType:t,label:null==n?void 0:n.LABEL});return r.definition.push(i),ta}},class{initPerformanceTracer(t){if(xr(t,"traceInitPerf")){const e=t.traceInitPerf,n="number"==typeof e;this.traceInitMaxIdent=n?e:1/0,this.traceInitPerf=n?e>0:e}else this.traceInitMaxIdent=0,this.traceInitPerf=aa.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,e){if(!0===this.traceInitPerf){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join("\t");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--\x3e <${t}>`);const{time:r,value:i}=Zr(e),s=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&s(`${n}<-- <${t}> time: ${r}ms`),this.traceInitIndent--,i}return e()}}].forEach(t=>{const e=t.prototype;Object.getOwnPropertyNames(e).forEach(n=>{if("constructor"===n)return;const r=Object.getOwnPropertyDescriptor(e,n);r&&(r.get||r.set)?Object.defineProperty(la.prototype,n,r):la.prototype[n]=t.prototype[n]})});class pa extends da{constructor(t,e=aa){const n=Nn(e);n.outputCst=!0,super(t,n)}}const fa=bs({name:"Whitespace",pattern:/[ \t\r\n]+/,group:Os.SKIPPED}),ma=bs({name:"LineComment",pattern:/\/\/[^\n]*/,group:Os.SKIPPED}),Ea=bs({name:"BlockComment",pattern:/\/\*[\s\S]*?\*\//,group:Os.SKIPPED}),ga=bs({name:"Identifier",pattern:/[A-Za-z_][A-Za-z0-9_]*/}),Ta=(t,e)=>bs({name:t,pattern:new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),longer_alt:ga}),Sa=Ta("Import","import"),La=Ta("Export","export"),Oa=Ta("From","from"),Ra=Ta("As","as"),Aa=Ta("Const","const"),va=Ta("Var","var"),ya=Ta("Let","let"),Na=Ta("Func","func"),Ia=Ta("Fai","fai"),Ca=Ta("Return","return"),xa=Ta("If","if"),ka=Ta("Else","else"),_a=Ta("For","for"),Ua=Ta("In","in"),ba=Ta("While","while"),Ma=Ta("Break","break"),Pa=Ta("Continue","continue"),wa=Ta("Try","try"),Da=Ta("Catch","catch"),Fa=Ta("True","true"),Ba=Ta("False","false"),ja=Ta("Null","null"),$a=Ta("KwEnum","enum"),Ka=Ta("KwArray","array"),Ga=Ta("KwObject","object"),za=bs({name:"FloatLit",pattern:/[0-9]+\.[0-9]+/}),Wa=bs({name:"IntLit",pattern:/[0-9]+/}),Va=bs({name:"StringLit",pattern:/"(?:[^"\\]|\\.)*"/}),Ha=bs({name:"Arrow",pattern:/->/}),Ya=bs({name:"FatArrow",pattern:/=>/}),Xa=bs({name:"EqEq",pattern:/==/}),qa=bs({name:"NotEq",pattern:/!=/}),Za=bs({name:"LtEq",pattern:/<=/}),Qa=bs({name:"GtEq",pattern:/>=/}),Ja=bs({name:"AndAnd",pattern:/&&/}),tc=bs({name:"OrOr",pattern:/\|\|/}),ec=bs({name:"PlusEq",pattern:/\+=/}),nc=bs({name:"MinusEq",pattern:/-=/}),rc=bs({name:"StarEq",pattern:/\*=/}),ic=bs({name:"SlashEq",pattern:/\/=/}),sc=bs({name:"PercentEq",pattern:/%=/}),oc=bs({name:"Spread",pattern:/\.\.\./}),ac=bs({name:"LCurly",pattern:/\{/}),cc=bs({name:"RCurly",pattern:/\}/}),hc=bs({name:"LParen",pattern:/\(/}),uc=bs({name:"RParen",pattern:/\)/}),lc=bs({name:"LBracket",pattern:/\[/}),dc=bs({name:"RBracket",pattern:/\]/}),pc=bs({name:"LAngle",pattern:/</}),fc=bs({name:"RAngle",pattern:/>/}),mc=bs({name:"Comma",pattern:/,/}),Ec=bs({name:"Colon",pattern:/:/}),gc=bs({name:"Semicolon",pattern:/;/}),Tc=bs({name:"Dot",pattern:/\./}),Sc=bs({name:"Question",pattern:/\?/}),Lc=bs({name:"AtName",pattern:/@[A-Za-z_][A-Za-z0-9_.\-]*/}),Oc=bs({name:"Plus",pattern:/\+/}),Rc=bs({name:"Dash",pattern:/-/}),Ac=bs({name:"Star",pattern:/\*/}),vc=bs({name:"Slash",pattern:/\//}),yc=bs({name:"Percent",pattern:/%/}),Nc=bs({name:"Bang",pattern:/!/}),Ic=bs({name:"Pipe",pattern:/\|/}),Cc=bs({name:"Equals",pattern:/=/}),xc=[fa,ma,Ea,Ha,Ya,Xa,qa,Za,Qa,Ja,tc,ec,nc,rc,ic,sc,oc,Sa,La,Oa,Ra,Aa,va,ya,Na,Ia,Ca,xa,ka,_a,ba,Ma,Pa,wa,Da,Fa,Ba,ja,$a,Ka,Ga,Ua,za,Wa,Va,ga,ac,cc,hc,uc,lc,dc,pc,fc,mc,Ec,gc,Tc,Sc,Lc,Oc,Rc,Ac,vc,yc,Nc,Ic,Cc],kc=new Os(xc,{positionTracking:"full",ensureOptimizations:!1});const _c=new class extends pa{constructor(){super(xc,{recoveryEnabled:!1}),e(this,"program",this.RULE("program",()=>{this.MANY(()=>this.SUBRULE(this.topLevel))})),e(this,"exprEntry",this.RULE("exprEntry",()=>{this.SUBRULE(this.expr)})),e(this,"topLevel",this.RULE("topLevel",()=>{this.OR([{ALT:()=>this.SUBRULE(this.importDecl)},{ALT:()=>this.SUBRULE(this.constDecl)},{ALT:()=>this.SUBRULE(this.varDecl)},{GATE:()=>this.isRuntimeAnnotation(),ALT:()=>this.SUBRULE(this.runtimeAnnotation)},{GATE:()=>this.isAnnotatedFuncOrFai(),ALT:()=>this.SUBRULE(this.annotatedDecl)},{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)},{ALT:()=>this.SUBRULE(this.exportDecl)}])})),e(this,"importDecl",this.RULE("importDecl",()=>{this.CONSUME(Sa),this.SUBRULE(this.importClause),this.CONSUME(Oa),this.CONSUME(Va),this.OPTION(()=>this.CONSUME(Lc))})),e(this,"importClause",this.RULE("importClause",()=>{this.OR([{ALT:()=>this.SUBRULE(this.namedImports)},{ALT:()=>this.SUBRULE(this.namespaceImport)}])})),e(this,"namedImports",this.RULE("namedImports",()=>{this.CONSUME(ac),this.SUBRULE(this.importSpec),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.importSpec)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"importSpec",this.RULE("importSpec",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)})})),e(this,"namespaceImport",this.RULE("namespaceImport",()=>{this.CONSUME(Ac),this.CONSUME(Ra),this.CONSUME(ga)})),e(this,"runtimeAnnotation",this.RULE("runtimeAnnotation",()=>{this.CONSUME(Lc),this.OPTION(()=>{this.CONSUME(hc),this.OPTION2(()=>this.SUBRULE(this.annoArgList)),this.CONSUME(uc)})})),e(this,"declAnnotation",this.RULE("declAnnotation",()=>{this.CONSUME(Lc),this.OPTION(()=>{this.CONSUME(hc),this.OPTION2(()=>this.SUBRULE(this.annoArgList)),this.CONSUME(uc)})})),e(this,"annoArgList",this.RULE("annoArgList",()=>{this.SUBRULE(this.annoArg),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.annoArg)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"annoArg",this.RULE("annoArg",()=>{this.OR([{GATE:()=>this.LA(1).tokenType===ga&&this.LA(2).tokenType===Cc,ALT:()=>{this.CONSUME(ga),this.CONSUME(Cc),this.SUBRULE(this.literal)}},{ALT:()=>this.SUBRULE2(this.literal)}])})),e(this,"annotatedDecl",this.RULE("annotatedDecl",()=>{this.AT_LEAST_ONE(()=>this.SUBRULE(this.declAnnotation)),this.OR([{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)}])})),e(this,"constDecl",this.RULE("constDecl",()=>{this.CONSUME(Aa),this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot),this.CONSUME(Cc),this.SUBRULE(this.expr)})),e(this,"varDecl",this.RULE("varDecl",()=>{this.CONSUME(va),this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot),this.OPTION(()=>{this.CONSUME(Cc),this.SUBRULE(this.expr)})})),e(this,"funcDecl",this.RULE("funcDecl",()=>{this.CONSUME(Na),this.CONSUME(ga),this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.paramList)),this.CONSUME(uc),this.OPTION2(()=>{this.CONSUME(Ha),this.SUBRULE(this.typeAnnot)}),this.SUBRULE(this.block)})),e(this,"faiDecl",this.RULE("faiDecl",()=>{this.CONSUME(Ia),this.CONSUME(ga),this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.faiParamList)),this.CONSUME(uc),this.CONSUME(Ha),this.SUBRULE(this.faiOutputList),this.SUBRULE(this.block)})),e(this,"exportDecl",this.RULE("exportDecl",()=>{this.CONSUME(La),this.OR([{ALT:()=>this.SUBRULE(this.exportNames)},{ALT:()=>this.SUBRULE(this.funcDecl)},{ALT:()=>this.SUBRULE(this.faiDecl)}])})),e(this,"exportNames",this.RULE("exportNames",()=>{this.OR([{ALT:()=>{this.SUBRULE(this.exportSpec)}},{ALT:()=>{this.CONSUME(ac),this.SUBRULE2(this.exportSpec),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE3(this.exportSpec)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)}}])})),e(this,"exportSpec",this.RULE("exportSpec",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)})})),e(this,"paramList",this.RULE("paramList",()=>{this.SUBRULE(this.param),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.param)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"param",this.RULE("param",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})})),e(this,"faiParamList",this.RULE("faiParamList",()=>{this.SUBRULE(this.faiParam),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.faiParam)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"faiParam",this.RULE("faiParam",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"faiOutputList",this.RULE("faiOutputList",()=>{this.SUBRULE(this.faiOutput),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.faiOutput)})})),e(this,"faiOutput",this.RULE("faiOutput",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"typeAnnot",this.RULE("typeAnnot",()=>{this.OR([{ALT:()=>this.SUBRULE(this.enumType)},{ALT:()=>this.SUBRULE(this.arrayType)},{ALT:()=>this.SUBRULE(this.objectType)},{ALT:()=>this.SUBRULE(this.scalarType)}])})),e(this,"scalarType",this.RULE("scalarType",()=>{this.CONSUME(ga),this.OPTION(()=>this.SUBRULE(this.typeConstraint))})),e(this,"enumType",this.RULE("enumType",()=>{this.CONSUME($a),this.CONSUME(Ec),this.CONSUME(ga),this.MANY(()=>{this.CONSUME(Ic),this.CONSUME2(ga)})})),e(this,"arrayType",this.RULE("arrayType",()=>{this.CONSUME(Ka),this.CONSUME(pc),this.SUBRULE(this.typeAnnot),this.CONSUME(fc),this.OPTION(()=>this.SUBRULE(this.namedConstraint))})),e(this,"objectType",this.RULE("objectType",()=>{this.CONSUME(Ga),this.CONSUME(ac),this.SUBRULE(this.objectTypeField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.objectTypeField)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"objectTypeField",this.RULE("objectTypeField",()=>{this.CONSUME(ga),this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)})),e(this,"typeConstraint",this.RULE("typeConstraint",()=>{this.OR([{GATE:()=>this.isRangeConstraint(),ALT:()=>this.SUBRULE(this.rangeConstraint)},{ALT:()=>this.SUBRULE(this.namedConstraint)}])})),e(this,"rangeConstraint",this.RULE("rangeConstraint",()=>{this.SUBRULE(this.numberLit),this.CONSUME(Rc),this.SUBRULE2(this.numberLit)})),e(this,"namedConstraint",this.RULE("namedConstraint",()=>{this.CONSUME(ga),this.CONSUME(Cc),this.OR([{ALT:()=>this.SUBRULE(this.numberLit)},{ALT:()=>this.CONSUME(Va)}])})),e(this,"numberLit",this.RULE("numberLit",()=>{this.OR([{ALT:()=>this.CONSUME(Wa)},{ALT:()=>this.CONSUME(za)}])})),e(this,"block",this.RULE("block",()=>{this.CONSUME(ac),this.MANY(()=>this.SUBRULE(this.stmt)),this.CONSUME(cc)})),e(this,"stmt",this.RULE("stmt",()=>{this.OR([{ALT:()=>this.SUBRULE(this.letDecl)},{ALT:()=>this.SUBRULE(this.ifStmt)},{ALT:()=>this.SUBRULE(this.forStmt)},{ALT:()=>this.SUBRULE(this.whileStmt)},{ALT:()=>this.SUBRULE(this.tryStmt)},{ALT:()=>this.SUBRULE(this.breakStmt)},{ALT:()=>this.SUBRULE(this.continueStmt)},{ALT:()=>this.SUBRULE(this.returnStmt)},{GATE:()=>this.isAssignment(),ALT:()=>this.SUBRULE(this.assignment)},{ALT:()=>this.SUBRULE(this.exprStmt)}]),this.OPTION(()=>this.CONSUME(gc))})),e(this,"letDecl",this.RULE("letDecl",()=>{this.CONSUME(ya),this.SUBRULE(this.letTarget),this.OPTION(()=>{this.CONSUME(Ec),this.SUBRULE(this.typeAnnot)}),this.OPTION2(()=>{this.CONSUME(Cc),this.SUBRULE(this.expr)})})),e(this,"letTarget",this.RULE("letTarget",()=>{this.OR([{ALT:()=>this.CONSUME(ga)},{ALT:()=>this.SUBRULE(this.objectDestruct)},{ALT:()=>this.SUBRULE(this.arrayDestruct)}])})),e(this,"objectDestruct",this.RULE("objectDestruct",()=>{this.CONSUME(ac),this.SUBRULE(this.destructField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.destructField)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(cc)})),e(this,"destructField",this.RULE("destructField",()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ec),this.CONSUME2(ga)})})),e(this,"arrayDestruct",this.RULE("arrayDestruct",()=>{this.CONSUME(lc),this.CONSUME(ga),this.MANY(()=>{this.CONSUME(mc),this.CONSUME2(ga)}),this.OPTION(()=>this.CONSUME2(mc)),this.CONSUME(dc)})),e(this,"assignment",this.RULE("assignment",()=>{this.SUBRULE(this.lvalue),this.SUBRULE(this.assignOp),this.SUBRULE(this.expr)})),e(this,"lvalue",this.RULE("lvalue",()=>{this.CONSUME(ga),this.MANY(()=>this.SUBRULE(this.lvalueSuffix))})),e(this,"lvalueSuffix",this.RULE("lvalueSuffix",()=>{this.OR([{ALT:()=>{this.CONSUME(Tc),this.CONSUME(ga)}},{ALT:()=>{this.CONSUME(lc),this.SUBRULE(this.expr),this.CONSUME(dc)}}])})),e(this,"assignOp",this.RULE("assignOp",()=>{this.OR([{ALT:()=>this.CONSUME(Cc)},{ALT:()=>this.CONSUME(ec)},{ALT:()=>this.CONSUME(nc)},{ALT:()=>this.CONSUME(rc)},{ALT:()=>this.CONSUME(ic)},{ALT:()=>this.CONSUME(sc)}])})),e(this,"ifStmt",this.RULE("ifStmt",()=>{this.CONSUME(xa),this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc),this.SUBRULE(this.block),this.MANY({GATE:()=>this.LA(1).tokenType===ka&&this.LA(2).tokenType===xa,DEF:()=>{this.CONSUME(ka),this.CONSUME2(xa),this.CONSUME2(hc),this.SUBRULE2(this.expr),this.CONSUME2(uc),this.SUBRULE2(this.block)}}),this.OPTION(()=>{this.CONSUME3(ka),this.SUBRULE3(this.block)})})),e(this,"forStmt",this.RULE("forStmt",()=>{this.CONSUME(_a),this.CONSUME(ga),this.CONSUME(Ua),this.SUBRULE(this.expr),this.SUBRULE(this.block)})),e(this,"whileStmt",this.RULE("whileStmt",()=>{this.CONSUME(ba),this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc),this.SUBRULE(this.block)})),e(this,"tryStmt",this.RULE("tryStmt",()=>{this.CONSUME(wa),this.SUBRULE(this.block),this.AT_LEAST_ONE(()=>this.SUBRULE(this.catchClause))})),e(this,"catchClause",this.RULE("catchClause",()=>{this.CONSUME(Da),this.CONSUME(ga),this.OPTION(()=>{this.CONSUME(Ra),this.CONSUME2(ga)}),this.SUBRULE(this.block)})),e(this,"breakStmt",this.RULE("breakStmt",()=>{this.CONSUME(Ma)})),e(this,"continueStmt",this.RULE("continueStmt",()=>{this.CONSUME(Pa)})),e(this,"returnStmt",this.RULE("returnStmt",()=>{this.CONSUME(Ca),this.OPTION({GATE:()=>this.canStartExpression(),DEF:()=>this.SUBRULE(this.expr)})})),e(this,"exprStmt",this.RULE("exprStmt",()=>{this.SUBRULE(this.expr)})),e(this,"expr",this.RULE("expr",()=>{this.SUBRULE(this.ternaryExpr)})),e(this,"ternaryExpr",this.RULE("ternaryExpr",()=>{this.SUBRULE(this.logicalOrExpr),this.OPTION(()=>{this.CONSUME(Sc),this.SUBRULE(this.expr),this.CONSUME(Ec),this.SUBRULE2(this.expr)})})),e(this,"logicalOrExpr",this.RULE("logicalOrExpr",()=>{this.SUBRULE(this.logicalAndExpr),this.MANY(()=>{this.CONSUME(tc),this.SUBRULE2(this.logicalAndExpr)})})),e(this,"logicalAndExpr",this.RULE("logicalAndExpr",()=>{this.SUBRULE(this.equalityExpr),this.MANY(()=>{this.CONSUME(Ja),this.SUBRULE2(this.equalityExpr)})})),e(this,"equalityExpr",this.RULE("equalityExpr",()=>{this.SUBRULE(this.comparisonExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Xa)},{ALT:()=>this.CONSUME(qa)}]),this.SUBRULE2(this.comparisonExpr)})})),e(this,"comparisonExpr",this.RULE("comparisonExpr",()=>{this.SUBRULE(this.additiveExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(pc)},{ALT:()=>this.CONSUME(Za)},{ALT:()=>this.CONSUME(fc)},{ALT:()=>this.CONSUME(Qa)}]),this.SUBRULE2(this.additiveExpr)})})),e(this,"additiveExpr",this.RULE("additiveExpr",()=>{this.SUBRULE(this.multiplicativeExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Oc)},{ALT:()=>this.CONSUME(Rc)}]),this.SUBRULE2(this.multiplicativeExpr)})})),e(this,"multiplicativeExpr",this.RULE("multiplicativeExpr",()=>{this.SUBRULE(this.unaryExpr),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(Ac)},{ALT:()=>this.CONSUME(vc)},{ALT:()=>this.CONSUME(yc)}]),this.SUBRULE2(this.unaryExpr)})})),e(this,"unaryExpr",this.RULE("unaryExpr",()=>{this.OPTION(()=>{this.OR([{ALT:()=>this.CONSUME(Rc)},{ALT:()=>this.CONSUME(Nc)}])}),this.SUBRULE(this.postfixExpr)})),e(this,"postfixExpr",this.RULE("postfixExpr",()=>{this.SUBRULE(this.primaryExpr),this.MANY(()=>this.SUBRULE(this.postfixSuffix))})),e(this,"postfixSuffix",this.RULE("postfixSuffix",()=>{this.OR([{ALT:()=>{this.CONSUME(Tc),this.CONSUME(ga)}},{ALT:()=>{this.CONSUME(lc),this.SUBRULE(this.expr),this.CONSUME(dc)}},{ALT:()=>{this.CONSUME(hc),this.OPTION(()=>this.SUBRULE(this.argList)),this.CONSUME(uc)}}])})),e(this,"argList",this.RULE("argList",()=>{this.SUBRULE(this.expr),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.expr)}),this.OPTION(()=>this.CONSUME2(mc))})),e(this,"primaryExpr",this.RULE("primaryExpr",()=>{this.OR([{ALT:()=>this.SUBRULE(this.literal)},{ALT:()=>this.CONSUME(ga)},{ALT:()=>this.SUBRULE(this.arrayLit)},{ALT:()=>this.SUBRULE(this.objectLit)},{ALT:()=>{this.CONSUME(hc),this.SUBRULE(this.expr),this.CONSUME(uc)}}])})),e(this,"literal",this.RULE("literal",()=>{this.OR([{ALT:()=>this.CONSUME(Wa)},{ALT:()=>this.CONSUME(za)},{ALT:()=>this.CONSUME(Va)},{ALT:()=>this.CONSUME(Fa)},{ALT:()=>this.CONSUME(Ba)},{ALT:()=>this.CONSUME(ja)}])})),e(this,"arrayLit",this.RULE("arrayLit",()=>{this.CONSUME(lc),this.OPTION(()=>{this.SUBRULE(this.expr),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.expr)}),this.OPTION2(()=>this.CONSUME2(mc))}),this.CONSUME(dc)})),e(this,"objectLit",this.RULE("objectLit",()=>{this.CONSUME(ac),this.OPTION(()=>{this.SUBRULE(this.objectLitField),this.MANY(()=>{this.CONSUME(mc),this.SUBRULE2(this.objectLitField)}),this.OPTION2(()=>this.CONSUME2(mc))}),this.CONSUME(cc)})),e(this,"objectLitField",this.RULE("objectLitField",()=>{this.OR([{GATE:()=>this.LA(1).tokenType===Va,ALT:()=>{this.CONSUME(Va),this.CONSUME(Ec),this.SUBRULE(this.expr)}},{ALT:()=>{this.CONSUME(ga),this.OPTION(()=>{this.CONSUME2(Ec),this.SUBRULE2(this.expr)})}}])})),this.performSelfAnalysis()}isRuntimeAnnotation(){const t=this.LA(1);return t.tokenType===Lc&&"@runtime"===t.image}isAnnotatedFuncOrFai(){let t=1;for(;this.LA(t).tokenType===Lc;)if(t++,this.LA(t).tokenType===hc){let e=1;for(t++;e>0&&this.LA(t).tokenType!==Ms;){const n=this.LA(t).tokenType;n===hc?e++:n===uc&&e--,t++}}const e=this.LA(t).tokenType;return e===Na||e===Ia}isRangeConstraint(){const t=this.LA(1).tokenType;return t===Wa||t===za}isAssignment(){if(this.LA(1).tokenType!==ga)return!1;let t=2,e=0;for(;;){const n=this.LA(t).tokenType;if(n===Ms)return!1;if(0===e){if(n===Cc||n===ec||n===nc||n===rc||n===ic||n===sc)return!0;if(n===gc||n===cc||n===ac||n===mc||n===uc)return!1;if(n===Tc||n===ga){t++;continue}if(n===lc||n===hc){e++,t++;continue}return!1}if(n===lc||n===hc?e++:n!==dc&&n!==uc||e--,t++,e<0)return!1}}canStartExpression(){const t=this.LA(1).tokenType;return t===Wa||t===za||t===Va||t===Fa||t===Ba||t===ja||t===ga||t===hc||t===lc||t===ac||t===Rc||t===Nc}};const Uc=_c.getBaseCstVisitorConstructor();function bc(t){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:t.endLine??0,endColumn:t.endColumn??0,startOffset:t.startOffset,endOffset:t.endOffset??t.startOffset}}function Mc(t){const e=t.location;return e?{startLine:e.startLine??0,startColumn:e.startColumn??0,endLine:e.endLine??0,endColumn:e.endColumn??0,startOffset:e.startOffset,endOffset:e.endOffset??e.startOffset}:{startLine:0,startColumn:0,endLine:0,endColumn:0,startOffset:0,endOffset:0}}function Pc(t){return wc(t.slice(1,-1))}function wc(t){return t.replace(/\\(.)/g,(t,e)=>{switch(e){case"n":return"\n";case"t":return"\t";case"r":return"\r";case"\\":return"\\";case'"':return'"';case"'":return"'";case"$":return"$";default:return e}})}function Dc(t){const e=t.image.slice(1,-1),n=bc(t),r=function(t){const e=[];let n="",r=0,i=0;const s=t=>{e.push({kind:"chunk",source:n,startInBody:r,endInBody:t}),n="",r=t};for(;i<t.length;)if("$"===t[i]&&"{"===t[i+1]){s(i);let o=1,a=i+2;for(;a<t.length&&o>0;){const e=t[a];if("{"===e)o++;else if("}"===e&&(o--,0===o))break;a++}if(0!==o){n+=t.slice(i),r=i,i=t.length;break}const c=t.slice(i+2,a);e.push({kind:"expr",source:c,startInBody:i,endInBody:a+1}),r=a+1,i=a+1}else"\\"===t[i]&&i+1<t.length?(n+=t.slice(i,i+2),i+=2):(n+=t[i],i++);return(e.some(t=>"expr"===t.kind)||0===e.length||n.length>0)&&s(t.length),e}(e);if(!r.some(t=>"expr"===t.kind)){return{kind:"StringLit",value:wc(r.map(t=>t.source).join("")),range:n}}const i=t.startOffset+1;return{kind:"TemplateString",parts:r.map(t=>{if("chunk"===t.kind)return{kind:"TemplateChunk",value:wc(t.source),range:Fc(n,i,t.startInBody,t.endInBody)};const e=function(t){const e=kc.tokenize(t);return _c.input=e.tokens,{cst:_c.exprEntry(),lexErrors:e.errors,parseErrors:_c.errors}}(t.source);if(e.lexErrors.length>0||e.parseErrors.length>0||!e.cst)return{kind:"TemplateChunk",value:"${"+t.source+"}",range:Fc(n,i,t.startInBody,t.endInBody)};return{kind:"TemplateExpr",expr:Hc.visit(e.cst),range:Fc(n,i,t.startInBody,t.endInBody)}}),range:n}}function Fc(t,e,n,r){return{startLine:t.startLine,startColumn:t.startColumn,endLine:t.endLine,endColumn:t.endColumn,startOffset:e+n,endOffset:e+r}}function Bc(t){return t.startsWith("@")?t.slice(1):t}function jc(t,e){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:e.endLine??0,endColumn:e.endColumn??0,startOffset:t.startOffset,endOffset:e.endOffset??e.startOffset}}function $c(t,e){return{startLine:t.startLine,startColumn:t.startColumn,endLine:e.endLine,endColumn:e.endColumn,startOffset:t.startOffset,endOffset:e.endOffset}}function Kc(t,e){return{startLine:t.startLine??0,startColumn:t.startColumn??0,endLine:e.endLine,endColumn:e.endColumn,startOffset:t.startOffset,endOffset:e.endOffset}}function Gc(t){if(0===t.length)return{startLine:0,startColumn:0,endLine:0,endColumn:0,startOffset:0,endOffset:0};return $c(t[0].range,t[t.length-1].range)}function zc(t){const e=t.children;let n;for(const r of Object.keys(e)){const t=e[r];for(const e of t){let t;t="image"in e?e:zc(e),t&&(!n||t.startOffset<n.startOffset)&&(n=t)}}return n}function Wc(t,e){let n=t[0];for(let r=0;r<e.length;r++){const i=t[r+1];n={kind:"BinaryExpr",op:e[r],left:n,right:i,range:$c(n.range,i.range)}}return n}function Vc(t,e){const n=[];for(const[r,i]of e){const e=t[r]??[];for(const t of e)n.push({offset:t.startOffset,op:i})}return n.sort((t,e)=>t.offset-e.offset),n.map(t=>t.op)}const Hc=new class extends Uc{constructor(){super(),this.validateVisitor()}exprEntry(t){return this.visit(t.expr[0])}program(t,e){const n=t.$cstNode??void 0,r=(t.topLevel??[]).map(t=>this.visit(t));return{kind:"Program",items:r,range:n?Mc(n):Gc(r)}}topLevel(t){if(t.importDecl)return this.visit(t.importDecl[0]);if(t.runtimeAnnotation)return this.visit(t.runtimeAnnotation[0]);if(t.constDecl)return this.visit(t.constDecl[0]);if(t.varDecl)return this.visit(t.varDecl[0]);if(t.annotatedDecl)return this.visit(t.annotatedDecl[0]);if(t.funcDecl)return this.visit(t.funcDecl[0]);if(t.faiDecl)return this.visit(t.faiDecl[0]);if(t.exportDecl)return this.visit(t.exportDecl[0]);throw new Error("unreachable: topLevel had no matching alternative")}importDecl(t){var e;const n=this.visit(t.importClause[0]),r=t.StringLit[0],i=null==(e=t.AtName)?void 0:e[0],s=t.Import[0],o=i??r;return{kind:"Import",clause:n,source:Pc(r.image),version:i?i.image.slice(1):null,range:jc(s,o)}}importClause(t){return t.namedImports?this.visit(t.namedImports[0]):this.visit(t.namespaceImport[0])}namedImports(t){return{kind:"NamedImports",specs:(t.importSpec??[]).map(t=>this.visit(t)),range:jc(t.LCurly[0],t.RCurly[0])}}importSpec(t){const e=t.Identifier;return{kind:"ImportSpec",name:e[0].image,alias:e.length>1?e[1].image:null,range:jc(e[0],e[e.length-1])}}namespaceImport(t){const e=t.Star[0],n=t.Identifier[0];return{kind:"NamespaceImport",alias:n.image,range:jc(e,n)}}runtimeAnnotation(t){var e,n;const r=t.AtName[0],i=null==(e=t.annoArgList)?void 0:e[0],s=i?this.visit(i):[],o=(null==(n=t.RParen)?void 0:n[0])??r;return{kind:"RuntimeAnnotation",name:Bc(r.image),args:s,range:jc(r,o)}}declAnnotation(t){var e,n;const r=t.AtName[0],i=null==(e=t.annoArgList)?void 0:e[0],s=i?this.visit(i):[],o=(null==(n=t.RParen)?void 0:n[0])??r;return{kind:"Annotation",name:Bc(r.image),args:s,range:jc(r,o)}}annoArgList(t){return(t.annoArg??[]).map(t=>this.visit(t))}annoArg(t){var e;const n=null==(e=t.Identifier)?void 0:e[0],r=t.literal[0],i=this.visit(r),s=n??zc(r),o=i.range;return{kind:"AnnotationArg",key:n?n.image:null,value:i,range:{startLine:(null==s?void 0:s.startLine)??o.startLine,startColumn:(null==s?void 0:s.startColumn)??o.startColumn,endLine:o.endLine,endColumn:o.endColumn,startOffset:(null==s?void 0:s.startOffset)??o.startOffset,endOffset:o.endOffset}}}annotatedDecl(t){const e=(t.declAnnotation??[]).map(t=>this.visit(t));let n;return n=t.funcDecl?this.visit(t.funcDecl[0]):this.visit(t.faiDecl[0]),{...n,annotations:e}}constDecl(t){const e=t.Const[0],n=t.Identifier[0],r=this.visit(t.typeAnnot[0]),i=this.visit(t.expr[0]);return{kind:"ConstDecl",name:n.image,type:r,value:i,range:Kc(e,i.range)}}varDecl(t){const e=t.Var[0],n=t.Identifier[0],r=this.visit(t.typeAnnot[0]),i=t.expr?this.visit(t.expr[0]):null,s=(null==i?void 0:i.range)??r.range;return{kind:"VarDecl",name:n.image,type:r,init:i,range:Kc(e,s)}}funcDecl(t){const e=t.Func[0],n=t.Identifier[0],r=t.paramList?this.visit(t.paramList[0]):[],i=t.typeAnnot?this.visit(t.typeAnnot[0]):null,s=this.visit(t.block[0]);return{kind:"FuncDecl",annotations:[],name:n.image,params:r,returnType:i,body:s,range:Kc(e,s.range)}}faiDecl(t){const e=t.Fai[0],n=t.Identifier[0],r=t.faiParamList?this.visit(t.faiParamList[0]):[],i=this.visit(t.faiOutputList[0]),s=this.visit(t.block[0]);return{kind:"FaiDecl",annotations:[],name:n.image,params:r,outputs:i,body:s,range:Kc(e,s.range)}}exportDecl(t){const e=t.Export[0];let n;return n=t.exportNames?this.visit(t.exportNames[0]):t.funcDecl?this.visit(t.funcDecl[0]):this.visit(t.faiDecl[0]),{kind:"ExportDecl",target:n,range:Kc(e,n.range)}}exportNames(t){const e=(t.exportSpec??[]).map(t=>this.visit(t));if(0===e.length)return{kind:"ExportNames",specs:[],range:Gc([])};return{kind:"ExportNames",specs:e,range:$c(e[0].range,e[e.length-1].range)}}exportSpec(t){const e=t.Identifier;return{kind:"ExportSpec",name:e[0].image,alias:e.length>1?e[1].image:null,range:jc(e[0],e[e.length-1])}}paramList(t){return(t.param??[]).map(t=>this.visit(t))}param(t){const e=t.Identifier[0],n=t.typeAnnot?this.visit(t.typeAnnot[0]):null,r=(null==n?void 0:n.range)??bc(e);return{kind:"Param",name:e.image,type:n,range:Kc(e,r)}}faiParamList(t){return(t.faiParam??[]).map(t=>this.visit(t))}faiParam(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"FaiParam",name:e.image,type:n,range:Kc(e,n.range)}}faiOutputList(t){return t.faiOutput.map(t=>this.visit(t))}faiOutput(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"FaiOutput",name:e.image,type:n,range:Kc(e,n.range)}}typeAnnot(t){return t.enumType?this.visit(t.enumType[0]):t.arrayType?this.visit(t.arrayType[0]):t.objectType?this.visit(t.objectType[0]):this.visit(t.scalarType[0])}scalarType(t){const e=t.Identifier[0],n=t.typeConstraint?this.visit(t.typeConstraint[0]):null,r=(null==n?void 0:n.range)??bc(e);return{kind:"ScalarType",name:e.image,constraint:n,range:Kc(e,r)}}enumType(t){const e=t.KwEnum[0];return{kind:"EnumType",variants:t.Identifier.map(t=>t.image),range:jc(e,t.Identifier.at(-1))}}arrayType(t){const e=t.KwArray[0],n=this.visit(t.typeAnnot[0]),r=t.RAngle[0],i=t.namedConstraint?this.visit(t.namedConstraint[0]):null;return{kind:"ArrayType",element:n,constraint:i,range:Kc(e,(null==i?void 0:i.range)??bc(r))}}objectType(t){const e=t.KwObject[0],n=t.RCurly[0];return{kind:"ObjectType",fields:(t.objectTypeField??[]).map(t=>this.visit(t)),range:jc(e,n)}}objectTypeField(t){const e=t.Identifier[0],n=this.visit(t.typeAnnot[0]);return{kind:"ObjectTypeField",name:e.image,type:n,range:Kc(e,n.range)}}typeConstraint(t){return t.rangeConstraint?this.visit(t.rangeConstraint[0]):this.visit(t.namedConstraint[0])}rangeConstraint(t){const e=t.numberLit.map(t=>this.visit(t));return{kind:"RangeConstraint",min:e[0].value,max:e[1].value,range:$c(e[0].range,e[1].range)}}namedConstraint(t){const e=t.Identifier[0];let n,r;if(t.numberLit){const e=this.visit(t.numberLit[0]);n=e.value,r=e.range}else{const e=t.StringLit[0];n=Pc(e.image),r=bc(e)}return{kind:"NamedConstraint",key:e.image,value:n,range:Kc(e,r)}}numberLit(t){if(t.IntLit){const e=t.IntLit[0];return{value:Number.parseInt(e.image,10),range:bc(e)}}const e=t.FloatLit[0];return{value:Number.parseFloat(e.image),range:bc(e)}}block(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"Block",stmts:(t.stmt??[]).map(t=>this.visit(t)),range:jc(e,n)}}stmt(t){if(t.letDecl)return this.visit(t.letDecl[0]);if(t.ifStmt)return this.visit(t.ifStmt[0]);if(t.forStmt)return this.visit(t.forStmt[0]);if(t.whileStmt)return this.visit(t.whileStmt[0]);if(t.tryStmt)return this.visit(t.tryStmt[0]);if(t.breakStmt)return this.visit(t.breakStmt[0]);if(t.continueStmt)return this.visit(t.continueStmt[0]);if(t.returnStmt)return this.visit(t.returnStmt[0]);if(t.assignment)return this.visit(t.assignment[0]);if(t.exprStmt)return this.visit(t.exprStmt[0]);throw new Error("unreachable: stmt had no matching alternative")}letDecl(t){const e=t.Let[0],n=this.visit(t.letTarget[0]),r=t.typeAnnot?this.visit(t.typeAnnot[0]):null,i=t.expr?this.visit(t.expr[0]):null;return{kind:"LetDecl",target:n,type:r,init:i,range:Kc(e,(null==i?void 0:i.range)??(null==r?void 0:r.range)??n.range)}}letTarget(t){if(t.Identifier){const e=t.Identifier[0];return{kind:"IdentTarget",name:e.image,range:bc(e)}}return t.objectDestruct?this.visit(t.objectDestruct[0]):this.visit(t.arrayDestruct[0])}objectDestruct(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"ObjectDestruct",fields:(t.destructField??[]).map(t=>this.visit(t)),range:jc(e,n)}}destructField(t){const e=t.Identifier,n=e[0].image;return{kind:"DestructField",source:n,local:e.length>1?e[1].image:n,range:jc(e[0],e[e.length-1])}}arrayDestruct(t){const e=t.LBracket[0],n=t.RBracket[0];return{kind:"ArrayDestruct",names:t.Identifier.map(t=>t.image),range:jc(e,n)}}assignment(t){const e=this.visit(t.lvalue[0]),n=this.visit(t.assignOp[0]),r=this.visit(t.expr[0]);return{kind:"Assignment",target:e,op:n,value:r,range:$c(e.range,r.range)}}lvalue(t){const e=t.Identifier[0],n=(t.lvalueSuffix??[]).map(t=>this.visit(t)),r=n.length>0?n[n.length-1].range:bc(e);return{kind:"LValue",base:e.image,suffixes:n,range:Kc(e,r)}}lvalueSuffix(t){if(t.Dot){const e=t.Dot[0],n=t.Identifier[0];return{kind:"MemberSuffix",name:n.image,range:jc(e,n)}}const e=t.LBracket[0],n=t.RBracket[0];return{kind:"IndexSuffix",index:this.visit(t.expr[0]),range:jc(e,n)}}assignOp(t){return t.Equals?"=":t.PlusEq?"+=":t.MinusEq?"-=":t.StarEq?"*=":t.SlashEq?"/=":"%="}ifStmt(t){var e;const n=t.If[0],r=t.expr,i=t.block,s=this.visit(r[0]),o=this.visit(i[0]),a=[];for(let u=1;u<r.length;u++){const t=this.visit(r[u]),e=this.visit(i[u]);a.push({kind:"ElseIf",cond:t,body:e,range:$c(t.range,e.range)})}let c=null;i.length>r.length&&(c=this.visit(i[i.length-1]));const h=(null==c?void 0:c.range)??(null==(e=a.at(-1))?void 0:e.range)??o.range;return{kind:"IfStmt",cond:s,then:o,elifs:a,otherwise:c,range:Kc(n,h)}}forStmt(t){const e=t.For[0],n=t.Identifier[0].image,r=this.visit(t.expr[0]),i=this.visit(t.block[0]);return{kind:"ForStmt",binding:n,iterable:r,body:i,range:Kc(e,i.range)}}whileStmt(t){const e=t.While[0],n=this.visit(t.expr[0]),r=this.visit(t.block[0]);return{kind:"WhileStmt",cond:n,body:r,range:Kc(e,r.range)}}tryStmt(t){var e;const n=t.Try[0],r=this.visit(t.block[0]),i=t.catchClause.map(t=>this.visit(t)),s=(null==(e=i.at(-1))?void 0:e.range)??r.range;return{kind:"TryStmt",body:r,catches:i,range:Kc(n,s)}}catchClause(t){const e=t.Catch[0],n=t.Identifier,r=n[0].image,i=n.length>1?n[1].image:null,s=this.visit(t.block[0]);return{kind:"CatchClause",errorType:r,binding:i,body:s,range:Kc(e,s.range)}}breakStmt(t){return{kind:"BreakStmt",range:bc(t.Break[0])}}continueStmt(t){return{kind:"ContinueStmt",range:bc(t.Continue[0])}}returnStmt(t){const e=t.Return[0],n=t.expr?this.visit(t.expr[0]):null;return{kind:"ReturnStmt",value:n,range:n?Kc(e,n.range):bc(e)}}exprStmt(t){const e=this.visit(t.expr[0]);return{kind:"ExprStmt",expr:e,range:e.range}}expr(t){return this.visit(t.ternaryExpr[0])}ternaryExpr(t){const e=this.visit(t.logicalOrExpr[0]);if(!t.expr)return e;const[n,r]=t.expr,i=this.visit(n),s=this.visit(r);return{kind:"TernaryExpr",cond:e,then:i,otherwise:s,range:$c(e.range,s.range)}}logicalOrExpr(t){return Wc(t.logicalAndExpr.map(t=>this.visit(t)),(t.OrOr??[]).map(()=>"||"))}logicalAndExpr(t){return Wc(t.equalityExpr.map(t=>this.visit(t)),(t.AndAnd??[]).map(()=>"&&"))}equalityExpr(t){return Wc(t.comparisonExpr.map(t=>this.visit(t)),Vc(t,[["EqEq","=="],["NotEq","!="]]))}comparisonExpr(t){return Wc(t.additiveExpr.map(t=>this.visit(t)),Vc(t,[["LAngle","<"],["LtEq","<="],["RAngle",">"],["GtEq",">="]]))}additiveExpr(t){return Wc(t.multiplicativeExpr.map(t=>this.visit(t)),Vc(t,[["Plus","+"],["Dash","-"]]))}multiplicativeExpr(t){return Wc(t.unaryExpr.map(t=>this.visit(t)),Vc(t,[["Star","*"],["Slash","/"],["Percent","%"]]))}unaryExpr(t){const e=this.visit(t.postfixExpr[0]);if(t.Dash){return{kind:"UnaryExpr",op:"-",operand:e,range:Kc(t.Dash[0],e.range)}}if(t.Bang){return{kind:"UnaryExpr",op:"!",operand:e,range:Kc(t.Bang[0],e.range)}}return e}postfixExpr(t){let e=this.visit(t.primaryExpr[0]);const n=t.postfixSuffix??[];for(const r of n){const t=this.visit(r);e="member"===t.tag?{kind:"MemberExpr",object:e,property:t.name,range:$c(e.range,t.range)}:"index"===t.tag?{kind:"IndexExpr",object:e,index:t.index,range:$c(e.range,t.range)}:{kind:"CallExpr",callee:e,args:t.args,range:$c(e.range,t.range)}}return e}postfixSuffix(t){if(t.Dot){const e=t.Dot[0],n=t.Identifier[0];return{tag:"member",name:n.image,range:jc(e,n)}}if(t.LBracket){const e=t.LBracket[0],n=t.RBracket[0];return{tag:"index",index:this.visit(t.expr[0]),range:jc(e,n)}}const e=t.LParen[0],n=t.RParen[0];return{tag:"call",args:t.argList?this.visit(t.argList[0]):[],range:jc(e,n)}}argList(t){return t.expr.map(t=>this.visit(t))}primaryExpr(t){if(t.literal)return this.visit(t.literal[0]);if(t.Identifier){const e=t.Identifier[0];return{kind:"IdentExpr",name:e.image,range:bc(e)}}return t.arrayLit?this.visit(t.arrayLit[0]):t.objectLit?this.visit(t.objectLit[0]):this.visit(t.expr[0])}literal(t){if(t.IntLit){const e=t.IntLit[0];return{kind:"IntLit",value:Number.parseInt(e.image,10),range:bc(e)}}if(t.FloatLit){const e=t.FloatLit[0];return{kind:"FloatLit",value:Number.parseFloat(e.image),range:bc(e)}}if(t.StringLit){return Dc(t.StringLit[0])}if(t.True){return{kind:"BoolLit",value:!0,range:bc(t.True[0])}}if(t.False){return{kind:"BoolLit",value:!1,range:bc(t.False[0])}}return{kind:"NullLit",range:bc(t.Null[0])}}arrayLit(t){const e=t.LBracket[0],n=t.RBracket[0];return{kind:"ArrayLit",elements:t.expr?t.expr.map(t=>this.visit(t)):[],range:jc(e,n)}}objectLit(t){const e=t.LCurly[0],n=t.RCurly[0];return{kind:"ObjectLit",fields:(t.objectLitField??[]).map(t=>this.visit(t)),range:jc(e,n)}}objectLitField(t){if(t.StringLit){const e=t.StringLit[0],n=this.visit(t.expr[0]);return{kind:"ObjectLitField",key:Pc(e.image),shorthand:!1,value:n,range:Kc(e,n.range)}}const e=t.Identifier[0];if(t.expr){const n=this.visit(t.expr[0]);return{kind:"ObjectLitField",key:e.image,shorthand:!1,value:n,range:Kc(e,n.range)}}return{kind:"ObjectLitField",key:e.image,shorthand:!0,value:{kind:"IdentExpr",name:e.image,range:bc(e)},range:bc(e)}}};function Yc(t){let e;try{e=function(t){const e=kc.tokenize(t);return _c.input=e.tokens,{cst:_c.program(),lexErrors:e.errors,parseErrors:_c.errors}}(t)}catch(i){return{ast:null,lexErrors:[],parseErrors:[{name:i.name??"ParseException",message:i.message??String(i),token:{startLine:1,startColumn:1,image:""}}]}}if(e.lexErrors.length>0||e.parseErrors.length>0||!e.cst)return{ast:null,lexErrors:e.lexErrors,parseErrors:e.parseErrors};let n=null;try{n=(r=e.cst)?Hc.visit(r):null}catch(i){return{ast:null,lexErrors:e.lexErrors,parseErrors:[...e.parseErrors,{name:i.name??"BuildAstException",message:`buildAst crashed: ${i.message??String(i)}`,token:{startLine:1,startColumn:1,image:""}}]}}var r;return{ast:n,lexErrors:e.lexErrors,parseErrors:e.parseErrors}}function Xc(t){return`(${t.params.map(t=>t.name).join(", ")})`}function qc(t){return`(${t.params.map(t=>t.name).join(", ")}) → ${t.outputs.map(t=>t.name).join(", ")}`}function Zc(t){switch(t){case"fai":return i.jsx(s,{className:"h-3.5 w-3.5 text-purple-500 dark:text-purple-400"});case"func":return i.jsx(u,{className:"h-3.5 w-3.5 text-blue-500 dark:text-blue-400"});case"const":return i.jsx(l,{className:"h-3.5 w-3.5 text-emerald-500 dark:text-emerald-400"});case"var":return i.jsx(d,{className:"h-3.5 w-3.5 text-amber-500 dark:text-amber-400"});case"export":return i.jsx(h,{className:"h-3.5 w-3.5 text-pink-500 dark:text-pink-400"});case"import":return i.jsx(h,{className:"h-3.5 w-3.5 rotate-180 text-cyan-500 dark:text-cyan-400"})}}function Qc({source:t,parseResult:e,onJump:n}){const s=r.useMemo(()=>{const n=e??Yc(t);return n.ast&&0===n.lexErrors.length&&0===n.parseErrors.length?function(t){const e=[];for(const n of t.items)switch(n.kind){case"Import":{const t=n;e.push({kind:"import",name:t.source,line:t.range.startLine,column:t.range.startColumn});break}case"ConstDecl":{const t=n;e.push({kind:"const",name:t.name,line:t.range.startLine,column:t.range.startColumn});break}case"VarDecl":{const t=n;e.push({kind:"var",name:t.name,line:t.range.startLine,column:t.range.startColumn});break}case"FuncDecl":{const t=n;e.push({kind:"func",name:t.name,signature:Xc(t),line:t.range.startLine,column:t.range.startColumn});break}case"FaiDecl":{const t=n;e.push({kind:"fai",name:t.name,signature:qc(t),line:t.range.startLine,column:t.range.startColumn});break}case"ExportDecl":{const t=n.target;if("ExportNames"===t.kind)for(const n of t.specs)e.push({kind:"export",name:n.alias??n.name,line:n.range.startLine,column:n.range.startColumn});else if("FuncDecl"===t.kind){const n=t;e.push({kind:"func",name:`export ${n.name}`,signature:Xc(n),line:n.range.startLine,column:n.range.startColumn})}else if("FaiDecl"===t.kind){const n=t;e.push({kind:"fai",name:`export ${n.name}`,signature:qc(n),line:n.range.startLine,column:n.range.startColumn})}break}}return e}(n.ast):function(t){const e=[],n=t.split(/\r?\n/),r=/^(import|export|const|var|fai|func)\s+([A-Za-z_]\w*)/;for(let i=0;i<n.length;i++){const t=r.exec(n[i]??"");if(!t)continue;const s=t[1],o=t[2]??"";o&&e.push({kind:s,name:o,line:i+1,column:1})}return e}(t)},[t,e]);return i.jsxs("div",{className:"h-full flex flex-col bg-muted/30",children:[i.jsxs("div",{className:"px-3 py-1.5 text-xs font-medium text-muted-foreground border-b border-border",children:["大纲 (",s.length,")"]}),i.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[0===s.length&&i.jsx("p",{className:"px-3 py-4 text-xs text-muted-foreground text-center",children:"(空)"}),s.map((t,e)=>i.jsxs("button",{className:"\n w-full flex items-center gap-2 px-3 py-1.5\n text-xs text-left hover:bg-accent\n transition-colors\n ",onClick:()=>n(t.line,t.column),title:`${t.kind} ${t.name}${t.signature??""} (行 ${t.line})`,children:[Zc(t.kind),i.jsxs("span",{className:"font-mono truncate flex-1",children:[t.name,t.signature&&i.jsx("span",{className:"text-muted-foreground ml-1",children:t.signature})]}),i.jsx("span",{className:"text-muted-foreground tabular-nums",children:t.line})]},`${t.kind}-${t.name}-${e}`))]})]})}const Jc=["import","export","from","as","const","var","let","func","fai","return","if","else","for","in","while","break","continue","try","catch"],th=["int","float","bool","string","prompt","any","enum","array","object"],eh=["true","false","null"],nh=["__ccweb_ask_user","len","push","concat","range","log","JSON","math","str"];let rh=!1;const ih=r.lazy(async()=>{const[t,e]=await Promise.all([c(()=>import("./editor.main-D97712kV.js").then(t=>t.e),__vite__mapDeps([0,1,2,3])),c(()=>import("./index-x6PSyNuH.js"),__vite__mapDeps([4,1,2]))]),n=t.default??t;return e.loader.config({monaco:n}),{default:e.default}});function sh(t,e){var n,r,i,s;const o=[];for(const a of t){const t=a,e=t.line??1,n=t.column??1,r=t.length??1;o.push({line:e,column:n,endLine:e,endColumn:n+r,message:t.message??"lex error"})}for(const a of e){const t=a,e=(null==(n=t.token)?void 0:n.startLine)??1,c=(null==(r=t.token)?void 0:r.startColumn)??1,h=(null==(s=null==(i=t.token)?void 0:i.image)?void 0:s.length)??1;o.push({line:e,column:c,endLine:e,endColumn:c+h,message:`${t.name??"ParseError"}: ${t.message??""}`})}return o}function oh({filename:t,initialSource:e,onCancel:n,onSave:s}){const{resolved:c}=o(),[h,u]=r.useState(e),[l,d]=r.useState(!1),[p,f]=r.useState(()=>Yc(e)),m=r.useMemo(()=>sh(p.lexErrors,p.parseErrors),[p]),E=r.useRef(null),g=r.useRef(null),T=r.useRef(null),S=r.useCallback(t=>{try{const e=Yc(t);f(e);const n=sh(e.lexErrors,e.parseErrors),r=g.current,i=E.current;if(r&&i){const t=i.getModel();t&&r.editor.setModelMarkers(t,"train-parser",n.map(t=>({startLineNumber:t.line,startColumn:t.column,endLineNumber:t.endLine,endColumn:t.endColumn,message:t.message,severity:r.MarkerSeverity.Error})))}}catch(e){f({ast:null,lexErrors:[],parseErrors:[{message:`parser crashed: ${e.message}`,name:"ParserCrash",token:{startLine:1,startColumn:1,image:""}}]})}},[]);r.useEffect(()=>(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>S(h),250),()=>{T.current&&clearTimeout(T.current)}),[h,S]);const L=r.useCallback(async()=>{if(!l){d(!0);try{await s(h)}finally{d(!1)}}},[l,h,s]);return i.jsxs("div",{className:"flex flex-col gap-2 h-full",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[i.jsx("span",{className:"text-sm font-mono text-muted-foreground truncate flex-1",children:t}),m.length>0?i.jsxs("span",{className:"text-xs text-red-600 dark:text-red-400",children:[m.length," 个问题"]}):i.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:"语法正确"}),i.jsx(a,{onClick:n,variant:"ghost",size:"sm",children:"取消"}),i.jsx(a,{onClick:L,size:"sm",disabled:l,children:l?"保存中…":"保存"})]}),i.jsxs("div",{className:"flex gap-2 flex-1 min-h-0",children:[i.jsx("div",{className:"flex-1 min-w-0 rounded-md border border-border overflow-hidden",children:i.jsx(r.Suspense,{fallback:i.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground",children:"加载编辑器…"}),children:i.jsx(ih,{height:"100%",defaultLanguage:"train",language:"train",value:h,onChange:t=>u(t??""),onMount:(t,e)=>{E.current=t,g.current=e,function(t){rh||(rh=!0,t.languages.register({id:"train",extensions:[".tr"],aliases:["train","tr"]}),t.languages.setLanguageConfiguration("train",{comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'}]}),t.languages.setMonarchTokensProvider("train",{defaultToken:"",keywords:Jc,typeKeywords:th,literals:eh,builtins:nh,operators:["=","==","!=","<=",">=","<",">","&&","||","+","-","*","/","%","!","?","??","->","=>","+=","-=","*=","/=","%="],symbols:/[=<>!?:&|+\-*\/%~^@]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4})/,tokenizer:{root:[[/@[A-Za-z_][\w.\-]*/,"annotation"],[/[A-Za-z_]\w*/,{cases:{"@keywords":"keyword","@typeKeywords":"type","@literals":"keyword.constant","@builtins":"predefined","@default":"identifier"}}],{include:"@whitespace"},[/\d*\.\d+([eE][\-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F_]+/,"number.hex"],[/0[bB][01_]+/,"number.binary"],[/0[oO][0-7_]+/,"number.octal"],[/\d+([eE][\-+]?\d+)?/,"number"],[/"([^"\\$]|\\.|\$(?!\{))*"/,"string"],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/[,;.]/,"delimiter"]],string:[[/[^\\"$]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/\$\{/,{token:"string.interpolation.open",bracket:"@open",next:"@interpolation"}],[/\$/,"string"],[/"/,{token:"string.quote",bracket:"@close",next:"@pop"}]],interpolation:[[/\}/,{token:"string.interpolation.close",bracket:"@close",next:"@pop"}],{include:"root"}],whitespace:[[/[ \t\r\n]+/,""],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]]}}))}(e),e.editor.setModelLanguage(t.getModel(),"train"),t.addCommand(e.KeyMod.CtrlCmd|e.KeyCode.KeyS,()=>{L()}),S(h)},theme:"dark"===c?"vs-dark":"vs",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",tabSize:2,insertSpaces:!0,wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0}})})}),i.jsx("div",{className:"w-56 flex-shrink-0 rounded-md border border-border overflow-hidden",children:i.jsx(Qc,{parseResult:p,source:h,onJump:(t,e)=>{const n=E.current;n&&(n.revealLineInCenter(t),n.setPosition({lineNumber:t,column:e}),n.focus())}})})]}),i.jsx("p",{className:"text-xs text-muted-foreground flex-shrink-0",children:".tr 源码 · train-lang DSL · Cmd/Ctrl+S 保存 · 实时语法检查 + AST 大纲"})]})}export{oh as TrackEditor};