@sheetxl/sdk 0.4.20 → 0.4.22

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 (105) hide show
  1. package/browser/cjs/7IXJLhV4t0ot3XB5.cjs +7 -0
  2. package/browser/cjs/{CHIrWDL1wDd2pj7r.cjs → 88wgo6pjVpM9y5ul.cjs} +1 -1
  3. package/browser/cjs/{CgISg2QUFvnxelIg.cjs → B1FA-mZrhIhB8VoC.cjs} +1 -1
  4. package/browser/cjs/{HoZidg9qBDX62oNO.cjs → BFSSWIb-BPsXlS8k.cjs} +1 -1
  5. package/browser/cjs/{lTo12h7XrLmPRVhi.cjs → BG_fhZO0IruefQYx.cjs} +1 -1
  6. package/browser/cjs/{aBAvcAfOvtWy7o9B.cjs → BHMiYQTwGjWzRdGf.cjs} +1 -1
  7. package/browser/cjs/{We0naT5G_vQo6RkK.cjs → BSj9kpCBxyd5EZvX.cjs} +1 -1
  8. package/browser/cjs/{B8nuUUIsnE-6vbAQ.cjs → BYwSD92n1THKdj9V.cjs} +1 -1
  9. package/browser/cjs/{CW9IcRQqCCBSJ1g0.cjs → Bein9-S48RBhhxLW.cjs} +1 -1
  10. package/browser/cjs/{C4KbNJbRD0LfrFFV.cjs → CFE-vojYpMggdKVQ.cjs} +1 -1
  11. package/browser/cjs/{BTPJz0JSs5PWhtbO.cjs → CGslljb6hC8DcpsE.cjs} +1 -1
  12. package/browser/cjs/{gn5aPOY6C-poXjky.cjs → CV_Kse7BQ7sBx0S2.cjs} +1 -1
  13. package/browser/cjs/{BfMzZ_GULllzBk6l.cjs → CW7Kbm45TFbAZYO3.cjs} +1 -1
  14. package/browser/cjs/{ZJeHuklpnM-x2Uor.cjs → Cx69pnzjeLfQMYgm.cjs} +1 -1
  15. package/browser/cjs/{BVwLRpPOJOkPiLVI.cjs → D1ZVN_gmSiXwUeCX.cjs} +1 -1
  16. package/browser/cjs/D1uvbAWH1atUhVUP.cjs +53 -0
  17. package/browser/cjs/{BvS85P-7zLIudyqb.cjs → D2eWn6G2QvkYzR0D.cjs} +1 -1
  18. package/browser/cjs/{CYueUIoDZwYE9fRk.cjs → D3ZDdkSutmtUfAG2.cjs} +1 -1
  19. package/browser/cjs/{BTa_vDbaAzt6YXV1.cjs → DItG5mSJNZ40zltg.cjs} +1 -1
  20. package/browser/cjs/{XxdMKuC0y29VOQ05.cjs → DMROSNSDJaUVqfoW.cjs} +1 -1
  21. package/browser/cjs/{Bw07AlLqg6ZIoMRL.cjs → DWG2lOB7T0SRr5Ni.cjs} +1 -1
  22. package/browser/cjs/Dub6MS5nk4D_Iv7p.cjs +124 -0
  23. package/browser/cjs/{BHa5nV8AH6dlgs29.cjs → Ko4UgjHi20zmyEpu.cjs} +1 -1
  24. package/browser/cjs/{CxXM6xsDd2bFDSNd.cjs → OgnqbIZEb37S4Hcz.cjs} +1 -1
  25. package/browser/cjs/{BkFMWwFWaisNXSf2.cjs → SkNXytY6UX9i6WhY.cjs} +2 -2
  26. package/browser/cjs/{CFwigDisNJzRlbSY.cjs → ZyyHV9ugA--j9V3Q.cjs} +1 -1
  27. package/browser/cjs/index.cjs +2 -2
  28. package/browser/cjs/{D9SMcp02EIWqiYk0.cjs → rPn2U0Q2Eagh41Xd.cjs} +1 -1
  29. package/browser/esm/{DK_FQ6Q7AZUprApR.mjs → -z0NclKcw0SSbo2L.mjs} +7603 -8898
  30. package/browser/esm/{DuvsEieHOiBb-GPZ.mjs → 45xuwq8di_97VrOg.mjs} +1 -1
  31. package/browser/esm/{CDbE_dl8edWRC33Z.mjs → B5M_o8HB4RRWBd_Y.mjs} +1 -1
  32. package/browser/esm/{9tFMamEgahdtRDzr.mjs → BANL0IBU0th0Z0aE.mjs} +1 -1
  33. package/browser/esm/{DOK9VvFQyTAsf7SL.mjs → BE-hRu2cYg4ljCeu.mjs} +1 -1
  34. package/browser/esm/{BNS7zLc3zoynBPYO.mjs → BcSVj-rRzZCTKFUS.mjs} +6 -4
  35. package/browser/esm/{DIePzm-XT-alFdDB.mjs → BsPKTSv0eCvPH73D.mjs} +1 -1
  36. package/{node/esm/Bqc8bvJoWC0_qUKU.mjs → browser/esm/C1VWw92RN5017GH2.mjs} +1 -1
  37. package/{node/esm/iYqJLAQld4jtK1Be.mjs → browser/esm/C1m7sGNTYP1bb_Uu.mjs} +1 -1
  38. package/{node/esm/DdDDFLZKFx1DAkKM.mjs → browser/esm/CB1_HpaA6RdaxTgB.mjs} +1 -1
  39. package/browser/esm/{DV9p0Ai4HUPYjT-H.mjs → CESAJuxgB8SgHaC0.mjs} +2 -2
  40. package/browser/esm/{_q37vK_NIykwwqbg.mjs → CF-2-aQTgc-DoXzn.mjs} +1 -1
  41. package/{node/esm/CivKgcEQiXpDFLHE.mjs → browser/esm/CIOhVshLBBACTKw4.mjs} +1 -1
  42. package/{node/esm/DlNI2fuUSYxsUPt8.mjs → browser/esm/CMSKXl6rbx5miTNQ.mjs} +1 -1
  43. package/{node/esm/D3YTY3N6YHU69ymA.mjs → browser/esm/CiTlupx_cuXQySFz.mjs} +1 -1
  44. package/browser/esm/{DoIENSc8L0Rof6Kz.mjs → D3P3XCQVij2nAmi9.mjs} +46 -44
  45. package/{node/esm/bIOUtGNQ6YQktkYZ.mjs → browser/esm/D6IgoU0LlIv_Vb4m.mjs} +1 -1
  46. package/{node/esm/DaJrKgrSikJvUv0q.mjs → browser/esm/DDHWZD7Y6pihyVio.mjs} +1 -1
  47. package/browser/esm/{mxJXDPqwl0wNxd66.mjs → DEAxRkKlMDxHooJB.mjs} +1 -1
  48. package/browser/esm/{BcUYcXaMbk6W8AWk.mjs → DI52n-xcpb7jEqop.mjs} +1 -1
  49. package/{node/esm/DP9RiXAeb1fiRFpG.mjs → browser/esm/Dd2ZeNLusT_ZXcoE.mjs} +1 -1
  50. package/browser/esm/{fP2GLQ5W7VVbn5TA.mjs → E-RGQA1dKJwkkonk.mjs} +1 -1
  51. package/{node/esm/aF3uflTbayaEj07D.mjs → browser/esm/NvmvIR3jfjlY98jJ.mjs} +1 -1
  52. package/browser/esm/{BoB-LPOX1uKjZhKH.mjs → OABZjfPgUYHzd5rY.mjs} +1 -1
  53. package/browser/esm/{BNURhfAYTEVJWTYT.mjs → XxsAmmMnL6UJ_NtN.mjs} +1 -1
  54. package/browser/esm/{io70M3K8dlSe5V-4.mjs → ease-qEarwjnTOzw.mjs} +1 -1
  55. package/browser/esm/index.mjs +54 -82
  56. package/{node/esm/HTDFLMWuQb82Y-GF.mjs → browser/esm/pyVBYhEMGgaVvnd1.mjs} +1 -1
  57. package/licenses/dependencies.txt +0 -66
  58. package/node/esm/{9tFMamEgahdtRDzr.mjs → BANL0IBU0th0Z0aE.mjs} +1 -1
  59. package/node/esm/{DOK9VvFQyTAsf7SL.mjs → BE-hRu2cYg4ljCeu.mjs} +1 -1
  60. package/node/esm/{BpBhk74DpxGo00aZ.mjs → BFQWsItEwIA8MHSr.mjs} +1 -1
  61. package/{browser/esm/Bqc8bvJoWC0_qUKU.mjs → node/esm/C1VWw92RN5017GH2.mjs} +1 -1
  62. package/{browser/esm/iYqJLAQld4jtK1Be.mjs → node/esm/C1m7sGNTYP1bb_Uu.mjs} +1 -1
  63. package/node/esm/{B7ZcsKf8cxOEMq7p.mjs → C2cb5mfR_vAlX9Fe.mjs} +1 -1
  64. package/node/esm/{CDjHCv3dEEOY9Foy.mjs → C5pshc3Ik9rfVQTG.mjs} +1 -1
  65. package/{browser/esm/DdDDFLZKFx1DAkKM.mjs → node/esm/CB1_HpaA6RdaxTgB.mjs} +1 -1
  66. package/node/esm/{MrOJ8ENTixputV8_.mjs → CE5UUdZ8bidtZxVI.mjs} +362 -360
  67. package/{browser/esm/CivKgcEQiXpDFLHE.mjs → node/esm/CIOhVshLBBACTKw4.mjs} +1 -1
  68. package/{browser/esm/DlNI2fuUSYxsUPt8.mjs → node/esm/CMSKXl6rbx5miTNQ.mjs} +1 -1
  69. package/node/esm/{Tl8jbxaeK1y9aMPJ.mjs → CNmI4DKpe0t8gN4o.mjs} +1 -1
  70. package/node/esm/{BXc12GgwQ08R7S8e.mjs → CPs770aIZwPh6mF0.mjs} +1 -1
  71. package/node/esm/{rpVHlxg6GM8pJL5c.mjs → Cb6FcT6gppjhiDSw.mjs} +253 -251
  72. package/{browser/esm/D3YTY3N6YHU69ymA.mjs → node/esm/CiTlupx_cuXQySFz.mjs} +1 -1
  73. package/{browser/esm/bIOUtGNQ6YQktkYZ.mjs → node/esm/D6IgoU0LlIv_Vb4m.mjs} +1 -1
  74. package/{browser/esm/DaJrKgrSikJvUv0q.mjs → node/esm/DDHWZD7Y6pihyVio.mjs} +1 -1
  75. package/node/esm/{mxJXDPqwl0wNxd66.mjs → DEAxRkKlMDxHooJB.mjs} +1 -1
  76. package/{browser/esm/DP9RiXAeb1fiRFpG.mjs → node/esm/Dd2ZeNLusT_ZXcoE.mjs} +1 -1
  77. package/node/esm/{C6lX28OYg20N0MeO.mjs → DzsYVdrM0pVVPfdv.mjs} +1 -1
  78. package/{browser/esm/aF3uflTbayaEj07D.mjs → node/esm/NvmvIR3jfjlY98jJ.mjs} +1 -1
  79. package/node/esm/{BNURhfAYTEVJWTYT.mjs → XxsAmmMnL6UJ_NtN.mjs} +1 -1
  80. package/node/esm/{io70M3K8dlSe5V-4.mjs → ease-qEarwjnTOzw.mjs} +1 -1
  81. package/node/esm/index.mjs +12252 -13543
  82. package/{browser/esm/HTDFLMWuQb82Y-GF.mjs → node/esm/pyVBYhEMGgaVvnd1.mjs} +1 -1
  83. package/node/esm/{CHnRYVDwiNY7YZxQ.mjs → xlM5nOnBp3h54uCb.mjs} +1 -1
  84. package/package.json +4 -4
  85. package/browser/cjs/BRvrxzKBJ-g1N73t.cjs +0 -1501
  86. package/browser/cjs/Ba3X8U1ch1pBFv_a.cjs +0 -124
  87. package/browser/cjs/C2DyH3SwPIgmFosH.cjs +0 -7
  88. package/browser/cjs/CEW45o7VnarqfsgH.cjs +0 -6
  89. package/browser/cjs/CZ4_zpdkkZ0zH7aN.cjs +0 -6
  90. package/browser/cjs/CbYFnsibjJUHV0xm.cjs +0 -6
  91. package/browser/cjs/D_zdscoLJ72sNgWv.cjs +0 -32
  92. package/browser/cjs/mf_wa0ubPjGaRkSW.cjs +0 -13
  93. package/browser/cjs/wcsUsHAbDuK3rvVp.cjs +0 -60
  94. package/browser/esm/B0RFp5vlJWj9U4Wn.mjs +0 -29
  95. package/browser/esm/BikAM7lQn1NrVPNP.mjs +0 -21
  96. package/browser/esm/C0d1-jgvvUt3Bpg9.mjs +0 -472
  97. package/browser/esm/CqYcEZmhnI3bq0wV.mjs +0 -820
  98. package/browser/esm/DbvBy4EEBdPhE-8G.mjs +0 -24
  99. package/browser/esm/DhIglmQyhLXPjrbo.mjs +0 -1575
  100. package/node/esm/BI2k0XM8cAqRUH3e.mjs +0 -80
  101. package/node/esm/BPSX88j1UHZNFlgn.mjs +0 -14
  102. package/node/esm/BcQcJWzyihj46-gX.mjs +0 -454
  103. package/node/esm/C4d62D9fLTRjV7rI.mjs +0 -29
  104. package/node/esm/D_13otLly5j8n5Gg.mjs +0 -813
  105. package/node/esm/Dsf-AEKpZlzGOrcG.mjs +0 -16
