fast-formula-parser
Version:
fast excel formula parser
1 lines • 298 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.FormulaParser=e():t.FormulaParser=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=14)}([function(t,e,n){"use strict";function r(t){return t&&0===t.length}function o(t){return null==t?[]:Object.keys(t)}function i(t){for(var e=[],n=Object.keys(t),r=0;r<n.length;r++)e.push(t[n[r]]);return e}function a(t,e){for(var n=[],r=o(t),i=0;i<r.length;i++){var a=r[i];n.push(e.call(null,t[a],a))}return n}function c(t,e){for(var n=[],r=0;r<t.length;r++)n.push(e.call(null,t[r],r));return n}function s(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];Array.isArray(r)?e=e.concat(s(r)):e.push(r)}return e}function u(t){return r(t)?void 0:t[0]}function f(t){var e=t&&t.length;return e?t[e-1]:void 0}function l(t,e){if(Array.isArray(t))for(var n=0;n<t.length;n++)e.call(null,t[n],n);else{if(!L(t))throw Error("non exhaustive match");var r=o(t);for(n=0;n<r.length;n++){var i=r[n],a=t[i];e.call(null,a,i)}}}function h(t){return"string"==typeof t}function p(t){return void 0===t}function d(t){return t instanceof Function}function m(t,e){return void 0===e&&(e=1),t.slice(e,t.length)}function g(t,e){return void 0===e&&(e=1),t.slice(0,t.length-e)}function E(t,e){var n=[];if(Array.isArray(t))for(var r=0;r<t.length;r++){var o=t[r];e.call(null,o)&&n.push(o)}return n}function v(t,e){return E(t,(function(t){return!e(t)}))}function N(t,e){for(var n=Object.keys(t),r={},o=0;o<n.length;o++){var i=n[o],a=t[i];e(a)&&(r[i]=a)}return r}function O(t,e){return!!L(t)&&t.hasOwnProperty(e)}function R(t,e){return void 0!==T(t,(function(t){return t===e}))}function y(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e}function A(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function T(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(e.call(null,r))return r}}function M(t,e){for(var n=[],r=0;r<t.length;r++){var o=t[r];e.call(null,o)&&n.push(o)}return n}function b(t,e,n){for(var r=Array.isArray(t),a=r?t:i(t),c=r?[]:o(t),s=n,u=0;u<a.length;u++)s=e.call(null,s,a[u],r?u:c[u]);return s}function I(t){return v(t,(function(t){return null==t}))}function w(t,e){void 0===e&&(e=function(t){return t});var n=[];return b(t,(function(t,r){var o=e(r);return R(n,o)?t:(n.push(o),t.concat(r))}),[])}function S(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=[null],o=r.concat(e);return Function.bind.apply(t,o)}function C(t){return Array.isArray(t)}function U(t){return t instanceof RegExp}function L(t){return t instanceof Object}function x(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n))return!1;return!0}function _(t,e){return v(t,(function(t){return R(e,t)}))}function k(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return!0;return!1}function P(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return n;return-1}function j(t,e){var n=y(t);return n.sort((function(t,n){return e(t)-e(n)})),n}function B(t,e){if(t.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var n={},r=0;r<t.length;r++)n[t[r]]=e[r];return n}function F(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],a=o(i),c=0;c<a.length;c++){var s=a[c];t[s]=i[s]}return t}function D(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],a=o(i),c=0;c<a.length;c++){var s=a[c];O(t,s)||(t[s]=i[s])}return t}function V(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return D.apply(null,[{}].concat(t))}function G(t,e){var n={};return l(t,(function(t){var r=e(t),o=n[r];o?o.push(t):n[r]=[t]})),n}function H(t,e){for(var n=A(t),r=o(e),i=0;i<r.length;i++){var a=r[i],c=e[a];n[a]=c}return n}function Y(){}function W(t){return t}function q(t){for(var e=[],n=0;n<t.length;n++){var r=t[n];e.push(void 0!==r?r:void 0)}return e}function $(t){console&&console.error&&console.error("Error: "+t)}function K(t){console&&console.warn&&console.warn("Warning: "+t)}function X(){return"function"==typeof Map}function z(t,e){e.forEach((function(e){var n=e.prototype;Object.getOwnPropertyNames(n).forEach((function(r){if("constructor"!==r){var o=Object.getOwnPropertyDescriptor(n,r);o&&(o.get||o.set)?Object.defineProperty(t.prototype,r,o):t.prototype[r]=e.prototype[r]}}))}))}function Q(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.bar}return r(),r(),t}function Z(t){return t[t.length-1]}function J(t){var e=(new Date).getTime(),n=t();return{time:(new Date).getTime()-e,value:n}}n.d(e,"A",(function(){return r})),n.d(e,"G",(function(){return o})),n.d(e,"U",(function(){return i})),n.d(e,"J",(function(){return a})),n.d(e,"I",(function(){return c})),n.d(e,"t",(function(){return s})),n.d(e,"s",(function(){return u})),n.d(e,"H",(function(){return f})),n.d(e,"u",(function(){return l})),n.d(e,"E",(function(){return h})),n.d(e,"F",(function(){return p})),n.d(e,"B",(function(){return d})),n.d(e,"m",(function(){return m})),n.d(e,"n",(function(){return g})),n.d(e,"p",(function(){return E})),n.d(e,"P",(function(){return v})),n.d(e,"N",(function(){return N})),n.d(e,"w",(function(){return O})),n.d(e,"j",(function(){return R})),n.d(e,"g",(function(){return y})),n.d(e,"h",(function(){return A})),n.d(e,"q",(function(){return T})),n.d(e,"r",(function(){return M})),n.d(e,"O",(function(){return b})),n.d(e,"i",(function(){return I})),n.d(e,"T",(function(){return w})),n.d(e,"y",(function(){return C})),n.d(e,"D",(function(){return U})),n.d(e,"C",(function(){return L})),n.d(e,"o",(function(){return x})),n.d(e,"l",(function(){return _})),n.d(e,"Q",(function(){return k})),n.d(e,"x",(function(){return P})),n.d(e,"f",(function(){return F})),n.d(e,"k",(function(){return V})),n.d(e,"v",(function(){return G})),n.d(e,"K",(function(){return H})),n.d(e,"b",(function(){return Y})),n.d(e,"a",(function(){return W})),n.d(e,"L",(function(){return q})),n.d(e,"c",(function(){return $})),n.d(e,"d",(function(){return K})),n.d(e,"z",(function(){return X})),n.d(e,"e",(function(){return z})),n.d(e,"S",(function(){return Q})),n.d(e,"M",(function(){return Z})),n.d(e,"R",(function(){return J}))},function(t,e,n){class r extends Error{constructor(t,e,n){if(super(e),null==e&&null==n&&r.errorMap.has(t))return r.errorMap.get(t);null==e&&null==n?(this._error=t,r.errorMap.set(t,this)):this._error=t,this.details=n}get error(){return this._error}get name(){return this._error}equals(t){return t instanceof r&&t._error===this._error}toString(){return this._error}}r.errorMap=new Map,r.DIV0=new r("#DIV/0!"),r.NA=new r("#N/A"),r.NAME=new r("#NAME?"),r.NULL=new r("#NULL!"),r.NUM=new r("#NUM!"),r.REF=new r("#REF!"),r.VALUE=new r("#VALUE!"),r.NOT_IMPLEMENTED=t=>new r("#NAME?",`Function ${t} is not implemented.`),r.TOO_MANY_ARGS=t=>new r("#N/A",`Function ${t} has too many arguments.`),r.ARG_MISSING=t=>{const{Types:e}=n(2);return new r("#N/A",`Argument type ${t.map(t=>e[t]).join(", ")} is missing.`)},r.ERROR=(t,e)=>new r("#ERROR!",t,e),t.exports=r},function(t,e,n){const r=n(1),o=n(4),i={NUMBER:0,ARRAY:1,BOOLEAN:2,STRING:3,RANGE_REF:4,CELL_REF:5,COLLECTIONS:6,NUMBER_NO_BOOLEAN:10},a={};Object.keys(i).forEach(t=>{a[i[t]]=t});const c=new class{constructor(){this.Types=i,this.type2Number={number:i.NUMBER,boolean:i.BOOLEAN,string:i.STRING,object:-1}}checkFunctionResult(t){if("number"===typeof t){if(isNaN(t))return r.VALUE;if(!isFinite(t))return r.NUM}return null==t?r.NULL:t}flattenDeep(t){return t.reduce((t,e)=>Array.isArray(e)?t.concat(this.flattenDeep(e)):t.concat(e),[])}acceptNumber(t,e=!0,n=!0){if(t instanceof r)return t;let o;if("number"==typeof t)o=t;else if("boolean"==typeof t){if(!n)throw r.VALUE;o=Number(t)}else if("string"==typeof t){if(0===t.length)throw r.VALUE;if(o=Number(t),o!=o)throw r.VALUE}else{if(!Array.isArray(t))throw Error("Unknown type in FormulaHelpers.acceptNumber");if(e)o=this.acceptNumber(t[0][0]);else{if(1!==t[0].length)throw r.VALUE;o=this.acceptNumber(t[0][0])}}return o}flattenParams(t,e,n,a,c=null,s=1){if(t.length<s)throw r.ARG_MISSING([e]);null==c&&(c=e===i.NUMBER?0:null==e?null:""),t.forEach(t=>{const{isCellRef:i,isRangeRef:s,isArray:u}=t,f=t.value instanceof o,l=!(i||s||u||f),h={isLiteral:l,isCellRef:i,isRangeRef:s,isArray:u,isUnion:f};if(l)t=t.omitted?c:this.accept(t,e,c),a(t,h);else if(i)a(t.value,h);else if(f){if(!n)throw r.VALUE;t=t.value.data,(t=this.flattenDeep(t)).forEach(t=>{a(t,h)})}else(s||u)&&(t=this.flattenDeep(t.value)).forEach(t=>{a(t,h)})})}accept(t,e=null,n,a=!0,c=!1){if(Array.isArray(e)&&(e=e[0]),null==t&&void 0===n)throw r.ARG_MISSING([e]);if(null==t)return n;if("object"!=typeof t||Array.isArray(t))return t;const s=t.isArray;if(null!=t.value&&(t=t.value),null==e)return t;if(t instanceof r)throw t;if(e===i.ARRAY){if(Array.isArray(t))return a?this.flattenDeep(t):t;if(t instanceof o)throw r.VALUE;if(c)return a?[t]:[[t]];throw r.VALUE}if(e===i.COLLECTIONS)return t;s&&(t=t[0][0]);const u=this.type(t);if(e===i.STRING)t=u===i.BOOLEAN?t?"TRUE":"FALSE":""+t;else if(e===i.BOOLEAN){if(u===i.STRING)throw r.VALUE;u===i.NUMBER&&(t=Boolean(t))}else if(e===i.NUMBER)t=this.acceptNumber(t,!1);else{if(e!==i.NUMBER_NO_BOOLEAN)throw r.VALUE;t=this.acceptNumber(t,!1,!1)}return t}type(t){let e=this.type2Number[typeof t];return-1===e&&(Array.isArray(t)?e=i.ARRAY:t.ref?e=t.ref.from?i.RANGE_REF:i.CELL_REF:t instanceof o&&(e=i.COLLECTIONS)),e}isRangeRef(t){return t.ref&&t.ref.from}isCellRef(t){return t.ref&&!t.ref.from}retrieveRanges(t,e,n){return n=f.extend(e,n),e=this.retrieveArg(t,e),n!==(e=c.accept(e,i.ARRAY,void 0,!1,!0))?(n=this.retrieveArg(t,n),n=c.accept(n,i.ARRAY,void 0,!1,!0)):n=e,[e,n]}retrieveArg(t,e){if(null===e)return{value:0,isArray:!1,omitted:!0};const n=t.utils.extractRefValue(e);return{value:n.val,isArray:n.isArray,ref:e.ref}}},s={isWildCard:t=>"string"==typeof t&&/[*?]/.test(t),toRegex:(t,e)=>RegExp(t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/([^~]??)[?]/g,"$1.").replace(/([^~]??)[*]/g,"$1.*").replace(/~([?*])/g,"$1"),e)},u={parse:t=>{const e=typeof t;if("string"===e){const e=t.toUpperCase();if("TRUE"===e||"FALSE"===e)return{op:"=",value:"TRUE"===e};const n=t.match(/(<>|>=|<=|>|<|=)(.*)/);if(n){let t,e=n[1];if(isNaN(n[2])){const o=n[2].toUpperCase();if("TRUE"===o||"FALSE"===o)t="TRUE"===o;else if(/#NULL!|#DIV\/0!|#VALUE!|#NAME\?|#NUM!|#N\/A|#REF!/.test(n[2]))t=new r(n[2]);else if(t=n[2],s.isWildCard(t))return{op:"wc",value:s.toRegex(t),match:"="===e}}else t=Number(n[2]);return{op:e,value:t}}return s.isWildCard(t)?{op:"wc",value:s.toRegex(t),match:!0}:{op:"=",value:t}}if("boolean"===e||"number"===e||Array.isArray(t)||t instanceof r)return{op:"=",value:t};throw Error(`Criteria.parse: type ${typeof t} not support`)}},f={columnNumberToName:t=>{let e=t,n="",r=0;for(;e>0;)r=(e-1)%26,n=String.fromCharCode("A".charCodeAt(0)+r)+n,e=Math.floor((e-r)/26);return n},columnNameToNumber:t=>{const e=(t=t.toUpperCase()).length;let n=0;for(let r=0;r<e;r++){const o=t.charCodeAt(r);isNaN(o)||(n+=(o-64)*26**(e-r-1))}return n},extend:(t,e)=>{if(null==e)return t;let n,r;if(c.isCellRef(t))n=0,r=0;else{if(!c.isRangeRef(t))throw Error("Address.extend should not reach here.");n=t.ref.to.row-t.ref.from.row,r=t.ref.to.col-t.ref.from.col}return c.isCellRef(e)?(n>0||r>0)&&(e={ref:{from:{col:e.ref.col,row:e.ref.row},to:{row:e.ref.row+n,col:e.ref.col+r}}}):(e.ref.to.row=e.ref.from.row+n,e.ref.to.col=e.ref.from.col+r),e}};t.exports={FormulaHelpers:c,Types:i,ReversedTypes:a,Factorials:[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3,0x1b02b9306890000,243290200817664e4,5109094217170944e4,11240007277776077e5,2585201673888498e7,6204484017332394e8,15511210043330986e9,40329146112660565e10,10888869450418352e12,30488834461171387e13,8.841761993739702e30,26525285981219107e16,8222838654177922e18,2631308369336935e20,8683317618811886e21,29523279903960416e22,1.0333147966386145e40,37199332678990125e25,13763753091226346e27,5230226174666011e29,20397882081197444e30,8159152832478977e32,3345252661316381e34,140500611775288e37,6041526306337383e37,2658271574788449e39,11962222086548019e40,5502622159812089e42,25862324151116818e43,12413915592536073e45,6082818640342675e47,30414093201713376e48,15511187532873822e50,8065817517094388e52,42748832840600255e53,2308436973392414e56,12696403353658276e57,7109985878048635e59,40526919504877214e60,23505613312828785e62,1.3868311854568984e80,832098711274139e67,5075802138772248e68,3146997326038794e70,198260831540444e73,12688693218588417e73,8.247650592082472e90,5443449390774431e77,3647111091818868e79,24800355424368305e80,1711224524281413e83,1.1978571669969892e100,8504785885678623e86,61234458376886085e87,44701154615126844e89,3307885441519386e92,248091408113954e95,18854947016660504e95,14518309202828587e97,11324281178206297e99,8946182130782976e101,7156945704626381e103,5.797126020747368e120,4753643337012842e107,3945523969720659e109,3314240134565353e111,281710411438055e114,2.4227095383672734e130,2107757298379528e117,18548264225739844e118,1650795516090846e121,14857159644817615e122,1.352001527678403e140,12438414054641308e126,11567725070816416e128,1087366156656743e131,1032997848823906e133,9916779348709496e134,9619275968248212e136,9426890448883248e138,9332621544394415e140,9332621544394415e142],WildCard:s,Criteria:u,Address:f}},function(t,e,n){var r,o,i;"undefined"!=typeof self&&self,o=[],void 0===(i="function"==typeof(r=function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(t){this.idx=t.idx,this.input=t.input,this.groupIdx=t.groupIdx},t.prototype.pattern=function(t){this.idx=0,this.input=t,this.groupIdx=0,this.consumeChar("/");var e=this.disjunction();this.consumeChar("/");for(var n={type:"Flags",loc:{begin:this.idx,end:t.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(n,"global");break;case"i":c(n,"ignoreCase");break;case"m":c(n,"multiLine");break;case"u":c(n,"unicode");break;case"y":c(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)}},t.prototype.disjunction=function(){var 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)}},t.prototype.alternative=function(){for(var t=[],e=this.idx;this.isTerm();)t.push(this.term());return{type:"Alternative",value:t,loc:this.loc(e)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var 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"(":var e;switch(this.consumeChar("?"),this.popChar()){case"=":e="Lookahead";break;case"!":e="NegativeLookahead"}s(e);var n=this.disjunction();return this.consumeChar(")"),{type:e,value:n,loc:this.loc(t)}}!function(){throw Error("Internal Error - Should never get here!")}()},t.prototype.quantifier=function(t){var e,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"{":var r=this.integerIncludingZero();switch(this.popChar()){case"}":e={atLeast:r,atMost:r};break;case",":e=this.isDigit()?{atLeast:r,atMost:this.integerIncludingZero()}:{atLeast:r,atMost:1/0},this.consumeChar("}")}if(!0===t&&void 0===e)return;s(e)}if(!0!==t||void 0!==e)return s(e),"?"===this.peekChar(0)?(this.consumeChar("?"),e.greedy=!1):e.greedy=!0,e.type="Quantifier",e.loc=this.loc(n),e},t.prototype.atom=function(){var t,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()}return void 0===t&&this.isPatternCharacter()&&(t=this.patternCharacter()),s(t),t.loc=this.loc(e),this.isQuantifier()&&(t.quantifier=this.quantifier()),t},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[i("\n"),i("\r"),i("\u2028"),i("\u2029")]}},t.prototype.atomEscape=function(){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()}},t.prototype.decimalEscapeAtom=function(){return{type:"GroupBackReference",value:this.positiveInteger()}},t.prototype.characterClassEscape=function(){var t,e=!1;switch(this.popChar()){case"d":t=u;break;case"D":t=u,e=!0;break;case"s":t=l;break;case"S":t=l,e=!0;break;case"w":t=f;break;case"W":t=f,e=!0}return s(t),{type:"Set",value:t,complement:e}},t.prototype.controlEscapeAtom=function(){var t;switch(this.popChar()){case"f":t=i("\f");break;case"n":t=i("\n");break;case"r":t=i("\r");break;case"t":t=i("\t");break;case"v":t=i("\v")}return s(t),{type:"Character",value:t}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var t=this.popChar();if(!1===/[a-zA-Z]/.test(t))throw Error("Invalid ");return{type:"Character",value:t.toUpperCase().charCodeAt(0)-64}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:i("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){return{type:"Character",value:i(this.popChar())}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case"\n":case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:return{type:"Character",value:i(this.popChar())}}},t.prototype.characterClass=function(){var t=[],e=!1;for(this.consumeChar("["),"^"===this.peekChar(0)&&(this.consumeChar("^"),e=!0);this.isClassAtom();){var n=this.classAtom();if("Character"===n.type&&this.isRangeDash()){this.consumeChar("-");var r=this.classAtom();if("Character"===r.type){if(r.value<n.value)throw Error("Range out of order in character class");t.push({from:n.value,to:r.value})}else a(n.value,t),t.push(i("-")),a(r.value,t)}else a(n.value,t)}return this.consumeChar("]"),{type:"Set",complement:e,value:t}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case"\n":case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:i("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var t=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),t=!1;break;default:this.groupIdx++}var e=this.disjunction();this.consumeChar(")");var n={type:"Group",capturing:t,value:e};return t&&(n.idx=this.groupIdx),n},t.prototype.positiveInteger=function(){var t=this.popChar();if(!1===o.test(t))throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)},t.prototype.integerIncludingZero=function(){var t=this.popChar();if(!1===r.test(t))throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)t+=this.popChar();return parseInt(t,10)},t.prototype.patternCharacter=function(){var t=this.popChar();switch(t){case"\n":case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:i(t)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return"-"===this.peekChar()&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(t){switch(void 0===t&&(t=0),this.peekChar(t)){case"]":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){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}},t.prototype.isQuantifier=function(){var t=this.saveState();try{return void 0!==this.quantifier(!0)}catch(t){return!1}finally{this.restoreState(t)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case"\n":case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(t){for(var e="",r=0;r<t;r++){var o=this.popChar();if(!1===n.test(o))throw Error("Expecting a HexDecimal digits");e+=o}return{type:"Character",value:parseInt(e,16)}},t.prototype.peekChar=function(t){return void 0===t&&(t=0),this.input[this.idx+t]},t.prototype.popChar=function(){var t=this.peekChar(0);return this.consumeChar(),t},t.prototype.consumeChar=function(t){if(void 0!==t&&this.input[this.idx]!==t)throw Error("Expected: '"+t+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(t){return{begin:t,end:this.idx}};var e,n=/[0-9a-fA-F]/,r=/[0-9]/,o=/[1-9]/;function i(t){return t.charCodeAt(0)}function a(t,e){void 0!==t.length?t.forEach((function(t){e.push(t)})):e.push(t)}function c(t,e){if(!0===t[e])throw"duplicate flag "+e;t[e]=!0}function s(t){if(void 0===t)throw Error("Internal Error - Should never get here!")}var u=[];for(e=i("0");e<=i("9");e++)u.push(e);var f=[i("_")].concat(u);for(e=i("a");e<=i("z");e++)f.push(e);for(e=i("A");e<=i("Z");e++)f.push(e);var l=[i(" "),i("\f"),i("\n"),i("\r"),i("\t"),i("\v"),i("\t"),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i(" "),i("\u2028"),i("\u2029"),i(" "),i(" "),i(" "),i("\ufeff")];function h(){}return h.prototype.visitChildren=function(t){for(var e in t){var n=t[e];t.hasOwnProperty(e)&&(void 0!==n.type?this.visit(n):Array.isArray(n)&&n.forEach((function(t){this.visit(t)}),this))}},h.prototype.visit=function(t){switch(t.type){case"Pattern":this.visitPattern(t);break;case"Flags":this.visitFlags(t);break;case"Disjunction":this.visitDisjunction(t);break;case"Alternative":this.visitAlternative(t);break;case"StartAnchor":this.visitStartAnchor(t);break;case"EndAnchor":this.visitEndAnchor(t);break;case"WordBoundary":this.visitWordBoundary(t);break;case"NonWordBoundary":this.visitNonWordBoundary(t);break;case"Lookahead":this.visitLookahead(t);break;case"NegativeLookahead":this.visitNegativeLookahead(t);break;case"Character":this.visitCharacter(t);break;case"Set":this.visitSet(t);break;case"Group":this.visitGroup(t);break;case"GroupBackReference":this.visitGroupBackReference(t);break;case"Quantifier":this.visitQuantifier(t)}this.visitChildren(t)},h.prototype.visitPattern=function(t){},h.prototype.visitFlags=function(t){},h.prototype.visitDisjunction=function(t){},h.prototype.visitAlternative=function(t){},h.prototype.visitStartAnchor=function(t){},h.prototype.visitEndAnchor=function(t){},h.prototype.visitWordBoundary=function(t){},h.prototype.visitNonWordBoundary=function(t){},h.prototype.visitLookahead=function(t){},h.prototype.visitNegativeLookahead=function(t){},h.prototype.visitCharacter=function(t){},h.prototype.visitSet=function(t){},h.prototype.visitGroup=function(t){},h.prototype.visitGroupBackReference=function(t){},h.prototype.visitQuantifier=function(t){},{RegExpParser:t,BaseRegExpVisitor:h,VERSION:"0.5.0"}})?r.apply(e,o):r)||(t.exports=i)},function(t,e){t.exports=class{constructor(t,e){if(null==t&&null==e)this._data=[],this._refs=[];else{if(t.length!==e.length)throw Error("Collection: data length should match references length.");this._data=t,this._refs=e}}get data(){return this._data}get refs(){return this._refs}get length(){return this._data.length}add(t,e){this._data.push(t),this._refs.push(e)}}},function(t,e,n){const r=n(1),{FormulaHelpers:o}=n(2),i={unaryOp:(t,e,n)=>{let i=1;if(t.forEach(t=>{if("+"===t);else{if("-"!==t)throw new Error("Unrecognized prefix: "+t);i=-i}}),null==e&&(e=0),1===i)return e;try{e=o.acceptNumber(e,n)}catch(t){if(!(t instanceof r))throw t;Array.isArray(e)&&(e=e[0][0])}return"number"==typeof e&&isNaN(e)?r.VALUE:-e}},a={percentOp:(t,e,n)=>{try{t=o.acceptNumber(t,n)}catch(t){if(t instanceof r)return t;throw t}if("%"===e)return t/100;throw new Error("Unrecognized postfix: "+e)}},c={boolean:3,string:2,number:1},s={compareOp:(t,e,n,r,o)=>{null==t&&(t=0),null==n&&(n=0),r&&(t=t[0][0]),o&&(n=n[0][0]);const i=typeof t,a=typeof n;if(i===a)switch(e){case"=":return t===n;case">":return t>n;case"<":return t<n;case"<>":return t!==n;case"<=":return t<=n;case">=":return t>=n}else switch(e){case"=":return!1;case">":return c[i]>c[a];case"<":return c[i]<c[a];case"<>":return!0;case"<=":return c[i]<=c[a];case">=":return c[i]>=c[a]}throw Error("Infix.compareOp: Should not reach here.")},concatOp:(t,e,n,r,o)=>{null==t&&(t=""),null==n&&(n=""),r&&(t=t[0][0]),o&&(n=n[0][0]);return"boolean"===typeof t&&(t=t?"TRUE":"FALSE"),"boolean"===typeof n&&(n=n?"TRUE":"FALSE"),""+t+n},mathOp:(t,e,n,i,a)=>{null==t&&(t=0),null==n&&(n=0);try{t=o.acceptNumber(t,i),n=o.acceptNumber(n,a)}catch(t){if(t instanceof r)return t;throw t}switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return 0===n?r.DIV0:t/n;case"^":return t**n}throw Error("Infix.mathOp: Should not reach here.")}};t.exports={Prefix:i,Postfix:a,Infix:s,Operators:{compareOp:["<",">","=","<>","<=",">="],concatOp:["&"],mathOp:["+","-","*","/","^"]}}},function(t,e,n){"use strict";n.r(e),n.d(e,"VERSION",(function(){return r})),n.d(e,"CstParser",(function(){return rn})),n.d(e,"EmbeddedActionsParser",(function(){return on})),n.d(e,"ParserDefinitionErrorType",(function(){return Ze})),n.d(e,"EMPTY_ALT",(function(){return en})),n.d(e,"Lexer",(function(){return K})),n.d(e,"LexerDefinitionErrorType",(function(){return W})),n.d(e,"createToken",(function(){return Z})),n.d(e,"createTokenInstance",(function(){return tt})),n.d(e,"EOF",(function(){return J})),n.d(e,"tokenLabel",(function(){return X})),n.d(e,"tokenMatcher",(function(){return et})),n.d(e,"tokenName",(function(){return z})),n.d(e,"defaultGrammarResolverErrorProvider",(function(){return St})),n.d(e,"defaultGrammarValidatorErrorProvider",(function(){return Ct})),n.d(e,"defaultParserErrorProvider",(function(){return wt})),n.d(e,"EarlyExitException",(function(){return Ee})),n.d(e,"isRecognitionException",(function(){return pe})),n.d(e,"MismatchedTokenException",(function(){return de})),n.d(e,"NotAllInputParsedException",(function(){return ge})),n.d(e,"NoViableAltException",(function(){return me})),n.d(e,"defaultLexerErrorProvider",(function(){return q})),n.d(e,"Alternation",(function(){return ht})),n.d(e,"Alternative",(function(){return at})),n.d(e,"NonTerminal",(function(){return ot})),n.d(e,"Option",(function(){return ct})),n.d(e,"Repetition",(function(){return ft})),n.d(e,"RepetitionMandatory",(function(){return st})),n.d(e,"RepetitionMandatoryWithSeparator",(function(){return ut})),n.d(e,"RepetitionWithSeparator",(function(){return lt})),n.d(e,"Rule",(function(){return it})),n.d(e,"Terminal",(function(){return pt})),n.d(e,"serializeGrammar",(function(){return dt})),n.d(e,"serializeProduction",(function(){return mt})),n.d(e,"GAstVisitor",(function(){return vt})),n.d(e,"assignOccurrenceIndices",(function(){return le})),n.d(e,"resolveGrammar",(function(){return ue})),n.d(e,"validateGrammar",(function(){return fe})),n.d(e,"clearCache",(function(){return En})),n.d(e,"createSyntaxDiagramsCode",(function(){return an})),n.d(e,"generateParserFactory",(function(){return mn})),n.d(e,"generateParserModule",(function(){return gn})),n.d(e,"Parser",(function(){return vn}));var r="7.0.1",o=n(0),i=n(3),a={},c=new i.RegExpParser;function s(t){var e=t.toString();if(a.hasOwnProperty(e))return a[e];var n=c.pattern(e);return a[e]=n,n}var u,f=(u=function(t,e){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),l='Unable to use "first char" lexer optimizations:\n';function h(t,e){void 0===e&&(e=!1);try{var n=s(t);return function t(e,n,r){switch(e.type){case"Disjunction":for(var i=0;i<e.value.length;i++)t(e.value[i],n,r);break;case"Alternative":var a=e.value;for(i=0;i<a.length;i++){var c=a[i];switch(c.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var s=c;switch(s.type){case"Character":p(s.value,n,r);break;case"Set":if(!0===s.complement)throw Error("Complement Sets are not supported for first char optimization");Object(o.u)(s.value,(function(t){if("number"==typeof t)p(t,n,r);else{var e=t;if(!0===r)for(var o=e.from;o<=e.to;o++)p(o,n,r);else{for(o=e.from;o<=e.to&&o<_;o++)p(o,n,r);if(e.to>=_)for(var i=e.from>=_?e.from:_,a=e.to,c=k(i),s=k(a),u=c;u<=s;u++)n[u]=u}}}));break;case"Group":t(s.value,n,r);break;default:throw Error("Non Exhaustive Match")}var u=void 0!==s.quantifier&&0===s.quantifier.atLeast;if("Group"===s.type&&!1===m(s)||"Group"!==s.type&&!1===u)break}break;default:throw Error("non exhaustive match!")}return Object(o.U)(n)}(n.value,{},n.flags.ignoreCase)}catch(n){if("Complement Sets are not supported for first char optimization"===n.message)e&&Object(o.d)(l+"\tUnable to optimize: < "+t.toString()+" >\n\tComplement Sets cannot be automatically optimized.\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.");else{var r="";e&&(r="\n\tThis will disable the lexer's first char optimizations.\n\tSee: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details."),Object(o.c)(l+"\n\tFailed parsing: < "+t.toString()+" >\n\tUsing the regexp-to-ast library version: "+i.VERSION+"\n\tPlease open an issue at: https://github.com/bd82/regexp-to-ast/issues"+r)}}return[]}function p(t,e,n){var r=k(t);e[r]=r,!0===n&&function(t,e){var n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){var o=k(r.charCodeAt(0));e[o]=o}else{var i=n.toLowerCase();if(i!==n){o=k(i.charCodeAt(0));e[o]=o}}}(t,e)}function d(t,e){return Object(o.q)(t.value,(function(t){if("number"==typeof t)return Object(o.j)(e,t);var n=t;return void 0!==Object(o.q)(e,(function(t){return n.from<=t&&t<=n.to}))}))}function m(t){return!(!t.quantifier||0!==t.quantifier.atLeast)||!!t.value&&(Object(o.y)(t.value)?Object(o.o)(t.value,m):m(t.value))}var g=function(t){function e(e){var n=t.call(this)||this;return n.targetCharCodes=e,n.found=!1,n}return f(e,t),e.prototype.visitChildren=function(e){if(!0!==this.found){switch(e.type){case"Lookahead":return void this.visitLookahead(e);case"NegativeLookahead":return void this.visitNegativeLookahead(e)}t.prototype.visitChildren.call(this,e)}},e.prototype.visitCharacter=function(t){Object(o.j)(this.targetCharCodes,t.value)&&(this.found=!0)},e.prototype.visitSet=function(t){t.complement?void 0===d(t,this.targetCharCodes)&&(this.found=!0):void 0!==d(t,this.targetCharCodes)&&(this.found=!0)},e}(i.BaseRegExpVisitor);function E(t,e){if(e instanceof RegExp){var n=s(e),r=new g(t);return r.visit(n),r.found}return void 0!==Object(o.q)(e,(function(e){return Object(o.j)(t,e.charCodeAt(0))}))}var v=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),N="PATTERN",O="boolean"==typeof new RegExp("(?:)").sticky;function R(t,e){var n,r=(e=Object(o.k)(e,{useSticky:O,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r","\n"],tracer:function(t,e){return e()}})).tracer;r("initCharCodeToOptimizedIndexMap",(function(){!function(){if(Object(o.A)(P)){P=new Array(65536);for(var t=0;t<65536;t++)P[t]=t>255?255+~~(t/255):t}}()})),r("Reject Lexer.NA",(function(){n=Object(o.P)(t,(function(t){return t[N]===K.NA}))}));var i,a,c,s,u,f,p,d,m,g,v,R=!1;r("Transform Patterns",(function(){R=!1,i=Object(o.I)(n,(function(t){var n=t[N];if(Object(o.D)(n)){var r=n.source;return 1!==r.length||"^"===r||"$"===r||"."===r||n.ignoreCase?2!==r.length||"\\"!==r[0]||Object(o.j)(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],r[1])?e.useSticky?b(n):M(n):r[1]:r}if(Object(o.B)(n))return R=!0,{exec:n};if(Object(o.w)(n,"exec"))return R=!0,n;if("string"==typeof n){if(1===n.length)return n;var i=n.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),a=new RegExp(i);return e.useSticky?b(a):M(a)}throw Error("non exhaustive match")}))})),r("misc mapping",(function(){a=Object(o.I)(n,(function(t){return t.tokenTypeIdx})),c=Object(o.I)(n,(function(t){var e=t.GROUP;if(e!==K.SKIPPED){if(Object(o.E)(e))return e;if(Object(o.F)(e))return!1;throw Error("non exhaustive match")}})),s=Object(o.I)(n,(function(t){var e=t.LONGER_ALT;if(e)return Object(o.x)(n,e)})),u=Object(o.I)(n,(function(t){return t.PUSH_MODE})),f=Object(o.I)(n,(function(t){return Object(o.w)(t,"POP_MODE")}))})),r("Line Terminator Handling",(function(){var t=L(e.lineTerminatorCharacters);p=Object(o.I)(n,(function(t){return!1})),"onlyOffset"!==e.positionTracking&&(p=Object(o.I)(n,(function(e){return Object(o.w)(e,"LINE_BREAKS")?e.LINE_BREAKS:!1===U(e,t)?E(t,e.PATTERN):void 0})))})),r("Misc Mapping #2",(function(){d=Object(o.I)(n,w),m=Object(o.I)(i,S),g=Object(o.O)(n,(function(t,e){var n=e.GROUP;return Object(o.E)(n)&&n!==K.SKIPPED&&(t[n]=[]),t}),{}),v=Object(o.I)(i,(function(t,e){return{pattern:i[e],longerAlt:s[e],canLineTerminator:p[e],isCustom:d[e],short:m[e],group:c[e],push:u[e],pop:f[e],tokenTypeIdx:a[e],tokenType:n[e]}}))}));var y=!0,A=[];return e.safeMode||r("First Char Optimization",(function(){A=Object(o.O)(n,(function(t,n,r){if("string"==typeof n.PATTERN){var i=k(n.PATTERN.charCodeAt(0));x(t,i,v[r])}else if(Object(o.y)(n.START_CHARS_HINT)){var a;Object(o.u)(n.START_CHARS_HINT,(function(e){var n=k("string"==typeof e?e.charCodeAt(0):e);a!==n&&(a=n,x(t,n,v[r]))}))}else if(Object(o.D)(n.PATTERN))if(n.PATTERN.unicode)y=!1,e.ensureOptimizations&&Object(o.c)(l+"\tUnable to analyze < "+n.PATTERN.toString()+" > pattern.\n\tThe regexp unicode flag is not currently supported by the regexp-to-ast library.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE");else{var c=h(n.PATTERN,e.ensureOptimizations);Object(o.A)(c)&&(y=!1),Object(o.u)(c,(function(e){x(t,e,v[r])}))}else e.ensureOptimizations&&Object(o.c)(l+"\tTokenType: <"+n.name+"> is using a custom token pattern without providing <start_chars_hint> parameter.\n\tThis will disable the lexer's first char optimizations.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE"),y=!1;return t}),[])})),r("ArrayPacking",(function(){A=Object(o.L)(A)})),{emptyGroups:g,patternIdxToConfig:v,charCodeToPatternIdxToConfig:A,hasCustom:R,canBeOptimized:y}}function y(t,e){var n=[],r=function(t){var e=Object(o.p)(t,(function(t){return!Object(o.w)(t,N)})),n=Object(o.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- missing static 'PATTERN' property",type:W.MISSING_PATTERN,tokenTypes:[t]}})),r=Object(o.l)(t,e);return{errors:n,valid:r}}(t);n=n.concat(r.errors);var a=function(t){var e=Object(o.p)(t,(function(t){var e=t[N];return!(Object(o.D)(e)||Object(o.B)(e)||Object(o.w)(e,"exec")||Object(o.E)(e))})),n=Object(o.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:W.INVALID_PATTERN,tokenTypes:[t]}})),r=Object(o.l)(t,e);return{errors:n,valid:r}}(r.valid),c=a.valid;return n=(n=(n=(n=(n=n.concat(a.errors)).concat(function(t){var e=[],n=Object(o.p)(t,(function(t){return Object(o.D)(t[N])}));return e=(e=(e=(e=(e=e.concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return v(e,t),e.prototype.visitEndAnchor=function(t){this.found=!0},e}(i.BaseRegExpVisitor),n=Object(o.p)(t,(function(t){var n=t[N];try{var r=s(n),o=new e;return o.visit(r),o.found}catch(t){return A.test(n.source)}}));return Object(o.I)(n,(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain end of input anchor '$'\n\tSee sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:W.EOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.found=!1,e}return v(e,t),e.prototype.visitStartAnchor=function(t){this.found=!0},e}(i.BaseRegExpVisitor),n=Object(o.p)(t,(function(t){var n=t[N];try{var r=s(n),o=new e;return o.visit(r),o.found}catch(t){return T.test(n.source)}}));return Object(o.I)(n,(function(t){return{message:"Unexpected RegExp Anchor Error:\n\tToken Type: ->"+t.name+"<- static 'PATTERN' cannot contain start of input anchor '^'\n\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#ANCHORS\tfor details.",type:W.SOI_ANCHOR_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=Object(o.p)(t,(function(t){var e=t[N];return e instanceof RegExp&&(e.multiline||e.global)}));return Object(o.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:W.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[t]}}))}(n))).concat(function(t){var e=[],n=Object(o.I)(t,(function(n){return Object(o.O)(t,(function(t,r){return n.PATTERN.source!==r.PATTERN.source||Object(o.j)(e,r)||r.PATTERN===K.NA||(e.push(r),t.push(r)),t}),[])}));n=Object(o.i)(n);var r=Object(o.p)(n,(function(t){return t.length>1}));return Object(o.I)(r,(function(t){var e=Object(o.I)(t,(function(t){return t.name}));return{message:"The same RegExp pattern ->"+Object(o.s)(t).PATTERN+"<-has been used in all of the following Token Types: "+e.join(", ")+" <-",type:W.DUPLICATE_PATTERNS_FOUND,tokenTypes:t}}))}(n))).concat(function(t){var e=Object(o.p)(t,(function(t){return t[N].test("")}));return Object(o.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PATTERN' must not match an empty string",type:W.EMPTY_MATCH_PATTERN,tokenTypes:[t]}}))}(n))}(c))).concat(function(t){var e=Object(o.p)(t,(function(t){if(!Object(o.w)(t,"GROUP"))return!1;var e=t.GROUP;return e!==K.SKIPPED&&e!==K.NA&&!Object(o.E)(e)}));return Object(o.I)(e,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:W.INVALID_GROUP_TYPE_FOUND,tokenTypes:[t]}}))}(c))).concat(function(t,e){var n=Object(o.p)(t,(function(t){return void 0!==t.PUSH_MODE&&!Object(o.j)(e,t.PUSH_MODE)}));return Object(o.I)(n,(function(t){return{message:"Token Type: ->"+t.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+t.PUSH_MODE+"<-which does not exist",type:W.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[t]}}))}(c,e))).concat(function(t){var e=[],n=Object(o.O)(t,(function(t,e,n){var r,i=e.PATTERN;return i===K.NA||(Object(o.E)(i)?t.push({str:i,idx:n,tokenType:e}):Object(o.D)(i)&&(r=i,void 0===Object(o.q)([".","\\","[","]","|","^","$","(",")","?","*","+","{"],(function(t){return-1!==r.source.indexOf(t)})))&&t.push({str:i.source,idx:n,tokenType:e})),t}),[]);return Object(o.u)(t,(function(t,r){Object(o.u)(n,(function(n){var i=n.str,a=n.idx,c=n.tokenType;if(r<a&&function(t,e){if(Object(o.D)(e)){var n=e.exec(t);return null!==n&&0===n.index}if(Object(o.B)(e))return e(t,0,[],{});if(Object(o.w)(e,"exec"))return e.exec(t,0,[],{});if("string"==typeof e)return e===t;throw Error("non exhaustive match")}(i,t.PATTERN)){var s="Token: ->"+c.name+"<- can never be matched.\nBecause it appears AFTER the Token Type ->"+t.name+"<-in the lexer's definition.\nSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#UNREACHABLE";e.push({message:s,type:W.UNREACHABLE_PATTERN,tokenTypes:[t,c]})}}))})),e}(c))}var A=/[^\\][\$]/;var T=/[^\\[][\^]|^\^/;function M(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function b(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}function I(t,e,n){var r=[],i=!1,a=Object(o.i)(Object(o.t)(Object(o.J)(t.modes,(function(t){return t})))),c=Object(o.P)(a,(function(t){return t[N]===K.NA})),s=L(n);return e&&Object(o.u)(c,(function(t){var e=U(t,s);if(!1!==e){var n={message:function(t,e){if(e.issue===W.IDENTIFY_TERMINATOR)return"Warning: unable to identify line terminator usage in pattern.\n\tThe problem is in the <"+t.name+"> Token Type\n\t Root cause: "+e.errMsg+".\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===W.CUSTOM_LINE_BREAK)return"Warning: A Custom Token Pattern should specify the <line_breaks> option.\n\tThe problem is in the <"+t.name+"> Token Type\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}(t,e),type:e.issue,tokenType:t};r.push(n)}else Object(o.w)(t,"LINE_BREAKS")?!0===t.LINE_BREAKS&&(i=!0):E(s,t.PATTERN)&&(i=!0)})),e&&!i&&r.push({message:"Warning: No LINE_BREAKS Found.\n\tThis Lexer has been defined to track line and column information,\n\tBut none of the Token Types can be identified as matching a line terminator.\n\tSee https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#LINE_BREAKS \n\tfor details.",type:W.NO_LINE_BREAKS_FLAGS}),r}function w(t){var e=t.PATTERN;if(Object(o.D)(e))return!1;if(Object(o.B)(e))return!0;if(Object(o.w)(e,"exec"))return!0;if(Object(o.E)(e))return!1;throw Error("non exhaustive match")}function S(t){return!(!Object(o.E)(t)||1!==t.length)&&t.charCodeAt(0)}var C={test:function(t){for(var e=t.length,n=this.lastIndex;n<e;n++){var r=t.charCodeAt(n);if(10===r)return this.lastIndex=n+1,!0;if(13===r)return 10===t.charCodeAt(n+1)?this.lastIndex=n+2:this.lastIndex=n+1,!0}return!1},lastIndex:0};function U(t,e){if(Object(o.w)(t,"LINE_BREAKS"))return!1;if(Object(o.D)(t.PATTERN)){try{E(e,t.PATTERN)}catch(t){return{issue:W.IDENTIFY_TERMINATOR,errMsg:t.message}}return!1}if(Object(o.E)(t.PATTERN))return!1;if(w(t))return{issue:W.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}function L(t){return Object(o.I)(t,(function(t){return Object(o.E)(t)&&t.length>0?t.charCodeAt(0):t}))}function x(t,e,n){void 0===t[e]?t[e]=[n]:t[e].push(n)}var _=256;function k(t){return t<_?t:P[t]}var P=[];function j(t,e){var n=t.tokenTypeIdx;return n===e.tokenTypeIdx||!0===e.isParent&&!0===e.categoryMatchesMap[n]}function B(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}var F=1,D={};function V(t){var e=function(t){var e=Object(o.g)(t),n=t,r=!0;for(;r;){n=Object(o.i)(Object(o.t)(Object(o.I)(n,(function(t){return t.CATEGORIES}))));var i=Object(o.l)(n,e);e=e.concat(i),Object(o.A)(i)?r=!1:n=i}return e}(t);!function(t){Object(o.u)(t,(function(t){var e;G(t)||(D[F]=t,t.tokenTypeIdx=F++),H(t)&&!Object(o.y)(t.CATEGORIES)&&(t.CATEGORIES=[t.CATEGORIES]),H(t)||(t.CATEGORIES=[]),e=t,Object(o.w)(e,"categoryMatches")||(t.categoryMatches=[]),function(t){return Object(o.w)(t,"categoryMatchesMap")}(t)||(t.categoryMatchesMap={})}))}(e),function(t){Object(o.u)(t,(function(t){!function t(e,n){Object(o.u)(e,(function(t){n.categoryMatchesMap[t.tokenTypeIdx]=!0})),Object(o.u)(n.CATEGORIES,(function(r){var i=e.concat(n);Object(o.j)(i,r)||t(i,r)}))}([],t)}))}(e),function(t){Object(o.u)(t,(function(t){t.categoryMatches=[],Object(o.u)(t.categoryMatchesMap,(function(e,n){t.categoryMatches.push(D[n].tokenTypeIdx)}))}))}(e),Object(o.u)(e,(function(t){t.isParent=t.categoryMatches.length>0}))}function G(t){return Object(o.w)(t,"tokenTypeIdx")}function H(t){return Object(o.w)(t,"CATEGORIES")}function Y(t){return Object(o.w)(t,"tokenTypeIdx")}var W,q={buildUnableToPopLexerModeMessage:function(t){return"Unable to pop Lexer Mode after encountering Token ->"+t.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(t,e,n,r,o){return"unexpected character: ->"+t.charAt(e)+"<- at offset: "+e+", skipped "+n+" characters."}};!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"}(W||(W={}));var $={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:["\n","\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:q,traceInitPerf:!1,skipValidations:!1};Object.freeze($);var K=function(){function t(t,e){var n=this;if(void 0===e&&(e=$),this.lexerDefinition=t,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},"boolean"==typeof e)throw Error("The second argument to the Lexer constructor is now an ILexerConfig Object.\na boolean 2nd argument is no longer supported");this.config=Object(o.K)($,e);var r=this.config.traceInitPerf;!0===r?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):"number"==typeof r&&(this.traceInitMaxIdent=r,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",(function(){var r,i=!0;n.TRACE_INIT("Lexer Config handling",(function(){if(n.config.lineTerminatorsPattern===$.lineTerminatorsPattern)n.config.lineTerminatorsPattern=C;else if(n.config.lineTerminatorCharacters===$.lineTerminatorCharacters)throw Error("Error: Missing <lineTerminatorCharacters> property on the Lexer config.\n\tFor details See: https://sap.github.io/chevrotain/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS");if(e.safeMode&&e.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');n.trackStartLines=/full|onlyStart/i.test(n.config.positionTracking),n.trackEndLines=/full/i.test(n.config.positionTracking),Object(o.y)(t)?((r={modes:{}}).modes.defaultMode=Object(o.g)(t),r.defaultMode="defaultMode"):(i=!1,r=Object(o.h)(t))})),!1===n.config.skipValidations&&(n.TRACE_INIT("performRuntimeChecks",(function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(function(t,e,n){var r=[];return Object(o.w)(t,"defaultMode")||r.push({message:"A MultiMode Lexer cannot be initialized without a <defaultMode> property in its definition\n",type:W.MULTI_MODE_LEXER_WI