dsh-artifact-studio 0.8.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +72 -10
  2. package/THIRD_PARTY_NOTICES.md +57 -0
  3. package/assets/canvas.engine.js +72 -72
  4. package/assets/canvas.viewer.js +6415 -0
  5. package/client.canvas.js +1 -1
  6. package/client.doc.js +67 -79
  7. package/client.js +313 -291
  8. package/client.sheet.js +218 -0
  9. package/dist/contract.js +32 -5
  10. package/dist/host/lib/assets.js +12 -0
  11. package/dist/host/lib/brief.js +127 -0
  12. package/dist/host/lib/checks.js +62 -8
  13. package/dist/host/lib/design-catalog.js +149 -0
  14. package/dist/host/lib/design-render.js +37 -0
  15. package/dist/host/lib/design-system.js +1 -1
  16. package/dist/host/lib/export.js +123 -5
  17. package/dist/host/lib/fsutil.js +41 -0
  18. package/dist/host/lib/generation.js +36 -0
  19. package/dist/host/lib/guide.js +130 -0
  20. package/dist/host/lib/paths.js +2 -1
  21. package/dist/host/lib/recipes.js +224 -0
  22. package/dist/host/lib/rpc.js +20 -5
  23. package/dist/host/lib/service.js +253 -24
  24. package/dist/host/lib/skill.js +59 -18
  25. package/dist/host/lib/store.js +107 -25
  26. package/dist/host/lib/svg-model.js +85 -0
  27. package/dist/host/lib/svg-viewer.js +380 -0
  28. package/dist/host/lib/tools.js +346 -35
  29. package/dist/host/lib/validate.js +24 -0
  30. package/dist/host/lib/viewer.js +150 -0
  31. package/dist/host/lib/xlsx.js +314 -0
  32. package/dist/host/worker/design-worker.js +71 -5
  33. package/dist/host/worker/page-model.js +169 -0
  34. package/dist/html-tags.js +51 -0
  35. package/dist/kit.js +224 -0
  36. package/dist/render.js +10 -3
  37. package/dist/sheet/formula.js +475 -0
  38. package/dist/sheet/functions.js +463 -0
  39. package/dist/sheet/index.js +9 -0
  40. package/dist/sheet/model.js +695 -0
  41. package/dist/sheet/operations.js +384 -0
  42. package/dist/sheet/output.js +182 -0
  43. package/package.json +15 -3
@@ -0,0 +1,218 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "dsh-artifact-studio",
3
+ chunk: "client.sheet.js",
4
+ factory(require) {
5
+ var module = { exports: {} };
6
+ var exports = module.exports;
7
+ "use strict";var kh=Object.create;var Xn=Object.defineProperty;var bh=Object.getOwnPropertyDescriptor;var xh=Object.getOwnPropertyNames;var Lh=Object.getPrototypeOf,Uh=Object.prototype.hasOwnProperty;var D=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ph=(t,e)=>{for(var r in e)Xn(t,r,{get:e[r],enumerable:!0})},Js=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of xh(e))!Uh.call(t,o)&&o!==r&&Xn(t,o,{get:()=>e[o],enumerable:!(n=bh(e,o))||n.enumerable});return t};var Sh=(t,e,r)=>(r=t!=null?kh(Lh(t)):{},Js(e||!t||!t.__esModule?Xn(r,"default",{value:t,enumerable:!0}):r,t)),Fh=t=>Js(Xn({},"__esModule",{value:!0}),t);var Nn=D((sv,la)=>{var fi=class{constructor(e,r){if(e==null&&r==null)this._data=[],this._refs=[];else{if(e.length!==r.length)throw Error("Collection: data length should match references length.");this._data=e,this._refs=r}}get data(){return this._data}get refs(){return this._refs}get length(){return this._data.length}add(e,r){this._data.push(e),this._refs.push(r)}};la.exports=fi});var $e=D((av,pa)=>{var Ze=qe(),hi=Nn(),ke={NUMBER:0,ARRAY:1,BOOLEAN:2,STRING:3,RANGE_REF:4,CELL_REF:5,COLLECTIONS:6,NUMBER_NO_BOOLEAN:10},jh=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3,121645100408832e3,243290200817664e4,5109094217170944e4,11240007277776077e5,2585201673888498e7,6204484017332394e8,15511210043330986e9,40329146112660565e10,10888869450418352e12,30488834461171387e13,8841761993739702e15,26525285981219107e16,8222838654177922e18,2631308369336935e20,8683317618811886e21,29523279903960416e22,10333147966386145e24,37199332678990125e25,13763753091226346e27,5230226174666011e29,20397882081197444e30,8159152832478977e32,3345252661316381e34,140500611775288e37,6041526306337383e37,2658271574788449e39,11962222086548019e40,5502622159812089e42,25862324151116818e43,12413915592536073e45,6082818640342675e47,30414093201713376e48,15511187532873822e50,8065817517094388e52,42748832840600255e53,2308436973392414e56,12696403353658276e57,7109985878048635e59,40526919504877214e60,23505613312828785e62,13868311854568984e64,832098711274139e67,5075802138772248e68,3146997326038794e70,198260831540444e73,12688693218588417e73,8247650592082472e75,5443449390774431e77,3647111091818868e79,24800355424368305e80,1711224524281413e83,11978571669969892e84,8504785885678623e86,61234458376886085e87,44701154615126844e89,3307885441519386e92,248091408113954e95,18854947016660504e95,14518309202828587e97,11324281178206297e99,8946182130782976e101,7156945704626381e103,5797126020747368e105,4753643337012842e107,3945523969720659e109,3314240134565353e111,281710411438055e114,24227095383672734e114,2107757298379528e117,18548264225739844e118,1650795516090846e121,14857159644817615e122,1352001527678403e125,12438414054641308e126,11567725070816416e128,1087366156656743e131,1032997848823906e133,9916779348709496e134,9619275968248212e136,9426890448883248e138,9332621544394415e140,9332621544394415e142],fa={};Object.keys(ke).forEach(t=>{fa[ke[t]]=t});var pi=class{constructor(){this.Types=ke,this.type2Number={number:ke.NUMBER,boolean:ke.BOOLEAN,string:ke.STRING,object:-1}}checkFunctionResult(e){if(typeof e==="number"){if(isNaN(e))return Ze.VALUE;if(!isFinite(e))return Ze.NUM}return e??Ze.NULL}flattenDeep(e){return e.reduce((r,n)=>Array.isArray(n)?r.concat(this.flattenDeep(n)):r.concat(n),[])}acceptNumber(e,r=!0,n=!0){if(e instanceof Ze)return e;let o;if(typeof e=="number")o=e;else if(typeof e=="boolean")if(n)o=Number(e);else throw Ze.VALUE;else if(typeof e=="string"){if(e.length===0||(o=Number(e),o!==o))throw Ze.VALUE}else if(Array.isArray(e))if(r)o=this.acceptNumber(e[0][0]);else if(e[0].length===1)o=this.acceptNumber(e[0][0]);else throw Ze.VALUE;else throw Error("Unknown type in FormulaHelpers.acceptNumber");return o}flattenParams(e,r,n,o,s=null,c=1){if(e.length<c)throw Ze.ARG_MISSING([r]);s==null&&(s=r===ke.NUMBER?0:r==null?null:""),e.forEach(u=>{let{isCellRef:i,isRangeRef:a,isArray:l}=u,f=u.value instanceof hi,p=!i&&!a&&!l&&!f,d={isLiteral:p,isCellRef:i,isRangeRef:a,isArray:l,isUnion:f};if(p)u.omitted?u=s:u=this.accept(u,r,s),o(u,d);else if(i)o(u.value,d);else if(f){if(!n)throw Ze.VALUE;u=u.value.data,u=this.flattenDeep(u),u.forEach(h=>{o(h,d)})}else(a||l)&&(u=this.flattenDeep(u.value),u.forEach(h=>{o(h,d)}))})}accept(e,r=null,n,o=!0,s=!1){if(Array.isArray(r)&&(r=r[0]),e==null&&n===void 0)throw Ze.ARG_MISSING([r]);if(e==null)return n;if(typeof e!="object"||Array.isArray(e))return e;let c=e.isArray;if(e.value!=null&&(e=e.value),r==null)return e;if(e instanceof Ze)throw e;if(r===ke.ARRAY){if(Array.isArray(e))return o?this.flattenDeep(e):e;if(e instanceof hi)throw Ze.VALUE;if(s)return o?[e]:[[e]];throw Ze.VALUE}else if(r===ke.COLLECTIONS)return e;c&&(e=e[0][0]);let u=this.type(e);if(r===ke.STRING)u===ke.BOOLEAN?e=e?"TRUE":"FALSE":e=`${e}`;else if(r===ke.BOOLEAN){if(u===ke.STRING)throw Ze.VALUE;u===ke.NUMBER&&(e=!!e)}else if(r===ke.NUMBER)e=this.acceptNumber(e,!1);else if(r===ke.NUMBER_NO_BOOLEAN)e=this.acceptNumber(e,!1,!1);else throw Ze.VALUE;return e}type(e){let r=this.type2Number[typeof e];return r===-1&&(Array.isArray(e)?r=ke.ARRAY:e.ref?e.ref.from?r=ke.RANGE_REF:r=ke.CELL_REF:e instanceof hi&&(r=ke.COLLECTIONS)),r}isRangeRef(e){return e.ref&&e.ref.from}isCellRef(e){return e.ref&&!e.ref.from}retrieveRanges(e,r,n){return n=ha.extend(r,n),r=this.retrieveArg(e,r),r=Jr.accept(r,ke.ARRAY,void 0,!1,!0),n!==r?(n=this.retrieveArg(e,n),n=Jr.accept(n,ke.ARRAY,void 0,!1,!0)):n=r,[r,n]}retrieveArg(e,r){if(r===null)return{value:0,isArray:!1,omitted:!0};let n=e.utils.extractRefValue(r);return{value:n.val,isArray:n.isArray,ref:r.ref}}},Jr=new pi,An={isWildCard:t=>typeof t=="string"?/[*?]/.test(t):!1,toRegex:(t,e)=>RegExp(t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/([^~]??)[?]/g,"$1.").replace(/([^~]??)[*]/g,"$1.*").replace(/~([?*])/g,"$1"),e)},ep={parse:t=>{let e=typeof t;if(e==="string"){let r=t.toUpperCase();if(r==="TRUE"||r==="FALSE")return{op:"=",value:r==="TRUE"};let n=t.match(/(<>|>=|<=|>|<|=)(.*)/);if(n){let o=n[1],s;if(isNaN(n[2])){let c=n[2].toUpperCase();if(c==="TRUE"||c==="FALSE")s=c==="TRUE";else if(/#NULL!|#DIV\/0!|#VALUE!|#NAME\?|#NUM!|#N\/A|#REF!/.test(n[2]))s=new Ze(n[2]);else if(s=n[2],An.isWildCard(s))return{op:"wc",value:An.toRegex(s),match:o==="="}}else s=Number(n[2]);return{op:o,value:s}}else return An.isWildCard(t)?{op:"wc",value:An.toRegex(t),match:!0}:{op:"=",value:t}}else{if(e==="boolean"||e==="number"||Array.isArray(t)||t instanceof Ze)return{op:"=",value:t};throw Error(`Criteria.parse: type ${typeof t} not support`)}}},ha={columnNumberToName:t=>{let e=t,r="",n=0;for(;e>0;)n=(e-1)%26,r=String.fromCharCode(65+n)+r,e=Math.floor((e-n)/26);return r},columnNameToNumber:t=>{t=t.toUpperCase();let e=t.length,r=0;for(let n=0;n<e;n++){let o=t.charCodeAt(n);isNaN(o)||(r+=(o-64)*26**(e-n-1))}return r},extend:(t,e)=>{if(e==null)return t;let r,n;if(Jr.isCellRef(t))r=0,n=0;else if(Jr.isRangeRef(t))r=t.ref.to.row-t.ref.from.row,n=t.ref.to.col-t.ref.from.col;else throw Error("Address.extend should not reach here.");return Jr.isCellRef(e)?(r>0||n>0)&&(e={ref:{from:{col:e.ref.col,row:e.ref.row},to:{row:e.ref.row+r,col:e.ref.col+n}}}):(e.ref.to.row=e.ref.from.row+r,e.ref.to.col=e.ref.from.col+n),e}};pa.exports={FormulaHelpers:Jr,Types:ke,ReversedTypes:fa,Factorials:jh,WildCard:An,Criteria:ep,Address:ha}});var qe=D((uv,da)=>{var Ae=class t extends Error{constructor(e,r,n){if(super(r),r==null&&n==null&&t.errorMap.has(e))return t.errorMap.get(e);r==null&&n==null?(this._error=e,t.errorMap.set(e,this)):this._error=e,this.details=n}get error(){return this._error}get name(){return this._error}equals(e){return e instanceof t&&e._error===this._error}toString(){return this._error}};Ae.errorMap=new Map;Ae.DIV0=new Ae("#DIV/0!");Ae.NA=new Ae("#N/A");Ae.NAME=new Ae("#NAME?");Ae.NULL=new Ae("#NULL!");Ae.NUM=new Ae("#NUM!");Ae.REF=new Ae("#REF!");Ae.VALUE=new Ae("#VALUE!");Ae.NOT_IMPLEMENTED=t=>new Ae("#NAME?",`Function ${t} is not implemented.`);Ae.TOO_MANY_ARGS=t=>new Ae("#N/A",`Function ${t} has too many arguments.`);Ae.ARG_MISSING=t=>{let{Types:e}=$e();return new Ae("#N/A",`Argument type ${t.map(r=>e[r]).join(", ")} is missing.`)};Ae.ERROR=(t,e)=>new Ae("#ERROR!",t,e);da.exports=Ae});var gi=D((cv,ba)=>{var ot=class{};ot.version="0.10.3";function jr(t){let e="",r=t.length-1;for(;r>=0;)e+=t.charAt(r--);return e}function yt(t,e){let r="";for(;r.length<e;)r+=t;return r}function Vt(t,e){let r=""+t;return r.length>=e?r:yt("0",e-r.length)+r}function di(t,e){let r=""+t;return r.length>=e?r:yt(" ",e-r.length)+r}function eo(t,e){let r=""+t;return r.length>=e?r:r+yt(" ",e-r.length)}function tp(t,e){let r=""+Math.round(t);return r.length>=e?r:yt("0",e-r.length)+r}function rp(t,e){let r=""+t;return r.length>=e?r:yt("0",e-r.length)+r}var ma=Math.pow(2,32);function en(t,e){if(t>ma||t<-ma)return tp(t,e);let r=Math.round(t);return rp(r,e)}function ro(t,e){return e=e||0,t.length>=7+e&&(t.charCodeAt(e)|32)===103&&(t.charCodeAt(e+1)|32)===101&&(t.charCodeAt(e+2)|32)===110&&(t.charCodeAt(e+3)|32)===101&&(t.charCodeAt(e+4)|32)===114&&(t.charCodeAt(e+5)|32)===97&&(t.charCodeAt(e+6)|32)===108}var ga=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],mi=[["J","Jan","January"],["F","Feb","February"],["M","Mar","March"],["A","Apr","April"],["M","May","May"],["J","Jun","June"],["J","Jul","July"],["A","Aug","August"],["S","Sep","September"],["O","Oct","October"],["N","Nov","November"],["D","Dec","December"]];function Ra(t){t[0]="General",t[1]="0",t[2]="0.00",t[3]="#,##0",t[4]="#,##0.00",t[9]="0%",t[10]="0.00%",t[11]="0.00E+00",t[12]="# ?/?",t[13]="# ??/??",t[14]="m/d/yy",t[15]="d-mmm-yy",t[16]="d-mmm",t[17]="mmm-yy",t[18]="h:mm AM/PM",t[19]="h:mm:ss AM/PM",t[20]="h:mm",t[21]="h:mm:ss",t[22]="m/d/yy h:mm",t[37]="#,##0 ;(#,##0)",t[38]="#,##0 ;[Red](#,##0)",t[39]="#,##0.00;(#,##0.00)",t[40]="#,##0.00;[Red](#,##0.00)",t[45]="mm:ss",t[46]="[h]:mm:ss",t[47]="mmss.0",t[48]="##0.0E+0",t[49]="@",t[56]='"\u4E0A\u5348/\u4E0B\u5348 "hh"\u6642"mm"\u5206"ss"\u79D2 "',t[65535]="General"}var Br={};Ra(Br);function to(t,e,r){let n=t<0?-1:1,o=t*n,s=0,c=1,u=0,i=1,a=0,l=0,f=Math.floor(o);for(;a<e&&(f=Math.floor(o),u=f*c+s,l=f*a+i,!(o-f<5e-8));)o=1/(o-f),s=c,c=u,i=a,a=l;if(l>e&&(a>e?(l=i,u=s):(l=a,u=c)),!r)return[0,n*u,l];let p=Math.floor(n*u/l);return[p,n*u-p*l,l]}function Tn(t,e,r){if(t>2958465||t<0)return null;let n=t|0,o=Math.floor(86400*(t-n)),s=0,c=[],u={D:n,T:o,u:86400*(t-n)-o,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(u.u)<1e-6&&(u.u=0),e&&e.date1904&&(n+=1462),u.u>.9999&&(u.u=0,++o===86400&&(u.T=o=0,++n,++u.D)),n===60)c=r?[1317,10,29]:[1900,2,29],s=3;else if(n===0)c=r?[1317,8,29]:[1900,1,0],s=6;else{n>60&&--n;let i=new Date(1900,0,1);i.setDate(i.getDate()+n-1),c=[i.getFullYear(),i.getMonth()+1,i.getDate()],s=i.getDay(),n<60&&(s=(s+6)%7),r&&(s=ip(i,c))}return u.y=c[0],u.m=c[1],u.d=c[2],u.S=o%60,o=Math.floor(o/60),u.M=o%60,o=Math.floor(o/60),u.H=o,u.q=s,u}ot.parse_date_code=Tn;var Na=new Date(1899,11,31,0,0,0),np=Na.getTime(),op=new Date(1900,2,1,0,0,0);function Aa(t,e){let r=t.getTime();return e?r-=1461*24*60*60*1e3:t>=op&&(r+=1440*60*1e3),(r-(np+(t.getTimezoneOffset()-Na.getTimezoneOffset())*6e4))/(1440*60*1e3)}function Ta(t){return t.toString(10)}ot._general_int=Ta;var Oa=(function(){let e=/\.(\d*[1-9])0+$/,r=/\.0*$/,n=/\.(\d*[1-9])0+/,o=/\.0*[Ee]/,s=/(E[+-])(\d)$/;function c(l){let f=l<0?12:11,p=a(l.toFixed(12));return p.length<=f||(p=l.toPrecision(10),p.length<=f)?p:l.toExponential(5)}function u(l){let f=l.toFixed(11).replace(e,".$1");return f.length>(l<0?12:11)&&(f=l.toPrecision(6)),f}function i(l){for(let f=0;f!==l.length;++f)if((l.charCodeAt(f)|32)===101)return l.replace(n,".$1").replace(o,"E").replace("e","E").replace(s,"$10$2");return l}function a(l){return l.indexOf(".")>-1?l.replace(r,"").replace(e,".$1"):l}return function(f){let p=Math.floor(Math.log(Math.abs(f))*Math.LOG10E),d;return p>=-4&&p<=-1?d=f.toPrecision(10+p):Math.abs(p)<=9?d=c(f):p===10?d=f.toFixed(10).substr(0,12):d=u(f),a(i(d))}})();ot._general_num=Oa;function no(t,e){switch(typeof t){case"string":return t;case"boolean":return t?"TRUE":"FALSE";case"number":return(t|0)===t?Ta(t):Oa(t);case"undefined":return"";case"object":if(t==null)return"";if(t instanceof Date)return _a(14,Aa(t,e&&e.date1904),e)}throw new Error("unsupported value in General format: "+t)}ot._general=no;function ip(){return 0}function sp(t,e,r,n){let o="",s=0,c=0,u=r.y,i,a=0;switch(t){case 98:u=r.y+543;case 121:switch(e.length){case 1:case 2:i=u%100,a=2;break;default:i=u%1e4,a=4;break}break;case 109:switch(e.length){case 1:case 2:i=r.m,a=e.length;break;case 3:return mi[r.m-1][1];case 5:return mi[r.m-1][0];default:return mi[r.m-1][2]}break;case 100:switch(e.length){case 1:case 2:i=r.d,a=e.length;break;case 3:return ga[r.q][0];default:return ga[r.q][1]}break;case 104:switch(e.length){case 1:case 2:i=1+(r.H+11)%12,a=e.length;break;default:throw"bad hour format: "+e}break;case 72:switch(e.length){case 1:case 2:i=r.H,a=e.length;break;default:throw"bad hour format: "+e}break;case 77:switch(e.length){case 1:case 2:i=r.M,a=e.length;break;default:throw"bad minute format: "+e}break;case 115:if(e!=="s"&&e!=="ss"&&e!==".0"&&e!==".00"&&e!==".000")throw"bad second format: "+e;return r.u===0&&(e==="s"||e==="ss")?Vt(r.S,e.length):(n>=2?c=n===3?1e3:100:c=n===1?10:1,s=Math.round(c*(r.S+r.u)),s>=60*c&&(s=0),e==="s"?s===0?"0":""+s/c:(o=Vt(s,2+n),e==="ss"?o.substr(0,2):"."+o.substr(2,e.length-1)));case 90:switch(e){case"[h]":case"[hh]":i=r.D*24+r.H;break;case"[m]":case"[mm]":i=(r.D*24+r.H)*60+r.M;break;case"[s]":case"[ss]":i=((r.D*24+r.H)*60+r.M)*60+Math.round(r.S+r.u);break;default:throw"bad abstime format: "+e}a=e.length===3?1:2;break;case 101:i=u,a=1}return a>0?Vt(i,a):""}function Or(t){if(t.length<=3)return t;let r=t.length%3,n=t.substr(0,r);for(;r!==t.length;r+=3)n+=(n.length>0?",":"")+t.substr(r,3);return n}var lr=(function(){let e=/%/g;function r(A,y,T){let I=y.replace(e,""),M=y.length-I.length;return lr(A,I,T*Math.pow(10,2*M))+yt("%",M)}function n(A,y,T){let I=y.length-1;for(;y.charCodeAt(I-1)===44;)--I;return lr(A,y.substr(0,I),T/Math.pow(10,3*(y.length-I)))}function o(A,y){let T,I=A.indexOf("E")-A.indexOf(".")-1;if(A.match(/^#+0.0E\+0$/)){if(y===0)return"0.0E+0";if(y<0)return"-"+o(A,-y);let M=A.indexOf(".");M===-1&&(M=A.indexOf("E"));let b=Math.floor(Math.log(y)*Math.LOG10E)%M;if(b<0&&(b+=M),T=(y/Math.pow(10,b)).toPrecision(I+1+(M+b)%M),T.indexOf("e")===-1){let S=Math.floor(Math.log(y)*Math.LOG10E);for(T.indexOf(".")===-1?T=T.charAt(0)+"."+T.substr(1)+"E+"+(S-T.length+b):T+="E+"+(S-b);T.substr(0,2)==="0.";)T=T.charAt(0)+T.substr(2,M)+"."+T.substr(2+M),T=T.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");T=T.replace(/\+-/,"-")}T=T.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(S,G,j,$){return G+j+$.substr(0,(M+b)%M)+"."+$.substr(b)+"E"})}else T=y.toExponential(I);return A.match(/E\+00$/)&&T.match(/e[+-]\d$/)&&(T=T.substr(0,T.length-1)+"0"+T.charAt(T.length-1)),A.match(/E\-/)&&T.match(/e\+/)&&(T=T.replace(/e\+/,"e")),T.replace("e","E")}let s=/# (\?+)( ?)\/( ?)(\d+)/;function c(A,y,T){let I=parseInt(A[4],10),M=Math.round(y*I),b=Math.floor(M/I),S=M-b*I,G=I;return T+(b===0?"":""+b)+" "+(S===0?yt(" ",A[1].length+1+A[4].length):di(S,A[1].length)+A[2]+"/"+A[3]+Vt(G,A[4].length))}function u(A,y,T){return T+(y===0?"":""+y)+yt(" ",A[1].length+2+A[4].length)}let i=/^#*0*\.([0#]+)/,a=/\).*[0#]/,l=/\(###\) ###\\?-####/;function f(A){let y="",T;for(let I=0;I!==A.length;++I)switch(T=A.charCodeAt(I)){case 35:break;case 63:y+=" ";break;case 48:y+="0";break;default:y+=String.fromCharCode(T)}return y}function p(A,y){let T=Math.pow(10,y);return""+Math.round(A*T)/T}function d(A,y){return y<(""+Math.round((A-Math.floor(A))*Math.pow(10,y))).length?0:Math.round((A-Math.floor(A))*Math.pow(10,y))}function h(A,y){return y<(""+Math.round((A-Math.floor(A))*Math.pow(10,y))).length?1:0}function m(A){return A<2147483647&&A>-2147483648?""+(A>=0?A|0:A-1|0):""+Math.floor(A)}function E(A,y,T){if(A.charCodeAt(0)===40&&!y.match(a)){let W=y.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return T>=0?E("n",W,T):"("+E("n",W,-T)+")"}if(y.charCodeAt(y.length-1)===44)return n(A,y,T);if(y.indexOf("%")!==-1)return r(A,y,T);if(y.indexOf("E")!==-1)return o(y,T);if(y.charCodeAt(0)===36)return"$"+E(A,y.substr(y.charAt(1)==" "?2:1),T);let I,M,b,S,G=Math.abs(T),j=T<0?"-":"";if(y.match(/^00+$/))return j+en(G,y.length);if(y.match(/^[#?]+$/))return I=en(T,0),I==="0"&&(I=""),I.length>y.length?I:f(y.substr(0,y.length-I.length))+I;if(M=y.match(s))return c(M,G,j);if(y.match(/^#+0+$/))return j+en(G,y.length-y.indexOf("0"));if(M=y.match(i))return I=p(T,M[1].length).replace(/^([^\.]+)$/,"$1."+f(M[1])).replace(/\.$/,"."+f(M[1])).replace(/\.(\d*)$/,function(W,he){return"."+he+yt("0",f(M[1]).length-he.length)}),y.indexOf("0.")!==-1?I:I.replace(/^0\./,".");if(y=y.replace(/^#+([0.])/,"$1"),M=y.match(/^(0*)\.(#*)$/))return j+p(G,M[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,M[1].length?"0.":".");if(M=y.match(/^#{1,3},##0(\.?)$/))return j+Or(en(G,0));if(M=y.match(/^#,##0\.([#0]*0)$/))return T<0?"-"+E(A,y,-T):Or(""+(Math.floor(T)+h(T,M[1].length)))+"."+Vt(d(T,M[1].length),M[1].length);if(M=y.match(/^#,#*,#0/))return E(A,y.replace(/^#,#*,/,""),T);if(M=y.match(/^([0#]+)(\\?-([0#]+))+$/))return I=jr(E(A,y.replace(/[\\-]/g,""),T)),b=0,jr(jr(y.replace(/\\/g,"")).replace(/[0#]/g,function(W){return b<I.length?I.charAt(b++):W==="0"?"0":""}));if(y.match(l))return I=E(A,"##########",T),"("+I.substr(0,3)+") "+I.substr(3,3)+"-"+I.substr(6);let $="";if(M=y.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return b=Math.min(M[4].length,7),S=to(G,Math.pow(10,b)-1,!1),I=""+j,$=lr("n",M[1],S[1]),$.charAt($.length-1)===" "&&($=$.substr(0,$.length-1)+"0"),I+=$+M[2]+"/"+M[3],$=eo(S[2],b),$.length<M[4].length&&($=f(M[4].substr(M[4].length-$.length))+$),I+=$,I;if(M=y.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return b=Math.min(Math.max(M[1].length,M[4].length),7),S=to(G,Math.pow(10,b)-1,!0),j+(S[0]||(S[1]?"":"0"))+" "+(S[1]?di(S[1],b)+M[2]+"/"+M[3]+eo(S[2],b):yt(" ",2*b+1+M[2].length+M[3].length));if(M=y.match(/^[#0?]+$/))return I=en(T,0),y.length<=I.length?I:f(y.substr(0,y.length-I.length))+I;if(M=y.match(/^([#0?]+)\.([#0]+)$/)){I=""+T.toFixed(Math.min(M[2].length,10)).replace(/([^0])0+$/,"$1"),b=I.indexOf(".");let W=y.indexOf(".")-b,he=y.length-I.length-W;return f(y.substr(0,W)+I+y.substr(y.length-he))}if(M=y.match(/^00,000\.([#0]*0)$/))return b=d(T,M[1].length),T<0?"-"+E(A,y,-T):Or(m(T)).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(W){return"00,"+(W.length<3?Vt(0,3-W.length):"")+W})+"."+Vt(b,M[1].length);switch(y){case"###,##0.00":return E(A,"#,##0.00",T);case"###,###":case"##,###":case"#,###":let W=Or(en(G,0));return W!=="0"?j+W:"";case"###,###.00":return E(A,"###,##0.00",T).replace(/^0\./,".");case"#,###.00":return E(A,"#,##0.00",T).replace(/^0\./,".");default:}throw new Error("unsupported format |"+y+"|")}function g(A,y,T){let I=y.length-1;for(;y.charCodeAt(I-1)===44;)--I;return lr(A,y.substr(0,I),T/Math.pow(10,3*(y.length-I)))}function v(A,y,T){let I=y.replace(e,""),M=y.length-I.length;return lr(A,I,T*Math.pow(10,2*M))+yt("%",M)}function R(A,y){let T,I=A.indexOf("E")-A.indexOf(".")-1;if(A.match(/^#+0.0E\+0$/)){if(y===0)return"0.0E+0";if(y<0)return"-"+R(A,-y);let M=A.indexOf(".");M===-1&&(M=A.indexOf("E"));let b=Math.floor(Math.log(y)*Math.LOG10E)%M;if(b<0&&(b+=M),T=(y/Math.pow(10,b)).toPrecision(I+1+(M+b)%M),!T.match(/[Ee]/)){let S=Math.floor(Math.log(y)*Math.LOG10E);T.indexOf(".")===-1?T=T.charAt(0)+"."+T.substr(1)+"E+"+(S-T.length+b):T+="E+"+(S-b),T=T.replace(/\+-/,"-")}T=T.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(S,G,j,$){return G+j+$.substr(0,(M+b)%M)+"."+$.substr(b)+"E"})}else T=y.toExponential(I);return A.match(/E\+00$/)&&T.match(/e[+-]\d$/)&&(T=T.substr(0,T.length-1)+"0"+T.charAt(T.length-1)),A.match(/E\-/)&&T.match(/e\+/)&&(T=T.replace(/e\+/,"e")),T.replace("e","E")}function N(A,y,T){if(A.charCodeAt(0)===40&&!y.match(a)){let W=y.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return T>=0?N("n",W,T):"("+N("n",W,-T)+")"}if(y.charCodeAt(y.length-1)===44)return g(A,y,T);if(y.indexOf("%")!==-1)return v(A,y,T);if(y.indexOf("E")!==-1)return R(y,T);if(y.charCodeAt(0)===36)return"$"+N(A,y.substr(y.charAt(1)==" "?2:1),T);let I,M,b,S,G=Math.abs(T),j=T<0?"-":"";if(y.match(/^00+$/))return j+Vt(G,y.length);if(y.match(/^[#?]+$/))return I=""+T,T===0&&(I=""),I.length>y.length?I:f(y.substr(0,y.length-I.length))+I;if(M=y.match(s))return u(M,G,j);if(y.match(/^#+0+$/))return j+Vt(G,y.length-y.indexOf("0"));if(M=y.match(i))return I=(""+T).replace(/^([^\.]+)$/,"$1."+f(M[1])).replace(/\.$/,"."+f(M[1])),I=I.replace(/\.(\d*)$/,function(W,he){return"."+he+yt("0",f(M[1]).length-he.length)}),y.indexOf("0.")!==-1?I:I.replace(/^0\./,".");if(y=y.replace(/^#+([0.])/,"$1"),M=y.match(/^(0*)\.(#*)$/))return j+(""+G).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,M[1].length?"0.":".");if(M=y.match(/^#{1,3},##0(\.?)$/))return j+Or(""+G);if(M=y.match(/^#,##0\.([#0]*0)$/))return T<0?"-"+N(A,y,-T):Or(""+T)+"."+yt("0",M[1].length);if(M=y.match(/^#,#*,#0/))return N(A,y.replace(/^#,#*,/,""),T);if(M=y.match(/^([0#]+)(\\?-([0#]+))+$/))return I=jr(N(A,y.replace(/[\\-]/g,""),T)),b=0,jr(jr(y.replace(/\\/g,"")).replace(/[0#]/g,function(W){return b<I.length?I.charAt(b++):W==="0"?"0":""}));if(y.match(l))return I=N(A,"##########",T),"("+I.substr(0,3)+") "+I.substr(3,3)+"-"+I.substr(6);let $="";if(M=y.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))return b=Math.min(M[4].length,7),S=to(G,Math.pow(10,b)-1,!1),I=""+j,$=lr("n",M[1],S[1]),$.charAt($.length-1)==" "&&($=$.substr(0,$.length-1)+"0"),I+=$+M[2]+"/"+M[3],$=eo(S[2],b),$.length<M[4].length&&($=f(M[4].substr(M[4].length-$.length))+$),I+=$,I;if(M=y.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))return b=Math.min(Math.max(M[1].length,M[4].length),7),S=to(G,Math.pow(10,b)-1,!0),j+(S[0]||(S[1]?"":"0"))+" "+(S[1]?di(S[1],b)+M[2]+"/"+M[3]+eo(S[2],b):yt(" ",2*b+1+M[2].length+M[3].length));if(M=y.match(/^[#0?]+$/))return I=""+T,y.length<=I.length?I:f(y.substr(0,y.length-I.length))+I;if(M=y.match(/^([#0]+)\.([#0]+)$/)){I=""+T.toFixed(Math.min(M[2].length,10)).replace(/([^0])0+$/,"$1"),b=I.indexOf(".");let W=y.indexOf(".")-b,he=y.length-I.length-W;return f(y.substr(0,W)+I+y.substr(y.length-he))}if(M=y.match(/^00,000\.([#0]*0)$/))return T<0?"-"+N(A,y,-T):Or(""+T).replace(/^\d,\d{3}$/,"0$&").replace(/^\d*$/,function(W){return"00,"+(W.length<3?Vt(0,3-W.length):"")+W})+"."+Vt(0,M[1].length);switch(y){case"###,###":case"##,###":case"#,###":let W=Or(""+G);return W!=="0"?j+W:"";default:if(y.match(/\.[0#?]*$/))return N(A,y.slice(0,y.lastIndexOf(".")),T)+f(y.slice(y.lastIndexOf(".")))}throw new Error("unsupported format |"+y+"|")}return function(y,T,I){return(I|0)===I?N(y,T,I):E(y,T,I)}})();function Ia(t){let e=[],r=!1,n=0;for(let o=0;o<t.length;++o)switch(t.charCodeAt(o)){case 34:r=!r;break;case 95:case 42:case 92:++o;break;case 59:e[e.length]=t.substr(n,o-n),n=o+1}if(e[e.length]=t.substr(n),r===!0)throw new Error("Format |"+t+"| unterminated string ");return e}ot._split=Ia;var Ma=/\[[HhMmSs]*\]/;function Ca(t){let e=0,r="",n="";for(;e<t.length;)switch(r=t.charAt(e)){case"G":ro(t,e)&&(e+=6),e++;break;case'"':for(;t.charCodeAt(++e)!==34&&e<t.length;)++e;++e;break;case"\\":e+=2;break;case"_":e+=2;break;case"@":++e;break;case"B":case"b":if(t.charAt(e+1)==="1"||t.charAt(e+1)==="2")return!0;case"M":case"D":case"Y":case"H":case"S":case"E":case"m":case"d":case"y":case"h":case"s":case"e":case"g":return!0;case"A":case"a":if(t.substr(e,3).toUpperCase()==="A/P"||t.substr(e,5).toUpperCase()==="AM/PM")return!0;++e;break;case"[":for(n=r;t.charAt(e++)!=="]"&&e<t.length;)n+=t.charAt(e);if(n.match(Ma))return!0;break;case".":case"0":case"#":for(;e<t.length&&("0#?.,E+-%".indexOf(r=t.charAt(++e))>-1||r=="\\"&&t.charAt(e+1)=="-"&&"0#".indexOf(t.charAt(e+2))>-1););break;case"?":for(;t.charAt(++e)===r;);break;case"*":++e,(t.charAt(e)===" "||t.charAt(e)==="*")&&++e;break;case"(":case")":++e;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(;e<t.length&&"0123456789".indexOf(t.charAt(++e))>-1;);break;case" ":++e;break;default:++e;break}return!1}ot.is_date=Ca;function wa(t,e,r,n){let o=[],s="",c=0,u="",i="t",a,l,f,p="H";for(;c<t.length;)switch(u=t.charAt(c)){case"G":if(!ro(t,c))throw new Error("unrecognized character "+u+" in "+t);o[o.length]={t:"G",v:"General"},c+=7;break;case'"':for(s="";(f=t.charCodeAt(++c))!==34&&c<t.length;)s+=String.fromCharCode(f);o[o.length]={t:"t",v:s},++c;break;case"\\":let y=t.charAt(++c),T=y==="("||y===")"?y:"t";o[o.length]={t:T,v:y},++c;break;case"_":o[o.length]={t:"t",v:" "},c+=2;break;case"@":o[o.length]={t:"T",v:e},++c;break;case"B":case"b":if(t.charAt(c+1)==="1"||t.charAt(c+1)==="2"){if(a==null&&(a=Tn(e,r,t.charAt(c+1)==="2"),a==null))return"";o[o.length]={t:"X",v:t.substr(c,2)},i=u,c+=2;break}case"M":case"D":case"Y":case"H":case"S":case"E":u=u.toLowerCase();case"m":case"d":case"y":case"h":case"s":case"e":case"g":if(e<0||a==null&&(a=Tn(e,r),a==null))return"";for(s=u;++c<t.length&&t.charAt(c).toLowerCase()===u;)s+=u;u==="m"&&i.toLowerCase()==="h"&&(u="M"),u==="h"&&(u=p),o[o.length]={t:u,v:s},i=u;break;case"A":case"a":let I={t:u,v:u};if(a==null&&(a=Tn(e,r)),t.substr(c,3).toUpperCase()==="A/P"?(a!=null&&(I.v=a.H>=12?"P":"A"),I.t="T",p="h",c+=3):t.substr(c,5).toUpperCase()==="AM/PM"?(a!=null&&(I.v=a.H>=12?"PM":"AM"),I.t="T",c+=5,p="h"):(I.t="t",++c),a==null&&I.t==="T")return"";o[o.length]=I,i=u;break;case"[":for(s=u;t.charAt(c++)!=="]"&&c<t.length;)s+=t.charAt(c);if(s.slice(-1)!=="]")throw'unterminated "[" block: |'+s+"|";if(s.match(Ma)){if(a==null&&(a=Tn(e,r),a==null))return"";o[o.length]={t:"Z",v:s.toLowerCase()},i=s.charAt(1)}else s.indexOf("$")>-1&&(s=(s.match(/\$([^-\[\]]*)/)||[])[1]||"$",Ca(t)||(o[o.length]={t:"t",v:s}));break;case".":if(a!=null){for(s=u;++c<t.length&&(u=t.charAt(c))==="0";)s+=u;o[o.length]={t:"s",v:s};break}case"0":case"#":for(s=u;++c<t.length&&"0#?.,E+-%".indexOf(u=t.charAt(c))>-1||u=="\\"&&t.charAt(c+1)=="-"&&c<t.length-2&&"0#".indexOf(t.charAt(c+2))>-1;)s+=u;o[o.length]={t:"n",v:s};break;case"?":for(s=u;t.charAt(++c)===u;)s+=u;o[o.length]={t:u,v:s},i=u;break;case"*":++c,(t.charAt(c)===" "||t.charAt(c)==="*")&&++c;break;case"(":case")":o[o.length]={t:n===1||typeof e=="number"&&e<0?"t":u,v:u},++c;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(s=u;c<t.length&&"0123456789".indexOf(t.charAt(++c))>-1;)s+=t.charAt(c);o[o.length]={t:"D",v:s};break;case" ":o[o.length]={t:u,v:u},++c;break;default:if(",$-+/():!^&'~{}<>=\u20ACacfijklopqrtuvwxzP".indexOf(u)===-1)throw new Error("unrecognized character "+u+" in "+t);o[o.length]={t:"t",v:u},++c;break}let d=0,h=0,m;for(c=o.length-1,i="t";c>=0;--c)switch(o[c].t){case"h":case"H":o[c].t=p,i="h",d<1&&(d=1);break;case"s":(m=o[c].v.match(/\.0+$/))&&(h=Math.max(h,m[0].length-1)),d<3&&(d=3);case"d":case"y":case"M":case"e":i=o[c].t;break;case"m":i==="s"&&(o[c].t="M",d<2&&(d=2));break;case"X":break;case"Z":d<1&&o[c].v.match(/[Hh]/)&&(d=1),d<2&&o[c].v.match(/[Mm]/)&&(d=2),d<3&&o[c].v.match(/[Ss]/)&&(d=3)}switch(d){case 0:break;case 1:a.u>=.5&&(a.u=0,++a.S),a.S>=60&&(a.S=0,++a.M),a.M>=60&&(a.M=0,++a.H);break;case 2:a.u>=.5&&(a.u=0,++a.S),a.S>=60&&(a.S=0,++a.M);break}let E="",g;for(c=0;c<o.length;++c)switch(o[c].t){case"t":case"T":case" ":case"D":break;case"X":o[c].v="",o[c].t=";";break;case"d":case"m":case"y":case"h":case"H":case"M":case"s":case"e":case"b":case"Z":o[c].v=sp(o[c].t.charCodeAt(0),o[c].v,a,h),o[c].t="t";break;case"n":case"(":case"?":for(g=c+1;o[g]!=null&&((u=o[g].t)==="?"||u==="D"||(u===" "||u==="t")&&o[g+1]!=null&&(o[g+1].t==="?"||o[g+1].t==="t"&&o[g+1].v==="/")||o[c].t==="("&&(u===" "||u==="n"||u===")")||u==="t"&&(o[g].v==="/"||o[g].v===" "&&o[g+1]!=null&&o[g+1].t==="?"));)o[c].v+=o[g].v,o[g]={v:"",t:";"},++g;E+=o[c].v,c=g-1;break;case"G":o[c].t="t",o[c].v=no(e,r);break}let v="",R,N;if(E.length>0){E.charCodeAt(0)===40?(R=e<0&&E.charCodeAt(0)===45?-e:e,N=lr("(",E,R)):(R=e<0&&n>1?-e:e,N=lr("n",E,R),R<0&&o[0]&&o[0].t==="t"&&(N=N.substr(1),o[0].v="-"+o[0].v)),g=N.length-1;let y=o.length;for(c=0;c<o.length;++c)if(o[c]!=null&&o[c].t!=="t"&&o[c].v.indexOf(".")>-1){y=c;break}let T=o.length;if(y===o.length&&N.indexOf("E")===-1){for(c=o.length-1;c>=0;--c)o[c]==null||"n?(".indexOf(o[c].t)===-1||(g>=o[c].v.length-1?(g-=o[c].v.length,o[c].v=N.substr(g+1,o[c].v.length)):g<0?o[c].v="":(o[c].v=N.substr(0,g+1),g=-1),o[c].t="t",T=c);g>=0&&T<o.length&&(o[T].v=N.substr(0,g+1)+o[T].v)}else if(y!==o.length&&N.indexOf("E")===-1){for(g=N.indexOf(".")-1,c=y;c>=0;--c)if(!(o[c]==null||"n?(".indexOf(o[c].t)===-1)){for(l=o[c].v.indexOf(".")>-1&&c===y?o[c].v.indexOf(".")-1:o[c].v.length-1,v=o[c].v.substr(l+1);l>=0;--l)g>=0&&(o[c].v.charAt(l)==="0"||o[c].v.charAt(l)==="#")&&(v=N.charAt(g--)+v);o[c].v=v,o[c].t="t",T=c}for(g>=0&&T<o.length&&(o[T].v=N.substr(0,g+1)+o[T].v),g=N.indexOf(".")+1,c=y;c<o.length;++c)if(!(o[c]==null||"n?(".indexOf(o[c].t)===-1&&c!==y)){for(l=o[c].v.indexOf(".")>-1&&c===y?o[c].v.indexOf(".")+1:0,v=o[c].v.substr(0,l);l<o[c].v.length;++l)g<N.length&&(v+=N.charAt(g++));o[c].v=v,o[c].t="t",T=c}}}for(c=0;c<o.length;++c)o[c]!=null&&"n(?".indexOf(o[c].t)>-1&&(R=n>1&&e<0&&c>0&&o[c-1].v==="-"?-e:e,o[c].v=lr(o[c].t,o[c].v,R),o[c].t="t");let A="";for(c=0;c!==o.length;++c)o[c]!=null&&(A+=o[c].v);return A}ot._eval=wa;var va=/\[[=<>]/,Ea=/\[([=<>]*)(-?\d+\.?\d*)\]/;function ya(t,e){if(e==null)return!1;let r=parseFloat(e[2]);switch(e[1]){case"=":if(t===r)return!0;break;case">":if(t>r)return!0;break;case"<":if(t<r)return!0;break;case"<>":if(t!==r)return!0;break;case">=":if(t>=r)return!0;break;case"<=":if(t<=r)return!0;break}return!1}function ap(t,e){let r=Ia(t),n=r.length,o=r[n-1].indexOf("@");if(n<4&&o>-1&&--n,r.length>4)throw new Error("cannot find right format for |"+r.join("|")+"|");if(typeof e!="number")return[4,r.length===4||o>-1?r[r.length-1]:"@"];switch(r.length){case 1:r=o>-1?["General","General","General",r[0]]:[r[0],r[0],r[0],"@"];break;case 2:r=o>-1?[r[0],r[0],r[0],r[1]]:[r[0],r[1],r[0],"@"];break;case 3:r=o>-1?[r[0],r[1],r[0],r[2]]:[r[0],r[1],r[2],"@"];break;case 4:break}let s=e>0?r[0]:e<0?r[1]:r[2];if(r[0].indexOf("[")===-1&&r[1].indexOf("[")===-1)return[n,s];if(r[0].match(va)!=null||r[1].match(va)!=null){let c=r[0].match(Ea),u=r[1].match(Ea);return ya(e,c)?[n,r[0]]:ya(e,u)?[n,r[1]]:[n,r[c!=null&&u!=null?2:1]]}return[n,s]}function _a(t,e,r){r==null&&(r={});let n="";switch(typeof t){case"string":t==="m/d/yy"&&r.dateNF?n=r.dateNF:n=t;break;case"number":t===14&&r.dateNF?n=r.dateNF:n=(r.table!=null?r.table:Br)[t];break}if(ro(n,0))return no(e,r);e instanceof Date&&(e=Aa(e,r.date1904));let o=ap(n,e);if(ro(o[1]))return no(e,r);if(e===!0)e="TRUE";else if(e===!1)e="FALSE";else if(e===""||e==null)return"";return wa(o[1],e,r,o[0])}function ka(t,e){if(typeof e!="number"){e=+e||-1;for(let r=0;r<392;++r){if(Br[r]===void 0){e<0&&(e=r);continue}if(Br[r]===t){e=r;break}}e<0&&(e=391)}return Br[e]=t,e}ot.load=ka;ot._table=Br;ot.get_table=function(){return Br};ot.load_table=function(e){for(let r=0;r!==392;++r)e[r]!==void 0&&ka(e[r],r)};ot.init_table=Ra;ot.format=_a;ba.exports=ot});var Ua=D((lv,oo)=>{var La="\u0E28\u0E39\u0E19\u0E22\u0E4C\u0E1A\u0E32\u0E17\u0E16\u0E49\u0E27\u0E19",up=["","\u0E2B\u0E19\u0E36\u0E48\u0E07","\u0E2A\u0E2D\u0E07","\u0E2A\u0E32\u0E21","\u0E2A\u0E35\u0E48","\u0E2B\u0E49\u0E32","\u0E2B\u0E01","\u0E40\u0E08\u0E47\u0E14","\u0E41\u0E1B\u0E14","\u0E40\u0E01\u0E49\u0E32"],cp=["","\u0E2A\u0E34\u0E1A","\u0E23\u0E49\u0E2D\u0E22","\u0E1E\u0E31\u0E19","\u0E2B\u0E21\u0E37\u0E48\u0E19","\u0E41\u0E2A\u0E19","\u0E25\u0E49\u0E32\u0E19"];function io(t){let e="",r=t.length,n=7;if(r>n){let o=r-n+1,s=t.slice(0,o),c=t.slice(o);return io(s)+"\u0E25\u0E49\u0E32\u0E19"+io(c)}else for(let o=0;o<r;o++){let s=t[o];s>0&&(e+=up[s]+cp[r-o-1])}return e}function xa(t){let e=t;e=e.replace("\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E2A\u0E34\u0E1A","\u0E2A\u0E34\u0E1A"),e=e.replace("\u0E2A\u0E2D\u0E07\u0E2A\u0E34\u0E1A","\u0E22\u0E35\u0E48\u0E2A\u0E34\u0E1A");let r=5;return e.length>r&&e.length-e.lastIndexOf("\u0E2B\u0E19\u0E36\u0E48\u0E07")===r&&(e=e.substr(0,e.length-r)+"\u0E40\u0E2D\u0E47\u0E14"),e}function lp(t,e){let r="";return t===""&&e===""?r=La:t!==""&&e===""?r=t+"\u0E1A\u0E32\u0E17\u0E16\u0E49\u0E27\u0E19":t===""&&e!==""?r=e+"\u0E2A\u0E15\u0E32\u0E07\u0E04\u0E4C":r=t+"\u0E1A\u0E32\u0E17"+e+"\u0E2A\u0E15\u0E32\u0E07\u0E04\u0E4C",r}function fp(t){let e=La;if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return e;let r=Math.floor(t).toString(),n=Math.round(t%1*100).toString(),o=Array.from(r).map(Number),s=Array.from(n).map(Number),c=io(o),u=io(s);return c=xa(c),u=xa(u),e=lp(c,u),e}typeof oo<"u"&&oo.exports!=null&&(oo.exports=fp)});var Ei=D((fv,Da)=>{var pt=qe(),{FormulaHelpers:hp,Types:J,WildCard:Pa}=$e(),Q=hp,vi=gi(),pp=Ua(),Sa={latin:{halfRE:/[!-~]/g,fullRE:/[!-~]/g,delta:65248},hangul1:{halfRE:/[ᄀ-ᄒ]/g,fullRE:/[ᆨ-ᇂ]/g,delta:-60921},hangul2:{halfRE:/[ᅡ-ᅵ]/g,fullRE:/[ᅡ-ᅵ]/g,delta:-61025},kana:{delta:0,half:"\uFF61\uFF62\uFF63\uFF64\uFF65\uFF66\uFF67\uFF68\uFF69\uFF6A\uFF6B\uFF6C\uFF6D\uFF6E\uFF6F\uFF70\uFF71\uFF72\uFF73\uFF74\uFF75\uFF76\uFF77\uFF78\uFF79\uFF7A\uFF7B\uFF7C\uFF7D\uFF7E\uFF7F\uFF80\uFF81\uFF82\uFF83\uFF84\uFF85\uFF86\uFF87\uFF88\uFF89\uFF8A\uFF8B\uFF8C\uFF8D\uFF8E\uFF8F\uFF90\uFF91\uFF92\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98\uFF99\uFF9A\uFF9B\uFF9C\uFF9D\uFF9E\uFF9F",full:"\u3002\u300C\u300D\u3001\u30FB\u30F2\u30A1\u30A3\u30A5\u30A7\u30A9\u30E3\u30E5\u30E7\u30C3\u30FC\u30A2\u30A4\u30A6\u30A8\u30AA\u30AB\u30AD\u30AF\u30B1\u30B3\u30B5\u30B7\u30B9\u30BB\u30BD\u30BF\u30C1\u30C4\u30C6\u30C8\u30CA\u30CB\u30CC\u30CD\u30CE\u30CF\u30D2\u30D5\u30D8\u30DB\u30DE\u30DF\u30E0\u30E1\u30E2\u30E4\u30E6\u30E8\u30E9\u30EA\u30EB\u30EC\u30ED\u30EF\u30F3\u309B\u309C"},extras:{delta:0,half:"\xA2\xA3\xAC\xAF\xA6\xA5\u20A9 |\u2190\u2191\u2192\u2193\u25A0\xB0",full:"\uFFE0\uFFE1\uFFE2\uFFE3\uFFE4\uFFE5\uFFE6\u3000\uFFE8\uFFE9\uFFEA\uFFEB\uFFEC\uFFED\uFFEE"}},dp=t=>e=>t.delta?String.fromCharCode(e.charCodeAt(0)+t.delta):[...t.full][[...t.half].indexOf(e)],mp=t=>e=>t.delta?String.fromCharCode(e.charCodeAt(0)-t.delta):[...t.half][[...t.full].indexOf(e)],Fa=(t,e)=>t[e+"RE"]||new RegExp("["+t[e]+"]","g"),Ba=Object.keys(Sa).map(t=>Sa[t]),gp=t=>Ba.reduce((e,r)=>e.replace(Fa(r,"half"),dp(r)),t),vp=t=>Ba.reduce((e,r)=>e.replace(Fa(r,"full"),mp(r)),t),fr={ASC:t=>(t=Q.accept(t,J.STRING),vp(t)),BAHTTEXT:t=>{t=Q.accept(t,J.NUMBER);try{return pp(t)}catch(e){throw Error(`Error in https://github.com/jojoee/bahttext
8
+ ${e.toString()}`)}},CHAR:t=>{if(t=Q.accept(t,J.NUMBER),t>255||t<1)throw pt.VALUE;return String.fromCharCode(t)},CLEAN:t=>(t=Q.accept(t,J.STRING),t.replace(/[\x00-\x1F]/g,"")),CODE:t=>{if(t=Q.accept(t,J.STRING),t.length===0)throw pt.VALUE;return t.charCodeAt(0)},CONCAT:(...t)=>{let e="";return Q.flattenParams(t,J.STRING,!1,r=>{r=Q.accept(r,J.STRING),e+=r}),e},CONCATENATE:(...t)=>{let e="";if(t.length===0)throw Error("CONCATENATE need at least one argument.");return t.forEach(r=>{r=Q.accept(r,J.STRING),e+=r}),e},DBCS:t=>(t=Q.accept(t,J.STRING),gp(t)),DOLLAR:(t,e)=>{t=Q.accept(t,J.NUMBER),e=Q.accept(e,J.NUMBER,2);let r=Array(e).fill("0").join("");return vi.format(`$#,##0.${r}_);($#,##0.${r})`,t).trim()},EXACT:(t,e)=>(t=Q.accept(t,[J.STRING]),e=Q.accept(e,[J.STRING]),t===e),FIND:(t,e,r)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.STRING),r=Q.accept(r,J.NUMBER,1),r<1||r>e.length)throw pt.VALUE;let n=e.indexOf(t,r-1);if(n===-1)throw pt.VALUE;return n+1},FINDB:(...t)=>fr.FIND(...t),FIXED:(t,e,r)=>{t=Q.accept(t,J.NUMBER),e=Q.accept(e,J.NUMBER,2),r=Q.accept(r,J.BOOLEAN,!1);let n=Array(e).fill("0").join(""),o=r?"":"#,";return vi.format(`${o}##0.${n}_);(${o}##0.${n})`,t).trim()},LEFT:(t,e)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.NUMBER,1),e<0)throw pt.VALUE;return e>t.length?t:t.slice(0,e)},LEFTB:(...t)=>fr.LEFT(...t),LEN:t=>(t=Q.accept(t,J.STRING),t.length),LENB:(...t)=>fr.LEN(...t),LOWER:t=>(t=Q.accept(t,J.STRING),t.toLowerCase()),MID:(t,e,r)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.NUMBER),r=Q.accept(r,J.NUMBER),e>t.length)return"";if(e<1||r<1)throw pt.VALUE;return t.slice(e-1,e+r-1)},MIDB:(...t)=>fr.MID(...t),NUMBERVALUE:(t,e,r)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.STRING,"."),r=Q.accept(r,J.STRING,","),t.length===0)return 0;if(e.length===0||r.length===0||(e=e[0],r=r[0],e===r||t.indexOf(e)<t.lastIndexOf(r)))throw pt.VALUE;let n=t.replace(r,"").replace(e,".").replace(/[^\-0-9.%()]/g,"").match(/([(-]*)([0-9]*[.]*[0-9]+)([)]?)([%]*)/);if(!n)throw pt.VALUE;let o=n[1].length,s=n[3].length,c=n[4].length,u=Number(n[2]);if(o>1||o&&!s||!o&&s||isNaN(u))throw pt.VALUE;return u=u/100**c,o?-u:u},PHONETIC:()=>{},PROPER:t=>(t=Q.accept(t,[J.STRING]),t=t.toLowerCase(),t=t.charAt(0).toUpperCase()+t.slice(1),t.replace(/(?:[^a-zA-Z])([a-zA-Z])/g,e=>e.toUpperCase())),REPLACE:(t,e,r,n)=>{t=Q.accept(t,[J.STRING]),e=Q.accept(e,[J.NUMBER]),r=Q.accept(r,[J.NUMBER]),n=Q.accept(n,[J.STRING]);let o=t.split("");return o.splice(e-1,r,n),o.join("")},REPLACEB:(...t)=>fr.REPLACE(...t),REPT:(t,e)=>{t=Q.accept(t,J.STRING),e=Q.accept(e,J.NUMBER);let r="";for(let n=0;n<e;n++)r+=t;return r},RIGHT:(t,e)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.NUMBER,1),e<0)throw pt.VALUE;let r=t.length;return e>r?t:t.slice(r-e)},RIGHTB:(...t)=>fr.RIGHT(...t),SEARCH:(t,e,r)=>{if(t=Q.accept(t,J.STRING),e=Q.accept(e,J.STRING),r=Q.accept(r,J.NUMBER,1),r<1||r>e.length)throw pt.VALUE;let n=Pa.isWildCard(t)?Pa.toRegex(t,"i"):t,o=e.slice(r-1).search(n);if(o===-1)throw pt.VALUE;return o+r},SEARCHB:(...t)=>fr.SEARCH(...t),SUBSTITUTE:(...t)=>{},T:t=>(t=Q.accept(t),typeof t=="string"?t:""),TEXT:(t,e)=>{t=Q.accept(t,J.NUMBER),e=Q.accept(e,J.STRING);try{return vi.format(e,t)}catch(r){throw console.error(r),pt.VALUE}},TEXTJOIN:(...t)=>{},TRIM:t=>(t=Q.accept(t,[J.STRING]),t.replace(/^\s+|\s+$/g,"")),UNICHAR:t=>{if(t=Q.accept(t,[J.NUMBER]),t<=0)throw pt.VALUE;return String.fromCharCode(t)},UNICODE:t=>fr.CODE(t)};Da.exports=fr});var In=D((hv,Wa)=>{var On=qe(),{FormulaHelpers:so}=$e(),Ep={unaryOp:(t,e,r)=>{let n=1;if(t.forEach(o=>{if(o!=="+")if(o==="-")n=-n;else throw new Error(`Unrecognized prefix: ${o}`)}),e==null&&(e=0),n===1)return e;try{e=so.acceptNumber(e,r)}catch(o){if(o instanceof On)Array.isArray(e)&&(e=e[0][0]);else throw o}return typeof e=="number"&&isNaN(e)?On.VALUE:-e}},yp={percentOp:(t,e,r)=>{try{t=so.acceptNumber(t,r)}catch(n){if(n instanceof On)return n;throw n}if(e==="%")return t/100;throw new Error(`Unrecognized postfix: ${e}`)}},Ir={boolean:3,string:2,number:1},Rp={compareOp:(t,e,r,n,o)=>{t==null&&(t=0),r==null&&(r=0),n&&(t=t[0][0]),o&&(r=r[0][0]);let s=typeof t,c=typeof r;if(s===c)switch(e){case"=":return t===r;case">":return t>r;case"<":return t<r;case"<>":return t!==r;case"<=":return t<=r;case">=":return t>=r}else switch(e){case"=":return!1;case">":return Ir[s]>Ir[c];case"<":return Ir[s]<Ir[c];case"<>":return!0;case"<=":return Ir[s]<=Ir[c];case">=":return Ir[s]>=Ir[c]}throw Error("Infix.compareOp: Should not reach here.")},concatOp:(t,e,r,n,o)=>{t==null&&(t=""),r==null&&(r=""),n&&(t=t[0][0]),o&&(r=r[0][0]);let s=typeof t,c=typeof r;return s==="boolean"&&(t=t?"TRUE":"FALSE"),c==="boolean"&&(r=r?"TRUE":"FALSE"),""+t+r},mathOp:(t,e,r,n,o)=>{t==null&&(t=0),r==null&&(r=0);try{t=so.acceptNumber(t,n),r=so.acceptNumber(r,o)}catch(s){if(s instanceof On)return s;throw s}switch(e){case"+":return t+r;case"-":return t-r;case"*":return t*r;case"/":return r===0?On.DIV0:t/r;case"^":return t**r}throw Error("Infix.mathOp: Should not reach here.")}};Wa.exports={Prefix:Ep,Postfix:yp,Infix:Rp,Operators:{compareOp:["<",">","=","<>","<=",">="],concatOp:["&"],mathOp:["+","-","*","/","^"]}}});var Ni=D((pv,qa)=>{var de=qe(),{FormulaHelpers:Np,Types:B,Factorials:Va,Criteria:Ap}=$e(),{Infix:Tp}=In(),U=Np,yi=[],Ri=[];function ao(t){return t<=100?Va[t]:yi[t]>0?yi[t]:yi[t]=ao(t-1)*t}function Ga(t){return t===1||t===0?1:t===2?2:Ri[t]>0?Ri[t]:Ri[t]=Ga(t-2)*t}var Rt={ABS:t=>(t=U.accept(t,B.NUMBER),Math.abs(t)),AGGREGATE:(t,e,r,...n)=>{},ARABIC:t=>{if(t=U.accept(t,B.STRING).toUpperCase(),!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(t))throw new de("#VALUE!","Invalid roman numeral in ARABIC evaluation.");let e=0;return t.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,function(r){e+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[r]}),e},BASE:(t,e,r)=>{if(t=U.accept(t,B.NUMBER),t<0||t>=2**53||(e=U.accept(e,B.NUMBER),e<2||e>36)||(r=U.accept(r,B.NUMBER,0),r<0))throw de.NUM;let n=t.toString(e).toUpperCase();return new Array(Math.max(r+1-n.length,0)).join("0")+n},CEILING:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),e===0)return 0;if(t/e%1===0)return t;let r=Math.abs(e),n=Math.floor(Math.abs(t)/r);return t<0?e<0?-r*(n+1):-r*n:(n+1)*r},"CEILING.MATH":(t,e,r)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,t>0?1:-1),r=U.accept(r,B.NUMBER,0),t>=0)return Rt.CEILING(t,e);let n=r?e:0;return Rt.CEILING(t,e)-n},"CEILING.PRECISE":(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,1),Rt.CEILING(t,Math.abs(e))),COMBIN:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),t<0||e<0||t<e)throw de.NUM;let r=Rt.FACT(t),n=Rt.FACT(e);return r/n/Rt.FACT(t-e)},COMBINA:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),(t===0||t===1)&&e===0)return 1;if(t<0||e<0)throw de.NUM;return Rt.COMBIN(t+e-1,t-1)},DECIMAL:(t,e)=>{if(t=U.accept(t,B.STRING),e=U.accept(e,B.NUMBER),e=Math.trunc(e),e<2||e>36)throw de.NUM;let r=parseInt(t,e);if(isNaN(r))throw de.NUM;return r},DEGREES:t=>(t=U.accept(t,B.NUMBER),t*(180/Math.PI)),EVEN:t=>Rt.CEILING(t,-2),EXP:t=>(t=U.accept(t,B.NUMBER),Math.exp(t)),FACT:t=>{if(t=U.accept(t,B.NUMBER),t=Math.trunc(t),t>170||t<0)throw de.NUM;return t<=100?Va[t]:ao(t)},FACTDOUBLE:t=>{if(t=U.accept(t,B.NUMBER),t=Math.trunc(t),t<-1)throw de.NUM;return t===-1?1:Ga(t)},FLOOR:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),e===0)return 0;if(t>0&&e<0)throw de.NUM;if(t/e%1===0)return t;let r=Math.abs(e),n=Math.floor(Math.abs(t)/r);return t<0?e<0?-r*n:-r*(n+1):n*r},"FLOOR.MATH":(t,e,r)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,t>0?1:-1),r=U.accept(r,B.NUMBER,0),r===0||t>=0?Rt.FLOOR(t,Math.abs(e)):Rt.FLOOR(t,e)+e),"FLOOR.PRECISE":(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,1),Rt.FLOOR(t,Math.abs(e))),GCD:(...t)=>{let e=[];U.flattenParams(t,null,!1,c=>{if(c=typeof c=="boolean"?NaN:Number(c),isNaN(c))throw de.VALUE;if(c<0||c>9007199254740990)throw de.NUM;e.push(Math.trunc(c))},0);let r,n,o=t.length,s=Math.abs(e[0]);for(r=1;r<o;r++){for(n=Math.abs(e[r]);s&&n;)s>n?s%=n:n%=s;s+=n}return s},INT:t=>(t=U.accept(t,B.NUMBER),Math.floor(t)),"ISO.CEILING":(...t)=>Rt["CEILING.PRECISE"](...t),LCM:(...t)=>{let e=[];U.flattenParams(t,null,!1,o=>{if(o=typeof o=="boolean"?NaN:Number(o),isNaN(o))throw de.VALUE;if(o<0||o>9007199254740990)throw de.NUM;e.push(Math.trunc(o))},1);let r=e.length,n=Math.abs(e[0]);for(let o=1;o<r;o++){let s=Math.abs(e[o]),c=n;for(;n&&s;)n>s?n%=s:s%=n;n=Math.abs(c*e[o])/(n+s)}return n},LN:t=>(t=U.accept(t,B.NUMBER),Math.log(t)),LOG:(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,10),Math.log(t)/Math.log(e)),LOG10:t=>(t=U.accept(t,B.NUMBER),Math.log10(t)),MDETERM:t=>{if(t=U.accept(t,B.ARRAY,void 0,!1,!0),t[0].length!==t.length)throw de.VALUE;let e=t.length,r=t[0].length,n=0,o,s;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(let c=0;c<r;c++){o=t[0][c],s=t[0][c];for(let u=1;u<e;u++)s*=t[u][((c+u)%r+r)%r],o*=t[u][((c-u)%r+r)%r];n+=s-o}return n},MINVERSE:t=>{},MMULT:(t,e)=>{t=U.accept(t,B.ARRAY,void 0,!1,!0),e=U.accept(e,B.ARRAY,void 0,!1,!0);let r=t.length,n=t[0].length,o=e.length,s=e[0].length,c=new Array(r);if(n!==o)throw de.VALUE;for(let u=0;u<r;u++){c[u]=new Array(s);for(let i=0;i<s;i++){c[u][i]=0;for(let a=0;a<n;a++){let l=t[u][a],f=e[a][i];if(typeof l!="number"||typeof f!="number")throw de.VALUE;c[u][i]+=t[u][a]*e[a][i]}}}return c},MOD:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),e===0)throw de.DIV0;return t-e*Rt.INT(t/e)},MROUND:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),e===0)return 0;if(t>0&&e<0||t<0&&e>0)throw de.NUM;return t/e%1===0?t:Math.round(t/e)*e},MULTINOMIAL:(...t)=>{let e=0,r=1;return U.flattenParams(t,B.NUMBER,!1,n=>{if(n<0)throw de.NUM;e+=n,r*=ao(n)}),ao(e)/r},MUNIT:t=>{t=U.accept(t,B.NUMBER);let e=[];for(let r=0;r<t;r++){let n=[];for(let o=0;o<t;o++)r===o?n.push(1):n.push(0);e.push(n)}return e},ODD:t=>{if(t=U.accept(t,B.NUMBER),t===0)return 1;let e=Math.ceil(Math.abs(t));return e=e&1?e:e+1,t>0?e:-e},PI:()=>Math.PI,POWER:(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),t**e),PRODUCT:(...t)=>{let e=1;return U.flattenParams(t,null,!0,(r,n)=>{let o=Number(r);n.isLiteral&&!isNaN(o)?e*=o:typeof r=="number"&&(e*=r)},1),e},QUOTIENT:(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),Math.trunc(t/e)),RADIANS:t=>(t=U.accept(t,B.NUMBER),t/180*Math.PI),RAND:()=>Math.random(),RANDBETWEEN:(t,e)=>(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),Math.floor(Math.random()*(e-t+1)+t)),ROMAN:(t,e)=>{if(t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER,0),e!==0)throw Error("ROMAN: only allows form=0 (classic form).");let r=String(t).split(""),n=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],o="",s=3;for(;s--;)o=(n[+r.pop()+s*10]||"")+o;return new Array(+r.join("")+1).join("M")+o},ROUND:(t,e)=>{t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER);let r=Math.pow(10,Math.abs(e)),n=t>0?1:-1;return e>0?n*Math.round(Math.abs(t)*r)/r:e===0?n*Math.round(Math.abs(t)):n*Math.round(Math.abs(t)/r)*r},ROUNDDOWN:(t,e)=>{t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER);let r=Math.pow(10,Math.abs(e)),n=t>0?1:-1;if(e>0){let o=1/r*.5;return n*Math.round((Math.abs(t)-o)*r)/r}else{if(e===0)return n*Math.round(Math.abs(t)-.5);{let o=r*.5;return n*Math.round((Math.abs(t)-o)/r)*r}}},ROUNDUP:(t,e)=>{t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER);let r=Math.pow(10,Math.abs(e)),n=t>0?1:-1;if(e>0){let o=1/r*.5;return n*Math.round((Math.abs(t)+o)*r)/r}else{if(e===0)return n*Math.round(Math.abs(t)+.5);{let o=r*.5;return n*Math.round((Math.abs(t)+o)/r)*r}}},SERIESSUM:(t,e,r,n)=>{t=U.accept(t,B.NUMBER),e=U.accept(e,B.NUMBER),r=U.accept(r,B.NUMBER);let o=0,s;return U.flattenParams([n],B.NUMBER,!1,c=>{if(typeof c!="number")throw de.VALUE;o===0?s=c*Math.pow(t,e):s+=c*Math.pow(t,e+o*r),o++}),s},SIGN:t=>(t=U.accept(t,B.NUMBER),t>0?1:t===0?0:-1),SQRT:t=>{if(t=U.accept(t,B.NUMBER),t<0)throw de.NUM;return Math.sqrt(t)},SQRTPI:t=>{if(t=U.accept(t,B.NUMBER),t<0)throw de.NUM;return Math.sqrt(t*Math.PI)},SUBTOTAL:()=>{},SUM:(...t)=>{let e=0;return U.flattenParams(t,B.NUMBER,!0,(r,n)=>{(n.isLiteral||typeof r=="number")&&(e+=r)}),e},SUMIF:(t,e,r,n)=>{let o=U.retrieveRanges(t,e,n);e=o[0],n=o[1],r=U.retrieveArg(t,r);let s=r.isArray;r=Ap.parse(U.accept(r));let c=0;return e.forEach((u,i)=>{u.forEach((a,l)=>{let f=n[i][l];typeof f=="number"&&(r.op==="wc"?r.match===r.value.test(a)&&(c+=f):Tp.compareOp(a,r.op,r.value,Array.isArray(a),s)&&(c+=f))})}),c},SUMIFS:()=>{},SUMPRODUCT:(t,...e)=>{t=U.accept(t,B.ARRAY,void 0,!1,!0),e.forEach(n=>{if(n=U.accept(n,B.ARRAY,void 0,!1,!0),t[0].length!==n[0].length||t.length!==n.length)throw de.VALUE;for(let o=0;o<t.length;o++)for(let s=0;s<t[0].length;s++)typeof t[o][s]!="number"&&(t[o][s]=0),typeof n[o][s]!="number"&&(n[o][s]=0),t[o][s]*=n[o][s]});let r=0;return t.forEach(n=>{n.forEach(o=>{r+=o})}),r},SUMSQ:(...t)=>{let e=0;return U.flattenParams(t,B.NUMBER,!0,(r,n)=>{(n.isLiteral||typeof r=="number")&&(e+=r**2)}),e},SUMX2MY2:(t,e)=>{let r=[],n=[],o=0;if(U.flattenParams([t],null,!1,(s,c)=>{r.push(s)}),U.flattenParams([e],null,!1,(s,c)=>{n.push(s)}),r.length!==n.length)throw de.NA;for(let s=0;s<r.length;s++)typeof r[s]=="number"&&typeof n[s]=="number"&&(o+=r[s]**2-n[s]**2);return o},SUMX2PY2:(t,e)=>{let r=[],n=[],o=0;if(U.flattenParams([t],null,!1,(s,c)=>{r.push(s)}),U.flattenParams([e],null,!1,(s,c)=>{n.push(s)}),r.length!==n.length)throw de.NA;for(let s=0;s<r.length;s++)typeof r[s]=="number"&&typeof n[s]=="number"&&(o+=r[s]**2+n[s]**2);return o},SUMXMY2:(t,e)=>{let r=[],n=[],o=0;if(U.flattenParams([t],null,!1,(s,c)=>{r.push(s)}),U.flattenParams([e],null,!1,(s,c)=>{n.push(s)}),r.length!==n.length)throw de.NA;for(let s=0;s<r.length;s++)typeof r[s]=="number"&&typeof n[s]=="number"&&(o+=(r[s]-n[s])**2);return o},TRUNC:t=>(t=U.accept(t,B.NUMBER),Math.trunc(t))};qa.exports=Rt});var za=D((dv,Ha)=>{var dt=qe(),{FormulaHelpers:Op,Types:Ue}=$e(),Pe=Op,tn=2**27-1,Ip={ACOS:t=>{if(t=Pe.accept(t,Ue.NUMBER),t>1||t<-1)throw dt.NUM;return Math.acos(t)},ACOSH:t=>{if(t=Pe.accept(t,Ue.NUMBER),t<1)throw dt.NUM;return Math.acosh(t)},ACOT:t=>(t=Pe.accept(t,Ue.NUMBER),Math.PI/2-Math.atan(t)),ACOTH:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)<=1)throw dt.NUM;return Math.atanh(1/t)},ASIN:t=>{if(t=Pe.accept(t,Ue.NUMBER),t>1||t<-1)throw dt.NUM;return Math.asin(t)},ASINH:t=>(t=Pe.accept(t,Ue.NUMBER),Math.asinh(t)),ATAN:t=>(t=Pe.accept(t,Ue.NUMBER),Math.atan(t)),ATAN2:(t,e)=>{if(t=Pe.accept(t,Ue.NUMBER),e=Pe.accept(e,Ue.NUMBER),e===0&&t===0)throw dt.DIV0;return Math.atan2(e,t)},ATANH:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>1)throw dt.NUM;return Math.atanh(t)},COS:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;return Math.cos(t)},COSH:t=>(t=Pe.accept(t,Ue.NUMBER),Math.cosh(t)),COT:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;if(t===0)throw dt.DIV0;return 1/Math.tan(t)},COTH:t=>{if(t=Pe.accept(t,Ue.NUMBER),t===0)throw dt.DIV0;return 1/Math.tanh(t)},CSC:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;return 1/Math.sin(t)},CSCH:t=>{if(t=Pe.accept(t,Ue.NUMBER),t===0)throw dt.DIV0;return 1/Math.sinh(t)},SEC:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;return 1/Math.cos(t)},SECH:t=>(t=Pe.accept(t,Ue.NUMBER),1/Math.cosh(t)),SIN:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;return Math.sin(t)},SINH:t=>(t=Pe.accept(t,Ue.NUMBER),Math.sinh(t)),TAN:t=>{if(t=Pe.accept(t,Ue.NUMBER),Math.abs(t)>tn)throw dt.NUM;return Math.tan(t)},TANH:t=>(t=Pe.accept(t,Ue.NUMBER),Math.tanh(t))};Ha.exports=Ip});var $a=D((mv,Ya)=>{var Mr=qe(),{FormulaHelpers:Mp,Types:Ai}=$e(),Gt=Mp;function Ti(t){let e=0,r=0;return Gt.flattenParams(t,null,!0,n=>{let o=typeof n;o==="string"?n==="TRUE"?n=!0:n==="FALSE"&&(n=!1):o==="number"&&(n=!!n),typeof n=="boolean"&&(n===!0?e++:r++)}),[e,r]}var Cp={AND:(...t)=>{let[e,r]=Ti(t);return e===0&&r===0?Mr.VALUE:e>0&&r===0},FALSE:()=>!1,IF:(t,e,r,n)=>(e=Gt.accept(e,Ai.BOOLEAN),r=Gt.accept(r),n=Gt.accept(n,null,!1),e?r:n),IFERROR:(t,e)=>t.value instanceof Mr?Gt.accept(e):Gt.accept(t),IFNA:function(t,e){if(arguments.length>2)throw Mr.TOO_MANY_ARGS("IFNA");return Mr.NA.equals(t.value)?Gt.accept(e):Gt.accept(t)},IFS:(...t)=>{if(t.length%2!==0)return new Mr("#N/A","IFS expects all arguments after position 0 to be in pairs.");for(let e=0;e<t.length/2;e++){let r=Gt.accept(t[e*2],Ai.BOOLEAN),n=Gt.accept(t[e*2+1]);if(r)return n}return Mr.NA},NOT:t=>(t=Gt.accept(t,Ai.BOOLEAN),!t),OR:(...t)=>{let[e,r]=Ti(t);return e===0&&r===0?Mr.VALUE:e>0},SWITCH:(...t)=>{},TRUE:()=>!0,XOR:(...t)=>{let[e,r]=Ti(t);return e===0&&r===0?Mr.VALUE:e%2===1}};Ya.exports=Cp});var Xa=D(Oi=>{var Ka;(function(t){typeof DO_NOT_EXPORT_BESSEL>"u"?typeof Oi=="object"?t(Oi):typeof define=="function"&&define.amd?define(function(){var e={};return t(e),e}):t(Ka={}):t(Ka={})})(function(t){t.version="1.0.2";var e=Math;function r(a,l){for(var f=0,p=0;f<a.length;++f)p=l*p+a[f];return p}function n(a,l,f,p,d){if(l===0)return f;if(l===1)return p;for(var h=2/a,m=p,E=1;E<l;++E)m=p*E*h+d*f,f=p,p=m;return m}function o(a,l,f,p,d){return function(m,E){if(p){if(m===0)return p==1?-1/0:1/0;if(m<0)return NaN}if(E===0)return a(m);if(E===1)return l(m);if(E<0)return NaN;E|=0;var g=a(m),v=l(m);return n(m,E,g,v,d)}}var s=(function(){var a=.636619772,l=[57568490574,-13362590354,6516196407e-1,-1121442418e-2,77392.33017,-184.9052456].reverse(),f=[57568490411,1029532985,9494680718e-3,59272.64853,267.8532712,1].reverse(),p=[1,-.001098628627,2734510407e-14,-2073370639e-15,2093887211e-16].reverse(),d=[-.01562499995,.0001430488765,-6911147651e-15,7621095161e-16,-934935152e-16].reverse();function h(N){var A=0,y=0,T=0,I=N*N;if(N<8)y=r(l,I),T=r(f,I),A=y/T;else{var M=N-.785398164;I=64/I,y=r(p,I),T=r(d,I),A=e.sqrt(a/N)*(e.cos(M)*y-e.sin(M)*T*8/N)}return A}var m=[72362614232,-7895059235,2423968531e-1,-2972611439e-3,15704.4826,-30.16036606].reverse(),E=[144725228442,2300535178,1858330474e-2,99447.43394,376.9991397,1].reverse(),g=[1,.00183105,-3516396496e-14,2457520174e-15,-240337019e-15].reverse(),v=[.04687499995,-.0002002690873,8449199096e-15,-88228987e-14,105787412e-15].reverse();function R(N){var A=0,y=0,T=0,I=N*N,M=e.abs(N)-2.356194491;return Math.abs(N)<8?(y=N*r(m,I),T=r(E,I),A=y/T):(I=64/I,y=r(g,I),T=r(v,I),A=e.sqrt(a/e.abs(N))*(e.cos(M)*y-e.sin(M)*T*8/e.abs(N)),N<0&&(A=-A)),A}return function N(A,y){if(y=Math.round(y),!isFinite(A))return isNaN(A)?A:0;if(y<0)return(y%2?-1:1)*N(A,-y);if(A<0)return(y%2?-1:1)*N(-A,y);if(y===0)return h(A);if(y===1)return R(A);if(A===0)return 0;var T=0;if(A>y)T=n(A,y,h(A),R(A),-1);else{for(var I=2*e.floor((y+e.floor(e.sqrt(40*y)))/2),M=!1,b=0,S=0,G=1,j=0,$=2/A,W=I;W>0;W--)j=W*$*G-b,b=G,G=j,e.abs(G)>1e10&&(G*=1e-10,b*=1e-10,T*=1e-10,S*=1e-10),M&&(S+=G),M=!M,W==y&&(T=b);S=2*S-G,T/=S}return T}})(),c=(function(){var a=.636619772,l=[-2957821389,7062834065,-5123598036e-1,1087988129e-2,-86327.92757,228.4622733].reverse(),f=[40076544269,7452499648e-1,7189466438e-3,47447.2647,226.1030244,1].reverse(),p=[1,-.001098628627,2734510407e-14,-2073370639e-15,2093887211e-16].reverse(),d=[-.01562499995,.0001430488765,-6911147651e-15,7621095161e-16,-934945152e-16].reverse();function h(N){var A=0,y=0,T=0,I=N*N,M=N-.785398164;return N<8?(y=r(l,I),T=r(f,I),A=y/T+a*s(N,0)*e.log(N)):(I=64/I,y=r(p,I),T=r(d,I),A=e.sqrt(a/N)*(e.sin(M)*y+e.cos(M)*T*8/N)),A}var m=[-4900604943e3,127527439e4,-51534381390,7349264551e-1,-4237922726e-3,8511.937935].reverse(),E=[249958057e5,424441966400,3733650367,2245904002e-2,102042.605,354.9632885,1].reverse(),g=[1,.00183105,-3516396496e-14,2457520174e-15,-240337019e-15].reverse(),v=[.04687499995,-.0002002690873,8449199096e-15,-88228987e-14,105787412e-15].reverse();function R(N){var A=0,y=0,T=0,I=N*N,M=N-2.356194491;return N<8?(y=N*r(m,I),T=r(E,I),A=y/T+a*(s(N,1)*e.log(N)-1/N)):(I=64/I,y=r(g,I),T=r(v,I),A=e.sqrt(a/N)*(e.sin(M)*y+e.cos(M)*T*8/N)),A}return o(h,R,"BESSELY",1,-1)})(),u=(function(){var a=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),l=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse();function f(m){return m<=3.75?r(a,m*m/(3.75*3.75)):e.exp(e.abs(m))/e.sqrt(e.abs(m))*r(l,3.75/e.abs(m))}var p=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),d=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse();function h(m){return m<3.75?m*r(p,m*m/(3.75*3.75)):(m<0?-1:1)*e.exp(e.abs(m))/e.sqrt(e.abs(m))*r(d,3.75/e.abs(m))}return function m(E,g){if(g=Math.round(g),g===0)return f(E);if(g===1)return h(E);if(g<0)return NaN;if(e.abs(E)===0)return 0;if(E==1/0)return 1/0;var v=0,R,N=2/e.abs(E),A=0,y=1,T=0,I=2*e.round((g+e.round(e.sqrt(40*g)))/2);for(R=I;R>0;R--)T=R*N*y+A,A=y,y=T,e.abs(y)>1e10&&(y*=1e-10,A*=1e-10,v*=1e-10),R==g&&(v=A);return v*=m(E,0)/y,E<0&&g%2?-v:v}})(),i=(function(){var a=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),l=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse();function f(m){return m<=2?-e.log(m/2)*u(m,0)+r(a,m*m/4):e.exp(-m)/e.sqrt(m)*r(l,2/m)}var p=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),d=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();function h(m){return m<=2?e.log(m/2)*u(m,1)+1/m*r(p,m*m/4):e.exp(-m)/e.sqrt(m)*r(d,2/m)}return o(f,h,"BESSELK",2,1)})();t.besselj=s,t.bessely=c,t.besseli=u,t.besselk=i})});var Mi=D((Ii,Qa)=>{(function(t,e){typeof Ii=="object"?Qa.exports=e():typeof define=="function"&&define.amd?define(e):t.jStat=e()})(Ii,function(){var t=(function(e,r){var n=Array.prototype.concat,o=Array.prototype.slice,s=Object.prototype.toString;function c(E,g){var v=E>g?E:g;return e.pow(10,17-~~(e.log(v>0?v:-v)*e.LOG10E))}var u=Array.isArray||function(g){return s.call(g)==="[object Array]"};function i(E){return s.call(E)==="[object Function]"}function a(E){return typeof E=="number"?E-E===0:!1}function l(E){return n.apply([],E)}function f(){return new f._init(arguments)}f.fn=f.prototype,f._init=function(g){if(u(g[0]))if(u(g[0][0])){i(g[1])&&(g[0]=f.map(g[0],g[1]));for(var v=0;v<g[0].length;v++)this[v]=g[0][v];this.length=g[0].length}else this[0]=i(g[1])?f.map(g[0],g[1]):g[0],this.length=1;else if(a(g[0]))this[0]=f.seq.apply(null,g),this.length=1;else{if(g[0]instanceof f)return f(g[0].toArray());this[0]=[],this.length=1}return this},f._init.prototype=f.prototype,f._init.constructor=f,f.utils={calcRdx:c,isArray:u,isFunction:i,isNumber:a,toVector:l},f._random_fn=e.random,f.setRandom=function(g){if(typeof g!="function")throw new TypeError("fn is not a function");f._random_fn=g},f.extend=function(g){var v,R;if(arguments.length===1){for(R in g)f[R]=g[R];return this}for(v=1;v<arguments.length;v++)for(R in arguments[v])g[R]=arguments[v][R];return g},f.rows=function(g){return g.length||1},f.cols=function(g){return g[0].length||1},f.dimensions=function(g){return{rows:f.rows(g),cols:f.cols(g)}},f.row=function(g,v){return u(v)?v.map(function(R){return f.row(g,R)}):g[v]},f.rowa=function(g,v){return f.row(g,v)},f.col=function(g,v){if(u(v)){var R=f.arange(g.length).map(function(){return new Array(v.length)});return v.forEach(function(y,T){f.arange(g.length).forEach(function(I){R[I][T]=g[I][y]})}),R}for(var N=new Array(g.length),A=0;A<g.length;A++)N[A]=[g[A][v]];return N},f.cola=function(g,v){return f.col(g,v).map(function(R){return R[0]})},f.diag=function(g){for(var v=f.rows(g),R=new Array(v),N=0;N<v;N++)R[N]=[g[N][N]];return R},f.antidiag=function(g){for(var v=f.rows(g)-1,R=new Array(v),N=0;v>=0;v--,N++)R[N]=[g[N][v]];return R},f.transpose=function(g){var v=[],R,N,A,y,T;for(u(g[0])||(g=[g]),N=g.length,A=g[0].length,T=0;T<A;T++){for(R=new Array(N),y=0;y<N;y++)R[y]=g[y][T];v.push(R)}return v.length===1?v[0]:v},f.map=function(g,v,R){var N,A,y,T,I;for(u(g[0])||(g=[g]),A=g.length,y=g[0].length,T=R?g:new Array(A),N=0;N<A;N++)for(T[N]||(T[N]=new Array(y)),I=0;I<y;I++)T[N][I]=v(g[N][I],N,I);return T.length===1?T[0]:T},f.cumreduce=function(g,v,R){var N,A,y,T,I;for(u(g[0])||(g=[g]),A=g.length,y=g[0].length,T=R?g:new Array(A),N=0;N<A;N++)for(T[N]||(T[N]=new Array(y)),y>0&&(T[N][0]=g[N][0]),I=1;I<y;I++)T[N][I]=v(T[N][I-1],g[N][I]);return T.length===1?T[0]:T},f.alter=function(g,v){return f.map(g,v,!0)},f.create=function(g,v,R){var N=new Array(g),A,y;for(i(v)&&(R=v,v=g),A=0;A<g;A++)for(N[A]=new Array(v),y=0;y<v;y++)N[A][y]=R(A,y);return N};function p(){return 0}f.zeros=function(g,v){return a(v)||(v=g),f.create(g,v,p)};function d(){return 1}f.ones=function(g,v){return a(v)||(v=g),f.create(g,v,d)},f.rand=function(g,v){return a(v)||(v=g),f.create(g,v,f._random_fn)};function h(E,g){return E===g?1:0}f.identity=function(g,v){return a(v)||(v=g),f.create(g,v,h)},f.symmetric=function(g){var v=g.length,R,N;if(g.length!==g[0].length)return!1;for(R=0;R<v;R++)for(N=0;N<v;N++)if(g[N][R]!==g[R][N])return!1;return!0},f.clear=function(g){return f.alter(g,p)},f.seq=function(g,v,R,N){i(N)||(N=!1);var A=[],y=c(g,v),T=(v*y-g*y)/((R-1)*y),I=g,M;for(M=0;I<=v&&M<R;M++,I=(g*y+T*y*M)/y)A.push(N?N(I,M):I);return A},f.arange=function(g,v,R){var N=[],A;if(R=R||1,v===r&&(v=g,g=0),g===v||R===0)return[];if(g<v&&R<0)return[];if(g>v&&R>0)return[];if(R>0)for(A=g;A<v;A+=R)N.push(A);else for(A=g;A>v;A+=R)N.push(A);return N},f.slice=(function(){function E(v,R,N,A){var y,T=[],I=v.length;if(R===r&&N===r&&A===r)return f.copy(v);if(R=R||0,N=N||v.length,R=R>=0?R:I+R,N=N>=0?N:I+N,A=A||1,R===N||A===0)return[];if(R<N&&A<0)return[];if(R>N&&A>0)return[];if(A>0)for(y=R;y<N;y+=A)T.push(v[y]);else for(y=R;y>N;y+=A)T.push(v[y]);return T}function g(v,R){var N,A;if(R=R||{},a(R.row)){if(a(R.col))return v[R.row][R.col];var y=f.rowa(v,R.row);return N=R.col||{},E(y,N.start,N.end,N.step)}if(a(R.col)){var T=f.cola(v,R.col);return A=R.row||{},E(T,A.start,A.end,A.step)}A=R.row||{},N=R.col||{};var I=E(v,A.start,A.end,A.step);return I.map(function(M){return E(M,N.start,N.end,N.step)})}return g})(),f.sliceAssign=function(g,v,R){var N,A;if(a(v.row)){if(a(v.col))return g[v.row][v.col]=R;v.col=v.col||{},v.col.start=v.col.start||0,v.col.end=v.col.end||g[0].length,v.col.step=v.col.step||1,N=f.arange(v.col.start,e.min(g.length,v.col.end),v.col.step);var y=v.row;return N.forEach(function(I,M){g[y][I]=R[M]}),g}if(a(v.col)){v.row=v.row||{},v.row.start=v.row.start||0,v.row.end=v.row.end||g.length,v.row.step=v.row.step||1,A=f.arange(v.row.start,e.min(g[0].length,v.row.end),v.row.step);var T=v.col;return A.forEach(function(I,M){g[I][T]=R[M]}),g}return R[0].length===r&&(R=[R]),v.row.start=v.row.start||0,v.row.end=v.row.end||g.length,v.row.step=v.row.step||1,v.col.start=v.col.start||0,v.col.end=v.col.end||g[0].length,v.col.step=v.col.step||1,A=f.arange(v.row.start,e.min(g.length,v.row.end),v.row.step),N=f.arange(v.col.start,e.min(g[0].length,v.col.end),v.col.step),A.forEach(function(I,M){N.forEach(function(b,S){g[I][b]=R[M][S]})}),g},f.diagonal=function(g){var v=f.zeros(g.length,g.length);return g.forEach(function(R,N){v[N][N]=R}),v},f.copy=function(g){return g.map(function(v){return a(v)?v:v.map(function(R){return R})})};var m=f.prototype;return m.length=0,m.push=Array.prototype.push,m.sort=Array.prototype.sort,m.splice=Array.prototype.splice,m.slice=Array.prototype.slice,m.toArray=function(){return this.length>1?o.call(this):o.call(this)[0]},m.map=function(g,v){return f(f.map(this,g,v))},m.cumreduce=function(g,v){return f(f.cumreduce(this,g,v))},m.alter=function(g){return f.alter(this,g),this},(function(E){for(var g=0;g<E.length;g++)(function(v){m[v]=function(R){var N=this,A;return R?(setTimeout(function(){R.call(N,m[v].call(N))}),this):(A=f[v](this),u(A)?f(A):A)}})(E[g])})("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),(function(E){for(var g=0;g<E.length;g++)(function(v){m[v]=function(R,N){var A=this;return N?(setTimeout(function(){N.call(A,m[v].call(A,R))}),this):f(f[v](this,R))}})(E[g])})("row col".split(" ")),(function(E){for(var g=0;g<E.length;g++)(function(v){m[v]=function(){return f(f[v].apply(null,arguments))}})(E[g])})("create zeros ones rand identity".split(" ")),f})(Math);return(function(e,r){var n=e.utils.isFunction;function o(u,i){return u-i}function s(u,i,a){return r.max(i,r.min(u,a))}e.sum=function(i){for(var a=0,l=i.length;--l>=0;)a+=i[l];return a},e.sumsqrd=function(i){for(var a=0,l=i.length;--l>=0;)a+=i[l]*i[l];return a},e.sumsqerr=function(i){for(var a=e.mean(i),l=0,f=i.length,p;--f>=0;)p=i[f]-a,l+=p*p;return l},e.sumrow=function(i){for(var a=0,l=i.length;--l>=0;)a+=i[l];return a},e.product=function(i){for(var a=1,l=i.length;--l>=0;)a*=i[l];return a},e.min=function(i){for(var a=i[0],l=0;++l<i.length;)i[l]<a&&(a=i[l]);return a},e.max=function(i){for(var a=i[0],l=0;++l<i.length;)i[l]>a&&(a=i[l]);return a},e.unique=function(i){for(var a={},l=[],f=0;f<i.length;f++)a[i[f]]||(a[i[f]]=!0,l.push(i[f]));return l},e.mean=function(i){return e.sum(i)/i.length},e.meansqerr=function(i){return e.sumsqerr(i)/i.length},e.geomean=function(i){var a=i.map(r.log),l=e.mean(a);return r.exp(l)},e.median=function(i){var a=i.length,l=i.slice().sort(o);return a&1?l[a/2|0]:(l[a/2-1]+l[a/2])/2},e.cumsum=function(i){return e.cumreduce(i,function(a,l){return a+l})},e.cumprod=function(i){return e.cumreduce(i,function(a,l){return a*l})},e.diff=function(i){var a=[],l=i.length,f;for(f=1;f<l;f++)a.push(i[f]-i[f-1]);return a},e.rank=function(u){var i,a=[],l={};for(i=0;i<u.length;i++){var f=u[i];l[f]?l[f]++:(l[f]=1,a.push(f))}var p=a.sort(o),d={},h=1;for(i=0;i<p.length;i++){var f=p[i],m=l[f],E=h,g=h+m-1,v=(E+g)/2;d[f]=v,h+=m}return u.map(function(R){return d[R]})},e.mode=function(i){var a=i.length,l=i.slice().sort(o),f=1,p=0,d=0,h=[],m;for(m=0;m<a;m++)l[m]===l[m+1]?f++:(f>p?(h=[l[m]],p=f,d=0):f===p&&(h.push(l[m]),d++),f=1);return d===0?h[0]:h},e.range=function(i){return e.max(i)-e.min(i)},e.variance=function(i,a){return e.sumsqerr(i)/(i.length-(a?1:0))},e.pooledvariance=function(i){var a=i.reduce(function(f,p){return f+e.sumsqerr(p)},0),l=i.reduce(function(f,p){return f+p.length},0);return a/(l-i.length)},e.deviation=function(u){for(var i=e.mean(u),a=u.length,l=new Array(a),f=0;f<a;f++)l[f]=u[f]-i;return l},e.stdev=function(i,a){return r.sqrt(e.variance(i,a))},e.pooledstdev=function(i){return r.sqrt(e.pooledvariance(i))},e.meandev=function(i){for(var a=e.mean(i),l=[],f=i.length-1;f>=0;f--)l.push(r.abs(i[f]-a));return e.mean(l)},e.meddev=function(i){for(var a=e.median(i),l=[],f=i.length-1;f>=0;f--)l.push(r.abs(i[f]-a));return e.median(l)},e.coeffvar=function(i){return e.stdev(i)/e.mean(i)},e.quartiles=function(i){var a=i.length,l=i.slice().sort(o);return[l[r.round(a/4)-1],l[r.round(a/2)-1],l[r.round(a*3/4)-1]]},e.quantiles=function(i,a,l,f){var p=i.slice().sort(o),d=[a.length],h=i.length,m,E,g,v,R,N;for(typeof l>"u"&&(l=3/8),typeof f>"u"&&(f=3/8),m=0;m<a.length;m++)E=a[m],g=l+E*(1-l-f),v=h*E+g,R=r.floor(s(v,1,h-1)),N=s(v-R,0,1),d[m]=(1-N)*p[R-1]+N*p[R];return d},e.percentile=function(i,a,l){var f=i.slice().sort(o),p=a*(f.length+(l?1:-1))+(l?0:1),d=parseInt(p),h=p-d;return d+1<f.length?f[d-1]+h*(f[d]-f[d-1]):f[d-1]},e.percentileOfScore=function(i,a,l){var f=0,p=i.length,d=!1,h,m;for(l==="strict"&&(d=!0),m=0;m<p;m++)h=i[m],(d&&h<a||!d&&h<=a)&&f++;return f/p},e.histogram=function(i,a){a=a||4;var l=e.min(i),f=(e.max(i)-l)/a,p=i.length,d=[],h;for(h=0;h<a;h++)d[h]=0;for(h=0;h<p;h++)d[r.min(r.floor((i[h]-l)/f),a-1)]+=1;return d},e.covariance=function(i,a){var l=e.mean(i),f=e.mean(a),p=i.length,d=new Array(p),h;for(h=0;h<p;h++)d[h]=(i[h]-l)*(a[h]-f);return e.sum(d)/(p-1)},e.corrcoeff=function(i,a){return e.covariance(i,a)/e.stdev(i,1)/e.stdev(a,1)},e.spearmancoeff=function(u,i){return u=e.rank(u),i=e.rank(i),e.corrcoeff(u,i)},e.stanMoment=function(i,a){for(var l=e.mean(i),f=e.stdev(i),p=i.length,d=0,h=0;h<p;h++)d+=r.pow((i[h]-l)/f,a);return d/i.length},e.skewness=function(i){return e.stanMoment(i,3)},e.kurtosis=function(i){return e.stanMoment(i,4)-3};var c=e.prototype;(function(u){for(var i=0;i<u.length;i++)(function(a){c[a]=function(l,f){var p=[],d=0,h=this;if(n(l)&&(f=l,l=!1),f)return setTimeout(function(){f.call(h,c[a].call(h,l))}),this;if(this.length>1){for(h=l===!0?this:this.transpose();d<h.length;d++)p[d]=e[a](h[d]);return p}return e[a](this[0],l)}})(u[i])})("cumsum cumprod".split(" ")),(function(u){for(var i=0;i<u.length;i++)(function(a){c[a]=function(l,f){var p=[],d=0,h=this;if(n(l)&&(f=l,l=!1),f)return setTimeout(function(){f.call(h,c[a].call(h,l))}),this;if(this.length>1){for(a!=="sumrow"&&(h=l===!0?this:this.transpose());d<h.length;d++)p[d]=e[a](h[d]);return l===!0?e[a](e.utils.toVector(p)):p}return e[a](this[0],l)}})(u[i])})("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),(function(u){for(var i=0;i<u.length;i++)(function(a){c[a]=function(){var l=[],f=0,p=this,d=Array.prototype.slice.call(arguments),h;if(n(d[d.length-1])){h=d[d.length-1];var m=d.slice(0,d.length-1);return setTimeout(function(){h.call(p,c[a].apply(p,m))}),this}else{h=void 0;var E=function(v){return e[a].apply(p,[v].concat(d))}}if(this.length>1){for(p=p.transpose();f<p.length;f++)l[f]=E(p[f]);return l}return E(this[0])}})(u[i])})("quantiles percentileOfScore".split(" "))})(t,Math),(function(e,r){e.gammaln=function(o){var s=0,c=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],u=1.000000000190015,i,a,l;for(l=(a=i=o)+5.5,l-=(i+.5)*r.log(l);s<6;s++)u+=c[s]/++a;return r.log(2.5066282746310007*u/i)-l},e.loggam=function(o){var s,c,u,i,a,l,f,p=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(s=o,f=0,o==1||o==2)return 0;for(o<=7&&(f=r.floor(7-o),s=o+f),c=1/(s*s),u=2*r.PI,a=p[9],l=8;l>=0;l--)a*=c,a+=p[l];if(i=a/s+.5*r.log(u)+(s-.5)*r.log(s)-s,o<=7)for(l=1;l<=f;l++)i-=r.log(s-1),s-=1;return i},e.gammafn=function(o){var s=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],c=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,i=0,a=0,l=0,f=o,p,d,h,m;if(o>171.6243769536076)return 1/0;if(f<=0)if(m=f%1+36e-17,m)u=(f&1?-1:1)*r.PI/r.sin(r.PI*m),f=1-f;else return 1/0;for(h=f,f<1?d=f++:d=(f-=i=(f|0)-1)-1,p=0;p<8;++p)l=(l+s[p])*d,a=a*d+c[p];if(m=l/a+1,h<f)m/=h;else if(h>f)for(p=0;p<i;++p)m*=f,f++;return u&&(m=u/m),m},e.gammap=function(o,s){return e.lowRegGamma(o,s)*e.gammafn(o)},e.lowRegGamma=function(o,s){var c=e.gammaln(o),u=o,i=1/o,a=i,l=s+1-o,f=1/1e-30,p=1/l,d=p,h=1,m=-~(r.log(o>=1?o:1/o)*8.5+o*.4+17),E;if(s<0||o<=0)return NaN;if(s<o+1){for(;h<=m;h++)i+=a*=s/++u;return i*r.exp(-s+o*r.log(s)-c)}for(;h<=m;h++)E=-h*(h-o),l+=2,p=E*p+l,f=l+E/f,p=1/p,d*=p*f;return 1-d*r.exp(-s+o*r.log(s)-c)},e.factorialln=function(o){return o<0?NaN:e.gammaln(o+1)},e.factorial=function(o){return o<0?NaN:e.gammafn(o+1)},e.combination=function(o,s){return o>170||s>170?r.exp(e.combinationln(o,s)):e.factorial(o)/e.factorial(s)/e.factorial(o-s)},e.combinationln=function(o,s){return e.factorialln(o)-e.factorialln(s)-e.factorialln(o-s)},e.permutation=function(o,s){return e.factorial(o)/e.factorial(o-s)},e.betafn=function(o,s){if(!(o<=0||s<=0))return o+s>170?r.exp(e.betaln(o,s)):e.gammafn(o)*e.gammafn(s)/e.gammafn(o+s)},e.betaln=function(o,s){return e.gammaln(o)+e.gammaln(s)-e.gammaln(o+s)},e.betacf=function(o,s,c){var u=1e-30,i=1,a=s+c,l=s+1,f=s-1,p=1,d=1-a*o/l,h,m,E,g;for(r.abs(d)<u&&(d=u),d=1/d,g=d;i<=100&&(h=2*i,m=i*(c-i)*o/((f+h)*(s+h)),d=1+m*d,r.abs(d)<u&&(d=u),p=1+m/p,r.abs(p)<u&&(p=u),d=1/d,g*=d*p,m=-(s+i)*(a+i)*o/((s+h)*(l+h)),d=1+m*d,r.abs(d)<u&&(d=u),p=1+m/p,r.abs(p)<u&&(p=u),d=1/d,E=d*p,g*=E,!(r.abs(E-1)<3e-7));i++);return g},e.gammapinv=function(o,s){var c=0,u=s-1,i=1e-8,a=e.gammaln(s),l,f,p,d,h,m,E;if(o>=1)return r.max(100,s+100*r.sqrt(s));if(o<=0)return 0;for(s>1?(m=r.log(u),E=r.exp(u*(m-1)-a),h=o<.5?o:1-o,p=r.sqrt(-2*r.log(h)),l=(2.30753+p*.27061)/(1+p*(.99229+p*.04481))-p,o<.5&&(l=-l),l=r.max(.001,s*r.pow(1-1/(9*s)-l/(3*r.sqrt(s)),3))):(p=1-s*(.253+s*.12),o<p?l=r.pow(o/p,1/s):l=1-r.log(1-(o-p)/(1-p)));c<12;c++){if(l<=0)return 0;if(f=e.lowRegGamma(s,l)-o,s>1?p=E*r.exp(-(l-u)+u*(r.log(l)-m)):p=r.exp(-l+u*r.log(l)-a),d=f/p,l-=p=d/(1-.5*r.min(1,d*((s-1)/l-1))),l<=0&&(l=.5*(l+p)),r.abs(p)<i*l)break}return l},e.erf=function(o){var s=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],c=s.length-1,u=!1,i=0,a=0,l,f,p,d;for(o<0&&(o=-o,u=!0),l=2/(2+o),f=4*l-2;c>0;c--)p=i,i=f*i-a+s[c],a=p;return d=l*r.exp(-o*o+.5*(s[0]+f*i)-a),u?d-1:1-d},e.erfc=function(o){return 1-e.erf(o)},e.erfcinv=function(o){var s=0,c,u,i,a;if(o>=2)return-100;if(o<=0)return 100;for(a=o<1?o:2-o,i=r.sqrt(-2*r.log(a/2)),c=-.70711*((2.30753+i*.27061)/(1+i*(.99229+i*.04481))-i);s<2;s++)u=e.erfc(c)-a,c+=u/(1.1283791670955126*r.exp(-c*c)-c*u);return o<1?c:-c},e.ibetainv=function(o,s,c){var u=1e-8,i=s-1,a=c-1,l=0,f,p,d,h,m,E,g,v,R,N,A;if(o<=0)return 0;if(o>=1)return 1;for(s>=1&&c>=1?(d=o<.5?o:1-o,h=r.sqrt(-2*r.log(d)),g=(2.30753+h*.27061)/(1+h*(.99229+h*.04481))-h,o<.5&&(g=-g),v=(g*g-3)/6,R=2/(1/(2*s-1)+1/(2*c-1)),N=g*r.sqrt(v+R)/R-(1/(2*c-1)-1/(2*s-1))*(v+5/6-2/(3*R)),g=s/(s+c*r.exp(2*N))):(f=r.log(s/(s+c)),p=r.log(c/(s+c)),h=r.exp(s*f)/s,m=r.exp(c*p)/c,N=h+m,o<h/N?g=r.pow(s*N*o,1/s):g=1-r.pow(c*N*(1-o),1/c)),A=-e.gammaln(s)-e.gammaln(c)+e.gammaln(s+c);l<10;l++){if(g===0||g===1)return g;if(E=e.ibeta(g,s,c)-o,h=r.exp(i*r.log(g)+a*r.log(1-g)+A),m=E/h,g-=h=m/(1-.5*r.min(1,m*(i/g-a/(1-g)))),g<=0&&(g=.5*(g+h)),g>=1&&(g=.5*(g+h+1)),r.abs(h)<u*g&&l>0)break}return g},e.ibeta=function(o,s,c){var u=o===0||o===1?0:r.exp(e.gammaln(s+c)-e.gammaln(s)-e.gammaln(c)+s*r.log(o)+c*r.log(1-o));return o<0||o>1?!1:o<(s+1)/(s+c+2)?u*e.betacf(o,s,c)/s:1-u*e.betacf(1-o,c,s)/c},e.randn=function(o,s){var c,u,i,a,l;if(s||(s=o),o)return e.create(o,s,function(){return e.randn()});do c=e._random_fn(),u=1.7156*(e._random_fn()-.5),i=c-.449871,a=r.abs(u)+.386595,l=i*i+a*(.196*a-.25472*i);while(l>.27597&&(l>.27846||u*u>-4*r.log(c)*c*c));return u/c},e.randg=function(o,s,c){var u=o,i,a,l,f,p,d;if(c||(c=s),o||(o=1),s)return d=e.zeros(s,c),d.alter(function(){return e.randg(o)}),d;o<1&&(o+=1),i=o-1/3,a=1/r.sqrt(9*i);do{do p=e.randn(),f=1+a*p;while(f<=0);f=f*f*f,l=e._random_fn()}while(l>1-.331*r.pow(p,4)&&r.log(l)>.5*p*p+i*(1-f+r.log(f)));if(o==u)return i*f;do l=e._random_fn();while(l===0);return r.pow(l,1/u)*i*f},(function(n){for(var o=0;o<n.length;o++)(function(s){e.fn[s]=function(){return e(e.map(this,function(c){return e[s](c)}))}})(n[o])})("gammaln gammafn factorial factorialln".split(" ")),(function(n){for(var o=0;o<n.length;o++)(function(s){e.fn[s]=function(){return e(e[s].apply(null,arguments))}})(n[o])})("randn".split(" "))})(t,Math),(function(e,r){(function(u){for(var i=0;i<u.length;i++)(function(a){e[a]=function l(f,p,d){return this instanceof l?(this._a=f,this._b=p,this._c=d,this):new l(f,p,d)},e.fn[a]=function(l,f,p){var d=e[a](l,f,p);return d.data=this,d},e[a].prototype.sample=function(l){var f=this._a,p=this._b,d=this._c;return l?e.alter(l,function(){return e[a].sample(f,p,d)}):e[a].sample(f,p,d)},(function(l){for(var f=0;f<l.length;f++)(function(p){e[a].prototype[p]=function(d){var h=this._a,m=this._b,E=this._c;return!d&&d!==0&&(d=this.data),typeof d!="number"?e.fn.map.call(d,function(g){return e[a][p](g,h,m,E)}):e[a][p](d,h,m,E)}})(l[f])})("pdf cdf inv".split(" ")),(function(l){for(var f=0;f<l.length;f++)(function(p){e[a].prototype[p]=function(){return e[a][p](this._a,this._b,this._c)}})(l[f])})("mean median mode variance".split(" "))})(u[i])})("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),e.extend(e.beta,{pdf:function(i,a,l){return i>1||i<0?0:a==1&&l==1?1:a<512&&l<512?r.pow(i,a-1)*r.pow(1-i,l-1)/e.betafn(a,l):r.exp((a-1)*r.log(i)+(l-1)*r.log(1-i)-e.betaln(a,l))},cdf:function(i,a,l){return i>1||i<0?(i>1)*1:e.ibeta(i,a,l)},inv:function(i,a,l){return e.ibetainv(i,a,l)},mean:function(i,a){return i/(i+a)},median:function(i,a){return e.ibetainv(.5,i,a)},mode:function(i,a){return(i-1)/(i+a-2)},sample:function(i,a){var l=e.randg(i);return l/(l+e.randg(a))},variance:function(i,a){return i*a/(r.pow(i+a,2)*(i+a+1))}}),e.extend(e.centralF,{pdf:function(i,a,l){var f,p,d;return i<0?0:a<=2?i===0&&a<2?1/0:i===0&&a===2?1:1/e.betafn(a/2,l/2)*r.pow(a/l,a/2)*r.pow(i,a/2-1)*r.pow(1+a/l*i,-(a+l)/2):(f=a*i/(l+i*a),p=l/(l+i*a),d=a*p/2,d*e.binomial.pdf((a-2)/2,(a+l-2)/2,f))},cdf:function(i,a,l){return i<0?0:e.ibeta(a*i/(a*i+l),a/2,l/2)},inv:function(i,a,l){return l/(a*(1/e.ibetainv(i,a/2,l/2)-1))},mean:function(i,a){return a>2?a/(a-2):void 0},mode:function(i,a){return i>2?a*(i-2)/(i*(a+2)):void 0},sample:function(i,a){var l=e.randg(i/2)*2,f=e.randg(a/2)*2;return l/i/(f/a)},variance:function(i,a){if(!(a<=4))return 2*a*a*(i+a-2)/(i*(a-2)*(a-2)*(a-4))}}),e.extend(e.cauchy,{pdf:function(i,a,l){return l<0?0:l/(r.pow(i-a,2)+r.pow(l,2))/r.PI},cdf:function(i,a,l){return r.atan((i-a)/l)/r.PI+.5},inv:function(u,i,a){return i+a*r.tan(r.PI*(u-.5))},median:function(i){return i},mode:function(i){return i},sample:function(i,a){return e.randn()*r.sqrt(1/(2*e.randg(.5)))*a+i}}),e.extend(e.chisquare,{pdf:function(i,a){return i<0?0:i===0&&a===2?.5:r.exp((a/2-1)*r.log(i)-i/2-a/2*r.log(2)-e.gammaln(a/2))},cdf:function(i,a){return i<0?0:e.lowRegGamma(a/2,i/2)},inv:function(u,i){return 2*e.gammapinv(u,.5*i)},mean:function(u){return u},median:function(i){return i*r.pow(1-2/(9*i),3)},mode:function(i){return i-2>0?i-2:0},sample:function(i){return e.randg(i/2)*2},variance:function(i){return 2*i}}),e.extend(e.exponential,{pdf:function(i,a){return i<0?0:a*r.exp(-a*i)},cdf:function(i,a){return i<0?0:1-r.exp(-a*i)},inv:function(u,i){return-r.log(1-u)/i},mean:function(u){return 1/u},median:function(u){return 1/u*r.log(2)},mode:function(){return 0},sample:function(i){return-1/i*r.log(e._random_fn())},variance:function(u){return r.pow(u,-2)}}),e.extend(e.gamma,{pdf:function(i,a,l){return i<0?0:i===0&&a===1?1/l:r.exp((a-1)*r.log(i)-i/l-e.gammaln(a)-a*r.log(l))},cdf:function(i,a,l){return i<0?0:e.lowRegGamma(a,i/l)},inv:function(u,i,a){return e.gammapinv(u,i)*a},mean:function(u,i){return u*i},mode:function(i,a){if(i>1)return(i-1)*a},sample:function(i,a){return e.randg(i)*a},variance:function(i,a){return i*a*a}}),e.extend(e.invgamma,{pdf:function(i,a,l){return i<=0?0:r.exp(-(a+1)*r.log(i)-l/i-e.gammaln(a)+a*r.log(l))},cdf:function(i,a,l){return i<=0?0:1-e.lowRegGamma(a,l/i)},inv:function(u,i,a){return a/e.gammapinv(1-u,i)},mean:function(u,i){return u>1?i/(u-1):void 0},mode:function(i,a){return a/(i+1)},sample:function(i,a){return a/e.randg(i)},variance:function(i,a){if(!(i<=2))return a*a/((i-1)*(i-1)*(i-2))}}),e.extend(e.kumaraswamy,{pdf:function(i,a,l){return i===0&&a===1?l:i===1&&l===1?a:r.exp(r.log(a)+r.log(l)+(a-1)*r.log(i)+(l-1)*r.log(1-r.pow(i,a)))},cdf:function(i,a,l){return i<0?0:i>1?1:1-r.pow(1-r.pow(i,a),l)},inv:function(i,a,l){return r.pow(1-r.pow(1-i,1/l),1/a)},mean:function(u,i){return i*e.gammafn(1+1/u)*e.gammafn(i)/e.gammafn(1+1/u+i)},median:function(i,a){return r.pow(1-r.pow(2,-1/a),1/i)},mode:function(i,a){if(i>=1&&a>=1&&i!==1&&a!==1)return r.pow((i-1)/(i*a-1),1/i)},variance:function(){throw new Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(i,a,l){return i<=0?0:r.exp(-r.log(i)-.5*r.log(2*r.PI)-r.log(l)-r.pow(r.log(i)-a,2)/(2*l*l))},cdf:function(i,a,l){return i<0?0:.5+.5*e.erf((r.log(i)-a)/r.sqrt(2*l*l))},inv:function(u,i,a){return r.exp(-1.4142135623730951*a*e.erfcinv(2*u)+i)},mean:function(i,a){return r.exp(i+a*a/2)},median:function(i){return r.exp(i)},mode:function(i,a){return r.exp(i-a*a)},sample:function(i,a){return r.exp(e.randn()*a+i)},variance:function(i,a){return(r.exp(a*a)-1)*r.exp(2*i+a*a)}}),e.extend(e.noncentralt,{pdf:function(i,a,l){var f=1e-14;return r.abs(l)<f?e.studentt.pdf(i,a):r.abs(i)<f?r.exp(e.gammaln((a+1)/2)-l*l/2-.5*r.log(r.PI*a)-e.gammaln(a/2)):a/i*(e.noncentralt.cdf(i*r.sqrt(1+2/a),a+2,l)-e.noncentralt.cdf(i,a,l))},cdf:function(i,a,l){var f=1e-14,p=200;if(r.abs(l)<f)return e.studentt.cdf(i,a);var d=!1;i<0&&(d=!0,l=-l);for(var h=e.normal.cdf(-l,0,1),m=f+1,E=m,g=i*i/(i*i+a),v=0,R=r.exp(-l*l/2),N=r.exp(-l*l/2-.5*r.log(2)-e.gammaln(3/2))*l;v<p||E>f||m>f;)E=m,v>0&&(R*=l*l/(2*v),N*=l*l/(2*(v+1/2))),m=R*e.beta.cdf(g,v+.5,a/2)+N*e.beta.cdf(g,v+1,a/2),h+=.5*m,v++;return d?1-h:h}}),e.extend(e.normal,{pdf:function(i,a,l){return r.exp(-.5*r.log(2*r.PI)-r.log(l)-r.pow(i-a,2)/(2*l*l))},cdf:function(i,a,l){return .5*(1+e.erf((i-a)/r.sqrt(2*l*l)))},inv:function(u,i,a){return-1.4142135623730951*a*e.erfcinv(2*u)+i},mean:function(u){return u},median:function(i){return i},mode:function(u){return u},sample:function(i,a){return e.randn()*a+i},variance:function(u,i){return i*i}}),e.extend(e.pareto,{pdf:function(i,a,l){return i<a?0:l*r.pow(a,l)/r.pow(i,l+1)},cdf:function(i,a,l){return i<a?0:1-r.pow(a/i,l)},inv:function(i,a,l){return a/r.pow(1-i,1/l)},mean:function(i,a){if(!(a<=1))return a*r.pow(i,a)/(a-1)},median:function(i,a){return i*(a*r.SQRT2)},mode:function(i){return i},variance:function(u,i){if(!(i<=2))return u*u*i/(r.pow(i-1,2)*(i-2))}}),e.extend(e.studentt,{pdf:function(i,a){return a=a>1e100?1e100:a,1/(r.sqrt(a)*e.betafn(.5,a/2))*r.pow(1+i*i/a,-((a+1)/2))},cdf:function(i,a){var l=a/2;return e.ibeta((i+r.sqrt(i*i+a))/(2*r.sqrt(i*i+a)),l,l)},inv:function(u,i){var a=e.ibetainv(2*r.min(u,1-u),.5*i,.5);return a=r.sqrt(i*(1-a)/a),u>.5?a:-a},mean:function(i){return i>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(i){return e.randn()*r.sqrt(i/(2*e.randg(i/2)))},variance:function(i){return i>2?i/(i-2):i>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(i,a,l){return i<0||a<0||l<0?0:l/a*r.pow(i/a,l-1)*r.exp(-r.pow(i/a,l))},cdf:function(i,a,l){return i<0?0:1-r.exp(-r.pow(i/a,l))},inv:function(u,i,a){return i*r.pow(-r.log(1-u),1/a)},mean:function(u,i){return u*e.gammafn(1+1/i)},median:function(i,a){return i*r.pow(r.log(2),1/a)},mode:function(i,a){return a<=1?0:i*r.pow((a-1)/a,1/a)},sample:function(i,a){return i*r.pow(-r.log(e._random_fn()),1/a)},variance:function(i,a){return i*i*e.gammafn(1+2/a)-r.pow(e.weibull.mean(i,a),2)}}),e.extend(e.uniform,{pdf:function(i,a,l){return i<a||i>l?0:1/(l-a)},cdf:function(i,a,l){return i<a?0:i<l?(i-a)/(l-a):1},inv:function(u,i,a){return i+u*(a-i)},mean:function(i,a){return .5*(i+a)},median:function(i,a){return e.mean(i,a)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(i,a){return i/2+a/2+(a/2-i/2)*(2*e._random_fn()-1)},variance:function(i,a){return r.pow(a-i,2)/12}});function n(u,i,a,l){for(var f=0,p=1,d=1,h=1,m=0,E=0,g;r.abs((d-E)/d)>l;)E=d,g=-(i+m)*(i+a+m)*u/(i+2*m)/(i+2*m+1),f=d+g*f,p=h+g*p,m=m+1,g=m*(a-m)*u/(i+2*m-1)/(i+2*m),d=f+g*d,h=p+g*h,f=f/h,p=p/h,d=d/h,h=1;return d/i}e.extend(e.binomial,{pdf:function(i,a,l){return l===0||l===1?a*l===i?1:0:e.combination(a,i)*r.pow(l,i)*r.pow(1-l,a-i)},cdf:function(i,a,l){var f,p=1e-10;if(i<0)return 0;if(i>=a)return 1;if(l<0||l>1||a<=0)return NaN;i=r.floor(i);var d=l,h=i+1,m=a-i,E=h+m,g=r.exp(e.gammaln(E)-e.gammaln(m)-e.gammaln(h)+h*r.log(d)+m*r.log(1-d));return d<(h+1)/(E+2)?f=g*n(d,h,m,p):f=1-g*n(1-d,m,h,p),r.round((1-f)*(1/p))/(1/p)}}),e.extend(e.negbin,{pdf:function(i,a,l){return i!==i>>>0?!1:i<0?0:e.combination(i+a-1,a-1)*r.pow(1-l,i)*r.pow(l,a)},cdf:function(i,a,l){var f=0,p=0;if(i<0)return 0;for(;p<=i;p++)f+=e.negbin.pdf(p,a,l);return f}}),e.extend(e.hypgeom,{pdf:function(i,a,l,f){if(i!==i|0)return!1;if(i<0||i<l-(a-f))return 0;if(i>f||i>l)return 0;if(l*2>a)return f*2>a?e.hypgeom.pdf(a-l-f+i,a,a-l,a-f):e.hypgeom.pdf(f-i,a,a-l,f);if(f*2>a)return e.hypgeom.pdf(l-i,a,l,a-f);if(l<f)return e.hypgeom.pdf(i,a,f,l);for(var p=1,d=0,h=0;h<i;h++){for(;p>1&&d<f;)p*=1-l/(a-d),d++;p*=(f-h)*(l-h)/((h+1)*(a-l-f+h+1))}for(;d<f;d++)p*=1-l/(a-d);return r.min(1,r.max(0,p))},cdf:function(i,a,l,f){if(i<0||i<l-(a-f))return 0;if(i>=f||i>=l)return 1;if(l*2>a)return f*2>a?e.hypgeom.cdf(a-l-f+i,a,a-l,a-f):1-e.hypgeom.cdf(f-i-1,a,a-l,f);if(f*2>a)return 1-e.hypgeom.cdf(l-i-1,a,l,a-f);if(l<f)return e.hypgeom.cdf(i,a,f,l);for(var p=1,d=1,h=0,m=0;m<i;m++){for(;p>1&&h<f;){var E=1-l/(a-h);d*=E,p*=E,h++}d*=(f-m)*(l-m)/((m+1)*(a-l-f+m+1)),p+=d}for(;h<f;h++)p*=1-l/(a-h);return r.min(1,r.max(0,p))}}),e.extend(e.poisson,{pdf:function(i,a){return a<0||i%1!==0||i<0?0:r.pow(a,i)*r.exp(-a)/e.factorial(i)},cdf:function(i,a){var l=[],f=0;if(i<0)return 0;for(;f<=i;f++)l.push(e.poisson.pdf(f,a));return e.sum(l)},mean:function(u){return u},variance:function(u){return u},sampleSmall:function(i){var a=1,l=0,f=r.exp(-i);do l++,a*=e._random_fn();while(a>f);return l-1},sampleLarge:function(i){var a=i,l,f,p,d,h,m,E,g,v,R;for(d=r.sqrt(a),h=r.log(a),E=.931+2.53*d,m=-.059+.02483*E,g=1.1239+1.1328/(E-3.4),v=.9277-3.6224/(E-2);;){if(f=r.random()-.5,p=r.random(),R=.5-r.abs(f),l=r.floor((2*m/R+E)*f+a+.43),R>=.07&&p<=v)return l;if(!(l<0||R<.013&&p>R)&&r.log(p)+r.log(g)-r.log(m/(R*R)+E)<=-a+l*h-e.loggam(l+1))return l}},sample:function(i){return i<10?this.sampleSmall(i):this.sampleLarge(i)}}),e.extend(e.triangular,{pdf:function(i,a,l,f){return l<=a||f<a||f>l?NaN:i<a||i>l?0:i<f?2*(i-a)/((l-a)*(f-a)):i===f?2/(l-a):2*(l-i)/((l-a)*(l-f))},cdf:function(i,a,l,f){return l<=a||f<a||f>l?NaN:i<=a?0:i>=l?1:i<=f?r.pow(i-a,2)/((l-a)*(f-a)):1-r.pow(l-i,2)/((l-a)*(l-f))},inv:function(i,a,l,f){return l<=a||f<a||f>l?NaN:i<=(f-a)/(l-a)?a+(l-a)*r.sqrt(i*((f-a)/(l-a))):a+(l-a)*(1-r.sqrt((1-i)*(1-(f-a)/(l-a))))},mean:function(i,a,l){return(i+a+l)/3},median:function(i,a,l){if(l<=(i+a)/2)return a-r.sqrt((a-i)*(a-l))/r.sqrt(2);if(l>(i+a)/2)return i+r.sqrt((a-i)*(l-i))/r.sqrt(2)},mode:function(i,a,l){return l},sample:function(i,a,l){var f=e._random_fn();return f<(l-i)/(a-i)?i+r.sqrt(f*(a-i)*(l-i)):a-r.sqrt((1-f)*(a-i)*(a-l))},variance:function(i,a,l){return(i*i+a*a+l*l-i*a-i*l-a*l)/18}}),e.extend(e.arcsine,{pdf:function(i,a,l){return l<=a?NaN:i<=a||i>=l?0:2/r.PI*r.pow(r.pow(l-a,2)-r.pow(2*i-a-l,2),-.5)},cdf:function(i,a,l){return i<a?0:i<l?2/r.PI*r.asin(r.sqrt((i-a)/(l-a))):1},inv:function(u,i,a){return i+(.5-.5*r.cos(r.PI*u))*(a-i)},mean:function(i,a){return a<=i?NaN:(i+a)/2},median:function(i,a){return a<=i?NaN:(i+a)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(i,a){return(i+a)/2+(a-i)/2*r.sin(2*r.PI*e.uniform.sample(0,1))},variance:function(i,a){return a<=i?NaN:r.pow(a-i,2)/8}});function o(u){return u/r.abs(u)}e.extend(e.laplace,{pdf:function(i,a,l){return l<=0?0:r.exp(-r.abs(i-a)/l)/(2*l)},cdf:function(i,a,l){return l<=0?0:i<a?.5*r.exp((i-a)/l):1-.5*r.exp(-(i-a)/l)},mean:function(u){return u},median:function(u){return u},mode:function(u){return u},variance:function(u,i){return 2*i*i},sample:function(i,a){var l=e._random_fn()-.5;return i-a*o(l)*r.log(1-2*r.abs(l))}});function s(u,i,a){var l=12,f=6,p=-30,d=-50,h=60,m=8,E=3,g=2,v=3,R=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],N=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],A=u*.5;if(A>=m)return 1;var y=2*e.normal.cdf(A,0,1,1,0)-1;y>=r.exp(d/a)?y=r.pow(y,a):y=0;var T;u>E?T=g:T=v;for(var I=A,M=(m-A)/T,b=I+M,S=0,G=a-1,j=1;j<=T;j++){for(var $=0,W=.5*(b+I),he=.5*(b-I),Ge=1;Ge<=l;Ge++){var Xe,tt;f<Ge?(Xe=l-Ge+1,tt=R[Xe-1]):(Xe=Ge,tt=-R[Xe-1]);var Fe=he*tt,xe=W+Fe,kt=xe*xe;if(kt>h)break;var bt=2*e.normal.cdf(xe,0,1,1,0),Wt=2*e.normal.cdf(xe,u,1,1,0),Be=bt*.5-Wt*.5;Be>=r.exp(p/G)&&(Be=N[Xe-1]*r.exp(-(.5*kt))*r.pow(Be,G),$+=Be)}$*=2*he*a/r.sqrt(2*r.PI),S+=$,I=b,b+=M}return y+=S,y<=r.exp(p/i)?0:(y=r.pow(y,i),y>=1?1:y)}function c(u,i,a){var l=.322232421088,f=.099348462606,p=-1,d=.588581570495,h=-.342242088547,m=.531103462366,E=-.204231210125,g=.10353775285,v=-453642210148e-16,R=.0038560700634,N=.8832,A=.2368,y=1.214,T=1.208,I=1.4142,M=120,b=.5-.5*u,S=r.sqrt(r.log(1/(b*b))),G=S+((((S*v+E)*S+h)*S+p)*S+l)/((((S*R+g)*S+m)*S+d)*S+f);a<M&&(G+=(G*G*G+G)/a/4);var j=N-A*G;return a<M&&(j+=-y/a+T*G/a),G*(j*r.log(i-1)+I)}e.extend(e.tukey,{cdf:function(i,a,l){var f=1,p=a,d=16,h=8,m=-30,E=1e-14,g=100,v=800,R=5e3,N=25e3,A=1,y=.5,T=.25,I=.125,M=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],b=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(i<=0)return 0;if(l<2||f<1||p<2)return NaN;if(!Number.isFinite(i))return 1;if(l>N)return s(i,f,p);var S=l*.5,G=S*r.log(l)-l*r.log(2)-e.gammaln(S),j=S-1,$=l*.25,W;l<=g?W=A:l<=v?W=y:l<=R?W=T:W=I,G+=r.log(W);for(var he=0,Ge=1;Ge<=50;Ge++){for(var Xe=0,tt=(2*Ge-1)*W,Fe=1;Fe<=d;Fe++){var xe,kt;h<Fe?(xe=Fe-h-1,kt=G+j*r.log(tt+M[xe]*W)-(M[xe]*W+tt)*$):(xe=Fe-1,kt=G+j*r.log(tt-M[xe]*W)+(M[xe]*W-tt)*$);var bt;if(kt>=m){h<Fe?bt=i*r.sqrt((M[xe]*W+tt)*.5):bt=i*r.sqrt((-(M[xe]*W)+tt)*.5);var Wt=s(bt,f,p),Be=Wt*b[xe]*r.exp(kt);Xe+=Be}}if(Ge*W>=1&&Xe<=E)break;he+=Xe}if(Xe>E)throw new Error("tukey.cdf failed to converge");return he>1&&(he=1),he},inv:function(u,i,a){var l=1,f=i,p=1e-4,d=50;if(a<2||l<1||f<2)return NaN;if(u<0||u>1)return NaN;if(u===0)return 0;if(u===1)return 1/0;var h=c(u,f,a),m=e.tukey.cdf(h,i,a)-u,E;m>0?E=r.max(0,h-1):E=h+1;for(var g=e.tukey.cdf(E,i,a)-u,v,R=1;R<d;R++){v=E-g*(E-h)/(g-m),m=g,h=E,v<0&&(v=0,g=-u),g=e.tukey.cdf(v,i,a)-u,E=v;var N=r.abs(E-h);if(N<p)return v}throw new Error("tukey.inv failed to converge")}})})(t,Math),(function(e,r){var n=Array.prototype.push,o=e.utils.isArray;function s(c){return o(c)||c instanceof e}e.extend({add:function(u,i){return s(i)?(s(i[0])||(i=[i]),e.map(u,function(a,l,f){return a+i[l][f]})):e.map(u,function(a){return a+i})},subtract:function(u,i){return s(i)?(s(i[0])||(i=[i]),e.map(u,function(a,l,f){return a-i[l][f]||0})):e.map(u,function(a){return a-i})},divide:function(u,i){return s(i)?(s(i[0])||(i=[i]),e.multiply(u,e.inv(i))):e.map(u,function(a){return a/i})},multiply:function(u,i){var a,l,f,p,d,h,m,E;if(u.length===void 0&&i.length===void 0)return u*i;if(d=u.length,h=u[0].length,m=e.zeros(d,f=s(i)?i[0].length:h),E=0,s(i)){for(;E<f;E++)for(a=0;a<d;a++){for(p=0,l=0;l<h;l++)p+=u[a][l]*i[l][E];m[a][E]=p}return d===1&&E===1?m[0][0]:m}return e.map(u,function(g){return g*i})},outer:function(u,i){return e.multiply(u.map(function(a){return[a]}),[i])},dot:function(u,i){s(u[0])||(u=[u]),s(i[0])||(i=[i]);for(var a=u[0].length===1&&u.length!==1?e.transpose(u):u,l=i[0].length===1&&i.length!==1?e.transpose(i):i,f=[],p=0,d=a.length,h=a[0].length,m,E;p<d;p++){for(f[p]=[],m=0,E=0;E<h;E++)m+=a[p][E]*l[p][E];f[p]=m}return f.length===1?f[0]:f},pow:function(u,i){return e.map(u,function(a){return r.pow(a,i)})},exp:function(u){return e.map(u,function(i){return r.exp(i)})},log:function(u){return e.map(u,function(i){return r.log(i)})},abs:function(u){return e.map(u,function(i){return r.abs(i)})},norm:function(u,i){var a=0,l=0;for(isNaN(i)&&(i=2),s(u[0])&&(u=u[0]);l<u.length;l++)a+=r.pow(r.abs(u[l]),i);return r.pow(a,1/i)},angle:function(u,i){return r.acos(e.dot(u,i)/(e.norm(u)*e.norm(i)))},aug:function(u,i){var a=[],l;for(l=0;l<u.length;l++)a.push(u[l].slice());for(l=0;l<a.length;l++)n.apply(a[l],i[l]);return a},inv:function(u){for(var i=u.length,a=u[0].length,l=e.identity(i,a),f=e.gauss_jordan(u,l),p=[],d=0,h;d<i;d++)for(p[d]=[],h=a;h<f[0].length;h++)p[d][h-a]=f[d][h];return p},det:function c(u){if(u.length===2)return u[0][0]*u[1][1]-u[0][1]*u[1][0];for(var i=0,a=0;a<u.length;a++){for(var l=[],f=1;f<u.length;f++){l[f-1]=[];for(var p=0;p<u.length;p++)p<a?l[f-1][p]=u[f][p]:p>a&&(l[f-1][p-1]=u[f][p])}var d=a%2?-1:1;i+=c(l)*u[0][a]*d}return i},gauss_elimination:function(u,i){var a=0,l=0,f=u.length,p=u[0].length,d=1,h=0,m=[],E,g,v,R;for(u=e.aug(u,i),E=u[0].length,a=0;a<f;a++){for(g=u[a][a],l=a,R=a+1;R<p;R++)g<r.abs(u[R][a])&&(g=u[R][a],l=R);if(l!=a)for(R=0;R<E;R++)v=u[a][R],u[a][R]=u[l][R],u[l][R]=v;for(l=a+1;l<f;l++)for(d=u[l][a]/u[a][a],R=a;R<E;R++)u[l][R]=u[l][R]-d*u[a][R]}for(a=f-1;a>=0;a--){for(h=0,l=a+1;l<=f-1;l++)h=h+m[l]*u[a][l];m[a]=(u[a][E-1]-h)/u[a][a]}return m},gauss_jordan:function(u,i){var a=e.aug(u,i),l=a.length,f=a[0].length,p=0,d,h,m;for(h=0;h<l;h++){var E=h;for(m=h+1;m<l;m++)r.abs(a[m][h])>r.abs(a[E][h])&&(E=m);var g=a[h];for(a[h]=a[E],a[E]=g,m=h+1;m<l;m++)for(p=a[m][h]/a[h][h],d=h;d<f;d++)a[m][d]-=a[h][d]*p}for(h=l-1;h>=0;h--){for(p=a[h][h],m=0;m<h;m++)for(d=f-1;d>h-1;d--)a[m][d]-=a[h][d]*a[m][h]/p;for(a[h][h]/=p,d=l;d<f;d++)a[h][d]/=p}return a},triaUpSolve:function(u,i){var a=u[0].length,l=e.zeros(1,a)[0],f,p=!1;return i[0].length!=null&&(i=i.map(function(d){return d[0]}),p=!0),e.arange(a-1,-1,-1).forEach(function(d){f=e.arange(d+1,a).map(function(h){return l[h]*u[d][h]}),l[d]=(i[d]-e.sum(f))/u[d][d]}),p?l.map(function(d){return[d]}):l},triaLowSolve:function(u,i){var a=u[0].length,l=e.zeros(1,a)[0],f,p=!1;return i[0].length!=null&&(i=i.map(function(d){return d[0]}),p=!0),e.arange(a).forEach(function(d){f=e.arange(d).map(function(h){return u[d][h]*l[h]}),l[d]=(i[d]-e.sum(f))/u[d][d]}),p?l.map(function(d){return[d]}):l},lu:function(u){var i=u.length,a=e.identity(i),l=e.zeros(u.length,u[0].length),f;return e.arange(i).forEach(function(p){l[0][p]=u[0][p]}),e.arange(1,i).forEach(function(p){e.arange(p).forEach(function(d){f=e.arange(d).map(function(h){return a[p][h]*l[h][d]}),a[p][d]=(u[p][d]-e.sum(f))/l[d][d]}),e.arange(p,i).forEach(function(d){f=e.arange(p).map(function(h){return a[p][h]*l[h][d]}),l[p][d]=u[f.length][d]-e.sum(f)})}),[a,l]},cholesky:function(u){var i=u.length,a=e.zeros(u.length,u[0].length),l;return e.arange(i).forEach(function(f){l=e.arange(f).map(function(p){return r.pow(a[f][p],2)}),a[f][f]=r.sqrt(u[f][f]-e.sum(l)),e.arange(f+1,i).forEach(function(p){l=e.arange(f).map(function(d){return a[f][d]*a[p][d]}),a[p][f]=(u[f][p]-e.sum(l))/a[f][f]})}),a},gauss_jacobi:function(u,i,a,l){for(var f=0,p=0,d=u.length,h=[],m=[],E=[],g,v,R,N;f<d;f++)for(h[f]=[],m[f]=[],E[f]=[],p=0;p<d;p++)f>p?(h[f][p]=u[f][p],m[f][p]=E[f][p]=0):f<p?(m[f][p]=u[f][p],h[f][p]=E[f][p]=0):(E[f][p]=u[f][p],h[f][p]=m[f][p]=0);for(R=e.multiply(e.multiply(e.inv(E),e.add(h,m)),-1),v=e.multiply(e.inv(E),i),g=a,N=e.add(e.multiply(R,a),v),f=2;r.abs(e.norm(e.subtract(N,g)))>l;)g=N,N=e.add(e.multiply(R,g),v),f++;return N},gauss_seidel:function(u,i,a,l){for(var f=0,p=u.length,d=[],h=[],m=[],E,g,v,R,N;f<p;f++)for(d[f]=[],h[f]=[],m[f]=[],E=0;E<p;E++)f>E?(d[f][E]=u[f][E],h[f][E]=m[f][E]=0):f<E?(h[f][E]=u[f][E],d[f][E]=m[f][E]=0):(m[f][E]=u[f][E],d[f][E]=h[f][E]=0);for(R=e.multiply(e.multiply(e.inv(e.add(m,d)),h),-1),v=e.multiply(e.inv(e.add(m,d)),i),g=a,N=e.add(e.multiply(R,a),v),f=2;r.abs(e.norm(e.subtract(N,g)))>l;)g=N,N=e.add(e.multiply(R,g),v),f=f+1;return N},SOR:function(u,i,a,l,f){for(var p=0,d=u.length,h=[],m=[],E=[],g,v,R,N,A;p<d;p++)for(h[p]=[],m[p]=[],E[p]=[],g=0;g<d;g++)p>g?(h[p][g]=u[p][g],m[p][g]=E[p][g]=0):p<g?(m[p][g]=u[p][g],h[p][g]=E[p][g]=0):(E[p][g]=u[p][g],h[p][g]=m[p][g]=0);for(N=e.multiply(e.inv(e.add(E,e.multiply(h,f))),e.subtract(e.multiply(E,1-f),e.multiply(m,f))),R=e.multiply(e.multiply(e.inv(e.add(E,e.multiply(h,f))),i),f),v=a,A=e.add(e.multiply(N,a),R),p=2;r.abs(e.norm(e.subtract(A,v)))>l;)v=A,A=e.add(e.multiply(N,v),R),p++;return A},householder:function(u){for(var i=u.length,a=u[0].length,l=0,f=[],p=[],d,h,m,E,g;l<i-1;l++){for(d=0,E=l+1;E<a;E++)d+=u[E][l]*u[E][l];for(g=u[l+1][l]>0?-1:1,d=g*r.sqrt(d),h=r.sqrt((d*d-u[l+1][l]*d)/2),f=e.zeros(i,1),f[l+1][0]=(u[l+1][l]-d)/(2*h),m=l+2;m<i;m++)f[m][0]=u[m][l]/(2*h);p=e.subtract(e.identity(i,a),e.multiply(e.multiply(f,e.transpose(f)),2)),u=e.multiply(p,e.multiply(u,p))}return u},QR:(function(){var c=e.sum,u=e.arange;function i(a){var l=a.length,f=a[0].length,p=e.zeros(f,f);a=e.copy(a);var d,h,m;for(h=0;h<f;h++){for(p[h][h]=r.sqrt(c(u(l).map(function(E){return a[E][h]*a[E][h]}))),d=0;d<l;d++)a[d][h]=a[d][h]/p[h][h];for(m=h+1;m<f;m++)for(p[h][m]=c(u(l).map(function(E){return a[E][h]*a[E][m]})),d=0;d<l;d++)a[d][m]=a[d][m]-a[d][h]*p[h][m]}return[a,p]}return i})(),lstsq:(function(){function c(i){i=e.copy(i);var a=i.length,l=e.identity(a);return e.arange(a-1,-1,-1).forEach(function(f){e.sliceAssign(l,{row:f},e.divide(e.slice(l,{row:f}),i[f][f])),e.sliceAssign(i,{row:f},e.divide(e.slice(i,{row:f}),i[f][f])),e.arange(f).forEach(function(p){var d=e.multiply(i[p][f],-1),h=e.slice(i,{row:p}),m=e.multiply(e.slice(i,{row:f}),d);e.sliceAssign(i,{row:p},e.add(h,m));var E=e.slice(l,{row:p}),g=e.multiply(e.slice(l,{row:f}),d);e.sliceAssign(l,{row:p},e.add(E,g))})}),l}function u(i,a){var l=!1;a[0].length===void 0&&(a=a.map(function(N){return[N]}),l=!0);var f=e.QR(i),p=f[0],d=f[1],h=i[0].length,m=e.slice(p,{col:{end:h}}),E=e.slice(d,{row:{end:h}}),g=c(E),v=e.transpose(m);v[0].length===void 0&&(v=[v]);var R=e.multiply(e.multiply(g,v),a);return R.length===void 0&&(R=[[R]]),l?R.map(function(N){return N[0]}):R}return u})(),jacobi:function(u){for(var i=1,a=u.length,l=e.identity(a,a),f=[],p,d,h,m,E,g,v,R;i===1;){for(g=u[0][1],m=0,E=1,d=0;d<a;d++)for(h=0;h<a;h++)d!=h&&g<r.abs(u[d][h])&&(g=r.abs(u[d][h]),m=d,E=h);for(u[m][m]===u[E][E]?v=u[m][E]>0?r.PI/4:-r.PI/4:v=r.atan(2*u[m][E]/(u[m][m]-u[E][E]))/2,R=e.identity(a,a),R[m][m]=r.cos(v),R[m][E]=-r.sin(v),R[E][m]=r.sin(v),R[E][E]=r.cos(v),l=e.multiply(l,R),p=e.multiply(e.multiply(e.inv(R),u),R),u=p,i=0,d=1;d<a;d++)for(h=1;h<a;h++)d!=h&&r.abs(u[d][h])>.001&&(i=1)}for(d=0;d<a;d++)f.push(u[d][d]);return[l,f]},rungekutta:function(u,i,a,l,f,p){var d,h,m,E,g;if(p===2)for(;l<=a;)d=i*u(l,f),h=i*u(l+i,f+d),m=f+(d+h)/2,f=m,l=l+i;if(p===4)for(;l<=a;)d=i*u(l,f),h=i*u(l+i/2,f+d/2),E=i*u(l+i/2,f+h/2),g=i*u(l+i,f+E),m=f+(d+2*h+2*E+g)/6,f=m,l=l+i;return f},romberg:function(u,i,a,l){for(var f=0,p=(a-i)/2,d=[],h=[],m=[],E,g,v,R,N;f<l/2;){for(N=u(i),v=i,R=0;v<=a;v=v+p,R++)d[R]=v;for(E=d.length,v=1;v<E-1;v++)N+=(v%2!==0?4:2)*u(d[v]);N=p/3*(N+u(a)),m[f]=N,p/=2,f++}for(g=m.length,E=1;g!==1;){for(v=0;v<g-1;v++)h[v]=(r.pow(4,E)*m[v+1]-m[v])/(r.pow(4,E)-1);g=h.length,m=h,h=[],E++}return m},richardson:function(u,i,a,l){function f(A,y){for(var T=0,I=A.length,M;T<I;T++)A[T]===y&&(M=T);return M}for(var p=r.abs(a-u[f(u,a)+1]),d=0,h=[],m=[],E,g,v,R,N;l>=p;)E=f(u,a+l),g=f(u,a),h[d]=(i[E]-2*i[g]+i[2*g-E])/(l*l),l/=2,d++;for(R=h.length,v=1;R!=1;){for(N=0;N<R-1;N++)m[N]=(r.pow(4,v)*h[N+1]-h[N])/(r.pow(4,v)-1);R=m.length,h=m,m=[],v++}return h},simpson:function(u,i,a,l){for(var f=(a-i)/l,p=u(i),d=[],h=i,m=0,E=1,g;h<=a;h=h+f,m++)d[m]=h;for(g=d.length;E<g-1;E++)p+=(E%2!==0?4:2)*u(d[E]);return f/3*(p+u(a))},hermite:function(u,i,a,l){for(var f=u.length,p=0,d=0,h=[],m=[],E=[],g=[],v;d<f;d++){for(h[d]=1,v=0;v<f;v++)d!=v&&(h[d]*=(l-u[v])/(u[d]-u[v]));for(m[d]=0,v=0;v<f;v++)d!=v&&(m[d]+=1/(u[d]-u[v]));E[d]=(1-2*(l-u[d])*m[d])*(h[d]*h[d]),g[d]=(l-u[d])*(h[d]*h[d]),p+=E[d]*i[d]+g[d]*a[d]}return p},lagrange:function(u,i,a){for(var l=0,f=0,p,d,h=u.length;f<h;f++){for(d=i[f],p=0;p<h;p++)f!=p&&(d*=(a-u[p])/(u[f]-u[p]));l+=d}return l},cubic_spline:function(u,i,a){for(var l=u.length,f=0,p,d=[],h=[],m=[],E=[],g=[],v=[],R=[];f<l-1;f++)g[f]=u[f+1]-u[f];for(m[0]=0,f=1;f<l-1;f++)m[f]=3/g[f]*(i[f+1]-i[f])-3/g[f-1]*(i[f]-i[f-1]);for(f=1;f<l-1;f++)d[f]=[],h[f]=[],d[f][f-1]=g[f-1],d[f][f]=2*(g[f-1]+g[f]),d[f][f+1]=g[f],h[f][0]=m[f];for(E=e.multiply(e.inv(d),h),p=0;p<l-1;p++)v[p]=(i[p+1]-i[p])/g[p]-g[p]*(E[p+1][0]+2*E[p][0])/3,R[p]=(E[p+1][0]-E[p][0])/(3*g[p]);for(p=0;p<l&&!(u[p]>a);p++);return p-=1,i[p]+(a-u[p])*v[p]+e.sq(a-u[p])*E[p]+(a-u[p])*e.sq(a-u[p])*R[p]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(u){var i=u.length,a=u[0].length,l=0,f,p,d=[],h=[],m=[],E=[],g=[],v=[],R=[],N=[],A=[],y=[];for(l=0;l<i;l++)d[l]=e.sum(u[l])/a;for(l=0;l<a;l++)for(R[l]=[],f=0;f<i;f++)R[l][f]=u[f][l]-d[f];for(R=e.transpose(R),l=0;l<i;l++)for(N[l]=[],f=0;f<i;f++)N[l][f]=e.dot([R[l]],[R[f]])/(a-1);for(m=e.jacobi(N),A=m[0],h=m[1],y=e.transpose(A),l=0;l<h.length;l++)for(f=l;f<h.length;f++)h[l]<h[f]&&(p=h[l],h[l]=h[f],h[f]=p,E=y[l],y[l]=y[f],y[f]=E);for(v=e.transpose(R),l=0;l<i;l++)for(g[l]=[],f=0;f<v.length;f++)g[l][f]=e.dot([y[l]],[v[f]]);return[u,h,y,g]}}),(function(c){for(var u=0;u<c.length;u++)(function(i){e.fn[i]=function(a,l){var f=this;return l?(setTimeout(function(){l.call(f,e.fn[i].call(f,a))},15),this):typeof e[i](this,a)=="number"?e[i](this,a):e(e[i](this,a))}})(c[u])})("add divide multiply subtract dot pow exp log abs norm angle".split(" "))})(t,Math),(function(e,r){var n=[].slice,o=e.utils.isNumber,s=e.utils.isArray;e.extend({zscore:function(){var i=n.call(arguments);return o(i[1])?(i[0]-i[1])/i[2]:(i[0]-e.mean(i[1]))/e.stdev(i[1],i[2])},ztest:function(){var i=n.call(arguments),a;return s(i[1])?(a=e.zscore(i[0],i[1],i[3]),i[2]===1?e.normal.cdf(-r.abs(a),0,1):e.normal.cdf(-r.abs(a),0,1)*2):i.length>2?(a=e.zscore(i[0],i[1],i[2]),i[3]===1?e.normal.cdf(-r.abs(a),0,1):e.normal.cdf(-r.abs(a),0,1)*2):(a=i[0],i[1]===1?e.normal.cdf(-r.abs(a),0,1):e.normal.cdf(-r.abs(a),0,1)*2)}}),e.extend(e.fn,{zscore:function(i,a){return(i-this.mean())/this.stdev(a)},ztest:function(i,a,l){var f=r.abs(this.zscore(i,l));return a===1?e.normal.cdf(-f,0,1):e.normal.cdf(-f,0,1)*2}}),e.extend({tscore:function(){var i=n.call(arguments);return i.length===4?(i[0]-i[1])/(i[2]/r.sqrt(i[3])):(i[0]-e.mean(i[1]))/(e.stdev(i[1],!0)/r.sqrt(i[1].length))},ttest:function(){var i=n.call(arguments),a;return i.length===5?(a=r.abs(e.tscore(i[0],i[1],i[2],i[3])),i[4]===1?e.studentt.cdf(-a,i[3]-1):e.studentt.cdf(-a,i[3]-1)*2):o(i[1])?(a=r.abs(i[0]),i[2]==1?e.studentt.cdf(-a,i[1]-1):e.studentt.cdf(-a,i[1]-1)*2):(a=r.abs(e.tscore(i[0],i[1])),i[2]==1?e.studentt.cdf(-a,i[1].length-1):e.studentt.cdf(-a,i[1].length-1)*2)}}),e.extend(e.fn,{tscore:function(i){return(i-this.mean())/(this.stdev(!0)/r.sqrt(this.cols()))},ttest:function(i,a){return a===1?1-e.studentt.cdf(r.abs(this.tscore(i)),this.cols()-1):e.studentt.cdf(-r.abs(this.tscore(i)),this.cols()-1)*2}}),e.extend({anovafscore:function(){var i=n.call(arguments),a,l,f,p,d,h,m,E;if(i.length===1){for(d=new Array(i[0].length),m=0;m<i[0].length;m++)d[m]=i[0][m];i=d}for(l=new Array,m=0;m<i.length;m++)l=l.concat(i[m]);for(f=e.mean(l),a=0,m=0;m<i.length;m++)a=a+i[m].length*r.pow(e.mean(i[m])-f,2);for(a/=i.length-1,h=0,m=0;m<i.length;m++)for(p=e.mean(i[m]),E=0;E<i[m].length;E++)h+=r.pow(i[m][E]-p,2);return h/=l.length-i.length,a/h},anovaftest:function(){var i=n.call(arguments),a,l,f,p;if(o(i[0]))return 1-e.centralF.cdf(i[0],i[1],i[2]);var d=e.anovafscore(i);for(a=i.length-1,f=0,p=0;p<i.length;p++)f=f+i[p].length;return l=f-a-1,1-e.centralF.cdf(d,a,l)},ftest:function(i,a,l){return 1-e.centralF.cdf(i,a,l)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var i=0,a;for(a=0;a<this.length;a++)i=i+this[a].length;return e.ftest(this.anovafscore(),this.length-1,i-this.length)}}),e.extend({qscore:function(){var i=n.call(arguments),a,l,f,p,d;return o(i[0])?(a=i[0],l=i[1],f=i[2],p=i[3],d=i[4]):(a=e.mean(i[0]),l=e.mean(i[1]),f=i[0].length,p=i[1].length,d=i[2]),r.abs(a-l)/(d*r.sqrt((1/f+1/p)/2))},qtest:function(){var i=n.call(arguments),a;i.length===3?(a=i[0],i=i.slice(1)):i.length===7?(a=e.qscore(i[0],i[1],i[2],i[3],i[4]),i=i.slice(5)):(a=e.qscore(i[0],i[1],i[2]),i=i.slice(3));var l=i[0],f=i[1];return 1-e.tukey.cdf(a,f,l-f)},tukeyhsd:function(i){for(var a=e.pooledstdev(i),l=i.map(function(E){return e.mean(E)}),f=i.reduce(function(E,g){return E+g.length},0),p=[],d=0;d<i.length;++d)for(var h=d+1;h<i.length;++h){var m=e.qtest(l[d],l[h],i[d].length,i[h].length,a,f,i.length);p.push([[d,h],m])}return p}}),e.extend({normalci:function(){var i=n.call(arguments),a=new Array(2),l;return i.length===4?l=r.abs(e.normal.inv(i[1]/2,0,1)*i[2]/r.sqrt(i[3])):l=r.abs(e.normal.inv(i[1]/2,0,1)*e.stdev(i[2])/r.sqrt(i[2].length)),a[0]=i[0]-l,a[1]=i[0]+l,a},tci:function(){var i=n.call(arguments),a=new Array(2),l;return i.length===4?l=r.abs(e.studentt.inv(i[1]/2,i[3]-1)*i[2]/r.sqrt(i[3])):l=r.abs(e.studentt.inv(i[1]/2,i[2].length-1)*e.stdev(i[2],!0)/r.sqrt(i[2].length)),a[0]=i[0]-l,a[1]=i[0]+l,a},significant:function(i,a){return i<a}}),e.extend(e.fn,{normalci:function(i,a){return e.normalci(i,a,this.toArray())},tci:function(i,a){return e.tci(i,a,this.toArray())}});function c(u,i,a,l){if(u>1||a>1||u<=0||a<=0)throw new Error("Proportions should be greater than 0 and less than 1");var f=(u*i+a*l)/(i+l),p=r.sqrt(f*(1-f)*(1/i+1/l));return(u-a)/p}e.extend(e.fn,{oneSidedDifferenceOfProportions:function(i,a,l,f){var p=c(i,a,l,f);return e.ztest(p,1)},twoSidedDifferenceOfProportions:function(i,a,l,f){var p=c(i,a,l,f);return e.ztest(p,2)}})})(t,Math),t.models=(function(){function e(c){var u=c[0].length,i=t.arange(u).map(function(a){var l=t.arange(u).filter(function(f){return f!==a});return r(t.col(c,a).map(function(f){return f[0]}),t.col(c,l))});return i}function r(c,u){var i=c.length,a=u[0].length-1,l=i-a-1,f=t.lstsq(u,c),p=t.multiply(u,f.map(function(R){return[R]})).map(function(R){return R[0]}),d=t.subtract(c,p),h=t.mean(c),m=t.sum(p.map(function(R){return Math.pow(R-h,2)})),E=t.sum(c.map(function(R,N){return Math.pow(R-p[N],2)})),g=m+E,v=m/g;return{exog:u,endog:c,nobs:i,df_model:a,df_resid:l,coef:f,predict:p,resid:d,ybar:h,SST:g,SSE:m,SSR:E,R2:v}}function n(c){var u=e(c.exog),i=Math.sqrt(c.SSR/c.df_resid),a=u.map(function(h){var m=h.SST,E=h.R2;return i/Math.sqrt(m*(1-E))}),l=c.coef.map(function(h,m){return(h-0)/a[m]}),f=l.map(function(h){var m=t.studentt.cdf(h,c.df_resid);return(m>.5?1-m:m)*2}),p=t.studentt.inv(.975,c.df_resid),d=c.coef.map(function(h,m){var E=p*a[m];return[h-E,h+E]});return{se:a,t:l,p:f,sigmaHat:i,interval95:d}}function o(c){var u=c.R2/c.df_model/((1-c.R2)/c.df_resid),i=function(l,f,p){return t.beta.cdf(l/(p/f+l),f/2,p/2)},a=1-i(u,c.df_model,c.df_resid);return{F_statistic:u,pvalue:a}}function s(c,u){var i=r(c,u),a=n(i),l=o(i),f=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=a,i.f=l,i.adjust_R2=f,i}return{ols:s}})(),t.extend({buildxmatrix:function(){for(var r=new Array(arguments.length),n=0;n<arguments.length;n++){var o=[1];r[n]=o.concat(arguments[n])}return t(r)},builddxmatrix:function(){for(var r=new Array(arguments[0].length),n=0;n<arguments[0].length;n++){var o=[1];r[n]=o.concat(arguments[0][n])}return t(r)},buildjxmatrix:function(r){for(var n=new Array(r.length),o=0;o<r.length;o++)n[o]=r[o];return t.builddxmatrix(n)},buildymatrix:function(r){return t(r).transpose()},buildjymatrix:function(r){return r.transpose()},matrixmult:function(r,n){var o,s,c,u,i;if(r.cols()==n.rows()){if(n.rows()>1){for(u=[],o=0;o<r.rows();o++)for(u[o]=[],s=0;s<n.cols();s++){for(i=0,c=0;c<r.cols();c++)i+=r.toArray()[o][c]*n.toArray()[c][s];u[o][s]=i}return t(u)}for(u=[],o=0;o<r.rows();o++)for(u[o]=[],s=0;s<n.cols();s++){for(i=0,c=0;c<r.cols();c++)i+=r.toArray()[o][c]*n.toArray()[s];u[o][s]=i}return t(u)}},regress:function(r,n){var o=t.xtranspxinv(r),s=r.transpose(),c=t.matrixmult(t(o),s);return t.matrixmult(c,n)},regresst:function(r,n,o){var s=t.regress(r,n),c={};c.anova={};var u=t.jMatYBar(r,s);c.yBar=u;var i=n.mean();c.anova.residuals=t.residuals(n,u),c.anova.ssr=t.ssr(u,i),c.anova.msr=c.anova.ssr/(r[0].length-1),c.anova.sse=t.sse(n,u),c.anova.mse=c.anova.sse/(n.length-(r[0].length-1)-1),c.anova.sst=t.sst(n,i),c.anova.mst=c.anova.sst/(n.length-1),c.anova.r2=1-c.anova.sse/c.anova.sst,c.anova.r2<0&&(c.anova.r2=0),c.anova.fratio=c.anova.msr/c.anova.mse,c.anova.pvalue=t.anovaftest(c.anova.fratio,r[0].length-1,n.length-(r[0].length-1)-1),c.anova.rmse=Math.sqrt(c.anova.mse),c.anova.r2adj=1-c.anova.mse/c.anova.mst,c.anova.r2adj<0&&(c.anova.r2adj=0),c.stats=new Array(r[0].length);for(var a=t.xtranspxinv(r),l,f,p,d=0;d<s.length;d++)l=Math.sqrt(c.anova.mse*Math.abs(a[d][d])),f=Math.abs(s[d]/l),p=t.ttest(f,n.length-r[0].length-1,o),c.stats[d]=[s[d],l,f,p];return c.regress=s,c},xtranspx:function(r){return t.matrixmult(r.transpose(),r)},xtranspxinv:function(r){var n=t.matrixmult(r.transpose(),r),o=t.inv(n);return o},jMatYBar:function(r,n){var o=t.matrixmult(r,n);return new t(o)},residuals:function(r,n){return t.matrixsubtract(r,n)},ssr:function(r,n){for(var o=0,s=0;s<r.length;s++)o+=Math.pow(r[s]-n,2);return o},sse:function(r,n){for(var o=0,s=0;s<r.length;s++)o+=Math.pow(r[s]-n[s],2);return o},sst:function(r,n){for(var o=0,s=0;s<r.length;s++)o+=Math.pow(r[s]-n,2);return o},matrixsubtract:function(r,n){for(var o=new Array(r.length),s=0;s<r.length;s++){o[s]=new Array(r[s].length);for(var c=0;c<r[s].length;c++)o[s][c]=r[s][c]-n[s][c]}return t(o)}}),t.jStat=t,t})});var ja=D((vv,Ja)=>{var z=qe(),qt=Ei(),{FormulaHelpers:wp,Types:X}=$e(),H=wp,uo=Xa(),Za=Mi(),_p=536870911,kp=-536870912,Ci=511,co=-512,bp=/^\s?[+-]?\s?[0-9]+[.]?[0-9]*([eE][+\-][0-9]+)?\s?$/,xp=/^\s?([+-]?\s?([0-9]+[.]?[0-9]*([eE][+\-][0-9]+)?)?)\s?[ij]\s?$/,Lp=/^\s?([+-]?\s?[0-9]+[.]?[0-9]*([eE][+\-][0-9]+)?)\s?([+-]?\s?([0-9]+[.]?[0-9]*([eE][+\-][0-9]+)?)?)\s?[ij]\s?$/;function Me(t){t=H.accept(t);let e=0,r=0,n="i";if(typeof t=="number")return{real:t,im:r,unit:n};if(typeof t=="boolean")throw z.VALUE;let o=t.match(bp);if(o)return e=Number(o[0]),{real:e,im:r,unit:n};if(o=t.match(xp),o)return r=Number(/^\s?[+-]?\s?$/.test(o[1])?o[1]+"1":o[1]),n=o[0].slice(-1),{real:e,im:r,unit:n};if(o=t.match(Lp),o)return e=Number(o[1]),r=Number(/^\s?[+-]?\s?$/.test(o[3])?o[3]+"1":o[3]),n=o[0].slice(-1),{real:e,im:r,unit:n};throw z.NUM}var ee={BESSELI:(t,e)=>{if(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw z.NUM;return uo.besseli(t,e)},BESSELJ:(t,e)=>{if(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw z.NUM;return uo.besselj(t,e)},BESSELK:(t,e)=>{if(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw z.NUM;return uo.besselk(t,e)},BESSELY:(t,e)=>{if(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw z.NUM;return uo.bessely(t,e)},BIN2DEC:t=>{t=H.accept(t,X.NUMBER_NO_BOOLEAN);let e=t.toString();if(e.length>10)throw z.NUM;return e.length===10&&e.substring(0,1)==="1"?parseInt(e.substring(1),2)+co:parseInt(e,2)},BIN2HEX:(t,e)=>{t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN,null);let r=t.toString();if(r.length>10)throw z.NUM;if(r.length===10&&r.substring(0,1)==="1")return(parseInt(r.substring(1),2)+0xfffffffe00).toString(16).toUpperCase();let n=parseInt(t,2).toString(16);if(e==null)return n.toUpperCase();if(e<0)throw z.NUM;if(e=Math.trunc(e),e>=n.length)return(qt.REPT("0",e-n.length)+n).toUpperCase();throw z.NUM},BIN2OCT:(t,e)=>{t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER,null);let r=t.toString();if(r.length>10)throw z.NUM;if(r.length===10&&r.substr(0,1)==="1")return(parseInt(r.substr(1),2)+1073741312).toString(8);let n=parseInt(t,2).toString(8);if(e==null)return n.toUpperCase();if(e<0)throw z.NUM;if(e=Math.trunc(e),e>=n.length)return qt.REPT("0",e-n.length)+n;throw z.NUM},BITAND:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER),t<0||e<0||Math.floor(t)!==t||Math.floor(e)!==e||t>0xffffffffffff||e>0xffffffffffff)throw z.NUM;return t&e},BITLSHIFT:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER),e=Math.trunc(e),Math.abs(e)>53||t<0||Math.floor(t)!==t||t>0xffffffffffff)throw z.NUM;let r=e>=0?t*2**e:Math.trunc(t/2**-e);if(r>0xffffffffffff)throw z.NUM;return r},BITOR:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER),t<0||e<0||Math.floor(t)!==t||Math.floor(e)!==e||t>0xffffffffffff||e>0xffffffffffff)throw z.NUM;return t|e},BITRSHIFT:(t,e)=>(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER),ee.BITLSHIFT(t,-e)),BITXOR:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER),t<0||t>0xffffffffffff||Math.floor(t)!==t||e<0||e>0xffffffffffff||Math.floor(e)!==e)throw z.NUM;return t^e},COMPLEX:(t,e,r)=>{if(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN),r=H.accept(r,X.STRING,"i"),r!=="i"&&r!=="j")throw z.VALUE;if(t===0&&e===0)return 0;if(t===0)return e===1?r:e===-1?"-"+r:e.toString()+r;if(e===0)return t.toString();{let n=e>0?"+":"";return e===1?t.toString()+n+r:e===-1?t.toString()+n+"-"+r:t.toString()+n+e.toString()+r}},DEC2BIN:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER,null),t<co||t>Ci)throw z.NUM;if(t<0)return"1"+qt.REPT("0",9-(512+t).toString(2).length)+(512+t).toString(2);let r=parseInt(t,10).toString(2);if(e==null)return r;if(e=Math.trunc(e),e<=0||e<r.length)throw z.NUM;return qt.REPT("0",e-r.length)+r},DEC2HEX:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER,null),t<-549755813888||t>549755813888)throw z.NUM;if(t<0)return(1099511627776+t).toString(16).toUpperCase();let r=parseInt(t,10).toString(16);if(e==null)return r.toUpperCase();if(e=Math.trunc(e),e<=0||e<r.length)throw z.NUM;return qt.REPT("0",e-r.length)+r.toUpperCase()},DEC2OCT:(t,e)=>{if(t=H.accept(t,X.NUMBER),e=H.accept(e,X.NUMBER,null),t<-536870912||t>536870912)throw z.NUM;if(t<0)return(t+1073741824).toString(8);let r=parseInt(t,10).toString(8);if(e==null)return r.toUpperCase();if(e=Math.trunc(e),e<=0||e<r.length)throw z.NUM;return qt.REPT("0",e-r.length)+r},DELTA:(t,e)=>(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN,0),t===e?1:0),ERF:(t,e)=>(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN,0),Za.erf(t)),ERFC:t=>(t=H.accept(t,X.NUMBER_NO_BOOLEAN),Za.erfc(t)),GESTEP:(t,e)=>(t=H.accept(t,X.NUMBER_NO_BOOLEAN),e=H.accept(e,X.NUMBER_NO_BOOLEAN,0),t>=e?1:0),HEX2BIN:(t,e)=>{if(t=H.accept(t,X.STRING),e=H.accept(e,X.NUMBER,null),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw z.NUM;let r=t.length===10&&t.substr(0,1).toLowerCase()==="f",n=r?parseInt(t,16)-1099511627776:parseInt(t,16);if(n<co||n>Ci)throw z.NUM;if(r)return"1"+qt.REPT("0",9-(n+512).toString(2).length)+(n+512).toString(2);let o=n.toString(2);if(e==null)return o;if(e=Math.trunc(e),e<=0||e<o.length)throw z.NUM;return qt.REPT("0",e-o.length)+o},HEX2DEC:t=>{if(t=H.accept(t,X.STRING),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw z.NUM;let e=parseInt(t,16);return e>=549755813888?e-1099511627776:e},HEX2OCT:(t,e)=>{if(t=H.accept(t,X.STRING),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw z.NUM;let r=ee.HEX2DEC(t);if(r>_p||r<kp)throw z.NUM;return ee.DEC2OCT(r,e)},IMABS:t=>{let{real:e,im:r}=Me(t);return Math.sqrt(Math.pow(e,2)+Math.pow(r,2))},IMAGINARY:t=>Me(t).im,IMARGUMENT:t=>{let{real:e,im:r}=Me(t);if(e===0&&r===0)throw z.DIV0;return e===0&&r>0?Math.PI/2:e===0&&r<0?-Math.PI/2:e<0&&r===0?Math.PI:e>0&&r===0?0:e>0?Math.atan(r/e):e<0&&r>0?Math.atan(r/e)+Math.PI:Math.atan(r/e)-Math.PI},IMCONJUGATE:t=>{let{real:e,im:r,unit:n}=Me(t);return r!==0?ee.COMPLEX(e,-r,n):""+e},IMCOS:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.cos(e)*(Math.exp(r)+Math.exp(-r))/2,s=-Math.sin(e)*(Math.exp(r)-Math.exp(-r))/2;return ee.COMPLEX(o,s,n)},IMCOSH:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.cos(r)*(Math.exp(e)+Math.exp(-e))/2,s=-Math.sin(r)*(Math.exp(e)-Math.exp(-e))/2;return ee.COMPLEX(o,-s,n)},IMCOT:t=>{t=H.accept(t);let e=ee.IMCOS(t),r=ee.IMSIN(t);return ee.IMDIV(e,r)},IMCSC:t=>(t=H.accept(t),ee.IMDIV("1",ee.IMSIN(t))),IMCSCH:t=>(t=H.accept(t),ee.IMDIV("1",ee.IMSINH(t))),IMDIV:(t,e)=>{let r=Me(t),n=r.real,o=r.im,s=r.unit,c=Me(e),u=c.real,i=c.im,a=c.unit;if(u===0&&i===0||s!==a)throw z.NUM;let l=s,f=Math.pow(u,2)+Math.pow(i,2);return ee.COMPLEX((n*u+o*i)/f,(o*u-n*i)/f,l)},IMEXP:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.exp(e);return ee.COMPLEX(o*Math.cos(r),o*Math.sin(r),n)},IMLN:t=>{let{real:e,im:r,unit:n}=Me(t);return ee.COMPLEX(Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(r,2))),Math.atan(r/e),n)},IMLOG10:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(r,2)))/Math.log(10),s=Math.atan(r/e)/Math.log(10);return ee.COMPLEX(o,s,n)},IMLOG2:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(r,2)))/Math.log(2),s=Math.atan(r/e)/Math.log(2);return ee.COMPLEX(o,s,n)},IMPOWER:(t,e)=>{let{unit:r}=Me(t);e=H.accept(e,X.NUMBER_NO_BOOLEAN);let n=Math.pow(ee.IMABS(t),e),o=ee.IMARGUMENT(t),s=n*Math.cos(e*o),c=n*Math.sin(e*o);return ee.COMPLEX(s,c,r)},IMPRODUCT:(...t)=>{let e,r=0;return H.flattenParams(t,null,!1,n=>{if(r===0)e=H.accept(n),Me(e);else{let o=Me(e),s=o.real,c=o.im,u=o.unit,i=Me(n),a=i.real,l=i.im,f=i.unit;if(u!==f)throw z.VALUE;e=ee.COMPLEX(s*a-c*l,s*l+c*a)}r++},1),e},IMREAL:t=>Me(t).real,IMSEC:t=>ee.IMDIV("1",ee.IMCOS(t)),IMSECH:t=>ee.IMDIV("1",ee.IMCOSH(t)),IMSIN:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.sin(e)*(Math.exp(r)+Math.exp(-r))/2,s=Math.cos(e)*(Math.exp(r)-Math.exp(-r))/2;return ee.COMPLEX(o,s,n)},IMSINH:t=>{let{real:e,im:r,unit:n}=Me(t),o=Math.cos(r)*(Math.exp(e)-Math.exp(-e))/2,s=Math.sin(r)*(Math.exp(e)+Math.exp(-e))/2;return ee.COMPLEX(o,s,n)},IMSQRT:t=>{let{unit:e}=Me(t),r=Math.sqrt(ee.IMABS(t)),n=ee.IMARGUMENT(t);return ee.COMPLEX(r*Math.cos(n/2),r*Math.sin(n/2),e)},IMSUB:(t,e)=>{let r=Me(t),n=r.real,o=r.im,s=r.unit,c=Me(e),u=c.real,i=c.im,a=c.unit;if(s!==a)throw z.VALUE;return ee.COMPLEX(n-u,o-i,s)},IMSUM:(...t)=>{let e=0,r=0,n;return H.flattenParams(t,null,!1,o=>{let{real:s,im:c,unit:u}=Me(o);if(n||(n=u),n!==u)throw z.VALUE;e+=s,r+=c}),ee.COMPLEX(e,r,n)},IMTAN:t=>{let{unit:e}=Me(t);return ee.IMDIV(ee.IMSIN(t),ee.IMCOS(t),e)},OCT2BIN:(t,e)=>{if(t=H.accept(t,X.STRING),e=H.accept(e,X.NUMBER,null),t.length>10||e>10||e!==null&&e<0)throw z.NUM;e=Math.trunc(e);let r=t.length===10&&t.substring(0,1)==="7",n=ee.OCT2DEC(t);if(n<co||n>Ci)return z.NUM;if(r)return"1"+qt.REPT("0",9-(512+n).toString(2).length)+(512+n).toString(2);let o=n.toString(2);if(e===0)return o;if(e<o.length)throw z.NUM;return qt.REPT("0",e-o.length)+o},OCT2DEC:t=>{if(t=H.accept(t,X.STRING),t.length>10)throw z.NUM;for(let r of t)if(r<"0"||r>"7")throw z.NUM;let e=parseInt(t,8);return e>=536870912?e-1073741824:e},OCT2HEX:(t,e)=>{if(t=H.accept(t,X.STRING),e=H.accept(e,X.NUMBER_NO_BOOLEAN,null),t.length>10)throw z.NUM;for(let o of t)if(o<"0"||o>"7")throw z.NUM;if(e=Math.trunc(e),e<0||e>10)throw z.NUM;let r=ee.OCT2DEC(t),n=ee.DEC2HEX(r);if(e===0)return n;if(e<n.length)throw z.NUM;return qt.REPT("0",e-n.length)+n}};Ja.exports=ee});var ru=D((Ev,tu)=>{var Oe=qe(),{FormulaHelpers:Up,Types:mt,WildCard:lo,Address:Pp}=$e(),eu=Nn(),ce=Up,Sp={ADDRESS:(t,e,r,n,o)=>{if(t=ce.accept(t,mt.NUMBER),e=ce.accept(e,mt.NUMBER),r=ce.accept(r,mt.NUMBER,1),n=ce.accept(n,mt.BOOLEAN,!0),o=ce.accept(o,mt.STRING,""),t<1||e<1||r<1||r>4)throw Oe.VALUE;let s="";return o.length>0&&(/[^A-Za-z_.\d\u007F-\uFFFF]/.test(o)?s+=`'${o}'!`:s+=o+"!"),n?(s+=r===1||r===3?"$":"",s+=Pp.columnNumberToName(e),s+=r===1||r===2?"$":"",s+=t):(s+="R",s+=r===4||r===3?`[${t}]`:t,s+="C",s+=r===4||r===2?`[${e}]`:e),s},AREAS:t=>(t=ce.accept(t),t instanceof eu?t.length:1),CHOOSE:(t,...e)=>{},COLUMN:(t,e)=>{if(e==null){if(t.position.col!=null)return t.position.col;throw Error("FormulaParser.parse is called without position parameter.")}else{if(typeof e!="object"||Array.isArray(e))throw Oe.VALUE;if(ce.isCellRef(e))return e.ref.col;if(ce.isRangeRef(e))return e.ref.from.col;throw Error("ReferenceFunctions.COLUMN should not reach here.")}},COLUMNS:(t,e)=>{if(e==null)throw Error("COLUMNS requires one argument");if(typeof e!="object"||Array.isArray(e))throw Oe.VALUE;if(ce.isCellRef(e))return 1;if(ce.isRangeRef(e))return Math.abs(e.ref.from.col-e.ref.to.col)+1;throw Error("ReferenceFunctions.COLUMNS should not reach here.")},HLOOKUP:(t,e,r,n)=>{t=ce.accept(t);try{e=ce.accept(e,mt.ARRAY,void 0,!1)}catch(s){throw s instanceof Oe?Oe.NA:s}if(r=ce.accept(r,mt.NUMBER),n=ce.accept(n,mt.BOOLEAN,!0),r<1)throw Oe.VALUE;if(e[r-1]===void 0)throw Oe.REF;let o=typeof t;if(n){let s=o===typeof e[0][0]?e[0][0]:null;for(let c=1;c<e[0].length;c++){let u=e[0][c];if(typeof u===o){if(s>t&&u>t)throw Oe.NA;if(u===t)return e[r-1][c];if(s!=null&&u>t&&s<=t)return e[r-1][c-1];s=u}}if(s==null)throw Oe.NA;return s}else{let s=-1;if(lo.isWildCard(t)?s=e[0].findIndex(c=>lo.toRegex(t,"i").test(c)):s=e[0].findIndex(c=>c===t),s===-1)throw Oe.NA;return e[r-1][s]}},INDEX:(t,e,r,n,o)=>{r=t.utils.extractRefValue(r),r={value:r.val,isArray:r.isArray},r=ce.accept(r,mt.NUMBER),r=Math.trunc(r),n==null?n=1:(n=t.utils.extractRefValue(n),n={value:n.val,isArray:n.isArray},n=ce.accept(n,mt.NUMBER,1),n=Math.trunc(n)),o==null?o=1:(o=t.utils.extractRefValue(o),o={value:o.val,isArray:o.isArray},o=ce.accept(o,mt.NUMBER,1),o=Math.trunc(o));let s=e;if(e instanceof eu)s=e.refs[o-1];else if(o>1)throw Oe.REF;if(r===0&&n===0)return s;if(r===0){if(ce.isRangeRef(s)){if(s.ref.to.col-s.ref.from.col<n-1)throw Oe.REF;return s.ref.from.col+=n-1,s.ref.to.col=s.ref.from.col,s}else if(Array.isArray(s)){let c=[];return s.forEach(u=>c.push([u[n-1]])),c}}if(n===0){if(ce.isRangeRef(s)){if(s.ref.to.row-s.ref.from.row<r-1)throw Oe.REF;return s.ref.from.row+=r-1,s.ref.to.row=s.ref.from.row,s}else if(Array.isArray(s))return s[n-1]}if(r!==0&&n!==0){if(ce.isRangeRef(s)){if(s=s.ref,s.to.row-s.from.row<r-1||s.to.col-s.from.col<n-1)throw Oe.REF;return{ref:{row:s.from.row+r-1,col:s.from.col+n-1}}}else if(ce.isCellRef(s)){if(s=s.ref,r>1||n>1)throw Oe.REF;return{ref:{row:s.row+r-1,col:s.col+n-1}}}else if(Array.isArray(s)){if(s.length<r||s[0].length<n)throw Oe.REF;return s[r-1][n-1]}}},MATCH:()=>{},ROW:(t,e)=>{if(e==null){if(t.position.row!=null)return t.position.row;throw Error("FormulaParser.parse is called without position parameter.")}else{if(typeof e!="object"||Array.isArray(e))throw Oe.VALUE;if(ce.isCellRef(e))return e.ref.row;if(ce.isRangeRef(e))return e.ref.from.row;throw Error("ReferenceFunctions.ROW should not reach here.")}},ROWS:(t,e)=>{if(e==null)throw Error("ROWS requires one argument");if(typeof e!="object"||Array.isArray(e))throw Oe.VALUE;if(ce.isCellRef(e))return 1;if(ce.isRangeRef(e))return Math.abs(e.ref.from.row-e.ref.to.row)+1;throw Error("ReferenceFunctions.ROWS should not reach here.")},TRANSPOSE:t=>{t=ce.accept(t,mt.ARRAY,void 0,!1);let e=[];for(let r=0;r<t[0].length;r++){e[r]=[];for(let n=0;n<t.length;n++)e[r][n]=t[n][r]}return e},VLOOKUP:(t,e,r,n)=>{t=ce.accept(t);try{e=ce.accept(e,mt.ARRAY,void 0,!1)}catch(s){throw s instanceof Oe?Oe.NA:s}if(r=ce.accept(r,mt.NUMBER),n=ce.accept(n,mt.BOOLEAN,!0),r<1)throw Oe.VALUE;if(e[0][r-1]===void 0)throw Oe.REF;let o=typeof t;if(n){let s=o===typeof e[0][0]?e[0][0]:null;for(let c=1;c<e.length;c++){let u=e[c],i=e[c][0];if(typeof i===o){if(s>t&&i>t)throw Oe.NA;if(i===t)return u[r-1];if(s!=null&&i>t&&s<=t)return e[c-1][r-1];s=i}}if(s==null)throw Oe.NA;return s}else{let s=-1;if(lo.isWildCard(t)?s=e.findIndex(c=>lo.toRegex(t,"i").test(c[0])):s=e.findIndex(c=>c[0]===t),s===-1)throw Oe.NA;return e[s][r-1]}}};tu.exports=Sp});var ou=D((yv,nu)=>{var hr=qe(),{FormulaHelpers:Fp,Types:Bp}=$e(),it=Fp,Dp={"#NULL!":1,"#DIV/0!":2,"#VALUE!":3,"#REF!":4,"#NAME?":5,"#NUM!":6,"#N/A":7},Wp={CELL:(t,e)=>{},"ERROR.TYPE":t=>{if(t=it.accept(t),t instanceof hr)return Dp[t.toString()];throw hr.NA},INFO:()=>{},ISBLANK:t=>t.ref?t.value==null||t.value==="":!1,ISERR:t=>(t=it.accept(t),t instanceof hr&&t.toString()!=="#N/A"),ISERROR:t=>(t=it.accept(t),t instanceof hr),ISEVEN:t=>(t=it.accept(t,Bp.NUMBER),t=Math.trunc(t),t%2===0),ISLOGICAL:t=>(t=it.accept(t),typeof t=="boolean"),ISNA:t=>(t=it.accept(t),t instanceof hr&&t.toString()==="#N/A"),ISNONTEXT:t=>(t=it.accept(t),typeof t!="string"),ISNUMBER:t=>(t=it.accept(t),typeof t=="number"),ISREF:t=>!t.ref||it.isCellRef(t)&&(t.ref.row>1048576||t.ref.col>16384)||it.isRangeRef(t)&&(t.ref.from.row>1048576||t.ref.from.col>16384||t.ref.to.row>1048576||t.ref.to.col>16384)?!1:(t=it.accept(t),!(t instanceof hr&&t.toString()==="#REF!")),ISTEXT:t=>(t=it.accept(t),typeof t=="string"),N:t=>{t=it.accept(t);let e=typeof t;if(e==="number")return t;if(e==="boolean")return Number(t);if(t instanceof hr)throw t;return 0},NA:()=>{throw hr.NA},TYPE:t=>{if(t.ref){if(it.isRangeRef(t))return 16;if(it.isCellRef(t)&&(t=it.accept(t),typeof t=="string"&&t.length===0))return 1}t=it.accept(t);let e=typeof t;if(e==="number")return 1;if(e==="string")return 2;if(e==="boolean")return 4;if(t instanceof hr)return 16;if(Array.isArray(t))return 64}};nu.exports=Wp});var au=D((Rv,su)=>{var V=qe(),{FormulaHelpers:Vp,Types:C}=$e(),w=Vp,q=Mi(),fo=Ni(),Gp=2.5066282746310002,iu={"BETA.DIST":(t,e,r,n,o,s)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),o=w.accept(o,C.NUMBER,0),s=w.accept(s,C.NUMBER,1),e<=0||r<=0||t<o||t>s||o===s)throw V.NUM;return t=(t-o)/(s-o),n?q.beta.cdf(t,e,r):q.beta.pdf(t,e,r)/(s-o)},"BETA.INV":(t,e,r,n,o)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.NUMBER,0),o=w.accept(o,C.NUMBER,1),e<=0||r<=0||t<=0||t>1)throw V.NUM;return q.beta.inv(t,e,r)*(o-n)+n},"BINOM.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),e<0||r<0||r>1||t<0||t>e)throw V.NUM;return n?q.binomial.cdf(t,e,r):q.binomial.pdf(t,e,r)},"BINOM.DIST.RANGE":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.NUMBER,r),t<0||e<0||e>1||r<0||r>t||n<r||n>t)throw V.NUM;let o=0;for(let s=r;s<=n;s++)o+=fo.COMBIN(t,s)*Math.pow(e,s)*Math.pow(1-e,t-s);return o},"BINOM.INV":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<0||e<0||e>1||r<0||r>1)throw V.NUM;let n=0;for(;n<=t;){if(q.binomial.cdf(n,t,e)>=r)return n;n++}},"CHISQ.DIST":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),e=Math.trunc(e),t<0||e<1||e>10**10)throw V.NUM;return r?q.chisquare.cdf(t,e):q.chisquare.pdf(t,e)},"CHISQ.DIST.RT":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),e=Math.trunc(e),t<0||e<1||e>10**10)throw V.NUM;return 1-q.chisquare.cdf(t,e)},"CHISQ.INV":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),e=Math.trunc(e),t<0||t>1||e<1||e>10**10)throw V.NUM;return q.chisquare.inv(t,e)},"CHISQ.INV.RT":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),e=Math.trunc(e),t<0||t>1||e<1||e>10**10)throw V.NUM;return q.chisquare.inv(1-t,e)},"CHISQ.TEST":(t,e)=>{let r=w.accept(t,C.ARRAY,void 0,!1,!1),n=w.accept(e,C.ARRAY,void 0,!1,!1);if(r.length!==n.length||r[0].length!==n[0].length||r.length===1&&r[0].length===1)throw V.NA;let o=r.length,s=r[0].length,c=(o-1)*(s-1);o===1?c=s-1:c=o-1;let u=0;for(let p=0;p<o;p++)for(let d=0;d<s;d++)if(!(typeof r[p][d]!="number"||typeof n[p][d]!="number")){if(n[p][d]===0)throw V.DIV0;u+=Math.pow(r[p][d]-n[p][d],2)/n[p][d]}let i=Math.exp(-.5*u);c%2===1&&(i=i*Math.sqrt(2*u/Math.PI));let a=c;for(;a>=2;)i=i*u/a,a=a-2;let l=i,f=c;for(;l>1e-15*i;)f=f+2,l=l*u/f,i=i+l;return 1-i},"CONFIDENCE.NORM":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),r=Math.trunc(r),t<=0||t>=1||e<=0||r<1)throw V.NUM;return q.normalci(1,t,e,r)[1]-1},"CONFIDENCE.T":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),r=Math.trunc(r),t<=0||t>=1||e<=0||r<1)throw V.NUM;if(r===1)throw V.DIV0;return q.tci(1,t,e,r)[1]-1},CORREL:(t,e)=>{if(t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0),t.length!==e.length)throw V.NA;let r=[],n=[];for(let o=0;o<t.length;o++)typeof t[o]!="number"||typeof e[o]!="number"||(r.push(t[o]),n.push(e[o]));if(r.length<=1)throw V.DIV0;return q.corrcoeff(r,n)},"COVARIANCE.P":(t,e)=>{if(t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0),t.length!==e.length)throw V.NA;let r=[],n=[];for(let u=0;u<t.length;u++)typeof t[u]!="number"||typeof e[u]!="number"||(r.push(t[u]),n.push(e[u]));let o=q.mean(r),s=q.mean(n),c=0;for(let u=0;u<r.length;u++)c+=(r[u]-o)*(n[u]-s);return c/r.length},"COVARIANCE.S":(t,e)=>{if(t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0),t.length!==e.length)throw V.NA;let r=[],n=[];for(let o=0;o<t.length;o++)typeof t[o]!="number"||typeof e[o]!="number"||(r.push(t[o]),n.push(e[o]));if(r.length<=1)throw V.DIV0;return q.covariance(r,n)},DEVSQ:(...t)=>{let e=0,r=[];w.flattenParams(t,C.NUMBER,!0,(o,s)=>{typeof o=="number"&&(e+=o,r.push(o))});let n=e/r.length;e=0;for(let o=0;o<r.length;o++)e+=(r[o]-n)**2;return e},"EXPON.DIST":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.BOOLEAN),t<0||e<=0)throw V.NUM;return r?q.exponential.cdf(t,e):q.exponential.pdf(t,e)},"F.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),t<0||e<1||r<1)throw V.NUM;return e=Math.trunc(e),r=Math.trunc(r),n?q.centralF.cdf(t,e,r):q.centralF.pdf(t,e,r)},"F.DIST.RT":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<0||e<1||r<1)throw V.NUM;return e=Math.trunc(e),r=Math.trunc(r),1-q.centralF.cdf(t,e,r)},"F.INV":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<0||t>1||e<1||r<1)throw V.NUM;return e=Math.trunc(e),r=Math.trunc(r),q.centralF.inv(t,e,r)},"F.INV.RT":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<0||t>1||e<1||e>=Math.pow(10,10)||r<1||r>=Math.pow(10,10))throw V.NUM;return e=Math.trunc(e),r=Math.trunc(r),q.centralF.inv(1-t,e,r)},"F.TEST":(t,e)=>{t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0);let r=[],n=[],o=0,s=0;for(let i=0;i<Math.max(t.length,e.length);i++)typeof t[i]=="number"&&(r.push(t[i]),o+=t[i]),typeof e[i]=="number"&&(n.push(e[i]),s+=e[i]);if(r.length<=1||n.length<=1)throw V.DIV0;o/=r.length,s/=n.length;let c=0,u=0;for(let i=0;i<r.length;i++)c+=(o-r[i])**2;c/=r.length-1;for(let i=0;i<n.length;i++)u+=(s-n[i])**2;return u/=n.length-1,q.centralF.cdf(c/u,r.length-1,n.length-1)*2},FISHER:t=>{if(t=w.accept(t,C.NUMBER),t<=-1||t>=1)throw V.NUM;return Math.log((1+t)/(1-t))/2},FISHERINV:t=>{t=w.accept(t,C.NUMBER);let e=Math.exp(2*t);return(e-1)/(e+1)},FORECAST:(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.ARRAY,void 0,!0,!0),r=w.accept(r,C.ARRAY,void 0,!0,!0),r.length!==e.length)throw V.NA;let n=[],o=[],s=!0;for(let p=0;p<e.length;p++)typeof e[p]!="number"||typeof r[p]!="number"||(n.push(e[p]),o.push(r[p]),r[p]!==r[0]&&(s=!1));if(s)throw V.DIV0;let c=q.mean(n),u=q.mean(o),i=0,a=0;for(let p=0;p<n.length;p++)i+=(o[p]-u)*(n[p]-c),a+=(o[p]-u)**2;let l=i/a;return c-l*u+l*t},"FORECAST.ETS":()=>{},"FORECAST.ETS.CONFINT":()=>{},"FORECAST.ETS.SEASONALITY":()=>{},"FORECAST.ETS.STAT":()=>{},"FORECAST.LINEAR":(...t)=>iu.FORECAST(...t),FREQUENCY:(t,e)=>{t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0);let r=[];for(let o=0;o<e.length;o++)typeof e[o]=="number"&&r.push(e[o]);r.sort(),r.push(1/0);let n=[];for(let o=0;o<r.length;o++){n[o]=[],n[o][0]=0;for(let s=0;s<t.length;s++){if(typeof t[s]!="number")continue;t[s]<=r[o]&&(n[o][0]++,t[s]=null)}}return n},GAMMA:t=>{if(t=w.accept(t,C.NUMBER),t===0||t<0&&t===Math.trunc(t))throw V.NUM;return q.gammafn(t)},"GAMMA.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),t<0||e<=0||r<=0)throw V.NUM;return n?q.gamma.cdf(t,e,r,!0):q.gamma.pdf(t,e,r,!1)},"GAMMA.INV":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<0||t>1||e<=0||r<=0)throw V.NUM;return q.gamma.inv(t,e,r)},GAMMALN:t=>{if(t=w.accept(t,C.NUMBER),t<=0)throw V.NUM;return q.gammaln(t)},"GAMMALN.PRECISE":t=>{if(t=w.accept(t,C.NUMBER),t<=0)throw V.NUM;return q.gammaln(t)},GAUSS:t=>(t=w.accept(t,C.NUMBER),q.normal.cdf(t,0,1)-.5),GEOMEAN:(...t)=>{let e=[];return w.flattenParams(t,C.NUMBER,!0,(r,n)=>{typeof r=="number"&&e.push(r)}),q.geomean(e)},GROWTH:(t,e,r,n)=>{t=w.accept(t,C.ARRAY,void 0,!0,!0);for(let d=0;d<t.length;d++)if(typeof t[d]!="number")throw V.VALUE;e=w.accept(e,C.ARRAY,null,!0,!0);let o=e==null;if(e==null){e=[];for(let d=1;d<=t.length;d++)e.push(d)}else{if(e.length!==t.length)throw V.REF;for(let d=0;d<e.length;d++)if(typeof e[d]!="number")throw V.VALUE}if(r=w.accept(r,C.ARRAY,null,!1,!0),r==null&&o){r=[];for(let d=1;d<=t.length;d++)r.push(d);r=[r]}else r==null&&(r=Array.isArray(e[0])?e:[e]);n=w.accept(n,C.BOOLEAN,!0);let s=t.length,c=0,u=0,i=0,a=0;for(let d=0;d<s;d++){let h=e[d],m=Math.log(t[d]);c+=h,u+=m,i+=h*m,a+=h*h}c/=s,u/=s,i/=s,a/=s;let l,f;n?(l=(i-c*u)/(a-c*c),f=u-l*c):(l=i/a,f=0);let p=[];for(let d=0;d<r.length;d++){p[d]=[];for(let h=0;h<r[0].length;h++){if(typeof r[d][h]!="number")throw V.VALUE;p[d][h]=Math.exp(f+l*r[d][h])}}return p},HARMEAN:(...t)=>{let e=0,r=0;return w.flattenParams(t,C.NUMBER,!0,(n,o)=>{typeof n=="number"&&(r+=1/n,e++)}),e/r},"HYPGEOM.DIST":(t,e,r,n,o)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.NUMBER),o=w.accept(o,C.BOOLEAN),t=Math.trunc(t),e=Math.trunc(e),r=Math.trunc(r),n=Math.trunc(n),n<=0||t<0||e<=0||r<=0||e>n||r>n||e<t||r<t||t<e-n+r)throw V.NUM;function s(u,i,a,l){return fo.COMBIN(a,u)*fo.COMBIN(l-a,i-u)/fo.COMBIN(l,i)}function c(u,i,a,l){let f=0;for(let p=0;p<=u;p++)f+=s(p,i,a,l);return f}return o?c(t,e,r,n):s(t,e,r,n)},INTERCEPT:(t,e)=>{if(t=w.accept(t,C.ARRAY,void 0,!0,!0),e=w.accept(e,C.ARRAY,void 0,!0,!0),e.length!==t.length)throw V.NA;let r=[],n=[];for(let a=0;a<t.length;a++)typeof t[a]!="number"||typeof e[a]!="number"||(r.push(t[a]),n.push(e[a]));if(r.length<=1)throw V.DIV0;let o=q.mean(r),s=q.mean(n),c=0,u=0;for(let a=0;a<r.length;a++)c+=(n[a]-s)*(r[a]-o),u+=(n[a]-s)**2;let i=c/u;return o-i*s},KURT:(...t)=>{let e=0,r=[];w.flattenParams(t,C.NUMBER,!0,(s,c)=>{typeof s=="number"&&(e+=s,r.push(s))});let n=r.length;e/=n;let o=0;for(let s=0;s<n;s++)o+=Math.pow(r[s]-e,4);return o=o/Math.pow(q.stdev(r,!0),4),n*(n+1)/((n-1)*(n-2)*(n-3))*o-3*(n-1)*(n-1)/((n-2)*(n-3))},LINEST:()=>{},LOGEST:()=>{},"LOGNORM.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),t<=0||r<=0)throw V.NUM;return n?q.lognormal.cdf(t,e,r):q.lognormal.pdf(t,e,r)},"LOGNORM.INV":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<=0||t>=1||r<=0)throw V.NUM;return q.lognormal.inv(t,e,r)},"MODE.MULT":()=>{},"MODE.SNGL":()=>{},"NEGBINOM.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),t=Math.trunc(t),e=Math.trunc(e),r<0||r>1||t<0||e<1)throw V.NUM;return n?q.negbin.cdf(t,e,r):q.negbin.pdf(t,e,r)},"NORM.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),r<=0)throw V.NUM;return n?q.normal.cdf(t,e,r):q.normal.pdf(t,e,r)},"NORM.INV":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),t<=0||t>=1||r<=0)throw V.NUM;return q.normal.inv(t,e,r)},"NORM.S.DIST":(t,e)=>(t=w.accept(t,C.NUMBER),e=w.accept(e,C.BOOLEAN),e?q.normal.cdf(t,0,1):q.normal.pdf(t,0,1)),"NORM.S.INV":t=>{if(t=w.accept(t,C.NUMBER),t<=0||t>=1)throw V.NUM;return q.normal.inv(t,0,1)},PEARSON:()=>{},"PERCENTILE.EXC":()=>{},"PERCENTILE.INC":()=>{},"PERCENTRANK.EXC":()=>{},"PERCENTRANK.INC":()=>{},PERMUTATIONA:()=>{},PHI:t=>(t=w.accept(t,C.NUMBER),Math.exp(-.5*t*t)/Gp),"POISSON.DIST":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.BOOLEAN),t<0||e<0)throw V.NUM;return t=Math.trunc(t),r?q.poisson.cdf(t,e):q.poisson.pdf(t,e)},PROB:()=>{},"QUARTILE.EXC":()=>{},"QUARTILE.INC":()=>{},"RANK.AVG":()=>{},"RANK.EQ":()=>{},RSQ:()=>{},SKEW:()=>{},"SKEW.P":()=>{},SLOPE:()=>{},STANDARDIZE:(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),r<=0)throw V.NUM;return(t-e)/r},"STDEV.P":()=>{},"STDEV.S":()=>{},STDEVA:()=>{},STDEVPA:()=>{},STEYX:()=>{},"T.DIST":(t,e,r)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.BOOLEAN),e<1)throw V.NUM;return r?q.studentt.cdf(t,e):q.studentt.pdf(t,e)},"T.DIST.2T":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),e<1||t<0)throw V.NUM;return(1-q.studentt.cdf(t,e))*2},"T.DIST.RT":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),e<1)throw V.NUM;return 1-q.studentt.cdf(t,e)},"T.INV":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),t<=0||t>1||e<1)throw V.NUM;return e=e%1===0?e:Math.trunc(e),q.studentt.inv(t,e)},"T.INV.2T":(t,e)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),t<=0||t>1||e<1)throw V.NUM;return e=e%1===0?e:Math.trunc(e),Math.abs(q.studentt.inv(t/2,e))},"T.TEST":()=>{},TREND:()=>{},TRIMMEAN:()=>{},"VAR.P":()=>{},"VAR.S":()=>{},VARA:()=>{},VARPA:()=>{},"WEIBULL.DIST":(t,e,r,n)=>{if(t=w.accept(t,C.NUMBER),e=w.accept(e,C.NUMBER),r=w.accept(r,C.NUMBER),n=w.accept(n,C.BOOLEAN),t<0||e<=0||r<=0)throw V.NUM;return n?1-Math.exp(-Math.pow(t/r,e)):Math.pow(t,e-1)*Math.exp(-Math.pow(t/r,e))*e/Math.pow(r,e)},"Z.TEST":()=>{}};su.exports={DistributionFunctions:iu}});var fu=D((Av,lu)=>{var qp=qe(),{FormulaHelpers:Hp,Types:ho,Criteria:uu,Address:Nv}=$e(),{Infix:cu}=In(),pr=Hp,{DistributionFunctions:zp}=au(),Yp={AVEDEV:(...t)=>{let e=0,r=[];pr.flattenParams(t,ho.NUMBER,!0,(o,s)=>{typeof o=="number"&&(e+=o,r.push(o))});let n=e/r.length;e=0;for(let o=0;o<r.length;o++)e+=Math.abs(r[o]-n);return e/r.length},AVERAGE:(...t)=>{let e=0,r=0;return pr.flattenParams(t,ho.NUMBER,!0,(n,o)=>{typeof n=="number"&&(e+=n,r++)}),e/r},AVERAGEA:(...t)=>{let e=0,r=0;return pr.flattenParams(t,ho.NUMBER,!0,(n,o)=>{let s=typeof n;s==="number"?(e+=n,r++):s==="string"&&r++}),e/r},AVERAGEIF:(t,e,r,n)=>{let o=pr.retrieveRanges(t,e,n);e=o[0],n=o[1],r=pr.retrieveArg(t,r);let s=r.isArray;r=uu.parse(pr.accept(r));let c=0,u=0;if(e.forEach((i,a)=>{i.forEach((l,f)=>{let p=n[a][f];typeof p=="number"&&(r.op==="wc"?r.match===r.value.test(l)&&(c+=p,u++):cu.compareOp(l,r.op,r.value,Array.isArray(l),s)&&(c+=p,u++))})}),u===0)throw qp.DIV0;return c/u},AVERAGEIFS:()=>{},COUNT:(...t)=>{let e=0;return pr.flattenParams(t,null,!0,(r,n)=>{(n.isLiteral&&!isNaN(r)||typeof r=="number")&&e++}),e},COUNTIF:(t,e)=>{t=pr.accept(t,ho.ARRAY,void 0,!1,!0);let r=e.isArray;e=pr.accept(e);let n=0;return e=uu.parse(e),t.forEach(o=>{o.forEach(s=>{e.op==="wc"?e.match===e.value.test(s)&&n++:cu.compareOp(s,e.op,e.value,Array.isArray(s),r)&&n++})}),n},LARGE:()=>{},MAX:()=>{},MAXA:()=>{},MAXIFS:()=>{},MEDIAN:()=>{},MIN:()=>{},MINA:()=>{},MINIFS:()=>{},PERMUT:()=>{},PERMUTATIONA:()=>{},SMALL:()=>{}};lu.exports=Object.assign(Yp,zp)});var mu=D((Tv,du)=>{var It=qe(),{FormulaHelpers:$p,Types:Je}=$e(),Ve=$p,po=1e3*60*60*24,_i=new Date(Date.UTC(1900,0,1)),Kp=[void 0,0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,1,2,3,4,5,6,0],Xp=[void 0,[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],void 0,void 0,void 0,void 0,void 0,void 0,void 0,[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],hu=[void 0,[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],void 0,void 0,void 0,[0],[1],[2],[3],[4],[5],[6]],Qp=/^\s*(\d\d?)\s*(:\s*\d\d?)?\s*(:\s*\d\d?)?\s*(pm|am)?\s*$/i,Zp=/^\s*((\d\d?)\s*([-\/])\s*(\d\d?))([\d:.apm\s]*)$/i,Jp=/^\s*((\d\d?)\s*([-/])\s*(jan\w*|feb\w*|mar\w*|apr\w*|may\w*|jun\w*|jul\w*|aug\w*|sep\w*|oct\w*|nov\w*|dec\w*))([\d:.apm\s]*)$/i,jp=/^\s*((jan\w*|feb\w*|mar\w*|apr\w*|may\w*|jun\w*|jul\w*|aug\w*|sep\w*|oct\w*|nov\w*|dec\w*)\s*([-/])\s*(\d\d?))([\d:.apm\s]*)$/i;function e0(t){let e=t.match(Zp),r=t.match(Jp),n=t.match(jp);return e?t=e[1]+e[3]+new Date().getFullYear()+e[5]:r?t=r[1]+r[3]+new Date().getFullYear()+r[5]:n&&(t=n[1]+n[3]+new Date().getFullYear()+n[5]),new Date(Date.parse(`${t} UTC`))}function t0(t){let e=t.match(Qp);if(!e)return;let r=e[2]?e[2]:":00",n=e[3]?e[3]:":00",o=e[4]?" "+e[4]:"",s=new Date(Date.parse(`1/1/1900 ${e[1]+r+n+o} UTC`)),c=new Date;return c=new Date(Date.UTC(c.getFullYear(),c.getMonth(),c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds(),c.getMilliseconds())),new Date(Date.UTC(c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()))}function Dr(t){let e=t>-22038912e5?2:1;return Math.floor((t-_i)/864e5)+e}function r0(t){if(t<0)throw It.VALUE;return t<=60?new Date(_i.getTime()+(t-1)*864e5):new Date(_i.getTime()+(t-2)*864e5)}function pu(t){if(t instanceof Date)return{date:t};t=Ve.accept(t);let e=!0,r;return isNaN(t)?(r=t0(t),r?e=!1:r=e0(t)):(t=Number(t),r=r0(t)),{date:r,isDateGiven:e}}function me(t){return pu(t).date}function wi(t,e){return t.getUTCFullYear()===e.getUTCFullYear()&&t.getUTCMonth()===e.getUTCMonth()&&t.getUTCDate()===e.getUTCDate()}function n0(t){return t===1900?!0:new Date(t,1,29).getMonth()===1}var Wr={DATE:(t,e,r)=>{if(t=Ve.accept(t,Je.NUMBER),e=Ve.accept(e,Je.NUMBER),r=Ve.accept(r,Je.NUMBER),t<0||t>=1e4)throw It.NUM;return t<1900&&(t+=1900),Dr(Date.UTC(t,e-1,r))},DATEDIF:(t,e,r)=>{if(t=me(t),e=me(e),r=Ve.accept(r,Je.STRING).toLowerCase(),t>e)throw It.NUM;let n=e.getUTCFullYear()-t.getUTCFullYear(),o=e.getUTCMonth()-t.getUTCMonth(),s=e.getUTCDate()-t.getUTCDate(),c;switch(r){case"y":return c=o<0||o===0&&s<0?-1:0,c+n;case"m":return c=s<0?-1:0,n*12+o+c;case"d":return Math.floor(e-t)/po;case"md":return t.setUTCFullYear(e.getUTCFullYear()),s<0?t.setUTCMonth(e.getUTCMonth()-1):t.setUTCMonth(e.getUTCMonth()),Math.floor(e-t)/po;case"ym":return c=s<0?-1:0,(c+n*12+o)%12;case"yd":return o<0||o===0&&s<0?t.setUTCFullYear(e.getUTCFullYear()-1):t.setUTCFullYear(e.getUTCFullYear()),Math.floor(e-t)/po}},DATEVALUE:t=>{t=Ve.accept(t,Je.STRING);let{date:e,isDateGiven:r}=pu(t);if(!r)return 0;let n=Dr(e);if(n<0||n>2958465)throw It.VALUE;return n},DAY:t=>me(t).getUTCDate(),DAYS:(t,e)=>{t=me(t),e=me(e);let r=0;return e<-22038912e5&&-22038912e5<t&&(r=1),Math.floor(t-e)/po+r},DAYS360:(t,e,r)=>{t=me(t),e=me(e),r=Ve.accept(r,Je.BOOLEAN,!1),t.getUTCDate()===31&&t.setUTCDate(30),!r&&t.getUTCDate()<30&&e.getUTCDate()>30?e.setUTCMonth(e.getUTCMonth()+1,1):e.getUTCDate()===31&&e.setUTCDate(30);let n=e.getUTCFullYear()-t.getUTCFullYear(),o=e.getUTCMonth()-t.getUTCMonth(),s=e.getUTCDate()-t.getUTCDate();return o*30+s+n*12*30},EDATE:(t,e)=>(t=me(t),e=Ve.accept(e,Je.NUMBER),t.setUTCMonth(t.getUTCMonth()+e),Dr(t)),EOMONTH:(t,e)=>(t=me(t),e=Ve.accept(e,Je.NUMBER),t.setUTCMonth(t.getUTCMonth()+e+1,0),Dr(t)),HOUR:t=>me(t).getUTCHours(),ISOWEEKNUM:t=>{let e=me(t),r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),n=r.getUTCDay();r.setUTCDate(r.getUTCDate()+4-n);let o=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r-o)/864e5+1)/7)},MINUTE:t=>me(t).getUTCMinutes(),MONTH:t=>me(t).getUTCMonth()+1,NETWORKDAYS:(t,e,r)=>{t=me(t),e=me(e);let n=1;if(t>e){n=-1;let c=t;t=e,e=c}let o=[];r!=null&&Ve.flattenParams([r],Je.NUMBER,!1,c=>{o.push(me(c))});let s=0;for(;t<=e;){if(t.getUTCDay()!==0&&t.getUTCDay()!==6){let c=!1;for(let u=0;u<o.length;u++)if(wi(t,o[u])){c=!0;break}c||s++}t.setUTCDate(t.getUTCDate()+1)}return n*s},"NETWORKDAYS.INTL":(t,e,r,n)=>{t=me(t),e=me(e);let o=1;if(t>e){o=-1;let u=t;t=e,e=u}if(r=Ve.accept(r,null,1),r==="1111111")return 0;if(typeof r=="string"&&Number(r).toString()!==r){if(r.length!==7)throw It.VALUE;r=r.charAt(6)+r.slice(0,6);let u=[];for(let i=0;i<r.length;i++)r.charAt(i)==="1"&&u.push(i);r=u}else{if(typeof r!="number")throw It.VALUE;r=hu[r]}let s=[];n!=null&&Ve.flattenParams([n],Je.NUMBER,!1,u=>{s.push(me(u))});let c=0;for(;t<=e;){let u=!1;for(let i=0;i<r.length;i++)if(r[i]===t.getUTCDay()){u=!0;break}if(!u){let i=!1;for(let a=0;a<s.length;a++)if(wi(t,s[a])){i=!0;break}i||c++}t.setUTCDate(t.getUTCDate()+1)}return o*c},NOW:()=>{let t=new Date;return Dr(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()))+(3600*t.getHours()+60*t.getMinutes()+t.getSeconds())/86400},SECOND:t=>me(t).getUTCSeconds(),TIME:(t,e,r)=>{if(t=Ve.accept(t,Je.NUMBER),e=Ve.accept(e,Je.NUMBER),r=Ve.accept(r,Je.NUMBER),t<0||t>32767||e<0||e>32767||r<0||r>32767)throw It.NUM;return(3600*t+60*e+r)/86400},TIMEVALUE:t=>(t=me(t),(3600*t.getUTCHours()+60*t.getUTCMinutes()+t.getUTCSeconds())/86400),TODAY:()=>{let t=new Date;return Dr(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()))},WEEKDAY:(t,e)=>{let r=me(t);e=Ve.accept(e,Je.NUMBER,1);let n=r.getUTCDay(),o=Xp[e];if(!o)throw It.NUM;return o[n]},WEEKNUM:(t,e)=>{let r=me(t);if(e=Ve.accept(e,Je.NUMBER,1),e===21)return Wr.ISOWEEKNUM(t);let n=Kp[e],o=new Date(Date.UTC(r.getUTCFullYear(),0,1)),s=o.getUTCDay()<n?1:0;return Math.ceil(((r-o)/864e5+1)/7)+s},WORKDAY:(t,e,r)=>Wr["WORKDAY.INTL"](t,e,1,r),"WORKDAY.INTL":(t,e,r,n)=>{if(t=me(t),e=Ve.accept(e,Je.NUMBER),r=Ve.accept(r,null,1),r==="1111111")throw It.VALUE;if(typeof r=="string"&&Number(r).toString()!==r){if(r.length!==7)throw It.VALUE;r=r.charAt(6)+r.slice(0,6);let c=[];for(let u=0;u<r.length;u++)r.charAt(u)==="1"&&c.push(u);r=c}else{if(typeof r!="number")throw It.VALUE;if(r=hu[r],r==null)throw It.NUM}let o=[];n!=null&&Ve.flattenParams([n],Je.NUMBER,!1,c=>{o.push(me(c))}),t.setUTCDate(t.getUTCDate()+1);let s=0;for(;s<e;){let c=!1;for(let u=0;u<r.length;u++)if(r[u]===t.getUTCDay()){c=!0;break}if(!c){let u=!1;for(let i=0;i<o.length;i++)if(wi(t,o[i])){u=!0;break}u||s++}t.setUTCDate(t.getUTCDate()+1)}return Dr(t)-1},YEAR:t=>me(t).getUTCFullYear(),YEARFRAC:(t,e,r)=>{if(t=me(t),e=me(e),t>e){let a=t;t=e,e=a}if(r=Ve.accept(r,Je.NUMBER,0),r=Math.trunc(r),r<0||r>4)throw It.VALUE;let n=t.getUTCDate(),o=t.getUTCMonth()+1,s=t.getUTCFullYear(),c=e.getUTCDate(),u=e.getUTCMonth()+1,i=e.getUTCFullYear();switch(r){case 0:return n===31&&c===31?(n=30,c=30):n===31?n=30:n===30&&c===31&&(c=30),Math.abs(c+u*30+i*360-(n+o*30+s*360))/360;case 1:if(i-s<2){let a=n0(s)&&s!==1900?366:365;return Wr.DAYS(e,t)/a}else{let a=i-s+1,f=(new Date(i+1,0,1)-new Date(s,0,1))/1e3/60/60/24/a;return Wr.DAYS(e,t)/f}case 2:return Math.abs(Wr.DAYS(e,t)/360);case 3:return Math.abs(Wr.DAYS(e,t)/365);case 4:return Math.abs(c+u*30+i*360-(n+o*30+s*360))/360}}};du.exports=Wr});var Ru=D((Ov,yu)=>{var gu=qe(),{FormulaHelpers:o0,Types:vu}=$e(),Eu=o0,i0={ENCODEURL:t=>encodeURIComponent(Eu.accept(t,vu.STRING)),FILTERXML:()=>{},WEBSERVICE:(t,e)=>{throw gu.ERROR("WEBSERVICE is not supported in sync mode.")}};yu.exports=i0});var ki=D(mo=>{"use strict";Object.defineProperty(mo,"__esModule",{value:!0});mo.VERSION=void 0;mo.VERSION="7.1.2"});var se=D((exports,module)=>{"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.peek=exports.toFastProperties=exports.applyMixins=exports.isES2015MapSupported=exports.PRINT_WARNING=exports.PRINT_ERROR=exports.packArray=exports.IDENTITY=exports.NOOP=exports.merge=exports.groupBy=exports.defaults=exports.assignNoOverwrite=exports.assign=exports.zipObject=exports.sortBy=exports.indexOf=exports.some=exports.difference=exports.every=exports.isObject=exports.isRegExp=exports.isArray=exports.partial=exports.uniq=exports.compact=exports.reduce=exports.findAll=exports.find=exports.cloneObj=exports.cloneArr=exports.contains=exports.has=exports.pick=exports.reject=exports.filter=exports.dropRight=exports.drop=exports.isFunction=exports.isUndefined=exports.isString=exports.forEach=exports.last=exports.first=exports.flatten=exports.map=exports.mapValues=exports.values=exports.keys=exports.isEmpty=void 0;exports.timer=void 0;function isEmpty(t){return t&&t.length===0}exports.isEmpty=isEmpty;function keys(t){return t==null?[]:Object.keys(t)}exports.keys=keys;function values(t){for(var e=[],r=Object.keys(t),n=0;n<r.length;n++)e.push(t[r[n]]);return e}exports.values=values;function mapValues(t,e){for(var r=[],n=keys(t),o=0;o<n.length;o++){var s=n[o];r.push(e.call(null,t[s],s))}return r}exports.mapValues=mapValues;function map(t,e){for(var r=[],n=0;n<t.length;n++)r.push(e.call(null,t[n],n));return r}exports.map=map;function flatten(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];Array.isArray(n)?e=e.concat(flatten(n)):e.push(n)}return e}exports.flatten=flatten;function first(t){return isEmpty(t)?void 0:t[0]}exports.first=first;function last(t){var e=t&&t.length;return e?t[e-1]:void 0}exports.last=last;function forEach(t,e){if(Array.isArray(t))for(var r=0;r<t.length;r++)e.call(null,t[r],r);else if(isObject(t))for(var n=keys(t),r=0;r<n.length;r++){var o=n[r],s=t[o];e.call(null,s,o)}else throw Error("non exhaustive match")}exports.forEach=forEach;function isString(t){return typeof t=="string"}exports.isString=isString;function isUndefined(t){return t===void 0}exports.isUndefined=isUndefined;function isFunction(t){return t instanceof Function}exports.isFunction=isFunction;function drop(t,e){return e===void 0&&(e=1),t.slice(e,t.length)}exports.drop=drop;function dropRight(t,e){return e===void 0&&(e=1),t.slice(0,t.length-e)}exports.dropRight=dropRight;function filter(t,e){var r=[];if(Array.isArray(t))for(var n=0;n<t.length;n++){var o=t[n];e.call(null,o)&&r.push(o)}return r}exports.filter=filter;function reject(t,e){return filter(t,function(r){return!e(r)})}exports.reject=reject;function pick(t,e){for(var r=Object.keys(t),n={},o=0;o<r.length;o++){var s=r[o],c=t[s];e(c)&&(n[s]=c)}return n}exports.pick=pick;function has(t,e){return isObject(t)?t.hasOwnProperty(e):!1}exports.has=has;function contains(t,e){return find(t,function(r){return r===e})!==void 0}exports.contains=contains;function cloneArr(t){for(var e=[],r=0;r<t.length;r++)e.push(t[r]);return e}exports.cloneArr=cloneArr;function cloneObj(t){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}exports.cloneObj=cloneObj;function find(t,e){for(var r=0;r<t.length;r++){var n=t[r];if(e.call(null,n))return n}}exports.find=find;function findAll(t,e){for(var r=[],n=0;n<t.length;n++){var o=t[n];e.call(null,o)&&r.push(o)}return r}exports.findAll=findAll;function reduce(t,e,r){for(var n=Array.isArray(t),o=n?t:values(t),s=n?[]:keys(t),c=r,u=0;u<o.length;u++)c=e.call(null,c,o[u],n?u:s[u]);return c}exports.reduce=reduce;function compact(t){return reject(t,function(e){return e==null})}exports.compact=compact;function uniq(t,e){e===void 0&&(e=function(n){return n});var r=[];return reduce(t,function(n,o){var s=e(o);return contains(r,s)?n:(r.push(s),n.concat(o))},[])}exports.uniq=uniq;function partial(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];var n=[null],o=n.concat(e);return Function.bind.apply(t,o)}exports.partial=partial;function isArray(t){return Array.isArray(t)}exports.isArray=isArray;function isRegExp(t){return t instanceof RegExp}exports.isRegExp=isRegExp;function isObject(t){return t instanceof Object}exports.isObject=isObject;function every(t,e){for(var r=0;r<t.length;r++)if(!e(t[r],r))return!1;return!0}exports.every=every;function difference(t,e){return reject(t,function(r){return contains(e,r)})}exports.difference=difference;function some(t,e){for(var r=0;r<t.length;r++)if(e(t[r]))return!0;return!1}exports.some=some;function indexOf(t,e){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return-1}exports.indexOf=indexOf;function sortBy(t,e){var r=cloneArr(t);return r.sort(function(n,o){return e(n)-e(o)}),r}exports.sortBy=sortBy;function zipObject(t,e){if(t.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var r={},n=0;n<t.length;n++)r[t[n]]=e[n];return r}exports.zipObject=zipObject;function assign(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n++)for(var o=e[n],s=keys(o),c=0;c<s.length;c++){var u=s[c];t[u]=o[u]}return t}exports.assign=assign;function assignNoOverwrite(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];for(var n=0;n<e.length;n++)for(var o=e[n],s=keys(o),c=0;c<s.length;c++){var u=s[c];has(t,u)||(t[u]=o[u])}return t}exports.assignNoOverwrite=assignNoOverwrite;function defaults(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return assignNoOverwrite.apply(null,[{}].concat(t))}exports.defaults=defaults;function groupBy(t,e){var r={};return forEach(t,function(n){var o=e(n),s=r[o];s?s.push(n):r[o]=[n]}),r}exports.groupBy=groupBy;function merge(t,e){for(var r=cloneObj(t),n=keys(e),o=0;o<n.length;o++){var s=n[o],c=e[s];r[s]=c}return r}exports.merge=merge;function NOOP(){}exports.NOOP=NOOP;function IDENTITY(t){return t}exports.IDENTITY=IDENTITY;function packArray(t){for(var e=[],r=0;r<t.length;r++){var n=t[r];e.push(n!==void 0?n:void 0)}return e}exports.packArray=packArray;function PRINT_ERROR(t){console&&console.error&&console.error("Error: "+t)}exports.PRINT_ERROR=PRINT_ERROR;function PRINT_WARNING(t){console&&console.warn&&console.warn("Warning: "+t)}exports.PRINT_WARNING=PRINT_WARNING;function isES2015MapSupported(){return typeof Map=="function"}exports.isES2015MapSupported=isES2015MapSupported;function applyMixins(t,e){e.forEach(function(r){var n=r.prototype;Object.getOwnPropertyNames(n).forEach(function(o){if(o!=="constructor"){var s=Object.getOwnPropertyDescriptor(n,o);s&&(s.get||s.set)?Object.defineProperty(t.prototype,o,s):t.prototype[o]=r.prototype[o]}})})}exports.applyMixins=applyMixins;function toFastProperties(toBecomeFast){function FakeConstructor(){}FakeConstructor.prototype=toBecomeFast;var fakeInstance=new FakeConstructor;function fakeAccess(){return typeof fakeInstance.bar}return fakeAccess(),fakeAccess(),toBecomeFast;eval(toBecomeFast)}exports.toFastProperties=toFastProperties;function peek(t){return t[t.length-1]}exports.peek=peek;function timer(t){var e=new Date().getTime(),r=t(),n=new Date().getTime(),o=n-e;return{time:o,value:r}}exports.timer=timer});var vo=D((Nu,go)=>{(function(t,e){typeof define=="function"&&define.amd?define([],e):typeof go=="object"&&go.exports?go.exports=e():t.regexpToAst=e()})(typeof self<"u"?self:Nu,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(h){this.idx=h.idx,this.input=h.input,this.groupIdx=h.groupIdx},t.prototype.pattern=function(h){this.idx=0,this.input=h,this.groupIdx=0,this.consumeChar("/");var m=this.disjunction();this.consumeChar("/");for(var E={type:"Flags",loc:{begin:this.idx,end:h.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(E,"global");break;case"i":c(E,"ignoreCase");break;case"m":c(E,"multiLine");break;case"u":c(E,"unicode");break;case"y":c(E,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:E,value:m,loc:this.loc(0)}},t.prototype.disjunction=function(){var h=[],m=this.idx;for(h.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),h.push(this.alternative());return{type:"Disjunction",value:h,loc:this.loc(m)}},t.prototype.alternative=function(){for(var h=[],m=this.idx;this.isTerm();)h.push(this.term());return{type:"Alternative",value:h,loc:this.loc(m)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var h=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(h)};case"$":return{type:"EndAnchor",loc:this.loc(h)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(h)};case"B":return{type:"NonWordBoundary",loc:this.loc(h)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var m;switch(this.popChar()){case"=":m="Lookahead";break;case"!":m="NegativeLookahead";break}u(m);var E=this.disjunction();return this.consumeChar(")"),{type:m,value:E,loc:this.loc(h)}}i()},t.prototype.quantifier=function(h){var m,E=this.idx;switch(this.popChar()){case"*":m={atLeast:0,atMost:1/0};break;case"+":m={atLeast:1,atMost:1/0};break;case"?":m={atLeast:0,atMost:1};break;case"{":var g=this.integerIncludingZero();switch(this.popChar()){case"}":m={atLeast:g,atMost:g};break;case",":var v;this.isDigit()?(v=this.integerIncludingZero(),m={atLeast:g,atMost:v}):m={atLeast:g,atMost:1/0},this.consumeChar("}");break}if(h===!0&&m===void 0)return;u(m);break}if(!(h===!0&&m===void 0))return u(m),this.peekChar(0)==="?"?(this.consumeChar("?"),m.greedy=!1):m.greedy=!0,m.type="Quantifier",m.loc=this.loc(E),m},t.prototype.atom=function(){var h,m=this.idx;switch(this.peekChar()){case".":h=this.dotAll();break;case"\\":h=this.atomEscape();break;case"[":h=this.characterClass();break;case"(":h=this.group();break}return h===void 0&&this.isPatternCharacter()&&(h=this.patternCharacter()),u(h),h.loc=this.loc(m),this.isQuantifier()&&(h.quantifier=this.quantifier()),h},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
9
+ `),o("\r"),o("\u2028"),o("\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(){var h=this.positiveInteger();return{type:"GroupBackReference",value:h}},t.prototype.characterClassEscape=function(){var h,m=!1;switch(this.popChar()){case"d":h=l;break;case"D":h=l,m=!0;break;case"s":h=p;break;case"S":h=p,m=!0;break;case"w":h=f;break;case"W":h=f,m=!0;break}return u(h),{type:"Set",value:h,complement:m}},t.prototype.controlEscapeAtom=function(){var h;switch(this.popChar()){case"f":h=o("\f");break;case"n":h=o(`
10
+ `);break;case"r":h=o("\r");break;case"t":h=o(" ");break;case"v":h=o("\v");break}return u(h),{type:"Character",value:h}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var h=this.popChar();if(/[a-zA-Z]/.test(h)===!1)throw Error("Invalid ");var m=h.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:m}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\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(){var h=this.popChar();return{type:"Character",value:o(h)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
11
+ `:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var h=this.popChar();return{type:"Character",value:o(h)}}},t.prototype.characterClass=function(){var h=[],m=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),m=!0);this.isClassAtom();){var E=this.classAtom(),g=E.type==="Character";if(g&&this.isRangeDash()){this.consumeChar("-");var v=this.classAtom(),R=v.type==="Character";if(R){if(v.value<E.value)throw Error("Range out of order in character class");h.push({from:E.value,to:v.value})}else s(E.value,h),h.push(o("-")),s(v.value,h)}else s(E.value,h)}return this.consumeChar("]"),{type:"Set",complement:m,value:h}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
12
+ `: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:o("\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 h=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),h=!1;break;default:this.groupIdx++;break}var m=this.disjunction();this.consumeChar(")");var E={type:"Group",capturing:h,value:m};return h&&(E.idx=this.groupIdx),E},t.prototype.positiveInteger=function(){var h=this.popChar();if(n.test(h)===!1)throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)h+=this.popChar();return parseInt(h,10)},t.prototype.integerIncludingZero=function(){var h=this.popChar();if(r.test(h)===!1)throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)h+=this.popChar();return parseInt(h,10)},t.prototype.patternCharacter=function(){var h=this.popChar();switch(h){case`
13
+ `: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:o(h)}}},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(h){switch(h===void 0&&(h=0),this.peekChar(h)){case"]":case`
14
+ `: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 h=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(h)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
15
+ `:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(h){for(var m="",E=0;E<h;E++){var g=this.popChar();if(e.test(g)===!1)throw Error("Expecting a HexDecimal digits");m+=g}var v=parseInt(m,16);return{type:"Character",value:v}},t.prototype.peekChar=function(h){return h===void 0&&(h=0),this.input[this.idx+h]},t.prototype.popChar=function(){var h=this.peekChar(0);return this.consumeChar(),h},t.prototype.consumeChar=function(h){if(h!==void 0&&this.input[this.idx]!==h)throw Error("Expected: '"+h+"' 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(h){return{begin:h,end:this.idx}};var e=/[0-9a-fA-F]/,r=/[0-9]/,n=/[1-9]/;function o(h){return h.charCodeAt(0)}function s(h,m){h.length!==void 0?h.forEach(function(E){m.push(E)}):m.push(h)}function c(h,m){if(h[m]===!0)throw"duplicate flag "+m;h[m]=!0}function u(h){if(h===void 0)throw Error("Internal Error - Should never get here!")}function i(){throw Error("Internal Error - Should never get here!")}var a,l=[];for(a=o("0");a<=o("9");a++)l.push(a);var f=[o("_")].concat(l);for(a=o("a");a<=o("z");a++)f.push(a);for(a=o("A");a<=o("Z");a++)f.push(a);var p=[o(" "),o("\f"),o(`
16
+ `),o("\r"),o(" "),o("\v"),o(" "),o("\xA0"),o("\u1680"),o("\u2000"),o("\u2001"),o("\u2002"),o("\u2003"),o("\u2004"),o("\u2005"),o("\u2006"),o("\u2007"),o("\u2008"),o("\u2009"),o("\u200A"),o("\u2028"),o("\u2029"),o("\u202F"),o("\u205F"),o("\u3000"),o("\uFEFF")];function d(){}return d.prototype.visitChildren=function(h){for(var m in h){var E=h[m];h.hasOwnProperty(m)&&(E.type!==void 0?this.visit(E):Array.isArray(E)&&E.forEach(function(g){this.visit(g)},this))}},d.prototype.visit=function(h){switch(h.type){case"Pattern":this.visitPattern(h);break;case"Flags":this.visitFlags(h);break;case"Disjunction":this.visitDisjunction(h);break;case"Alternative":this.visitAlternative(h);break;case"StartAnchor":this.visitStartAnchor(h);break;case"EndAnchor":this.visitEndAnchor(h);break;case"WordBoundary":this.visitWordBoundary(h);break;case"NonWordBoundary":this.visitNonWordBoundary(h);break;case"Lookahead":this.visitLookahead(h);break;case"NegativeLookahead":this.visitNegativeLookahead(h);break;case"Character":this.visitCharacter(h);break;case"Set":this.visitSet(h);break;case"Group":this.visitGroup(h);break;case"GroupBackReference":this.visitGroupBackReference(h);break;case"Quantifier":this.visitQuantifier(h);break}this.visitChildren(h)},d.prototype.visitPattern=function(h){},d.prototype.visitFlags=function(h){},d.prototype.visitDisjunction=function(h){},d.prototype.visitAlternative=function(h){},d.prototype.visitStartAnchor=function(h){},d.prototype.visitEndAnchor=function(h){},d.prototype.visitWordBoundary=function(h){},d.prototype.visitNonWordBoundary=function(h){},d.prototype.visitLookahead=function(h){},d.prototype.visitNegativeLookahead=function(h){},d.prototype.visitCharacter=function(h){},d.prototype.visitSet=function(h){},d.prototype.visitGroup=function(h){},d.prototype.visitGroupBackReference=function(h){},d.prototype.visitQuantifier=function(h){},{RegExpParser:t,BaseRegExpVisitor:d,VERSION:"0.5.0"}})});var yo=D(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.clearRegExpParserCache=rn.getRegExpAst=void 0;var s0=vo(),Eo={},a0=new s0.RegExpParser;function u0(t){var e=t.toString();if(Eo.hasOwnProperty(e))return Eo[e];var r=a0.pattern(e);return Eo[e]=r,r}rn.getRegExpAst=u0;function c0(){Eo={}}rn.clearRegExpParserCache=c0});var Mu=D(Nt=>{"use strict";var l0=Nt&&Nt.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(Nt,"__esModule",{value:!0});Nt.canMatchCharCode=Nt.firstCharOptimizedIndices=Nt.getOptimizedStartCodesIndices=Nt.failedOptimizationPrefixMsg=void 0;var Tu=vo(),Ut=se(),Ou=yo(),dr=xi(),Iu="Complement Sets are not supported for first char optimization";Nt.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
17
+ `;function f0(t,e){e===void 0&&(e=!1);try{var r=Ou.getRegExpAst(t),n=No(r.value,{},r.flags.ignoreCase);return n}catch(s){if(s.message===Iu)e&&Ut.PRINT_WARNING(""+Nt.failedOptimizationPrefixMsg+(" Unable to optimize: < "+t.toString()+` >
18
+ `)+` Complement Sets cannot be automatically optimized.
19
+ This will disable the lexer's first char optimizations.
20
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var o="";e&&(o=`
21
+ This will disable the lexer's first char optimizations.
22
+ See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Ut.PRINT_ERROR(Nt.failedOptimizationPrefixMsg+`
23
+ `+(" Failed parsing: < "+t.toString()+` >
24
+ `)+(" Using the regexp-to-ast library version: "+Tu.VERSION+`
25
+ `)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+o)}}return[]}Nt.getOptimizedStartCodesIndices=f0;function No(t,e,r){switch(t.type){case"Disjunction":for(var n=0;n<t.value.length;n++)No(t.value[n],e,r);break;case"Alternative":for(var o=t.value,n=0;n<o.length;n++){var s=o[n];switch(s.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var c=s;switch(c.type){case"Character":Ro(c.value,e,r);break;case"Set":if(c.complement===!0)throw Error(Iu);Ut.forEach(c.value,function(a){if(typeof a=="number")Ro(a,e,r);else{var l=a;if(r===!0)for(var f=l.from;f<=l.to;f++)Ro(f,e,r);else{for(var f=l.from;f<=l.to&&f<dr.minOptimizationVal;f++)Ro(f,e,r);if(l.to>=dr.minOptimizationVal)for(var p=l.from>=dr.minOptimizationVal?l.from:dr.minOptimizationVal,d=l.to,h=dr.charCodeToOptimizedIndex(p),m=dr.charCodeToOptimizedIndex(d),E=h;E<=m;E++)e[E]=E}}});break;case"Group":No(c.value,e,r);break;default:throw Error("Non Exhaustive Match")}var u=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&bi(c)===!1||c.type!=="Group"&&u===!1)break}break;default:throw Error("non exhaustive match!")}return Ut.values(e)}Nt.firstCharOptimizedIndices=No;function Ro(t,e,r){var n=dr.charCodeToOptimizedIndex(t);e[n]=n,r===!0&&h0(t,e)}function h0(t,e){var r=String.fromCharCode(t),n=r.toUpperCase();if(n!==r){var o=dr.charCodeToOptimizedIndex(n.charCodeAt(0));e[o]=o}else{var s=r.toLowerCase();if(s!==r){var o=dr.charCodeToOptimizedIndex(s.charCodeAt(0));e[o]=o}}}function Au(t,e){return Ut.find(t.value,function(r){if(typeof r=="number")return Ut.contains(e,r);var n=r;return Ut.find(e,function(o){return n.from<=o&&o<=n.to})!==void 0})}function bi(t){return t.quantifier&&t.quantifier.atLeast===0?!0:t.value?Ut.isArray(t.value)?Ut.every(t.value,bi):bi(t.value):!1}var p0=(function(t){l0(e,t);function e(r){var n=t.call(this)||this;return n.targetCharCodes=r,n.found=!1,n}return e.prototype.visitChildren=function(r){if(this.found!==!0){switch(r.type){case"Lookahead":this.visitLookahead(r);return;case"NegativeLookahead":this.visitNegativeLookahead(r);return}t.prototype.visitChildren.call(this,r)}},e.prototype.visitCharacter=function(r){Ut.contains(this.targetCharCodes,r.value)&&(this.found=!0)},e.prototype.visitSet=function(r){r.complement?Au(r,this.targetCharCodes)===void 0&&(this.found=!0):Au(r,this.targetCharCodes)!==void 0&&(this.found=!0)},e})(Tu.BaseRegExpVisitor);function d0(t,e){if(e instanceof RegExp){var r=Ou.getRegExpAst(e),n=new p0(t);return n.visit(r),n.found}else return Ut.find(e,function(o){return Ut.contains(t,o.charCodeAt(0))})!==void 0}Nt.canMatchCharCode=d0});var xi=D(F=>{"use strict";var Cu=F&&F.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(F,"__esModule",{value:!0});F.charCodeToOptimizedIndex=F.minOptimizationVal=F.buildLineBreakIssueMessage=F.LineTerminatorOptimizedTester=F.isShortPattern=F.isCustomPattern=F.cloneEmptyGroups=F.performWarningRuntimeChecks=F.performRuntimeChecks=F.addStickyFlag=F.addStartOfInput=F.findUnreachablePatterns=F.findModesThatDoNotExist=F.findInvalidGroupType=F.findDuplicatePatterns=F.findUnsupportedFlags=F.findStartOfInputAnchor=F.findEmptyMatchRegExps=F.findEndOfInputAnchor=F.findInvalidPatterns=F.findMissingPatterns=F.validatePatterns=F.analyzeTokenTypes=F.enableSticky=F.disableSticky=F.SUPPORT_STICKY=F.MODES=F.DEFAULT_MODE=void 0;var wu=vo(),ve=Mn(),k=se(),nn=Mu(),_u=yo(),Jt="PATTERN";F.DEFAULT_MODE="defaultMode";F.MODES="modes";F.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function m0(){F.SUPPORT_STICKY=!1}F.disableSticky=m0;function g0(){F.SUPPORT_STICKY=!0}F.enableSticky=g0;function v0(t,e){e=k.defaults(e,{useSticky:F.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
26
+ `],tracer:function(v,R){return R()}});var r=e.tracer;r("initCharCodeToOptimizedIndexMap",function(){C0()});var n;r("Reject Lexer.NA",function(){n=k.reject(t,function(v){return v[Jt]===ve.Lexer.NA})});var o=!1,s;r("Transform Patterns",function(){o=!1,s=k.map(n,function(v){var R=v[Jt];if(k.isRegExp(R)){var N=R.source;return N.length===1&&N!=="^"&&N!=="$"&&N!=="."&&!R.ignoreCase?N:N.length===2&&N[0]==="\\"&&!k.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],N[1])?N[1]:e.useSticky?Pi(R):Ui(R)}else{if(k.isFunction(R))return o=!0,{exec:R};if(k.has(R,"exec"))return o=!0,R;if(typeof R=="string"){if(R.length===1)return R;var A=R.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),y=new RegExp(A);return e.useSticky?Pi(y):Ui(y)}else throw Error("non exhaustive match")}})});var c,u,i,a,l;r("misc mapping",function(){c=k.map(n,function(v){return v.tokenTypeIdx}),u=k.map(n,function(v){var R=v.GROUP;if(R!==ve.Lexer.SKIPPED){if(k.isString(R))return R;if(k.isUndefined(R))return!1;throw Error("non exhaustive match")}}),i=k.map(n,function(v){var R=v.LONGER_ALT;if(R){var N=k.indexOf(n,R);return N}}),a=k.map(n,function(v){return v.PUSH_MODE}),l=k.map(n,function(v){return k.has(v,"POP_MODE")})});var f;r("Line Terminator Handling",function(){var v=qu(e.lineTerminatorCharacters);f=k.map(n,function(R){return!1}),e.positionTracking!=="onlyOffset"&&(f=k.map(n,function(R){if(k.has(R,"LINE_BREAKS"))return R.LINE_BREAKS;if(Vu(R,v)===!1)return nn.canMatchCharCode(v,R.PATTERN)}))});var p,d,h,m;r("Misc Mapping #2",function(){p=k.map(n,Fi),d=k.map(s,Wu),h=k.reduce(n,function(v,R){var N=R.GROUP;return k.isString(N)&&N!==ve.Lexer.SKIPPED&&(v[N]=[]),v},{}),m=k.map(s,function(v,R){return{pattern:s[R],longerAlt:i[R],canLineTerminator:f[R],isCustom:p[R],short:d[R],group:u[R],push:a[R],pop:l[R],tokenTypeIdx:c[R],tokenType:n[R]}})});var E=!0,g=[];return e.safeMode||r("First Char Optimization",function(){g=k.reduce(n,function(v,R,N){if(typeof R.PATTERN=="string"){var A=R.PATTERN.charCodeAt(0),y=Si(A);Li(v,y,m[N])}else if(k.isArray(R.START_CHARS_HINT)){var T;k.forEach(R.START_CHARS_HINT,function(M){var b=typeof M=="string"?M.charCodeAt(0):M,S=Si(b);T!==S&&(T=S,Li(v,S,m[N]))})}else if(k.isRegExp(R.PATTERN))if(R.PATTERN.unicode)E=!1,e.ensureOptimizations&&k.PRINT_ERROR(""+nn.failedOptimizationPrefixMsg+(" Unable to analyze < "+R.PATTERN.toString()+` > pattern.
27
+ `)+` The regexp unicode flag is not currently supported by the regexp-to-ast library.
28
+ This will disable the lexer's first char optimizations.
29
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var I=nn.getOptimizedStartCodesIndices(R.PATTERN,e.ensureOptimizations);k.isEmpty(I)&&(E=!1),k.forEach(I,function(M){Li(v,M,m[N])})}else e.ensureOptimizations&&k.PRINT_ERROR(""+nn.failedOptimizationPrefixMsg+(" TokenType: <"+R.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
30
+ `)+` This will disable the lexer's first char optimizations.
31
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),E=!1;return v},[])}),r("ArrayPacking",function(){g=k.packArray(g)}),{emptyGroups:h,patternIdxToConfig:m,charCodeToPatternIdxToConfig:g,hasCustom:o,canBeOptimized:E}}F.analyzeTokenTypes=v0;function E0(t,e){var r=[],n=ku(t);r=r.concat(n.errors);var o=bu(n.valid),s=o.valid;return r=r.concat(o.errors),r=r.concat(y0(s)),r=r.concat(Fu(s)),r=r.concat(Bu(s,e)),r=r.concat(Du(s)),r}F.validatePatterns=E0;function y0(t){var e=[],r=k.filter(t,function(n){return k.isRegExp(n[Jt])});return e=e.concat(xu(r)),e=e.concat(Uu(r)),e=e.concat(Pu(r)),e=e.concat(Su(r)),e=e.concat(Lu(r)),e}function ku(t){var e=k.filter(t,function(o){return!k.has(o,Jt)}),r=k.map(e,function(o){return{message:"Token Type: ->"+o.name+"<- missing static 'PATTERN' property",type:ve.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[o]}}),n=k.difference(t,e);return{errors:r,valid:n}}F.findMissingPatterns=ku;function bu(t){var e=k.filter(t,function(o){var s=o[Jt];return!k.isRegExp(s)&&!k.isFunction(s)&&!k.has(s,"exec")&&!k.isString(s)}),r=k.map(e,function(o){return{message:"Token Type: ->"+o.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:ve.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[o]}}),n=k.difference(t,e);return{errors:r,valid:n}}F.findInvalidPatterns=bu;var R0=/[^\\][\$]/;function xu(t){var e=(function(o){Cu(s,o);function s(){var c=o!==null&&o.apply(this,arguments)||this;return c.found=!1,c}return s.prototype.visitEndAnchor=function(c){this.found=!0},s})(wu.BaseRegExpVisitor),r=k.filter(t,function(o){var s=o[Jt];try{var c=_u.getRegExpAst(s),u=new e;return u.visit(c),u.found}catch{return R0.test(s.source)}}),n=k.map(r,function(o){return{message:`Unexpected RegExp Anchor Error:
32
+ Token Type: ->`+o.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
33
+ See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ve.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[o]}});return n}F.findEndOfInputAnchor=xu;function Lu(t){var e=k.filter(t,function(n){var o=n[Jt];return o.test("")}),r=k.map(e,function(n){return{message:"Token Type: ->"+n.name+"<- static 'PATTERN' must not match an empty string",type:ve.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[n]}});return r}F.findEmptyMatchRegExps=Lu;var N0=/[^\\[][\^]|^\^/;function Uu(t){var e=(function(o){Cu(s,o);function s(){var c=o!==null&&o.apply(this,arguments)||this;return c.found=!1,c}return s.prototype.visitStartAnchor=function(c){this.found=!0},s})(wu.BaseRegExpVisitor),r=k.filter(t,function(o){var s=o[Jt];try{var c=_u.getRegExpAst(s),u=new e;return u.visit(c),u.found}catch{return N0.test(s.source)}}),n=k.map(r,function(o){return{message:`Unexpected RegExp Anchor Error:
34
+ Token Type: ->`+o.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
35
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:ve.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[o]}});return n}F.findStartOfInputAnchor=Uu;function Pu(t){var e=k.filter(t,function(n){var o=n[Jt];return o instanceof RegExp&&(o.multiline||o.global)}),r=k.map(e,function(n){return{message:"Token Type: ->"+n.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:ve.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[n]}});return r}F.findUnsupportedFlags=Pu;function Su(t){var e=[],r=k.map(t,function(s){return k.reduce(t,function(c,u){return s.PATTERN.source===u.PATTERN.source&&!k.contains(e,u)&&u.PATTERN!==ve.Lexer.NA&&(e.push(u),c.push(u)),c},[])});r=k.compact(r);var n=k.filter(r,function(s){return s.length>1}),o=k.map(n,function(s){var c=k.map(s,function(i){return i.name}),u=k.first(s).PATTERN;return{message:"The same RegExp pattern ->"+u+"<-"+("has been used in all of the following Token Types: "+c.join(", ")+" <-"),type:ve.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:s}});return o}F.findDuplicatePatterns=Su;function Fu(t){var e=k.filter(t,function(n){if(!k.has(n,"GROUP"))return!1;var o=n.GROUP;return o!==ve.Lexer.SKIPPED&&o!==ve.Lexer.NA&&!k.isString(o)}),r=k.map(e,function(n){return{message:"Token Type: ->"+n.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:ve.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[n]}});return r}F.findInvalidGroupType=Fu;function Bu(t,e){var r=k.filter(t,function(o){return o.PUSH_MODE!==void 0&&!k.contains(e,o.PUSH_MODE)}),n=k.map(r,function(o){var s="Token Type: ->"+o.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+o.PUSH_MODE+"<-which does not exist";return{message:s,type:ve.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[o]}});return n}F.findModesThatDoNotExist=Bu;function Du(t){var e=[],r=k.reduce(t,function(n,o,s){var c=o.PATTERN;return c===ve.Lexer.NA||(k.isString(c)?n.push({str:c,idx:s,tokenType:o}):k.isRegExp(c)&&T0(c)&&n.push({str:c.source,idx:s,tokenType:o})),n},[]);return k.forEach(t,function(n,o){k.forEach(r,function(s){var c=s.str,u=s.idx,i=s.tokenType;if(o<u&&A0(c,n.PATTERN)){var a="Token: ->"+i.name+`<- can never be matched.
36
+ `+("Because it appears AFTER the Token Type ->"+n.name+"<-")+`in the lexer's definition.
37
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:a,type:ve.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[n,i]})}})}),e}F.findUnreachablePatterns=Du;function A0(t,e){if(k.isRegExp(e)){var r=e.exec(t);return r!==null&&r.index===0}else{if(k.isFunction(e))return e(t,0,[],{});if(k.has(e,"exec"))return e.exec(t,0,[],{});if(typeof e=="string")return e===t;throw Error("non exhaustive match")}}function T0(t){var e=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return k.find(e,function(r){return t.source.indexOf(r)!==-1})===void 0}function Ui(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}F.addStartOfInput=Ui;function Pi(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}F.addStickyFlag=Pi;function O0(t,e,r){var n=[];return k.has(t,F.DEFAULT_MODE)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+F.DEFAULT_MODE+`> property in its definition
38
+ `,type:ve.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),k.has(t,F.MODES)||n.push({message:"A MultiMode Lexer cannot be initialized without a <"+F.MODES+`> property in its definition
39
+ `,type:ve.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),k.has(t,F.MODES)&&k.has(t,F.DEFAULT_MODE)&&!k.has(t.modes,t.defaultMode)&&n.push({message:"A MultiMode Lexer cannot be initialized with a "+F.DEFAULT_MODE+": <"+t.defaultMode+`>which does not exist
40
+ `,type:ve.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),k.has(t,F.MODES)&&k.forEach(t.modes,function(o,s){k.forEach(o,function(c,u){k.isUndefined(c)&&n.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+s+"> at index: <"+u+`>
41
+ `),type:ve.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),n}F.performRuntimeChecks=O0;function I0(t,e,r){var n=[],o=!1,s=k.compact(k.flatten(k.mapValues(t.modes,function(i){return i}))),c=k.reject(s,function(i){return i[Jt]===ve.Lexer.NA}),u=qu(r);return e&&k.forEach(c,function(i){var a=Vu(i,u);if(a!==!1){var l=Gu(i,a),f={message:l,type:a.issue,tokenType:i};n.push(f)}else k.has(i,"LINE_BREAKS")?i.LINE_BREAKS===!0&&(o=!0):nn.canMatchCharCode(u,i.PATTERN)&&(o=!0)}),e&&!o&&n.push({message:`Warning: No LINE_BREAKS Found.
42
+ This Lexer has been defined to track line and column information,
43
+ But none of the Token Types can be identified as matching a line terminator.
44
+ See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
45
+ for details.`,type:ve.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),n}F.performWarningRuntimeChecks=I0;function M0(t){var e={},r=k.keys(t);return k.forEach(r,function(n){var o=t[n];if(k.isArray(o))e[n]=[];else throw Error("non exhaustive match")}),e}F.cloneEmptyGroups=M0;function Fi(t){var e=t.PATTERN;if(k.isRegExp(e))return!1;if(k.isFunction(e))return!0;if(k.has(e,"exec"))return!0;if(k.isString(e))return!1;throw Error("non exhaustive match")}F.isCustomPattern=Fi;function Wu(t){return k.isString(t)&&t.length===1?t.charCodeAt(0):!1}F.isShortPattern=Wu;F.LineTerminatorOptimizedTester={test:function(t){for(var e=t.length,r=this.lastIndex;r<e;r++){var n=t.charCodeAt(r);if(n===10)return this.lastIndex=r+1,!0;if(n===13)return t.charCodeAt(r+1)===10?this.lastIndex=r+2:this.lastIndex=r+1,!0}return!1},lastIndex:0};function Vu(t,e){if(k.has(t,"LINE_BREAKS"))return!1;if(k.isRegExp(t.PATTERN)){try{nn.canMatchCharCode(e,t.PATTERN)}catch(r){return{issue:ve.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:r.message}}return!1}else{if(k.isString(t.PATTERN))return!1;if(Fi(t))return{issue:ve.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function Gu(t,e){if(e.issue===ve.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
46
+ `+(" The problem is in the <"+t.name+`> Token Type
47
+ `)+(" Root cause: "+e.errMsg+`.
48
+ `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===ve.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
49
+ `+(" The problem is in the <"+t.name+`> Token Type
50
+ `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}F.buildLineBreakIssueMessage=Gu;function qu(t){var e=k.map(t,function(r){return k.isString(r)&&r.length>0?r.charCodeAt(0):r});return e}function Li(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}F.minOptimizationVal=256;function Si(t){return t<F.minOptimizationVal?t:Ao[t]}F.charCodeToOptimizedIndex=Si;var Ao=[];function C0(){if(k.isEmpty(Ao)){Ao=new Array(65536);for(var t=0;t<65536;t++)Ao[t]=t>255?255+~~(t/255):t}}});var on=D(oe=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.isTokenType=oe.hasExtendingTokensTypesMapProperty=oe.hasExtendingTokensTypesProperty=oe.hasCategoriesProperty=oe.hasShortKeyProperty=oe.singleAssignCategoriesToksMap=oe.assignCategoriesMapProp=oe.assignCategoriesTokensProp=oe.assignTokenDefaultProps=oe.expandCategories=oe.augmentTokenTypes=oe.tokenIdxToClass=oe.tokenShortNameIdx=oe.tokenStructuredMatcherNoCategories=oe.tokenStructuredMatcher=void 0;var He=se();function w0(t,e){var r=t.tokenTypeIdx;return r===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[r]===!0}oe.tokenStructuredMatcher=w0;function _0(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}oe.tokenStructuredMatcherNoCategories=_0;oe.tokenShortNameIdx=1;oe.tokenIdxToClass={};function k0(t){var e=Hu(t);zu(e),$u(e),Yu(e),He.forEach(e,function(r){r.isParent=r.categoryMatches.length>0})}oe.augmentTokenTypes=k0;function Hu(t){for(var e=He.cloneArr(t),r=t,n=!0;n;){r=He.compact(He.flatten(He.map(r,function(s){return s.CATEGORIES})));var o=He.difference(r,e);e=e.concat(o),He.isEmpty(o)?n=!1:r=o}return e}oe.expandCategories=Hu;function zu(t){He.forEach(t,function(e){Ku(e)||(oe.tokenIdxToClass[oe.tokenShortNameIdx]=e,e.tokenTypeIdx=oe.tokenShortNameIdx++),Bi(e)&&!He.isArray(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Bi(e)||(e.CATEGORIES=[]),Xu(e)||(e.categoryMatches=[]),Qu(e)||(e.categoryMatchesMap={})})}oe.assignTokenDefaultProps=zu;function Yu(t){He.forEach(t,function(e){e.categoryMatches=[],He.forEach(e.categoryMatchesMap,function(r,n){e.categoryMatches.push(oe.tokenIdxToClass[n].tokenTypeIdx)})})}oe.assignCategoriesTokensProp=Yu;function $u(t){He.forEach(t,function(e){Di([],e)})}oe.assignCategoriesMapProp=$u;function Di(t,e){He.forEach(t,function(r){e.categoryMatchesMap[r.tokenTypeIdx]=!0}),He.forEach(e.CATEGORIES,function(r){var n=t.concat(e);He.contains(n,r)||Di(n,r)})}oe.singleAssignCategoriesToksMap=Di;function Ku(t){return He.has(t,"tokenTypeIdx")}oe.hasShortKeyProperty=Ku;function Bi(t){return He.has(t,"CATEGORIES")}oe.hasCategoriesProperty=Bi;function Xu(t){return He.has(t,"categoryMatches")}oe.hasExtendingTokensTypesProperty=Xu;function Qu(t){return He.has(t,"categoryMatchesMap")}oe.hasExtendingTokensTypesMapProperty=Qu;function b0(t){return He.has(t,"tokenTypeIdx")}oe.isTokenType=b0});var Wi=D(To=>{"use strict";Object.defineProperty(To,"__esModule",{value:!0});To.defaultLexerErrorProvider=void 0;To.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(t){return"Unable to pop Lexer Mode after encountering Token ->"+t.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(t,e,r,n,o){return"unexpected character: ->"+t.charAt(e)+"<- at offset: "+e+","+(" skipped "+r+" characters.")}}});var Mn=D(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.Lexer=Vr.LexerDefinitionErrorType=void 0;var Ht=xi(),Ee=se(),x0=on(),L0=Wi(),U0=yo(),P0;(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"})(P0=Vr.LexerDefinitionErrorType||(Vr.LexerDefinitionErrorType={}));var Cn={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
51
+ `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:L0.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(Cn);var S0=(function(){function t(e,r){var n=this;if(r===void 0&&(r=Cn),this.lexerDefinition=e,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={},typeof r=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
52
+ a boolean 2nd argument is no longer supported`);this.config=Ee.merge(Cn,r);var o=this.config.traceInitPerf;o===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof o=="number"&&(this.traceInitMaxIdent=o,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var s,c=!0;n.TRACE_INIT("Lexer Config handling",function(){if(n.config.lineTerminatorsPattern===Cn.lineTerminatorsPattern)n.config.lineTerminatorsPattern=Ht.LineTerminatorOptimizedTester;else if(n.config.lineTerminatorCharacters===Cn.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
53
+ For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(r.safeMode&&r.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),Ee.isArray(e)?(s={modes:{}},s.modes[Ht.DEFAULT_MODE]=Ee.cloneArr(e),s[Ht.DEFAULT_MODE]=Ht.DEFAULT_MODE):(c=!1,s=Ee.cloneObj(e))}),n.config.skipValidations===!1&&(n.TRACE_INIT("performRuntimeChecks",function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(Ht.performRuntimeChecks(s,n.trackStartLines,n.config.lineTerminatorCharacters))}),n.TRACE_INIT("performWarningRuntimeChecks",function(){n.lexerDefinitionWarning=n.lexerDefinitionWarning.concat(Ht.performWarningRuntimeChecks(s,n.trackStartLines,n.config.lineTerminatorCharacters))})),s.modes=s.modes?s.modes:{},Ee.forEach(s.modes,function(l,f){s.modes[f]=Ee.reject(l,function(p){return Ee.isUndefined(p)})});var u=Ee.keys(s.modes);if(Ee.forEach(s.modes,function(l,f){n.TRACE_INIT("Mode: <"+f+"> processing",function(){if(n.modes.push(f),n.config.skipValidations===!1&&n.TRACE_INIT("validatePatterns",function(){n.lexerDefinitionErrors=n.lexerDefinitionErrors.concat(Ht.validatePatterns(l,u))}),Ee.isEmpty(n.lexerDefinitionErrors)){x0.augmentTokenTypes(l);var p;n.TRACE_INIT("analyzeTokenTypes",function(){p=Ht.analyzeTokenTypes(l,{lineTerminatorCharacters:n.config.lineTerminatorCharacters,positionTracking:r.positionTracking,ensureOptimizations:r.ensureOptimizations,safeMode:r.safeMode,tracer:n.TRACE_INIT.bind(n)})}),n.patternIdxToConfig[f]=p.patternIdxToConfig,n.charCodeToPatternIdxToConfig[f]=p.charCodeToPatternIdxToConfig,n.emptyGroups=Ee.merge(n.emptyGroups,p.emptyGroups),n.hasCustom=p.hasCustom||n.hasCustom,n.canModeBeOptimized[f]=p.canBeOptimized}})}),n.defaultMode=s.defaultMode,!Ee.isEmpty(n.lexerDefinitionErrors)&&!n.config.deferDefinitionErrorsHandling){var i=Ee.map(n.lexerDefinitionErrors,function(l){return l.message}),a=i.join(`-----------------------
54
+ `);throw new Error(`Errors detected in definition of Lexer:
55
+ `+a)}Ee.forEach(n.lexerDefinitionWarning,function(l){Ee.PRINT_WARNING(l.message)}),n.TRACE_INIT("Choosing sub-methods implementations",function(){if(Ht.SUPPORT_STICKY?(n.chopInput=Ee.IDENTITY,n.match=n.matchWithTest):(n.updateLastIndex=Ee.NOOP,n.match=n.matchWithExec),c&&(n.handleModes=Ee.NOOP),n.trackStartLines===!1&&(n.computeNewColumn=Ee.IDENTITY),n.trackEndLines===!1&&(n.updateTokenEndLineColumnLocation=Ee.NOOP),/full/i.test(n.config.positionTracking))n.createTokenInstance=n.createFullToken;else if(/onlyStart/i.test(n.config.positionTracking))n.createTokenInstance=n.createStartOnlyToken;else if(/onlyOffset/i.test(n.config.positionTracking))n.createTokenInstance=n.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+n.config.positionTracking+'"');n.hasCustom?(n.addToken=n.addTokenUsingPush,n.handlePayload=n.handlePayloadWithCustom):(n.addToken=n.addTokenUsingMemberAccess,n.handlePayload=n.handlePayloadNoCustom)}),n.TRACE_INIT("Failed Optimization Warnings",function(){var l=Ee.reduce(n.canModeBeOptimized,function(f,p,d){return p===!1&&f.push(d),f},[]);if(r.ensureOptimizations&&!Ee.isEmpty(l))throw Error("Lexer Modes: < "+l.join(", ")+` > cannot be optimized.
56
+ Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
57
+ Or inspect the console log for details on how to resolve these issues.`)}),n.TRACE_INIT("clearRegExpParserCache",function(){U0.clearRegExpParserCache()}),n.TRACE_INIT("toFastProperties",function(){Ee.toFastProperties(n)})})}return t.prototype.tokenize=function(e,r){if(r===void 0&&(r=this.defaultMode),!Ee.isEmpty(this.lexerDefinitionErrors)){var n=Ee.map(this.lexerDefinitionErrors,function(c){return c.message}),o=n.join(`-----------------------
58
+ `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
59
+ `+o)}var s=this.tokenizeInternal(e,r);return s},t.prototype.tokenizeInternal=function(e,r){var n=this,o,s,c,u,i,a,l,f,p,d,h,m,E,g,v,R=e,N=R.length,A=0,y=0,T=this.hasCustom?0:Math.floor(e.length/10),I=new Array(T),M=[],b=this.trackStartLines?1:void 0,S=this.trackStartLines?1:void 0,G=Ht.cloneEmptyGroups(this.emptyGroups),j=this.trackStartLines,$=this.config.lineTerminatorsPattern,W=0,he=[],Ge=[],Xe=[],tt=[];Object.freeze(tt);var Fe=void 0;function xe(){return he}function kt(nt){var Nr=Ht.charCodeToOptimizedIndex(nt),Ar=Ge[Nr];return Ar===void 0?tt:Ar}var bt=function(nt){if(Xe.length===1&&nt.tokenType.PUSH_MODE===void 0){var Nr=n.config.errorMessageProvider.buildUnableToPopLexerModeMessage(nt);M.push({offset:nt.startOffset,line:nt.startLine!==void 0?nt.startLine:void 0,column:nt.startColumn!==void 0?nt.startColumn:void 0,length:nt.image.length,message:Nr})}else{Xe.pop();var Ar=Ee.last(Xe);he=n.patternIdxToConfig[Ar],Ge=n.charCodeToPatternIdxToConfig[Ar],W=he.length;var ii=n.canModeBeOptimized[Ar]&&n.config.safeMode===!1;Ge&&ii?Fe=kt:Fe=xe}};function Wt(nt){Xe.push(nt),Ge=this.charCodeToPatternIdxToConfig[nt],he=this.patternIdxToConfig[nt],W=he.length,W=he.length;var Nr=this.canModeBeOptimized[nt]&&this.config.safeMode===!1;Ge&&Nr?Fe=kt:Fe=xe}Wt.call(this,r);for(var Be;A<N;){i=null;var Et=R.charCodeAt(A),Qt=Fe(Et),$r=Qt.length;for(o=0;o<$r;o++){Be=Qt[o];var xt=Be.pattern;a=null;var Rr=Be.short;if(Rr!==!1?Et===Rr&&(i=xt):Be.isCustom===!0?(v=xt.exec(R,A,I,G),v!==null?(i=v[0],v.payload!==void 0&&(a=v.payload)):i=null):(this.updateLastIndex(xt,A),i=this.match(xt,e,A)),i!==null){if(u=Be.longerAlt,u!==void 0){var Ur=he[u],De=Ur.pattern;l=null,Ur.isCustom===!0?(v=De.exec(R,A,I,G),v!==null?(c=v[0],v.payload!==void 0&&(l=v.payload)):c=null):(this.updateLastIndex(De,A),c=this.match(De,e,A)),c&&c.length>i.length&&(i=c,a=l,Be=Ur)}break}}if(i!==null){if(f=i.length,p=Be.group,p!==void 0&&(d=Be.tokenTypeIdx,h=this.createTokenInstance(i,A,d,Be.tokenType,b,S,f),this.handlePayload(h,a),p===!1?y=this.addToken(I,y,h):G[p].push(h)),e=this.chopInput(e,f),A=A+f,S=this.computeNewColumn(S,f),j===!0&&Be.canLineTerminator===!0){var Lt=0,ut=void 0,Re=void 0;$.lastIndex=0;do ut=$.test(i),ut===!0&&(Re=$.lastIndex-1,Lt++);while(ut===!0);Lt!==0&&(b=b+Lt,S=f-Re,this.updateTokenEndLineColumnLocation(h,p,Re,Lt,b,S,f))}this.handleModes(Be,bt,Wt,h)}else{for(var Kr=A,sr=b,En=S,rt=!1;!rt&&A<N;)for(E=R.charCodeAt(A),e=this.chopInput(e,1),A++,s=0;s<W;s++){var yn=he[s],xt=yn.pattern,Rr=yn.short;if(Rr!==!1?R.charCodeAt(A)===Rr&&(rt=!0):yn.isCustom===!0?rt=xt.exec(R,A,I,G)!==null:(this.updateLastIndex(xt,A),rt=xt.exec(e)!==null),rt===!0)break}m=A-Kr,g=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(R,Kr,m,sr,En),M.push({offset:Kr,line:sr,column:En,length:m,message:g})}}return this.hasCustom||(I.length=y),{tokens:I,groups:G,errors:M}},t.prototype.handleModes=function(e,r,n,o){if(e.pop===!0){var s=e.push;r(o),s!==void 0&&n.call(this,s)}else e.push!==void 0&&n.call(this,e.push)},t.prototype.chopInput=function(e,r){return e.substring(r)},t.prototype.updateLastIndex=function(e,r){e.lastIndex=r},t.prototype.updateTokenEndLineColumnLocation=function(e,r,n,o,s,c,u){var i,a;r!==void 0&&(i=n===u-1,a=i?-1:0,o===1&&i===!0||(e.endLine=s+a,e.endColumn=c-1+-a))},t.prototype.computeNewColumn=function(e,r){return e+r},t.prototype.createTokenInstance=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return null},t.prototype.createOffsetOnlyToken=function(e,r,n,o){return{image:e,startOffset:r,tokenTypeIdx:n,tokenType:o}},t.prototype.createStartOnlyToken=function(e,r,n,o,s,c){return{image:e,startOffset:r,startLine:s,startColumn:c,tokenTypeIdx:n,tokenType:o}},t.prototype.createFullToken=function(e,r,n,o,s,c,u){return{image:e,startOffset:r,endOffset:r+u-1,startLine:s,endLine:s,startColumn:c,endColumn:c+u-1,tokenTypeIdx:n,tokenType:o}},t.prototype.addToken=function(e,r,n){return 666},t.prototype.addTokenUsingPush=function(e,r,n){return e.push(n),r},t.prototype.addTokenUsingMemberAccess=function(e,r,n){return e[r]=n,r++,r},t.prototype.handlePayload=function(e,r){},t.prototype.handlePayloadNoCustom=function(e,r){},t.prototype.handlePayloadWithCustom=function(e,r){r!==null&&(e.payload=r)},t.prototype.match=function(e,r,n){return null},t.prototype.matchWithTest=function(e,r,n){var o=e.test(r);return o===!0?r.substring(n,e.lastIndex):null},t.prototype.matchWithExec=function(e,r){var n=e.exec(r);return n!==null?n[0]:n},t.prototype.TRACE_INIT=function(e,r){if(this.traceInitPerf===!0){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--> <"+e+">");var o=Ee.timer(r),s=o.time,c=o.value,u=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&u(n+"<-- <"+e+"> time: "+s+"ms"),this.traceInitIndent--,c}else return r()},t.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.",t.NA=/NOT_APPLICABLE/,t})();Vr.Lexer=S0});var Cr=D(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.tokenMatcher=st.createTokenInstance=st.EOF=st.createToken=st.hasTokenLabel=st.tokenName=st.tokenLabel=void 0;var zt=se(),F0=Mn(),Vi=on();function B0(t){return ic(t)?t.LABEL:t.name}st.tokenLabel=B0;function D0(t){return t.name}st.tokenName=D0;function ic(t){return zt.isString(t.LABEL)&&t.LABEL!==""}st.hasTokenLabel=ic;var W0="parent",Zu="categories",Ju="label",ju="group",ec="push_mode",tc="pop_mode",rc="longer_alt",nc="line_breaks",oc="start_chars_hint";function sc(t){return V0(t)}st.createToken=sc;function V0(t){var e=t.pattern,r={};if(r.name=t.name,zt.isUndefined(e)||(r.PATTERN=e),zt.has(t,W0))throw`The parent property is no longer supported.
60
+ See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return zt.has(t,Zu)&&(r.CATEGORIES=t[Zu]),Vi.augmentTokenTypes([r]),zt.has(t,Ju)&&(r.LABEL=t[Ju]),zt.has(t,ju)&&(r.GROUP=t[ju]),zt.has(t,tc)&&(r.POP_MODE=t[tc]),zt.has(t,ec)&&(r.PUSH_MODE=t[ec]),zt.has(t,rc)&&(r.LONGER_ALT=t[rc]),zt.has(t,nc)&&(r.LINE_BREAKS=t[nc]),zt.has(t,oc)&&(r.START_CHARS_HINT=t[oc]),r}st.EOF=sc({name:"EOF",pattern:F0.Lexer.NA});Vi.augmentTokenTypes([st.EOF]);function G0(t,e,r,n,o,s,c,u){return{image:e,startOffset:r,endOffset:n,startLine:o,endLine:s,startColumn:c,endColumn:u,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}st.createTokenInstance=G0;function q0(t,e){return Vi.tokenStructuredMatcher(t,e)}st.tokenMatcher=q0});var gt=D(le=>{"use strict";var mr=le&&le.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(le,"__esModule",{value:!0});le.serializeProduction=le.serializeGrammar=le.Terminal=le.Alternation=le.RepetitionWithSeparator=le.Repetition=le.RepetitionMandatoryWithSeparator=le.RepetitionMandatory=le.Option=le.Alternative=le.Rule=le.NonTerminal=le.AbstractProduction=void 0;var Ce=se(),H0=Cr(),jt=(function(){function t(e){this._definition=e}return Object.defineProperty(t.prototype,"definition",{get:function(){return this._definition},set:function(e){this._definition=e},enumerable:!1,configurable:!0}),t.prototype.accept=function(e){e.visit(this),Ce.forEach(this.definition,function(r){r.accept(e)})},t})();le.AbstractProduction=jt;var ac=(function(t){mr(e,t);function e(r){var n=t.call(this,[])||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return Object.defineProperty(e.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(r){},enumerable:!1,configurable:!0}),e.prototype.accept=function(r){r.visit(this)},e})(jt);le.NonTerminal=ac;var uc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.orgText="",Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.Rule=uc;var cc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.ignoreAmbiguities=!1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.Alternative=cc;var lc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.Option=lc;var fc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.RepetitionMandatory=fc;var hc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.RepetitionMandatoryWithSeparator=hc;var pc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.Repetition=pc;var dc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return e})(jt);le.RepetitionWithSeparator=dc;var mc=(function(t){mr(e,t);function e(r){var n=t.call(this,r.definition)||this;return n.idx=1,n.ignoreAmbiguities=!1,n.hasPredicates=!1,Ce.assign(n,Ce.pick(r,function(o){return o!==void 0})),n}return Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(r){this._definition=r},enumerable:!1,configurable:!0}),e})(jt);le.Alternation=mc;var Oo=(function(){function t(e){this.idx=1,Ce.assign(this,Ce.pick(e,function(r){return r!==void 0}))}return t.prototype.accept=function(e){e.visit(this)},t})();le.Terminal=Oo;function z0(t){return Ce.map(t,wn)}le.serializeGrammar=z0;function wn(t){function e(o){return Ce.map(o,wn)}if(t instanceof ac)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof cc)return{type:"Alternative",definition:e(t.definition)};if(t instanceof lc)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof fc)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof hc)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:wn(new Oo({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof dc)return{type:"RepetitionWithSeparator",idx:t.idx,separator:wn(new Oo({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof pc)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof mc)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof Oo){var r={type:"Terminal",name:t.terminalType.name,label:H0.tokenLabel(t.terminalType),idx:t.idx},n=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(r.pattern=Ce.isRegExp(n)?n.source:n),r}else{if(t instanceof uc)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}le.serializeProduction=wn});var Mo=D(Io=>{"use strict";Object.defineProperty(Io,"__esModule",{value:!0});Io.RestWalker=void 0;var Gi=se(),At=gt(),Y0=(function(){function t(){}return t.prototype.walk=function(e,r){var n=this;r===void 0&&(r=[]),Gi.forEach(e.definition,function(o,s){var c=Gi.drop(e.definition,s+1);if(o instanceof At.NonTerminal)n.walkProdRef(o,c,r);else if(o instanceof At.Terminal)n.walkTerminal(o,c,r);else if(o instanceof At.Alternative)n.walkFlat(o,c,r);else if(o instanceof At.Option)n.walkOption(o,c,r);else if(o instanceof At.RepetitionMandatory)n.walkAtLeastOne(o,c,r);else if(o instanceof At.RepetitionMandatoryWithSeparator)n.walkAtLeastOneSep(o,c,r);else if(o instanceof At.RepetitionWithSeparator)n.walkManySep(o,c,r);else if(o instanceof At.Repetition)n.walkMany(o,c,r);else if(o instanceof At.Alternation)n.walkOr(o,c,r);else throw Error("non exhaustive match")})},t.prototype.walkTerminal=function(e,r,n){},t.prototype.walkProdRef=function(e,r,n){},t.prototype.walkFlat=function(e,r,n){var o=r.concat(n);this.walk(e,o)},t.prototype.walkOption=function(e,r,n){var o=r.concat(n);this.walk(e,o)},t.prototype.walkAtLeastOne=function(e,r,n){var o=[new At.Option({definition:e.definition})].concat(r,n);this.walk(e,o)},t.prototype.walkAtLeastOneSep=function(e,r,n){var o=gc(e,r,n);this.walk(e,o)},t.prototype.walkMany=function(e,r,n){var o=[new At.Option({definition:e.definition})].concat(r,n);this.walk(e,o)},t.prototype.walkManySep=function(e,r,n){var o=gc(e,r,n);this.walk(e,o)},t.prototype.walkOr=function(e,r,n){var o=this,s=r.concat(n);Gi.forEach(e.definition,function(c){var u=new At.Alternative({definition:[c]});o.walk(u,s)})},t})();Io.RestWalker=Y0;function gc(t,e,r){var n=[new At.Option({definition:[new At.Terminal({terminalType:t.separator})].concat(t.definition)})],o=n.concat(e,r);return o}});var sn=D(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:!0});Co.GAstVisitor=void 0;var er=gt(),$0=(function(){function t(){}return t.prototype.visit=function(e){var r=e;switch(r.constructor){case er.NonTerminal:return this.visitNonTerminal(r);case er.Alternative:return this.visitAlternative(r);case er.Option:return this.visitOption(r);case er.RepetitionMandatory:return this.visitRepetitionMandatory(r);case er.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(r);case er.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(r);case er.Repetition:return this.visitRepetition(r);case er.Alternation:return this.visitAlternation(r);case er.Terminal:return this.visitTerminal(r);case er.Rule:return this.visitRule(r);default:throw Error("non exhaustive match")}},t.prototype.visitNonTerminal=function(e){},t.prototype.visitAlternative=function(e){},t.prototype.visitOption=function(e){},t.prototype.visitRepetition=function(e){},t.prototype.visitRepetitionMandatory=function(e){},t.prototype.visitRepetitionMandatoryWithSeparator=function(e){},t.prototype.visitRepetitionWithSeparator=function(e){},t.prototype.visitAlternation=function(e){},t.prototype.visitTerminal=function(e){},t.prototype.visitRule=function(e){},t})();Co.GAstVisitor=$0});var an=D(ct=>{"use strict";var K0=ct&&ct.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(ct,"__esModule",{value:!0});ct.collectMethods=ct.DslMethodsCollectorVisitor=ct.getProductionDslName=ct.isBranchingProd=ct.isOptionalProd=ct.isSequenceProd=void 0;var _n=se(),we=gt(),X0=sn();function Q0(t){return t instanceof we.Alternative||t instanceof we.Option||t instanceof we.Repetition||t instanceof we.RepetitionMandatory||t instanceof we.RepetitionMandatoryWithSeparator||t instanceof we.RepetitionWithSeparator||t instanceof we.Terminal||t instanceof we.Rule}ct.isSequenceProd=Q0;function qi(t,e){e===void 0&&(e=[]);var r=t instanceof we.Option||t instanceof we.Repetition||t instanceof we.RepetitionWithSeparator;return r?!0:t instanceof we.Alternation?_n.some(t.definition,function(n){return qi(n,e)}):t instanceof we.NonTerminal&&_n.contains(e,t)?!1:t instanceof we.AbstractProduction?(t instanceof we.NonTerminal&&e.push(t),_n.every(t.definition,function(n){return qi(n,e)})):!1}ct.isOptionalProd=qi;function Z0(t){return t instanceof we.Alternation}ct.isBranchingProd=Z0;function J0(t){if(t instanceof we.NonTerminal)return"SUBRULE";if(t instanceof we.Option)return"OPTION";if(t instanceof we.Alternation)return"OR";if(t instanceof we.RepetitionMandatory)return"AT_LEAST_ONE";if(t instanceof we.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(t instanceof we.RepetitionWithSeparator)return"MANY_SEP";if(t instanceof we.Repetition)return"MANY";if(t instanceof we.Terminal)return"CONSUME";throw Error("non exhaustive match")}ct.getProductionDslName=J0;var vc=(function(t){K0(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.separator="-",r.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},r}return e.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},e.prototype.visitTerminal=function(r){var n=r.terminalType.name+this.separator+"Terminal";_n.has(this.dslMethods,n)||(this.dslMethods[n]=[]),this.dslMethods[n].push(r)},e.prototype.visitNonTerminal=function(r){var n=r.nonTerminalName+this.separator+"Terminal";_n.has(this.dslMethods,n)||(this.dslMethods[n]=[]),this.dslMethods[n].push(r)},e.prototype.visitOption=function(r){this.dslMethods.option.push(r)},e.prototype.visitRepetitionWithSeparator=function(r){this.dslMethods.repetitionWithSeparator.push(r)},e.prototype.visitRepetitionMandatory=function(r){this.dslMethods.repetitionMandatory.push(r)},e.prototype.visitRepetitionMandatoryWithSeparator=function(r){this.dslMethods.repetitionMandatoryWithSeparator.push(r)},e.prototype.visitRepetition=function(r){this.dslMethods.repetition.push(r)},e.prototype.visitAlternation=function(r){this.dslMethods.alternation.push(r)},e})(X0.GAstVisitor);ct.DslMethodsCollectorVisitor=vc;var wo=new vc;function j0(t){wo.reset(),t.accept(wo);var e=wo.dslMethods;return wo.reset(),e}ct.collectMethods=j0});var zi=D(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.firstForTerminal=tr.firstForBranching=tr.firstForSequence=tr.first=void 0;var _o=se(),Ec=gt(),Hi=an();function ko(t){if(t instanceof Ec.NonTerminal)return ko(t.referencedRule);if(t instanceof Ec.Terminal)return Nc(t);if(Hi.isSequenceProd(t))return yc(t);if(Hi.isBranchingProd(t))return Rc(t);throw Error("non exhaustive match")}tr.first=ko;function yc(t){for(var e=[],r=t.definition,n=0,o=r.length>n,s,c=!0;o&&c;)s=r[n],c=Hi.isOptionalProd(s),e=e.concat(ko(s)),n=n+1,o=r.length>n;return _o.uniq(e)}tr.firstForSequence=yc;function Rc(t){var e=_o.map(t.definition,function(r){return ko(r)});return _o.uniq(_o.flatten(e))}tr.firstForBranching=Rc;function Nc(t){return[t.terminalType]}tr.firstForTerminal=Nc});var Yi=D(bo=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});bo.IN=void 0;bo.IN="_~IN~_"});var Mc=D(Pt=>{"use strict";var ed=Pt&&Pt.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(Pt,"__esModule",{value:!0});Pt.buildInProdFollowPrefix=Pt.buildBetweenProdsFollowPrefix=Pt.computeAllProdsFollows=Pt.ResyncFollowsWalker=void 0;var td=Mo(),rd=zi(),Ac=se(),Tc=Yi(),nd=gt(),Oc=(function(t){ed(e,t);function e(r){var n=t.call(this)||this;return n.topProd=r,n.follows={},n}return e.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},e.prototype.walkTerminal=function(r,n,o){},e.prototype.walkProdRef=function(r,n,o){var s=Ic(r.referencedRule,r.idx)+this.topProd.name,c=n.concat(o),u=new nd.Alternative({definition:c}),i=rd.first(u);this.follows[s]=i},e})(td.RestWalker);Pt.ResyncFollowsWalker=Oc;function od(t){var e={};return Ac.forEach(t,function(r){var n=new Oc(r).startWalking();Ac.assign(e,n)}),e}Pt.computeAllProdsFollows=od;function Ic(t,e){return t.name+e+Tc.IN}Pt.buildBetweenProdsFollowPrefix=Ic;function id(t){var e=t.terminalType.name;return e+t.idx+Tc.IN}Pt.buildInProdFollowPrefix=id});var kn=D(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});gr.defaultGrammarValidatorErrorProvider=gr.defaultGrammarResolverErrorProvider=gr.defaultParserErrorProvider=void 0;var un=Cr(),sd=se(),Yt=se(),$i=gt(),Cc=an();gr.defaultParserErrorProvider={buildMismatchTokenMessage:function(t){var e=t.expected,r=t.actual,n=t.previous,o=t.ruleName,s=un.hasTokenLabel(e),c=s?"--> "+un.tokenLabel(e)+" <--":"token of type --> "+e.name+" <--",u="Expecting "+c+" but found --> '"+r.image+"' <--";return u},buildNotAllInputParsedMessage:function(t){var e=t.firstRedundant,r=t.ruleName;return"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(t){var e=t.expectedPathsPerAlt,r=t.actual,n=t.previous,o=t.customUserDescription,s=t.ruleName,c="Expecting: ",u=Yt.first(r).image,i=`
61
+ but found: '`+u+"'";if(o)return c+o+i;var a=Yt.reduce(e,function(d,h){return d.concat(h)},[]),l=Yt.map(a,function(d){return"["+Yt.map(d,function(h){return un.tokenLabel(h)}).join(", ")+"]"}),f=Yt.map(l,function(d,h){return" "+(h+1)+". "+d}),p=`one of these possible Token sequences:
62
+ `+f.join(`
63
+ `);return c+p+i},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,r=t.actual,n=t.customUserDescription,o=t.ruleName,s="Expecting: ",c=Yt.first(r).image,u=`
64
+ but found: '`+c+"'";if(n)return s+n+u;var i=Yt.map(e,function(l){return"["+Yt.map(l,function(f){return un.tokenLabel(f)}).join(",")+"]"}),a=`expecting at least one iteration which starts with one of these possible Token sequences::
65
+ `+("<"+i.join(" ,")+">");return s+a+u}};Object.freeze(gr.defaultParserErrorProvider);gr.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(t,e){var r="Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<-
66
+ inside top level rule: ->`+t.name+"<-";return r}};gr.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(t,e){function r(l){return l instanceof $i.Terminal?l.terminalType.name:l instanceof $i.NonTerminal?l.nonTerminalName:""}var n=t.name,o=Yt.first(e),s=o.idx,c=Cc.getProductionDslName(o),u=r(o),i=s>0,a="->"+c+(i?s:"")+"<- "+(u?"with argument: ->"+u+"<-":"")+`
67
+ appears more than once (`+e.length+" times) in the top level rule: ->"+n+`<-.
68
+ For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
69
+ `;return a=a.replace(/[ \t]+/g," "),a=a.replace(/\s\s+/g,`
70
+ `),a},buildNamespaceConflictError:function(t){var e=`Namespace conflict found in grammar.
71
+ `+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+t.name+`>.
72
+ `)+`To resolve this make sure each Terminal and Non-Terminal names are unique
73
+ This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
74
+ and Non-Terminal names start with a lower case letter.`;return e},buildAlternationPrefixAmbiguityError:function(t){var e=Yt.map(t.prefixPath,function(o){return un.tokenLabel(o)}).join(", "),r=t.alternation.idx===0?"":t.alternation.idx,n="Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+`> due to common lookahead prefix
75
+ `+("in <OR"+r+"> inside <"+t.topLevelRule.name+`> Rule,
76
+ `)+("<"+e+`> may appears as a prefix path in all these alternatives.
77
+ `)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
78
+ For Further details.`;return n},buildAlternationAmbiguityError:function(t){var e=Yt.map(t.prefixPath,function(o){return un.tokenLabel(o)}).join(", "),r=t.alternation.idx===0?"":t.alternation.idx,n="Ambiguous Alternatives Detected: <"+t.ambiguityIndices.join(" ,")+"> in <OR"+r+">"+(" inside <"+t.topLevelRule.name+`> Rule,
79
+ `)+("<"+e+`> may appears as a prefix path in all these alternatives.
80
+ `);return n=n+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
81
+ For Further details.`,n},buildEmptyRepetitionError:function(t){var e=Cc.getProductionDslName(t.repetition);t.repetition.idx!==0&&(e+=t.repetition.idx);var r="The repetition <"+e+"> within Rule <"+t.topLevelRule.name+`> can never consume any tokens.
82
+ This could lead to an infinite loop.`;return r},buildTokenNameError:function(t){return"deprecated"},buildEmptyAlternationError:function(t){var e="Ambiguous empty alternative: <"+(t.emptyChoiceIdx+1)+">"+(" in <OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+`> Rule.
83
+ `)+"Only the last alternative may be an empty alternative.";return e},buildTooManyAlternativesError:function(t){var e=`An Alternation cannot have more than 256 alternatives:
84
+ `+("<OR"+t.alternation.idx+"> inside <"+t.topLevelRule.name+`> Rule.
85
+ has `+(t.alternation.definition.length+1)+" alternatives.");return e},buildLeftRecursionError:function(t){var e=t.topLevelRule.name,r=sd.map(t.leftRecursionPath,function(s){return s.name}),n=e+" --> "+r.concat([e]).join(" --> "),o=`Left Recursion found in grammar.
86
+ `+("rule: <"+e+`> can be invoked from itself (directly or indirectly)
87
+ `)+(`without consuming any Tokens. The grammar path that causes this is:
88
+ `+n+`
89
+ `)+` To fix this refactor your grammar to remove the left recursion.
90
+ see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return o},buildInvalidRuleNameError:function(t){return"deprecated"},buildDuplicateRuleNameError:function(t){var e;t.topLevelRule instanceof $i.Rule?e=t.topLevelRule.name:e=t.topLevelRule;var r="Duplicate definition, rule: ->"+e+"<- is already defined in the grammar: ->"+t.grammarName+"<-";return r}}});var kc=D(wr=>{"use strict";var ad=wr&&wr.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(wr,"__esModule",{value:!0});wr.GastRefResolverVisitor=wr.resolveGrammar=void 0;var ud=Mt(),wc=se(),cd=sn();function ld(t,e){var r=new _c(t,e);return r.resolveRefs(),r.errors}wr.resolveGrammar=ld;var _c=(function(t){ad(e,t);function e(r,n){var o=t.call(this)||this;return o.nameToTopRule=r,o.errMsgProvider=n,o.errors=[],o}return e.prototype.resolveRefs=function(){var r=this;wc.forEach(wc.values(this.nameToTopRule),function(n){r.currTopLevel=n,n.accept(r)})},e.prototype.visitNonTerminal=function(r){var n=this.nameToTopRule[r.nonTerminalName];if(n)r.referencedRule=n;else{var o=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,r);this.errors.push({message:o,type:ud.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:r.nonTerminalName})}},e})(cd.GAstVisitor);wr.GastRefResolverVisitor=_c});var xn=D(Se=>{"use strict";var Gr=Se&&Se.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(Se,"__esModule",{value:!0});Se.nextPossibleTokensAfter=Se.possiblePathsFrom=Se.NextTerminalAfterAtLeastOneSepWalker=Se.NextTerminalAfterAtLeastOneWalker=Se.NextTerminalAfterManySepWalker=Se.NextTerminalAfterManyWalker=Se.AbstractNextTerminalAfterProductionWalker=Se.NextAfterTokenWalker=Se.AbstractNextPossibleTokensWalker=void 0;var bc=Mo(),ie=se(),fd=zi(),ne=gt(),xc=(function(t){Gr(e,t);function e(r,n){var o=t.call(this)||this;return o.topProd=r,o.path=n,o.possibleTokTypes=[],o.nextProductionName="",o.nextProductionOccurrence=0,o.found=!1,o.isAtEndOfPath=!1,o}return e.prototype.startWalking=function(){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=ie.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=ie.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},e.prototype.walk=function(r,n){n===void 0&&(n=[]),this.found||t.prototype.walk.call(this,r,n)},e.prototype.walkProdRef=function(r,n,o){if(r.referencedRule.name===this.nextProductionName&&r.idx===this.nextProductionOccurrence){var s=n.concat(o);this.updateExpectedNext(),this.walk(r.referencedRule,s)}},e.prototype.updateExpectedNext=function(){ie.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e})(bc.RestWalker);Se.AbstractNextPossibleTokensWalker=xc;var hd=(function(t){Gr(e,t);function e(r,n){var o=t.call(this,r,n)||this;return o.path=n,o.nextTerminalName="",o.nextTerminalOccurrence=0,o.nextTerminalName=o.path.lastTok.name,o.nextTerminalOccurrence=o.path.lastTokOccurrence,o}return e.prototype.walkTerminal=function(r,n,o){if(this.isAtEndOfPath&&r.terminalType.name===this.nextTerminalName&&r.idx===this.nextTerminalOccurrence&&!this.found){var s=n.concat(o),c=new ne.Alternative({definition:s});this.possibleTokTypes=fd.first(c),this.found=!0}},e})(xc);Se.NextAfterTokenWalker=hd;var bn=(function(t){Gr(e,t);function e(r,n){var o=t.call(this)||this;return o.topRule=r,o.occurrence=n,o.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},o}return e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e})(bc.RestWalker);Se.AbstractNextTerminalAfterProductionWalker=bn;var pd=(function(t){Gr(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkMany=function(r,n,o){if(r.idx===this.occurrence){var s=ie.first(n.concat(o));this.result.isEndOfRule=s===void 0,s instanceof ne.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else t.prototype.walkMany.call(this,r,n,o)},e})(bn);Se.NextTerminalAfterManyWalker=pd;var dd=(function(t){Gr(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkManySep=function(r,n,o){if(r.idx===this.occurrence){var s=ie.first(n.concat(o));this.result.isEndOfRule=s===void 0,s instanceof ne.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else t.prototype.walkManySep.call(this,r,n,o)},e})(bn);Se.NextTerminalAfterManySepWalker=dd;var md=(function(t){Gr(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkAtLeastOne=function(r,n,o){if(r.idx===this.occurrence){var s=ie.first(n.concat(o));this.result.isEndOfRule=s===void 0,s instanceof ne.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else t.prototype.walkAtLeastOne.call(this,r,n,o)},e})(bn);Se.NextTerminalAfterAtLeastOneWalker=md;var gd=(function(t){Gr(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkAtLeastOneSep=function(r,n,o){if(r.idx===this.occurrence){var s=ie.first(n.concat(o));this.result.isEndOfRule=s===void 0,s instanceof ne.Terminal&&(this.result.token=s.terminalType,this.result.occurrence=s.idx)}else t.prototype.walkAtLeastOneSep.call(this,r,n,o)},e})(bn);Se.NextTerminalAfterAtLeastOneSepWalker=gd;function Lc(t,e,r){r===void 0&&(r=[]),r=ie.cloneArr(r);var n=[],o=0;function s(a){return a.concat(ie.drop(t,o+1))}function c(a){var l=Lc(s(a),e,r);return n.concat(l)}for(;r.length<e&&o<t.length;){var u=t[o];if(u instanceof ne.Alternative)return c(u.definition);if(u instanceof ne.NonTerminal)return c(u.definition);if(u instanceof ne.Option)n=c(u.definition);else if(u instanceof ne.RepetitionMandatory){var i=u.definition.concat([new ne.Repetition({definition:u.definition})]);return c(i)}else if(u instanceof ne.RepetitionMandatoryWithSeparator){var i=[new ne.Alternative({definition:u.definition}),new ne.Repetition({definition:[new ne.Terminal({terminalType:u.separator})].concat(u.definition)})];return c(i)}else if(u instanceof ne.RepetitionWithSeparator){var i=u.definition.concat([new ne.Repetition({definition:[new ne.Terminal({terminalType:u.separator})].concat(u.definition)})]);n=c(i)}else if(u instanceof ne.Repetition){var i=u.definition.concat([new ne.Repetition({definition:u.definition})]);n=c(i)}else{if(u instanceof ne.Alternation)return ie.forEach(u.definition,function(a){ie.isEmpty(a.definition)===!1&&(n=c(a.definition))}),n;if(u instanceof ne.Terminal)r.push(u.terminalType);else throw Error("non exhaustive match")}o++}return n.push({partialPath:r,suffixDef:ie.drop(t,o)}),n}Se.possiblePathsFrom=Lc;function vd(t,e,r,n){var o="EXIT_NONE_TERMINAL",s=[o],c="EXIT_ALTERNATIVE",u=!1,i=e.length,a=i-n-1,l=[],f=[];for(f.push({idx:-1,def:t,ruleStack:[],occurrenceStack:[]});!ie.isEmpty(f);){var p=f.pop();if(p===c){u&&ie.last(f).idx<=a&&f.pop();continue}var d=p.def,h=p.idx,m=p.ruleStack,E=p.occurrenceStack;if(!ie.isEmpty(d)){var g=d[0];if(g===o){var v={idx:h,def:ie.drop(d),ruleStack:ie.dropRight(m),occurrenceStack:ie.dropRight(E)};f.push(v)}else if(g instanceof ne.Terminal)if(h<i-1){var R=h+1,N=e[R];if(r(N,g.terminalType)){var v={idx:R,def:ie.drop(d),ruleStack:m,occurrenceStack:E};f.push(v)}}else if(h===i-1)l.push({nextTokenType:g.terminalType,nextTokenOccurrence:g.idx,ruleStack:m,occurrenceStack:E}),u=!0;else throw Error("non exhaustive match");else if(g instanceof ne.NonTerminal){var A=ie.cloneArr(m);A.push(g.nonTerminalName);var y=ie.cloneArr(E);y.push(g.idx);var v={idx:h,def:g.definition.concat(s,ie.drop(d)),ruleStack:A,occurrenceStack:y};f.push(v)}else if(g instanceof ne.Option){var T={idx:h,def:ie.drop(d),ruleStack:m,occurrenceStack:E};f.push(T),f.push(c);var I={idx:h,def:g.definition.concat(ie.drop(d)),ruleStack:m,occurrenceStack:E};f.push(I)}else if(g instanceof ne.RepetitionMandatory){var M=new ne.Repetition({definition:g.definition,idx:g.idx}),b=g.definition.concat([M],ie.drop(d)),v={idx:h,def:b,ruleStack:m,occurrenceStack:E};f.push(v)}else if(g instanceof ne.RepetitionMandatoryWithSeparator){var S=new ne.Terminal({terminalType:g.separator}),M=new ne.Repetition({definition:[S].concat(g.definition),idx:g.idx}),b=g.definition.concat([M],ie.drop(d)),v={idx:h,def:b,ruleStack:m,occurrenceStack:E};f.push(v)}else if(g instanceof ne.RepetitionWithSeparator){var T={idx:h,def:ie.drop(d),ruleStack:m,occurrenceStack:E};f.push(T),f.push(c);var S=new ne.Terminal({terminalType:g.separator}),G=new ne.Repetition({definition:[S].concat(g.definition),idx:g.idx}),b=g.definition.concat([G],ie.drop(d)),I={idx:h,def:b,ruleStack:m,occurrenceStack:E};f.push(I)}else if(g instanceof ne.Repetition){var T={idx:h,def:ie.drop(d),ruleStack:m,occurrenceStack:E};f.push(T),f.push(c);var G=new ne.Repetition({definition:g.definition,idx:g.idx}),b=g.definition.concat([G],ie.drop(d)),I={idx:h,def:b,ruleStack:m,occurrenceStack:E};f.push(I)}else if(g instanceof ne.Alternation)for(var j=g.definition.length-1;j>=0;j--){var $=g.definition[j],W={idx:h,def:$.definition.concat(ie.drop(d)),ruleStack:m,occurrenceStack:E};f.push(W),f.push(c)}else if(g instanceof ne.Alternative)f.push({idx:h,def:g.definition.concat(ie.drop(d)),ruleStack:m,occurrenceStack:E});else if(g instanceof ne.Rule)f.push(Ed(g,h,m,E));else throw Error("non exhaustive match")}}return l}Se.nextPossibleTokensAfter=vd;function Ed(t,e,r,n){var o=ie.cloneArr(r);o.push(t.name);var s=ie.cloneArr(n);return s.push(1),{idx:e,def:t.definition,ruleStack:o,occurrenceStack:s}}});var Ln=D(pe=>{"use strict";var Sc=pe&&pe.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(pe,"__esModule",{value:!0});pe.areTokenCategoriesNotUsed=pe.isStrictPrefixOfPath=pe.containsPath=pe.getLookaheadPathsForOptionalProd=pe.getLookaheadPathsForOr=pe.lookAheadSequenceFromAlternatives=pe.buildSingleAlternativeLookaheadFunction=pe.buildAlternativesLookAheadFunc=pe.buildLookaheadFuncForOptionalProd=pe.buildLookaheadFuncForOr=pe.getProdType=pe.PROD_TYPE=void 0;var ye=se(),Uc=xn(),yd=Mo(),xo=on(),_r=gt(),Rd=sn(),Ke;(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"})(Ke=pe.PROD_TYPE||(pe.PROD_TYPE={}));function Nd(t){if(t instanceof _r.Option)return Ke.OPTION;if(t instanceof _r.Repetition)return Ke.REPETITION;if(t instanceof _r.RepetitionMandatory)return Ke.REPETITION_MANDATORY;if(t instanceof _r.RepetitionMandatoryWithSeparator)return Ke.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof _r.RepetitionWithSeparator)return Ke.REPETITION_WITH_SEPARATOR;if(t instanceof _r.Alternation)return Ke.ALTERNATION;throw Error("non exhaustive match")}pe.getProdType=Nd;function Ad(t,e,r,n,o,s){var c=Bc(t,e,r),u=Qi(c)?xo.tokenStructuredMatcherNoCategories:xo.tokenStructuredMatcher;return s(c,n,u,o)}pe.buildLookaheadFuncForOr=Ad;function Td(t,e,r,n,o,s){var c=Dc(t,e,o,r),u=Qi(c)?xo.tokenStructuredMatcherNoCategories:xo.tokenStructuredMatcher;return s(c[0],u,n)}pe.buildLookaheadFuncForOptionalProd=Td;function Od(t,e,r,n){var o=t.length,s=ye.every(t,function(i){return ye.every(i,function(a){return a.length===1})});if(e)return function(i){for(var a=ye.map(i,function(R){return R.GATE}),l=0;l<o;l++){var f=t[l],p=f.length,d=a[l];if(!(d!==void 0&&d.call(this)===!1))e:for(var h=0;h<p;h++){for(var m=f[h],E=m.length,g=0;g<E;g++){var v=this.LA(g+1);if(r(v,m[g])===!1)continue e}return l}}};if(s&&!n){var c=ye.map(t,function(i){return ye.flatten(i)}),u=ye.reduce(c,function(i,a,l){return ye.forEach(a,function(f){ye.has(i,f.tokenTypeIdx)||(i[f.tokenTypeIdx]=l),ye.forEach(f.categoryMatches,function(p){ye.has(i,p)||(i[p]=l)})}),i},[]);return function(){var i=this.LA(1);return u[i.tokenTypeIdx]}}else return function(){for(var i=0;i<o;i++){var a=t[i],l=a.length;e:for(var f=0;f<l;f++){for(var p=a[f],d=p.length,h=0;h<d;h++){var m=this.LA(h+1);if(r(m,p[h])===!1)continue e}return i}}}}pe.buildAlternativesLookAheadFunc=Od;function Id(t,e,r){var n=ye.every(t,function(a){return a.length===1}),o=t.length;if(n&&!r){var s=ye.flatten(t);if(s.length===1&&ye.isEmpty(s[0].categoryMatches)){var c=s[0],u=c.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===u}}else{var i=ye.reduce(s,function(a,l,f){return a[l.tokenTypeIdx]=!0,ye.forEach(l.categoryMatches,function(p){a[p]=!0}),a},[]);return function(){var a=this.LA(1);return i[a.tokenTypeIdx]===!0}}}else return function(){e:for(var a=0;a<o;a++){for(var l=t[a],f=l.length,p=0;p<f;p++){var d=this.LA(p+1);if(e(d,l[p])===!1)continue e}return!0}return!1}}pe.buildSingleAlternativeLookaheadFunction=Id;var Md=(function(t){Sc(e,t);function e(r,n,o){var s=t.call(this)||this;return s.topProd=r,s.targetOccurrence=n,s.targetProdType=o,s}return e.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},e.prototype.checkIsTarget=function(r,n,o,s){return r.idx===this.targetOccurrence&&this.targetProdType===n?(this.restDef=o.concat(s),!0):!1},e.prototype.walkOption=function(r,n,o){this.checkIsTarget(r,Ke.OPTION,n,o)||t.prototype.walkOption.call(this,r,n,o)},e.prototype.walkAtLeastOne=function(r,n,o){this.checkIsTarget(r,Ke.REPETITION_MANDATORY,n,o)||t.prototype.walkOption.call(this,r,n,o)},e.prototype.walkAtLeastOneSep=function(r,n,o){this.checkIsTarget(r,Ke.REPETITION_MANDATORY_WITH_SEPARATOR,n,o)||t.prototype.walkOption.call(this,r,n,o)},e.prototype.walkMany=function(r,n,o){this.checkIsTarget(r,Ke.REPETITION,n,o)||t.prototype.walkOption.call(this,r,n,o)},e.prototype.walkManySep=function(r,n,o){this.checkIsTarget(r,Ke.REPETITION_WITH_SEPARATOR,n,o)||t.prototype.walkOption.call(this,r,n,o)},e})(yd.RestWalker),Fc=(function(t){Sc(e,t);function e(r,n,o){var s=t.call(this)||this;return s.targetOccurrence=r,s.targetProdType=n,s.targetRef=o,s.result=[],s}return e.prototype.checkIsTarget=function(r,n){r.idx===this.targetOccurrence&&this.targetProdType===n&&(this.targetRef===void 0||r===this.targetRef)&&(this.result=r.definition)},e.prototype.visitOption=function(r){this.checkIsTarget(r,Ke.OPTION)},e.prototype.visitRepetition=function(r){this.checkIsTarget(r,Ke.REPETITION)},e.prototype.visitRepetitionMandatory=function(r){this.checkIsTarget(r,Ke.REPETITION_MANDATORY)},e.prototype.visitRepetitionMandatoryWithSeparator=function(r){this.checkIsTarget(r,Ke.REPETITION_MANDATORY_WITH_SEPARATOR)},e.prototype.visitRepetitionWithSeparator=function(r){this.checkIsTarget(r,Ke.REPETITION_WITH_SEPARATOR)},e.prototype.visitAlternation=function(r){this.checkIsTarget(r,Ke.ALTERNATION)},e})(Rd.GAstVisitor);function Pc(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=[];return e}function Ki(t){for(var e=[""],r=0;r<t.length;r++){for(var n=t[r],o=[],s=0;s<e.length;s++){var c=e[s];o.push(c+"_"+n.tokenTypeIdx);for(var u=0;u<n.categoryMatches.length;u++){var i="_"+n.categoryMatches[u];o.push(c+i)}}e=o}return e}function Cd(t,e,r){for(var n=0;n<t.length;n++)if(n!==r)for(var o=t[n],s=0;s<e.length;s++){var c=e[s];if(o[c]===!0)return!1}return!0}function Xi(t,e){for(var r=ye.map(t,function(l){return Uc.possiblePathsFrom([l],1)}),n=Pc(r.length),o=ye.map(r,function(l){var f={};return ye.forEach(l,function(p){var d=Ki(p.partialPath);ye.forEach(d,function(h){f[h]=!0})}),f}),s=r,c=1;c<=e;c++){var u=s;s=Pc(u.length);for(var i=function(l){for(var f=u[l],p=0;p<f.length;p++){var d=f[p].partialPath,h=f[p].suffixDef,m=Ki(d),E=Cd(o,m,l);if(E||ye.isEmpty(h)||d.length===e){var g=n[l];if(Wc(g,d)===!1){g.push(d);for(var v=0;v<m.length;v++){var R=m[v];o[l][R]=!0}}}else{var N=Uc.possiblePathsFrom(h,c+1,d);s[l]=s[l].concat(N),ye.forEach(N,function(A){var y=Ki(A.partialPath);ye.forEach(y,function(T){o[l][T]=!0})})}}},a=0;a<u.length;a++)i(a)}return n}pe.lookAheadSequenceFromAlternatives=Xi;function Bc(t,e,r,n){var o=new Fc(t,Ke.ALTERNATION,n);return e.accept(o),Xi(o.result,r)}pe.getLookaheadPathsForOr=Bc;function Dc(t,e,r,n){var o=new Fc(t,r);e.accept(o);var s=o.result,c=new Md(e,t,r),u=c.startWalking(),i=new _r.Alternative({definition:s}),a=new _r.Alternative({definition:u});return Xi([i,a],n)}pe.getLookaheadPathsForOptionalProd=Dc;function Wc(t,e){e:for(var r=0;r<t.length;r++){var n=t[r];if(n.length===e.length){for(var o=0;o<n.length;o++){var s=e[o],c=n[o],u=s===c||c.categoryMatchesMap[s.tokenTypeIdx]!==void 0;if(u===!1)continue e}return!0}}return!1}pe.containsPath=Wc;function wd(t,e){return t.length<e.length&&ye.every(t,function(r,n){var o=e[n];return r===o||o.categoryMatchesMap[r.tokenTypeIdx]})}pe.isStrictPrefixOfPath=wd;function Qi(t){return ye.every(t,function(e){return ye.every(e,function(r){return ye.every(r,function(n){return ye.isEmpty(n.categoryMatches)})})})}pe.areTokenCategoriesNotUsed=Qi});var rs=D(fe=>{"use strict";var Zi=fe&&fe.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(fe,"__esModule",{value:!0});fe.checkPrefixAlternativesAmbiguities=fe.validateSomeNonEmptyLookaheadPath=fe.validateTooManyAlts=fe.RepetionCollector=fe.validateAmbiguousAlternationAlternatives=fe.validateEmptyOrAlternative=fe.getFirstNoneTerminal=fe.validateNoLeftRecursion=fe.validateRuleIsOverridden=fe.validateRuleDoesNotAlreadyExist=fe.OccurrenceValidationCollector=fe.identifyProductionForDuplicates=fe.validateGrammar=void 0;var ge=se(),_e=se(),rr=Mt(),Ji=an(),cn=Ln(),_d=xn(),$t=gt(),ji=sn();function kd(t,e,r,n,o){var s=ge.map(t,function(d){return bd(d,n)}),c=ge.map(t,function(d){return es(d,d,n)}),u=[],i=[],a=[];_e.every(c,_e.isEmpty)&&(u=_e.map(t,function(d){return zc(d,n)}),i=_e.map(t,function(d){return Yc(d,e,n)}),a=Xc(t,e,n));var l=Ud(t,r,n),f=_e.map(t,function(d){return Kc(d,n)}),p=_e.map(t,function(d){return Hc(d,t,o,n)});return ge.flatten(s.concat(a,c,u,i,l,f,p))}fe.validateGrammar=kd;function bd(t,e){var r=new qc;t.accept(r);var n=r.allProductions,o=ge.groupBy(n,Vc),s=ge.pick(o,function(u){return u.length>1}),c=ge.map(ge.values(s),function(u){var i=ge.first(u),a=e.buildDuplicateFoundError(t,u),l=Ji.getProductionDslName(i),f={message:a,type:rr.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:l,occurrence:i.idx},p=Gc(i);return p&&(f.parameter=p),f});return c}function Vc(t){return Ji.getProductionDslName(t)+"_#_"+t.idx+"_#_"+Gc(t)}fe.identifyProductionForDuplicates=Vc;function Gc(t){return t instanceof $t.Terminal?t.terminalType.name:t instanceof $t.NonTerminal?t.nonTerminalName:""}var qc=(function(t){Zi(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.allProductions=[],r}return e.prototype.visitNonTerminal=function(r){this.allProductions.push(r)},e.prototype.visitOption=function(r){this.allProductions.push(r)},e.prototype.visitRepetitionWithSeparator=function(r){this.allProductions.push(r)},e.prototype.visitRepetitionMandatory=function(r){this.allProductions.push(r)},e.prototype.visitRepetitionMandatoryWithSeparator=function(r){this.allProductions.push(r)},e.prototype.visitRepetition=function(r){this.allProductions.push(r)},e.prototype.visitAlternation=function(r){this.allProductions.push(r)},e.prototype.visitTerminal=function(r){this.allProductions.push(r)},e})(ji.GAstVisitor);fe.OccurrenceValidationCollector=qc;function Hc(t,e,r,n){var o=[],s=_e.reduce(e,function(u,i){return i.name===t.name?u+1:u},0);if(s>1){var c=n.buildDuplicateRuleNameError({topLevelRule:t,grammarName:r});o.push({message:c,type:rr.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:t.name})}return o}fe.validateRuleDoesNotAlreadyExist=Hc;function xd(t,e,r){var n=[],o;return ge.contains(e,t)||(o="Invalid rule override, rule: ->"+t+"<- cannot be overridden in the grammar: ->"+r+"<-as it is not defined in any of the super grammars ",n.push({message:o,type:rr.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:t})),n}fe.validateRuleIsOverridden=xd;function es(t,e,r,n){n===void 0&&(n=[]);var o=[],s=Un(e.definition);if(ge.isEmpty(s))return[];var c=t.name,u=ge.contains(s,t);u&&o.push({message:r.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:n}),type:rr.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:c});var i=ge.difference(s,n.concat([t])),a=ge.map(i,function(l){var f=ge.cloneArr(n);return f.push(l),es(t,l,r,f)});return o.concat(ge.flatten(a))}fe.validateNoLeftRecursion=es;function Un(t){var e=[];if(ge.isEmpty(t))return e;var r=ge.first(t);if(r instanceof $t.NonTerminal)e.push(r.referencedRule);else if(r instanceof $t.Alternative||r instanceof $t.Option||r instanceof $t.RepetitionMandatory||r instanceof $t.RepetitionMandatoryWithSeparator||r instanceof $t.RepetitionWithSeparator||r instanceof $t.Repetition)e=e.concat(Un(r.definition));else if(r instanceof $t.Alternation)e=ge.flatten(ge.map(r.definition,function(c){return Un(c.definition)}));else if(!(r instanceof $t.Terminal))throw Error("non exhaustive match");var n=Ji.isOptionalProd(r),o=t.length>1;if(n&&o){var s=ge.drop(t);return e.concat(Un(s))}else return e}fe.getFirstNoneTerminal=Un;var ts=(function(t){Zi(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.alternations=[],r}return e.prototype.visitAlternation=function(r){this.alternations.push(r)},e})(ji.GAstVisitor);function zc(t,e){var r=new ts;t.accept(r);var n=r.alternations,o=ge.reduce(n,function(s,c){var u=ge.dropRight(c.definition),i=ge.map(u,function(a,l){var f=_d.nextPossibleTokensAfter([a],[],null,1);return ge.isEmpty(f)?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:c,emptyChoiceIdx:l}),type:rr.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:c.idx,alternative:l+1}:null});return s.concat(ge.compact(i))},[]);return o}fe.validateEmptyOrAlternative=zc;function Yc(t,e,r){var n=new ts;t.accept(n);var o=n.alternations;o=_e.reject(o,function(c){return c.ignoreAmbiguities===!0});var s=ge.reduce(o,function(c,u){var i=u.idx,a=u.maxLookahead||e,l=cn.getLookaheadPathsForOr(i,t,a,u),f=Ld(l,u,t,r),p=Qc(l,u,t,r);return c.concat(f,p)},[]);return s}fe.validateAmbiguousAlternationAlternatives=Yc;var $c=(function(t){Zi(e,t);function e(){var r=t!==null&&t.apply(this,arguments)||this;return r.allProductions=[],r}return e.prototype.visitRepetitionWithSeparator=function(r){this.allProductions.push(r)},e.prototype.visitRepetitionMandatory=function(r){this.allProductions.push(r)},e.prototype.visitRepetitionMandatoryWithSeparator=function(r){this.allProductions.push(r)},e.prototype.visitRepetition=function(r){this.allProductions.push(r)},e})(ji.GAstVisitor);fe.RepetionCollector=$c;function Kc(t,e){var r=new ts;t.accept(r);var n=r.alternations,o=ge.reduce(n,function(s,c){return c.definition.length>255&&s.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:c}),type:rr.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:t.name,occurrence:c.idx}),s},[]);return o}fe.validateTooManyAlts=Kc;function Xc(t,e,r){var n=[];return _e.forEach(t,function(o){var s=new $c;o.accept(s);var c=s.allProductions;_e.forEach(c,function(u){var i=cn.getProdType(u),a=u.maxLookahead||e,l=u.idx,f=cn.getLookaheadPathsForOptionalProd(l,o,i,a),p=f[0];if(_e.isEmpty(_e.flatten(p))){var d=r.buildEmptyRepetitionError({topLevelRule:o,repetition:u});n.push({message:d,type:rr.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:o.name})}})}),n}fe.validateSomeNonEmptyLookaheadPath=Xc;function Ld(t,e,r,n){var o=[],s=_e.reduce(t,function(u,i,a){return e.definition[a].ignoreAmbiguities===!0||_e.forEach(i,function(l){var f=[a];_e.forEach(t,function(p,d){a!==d&&cn.containsPath(p,l)&&e.definition[d].ignoreAmbiguities!==!0&&f.push(d)}),f.length>1&&!cn.containsPath(o,l)&&(o.push(l),u.push({alts:f,path:l}))}),u},[]),c=ge.map(s,function(u){var i=_e.map(u.alts,function(l){return l+1}),a=n.buildAlternationAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:i,prefixPath:u.path});return{message:a,type:rr.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:r.name,occurrence:e.idx,alternatives:[u.alts]}});return c}function Qc(t,e,r,n){var o=[],s=_e.reduce(t,function(c,u,i){var a=_e.map(u,function(l){return{idx:i,path:l}});return c.concat(a)},[]);return _e.forEach(s,function(c){var u=e.definition[c.idx];if(u.ignoreAmbiguities!==!0){var i=c.idx,a=c.path,l=_e.findAll(s,function(p){return e.definition[p.idx].ignoreAmbiguities!==!0&&p.idx<i&&cn.isStrictPrefixOfPath(p.path,a)}),f=_e.map(l,function(p){var d=[p.idx+1,i+1],h=e.idx===0?"":e.idx,m=n.buildAlternationPrefixAmbiguityError({topLevelRule:r,alternation:e,ambiguityIndices:d,prefixPath:p.path});return{message:m,type:rr.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:r.name,occurrence:h,alternatives:d}});o=o.concat(f)}}),o}fe.checkPrefixAlternativesAmbiguities=Qc;function Ud(t,e,r){var n=[],o=_e.map(e,function(s){return s.name});return _e.forEach(t,function(s){var c=s.name;if(_e.contains(o,c)){var u=r.buildNamespaceConflictError(s);n.push({message:u,type:rr.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:c})}}),n}});var ns=D(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.assignOccurrenceIndices=kr.validateGrammar=kr.resolveGrammar=void 0;var ln=se(),Pd=kc(),Sd=rs(),Zc=kn(),Fd=an();function Bd(t){t=ln.defaults(t,{errMsgProvider:Zc.defaultGrammarResolverErrorProvider});var e={};return ln.forEach(t.rules,function(r){e[r.name]=r}),Pd.resolveGrammar(e,t.errMsgProvider)}kr.resolveGrammar=Bd;function Dd(t){return t=ln.defaults(t,{errMsgProvider:Zc.defaultGrammarValidatorErrorProvider}),Sd.validateGrammar(t.rules,t.maxLookahead,t.tokenTypes,t.errMsgProvider,t.grammarName)}kr.validateGrammar=Dd;function Wd(t){ln.forEach(t.rules,function(e){var r=new Fd.DslMethodsCollectorVisitor;e.accept(r),ln.forEach(r.dslMethods,function(n){ln.forEach(n,function(o,s){o.idx=s+1})})})}kr.assignOccurrenceIndices=Wd});var fn=D(Tt=>{"use strict";var Pn=Tt&&Tt.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(Tt,"__esModule",{value:!0});Tt.EarlyExitException=Tt.NotAllInputParsedException=Tt.NoViableAltException=Tt.MismatchedTokenException=Tt.isRecognitionException=void 0;var Vd=se(),Jc="MismatchedTokenException",jc="NoViableAltException",el="EarlyExitException",tl="NotAllInputParsedException",rl=[Jc,jc,el,tl];Object.freeze(rl);function Gd(t){return Vd.contains(rl,t.name)}Tt.isRecognitionException=Gd;var Lo=(function(t){Pn(e,t);function e(r,n){var o=this.constructor,s=t.call(this,r)||this;return s.token=n,s.resyncedTokens=[],Object.setPrototypeOf(s,o.prototype),Error.captureStackTrace&&Error.captureStackTrace(s,s.constructor),s}return e})(Error),qd=(function(t){Pn(e,t);function e(r,n,o){var s=t.call(this,r,n)||this;return s.previousToken=o,s.name=Jc,s}return e})(Lo);Tt.MismatchedTokenException=qd;var Hd=(function(t){Pn(e,t);function e(r,n,o){var s=t.call(this,r,n)||this;return s.previousToken=o,s.name=jc,s}return e})(Lo);Tt.NoViableAltException=Hd;var zd=(function(t){Pn(e,t);function e(r,n){var o=t.call(this,r,n)||this;return o.name=tl,o}return e})(Lo);Tt.NotAllInputParsedException=zd;var Yd=(function(t){Pn(e,t);function e(r,n,o){var s=t.call(this,r,n)||this;return s.previousToken=o,s.name=el,s}return e})(Lo);Tt.EarlyExitException=Yd});var is=D(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.attemptInRepetitionRecovery=lt.Recoverable=lt.InRuleRecoveryException=lt.IN_RULE_RECOVERY_EXCEPTION=lt.EOF_FOLLOW_KEY=void 0;var Uo=Cr(),St=se(),$d=fn(),Kd=Yi(),Xd=Mt();lt.EOF_FOLLOW_KEY={};lt.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function os(t){this.name=lt.IN_RULE_RECOVERY_EXCEPTION,this.message=t}lt.InRuleRecoveryException=os;os.prototype=Error.prototype;var Qd=(function(){function t(){}return t.prototype.initRecoverable=function(e){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=St.has(e,"recoveryEnabled")?e.recoveryEnabled:Xd.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=nl)},t.prototype.getTokenToInsert=function(e){var r=Uo.createTokenInstance(e,"",NaN,NaN,NaN,NaN,NaN,NaN);return r.isInsertedInRecovery=!0,r},t.prototype.canTokenTypeBeInsertedInRecovery=function(e){return!0},t.prototype.tryInRepetitionRecovery=function(e,r,n,o){for(var s=this,c=this.findReSyncTokenType(),u=this.exportLexerState(),i=[],a=!1,l=this.LA(1),f=this.LA(1),p=function(){var d=s.LA(0),h=s.errorMessageProvider.buildMismatchTokenMessage({expected:o,actual:l,previous:d,ruleName:s.getCurrRuleFullName()}),m=new $d.MismatchedTokenException(h,l,s.LA(0));m.resyncedTokens=St.dropRight(i),s.SAVE_ERROR(m)};!a;)if(this.tokenMatcher(f,o)){p();return}else if(n.call(this)){p(),e.apply(this,r);return}else this.tokenMatcher(f,c)?a=!0:(f=this.SKIP_TOKEN(),this.addToResyncTokens(f,i));this.importLexerState(u)},t.prototype.shouldInRepetitionRecoveryBeTried=function(e,r,n){return!(n===!1||e===void 0||r===void 0||this.tokenMatcher(this.LA(1),e)||this.isBackTracking()||this.canPerformInRuleRecovery(e,this.getFollowsForInRuleRecovery(e,r)))},t.prototype.getFollowsForInRuleRecovery=function(e,r){var n=this.getCurrentGrammarPath(e,r),o=this.getNextPossibleTokenTypes(n);return o},t.prototype.tryInRuleRecovery=function(e,r){if(this.canRecoverWithSingleTokenInsertion(e,r)){var n=this.getTokenToInsert(e);return n}if(this.canRecoverWithSingleTokenDeletion(e)){var o=this.SKIP_TOKEN();return this.consumeToken(),o}throw new os("sad sad panda")},t.prototype.canPerformInRuleRecovery=function(e,r){return this.canRecoverWithSingleTokenInsertion(e,r)||this.canRecoverWithSingleTokenDeletion(e)},t.prototype.canRecoverWithSingleTokenInsertion=function(e,r){var n=this;if(!this.canTokenTypeBeInsertedInRecovery(e)||St.isEmpty(r))return!1;var o=this.LA(1),s=St.find(r,function(c){return n.tokenMatcher(o,c)})!==void 0;return s},t.prototype.canRecoverWithSingleTokenDeletion=function(e){var r=this.tokenMatcher(this.LA(2),e);return r},t.prototype.isInCurrentRuleReSyncSet=function(e){var r=this.getCurrFollowKey(),n=this.getFollowSetFromFollowKey(r);return St.contains(n,e)},t.prototype.findReSyncTokenType=function(){for(var e=this.flattenFollowSet(),r=this.LA(1),n=2;;){var o=r.tokenType;if(St.contains(e,o))return o;r=this.LA(n),n++}},t.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return lt.EOF_FOLLOW_KEY;var e=this.getLastExplicitRuleShortName(),r=this.getLastExplicitRuleOccurrenceIndex(),n=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(e),idxInCallingRule:r,inRule:this.shortRuleNameToFullName(n)}},t.prototype.buildFullFollowKeyStack=function(){var e=this,r=this.RULE_STACK,n=this.RULE_OCCURRENCE_STACK;return St.map(r,function(o,s){return s===0?lt.EOF_FOLLOW_KEY:{ruleName:e.shortRuleNameToFullName(o),idxInCallingRule:n[s],inRule:e.shortRuleNameToFullName(r[s-1])}})},t.prototype.flattenFollowSet=function(){var e=this,r=St.map(this.buildFullFollowKeyStack(),function(n){return e.getFollowSetFromFollowKey(n)});return St.flatten(r)},t.prototype.getFollowSetFromFollowKey=function(e){if(e===lt.EOF_FOLLOW_KEY)return[Uo.EOF];var r=e.ruleName+e.idxInCallingRule+Kd.IN+e.inRule;return this.resyncFollows[r]},t.prototype.addToResyncTokens=function(e,r){return this.tokenMatcher(e,Uo.EOF)||r.push(e),r},t.prototype.reSyncTo=function(e){for(var r=[],n=this.LA(1);this.tokenMatcher(n,e)===!1;)n=this.SKIP_TOKEN(),this.addToResyncTokens(n,r);return St.dropRight(r)},t.prototype.attemptInRepetitionRecovery=function(e,r,n,o,s,c,u){},t.prototype.getCurrentGrammarPath=function(e,r){var n=this.getHumanReadableRuleStack(),o=St.cloneArr(this.RULE_OCCURRENCE_STACK),s={ruleStack:n,occurrenceStack:o,lastTok:e,lastTokOccurrence:r};return s},t.prototype.getHumanReadableRuleStack=function(){var e=this;return St.map(this.RULE_STACK,function(r){return e.shortRuleNameToFullName(r)})},t})();lt.Recoverable=Qd;function nl(t,e,r,n,o,s,c){var u=this.getKeyForAutomaticLookahead(n,o),i=this.firstAfterRepMap[u];if(i===void 0){var a=this.getCurrRuleFullName(),l=this.getGAstProductions()[a],f=new s(l,o);i=f.startWalking(),this.firstAfterRepMap[u]=i}var p=i.token,d=i.occurrence,h=i.isEndOfRule;this.RULE_STACK.length===1&&h&&p===void 0&&(p=Uo.EOF,d=1),this.shouldInRepetitionRecoveryBeTried(p,d,c)&&this.tryInRepetitionRecovery(t,e,r,p)}lt.attemptInRepetitionRecovery=nl});var Po=D(ae=>{"use strict";Object.defineProperty(ae,"__esModule",{value:!0});ae.getKeyForAutomaticLookahead=ae.AT_LEAST_ONE_SEP_IDX=ae.MANY_SEP_IDX=ae.AT_LEAST_ONE_IDX=ae.MANY_IDX=ae.OPTION_IDX=ae.OR_IDX=ae.BITS_FOR_ALT_IDX=ae.BITS_FOR_RULE_IDX=ae.BITS_FOR_OCCURRENCE_IDX=ae.BITS_FOR_METHOD_TYPE=void 0;ae.BITS_FOR_METHOD_TYPE=4;ae.BITS_FOR_OCCURRENCE_IDX=8;ae.BITS_FOR_RULE_IDX=12;ae.BITS_FOR_ALT_IDX=8;ae.OR_IDX=1<<ae.BITS_FOR_OCCURRENCE_IDX;ae.OPTION_IDX=2<<ae.BITS_FOR_OCCURRENCE_IDX;ae.MANY_IDX=3<<ae.BITS_FOR_OCCURRENCE_IDX;ae.AT_LEAST_ONE_IDX=4<<ae.BITS_FOR_OCCURRENCE_IDX;ae.MANY_SEP_IDX=5<<ae.BITS_FOR_OCCURRENCE_IDX;ae.AT_LEAST_ONE_SEP_IDX=6<<ae.BITS_FOR_OCCURRENCE_IDX;function Zd(t,e,r){return r|e|t}ae.getKeyForAutomaticLookahead=Zd;var Kv=32-ae.BITS_FOR_ALT_IDX});var il=D(So=>{"use strict";Object.defineProperty(So,"__esModule",{value:!0});So.LooksAhead=void 0;var vr=Ln(),Kt=se(),ol=Mt(),Er=Po(),qr=an(),Jd=(function(){function t(){}return t.prototype.initLooksAhead=function(e){this.dynamicTokensEnabled=Kt.has(e,"dynamicTokensEnabled")?e.dynamicTokensEnabled:ol.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=Kt.has(e,"maxLookahead")?e.maxLookahead:ol.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=Kt.isES2015MapSupported()?new Map:[],Kt.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},t.prototype.preComputeLookaheadFunctions=function(e){var r=this;Kt.forEach(e,function(n){r.TRACE_INIT(n.name+" Rule Lookahead",function(){var o=qr.collectMethods(n),s=o.alternation,c=o.repetition,u=o.option,i=o.repetitionMandatory,a=o.repetitionMandatoryWithSeparator,l=o.repetitionWithSeparator;Kt.forEach(s,function(f){var p=f.idx===0?"":f.idx;r.TRACE_INIT(""+qr.getProductionDslName(f)+p,function(){var d=vr.buildLookaheadFuncForOr(f.idx,n,f.maxLookahead||r.maxLookahead,f.hasPredicates,r.dynamicTokensEnabled,r.lookAheadBuilderForAlternatives),h=Er.getKeyForAutomaticLookahead(r.fullRuleNameToShort[n.name],Er.OR_IDX,f.idx);r.setLaFuncCache(h,d)})}),Kt.forEach(c,function(f){r.computeLookaheadFunc(n,f.idx,Er.MANY_IDX,vr.PROD_TYPE.REPETITION,f.maxLookahead,qr.getProductionDslName(f))}),Kt.forEach(u,function(f){r.computeLookaheadFunc(n,f.idx,Er.OPTION_IDX,vr.PROD_TYPE.OPTION,f.maxLookahead,qr.getProductionDslName(f))}),Kt.forEach(i,function(f){r.computeLookaheadFunc(n,f.idx,Er.AT_LEAST_ONE_IDX,vr.PROD_TYPE.REPETITION_MANDATORY,f.maxLookahead,qr.getProductionDslName(f))}),Kt.forEach(a,function(f){r.computeLookaheadFunc(n,f.idx,Er.AT_LEAST_ONE_SEP_IDX,vr.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,f.maxLookahead,qr.getProductionDslName(f))}),Kt.forEach(l,function(f){r.computeLookaheadFunc(n,f.idx,Er.MANY_SEP_IDX,vr.PROD_TYPE.REPETITION_WITH_SEPARATOR,f.maxLookahead,qr.getProductionDslName(f))})})})},t.prototype.computeLookaheadFunc=function(e,r,n,o,s,c){var u=this;this.TRACE_INIT(""+c+(r===0?"":r),function(){var i=vr.buildLookaheadFuncForOptionalProd(r,e,s||u.maxLookahead,u.dynamicTokensEnabled,o,u.lookAheadBuilderForOptional),a=Er.getKeyForAutomaticLookahead(u.fullRuleNameToShort[e.name],n,r);u.setLaFuncCache(a,i)})},t.prototype.lookAheadBuilderForOptional=function(e,r,n){return vr.buildSingleAlternativeLookaheadFunction(e,r,n)},t.prototype.lookAheadBuilderForAlternatives=function(e,r,n,o){return vr.buildAlternativesLookAheadFunc(e,r,n,o)},t.prototype.getKeyForAutomaticLookahead=function(e,r){var n=this.getLastExplicitRuleShortName();return Er.getKeyForAutomaticLookahead(n,e,r)},t.prototype.getLaFuncFromCache=function(e){},t.prototype.getLaFuncFromMap=function(e){return this.lookAheadFuncsCache.get(e)},t.prototype.getLaFuncFromObj=function(e){return this.lookAheadFuncsCache[e]},t.prototype.setLaFuncCache=function(e,r){},t.prototype.setLaFuncCacheUsingMap=function(e,r){this.lookAheadFuncsCache.set(e,r)},t.prototype.setLaFuncUsingObj=function(e,r){this.lookAheadFuncsCache[e]=r},t})();So.LooksAhead=Jd});var sl=D(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.addNoneTerminalToCst=nr.addTerminalToCst=nr.setNodeLocationFull=nr.setNodeLocationOnlyOffset=void 0;function jd(t,e){isNaN(t.startOffset)===!0?(t.startOffset=e.startOffset,t.endOffset=e.endOffset):t.endOffset<e.endOffset&&(t.endOffset=e.endOffset)}nr.setNodeLocationOnlyOffset=jd;function em(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)}nr.setNodeLocationFull=em;function tm(t,e,r){t.children[r]===void 0?t.children[r]=[e]:t.children[r].push(e)}nr.addTerminalToCst=tm;function rm(t,e,r){t.children[e]===void 0?t.children[e]=[r]:t.children[e].push(r)}nr.addNoneTerminalToCst=rm});var ss=D(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.defineNameProp=br.functionName=br.classNameFromInstance=void 0;var nm=se();function om(t){return ul(t.constructor)}br.classNameFromInstance=om;var al="name";function ul(t){var e=t.name;return e||"anonymous"}br.functionName=ul;function im(t,e){var r=Object.getOwnPropertyDescriptor(t,al);return nm.isUndefined(r)||r.configurable?(Object.defineProperty(t,al,{enumerable:!1,configurable:!0,writable:!1,value:e}),!0):!1}br.defineNameProp=im});var pl=D(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.validateRedundantMethods=at.validateMissingCstMethods=at.validateVisitor=at.CstVisitorDefinitionError=at.createBaseVisitorConstructorWithDefaults=at.createBaseSemanticVisitorConstructor=at.defaultVisit=void 0;var Ft=se(),Sn=ss();function cl(t,e){for(var r=Ft.keys(t),n=r.length,o=0;o<n;o++)for(var s=r[o],c=t[s],u=c.length,i=0;i<u;i++){var a=c[i];a.tokenTypeIdx===void 0&&this[a.name](a.children,e)}}at.defaultVisit=cl;function sm(t,e){var r=function(){};Sn.defineNameProp(r,t+"BaseSemantics");var n={visit:function(o,s){if(Ft.isArray(o)&&(o=o[0]),!Ft.isUndefined(o))return this[o.name](o.children,s)},validateVisitor:function(){var o=ll(this,e);if(!Ft.isEmpty(o)){var s=Ft.map(o,function(c){return c.msg});throw Error("Errors Detected in CST Visitor <"+Sn.functionName(this.constructor)+`>:
91
+ `+(""+s.join(`
92
+
93
+ `).replace(/\n/g,`
94
+ `)))}}};return r.prototype=n,r.prototype.constructor=r,r._RULE_NAMES=e,r}at.createBaseSemanticVisitorConstructor=sm;function am(t,e,r){var n=function(){};Sn.defineNameProp(n,t+"BaseSemanticsWithDefaults");var o=Object.create(r.prototype);return Ft.forEach(e,function(s){o[s]=cl}),n.prototype=o,n.prototype.constructor=n,n}at.createBaseVisitorConstructorWithDefaults=am;var as;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(as=at.CstVisitorDefinitionError||(at.CstVisitorDefinitionError={}));function ll(t,e){var r=fl(t,e),n=hl(t,e);return r.concat(n)}at.validateVisitor=ll;function fl(t,e){var r=Ft.map(e,function(n){if(!Ft.isFunction(t[n]))return{msg:"Missing visitor method: <"+n+"> on "+Sn.functionName(t.constructor)+" CST Visitor.",type:as.MISSING_METHOD,methodName:n}});return Ft.compact(r)}at.validateMissingCstMethods=fl;var um=["constructor","visit","validateVisitor"];function hl(t,e){var r=[];for(var n in t)Ft.isFunction(t[n])&&!Ft.contains(um,n)&&!Ft.contains(e,n)&&r.push({msg:"Redundant visitor method: <"+n+"> on "+Sn.functionName(t.constructor)+` CST Visitor
95
+ There is no Grammar Rule corresponding to this method's name.
96
+ `,type:as.REDUNDANT_METHOD,methodName:n});return r}at.validateRedundantMethods=hl});var ml=D(Fo=>{"use strict";Object.defineProperty(Fo,"__esModule",{value:!0});Fo.TreeBuilder=void 0;var hn=sl(),ze=se(),dl=pl(),cm=Mt(),lm=(function(){function t(){}return t.prototype.initTreeBuilder=function(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=ze.has(e,"nodeLocationTracking")?e.nodeLocationTracking:cm.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=ze.NOOP,this.cstFinallyStateUpdate=ze.NOOP,this.cstPostTerminal=ze.NOOP,this.cstPostNonTerminal=ze.NOOP,this.cstPostRule=ze.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=hn.setNodeLocationFull,this.setNodeLocationFromNode=hn.setNodeLocationFull,this.cstPostRule=ze.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=ze.NOOP,this.setNodeLocationFromNode=ze.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=hn.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=hn.setNodeLocationOnlyOffset,this.cstPostRule=ze.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=ze.NOOP,this.setNodeLocationFromNode=ze.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=ze.NOOP,this.setNodeLocationFromNode=ze.NOOP,this.cstPostRule=ze.NOOP,this.setInitialNodeLocation=ze.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+e.nodeLocationTracking+'"')},t.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(e){e.location={startOffset:NaN,endOffset:NaN}},t.prototype.setInitialNodeLocationOnlyOffsetRegular=function(e){e.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},t.prototype.setInitialNodeLocationFullRecovery=function(e){e.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.setInitialNodeLocationFullRegular=function(e){var r=this.LA(1);e.location={startOffset:r.startOffset,startLine:r.startLine,startColumn:r.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.cstInvocationStateUpdate=function(e,r){var n={name:e,children:{}};this.setInitialNodeLocation(n),this.CST_STACK.push(n)},t.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},t.prototype.cstPostRuleFull=function(e){var r=this.LA(0),n=e.location;n.startOffset<=r.startOffset?(n.endOffset=r.endOffset,n.endLine=r.endLine,n.endColumn=r.endColumn):(n.startOffset=NaN,n.startLine=NaN,n.startColumn=NaN)},t.prototype.cstPostRuleOnlyOffset=function(e){var r=this.LA(0),n=e.location;n.startOffset<=r.startOffset?n.endOffset=r.endOffset:n.startOffset=NaN},t.prototype.cstPostTerminal=function(e,r){var n=this.CST_STACK[this.CST_STACK.length-1];hn.addTerminalToCst(n,r,e),this.setNodeLocationFromToken(n.location,r)},t.prototype.cstPostNonTerminal=function(e,r){var n=this.CST_STACK[this.CST_STACK.length-1];hn.addNoneTerminalToCst(n,r,e),this.setNodeLocationFromNode(n.location,e.location)},t.prototype.getBaseCstVisitorConstructor=function(){if(ze.isUndefined(this.baseCstVisitorConstructor)){var e=dl.createBaseSemanticVisitorConstructor(this.className,ze.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(ze.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var e=dl.createBaseVisitorConstructorWithDefaults(this.className,ze.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=e,e}return this.baseCstVisitorWithDefaultsConstructor},t.prototype.getLastExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-1]},t.prototype.getPreviousExplicitRuleShortName=function(){var e=this.RULE_STACK;return e[e.length-2]},t.prototype.getLastExplicitRuleOccurrenceIndex=function(){var e=this.RULE_OCCURRENCE_STACK;return e[e.length-1]},t})();Fo.TreeBuilder=lm});var vl=D(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.LexerAdapter=void 0;var gl=Mt(),fm=(function(){function t(){}return t.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(t.prototype,"input",{get:function(){return this.tokVector},set:function(e){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=e,this.tokVectorLength=e.length},enumerable:!1,configurable:!0}),t.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):gl.END_OF_FILE},t.prototype.LA=function(e){var r=this.currIdx+e;return r<0||this.tokVectorLength<=r?gl.END_OF_FILE:this.tokVector[r]},t.prototype.consumeToken=function(){this.currIdx++},t.prototype.exportLexerState=function(){return this.currIdx},t.prototype.importLexerState=function(e){this.currIdx=e},t.prototype.resetLexerState=function(){this.currIdx=-1},t.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},t.prototype.getLexerPosition=function(){return this.exportLexerState()},t})();Bo.LexerAdapter=fm});var yl=D(Do=>{"use strict";Object.defineProperty(Do,"__esModule",{value:!0});Do.RecognizerApi=void 0;var El=se(),hm=fn(),us=Mt(),pm=kn(),dm=rs(),mm=gt(),gm=(function(){function t(){}return t.prototype.ACTION=function(e){return e.call(this)},t.prototype.consume=function(e,r,n){return this.consumeInternal(r,e,n)},t.prototype.subrule=function(e,r,n){return this.subruleInternal(r,e,n)},t.prototype.option=function(e,r){return this.optionInternal(r,e)},t.prototype.or=function(e,r){return this.orInternal(r,e)},t.prototype.many=function(e,r){return this.manyInternal(e,r)},t.prototype.atLeastOne=function(e,r){return this.atLeastOneInternal(e,r)},t.prototype.CONSUME=function(e,r){return this.consumeInternal(e,0,r)},t.prototype.CONSUME1=function(e,r){return this.consumeInternal(e,1,r)},t.prototype.CONSUME2=function(e,r){return this.consumeInternal(e,2,r)},t.prototype.CONSUME3=function(e,r){return this.consumeInternal(e,3,r)},t.prototype.CONSUME4=function(e,r){return this.consumeInternal(e,4,r)},t.prototype.CONSUME5=function(e,r){return this.consumeInternal(e,5,r)},t.prototype.CONSUME6=function(e,r){return this.consumeInternal(e,6,r)},t.prototype.CONSUME7=function(e,r){return this.consumeInternal(e,7,r)},t.prototype.CONSUME8=function(e,r){return this.consumeInternal(e,8,r)},t.prototype.CONSUME9=function(e,r){return this.consumeInternal(e,9,r)},t.prototype.SUBRULE=function(e,r){return this.subruleInternal(e,0,r)},t.prototype.SUBRULE1=function(e,r){return this.subruleInternal(e,1,r)},t.prototype.SUBRULE2=function(e,r){return this.subruleInternal(e,2,r)},t.prototype.SUBRULE3=function(e,r){return this.subruleInternal(e,3,r)},t.prototype.SUBRULE4=function(e,r){return this.subruleInternal(e,4,r)},t.prototype.SUBRULE5=function(e,r){return this.subruleInternal(e,5,r)},t.prototype.SUBRULE6=function(e,r){return this.subruleInternal(e,6,r)},t.prototype.SUBRULE7=function(e,r){return this.subruleInternal(e,7,r)},t.prototype.SUBRULE8=function(e,r){return this.subruleInternal(e,8,r)},t.prototype.SUBRULE9=function(e,r){return this.subruleInternal(e,9,r)},t.prototype.OPTION=function(e){return this.optionInternal(e,0)},t.prototype.OPTION1=function(e){return this.optionInternal(e,1)},t.prototype.OPTION2=function(e){return this.optionInternal(e,2)},t.prototype.OPTION3=function(e){return this.optionInternal(e,3)},t.prototype.OPTION4=function(e){return this.optionInternal(e,4)},t.prototype.OPTION5=function(e){return this.optionInternal(e,5)},t.prototype.OPTION6=function(e){return this.optionInternal(e,6)},t.prototype.OPTION7=function(e){return this.optionInternal(e,7)},t.prototype.OPTION8=function(e){return this.optionInternal(e,8)},t.prototype.OPTION9=function(e){return this.optionInternal(e,9)},t.prototype.OR=function(e){return this.orInternal(e,0)},t.prototype.OR1=function(e){return this.orInternal(e,1)},t.prototype.OR2=function(e){return this.orInternal(e,2)},t.prototype.OR3=function(e){return this.orInternal(e,3)},t.prototype.OR4=function(e){return this.orInternal(e,4)},t.prototype.OR5=function(e){return this.orInternal(e,5)},t.prototype.OR6=function(e){return this.orInternal(e,6)},t.prototype.OR7=function(e){return this.orInternal(e,7)},t.prototype.OR8=function(e){return this.orInternal(e,8)},t.prototype.OR9=function(e){return this.orInternal(e,9)},t.prototype.MANY=function(e){this.manyInternal(0,e)},t.prototype.MANY1=function(e){this.manyInternal(1,e)},t.prototype.MANY2=function(e){this.manyInternal(2,e)},t.prototype.MANY3=function(e){this.manyInternal(3,e)},t.prototype.MANY4=function(e){this.manyInternal(4,e)},t.prototype.MANY5=function(e){this.manyInternal(5,e)},t.prototype.MANY6=function(e){this.manyInternal(6,e)},t.prototype.MANY7=function(e){this.manyInternal(7,e)},t.prototype.MANY8=function(e){this.manyInternal(8,e)},t.prototype.MANY9=function(e){this.manyInternal(9,e)},t.prototype.MANY_SEP=function(e){this.manySepFirstInternal(0,e)},t.prototype.MANY_SEP1=function(e){this.manySepFirstInternal(1,e)},t.prototype.MANY_SEP2=function(e){this.manySepFirstInternal(2,e)},t.prototype.MANY_SEP3=function(e){this.manySepFirstInternal(3,e)},t.prototype.MANY_SEP4=function(e){this.manySepFirstInternal(4,e)},t.prototype.MANY_SEP5=function(e){this.manySepFirstInternal(5,e)},t.prototype.MANY_SEP6=function(e){this.manySepFirstInternal(6,e)},t.prototype.MANY_SEP7=function(e){this.manySepFirstInternal(7,e)},t.prototype.MANY_SEP8=function(e){this.manySepFirstInternal(8,e)},t.prototype.MANY_SEP9=function(e){this.manySepFirstInternal(9,e)},t.prototype.AT_LEAST_ONE=function(e){this.atLeastOneInternal(0,e)},t.prototype.AT_LEAST_ONE1=function(e){return this.atLeastOneInternal(1,e)},t.prototype.AT_LEAST_ONE2=function(e){this.atLeastOneInternal(2,e)},t.prototype.AT_LEAST_ONE3=function(e){this.atLeastOneInternal(3,e)},t.prototype.AT_LEAST_ONE4=function(e){this.atLeastOneInternal(4,e)},t.prototype.AT_LEAST_ONE5=function(e){this.atLeastOneInternal(5,e)},t.prototype.AT_LEAST_ONE6=function(e){this.atLeastOneInternal(6,e)},t.prototype.AT_LEAST_ONE7=function(e){this.atLeastOneInternal(7,e)},t.prototype.AT_LEAST_ONE8=function(e){this.atLeastOneInternal(8,e)},t.prototype.AT_LEAST_ONE9=function(e){this.atLeastOneInternal(9,e)},t.prototype.AT_LEAST_ONE_SEP=function(e){this.atLeastOneSepFirstInternal(0,e)},t.prototype.AT_LEAST_ONE_SEP1=function(e){this.atLeastOneSepFirstInternal(1,e)},t.prototype.AT_LEAST_ONE_SEP2=function(e){this.atLeastOneSepFirstInternal(2,e)},t.prototype.AT_LEAST_ONE_SEP3=function(e){this.atLeastOneSepFirstInternal(3,e)},t.prototype.AT_LEAST_ONE_SEP4=function(e){this.atLeastOneSepFirstInternal(4,e)},t.prototype.AT_LEAST_ONE_SEP5=function(e){this.atLeastOneSepFirstInternal(5,e)},t.prototype.AT_LEAST_ONE_SEP6=function(e){this.atLeastOneSepFirstInternal(6,e)},t.prototype.AT_LEAST_ONE_SEP7=function(e){this.atLeastOneSepFirstInternal(7,e)},t.prototype.AT_LEAST_ONE_SEP8=function(e){this.atLeastOneSepFirstInternal(8,e)},t.prototype.AT_LEAST_ONE_SEP9=function(e){this.atLeastOneSepFirstInternal(9,e)},t.prototype.RULE=function(e,r,n){if(n===void 0&&(n=us.DEFAULT_RULE_CONFIG),El.contains(this.definedRulesNames,e)){var o=pm.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),s={message:o,type:us.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(s)}this.definedRulesNames.push(e);var c=this.defineRule(e,r,n);return this[e]=c,c},t.prototype.OVERRIDE_RULE=function(e,r,n){n===void 0&&(n=us.DEFAULT_RULE_CONFIG);var o=[];o=o.concat(dm.validateRuleIsOverridden(e,this.definedRulesNames,this.className)),this.definitionErrors.push.apply(this.definitionErrors,o);var s=this.defineRule(e,r,n);return this[e]=s,s},t.prototype.BACKTRACK=function(e,r){return function(){this.isBackTrackingStack.push(1);var n=this.saveRecogState();try{return e.apply(this,r),!0}catch(o){if(hm.isRecognitionException(o))return!1;throw o}finally{this.reloadRecogState(n),this.isBackTrackingStack.pop()}}},t.prototype.getGAstProductions=function(){return this.gastProductionsCache},t.prototype.getSerializedGastProductions=function(){return mm.serializeGrammar(El.values(this.gastProductionsCache))},t})();Do.RecognizerApi=gm});var Tl=D(Vo=>{"use strict";Object.defineProperty(Vo,"__esModule",{value:!0});Vo.RecognizerEngine=void 0;var be=se(),Ct=Po(),Wo=fn(),Rl=Ln(),pn=xn(),Nl=Mt(),vm=is(),Al=Cr(),Fn=on(),Em=ss(),ym=(function(){function t(){}return t.prototype.initRecognizerEngine=function(e,r){if(this.className=Em.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Fn.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},be.has(r,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
97
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
98
+ For Further details.`);if(be.isArray(e)){if(be.isEmpty(e))throw Error(`A Token Vocabulary cannot be empty.
99
+ Note that the first argument for the parser constructor
100
+ is no longer a Token vector (since v4.0).`);if(typeof e[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
101
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
102
+ For Further details.`)}if(be.isArray(e))this.tokensMap=be.reduce(e,function(c,u){return c[u.name]=u,c},{});else if(be.has(e,"modes")&&be.every(be.flatten(be.values(e.modes)),Fn.isTokenType)){var n=be.flatten(be.values(e.modes)),o=be.uniq(n);this.tokensMap=be.reduce(o,function(c,u){return c[u.name]=u,c},{})}else if(be.isObject(e))this.tokensMap=be.cloneObj(e);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=Al.EOF;var s=be.every(be.values(e),function(c){return be.isEmpty(c.categoryMatches)});this.tokenMatcher=s?Fn.tokenStructuredMatcherNoCategories:Fn.tokenStructuredMatcher,Fn.augmentTokenTypes(be.values(this.tokensMap))},t.prototype.defineRule=function(e,r,n){if(this.selfAnalysisDone)throw Error("Grammar rule <"+e+`> may not be defined after the 'performSelfAnalysis' method has been called'
103
+ Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var o=be.has(n,"resyncEnabled")?n.resyncEnabled:Nl.DEFAULT_RULE_CONFIG.resyncEnabled,s=be.has(n,"recoveryValueFunc")?n.recoveryValueFunc:Nl.DEFAULT_RULE_CONFIG.recoveryValueFunc,c=this.ruleShortNameIdx<<Ct.BITS_FOR_METHOD_TYPE+Ct.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[c]=e,this.fullRuleNameToShort[e]=c;function u(l){try{if(this.outputCst===!0){r.apply(this,l);var f=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(f),f}else return r.apply(this,l)}catch(p){return this.invokeRuleCatch(p,o,s)}finally{this.ruleFinallyStateUpdate()}}var i;i=function(l,f){return l===void 0&&(l=0),this.ruleInvocationStateUpdate(c,e,l),u.call(this,f)};var a="ruleName";return i[a]=e,i.originalGrammarAction=r,i},t.prototype.invokeRuleCatch=function(e,r,n){var o=this.RULE_STACK.length===1,s=r&&!this.isBackTracking()&&this.recoveryEnabled;if(Wo.isRecognitionException(e)){var c=e;if(s){var u=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(u))if(c.resyncedTokens=this.reSyncTo(u),this.outputCst){var i=this.CST_STACK[this.CST_STACK.length-1];return i.recoveredNode=!0,i}else return n();else{if(this.outputCst){var i=this.CST_STACK[this.CST_STACK.length-1];i.recoveredNode=!0,c.partialCstResult=i}throw c}}else{if(o)return this.moveToTerminatedState(),n();throw c}}else throw e},t.prototype.optionInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.OPTION_IDX,r);return this.optionInternalLogic(e,r,n)},t.prototype.optionInternalLogic=function(e,r,n){var o=this,s=this.getLaFuncFromCache(n),c,u;if(e.DEF!==void 0){if(c=e.DEF,u=e.GATE,u!==void 0){var i=s;s=function(){return u.call(o)&&i.call(o)}}}else c=e;if(s.call(this)===!0)return c.call(this)},t.prototype.atLeastOneInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.AT_LEAST_ONE_IDX,e);return this.atLeastOneInternalLogic(e,r,n)},t.prototype.atLeastOneInternalLogic=function(e,r,n){var o=this,s=this.getLaFuncFromCache(n),c,u;if(r.DEF!==void 0){if(c=r.DEF,u=r.GATE,u!==void 0){var i=s;s=function(){return u.call(o)&&i.call(o)}}}else c=r;if(s.call(this)===!0)for(var a=this.doSingleRepetition(c);s.call(this)===!0&&a===!0;)a=this.doSingleRepetition(c);else throw this.raiseEarlyExitException(e,Rl.PROD_TYPE.REPETITION_MANDATORY,r.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[e,r],s,Ct.AT_LEAST_ONE_IDX,e,pn.NextTerminalAfterAtLeastOneWalker)},t.prototype.atLeastOneSepFirstInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.AT_LEAST_ONE_SEP_IDX,e);this.atLeastOneSepFirstInternalLogic(e,r,n)},t.prototype.atLeastOneSepFirstInternalLogic=function(e,r,n){var o=this,s=r.DEF,c=r.SEP,u=this.getLaFuncFromCache(n);if(u.call(this)===!0){s.call(this);for(var i=function(){return o.tokenMatcher(o.LA(1),c)};this.tokenMatcher(this.LA(1),c)===!0;)this.CONSUME(c),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,c,i,s,pn.NextTerminalAfterAtLeastOneSepWalker],i,Ct.AT_LEAST_ONE_SEP_IDX,e,pn.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(e,Rl.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,r.ERR_MSG)},t.prototype.manyInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.MANY_IDX,e);return this.manyInternalLogic(e,r,n)},t.prototype.manyInternalLogic=function(e,r,n){var o=this,s=this.getLaFuncFromCache(n),c,u;if(r.DEF!==void 0){if(c=r.DEF,u=r.GATE,u!==void 0){var i=s;s=function(){return u.call(o)&&i.call(o)}}}else c=r;for(var a=!0;s.call(this)===!0&&a===!0;)a=this.doSingleRepetition(c);this.attemptInRepetitionRecovery(this.manyInternal,[e,r],s,Ct.MANY_IDX,e,pn.NextTerminalAfterManyWalker,a)},t.prototype.manySepFirstInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.MANY_SEP_IDX,e);this.manySepFirstInternalLogic(e,r,n)},t.prototype.manySepFirstInternalLogic=function(e,r,n){var o=this,s=r.DEF,c=r.SEP,u=this.getLaFuncFromCache(n);if(u.call(this)===!0){s.call(this);for(var i=function(){return o.tokenMatcher(o.LA(1),c)};this.tokenMatcher(this.LA(1),c)===!0;)this.CONSUME(c),s.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,c,i,s,pn.NextTerminalAfterManySepWalker],i,Ct.MANY_SEP_IDX,e,pn.NextTerminalAfterManySepWalker)}},t.prototype.repetitionSepSecondInternal=function(e,r,n,o,s){for(;n();)this.CONSUME(r),o.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[e,r,n,o,s],n,Ct.AT_LEAST_ONE_SEP_IDX,e,s)},t.prototype.doSingleRepetition=function(e){var r=this.getLexerPosition();e.call(this);var n=this.getLexerPosition();return n>r},t.prototype.orInternal=function(e,r){var n=this.getKeyForAutomaticLookahead(Ct.OR_IDX,r),o=be.isArray(e)?e:e.DEF,s=this.getLaFuncFromCache(n),c=s.call(this,o);if(c!==void 0){var u=o[c];return u.ALT.call(this)}this.raiseNoAltException(r,e.ERR_MSG)},t.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var e=this.LA(1),r=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new Wo.NotAllInputParsedException(r,e))}},t.prototype.subruleInternal=function(e,r,n){var o;try{var s=n!==void 0?n.ARGS:void 0;return o=e.call(this,r,s),this.cstPostNonTerminal(o,n!==void 0&&n.LABEL!==void 0?n.LABEL:e.ruleName),o}catch(c){this.subruleInternalError(c,n,e.ruleName)}},t.prototype.subruleInternalError=function(e,r,n){throw Wo.isRecognitionException(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,r!==void 0&&r.LABEL!==void 0?r.LABEL:n),delete e.partialCstResult),e},t.prototype.consumeInternal=function(e,r,n){var o;try{var s=this.LA(1);this.tokenMatcher(s,e)===!0?(this.consumeToken(),o=s):this.consumeInternalError(e,s,n)}catch(c){o=this.consumeInternalRecovery(e,r,c)}return this.cstPostTerminal(n!==void 0&&n.LABEL!==void 0?n.LABEL:e.name,o),o},t.prototype.consumeInternalError=function(e,r,n){var o,s=this.LA(0);throw n!==void 0&&n.ERR_MSG?o=n.ERR_MSG:o=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:r,previous:s,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new Wo.MismatchedTokenException(o,r,s))},t.prototype.consumeInternalRecovery=function(e,r,n){if(this.recoveryEnabled&&n.name==="MismatchedTokenException"&&!this.isBackTracking()){var o=this.getFollowsForInRuleRecovery(e,r);try{return this.tryInRuleRecovery(e,o)}catch(s){throw s.name===vm.IN_RULE_RECOVERY_EXCEPTION?n:s}}else throw n},t.prototype.saveRecogState=function(){var e=this.errors,r=be.cloneArr(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:r,CST_STACK:this.CST_STACK}},t.prototype.reloadRecogState=function(e){this.errors=e.errors,this.importLexerState(e.lexerState),this.RULE_STACK=e.RULE_STACK},t.prototype.ruleInvocationStateUpdate=function(e,r,n){this.RULE_OCCURRENCE_STACK.push(n),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(r,e)},t.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},t.prototype.getCurrRuleFullName=function(){var e=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[e]},t.prototype.shortRuleNameToFullName=function(e){return this.shortRuleNameToFull[e]},t.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),Al.EOF)},t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t})();Vo.RecognizerEngine=ym});var Il=D(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.ErrorHandler=void 0;var cs=fn(),ls=se(),Ol=Ln(),Rm=Mt(),Nm=(function(){function t(){}return t.prototype.initErrorHandler=function(e){this._errors=[],this.errorMessageProvider=ls.has(e,"errorMessageProvider")?e.errorMessageProvider:Rm.DEFAULT_PARSER_CONFIG.errorMessageProvider},t.prototype.SAVE_ERROR=function(e){if(cs.isRecognitionException(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:ls.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(e),e;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(t.prototype,"errors",{get:function(){return ls.cloneArr(this._errors)},set:function(e){this._errors=e},enumerable:!1,configurable:!0}),t.prototype.raiseEarlyExitException=function(e,r,n){for(var o=this.getCurrRuleFullName(),s=this.getGAstProductions()[o],c=Ol.getLookaheadPathsForOptionalProd(e,s,r,this.maxLookahead),u=c[0],i=[],a=1;a<=this.maxLookahead;a++)i.push(this.LA(a));var l=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:u,actual:i,previous:this.LA(0),customUserDescription:n,ruleName:o});throw this.SAVE_ERROR(new cs.EarlyExitException(l,this.LA(1),this.LA(0)))},t.prototype.raiseNoAltException=function(e,r){for(var n=this.getCurrRuleFullName(),o=this.getGAstProductions()[n],s=Ol.getLookaheadPathsForOr(e,o,this.maxLookahead),c=[],u=1;u<=this.maxLookahead;u++)c.push(this.LA(u));var i=this.LA(0),a=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:s,actual:c,previous:i,customUserDescription:r,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new cs.NoViableAltException(a,this.LA(1),i))},t})();Go.ErrorHandler=Nm});var wl=D(qo=>{"use strict";Object.defineProperty(qo,"__esModule",{value:!0});qo.ContentAssist=void 0;var Ml=xn(),Cl=se(),Am=(function(){function t(){}return t.prototype.initContentAssist=function(){},t.prototype.computeContentAssist=function(e,r){var n=this.gastProductionsCache[e];if(Cl.isUndefined(n))throw Error("Rule ->"+e+"<- does not exist in this grammar.");return Ml.nextPossibleTokensAfter([n],r,this.tokenMatcher,this.maxLookahead)},t.prototype.getNextPossibleTokenTypes=function(e){var r=Cl.first(e.ruleStack),n=this.getGAstProductions(),o=n[r],s=new Ml.NextAfterTokenWalker(o,e).startWalking();return s},t})();qo.ContentAssist=Am});var Sl=D(Yo=>{"use strict";Object.defineProperty(Yo,"__esModule",{value:!0});Yo.GastRecorder=void 0;var Ot=se(),or=gt(),Tm=Mn(),xl=on(),Ll=Cr(),Om=Mt(),Im=Po(),zo={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(zo);var _l=!0,kl=Math.pow(2,Im.BITS_FOR_OCCURRENCE_IDX)-1,Ul=Ll.createToken({name:"RECORDING_PHASE_TOKEN",pattern:Tm.Lexer.NA});xl.augmentTokenTypes([Ul]);var Pl=Ll.createTokenInstance(Ul,`This IToken indicates the Parser is in Recording Phase
104
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Pl);var Mm={name:`This CSTNode indicates the Parser is in Recording Phase
105
+ See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},Cm=(function(){function t(){}return t.prototype.initGastRecorder=function(e){this.recordingProdStack=[],this.RECORDING_PHASE=!1},t.prototype.enableRecording=function(){var e=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var r=function(o){var s=o>0?o:"";e["CONSUME"+s]=function(c,u){return this.consumeInternalRecord(c,o,u)},e["SUBRULE"+s]=function(c,u){return this.subruleInternalRecord(c,o,u)},e["OPTION"+s]=function(c){return this.optionInternalRecord(c,o)},e["OR"+s]=function(c){return this.orInternalRecord(c,o)},e["MANY"+s]=function(c){this.manyInternalRecord(o,c)},e["MANY_SEP"+s]=function(c){this.manySepFirstInternalRecord(o,c)},e["AT_LEAST_ONE"+s]=function(c){this.atLeastOneInternalRecord(o,c)},e["AT_LEAST_ONE_SEP"+s]=function(c){this.atLeastOneSepFirstInternalRecord(o,c)}},n=0;n<10;n++)r(n);e.consume=function(o,s,c){return this.consumeInternalRecord(s,o,c)},e.subrule=function(o,s,c){return this.subruleInternalRecord(s,o,c)},e.option=function(o,s){return this.optionInternalRecord(s,o)},e.or=function(o,s){return this.orInternalRecord(s,o)},e.many=function(o,s){this.manyInternalRecord(o,s)},e.atLeastOne=function(o,s){this.atLeastOneInternalRecord(o,s)},e.ACTION=e.ACTION_RECORD,e.BACKTRACK=e.BACKTRACK_RECORD,e.LA=e.LA_RECORD})},t.prototype.disableRecording=function(){var e=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var r=0;r<10;r++){var n=r>0?r:"";delete e["CONSUME"+n],delete e["SUBRULE"+n],delete e["OPTION"+n],delete e["OR"+n],delete e["MANY"+n],delete e["MANY_SEP"+n],delete e["AT_LEAST_ONE"+n],delete e["AT_LEAST_ONE_SEP"+n]}delete e.consume,delete e.subrule,delete e.option,delete e.or,delete e.many,delete e.atLeastOne,delete e.ACTION,delete e.BACKTRACK,delete e.LA})},t.prototype.ACTION_RECORD=function(e){},t.prototype.BACKTRACK_RECORD=function(e,r){return function(){return!0}},t.prototype.LA_RECORD=function(e){return Om.END_OF_FILE},t.prototype.topLevelRuleRecord=function(e,r){try{var n=new or.Rule({definition:[],name:e});return n.name=e,this.recordingProdStack.push(n),r.call(this),this.recordingProdStack.pop(),n}catch(o){if(o.KNOWN_RECORDER_ERROR!==!0)try{o.message=o.message+`
106
+ This error was thrown during the "grammar recording phase" For more info see:
107
+ https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw o}throw o}},t.prototype.optionInternalRecord=function(e,r){return Bn.call(this,or.Option,e,r)},t.prototype.atLeastOneInternalRecord=function(e,r){Bn.call(this,or.RepetitionMandatory,r,e)},t.prototype.atLeastOneSepFirstInternalRecord=function(e,r){Bn.call(this,or.RepetitionMandatoryWithSeparator,r,e,_l)},t.prototype.manyInternalRecord=function(e,r){Bn.call(this,or.Repetition,r,e)},t.prototype.manySepFirstInternalRecord=function(e,r){Bn.call(this,or.RepetitionWithSeparator,r,e,_l)},t.prototype.orInternalRecord=function(e,r){return wm.call(this,e,r)},t.prototype.subruleInternalRecord=function(e,r,n){if(Ho(r),!e||Ot.has(e,"ruleName")===!1){var o=new Error("<SUBRULE"+bl(r)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(e)+">")+(`
108
+ inside top level rule: <`+this.recordingProdStack[0].name+">"));throw o.KNOWN_RECORDER_ERROR=!0,o}var s=Ot.peek(this.recordingProdStack),c=e.ruleName,u=new or.NonTerminal({idx:r,nonTerminalName:c,referencedRule:void 0});return s.definition.push(u),this.outputCst?Mm:zo},t.prototype.consumeInternalRecord=function(e,r,n){if(Ho(r),!xl.hasShortKeyProperty(e)){var o=new Error("<CONSUME"+bl(r)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(e)+">")+(`
109
+ inside top level rule: <`+this.recordingProdStack[0].name+">"));throw o.KNOWN_RECORDER_ERROR=!0,o}var s=Ot.peek(this.recordingProdStack),c=new or.Terminal({idx:r,terminalType:e});return s.definition.push(c),Pl},t})();Yo.GastRecorder=Cm;function Bn(t,e,r,n){n===void 0&&(n=!1),Ho(r);var o=Ot.peek(this.recordingProdStack),s=Ot.isFunction(e)?e:e.DEF,c=new t({definition:[],idx:r});return n&&(c.separator=e.SEP),Ot.has(e,"MAX_LOOKAHEAD")&&(c.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(c),s.call(this),o.definition.push(c),this.recordingProdStack.pop(),zo}function wm(t,e){var r=this;Ho(e);var n=Ot.peek(this.recordingProdStack),o=Ot.isArray(t)===!1,s=o===!1?t:t.DEF,c=new or.Alternation({definition:[],idx:e,ignoreAmbiguities:o&&t.IGNORE_AMBIGUITIES===!0});Ot.has(t,"MAX_LOOKAHEAD")&&(c.maxLookahead=t.MAX_LOOKAHEAD);var u=Ot.some(s,function(i){return Ot.isFunction(i.GATE)});return c.hasPredicates=u,n.definition.push(c),Ot.forEach(s,function(i){var a=new or.Alternative({definition:[]});c.definition.push(a),Ot.has(i,"IGNORE_AMBIGUITIES")?a.ignoreAmbiguities=i.IGNORE_AMBIGUITIES:Ot.has(i,"GATE")&&(a.ignoreAmbiguities=!0),r.recordingProdStack.push(a),i.ALT.call(r),r.recordingProdStack.pop()}),zo}function bl(t){return t===0?"":""+t}function Ho(t){if(t<0||t>kl){var e=new Error("Invalid DSL Method idx value: <"+t+`>
110
+ `+("Idx value must be a none negative value smaller than "+(kl+1)));throw e.KNOWN_RECORDER_ERROR=!0,e}}});var Bl=D($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:!0});$o.PerformanceTracer=void 0;var Fl=se(),_m=Mt(),km=(function(){function t(){}return t.prototype.initPerformanceTracer=function(e){if(Fl.has(e,"traceInitPerf")){var r=e.traceInitPerf,n=typeof r=="number";this.traceInitMaxIdent=n?r:1/0,this.traceInitPerf=n?r>0:r}else this.traceInitMaxIdent=0,this.traceInitPerf=_m.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},t.prototype.TRACE_INIT=function(e,r){if(this.traceInitPerf===!0){this.traceInitIndent++;var n=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent<this.traceInitMaxIdent&&console.log(n+"--> <"+e+">");var o=Fl.timer(r),s=o.time,c=o.value,u=s>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&u(n+"<-- <"+e+"> time: "+s+"ms"),this.traceInitIndent--,c}else return r()},t})();$o.PerformanceTracer=km});var Mt=D(Ie=>{"use strict";var Vl=Ie&&Ie.__extends||(function(){var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},t(e,r)};return function(e,r){t(e,r);function n(){this.constructor=e}e.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}})();Object.defineProperty(Ie,"__esModule",{value:!0});Ie.EmbeddedActionsParser=Ie.CstParser=Ie.Parser=Ie.EMPTY_ALT=Ie.ParserDefinitionErrorType=Ie.DEFAULT_RULE_CONFIG=Ie.DEFAULT_PARSER_CONFIG=Ie.END_OF_FILE=void 0;var ft=se(),bm=Mc(),Dl=Cr(),Gl=kn(),Wl=ns(),xm=is(),Lm=il(),Um=ml(),Pm=vl(),Sm=yl(),Fm=Tl(),Bm=Il(),Dm=wl(),Wm=Sl(),Vm=Bl();Ie.END_OF_FILE=Dl.createTokenInstance(Dl.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Ie.END_OF_FILE);Ie.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Gl.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1});Ie.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var Gm;(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"})(Gm=Ie.ParserDefinitionErrorType||(Ie.ParserDefinitionErrorType={}));function qm(t){return t===void 0&&(t=void 0),function(){return t}}Ie.EMPTY_ALT=qm;var Ko=(function(){function t(e,r){this.definitionErrors=[],this.selfAnalysisDone=!1;var n=this;if(n.initErrorHandler(r),n.initLexerAdapter(),n.initLooksAhead(r),n.initRecognizerEngine(e,r),n.initRecoverable(r),n.initTreeBuilder(r),n.initContentAssist(),n.initGastRecorder(r),n.initPerformanceTracer(r),ft.has(r,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
111
+ Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
112
+ See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
113
+ For further details.`);this.skipValidations=ft.has(r,"skipValidations")?r.skipValidations:Ie.DEFAULT_PARSER_CONFIG.skipValidations}return t.performSelfAnalysis=function(e){throw Error("The **static** `performSelfAnalysis` method has been deprecated. \nUse the **instance** method with the same name instead.")},t.prototype.performSelfAnalysis=function(){var e=this;this.TRACE_INIT("performSelfAnalysis",function(){var r;e.selfAnalysisDone=!0;var n=e.className;e.TRACE_INIT("toFastProps",function(){ft.toFastProperties(e)}),e.TRACE_INIT("Grammar Recording",function(){try{e.enableRecording(),ft.forEach(e.definedRulesNames,function(s){var c=e[s],u=c.originalGrammarAction,i=void 0;e.TRACE_INIT(s+" Rule",function(){i=e.topLevelRuleRecord(s,u)}),e.gastProductionsCache[s]=i})}finally{e.disableRecording()}});var o=[];if(e.TRACE_INIT("Grammar Resolving",function(){o=Wl.resolveGrammar({rules:ft.values(e.gastProductionsCache)}),e.definitionErrors.push.apply(e.definitionErrors,o)}),e.TRACE_INIT("Grammar Validations",function(){if(ft.isEmpty(o)&&e.skipValidations===!1){var s=Wl.validateGrammar({rules:ft.values(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:ft.values(e.tokensMap),errMsgProvider:Gl.defaultGrammarValidatorErrorProvider,grammarName:n});e.definitionErrors.push.apply(e.definitionErrors,s)}}),ft.isEmpty(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",function(){var s=bm.computeAllProdsFollows(ft.values(e.gastProductionsCache));e.resyncFollows=s}),e.TRACE_INIT("ComputeLookaheadFunctions",function(){e.preComputeLookaheadFunctions(ft.values(e.gastProductionsCache))})),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!ft.isEmpty(e.definitionErrors))throw r=ft.map(e.definitionErrors,function(s){return s.message}),new Error(`Parser Definition Errors detected:
114
+ `+r.join(`
115
+ -------------------------------
116
+ `))})},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t})();Ie.Parser=Ko;ft.applyMixins(Ko,[xm.Recoverable,Lm.LooksAhead,Um.TreeBuilder,Pm.LexerAdapter,Fm.RecognizerEngine,Sm.RecognizerApi,Bm.ErrorHandler,Dm.ContentAssist,Wm.GastRecorder,Vm.PerformanceTracer]);var Hm=(function(t){Vl(e,t);function e(r,n){n===void 0&&(n=Ie.DEFAULT_PARSER_CONFIG);var o=this,s=ft.cloneObj(n);return s.outputCst=!0,o=t.call(this,r,s)||this,o}return e})(Ko);Ie.CstParser=Hm;var zm=(function(t){Vl(e,t);function e(r,n){n===void 0&&(n=Ie.DEFAULT_PARSER_CONFIG);var o=this,s=ft.cloneObj(n);return s.outputCst=!1,o=t.call(this,r,s)||this,o}return e})(Ko);Ie.EmbeddedActionsParser=zm});var Hl=D(Xo=>{"use strict";Object.defineProperty(Xo,"__esModule",{value:!0});Xo.createSyntaxDiagramsCode=void 0;var ql=ki();function Ym(t,e){var r=e===void 0?{}:e,n=r.resourceBase,o=n===void 0?"https://unpkg.com/chevrotain@"+ql.VERSION+"/diagrams/":n,s=r.css,c=s===void 0?"https://unpkg.com/chevrotain@"+ql.VERSION+"/diagrams/diagrams.css":s,u=`
117
+ <!-- This is a generated file -->
118
+ <!DOCTYPE html>
119
+ <meta charset="utf-8">
120
+ <style>
121
+ body {
122
+ background-color: hsl(30, 20%, 95%)
123
+ }
124
+ </style>
125
+
126
+ `,i=`
127
+ <link rel='stylesheet' href='`+c+`'>
128
+ `,a=`
129
+ <script src='`+o+`vendor/railroad-diagrams.js'><\/script>
130
+ <script src='`+o+`src/diagrams_builder.js'><\/script>
131
+ <script src='`+o+`src/diagrams_behavior.js'><\/script>
132
+ <script src='`+o+`src/main.js'><\/script>
133
+ `,l=`
134
+ <div id="diagrams" align="center"></div>
135
+ `,f=`
136
+ <script>
137
+ window.serializedGrammar = `+JSON.stringify(t,null," ")+`;
138
+ <\/script>
139
+ `,p=`
140
+ <script>
141
+ var diagramsDiv = document.getElementById("diagrams");
142
+ main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
143
+ <\/script>
144
+ `;return u+i+a+l+f+p}Xo.createSyntaxDiagramsCode=Ym});var Jl=D(Ye=>{"use strict";Object.defineProperty(Ye,"__esModule",{value:!0});Ye.genSingleAlt=Ye.genAlternation=Ye.genNonTerminal=Ye.genTerminal=Ye.genRule=Ye.genAllRules=Ye.genClass=Ye.genWrapperFunction=Ye.genUmdModule=void 0;var fs=se(),yr=gt(),je=`
145
+ `;function $m(t){return`
146
+ (function (root, factory) {
147
+ if (typeof define === 'function' && define.amd) {
148
+ // AMD. Register as an anonymous module.
149
+ define(['chevrotain'], factory);
150
+ } else if (typeof module === 'object' && module.exports) {
151
+ // Node. Does not work with strict CommonJS, but
152
+ // only CommonJS-like environments that support module.exports,
153
+ // like Node.
154
+ module.exports = factory(require('chevrotain'));
155
+ } else {
156
+ // Browser globals (root is window)
157
+ root.returnExports = factory(root.b);
158
+ }
159
+ }(typeof self !== 'undefined' ? self : this, function (chevrotain) {
160
+
161
+ `+hs(t)+`
162
+
163
+ return {
164
+ `+t.name+": "+t.name+`
165
+ }
166
+ }));
167
+ `}Ye.genUmdModule=$m;function Km(t){return`
168
+ `+hs(t)+`
169
+ return new `+t.name+`(tokenVocabulary, config)
170
+ `}Ye.genWrapperFunction=Km;function hs(t){var e=`
171
+ function `+t.name+`(tokenVocabulary, config) {
172
+ // invoke super constructor
173
+ // No support for embedded actions currently, so we can 'hardcode'
174
+ // The use of CstParser.
175
+ chevrotain.CstParser.call(this, tokenVocabulary, config)
176
+
177
+ const $ = this
178
+
179
+ `+Yl(t.rules)+`
180
+
181
+ // very important to call this after all the rules have been defined.
182
+ // otherwise the parser may not work correctly as it will lack information
183
+ // derived during the self analysis phase.
184
+ this.performSelfAnalysis(this)
185
+ }
186
+
187
+ // inheritance as implemented in javascript in the previous decade... :(
188
+ `+t.name+`.prototype = Object.create(chevrotain.CstParser.prototype)
189
+ `+t.name+".prototype.constructor = "+t.name+`
190
+ `;return e}Ye.genClass=hs;function Yl(t){var e=fs.map(t,function(r){return $l(r,1)});return e.join(`
191
+ `)}Ye.genAllRules=Yl;function $l(t,e){var r=vt(e,'$.RULE("'+t.name+'", function() {')+je;return r+=Qo(t.definition,e+1),r+=vt(e+1,"})")+je,r}Ye.genRule=$l;function Kl(t,e){var r=t.terminalType.name;return vt(e,"$.CONSUME"+t.idx+"(this.tokensMap."+r+")"+je)}Ye.genTerminal=Kl;function Xl(t,e){return vt(e,"$.SUBRULE"+t.idx+"($."+t.nonTerminalName+")"+je)}Ye.genNonTerminal=Xl;function Ql(t,e){var r=vt(e,"$.OR"+t.idx+"([")+je,n=fs.map(t.definition,function(o){return Zl(o,e+1)});return r+=n.join(","+je),r+=je+vt(e,"])"+je),r}Ye.genAlternation=Ql;function Zl(t,e){var r=vt(e,"{")+je;return r+=vt(e+1,"ALT: function() {")+je,r+=Qo(t.definition,e+1),r+=vt(e+1,"}")+je,r+=vt(e,"}"),r}Ye.genSingleAlt=Zl;function Xm(t,e){if(t instanceof yr.NonTerminal)return Xl(t,e);if(t instanceof yr.Option)return Dn("OPTION",t,e);if(t instanceof yr.RepetitionMandatory)return Dn("AT_LEAST_ONE",t,e);if(t instanceof yr.RepetitionMandatoryWithSeparator)return Dn("AT_LEAST_ONE_SEP",t,e);if(t instanceof yr.RepetitionWithSeparator)return Dn("MANY_SEP",t,e);if(t instanceof yr.Repetition)return Dn("MANY",t,e);if(t instanceof yr.Alternation)return Ql(t,e);if(t instanceof yr.Terminal)return Kl(t,e);if(t instanceof yr.Alternative)return Qo(t.definition,e);throw Error("non exhaustive match")}function Dn(t,e,r){var n=vt(r,"$."+(t+e.idx)+"(");return e.separator?(n+="{"+je,n+=vt(r+1,"SEP: this.tokensMap."+e.separator.name)+","+je,n+="DEF: "+zl(e.definition,r+2)+je,n+=vt(r,"}")+je):n+=zl(e.definition,r+1),n+=vt(r,")")+je,n}function zl(t,e){var r="function() {"+je;return r+=Qo(t,e),r+=vt(e,"}")+je,r}function Qo(t,e){var r="";return fs.forEach(t,function(n){r+=Xm(n,e+1)}),r}function vt(t,e){var r=Array(t*4+1).join(" ");return r+e}});var ef=D(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});dn.generateParserModule=dn.generateParserFactory=void 0;var jl=Jl();function Qm(t){var e=jl.genWrapperFunction({name:t.name,rules:t.rules}),r=new Function("tokenVocabulary","config","chevrotain",e);return function(n){return r(t.tokenVocabulary,n,Wn())}}dn.generateParserFactory=Qm;function Zm(t){return jl.genUmdModule({name:t.name,rules:t.rules})}dn.generateParserModule=Zm});var Wn=D(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.Parser=L.generateParserModule=L.generateParserFactory=L.createSyntaxDiagramsCode=L.clearCache=L.validateGrammar=L.resolveGrammar=L.assignOccurrenceIndices=L.GAstVisitor=L.serializeProduction=L.serializeGrammar=L.Terminal=L.Rule=L.RepetitionWithSeparator=L.RepetitionMandatoryWithSeparator=L.RepetitionMandatory=L.Repetition=L.Option=L.NonTerminal=L.Alternative=L.Alternation=L.defaultLexerErrorProvider=L.NoViableAltException=L.NotAllInputParsedException=L.MismatchedTokenException=L.isRecognitionException=L.EarlyExitException=L.defaultParserErrorProvider=L.defaultGrammarValidatorErrorProvider=L.defaultGrammarResolverErrorProvider=L.tokenName=L.tokenMatcher=L.tokenLabel=L.EOF=L.createTokenInstance=L.createToken=L.LexerDefinitionErrorType=L.Lexer=L.EMPTY_ALT=L.ParserDefinitionErrorType=L.EmbeddedActionsParser=L.CstParser=L.VERSION=void 0;var Jm=ki();Object.defineProperty(L,"VERSION",{enumerable:!0,get:function(){return Jm.VERSION}});var Zo=Mt();Object.defineProperty(L,"CstParser",{enumerable:!0,get:function(){return Zo.CstParser}});Object.defineProperty(L,"EmbeddedActionsParser",{enumerable:!0,get:function(){return Zo.EmbeddedActionsParser}});Object.defineProperty(L,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return Zo.ParserDefinitionErrorType}});Object.defineProperty(L,"EMPTY_ALT",{enumerable:!0,get:function(){return Zo.EMPTY_ALT}});var tf=Mn();Object.defineProperty(L,"Lexer",{enumerable:!0,get:function(){return tf.Lexer}});Object.defineProperty(L,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return tf.LexerDefinitionErrorType}});var mn=Cr();Object.defineProperty(L,"createToken",{enumerable:!0,get:function(){return mn.createToken}});Object.defineProperty(L,"createTokenInstance",{enumerable:!0,get:function(){return mn.createTokenInstance}});Object.defineProperty(L,"EOF",{enumerable:!0,get:function(){return mn.EOF}});Object.defineProperty(L,"tokenLabel",{enumerable:!0,get:function(){return mn.tokenLabel}});Object.defineProperty(L,"tokenMatcher",{enumerable:!0,get:function(){return mn.tokenMatcher}});Object.defineProperty(L,"tokenName",{enumerable:!0,get:function(){return mn.tokenName}});var ps=kn();Object.defineProperty(L,"defaultGrammarResolverErrorProvider",{enumerable:!0,get:function(){return ps.defaultGrammarResolverErrorProvider}});Object.defineProperty(L,"defaultGrammarValidatorErrorProvider",{enumerable:!0,get:function(){return ps.defaultGrammarValidatorErrorProvider}});Object.defineProperty(L,"defaultParserErrorProvider",{enumerable:!0,get:function(){return ps.defaultParserErrorProvider}});var Vn=fn();Object.defineProperty(L,"EarlyExitException",{enumerable:!0,get:function(){return Vn.EarlyExitException}});Object.defineProperty(L,"isRecognitionException",{enumerable:!0,get:function(){return Vn.isRecognitionException}});Object.defineProperty(L,"MismatchedTokenException",{enumerable:!0,get:function(){return Vn.MismatchedTokenException}});Object.defineProperty(L,"NotAllInputParsedException",{enumerable:!0,get:function(){return Vn.NotAllInputParsedException}});Object.defineProperty(L,"NoViableAltException",{enumerable:!0,get:function(){return Vn.NoViableAltException}});var jm=Wi();Object.defineProperty(L,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return jm.defaultLexerErrorProvider}});var ir=gt();Object.defineProperty(L,"Alternation",{enumerable:!0,get:function(){return ir.Alternation}});Object.defineProperty(L,"Alternative",{enumerable:!0,get:function(){return ir.Alternative}});Object.defineProperty(L,"NonTerminal",{enumerable:!0,get:function(){return ir.NonTerminal}});Object.defineProperty(L,"Option",{enumerable:!0,get:function(){return ir.Option}});Object.defineProperty(L,"Repetition",{enumerable:!0,get:function(){return ir.Repetition}});Object.defineProperty(L,"RepetitionMandatory",{enumerable:!0,get:function(){return ir.RepetitionMandatory}});Object.defineProperty(L,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return ir.RepetitionMandatoryWithSeparator}});Object.defineProperty(L,"RepetitionWithSeparator",{enumerable:!0,get:function(){return ir.RepetitionWithSeparator}});Object.defineProperty(L,"Rule",{enumerable:!0,get:function(){return ir.Rule}});Object.defineProperty(L,"Terminal",{enumerable:!0,get:function(){return ir.Terminal}});var rf=gt();Object.defineProperty(L,"serializeGrammar",{enumerable:!0,get:function(){return rf.serializeGrammar}});Object.defineProperty(L,"serializeProduction",{enumerable:!0,get:function(){return rf.serializeProduction}});var e1=sn();Object.defineProperty(L,"GAstVisitor",{enumerable:!0,get:function(){return e1.GAstVisitor}});var ds=ns();Object.defineProperty(L,"assignOccurrenceIndices",{enumerable:!0,get:function(){return ds.assignOccurrenceIndices}});Object.defineProperty(L,"resolveGrammar",{enumerable:!0,get:function(){return ds.resolveGrammar}});Object.defineProperty(L,"validateGrammar",{enumerable:!0,get:function(){return ds.validateGrammar}});function t1(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
192
+ It performs no action other than printing this message.
193
+ Please avoid using it as it will be completely removed in the future`)}L.clearCache=t1;var r1=Hl();Object.defineProperty(L,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return r1.createSyntaxDiagramsCode}});var nf=ef();Object.defineProperty(L,"generateParserFactory",{enumerable:!0,get:function(){return nf.generateParserFactory}});Object.defineProperty(L,"generateParserModule",{enumerable:!0,get:function(){return nf.generateParserModule}});var n1=(function(){function t(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
194
+ See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return t})();L.Parser=n1});var Jo=D((dE,cf)=>{var{createToken:re,Lexer:sf}=Wn(),o1=qe(),af={},i1=re({name:"WhiteSpace",pattern:/\s+/,group:sf.SKIPPED}),s1=re({name:"String",pattern:/"(""|[^"])*"/}),a1=re({name:"SingleQuotedString",pattern:/'(''|[^'])*'/}),u1=re({name:"SheetQuoted",pattern:/'((?![\\\/\[\]*?:]).)+?'!/}),c1=re({name:"Function",pattern:/[A-Za-z_]+[A-Za-z_0-9.]*\(/}),l1=re({name:"FormulaErrorT",pattern:/#NULL!|#DIV\/0!|#VALUE!|#NAME\?|#NUM!|#N\/A/}),f1=re({name:"RefError",pattern:/#REF!/}),ms=re({name:"Name",pattern:/[a-zA-Z_][a-zA-Z0-9_.?]*/}),h1=re({name:"Sheet",pattern:/[A-Za-z_.\d\u007F-\uFFFF]+!/}),p1=re({name:"Cell",pattern:/[$]?[A-Za-z]{1,3}[$]?[1-9][0-9]*/,longer_alt:ms}),d1=re({name:"Number",pattern:/[0-9]+[.]?[0-9]*([eE][+\-][0-9]+)?/}),m1=re({name:"Boolean",pattern:/TRUE|FALSE/i}),g1=re({name:"Column",pattern:/[$]?[A-Za-z]{1,3}/,longer_alt:ms}),v1=re({name:"At",pattern:/@/}),E1=re({name:"Comma",pattern:/,/}),y1=re({name:"Colon",pattern:/:/}),R1=re({name:"Semicolon",pattern:/;/}),N1=re({name:"OpenParen",pattern:/\(/}),A1=re({name:"CloseParen",pattern:/\)/}),T1=re({name:"OpenSquareParen",pattern:/\[/}),O1=re({name:"CloseSquareParen",pattern:/]/}),pE=re({name:"exclamationMark",pattern:/!/}),I1=re({name:"OpenCurlyParen",pattern:/{/}),M1=re({name:"CloseCurlyParen",pattern:/}/}),C1=re({name:"QuoteS",pattern:/'/}),of=re({name:"MulOp",pattern:/\*/}),w1=re({name:"PlusOp",pattern:/\+/}),_1=re({name:"DivOp",pattern:/\//}),k1=re({name:"MinOp",pattern:/-/}),b1=re({name:"ConcatOp",pattern:/&/}),x1=re({name:"ExOp",pattern:/\^/}),L1=re({name:"PercentOp",pattern:/%/}),U1=re({name:"GtOp",pattern:/>/}),P1=re({name:"EqOp",pattern:/=/}),S1=re({name:"LtOp",pattern:/</}),F1=re({name:"NeqOp",pattern:/<>/}),B1=re({name:"GteOp",pattern:/>=/}),D1=re({name:"LteOp",pattern:/<=/}),uf=[i1,s1,u1,a1,c1,l1,f1,h1,p1,m1,g1,ms,d1,v1,E1,y1,R1,N1,A1,T1,O1,I1,M1,C1,of,w1,_1,k1,b1,x1,of,L1,F1,B1,D1,U1,P1,S1],W1=new sf(uf,{ensureOptimizations:!0});uf.forEach(t=>{af[t.name]=t});cf.exports={tokenVocabulary:af,lex:function(t){let e=W1.tokenize(t);if(e.errors.length>0){let r=e.errors[0],n=r.line,o=r.column,s=`
195
+ `+t.split(`
196
+ `)[n-1]+`
197
+ `;throw s+=Array(o-1).fill(" ").join("")+`^
198
+ `,r.message=s+`Error at position ${n}:${o}
199
+ `+r.message,r.errorLocation={line:n,column:o},o1.ERROR(r.message,r)}return e}}});var ys=D((vE,vf)=>{var gf=Jo(),{EmbeddedActionsParser:V1}=Wn(),G1=gf.tokenVocabulary,{String:lf,SheetQuoted:q1,ExcelRefFunction:mE,ExcelConditionalRefFunction:gE,Function:H1,FormulaErrorT:ff,RefError:hf,Cell:z1,Sheet:Y1,Name:$1,Number:pf,Boolean:df,Column:K1,Comma:jo,Colon:X1,Semicolon:Q1,OpenParen:Z1,CloseParen:mf,OpenCurlyParen:J1,CloseCurlyParen:j1,MulOp:eg,PlusOp:gs,DivOp:tg,MinOp:vs,ConcatOp:rg,ExOp:ng,PercentOp:og,NeqOp:ig,GteOp:sg,LteOp:ag,GtOp:ug,EqOp:cg,LtOp:lg}=gf.tokenVocabulary,Es=class extends V1{constructor(e,r){super(G1,{outputCst:!1,maxLookahead:1,skipValidations:!0}),this.utils=r,this.binaryOperatorsPrecedence=[["^"],["*","/"],["+","-"],["&"],["<",">","=","<>","<=",">="]];let n=this;n.RULE("formulaWithBinaryOp",()=>{let o=[],s=[n.SUBRULE(n.formulaWithPercentOp)];return n.MANY(()=>{o.push(n.OR(n.c1||(n.c1=[{ALT:()=>n.CONSUME(ug).image},{ALT:()=>n.CONSUME(cg).image},{ALT:()=>n.CONSUME(lg).image},{ALT:()=>n.CONSUME(ig).image},{ALT:()=>n.CONSUME(sg).image},{ALT:()=>n.CONSUME(ag).image},{ALT:()=>n.CONSUME(rg).image},{ALT:()=>n.CONSUME(gs).image},{ALT:()=>n.CONSUME(vs).image},{ALT:()=>n.CONSUME(eg).image},{ALT:()=>n.CONSUME(tg).image},{ALT:()=>n.CONSUME(ng).image}]))),s.push(n.SUBRULE2(n.formulaWithPercentOp))}),n.ACTION(()=>{for(let c of this.binaryOperatorsPrecedence)for(let u=0,i=o.length;u<i;u++){let a=o[u];c.includes(a)&&(o.splice(u,1),s.splice(u,2,this.utils.applyInfix(s[u],a,s[u+1])),u--,i--)}}),s[0]}),n.RULE("plusMinusOp",()=>n.OR([{ALT:()=>n.CONSUME(gs).image},{ALT:()=>n.CONSUME(vs).image}])),n.RULE("formulaWithPercentOp",()=>{let o=n.SUBRULE(n.formulaWithUnaryOp);return n.OPTION(()=>{let s=n.CONSUME(og).image;o=n.ACTION(()=>this.utils.applyPostfix(o,s))}),o}),n.RULE("formulaWithUnaryOp",()=>{let o=[];n.MANY(()=>{let c=n.OR([{ALT:()=>n.CONSUME(gs).image},{ALT:()=>n.CONSUME(vs).image}]);o.push(c)});let s=n.SUBRULE(n.formulaWithIntersect);return o.length>0?n.ACTION(()=>this.utils.applyPrefix(o,s)):s}),n.RULE("formulaWithIntersect",()=>{let o=n.SUBRULE(n.formulaWithRange),s=[o];return n.MANY({GATE:()=>{let c=n.LA(0);return n.LA(1).startOffset>c.endOffset+1},DEF:()=>{s.push(n.SUBRULE3(n.formulaWithRange))}}),s.length>1?n.ACTION(()=>n.ACTION(()=>this.utils.applyIntersect(s))):o}),n.RULE("formulaWithRange",()=>{let o=n.SUBRULE(n.formula),s=[o];return n.MANY(()=>{n.CONSUME(X1),s.push(n.SUBRULE2(n.formula))}),s.length>1?n.ACTION(()=>n.ACTION(()=>this.utils.applyRange(s))):o}),n.RULE("formula",()=>n.OR9([{ALT:()=>n.SUBRULE(n.referenceWithoutInfix)},{ALT:()=>n.SUBRULE(n.paren)},{ALT:()=>n.SUBRULE(n.constant)},{ALT:()=>n.SUBRULE(n.functionCall)},{ALT:()=>n.SUBRULE(n.constantArray)}])),n.RULE("paren",()=>{n.CONSUME(Z1);let o,s=[];return s.push(n.SUBRULE(n.formulaWithBinaryOp)),n.MANY(()=>{n.CONSUME(jo),s.push(n.SUBRULE2(n.formulaWithBinaryOp))}),s.length>1?o=n.ACTION(()=>this.utils.applyUnion(s)):o=s[0],n.CONSUME(mf),o}),n.RULE("constantArray",()=>{let o=[[]],s=0;return n.CONSUME(J1),o[s].push(n.SUBRULE(n.constantForArray)),n.MANY(()=>{let c=n.OR([{ALT:()=>n.CONSUME(jo).image},{ALT:()=>n.CONSUME(Q1).image}]),u=n.SUBRULE2(n.constantForArray);c===","||(s++,o[s]=[]),o[s].push(u)}),n.CONSUME(j1),n.ACTION(()=>this.utils.toArray(o))}),n.RULE("constantForArray",()=>n.OR([{ALT:()=>{let o=n.OPTION(()=>n.SUBRULE(n.plusMinusOp)),s=n.CONSUME(pf).image,c=n.ACTION(()=>this.utils.toNumber(s));return o?n.ACTION(()=>this.utils.applyPrefix([o],c)):c}},{ALT:()=>{let o=n.CONSUME(lf).image;return n.ACTION(()=>this.utils.toString(o))}},{ALT:()=>{let o=n.CONSUME(df).image;return n.ACTION(()=>this.utils.toBoolean(o))}},{ALT:()=>{let o=n.CONSUME(ff).image;return n.ACTION(()=>this.utils.toError(o))}},{ALT:()=>{let o=n.CONSUME(hf).image;return n.ACTION(()=>this.utils.toError(o))}}])),n.RULE("constant",()=>n.OR([{ALT:()=>{let o=n.CONSUME(pf).image;return n.ACTION(()=>this.utils.toNumber(o))}},{ALT:()=>{let o=n.CONSUME(lf).image;return n.ACTION(()=>this.utils.toString(o))}},{ALT:()=>{let o=n.CONSUME(df).image;return n.ACTION(()=>this.utils.toBoolean(o))}},{ALT:()=>{let o=n.CONSUME(ff).image;return n.ACTION(()=>this.utils.toError(o))}}])),n.RULE("functionCall",()=>{let o=n.CONSUME(H1).image.slice(0,-1),s=n.SUBRULE(n.arguments);return n.CONSUME(mf),n.ACTION(()=>e.callFunction(o,s))}),n.RULE("arguments",()=>{n.MANY2(()=>{n.CONSUME2(jo)});let o=[];return n.OPTION(()=>{o.push(n.SUBRULE(n.formulaWithBinaryOp)),n.MANY(()=>{n.CONSUME1(jo),o.push(null),n.OPTION3(()=>{o.pop(),o.push(n.SUBRULE2(n.formulaWithBinaryOp))})})}),o}),n.RULE("referenceWithoutInfix",()=>n.OR([{ALT:()=>n.SUBRULE(n.referenceItem)},{ALT:()=>{let o=n.SUBRULE(n.prefixName),s=n.SUBRULE2(n.formulaWithRange);return n.ACTION(()=>{if(this.utils.isFormulaError(s))return s;s.ref.sheet=o}),s}}])),n.RULE("referenceItem",()=>n.OR([{ALT:()=>{let o=n.CONSUME(z1).image;return n.ACTION(()=>this.utils.parseCellAddress(o))}},{ALT:()=>{let o=n.CONSUME($1).image;return n.ACTION(()=>e.getVariable(o))}},{ALT:()=>{let o=n.CONSUME(K1).image;return n.ACTION(()=>this.utils.parseCol(o))}},{ALT:()=>{let o=n.CONSUME(hf).image;return n.ACTION(()=>this.utils.toError(o))}}])),n.RULE("prefixName",()=>n.OR([{ALT:()=>n.CONSUME(Y1).image.slice(0,-1)},{ALT:()=>n.CONSUME(q1).image.slice(1,-2).replace(/''/g,"'")}])),this.performSelfAnalysis()}};vf.exports={Parser:Es}});var Ts=D((EE,Rf)=>{var Gn=qe(),{Address:fg}=$e(),{Prefix:hg,Postfix:pg,Infix:Rs,Operators:Ns}=In(),dg=Nn(),Ef=1048576,yf=16384,{NotAllInputParsedException:mg}=Wn(),As=class{constructor(e){this.context=e}columnNameToNumber(e){return fg.columnNameToNumber(e)}parseCellAddress(e){let r=e.match(/([$]?)([A-Za-z]{1,3})([$]?)([1-9][0-9]*)/);return{ref:{address:r[0],col:this.columnNameToNumber(r[2]),row:+r[4]}}}parseRow(e){let r=+e;if(!Number.isInteger(r))throw Error("Row number must be integer.");return{ref:{col:void 0,row:+e}}}parseCol(e){return{ref:{col:this.columnNameToNumber(e),row:void 0}}}parseColRange(e,r){return e=this.columnNameToNumber(e),r=this.columnNameToNumber(r),{ref:{from:{col:Math.min(e,r),row:null},to:{col:Math.max(e,r),row:null}}}}parseRowRange(e,r){return{ref:{from:{col:null,row:Math.min(e,r)},to:{col:null,row:Math.max(e,r)}}}}_applyPrefix(e,r,n){return this.isFormulaError(r)?r:hg.unaryOp(e,r,n)}async applyPrefixAsync(e,r){let{val:n,isArray:o}=this.extractRefValue(await r);return this._applyPrefix(e,n,o)}applyPrefix(e,r){if(this.context.async)return this.applyPrefixAsync(e,r);{let{val:n,isArray:o}=this.extractRefValue(r);return this._applyPrefix(e,n,o)}}_applyPostfix(e,r,n){return this.isFormulaError(e)?e:pg.percentOp(e,n,r)}async applyPostfixAsync(e,r){let{val:n,isArray:o}=this.extractRefValue(await e);return this._applyPostfix(n,o,r)}applyPostfix(e,r){if(this.context.async)return this.applyPostfixAsync(e,r);{let{val:n,isArray:o}=this.extractRefValue(e);return this._applyPostfix(n,o,r)}}_applyInfix(e,r,n){let o=e.val,s=e.isArray,c=n.val,u=n.isArray;if(this.isFormulaError(o))return o;if(this.isFormulaError(c))return c;if(Ns.compareOp.includes(r))return Rs.compareOp(o,r,c,s,u);if(Ns.concatOp.includes(r))return Rs.concatOp(o,r,c,s,u);if(Ns.mathOp.includes(r))return Rs.mathOp(o,r,c,s,u);throw new Error(`Unrecognized infix: ${r}`)}async applyInfixAsync(e,r,n){let o=this.extractRefValue(await e),s=this.extractRefValue(await n);return this._applyInfix(o,r,s)}applyInfix(e,r,n){if(this.context.async)return this.applyInfixAsync(e,r,n);{let o=this.extractRefValue(e),s=this.extractRefValue(n);return this._applyInfix(o,r,s)}}applyIntersect(e){if(this.isFormulaError(e[0]))return e[0];if(!e[0].ref)throw Error(`Expecting a reference, but got ${e[0]}.`);let r,n,o,s,c,u,i=e.shift().ref;if(c=i.sheet,i.from)r=Math.max(i.from.row,i.to.row),o=Math.min(i.from.row,i.to.row),n=Math.max(i.from.col,i.to.col),s=Math.min(i.from.col,i.to.col);else{if(i.row===void 0||i.col===void 0)throw Error("Cannot intersect the whole row or column.");r=o=i.row,n=s=i.col}let a;return e.forEach(l=>{if(this.isFormulaError(l))return l;if(l=l.ref,!l)throw Error(`Expecting a reference, but got ${l}.`);if(l.from){let f=Math.max(l.from.row,l.to.row),p=Math.min(l.from.row,l.to.row),d=Math.max(l.from.col,l.to.col),h=Math.min(l.from.col,l.to.col);(p>r||f<o||h>n||d<s||c!==l.sheet)&&(a=Gn.NULL),r=Math.min(r,f),o=Math.max(o,p),n=Math.min(n,d),s=Math.max(s,h)}else{if(l.row===void 0||l.col===void 0)throw Error("Cannot intersect the whole row or column.");(l.row>r||l.row<o||l.col>n||l.col<s||c!==l.sheet)&&(a=Gn.NULL),r=o=l.row,n=s=l.col}}),a||(r===o&&n===s?u={ref:{sheet:c,row:r,col:n}}:u={ref:{sheet:c,from:{row:o,col:s},to:{row:r,col:n}}},u.ref.sheet||delete u.ref.sheet,u)}applyUnion(e){let r=new dg;for(let n=0;n<e.length;n++){if(this.isFormulaError(e[n]))return e[n];r.add(this.extractRefValue(e[n]).val,e[n])}return r}applyRange(e){let r,n=-1,o=-1,s=Ef+1,c=yf+1;return e.forEach(u=>{if(this.isFormulaError(u))return u;typeof u=="number"&&(u=this.parseRow(u)),u=u.ref,u.row===void 0&&(s=1,n=Ef),u.col===void 0&&(c=1,o=yf),u.row>n&&(n=u.row),u.row<s&&(s=u.row),u.col>o&&(o=u.col),u.col<c&&(c=u.col)}),n===s&&o===c?r={ref:{row:n,col:o}}:r={ref:{from:{row:s,col:c},to:{row:n,col:o}}},r}extractRefValue(e){let r=e,n=!1;return Array.isArray(r)&&(n=!0),e.ref?{val:this.context.retrieveRef(e),isArray:n}:{val:r,isArray:n}}toArray(e){return e}toNumber(e){return Number(e)}toString(e){return e.substring(1,e.length-1).replace(/""/g,'"')}toBoolean(e){return e==="TRUE"}toError(e){return new Gn(e.toUpperCase())}isFormulaError(e){return e instanceof Gn}static formatChevrotainError(e,r){let n,o,s="";return e instanceof mg?(n=e.token.startLine,o=e.token.startColumn):(n=e.previousToken.startLine,o=e.previousToken.startColumn+1),s+=`
200
+ `+r.split(`
201
+ `)[n-1]+`
202
+ `,s+=Array(o-1).fill(" ").join("")+`^
203
+ `,s+=`Error at position ${n}:${o}
204
+ `+e.message,e.errorLocation={line:n,column:o},Gn.ERROR(s,e)}};Rf.exports=As});var bf=D((yE,kf)=>{var gg=Ei(),Nf=Ni(),Af=za(),Tf=$a(),Of=ja(),If=ru(),Mf=ou(),Cf=fu(),wf=mu(),vg=Ru(),wt=qe(),{FormulaHelpers:Hr}=$e(),{Parser:Eg,allTokens:yg}=ys(),_f=Jo(),Os=Ts(),Is=class{constructor(e,r=!1){this.logs=[],this.isTest=r,this.utils=new Os(this),e=Object.assign({functions:{},functionsNeedContext:{},onVariable:()=>null,onCell:()=>0,onRange:()=>[[0]]},e),this.onVariable=e.onVariable,this.functions=Object.assign({},wf,Cf,Mf,If,Of,Tf,gg,Nf,Af,vg,e.functions,e.functionsNeedContext),this.onRange=e.onRange,this.onCell=e.onCell,this.funsNullAs0=Object.keys(Nf).concat(Object.keys(Af)).concat(Object.keys(Tf)).concat(Object.keys(Of)).concat(Object.keys(If)).concat(Object.keys(Cf)).concat(Object.keys(wf)),this.funsNeedContextAndNoDataRetrieve=["ROW","ROWS","COLUMN","COLUMNS","SUMIF","INDEX","AVERAGEIF","IF"],this.funsNeedContext=[...Object.keys(e.functionsNeedContext),...this.funsNeedContextAndNoDataRetrieve,"INDEX","OFFSET","INDIRECT","IF","CHOOSE","WEBSERVICE"],this.funsPreserveRef=Object.keys(Mf),this.parser=new Eg(this,this.utils)}static get allTokens(){return yg}getCell(e){return e.sheet==null&&(e.sheet=this.position?this.position.sheet:void 0),this.onCell(e)}getRange(e){return e.sheet==null&&(e.sheet=this.position?this.position.sheet:void 0),this.onRange(e)}getVariable(e){let r={ref:this.onVariable(e,this.position.sheet,this.position)};return r.ref==null?wt.NAME:r}retrieveRef(e){return Hr.isRangeRef(e)?this.getRange(e.ref):Hr.isCellRef(e)?this.getCell(e.ref):e}_callFunction(e,r){e.indexOf("_xlfn.")===0&&(e=e.slice(6)),e=e.toUpperCase();let n=this.funsNullAs0.includes(e)?0:"";if(this.funsNeedContextAndNoDataRetrieve.includes(e)||(r=r.map(o=>{if(o===null)return{value:n,isArray:!1,omitted:!0};let s=this.utils.extractRefValue(o);return this.funsPreserveRef.includes(e)?{value:s.val,isArray:s.isArray,ref:o.ref}:{value:s.val,isArray:s.isArray,isRangeRef:!!Hr.isRangeRef(o),isCellRef:!!Hr.isCellRef(o)}})),this.functions[e]){let o;try{!this.funsNeedContextAndNoDataRetrieve.includes(e)&&!this.funsNeedContext.includes(e)?o=this.functions[e](...r):o=this.functions[e](this,...r)}catch(s){if(s instanceof wt)return s;throw s}if(o===void 0){if(this.isTest)return this.logs.includes(e)||this.logs.push(e),{value:0,ref:{}};throw wt.NOT_IMPLEMENTED(e)}return o}else{if(this.isTest)return this.logs.includes(e)||this.logs.push(e),{value:0,ref:{}};throw wt.NOT_IMPLEMENTED(e)}}async callFunctionAsync(e,r){let n=[];for(let s of r)n.push(await s);let o=await this._callFunction(e,n);return Hr.checkFunctionResult(o)}callFunction(e,r){if(this.async)return this.callFunctionAsync(e,r);{let n=this._callFunction(e,r);return Hr.checkFunctionResult(n)}}supportedFunctions(){let e=[];return Object.keys(this.functions).forEach(n=>{try{if(this.functions[n](0,0,0,0,0,0,0,0,0,0,0)===void 0)return;e.push(n)}catch(o){o instanceof Error&&e.push(n)}}),e.sort()}checkFormulaResult(e,r=!1){let n=typeof e;if(n==="number"){if(isNaN(e))return wt.VALUE;if(!isFinite(e))return wt.NUM;e+=0}else if(n==="object"){if(e instanceof wt)return e;if(r){if(e.ref&&(e=this.retrieveRef(e)),typeof e=="object"&&!Array.isArray(e)&&e!=null)return wt.VALUE}else if(e.ref&&e.ref.row&&!e.ref.from)e=this.retrieveRef(e);else if(e.ref&&e.ref.from&&e.ref.from.col===e.ref.to.col)e=this.retrieveRef({ref:{row:e.ref.from.row,col:e.ref.from.col}});else if(Array.isArray(e))e=e[0][0];else return wt.VALUE}return e}parse(e,r,n=!1){if(e.length===0)throw Error("Input must not be empty.");this.position=r,this.async=!1;let o=_f.lex(e);this.parser.input=o.tokens;let s;try{if(s=this.parser.formulaWithBinaryOp(),s=this.checkFormulaResult(s,n),s instanceof wt)return s}catch(c){throw wt.ERROR(c.message,c)}if(this.parser.errors.length>0){let c=this.parser.errors[0];throw Os.formatChevrotainError(c,e)}return s}async parseAsync(e,r,n=!1){if(e.length===0)throw Error("Input must not be empty.");this.position=r,this.async=!0;let o=_f.lex(e);this.parser.input=o.tokens;let s;try{if(s=await this.parser.formulaWithBinaryOp(),s=this.checkFormulaResult(s,n),s instanceof wt)return s}catch(c){throw wt.ERROR(c.message,c)}if(this.parser.errors.length>0){let c=this.parser.errors[0];throw Os.formatChevrotainError(c,e)}return s}};kf.exports={FormulaParser:Is,FormulaHelpers:Hr}});var Pf=D((ME,Uf)=>{var ei=qe(),{FormulaHelpers:RE,Types:NE,Address:Rg}=$e(),{Prefix:AE,Postfix:TE,Infix:OE,Operators:IE}=In(),Ng=Nn(),xf=1048576,Lf=16384,Ms=class{constructor(e){this.context=e}columnNameToNumber(e){return Rg.columnNameToNumber(e)}parseCellAddress(e){let r=e.match(/([$]?)([A-Za-z]{1,3})([$]?)([1-9][0-9]*)/);return{ref:{col:this.columnNameToNumber(r[2]),row:+r[4]}}}parseRow(e){let r=+e;if(!Number.isInteger(r))throw Error("Row number must be integer.");return{ref:{col:void 0,row:+e}}}parseCol(e){return{ref:{col:this.columnNameToNumber(e),row:void 0}}}applyPrefix(e,r){return this.extractRefValue(r),0}applyPostfix(e,r){return this.extractRefValue(e),0}applyInfix(e,r,n){return this.extractRefValue(e),this.extractRefValue(n),0}applyIntersect(e){if(this.isFormulaError(e[0]))return e[0];if(!e[0].ref)throw Error(`Expecting a reference, but got ${e[0]}.`);let r,n,o,s,c,u,i=e.shift().ref;if(c=i.sheet,i.from)r=Math.max(i.from.row,i.to.row),o=Math.min(i.from.row,i.to.row),n=Math.max(i.from.col,i.to.col),s=Math.min(i.from.col,i.to.col);else{if(i.row===void 0||i.col===void 0)throw Error("Cannot intersect the whole row or column.");r=o=i.row,n=s=i.col}let a;return e.forEach(l=>{if(this.isFormulaError(l))return l;if(l=l.ref,!l)throw Error(`Expecting a reference, but got ${l}.`);if(l.from){let f=Math.max(l.from.row,l.to.row),p=Math.min(l.from.row,l.to.row),d=Math.max(l.from.col,l.to.col),h=Math.min(l.from.col,l.to.col);(p>r||f<o||h>n||d<s||c!==l.sheet)&&(a=ei.NULL),r=Math.min(r,f),o=Math.max(o,p),n=Math.min(n,d),s=Math.max(s,h)}else{if(l.row===void 0||l.col===void 0)throw Error("Cannot intersect the whole row or column.");(l.row>r||l.row<o||l.col>n||l.col<s||c!==l.sheet)&&(a=ei.NULL),r=o=l.row,n=s=l.col}}),a||(r===o&&n===s?u={ref:{sheet:c,row:r,col:n}}:u={ref:{sheet:c,from:{row:o,col:s},to:{row:r,col:n}}},u.ref.sheet||delete u.ref.sheet,u)}applyUnion(e){let r=new Ng;for(let n=0;n<e.length;n++){if(this.isFormulaError(e[n]))return e[n];r.add(this.extractRefValue(e[n]).val,e[n])}return r}applyRange(e){let r,n=-1,o=-1,s=xf+1,c=Lf+1;return e.forEach(u=>{if(this.isFormulaError(u))return u;typeof u=="number"&&(u=this.parseRow(u)),u=u.ref,u.row===void 0&&(s=1,n=xf),u.col===void 0&&(c=1,o=Lf),u.row>n&&(n=u.row),u.row<s&&(s=u.row),u.col>o&&(o=u.col),u.col<c&&(c=u.col)}),n===s&&o===c?r={ref:{row:n,col:o}}:r={ref:{from:{row:s,col:c},to:{row:n,col:o}}},r}extractRefValue(e){let r=Array.isArray(e);return e.ref?{val:this.context.retrieveRef(e),isArray:r}:{val:e,isArray:r}}toArray(e){return e}toNumber(e){return Number(e)}toString(e){return e.substring(1,e.length-1).replace(/""/g,'"')}toBoolean(e){return e==="TRUE"}toError(e){return new ei(e.toUpperCase())}isFormulaError(e){return e instanceof ei}};Uf.exports=Ms});var Df=D((CE,Bf)=>{var Sf=qe(),{FormulaHelpers:Cs}=$e(),{Parser:Ag}=ys(),Tg=Jo(),Ff=Pf(),{formatChevrotainError:Og}=Ts(),ws=class{constructor(e){this.data=[],this.utils=new Ff(this),e=Object.assign({onVariable:()=>null},e),this.utils=new Ff(this),this.onVariable=e.onVariable,this.functions={},this.parser=new Ag(this,this.utils)}getCell(e){return e.row!=null&&(e.sheet==null&&(e.sheet=this.position?this.position.sheet:void 0),this.data.findIndex(n=>n.from&&n.from.row<=e.row&&n.to.row>=e.row&&n.from.col<=e.col&&n.to.col>=e.col||n.row===e.row&&n.col===e.col&&n.sheet===e.sheet)===-1&&this.data.push(e)),0}getRange(e){return e.from.row!=null&&(e.sheet==null&&(e.sheet=this.position?this.position.sheet:void 0),this.data.findIndex(n=>n.from&&n.from.row===e.from.row&&n.from.col===e.from.col&&n.to.row===e.to.row&&n.to.col===e.to.col)===-1&&this.data.push(e)),[[0]]}getVariable(e){let r={ref:this.onVariable(e,this.position.sheet)};return r.ref==null?Sf.NAME:(Cs.isCellRef(r)?this.getCell(r.ref):this.getRange(r.ref),0)}retrieveRef(e){return Cs.isRangeRef(e)?this.getRange(e.ref):Cs.isCellRef(e)?this.getCell(e.ref):e}callFunction(e,r){return r.forEach(n=>{n!=null&&this.retrieveRef(n)}),{value:0,ref:{}}}checkFormulaResult(e){this.retrieveRef(e)}parse(e,r,n=!1){if(e.length===0)throw Error("Input must not be empty.");this.data=[],this.position=r;let o=Tg.lex(e);this.parser.input=o.tokens;try{let s=this.parser.formulaWithBinaryOp();this.checkFormulaResult(s)}catch(s){if(!n)throw Sf.ERROR(s.message,s)}if(this.parser.errors.length>0&&!n){let s=this.parser.errors[0];throw Og(s,e)}return this.data}};Bf.exports={DepParser:ws}});var Gf=D((wE,Vf)=>{var{FormulaParser:Wf}=bf(),{DepParser:Ig}=Df(),Mg=gi(),Cg=qe();Object.assign(Wf,{MAX_ROW:1048576,MAX_COLUMN:16384,SSF:Mg,DepParser:Ig,FormulaError:Cg,...$e()});Vf.exports=Wf});var rv={};Ph(rv,{mountSheetEditor:()=>tv});module.exports=Fh(rv);var fh=require("react"),hh=require("react-dom/client");var Z=require("react"),Te=require("@deepseek-ai/dsh-client-ui-primitives");var Y={maxSheets:20,maxRows:5e3,maxColumns:100,maxCells:2e4,maxFormulaCells:5e3,maxCellText:1e4,maxFormula:2e3,maxName:31,minColumnWidth:24,maxColumnWidth:800,defaultColumnWidth:96,defaultRowHeight:28,maxOperations:200,maxOperationCells:4e3,maxEvaluationCells:2e5,maxSelectionQuote:1500},te=class extends Error{code;constructor(e,r="sheet/invalid"){super(e),this.name="SheetError",this.code=r}},Bh=/^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/,Dh=/^[A-Za-z]{1,3}$/,Wh=/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i,Vh=/[\\/?*[\]:]/,js=["general","number","integer","currency","percent","date"],Gh=["left","center","right"],na=["bold","italic","underline","strike","align","color","background","numberFormat"],qh=["value","formula","style"],Hh=["name","cells","columnWidths"],zh=["schemaVersion","sheets"];function Qr(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Zn(t,e,r){for(let n of Object.keys(t))if(!e.includes(n))throw new te(r+' has an unknown field "'+n+'". Use '+e.join(", ")+".")}function Sr(t){if(!Number.isInteger(t)||t<0)throw new te("A column index must be a non-negative integer.");let e=t+1,r="";for(;e>0;){let n=(e-1)%26;r=String.fromCharCode(65+n)+r,e=Math.floor((e-1)/26)}return r}function Jn(t){if(!Dh.test(t))return;let e=0;for(let n of t.toUpperCase())e=e*26+(n.charCodeAt(0)-64);let r=e-1;return r<Y.maxColumns?r:void 0}function cr(t){let e=Bh.exec(t.trim());if(e===null)return;let r=Jn(e[1]??""),n=Number(e[2]);if(!(r===void 0||!Number.isInteger(n)||n<1||n>Y.maxRows))return{row:n,column:r}}function Le(t,e){return Sr(e)+String(t)}function oa(t){let e=t.trim().split(":");if(e.length!==2)return;let r=cr(e[0]??""),n=cr(e[1]??"");if(!(r===void 0||n===void 0))return{row1:Math.min(r.row,n.row),column1:Math.min(r.column,n.column),row2:Math.max(r.row,n.row),column2:Math.max(r.column,n.column)}}function Rn(t){return Le(t.row1,t.column1)+":"+Le(t.row2,t.column2)}function ci(t){return(t.row2-t.row1+1)*(t.column2-t.column1+1)}function Yh(t,e="The sheet name"){if(typeof t!="string")throw new te(e+" must be a string.");let r=t.trim();if(r===""||r.length>Y.maxName)throw new te(e+" must be 1 to "+String(Y.maxName)+" characters.");if(Vh.test(r))throw new te(e+" cannot contain \\ / ? * [ ] or : characters.");if(r.startsWith("'")||r.endsWith("'"))throw new te(e+" cannot start or end with an apostrophe.");return r}function ea(t,e){if(typeof t!="string"||!Wh.test(t.trim()))throw new te(e+" must be a hex color such as #1f2933.");let r=t.trim().toLowerCase();return r.length===4?"#"+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]:r}function ta(t){let e=t.trim().toLowerCase(),r=/^#?([0-9a-f]{6})$/.exec(e);if(r===null)return;let n=r[1]??"";return[Number.parseInt(n.slice(0,2),16),Number.parseInt(n.slice(2,4),16),Number.parseInt(n.slice(4,6),16)]}function Qn(t){let e=t.map(r=>{let n=r/255;return n<=.03928?n/12.92:((n+.055)/1.055)**2.4});return .2126*(e[0]??0)+.7152*(e[1]??0)+.0722*(e[2]??0)}function Zr(t,e){let r=ta(t),n=ta(e);if(r===void 0||n===void 0)return 1;let o=Math.max(Qn(r),Qn(n)),s=Math.min(Qn(r),Qn(n));return(o+.05)/(s+.05)}function jn(t){let e="#1f2933",r="#ffffff";return Zr(e,t)>=Zr(r,t)?e:r}function ia(t){if(t!==void 0)return t.background===void 0||t.color!==void 0&&Zr(t.color,t.background)>=4.5?t.color:jn(t.background)}function $h(t,e){if(!Qr(t))throw new te(e+" must be an object.");Zn(t,na,e);let r={};for(let n of["bold","italic","underline","strike"]){let o=t[n];if(o!==void 0){if(typeof o!="boolean")throw new te(e+"."+n+" must be true or false.");r[n]=o}}if(t.align!==void 0){if(typeof t.align!="string"||!Gh.includes(t.align))throw new te(e+".align must be left, center, or right.");r.align=t.align}if(t.numberFormat!==void 0){if(typeof t.numberFormat!="string"||!js.includes(t.numberFormat))throw new te(e+".numberFormat must be "+js.join(", ")+".");r.numberFormat=t.numberFormat}return t.color!==void 0&&(r.color=ea(t.color,e+".color")),t.background!==void 0&&(r.background=ea(t.background,e+".background")),r}function li(t){return Object.keys(t).length===0}function sa(t,e){let r={...t??{}},n=["bold","italic","underline","strike"];for(let o of n){let s=e[o];s!==void 0&&(s===null||s===!1?delete r[o]:r[o]=!0)}return e.align!==void 0&&(e.align===null?delete r.align:r.align=e.align),e.numberFormat!==void 0&&(e.numberFormat===null||e.numberFormat==="general"?delete r.numberFormat:r.numberFormat=e.numberFormat),e.color!==void 0&&(e.color===null?delete r.color:r.color=e.color),e.background!==void 0&&(e.background===null?delete r.background:r.background=e.background),li(r)?void 0:r}function ra(t,e){if(t!=null){if(typeof t=="boolean")return t;if(typeof t=="number"){if(!Number.isFinite(t))throw new te(e+" must be a finite number.");return t}if(typeof t=="string"){if(t.length>Y.maxCellText)throw new te(e+" is longer than "+String(Y.maxCellText)+" characters.");return t}throw new te(e+" must be a string, number, boolean, or null.")}}function aa(t,e){if(t===null)return;if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"){let c=ra(t,e);return c===void 0?void 0:typeof c=="string"&&c.startsWith("=")?aa({formula:c},e):{value:c}}if(!Qr(t))throw new te(e+" must be a JSON scalar or an object with value, formula, or style.");Zn(t,qh,e);let r=t.style===void 0?void 0:$h(t.style,e+".style"),n=t.formula===void 0?void 0:Kh(t.formula,e+".formula");if(n!==void 0&&t.value!==void 0)throw new te(e+" cannot have both value and formula; the value of a formula is computed.");let o=ra(t.value,e+".value"),s={};if(n!==void 0&&(s.formula=n),o!==void 0&&(s.value=o),r!==void 0&&!li(r)&&(s.style=r),!(s.formula===void 0&&s.value===void 0&&s.style===void 0))return s}function Kh(t,e){if(typeof t!="string")throw new te(e+" must be a string formula.");let r=t.trim();if(r===""||r==="=")throw new te(e+" is empty.");if(r.startsWith("=")||(r="="+r),r.length>Y.maxFormula)throw new te(e+" is longer than "+String(Y.maxFormula)+" characters.");return r}function Xh(t,e){if(t===void 0)return;if(!Qr(t))throw new te(e+" must be an object of column letters to pixel widths.");let r={};for(let[n,o]of Object.entries(t)){let s=Jn(n);if(s===void 0)throw new te(e+' has an invalid column "'+n+'".');if(typeof o!="number"||!Number.isFinite(o)||!Number.isInteger(o))throw new te(e+"."+n+" must be a whole number of pixels.");if(o<Y.minColumnWidth||o>Y.maxColumnWidth)throw new te(e+"."+n+" must be between "+String(Y.minColumnWidth)+" and "+String(Y.maxColumnWidth)+" pixels.");let c=Sr(s);if(r[c]!==void 0)throw new te(e+" names column "+c+" twice.");r[c]=o}return Object.keys(r).length===0?void 0:r}function Qh(t){if(!Qr(t))throw new te("A sheet workbook must be a JSON object.");if(Zn(t,zh,"The workbook"),t.schemaVersion!==void 0&&t.schemaVersion!==1)throw new te("Unsupported sheet schemaVersion "+String(t.schemaVersion)+"; this build reads version "+String(1)+".");let e=t.sheets;if(!Array.isArray(e)||e.length===0)throw new te('A sheet workbook needs a "sheets" array with at least one sheet.');if(e.length>Y.maxSheets)throw new te("A workbook holds at most "+String(Y.maxSheets)+" sheets.");let r=new Set,n=0,o=0;return{schemaVersion:1,sheets:e.map((c,u)=>{let i="sheets["+String(u)+"]";if(!Qr(c))throw new te(i+" must be an object.");Zn(c,Hh,i);let a=Yh(c.name,i+".name");if(r.has(a.toLowerCase()))throw new te('Two sheets are named "'+a+'"; names must be unique.');r.add(a.toLowerCase());let l=c.cells??{};if(!Qr(l))throw new te(i+".cells must be an object of cell references to values.");let f={};for(let[m,E]of Object.entries(l)){let g=cr(m);if(g===void 0)throw new te(i+'.cells has an invalid cell reference "'+m+'".');let v=aa(E,i+".cells."+Le(g.row,g.column));v!==void 0&&(n+=1,v.formula!==void 0&&(o+=1),f[Le(g.row,g.column)]=v)}if(n>Y.maxCells)throw new te("A sheet artifact holds at most "+String(Y.maxCells)+" cells.");if(o>Y.maxFormulaCells)throw new te("A sheet artifact holds at most "+String(Y.maxFormulaCells)+" formulas.");let p={},d=Object.keys(f).sort((m,E)=>{let g=cr(m),v=cr(E);return g===void 0||v===void 0?m<E?-1:1:g.row===v.row?g.column-v.column:g.row-v.row});for(let m of d){let E=f[m];E!==void 0&&(p[m]=E)}let h=Xh(c.columnWidths,i+".columnWidths");return{name:a,cells:p,...h===void 0?{}:{columnWidths:h}}})}}function ua(t){let e;try{e=JSON.parse(t)}catch{throw new te("The sheet content is not valid JSON. Send one JSON object with schemaVersion and sheets.")}return Qh(e)}function Zh(t){if(!(t.style!==void 0&&!li(t.style)))return t.formula!==void 0?{formula:t.formula}:typeof t.value=="string"&&t.value.startsWith("=")?{value:t.value}:t.value!==void 0?t.value:null;let r={};return t.formula!==void 0?r.formula=t.formula:t.value!==void 0&&(r.value=t.value),r.style=Jh(t.style),r}function Jh(t){let e={};if(t===void 0)return e;for(let r of na){let n=t[r];n!==void 0&&(e[r]=n)}return e}function Fr(t){let e=t.sheets.map(r=>{let n=Object.keys(r.cells).sort((c,u)=>{let i=cr(c),a=cr(u);return i===void 0||a===void 0?c<u?-1:1:i.row===a.row?i.column-a.column:i.row-a.row}),o={};for(let c of n){let u=r.cells[c];if(u===void 0)continue;let i=Zh(u);i!==null&&(o[c]=i)}let s={name:r.name,cells:o};if(r.columnWidths!==void 0&&Object.keys(r.columnWidths).length>0){let c={},u=Object.keys(r.columnWidths).sort((i,a)=>(Jn(i)??0)-(Jn(a)??0));for(let i of u){let a=r.columnWidths[i];a!==void 0&&(c[i]=a)}s.columnWidths=c}return s});return JSON.stringify({schemaVersion:1,sheets:e},null,2)+`
205
+ `}function ca(t,e){if(e===void 0){let n=t.sheets[0];if(n===void 0)throw new te("The workbook has no sheets.");return n}let r=t.sheets.find(n=>n.name.toLowerCase()===e.trim().toLowerCase());if(r===void 0)throw new te('No sheet is named "'+e+'".');return r}var ri=Sh(Gf(),1);function $f(t){return t===null||typeof t!="object"?!1:typeof{...t}._error=="string"}function Kf(t){return t!==null&&typeof t=="object"?{...t}:{value:t}}function _t(t){let e=Kf(t),r=e.value;return Array.isArray(r)?{values:r.flat(1/0),range:!0}:{values:[r],range:e.isRangeRef===!0||e.isArray===!0}}function Bt(t){if($f(t))throw t}function Xt(t){let{values:e}=_t(t);return e[0]}function ht(t){return t==null?"":typeof t=="boolean"?t?"TRUE":"FALSE":String(t)}function qn(t,e){let r=Xt(t);if(r==null||r==="")return e;if(typeof r=="number")return r;if(typeof r=="boolean")return r?1:0;let n=Number(String(r).trim());return Number.isFinite(n)?n:void 0}function gn(t){let e=[];for(let r of t){let{values:n,range:o}=_t(r);for(let s of n)if(Bt(s),typeof s=="number")Number.isFinite(s)&&e.push(s);else if(!o&&typeof s=="boolean")e.push(s?1:0);else if(!o&&typeof s=="string"&&s.trim()!==""){let c=Number(s.trim());Number.isFinite(c)&&e.push(c)}}return e}function qf(t){let e=Number.NEGATIVE_INFINITY;for(let r of t)e=Math.max(e,r);return e}function Hf(t){let e=Number.POSITIVE_INFINITY;for(let r of t)e=Math.min(e,r);return e}function wg(t,e){let r="^"+e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$";return new RegExp(r,"i").test(t)}function ks(t,e){if(Bt(t),Bt(e),typeof t=="number"&&typeof e=="number")return t===e;let r=typeof t=="number"?t:Number(String(t??"").trim()),n=typeof e=="number"?e:Number(String(e??"").trim()),o=typeof t=="number"||typeof t=="string"&&t.trim()!==""&&/^[+\-]?\d/.test(t.trim()),s=typeof e=="number"||typeof e=="string"&&e.trim()!==""&&/^[+\-]?\d/.test(e.trim());if(o&&s&&Number.isFinite(r)&&Number.isFinite(n))return r===n;let c=ht(e);return/[*?]/.test(c)?wg(ht(t),c):ht(t).toLowerCase()===c.toLowerCase()}function _g(t,e){Bt(t),Bt(e);let r="=",n=e;if(typeof e=="string"){let c=/^(<=|>=|<>|<|>|=)([\s\S]*)$/.exec(e);c!==null&&(r=c[1]??"=",n=(c[2]??"").trim())}if(r==="="||r==="<>"){let c=ks(t,n);return r==="="?c:!c}let o=typeof t=="number"?t:Number(ht(t)),s=typeof n=="number"?n:Number(ht(n));if(!Number.isFinite(o)||!Number.isFinite(s)){let c=ht(t).toLowerCase(),u=ht(n).toLowerCase();switch(r){case"<":return c<u;case">":return c>u;case"<=":return c<=u;case">=":return c>=u;default:return!1}}switch(r){case"<":return o<s;case">":return o>s;case"<=":return o<=s;case">=":return o>=s;default:return!1}}function zf(t,e){if(t.length===0||t.length%2!==0)return;let r=[];for(let n=0;n<e;n+=1)r.push(n);for(let n=0;n<t.length;n+=2){let o=_t(t[n]).values,s=Xt(t[n+1]);if(o.length!==e)return;for(let c=r.length-1;c>=0;c-=1){let u=r[c];u!==void 0&&(_g(o[u],s)||r.splice(c,1))}}return r}function bs(t,e,r){let n=gn(t);if(n.length===0||e&&n.length<2)throw r.div0;let o=n.reduce((c,u)=>c+u,0)/n.length;return n.reduce((c,u)=>c+(u-o)**2,0)/(e?n.length-1:n.length)}function Yf(t,e,r){return Math.sqrt(bs(t,e,r))}function _s(t,e){if(e!==void 0)try{return e.utils.extractRefValue(t).val}catch{return t}return Kf(t).value}function Xf(t){let e=(n,o)=>{let s=gn(n);return s.length===0?0:o(s)},r=n=>{let o=_t(n[0]).values,s=zf(n.slice(1),o.length);if(s===void 0)return;let c=[];for(let u of s){let i=o[u];Bt(i),typeof i=="number"&&c.push(i)}return c};return{MAX:(...n)=>e(n,qf),MIN:(...n)=>e(n,Hf),MEDIAN:(...n)=>{let o=[...gn(n)].sort((c,u)=>c-u);if(o.length===0)throw t.num;let s=Math.floor(o.length/2);return o.length%2===1?o[s]:((o[s-1]??0)+(o[s]??0))/2},LARGE:(...n)=>{let o=[...gn([n[0]])].sort((c,u)=>u-c),s=qn(n[1],void 0);if(s===void 0||!Number.isInteger(s)||s<1||s>o.length)throw t.num;return o[s-1]},SMALL:(...n)=>{let o=[...gn([n[0]])].sort((c,u)=>c-u),s=qn(n[1],void 0);if(s===void 0||!Number.isInteger(s)||s<1||s>o.length)throw t.num;return o[s-1]},COUNTA:(...n)=>{let o=0;for(let s of n){let{values:c}=_t(s);for(let u of c){if($f(u)){o+=1;continue}u!=null&&u!==""&&(o+=1)}}return o},COUNTBLANK:(...n)=>{let o=0;for(let s of n){let{values:c}=_t(s);for(let u of c)(u==null||u==="")&&(o+=1)}return o},MATCH:(...n)=>{let o=Xt(n[0]),s=_t(n[1]).values,c=(n[2]===void 0?1:qn(n[2],1))??1;for(let i=0;i<s.length;i+=1)if(ks(s[i],o))return i+1;if(c===0)throw t.na;let u=-1;for(let i=0;i<s.length;i+=1){let a=s[i];Bt(a);let l=Number(ht(a)),f=Number(ht(o));!Number.isFinite(l)||!Number.isFinite(f)||(c>0?l<=f:l>=f)&&(u=i)}if(u<0)throw t.na;return u+1},INDEX:(...n)=>{let o=n[0],s=o!==null&&typeof o=="object"&&"utils"in o?o:void 0,c=s===void 0?n:n.slice(1),u=_s(c[0],s),i=_s(c[1],s),a=Number(i);if(!Number.isInteger(a)||a<1)throw t.value;let l;if(Array.isArray(u)&&u.length>0&&Array.isArray(u[0])?l=u:Array.isArray(u)?l=[u]:l=[[u]],l.length===1||(l[0]?.length??0)===1){let m=(l.length===1?l[0]??[]:l.map(E=>E[0]))[a-1];if(m===void 0)throw t.ref;return Bt(m),m}let f=c[2]===void 0?1:Number(_s(c[2],s));if(!Number.isInteger(f)||f<1)throw t.value;let d=l[a-1]?.[f-1];if(d===void 0)throw t.ref;return Bt(d),d},LOOKUP:(...n)=>{let o=Xt(n[0]),s=_t(n[1]).values,c=n[2]===void 0?s:_t(n[2]).values,u=-1;for(let i=0;i<s.length;i+=1){let a=s[i];Bt(a);let l=Number(ht(a)),f=Number(ht(o));!Number.isFinite(l)||!Number.isFinite(f)||l<=f&&(u=i)}if(u<0||c[u]===void 0)throw t.na;return c[u]},RANK:(...n)=>{let o=qn(n[0],void 0);if(o===void 0)throw t.value;let s=gn([n[1]]),c=qn(n[2],0)===1;if(!s.includes(o))throw t.na;return s.filter(i=>c?i<o:i>o).length+1},STDEV:(...n)=>Yf(n,!0,t),STDEVP:(...n)=>Yf(n,!1,t),VAR:(...n)=>bs(n,!0,t),VARP:(...n)=>bs(n,!1,t),SUMIFS:(...n)=>{let o=r(n);if(o===void 0)throw t.value;return o.reduce((s,c)=>s+c,0)},COUNTIFS:(...n)=>{let o=zf(n,_t(n[0]).values.length);if(o===void 0)throw t.value;return o.length},AVERAGEIFS:(...n)=>{let o=r(n);if(o===void 0)throw t.value;if(o.length===0)throw t.div0;return o.reduce((s,c)=>s+c,0)/o.length},MAXIFS:(...n)=>{let o=r(n);if(o===void 0||o.length===0)throw t.value;return qf(o)},MINIFS:(...n)=>{let o=r(n);if(o===void 0||o.length===0)throw t.value;return Hf(o)},UPPER:n=>ht(Xt(n)).toUpperCase(),VALUE:n=>{let o=ht(Xt(n)).trim(),s=Number(o);if(o===""||!Number.isFinite(s))throw t.value;return s},TEXTJOIN:(...n)=>{let o=ht(Xt(n[0])),s=Xt(n[1])===!0||ht(Xt(n[1])).toUpperCase()==="TRUE",c=[];for(let u of n.slice(2)){let{values:i}=_t(u);for(let a of i)Bt(a),!(s&&(a==null||a===""))&&c.push(ht(a))}return c.join(o)},XLOOKUP:(...n)=>{let o=Xt(n[0]),s=_t(n[1]).values,c=_t(n[2]).values;for(let u=0;u<s.length;u+=1)if(ks(s[u],o)){let i=c[u];return Bt(i),i}if(n[3]!==void 0)return Xt(n[3]);throw t.na}}}function Qf(){return{cycle:!1,limit:!1,syntax:void 0,referenceError:void 0,unresolved:!1}}function xr(t){return"error"in t}function Zf(t){if(t===null||typeof t!="object"||Array.isArray(t))return;let e={...t},r=e._error??e.name;return typeof r=="string"&&r.startsWith("#")?r:void 0}function kg(t){if(t===null||typeof t!="object")return"";let e={...t};return typeof e.message=="string"?e.message:""}function Jf(t,e){switch(t){case"#VALUE!":case"#DIV/0!":case"#NAME?":case"#REF!":case"#N/A":case"#NUM!":case"#NULL!":return t;case"#CYCLE!":case"#LIMIT!":case"#SYNTAX!":return t;case"#ERROR!":return/not implemented/i.test(e)?"#NAME?":"#SYNTAX!";default:return"#ERROR!".startsWith(t)?"#SYNTAX!":"#VALUE!"}}var Dt=ri.default.FormulaError;function vn(t){switch(t){case"#DIV/0!":return Dt.DIV0;case"#N/A":return Dt.NA;case"#NAME?":return Dt.NAME;case"#NUM!":return Dt.NUM;case"#REF!":return Dt.REF;case"#NULL!":return Dt.NULL;default:return Dt.VALUE}}function bg(t,e){if(!Number.isFinite(t))return"#NUM!";switch(e){case"number":return ti(t,2);case"integer":return ti(Math.round(t),0);case"currency":{let r=ti(Math.abs(t),2);return(t<0?"-$":"$")+r}case"percent":return ti(t*100,2)+"%";case"date":return xg(t);case void 0:case"general":default:return jf(t)}}function ti(t,e){let r=Math.abs(t).toFixed(e),n=r.split("."),o=n[0]??"0",s=n[1],c=o.replace(/\B(?=(\d{3})+(?!\d))/g,","),u=s===void 0?c:c+"."+s;return t<0&&Number(r)!==0?"-"+u:u}function jf(t){if(Number.isInteger(t))return String(t);let e=Math.abs(t);return e>=1e15||e>0&&e<1e-9?t.toExponential(6):String(Number(t.toPrecision(12)))}function xg(t){if(t<=0||t>2958465)return jf(t);let e=Math.floor(t),r=t-e,n=e<60?Date.UTC(1899,11,31)+e*864e5:Date.UTC(1899,11,30)+e*864e5,o=new Date(n+Math.round(r*864e5)),s=u=>String(u).padStart(2,"0"),c=String(o.getUTCFullYear())+"-"+s(o.getUTCMonth()+1)+"-"+s(o.getUTCDate());return r===0?c:c+" "+s(o.getUTCHours())+":"+s(o.getUTCMinutes())}function Lg(t,e){return t===null?"":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?bg(t,e):t}var xs=class{workbook;sheets=new Map;memo=new Map;visiting=new Set;parser;depParser;flags=Qf();budget=Y.maxEvaluationCells;constructor(e){this.workbook=e;for(let r of e.sheets)this.sheets.set(r.name.toLowerCase(),r);this.parser=new ri.default({onCell:r=>this.parserCell(r),onRange:r=>this.parserRange(r),functions:Xf({value:Dt.VALUE,na:Dt.NA,num:Dt.NUM,div0:Dt.DIV0,ref:Dt.REF})}),this.depParser=new ri.default.DepParser({onVariable:()=>{}})}prepareDependencies(e,r,n,o){let s=e.startsWith("=")?e.slice(1):e,c;try{c=this.depParser.parse(s,{row:n,col:o+1,sheet:r})}catch{return}if(Array.isArray(c))for(let u of c){if(u===null||typeof u!="object")continue;let i={...u},a=typeof i.sheet=="string"?i.sheet:r;if(typeof i.row=="number"&&typeof i.col=="number"){this.resultOf(a,i.row,i.col-1);continue}let l=i.from,f=i.to;if(l===null||typeof l!="object"||f===null||typeof f!="object")continue;let p=l.row,d=l.col,h=f.row,m=f.col;if(typeof p!="number"||typeof d!="number"||typeof h!="number"||typeof m!="number")continue;let E=Math.max(1,p),g=Math.min(Y.maxRows,h),v=Math.max(0,d-1),R=Math.min(Y.maxColumns-1,m-1),N=(g-E+1)*(R-v+1);if(!this.spend(N))return;for(let A=E;A<=g;A+=1)for(let y=v;y<=R;y+=1)this.resultOf(a,A,y)}}spend(e=1){return this.budget-=e,this.budget>=0?!0:(this.flags.limit=!0,!1)}parserCell(e){let r=e.sheet??this.workbook.sheets[0]?.name??"",n=Math.max(0,e.col-1);return this.unevaluatedFormula(r,e.row,n)?(this.flags.unresolved=!0,vn("#REF!")):this.toParserValue(this.resultOf(r,e.row,n),e.sheet!==void 0)}unevaluatedFormula(e,r,n){let o=this.sheets.get(e.toLowerCase());if(o===void 0)return!1;let s=o.cells[Le(r,n)];return s===void 0||s.formula===void 0?!1:!this.memo.has(o.name.toLowerCase()+"!"+Le(r,n))}parserRange(e){let r=e.sheet??this.workbook.sheets[0]?.name??"",n=Math.max(1,e.from.row),o=Math.min(Y.maxRows,e.to.row),s=Math.max(0,e.from.col-1),c=Math.min(Y.maxColumns-1,e.to.col-1);if(o<n||c<s)return[];if(!this.spend((o-n+1)*(c-s+1)))return[[vn("#REF!")]];let u=[];for(let i=n;i<=o;i+=1){let a=[];for(let l=s;l<=c;l+=1)a.push(this.toParserValue(this.resultOf(r,i,l),!1));u.push(a)}return u}toParserValue(e,r){return xr(e)?(this.flags.referenceError===void 0&&(this.flags.referenceError=e),e.error==="#CYCLE!"?(this.flags.cycle=!0,vn("#REF!")):e.error==="#LIMIT!"?(this.flags.limit=!0,vn("#REF!")):e.error==="#SYNTAX!"?(this.flags.syntax===void 0&&(this.flags.syntax=e.message??"A referenced formula has invalid syntax."),vn("#REF!")):vn(e.error)):e.value}evaluateFormula(e,r,n,o){let s=e.startsWith("=")?e.slice(1):e;try{let c=this.parser.parse(s,{row:n,col:o+1,sheet:r});return this.outcomeOf(c)}catch(c){let u=c instanceof Error?c.message:"The formula could not be parsed.",i=Zf(c);return i!==void 0?{error:Jf(i,u),message:u.split(`
206
+ `)[0]??u}:/not implemented/i.test(u)?{error:"#NAME?",message:u}:{error:"#SYNTAX!",message:u.split(`
207
+ `)[0]??u}}}outcomeOf(e){if(e==null)return{value:null};if(typeof e=="number")return Number.isFinite(e)?{value:e}:{error:"#NUM!",message:"The result is not a finite number."};if(typeof e=="string"||typeof e=="boolean")return{value:e};if(Array.isArray(e))return{error:"#VALUE!",message:"Array formulas are not supported in a sheet artifact."};let r=Zf(e);if(r!==void 0){let n=kg(e);return{error:Jf(r,n),message:n.split(`
208
+ `)[0]??n}}return{error:"#VALUE!",message:"The formula returned a value this build cannot show."}}resultOf(e,r,n){let o=this.sheets.get(e.toLowerCase());if(o===void 0)return{error:"#REF!",message:'There is no sheet named "'+e+'".'};let s=Le(r,n),c=o.name.toLowerCase()+"!"+s,u=this.memo.get(c);if(u!==void 0)return u;if(this.visiting.has(c))return this.flags.cycle=!0,{error:"#CYCLE!",message:"The formula refers back to its own cell."};if(!this.spend())return{error:"#LIMIT!",message:"The formula calculation is too large."};let i=o.cells[s];if(i===void 0||i.formula===void 0){let f={value:i===void 0?null:i.value??null};return this.memo.set(c,f),f}let a=this.flags;this.flags=Qf(),this.visiting.add(c);let l;try{this.prepareDependencies(i.formula,o.name,r,n),l=this.evaluateFormula(i.formula,o.name,r,n),this.flags.cycle?l={error:"#CYCLE!",message:"The formula refers back to its own cell."}:this.flags.limit?l={error:"#LIMIT!",message:"The formula calculation is too large."}:this.flags.unresolved?l={error:"#REF!",message:"A dynamic reference points at a formula this build could not resolve first."}:xr(l)&&this.flags.syntax!==void 0?l={error:"#SYNTAX!",message:this.flags.syntax}:!xr(l)&&this.flags.referenceError!==void 0&&Pg(i.formula)&&(l=this.flags.referenceError)}finally{this.visiting.delete(c),this.flags=a}return this.memo.set(c,l),l}run(){let e={},r=[];for(let n of this.workbook.sheets){let o={};e[n.name]=o;for(let s of Object.entries(n.cells)){let c=s[0],u=s[1],i=c===void 0?void 0:Sg(c);if(i===void 0)continue;let a=this.resultOf(n.name,i.row,i.column);if(xr(a)&&u.formula!==void 0&&r.length<8){let l=a.message===void 0?"":a.message.replace(/\.$/,"");r.push("formula-error: "+n.name+"!"+c+" shows "+a.error+' for "'+u.formula+'"'+(l===""?".":"; "+l+"."))}o[c]={value:xr(a)?null:a.value,...xr(a)?{error:a.error}:{},...xr(a)&&a.message!==void 0?{message:a.message}:{},display:xr(a)?a.error:Lg(a.value,u.style?.numberFormat)}}}return{results:e,warnings:r}}},Ug=/^=\s*(?:SUM|AVERAGE|MIN|MAX|PRODUCT|MEDIAN)\s*\(/i;function Pg(t){return Ug.test(t)?!/\b(?:IFERROR|IF|ISERROR|ISNA)\s*\(/i.test(t):!1}function Sg(t){let e=/^([A-Z]{1,3})([1-9][0-9]{0,6})$/.exec(t);if(e===null)return;let r=e[1]??"",n=0;for(let o of r)n=n*26+(o.charCodeAt(0)-64);return{row:Number(e[2]),column:n-1}}function Ls(t){return new xs(t).run()}function eh(t,e,r,n){let o=ca(t,r),s=oa(n);if(s===void 0)return r+"!"+n;let c=e.results[o.name]??{},u=Math.min(s.row2,s.row1+19),i=Math.min(s.column2,s.column1+11),a=[o.name+"!"+Rn(s)];for(let f=s.row1;f<=u;f+=1){let p=[];for(let d=s.column1;d<=i;d+=1){let h=Le(f,d);p.push((c[h]?.display??"").replace(/\t/g," ").replace(/\r?\n/g," "))}a.push(p.join(" "))}let l=a.join(`
209
+ `).trimEnd();return(u<s.row2||i<s.column2)&&(l+=`
210
+ ...`),l.length>Y.maxSelectionQuote&&(l=l.slice(0,Y.maxSelectionQuote-3).trimEnd()+"..."),l}var zr=require("react/jsx-runtime");function th({children:t,size:e=16}){return(0,zr.jsx)("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t})}var rh=({size:t})=>(0,zr.jsx)(th,{size:t,children:(0,zr.jsx)("path",{d:"M4 9.5h9.5a5.5 5.5 0 0 1 0 11H9M4 9.5l4-4M4 9.5l4 4"})}),nh=({size:t})=>(0,zr.jsx)(th,{size:t,children:(0,zr.jsx)("path",{d:"M20 9.5h-9.5a5.5 5.5 0 0 0 0 11H15M20 9.5l-4-4M20 9.5l-4 4"})});var Fg=["primary","accent","surface","text","muted","background","raised","border","control","action","actionText","focus","success","warning","danger"];function Bg(t){return"--artifact-color-"+t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function oh(t,e){let r=e?t.colorsDark:t.colors,n={"--artifact-font-family":t.typography.fontFamily,"--artifact-font-display":t.typography.displayFamily,"--artifact-font-mono":t.typography.monoFamily};for(let o of Fg)n[Bg(o)]=r[o];t.typography.scale.forEach((o,s)=>{n[`--artifact-font-size-${s}`]=`${o}px`}),t.spacing.scale.forEach((o,s)=>{n[`--artifact-space-${s}`]=`${o}px`});for(let[o,s]of Object.entries(t.radius))n[`--artifact-radius-${o}`]=`${s}px`;return n}var P=require("react/jsx-runtime"),et=28,Dg=28,Wg=48,Yr=Y.defaultColumnWidth,Vg=50;function Hn(t,e,r){return Math.min(Math.max(t,e),r)}function ih(t,e){return{row:Hn(t,1,Y.maxRows),column:Hn(e,0,Y.maxColumns-1)}}function Gg(t){return{row1:Math.min(t.anchor.row,t.focus.row),column1:Math.min(t.anchor.column,t.focus.column),row2:Math.max(t.anchor.row,t.focus.row),column2:Math.max(t.anchor.column,t.focus.column)}}function qg(t){return ci(t)===1?Le(t.row1,t.column1):Rn(t)}function Ss(t,e){return t.sheets[e]}function ni(t){return t===void 0?"":t.formula!==void 0?t.formula:t.value===void 0?"":typeof t.value=="boolean"?t.value?"TRUE":"FALSE":String(t.value)}function Hg(t){let e=/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?)\s*%$/.exec(t.trim());if(e!==null){let n=Number(e[1]);return Number.isFinite(n)?n/100:null}let r=/^([+-]?)\$?\s*((?:\d{1,3}(?:,\d{3})*|\d+)(?:\.\d+)?)$/.exec(t.trim());if(r!==null){let n=Number((r[1]??"")+(r[2]??"").replace(/,/g,""));return Number.isFinite(n)?n:null}if(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(t.trim())){let n=Number(t.trim());return Number.isFinite(n)?n:null}return null}function uh(t,e){let r=e===void 0?{}:{style:{...e}},n=t.trim();if(n===""&&!t.startsWith("'"))return e===void 0?void 0:{style:{...e}};if(t.startsWith("'"))return{value:t.slice(1),...r};if(t.startsWith("=")&&n.length>1)return{formula:t,...r};let o=n.toUpperCase();if(o==="TRUE")return{value:!0,...r};if(o==="FALSE")return{value:!1,...r};let s=Hg(t);return s!==null?{value:s,...r}:{value:t,...r}}function zg(t,e,r,n,o){let s=t.sheets.map((c,u)=>{if(u!==e)return c;let i={...c.cells},a=Le(r,n);return o===void 0?delete i[a]:i[a]=o,{...c,cells:i}});return{schemaVersion:Lr,sheets:s}}var Lr=1;function Yg(t){let e=[],r=[],n=0;for(let o=0;o<Y.maxColumns;o+=1){let s=Sr(o);r.push(n);let c=t?.columnWidths?.[s]??Yr;e.push(c),n+=c}return r.push(n),{widths:e,starts:r,total:n}}function Us(t,e){let r=0,n=Y.maxColumns-1;for(;r<n;){let o=Math.ceil((r+n)/2);(t[o]??0)<=e?r=o:n=o-1}return r}function ch(t,e){let r=[];for(let n of Object.keys(t.cells)){let o=cr(n);o!==void 0&&o.row>=e.row1&&o.row<=e.row2&&o.column>=e.column1&&o.column<=e.column2&&r.push(n)}return r}function $g(t,e,r,n,o){let s=Ss(t,e);if(s===void 0)return t;let c=ch(s,r),u=c.length===0?[o]:c,i=t.sheets.map((a,l)=>{if(l!==e)return a;let f={...a.cells};for(let p of u){let d=f[p]??{},h=sa(d.style,n),m={...d};h===void 0?delete m.style:m.style=h,m.formula===void 0&&m.value===void 0&&m.style===void 0?delete f[p]:f[p]=m}return{...a,cells:f}});return{schemaVersion:Lr,sheets:i}}function sh(t,e,r){let n=t.sheets.map((o,s)=>{if(s!==e)return o;let c={...o.cells};for(let u of ch(o,r))delete c[u];return{...o,cells:c}});return{schemaVersion:Lr,sheets:n}}function Kg(t,e,r,n,o){let s=Ss(t,e);if(s===void 0)return t;let c={...s.cells};o.forEach((i,a)=>{i.forEach((l,f)=>{let p=Le(r+a,n+f),d=c[p],h=uh(l,d?.style);h===void 0?delete c[p]:c[p]=h})});let u=t.sheets.map((i,a)=>a===e?{...i,cells:c}:i);return{schemaVersion:Lr,sheets:u}}function Xg(t,e){return{schemaVersion:Lr,sheets:[...t.sheets,{name:e,cells:{}}]}}function Qg(t){for(let e=1;e<=Y.maxSheets+1;e+=1){let r="Sheet"+String(e);if(!t.sheets.some(n=>n.name.toLowerCase()===r.toLowerCase()))return r}return"Sheet"+String(t.sheets.length+1)}function Zg(t,e,r){return{schemaVersion:Lr,sheets:t.sheets.map((n,o)=>o===e?{...n,name:r}:n)}}function Jg(t,e){return{schemaVersion:Lr,sheets:t.sheets.filter((r,n)=>n!==e)}}function jg(t,e,r,n){let o=t.sheets.map((s,c)=>{if(c!==e)return s;let u={...s.columnWidths??{}};return u[Sr(r)]=Math.round(n),{...s,columnWidths:u}});return{schemaVersion:Lr,sheets:o}}function oi(t){try{return{workbook:ua(t),error:null}}catch(e){return{workbook:null,error:e instanceof Error?e.message:"The sheet content is invalid."}}}function Ps({align:t}){return(0,P.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":"true",children:(t==="left"?["M3 4.5h10","M3 8h7","M3 11.5h10"]:t==="right"?["M3 4.5h10","M6 8h7","M3 11.5h10"]:["M3 4.5h10","M4.5 8h7","M3 11.5h10"]).map((r,n)=>(0,P.jsx)("path",{d:r},n))})}var ev=["general","number","integer","currency","percent","date"],ah={general:"sheet.format.general",number:"sheet.format.number",integer:"sheet.format.integer",currency:"sheet.format.currency",percent:"sheet.format.percent",date:"sheet.format.date"};function lh({options:t,register:e}){let r=t.live,n=r.current.t,o=(0,Z.useRef)(t.content),s=(0,Z.useRef)(oi(t.content)),[c,u]=(0,Z.useState)(s.current.workbook),[i,a]=(0,Z.useState)(s.current.error),[l,f]=(0,Z.useState)(0),[p,d]=(0,Z.useState)({anchor:{row:1,column:0},focus:{row:1,column:0}}),[h,m]=(0,Z.useState)(null),[E,g]=(0,Z.useState)(""),[v,R]=(0,Z.useState)({top:0,left:0}),[N,A]=(0,Z.useState)({width:640,height:420}),[y,T]=(0,Z.useState)(t.editable),[I,M]=(0,Z.useState)({design:t.design,dark:t.dark}),[b,S]=(0,Z.useState)(),[G,j]=(0,Z.useState)(!1),[$,W]=(0,Z.useState)(!1),[he,Ge]=(0,Z.useState)(!1),[Xe,tt]=(0,Z.useState)(!1),[Fe,xe]=(0,Z.useState)(null),[kt,bt]=(0,Z.useState)(!1),[Wt,Be]=(0,Z.useState)(null),Et=(0,Z.useRef)(c),Qt=(0,Z.useRef)({past:[],future:[]}),$r=(0,Z.useRef)(null),xt=(0,Z.useRef)(null),Rr=(0,Z.useRef)(null),Ur=(0,Z.useRef)(!1),De=c===null?void 0:Ss(c,l),Lt=(0,Z.useMemo)(()=>c===null?null:Ls(c),[c]),ut=(0,Z.useMemo)(()=>Yg(De),[De]),Re=(0,Z.useMemo)(()=>Gg(p),[p]),Kr=Le(p.focus.row,p.focus.column),sr=De?.cells[Kr],En=Lt===null||De===void 0?void 0:Lt.results[De.name]?.[Kr],rt=sr?.style,yn=qg(Re),nt=(0,Z.useMemo)(()=>I.design===void 0?{}:{...oh(I.design,I.dark),colorScheme:I.dark?"dark":"light"},[I]);(0,Z.useLayoutEffect)(()=>{let O=xt.current;if(O===null)return;let _=getComputedStyle(O).backgroundColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);_!==null&&S("#"+_.slice(1).map(x=>Number(x).toString(16).padStart(2,"0")).join(""))},[I.dark]);let Nr=O=>{let _=ia(O);return O?.background!==void 0||_===void 0||b===void 0||Zr(_,b)>=4.5?_:jn(b)},Ar={left:ut.starts[Re.column1]??0,top:(Re.row1-1)*et,width:(ut.starts[Re.column2+1]??0)-(ut.starts[Re.column1]??0),height:(Re.row2-Re.row1+1)*et},ii={left:ut.starts[p.focus.column]??0,top:(p.focus.row-1)*et,width:ut.widths[p.focus.column]??Yr,height:et},ph=O=>{let _=Qt.current.past;_.push(O),_.length>Vg&&_.shift(),Qt.current.future.length=0,j(_.length>0),W(!1)},ar=(0,Z.useCallback)(O=>{let _=Et.current;if(_===null||!y)return;let x=Fr(_),K=O(_);Fr(K)!==x&&(ph(x),Et.current=K,u(K),r.current.onChange(Fr(K)))},[y,r]),Fs=(0,Z.useCallback)(O=>{let _=oi(O);o.current=O,Et.current=_.workbook,u(_.workbook),a(_.error),m(null),f(0),d({anchor:{row:1,column:0},focus:{row:1,column:0}}),Qt.current={past:[],future:[]},j(!1),W(!1)},[]);(0,Z.useEffect)(()=>{e({getJson:()=>Et.current===null?o.current:Fr(Et.current),setContent:O=>Fs(O),setEditable:O=>T(O),setAppearance:(O,_)=>M({design:O,dark:_}),destroy:()=>{}})},[Fs,e]),(0,Z.useEffect)(()=>{let O=xt.current;if(O===null)return;let _=()=>{A({width:Math.max(120,O.clientWidth-Wg),height:Math.max(120,O.clientHeight-Dg)})};if(_(),typeof ResizeObserver>"u")return;let x=new ResizeObserver(_);return x.observe(O),()=>x.disconnect()},[]),(0,Z.useEffect)(()=>{h===null&&g(ni(sr))},[l,sr,h,p.focus.row,p.focus.column]),(0,Z.useEffect)(()=>{if(h===null)return;let O=Rr.current;O!==null&&(O.focus(),O.setSelectionRange(h.draft.length,h.draft.length))},[h?.row,h?.column]),(0,Z.useEffect)(()=>{if(c===null||Lt===null||De===void 0)return;let O=sr===void 0&&En===void 0;r.current.onSelectionText(ci(Re)===1&&O?"":eh(c,Lt,De.name,Rn(Re)))},[c,Lt,De,Re,sr,En,r]),(0,Z.useEffect)(()=>{d({anchor:{row:1,column:0},focus:{row:1,column:0}}),m(null)},[l]);let si=O=>{let _=$r.current;if(_===null)return;let x=(O.row-1)*et;x<_.scrollTop?_.scrollTop=x:x+et>_.scrollTop+_.clientHeight&&(_.scrollTop=x+et-_.clientHeight);let K=ut.starts[O.column]??0,ue=ut.widths[O.column]??Yr;K<_.scrollLeft?_.scrollLeft=K:K+ue>_.scrollLeft+_.clientWidth&&(_.scrollLeft=K+ue-_.clientWidth)},Zt=(O,_)=>{let x=p.focus,K=Math.max(1,Math.floor(N.height/et)-1),ue=x.row,We=x.column;switch(O){case"up":ue-=1;break;case"down":ue+=1;break;case"left":We-=1;break;case"right":We+=1;break;case"pageup":ue-=K;break;case"pagedown":ue+=K;break;case"home":We=0;break;case"end":We=Y.maxColumns-1;break;default:break}let Ne=ih(ue,We);d(_?{anchor:p.anchor,focus:Ne}:{anchor:Ne,focus:Ne}),si(Ne)},dh=(O,_,x)=>{let K=ih(O,_);d(x?{anchor:p.anchor,focus:K}:{anchor:K,focus:K}),si(K)},zn=(O,_,x)=>{if(!y||c===null)return;let K=De?.cells[Le(O,_)],ue=ni(K);d({anchor:{row:O,column:_},focus:{row:O,column:_}}),m({row:O,column:_,draft:x===void 0?ue:x,initial:ue})},Bs=()=>{m(null),g(ni(sr))},Xr=O=>{if(h===null)return;let{row:_,column:x,draft:K,initial:ue}=h;if(m(null),K!==ue){let We=De?.cells[Le(_,x)]?.style,Ne=uh(K,We);ar(Qe=>zg(Qe,l,_,x,Ne))}O!==null&&Zt(O,!1)},Pr=O=>{let _=Le(p.focus.row,p.focus.column),x=l,K=Re;ar(ue=>$g(ue,x,K,O,_))},Yn=O=>rt?.[O]===!0,$n=O=>{Pr({[O]:Yn(O)?null:!0})},Ds=()=>{let O=Qt.current.past,_=O.pop();if(_===void 0||Et.current===null)return;Qt.current.future.push(Fr(Et.current));let x=oi(_);Et.current=x.workbook,u(x.workbook),j(O.length>0),W(!0),r.current.onChange(_)},ai=()=>{let O=Qt.current.future,_=O.pop();if(_===void 0||Et.current===null)return;Qt.current.past.push(Fr(Et.current));let x=oi(_);Et.current=x.workbook,u(x.workbook),j(!0),W(O.length>0),r.current.onChange(_)},Ws=()=>{if(c===null||De===void 0)return"";let O=[],_=Math.min(Re.row2,Re.row1+1999);for(let x=Re.row1;x<=_;x+=1){let K=[];for(let ue=Re.column1;ue<=Re.column2;ue+=1)K.push(ni(De.cells[Le(x,ue)]));O.push(K.join(" "))}return O.join(`
211
+ `)},mh=O=>{O.preventDefault(),O.clipboardData.setData("text/plain",Ws())},gh=O=>{O.preventDefault(),O.clipboardData.setData("text/plain",Ws());let _=l,x=Re;ar(K=>sh(K,_,x))},vh=O=>{if(!y)return;O.preventDefault();let _=O.clipboardData.getData("text/plain");if(_==="")return;let x=_.replace(/\r\n/g,`
212
+ `).replace(/\r/g,`
213
+ `).split(`
214
+ `);x.length>0&&x[x.length-1]===""&&x.pop();let K=x.map(Tr=>Tr.split(" ")),ue=l,We=p.focus;ar(Tr=>Kg(Tr,ue,We.row,We.column,K));let Ne=Math.min(Y.maxRows,We.row+Math.max(0,K.length-1)),Qe=Math.min(Y.maxColumns-1,We.column+Math.max(0,(K[0]?.length??1)-1));d({anchor:We,focus:{row:Ne,column:Qe}})},Eh=()=>{let O=l,_=Re;ar(x=>sh(x,O,_))},yh=O=>{if(h!==null||c===null||De===void 0)return;let _=O.ctrlKey||O.metaKey;if(_&&O.key.toLowerCase()==="s"){O.preventDefault(),r.current.onSave();return}if(_&&O.key.toLowerCase()==="z"){O.preventDefault(),O.shiftKey?ai():Ds();return}if(_&&O.key.toLowerCase()==="y"){O.preventDefault(),ai();return}if(_&&O.key.toLowerCase()==="a"){O.preventDefault(),d({anchor:{row:1,column:0},focus:{row:Y.maxRows,column:Y.maxColumns-1}});return}if(_&&(O.key.toLowerCase()==="b"||O.key.toLowerCase()==="i"||O.key.toLowerCase()==="u")){O.preventDefault();let K=O.key.toLowerCase()==="b"?"bold":O.key.toLowerCase()==="i"?"italic":"underline";$n(K);return}let x=O.shiftKey;switch(O.key){case"ArrowUp":O.preventDefault(),Zt("up",x);return;case"ArrowDown":O.preventDefault(),Zt("down",x);return;case"ArrowLeft":O.preventDefault(),Zt("left",x);return;case"ArrowRight":O.preventDefault(),Zt("right",x);return;case"PageUp":O.preventDefault(),Zt("pageup",x);return;case"PageDown":O.preventDefault(),Zt("pagedown",x);return;case"Home":if(O.preventDefault(),O.ctrlKey||O.metaKey){let K={row:1,column:0};d(x?{anchor:p.anchor,focus:K}:{anchor:K,focus:K}),si(K)}else Zt("home",x);return;case"End":O.preventDefault(),Zt("end",x);return;case"Enter":{O.preventDefault(),y&&zn(p.focus.row,p.focus.column);return}case"Tab":{O.preventDefault(),Zt(O.shiftKey?"left":"right",!1);return}case"F2":{O.preventDefault(),y&&zn(p.focus.row,p.focus.column);return}case"Delete":case"Backspace":O.preventDefault(),y&&Eh();return;case"Escape":O.preventDefault(),d({anchor:p.focus,focus:p.focus});return;default:break}y&&O.key.length===1&&!O.ctrlKey&&!O.metaKey&&!O.altKey&&(O.preventDefault(),zn(p.focus.row,p.focus.column,O.key))},ui=(O,_)=>{let x=$r.current;if(x===null)return null;let K=x.getBoundingClientRect(),ue=O-K.left+x.scrollLeft,We=_-K.top+x.scrollTop;if(ue<0||We<0)return null;let Ne=Hn(Math.floor(We/et)+1,1,Y.maxRows),Qe=Us(ut.starts,ue);return{row:Ne,column:Qe}},Rh=O=>{let _=O.target;if(_ instanceof HTMLElement&&(_.closest("input")!==null||_.closest(".art-sheet-resize")!==null))return;let x=ui(O.clientX,O.clientY);x!==null&&(O.currentTarget.focus(),m(null),dh(x.row,x.column,O.shiftKey),Ur.current=!0,O.currentTarget.setPointerCapture(O.pointerId))},Nh=O=>{if(!Ur.current)return;let _=ui(O.clientX,O.clientY);_!==null&&d({anchor:p.anchor,focus:{row:_.row,column:_.column}})},Ah=O=>{Ur.current=!1,O.currentTarget.hasPointerCapture(O.pointerId)&&O.currentTarget.releasePointerCapture(O.pointerId)},Th=(O,_)=>{if(!y)return;O.preventDefault(),O.stopPropagation();let x=O.clientX,K=ut.widths[_]??Yr,ue=Ne=>{let Qe=Hn(K+(Ne.clientX-x),Y.minColumnWidth,Y.maxColumnWidth);Be({column:_,width:Qe})},We=Ne=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",We);let Qe=Hn(K+(Ne.clientX-x),Y.minColumnWidth,Y.maxColumnWidth);Be(null);let Tr=l;ar(_h=>jg(_h,Tr,_,Qe))};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",We)},ur=(0,Z.useMemo)(()=>{if(Wt===null)return ut;let O=ut.widths.slice();O[Wt.column]=Wt.width;let _=[],x=0;for(let K of O)_.push(x),x+=K;return _.push(x),{widths:O,starts:_,total:x}},[ut,Wt]),Oh=()=>{if(c===null||!y)return;let O=Qg(c);ar(_=>Xg(_,O)),f(c.sheets.length)},Vs=O=>{if(c===null||!y)return;let _=c.sheets[O];_!==void 0&&xe({index:O,text:_.name})},Gs=()=>{if(Fe===null||c===null)return;let O=Fe.text.trim(),_=Fe.index;xe(null),!(O===""||O===c.sheets[_]?.name)&&ar(x=>Zg(x,_,O))},Ih=()=>{if(c===null||c.sheets.length<=1)return;let O=l;bt(!1),ar(_=>Jg(_,O)),f(Math.max(0,O-1))},Mh=()=>{let O=$r.current;O!==null&&R({top:O.scrollTop,left:O.scrollLeft})},qs=Math.max(0,Math.floor(v.top/et)-1),Hs=Math.min(Y.maxRows-1,Math.ceil((v.top+N.height)/et)+1),zs=Math.max(0,Us(ur.starts,v.left)-1),Ys=Math.min(Y.maxColumns-1,Us(ur.starts,v.left+N.width)+1),$s=ur.total,Ks=Y.maxRows*et,Xs=[];for(let O=qs;O<=Hs;O+=1)for(let _=zs;_<=Ys;_+=1){let x=Le(O+1,_),K=De?.cells[x],ue=De===void 0||Lt===null?void 0:Lt.results[De.name]?.[x],We=ue?.display??"",Ne=K?.style,Qe={left:ur.starts[_]??0,top:O*et,width:ur.widths[_]??Yr,height:et},Tr=Nr(Ne);Tr!==void 0&&(Qe.color=Tr),Ne?.background!==void 0&&(Qe.background=Ne.background),Ne?.bold===!0&&(Qe.fontWeight=600),Ne?.italic===!0&&(Qe.fontStyle="italic"),(Ne?.underline===!0||Ne?.strike===!0)&&(Qe.textDecoration=(Ne.underline===!0?"underline ":"")+(Ne.strike===!0?"line-through":"")),Ne?.align!==void 0?Qe.textAlign=Ne.align:typeof ue?.value=="number"&&(Qe.textAlign="right"),Xs.push((0,P.jsx)("div",{className:"art-sheet-cell",style:Qe,role:"gridcell","aria-rowindex":O+1,"aria-colindex":_+1,"data-cell":x,children:We},x))}let Qs=[];for(let O=zs;O<=Ys;O+=1){let _=O>=Re.column1&&O<=Re.column2;Qs.push((0,P.jsxs)("div",{className:"art-sheet-colhead","data-active":_?"true":void 0,style:{left:ur.starts[O]??0,width:ur.widths[O]??Yr},children:[(0,P.jsx)("button",{type:"button",className:"art-sheet-headbutton","aria-label":n("sheet.selectColumn",{name:Sr(O)}),onClick:()=>d({anchor:{row:1,column:O},focus:{row:Y.maxRows,column:O}}),children:Sr(O)}),y?(0,P.jsx)("span",{className:"art-sheet-resize",role:"separator","aria-orientation":"vertical",onPointerDown:x=>Th(x,O)}):null]},O))}let Zs=[];for(let O=qs;O<=Hs;O+=1){let _=O+1>=Re.row1&&O+1<=Re.row2;Zs.push((0,P.jsx)("div",{className:"art-sheet-rowhead","data-active":_?"true":void 0,style:{top:O*et,height:et},children:(0,P.jsx)("button",{type:"button",className:"art-sheet-headbutton","aria-label":n("sheet.selectRow",{row:O+1}),onClick:()=>d({anchor:{row:O+1,column:0},focus:{row:O+1,column:Y.maxColumns-1}}),children:O+1})},O))}let Ch=ev.map(O=>({id:O,label:n(ah[O])})),wh=[{id:"rename",label:n("sheet.renameSheet")},{id:"delete",label:n("sheet.deleteSheet"),danger:!0,disabled:c===null||c.sheets.length<=1}],Kn=h===null?void 0:De?.cells[Le(h.row,h.column)]?.style;return(0,P.jsxs)("div",{className:"art-sheet-editor",style:nt,children:[(0,P.jsxs)("div",{className:"art-sheet-toolbar",role:"toolbar","aria-label":n("sheet.toolbar"),children:[(0,P.jsxs)("div",{className:"art-sheet-formula",children:[(0,P.jsx)("span",{className:"art-sheet-ref",title:n("sheet.selection"),children:yn}),(0,P.jsx)("input",{className:"art-sheet-formula-input","aria-label":n("sheet.formulaBar"),value:h===null?E:h.draft,readOnly:!y,spellCheck:!1,onChange:O=>{y&&m(h===null?{row:p.focus.row,column:p.focus.column,draft:O.target.value,initial:E}:{...h,draft:O.target.value})},onKeyDown:O=>{O.key==="Enter"?(O.preventDefault(),Xr("down")):O.key==="Escape"?(O.preventDefault(),Bs()):O.key==="Tab"&&(O.preventDefault(),Xr("right"))},onBlur:()=>{h!==null&&Xr(null)}})]}),(0,P.jsxs)("div",{className:"art-sheet-formatbar",children:[(0,P.jsx)(Te.Tooltip,{label:n("sheet.undo"),side:"bottom",portal:!0,children:(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool","aria-label":n("sheet.undo"),disabled:!y||!G,onClick:Ds,children:(0,P.jsx)(rh,{size:16})})}),(0,P.jsx)(Te.Tooltip,{label:n("sheet.redo"),side:"bottom",portal:!0,children:(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool","aria-label":n("sheet.redo"),disabled:!y||!$,onClick:ai,children:(0,P.jsx)(nh,{size:16})})}),(0,P.jsx)("span",{className:"art-sheet-divider","aria-hidden":"true"}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool art-sheet-tool-text","aria-label":n("sheet.bold"),"aria-pressed":Yn("bold"),disabled:!y,onClick:()=>$n("bold"),children:(0,P.jsx)("span",{style:{fontWeight:700},children:"B"})}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool art-sheet-tool-text","aria-label":n("sheet.italic"),"aria-pressed":Yn("italic"),disabled:!y,onClick:()=>$n("italic"),children:(0,P.jsx)("span",{style:{fontStyle:"italic",fontFamily:"serif"},children:"I"})}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool art-sheet-tool-text","aria-label":n("sheet.underline"),"aria-pressed":Yn("underline"),disabled:!y,onClick:()=>$n("underline"),children:(0,P.jsx)("span",{style:{textDecoration:"underline"},children:"U"})}),(0,P.jsx)("span",{className:"art-sheet-divider","aria-hidden":"true"}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool","aria-label":n("sheet.alignLeft"),"aria-pressed":rt?.align==="left",disabled:!y,onClick:()=>Pr({align:"left"}),children:(0,P.jsx)(Ps,{align:"left"})}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool","aria-label":n("sheet.alignCenter"),"aria-pressed":rt?.align==="center",disabled:!y,onClick:()=>Pr({align:"center"}),children:(0,P.jsx)(Ps,{align:"center"})}),(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool","aria-label":n("sheet.alignRight"),"aria-pressed":rt?.align==="right",disabled:!y,onClick:()=>Pr({align:"right"}),children:(0,P.jsx)(Ps,{align:"right"})}),(0,P.jsx)("span",{className:"art-sheet-divider","aria-hidden":"true"}),(0,P.jsx)(Te.Menu,{open:he,onClose:()=>Ge(!1),items:Ch,onSelect:O=>{Ge(!1),Pr({numberFormat:O==="general"?null:O})},align:"start",portal:!0,autoFocus:!0,anchor:(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tool art-sheet-format-label","aria-label":n("sheet.numberFormat"),"aria-haspopup":"menu","aria-expanded":he,disabled:!y,onClick:()=>Ge(O=>!O),children:n(ah[rt?.numberFormat??"general"])})}),(0,P.jsxs)("label",{className:"art-sheet-color",title:n("sheet.fillColor"),children:[(0,P.jsx)("input",{type:"color","aria-label":n("sheet.fillColor"),value:rt?.background??"#ffffff",disabled:!y,onChange:O=>Pr({background:O.target.value})}),(0,P.jsx)("span",{className:"art-sheet-color-swatch",style:{background:rt?.background??"transparent"},"aria-hidden":"true"})]}),(0,P.jsxs)("label",{className:"art-sheet-color",title:n("sheet.textColor"),children:[(0,P.jsx)("input",{type:"color","aria-label":n("sheet.textColor"),value:rt?.color??"#1f2933",disabled:!y,onChange:O=>Pr({color:O.target.value})}),(0,P.jsx)("span",{className:"art-sheet-color-swatch art-sheet-color-letter",style:{color:rt?.color,background:rt?.color===void 0?void 0:jn(rt.color)},"aria-hidden":"true",children:"A"})]})]})]}),i!==null?(0,P.jsxs)("div",{className:"art-sheet-error",role:"alert",children:[(0,P.jsx)("p",{children:n("sheet.invalid")}),(0,P.jsx)("p",{className:"art-sheet-error-detail",children:i})]}):null,(0,P.jsxs)("div",{className:"art-sheet-gridwrap",ref:xt,children:[(0,P.jsx)("div",{className:"art-sheet-corner","aria-hidden":"true"}),(0,P.jsx)("div",{className:"art-sheet-colheads","aria-hidden":"true",children:(0,P.jsx)("div",{className:"art-sheet-colheads-inner",style:{width:$s,transform:"translateX("+String(-v.left)+"px)"},children:Qs})}),(0,P.jsx)("div",{className:"art-sheet-rowheads","aria-hidden":"true",children:(0,P.jsx)("div",{className:"art-sheet-rowheads-inner",style:{height:Ks,transform:"translateY("+String(-v.top)+"px)"},children:Zs})}),(0,P.jsx)("div",{className:"art-sheet-scroll",ref:$r,role:"grid",tabIndex:0,"aria-label":t.label,"aria-rowcount":Y.maxRows,"aria-colcount":Y.maxColumns,onScroll:Mh,onKeyDown:yh,onPointerDown:Rh,onPointerMove:Nh,onPointerUp:Ah,onDoubleClick:O=>{let _=ui(O.clientX,O.clientY);_!==null&&y&&zn(_.row,_.column)},onCopy:mh,onCut:gh,onPaste:vh,children:(0,P.jsxs)("div",{className:"art-sheet-canvas",style:{width:$s,height:Ks},children:[Xs,(0,P.jsx)("div",{className:"art-sheet-selected",style:Ar,"aria-hidden":"true"}),(0,P.jsx)("div",{className:"art-sheet-active",style:ii,"aria-hidden":"true"}),h===null?null:(0,P.jsx)("input",{ref:Rr,className:"art-sheet-cell-input","aria-label":n("sheet.editCell",{ref:Le(h.row,h.column)}),style:{left:ur.starts[h.column]??0,top:(h.row-1)*et,width:ur.widths[h.column]??Yr,height:et,fontWeight:Kn?.bold===!0?600:void 0,fontStyle:Kn?.italic===!0?"italic":void 0,background:Kn?.background,color:Nr(Kn)},value:h.draft,spellCheck:!1,onChange:O=>m({...h,draft:O.target.value}),onKeyDown:O=>{O.key==="Enter"?(O.preventDefault(),Xr(O.shiftKey?"up":"down")):O.key==="Tab"?(O.preventDefault(),Xr(O.shiftKey?"left":"right")):O.key==="Escape"&&(O.preventDefault(),Bs())},onBlur:()=>{h!==null&&Xr(null)}})]})})]}),(0,P.jsxs)("div",{className:"art-sheet-tabs",children:[(0,P.jsx)("div",{className:"art-sheet-tablist",role:"tablist","aria-label":n("sheet.sheets"),children:(c?.sheets??[]).map((O,_)=>(0,P.jsx)("div",{className:"art-sheet-tab",children:Fe!==null&&Fe.index===_?(0,P.jsx)("input",{className:"art-sheet-tab-input","aria-label":n("sheet.sheetName"),value:Fe.text,autoFocus:!0,onChange:x=>xe({index:_,text:x.target.value}),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),Gs()):x.key==="Escape"&&(x.preventDefault(),xe(null))},onBlur:Gs}):(0,P.jsx)("button",{type:"button",role:"tab",className:"art-sheet-tab-button","aria-selected":_===l,onClick:()=>f(_),onDoubleClick:()=>Vs(_),children:O.name})},O.name+":"+String(_)))}),y?(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-add","aria-label":n("sheet.addSheet"),onClick:Oh,children:(0,P.jsx)(Te.IconPlusOutlineRegular,{size:16})}):null,y?(0,P.jsx)(Te.Menu,{open:Xe,onClose:()=>tt(!1),items:wh,onSelect:O=>{tt(!1),O==="rename"?Vs(l):O==="delete"&&bt(!0)},side:"top",align:"end",portal:!0,autoFocus:!0,anchor:(0,P.jsx)(Te.Button,{size:"sm",variant:"ghost",className:"art-sheet-tab-more","aria-label":n("sheet.sheetActions"),"aria-haspopup":"menu","aria-expanded":Xe,onClick:()=>tt(O=>!O),children:(0,P.jsx)(Te.IconEllipsisOutlineRegular,{size:16})})}):null]}),(0,P.jsx)(Te.Modal,{open:kt,onClose:()=>bt(!1),title:n("sheet.deleteSheet"),closeLabel:n("sheet.cancel"),description:n("sheet.deleteConfirm",{name:c?.sheets[l]?.name??""}),footer:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Te.Button,{variant:"outline",onClick:()=>bt(!1),children:n("sheet.cancel")}),(0,P.jsx)(Te.Button,{variant:"primary",onClick:Ih,children:n("sheet.delete")})]})})]})}function tv(t){let e,r=(0,hh.createRoot)(t.element);return r.render((0,fh.createElement)(lh,{options:t,register:n=>{e=n}})),{getJson:()=>e===void 0?t.content:e.getJson(),setContent:n=>e?.setContent(n),setEditable:n=>e?.setEditable(n),setAppearance:(n,o)=>e?.setAppearance(n,o),destroy:()=>{try{r.unmount()}catch{}}}}
215
+
216
+ return module.exports;
217
+ },
218
+ });