@@ -1,124 +0,0 @@
1
- "use strict";/**
2
- * @license @sheetxl/sdk - SDK - A high-performance, embeddable spreadsheet engine. - v0.4.20
3
- *
4
- * (C) 2025-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./wcsUsHAbDuK3rvVp.cjs");var vo=typeof global=="object"&&global&&global.Object===Object&&global,Ps=typeof self=="object"&&self&&self.Object===Object&&self,Ct=vo||Ps||Function("return this")(),Et=Ct.Symbol,No=Object.prototype,ws=No.hasOwnProperty,Ms=No.toString,Ee=Et?Et.toStringTag:void 0,Us=Object.prototype.toString,Wr=Et?Et.toStringTag:void 0;function Yt(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Wr&&Wr in Object(t)?function(e){var n=ws.call(e,Ee),r=e[Ee];try{e[Ee]=void 0;var i=!0}catch{}var o=Ms.call(e);return i&&(n?e[Ee]=r:delete e[Ee]),o}(t):function(e){return Us.call(e)}(t)}function Nt(t){return t!=null&&typeof t=="object"}function pn(t){return typeof t=="symbol"||Nt(t)&&Yt(t)=="[object Symbol]"}function mn(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}var D=Array.isArray,Gr=Et?Et.prototype:void 0,Kr=Gr?Gr.toString:void 0;function yo(t){if(typeof t=="string")return t;if(D(t))return mn(t,yo)+"";if(pn(t))return Kr?Kr.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Fs=/\s/,Ds=/^\s+/;function js(t){return t&&t.slice(0,function(e){for(var n=e.length;n--&&Fs.test(e.charAt(n)););return n}(t)+1).replace(Ds,"")}function gt(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Bs=/^[-+]0x[0-9a-f]+$/i,$s=/^0b[01]+$/i,Ws=/^0o[0-7]+$/i,Gs=parseInt,Ks=1/0;function zs(t){return t?(t=function(e){if(typeof e=="number")return e;if(pn(e))return NaN;if(gt(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=gt(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=js(e);var r=$s.test(e);return r||Ws.test(e)?Gs(e.slice(2),r?2:8):Bs.test(e)?NaN:+e}(t))===Ks||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:t===0?t:0}function En(t){var e=zs(t),n=e%1;return e==e?n?e-n:e:0}function le(t){return t}function Kt(t){if(!gt(t))return!1;var e=Yt(t);return e=="[object Function]"||e=="[object GeneratorFunction]"||e=="[object AsyncFunction]"||e=="[object Proxy]"}var zr,xn=Ct["__core-js_shared__"],Vr=(zr=/[^.]+$/.exec(xn&&xn.keys&&xn.keys.IE_PROTO||""))?"Symbol(src)_1."+zr:"",Vs=Function.prototype.toString;function ee(t){if(t!=null){try{return Vs.call(t)}catch{}try{return t+""}catch{}}return""}var Hs=/^\[object .+?Constructor\]$/,Ys=Function.prototype,Xs=Object.prototype,qs=Ys.toString,Zs=Xs.hasOwnProperty,Qs=RegExp("^"+qs.call(Zs).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Js(t){return!(!gt(t)||(e=t,Vr&&Vr in e))&&(Kt(t)?Qs:Hs).test(ee(t));var e}function ne(t,e){var n=function(r,i){return r?.[i]}(t,e);return Js(n)?n:void 0}var nr=ne(Ct,"WeakMap"),Hr=Object.create,ta=function(){function t(){}return function(e){if(!gt(e))return{};if(Hr)return Hr(e);t.prototype=e;var n=new t;return t.prototype=void 0,n}}();function q(){}var ea=Date.now,Yr,Cn,kn,nn=function(){try{var t=ne(Object,"defineProperty");return t({},"",{}),t}catch{}}(),na=nn?function(t,e){return nn(t,"toString",{configurable:!0,enumerable:!1,value:(n=e,function(){return n}),writable:!0});var n}:le,ra=(Yr=na,Cn=0,kn=0,function(){var t=ea(),e=16-(t-kn);if(kn=t,e>0){if(++Cn>=800)return arguments[0]}else Cn=0;return Yr.apply(void 0,arguments)});function Ro(t,e){for(var n=-1,r=t==null?0:t.length;++n<r&&e(t[n],n,t)!==!1;);return t}function Oo(t,e,n,r){for(var i=t.length,o=n+-1;++o<i;)if(e(t[o],o,t))return o;return-1}function ia(t){return t!=t}function Tr(t,e,n){return e==e?function(r,i,o){for(var s=o-1,a=r.length;++s<a;)if(r[s]===i)return s;return-1}(t,e,n):Oo(t,ia,n)}function So(t,e){return!!(t!=null&&t.length)&&Tr(t,e,0)>-1}var oa=/^(?:0|[1-9]\d*)$/;function gn(t,e){var n=typeof t;return!!(e=e??9007199254740991)&&(n=="number"||n!="symbol"&&oa.test(t))&&t>-1&&t%1==0&&t<e}function Ar(t,e,n){e=="__proto__"&&nn?nn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function Me(t,e){return t===e||t!=t&&e!=e}var sa=Object.prototype.hasOwnProperty;function Tn(t,e,n){var r=t[e];sa.call(t,e)&&Me(r,n)&&(n!==void 0||e in t)||Ar(t,e,n)}function rr(t,e,n,r){var i=!n;n||(n={});for(var o=-1,s=e.length;++o<s;){var a=e[o],c=void 0;c===void 0&&(c=t[a]),i?Ar(n,a,c):Tn(n,a,c)}return n}var Xr=Math.max;function Ir(t,e){return ra(function(n,r,i){return r=Xr(r===void 0?n.length-1:r,0),function(){for(var o=arguments,s=-1,a=Xr(o.length-r,0),c=Array(a);++s<a;)c[s]=o[r+s];s=-1;for(var u=Array(r+1);++s<r;)u[s]=o[s];return u[r]=i(c),function(l,h,f){switch(f.length){case 0:return l.call(h);case 1:return l.call(h,f[0]);case 2:return l.call(h,f[0],f[1]);case 3:return l.call(h,f[0],f[1],f[2])}return l.apply(h,f)}(n,this,u)}}(t,e,le),t+"")}function vr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=9007199254740991}function kt(t){return t!=null&&vr(t.length)&&!Kt(t)}function _o(t,e,n){if(!gt(n))return!1;var r=typeof e;return!!(r=="number"?kt(n)&&gn(e,n.length):r=="string"&&e in n)&&Me(n[e],t)}var aa=Object.prototype;function Ue(t){var e=t&&t.constructor;return t===(typeof e=="function"&&e.prototype||aa)}function qr(t){return Nt(t)&&Yt(t)=="[object Arguments]"}var Lo=Object.prototype,ca=Lo.hasOwnProperty,ua=Lo.propertyIsEnumerable,An=qr(function(){return arguments}())?qr:function(t){return Nt(t)&&ca.call(t,"callee")&&!ua.call(t,"callee")},xo=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Zr=xo&&typeof module=="object"&&module&&!module.nodeType&&module,Qr=Zr&&Zr.exports===xo?Ct.Buffer:void 0,Ce=(Qr?Qr.isBuffer:void 0)||function(){return!1},K={};function In(t){return function(e){return t(e)}}K["[object Float32Array]"]=K["[object Float64Array]"]=K["[object Int8Array]"]=K["[object Int16Array]"]=K["[object Int32Array]"]=K["[object Uint8Array]"]=K["[object Uint8ClampedArray]"]=K["[object Uint16Array]"]=K["[object Uint32Array]"]=!0,K["[object Arguments]"]=K["[object Array]"]=K["[object ArrayBuffer]"]=K["[object Boolean]"]=K["[object DataView]"]=K["[object Date]"]=K["[object Error]"]=K["[object Function]"]=K["[object Map]"]=K["[object Number]"]=K["[object Object]"]=K["[object RegExp]"]=K["[object Set]"]=K["[object String]"]=K["[object WeakMap]"]=!1;var Co=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Oe=Co&&typeof module=="object"&&module&&!module.nodeType&&module,bn=Oe&&Oe.exports===Co&&vo.process,Vt=function(){try{var t=Oe&&Oe.require&&Oe.require("util").types;return t||bn&&bn.binding&&bn.binding("util")}catch{}}(),Jr=Vt&&Vt.isTypedArray,Nr=Jr?In(Jr):function(t){return Nt(t)&&vr(t.length)&&!!K[Yt(t)]},la=Object.prototype.hasOwnProperty;function ko(t,e){var n=D(t),r=!n&&An(t),i=!n&&!r&&Ce(t),o=!n&&!r&&!i&&Nr(t),s=n||r||i||o,a=s?function(l,h){for(var f=-1,d=Array(l);++f<l;)d[f]=h(f);return d}(t.length,String):[],c=a.length;for(var u in t)!e&&!la.call(t,u)||s&&(u=="length"||i&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||gn(u,c))||a.push(u);return a}function bo(t,e){return function(n){return t(e(n))}}var ha=bo(Object.keys,Object),fa=Object.prototype.hasOwnProperty;function Po(t){if(!Ue(t))return ha(t);var e=[];for(var n in Object(t))fa.call(t,n)&&n!="constructor"&&e.push(n);return e}function Tt(t){return kt(t)?ko(t):Po(t)}var Pn,da=Object.prototype.hasOwnProperty,lt=(Pn=function(t,e){if(Ue(e)||kt(e))rr(e,Tt(e),t);else for(var n in e)da.call(e,n)&&Tn(t,n,e[n])},Ir(function(t,e){var n=-1,r=e.length,i=r>1?e[r-1]:void 0,o=r>2?e[2]:void 0;for(i=Pn.length>3&&typeof i=="function"?(r--,i):void 0,o&&_o(e[0],e[1],o)&&(i=r<3?void 0:i,r=1),t=Object(t);++n<r;){var s=e[n];s&&Pn(t,s,n,i)}return t})),pa=Object.prototype.hasOwnProperty;function ma(t){if(!gt(t))return function(i){var o=[];if(i!=null)for(var s in Object(i))o.push(s);return o}(t);var e=Ue(t),n=[];for(var r in t)(r!="constructor"||!e&&pa.call(t,r))&&n.push(r);return n}function wo(t){return kt(t)?ko(t,!0):ma(t)}var Ea=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ga=/^\w*$/;function yr(t,e){if(D(t))return!1;var n=typeof t;return!(n!="number"&&n!="symbol"&&n!="boolean"&&t!=null&&!pn(t))||ga.test(t)||!Ea.test(t)||e!=null&&t in Object(e)}var ge=ne(Object,"create"),Ta=Object.prototype.hasOwnProperty,Aa=Object.prototype.hasOwnProperty;function Zt(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Be(t,e){for(var n=t.length;n--;)if(Me(t[n][0],e))return n;return-1}Zt.prototype.clear=function(){this.__data__=ge?ge(null):{},this.size=0},Zt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Zt.prototype.get=function(t){var e=this.__data__;if(ge){var n=e[t];return n==="__lodash_hash_undefined__"?void 0:n}return Ta.call(e,t)?e[t]:void 0},Zt.prototype.has=function(t){var e=this.__data__;return ge?e[t]!==void 0:Aa.call(e,t)},Zt.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ge&&e===void 0?"__lodash_hash_undefined__":e,this};var Ia=Array.prototype.splice;function Bt(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Bt.prototype.clear=function(){this.__data__=[],this.size=0},Bt.prototype.delete=function(t){var e=this.__data__,n=Be(e,t);return!(n<0)&&(n==e.length-1?e.pop():Ia.call(e,n,1),--this.size,!0)},Bt.prototype.get=function(t){var e=this.__data__,n=Be(e,t);return n<0?void 0:e[n][1]},Bt.prototype.has=function(t){return Be(this.__data__,t)>-1},Bt.prototype.set=function(t,e){var n=this.__data__,r=Be(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this};var ke=ne(Ct,"Map");function $e(t,e){var n,r,i=t.__data__;return((r=typeof(n=e))=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null)?i[typeof e=="string"?"string":"hash"]:i.map}function $t(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}$t.prototype.clear=function(){this.size=0,this.__data__={hash:new Zt,map:new(ke||Bt),string:new Zt}},$t.prototype.delete=function(t){var e=$e(this,t).delete(t);return this.size-=e?1:0,e},$t.prototype.get=function(t){return $e(this,t).get(t)},$t.prototype.has=function(t){return $e(this,t).has(t)},$t.prototype.set=function(t,e){var n=$e(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this};function Rr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError("Expected a function");var n=function(){var r=arguments,i=e?e.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var s=t.apply(this,r);return n.cache=o.set(i,s)||o,s};return n.cache=new(Rr.Cache||$t),n}Rr.Cache=$t;var va=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Na=/\\(\\)?/g,ya=function(t){var e=Rr(t,function(r){return n.size===500&&n.clear(),r}),n=e.cache;return e}(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(va,function(n,r,i,o){e.push(i?o.replace(Na,"$1"):r||n)}),e});function vn(t,e){return D(t)?t:yr(t,e)?[t]:ya(function(n){return n==null?"":yo(n)}(t))}function Fe(t){if(typeof t=="string"||pn(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Or(t,e){for(var n=0,r=(e=vn(e,t)).length;t!=null&&n<r;)t=t[Fe(e[n++])];return n&&n==r?t:void 0}function Sr(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}var ti=Et?Et.isConcatSpreadable:void 0;function Ra(t){return D(t)||An(t)||!!(ti&&t&&t[ti])}function _r(t,e,n,r,i){var o=-1,s=t.length;for(n||(n=Ra),i||(i=[]);++o<s;){var a=t[o];n(a)?Sr(i,a):r||(i[i.length]=a)}return i}function It(t){return t!=null&&t.length?_r(t):[]}var Mo=bo(Object.getPrototypeOf,Object);function Uo(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 o=Array(i);++r<i;)o[r]=t[r+e];return o}function Oa(t,e,n,r){var i=-1,o=t==null?0:t.length;for(r&&o&&(n=t[++i]);++i<o;)n=e(n,t[i],i,t);return n}function Lt(t){var e=this.__data__=new Bt(t);this.size=e.size}Lt.prototype.clear=function(){this.__data__=new Bt,this.size=0},Lt.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},Lt.prototype.get=function(t){return this.__data__.get(t)},Lt.prototype.has=function(t){return this.__data__.has(t)},Lt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof Bt){var r=n.__data__;if(!ke||r.length<199)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new $t(r)}return n.set(t,e),this.size=n.size,this};var Fo=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ei=Fo&&typeof module=="object"&&module&&!module.nodeType&&module,ni=ei&&ei.exports===Fo?Ct.Buffer:void 0,ri=ni?ni.allocUnsafe:void 0;function Lr(t,e){for(var n=-1,r=t==null?0:t.length,i=0,o=[];++n<r;){var s=t[n];e(s,n,t)&&(o[i++]=s)}return o}function Do(){return[]}var Sa=Object.prototype.propertyIsEnumerable,ii=Object.getOwnPropertySymbols,xr=ii?function(t){return t==null?[]:(t=Object(t),Lr(ii(t),function(e){return Sa.call(t,e)}))}:Do,_a=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)Sr(e,xr(t)),t=Mo(t);return e}:Do;function jo(t,e,n){var r=e(t);return D(t)?r:Sr(r,n(t))}function ir(t){return jo(t,Tt,xr)}var or=ne(Ct,"DataView"),sr=ne(Ct,"Promise"),ce=ne(Ct,"Set"),oi="[object Map]",si="[object Promise]",ai="[object Set]",ci="[object WeakMap]",ui="[object DataView]",La=ee(or),xa=ee(ke),Ca=ee(sr),ka=ee(ce),ba=ee(nr),pt=Yt;(or&&pt(new or(new ArrayBuffer(1)))!=ui||ke&&pt(new ke)!=oi||sr&&pt(sr.resolve())!=si||ce&&pt(new ce)!=ai||nr&&pt(new nr)!=ci)&&(pt=function(t){var e=Yt(t),n=e=="[object Object]"?t.constructor:void 0,r=n?ee(n):"";if(r)switch(r){case La:return ui;case xa:return oi;case Ca:return si;case ka:return ai;case ba:return ci}return e});var Pa=Object.prototype.hasOwnProperty,rn=Ct.Uint8Array,wa=/\w*$/,li=Et?Et.prototype:void 0,hi=li?li.valueOf:void 0;function Ma(t,e,n){var r,i,o,s,a,c=t.constructor;switch(e){case"[object ArrayBuffer]":return a=new(s=t).constructor(s.byteLength),new rn(a).set(new rn(s)),a;case"[object Boolean]":case"[object Date]":return new c(+t);case"[object DataView]":return o=(i=t).buffer,new i.constructor(o,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(u){var l=u.buffer;return new u.constructor(l,u.byteOffset,u.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(u){var l=new u.constructor(u.source,wa.exec(u));return l.lastIndex=u.lastIndex,l}(t);case"[object Symbol]":return r=t,hi?Object(hi.call(r)):{}}}var fi=Vt&&Vt.isMap,Ua=fi?In(fi):function(t){return Nt(t)&&pt(t)=="[object Map]"},di=Vt&&Vt.isSet,Fa=di?In(di):function(t){return Nt(t)&&pt(t)=="[object Set]"},Bo="[object Arguments]",$o="[object Function]",Wo="[object Object]",W={};function Xe(t,e,n,r,i,o){var s;if(s!==void 0)return s;if(!gt(t))return t;var a=D(t);if(a)return s=function(f){var d=f.length,E=new f.constructor(d);return d&&typeof f[0]=="string"&&Pa.call(f,"index")&&(E.index=f.index,E.input=f.input),E}(t),function(f,d){var E=-1,I=f.length;for(d||(d=Array(I));++E<I;)d[E]=f[E];return d}(t,s);var c=pt(t),u=c==$o||c=="[object GeneratorFunction]";if(Ce(t))return function(f){var d=f.length,E=ri?ri(d):new f.constructor(d);return f.copy(E),E}(t);if(c==Wo||c==Bo||u&&!i)return s=u?{}:function(f){return typeof f.constructor!="function"||Ue(f)?{}:ta(Mo(f))}(t),function(f,d){return rr(f,xr(f),d)}(t,function(f,d){return f&&rr(d,Tt(d),f)}(s,t));if(!W[c])return i?t:{};s=Ma(t,c),o||(o=new Lt);var l=o.get(t);if(l)return l;o.set(t,s),Fa(t)?t.forEach(function(f){s.add(Xe(f,e,n,f,t,o))}):Ua(t)&&t.forEach(function(f,d){s.set(d,Xe(f,e,n,d,t,o))});var h=a?void 0:ir(t);return Ro(h||t,function(f,d){h&&(f=t[d=f]),Tn(s,d,Xe(f,e,n,d,t,o))}),s}W[Bo]=W["[object Array]"]=W["[object ArrayBuffer]"]=W["[object DataView]"]=W["[object Boolean]"]=W["[object Date]"]=W["[object Float32Array]"]=W["[object Float64Array]"]=W["[object Int8Array]"]=W["[object Int16Array]"]=W["[object Int32Array]"]=W["[object Map]"]=W["[object Number]"]=W[Wo]=W["[object RegExp]"]=W["[object Set]"]=W["[object String]"]=W["[object Symbol]"]=W["[object Uint8Array]"]=W["[object Uint8ClampedArray]"]=W["[object Uint16Array]"]=W["[object Uint32Array]"]=!0,W["[object Error]"]=W[$o]=W["[object WeakMap]"]=!1;function tt(t){return Xe(t,4)}function De(t){for(var e=-1,n=t==null?0:t.length,r=0,i=[];++e<n;){var o=t[e];o&&(i[r++]=o)}return i}function ue(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new $t;++e<n;)this.add(t[e])}function Go(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function Cr(t,e){return t.has(e)}ue.prototype.add=ue.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ue.prototype.has=function(t){return this.__data__.has(t)};function pi(t,e,n,r,i,o){var s=1&n,a=t.length,c=e.length;if(a!=c&&!(s&&c>a))return!1;var u=o.get(t),l=o.get(e);if(u&&l)return u==e&&l==t;var h=-1,f=!0,d=2&n?new ue:void 0;for(o.set(t,e),o.set(e,t);++h<a;){var E=t[h],I=e[h];if(r)var _=s?r(I,E,h,e,t,o):r(E,I,h,t,e,o);if(_!==void 0){if(_)continue;f=!1;break}if(d){if(!Go(e,function(T,m){if(!Cr(d,m)&&(E===T||i(E,T,n,r,o)))return d.push(m)})){f=!1;break}}else if(E!==I&&!i(E,I,n,r,o)){f=!1;break}}return o.delete(t),o.delete(e),f}function Da(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}function kr(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var mi=Et?Et.prototype:void 0,wn=mi?mi.valueOf:void 0,ja=Object.prototype.hasOwnProperty,Ei="[object Arguments]",gi="[object Array]",We="[object Object]",Ti=Object.prototype.hasOwnProperty;function Ba(t,e,n,r,i,o){var s=D(t),a=D(e),c=s?gi:pt(t),u=a?gi:pt(e),l=(c=c==Ei?We:c)==We,h=(u=u==Ei?We:u)==We,f=c==u;if(f&&Ce(t)){if(!Ce(e))return!1;s=!0,l=!1}if(f&&!l)return o||(o=new Lt),s||Nr(t)?pi(t,e,n,r,i,o):function(T,m,p,A,S,g,O){switch(p){case"[object DataView]":if(T.byteLength!=m.byteLength||T.byteOffset!=m.byteOffset)return!1;T=T.buffer,m=m.buffer;case"[object ArrayBuffer]":return!(T.byteLength!=m.byteLength||!g(new rn(T),new rn(m)));case"[object Boolean]":case"[object Date]":case"[object Number]":return Me(+T,+m);case"[object Error]":return T.name==m.name&&T.message==m.message;case"[object RegExp]":case"[object String]":return T==m+"";case"[object Map]":var N=Da;case"[object Set]":var v=1&A;if(N||(N=kr),T.size!=m.size&&!v)return!1;var y=O.get(T);if(y)return y==m;A|=2,O.set(T,m);var U=pi(N(T),N(m),A,S,g,O);return O.delete(T),U;case"[object Symbol]":if(wn)return wn.call(T)==wn.call(m)}return!1}(t,e,c,n,r,i,o);if(!(1&n)){var d=l&&Ti.call(t,"__wrapped__"),E=h&&Ti.call(e,"__wrapped__");if(d||E){var I=d?t.value():t,_=E?e.value():e;return o||(o=new Lt),i(I,_,n,r,o)}}return!!f&&(o||(o=new Lt),function(T,m,p,A,S,g){var O=1&p,N=ir(T),v=N.length;if(v!=ir(m).length&&!O)return!1;for(var y=v;y--;){var U=N[y];if(!(O?U in m:ja.call(m,U)))return!1}var M=g.get(T),F=g.get(m);if(M&&F)return M==m&&F==T;var $=!0;g.set(T,m),g.set(m,T);for(var C=O;++y<v;){var k=T[U=N[y]],j=m[U];if(A)var Y=O?A(j,k,U,m,T,g):A(k,j,U,T,m,g);if(!(Y===void 0?k===j||S(k,j,p,A,g):Y)){$=!1;break}C||(C=U=="constructor")}if($&&!C){var B=T.constructor,et=m.constructor;B==et||!("constructor"in T)||!("constructor"in m)||typeof B=="function"&&B instanceof B&&typeof et=="function"&&et instanceof et||($=!1)}return g.delete(T),g.delete(m),$}(t,e,n,r,i,o))}function br(t,e,n,r,i){return t===e||(t==null||e==null||!Nt(t)&&!Nt(e)?t!=t&&e!=e:Ba(t,e,n,r,br,i))}function Ko(t){return t==t&&!gt(t)}function zo(t,e){return function(n){return n!=null&&n[t]===e&&(e!==void 0||t in Object(n))}}function $a(t){var e=function(n){for(var r=Tt(n),i=r.length;i--;){var o=r[i],s=n[o];r[i]=[o,s,Ko(s)]}return r}(t);return e.length==1&&e[0][2]?zo(e[0][0],e[0][1]):function(n){return n===t||function(r,i,o,s){var a=o.length,c=a;if(r==null)return!c;for(r=Object(r);a--;){var u=o[a];if(u[2]?u[1]!==r[u[0]]:!(u[0]in r))return!1}for(;++a<c;){var l=(u=o[a])[0],h=r[l],f=u[1];if(u[2]){if(h===void 0&&!(l in r))return!1}else if(!br(f,h,3,s,new Lt))return!1}return!0}(n,0,e)}}function Wa(t,e){return t!=null&&e in Object(t)}function Vo(t,e,n){for(var r=-1,i=(e=vn(e,t)).length,o=!1;++r<i;){var s=Fe(e[r]);if(!(o=t!=null&&n(t,s)))break;t=t[s]}return o||++r!=i?o:!!(i=t==null?0:t.length)&&vr(i)&&gn(s,i)&&(D(t)||An(t))}function Ga(t,e){return yr(t)&&Ko(e)?zo(Fe(t),e):function(n){var r=function(i,o,s){var a=i==null?void 0:Or(i,o);return a===void 0?s:a}(n,t);return r===void 0&&r===e?function(i,o){return i!=null&&Vo(i,o,Wa)}(n,t):br(e,r,3)}}function Ka(t){return yr(t)?(e=Fe(t),function(n){return n?.[e]}):function(n){return function(r){return Or(r,n)}}(t);var e}function xt(t){return typeof t=="function"?t:t==null?le:typeof t=="object"?D(t)?Ga(t[0],t[1]):$a(t):Ka(t)}function za(t,e,n,r){for(var i=-1,o=t==null?0:t.length;++i<o;){var s=t[i];e(r,s,n(s),t)}return r}var Va=function(t,e,n){for(var r=-1,i=Object(t),o=n(t),s=o.length;s--;){var a=o[++r];if(e(i[a],a,i)===!1)break}return t},Ai,re=(Ai=function(t,e){return t&&Va(t,e,Tt)},function(t,e){if(t==null)return t;if(!kt(t))return Ai(t,e);for(var n=t.length,r=-1,i=Object(t);++r<n&&e(i[r],r,i)!==!1;);return t});function Ha(t,e,n,r){return re(t,function(i,o,s){e(r,i,n(i),s)}),r}var Ho=Object.prototype,Ya=Ho.hasOwnProperty,Pr=Ir(function(t,e){t=Object(t);var n=-1,r=e.length,i=r>2?e[2]:void 0;for(i&&_o(e[0],e[1],i)&&(r=1);++n<r;)for(var o=e[n],s=wo(o),a=-1,c=s.length;++a<c;){var u=s[a],l=t[u];(l===void 0||Me(l,Ho[u])&&!Ya.call(t,u))&&(t[u]=o[u])}return t});function Ii(t){return Nt(t)&&kt(t)}var on=Ir(function(t,e){return Ii(t)?function(n,r,i,o){var s=-1,a=So,c=!0,u=n.length,l=[],h=r.length;if(!u)return l;r.length>=200&&(a=Cr,c=!1,r=new ue(r));t:for(;++s<u;){var f=n[s],d=f;if(f=f!==0?f:0,c&&d==d){for(var E=h;E--;)if(r[E]===d)continue t;l.push(f)}else a(r,d,o)||l.push(f)}return l}(t,_r(e,0,Ii,!0)):[]});function he(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function J(t,e,n){var r=t==null?0:t.length;return r?Uo(t,(e=e===void 0?1:En(e))<0?0:e,r):[]}function be(t,e,n){var r=t==null?0:t.length;return r?Uo(t,0,(e=r-(e=e===void 0?1:En(e)))<0?0:e):[]}function b(t,e){var n;return(D(t)?Ro:re)(t,typeof(n=e)=="function"?n:le)}function Xa(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(!e(t[n],n,t))return!1;return!0}function qa(t,e){var n=!0;return re(t,function(r,i,o){return n=!!e(r,i,o)}),n}function vt(t,e,n){return(D(t)?Xa:qa)(t,xt(e))}function Yo(t,e){var n=[];return re(t,function(r,i,o){e(r,i,o)&&n.push(r)}),n}function dt(t,e){return(D(t)?Lr:Yo)(t,xt(e))}var Za=Math.max,vi,fe=(vi=function(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var i=n==null?0:En(n);return i<0&&(i=Za(r+i,0)),Oo(t,xt(e),i)},function(t,e,n){var r=Object(t);if(!kt(t)){var i=xt(e);t=Tt(t),e=function(s){return i(r[s],s,r)}}var o=vi(t,e,n);return o>-1?r[i?t[o]:o]:void 0});function yt(t){return t&&t.length?t[0]:void 0}function Qa(t,e){var n=-1,r=kt(t)?Array(t.length):[];return re(t,function(i,o,s){r[++n]=e(i,o,s)}),r}function L(t,e){return(D(t)?mn:Qa)(t,xt(e))}function mt(t,e){return _r(L(t,e))}var Ni,yi,Ja=Object.prototype.hasOwnProperty,tc=(Ni=function(t,e,n){Ja.call(t,n)?t[n].push(e):Ar(t,n,[e])},function(t,e){var n=D(t)?za:Ha,r=yi?yi():{};return n(t,Ni,xt(e),r)}),ec=Object.prototype.hasOwnProperty;function nc(t,e){return t!=null&&ec.call(t,e)}function x(t,e){return t!=null&&Vo(t,e,nc)}function at(t){return typeof t=="string"||!D(t)&&Nt(t)&&Yt(t)=="[object String]"}function Z(t){return t==null?[]:function(e,n){return mn(n,function(r){return e[r]})}(t,Tt(t))}var rc=Math.max;function it(t,e,n,r){t=kt(t)?t:Z(t),n=n?En(n):0;var i=t.length;return n<0&&(n=rc(i+n,0)),at(t)?n<=i&&t.indexOf(e,n)>-1:!!i&&Tr(t,e,n)>-1}function Ri(t,e,n){return t!=null&&t.length?Tr(t,e,0):-1}var ic=Object.prototype.hasOwnProperty;function G(t){if(t==null)return!0;if(kt(t)&&(D(t)||typeof t=="string"||typeof t.splice=="function"||Ce(t)||Nr(t)||An(t)))return!t.length;var e=pt(t);if(e=="[object Map]"||e=="[object Set]")return!t.size;if(Ue(t))return!Po(t).length;for(var n in t)if(ic.call(t,n))return!1;return!0}var Oi=Vt&&Vt.isRegExp,Wt=Oi?In(Oi):function(t){return Nt(t)&&Yt(t)=="[object RegExp]"};function Gt(t){return t===void 0}function oc(t,e,n,r){if(!gt(t))return t;for(var i=-1,o=(e=vn(e,t)).length,s=o-1,a=t;a!=null&&++i<o;){var c=Fe(e[i]),u=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=s){var l=a[c];(u=void 0)==void 0&&(u=gt(l)?l:gn(e[i+1])?[]:{})}Tn(a,c,u),a=a[c]}return t}function Rt(t,e){if(t==null)return{};var n=mn(function(r){return jo(r,wo,_a)}(t),function(r){return[r]});return e=xt(e),function(r,i,o){for(var s=-1,a=i.length,c={};++s<a;){var u=i[s],l=Or(r,u);o(l,u)&&oc(c,vn(u,r),l)}return c}(t,n,function(r,i){return e(r,i[0])})}function sc(t,e,n,r,i){return i(t,function(o,s,a){n=r?(r=!1,o):e(n,o,s,a)}),n}function ht(t,e,n){var r=D(t)?Oa:sc,i=arguments.length<3;return r(t,xt(e),n,i,re)}function Nn(t,e){return(D(t)?Lr:Yo)(t,function(n){if(typeof n!="function")throw new TypeError("Expected a function");return function(){var r=arguments;switch(r.length){case 0:return!n.call(this);case 1:return!n.call(this,r[0]);case 2:return!n.call(this,r[0],r[1]);case 3:return!n.call(this,r[0],r[1],r[2])}return!n.apply(this,r)}}(xt(e)))}function ac(t,e){var n;return re(t,function(r,i,o){return!(n=e(r,i,o))}),!!n}function Xo(t,e,n){return(D(t)?Go:ac)(t,xt(e))}var cc=ce&&1/kr(new ce([,-0]))[1]==1/0?function(t){return new ce(t)}:q;function ar(t){return t&&t.length?function(e,n,r){var i=-1,o=So,s=e.length,a=!0,c=[],u=c;if(s>=200){var l=cc(e);if(l)return kr(l);a=!1,o=Cr,u=new ue}else u=c;t:for(;++i<s;){var h=e[i],f=h;if(h=h!==0?h:0,a&&f==f){for(var d=u.length;d--;)if(u[d]===f)continue t;c.push(h)}else o(u,f,r)||(u!==c&&u.push(f),c.push(h))}return c}(t):[]}function cr(t){console&&console.error&&console.error(`Error: ${t}`)}function qo(t){console&&console.warn&&console.warn(`Warning: ${t}`)}function Zo(t){const e=new Date().getTime(),n=t();return{time:new Date().getTime()-e,value:n}}function Qo(t){function e(){}e.prototype=t;const n=new e;function r(){return typeof n.bar}return r(),r(),t}function uc(t){return at((e=t).LABEL)&&e.LABEL!==""?t.LABEL:t.name;var e}class bt{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){this._definition=e}accept(e){e.visit(this),b(this.definition,n=>{n.accept(e)})}}class ft extends bt{constructor(e){super([]),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}set definition(e){}get definition(){return this.referencedRule!==void 0?this.referencedRule.definition:[]}accept(e){e.visit(this)}}class de extends bt{constructor(e){super(e.definition),this.orgText="",lt(this,Rt(e,n=>n!==void 0))}}class ut extends bt{constructor(e){super(e.definition),this.ignoreAmbiguities=!1,lt(this,Rt(e,n=>n!==void 0))}}class ct extends bt{constructor(e){super(e.definition),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}}class Pt extends bt{constructor(e){super(e.definition),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}}class wt extends bt{constructor(e){super(e.definition),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}}class Q extends bt{constructor(e){super(e.definition),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}}class Ot extends bt{constructor(e){super(e.definition),this.idx=1,lt(this,Rt(e,n=>n!==void 0))}}class St extends bt{get definition(){return this._definition}set definition(e){this._definition=e}constructor(e){super(e.definition),this.idx=1,this.ignoreAmbiguities=!1,this.hasPredicates=!1,lt(this,Rt(e,n=>n!==void 0))}}class z{constructor(e){this.idx=1,lt(this,Rt(e,n=>n!==void 0))}accept(e){e.visit(this)}}function qe(t){function e(n){return L(n,qe)}if(t instanceof ft){const n={type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};return at(t.label)&&(n.label=t.label),n}if(t instanceof ut)return{type:"Alternative",definition:e(t.definition)};if(t instanceof ct)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof Pt)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof wt)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:qe(new z({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof Ot)return{type:"RepetitionWithSeparator",idx:t.idx,separator:qe(new z({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof Q)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof St)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof z){const n={type:"Terminal",name:t.terminalType.name,label:uc(t.terminalType),idx:t.idx};at(t.label)&&(n.terminalLabel=t.label);const r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=Wt(r)?r.source:r),n}if(t instanceof de)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}class pe{visit(e){const n=e;switch(n.constructor){case ft:return this.visitNonTerminal(n);case ut:return this.visitAlternative(n);case ct:return this.visitOption(n);case Pt:return this.visitRepetitionMandatory(n);case wt:return this.visitRepetitionMandatoryWithSeparator(n);case Ot:return this.visitRepetitionWithSeparator(n);case Q:return this.visitRepetition(n);case St:return this.visitAlternation(n);case z:return this.visitTerminal(n);case de:return this.visitRule(n);default:throw Error("non exhaustive match")}}visitNonTerminal(e){}visitAlternative(e){}visitOption(e){}visitRepetition(e){}visitRepetitionMandatory(e){}visitRepetitionMandatoryWithSeparator(e){}visitRepetitionWithSeparator(e){}visitAlternation(e){}visitTerminal(e){}visitRule(e){}}function sn(t,e=[]){return t instanceof ct||t instanceof Q||t instanceof Ot||(t instanceof St?Xo(t.definition,n=>sn(n,e)):!(t instanceof ft&&it(e,t))&&t instanceof bt&&(t instanceof ft&&e.push(t),vt(t.definition,n=>sn(n,e))))}function _t(t){if(t instanceof ft)return"SUBRULE";if(t instanceof ct)return"OPTION";if(t instanceof St)return"OR";if(t instanceof Pt)return"AT_LEAST_ONE";if(t instanceof wt)return"AT_LEAST_ONE_SEP";if(t instanceof Ot)return"MANY_SEP";if(t instanceof Q)return"MANY";if(t instanceof z)return"CONSUME";throw Error("non exhaustive match")}class yn{walk(e,n=[]){b(e.definition,(r,i)=>{const o=J(e.definition,i+1);if(r instanceof ft)this.walkProdRef(r,o,n);else if(r instanceof z)this.walkTerminal(r,o,n);else if(r instanceof ut)this.walkFlat(r,o,n);else if(r instanceof ct)this.walkOption(r,o,n);else if(r instanceof Pt)this.walkAtLeastOne(r,o,n);else if(r instanceof wt)this.walkAtLeastOneSep(r,o,n);else if(r instanceof Ot)this.walkManySep(r,o,n);else if(r instanceof Q)this.walkMany(r,o,n);else{if(!(r instanceof St))throw Error("non exhaustive match");this.walkOr(r,o,n)}})}walkTerminal(e,n,r){}walkProdRef(e,n,r){}walkFlat(e,n,r){const i=n.concat(r);this.walk(e,i)}walkOption(e,n,r){const i=n.concat(r);this.walk(e,i)}walkAtLeastOne(e,n,r){const i=[new ct({definition:e.definition})].concat(n,r);this.walk(e,i)}walkAtLeastOneSep(e,n,r){const i=Si(e,n,r);this.walk(e,i)}walkMany(e,n,r){const i=[new ct({definition:e.definition})].concat(n,r);this.walk(e,i)}walkManySep(e,n,r){const i=Si(e,n,r);this.walk(e,i)}walkOr(e,n,r){const i=n.concat(r);b(e.definition,o=>{const s=new ut({definition:[o]});this.walk(s,i)})}}function Si(t,e,n){return[new ct({definition:[new z({terminalType:t.separator})].concat(t.definition)})].concat(e,n)}function Se(t){if(t instanceof ft)return Se(t.referencedRule);if(t instanceof z)return[t.terminalType];if(function(e){return e instanceof ut||e instanceof ct||e instanceof Q||e instanceof Pt||e instanceof wt||e instanceof Ot||e instanceof z||e instanceof de}(t))return function(e){let n=[];const r=e.definition;let i,o=0,s=r.length>o,a=!0;for(;s&&a;)i=r[o],a=sn(i),n=n.concat(Se(i)),o+=1,s=r.length>o;return ar(n)}(t);if(function(e){return e instanceof St}(t))return function(e){const n=L(e.definition,r=>Se(r));return ar(It(n))}(t);throw Error("non exhaustive match")}const Jo="_~IN~_";class lc extends yn{constructor(e){super(),this.topProd=e,this.follows={}}startWalking(){return this.walk(this.topProd),this.follows}walkTerminal(e,n,r){}walkProdRef(e,n,r){const i=(o=e.referencedRule,s=e.idx,o.name+s+Jo+this.topProd.name);var o,s;const a=n.concat(r),c=Se(new ut({definition:a}));this.follows[i]=c}}function P(t){return t.charCodeAt(0)}function Mn(t,e){Array.isArray(t)?t.forEach(function(n){e.push(n)}):e.push(t)}function Te(t,e){if(t[e]===!0)throw"duplicate flag "+e;t[e],t[e]=!0}function ie(t){if(t===void 0)throw Error("Internal Error - Should never get here!");return!0}function _i(t){return t.type==="Character"}const an=[];for(let t=P("0");t<=P("9");t++)an.push(t);const cn=[P("_")].concat(an);for(let t=P("a");t<=P("z");t++)cn.push(t);for(let t=P("A");t<=P("Z");t++)cn.push(t);const Li=[P(" "),P("\f"),P(`
7
- `),P("\r"),P(" "),P("\v"),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P(" "),P("\u2028"),P("\u2029"),P(" "),P(" "),P(" "),P("\uFEFF")],hc=/[0-9a-fA-F]/,Ge=/[0-9]/,fc=/[1-9]/;class ur{visitChildren(e){for(const n in e){const r=e[n];e.hasOwnProperty(n)&&(r.type!==void 0?this.visit(r):Array.isArray(r)&&r.forEach(i=>{this.visit(i)},this))}}visit(e){switch(e.type){case"Pattern":this.visitPattern(e);break;case"Flags":this.visitFlags(e);break;case"Disjunction":this.visitDisjunction(e);break;case"Alternative":this.visitAlternative(e);break;case"StartAnchor":this.visitStartAnchor(e);break;case"EndAnchor":this.visitEndAnchor(e);break;case"WordBoundary":this.visitWordBoundary(e);break;case"NonWordBoundary":this.visitNonWordBoundary(e);break;case"Lookahead":this.visitLookahead(e);break;case"NegativeLookahead":this.visitNegativeLookahead(e);break;case"Character":this.visitCharacter(e);break;case"Set":this.visitSet(e);break;case"Group":this.visitGroup(e);break;case"GroupBackReference":this.visitGroupBackReference(e);break;case"Quantifier":this.visitQuantifier(e)}this.visitChildren(e)}visitPattern(e){}visitFlags(e){}visitDisjunction(e){}visitAlternative(e){}visitStartAnchor(e){}visitEndAnchor(e){}visitWordBoundary(e){}visitNonWordBoundary(e){}visitLookahead(e){}visitNegativeLookahead(e){}visitCharacter(e){}visitSet(e){}visitGroup(e){}visitGroupBackReference(e){}visitQuantifier(e){}}let Ze={};const dc=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":Te(n,"global");break;case"i":Te(n,"ignoreCase");break;case"m":Te(n,"multiLine");break;case"u":Te(n,"unicode");break;case"y":Te(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"}ie(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 r=this.integerIncludingZero();switch(this.popChar()){case"}":e={atLeast:r,atMost:r};break;case",":let i;this.isDigit()?(i=this.integerIncludingZero(),e={atLeast:r,atMost:i}):e={atLeast:r,atMost:1/0},this.consumeChar("}")}if(t===!0&&e===void 0)return;ie(e)}if(t!==!0||e!==void 0)return ie(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(t===void 0&&this.isPatternCharacter()&&(t=this.patternCharacter()),ie(t))return t.loc=this.loc(e),this.isQuantifier()&&(t.quantifier=this.quantifier()),t}dotAll(){return this.consumeChar("."),{type:"Set",complement:!0,value:[P(`
8
- `),P("\r"),P("\u2028"),P("\u2029")]}}atomEscape(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}decimalEscapeAtom(){return{type:"GroupBackReference",value:this.positiveInteger()}}characterClassEscape(){let t,e=!1;switch(this.popChar()){case"d":t=an;break;case"D":t=an,e=!0;break;case"s":t=Li;break;case"S":t=Li,e=!0;break;case"w":t=cn;break;case"W":t=cn,e=!0}if(ie(t))return{type:"Set",value:t,complement:e}}controlEscapeAtom(){let t;switch(this.popChar()){case"f":t=P("\f");break;case"n":t=P(`
9
- `);break;case"r":t=P("\r");break;case"t":t=P(" ");break;case"v":t=P("\v")}if(ie(t))return{type:"Character",value:t}}controlLetterEscapeAtom(){this.consumeChar("c");const t=this.popChar();if(/[a-zA-Z]/.test(t)===!1)throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}}nulCharacterAtom(){return this.consumeChar("0"),{type:"Character",value:P("\0")}}hexEscapeSequenceAtom(){return this.consumeChar("x"),this.parseHexDigits(2)}regExpUnicodeEscapeSequenceAtom(){return this.consumeChar("u"),this.parseHexDigits(4)}identityEscapeAtom(){return{type:"Character",value:P(this.popChar())}}classPatternCharacterAtom(){switch(this.peekChar()){case`
10
- `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:P(this.popChar())}}}characterClass(){const t=[];let e=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),e=!0);this.isClassAtom();){const n=this.classAtom();if(n.type,_i(n)&&this.isRangeDash()){this.consumeChar("-");const r=this.classAtom();if(r.type,_i(r)){if(r.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:r.value})}else Mn(n.value,t),t.push(P("-")),Mn(r.value,t)}else Mn(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:e,value:t}}classAtom(){switch(this.peekChar()){case"]":case`
11
- `: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:P("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}}group(){let t=!0;this.consumeChar("("),this.peekChar(0)==="?"?(this.consumeChar("?"),this.consumeChar(":"),t=!1):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(fc.test(t)===!1)throw Error("Expecting a positive integer");for(;Ge.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}integerIncludingZero(){let t=this.popChar();if(Ge.test(t)===!1)throw Error("Expecting an integer");for(;Ge.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)}patternCharacter(){const t=this.popChar();switch(t){case`
12
- `: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:P(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 Ge.test(this.peekChar(0))}isClassAtom(t=0){switch(this.peekChar(t)){case"]":case`
13
- `: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)==="!");default:return!1}}isQuantifier(){const t=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(t)}}isPatternCharacter(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
14
- `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}}parseHexDigits(t){let e="";for(let n=0;n<t;n++){const r=this.popChar();if(hc.test(r)===!1)throw Error("Expecting a HexDecimal digits");e+=r}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(t!==void 0&&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 un(t){const e=t.toString();if(Ze.hasOwnProperty(e))return Ze[e];{const n=dc.pattern(e);return Ze[e]=n,n}}const ts="Complement Sets are not supported for first char optimization",ln=`Unable to use "first char" lexer optimizations:
15
- `;function pc(t,e=!1){try{const n=un(t);return lr(n.value,{},n.flags.ignoreCase)}catch(n){if(n.message===ts)e&&qo(`${ln} Unable to optimize: < ${t.toString()} >
16
- Complement Sets cannot be automatically optimized.
17
- This will disable the lexer's first char optimizations.
18
- See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{let r="";e&&(r=`
19
- This will disable the lexer's first char optimizations.
20
- See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),cr(`${ln}
21
- Failed parsing: < ${t.toString()} >
22
- Using the @chevrotain/regexp-to-ast library
23
- Please open an issue at: https://github.com/chevrotain/chevrotain/issues`+r)}}return[]}function lr(t,e,n){switch(t.type){case"Disjunction":for(let i=0;i<t.value.length;i++)lr(t.value[i],e,n);break;case"Alternative":const r=t.value;for(let i=0;i<r.length;i++){const o=r[i];switch(o.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}const s=o;switch(s.type){case"Character":Ke(s.value,e,n);break;case"Set":if(s.complement===!0)throw Error(ts);b(s.value,c=>{if(typeof c=="number")Ke(c,e,n);else{const u=c;if(n===!0)for(let l=u.from;l<=u.to;l++)Ke(l,e,n);else{for(let l=u.from;l<=u.to&&l<Ne;l++)Ke(l,e,n);if(u.to>=Ne){const l=u.from>=Ne?u.from:Ne,h=u.to,f=zt(l),d=zt(h);for(let E=f;E<=d;E++)e[E]=E}}}});break;case"Group":lr(s.value,e,n);break;default:throw Error("Non Exhaustive Match")}const a=s.quantifier!==void 0&&s.quantifier.atLeast===0;if(s.type==="Group"&&hr(s)===!1||s.type!=="Group"&&a===!1)break}break;default:throw Error("non exhaustive match!")}return Z(e)}function Ke(t,e,n){const r=zt(t);e[r]=r,n===!0&&function(i,o){const s=String.fromCharCode(i),a=s.toUpperCase();if(a!==s){const c=zt(a.charCodeAt(0));o[c]=c}else{const c=s.toLowerCase();if(c!==s){const u=zt(c.charCodeAt(0));o[u]=u}}}(t,e)}function xi(t,e){return fe(t.value,n=>{if(typeof n=="number")return it(e,n);{const r=n;return fe(e,i=>r.from<=i&&i<=r.to)!==void 0}})}function hr(t){const e=t.quantifier;return!(!e||e.atLeast!==0)||!!t.value&&(D(t.value)?vt(t.value,hr):hr(t.value))}class mc extends ur{constructor(e){super(),this.targetCharCodes=e,this.found=!1}visitChildren(e){if(this.found!==!0){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}super.visitChildren(e)}}visitCharacter(e){it(this.targetCharCodes,e.value)&&(this.found=!0)}visitSet(e){e.complement?xi(e,this.targetCharCodes)===void 0&&(this.found=!0):xi(e,this.targetCharCodes)!==void 0&&(this.found=!0)}}function wr(t,e){if(e instanceof RegExp){const n=un(e),r=new mc(t);return r.visit(n),r.found}return fe(e,n=>it(t,n.charCodeAt(0)))!==void 0}const Qt="PATTERN",Ae="defaultMode",Un="modes";let es=typeof new RegExp("(?:)").sticky=="boolean";function Ec(t,e){const n=(e=Pr(e,{useSticky:es,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
24
- `],tracer:(m,p)=>p()})).tracer;let r;n("initCharCodeToOptimizedIndexMap",()=>{(function(){if(G(Qe)){Qe=new Array(65536);for(let m=0;m<65536;m++)Qe[m]=m>255?255+~~(m/255):m}})()}),n("Reject Lexer.NA",()=>{r=Nn(t,m=>m[Qt]===st.NA)});let i,o,s,a,c,u,l,h,f,d,E,I=!1;n("Transform Patterns",()=>{I=!1,i=L(r,m=>{const p=m[Qt];if(Wt(p)){const A=p.source;return A.length!==1||A==="^"||A==="$"||A==="."||p.ignoreCase?A.length!==2||A[0]!=="\\"||it(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],A[1])?e.useSticky?ki(p):Ci(p):A[1]:A}if(Kt(p))return I=!0,{exec:p};if(typeof p=="object")return I=!0,p;if(typeof p=="string"){if(p.length===1)return p;{const A=p.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),S=new RegExp(A);return e.useSticky?ki(S):Ci(S)}}throw Error("non exhaustive match")})}),n("misc mapping",()=>{o=L(r,m=>m.tokenTypeIdx),s=L(r,m=>{const p=m.GROUP;if(p!==st.SKIPPED){if(at(p))return p;if(Gt(p))return!1;throw Error("non exhaustive match")}}),a=L(r,m=>{const p=m.LONGER_ALT;if(p)return D(p)?L(p,A=>Ri(r,A)):[Ri(r,p)]}),c=L(r,m=>m.PUSH_MODE),u=L(r,m=>x(m,"POP_MODE"))}),n("Line Terminator Handling",()=>{const m=is(e.lineTerminatorCharacters);l=L(r,p=>!1),e.positionTracking!=="onlyOffset"&&(l=L(r,p=>x(p,"LINE_BREAKS")?!!p.LINE_BREAKS:rs(p,m)===!1&&wr(m,p.PATTERN)))}),n("Misc Mapping #2",()=>{h=L(r,ns),f=L(i,vc),d=ht(r,(m,p)=>{const A=p.GROUP;return at(A)&&A!==st.SKIPPED&&(m[A]=[]),m},{}),E=L(i,(m,p)=>({pattern:i[p],longerAlt:a[p],canLineTerminator:l[p],isCustom:h[p],short:f[p],group:s[p],push:c[p],pop:u[p],tokenTypeIdx:o[p],tokenType:r[p]}))});let _=!0,T=[];return e.safeMode||n("First Char Optimization",()=>{T=ht(r,(m,p,A)=>{if(typeof p.PATTERN=="string"){const S=zt(p.PATTERN.charCodeAt(0));Fn(m,S,E[A])}else if(D(p.START_CHARS_HINT)){let S;b(p.START_CHARS_HINT,g=>{const O=zt(typeof g=="string"?g.charCodeAt(0):g);S!==O&&(S=O,Fn(m,O,E[A]))})}else if(Wt(p.PATTERN))if(p.PATTERN.unicode)_=!1,e.ensureOptimizations&&cr(`${ln} Unable to analyze < ${p.PATTERN.toString()} > pattern.
25
- The regexp unicode flag is not currently supported by the regexp-to-ast library.
26
- This will disable the lexer's first char optimizations.
27
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{const S=pc(p.PATTERN,e.ensureOptimizations);G(S)&&(_=!1),b(S,g=>{Fn(m,g,E[A])})}else e.ensureOptimizations&&cr(`${ln} TokenType: <${p.name}> is using a custom token pattern without providing <start_chars_hint> parameter.
28
- This will disable the lexer's first char optimizations.
29
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),_=!1;return m},[])}),{emptyGroups:d,patternIdxToConfig:E,charCodeToPatternIdxToConfig:T,hasCustom:I,canBeOptimized:_}}function gc(t,e){let n=[];const r=function(s){const a=dt(s,l=>!x(l,Qt)),c=L(a,l=>({message:"Token Type: ->"+l.name+"<- missing static 'PATTERN' property",type:V.MISSING_PATTERN,tokenTypes:[l]})),u=on(s,a);return{errors:c,valid:u}}(t);n=n.concat(r.errors);const i=function(s){const a=dt(s,l=>{const h=l[Qt];return!(Wt(h)||Kt(h)||x(h,"exec")||at(h))}),c=L(a,l=>({message:"Token Type: ->"+l.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:V.INVALID_PATTERN,tokenTypes:[l]})),u=on(s,a);return{errors:c,valid:u}}(r.valid),o=i.valid;return n=n.concat(i.errors),n=n.concat(function(s){let a=[];const c=dt(s,u=>Wt(u[Qt]));return a=a.concat(function(u){class l extends ur{constructor(){super(...arguments),this.found=!1}visitEndAnchor(E){this.found=!0}}const h=dt(u,d=>{const E=d.PATTERN;try{const I=un(E),_=new l;return _.visit(I),_.found}catch{return Tc.test(E.source)}});return L(h,d=>({message:`Unexpected RegExp Anchor Error:
30
- Token Type: ->`+d.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
31
- See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.EOI_ANCHOR_FOUND,tokenTypes:[d]}))}(c)),a=a.concat(function(u){class l extends ur{constructor(){super(...arguments),this.found=!1}visitStartAnchor(E){this.found=!0}}const h=dt(u,d=>{const E=d.PATTERN;try{const I=un(E),_=new l;return _.visit(I),_.found}catch{return Ac.test(E.source)}});return L(h,d=>({message:`Unexpected RegExp Anchor Error:
32
- Token Type: ->`+d.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
33
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:V.SOI_ANCHOR_FOUND,tokenTypes:[d]}))}(c)),a=a.concat(function(u){const l=dt(u,f=>{const d=f[Qt];return d instanceof RegExp&&(d.multiline||d.global)});return L(l,f=>({message:"Token Type: ->"+f.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:V.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[f]}))}(c)),a=a.concat(function(u){const l=[];let h=L(u,d=>ht(u,(E,I)=>(d.PATTERN.source!==I.PATTERN.source||it(l,I)||I.PATTERN===st.NA||(l.push(I),E.push(I)),E),[]));return h=De(h),L(dt(h,d=>d.length>1),d=>{const E=L(d,I=>I.name);return{message:`The same RegExp pattern ->${yt(d).PATTERN}<-has been used in all of the following Token Types: ${E.join(", ")} <-`,type:V.DUPLICATE_PATTERNS_FOUND,tokenTypes:d}})}(c)),a=a.concat(function(u){const l=dt(u,f=>f.PATTERN.test(""));return L(l,f=>({message:"Token Type: ->"+f.name+"<- static 'PATTERN' must not match an empty string",type:V.EMPTY_MATCH_PATTERN,tokenTypes:[f]}))}(c)),a}(o)),n=n.concat(function(s){const a=dt(s,u=>{if(!x(u,"GROUP"))return!1;const l=u.GROUP;return l!==st.SKIPPED&&l!==st.NA&&!at(l)});return L(a,u=>({message:"Token Type: ->"+u.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:V.INVALID_GROUP_TYPE_FOUND,tokenTypes:[u]}))}(o)),n=n.concat(function(s,a){const c=dt(s,l=>l.PUSH_MODE!==void 0&&!it(a,l.PUSH_MODE));return L(c,l=>({message:`Token Type: ->${l.name}<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->${l.PUSH_MODE}<-which does not exist`,type:V.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[l]}))}(o,e)),n=n.concat(function(s){const a=[],c=ht(s,(u,l,h)=>{const f=l.PATTERN;return f===st.NA||(at(f)?u.push({str:f,idx:h,tokenType:l}):Wt(f)&&(d=f,fe([".","\\","[","]","|","^","$","(",")","?","*","+","{"],E=>d.source.indexOf(E)!==-1)===void 0)&&u.push({str:f.source,idx:h,tokenType:l})),u;var d},[]);return b(s,(u,l)=>{b(c,({str:h,idx:f,tokenType:d})=>{if(l<f&&function(E,I){if(Wt(I)){const _=I.exec(E);return _!==null&&_.index===0}if(Kt(I))return I(E,0,[],{});if(x(I,"exec"))return I.exec(E,0,[],{});if(typeof I=="string")return I===E;throw Error("non exhaustive match")}(h,u.PATTERN)){const E=`Token: ->${d.name}<- can never be matched.
34
- Because it appears AFTER the Token Type ->${u.name}<-in the lexer's definition.
35
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;a.push({message:E,type:V.UNREACHABLE_PATTERN,tokenTypes:[u,d]})}})}),a}(o)),n}const Tc=/[^\\][$]/,Ac=/[^\\[][\^]|^\^/;function Ci(t){const e=t.ignoreCase?"i":"";return new RegExp(`^(?:${t.source})`,e)}function ki(t){const e=t.ignoreCase?"iy":"y";return new RegExp(`${t.source}`,e)}function Ic(t,e,n){const r=[];let i=!1;const o=Nn(De(It(Z(t.modes))),a=>a[Qt]===st.NA),s=is(n);return e&&b(o,a=>{const c=rs(a,s);if(c!==!1){const u=function(h,f){if(f.issue===V.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
36
- The problem is in the <${h.name}> Token Type
37
- Root cause: ${f.errMsg}.
38
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR`;if(f.issue===V.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
39
- The problem is in the <${h.name}> Token Type
40
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK`;throw Error("non exhaustive match")}(a,c),l={message:u,type:c.issue,tokenType:a};r.push(l)}else x(a,"LINE_BREAKS")?a.LINE_BREAKS===!0&&(i=!0):wr(s,a.PATTERN)&&(i=!0)}),e&&!i&&r.push({message:`Warning: No LINE_BREAKS Found.
41
- This Lexer has been defined to track line and column information,
42
- But none of the Token Types can be identified as matching a line terminator.
43
- See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
44
- for details.`,type:V.NO_LINE_BREAKS_FLAGS}),r}function ns(t){const e=t.PATTERN;if(Wt(e))return!1;if(Kt(e)||x(e,"exec"))return!0;if(at(e))return!1;throw Error("non exhaustive match")}function vc(t){return!(!at(t)||t.length!==1)&&t.charCodeAt(0)}const Nc={test:function(t){const e=t.length;for(let n=this.lastIndex;n<e;n++){const r=t.charCodeAt(n);if(r===10)return this.lastIndex=n+1,!0;if(r===13)return t.charCodeAt(n+1)===10?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function rs(t,e){if(x(t,"LINE_BREAKS"))return!1;if(Wt(t.PATTERN)){try{wr(e,t.PATTERN)}catch(n){return{issue:V.IDENTIFY_TERMINATOR,errMsg:n.message}}return!1}if(at(t.PATTERN))return!1;if(ns(t))return{issue:V.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function is(t){return L(t,e=>at(e)?e.charCodeAt(0):e)}function Fn(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}const Ne=256;let Qe=[];function zt(t){return t<Ne?t:Qe[t]}function _e(t,e){const n=t.tokenTypeIdx;return n===e.tokenTypeIdx||e.isParent===!0&&e.categoryMatchesMap[n]===!0}function hn(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}let bi=1;const Pi={};function je(t){const e=function(n){let r=tt(n),i=n,o=!0;for(;o;){i=De(It(L(i,a=>a.CATEGORIES)));const s=on(i,r);r=r.concat(s),G(s)?o=!1:i=s}return r}(t);(function(n){b(n,r=>{ss(r)||(Pi[bi]=r,r.tokenTypeIdx=bi++),wi(r)&&!D(r.CATEGORIES)&&(r.CATEGORIES=[r.CATEGORIES]),wi(r)||(r.CATEGORIES=[]),x(r,"categoryMatches")||(r.categoryMatches=[]),function(i){return x(i,"categoryMatchesMap")}(r)||(r.categoryMatchesMap={})})})(e),function(n){b(n,r=>{os([],r)})}(e),function(n){b(n,r=>{r.categoryMatches=[],b(r.categoryMatchesMap,(i,o)=>{r.categoryMatches.push(Pi[o].tokenTypeIdx)})})}(e),b(e,n=>{n.isParent=n.categoryMatches.length>0})}function os(t,e){b(t,n=>{e.categoryMatchesMap[n.tokenTypeIdx]=!0}),b(e.CATEGORIES,n=>{const r=t.concat(e);it(r,n)||os(r,n)})}function ss(t){return x(t,"tokenTypeIdx")}function wi(t){return x(t,"CATEGORIES")}function yc(t){return x(t,"tokenTypeIdx")}const Rc={buildUnableToPopLexerModeMessage:t=>`Unable to pop Lexer Mode after encountering Token ->${t.image}<- The Mode Stack is empty`,buildUnexpectedCharactersMessage:(t,e,n,r,i)=>`unexpected character: ->${t.charAt(e)}<- at offset: ${e}, skipped ${n} characters.`};var V;(function(t){t[t.MISSING_PATTERN=0]="MISSING_PATTERN",t[t.INVALID_PATTERN=1]="INVALID_PATTERN",t[t.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",t[t.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",t[t.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",t[t.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",t[t.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",t[t.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",t[t.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",t[t.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",t[t.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",t[t.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",t[t.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",t[t.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",t[t.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",t[t.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",t[t.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK",t[t.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE=17]="MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE"})(V||(V={}));const ye={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
45
- `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:Rc,traceInitPerf:!1,skipValidations:!1,recoveryEnabled:!0};Object.freeze(ye);class st{constructor(e,n=ye){if(this.lexerDefinition=e,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},this.TRACE_INIT=(i,o)=>{if(this.traceInitPerf===!0){this.traceInitIndent++;const s=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${s}--> <${i}>`);const{time:a,value:c}=Zo(o),u=a>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&u(`${s}<-- <${i}> time: ${a}ms`),this.traceInitIndent--,c}return o()},typeof n=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
46
- a boolean 2nd argument is no longer supported`);this.config=lt({},ye,n);const r=this.config.traceInitPerf;r===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof r=="number"&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",()=>{let i,o=!0;this.TRACE_INIT("Lexer Config handling",()=>{if(this.config.lineTerminatorsPattern===ye.lineTerminatorsPattern)this.config.lineTerminatorsPattern=Nc;else if(this.config.lineTerminatorCharacters===ye.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
47
- For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(n.safeMode&&n.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');this.trackStartLines=/full|onlyStart/i.test(this.config.positionTracking),this.trackEndLines=/full/i.test(this.config.positionTracking),D(e)?i={modes:{defaultMode:tt(e)},defaultMode:Ae}:(o=!1,i=tt(e))}),this.config.skipValidations===!1&&(this.TRACE_INIT("performRuntimeChecks",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(function(a){const c=[];return x(a,Ae)||c.push({message:"A MultiMode Lexer cannot be initialized without a <"+Ae+`> property in its definition
48
- `,type:V.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),x(a,Un)||c.push({message:`A MultiMode Lexer cannot be initialized without a <modes> property in its definition
49
- `,type:V.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),x(a,Un)&&x(a,Ae)&&!x(a.modes,a.defaultMode)&&c.push({message:`A MultiMode Lexer cannot be initialized with a ${Ae}: <${a.defaultMode}>which does not exist
50
- `,type:V.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),x(a,Un)&&b(a.modes,(u,l)=>{b(u,(h,f)=>{Gt(h)?c.push({message:`A Lexer cannot be initialized using an undefined Token Type. Mode:<${l}> at index: <${f}>
51
- `,type:V.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED}):x(h,"LONGER_ALT")&&b(D(h.LONGER_ALT)?h.LONGER_ALT:[h.LONGER_ALT],d=>{Gt(d)||it(u,d)||c.push({message:`A MultiMode Lexer cannot be initialized with a longer_alt <${d.name}> on token <${h.name}> outside of mode <${l}>
52
- `,type:V.MULTI_MODE_LEXER_LONGER_ALT_NOT_IN_CURRENT_MODE})})})}),c}(i,this.trackStartLines,this.config.lineTerminatorCharacters))}),this.TRACE_INIT("performWarningRuntimeChecks",()=>{this.lexerDefinitionWarning=this.lexerDefinitionWarning.concat(Ic(i,this.trackStartLines,this.config.lineTerminatorCharacters))})),i.modes=i.modes?i.modes:{},b(i.modes,(a,c)=>{i.modes[c]=Nn(a,u=>Gt(u))});const s=Tt(i.modes);if(b(i.modes,(a,c)=>{this.TRACE_INIT(`Mode: <${c}> processing`,()=>{if(this.modes.push(c),this.config.skipValidations===!1&&this.TRACE_INIT("validatePatterns",()=>{this.lexerDefinitionErrors=this.lexerDefinitionErrors.concat(gc(a,s))}),G(this.lexerDefinitionErrors)){let u;je(a),this.TRACE_INIT("analyzeTokenTypes",()=>{u=Ec(a,{lineTerminatorCharacters:this.config.lineTerminatorCharacters,positionTracking:n.positionTracking,ensureOptimizations:n.ensureOptimizations,safeMode:n.safeMode,tracer:this.TRACE_INIT})}),this.patternIdxToConfig[c]=u.patternIdxToConfig,this.charCodeToPatternIdxToConfig[c]=u.charCodeToPatternIdxToConfig,this.emptyGroups=lt({},this.emptyGroups,u.emptyGroups),this.hasCustom=u.hasCustom||this.hasCustom,this.canModeBeOptimized[c]=u.canBeOptimized}})}),this.defaultMode=i.defaultMode,!G(this.lexerDefinitionErrors)&&!this.config.deferDefinitionErrorsHandling){const a=L(this.lexerDefinitionErrors,c=>c.message).join(`-----------------------
53
- `);throw new Error(`Errors detected in definition of Lexer:
54
- `+a)}b(this.lexerDefinitionWarning,a=>{qo(a.message)}),this.TRACE_INIT("Choosing sub-methods implementations",()=>{if(es?(this.chopInput=le,this.match=this.matchWithTest):(this.updateLastIndex=q,this.match=this.matchWithExec),o&&(this.handleModes=q),this.trackStartLines===!1&&(this.computeNewColumn=le),this.trackEndLines===!1&&(this.updateTokenEndLineColumnLocation=q),/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 a=ht(this.canModeBeOptimized,(c,u,l)=>(u===!1&&c.push(l),c),[]);if(n.ensureOptimizations&&!G(a))throw Error(`Lexer Modes: < ${a.join(", ")} > cannot be optimized.
55
- Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
56
- Or inspect the console log for details on how to resolve these issues.`)}),this.TRACE_INIT("clearRegExpParserCache",()=>{Ze={}}),this.TRACE_INIT("toFastProperties",()=>{Qo(this)})})}tokenize(e,n=this.defaultMode){if(!G(this.lexerDefinitionErrors)){const r=L(this.lexerDefinitionErrors,i=>i.message).join(`-----------------------
57
- `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
58
- `+r)}return this.tokenizeInternal(e,n)}tokenizeInternal(e,n){let r,i,o,s,a,c,u,l,h,f,d,E,I,_,T;const m=e,p=m.length;let A=0,S=0;const g=this.hasCustom?0:Math.floor(e.length/10),O=new Array(g),N=[];let v=this.trackStartLines?1:void 0,y=this.trackStartLines?1:void 0;const U=function(X){const nt={};return b(Tt(X),Mt=>{const ot=X[Mt];if(!D(ot))throw Error("non exhaustive match");nt[Mt]=[]}),nt}(this.emptyGroups),M=this.trackStartLines,F=this.config.lineTerminatorsPattern;let $=0,C=[],k=[];const j=[],Y=[];let B;function et(){return C}function Xt(X){const nt=zt(X),Mt=k[nt];return Mt===void 0?Y:Mt}Object.freeze(Y);const me=X=>{if(j.length===1&&X.tokenType.PUSH_MODE===void 0){const nt=this.config.errorMessageProvider.buildUnableToPopLexerModeMessage(X);N.push({offset:X.startOffset,line:X.startLine,column:X.startColumn,length:X.image.length,message:nt})}else{j.pop();const nt=he(j);C=this.patternIdxToConfig[nt],k=this.charCodeToPatternIdxToConfig[nt],$=C.length;const Mt=this.canModeBeOptimized[nt]&&this.config.safeMode===!1;B=k&&Mt?Xt:et}};function jr(X){j.push(X),k=this.charCodeToPatternIdxToConfig[X],C=this.patternIdxToConfig[X],$=C.length,$=C.length;const nt=this.canModeBeOptimized[X]&&this.config.safeMode===!1;B=k&&nt?Xt:et}let At;jr.call(this,n);const Br=this.config.recoveryEnabled;for(;A<p;){c=null;const X=m.charCodeAt(A),nt=B(X),Mt=nt.length;for(r=0;r<Mt;r++){At=nt[r];const ot=At.pattern;u=null;const Ut=At.short;if(Ut!==!1?X===Ut&&(c=ot):At.isCustom===!0?(T=ot.exec(m,A,O,U),T!==null?(c=T[0],T.payload!==void 0&&(u=T.payload)):c=null):(this.updateLastIndex(ot,A),c=this.match(ot,e,A)),c!==null){if(a=At.longerAlt,a!==void 0){const Ft=a.length;for(o=0;o<Ft;o++){const Dt=C[a[o]],qt=Dt.pattern;if(l=null,Dt.isCustom===!0?(T=qt.exec(m,A,O,U),T!==null?(s=T[0],T.payload!==void 0&&(l=T.payload)):s=null):(this.updateLastIndex(qt,A),s=this.match(qt,e,A)),s&&s.length>c.length){c=s,u=l,At=Dt;break}}}break}}if(c!==null){if(h=c.length,f=At.group,f!==void 0&&(d=At.tokenTypeIdx,E=this.createTokenInstance(c,A,d,At.tokenType,v,y,h),this.handlePayload(E,u),f===!1?S=this.addToken(O,S,E):U[f].push(E)),e=this.chopInput(e,h),A+=h,y=this.computeNewColumn(y,h),M===!0&&At.canLineTerminator===!0){let ot,Ut,Ft=0;F.lastIndex=0;do ot=F.test(c),ot===!0&&(Ut=F.lastIndex-1,Ft++);while(ot===!0);Ft!==0&&(v+=Ft,y=h-Ut,this.updateTokenEndLineColumnLocation(E,f,Ut,Ft,v,y,h))}this.handleModes(At,me,jr,E)}else{const ot=A,Ut=v,Ft=y;let Dt=Br===!1;for(;Dt===!1&&A<p;)for(e=this.chopInput(e,1),A++,i=0;i<$;i++){const qt=C[i],Ln=qt.pattern,$r=qt.short;if($r!==!1?m.charCodeAt(A)===$r&&(Dt=!0):qt.isCustom===!0?Dt=Ln.exec(m,A,O,U)!==null:(this.updateLastIndex(Ln,A),Dt=Ln.exec(e)!==null),Dt===!0)break}if(I=A-ot,y=this.computeNewColumn(y,I),_=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(m,ot,I,Ut,Ft),N.push({offset:ot,line:Ut,column:Ft,length:I,message:_}),Br===!1)break}}return this.hasCustom||(O.length=S),{tokens:O,groups:U,errors:N}}handleModes(e,n,r,i){if(e.pop===!0){const o=e.push;n(i),o!==void 0&&r.call(this,o)}else e.push!==void 0&&r.call(this,e.push)}chopInput(e,n){return e.substring(n)}updateLastIndex(e,n){e.lastIndex=n}updateTokenEndLineColumnLocation(e,n,r,i,o,s,a){let c,u;n!==void 0&&(c=r===a-1,u=c?-1:0,i===1&&c===!0||(e.endLine=o+u,e.endColumn=s-1-u))}computeNewColumn(e,n){return e+n}createOffsetOnlyToken(e,n,r,i){return{image:e,startOffset:n,tokenTypeIdx:r,tokenType:i}}createStartOnlyToken(e,n,r,i,o,s){return{image:e,startOffset:n,startLine:o,startColumn:s,tokenTypeIdx:r,tokenType:i}}createFullToken(e,n,r,i,o,s,a){return{image:e,startOffset:n,endOffset:n+a-1,startLine:o,endLine:o,startColumn:s,endColumn:s+a-1,tokenTypeIdx:r,tokenType:i}}addTokenUsingPush(e,n,r){return e.push(r),n}addTokenUsingMemberAccess(e,n,r){return e[n]=r,++n}handlePayloadNoCustom(e,n){}handlePayloadWithCustom(e,n){n!==null&&(e.payload=n)}matchWithTest(e,n,r){return e.test(n)===!0?n.substring(r,e.lastIndex):null}matchWithExec(e,n){const r=e.exec(n);return r!==null?r[0]:null}}function Le(t){return as(t)?t.LABEL:t.name}function as(t){return at(t.LABEL)&&t.LABEL!==""}st.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",st.NA=/NOT_APPLICABLE/;const Oc="parent",Mi="categories",Ui="label",Fi="group",Di="push_mode",ji="pop_mode",Bi="longer_alt",$i="line_breaks",Wi="start_chars_hint";function w(t){return function(e){const n=e.pattern,r={};if(r.name=e.name,Gt(n)||(r.PATTERN=n),x(e,Oc))throw`The parent property is no longer supported.
59
- See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return x(e,Mi)&&(r.CATEGORIES=e[Mi]),je([r]),x(e,Ui)&&(r.LABEL=e[Ui]),x(e,Fi)&&(r.GROUP=e[Fi]),x(e,ji)&&(r.POP_MODE=e[ji]),x(e,Di)&&(r.PUSH_MODE=e[Di]),x(e,Bi)&&(r.LONGER_ALT=e[Bi]),x(e,$i)&&(r.LINE_BREAKS=e[$i]),x(e,Wi)&&(r.START_CHARS_HINT=e[Wi]),r}(t)}const Jt=w({name:"EOF",pattern:st.NA});function Mr(t,e,n,r,i,o,s,a){return{image:e,startOffset:n,endOffset:r,startLine:i,endLine:o,startColumn:s,endColumn:a,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}je([Jt]);const cs={buildMismatchTokenMessage:({expected:t,actual:e,previous:n,ruleName:r})=>`Expecting ${as(t)?`--> ${Le(t)} <--`:`token of type --> ${t.name} <--`} but found --> '${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 o="Expecting: ",s=`
60
- but found: '`+yt(e).image+"'";if(r)return o+r+s;{const a=L(ht(t,(c,u)=>c.concat(u),[]),c=>`[${L(c,u=>Le(u)).join(", ")}]`);return o+`one of these possible Token sequences:
61
- ${L(a,(c,u)=>` ${u+1}. ${c}`).join(`
62
- `)}`+s}},buildEarlyExitMessage({expectedIterationPaths:t,actual:e,customUserDescription:n,ruleName:r}){const i="Expecting: ",o=`
63
- but found: '`+yt(e).image+"'";return n?i+n+o:i+`expecting at least one iteration which starts with one of these possible Token sequences::
64
- <${L(t,s=>`[${L(s,a=>Le(a)).join(",")}]`).join(" ,")}>`+o}};Object.freeze(cs);const Sc={buildRuleNotFoundError:(t,e)=>"Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
65
- inside top level rule: ->`+t.name+"<-"},te={buildDuplicateFoundError(t,e){const n=t.name,r=yt(e),i=r.idx,o=_t(r),s=(a=r)instanceof z?a.terminalType.name:a instanceof ft?a.nonTerminalName:"";var a;let c=`->${o}${i>0?i:""}<- ${s?`with argument: ->${s}<-`:""}
66
- appears more than once (${e.length} times) in the top level rule: ->${n}<-.
67
- For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
68
- `;return c=c.replace(/[ \t]+/g," "),c=c.replace(/\s\s+/g,`
69
- `),c},buildNamespaceConflictError:t=>`Namespace conflict found in grammar.
70
- The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <${t.name}>.
71
- To resolve this make sure each Terminal and Non-Terminal names are unique
72
- This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
73
- and Non-Terminal names start with a lower case letter.`,buildAlternationPrefixAmbiguityError(t){const e=L(t.prefixPath,r=>Le(r)).join(", "),n=t.alternation.idx===0?"":t.alternation.idx;return`Ambiguous alternatives: <${t.ambiguityIndices.join(" ,")}> due to common lookahead prefix
74
- in <OR${n}> inside <${t.topLevelRule.name}> Rule,
75
- <${e}> may appears as a prefix path in all these alternatives.
76
- See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
77
- For Further details.`},buildAlternationAmbiguityError(t){const e=L(t.prefixPath,i=>Le(i)).join(", "),n=t.alternation.idx===0?"":t.alternation.idx;let r=`Ambiguous Alternatives Detected: <${t.ambiguityIndices.join(" ,")}> in <OR${n}> inside <${t.topLevelRule.name}> Rule,
78
- <${e}> may appears as a prefix path in all these alternatives.
79
- `;return r+=`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
80
- For Further details.`,r},buildEmptyRepetitionError(t){let e=_t(t.repetition);return t.repetition.idx!==0&&(e+=t.repetition.idx),`The repetition <${e}> within Rule <${t.topLevelRule.name}> can never consume any tokens.
81
- This 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.
82
- Only the last alternative may be an empty alternative.`,buildTooManyAlternativesError:t=>`An Alternation cannot have more than 256 alternatives:
83
- <OR${t.alternation.idx}> inside <${t.topLevelRule.name}> Rule.
84
- has ${t.alternation.definition.length+1} alternatives.`,buildLeftRecursionError(t){const e=t.topLevelRule.name;return`Left Recursion found in grammar.
85
- rule: <${e}> can be invoked from itself (directly or indirectly)
86
- without consuming any Tokens. The grammar path that causes this is:
87
- ${`${e} --> ${L(t.leftRecursionPath,n=>n.name).concat([e]).join(" --> ")}`}
88
- To fix this refactor your grammar to remove the left recursion.
89
- see: https://en.wikipedia.org/wiki/LL_parser#Left_factoring.`},buildInvalidRuleNameError:t=>"deprecated",buildDuplicateRuleNameError(t){let e;return e=t.topLevelRule instanceof de?t.topLevelRule.name:t.topLevelRule,`Duplicate definition, rule: ->${e}<- is already defined in the grammar: ->${t.grammarName}<-`}};class _c extends pe{constructor(e,n){super(),this.nameToTopRule=e,this.errMsgProvider=n,this.errors=[]}resolveRefs(){b(Z(this.nameToTopRule),e=>{this.currTopLevel=e,e.accept(this)})}visitNonTerminal(e){const n=this.nameToTopRule[e.nonTerminalName];if(n)e.referencedRule=n;else{const r=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,e);this.errors.push({message:r,type:rt.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:e.nonTerminalName})}}}class Lc extends yn{constructor(e,n){super(),this.topProd=e,this.path=n,this.possibleTokTypes=[],this.nextProductionName="",this.nextProductionOccurrence=0,this.found=!1,this.isAtEndOfPath=!1}startWalking(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=tt(this.path.ruleStack).reverse(),this.occurrenceStack=tt(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes}walk(e,n=[]){this.found||super.walk(e,n)}walkProdRef(e,n,r){if(e.referencedRule.name===this.nextProductionName&&e.idx===this.nextProductionOccurrence){const i=n.concat(r);this.updateExpectedNext(),this.walk(e.referencedRule,i)}}updateExpectedNext(){G(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())}}class xc extends Lc{constructor(e,n){super(e,n),this.path=n,this.nextTerminalName="",this.nextTerminalOccurrence=0,this.nextTerminalName=this.path.lastTok.name,this.nextTerminalOccurrence=this.path.lastTokOccurrence}walkTerminal(e,n,r){if(this.isAtEndOfPath&&e.terminalType.name===this.nextTerminalName&&e.idx===this.nextTerminalOccurrence&&!this.found){const i=n.concat(r),o=new ut({definition:i});this.possibleTokTypes=Se(o),this.found=!0}}}class Rn extends yn{constructor(e,n){super(),this.topRule=e,this.occurrence=n,this.result={token:void 0,occurrence:void 0,isEndOfRule:void 0}}startWalking(){return this.walk(this.topRule),this.result}}class Cc extends Rn{walkMany(e,n,r){if(e.idx===this.occurrence){const i=yt(n.concat(r));this.result.isEndOfRule=i===void 0,i instanceof z&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkMany(e,n,r)}}class Gi extends Rn{walkManySep(e,n,r){if(e.idx===this.occurrence){const i=yt(n.concat(r));this.result.isEndOfRule=i===void 0,i instanceof z&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkManySep(e,n,r)}}class kc extends Rn{walkAtLeastOne(e,n,r){if(e.idx===this.occurrence){const i=yt(n.concat(r));this.result.isEndOfRule=i===void 0,i instanceof z&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOne(e,n,r)}}class Ki extends Rn{walkAtLeastOneSep(e,n,r){if(e.idx===this.occurrence){const i=yt(n.concat(r));this.result.isEndOfRule=i===void 0,i instanceof z&&(this.result.token=i.terminalType,this.result.occurrence=i.idx)}else super.walkAtLeastOneSep(e,n,r)}}function fr(t,e,n=[]){n=tt(n);let r=[],i=0;function o(s){const a=fr(s.concat(J(t,i+1)),e,n);return r.concat(a)}for(;n.length<e&&i<t.length;){const s=t[i];if(s instanceof ut||s instanceof ft)return o(s.definition);if(s instanceof ct)r=o(s.definition);else{if(s instanceof Pt)return o(s.definition.concat([new Q({definition:s.definition})]));if(s instanceof wt)return o([new ut({definition:s.definition}),new Q({definition:[new z({terminalType:s.separator})].concat(s.definition)})]);if(s instanceof Ot){const a=s.definition.concat([new Q({definition:[new z({terminalType:s.separator})].concat(s.definition)})]);r=o(a)}else if(s instanceof Q){const a=s.definition.concat([new Q({definition:s.definition})]);r=o(a)}else{if(s instanceof St)return b(s.definition,a=>{G(a.definition)===!1&&(r=o(a.definition))}),r;if(!(s instanceof z))throw Error("non exhaustive match");n.push(s.terminalType)}}i++}return r.push({partialPath:n,suffixDef:J(t,i)}),r}function us(t,e,n,r){const i="EXIT_NONE_TERMINAL",o=[i],s="EXIT_ALTERNATIVE";let a=!1;const c=e.length,u=c-r-1,l=[],h=[];for(h.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!G(h);){const f=h.pop();if(f===s){a&&he(h).idx<=u&&h.pop();continue}const d=f.def,E=f.idx,I=f.ruleStack,_=f.occurrenceStack;if(G(d))continue;const T=d[0];if(T===i){const m={idx:E,def:J(d),ruleStack:be(I),occurrenceStack:be(_)};h.push(m)}else if(T instanceof z)if(E<c-1){const m=E+1;if(n(e[m],T.terminalType)){const p={idx:m,def:J(d),ruleStack:I,occurrenceStack:_};h.push(p)}}else{if(E!==c-1)throw Error("non exhaustive match");l.push({nextTokenType:T.terminalType,nextTokenOccurrence:T.idx,ruleStack:I,occurrenceStack:_}),a=!0}else if(T instanceof ft){const m=tt(I);m.push(T.nonTerminalName);const p=tt(_);p.push(T.idx);const A={idx:E,def:T.definition.concat(o,J(d)),ruleStack:m,occurrenceStack:p};h.push(A)}else if(T instanceof ct){const m={idx:E,def:J(d),ruleStack:I,occurrenceStack:_};h.push(m),h.push(s);const p={idx:E,def:T.definition.concat(J(d)),ruleStack:I,occurrenceStack:_};h.push(p)}else if(T instanceof Pt){const m=new Q({definition:T.definition,idx:T.idx}),p={idx:E,def:T.definition.concat([m],J(d)),ruleStack:I,occurrenceStack:_};h.push(p)}else if(T instanceof wt){const m=new z({terminalType:T.separator}),p=new Q({definition:[m].concat(T.definition),idx:T.idx}),A={idx:E,def:T.definition.concat([p],J(d)),ruleStack:I,occurrenceStack:_};h.push(A)}else if(T instanceof Ot){const m={idx:E,def:J(d),ruleStack:I,occurrenceStack:_};h.push(m),h.push(s);const p=new z({terminalType:T.separator}),A=new Q({definition:[p].concat(T.definition),idx:T.idx}),S={idx:E,def:T.definition.concat([A],J(d)),ruleStack:I,occurrenceStack:_};h.push(S)}else if(T instanceof Q){const m={idx:E,def:J(d),ruleStack:I,occurrenceStack:_};h.push(m),h.push(s);const p=new Q({definition:T.definition,idx:T.idx}),A={idx:E,def:T.definition.concat([p],J(d)),ruleStack:I,occurrenceStack:_};h.push(A)}else if(T instanceof St)for(let m=T.definition.length-1;m>=0;m--){const p={idx:E,def:T.definition[m].definition.concat(J(d)),ruleStack:I,occurrenceStack:_};h.push(p),h.push(s)}else if(T instanceof ut)h.push({idx:E,def:T.definition.concat(J(d)),ruleStack:I,occurrenceStack:_});else{if(!(T instanceof de))throw Error("non exhaustive match");h.push(bc(T,E,I,_))}}return l}function bc(t,e,n,r){const i=tt(n);i.push(t.name);const o=tt(r);return o.push(1),{idx:e,def:t.definition,ruleStack:i,occurrenceStack:o}}var H;function zi(t){if(t instanceof ct||t==="Option")return H.OPTION;if(t instanceof Q||t==="Repetition")return H.REPETITION;if(t instanceof Pt||t==="RepetitionMandatory")return H.REPETITION_MANDATORY;if(t instanceof wt||t==="RepetitionMandatoryWithSeparator")return H.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof Ot||t==="RepetitionWithSeparator")return H.REPETITION_WITH_SEPARATOR;if(t instanceof St||t==="Alternation")return H.ALTERNATION;throw Error("non exhaustive match")}function Pc(t,e,n,r){const i=t.length,o=vt(t,s=>vt(s,a=>a.length===1));if(e)return function(s){const a=L(s,c=>c.GATE);for(let c=0;c<i;c++){const u=t[c],l=u.length,h=a[c];if(h===void 0||h.call(this)!==!1)t:for(let f=0;f<l;f++){const d=u[f],E=d.length;for(let I=0;I<E;I++){const _=this.LA(I+1);if(n(_,d[I])===!1)continue t}return c}}};if(o&&!r){const s=ht(L(t,a=>It(a)),(a,c,u)=>(b(c,l=>{x(a,l.tokenTypeIdx)||(a[l.tokenTypeIdx]=u),b(l.categoryMatches,h=>{x(a,h)||(a[h]=u)})}),a),{});return function(){const a=this.LA(1);return s[a.tokenTypeIdx]}}return function(){for(let s=0;s<i;s++){const a=t[s],c=a.length;t:for(let u=0;u<c;u++){const l=a[u],h=l.length;for(let f=0;f<h;f++){const d=this.LA(f+1);if(n(d,l[f])===!1)continue t}return s}}}}function wc(t,e,n){const r=vt(t,o=>o.length===1),i=t.length;if(r&&!n){const o=It(t);if(o.length===1&&G(o[0].categoryMatches)){const s=o[0].tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===s}}{const s=ht(o,(a,c,u)=>(a[c.tokenTypeIdx]=!0,b(c.categoryMatches,l=>{a[l]=!0}),a),[]);return function(){const a=this.LA(1);return s[a.tokenTypeIdx]===!0}}}return function(){t:for(let o=0;o<i;o++){const s=t[o],a=s.length;for(let c=0;c<a;c++){const u=this.LA(c+1);if(e(u,s[c])===!1)continue t}return!0}return!1}}(function(t){t[t.OPTION=0]="OPTION",t[t.REPETITION=1]="REPETITION",t[t.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",t[t.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",t[t.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",t[t.ALTERNATION=5]="ALTERNATION"})(H||(H={}));class Mc extends yn{constructor(e,n,r){super(),this.topProd=e,this.targetOccurrence=n,this.targetProdType=r}startWalking(){return this.walk(this.topProd),this.restDef}checkIsTarget(e,n,r,i){return e.idx===this.targetOccurrence&&this.targetProdType===n&&(this.restDef=r.concat(i),!0)}walkOption(e,n,r){this.checkIsTarget(e,H.OPTION,n,r)||super.walkOption(e,n,r)}walkAtLeastOne(e,n,r){this.checkIsTarget(e,H.REPETITION_MANDATORY,n,r)||super.walkOption(e,n,r)}walkAtLeastOneSep(e,n,r){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR,n,r)||super.walkOption(e,n,r)}walkMany(e,n,r){this.checkIsTarget(e,H.REPETITION,n,r)||super.walkOption(e,n,r)}walkManySep(e,n,r){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR,n,r)||super.walkOption(e,n,r)}}class ls extends pe{constructor(e,n,r){super(),this.targetOccurrence=e,this.targetProdType=n,this.targetRef=r,this.result=[]}checkIsTarget(e,n){e.idx!==this.targetOccurrence||this.targetProdType!==n||this.targetRef!==void 0&&e!==this.targetRef||(this.result=e.definition)}visitOption(e){this.checkIsTarget(e,H.OPTION)}visitRepetition(e){this.checkIsTarget(e,H.REPETITION)}visitRepetitionMandatory(e){this.checkIsTarget(e,H.REPETITION_MANDATORY)}visitRepetitionMandatoryWithSeparator(e){this.checkIsTarget(e,H.REPETITION_MANDATORY_WITH_SEPARATOR)}visitRepetitionWithSeparator(e){this.checkIsTarget(e,H.REPETITION_WITH_SEPARATOR)}visitAlternation(e){this.checkIsTarget(e,H.ALTERNATION)}}function Vi(t){const e=new Array(t);for(let n=0;n<t;n++)e[n]=[];return e}function Dn(t){let e=[""];for(let n=0;n<t.length;n++){const r=t[n],i=[];for(let o=0;o<e.length;o++){const s=e[o];i.push(s+"_"+r.tokenTypeIdx);for(let a=0;a<r.categoryMatches.length;a++){const c="_"+r.categoryMatches[a];i.push(s+c)}}e=i}return e}function Uc(t,e,n){for(let r=0;r<t.length;r++){if(r===n)continue;const i=t[r];for(let o=0;o<e.length;o++)if(i[e[o]]===!0)return!1}return!0}function hs(t,e){const n=L(t,s=>fr([s],1)),r=Vi(n.length),i=L(n,s=>{const a={};return b(s,c=>{b(Dn(c.partialPath),u=>{a[u]=!0})}),a});let o=n;for(let s=1;s<=e;s++){const a=o;o=Vi(a.length);for(let c=0;c<a.length;c++){const u=a[c];for(let l=0;l<u.length;l++){const h=u[l].partialPath,f=u[l].suffixDef,d=Dn(h);if(Uc(i,d,c)||G(f)||h.length===e){const E=r[c];if(pr(E,h)===!1){E.push(h);for(let I=0;I<d.length;I++){const _=d[I];i[c][_]=!0}}}else{const E=fr(f,s+1,h);o[c]=o[c].concat(E),b(E,I=>{b(Dn(I.partialPath),_=>{i[c][_]=!0})})}}}}return r}function Ur(t,e,n,r){const i=new ls(t,H.ALTERNATION,r);return e.accept(i),hs(i.result,n)}function dr(t,e,n,r){const i=new ls(t,n);e.accept(i);const o=i.result,s=new Mc(e,t,n).startWalking();return hs([new ut({definition:o}),new ut({definition:s})],r)}function pr(t,e){t:for(let n=0;n<t.length;n++){const r=t[n];if(r.length===e.length){for(let i=0;i<r.length;i++){const o=e[i],s=r[i];if(!(o===s||s.categoryMatchesMap[o.tokenTypeIdx]!==void 0))continue t}return!0}}return!1}function Hi(t){return vt(t,e=>vt(e,n=>vt(n,r=>G(r.categoryMatches))))}function Fc(t,e,n,r){const i=mt(t,c=>function(u,l){const h=new jc;u.accept(h);const f=h.allProductions,d=tc(f,Dc);return L(Z(Rt(d,I=>I.length>1)),I=>{const _=yt(I),T=l.buildDuplicateFoundError(u,I),m=_t(_),p={message:T,type:rt.DUPLICATE_PRODUCTIONS,ruleName:u.name,dslName:m,occurrence:_.idx},A=fs(_);return A&&(p.parameter=A),p})}(c,n)),o=function(c,u,l){const h=[],f=L(u,d=>d.name);return b(c,d=>{const E=d.name;if(it(f,E)){const I=l.buildNamespaceConflictError(d);h.push({message:I,type:rt.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:E})}}),h}(t,e,n),s=mt(t,c=>function(u,l){const h=new Fr;return u.accept(h),mt(h.alternations,d=>d.definition.length>255?[{message:l.buildTooManyAlternativesError({topLevelRule:u,alternation:d}),type:rt.TOO_MANY_ALTS,ruleName:u.name,occurrence:d.idx}]:[])}(c,n)),a=mt(t,c=>function(u,l,h,f){const d=[];if(ht(l,(I,_)=>_.name===u.name?I+1:I,0)>1){const I=f.buildDuplicateRuleNameError({topLevelRule:u,grammarName:h});d.push({message:I,type:rt.DUPLICATE_RULE_NAME,ruleName:u.name})}return d}(c,t,r,n));return i.concat(o,s,a)}function Dc(t){return`${_t(t)}_#_${t.idx}_#_${fs(t)}`}function fs(t){return t instanceof z?t.terminalType.name:t instanceof ft?t.nonTerminalName:""}class jc extends pe{constructor(){super(...arguments),this.allProductions=[]}visitNonTerminal(e){this.allProductions.push(e)}visitOption(e){this.allProductions.push(e)}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}visitAlternation(e){this.allProductions.push(e)}visitTerminal(e){this.allProductions.push(e)}}function ds(t,e,n,r=[]){const i=[],o=Je(e.definition);if(G(o))return[];{const s=t.name;it(o,t)&&i.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:rt.LEFT_RECURSION,ruleName:s});const a=mt(on(o,r.concat([t])),c=>{const u=tt(r);return u.push(c),ds(t,c,n,u)});return i.concat(a)}}function Je(t){let e=[];if(G(t))return e;const n=yt(t);if(n instanceof ft)e.push(n.referencedRule);else if(n instanceof ut||n instanceof ct||n instanceof Pt||n instanceof wt||n instanceof Ot||n instanceof Q)e=e.concat(Je(n.definition));else if(n instanceof St)e=It(L(n.definition,o=>Je(o.definition)));else if(!(n instanceof z))throw Error("non exhaustive match");const r=sn(n),i=t.length>1;if(r&&i){const o=J(t);return e.concat(Je(o))}return e}class Fr extends pe{constructor(){super(...arguments),this.alternations=[]}visitAlternation(e){this.alternations.push(e)}}function Bc(t,e,n){const r=new Fr;t.accept(r);let i=r.alternations;return i=Nn(i,s=>s.ignoreAmbiguities===!0),mt(i,s=>{const a=s.idx,c=s.maxLookahead||e,u=Ur(a,t,c,s),l=function(f,d,E,I){const _=[],T=ht(f,(p,A,S)=>(d.definition[S].ignoreAmbiguities===!0||b(A,g=>{const O=[S];b(f,(N,v)=>{S!==v&&pr(N,g)&&d.definition[v].ignoreAmbiguities!==!0&&O.push(v)}),O.length>1&&!pr(_,g)&&(_.push(g),p.push({alts:O,path:g}))}),p),[]);return L(T,p=>{const A=L(p.alts,S=>S+1);return{message:I.buildAlternationAmbiguityError({topLevelRule:E,alternation:d,ambiguityIndices:A,prefixPath:p.path}),type:rt.AMBIGUOUS_ALTS,ruleName:E.name,occurrence:d.idx,alternatives:p.alts}})}(u,s,t,n),h=function(f,d,E,I){const _=ht(f,(m,p,A)=>{const S=L(p,g=>({idx:A,path:g}));return m.concat(S)},[]);return De(mt(_,m=>{if(d.definition[m.idx].ignoreAmbiguities===!0)return[];const p=m.idx,A=m.path;return L(dt(_,S=>{return d.definition[S.idx].ignoreAmbiguities!==!0&&S.idx<p&&(g=S.path,O=A,g.length<O.length&&vt(g,(N,v)=>{const y=O[v];return N===y||y.categoryMatchesMap[N.tokenTypeIdx]}));var g,O}),S=>{const g=[S.idx+1,p+1],O=d.idx===0?"":d.idx;return{message:I.buildAlternationPrefixAmbiguityError({topLevelRule:E,alternation:d,ambiguityIndices:g,prefixPath:S.path}),type:rt.AMBIGUOUS_PREFIX_ALTS,ruleName:E.name,occurrence:O,alternatives:g}})}))}(u,s,t,n);return l.concat(h)})}class $c extends pe{constructor(){super(...arguments),this.allProductions=[]}visitRepetitionWithSeparator(e){this.allProductions.push(e)}visitRepetitionMandatory(e){this.allProductions.push(e)}visitRepetitionMandatoryWithSeparator(e){this.allProductions.push(e)}visitRepetition(e){this.allProductions.push(e)}}function Wc(t){const e=Pr(t,{errMsgProvider:Sc}),n={};return b(t.rules,r=>{n[r.name]=r}),function(r,i){const o=new _c(r,i);return o.resolveRefs(),o.errors}(n,e.errMsgProvider)}const ps="MismatchedTokenException",ms="NoViableAltException",Es="EarlyExitException",gs="NotAllInputParsedException",Ts=[ps,ms,Es,gs];function ze(t){return it(Ts,t.name)}Object.freeze(Ts);class On extends Error{constructor(e,n){super(e),this.token=n,this.resyncedTokens=[],Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}class Yi extends On{constructor(e,n,r){super(e,n),this.previousToken=r,this.name=ps}}class Gc extends On{constructor(e,n,r){super(e,n),this.previousToken=r,this.name=ms}}class Kc extends On{constructor(e,n){super(e,n),this.name=gs}}class zc extends On{constructor(e,n,r){super(e,n),this.previousToken=r,this.name=Es}}const jn={},As="InRuleRecoveryException";class Vc extends Error{constructor(e){super(e),this.name=As}}function Hc(t,e,n,r,i,o,s){const a=this.getKeyForAutomaticLookahead(r,i);let c=this.firstAfterRepMap[a];if(c===void 0){const f=this.getCurrRuleFullName();c=new o(this.getGAstProductions()[f],i).startWalking(),this.firstAfterRepMap[a]=c}let u=c.token,l=c.occurrence;const h=c.isEndOfRule;this.RULE_STACK.length===1&&h&&u===void 0&&(u=Jt,l=1),u!==void 0&&l!==void 0&&this.shouldInRepetitionRecoveryBeTried(u,l,s)&&this.tryInRepetitionRecovery(t,e,n,u)}const Bn=1024,$n=1280,Ve=1536;function Wn(t,e,n){return n|e|t}class Yc{constructor(e){var n;this.maxLookahead=(n=e?.maxLookahead)!==null&&n!==void 0?n:jt.maxLookahead}validate(e){const n=this.validateNoLeftRecursion(e.rules);if(G(n)){const r=this.validateEmptyOrAlternatives(e.rules),i=this.validateAmbiguousAlternationAlternatives(e.rules,this.maxLookahead),o=this.validateSomeNonEmptyLookaheadPath(e.rules,this.maxLookahead);return[...n,...r,...i,...o]}return n}validateNoLeftRecursion(e){return mt(e,n=>ds(n,n,te))}validateEmptyOrAlternatives(e){return mt(e,n=>function(r,i){const o=new Fr;return r.accept(o),mt(o.alternations,s=>mt(be(s.definition),(a,c)=>G(us([a],[],_e,1))?[{message:i.buildEmptyAlternationError({topLevelRule:r,alternation:s,emptyChoiceIdx:c}),type:rt.NONE_LAST_EMPTY_ALT,ruleName:r.name,occurrence:s.idx,alternative:c+1}]:[]))}(n,te))}validateAmbiguousAlternationAlternatives(e,n){return mt(e,r=>Bc(r,n,te))}validateSomeNonEmptyLookaheadPath(e,n){return function(r,i,o){const s=[];return b(r,a=>{const c=new $c;a.accept(c),b(c.allProductions,u=>{const l=zi(u),h=u.maxLookahead||i;if(G(It(dr(u.idx,a,l,h)[0]))){const f=o.buildEmptyRepetitionError({topLevelRule:a,repetition:u});s.push({message:f,type:rt.NO_NON_EMPTY_LOOKAHEAD,ruleName:a.name})}})}),s}(e,n,te)}buildLookaheadForAlternation(e){return function(n,r,i,o,s,a){const c=Ur(n,r,i);return a(c,o,Hi(c)?hn:_e,s)}(e.prodOccurrence,e.rule,e.maxLookahead,e.hasPredicates,e.dynamicTokensEnabled,Pc)}buildLookaheadForOptional(e){return function(n,r,i,o,s,a){const c=dr(n,r,s,i),u=Hi(c)?hn:_e;return a(c[0],u,o)}(e.prodOccurrence,e.rule,e.maxLookahead,e.dynamicTokensEnabled,zi(e.prodType),wc)}}const He=new class extends pe{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 Xi(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}function qi(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.startColumn=e.startColumn,t.startLine=e.startLine,t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset,t.endColumn=e.endColumn,t.endLine=e.endLine)}function Is(t,e){Object.defineProperty(t,"name",{enumerable:!1,configurable:!0,writable:!1,value:e})}function Xc(t,e){const n=Tt(t),r=n.length;for(let i=0;i<r;i++){const o=t[n[i]],s=o.length;for(let a=0;a<s;a++){const c=o[a];c.tokenTypeIdx===void 0&&this[c.name](c.children,e)}}}function qc(t,e){const n=function(){};Is(n,t+"BaseSemantics");const r={visit:function(i,o){if(D(i)&&(i=i[0]),!Gt(i))return this[i.name](i.children,o)},validateVisitor:function(){const i=function(o,s){return function(c,u){const l=dt(u,f=>Kt(c[f])===!1),h=L(l,f=>({msg:`Missing visitor method: <${f}> on ${c.constructor.name} CST Visitor.`,type:mr.MISSING_METHOD,methodName:f}));return De(h)}(o,s)}(this,e);if(!G(i)){const o=L(i,s=>s.msg);throw Error(`Errors Detected in CST Visitor <${this.constructor.name}>:
90
- ${o.join(`
91
-
92
- `).replace(/\n/g,`
93
- `)}`)}}};return(n.prototype=r).constructor=n,n._RULE_NAMES=e,n}var mr;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(mr||(mr={}));const Sn={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(Sn);const Zi=!0,Qi=Math.pow(2,8)-1,vs=w({name:"RECORDING_PHASE_TOKEN",pattern:st.NA});je([vs]);const Ns=Mr(vs,`This IToken indicates the Parser is in Recording Phase
94
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Ns);const Zc={name:`This CSTNode indicates the Parser is in Recording Phase
95
- See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}};function Ie(t,e,n,r=!1){fn(n);const i=he(this.recordingProdStack),o=Kt(e)?e:e.DEF,s=new t({definition:[],idx:n});return r&&(s.separator=e.SEP),x(e,"MAX_LOOKAHEAD")&&(s.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(s),o.call(this),i.definition.push(s),this.recordingProdStack.pop(),Sn}function Qc(t,e){fn(e);const n=he(this.recordingProdStack),r=D(t)===!1,i=r===!1?t:t.DEF,o=new St({definition:[],idx:e,ignoreAmbiguities:r&&t.IGNORE_AMBIGUITIES===!0});x(t,"MAX_LOOKAHEAD")&&(o.maxLookahead=t.MAX_LOOKAHEAD);const s=Xo(i,a=>Kt(a.GATE));return o.hasPredicates=s,n.definition.push(o),b(i,a=>{const c=new ut({definition:[]});o.definition.push(c),x(a,"IGNORE_AMBIGUITIES")?c.ignoreAmbiguities=a.IGNORE_AMBIGUITIES:x(a,"GATE")&&(c.ignoreAmbiguities=!0),this.recordingProdStack.push(c),a.ALT.call(this),this.recordingProdStack.pop()}),Sn}function Ji(t){return t===0?"":`${t}`}function fn(t){if(t<0||t>Qi){const e=new Error(`Invalid DSL Method idx value: <${t}>
96
- Idx value must be a none negative value smaller than ${Qi+1}`);throw e.KNOWN_RECORDER_ERROR=!0,e}}const tn=Mr(Jt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(tn);const jt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:cs,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Ye=Object.freeze({recoveryValueFunc:()=>{},resyncEnabled:!0});var rt,Gn;(function(t){t[t.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",t[t.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",t[t.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",t[t.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",t[t.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",t[t.LEFT_RECURSION=5]="LEFT_RECURSION",t[t.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",t[t.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",t[t.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",t[t.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",t[t.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",t[t.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",t[t.TOO_MANY_ALTS=12]="TOO_MANY_ALTS",t[t.CUSTOM_LOOKAHEAD_VALIDATION=13]="CUSTOM_LOOKAHEAD_VALIDATION"})(rt||(rt={}));class Pe{static performSelfAnalysis(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")}performSelfAnalysis(){this.TRACE_INIT("performSelfAnalysis",()=>{let e;this.selfAnalysisDone=!0;const n=this.className;this.TRACE_INIT("toFastProps",()=>{Qo(this)}),this.TRACE_INIT("Grammar Recording",()=>{try{this.enableRecording(),b(this.definedRulesNames,i=>{const o=this[i].originalGrammarAction;let s;this.TRACE_INIT(`${i} Rule`,()=>{s=this.topLevelRuleRecord(i,o)}),this.gastProductionsCache[i]=s})}finally{this.disableRecording()}});let r=[];if(this.TRACE_INIT("Grammar Resolving",()=>{r=Wc({rules:Z(this.gastProductionsCache)}),this.definitionErrors=this.definitionErrors.concat(r)}),this.TRACE_INIT("Grammar Validations",()=>{if(G(r)&&this.skipValidations===!1){const o=(i={rules:Z(this.gastProductionsCache),tokenTypes:Z(this.tokensMap),errMsgProvider:te,grammarName:n},Fc((i=Pr(i,{errMsgProvider:te})).rules,i.tokenTypes,i.errMsgProvider,i.grammarName)),s=function(a){return L(a.lookaheadStrategy.validate({rules:a.rules,tokenTypes:a.tokenTypes,grammarName:a.grammarName}),c=>Object.assign({type:rt.CUSTOM_LOOKAHEAD_VALIDATION},c))}({lookaheadStrategy:this.lookaheadStrategy,rules:Z(this.gastProductionsCache),tokenTypes:Z(this.tokensMap),grammarName:n});this.definitionErrors=this.definitionErrors.concat(o,s)}var i}),G(this.definitionErrors)&&(this.recoveryEnabled&&this.TRACE_INIT("computeAllProdsFollows",()=>{const i=function(o){const s={};return b(o,a=>{const c=new lc(a).startWalking();lt(s,c)}),s}(Z(this.gastProductionsCache));this.resyncFollows=i}),this.TRACE_INIT("ComputeLookaheadFunctions",()=>{var i,o;(o=(i=this.lookaheadStrategy).initialize)===null||o===void 0||o.call(i,{rules:Z(this.gastProductionsCache)}),this.preComputeLookaheadFunctions(Z(this.gastProductionsCache))})),!Pe.DEFER_DEFINITION_ERRORS_HANDLING&&!G(this.definitionErrors))throw e=L(this.definitionErrors,i=>i.message),new Error(`Parser Definition Errors detected:
97
- ${e.join(`
98
- -------------------------------
99
- `)}`)})}constructor(e,n){this.definitionErrors=[],this.selfAnalysisDone=!1;const r=this;if(r.initErrorHandler(n),r.initLexerAdapter(),r.initLooksAhead(n),r.initRecognizerEngine(e,n),r.initRecoverable(n),r.initTreeBuilder(n),r.initContentAssist(),r.initGastRecorder(n),r.initPerformanceTracer(n),x(n,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
100
- Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
101
- See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
102
- For further details.`);this.skipValidations=x(n,"skipValidations")?n.skipValidations:jt.skipValidations}}Pe.DEFER_DEFINITION_ERRORS_HANDLING=!1,Gn=Pe,[class{initRecoverable(t){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=x(t,"recoveryEnabled")?t.recoveryEnabled:jt.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=Hc)}getTokenToInsert(t){const e=Mr(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(),o=this.exportLexerState(),s=[];let a=!1;const c=this.LA(1);let u=this.LA(1);const l=()=>{const h=this.LA(0),f=this.errorMessageProvider.buildMismatchTokenMessage({expected:r,actual:c,previous:h,ruleName:this.getCurrRuleFullName()}),d=new Yi(f,c,this.LA(0));d.resyncedTokens=be(s),this.SAVE_ERROR(d)};for(;!a;){if(this.tokenMatcher(u,r))return void l();if(n.call(this))return l(),void t.apply(this,e);this.tokenMatcher(u,i)?a=!0:(u=this.SKIP_TOKEN(),this.addToResyncTokens(u,s))}this.importLexerState(o)}shouldInRepetitionRecoveryBeTried(t,e,n){return n!==!1&&!this.tokenMatcher(this.LA(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 n=this.SKIP_TOKEN();return this.consumeToken(),n}throw new Vc("sad sad panda")}canPerformInRuleRecovery(t,e){return this.canRecoverWithSingleTokenInsertion(t,e)||this.canRecoverWithSingleTokenDeletion(t)}canRecoverWithSingleTokenInsertion(t,e){if(!this.canTokenTypeBeInsertedInRecovery(t)||G(e))return!1;const n=this.LA(1);return fe(e,r=>this.tokenMatcher(n,r))!==void 0}canRecoverWithSingleTokenDeletion(t){return!!this.canTokenTypeBeDeletedInRecovery(t)&&this.tokenMatcher(this.LA(2),t)}isInCurrentRuleReSyncSet(t){const e=this.getCurrFollowKey();return it(this.getFollowSetFromFollowKey(e),t)}findReSyncTokenType(){const t=this.flattenFollowSet();let e=this.LA(1),n=2;for(;;){const r=fe(t,i=>_e(e,i));if(r!==void 0)return r;e=this.LA(n),n++}}getCurrFollowKey(){if(this.RULE_STACK.length===1)return jn;const t=this.getLastExplicitRuleShortName(),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;return L(t,(n,r)=>r===0?jn:{ruleName:this.shortRuleNameToFullName(n),idxInCallingRule:e[r],inRule:this.shortRuleNameToFullName(t[r-1])})}flattenFollowSet(){return It(L(this.buildFullFollowKeyStack(),t=>this.getFollowSetFromFollowKey(t)))}getFollowSetFromFollowKey(t){if(t===jn)return[Jt];const e=t.ruleName+t.idxInCallingRule+Jo+t.inRule;return this.resyncFollows[e]}addToResyncTokens(t,e){return this.tokenMatcher(t,Jt)||e.push(t),e}reSyncTo(t){const e=[];let n=this.LA(1);for(;this.tokenMatcher(n,t)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,e);return be(e)}attemptInRepetitionRecovery(t,e,n,r,i,o,s){}getCurrentGrammarPath(t,e){return{ruleStack:this.getHumanReadableRuleStack(),occurrenceStack:tt(this.RULE_OCCURRENCE_STACK),lastTok:t,lastTokOccurrence:e}}getHumanReadableRuleStack(){return L(this.RULE_STACK,t=>this.shortRuleNameToFullName(t))}},class{initLooksAhead(t){this.dynamicTokensEnabled=x(t,"dynamicTokensEnabled")?t.dynamicTokensEnabled:jt.dynamicTokensEnabled,this.maxLookahead=x(t,"maxLookahead")?t.maxLookahead:jt.maxLookahead,this.lookaheadStrategy=x(t,"lookaheadStrategy")?t.lookaheadStrategy:new Yc({maxLookahead:this.maxLookahead}),this.lookAheadFuncsCache=new Map}preComputeLookaheadFunctions(t){b(t,e=>{this.TRACE_INIT(`${e.name} Rule Lookahead`,()=>{const{alternation:n,repetition:r,option:i,repetitionMandatory:o,repetitionMandatoryWithSeparator:s,repetitionWithSeparator:a}=function(c){He.reset(),c.accept(He);const u=He.dslMethods;return He.reset(),u}(e);b(n,c=>{const u=c.idx===0?"":c.idx;this.TRACE_INIT(`${_t(c)}${u}`,()=>{const l=this.lookaheadStrategy.buildLookaheadForAlternation({prodOccurrence:c.idx,rule:e,maxLookahead:c.maxLookahead||this.maxLookahead,hasPredicates:c.hasPredicates,dynamicTokensEnabled:this.dynamicTokensEnabled}),h=Wn(this.fullRuleNameToShort[e.name],256,c.idx);this.setLaFuncCache(h,l)})}),b(r,c=>{this.computeLookaheadFunc(e,c.idx,768,"Repetition",c.maxLookahead,_t(c))}),b(i,c=>{this.computeLookaheadFunc(e,c.idx,512,"Option",c.maxLookahead,_t(c))}),b(o,c=>{this.computeLookaheadFunc(e,c.idx,Bn,"RepetitionMandatory",c.maxLookahead,_t(c))}),b(s,c=>{this.computeLookaheadFunc(e,c.idx,Ve,"RepetitionMandatoryWithSeparator",c.maxLookahead,_t(c))}),b(a,c=>{this.computeLookaheadFunc(e,c.idx,$n,"RepetitionWithSeparator",c.maxLookahead,_t(c))})})})}computeLookaheadFunc(t,e,n,r,i,o){this.TRACE_INIT(`${o}${e===0?"":e}`,()=>{const s=this.lookaheadStrategy.buildLookaheadForOptional({prodOccurrence:e,rule:t,maxLookahead:i||this.maxLookahead,dynamicTokensEnabled:this.dynamicTokensEnabled,prodType:r}),a=Wn(this.fullRuleNameToShort[t.name],n,e);this.setLaFuncCache(a,s)})}getKeyForAutomaticLookahead(t,e){return Wn(this.getLastExplicitRuleShortName(),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=x(t,"nodeLocationTracking")?t.nodeLocationTracking:jt.nodeLocationTracking,this.outputCst)if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=qi,this.setNodeLocationFromNode=qi,this.cstPostRule=q,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=q,this.setNodeLocationFromNode=q,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Xi,this.setNodeLocationFromNode=Xi,this.cstPostRule=q,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=q,this.setNodeLocationFromNode=q,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=q,this.setNodeLocationFromNode=q,this.cstPostRule=q,this.setInitialNodeLocation=q}else this.cstInvocationStateUpdate=q,this.cstFinallyStateUpdate=q,this.cstPostTerminal=q,this.cstPostNonTerminal=q,this.cstPostRule=q}setInitialNodeLocationOnlyOffsetRecovery(t){t.location={startOffset:NaN,endOffset:NaN}}setInitialNodeLocationOnlyOffsetRegular(t){t.location={startOffset:this.LA(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(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,o;i=e,o=t,(r=n).children[o]===void 0?r.children[o]=[i]:r.children[o].push(i),this.setNodeLocationFromToken(n.location,e)}cstPostNonTerminal(t,e){const n=this.CST_STACK[this.CST_STACK.length-1];(function(r,i,o){r.children[i]===void 0?r.children[i]=[o]:r.children[i].push(o)})(n,e,t),this.setNodeLocationFromNode(n.location,t.location)}getBaseCstVisitorConstructor(){if(Gt(this.baseCstVisitorConstructor)){const t=qc(this.className,Tt(this.gastProductionsCache));return this.baseCstVisitorConstructor=t,t}return this.baseCstVisitorConstructor}getBaseCstVisitorConstructorWithDefaults(){if(Gt(this.baseCstVisitorWithDefaultsConstructor)){const t=function(e,n,r){const i=function(){};Is(i,e+"BaseSemanticsWithDefaults");const o=Object.create(r.prototype);return b(n,s=>{o[s]=Xc}),(i.prototype=o).constructor=i,i}(this.className,Tt(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=t,t}return this.baseCstVisitorWithDefaultsConstructor}getLastExplicitRuleShortName(){const t=this.RULE_STACK;return t[t.length-1]}getPreviousExplicitRuleShortName(){const t=this.RULE_STACK;return t[t.length-2]}getLastExplicitRuleOccurrenceIndex(){const t=this.RULE_OCCURRENCE_STACK;return t[t.length-1]}},class{initLexerAdapter(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1}set input(t){if(this.selfAnalysisDone!==!0)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.tokVector.length-2?(this.consumeToken(),this.LA(1)):tn}LA(t){const e=this.currIdx+t;return e<0||this.tokVectorLength<=e?tn:this.tokVector[e]}consumeToken(){this.currIdx++}exportLexerState(){return this.currIdx}importLexerState(t){this.currIdx=t}resetLexerState(){this.currIdx=-1}moveToTerminatedState(){this.currIdx=this.tokVector.length-1}getLexerPosition(){return this.exportLexerState()}},class{initRecognizerEngine(t,e){if(this.className=this.constructor.name,this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=hn,this.subruleIdx=0,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},x(e,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
103
- See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
104
- For Further details.`);if(D(t)){if(G(t))throw Error(`A Token Vocabulary cannot be empty.
105
- Note that the first argument for the parser constructor
106
- is no longer a Token vector (since v4.0).`);if(typeof t[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
107
- See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
108
- For Further details.`)}if(D(t))this.tokensMap=ht(t,(r,i)=>(r[i.name]=i,r),{});else if(x(t,"modes")&&vt(It(Z(t.modes)),yc)){const r=ar(It(Z(t.modes)));this.tokensMap=ht(r,(i,o)=>(i[o.name]=o,i),{})}else{if(!gt(t))throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap=tt(t)}this.tokensMap.EOF=Jt;const n=vt(x(t,"modes")?It(Z(t.modes)):Z(t),r=>G(r.categoryMatches));this.tokenMatcher=n?hn:_e,je(Z(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'
109
- Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);const r=x(n,"resyncEnabled")?n.resyncEnabled:Ye.resyncEnabled,i=x(n,"recoveryValueFunc")?n.recoveryValueFunc:Ye.recoveryValueFunc,o=this.ruleShortNameIdx<<12;let s;return this.ruleShortNameIdx++,this.shortRuleNameToFull[o]=t,this.fullRuleNameToShort[t]=o,s=this.outputCst===!0?function(...a){try{this.ruleInvocationStateUpdate(o,t,this.subruleIdx),e.apply(this,a);const c=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(c),c}catch(c){return this.invokeRuleCatch(c,r,i)}finally{this.ruleFinallyStateUpdate()}}:function(...a){try{return this.ruleInvocationStateUpdate(o,t,this.subruleIdx),e.apply(this,a)}catch(c){return this.invokeRuleCatch(c,r,i)}finally{this.ruleFinallyStateUpdate()}},Object.assign(s,{ruleName:t,originalGrammarAction:e})}invokeRuleCatch(t,e,n){const r=this.RULE_STACK.length===1,i=e&&!this.isBackTracking()&&this.recoveryEnabled;if(ze(t)){const o=t;if(i){const s=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(s)){if(o.resyncedTokens=this.reSyncTo(s),this.outputCst){const a=this.CST_STACK[this.CST_STACK.length-1];return a.recoveredNode=!0,a}return n(t)}if(this.outputCst){const a=this.CST_STACK[this.CST_STACK.length-1];a.recoveredNode=!0,o.partialCstResult=a}throw o}if(r)return this.moveToTerminatedState(),n(t);throw o}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(typeof t!="function"){r=t.DEF;const o=t.GATE;if(o!==void 0){const s=i;i=()=>o.call(this)&&s.call(this)}}else r=t;if(i.call(this)===!0)return r.call(this)}atLeastOneInternal(t,e){const n=this.getKeyForAutomaticLookahead(Bn,t);return this.atLeastOneInternalLogic(t,e,n)}atLeastOneInternalLogic(t,e,n){let r,i=this.getLaFuncFromCache(n);if(typeof e!="function"){r=e.DEF;const o=e.GATE;if(o!==void 0){const s=i;i=()=>o.call(this)&&s.call(this)}}else r=e;if(i.call(this)!==!0)throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY,e.ERR_MSG);{let o=this.doSingleRepetition(r);for(;i.call(this)===!0&&o===!0;)o=this.doSingleRepetition(r)}this.attemptInRepetitionRecovery(this.atLeastOneInternal,[t,e],i,Bn,t,kc)}atLeastOneSepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead(Ve,t);this.atLeastOneSepFirstInternalLogic(t,e,n)}atLeastOneSepFirstInternalLogic(t,e,n){const r=e.DEF,i=e.SEP;if(this.getLaFuncFromCache(n).call(this)!==!0)throw this.raiseEarlyExitException(t,H.REPETITION_MANDATORY_WITH_SEPARATOR,e.ERR_MSG);{r.call(this);const o=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,o,r,Ki],o,Ve,t,Ki)}}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(typeof e!="function"){r=e.DEF;const s=e.GATE;if(s!==void 0){const a=i;i=()=>s.call(this)&&a.call(this)}}else r=e;let o=!0;for(;i.call(this)===!0&&o===!0;)o=this.doSingleRepetition(r);this.attemptInRepetitionRecovery(this.manyInternal,[t,e],i,768,t,Cc,o)}manySepFirstInternal(t,e){const n=this.getKeyForAutomaticLookahead($n,t);this.manySepFirstInternalLogic(t,e,n)}manySepFirstInternalLogic(t,e,n){const r=e.DEF,i=e.SEP;if(this.getLaFuncFromCache(n).call(this)===!0){r.call(this);const o=()=>this.tokenMatcher(this.LA(1),i);for(;this.tokenMatcher(this.LA(1),i)===!0;)this.CONSUME(i),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,i,o,r,Gi],o,$n,t,Gi)}}repetitionSepSecondInternal(t,e,n,r,i){for(;n();)this.CONSUME(e),r.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[t,e,n,r,i],n,Ve,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=D(t)?t:t.DEF,i=this.getLaFuncFromCache(n).call(this,r);if(i!==void 0)return r[i].ALT.call(this);this.raiseNoAltException(e,t.ERR_MSG)}ruleFinallyStateUpdate(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){const t=this.LA(1),e=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:t,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Kc(e,t))}}subruleInternal(t,e,n){let r;try{const i=n!==void 0?n.ARGS:void 0;return this.subruleIdx=e,r=t.apply(this,i),this.cstPostNonTerminal(r,n!==void 0&&n.LABEL!==void 0?n.LABEL:t.ruleName),r}catch(i){throw this.subruleInternalError(i,n,t.ruleName)}}subruleInternalError(t,e,n){throw ze(t)&&t.partialCstResult!==void 0&&(this.cstPostNonTerminal(t.partialCstResult,e!==void 0&&e.LABEL!==void 0?e.LABEL:n),delete t.partialCstResult),t}consumeInternal(t,e,n){let r;try{const i=this.LA(1);this.tokenMatcher(i,t)===!0?(this.consumeToken(),r=i):this.consumeInternalError(t,i,n)}catch(i){r=this.consumeInternalRecovery(t,e,i)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:t.name,r),r}consumeInternalError(t,e,n){let r;const i=this.LA(0);throw r=n!==void 0&&n.ERR_MSG?n.ERR_MSG:this.errorMessageProvider.buildMismatchTokenMessage({expected:t,actual:e,previous:i,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Yi(r,e,i))}consumeInternalRecovery(t,e,n){if(!this.recoveryEnabled||n.name!=="MismatchedTokenException"||this.isBackTracking())throw n;{const r=this.getFollowsForInRuleRecovery(t,e);try{return this.tryInRuleRecovery(t,r)}catch(i){throw i.name===As?n:i}}}saveRecogState(){const t=this.errors,e=tt(this.RULE_STACK);return{errors:t,lexerState:this.exportLexerState(),RULE_STACK:e,CST_STACK:this.CST_STACK}}reloadRecogState(t){this.errors=t.errors,this.importLexerState(t.lexerState),this.RULE_STACK=t.RULE_STACK}ruleInvocationStateUpdate(t,e,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(t),this.cstInvocationStateUpdate(e)}isBackTracking(){return this.isBackTrackingStack.length!==0}getCurrRuleFullName(){const t=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[t]}shortRuleNameToFullName(t){return this.shortRuleNameToFull[t]}isAtEndOfInput(){return this.tokenMatcher(this.LA(1),Jt)}reset(){this.resetLexerState(),this.subruleIdx=0,this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]}},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=Ye){if(it(this.definedRulesNames,t)){const i={message:te.buildDuplicateRuleNameError({topLevelRule:t,grammarName:this.className}),type:rt.DUPLICATE_RULE_NAME,ruleName:t};this.definitionErrors.push(i)}this.definedRulesNames.push(t);const r=this.defineRule(t,e,n);return this[t]=r,r}OVERRIDE_RULE(t,e,n=Ye){const r=function(o,s,a){const c=[];let u;return it(s,o)||(u=`Invalid rule override, rule: ->${o}<- cannot be overridden in the grammar: ->${a}<-as it is not defined in any of the super grammars `,c.push({message:u,type:rt.INVALID_RULE_OVERRIDE,ruleName:o})),c}(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){return function(){this.isBackTrackingStack.push(1);const n=this.saveRecogState();try{return t.apply(this,e),!0}catch(r){if(ze(r))return!1;throw r}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}}getGAstProductions(){return this.gastProductionsCache}getSerializedGastProductions(){return L(Z(this.gastProductionsCache),qe)}},class{initErrorHandler(t){this._errors=[],this.errorMessageProvider=x(t,"errorMessageProvider")?t.errorMessageProvider:jt.errorMessageProvider}SAVE_ERROR(t){if(ze(t))return t.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:tt(this.RULE_OCCURRENCE_STACK)},this._errors.push(t),t;throw Error("Trying to save an Error which is not a RecognitionException")}get errors(){return tt(this._errors)}set errors(t){this._errors=t}raiseEarlyExitException(t,e,n){const r=this.getCurrRuleFullName(),i=dr(t,this.getGAstProductions()[r],e,this.maxLookahead)[0],o=[];for(let a=1;a<=this.maxLookahead;a++)o.push(this.LA(a));const s=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:i,actual:o,previous:this.LA(0),customUserDescription:n,ruleName:r});throw this.SAVE_ERROR(new zc(s,this.LA(1),this.LA(0)))}raiseNoAltException(t,e){const n=this.getCurrRuleFullName(),r=Ur(t,this.getGAstProductions()[n],this.maxLookahead),i=[];for(let a=1;a<=this.maxLookahead;a++)i.push(this.LA(a));const o=this.LA(0),s=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:r,actual:i,previous:o,customUserDescription:e,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Gc(s,this.LA(1),o))}},class{initContentAssist(){}computeContentAssist(t,e){const n=this.gastProductionsCache[t];if(Gt(n))throw Error(`Rule ->${t}<- does not exist in this grammar.`);return us([n],e,this.tokenMatcher,this.maxLookahead)}getNextPossibleTokenTypes(t){const e=yt(t.ruleStack),n=this.getGAstProductions()[e];return new xc(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(n,r){return this.consumeInternalRecord(n,t,r)},this[`SUBRULE${e}`]=function(n,r){return this.subruleInternalRecord(n,t,r)},this[`OPTION${e}`]=function(n){return this.optionInternalRecord(n,t)},this[`OR${e}`]=function(n){return this.orInternalRecord(n,t)},this[`MANY${e}`]=function(n){this.manyInternalRecord(t,n)},this[`MANY_SEP${e}`]=function(n){this.manySepFirstInternalRecord(t,n)},this[`AT_LEAST_ONE${e}`]=function(n){this.atLeastOneInternalRecord(t,n)},this[`AT_LEAST_ONE_SEP${e}`]=function(n){this.atLeastOneSepFirstInternalRecord(t,n)}}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 tn}topLevelRuleRecord(t,e){try{const n=new de({definition:[],name:t});return n.name=t,this.recordingProdStack.push(n),e.call(this),this.recordingProdStack.pop(),n}catch(n){if(n.KNOWN_RECORDER_ERROR!==!0)try{n.message=n.message+`
110
- This error was thrown during the "grammar recording phase" For more info see:
111
- https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw n}throw n}}optionInternalRecord(t,e){return Ie.call(this,ct,t,e)}atLeastOneInternalRecord(t,e){Ie.call(this,Pt,e,t)}atLeastOneSepFirstInternalRecord(t,e){Ie.call(this,wt,e,t,Zi)}manyInternalRecord(t,e){Ie.call(this,Q,e,t)}manySepFirstInternalRecord(t,e){Ie.call(this,Ot,e,t,Zi)}orInternalRecord(t,e){return Qc.call(this,t,e)}subruleInternalRecord(t,e,n){if(fn(e),!t||x(t,"ruleName")===!1){const s=new Error(`<SUBRULE${Ji(e)}> argument is invalid expecting a Parser method reference but got: <${JSON.stringify(t)}>
112
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw s.KNOWN_RECORDER_ERROR=!0,s}const r=he(this.recordingProdStack),i=t.ruleName,o=new ft({idx:e,nonTerminalName:i,label:n?.LABEL,referencedRule:void 0});return r.definition.push(o),this.outputCst?Zc:Sn}consumeInternalRecord(t,e,n){if(fn(e),!ss(t)){const o=new Error(`<CONSUME${Ji(e)}> argument is invalid expecting a TokenType reference but got: <${JSON.stringify(t)}>
113
- inside top level rule: <${this.recordingProdStack[0].name}>`);throw o.KNOWN_RECORDER_ERROR=!0,o}const r=he(this.recordingProdStack),i=new z({idx:e,terminalType:t,label:n?.LABEL});return r.definition.push(i),Ns}},class{initPerformanceTracer(t){if(x(t,"traceInitPerf")){const e=t.traceInitPerf,n=typeof e=="number";this.traceInitMaxIdent=n?e:1/0,this.traceInitPerf=n?e>0:e}else this.traceInitMaxIdent=0,this.traceInitPerf=jt.traceInitPerf;this.traceInitIndent=-1}TRACE_INIT(t,e){if(this.traceInitPerf===!0){this.traceInitIndent++;const n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(`${n}--> <${t}>`);const{time:r,value:i}=Zo(e),o=r>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&o(`${n}<-- <${t}> time: ${r}ms`),this.traceInitIndent--,i}return e()}}].forEach(t=>{const e=t.prototype;Object.getOwnPropertyNames(e).forEach(n=>{if(n==="constructor")return;const r=Object.getOwnPropertyDescriptor(e,n);r&&(r.get||r.set)?Object.defineProperty(Gn.prototype,n,r):Gn.prototype[n]=t.prototype[n]})});class Jc extends Pe{constructor(e,n=jt){const r=tt(n);r.outputCst=!1,super(e,r)}}const tu=w({name:"WhiteSpace",pattern:/\s+/,group:st.SKIPPED}),ys=w({name:"String",pattern:/"(""|[^"])*"/}),eu=w({name:"SingleQuotedString",pattern:/'(''|[^'])*'/}),nu=w({name:"SheetQuoted",pattern:/'((?![\\/[\]*?:]).)+?'!/}),ru=w({name:"FunctionToken",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\(/}),Rs=w({name:"NamedTableReference",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\[/}),iu=w({name:"BracketedString",pattern:/\[([^[\]]*)\]/,longer_alt:[Rs,ys]}),Os=w({name:"LiteralError",pattern:/#PARSE!|#NULL!|#DIV\/0!|#VALUE!|#NUM!|#FIELD!|#N\/A|#GETTING_DATA|#SPILL!|#CONNECT!|#BLOCKED!|#UNKNOWN!|#FIELD!|#CALC!|#BUSY!|#PYTHON!|#TIMEOUT!/}),Ss=w({name:"RefError",pattern:/#REF!|#NAME\?/}),ou=w({name:"Sheet",pattern:/[A-Za-z_.\d\u007F-\uFFFF]+!/}),su=/^[a-zA-Z_][a-zA-Z0-9_.?]*:?/,_n=w({name:"Name",pattern:{exec:(t,e)=>{try{const n=su.exec(t.substring(e));if(n){const r=n[0];if(r.endsWith(":")){const i=r.length;return r[i-2]==="."?[r.substring(0,i-2)]:[r.substring(0,i-1)]}return[r]}}catch(n){console.warn("Error parsing name",n)}return null}},line_breaks:!1,start_chars_hint:(()=>{const t=[];for(let e=65;e<=90;e++)t.push(e);for(let e=97;e<=122;e++)t.push(e);for(let e=48;e<=57;e++)t.push(e);return t})()}),au=w({name:"Cell",pattern:/[$]?[A-Za-z]{1,3}[$]?[1-9][0-9]*/,longer_alt:_n}),cu=w({name:"Column",pattern:/[$]?[A-Za-z]{1,3}/,longer_alt:_n}),uu=w({name:"AbsRow",pattern:/[$][0-9]+/,longer_alt:_n}),lu=w({name:"NumberToken",pattern:/[0-9]+[.]?[0-9]*([eE][+-][0-9]+)?/}),hu=w({name:"Boolean",pattern:/TRUE|FALSE/i}),fu=w({name:"Comma",pattern:/,/}),du=w({name:"RangeUnion",pattern:/:/}),pu=w({name:"RangeTrimFull",pattern:/\.:\./}),mu=w({name:"RangeTrimLeading",pattern:/\.:/}),Eu=w({name:"RangeTrimTrailing",pattern:/:\./}),gu=w({name:"Semicolon",pattern:/;/}),Tu=w({name:"OpenParen",pattern:/\(/}),Au=w({name:"CloseParen",pattern:/\)/}),Iu=w({name:"OpenSquareParen",pattern:/\[/}),vu=w({name:"CloseSquareParen",pattern:/]/});w({name:"exclamationMark",pattern:/!/});const Nu=w({name:"OpenCurlyParen",pattern:/{/}),yu=w({name:"CloseCurlyParen",pattern:/}/}),Ru=w({name:"QuoteS",pattern:/'/}),to=w({name:"MulOp",pattern:/\*/}),Ou=w({name:"PlusOp",pattern:/\+/}),Su=w({name:"DivOp",pattern:/\//}),_u=w({name:"MinOp",pattern:/-/}),Lu=w({name:"ImplicitIntersectOp",pattern:/@/}),xu=w({name:"ConcatOp",pattern:/&/}),Cu=w({name:"ExOp",pattern:/\^/}),ku=w({name:"PercentOp",pattern:/%/}),_s=w({name:"TableSpecifier",pattern:/#(All|Data|Headers|Totals|This Row)/i}),bu=w({name:"ArrayAnchorOp",pattern:/#/,longer_alt:[_s,Os,Ss]}),Pu=w({name:"GtOp",pattern:/>/}),wu=w({name:"EqOp",pattern:/=/}),Mu=w({name:"LtOp",pattern:/</}),Ls=[tu,ys,nu,eu,ru,Rs,iu,Os,Ss,ou,au,hu,cu,uu,_s,bu,Lu,_n,lu,fu,pu,mu,Eu,du,gu,Tu,Au,Iu,vu,Nu,yu,Ru,to,Ou,Su,_u,xu,Cu,to,ku,w({name:"NeqOp",pattern:/<>/}),w({name:"GteOp",pattern:/>=/}),w({name:"LteOp",pattern:/<=/}),Pu,wu,Mu],Uu=new st(Ls,{ensureOptimizations:!0}),Dr={};Ls.forEach(t=>{Dr[t.name]=t});const Ht={boolean:3,string:2,number:1},Fu=(t,e)=>{let n=t+e;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},Du=(t,e)=>{let n=t-e;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},xs=(t,e)=>{let n=t*e;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},Cs=(t,e)=>{if(e===0)return 1/0;let n=t/e;return n=Math.abs(n)<99e-14?0:n,isFinite(n)?n:Number.NaN},ju=(t,e)=>{const n=t**e;return isFinite(n)?n:Number.NaN},Bu=(t="",e="")=>(t===null&&(t=""),e===null&&(e=""),typeof t=="boolean"&&(t=t?"TRUE":"FALSE"),typeof e=="boolean"&&(e=e?"TRUE":"FALSE"),""+t+e),$u=(t=null,e=null)=>typeof t==typeof e&&t===e,Wu=(t=null,e=null)=>typeof t!=typeof e||t!==e,Gu=(t=null,e=null)=>{const n=typeof t,r=typeof e;return n===r?t>e:Ht[n]>Ht[r]},Ku=(t=null,e=null)=>{const n=typeof t,r=typeof e;return n===r?t>=e:Ht[n]>=Ht[r]},zu=(t=null,e=null)=>{const n=typeof t,r=typeof e;return n===r?t<e:Ht[n]<Ht[r]},Vu=(t=null,e=null)=>{const n=typeof t,r=typeof e;return n===r?t<=e:Ht[n]<=Ht[r]},Hu={type:R.M.Number,coerce:!0,includeBoolean:!0,includeMistyped:!0,mismatchFill:R.n.BuiltIn.NA},Yu={type:R.M.String,coerce:!0,includeMistyped:!0,mismatchFill:R.n.BuiltIn.NA},ks={type:null,coerce:!0,includeMistyped:!0,mismatchFill:R.n.BuiltIn.NA},ae=(t,e,n,r)=>{if(e!==null&&e.colStart!==void 0&&(e=t.getValueAt(e.rowStart,e.colStart)),n!==null&&n.colStart!==void 0&&(n=t.getValueAt(n.rowStart,n.colStart)),typeof e=="number"&&typeof n=="number")return r(e,n);let i,o;return e?.isIRange?i=e:n?.isIRange&&(o=n),!i&&!o?(e=R.coerceScalar(e,R.typeFromJsValue(e,!0),R.M.Number,!0,!1),n=R.coerceScalar(n,R.typeFromJsValue(n,!0),R.M.Number,!0,!1),e instanceof R.n.Value?e:n instanceof R.n.Value?n:r(e,n)):(i||(i=t.getRange(e)),i.broadcast(n,r,Hu).fillEmpty(0))},oe=(t,e,n,r)=>{let i,o;return e!==null&&e.colStart!==void 0&&(e=t.getValueAt(e.rowStart,e.colStart)),n!==null&&n.colStart!==void 0&&(n=t.getValueAt(n.rowStart,n.colStart)),e?.isIRange?(i=e,o=n):n?.isIRange&&(i=n,o=e),i?i.broadcast(o,r,ks):r(e,n)},eo=(t,e)=>{e==null&&(e=0);let n,r=1;if(t==="+")return e;if(t!=="-")throw new R.n.Value(`Unrecognized prefix: ${t}`);return r=-r,e?.isIRange&&(n=e),n?n.broadcast(r,xs,ks):typeof(e=R.coerceScalar(e,R.typeFromJsValue(e,!0),R.M.Number))!="number"||isNaN(e)?R.n.BuiltIn.Value:e*r},ve=(t,e,n,r)=>{if(!e||(e.isIReferenceRange&&(e=e.getCoords()),e.colStart===void 0)||(n.isIReferenceRange&&(n=n.getCoords()),n.colStart===void 0))return R.n.BuiltIn.Ref;const i=r(e,n);return i?t.getReference(i):R.n.BuiltIn.Null},Xu={"+":(t,e,n)=>ae(t,e,n,Fu),"-":(t,e,n)=>ae(t,e,n,Du),"*":(t,e,n)=>ae(t,e,n,xs),"/":(t,e,n)=>ae(t,e,n,Cs),"^":(t,e,n)=>ae(t,e,n,ju)," ":(t,e,n,r)=>ve(t,e,n,R.Kt.intersectRanges),":":(t,e,n,r)=>ve(t,e,n,R.Kt.unionRanges),".:.":(t,e,n,r)=>{const i=ve(t,e,n,R.Kt.unionRanges);return t.getFunction("TRIMRANGE").execute(i,3,3)},".:":(t,e,n,r)=>{const i=ve(t,e,n,R.Kt.unionRanges);return t.getFunction("TRIMRANGE").execute(i,1,1)},":.":(t,e,n,r)=>{const i=ve(t,e,n,R.Kt.unionRanges);return t.getFunction("TRIMRANGE").execute(i,2,2)},"&":(t,e,n)=>((r,i,o,s)=>{if(i!==null&&i.colStart!==void 0&&(i=r.getValueAt(i.rowStart,i.colStart)),o!==null&&o.colStart!==void 0&&(o=r.getValueAt(o.rowStart,o.colStart)),typeof i=="string"&&typeof o=="string")return s(i,o);let a,c;return i?.isIRange?a=i:o?.isIRange&&(c=o),a||c?(a||(a=r.getRange(i)),a.broadcast(o,s,Yu)):s(i=R.coerceScalar(i,R.typeFromJsValue(i,!0),R.M.String),o=R.coerceScalar(o,R.typeFromJsValue(o,!0),R.M.String))})(t,e,n,Bu),"=":(t,e,n)=>oe(t,e,n,$u),"<>":(t,e,n)=>oe(t,e,n,Wu),">":(t,e,n)=>oe(t,e,n,Gu),"<":(t,e,n)=>oe(t,e,n,zu),">=":(t,e,n)=>oe(t,e,n,Ku),"<=":(t,e,n)=>oe(t,e,n,Vu)},qu={"-":(t,e)=>eo("-",e),"+":(t,e)=>eo("+",e),"@":(t,e)=>{if(!e||!e.isIReferenceRange)return e;const n=e.getCoords(),r=e,i=t.getPosition(),o=r.getHeight(),s=r.getWidth();if(s>1&&o>1)return R.n.BuiltIn.Value;if(o>1){const a=i.rowIndex-n.rowStart;if(a>=0&&a<o)return r.getValueAt(a,0)}else{if(!(s>1))return r.getValueAt(0,0);{const a=i.colIndex-n.colStart;if(a>=0&&a<s)return r.getValueAt(0,a)}}return R.n.BuiltIn.Value}},Zu={"%":(t,e)=>ae(t,e,100,Cs),"#":(t,e)=>t.getSpillAt(e.rowStart,e.colStart)||R.n.BuiltIn.Ref};function no(t){const e=(t=t.toUpperCase()).length;let n=0;for(let r=0;r<e;r++){const i=t.charCodeAt(r);isNaN(i)||(n+=(i-64)*26**(e-r-1))}return n}function Kn(t){return{type:"cell",value:Object.freeze({colIndex:t.colIndex,rowIndex:t.rowIndex,$colIndex:t.$colIndex||!1,$rowIndex:t.$rowIndex||!1}),inputs:null,isReference:!0}}function ro(t,e){const n=t.startsWith("$");n&&(t=t.substring(1));let r=parseInt(t)-1;return n||r===Number.MIN_SAFE_INTEGER||(r-=e.colIndex),{type:"cell",value:Object.freeze({colIndex:Number.MIN_SAFE_INTEGER,$colIndex:!1,rowIndex:r,$rowIndex:n}),inputs:null,isReference:!0}}function io(t,e){return{type:"function",value:t=t.toUpperCase(),inputs:e}}function zn(t,e){return{type:"tableReference",value:t,inputs:e}}function Vn(t){return{type:"tableSpecifier",value:t,inputs:null,isReference:!0}}function Er(t,e,n,r=!1){const i={type:"infix",value:t,inputs:[e,n]};return r&&(i.isReference=!0),i}function Hn(t,e,n=!1){const r={type:"postfix",value:t,inputs:[e]};return n&&(r.isReference=!0),r}function Re(t,e,n=!1){const r={type:"prefix",value:t,inputs:[e]};return n&&(r.isReference=!0),r}function Yn(t){return{type:"named",value:t,inputs:null,isReference:!0}}function oo(t){return{type:"number",value:Number(t),isLiteral:!0}}function Xn(t){let e=t;const n=t&&t.length>1&&t[0]==='"'&&t[t.length-1]==='"';return n&&(e=t.substring(1,t.length-1)),{type:n?"quotedString":"string",value:e,isLiteral:!0}}function so(t){return{type:"boolean",value:t==="TRUE"||t.toUpperCase()==="TRUE",isLiteral:!0}}function ao(t){return{type:"error",value:R.n.getBuiltInByLabel(t.toUpperCase()),isLiteral:!0}}function dn(t){return{type:"error",value:t?R.n.getBuiltInByLabel(t.toUpperCase()):R.n.BuiltIn.Ref,inputs:null,isReference:!0}}function we(t,e){return function r(i,o){const s=i.inputs;let a;if(s){const l=s.length;for(let h=0;h<l;h++){const f=s[h],d=r(f,i);d!==f&&(a||(a=[...s]),a[h]=d)}}const c=a?{...i,inputs:a}:i,u=e(c,o);return u===void 0?c:u}(t,void 0)||this}function en(t,e){let n=0,r=we(t,p=>{const A={...p};return A.evalIndex=n++,A});const i=new Array(n),o=new Set,s=new Map;let a;const c=new Map,u=[],l=[];r=we(r,(p,A)=>{const S=p.type,g=p.evalIndex;if(i[g]=null,p.isReference){const O=p,N={node:p,index:c.size,op:null,value:null,inputs:null};if(c.set(O,N),S==="cell"){const v=O.value;return v.$colIndex&&(N.hasHorizontalAbs=!0),v.$rowIndex&&(N.hasVerticalAbs=!0),N.value=s.size,s.set(O,s.size),o.add(N),p.refIndex=l.length,void l.push(N.index)}if(S==="infix"||S==="prefix"||S==="postfix"||S==="spill"){const v=O.inputs,y=v.length,U=p.value;N.op=U;const M=new Array(y);N.inputs=M;for(let F=0;F<y;F++){const $=v[F],C=c.get($);C&&(C.hasHorizontalAbs&&(N.hasHorizontalAbs=!0),C.hasVerticalAbs&&(N.hasVerticalAbs=!0)),M[F]=C?C.index:-1,o.delete(C)}if(o.add(N),bs.includes(U)){const F=v[0],$=!!F&&F.type==="cell",C=v[1],k=!!C&&C.type==="cell";$&&k&&(l.splice(C.refIndex,1),C.refIndex=F.refIndex,p.refIndex=F.refIndex,l[F.refIndex]=N.index)}else U==="#"&&(p.refIndex=v[0].refIndex);return void u.push(p)}if(S==="error"||S==="named"){a||(a=new Map);const v=O.value;let y=a.get(v);return N.op=S,y===void 0&&(y=a.size,a.set(v,y)),N.value=y,o.add(N),p.refIndex=l.length,void l.push(N.index)}S==="tableReference"&&(N.op=S),S==="tableSpecifier"&&(N.op=S),S==="structuredArg"&&(N.op=S)}else if(A&&A.isReference){const O=p,N={node:p,index:c.size,op:"function",value:p.value,inputs:null};c.set(O,N)}if(p.isLiteral)if(S!=="array")i[g]=p.value;else{const O=p.value,N=O.length,v=new Array(N);for(let y=0;y<N;y++){const U=O[y].value,M=U.length,F=new Array(M);for(let $=0;$<M;$++){const C=U[$];let k=C.value;if(C.type==="prefix"){const j=C.value;k=C.inputs[0].value,j==="-"&&(k=-k)}F[$]=k}v[y]=F}i[g]=R.gridFromArray(v)}else{if(S!=="empty")return u.push(p),p;i[g]=void 0}});const h=new Array(s.size);s.forEach((p,A)=>{const S=A.value,g=S.colIndex,O=S.rowIndex,N=S.$colIndex,v=S.$rowIndex,y={colStart:g,rowStart:O,colEnd:g,rowEnd:O,$colStart:N,$rowStart:v,$colEnd:N,$rowEnd:v};g===Number.MIN_SAFE_INTEGER&&(y.colEnd=Number.MAX_SAFE_INTEGER),O===Number.MIN_SAFE_INTEGER&&(y.rowEnd=Number.MAX_SAFE_INTEGER),S.sheetName&&(y.sheetName=S.sheetName),h[p]=y});const f=h.length,d=new Array(f);for(let p=0;p<f;p++)d[p]={colStart:0,rowStart:0,colEnd:0,rowEnd:0,sheetName:null};const E=new Array(c.size);let I;c.forEach(p=>{E[p.index]=p}),a&&(I=[],a.forEach((p,A)=>{I.push(A)}));const _=[];o.forEach(p=>{_.push(p.index)});const T=u.length;for(let p=0;p<T;p++){const A=u[p],S=A.type;if(S==="infix"){const g=A.value;A.fn=Xu[g]}else if(S==="prefix"){const g=A.value;A.fn=qu[g]}else if(S==="postfix"){const g=A.value;A.fn=Zu[g]}}const m=function(p){const A=[],S=(N,v)=>{const y={type:N.type,value:N.value};N.evalIndex!==void 0&&(y.evalIndex=N.evalIndex),N.refIndex!==void 0&&(y.refIndex=N.refIndex),v&&(y.ctx=v),A.push(y)},g=(N,v,y,U)=>{if(v==null||A.length>1&&N==="whitespace"&&A[A.length-1].type==="whitespace")return;const M={type:N,value:v};y&&(M.ctx=y),U!==void 0&&(M.evalIndex=U),A.push(M)};(function N(v,y,U){const M=v.evalIndex??U??0,F=v.type,$=(C,k,j)=>{if(!C)return;const Y=C.length;for(let B=0;B<Y;B++)N(C[B],k,j),B<Y-1&&g("comma",",",k)};if(v.isLiteral){if(g("whitespace",v.wsBefore,y),F==="array"){g("type","{",y);const C=v.value,k=C.length;for(let j=0;j<k;j++){const Y=C[j],B=Y.value,et=B.length;for(let Xt=0;Xt<et;Xt++){const me=B[Xt];g("whitespace",me.wsBefore,y),N(me,y,M),g("whitespace",me.wsAfter,y),Xt<et-1&&g("comma",",",y)}j<k-1&&(g("whitespace",Y.wsBefore,y),g("comma",";",y),g("whitespace",Y.wsAfter,y))}v.error||g("type","}",y)}else F==="quotedString"&&(v={type:F,value:'"'+v.value+'"'}),S(v,y);g("whitespace",v.wsAfter,y)}else if(F==="infix")N(v.inputs[0],y,M),g("whitespace",v.wsBefore,y),S(v,y),g("whitespace",v.wsAfter,y),N(v.inputs[1],y,M);else if(F==="prefix")g("whitespace",v.wsBefore,y),S(v,y),g("whitespace",v.wsAfter,y),N(v.inputs[0],y,M);else if(F==="postfix")N(v.inputs[0],y,M),g("whitespace",v.wsBefore,y),S(v,y),g("whitespace",v.wsAfter,y);else{g("whitespace",v.wsBefore,y);const C=v.inputs;switch(F){case"function":S(v,y);const k={name:String(v.value),argIndex:-1};if(g("paren","(",k,v.evalIndex),C){const Y=C.length;for(let B=0;B<Y;B++){const et={...k,argIndex:B};N(C[B],et,M),B<Y-1&&g("comma",",",et)}}v.error||g("paren",")",k,v.evalIndex);break;case"cell":S(v,y);break;case"paren":g(F,"(",y,M),$(C,y,M),v.error||g(F,")",y,M);break;case"squareParen":g(F,"[",y,M),$(C,y,M),v.error||g(F,"]",y,M);break;case"tableReference":S(v,y);const j={name:String(v.value),argIndex:-1};if(g("paren","[",j),C){const Y=C.length;for(let B=0;B<Y;B++){const et={...j,argIndex:B};N(C[B],et,M),B<Y-1&&g("comma",",",et)}}v.error||g("paren","]",j);break;default:v.value!==void 0&&S(v,y),C&&C.forEach(Y=>N(Y,y,M))}g("whitespace",v.wsAfter,y)}})(p);const O=A.length;for(let N=0;N<O;N++){const v=A[N];if(v.type==="whitespace"&&v.evalIndex===void 0){const y=A[N+1];y&&y.evalIndex!==void 0&&(v.evalIndex=y.evalIndex)}}return A}(r);return{ast:r,evaluations:i,executions:u,precedentsAbsolute:d,precedentsExecute:E,precedentsNamed:I,precedentsRelative:h,precedentsRoot:_,references:l,tokens:m,error:e}}function co(t,e){let n,r=-1,i="";Number.isSafeInteger(t.previousToken?.startLine)?(r=t.previousToken.startLine,n=t.previousToken.endColumn+1):Number.isSafeInteger(t.token?.startLine)&&(r=t.token.startLine,n=t.token.startColumn),r!==-1?(i+=`
114
- `+e.split(`
115
- `)[r-1]+`
116
- `,i+=Array(n-1).fill(" ").join("")+`^
117
- `,i+=`Error at position ${r}:${n}
118
- `+t.message,t.errorLocation={line:r,column:n}):i=e+`
119
- `+t.message;const o=new R.n.Parse(i);return o.details=t,o}const qn=function(t,e){return e.wsBefore&&(t.wsBefore=e.wsBefore),e.wsAfter&&(t.wsAfter=e.wsAfter),e.image&&(t.image=e.image),t},Qu="_XLFN.",uo=Object.freeze([[":",".:.",".:",,":."],["^"],["*","/"],["+","-"],["&"],["<",">","=","<>","<=",">="]]),bs=Object.freeze([":",".:.",".:",,":."]),Ju=Object.freeze([":"," ",".:.",".:",,":."]),tl=Object.freeze(["@"]),el=Object.freeze(["#"]),Zn=Object.freeze(Ju.concat(tl).concat(el)),{String:lo,SheetQuoted:nl,SingleQuotedString:rl,FunctionToken:il,NamedTableReference:ol,LiteralError:ho,RefError:fo,Cell:sl,Sheet:al,Name:po,NumberToken:mo,Boolean:Eo,Column:cl,AbsRow:ul,ImplicitIntersectOp:Qn,Comma:se,RangeUnion:ll,RangeTrimFull:hl,RangeTrimLeading:fl,RangeTrimTrailing:dl,Semicolon:pl,OpenParen:ml,CloseParen:Jn,OpenSquareParen:go,CloseSquareParen:To,OpenCurlyParen:El,CloseCurlyParen:gl,MulOp:Tl,PlusOp:tr,DivOp:Al,MinOp:er,ConcatOp:Il,ExOp:vl,PercentOp:Nl,ArrayAnchorOp:Ao,TableSpecifier:yl,BracketedString:Io,NeqOp:Rl,GteOp:Ol,LteOp:Sl,GtOp:_l,EqOp:Ll,LtOp:xl}=Dr;class Cl extends Jc{constructor(){super(Dr,{nodeLocationTracking:"full",maxLookahead:1,skipValidations:!0,recoveryEnabled:!0}),this.position={colIndex:0,rowIndex:0},this.astErrors=[];const e=this,n=(r,i,o)=>{let s;e.CONSUME(i);const a=e.getLexerPosition();s=e.ACTION(()=>(s={type:r,value:null,inputs:null},this._ensureWhitespace(s,a,!0)));const c=[],u=e.SUBRULE(e.intersectOp);u&&c.push(u);const l=e.SUBRULE(e.group),h=e.OPTION(()=>this.CONSUME(o));return s=e.ACTION(()=>{if(l)for(let f=0;f<l.length;f++)c.push(l[f]);return s&&(h||this._reportError(s,"Missing closing parenthesis",a),s.inputs=c),this._ensureWhitespace(s,e.getLexerPosition(),!1,!0)}),s};e.RULE("infixOp",()=>{const r=[],i=[e.SUBRULE(e.postfixOp)];return e.MANY(()=>{const o=e.OR(e.c1||(e.c1=[{ALT:()=>e.CONSUME(ll).image},{ALT:()=>e.CONSUME(tr).image},{ALT:()=>e.CONSUME(er).image},{ALT:()=>e.CONSUME(Tl).image},{ALT:()=>e.CONSUME(Al).image},{ALT:()=>e.CONSUME(vl).image},{ALT:()=>e.CONSUME(Il).image},{ALT:()=>e.CONSUME(_l).image},{ALT:()=>e.CONSUME(Ll).image},{ALT:()=>e.CONSUME(xl).image},{ALT:()=>e.CONSUME(Rl).image},{ALT:()=>e.CONSUME(Ol).image},{ALT:()=>e.CONSUME(Sl).image},{ALT:()=>e.CONSUME(hl).image},{ALT:()=>e.CONSUME(fl).image},{ALT:()=>e.CONSUME(dl).image}]));r.push([o,e.getLexerPosition(),Zn.includes(o)]),i.push(e.SUBRULE2(e.postfixOp))}),e.ACTION(()=>{let o=r.length;const s=uo.length;for(let a=0;o>0&&a<s;a++){const c=uo[a];let u=r.length;for(let l=0;l<u;l++){const h=r[l],f=h[0];if(!c.includes(f))continue;let d=Er(f,i[l],i[l+1],h[2]);d=this._ensureWhitespace(d,h[1]),r.splice(l,1),i.splice(l,2,d),l--,u--,o--}}}),i[0]}),e.RULE("plusMinusOp",()=>e.OR([{ALT:()=>e.CONSUME(tr).image},{ALT:()=>e.CONSUME(er).image}])),e.RULE("postfixOp",()=>{let r=e.SUBRULE(e.prefixOp);const i=[];return e.MANY(()=>{const o=e.OR([{ALT:()=>e.CONSUME(Nl).image},{ALT:()=>e.CONSUME(Ao).image}]);e.ACTION(()=>{i.push([o,e.getLexerPosition()])})}),e.ACTION(()=>{const o=i.length;if(o!==0)for(let s=0;s<o;s++){const a=i[s],c=a[0],u=a[1],l=Zn.includes(c);r=Hn(c,r,l),r=this._ensureWhitespace(r,u)}}),r}),e.RULE("prefixOp",()=>{const r=[];e.MANY(()=>{const o=e.OR([{ALT:()=>e.CONSUME(tr).image},{ALT:()=>e.CONSUME(er).image},{ALT:()=>e.CONSUME(Qn).image}]);e.ACTION(()=>{r.push([o,e.getLexerPosition()])})});let i=e.SUBRULE(e.formula);return e.ACTION(()=>{const o=r.length;if(o!==0)for(let s=o-1;s>=0;s--){const a=r[s],c=a[0],u=a[1],l=Zn.includes(c);i=Re(c,i,l),i=this._ensureWhitespace(i,u)}}),i}),e.RULE("intersectOp",()=>{const r=[e.SUBRULE(e.infixOp)];return e.MANY(()=>{e.OPTION({GATE:()=>{const i=e.LA(0);return e.LA(1).startOffset>i.endOffset+1},DEF:()=>{r.push(e.SUBRULE3(e.infixOp))}})}),e.ACTION(()=>{for(;r.length>1;){let i=r.length-1;for(let o=0;o<i;o++){const s=r[o],a=r[o+1],c=Er(" ",s,a,!0);if(delete s.wsAfter,a.wsBefore){const u=a.wsBefore.slice(0,-1),l=u.length;delete a.wsBefore,l>0&&(c.wsBefore=u)}o+1<i&&delete a.wsAfter,r.splice(o,2,c),o--,i--}}}),r[0]}),e.RULE("formula",()=>e.OR9([{ALT:()=>e.SUBRULE(e.referenceWithoutInfix)},{ALT:()=>e.SUBRULE(e.function)},{ALT:()=>e.SUBRULE(e.paren)},{ALT:()=>e.SUBRULE(e.namedTableReference)},{ALT:()=>e.SUBRULE(e.bracketedString)},{ALT:()=>e.SUBRULE(e.squareParen)},{ALT:()=>e.SUBRULE(e.literal)},{ALT:()=>e.SUBRULE(e.literalArray)}])),e.RULE("group",()=>{const r=[];return e.MANY(()=>{e.CONSUME(se);const i=e.SUBRULE2(e.intersectOp);e.ACTION(()=>{r.push(i)})}),r}),e.RULE("paren",()=>n("paren",ml,Jn)),e.RULE("literalArray",()=>{let r={type:"row",value:[],isLiteral:!0};e.CONSUME(El);const i=e.getLexerPosition();let o=e.ACTION(()=>this._ensureWhitespace({type:"array",value:[r],isLiteral:!0},i,!0));const s=e.SUBRULE(e.literalForArray);e.ACTION(()=>{r.value.push(s)}),e.MANY(()=>{const c=e.OR([{ALT:()=>e.CONSUME(se).image},{ALT:()=>e.CONSUME(pl).image}]),u=e.SUBRULE2(e.literalForArray);e.ACTION(()=>{c===","||(r={type:"row",value:[],isLiteral:!0},o.value.push(r)),r.value.push(u)})});const a=e.OPTION(()=>this.CONSUME(gl));return o=e.ACTION(()=>(a||this._reportError(o,"Missing closing parenthesis '}'",i),this._ensureWhitespace(o,e.getLexerPosition(),!1,!0))),o}),e.RULE("literalForArray",()=>e.OR([{ALT:()=>{const r=e.OPTION(()=>e.SUBRULE(e.plusMinusOp)),i=e.CONSUME(mo),o=e.ACTION(()=>this._ensureWhitespace(oo(i.image),e.getLexerPosition()));return r?e.ACTION(()=>function(s,a){return{type:"prefix",value:s,inputs:[a]}}(r,o)):o}},{ALT:()=>{const r=e.CONSUME(lo);return e.ACTION(()=>this._ensureWhitespace(Xn(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(Eo);return e.ACTION(()=>this._ensureWhitespace(so(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(ho);return e.ACTION(()=>this._ensureWhitespace(ao(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(fo);return e.ACTION(()=>this._ensureWhitespace(dn(r.image),e.getLexerPosition()))}}])),e.RULE("literal",()=>e.OR([{ALT:()=>{const r=e.CONSUME(mo);return e.ACTION(()=>this._ensureWhitespace(oo(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(lo);return e.ACTION(()=>this._ensureWhitespace(Xn(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(Eo);return e.ACTION(()=>this._ensureWhitespace(so(r.image),e.getLexerPosition()))}},{ALT:()=>{const r=e.CONSUME(ho);return e.ACTION(()=>this._ensureWhitespace(ao(r.image),e.getLexerPosition()))}}])),e.RULE("function",()=>{const r=e.CONSUME(il).image.slice(0,-1),i=e.getLexerPosition(),o=e.SUBRULE(e.functionArguments);let s=e.ACTION(()=>this._ensureWhitespace(io(r,o),i,!0));const a=e.OPTION(()=>this.CONSUME(Jn));return s=e.ACTION(()=>(a||this._reportError(s,"Missing closing parenthesis ')'",i),this._ensureWhitespace(s,e.getLexerPosition(),!1,!0))),s}),e.RULE("functionArguments",()=>{const r=[];return e.MANY2(()=>{let i;e.CONSUME2(se),i=e.ACTION(()=>this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),r.push(i)}),e.OPTION(()=>{r.push(e.SUBRULE(e.intersectOp)),e.MANY(()=>{let i;e.CONSUME1(se),i=e.ACTION(()=>this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),r.push(i),e.OPTION3(()=>{r.pop(),r.push(e.SUBRULE2(e.intersectOp))})})}),r}),e.RULE("bracketedString",()=>{const r=e.CONSUME(Io),i=e.getLexerPosition();return e.ACTION(()=>{const o=r.image;let s=zn("",[Vn(o.substring(1,o.length-1))]);return s=this._ensureWhitespace(s,i,!0,!1),s=this._ensureWhitespace(s,e.getLexerPosition(),!1,!0),s})}),e.RULE("squareParen",()=>{e.CONSUME(go);const r=e.getLexerPosition();let i=zn("",[e.SUBRULE(e.structuredArgument)]);const o=e.OPTION(()=>this.CONSUME(To));return e.ACTION(()=>{o||this._reportError(i,"Missing closing parenthesis ']'",r),i=this._ensureWhitespace(i,r,!0,!1),i=this._ensureWhitespace(i,e.getLexerPosition(),!1,!0)}),i}),e.RULE("namedTableReference",()=>{const r=e.CONSUME(ol).image.slice(0,-1),i=e.getLexerPosition(),o=e.SUBRULE(e.structuredArguments);let s=e.ACTION(()=>this._ensureWhitespace(zn(r,o),i,!0));const a=e.OPTION(()=>this.CONSUME(To));return s=e.ACTION(()=>(a||this._reportError(s,"Missing closing parenthesis ']'",i),this._ensureWhitespace(s,e.getLexerPosition(),!1,!0))),s}),e.RULE("structuredArguments",()=>{const r=[];return e.MANY2(()=>{e.CONSUME2(se),e.ACTION(()=>{r.push(this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0))})}),e.OPTION(()=>{const i=e.SUBRULE(e.structuredArgument);e.ACTION(()=>{i&&r.push(i)}),e.MANY(()=>{e.CONSUME1(se),e.OPTION3(()=>{let o=e.SUBRULE2(e.structuredArgument);e.ACTION(()=>{o||(o=this._ensureWhitespace({type:"empty",value:""},e.getLexerPosition(),!1,!0)),r.push(o)})})})}),r}),e.RULE("structuredArgument",()=>{const r=e.OPTION(()=>e.CONSUME(Qn)),i=e.getLexerPosition(),o=e.OPTION2(()=>this.CONSUME(go));let s=e.OR([{ALT:()=>{const a=e.CONSUME(yl);return e.ACTION(()=>this._ensureWhitespace(Vn(a.image),e.getLexerPosition()))}},{ALT:()=>{const a=e.CONSUME(Io);return e.ACTION(()=>this._ensureWhitespace(Vn(a.image),e.getLexerPosition()))}},{ALT:()=>{const a=e.CONSUME(po);return e.ACTION(()=>this._ensureWhitespace(Yn(a.image),e.getLexerPosition()))}},{ALT:()=>{const a=e.CONSUME(rl);return e.ACTION(()=>this._ensureWhitespace(Xn(a.image),e.getLexerPosition()))}}]);if(o){const a=e.OPTION3(()=>this.CONSUME(Jn));e.ACTION(()=>(a||this._reportError(s,"Missing closing parenthesis ']'",i),this._ensureWhitespace(s,e.getLexerPosition(),!1,!0))),s={type:"structuredArg",value:null,inputs:[s]}}return e.ACTION(()=>{r&&(s=Re(r.image,s,!0),s=this._ensureWhitespace(s,e.getLexerPosition()))}),s}),e.RULE("referenceWithoutInfix",()=>e.OR([{ALT:()=>e.SUBRULE(e.reference)},{ALT:()=>{const r=e.SUBRULE(e.prefixSheetName),i=e.SUBRULE2(e.formula);return e.ACTION(()=>{if((o=i)&&o.isFormulaError)return i;var o;i.ref&&(i.ref.sheet=r)}),i}}])),e.RULE("reference",()=>{const r=e.OPTION4(()=>e.CONSUME(Qn));let i=e.OR([{ALT:()=>{const o=e.CONSUME(sl),s=e.getLexerPosition(),a=e.OPTION(()=>e.CONSUME(Ao));return e.ACTION(()=>{const c=this._ensureWhitespace(function(u,l){const h=u.match(/([$]?)([A-Za-z]{1,3})([$]?)([1-9][0-9]*)/);let f=no(h[2])-1;const d=h[1].length===1;let E=+h[4]-1;const I=h[3].length===1;return d||f===Number.MIN_SAFE_INTEGER||(f-=l.colIndex),I||E===Number.MIN_SAFE_INTEGER||(E-=l.rowIndex),{type:"cell",value:Object.freeze({colIndex:f,rowIndex:E,$colIndex:d,$rowIndex:I}),inputs:null,isReference:!0}}(o.image,e.position),s);return a?this._ensureWhitespace(Hn("#",c,!0),s):c})}},{ALT:()=>{const o=e.CONSUME(po);return e.ACTION(()=>this._ensureWhitespace(Yn(o.image),e.getLexerPosition()))}},{ALT:()=>{const o=e.CONSUME(cl);return e.ACTION(()=>this._ensureWhitespace(function(s,a){const c=s.startsWith("$");c&&(s=s.substring(1));let u=no(s)-1;return c||u===Number.MIN_SAFE_INTEGER||(u-=a.colIndex),{type:"cell",value:Object.freeze({colIndex:u,rowIndex:Number.MIN_SAFE_INTEGER,$colIndex:c,$rowIndex:!1}),inputs:null,isReference:!0}}(o.image,e.position),e.getLexerPosition()))}},{ALT:()=>{const o=e.CONSUME(ul);return e.ACTION(()=>this._ensureWhitespace(ro(o.image,e.position),e.getLexerPosition()))}},{ALT:()=>{const o=e.CONSUME(fo);return e.ACTION(()=>this._ensureWhitespace(dn(o.image),e.getLexerPosition()))}}]);return e.ACTION(()=>{r&&(i=Re(r,i,!0),i=this._ensureWhitespace(i,e.getLexerPosition()))}),i}),e.RULE("prefixSheetName",()=>e.OR([{ALT:()=>e.CONSUME(al).image.slice(0,-1)},{ALT:()=>e.CONSUME(nl).image.slice(1,-2).replace(/''/g,"'")}])),e.performSelfAnalysis()}_reportError(e,n,r=void 0,i="SyntaxError"){r===void 0&&(r=this.getLexerPosition()),e.error=!0,this.astErrors.push({name:i,message:n,previousToken:this.input[r],ast:e})}_ensureWhitespace(e,n,r=!1,i=!1){if(!e)return console.warn("node is null"),e;const o=this.input,s=o[n];if(e.image||(e.image=s.image),!i){const a=s.startOffset,c=o[n-1],u=c?.endOffset??-1;u+1<a&&(e.wsBefore=" ".repeat(a-u-1))}if(!r){const a=s.endOffset,c=o[n+1],u=c?.startOffset??this.inputTextLength;a+1<u&&(e.wsAfter=" ".repeat(u-a-1))}return e}_createAST(e,n){const r=function(a){const c=Uu.tokenize(a);if(c.errors.length>0){const u=c.errors[0],l=u.line,h=u.column;let f=`
120
- `+a.split(`
121
- `)[l-1]+`
122
- `;throw f+=Array(h-1).fill(" ").join("")+`^
123
- `,u.message=f+`Error at position ${l}:${h}
124
- `+u.message,u.errorLocation={line:l,column:h},new R.n.Parse(u.message,{line:l,column:h,offset:u.offset,length:u.length})}return c}(n);let i;if(!r)return i={type:"text",value:n},i;const o=r.tokens;this.input=o,this.inputTextLength=n.length;const s=e.getPosition();return this.position=s,this.astErrors=[],this.reset(),i=this.intersectOp(),i=we(i,(a,c)=>{let u=a.type;if(u==="function"&&a.value&&a.value.toUpperCase().startsWith(Qu)){const h=a.value.substring(6);let f=a.image.substring(6),d=a;h==="ANCHORARRAY"?(d=Hn("#",a.inputs[0],!0),f="#"):h==="SINGLE"?(d=Re("@",a.inputs[0],!0),f="@"):d=io(h,a.inputs),qn(d,a),d.image=f,u=(a=d).type}if(c?.isReference){const h=c.value;if((h===":"||h===".:."||h===".:"||h===":.")&&Number.isInteger(a.value)){const f=c.inputs[0]===a?c.inputs[1]:c.inputs[0];if(f&&Number.isInteger(f.value)){const d=ro(a.image,s);return qn(d,a),d}}}else if(u==="cell"){const h=a.value;if(h.rowIndex===Number.MIN_SAFE_INTEGER||h.colIndex>=16384){const f=Yn(a.image);return qn(f,a),f}}return a}),i}build(e,n){if(n.length===0)throw Error("Input must not be empty.");let r,i,o;try{r=this._createAST(e,n)}catch(c){o=c instanceof R.n.Parse?c:new R.n.Parse(c.message,c)}const s=this.errors;s.length>0&&(o=co(s[0],n));const a=this.astErrors;return a.length>0&&(o=co(a[0],n)),i=r?en(r,o):{ast:null,evaluations:R.Yt.EmptyArray,executions:R.Yt.EmptyArray,precedentsAbsolute:R.Yt.EmptyArray,precedentsExecute:R.Yt.EmptyArray,precedentsNamed:null,precedentsRelative:R.Yt.EmptyArray,precedentsRoot:R.Yt.EmptyArray,references:R.Yt.EmptyArray,tokens:R.Yt.EmptyArray,error:o},i}}class xe{constructor(e,n){this._options=e,this._compiled=n}getTextAt(e,n,r=!1){return r?R.tokensToR1C1(this._compiled.tokens):R.tokensToA1(this._compiled.tokens,e,n)}getTokens(){return this._compiled.tokens}getError(){return this._compiled.error??null}isEquals(e){if(!(e&&e instanceof xe))return!1;if(this===e)return!0;const n=this._compiled.tokens,r=e._compiled.tokens;return n.length!==r.length?!1:R.tokensToR1C1(n)===R.tokensToR1C1(r)}getReferences(){const e=this._compiled,n=e.references,r=n.length;if(r===0)return R.Yt.EmptyArray;const i=e.precedentsExecute,o=e.precedentsRelative,s=new Array(r);for(let a=0;a<r;a++){const c=i[n[a]],u=c.inputs;if(u&&u.length===2){const l=o[i[u[0]].value],h=o[i[u[1]].value];s[a]={colStart:l.colStart,rowStart:l.rowStart,colEnd:h.colEnd,rowEnd:h.rowEnd,$colStart:l.$colStart,$rowStart:l.$rowStart,$colEnd:h.$colEnd,$rowEnd:h.$rowEnd,sheetName:l.sheetName}}else if(c.node.type==="cell"){const l=o[c.value];s[a]={...l}}else if(c.op==="named"){const l=e.precedentsNamed;s[a]=l[c.value]}else c.op==="error"&&(s[a]=c.node.value)}return s}setReferenceAt(e,n){const r=this._compiled,i=r.references;if(i.length===0)return R.Yt.EmptyArray;const o=r.precedentsExecute,s=i[e];if(s===void 0)throw new Error(`Invalid reference index: ${e}`);const a=o[s],c=a.node,u=c.inputs??R.Yt.EmptyArray;let l,h,f=!1;n&&(l={colIndex:n.colStart,rowIndex:n.rowStart,$colIndex:n.$colStart??!1,$rowIndex:n.$rowStart??!1},n.sheetName&&(l.sheetName=n.sheetName),f=!R.Kt.isSingleCell(n),f&&(h={colIndex:n.colEnd,rowIndex:n.rowEnd,$colIndex:n.$colEnd??!1,$rowIndex:n.$rowEnd??!1},n.colEnd===Number.MAX_SAFE_INTEGER&&(h.colIndex=Number.MIN_SAFE_INTEGER),n.rowEnd===Number.MAX_SAFE_INTEGER&&(h.rowIndex=Number.MIN_SAFE_INTEGER)));const d=u.length===2;let E=-1,I=-1;if(d)E=u[0].evalIndex,I=u[1].evalIndex;else{if(c.type!=="cell")throw a.op==="named"?new Error("Cannot setReference for a named reference"):new Error(`Invalidate reference index: ${e}`);E=c.evalIndex}const _=this._compiled.ast,T=we(_,A=>{if(!A||!A.isReference)return;const S=A.type;if(!n&&bs.includes(A.value)){const v=u[0],y=u[1];let U=v.evalIndex===E,M=y.evalIndex===I;if(U||M){const F=dn();return F.image="#REF!",F}}if(!(S==="cell"||S==="error"))return;const g=A.evalIndex;let O,N=g===E;if(N||g===I){if(n)if(d===f){let v=N?l:h;O={...A},O.value=v,O.image=null}else O=f?Er(":",Kn(l),Kn(h),!0):Kn(l);else O=dn(),O.image="#REF!";return O}});if(T===_)return this;const m=en(T,this._compiled.error),p=this._options;return new xe(p,m)}_resolveNamed(e,n,r,i){const o=this._options?.getNamed;if(!o)return R.n.BuiltIn.Name;let s=o?.(e,this._options.getSheetName?.())?.[0];return s?(s.isFormulaError||(s=R.toAbsoluteRange(s,n,r,i)),s):R.n.BuiltIn.Name}getDirectPrecedentsAt(e,n,r=!1,i,o){const s=this._compiled,a=s.precedentsRoot,c=a.length;if(c===0)return R.Yt.EmptyArray;const u=s.precedentsRelative,l=s.precedentsAbsolute,h=u.length;for(let T=0;T<h;T++){const m=u[T];let p=l[T],A=R.toAbsoluteRange(m,e,n,p);l[T]=A}let f=!1;const d=s.precedentsExecute,E=d.length,I=gr;for(let T=0;T<E;T++){const m=d[T],p=m.op;if(!p){const N=l[m.value];I[m.index]=N;continue}if(p==="named"){f=!0,I[m.index]=this._resolveNamed(m.node.value,e,n);continue}if(p==="error"){I[m.index]=m.node.value;continue}if(p==="@"||p==="#"){I[m.index]=I[m.inputs[0]];continue}const A=m.inputs;if(!A)continue;let S=I[A[0]];if(S===void 0){I[m.index]=R.n.BuiltIn.Value;continue}if(S.isFormulaError){I[m.index]=S;continue}let g,O=I[A[1]];O!==void 0?O.isFormulaError?I[m.index]=O:(p===" "?g=R.Kt.intersectRanges(S,O):p!==":"&&p!==".:."&&p!==":."&&p!==".:"||(g=I[m.index]=R.Kt.unionRanges(S,O)),I[m.index]=g??R.n.BuiltIn.Null):I[m.index]=R.n.BuiltIn.Value}const _=new Array(c);for(let T=0;T<c;T++){const m=a[T],p=I[m];if(_[T]=p?.rowStart!==void 0?{...p}:p,i||o){const A=d[m];f&&A.op==="named"?(i&&(i[T]=p.$colStart||p.$colEnd),o&&(o[T]=p.$rowStart||p.$rowEnd)):(i&&(i[T]=A.hasVerticalAbs),o&&(o[T]=A.hasHorizontalAbs))}}return _}evaluate(e,n,r){const i=e.getPosition(),o=i?.rowIndex??0,s=i?.colIndex??0;let a=this._compiled;if(n!==void 0){let g;if(we(a.ast,O=>{O.evalIndex===n&&(g=O)}),!g)throw new Error(`Invalid evalIndex: ${n}`);a=en(g,a.error)}if(a.error)return a.error;const c=a.evaluations,u=a.executions;let l,h;r||(r=this._resolvePrecedents(e));const f=a.precedentsExecute,d=a.precedentsRelative,E=a.precedentsAbsolute,I=f.length;for(let g=0;g<I;g++){const O=f[g],N=O.op;if(N){if(N==="named"){const v=O.node;let y=this._resolveNamed(O.node.value,o,s);y?.colStart!==void 0&&(y=e.getReference(y)),c[v.evalIndex]=y}else if(N==="error"){const v=O.node;c[v.evalIndex]=O.node.value}}else{const v=d[O.value];let y=E[g];const U=R.toAbsoluteRange(v,o,s,y),M=O.node;c[M.evalIndex]=U}}const _=a.precedentsRoot,T=_.length;if(T!==r.length)return R.n.BuiltIn.Parse;for(let g=0;g<T;g++){const O=f[_[g]].node;let N=r[g];N.isIRange&&O.type==="cell"&&N.size>1&&(N=N.getValueAt(0,0)??null),c[O.evalIndex]=N}let m;const p=g=>{const O=g.inputs,N=O?O.length:0;let v;switch(g.type){case"infix":const y=g.value;let U=c[O[0].evalIndex],M=c[O[1].evalIndex];if(y==="+"&&typeof U=="number"&&typeof M=="number"){const k=U+M;return Math.abs(k)<99e-14?0:k}if(y==="-"&&typeof U=="number"&&typeof M=="number"){const k=U-M;return Math.abs(k)<99e-14?0:k}if(U&&U.isFormulaError)return U;if(M&&M.isFormulaError)return M;const F=g.fn;return v=F?F(e,U,M):R.n.BuiltIn.Value,v=R.minCoerce(v,null),v;case"function":m||(m=new Array(N)),m.length!==N&&(m.length=N);for(let k=0;k<N;k++)m[k]=c[O[k].evalIndex];return v=this._callFunction(e,g,m),v&&typeof v.then=="function"?v.then(k=>{k=R.minCoerce(k,e),v instanceof R.n.Known&&(h=v),c[g.evalIndex]=k}).catch(k=>{const j=k instanceof R.n.Known?k:new R.n.Value("Uncaught error",{cause:k});c[g.evalIndex]=j}):v instanceof R.n.Known&&(h=v),v;case"prefix":case"postfix":let $=c[O[0].evalIndex];if($&&$.isFormulaError)return $;const C=g.fn;return v=C?C(e,$):R.n.BuiltIn.Value,v;case"paren":if(N===1)return c[O[0].evalIndex];{const k=new Array(N);for(let j=0;j<N;j++)k[j]=c[O[j].evalIndex];return k}case"named":return null;case"empty":return}};let A=u.length;for(let g=0;g<A;g++){const O=u[g];if(h)return h;if(l)l=l.then(()=>{const N=p(O);return c[O.evalIndex]=N,N});else{const N=p(O);c[O.evalIndex]=N,N&&typeof N.then=="function"&&(l=N)}}if(l)return l.then(()=>{const g=c[c.length-1];return this._finalizeReturnValue(e,g)});const S=c[c.length-1];return this._finalizeReturnValue(e,S)}_resolvePrecedents(e){const n=e.getPosition(),r=n?.rowIndex??0,i=n?.colIndex??0,o=this.getDirectPrecedentsAt(r,i),s=o.length;let a;if(s>0){a=new Array(s);for(let c=0;c<s;c++){const u=o[c];if(u instanceof R.n.Known)a[c]=u;else if(Array.isArray(u)){const l=new Array(u.length);for(let h=0;h<u.length;h++)l[h]=e.getReference(u[h]);a[c]=l}else a[c]=e.getReference(u)}}else a=R.Yt.EmptyArray;return a}wrapImplicit(e,n,r){const i=this._compiled.ast;if(!i||!i.isReference)return this;if(i.type==="cell")return this;if(i.value==="@")return this;if(!r)return this;const o=R.colToString(n)+R.rowToString(e);if(r.has(o))return this;const s=en(Re("@",i,!0),this._compiled.error);return new xe(this._options,s)}_callFunction(e,n,r){const i=n?.cacheFn??e.getFunction(n.value);if(!i)return new R.n.Parse;const o=i.isBuiltIn();let s;o?n.cacheFn=i:this._context=e;try{s=i.execute(...r)}catch(a){s=a instanceof R.n.Known?a:new R.n.Value(a.message,{cause:a})}return o||(this._context=null),s===void 0?new R.n.Parse:s}_finalizeReturnValue(e,n){if(n&&n.colStart!==void 0&&(n=e.getValueAt(n.rowStart,n.colStart)),Array.isArray(n))if(n.length===1&&Array.isArray(n[0])&&n[0].length===1)n=n[0][0],Array.isArray(n)&&(n=R.n.BuiltIn.Value);else try{n=e.getRange(n)}catch{n=R.n.BuiltIn.Value}return n?.isIRange?n.size===1?(n=n.getValueAt(0,0,kl),(n=R.minCoerce(n,e))===null&&(n=0)):n=n.fillEmpty(0):(n=R.minCoerce(n,e))===null&&(n=0),n}get[Symbol.toStringTag](){return"[FormulaBlock]"}toString(){const e=this._compiled;if(e.error)return e.error.toString();const n=this._context;if(n){const r=n.getPosition();return this.getTextAt(r.rowIndex,r.colIndex)}return R.tokensToR1C1(e.tokens)}}const gr=new Array(20);for(let t=0;t<gr.length;t++)gr[t]={colStart:0,rowStart:0,colEnd:0,rowEnd:0,sheetName:null};const kl={type:null};exports.FormulaParser=class{constructor(t){this._options={getEntireCoords:R.defaultGetEntireCoords,...t},this._astBuilder=new Cl}parse(t,e){t.getPosition().sheetName;const r=this._astBuilder.build(t,e);return new xe(this._options,r)}eval(t,e){return this.parse(t,e).evaluate(t)}};