"use strict";var js=Object.defineProperty;var ea=(t,e,n)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var U=(t,e,n)=>(ea(t,typeof e!="symbol"?e+"":e,n),n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var Ve;(function(t){t.CELL_CLICK="CELL_CLICK",t.SELECTION_CHANGE="CHANGE_SELECTION",t.CELL_CHANGE="CELL_CHANGE",t.COPY_CELLS="COPY_CELLS"})(Ve||(Ve={}));class ta{constructor(e){U(this,"root");U(this,"cellClick",(e,n)=>{var p,u;if(e.button!==0)return;const{offsetX:r,offsetY:i}=e,a=this.root.getCellByCoords(r,i),c=this.root.getCell(a),h=new Hn;h.selectedCell=a,h.selectedRange={from:a,to:a},n.setSelectingMode(!0),this.changeSelection(h,!0),(u=(p=this.root.config).onCellClick)==null||u.call(p,e,c)});U(this,"changeSelection",(e,n=!1)=>{var r,i;this.root.selection=e,n&&((i=(r=this.root.config).onSelectonChange)==null||i.call(r,e)),this.root.renderSheet(),this.root.renderColumnsBar(),this.root.renderRowsBar()});U(this,"copy",(e,n,r)=>{var i,a;(a=(i=this.root.config).onCopy)==null||a.call(i,e,n,r)});this.root=e}async dispatch(e){switch(e.type){case Ve.CELL_CLICK:{const{event:n,scroller:r}=e;this.cellClick(n,r);break}case Ve.SELECTION_CHANGE:{const{selection:n,enableCallback:r}=e;this.changeSelection(n,r);break}case Ve.CELL_CHANGE:{const{cell:n,enableCallback:r}=e;if(n.value.substring(0,1).startsWith("="))try{await n.evalFormula(this.root.formulaParser),n.displayValue=n.resultValue,this.root.renderCell(n.position.row,n.position.column),this.changeCellValues(n,r);return}catch(i){console.error(i)}this.root.renderCell(n.position.row,n.position.column),this.changeCellValues(n,r);break}case Ve.COPY_CELLS:{const{data:n,dataAsString:r,range:i}=e;this.copy(i,n,r);break}}}changeCellValues(e,n=!0){var r,i;n&&((i=(r=this.root.config).onCellChange)==null||i.call(r,e))}}class kt{constructor(e,n){U(this,"x");U(this,"y");U(this,"width");U(this,"height");this.x=this.getXCoord(n.column,e),this.y=this.getYCoord(n.row,e),this.width=e.columns[n.column].width,this.height=e.rows[n.row].height}getXCoord(e,n){let r=0;for(let i=0;i{const{key:n}=e;switch(n){case"Escape":{this.hide();break}case"Enter":{if(!this.root.selection.selectedCell)return;this.root.changeCellValues(this.root.selection.selectedCell,{value:this.element.value,displayValue:this.element.value}),this.root.events.dispatch({type:Ve.CELL_CHANGE,cell:this.root.getCell(this.root.selection.selectedCell)}),this.hide(),this.root.renderSelection()}}});U(this,"handleClickOutside",e=>{const n=e.target;this.element.contains(n)||this.hide()});this.root=e;const n=document.createElement("input");n.classList.add(Ft+"editor"),this.element=n,this.hide()}hide(){this.element.style.display="none",this.element.classList.add("hide"),this.element.blur(),window.removeEventListener("click",this.handleClickOutside),this.element.removeEventListener("keydown",this.handleKeydown),this.root.focusTable()}show(e,n){const{height:r,width:i,x:a,y:c}=new kt(this.root.config,e),h=this.root.getCell(e);this.element.classList.remove("hide"),this.element.style.top=c-this.root.viewport.top+this.root.columnsBarHeight+"px",this.element.style.left=a-this.root.viewport.left+this.root.rowsBarWidth+"px",this.element.style.width=i+"px",this.element.style.height=r+"px",this.element.style.display="block",window.addEventListener("click",this.handleClickOutside),this.element.addEventListener("keydown",this.handleKeydown),this.element.value=n||h.value,this.element.focus(),n||this.element.select()}}function ci(t,e){return t.column===e.column&&t.row===e.row}class ra{constructor(e){U(this,"element");U(this,"verticalScroller");U(this,"horizontalScroller");U(this,"root");U(this,"isSelecting",!1);U(this,"handleMouseMove",e=>{if(!this.isSelecting)return;const{offsetX:n,offsetY:r}=e,i=this.root.getCellByCoords(n,r);let a=!1;this.root.selection.selectedRange&&(a=!ci(this.root.selection.selectedRange.to,i),a&&(this.root.selection.selectedRange.to=i,this.root.events.dispatch({type:Ve.SELECTION_CHANGE,selection:this.root.selection,enableCallback:!0})))});U(this,"handleMouseUp",()=>{this.isSelecting=!1;const e={...this.root.selection};this.root.selection.selectedRange&&ci(this.root.selection.selectedRange.from,this.root.selection.selectedRange.to)&&(e.selectedRange=null,this.root.events.dispatch({type:Ve.SELECTION_CHANGE,selection:e,enableCallback:!1})),this.root.renderSheet(),this.root.renderColumnsBar(),this.root.renderRowsBar()});U(this,"handleDoubleClick",e=>{e.preventDefault();const n=this.root.getCellByCoords(e.offsetX,e.offsetY);this.root.showEditor(n)});U(this,"handleKeydown",e=>{if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)){switch(e.preventDefault(),this.root.selection.selectedRange=null,e.key){case"ArrowLeft":{this.root.selection.selectedCell&&this.root.selection.selectedCell.column>0&&(this.root.selection.selectedCell.column-=1);break}case"ArrowRight":{this.root.selection.selectedCell&&this.root.selection.selectedCell.column0&&(this.root.selection.selectedCell.row-=1);break}case"ArrowDown":{this.root.selection.selectedCell&&this.root.selection.selectedCell.rowu.slice(a.column,c.column+1))]}else if(this.root.selection.selectedCell){const{column:a,row:c}=this.root.selection.selectedCell;r=[[this.root.data[c][a]]],i.selectedRange={from:this.root.selection.selectedCell,to:this.root.selection.selectedCell}}else return;this.root.clipboard.copy(r,i.selectedRange);return}e.code}});U(this,"handleClick",e=>{this.root.events.dispatch({type:Ve.CELL_CLICK,event:e,scroller:this})});U(this,"handleScroll",()=>{const e=this.getViewportBoundlingRect();this.root.viewport.updateValues(e),this.root.renderSheet(),this.root.renderColumnsBar(),this.root.renderRowsBar()});this.root=e;const{horizontalScroller:n,scroller:r,verticalScroller:i}=this.buildComponent();this.element=r,this.verticalScroller=i,this.horizontalScroller=n,this.element.style.height=this.root.config.view.height+"px",this.element.style.width=this.root.config.view.width+"px",this.element.style.top=this.root.columnsBarHeight+"px",this.element.style.left=this.root.rowsBarWidth+"px",this.element.tabIndex=-1,this.updateScrollerSize(),this.element.addEventListener("scroll",this.handleScroll),this.element.addEventListener("mousedown",this.handleClick),this.element.addEventListener("mousemove",this.handleMouseMove),this.element.addEventListener("mouseup",this.handleMouseUp),this.element.addEventListener("dblclick",this.handleDoubleClick),this.element.addEventListener("keydown",this.handleKeydown),this.element.addEventListener("paste",a=>{this.root.selection.selectedCell&&this.root.clipboard.paste(this.root,this.root.selection.selectedCell,a)})}setSelectingMode(e){this.isSelecting=e}getViewportBoundlingRect(){const{scrollTop:e,scrollLeft:n}=this.element,{height:r,width:i}=this.element.getBoundingClientRect(),a=e+r,c=n+i;return{top:e,left:n,bottom:a,right:c}}buildComponent(){const e=document.createElement("div"),n=document.createElement("div"),r=document.createElement("div"),i=document.createElement("div"),a=document.createElement("div");return n.style.width="0px",n.style.pointerEvents="none",r.style.pointerEvents="none",i.style.display="flex",a.appendChild(n),a.appendChild(r),i.appendChild(a),this.verticalScroller=n,this.horizontalScroller=r,e.appendChild(i),e.contentEditable="false",e.classList.add(Ft+"scroller"),{scroller:e,verticalScroller:n,horizontalScroller:r}}getActualHeight(){return this.root.config.rows.reduce((e,n)=>(e+=n.height,e),0)}getActualWidth(){return this.root.config.columns.reduce((e,n)=>(e+=n.width,e),0)}updateScrollerSize(){const e=this.getActualHeight(),n=this.getActualWidth();this.setScrollerHeight(e),this.setScrollerWidth(n)}setScrollerHeight(e){this.verticalScroller.style.height=e+"px"}setScrollerWidth(e){this.horizontalScroller.style.width=e+"px"}}class Vr{constructor(e){U(this,"fontSize",16);U(this,"fontColor","black");U(this,"background","white");U(this,"borderColor","black");U(this,"selectedBackground","#4287f5");U(this,"selectedFontColor","#ffffff");e&&Object.assign(this,e)}}class Ro{constructor(e,n){U(this,"row");U(this,"column");this.row=e,this.column=n}}class No{constructor(e){U(this,"value");U(this,"displayValue");U(this,"resultValue");U(this,"position");U(this,"style");this.value=e.value,this.displayValue=e.displayValue,this.resultValue=e.resultValue,this.position=e.position,this.style=e.style}}let $n=class{constructor(e){U(this,"value");U(this,"displayValue");U(this,"resultValue");U(this,"position");U(this,"style",null);U(this,"cellsDependsOnThisCell",[]);U(this,"dependedFromCells",[]);this.value=e.value,this.displayValue=e.displayValue,this.resultValue=e.resultValue,this.position=e.position,this.style=e.style}getSerializableCell(){return new No({displayValue:this.displayValue,position:this.position,resultValue:this.resultValue,style:this.style,value:this.value})}changeStyles(e){this.style=e}changeValues(e){Object.assign(this,e)}evalFormula(e){this.value.substring(0,1)==="="&&(this.resultValue=e.parser.parse(this.value.slice(1),{col:this.position.column,row:this.position.row}))}render(e){const n=new kt(e.config,this.position);let{x:r,y:i}=n;const{height:a,width:c}=n,{ctx:h}=e;i-=e.viewport.top,r-=e.viewport.left;const p=this.style??e.styles.cells;h.clearRect(r,i,c,a),h.fillStyle=p.background,h.strokeStyle="black",h.fillRect(r,i,c-1,a-1),h.strokeRect(r,i,c,a),h.fillStyle=p.fontColor,h.textAlign="left",h.font=`${p.fontSize}px Arial`,h.textBaseline="middle",h.fillText(this.displayValue,r+2,i+a/2)}},ia=class{constructor(e){U(this,"element");U(this,"ctx");U(this,"root");this.root=e;const n=document.createElement("canvas");n.classList.add(Ft+"sheet"),n.height=this.root.config.view.height,n.width=this.root.config.view.width,n.style.width=this.root.config.view.width+"px",n.style.height=this.root.config.view.height+"px",n.style.left="0px",this.element=n;const r=this.element.getContext("2d");if(!r)throw new Error("Enable hardware acceleration");this.ctx=r}getCellByCoords(e,n){let r=0,i=0;for(;i<=n&&(i+=this.root.config.rows[r].height,!(i>=n));)r++;let a=0,c=0;for(;c<=e&&(c+=this.root.config.columns[a].width,!(c>=e));)a++;return new Ro(r,a)}renderCell(e){const{column:n,row:r}=e;this.root.data[r][n].render(this.root)}getSelectionRange(){const{selectedCell:e,selectedRange:n}=this.root.selection;if(!(!e&&!n)){if(n){const r=Math.min(n.from.row,n.to.row),i=Math.min(n.from.column,n.to.column),a=Math.max(n.from.row,n.to.row),c=Math.max(n.from.column,n.to.column),h=new kt(this.root.config,{row:r,column:i});let p=0;for(let l=i;l<=c;l++)p+=this.root.config.columns[l].width;let u=0;for(let l=r;l<=a;l++)u+=this.root.config.rows[l].height;const o=h.x-this.root.viewport.left,s=h.y-this.root.viewport.top;return{x:o,y:s,height:u,width:p}}if(!n&&e){const r=new kt(this.root.config,e);return r.x-=this.root.viewport.left,r.y-=this.root.viewport.top,r}}}renderSelectionRange(e,n,r,i){this.ctx.save(),this.ctx.strokeStyle="#7da8ff",this.ctx.lineWidth=3,this.ctx.strokeRect(e,n,r,i),this.ctx.fillStyle="#7da8ff35",this.ctx.fillRect(e,n,r,i),this.ctx.restore()}renderSelection(){const e=this.getSelectionRange();if(!e)return;const{height:n,width:r,x:i,y:a}=e;this.renderSelectionRange(i,a,r,n)}renderSheet(){const e=this.root.viewport.firstRow,n=this.root.viewport.lastCol+3,r=this.root.viewport.lastRow+3,i=this.root.viewport.firstCol;for(let a=e;a<=r;a++)for(let c=i;c<=n&&!(!this.root.config.columns[c]||!this.root.config.rows[a]);c++)this.renderCell({column:c,row:a});this.renderSelection()}};class oa{constructor(e){U(this,"element");U(this,"root");this.root=e;const n=document.createElement("div");n.classList.add(Ft+"spreadsheet_container"),this.element=n,this.changeElementSizes(this.root.viewProps)}changeElementSizes(e){const{height:n,width:r}=e;this.element.style.width=r+this.root.rowsBarWidth+"px",this.element.style.height=n+this.root.columnsBarHeight+"px"}}class sa{constructor(e){U(this,"element");U(this,"root");U(this,"height",0);this.root=e;const n=document.createElement("div");n.classList.add(Ft+"toolbar"),this.element=n}}class Ln{constructor(e){U(this,"rows");U(this,"columns");U(this,"view",{width:800,height:600});U(this,"onCellClick",null);U(this,"onSelectonChange",null);U(this,"onCellChange",null);U(this,"onCopy");this.columns=e.columns,this.rows=e.rows,this.view=e.view,this.onCellClick=e.onCellClick??null,this.onSelectonChange=e.onSelectionChange??null,this.onCellChange=e.onCellChange??null,this.onCopy=e.onCopy??null}}class Hn{constructor(){U(this,"selectedCell",null);U(this,"selectedRange",null)}}class Ao{constructor(){U(this,"cells");this.cells=new Vr}}class Ur{constructor(e,n){U(this,"root");U(this,"top");U(this,"left");U(this,"right");U(this,"bottom");U(this,"firstRow");U(this,"lastRow");U(this,"firstCol");U(this,"lastCol");this.root=e,this.top=n.top,this.left=n.left,this.right=n.right,this.bottom=n.bottom,this.firstRow=this.getFirstRow(),this.lastCol=this.getFirstRow();//!Temp this.firstCol=this.getFirstRow();//!Temp this.lastRow=this.getLastRow(),this.updateValues({top:0,left:0,right:this.root.viewProps.width,bottom:this.root.viewProps.height})}updateValues(e){this.top=e.top,this.left=e.left,this.right=e.right,this.bottom=e.bottom,this.firstRow=this.getFirstRow(),this.lastRow=this.getLastRow(),this.firstCol=this.getFirstCol(),this.lastCol=this.getLastCol()}getFirstRow(){return this.root.cache.getRowByYCoord(this.top)}getLastRow(){return this.root.cache.getRowByYCoord(this.bottom)}getFirstCol(){return this.root.cache.getColumnByXCoord(this.left)}getLastCol(){return this.root.cache.getColumnByXCoord(this.right)}}let Gr=class{constructor(e){U(this,"width");U(this,"title");this.width=e.width,this.title=e.title}};class $r{constructor(e){U(this,"height");U(this,"title");this.height=e.height,this.title=e.title}}function Hr(t,e,n=!1){const r=[];for(let i=0;i<=t;i++){const a=[];for(let c=0;c<=e;c++){const h=n?`${i}:${c}`:"",p=new $n({displayValue:h,resultValue:h,value:h,position:{column:c,row:i},style:null});a.push(p)}r.push(a)}return r}function yo(t,e){const n=[];for(let a=0;a<=t;a++){const c=new $r({height:40,title:String(a)});n.push(c)}const r=[];for(let a=0;a<=e;a++){const c=new Gr({title:String(a),width:150});r.push(c)}return new Ln({columns:r,rows:n,view:{height:600,width:800}})}function aa(t,e){const n=Hr(t,e),r=yo(t,e);return{data:n,config:r}}class To{constructor(e){U(this,"xPos");U(this,"colIdx");this.xPos=e.xPos,this.colIdx=e.colIdx}}class wo{constructor(e){U(this,"yPos");U(this,"rowIdx");this.yPos=e.yPos,this.rowIdx=e.rowIdx}}class Co{constructor(e){U(this,"columns");U(this,"rows");this.columns=e.columns,this.rows=e.rows}getRowByYCoord(e){let n=0;for(let r=0;r=Math.min(r.from.column,r.to.column)&&e<=Math.max(r.from.column,r.to.column):!1}renderText(e,n){const{width:r,x:i}=n;this.ctx.fillStyle="black",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.font="12px Arial",this.ctx.fillText(this.root.config.columns[e].title,i+r/2-this.root.viewport.left,0+this.height/2)}renderRect(e,n){const{width:r,x:i}=n,a=this.isColumnSelected(e);this.ctx.fillStyle=a?"#c7ebff":"white",this.ctx.strokeStyle="black",this.ctx.lineWidth=1;const c=i-this.root.viewport.left;this.ctx.fillRect(c-1,0,r,this.height),this.ctx.strokeRect(c-1,0,r,this.height)}renderSingleColumn(e){const n=new kt(this.root.config,{row:0,column:e});this.renderRect(e,n),this.renderText(e,n)}renderBar(){const e=this.root.viewport.lastCol+3,n=this.root.viewport.firstCol;this.ctx.beginPath(),this.ctx.strokeStyle="black",this.ctx.lineWidth=1,this.ctx.moveTo(0,0),this.ctx.lineTo(0,this.height),this.ctx.closePath(),this.ctx.stroke();for(let r=n;r<=e&&this.root.config.columns[r];r++)this.renderSingleColumn(r)}}class la{constructor(e){U(this,"element");U(this,"ctx");U(this,"root");U(this,"width",35);U(this,"height");U(this,"resizerHeight",1);this.root=e,this.element=this.createElement();const n=this.element.getContext("2d");if(!n)throw new Error("Enable hardware acceleration");this.ctx=n,this.height=this.root.viewProps.height}createElement(){const e=document.createElement("canvas");return e.style.position="absolute",e.style.height=this.root.viewProps.height+"px",e.style.width=this.width+"px",e.style.display="block",e.style.borderTop="1px solid black",e.width=this.width,e.height=this.root.viewProps.height,e}setElementPosition(e,n){this.element.style.top=e+"px",this.element.style.left=n+"px"}isRowSelected(e){const{selectedCell:n,selectedRange:r}=this.root.selection;return n&&n.row===e?!0:r?e>=Math.min(r.from.row,r.to.row)&&e<=Math.max(r.from.row,r.to.row):!1}renderText(e,n){const{y:r,height:i}=n;this.ctx.fillStyle="black",this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.font="12px Arial",this.ctx.fillText(this.root.config.rows[e].title,this.width/2,r-this.root.viewport.top+i/2)}renderRect(e,n){const{y:r,height:i}=n,a=this.isRowSelected(e);this.ctx.fillStyle=a?"#c7ebff":"white",this.ctx.strokeStyle="black",this.ctx.lineWidth=this.resizerHeight;const c=r-this.root.viewport.top;this.ctx.fillRect(0,c-1,this.width,i),this.ctx.strokeRect(0,c-1,this.width,i)}renderSingleRow(e){const n=new kt(this.root.config,{column:0,row:e});this.renderRect(e,n),this.renderText(e,n)}renderBar(){const e=this.root.viewport.lastRow+3,n=this.root.viewport.firstRow;this.ctx.beginPath(),this.ctx.moveTo(0,0),this.ctx.strokeStyle="black",this.ctx.lineWidth=16,this.ctx.lineTo(35,0),this.ctx.closePath(),this.ctx.stroke();for(let r=n;r<=e&&this.root.config.rows[r];r++)this.renderSingleRow(r)}}class ua{constructor(e){U(this,"saved",null);U(this,"root");this.root=e}copy(e,n){const r=e.map(i=>i.map(a=>a.displayValue).join(" ")).join(` `);this.saved=e,navigator.clipboard.writeText(r),this.root.events.dispatch({type:Ve.COPY_CELLS,data:e,dataAsString:r,range:n})}paste(e,{column:n,row:r},i){if(!this.saved){if(!i.clipboardData)return;const h=i.clipboardData.getData("text");try{const u=h.split(` `).map(l=>l.split(" ")).map(l=>l.map(f=>{const v={displayValue:f,position:{column:n,row:r},resultValue:f,style:new Vr,value:f};return new $n(v)})),o=u.length,s=u[0]?u[0].length:0;for(let l=0;l{i[n[o]]=o});class a{constructor(){this.Types=n,this.type2Number={number:n.NUMBER,boolean:n.BOOLEAN,string:n.STRING,object:-1}}checkFunctionResult(s){if(typeof s==="number"){if(isNaN(s))return t.VALUE;if(!isFinite(s))return t.NUM}return s??t.NULL}flattenDeep(s){return s.reduce((l,f)=>Array.isArray(f)?l.concat(this.flattenDeep(f)):l.concat(f),[])}acceptNumber(s,l=!0,f=!0){if(s instanceof t)return s;let v;if(typeof s=="number")v=s;else if(typeof s=="boolean")if(f)v=Number(s);else throw t.VALUE;else if(typeof s=="string"){if(s.length===0||(v=Number(s),v!==v))throw t.VALUE}else if(Array.isArray(s))if(l)v=this.acceptNumber(s[0][0]);else if(s[0].length===1)v=this.acceptNumber(s[0][0]);else throw t.VALUE;else throw Error("Unknown type in FormulaHelpers.acceptNumber");return v}flattenParams(s,l,f,v,d=null,g=1){if(s.length{const{isCellRef:A,isRangeRef:m,isArray:N}=E,y=E.value instanceof e,R=!A&&!m&&!N&&!y,T={isLiteral:R,isCellRef:A,isRangeRef:m,isArray:N,isUnion:y};if(R)E.omitted?E=d:E=this.accept(E,l,d),v(E,T);else if(A)v(E.value,T);else if(y){if(!f)throw t.VALUE;E=E.value.data,E=this.flattenDeep(E),E.forEach(w=>{v(w,T)})}else(m||N)&&(E=this.flattenDeep(E.value),E.forEach(w=>{v(w,T)}))})}accept(s,l=null,f,v=!0,d=!1){if(Array.isArray(l)&&(l=l[0]),s==null&&f===void 0)throw t.ARG_MISSING([l]);if(s==null)return f;if(typeof s!="object"||Array.isArray(s))return s;const g=s.isArray;if(s.value!=null&&(s=s.value),l==null)return s;if(s instanceof t)throw s;if(l===n.ARRAY){if(Array.isArray(s))return v?this.flattenDeep(s):s;if(s instanceof e)throw t.VALUE;if(d)return v?[s]:[[s]];throw t.VALUE}else if(l===n.COLLECTIONS)return s;g&&(s=s[0][0]);const E=this.type(s);if(l===n.STRING)E===n.BOOLEAN?s=s?"TRUE":"FALSE":s=`${s}`;else if(l===n.BOOLEAN){if(E===n.STRING)throw t.VALUE;E===n.NUMBER&&(s=!!s)}else if(l===n.NUMBER)s=this.acceptNumber(s,!1);else if(l===n.NUMBER_NO_BOOLEAN)s=this.acceptNumber(s,!1,!1);else throw t.VALUE;return s}type(s){let l=this.type2Number[typeof s];return l===-1&&(Array.isArray(s)?l=n.ARRAY:s.ref?s.ref.from?l=n.RANGE_REF:l=n.CELL_REF:s instanceof e&&(l=n.COLLECTIONS)),l}isRangeRef(s){return s.ref&&s.ref.from}isCellRef(s){return s.ref&&!s.ref.from}retrieveRanges(s,l,f){return f=u.extend(l,f),l=this.retrieveArg(s,l),l=c.accept(l,n.ARRAY,void 0,!1,!0),f!==l?(f=this.retrieveArg(s,f),f=c.accept(f,n.ARRAY,void 0,!1,!0)):f=l,[l,f]}retrieveArg(s,l){if(l===null)return{value:0,isArray:!1,omitted:!0};const f=s.utils.extractRefValue(l);return{value:f.val,isArray:f.isArray,ref:l.ref}}}const c=new a,h={isWildCard:o=>typeof o=="string"?/[*?]/.test(o):!1,toRegex:(o,s)=>RegExp(o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/([^~]??)[?]/g,"$1.").replace(/([^~]??)[*]/g,"$1.*").replace(/~([?*])/g,"$1"),s)},p={parse:o=>{const s=typeof o;if(s==="string"){const l=o.toUpperCase();if(l==="TRUE"||l==="FALSE")return{op:"=",value:l==="TRUE"};const f=o.match(/(<>|>=|<=|>|<|=)(.*)/);if(f){let v=f[1],d;if(isNaN(f[2])){const g=f[2].toUpperCase();if(g==="TRUE"||g==="FALSE")d=g==="TRUE";else if(/#NULL!|#DIV\/0!|#VALUE!|#NAME\?|#NUM!|#N\/A|#REF!/.test(f[2]))d=new t(f[2]);else if(d=f[2],h.isWildCard(d))return{op:"wc",value:h.toRegex(d),match:v==="="}}else d=Number(f[2]);return{op:v,value:d}}else return h.isWildCard(o)?{op:"wc",value:h.toRegex(o),match:!0}:{op:"=",value:o}}else{if(s==="boolean"||s==="number"||Array.isArray(o)||o instanceof t)return{op:"=",value:o};throw Error(`Criteria.parse: type ${typeof o} not support`)}}},u={columnNumberToName:o=>{let s=o,l="",f=0;for(;s>0;)f=(s-1)%26,l=String.fromCharCode("A".charCodeAt(0)+f)+l,s=Math.floor((s-f)/26);return l},columnNameToNumber:o=>{o=o.toUpperCase();const s=o.length;let l=0;for(let f=0;f{if(s==null)return o;let l,f;if(c.isCellRef(o))l=0,f=0;else if(c.isRangeRef(o))l=o.ref.to.row-o.ref.from.row,f=o.ref.to.col-o.ref.from.col;else throw Error("Address.extend should not reach here.");return c.isCellRef(s)?(l>0||f>0)&&(s={ref:{from:{col:s.ref.col,row:s.ref.row},to:{row:s.ref.row+l,col:s.ref.col+f}}}):(s.ref.to.row=s.ref.from.row+l,s.ref.to.col=s.ref.from.col+f),s}};return cr={FormulaHelpers:c,Types:n,ReversedTypes:i,Factorials:r,WildCard:h,Criteria:p,Address:u},cr}var lr,ui;function he(){if(ui)return lr;ui=1;class t extends Error{constructor(n,r,i){if(super(r),r==null&&i==null&&t.errorMap.has(n))return t.errorMap.get(n);r==null&&i==null?(this._error=n,t.errorMap.set(n,this)):this._error=n,this.details=i}get error(){return this._error}get name(){return this._error}equals(n){return n instanceof t&&n._error===this._error}toString(){return this._error}}return t.errorMap=new Map,t.DIV0=new t("#DIV/0!"),t.NA=new t("#N/A"),t.NAME=new t("#NAME?"),t.NULL=new t("#NULL!"),t.NUM=new t("#NUM!"),t.REF=new t("#REF!"),t.VALUE=new t("#VALUE!"),t.NOT_IMPLEMENTED=e=>new t("#NAME?",`Function ${e} is not implemented.`),t.TOO_MANY_ARGS=e=>new t("#N/A",`Function ${e} has too many arguments.`),t.ARG_MISSING=e=>{const{Types:n}=ge();return new t("#N/A",`Argument type ${e.map(r=>n[r]).join(", ")} is missing.`)},t.ERROR=(e,n)=>new t("#ERROR!",e,n),lr=t,lr}let _e=class{};_e.version="0.10.3";function Vt(t){let e="",n=t.length-1;for(;n>=0;)e+=t.charAt(n--);return e}function ke(t,e){let n="";for(;n.length=e?n:ke("0",e-n.length)+n}function ur(t,e){let n=""+t;return n.length>=e?n:ke(" ",e-n.length)+n}function hn(t,e){let n=""+t;return n.length>=e?n:n+ke(" ",e-n.length)}function da(t,e){let n=""+Math.round(t);return n.length>=e?n:ke("0",e-n.length)+n}function va(t,e){let n=""+t;return n.length>=e?n:ke("0",e-n.length)+n}const fi=Math.pow(2,32);function Gt(t,e){if(t>fi||t<-fi)return da(t,e);const n=Math.round(t);return va(n,e)}function _n(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}const hi=[["Sun","Sunday"],["Mon","Monday"],["Tue","Tuesday"],["Wed","Wednesday"],["Thu","Thursday"],["Fri","Friday"],["Sat","Saturday"]],fr=[["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 Oo(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]='"上午/下午 "hh"時"mm"分"ss"秒 "',t[65535]="General"}const _t={};Oo(_t);function pn(t,e,n){const r=t<0?-1:1;let i=t*r,a=0,c=1,h=0,p=1,u=0,o=0,s=Math.floor(i);for(;ue&&(u>e?(o=p,h=a):(o=u,h=c)),!n)return[0,r*h,o];const l=Math.floor(r*h/o);return[l,r*h-l*o,o]}function Zt(t,e,n){if(t>2958465||t<0)return null;let r=t|0,i=Math.floor(86400*(t-r)),a=0,c=[];const h={D:r,T:i,u:86400*(t-r)-i,y:0,m:0,d:0,H:0,M:0,S:0,q:0};if(Math.abs(h.u)<1e-6&&(h.u=0),e&&e.date1904&&(r+=1462),h.u>.9999&&(h.u=0,++i===86400&&(h.T=i=0,++r,++h.D)),r===60)c=n?[1317,10,29]:[1900,2,29],a=3;else if(r===0)c=n?[1317,8,29]:[1900,1,0],a=6;else{r>60&&--r;const p=new Date(1900,0,1);p.setDate(p.getDate()+r-1),c=[p.getFullYear(),p.getMonth()+1,p.getDate()],a=p.getDay(),r<60&&(a=(a+6)%7),n&&(a=ma())}return h.y=c[0],h.m=c[1],h.d=c[2],h.S=i%60,i=Math.floor(i/60),h.M=i%60,i=Math.floor(i/60),h.H=i,h.q=a,h}_e.parse_date_code=Zt;const Mo=new Date(1899,11,31,0,0,0),ga=Mo.getTime(),Ea=new Date(1900,2,1,0,0,0);function Uo(t,e){let n=t.getTime();return e?n-=1461*24*60*60*1e3:t>=Ea&&(n+=24*60*60*1e3),(n-(ga+(t.getTimezoneOffset()-Mo.getTimezoneOffset())*6e4))/(24*60*60*1e3)}function Lo(t){return t.toString(10)}_e._general_int=Lo;const _o=function(){const e=/\.(\d*[1-9])0+$/,n=/\.0*$/,r=/\.(\d*[1-9])0+/,i=/\.0*[Ee]/,a=/(E[+-])(\d)$/;function c(o){const s=o<0?12:11;let l=u(o.toFixed(12));return l.length<=s||(l=o.toPrecision(10),l.length<=s)?l:o.toExponential(5)}function h(o){let s=o.toFixed(11).replace(e,".$1");return s.length>(o<0?12:11)&&(s=o.toPrecision(6)),s}function p(o){for(let s=0;s!==o.length;++s)if((o.charCodeAt(s)|32)===101)return o.replace(r,".$1").replace(i,"E").replace("e","E").replace(a,"$10$2");return o}function u(o){return o.indexOf(".")>-1?o.replace(n,"").replace(e,".$1"):o}return function(s){let l=Math.floor(Math.log(Math.abs(s))*Math.LOG10E),f;return l>=-4&&l<=-1?f=s.toPrecision(10+l):Math.abs(l)<=9?f=c(s):l===10?f=s.toFixed(10).substr(0,12):f=h(s),u(p(f))}}();_e._general_num=_o;function Pn(t,e){switch(typeof t){case"string":return t;case"boolean":return t?"TRUE":"FALSE";case"number":return(t|0)===t?Lo(t):_o(t);case"undefined":return"";case"object":if(t==null)return"";if(t instanceof Date)return Bo(14,Uo(t,e&&e.date1904),e)}throw new Error("unsupported value in General format: "+t)}_e._general=Pn;function ma(){return 0}function Ra(t,e,n,r){let i="",a=0,c=0,h=n.y,p,u=0;switch(t){case 98:h=n.y+543;case 121:switch(e.length){case 1:case 2:p=h%100,u=2;break;default:p=h%1e4,u=4;break}break;case 109:switch(e.length){case 1:case 2:p=n.m,u=e.length;break;case 3:return fr[n.m-1][1];case 5:return fr[n.m-1][0];default:return fr[n.m-1][2]}break;case 100:switch(e.length){case 1:case 2:p=n.d,u=e.length;break;case 3:return hi[n.q][0];default:return hi[n.q][1]}break;case 104:switch(e.length){case 1:case 2:p=1+(n.H+11)%12,u=e.length;break;default:throw"bad hour format: "+e}break;case 72:switch(e.length){case 1:case 2:p=n.H,u=e.length;break;default:throw"bad hour format: "+e}break;case 77:switch(e.length){case 1:case 2:p=n.M,u=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 n.u===0&&(e==="s"||e==="ss")?Xe(n.S,e.length):(r>=2?c=r===3?1e3:100:c=r===1?10:1,a=Math.round(c*(n.S+n.u)),a>=60*c&&(a=0),e==="s"?a===0?"0":""+a/c:(i=Xe(a,2+r),e==="ss"?i.substr(0,2):"."+i.substr(2,e.length-1)));case 90:switch(e){case"[h]":case"[hh]":p=n.D*24+n.H;break;case"[m]":case"[mm]":p=(n.D*24+n.H)*60+n.M;break;case"[s]":case"[ss]":p=((n.D*24+n.H)*60+n.M)*60+Math.round(n.S+n.u);break;default:throw"bad abstime format: "+e}u=e.length===3?1:2;break;case 101:p=h,u=1}return u>0?Xe(p,u):""}function Nt(t){if(t.length<=3)return t;let n=t.length%3,r=t.substr(0,n);for(;n!==t.length;n+=3)r+=(r.length>0?",":"")+t.substr(n,3);return r}const ht=function(){const e=/%/g;function n(y,R,T){const w=R.replace(e,""),C=R.length-w.length;return ht(y,w,T*Math.pow(10,2*C))+ke("%",C)}function r(y,R,T){let w=R.length-1;for(;R.charCodeAt(w-1)===44;)--w;return ht(y,R.substr(0,w),T/Math.pow(10,3*(R.length-w)))}function i(y,R){let T,w=y.indexOf("E")-y.indexOf(".")-1;if(y.match(/^#+0.0E\+0$/)){if(R===0)return"0.0E+0";if(R<0)return"-"+i(y,-R);let C=y.indexOf(".");C===-1&&(C=y.indexOf("E"));let M=Math.floor(Math.log(R)*Math.LOG10E)%C;if(M<0&&(M+=C),T=(R/Math.pow(10,M)).toPrecision(w+1+(C+M)%C),T.indexOf("e")===-1){const _=Math.floor(Math.log(R)*Math.LOG10E);for(T.indexOf(".")===-1?T=T.charAt(0)+"."+T.substr(1)+"E+"+(_-T.length+M):T+="E+"+(_-M);T.substr(0,2)==="0.";)T=T.charAt(0)+T.substr(2,C)+"."+T.substr(2+C),T=T.replace(/^0+([1-9])/,"$1").replace(/^0+\./,"0.");T=T.replace(/\+-/,"-")}T=T.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/,function(_,W,F,S){return W+F+S.substr(0,(C+M)%C)+"."+S.substr(M)+"E"})}else T=R.toExponential(w);return y.match(/E\+00$/)&&T.match(/e[+-]\d$/)&&(T=T.substr(0,T.length-1)+"0"+T.charAt(T.length-1)),y.match(/E\-/)&&T.match(/e\+/)&&(T=T.replace(/e\+/,"e")),T.replace("e","E")}const a=/# (\?+)( ?)\/( ?)(\d+)/;function c(y,R,T){const w=parseInt(y[4],10),C=Math.round(R*w),M=Math.floor(C/w);let _=C-M*w,W=w;return T+(M===0?"":""+M)+" "+(_===0?ke(" ",y[1].length+1+y[4].length):ur(_,y[1].length)+y[2]+"/"+y[3]+Xe(W,y[4].length))}function h(y,R,T){return T+(R===0?"":""+R)+ke(" ",y[1].length+2+y[4].length)}const p=/^#*0*\.([0#]+)/,u=/\).*[0#]/,o=/\(###\) ###\\?-####/;function s(y){let R="",T;for(let w=0;w!==y.length;++w)switch(T=y.charCodeAt(w)){case 35:break;case 63:R+=" ";break;case 48:R+="0";break;default:R+=String.fromCharCode(T)}return R}function l(y,R){const T=Math.pow(10,R);return""+Math.round(y*T)/T}function f(y,R){return R<(""+Math.round((y-Math.floor(y))*Math.pow(10,R))).length?0:Math.round((y-Math.floor(y))*Math.pow(10,R))}function v(y,R){return R<(""+Math.round((y-Math.floor(y))*Math.pow(10,R))).length?1:0}function d(y){return y<2147483647&&y>-2147483648?""+(y>=0?y|0:y-1|0):""+Math.floor(y)}function g(y,R,T){if(y.charCodeAt(0)===40&&!R.match(u)){const G=R.replace(/\( */,"").replace(/ \)/,"").replace(/\)/,"");return T>=0?g("n",G,T):"("+g("n",G,-T)+")"}if(R.charCodeAt(R.length-1)===44)return r(y,R,T);if(R.indexOf("%")!==-1)return n(y,R,T);if(R.indexOf("E")!==-1)return i(R,T);if(R.charCodeAt(0)===36)return"$"+g(y,R.substr(R.charAt(1)==" "?2:1),T);let w,C,M,_,W=Math.abs(T),F=T<0?"-":"";if(R.match(/^00+$/))return F+Gt(W,R.length);if(R.match(/^[#?]+$/))return w=Gt(T,0),w==="0"&&(w=""),w.length>R.length?w:s(R.substr(0,R.length-w.length))+w;if(C=R.match(a))return c(C,W,F);if(R.match(/^#+0+$/))return F+Gt(W,R.length-R.indexOf("0"));if(C=R.match(p))return w=l(T,C[1].length).replace(/^([^\.]+)$/,"$1."+s(C[1])).replace(/\.$/,"."+s(C[1])).replace(/\.(\d*)$/,function(G,J){return"."+J+ke("0",s(C[1]).length-J.length)}),R.indexOf("0.")!==-1?w:w.replace(/^0\./,".");if(R=R.replace(/^#+([0.])/,"$1"),C=R.match(/^(0*)\.(#*)$/))return F+l(W,C[2].length).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,C[1].length?"0.":".");if(C=R.match(/^#{1,3},##0(\.?)$/))return F+Nt(Gt(W,0));if(C=R.match(/^#,##0\.([#0]*0)$/))return T<0?"-"+g(y,R,-T):Nt(""+(Math.floor(T)+v(T,C[1].length)))+"."+Xe(f(T,C[1].length),C[1].length);if(C=R.match(/^#,#*,#0/))return g(y,R.replace(/^#,#*,/,""),T);if(C=R.match(/^([0#]+)(\\?-([0#]+))+$/))return w=Vt(g(y,R.replace(/[\\-]/g,""),T)),M=0,Vt(Vt(R.replace(/\\/g,"")).replace(/[0#]/g,function(G){return M=0?N("n",G,T):"("+N("n",G,-T)+")"}if(R.charCodeAt(R.length-1)===44)return E(y,R,T);if(R.indexOf("%")!==-1)return A(y,R,T);if(R.indexOf("E")!==-1)return m(R,T);if(R.charCodeAt(0)===36)return"$"+N(y,R.substr(R.charAt(1)==" "?2:1),T);let w,C,M,_,W=Math.abs(T),F=T<0?"-":"";if(R.match(/^00+$/))return F+Xe(W,R.length);if(R.match(/^[#?]+$/))return w=""+T,T===0&&(w=""),w.length>R.length?w:s(R.substr(0,R.length-w.length))+w;if(C=R.match(a))return h(C,W,F);if(R.match(/^#+0+$/))return F+Xe(W,R.length-R.indexOf("0"));if(C=R.match(p))return w=(""+T).replace(/^([^\.]+)$/,"$1."+s(C[1])).replace(/\.$/,"."+s(C[1])),w=w.replace(/\.(\d*)$/,function(G,J){return"."+J+ke("0",s(C[1]).length-J.length)}),R.indexOf("0.")!==-1?w:w.replace(/^0\./,".");if(R=R.replace(/^#+([0.])/,"$1"),C=R.match(/^(0*)\.(#*)$/))return F+(""+W).replace(/\.(\d*[1-9])0*$/,".$1").replace(/^(-?\d*)$/,"$1.").replace(/^0\./,C[1].length?"0.":".");if(C=R.match(/^#{1,3},##0(\.?)$/))return F+Nt(""+W);if(C=R.match(/^#,##0\.([#0]*0)$/))return T<0?"-"+N(y,R,-T):Nt(""+T)+"."+ke("0",C[1].length);if(C=R.match(/^#,#*,#0/))return N(y,R.replace(/^#,#*,/,""),T);if(C=R.match(/^([0#]+)(\\?-([0#]+))+$/))return w=Vt(N(y,R.replace(/[\\-]/g,""),T)),M=0,Vt(Vt(R.replace(/\\/g,"")).replace(/[0#]/g,function(G){return M-1||n=="\\"&&t.charAt(e+1)=="-"&&"0#".indexOf(t.charAt(e+2))>-1););break;case"?":for(;t.charAt(++e)===n;);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-1;);break;case" ":++e;break;default:++e;break}return!1}_e.is_date=xo;function So(t,e,n,r){let i=[],a="",c=0,h="",p="t",u,o,s,l="H";for(;c=12?"P":"A"),w.t="T",l="h",c+=3):t.substr(c,5).toUpperCase()==="AM/PM"?(u!=null&&(w.v=u.H>=12?"PM":"AM"),w.t="T",c+=5,l="h"):(w.t="t",++c),u==null&&w.t==="T")return"";i[i.length]=w,p=h;break;case"[":for(a=h;t.charAt(c++)!=="]"&&c-1&&(a=(a.match(/\$([^-\[\]]*)/)||[])[1]||"$",xo(t)||(i[i.length]={t:"t",v:a}));break;case".":if(u!=null){for(a=h;++c-1||h=="\\"&&t.charAt(c+1)=="-"&&c-1;)a+=h;i[i.length]={t:"n",v:a};break;case"?":for(a=h;t.charAt(++c)===h;)a+=h;i[i.length]={t:h,v:a},p=h;break;case"*":++c,(t.charAt(c)===" "||t.charAt(c)==="*")&&++c;break;case"(":case")":i[i.length]={t:r===1||typeof e=="number"&&e<0?"t":h,v:h},++c;break;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":for(a=h;c-1;)a+=t.charAt(c);i[i.length]={t:"D",v:a};break;case" ":i[i.length]={t:h,v:h},++c;break;default:if(",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(h)===-1)throw new Error("unrecognized character "+h+" in "+t);i[i.length]={t:"t",v:h},++c;break}let f=0,v=0,d;for(c=i.length-1,p="t";c>=0;--c)switch(i[c].t){case"h":case"H":i[c].t=l,p="h",f<1&&(f=1);break;case"s":(d=i[c].v.match(/\.0+$/))&&(v=Math.max(v,d[0].length-1)),f<3&&(f=3);case"d":case"y":case"M":case"e":p=i[c].t;break;case"m":p==="s"&&(i[c].t="M",f<2&&(f=2));break;case"X":break;case"Z":f<1&&i[c].v.match(/[Hh]/)&&(f=1),f<2&&i[c].v.match(/[Mm]/)&&(f=2),f<3&&i[c].v.match(/[Ss]/)&&(f=3)}switch(f){case 0:break;case 1:u.u>=.5&&(u.u=0,++u.S),u.S>=60&&(u.S=0,++u.M),u.M>=60&&(u.M=0,++u.H);break;case 2:u.u>=.5&&(u.u=0,++u.S),u.S>=60&&(u.S=0,++u.M);break}let g="",E;for(c=0;c0){g.charCodeAt(0)===40?(m=e<0&&g.charCodeAt(0)===45?-e:e,N=ht("(",g,m)):(m=e<0&&r>1?-e:e,N=ht("n",g,m),m<0&&i[0]&&i[0].t==="t"&&(N=N.substr(1),i[0].v="-"+i[0].v)),E=N.length-1;let R=i.length;for(c=0;c-1){R=c;break}let T=i.length;if(R===i.length&&N.indexOf("E")===-1){for(c=i.length-1;c>=0;--c)i[c]==null||"n?(".indexOf(i[c].t)===-1||(E>=i[c].v.length-1?(E-=i[c].v.length,i[c].v=N.substr(E+1,i[c].v.length)):E<0?i[c].v="":(i[c].v=N.substr(0,E+1),E=-1),i[c].t="t",T=c);E>=0&&T=0;--c)if(!(i[c]==null||"n?(".indexOf(i[c].t)===-1)){for(o=i[c].v.indexOf(".")>-1&&c===R?i[c].v.indexOf(".")-1:i[c].v.length-1,A=i[c].v.substr(o+1);o>=0;--o)E>=0&&(i[c].v.charAt(o)==="0"||i[c].v.charAt(o)==="#")&&(A=N.charAt(E--)+A);i[c].v=A,i[c].t="t",T=c}for(E>=0&&T-1&&c===R?i[c].v.indexOf(".")+1:0,A=i[c].v.substr(0,o);o-1&&(m=r>1&&e<0&&c>0&&i[c-1].v==="-"?-e:e,i[c].v=ht(i[c].t,i[c].v,m),i[c].t="t");let y="";for(c=0;c!==i.length;++c)i[c]!=null&&(y+=i[c].v);return y}_e._eval=So;const pi=/\[[=<>]/,di=/\[([=<>]*)(-?\d+\.?\d*)\]/;function vi(t,e){if(e==null)return!1;const n=parseFloat(e[2]);switch(e[1]){case"=":if(t===n)return!0;break;case">":if(t>n)return!0;break;case"<":if(t":if(t!==n)return!0;break;case">=":if(t>=n)return!0;break;case"<=":if(t<=n)return!0;break}return!1}function Na(t,e){let n=Po(t),r=n.length,i=n[r-1].indexOf("@");if(r<4&&i>-1&&--r,n.length>4)throw new Error("cannot find right format for |"+n.join("|")+"|");if(typeof e!="number")return[4,n.length===4||i>-1?n[n.length-1]:"@"];switch(n.length){case 1:n=i>-1?["General","General","General",n[0]]:[n[0],n[0],n[0],"@"];break;case 2:n=i>-1?[n[0],n[0],n[0],n[1]]:[n[0],n[1],n[0],"@"];break;case 3:n=i>-1?[n[0],n[1],n[0],n[2]]:[n[0],n[1],n[2],"@"];break}const a=e>0?n[0]:e<0?n[1]:n[2];if(n[0].indexOf("[")===-1&&n[1].indexOf("[")===-1)return[r,a];if(n[0].match(pi)!=null||n[1].match(pi)!=null){const c=n[0].match(di),h=n[1].match(di);return vi(e,c)?[r,n[0]]:vi(e,h)?[r,n[1]]:[r,n[c!=null&&h!=null?2:1]]}return[r,a]}function Bo(t,e,n){n==null&&(n={});let r="";switch(typeof t){case"string":t==="m/d/yy"&&n.dateNF?r=n.dateNF:r=t;break;case"number":t===14&&n.dateNF?r=n.dateNF:r=(n.table!=null?n.table:_t)[t];break}if(_n(r,0))return Pn(e,n);e instanceof Date&&(e=Uo(e,n.date1904));const i=Na(r,e);if(_n(i[1]))return Pn(e,n);if(e===!0)e="TRUE";else if(e===!1)e="FALSE";else if(e===""||e==null)return"";return So(i[1],e,n,i[0])}function Fo(t,e){if(typeof e!="number"){e=+e||-1;for(let n=0;n<392;++n){if(_t[n]===void 0){e<0&&(e=n);continue}if(_t[n]===t){e=n;break}}e<0&&(e=391)}return _t[e]=t,e}_e.load=Fo;_e._table=_t;_e.get_table=function(){return _t};_e.load_table=function(e){for(let n=0;n!==392;++n)e[n]!==void 0&&Fo(e[n],n)};_e.init_table=Oo;_e.format=Bo;var bo=_e,Do={exports:{}};(function(t){const e="ศูนย์บาทถ้วน",n=["","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],r=["","สิบ","ร้อย","พัน","หมื่น","แสน","ล้าน"];function i(p){let u="";const o=p.length,s=7;if(o>s){const l=o-s+1,f=p.slice(0,l),v=p.slice(l);return i(f)+"ล้าน"+i(v)}else for(let l=0;l0&&(u+=n[f]+r[o-l-1])}return u}function a(p){let u=p;u=u.replace("หนึ่งสิบ","สิบ"),u=u.replace("สองสิบ","ยี่สิบ");const o=5;return u.length>o&&u.length-u.lastIndexOf("หนึ่ง")===o&&(u=u.substr(0,u.length-o)+"เอ็ด"),u}function c(p,u){let o="";return p===""&&u===""?o=e:p!==""&&u===""?o=p+"บาทถ้วน":p===""&&u!==""?o=u+"สตางค์":o=p+"บาท"+u+"สตางค์",o}function h(p){let u=e;if(isNaN(p)||p>=Number.MAX_SAFE_INTEGER)return u;const o=Math.floor(p).toString(),s=Math.round(p%1*100).toString(),l=Array.from(o).map(Number),f=Array.from(s).map(Number);let v=i(l),d=i(f);return v=a(v),d=a(d),u=c(v,d),u}t.exports!=null&&(t.exports=h)})(Do);var Aa=Do.exports;const Ce=he(),{FormulaHelpers:ya,Types:Y,WildCard:gi}=ge(),q=ya,hr=bo,Ta=Aa,Ei={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:"。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚",full:"。「」、・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゛゜"},extras:{delta:0,half:"¢£¬¯¦¥₩ |←↑→↓■°",full:"¢£¬ ̄¦¥₩ │←↑→↓■○"}},wa=t=>e=>t.delta?String.fromCharCode(e.charCodeAt(0)+t.delta):[...t.full][[...t.half].indexOf(e)],Ca=t=>e=>t.delta?String.fromCharCode(e.charCodeAt(0)-t.delta):[...t.half][[...t.full].indexOf(e)],Vo=(t,e)=>t[e+"RE"]||new RegExp("["+t[e]+"]","g"),Go=Object.keys(Ei).map(t=>Ei[t]),Ia=t=>Go.reduce((e,n)=>e.replace(Vo(n,"half"),wa(n)),t),Oa=t=>Go.reduce((e,n)=>e.replace(Vo(n,"full"),Ca(n)),t),ft={ASC:t=>(t=q.accept(t,Y.STRING),Oa(t)),BAHTTEXT:t=>{t=q.accept(t,Y.NUMBER);try{return Ta(t)}catch(e){throw Error(`Error in https://github.com/jojoee/bahttext ${e.toString()}`)}},CHAR:t=>{if(t=q.accept(t,Y.NUMBER),t>255||t<1)throw Ce.VALUE;return String.fromCharCode(t)},CLEAN:t=>(t=q.accept(t,Y.STRING),t.replace(/[\x00-\x1F]/g,"")),CODE:t=>{if(t=q.accept(t,Y.STRING),t.length===0)throw Ce.VALUE;return t.charCodeAt(0)},CONCAT:(...t)=>{let e="";return q.flattenParams(t,Y.STRING,!1,n=>{n=q.accept(n,Y.STRING),e+=n}),e},CONCATENATE:(...t)=>{let e="";if(t.length===0)throw Error("CONCATENATE need at least one argument.");return t.forEach(n=>{n=q.accept(n,Y.STRING),e+=n}),e},DBCS:t=>(t=q.accept(t,Y.STRING),Ia(t)),DOLLAR:(t,e)=>{t=q.accept(t,Y.NUMBER),e=q.accept(e,Y.NUMBER,2);const n=Array(e).fill("0").join("");return hr.format(`$#,##0.${n}_);($#,##0.${n})`,t).trim()},EXACT:(t,e)=>(t=q.accept(t,[Y.STRING]),e=q.accept(e,[Y.STRING]),t===e),FIND:(t,e,n)=>{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.STRING),n=q.accept(n,Y.NUMBER,1),n<1||n>e.length)throw Ce.VALUE;const r=e.indexOf(t,n-1);if(r===-1)throw Ce.VALUE;return r+1},FINDB:(...t)=>ft.FIND(...t),FIXED:(t,e,n)=>{t=q.accept(t,Y.NUMBER),e=q.accept(e,Y.NUMBER,2),n=q.accept(n,Y.BOOLEAN,!1);const r=Array(e).fill("0").join(""),i=n?"":"#,";return hr.format(`${i}##0.${r}_);(${i}##0.${r})`,t).trim()},LEFT:(t,e)=>{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.NUMBER,1),e<0)throw Ce.VALUE;return e>t.length?t:t.slice(0,e)},LEFTB:(...t)=>ft.LEFT(...t),LEN:t=>(t=q.accept(t,Y.STRING),t.length),LENB:(...t)=>ft.LEN(...t),LOWER:t=>(t=q.accept(t,Y.STRING),t.toLowerCase()),MID:(t,e,n)=>{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.NUMBER),n=q.accept(n,Y.NUMBER),e>t.length)return"";if(e<1||n<1)throw Ce.VALUE;return t.slice(e-1,e+n-1)},MIDB:(...t)=>ft.MID(...t),NUMBERVALUE:(t,e,n)=>{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.STRING,"."),n=q.accept(n,Y.STRING,","),t.length===0)return 0;if(e.length===0||n.length===0||(e=e[0],n=n[0],e===n||t.indexOf(e)1||i&&!a||!i&&a||isNaN(h))throw Ce.VALUE;return h=h/100**c,i?-h:h},PHONETIC:()=>{},PROPER:t=>(t=q.accept(t,[Y.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,n,r)=>{t=q.accept(t,[Y.STRING]),e=q.accept(e,[Y.NUMBER]),n=q.accept(n,[Y.NUMBER]),r=q.accept(r,[Y.STRING]);let i=t.split("");return i.splice(e-1,n,r),i.join("")},REPLACEB:(...t)=>ft.REPLACE(...t),REPT:(t,e)=>{t=q.accept(t,Y.STRING),e=q.accept(e,Y.NUMBER);let n="";for(let r=0;r{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.NUMBER,1),e<0)throw Ce.VALUE;const n=t.length;return e>n?t:t.slice(n-e)},RIGHTB:(...t)=>ft.RIGHT(...t),SEARCH:(t,e,n)=>{if(t=q.accept(t,Y.STRING),e=q.accept(e,Y.STRING),n=q.accept(n,Y.NUMBER,1),n<1||n>e.length)throw Ce.VALUE;let r=gi.isWildCard(t)?gi.toRegex(t,"i"):t;const i=e.slice(n-1).search(r);if(i===-1)throw Ce.VALUE;return i+n},SEARCHB:(...t)=>ft.SEARCH(...t),SUBSTITUTE:(...t)=>{},T:t=>(t=q.accept(t),typeof t=="string"?t:""),TEXT:(t,e)=>{t=q.accept(t,Y.NUMBER),e=q.accept(e,Y.STRING);try{return hr.format(e,t)}catch(n){throw console.error(n),Ce.VALUE}},TEXTJOIN:(...t)=>{},TRIM:t=>(t=q.accept(t,[Y.STRING]),t.replace(/^\s+|\s+$/g,"")),UNICHAR:t=>{if(t=q.accept(t,[Y.NUMBER]),t<=0)throw Ce.VALUE;return String.fromCharCode(t)},UNICODE:t=>ft.CODE(t)};var $o=ft;const tn=he(),{FormulaHelpers:kn}=ge(),Ma={unaryOp:(t,e,n)=>{let r=1;if(t.forEach(i=>{if(i!=="+")if(i==="-")r=-r;else throw new Error(`Unrecognized prefix: ${i}`)}),e==null&&(e=0),r===1)return e;try{e=kn.acceptNumber(e,n)}catch(i){if(i instanceof tn)Array.isArray(e)&&(e=e[0][0]);else throw i}return typeof e=="number"&&isNaN(e)?tn.VALUE:-e}},Ua={percentOp:(t,e,n)=>{try{t=kn.acceptNumber(t,n)}catch(r){if(r instanceof tn)return r;throw r}if(e==="%")return t/100;throw new Error(`Unrecognized postfix: ${e}`)}},At={boolean:3,string:2,number:1},La={compareOp:(t,e,n,r,i)=>{t==null&&(t=0),n==null&&(n=0),r&&(t=t[0][0]),i&&(n=n[0][0]);const a=typeof t,c=typeof n;if(a===c)switch(e){case"=":return t===n;case">":return t>n;case"<":return t":return t!==n;case"<=":return t<=n;case">=":return t>=n}else switch(e){case"=":return!1;case">":return At[a]>At[c];case"<":return At[a]":return!0;case"<=":return At[a]<=At[c];case">=":return At[a]>=At[c]}throw Error("Infix.compareOp: Should not reach here.")},concatOp:(t,e,n,r,i)=>{t==null&&(t=""),n==null&&(n=""),r&&(t=t[0][0]),i&&(n=n[0][0]);const a=typeof t,c=typeof n;return a==="boolean"&&(t=t?"TRUE":"FALSE"),c==="boolean"&&(n=n?"TRUE":"FALSE"),""+t+n},mathOp:(t,e,n,r,i)=>{t==null&&(t=0),n==null&&(n=0);try{t=kn.acceptNumber(t,r),n=kn.acceptNumber(n,i)}catch(a){if(a instanceof tn)return a;throw a}switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return n===0?tn.DIV0:t/n;case"^":return t**n}throw Error("Infix.mathOp: Should not reach here.")}};var Wr={Prefix:Ma,Postfix:Ua,Infix:La,Operators:{compareOp:["<",">","=","<>","<=",">="],concatOp:["&"],mathOp:["+","-","*","/","^"]}};const Q=he(),{FormulaHelpers:_a,Types:P,Factorials:Ho,Criteria:Pa}=ge(),{Infix:ka}=Wr,L=_a,pr=[],dr=[];function Cn(t){return t<=100?Ho[t]:pr[t]>0?pr[t]:pr[t]=Cn(t-1)*t}function Wo(t){return t===1||t===0?1:t===2?2:dr[t]>0?dr[t]:dr[t]=Wo(t-2)*t}const Pe={ABS:t=>(t=L.accept(t,P.NUMBER),Math.abs(t)),AGGREGATE:(t,e,n,...r)=>{},ARABIC:t=>{if(t=L.accept(t,P.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 Q("#VALUE!","Invalid roman numeral in ARABIC evaluation.");let e=0;return t.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,function(n){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}[n]}),e},BASE:(t,e,n)=>{if(t=L.accept(t,P.NUMBER),t<0||t>=2**53||(e=L.accept(e,P.NUMBER),e<2||e>36)||(n=L.accept(n,P.NUMBER,0),n<0))throw Q.NUM;const r=t.toString(e).toUpperCase();return new Array(Math.max(n+1-r.length,0)).join("0")+r},CEILING:(t,e)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),e===0)return 0;if(t/e%1===0)return t;const n=Math.abs(e),r=Math.floor(Math.abs(t)/n);return t<0?e<0?-n*(r+1):-n*r:(r+1)*n},"CEILING.MATH":(t,e,n)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,t>0?1:-1),n=L.accept(n,P.NUMBER,0),t>=0)return Pe.CEILING(t,e);const r=n?e:0;return Pe.CEILING(t,e)-r},"CEILING.PRECISE":(t,e)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,1),Pe.CEILING(t,Math.abs(e))),COMBIN:(t,e)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),t<0||e<0||t{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),(t===0||t===1)&&e===0)return 1;if(t<0||e<0)throw Q.NUM;return Pe.COMBIN(t+e-1,t-1)},DECIMAL:(t,e)=>{if(t=L.accept(t,P.STRING),e=L.accept(e,P.NUMBER),e=Math.trunc(e),e<2||e>36)throw Q.NUM;const n=parseInt(t,e);if(isNaN(n))throw Q.NUM;return n},DEGREES:t=>(t=L.accept(t,P.NUMBER),t*(180/Math.PI)),EVEN:t=>Pe.CEILING(t,-2),EXP:t=>(t=L.accept(t,P.NUMBER),Math.exp(t)),FACT:t=>{if(t=L.accept(t,P.NUMBER),t=Math.trunc(t),t>170||t<0)throw Q.NUM;return t<=100?Ho[t]:Cn(t)},FACTDOUBLE:t=>{if(t=L.accept(t,P.NUMBER),t=Math.trunc(t),t<-1)throw Q.NUM;return t===-1?1:Wo(t)},FLOOR:(t,e)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),e===0)return 0;if(t>0&&e<0)throw Q.NUM;if(t/e%1===0)return t;const n=Math.abs(e),r=Math.floor(Math.abs(t)/n);return t<0?e<0?-n*r:-n*(r+1):r*n},"FLOOR.MATH":(t,e,n)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,t>0?1:-1),n=L.accept(n,P.NUMBER,0),n===0||t>=0?Pe.FLOOR(t,Math.abs(e)):Pe.FLOOR(t,e)+e),"FLOOR.PRECISE":(t,e)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,1),Pe.FLOOR(t,Math.abs(e))),GCD:(...t)=>{const e=[];L.flattenParams(t,null,!1,c=>{if(c=typeof c=="boolean"?NaN:Number(c),isNaN(c))throw Q.VALUE;if(c<0||c>9007199254740990)throw Q.NUM;e.push(Math.trunc(c))},0);let n,r,i=t.length,a=Math.abs(e[0]);for(n=1;nr?a%=r:r%=a;a+=r}return a},INT:t=>(t=L.accept(t,P.NUMBER),Math.floor(t)),"ISO.CEILING":(...t)=>Pe["CEILING.PRECISE"](...t),LCM:(...t)=>{const e=[];L.flattenParams(t,null,!1,i=>{if(i=typeof i=="boolean"?NaN:Number(i),isNaN(i))throw Q.VALUE;if(i<0||i>9007199254740990)throw Q.NUM;e.push(Math.trunc(i))},1);let n=e.length,r=Math.abs(e[0]);for(let i=1;ia?r%=a:a%=r;r=Math.abs(c*e[i])/(r+a)}return r},LN:t=>(t=L.accept(t,P.NUMBER),Math.log(t)),LOG:(t,e)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,10),Math.log(t)/Math.log(e)),LOG10:t=>(t=L.accept(t,P.NUMBER),Math.log10(t)),MDETERM:t=>{if(t=L.accept(t,P.ARRAY,void 0,!1,!0),t[0].length!==t.length)throw Q.VALUE;const e=t.length,n=t[0].length;let r=0,i,a;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{},MMULT:(t,e)=>{t=L.accept(t,P.ARRAY,void 0,!1,!0),e=L.accept(e,P.ARRAY,void 0,!1,!0);const n=t.length,r=t[0].length,i=e.length,a=e[0].length,c=new Array(n);if(r!==i)throw Q.VALUE;for(let h=0;h{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),e===0)throw Q.DIV0;return t-e*Pe.INT(t/e)},MROUND:(t,e)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),e===0)return 0;if(t>0&&e<0||t<0&&e>0)throw Q.NUM;return t/e%1===0?t:Math.round(t/e)*e},MULTINOMIAL:(...t)=>{let e=0,n=1;return L.flattenParams(t,P.NUMBER,!1,r=>{if(r<0)throw Q.NUM;e+=r,n*=Cn(r)}),Cn(e)/n},MUNIT:t=>{t=L.accept(t,P.NUMBER);const e=[];for(let n=0;n{if(t=L.accept(t,P.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=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),t**e),PRODUCT:(...t)=>{let e=1;return L.flattenParams(t,null,!0,(n,r)=>{const i=Number(n);r.isLiteral&&!isNaN(i)?e*=i:typeof n=="number"&&(e*=n)},1),e},QUOTIENT:(t,e)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),Math.trunc(t/e)),RADIANS:t=>(t=L.accept(t,P.NUMBER),t/180*Math.PI),RAND:()=>Math.random(),RANDBETWEEN:(t,e)=>(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),Math.floor(Math.random()*(e-t+1)+t)),ROMAN:(t,e)=>{if(t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER,0),e!==0)throw Error("ROMAN: only allows form=0 (classic form).");const n=String(t).split(""),r=["","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"];let i="",a=3;for(;a--;)i=(r[+n.pop()+a*10]||"")+i;return new Array(+n.join("")+1).join("M")+i},ROUND:(t,e)=>{t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER);const n=Math.pow(10,Math.abs(e)),r=t>0?1:-1;return e>0?r*Math.round(Math.abs(t)*n)/n:e===0?r*Math.round(Math.abs(t)):r*Math.round(Math.abs(t)/n)*n},ROUNDDOWN:(t,e)=>{t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER);const n=Math.pow(10,Math.abs(e)),r=t>0?1:-1;if(e>0){const i=1/n*.5;return r*Math.round((Math.abs(t)-i)*n)/n}else{if(e===0)return r*Math.round(Math.abs(t)-.5);{const i=n*.5;return r*Math.round((Math.abs(t)-i)/n)*n}}},ROUNDUP:(t,e)=>{t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER);const n=Math.pow(10,Math.abs(e)),r=t>0?1:-1;if(e>0){const i=1/n*.5;return r*Math.round((Math.abs(t)+i)*n)/n}else{if(e===0)return r*Math.round(Math.abs(t)+.5);{const i=n*.5;return r*Math.round((Math.abs(t)+i)/n)*n}}},SERIESSUM:(t,e,n,r)=>{t=L.accept(t,P.NUMBER),e=L.accept(e,P.NUMBER),n=L.accept(n,P.NUMBER);let i=0,a;return L.flattenParams([r],P.NUMBER,!1,c=>{if(typeof c!="number")throw Q.VALUE;i===0?a=c*Math.pow(t,e):a+=c*Math.pow(t,e+i*n),i++}),a},SIGN:t=>(t=L.accept(t,P.NUMBER),t>0?1:t===0?0:-1),SQRT:t=>{if(t=L.accept(t,P.NUMBER),t<0)throw Q.NUM;return Math.sqrt(t)},SQRTPI:t=>{if(t=L.accept(t,P.NUMBER),t<0)throw Q.NUM;return Math.sqrt(t*Math.PI)},SUBTOTAL:()=>{},SUM:(...t)=>{let e=0;return L.flattenParams(t,P.NUMBER,!0,(n,r)=>{(r.isLiteral||typeof n=="number")&&(e+=n)}),e},SUMIF:(t,e,n,r)=>{const i=L.retrieveRanges(t,e,r);e=i[0],r=i[1],n=L.retrieveArg(t,n);const a=n.isArray;n=Pa.parse(L.accept(n));let c=0;return e.forEach((h,p)=>{h.forEach((u,o)=>{const s=r[p][o];typeof s=="number"&&(n.op==="wc"?n.match===n.value.test(u)&&(c+=s):ka.compareOp(u,n.op,n.value,Array.isArray(u),a)&&(c+=s))})}),c},SUMIFS:()=>{},SUMPRODUCT:(t,...e)=>{t=L.accept(t,P.ARRAY,void 0,!1,!0),e.forEach(r=>{if(r=L.accept(r,P.ARRAY,void 0,!1,!0),t[0].length!==r[0].length||t.length!==r.length)throw Q.VALUE;for(let i=0;i{r.forEach(i=>{n+=i})}),n},SUMSQ:(...t)=>{let e=0;return L.flattenParams(t,P.NUMBER,!0,(n,r)=>{(r.isLiteral||typeof n=="number")&&(e+=n**2)}),e},SUMX2MY2:(t,e)=>{const n=[],r=[];let i=0;if(L.flattenParams([t],null,!1,(a,c)=>{n.push(a)}),L.flattenParams([e],null,!1,(a,c)=>{r.push(a)}),n.length!==r.length)throw Q.NA;for(let a=0;a{const n=[],r=[];let i=0;if(L.flattenParams([t],null,!1,(a,c)=>{n.push(a)}),L.flattenParams([e],null,!1,(a,c)=>{r.push(a)}),n.length!==r.length)throw Q.NA;for(let a=0;a{const n=[],r=[];let i=0;if(L.flattenParams([t],null,!1,(a,c)=>{n.push(a)}),L.flattenParams([e],null,!1,(a,c)=>{r.push(a)}),n.length!==r.length)throw Q.NA;for(let a=0;a(t=L.accept(t,P.NUMBER),Math.trunc(t))};var qo=Pe;const Ie=he(),{FormulaHelpers:xa,Types:ie}=ge(),oe=xa,$t=2**27-1,Sa={ACOS:t=>{if(t=oe.accept(t,ie.NUMBER),t>1||t<-1)throw Ie.NUM;return Math.acos(t)},ACOSH:t=>{if(t=oe.accept(t,ie.NUMBER),t<1)throw Ie.NUM;return Math.acosh(t)},ACOT:t=>(t=oe.accept(t,ie.NUMBER),Math.PI/2-Math.atan(t)),ACOTH:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)<=1)throw Ie.NUM;return Math.atanh(1/t)},ASIN:t=>{if(t=oe.accept(t,ie.NUMBER),t>1||t<-1)throw Ie.NUM;return Math.asin(t)},ASINH:t=>(t=oe.accept(t,ie.NUMBER),Math.asinh(t)),ATAN:t=>(t=oe.accept(t,ie.NUMBER),Math.atan(t)),ATAN2:(t,e)=>{if(t=oe.accept(t,ie.NUMBER),e=oe.accept(e,ie.NUMBER),e===0&&t===0)throw Ie.DIV0;return Math.atan2(e,t)},ATANH:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>1)throw Ie.NUM;return Math.atanh(t)},COS:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;return Math.cos(t)},COSH:t=>(t=oe.accept(t,ie.NUMBER),Math.cosh(t)),COT:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;if(t===0)throw Ie.DIV0;return 1/Math.tan(t)},COTH:t=>{if(t=oe.accept(t,ie.NUMBER),t===0)throw Ie.DIV0;return 1/Math.tanh(t)},CSC:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;return 1/Math.sin(t)},CSCH:t=>{if(t=oe.accept(t,ie.NUMBER),t===0)throw Ie.DIV0;return 1/Math.sinh(t)},SEC:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;return 1/Math.cos(t)},SECH:t=>(t=oe.accept(t,ie.NUMBER),1/Math.cosh(t)),SIN:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;return Math.sin(t)},SINH:t=>(t=oe.accept(t,ie.NUMBER),Math.sinh(t)),TAN:t=>{if(t=oe.accept(t,ie.NUMBER),Math.abs(t)>$t)throw Ie.NUM;return Math.tan(t)},TANH:t=>(t=oe.accept(t,ie.NUMBER),Math.tanh(t))};var Ba=Sa;const yt=he(),{FormulaHelpers:Fa,Types:vr}=ge(),ze=Fa;function gr(t){let e=0,n=0;return ze.flattenParams(t,null,!0,r=>{const i=typeof r;i==="string"?r==="TRUE"?r=!0:r==="FALSE"&&(r=!1):i==="number"&&(r=!!r),typeof r=="boolean"&&(r===!0?e++:n++)}),[e,n]}const ba={AND:(...t)=>{const[e,n]=gr(t);return e===0&&n===0?yt.VALUE:e>0&&n===0},FALSE:()=>!1,IF:(t,e,n,r)=>(e=ze.accept(e,vr.BOOLEAN),n=ze.accept(n),r=ze.accept(r,null,!1),e?n:r),IFERROR:(t,e)=>t.value instanceof yt?ze.accept(e):ze.accept(t),IFNA:function(t,e){if(arguments.length>2)throw yt.TOO_MANY_ARGS("IFNA");return yt.NA.equals(t.value)?ze.accept(e):ze.accept(t)},IFS:(...t)=>{if(t.length%2!==0)return new yt("#N/A","IFS expects all arguments after position 0 to be in pairs.");for(let e=0;e(t=ze.accept(t,vr.BOOLEAN),!t),OR:(...t)=>{const[e,n]=gr(t);return e===0&&n===0?yt.VALUE:e>0},SWITCH:(...t)=>{},TRUE:()=>!0,XOR:(...t)=>{const[e,n]=gr(t);return e===0&&n===0?yt.VALUE:e%2===1}};var Da=ba,Yo={};(function(t){(function(e){e(typeof DO_NOT_EXPORT_BESSEL>"u"?t:{})})(function(e){e.version="1.0.2";var n=Math;function r(o,s){for(var l=0,f=0;lT)w=i(R,T,d(R),N(R),-1);else{for(var C=2*n.floor((T+n.floor(n.sqrt(40*T)))/2),M=!1,_=0,W=0,F=1,S=0,G=2/R,J=C;J>0;J--)S=J*G*F-_,_=F,F=S,n.abs(F)>1e10&&(F*=1e-10,_*=1e-10,w*=1e-10,W*=1e-10),M&&(W+=F),M=!M,J==T&&(w=_);W=2*W-F,w/=W}return w}}(),h=function(){var o=.636619772,s=[-2957821389,7062834065,-5123598036e-1,1087988129e-2,-86327.92757,228.4622733].reverse(),l=[40076544269,7452499648e-1,7189466438e-3,47447.2647,226.1030244,1].reverse(),f=[1,-.001098628627,2734510407e-14,-2073370639e-15,2093887211e-16].reverse(),v=[-.01562499995,.0001430488765,-6911147651e-15,7621095161e-16,-934945152e-16].reverse();function d(y){var R=0,T=0,w=0,C=y*y,M=y-.785398164;return y<8?(T=r(s,C),w=r(l,C),R=T/w+o*c(y,0)*n.log(y)):(C=64/C,T=r(f,C),w=r(v,C),R=n.sqrt(o/y)*(n.sin(M)*T+n.cos(M)*w*8/y)),R}var g=[-4900604943e3,127527439e4,-51534381390,7349264551e-1,-4237922726e-3,8511.937935].reverse(),E=[249958057e5,424441966400,3733650367,2245904002e-2,102042.605,354.9632885,1].reverse(),A=[1,.00183105,-3516396496e-14,2457520174e-15,-240337019e-15].reverse(),m=[.04687499995,-.0002002690873,8449199096e-15,-88228987e-14,105787412e-15].reverse();function N(y){var R=0,T=0,w=0,C=y*y,M=y-2.356194491;return y<8?(T=y*r(g,C),w=r(E,C),R=T/w+o*(c(y,1)*n.log(y)-1/y)):(C=64/C,T=r(A,C),w=r(m,C),R=n.sqrt(o/y)*(n.sin(M)*T+n.cos(M)*w*8/y)),R}return a(d,N,"BESSELY",1,-1)}(),p=function(){var o=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),s=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse();function l(g){return g<=3.75?r(o,g*g/(3.75*3.75)):n.exp(n.abs(g))/n.sqrt(n.abs(g))*r(s,3.75/n.abs(g))}var f=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),v=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse();function d(g){return g<3.75?g*r(f,g*g/(3.75*3.75)):(g<0?-1:1)*n.exp(n.abs(g))/n.sqrt(n.abs(g))*r(v,3.75/n.abs(g))}return function g(E,A){if(A=Math.round(A),A===0)return l(E);if(A===1)return d(E);if(A<0)return NaN;if(n.abs(E)===0)return 0;if(E==1/0)return 1/0;var m=0,N,y=2/n.abs(E),R=0,T=1,w=0,C=2*n.round((A+n.round(n.sqrt(40*A)))/2);for(N=C;N>0;N--)w=N*y*T+R,R=T,T=w,n.abs(T)>1e10&&(T*=1e-10,R*=1e-10,m*=1e-10),N==A&&(m=R);return m*=g(E,0)/T,E<0&&A%2?-m:m}}(),u=function(){var o=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),s=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse();function l(g){return g<=2?-n.log(g/2)*p(g,0)+r(o,g*g/4):n.exp(-g)/n.sqrt(g)*r(s,2/g)}var f=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),v=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();function d(g){return g<=2?n.log(g/2)*p(g,1)+1/g*r(f,g*g/4):n.exp(-g)/n.sqrt(g)*r(v,2/g)}return a(l,d,"BESSELK",2,1)}();e.besselj=c,e.bessely=h,e.besseli=p,e.besselk=u})})(Yo);var Ko={exports:{}};(function(t,e){(function(n,r){t.exports=r()})(Io,function(){var n=function(r,i){var a=Array.prototype.concat,c=Array.prototype.slice,h=Object.prototype.toString;function p(A,m){var N=A>m?A:m;return r.pow(10,17-~~(r.log(N>0?N:-N)*r.LOG10E))}var u=Array.isArray||function(m){return h.call(m)==="[object Array]"};function o(A){return h.call(A)==="[object Function]"}function s(A){return typeof A=="number"?A-A===0:!1}function l(A){return a.apply([],A)}function f(){return new f._init(arguments)}f.fn=f.prototype,f._init=function(m){if(u(m[0]))if(u(m[0][0])){o(m[1])&&(m[0]=f.map(m[0],m[1]));for(var N=0;N=0;N--,R++)y[R]=[m[R][N]];return y},f.transpose=function(m){var N=[],y,R,T,w,C;for(u(m[0])||(m=[m]),R=m.length,T=m[0].length,C=0;C0&&(C[R][0]=m[R][0]),M=1;MN&&y>0)return[];if(y>0)for(T=m;TN;T+=y)R.push(T);return R},f.slice=function(){function A(N,y,R,T){var w,C=[],M=N.length;if(y===i&&R===i&&T===i)return f.copy(N);if(y=y||0,R=R||N.length,y=y>=0?y:M+y,R=R>=0?R:M+R,T=T||1,y===R||T===0)return[];if(yR&&T>0)return[];if(T>0)for(w=y;wR;w+=T)C.push(N[w]);return C}function m(N,y){var R,T;if(y=y||{},s(y.row)){if(s(y.col))return N[y.row][y.col];var w=f.rowa(N,y.row);return R=y.col||{},A(w,R.start,R.end,R.step)}if(s(y.col)){var C=f.cola(N,y.col);return T=y.row||{},A(C,T.start,T.end,T.step)}T=y.row||{},R=y.col||{};var M=A(N,T.start,T.end,T.step);return M.map(function(_){return A(_,R.start,R.end,R.step)})}return m}(),f.sliceAssign=function(m,N,y){var R,T;if(s(N.row)){if(s(N.col))return m[N.row][N.col]=y;N.col=N.col||{},N.col.start=N.col.start||0,N.col.end=N.col.end||m[0].length,N.col.step=N.col.step||1,R=f.arange(N.col.start,r.min(m.length,N.col.end),N.col.step);var w=N.row;return R.forEach(function(M,_){m[w][M]=y[_]}),m}if(s(N.col)){N.row=N.row||{},N.row.start=N.row.start||0,N.row.end=N.row.end||m.length,N.row.step=N.row.step||1,T=f.arange(N.row.start,r.min(m[0].length,N.row.end),N.row.step);var C=N.col;return T.forEach(function(M,_){m[M][C]=y[_]}),m}return y[0].length===i&&(y=[y]),N.row.start=N.row.start||0,N.row.end=N.row.end||m.length,N.row.step=N.row.step||1,N.col.start=N.col.start||0,N.col.end=N.col.end||m[0].length,N.col.step=N.col.step||1,T=f.arange(N.row.start,r.min(m.length,N.row.end),N.row.step),R=f.arange(N.col.start,r.min(m[0].length,N.col.end),N.col.step),T.forEach(function(M,_){R.forEach(function(W,F){m[M][W]=y[_][F]})}),m},f.diagonal=function(m){var N=f.zeros(m.length,m.length);return m.forEach(function(y,R){N[R][R]=y}),N},f.copy=function(m){return m.map(function(N){return s(N)?N:N.map(function(y){return y})})};var E=f.prototype;return E.length=0,E.push=Array.prototype.push,E.sort=Array.prototype.sort,E.splice=Array.prototype.splice,E.slice=Array.prototype.slice,E.toArray=function(){return this.length>1?c.call(this):c.call(this)[0]},E.map=function(m,N){return f(f.map(this,m,N))},E.cumreduce=function(m,N){return f(f.cumreduce(this,m,N))},E.alter=function(m){return f.alter(this,m),this},function(A){for(var m=0;m=0;)s+=o[l];return s},r.sumsqrd=function(o){for(var s=0,l=o.length;--l>=0;)s+=o[l]*o[l];return s},r.sumsqerr=function(o){for(var s=r.mean(o),l=0,f=o.length,v;--f>=0;)v=o[f]-s,l+=v*v;return l},r.sumrow=function(o){for(var s=0,l=o.length;--l>=0;)s+=o[l];return s},r.product=function(o){for(var s=1,l=o.length;--l>=0;)s*=o[l];return s},r.min=function(o){for(var s=o[0],l=0;++ls&&(s=o[l]);return s},r.unique=function(o){for(var s={},l=[],f=0;fv?(g=[l[E]],v=f,d=0):f===v&&(g.push(l[E]),d++),f=1);return d===0?g[0]:g},r.range=function(o){return r.max(o)-r.min(o)},r.variance=function(o,s){return r.sumsqerr(o)/(o.length-(s?1:0))},r.pooledvariance=function(o){var s=o.reduce(function(f,v){return f+r.sumsqerr(v)},0),l=o.reduce(function(f,v){return f+v.length},0);return s/(l-o.length)},r.deviation=function(u){for(var o=r.mean(u),s=u.length,l=new Array(s),f=0;f=0;f--)l.push(i.abs(o[f]-s));return r.mean(l)},r.meddev=function(o){for(var s=r.median(o),l=[],f=o.length-1;f>=0;f--)l.push(i.abs(o[f]-s));return r.median(l)},r.coeffvar=function(o){return r.stdev(o)/r.mean(o)},r.quartiles=function(o){var s=o.length,l=o.slice().sort(c);return[l[i.round(s/4)-1],l[i.round(s/2)-1],l[i.round(s*3/4)-1]]},r.quantiles=function(o,s,l,f){var v=o.slice().sort(c),d=[s.length],g=o.length,E,A,m,N,y,R;for(typeof l>"u"&&(l=3/8),typeof f>"u"&&(f=3/8),E=0;E1){for(g=l===!0?this:this.transpose();d1){for(s!=="sumrow"&&(g=l===!0?this:this.transpose());d1){for(v=v.transpose();f=0;l--)s*=p,s+=v[l];if(o=s/h+.5*i.log(u)+(h-.5)*i.log(h)-h,c<=7)for(l=1;l<=f;l++)o-=i.log(h-1),h-=1;return o},r.gammafn=function(c){var h=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],p=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],u=!1,o=0,s=0,l=0,f=c,v,d,g,E;if(c>171.6243769536076)return 1/0;if(f<=0)if(E=f%1+36e-17,E)u=(f&1?-1:1)*i.PI/i.sin(i.PI*E),f=1-f;else return 1/0;for(g=f,f<1?d=f++:d=(f-=o=(f|0)-1)-1,v=0;v<8;++v)l=(l+h[v])*d,s=s*d+p[v];if(E=l/s+1,gf)for(v=0;v=1?c:1/c)*8.5+c*.4+17),A;if(h<0||c<=0)return NaN;if(h170||h>170?i.exp(r.combinationln(c,h)):r.factorial(c)/r.factorial(h)/r.factorial(c-h)},r.combinationln=function(c,h){return r.factorialln(c)-r.factorialln(h)-r.factorialln(c-h)},r.permutation=function(c,h){return r.factorial(c)/r.factorial(c-h)},r.betafn=function(c,h){if(!(c<=0||h<=0))return c+h>170?i.exp(r.betaln(c,h)):r.gammafn(c)*r.gammafn(h)/r.gammafn(c+h)},r.betaln=function(c,h){return r.gammaln(c)+r.gammaln(h)-r.gammaln(c+h)},r.betacf=function(c,h,p){var u=1e-30,o=1,s=h+p,l=h+1,f=h-1,v=1,d=1-s*c/l,g,E,A,m;for(i.abs(d)=1)return i.max(100,h+100*i.sqrt(h));if(c<=0)return 0;for(h>1?(E=i.log(u),A=i.exp(u*(E-1)-s),g=c<.5?c:1-c,v=i.sqrt(-2*i.log(g)),l=(2.30753+v*.27061)/(1+v*(.99229+v*.04481))-v,c<.5&&(l=-l),l=i.max(.001,h*i.pow(1-1/(9*h)-l/(3*i.sqrt(h)),3))):(v=1-h*(.253+h*.12),c1?v=A*i.exp(-(l-u)+u*(i.log(l)-E)):v=i.exp(-l+u*i.log(l)-s),d=f/v,l-=v=d/(1-.5*i.min(1,d*((h-1)/l-1))),l<=0&&(l=.5*(l+v)),i.abs(v)0;p--)v=o,o=f*o-s+h[p],s=v;return d=l*i.exp(-c*c+.5*(h[0]+f*o)-s),u?d-1:1-d},r.erfc=function(c){return 1-r.erf(c)},r.erfcinv=function(c){var h=0,p,u,o,s;if(c>=2)return-100;if(c<=0)return 100;for(s=c<1?c:2-c,o=i.sqrt(-2*i.log(s/2)),p=-.70711*((2.30753+o*.27061)/(1+o*(.99229+o*.04481))-o);h<2;h++)u=r.erfc(p)-s,p+=u/(1.1283791670955126*i.exp(-p*p)-p*u);return c<1?p:-p},r.ibetainv=function(c,h,p){var u=1e-8,o=h-1,s=p-1,l=0,f,v,d,g,E,A,m,N,y,R,T;if(c<=0)return 0;if(c>=1)return 1;for(h>=1&&p>=1?(d=c<.5?c:1-c,g=i.sqrt(-2*i.log(d)),m=(2.30753+g*.27061)/(1+g*(.99229+g*.04481))-g,c<.5&&(m=-m),N=(m*m-3)/6,y=2/(1/(2*h-1)+1/(2*p-1)),R=m*i.sqrt(N+y)/y-(1/(2*p-1)-1/(2*h-1))*(N+5/6-2/(3*y)),m=h/(h+p*i.exp(2*R))):(f=i.log(h/(h+p)),v=i.log(p/(h+p)),g=i.exp(h*f)/h,E=i.exp(p*v)/p,R=g+E,c=1&&(m=.5*(m+g+1)),i.abs(g)0)break}return m},r.ibeta=function(c,h,p){var u=c===0||c===1?0:i.exp(r.gammaln(h+p)-r.gammaln(h)-r.gammaln(p)+h*i.log(c)+p*i.log(1-c));return c<0||c>1?!1:c<(h+1)/(h+p+2)?u*r.betacf(c,h,p)/h:1-u*r.betacf(1-c,p,h)/p},r.randn=function(c,h){var p,u,o,s,l;if(h||(h=c),c)return r.create(c,h,function(){return r.randn()});do p=r._random_fn(),u=1.7156*(r._random_fn()-.5),o=p-.449871,s=i.abs(u)+.386595,l=o*o+s*(.196*s-.25472*o);while(l>.27597&&(l>.27846||u*u>-4*i.log(p)*p*p));return u/p},r.randg=function(c,h,p){var u=c,o,s,l,f,v,d;if(p||(p=h),c||(c=1),h)return d=r.zeros(h,p),d.alter(function(){return r.randg(c)}),d;c<1&&(c+=1),o=c-1/3,s=1/i.sqrt(9*o);do{do v=r.randn(),f=1+s*v;while(f<=0);f=f*f*f,l=r._random_fn()}while(l>1-.331*i.pow(v,4)&&i.log(l)>.5*v*v+o*(1-f+i.log(f)));if(c==u)return o*f;do l=r._random_fn();while(l===0);return i.pow(l,1/u)*o*f},function(a){for(var c=0;c1||o<0?0:s==1&&l==1?1:s<512&&l<512?i.pow(o,s-1)*i.pow(1-o,l-1)/r.betafn(s,l):i.exp((s-1)*i.log(o)+(l-1)*i.log(1-o)-r.betaln(s,l))},cdf:function(o,s,l){return o>1||o<0?(o>1)*1:r.ibeta(o,s,l)},inv:function(o,s,l){return r.ibetainv(o,s,l)},mean:function(o,s){return o/(o+s)},median:function(o,s){return r.ibetainv(.5,o,s)},mode:function(o,s){return(o-1)/(o+s-2)},sample:function(o,s){var l=r.randg(o);return l/(l+r.randg(s))},variance:function(o,s){return o*s/(i.pow(o+s,2)*(o+s+1))}}),r.extend(r.centralF,{pdf:function(o,s,l){var f,v,d;return o<0?0:s<=2?o===0&&s<2?1/0:o===0&&s===2?1:1/r.betafn(s/2,l/2)*i.pow(s/l,s/2)*i.pow(o,s/2-1)*i.pow(1+s/l*o,-(s+l)/2):(f=s*o/(l+o*s),v=l/(l+o*s),d=s*v/2,d*r.binomial.pdf((s-2)/2,(s+l-2)/2,f))},cdf:function(o,s,l){return o<0?0:r.ibeta(s*o/(s*o+l),s/2,l/2)},inv:function(o,s,l){return l/(s*(1/r.ibetainv(o,s/2,l/2)-1))},mean:function(o,s){return s>2?s/(s-2):void 0},mode:function(o,s){return o>2?s*(o-2)/(o*(s+2)):void 0},sample:function(o,s){var l=r.randg(o/2)*2,f=r.randg(s/2)*2;return l/o/(f/s)},variance:function(o,s){if(!(s<=4))return 2*s*s*(o+s-2)/(o*(s-2)*(s-2)*(s-4))}}),r.extend(r.cauchy,{pdf:function(o,s,l){return l<0?0:l/(i.pow(o-s,2)+i.pow(l,2))/i.PI},cdf:function(o,s,l){return i.atan((o-s)/l)/i.PI+.5},inv:function(u,o,s){return o+s*i.tan(i.PI*(u-.5))},median:function(o){return o},mode:function(o){return o},sample:function(o,s){return r.randn()*i.sqrt(1/(2*r.randg(.5)))*s+o}}),r.extend(r.chisquare,{pdf:function(o,s){return o<0?0:o===0&&s===2?.5:i.exp((s/2-1)*i.log(o)-o/2-s/2*i.log(2)-r.gammaln(s/2))},cdf:function(o,s){return o<0?0:r.lowRegGamma(s/2,o/2)},inv:function(u,o){return 2*r.gammapinv(u,.5*o)},mean:function(u){return u},median:function(o){return o*i.pow(1-2/(9*o),3)},mode:function(o){return o-2>0?o-2:0},sample:function(o){return r.randg(o/2)*2},variance:function(o){return 2*o}}),r.extend(r.exponential,{pdf:function(o,s){return o<0?0:s*i.exp(-s*o)},cdf:function(o,s){return o<0?0:1-i.exp(-s*o)},inv:function(u,o){return-i.log(1-u)/o},mean:function(u){return 1/u},median:function(u){return 1/u*i.log(2)},mode:function(){return 0},sample:function(o){return-1/o*i.log(r._random_fn())},variance:function(u){return i.pow(u,-2)}}),r.extend(r.gamma,{pdf:function(o,s,l){return o<0?0:o===0&&s===1?1/l:i.exp((s-1)*i.log(o)-o/l-r.gammaln(s)-s*i.log(l))},cdf:function(o,s,l){return o<0?0:r.lowRegGamma(s,o/l)},inv:function(u,o,s){return r.gammapinv(u,o)*s},mean:function(u,o){return u*o},mode:function(o,s){if(o>1)return(o-1)*s},sample:function(o,s){return r.randg(o)*s},variance:function(o,s){return o*s*s}}),r.extend(r.invgamma,{pdf:function(o,s,l){return o<=0?0:i.exp(-(s+1)*i.log(o)-l/o-r.gammaln(s)+s*i.log(l))},cdf:function(o,s,l){return o<=0?0:1-r.lowRegGamma(s,l/o)},inv:function(u,o,s){return s/r.gammapinv(1-u,o)},mean:function(u,o){return u>1?o/(u-1):void 0},mode:function(o,s){return s/(o+1)},sample:function(o,s){return s/r.randg(o)},variance:function(o,s){if(!(o<=2))return s*s/((o-1)*(o-1)*(o-2))}}),r.extend(r.kumaraswamy,{pdf:function(o,s,l){return o===0&&s===1?l:o===1&&l===1?s:i.exp(i.log(s)+i.log(l)+(s-1)*i.log(o)+(l-1)*i.log(1-i.pow(o,s)))},cdf:function(o,s,l){return o<0?0:o>1?1:1-i.pow(1-i.pow(o,s),l)},inv:function(o,s,l){return i.pow(1-i.pow(1-o,1/l),1/s)},mean:function(u,o){return o*r.gammafn(1+1/u)*r.gammafn(o)/r.gammafn(1+1/u+o)},median:function(o,s){return i.pow(1-i.pow(2,-1/s),1/o)},mode:function(o,s){if(o>=1&&s>=1&&o!==1&&s!==1)return i.pow((o-1)/(o*s-1),1/o)},variance:function(){throw new Error("variance not yet implemented")}}),r.extend(r.lognormal,{pdf:function(o,s,l){return o<=0?0:i.exp(-i.log(o)-.5*i.log(2*i.PI)-i.log(l)-i.pow(i.log(o)-s,2)/(2*l*l))},cdf:function(o,s,l){return o<0?0:.5+.5*r.erf((i.log(o)-s)/i.sqrt(2*l*l))},inv:function(u,o,s){return i.exp(-1.4142135623730951*s*r.erfcinv(2*u)+o)},mean:function(o,s){return i.exp(o+s*s/2)},median:function(o){return i.exp(o)},mode:function(o,s){return i.exp(o-s*s)},sample:function(o,s){return i.exp(r.randn()*s+o)},variance:function(o,s){return(i.exp(s*s)-1)*i.exp(2*o+s*s)}}),r.extend(r.noncentralt,{pdf:function(o,s,l){var f=1e-14;return i.abs(l)f||E>f;)A=E,N>0&&(y*=l*l/(2*N),R*=l*l/(2*(N+1/2))),E=y*r.beta.cdf(m,N+.5,s/2)+R*r.beta.cdf(m,N+1,s/2),g+=.5*E,N++;return d?1-g:g}}),r.extend(r.normal,{pdf:function(o,s,l){return i.exp(-.5*i.log(2*i.PI)-i.log(l)-i.pow(o-s,2)/(2*l*l))},cdf:function(o,s,l){return .5*(1+r.erf((o-s)/i.sqrt(2*l*l)))},inv:function(u,o,s){return-1.4142135623730951*s*r.erfcinv(2*u)+o},mean:function(u){return u},median:function(o){return o},mode:function(u){return u},sample:function(o,s){return r.randn()*s+o},variance:function(u,o){return o*o}}),r.extend(r.pareto,{pdf:function(o,s,l){return o1e100?1e100:s,1/(i.sqrt(s)*r.betafn(.5,s/2))*i.pow(1+o*o/s,-((s+1)/2))},cdf:function(o,s){var l=s/2;return r.ibeta((o+i.sqrt(o*o+s))/(2*i.sqrt(o*o+s)),l,l)},inv:function(u,o){var s=r.ibetainv(2*i.min(u,1-u),.5*o,.5);return s=i.sqrt(o*(1-s)/s),u>.5?s:-s},mean:function(o){return o>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(o){return r.randn()*i.sqrt(o/(2*r.randg(o/2)))},variance:function(o){return o>2?o/(o-2):o>1?1/0:void 0}}),r.extend(r.weibull,{pdf:function(o,s,l){return o<0||s<0||l<0?0:l/s*i.pow(o/s,l-1)*i.exp(-i.pow(o/s,l))},cdf:function(o,s,l){return o<0?0:1-i.exp(-i.pow(o/s,l))},inv:function(u,o,s){return o*i.pow(-i.log(1-u),1/s)},mean:function(u,o){return u*r.gammafn(1+1/o)},median:function(o,s){return o*i.pow(i.log(2),1/s)},mode:function(o,s){return s<=1?0:o*i.pow((s-1)/s,1/s)},sample:function(o,s){return o*i.pow(-i.log(r._random_fn()),1/s)},variance:function(o,s){return o*o*r.gammafn(1+2/s)-i.pow(r.weibull.mean(o,s),2)}}),r.extend(r.uniform,{pdf:function(o,s,l){return ol?0:1/(l-s)},cdf:function(o,s,l){return ol;)A=d,m=-(o+E)*(o+s+E)*u/(o+2*E)/(o+2*E+1),f=d+m*f,v=g+m*v,E=E+1,m=E*(s-E)*u/(o+2*E-1)/(o+2*E),d=f+m*d,g=v+m*g,f=f/g,v=v/g,d=d/g,g=1;return d/o}r.extend(r.binomial,{pdf:function(o,s,l){return l===0||l===1?s*l===o?1:0:r.combination(s,o)*i.pow(l,o)*i.pow(1-l,s-o)},cdf:function(o,s,l){var f,v=1e-10;if(o<0)return 0;if(o>=s)return 1;if(l<0||l>1||s<=0)return NaN;o=i.floor(o);var d=l,g=o+1,E=s-o,A=g+E,m=i.exp(r.gammaln(A)-r.gammaln(E)-r.gammaln(g)+g*i.log(d)+E*i.log(1-d));return d<(g+1)/(A+2)?f=m*a(d,g,E,v):f=1-m*a(1-d,E,g,v),i.round((1-f)*(1/v))/(1/v)}}),r.extend(r.negbin,{pdf:function(o,s,l){return o!==o>>>0?!1:o<0?0:r.combination(o+s-1,s-1)*i.pow(1-l,o)*i.pow(l,s)},cdf:function(o,s,l){var f=0,v=0;if(o<0)return 0;for(;v<=o;v++)f+=r.negbin.pdf(v,s,l);return f}}),r.extend(r.hypgeom,{pdf:function(o,s,l,f){if(o!==o|0)return!1;if(o<0||of||o>l)return 0;if(l*2>s)return f*2>s?r.hypgeom.pdf(s-l-f+o,s,s-l,s-f):r.hypgeom.pdf(f-o,s,s-l,f);if(f*2>s)return r.hypgeom.pdf(l-o,s,l,s-f);if(l1&&d=f||o>=l)return 1;if(l*2>s)return f*2>s?r.hypgeom.cdf(s-l-f+o,s,s-l,s-f):1-r.hypgeom.cdf(f-o-1,s,s-l,f);if(f*2>s)return 1-r.hypgeom.cdf(l-o-1,s,l,s-f);if(l1&&gf);return l-1},sampleLarge:function(o){var s=o,l,f,v,d,g,E,A,m,N,y;for(d=i.sqrt(s),g=i.log(s),A=.931+2.53*d,E=-.059+.02483*A,m=1.1239+1.1328/(A-3.4),N=.9277-3.6224/(A-2);;){if(f=i.random()-.5,v=i.random(),y=.5-i.abs(f),l=i.floor((2*E/y+A)*f+s+.43),y>=.07&&v<=N)return l;if(!(l<0||y<.013&&v>y)&&i.log(v)+i.log(m)-i.log(E/(y*y)+A)<=-s+l*g-r.loggam(l+1))return l}},sample:function(o){return o<10?this.sampleSmall(o):this.sampleLarge(o)}}),r.extend(r.triangular,{pdf:function(o,s,l,f){return l<=s||fl?NaN:ol?0:ol?NaN:o<=s?0:o>=l?1:o<=f?i.pow(o-s,2)/((l-s)*(f-s)):1-i.pow(l-o,2)/((l-s)*(l-f))},inv:function(o,s,l,f){return l<=s||fl?NaN:o<=(f-s)/(l-s)?s+(l-s)*i.sqrt(o*((f-s)/(l-s))):s+(l-s)*(1-i.sqrt((1-o)*(1-(f-s)/(l-s))))},mean:function(o,s,l){return(o+s+l)/3},median:function(o,s,l){if(l<=(o+s)/2)return s-i.sqrt((s-o)*(s-l))/i.sqrt(2);if(l>(o+s)/2)return o+i.sqrt((s-o)*(l-o))/i.sqrt(2)},mode:function(o,s,l){return l},sample:function(o,s,l){var f=r._random_fn();return f<(l-o)/(s-o)?o+i.sqrt(f*(s-o)*(l-o)):s-i.sqrt((1-f)*(s-o)*(s-l))},variance:function(o,s,l){return(o*o+s*s+l*l-o*s-o*l-s*l)/18}}),r.extend(r.arcsine,{pdf:function(o,s,l){return l<=s?NaN:o<=s||o>=l?0:2/i.PI*i.pow(i.pow(l-s,2)-i.pow(2*o-s-l,2),-.5)},cdf:function(o,s,l){return o=E)return 1;var w=2*r.normal.cdf(T,0,1,1,0)-1;w>=i.exp(d/s)?w=i.pow(w,s):w=0;var C;u>A?C=m:C=N;for(var M=T,_=(E-T)/C,W=M+_,F=0,S=s-1,G=1;G<=C;G++){for(var J=0,le=.5*(W+M),nt=.5*(W-M),Ae=1;Ae<=l;Ae++){var Be,Fe;fg)break;var Et=2*r.normal.cdf(Ee,0,1,1,0),bt=2*r.normal.cdf(Ee,u,1,1,0),mt=Et*.5-bt*.5;mt>=i.exp(v/S)&&(mt=R[Be-1]*i.exp(-(.5*ue))*i.pow(mt,S),J+=mt)}J*=2*nt*s/i.sqrt(2*i.PI),F+=J,M=W,W+=_}return w+=F,w<=i.exp(v/o)?0:(w=i.pow(w,o),w>=1?1:w)}function p(u,o,s){var l=.322232421088,f=.099348462606,v=-1,d=.588581570495,g=-.342242088547,E=.531103462366,A=-.204231210125,m=.10353775285,N=-453642210148e-16,y=.0038560700634,R=.8832,T=.2368,w=1.214,C=1.208,M=1.4142,_=120,W=.5-.5*u,F=i.sqrt(i.log(1/(W*W))),S=F+((((F*N+A)*F+g)*F+v)*F+l)/((((F*y+m)*F+E)*F+d)*F+f);s<_&&(S+=(S*S*S+S)/s/4);var G=R-T*S;return s<_&&(G+=-w/s+C*S/s),S*(G*i.log(o-1)+M)}r.extend(r.tukey,{cdf:function(o,s,l){var f=1,v=s,d=16,g=8,E=-30,A=1e-14,m=100,N=800,y=5e3,R=25e3,T=1,w=.5,C=.25,M=.125,_=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],W=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(o<=0)return 0;if(l<2||f<1||v<2)return NaN;if(!Number.isFinite(o))return 1;if(l>R)return h(o,f,v);var F=l*.5,S=F*i.log(l)-l*i.log(2)-r.gammaln(F),G=F-1,J=l*.25,le;l<=m?le=T:l<=N?le=w:l<=y?le=C:le=M,S+=i.log(le);for(var nt=0,Ae=1;Ae<=50;Ae++){for(var Be=0,Fe=(2*Ae-1)*le,rt=1;rt<=d;rt++){var Ee,ue;g=E){g=1&&Be<=A)break;nt+=Be}if(Be>A)throw new Error("tukey.cdf failed to converge");return nt>1&&(nt=1),nt},inv:function(u,o,s){var l=1,f=o,v=1e-4,d=50;if(s<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 g=p(u,f,s),E=r.tukey.cdf(g,o,s)-u,A;E>0?A=i.max(0,g-1):A=g+1;for(var m=r.tukey.cdf(A,o,s)-u,N,y=1;ys&&(l[f-1][v-1]=u[f][v])}var d=s%2?-1:1;o+=p(l)*u[0][s]*d}return o},gauss_elimination:function(u,o){var s=0,l=0,f=u.length,v=u[0].length,d=1,g=0,E=[],A,m,N,y;for(u=r.aug(u,o),A=u[0].length,s=0;s=0;s--){for(g=0,l=s+1;l<=f-1;l++)g=g+E[l]*u[s][l];E[s]=(u[s][A-1]-g)/u[s][s]}return E},gauss_jordan:function(u,o){var s=r.aug(u,o),l=s.length,f=s[0].length,v=0,d,g,E;for(g=0;gi.abs(s[A][g])&&(A=E);var m=s[g];for(s[g]=s[A],s[A]=m,E=g+1;E=0;g--){for(v=s[g][g],E=0;Eg-1;d--)s[E][d]-=s[g][d]*s[E][g]/v;for(s[g][g]/=v,d=l;dv?(g[f][v]=u[f][v],E[f][v]=A[f][v]=0):fl;)m=R,R=r.add(r.multiply(y,m),N),f++;return R},gauss_seidel:function(u,o,s,l){for(var f=0,v=u.length,d=[],g=[],E=[],A,m,N,y,R;fA?(d[f][A]=u[f][A],g[f][A]=E[f][A]=0):fl;)m=R,R=r.add(r.multiply(y,m),N),f=f+1;return R},SOR:function(u,o,s,l,f){for(var v=0,d=u.length,g=[],E=[],A=[],m,N,y,R,T;vm?(g[v][m]=u[v][m],E[v][m]=A[v][m]=0):vl;)N=T,T=r.add(r.multiply(R,N),y),v++;return T},householder:function(u){for(var o=u.length,s=u[0].length,l=0,f=[],v=[],d,g,E,A,m;l0?-1:1,d=m*i.sqrt(d),g=i.sqrt((d*d-u[l+1][l]*d)/2),f=r.zeros(o,1),f[l+1][0]=(u[l+1][l]-d)/(2*g),E=l+2;E0?i.PI/4:-i.PI/4:N=i.atan(2*u[E][A]/(u[E][E]-u[A][A]))/2,y=r.identity(s,s),y[E][E]=i.cos(N),y[E][A]=-i.sin(N),y[A][E]=i.sin(N),y[A][A]=i.cos(N),l=r.multiply(l,y),v=r.multiply(r.multiply(r.inv(y),u),y),u=v,o=0,d=1;d.001&&(o=1)}for(d=0;d=v;)A=f(u,s+l),m=f(u,s),g[d]=(o[A]-2*o[m]+o[2*m-A])/(l*l),l/=2,d++;for(y=g.length,N=1;y!=1;){for(R=0;Rs);v++);return v-=1,o[v]+(s-u[v])*N[v]+r.sq(s-u[v])*A[v]+(s-u[v])*r.sq(s-u[v])*y[v]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(u){var o=u.length,s=u[0].length,l=0,f,v,d=[],g=[],E=[],A=[],m=[],N=[],y=[],R=[],T=[],w=[];for(l=0;l2?(s=r.zscore(o[0],o[1],o[2]),o[3]===1?r.normal.cdf(-i.abs(s),0,1):r.normal.cdf(-i.abs(s),0,1)*2):(s=o[0],o[1]===1?r.normal.cdf(-i.abs(s),0,1):r.normal.cdf(-i.abs(s),0,1)*2)}}),r.extend(r.fn,{zscore:function(o,s){return(o-this.mean())/this.stdev(s)},ztest:function(o,s,l){var f=i.abs(this.zscore(o,l));return s===1?r.normal.cdf(-f,0,1):r.normal.cdf(-f,0,1)*2}}),r.extend({tscore:function(){var o=a.call(arguments);return o.length===4?(o[0]-o[1])/(o[2]/i.sqrt(o[3])):(o[0]-r.mean(o[1]))/(r.stdev(o[1],!0)/i.sqrt(o[1].length))},ttest:function(){var o=a.call(arguments),s;return o.length===5?(s=i.abs(r.tscore(o[0],o[1],o[2],o[3])),o[4]===1?r.studentt.cdf(-s,o[3]-1):r.studentt.cdf(-s,o[3]-1)*2):c(o[1])?(s=i.abs(o[0]),o[2]==1?r.studentt.cdf(-s,o[1]-1):r.studentt.cdf(-s,o[1]-1)*2):(s=i.abs(r.tscore(o[0],o[1])),o[2]==1?r.studentt.cdf(-s,o[1].length-1):r.studentt.cdf(-s,o[1].length-1)*2)}}),r.extend(r.fn,{tscore:function(o){return(o-this.mean())/(this.stdev(!0)/i.sqrt(this.cols()))},ttest:function(o,s){return s===1?1-r.studentt.cdf(i.abs(this.tscore(o)),this.cols()-1):r.studentt.cdf(-i.abs(this.tscore(o)),this.cols()-1)*2}}),r.extend({anovafscore:function(){var o=a.call(arguments),s,l,f,v,d,g,E,A;if(o.length===1){for(d=new Array(o[0].length),E=0;E1||s>1||u<=0||s<=0)throw new Error("Proportions should be greater than 0 and less than 1");var f=(u*o+s*l)/(o+l),v=i.sqrt(f*(1-f)*(1/o+1/l));return(u-s)/v}r.extend(r.fn,{oneSidedDifferenceOfProportions:function(o,s,l,f){var v=p(o,s,l,f);return r.ztest(v,1)},twoSidedDifferenceOfProportions:function(o,s,l,f){var v=p(o,s,l,f);return r.ztest(v,2)}})}(n,Math),n.models=function(){function r(p){var u=p[0].length,o=n.arange(u).map(function(s){var l=n.arange(u).filter(function(f){return f!==s});return i(n.col(p,s).map(function(f){return f[0]}),n.col(p,l))});return o}function i(p,u){var o=p.length,s=u[0].length-1,l=o-s-1,f=n.lstsq(u,p),v=n.multiply(u,f.map(function(y){return[y]})).map(function(y){return y[0]}),d=n.subtract(p,v),g=n.mean(p),E=n.sum(v.map(function(y){return Math.pow(y-g,2)})),A=n.sum(p.map(function(y,R){return Math.pow(y-v[R],2)})),m=E+A,N=E/m;return{exog:u,endog:p,nobs:o,df_model:s,df_resid:l,coef:f,predict:v,resid:d,ybar:g,SST:m,SSE:E,SSR:A,R2:N}}function a(p){var u=r(p.exog),o=Math.sqrt(p.SSR/p.df_resid),s=u.map(function(g){var E=g.SST,A=g.R2;return o/Math.sqrt(E*(1-A))}),l=p.coef.map(function(g,E){return(g-0)/s[E]}),f=l.map(function(g){var E=n.studentt.cdf(g,p.df_resid);return(E>.5?1-E:E)*2}),v=n.studentt.inv(.975,p.df_resid),d=p.coef.map(function(g,E){var A=v*s[E];return[g-A,g+A]});return{se:s,t:l,p:f,sigmaHat:o,interval95:d}}function c(p){var u=p.R2/p.df_model/((1-p.R2)/p.df_resid),o=function(l,f,v){return n.beta.cdf(l/(v/f+l),f/2,v/2)},s=1-o(u,p.df_model,p.df_resid);return{F_statistic:u,pvalue:s}}function h(p,u){var o=i(p,u),s=a(o),l=c(o),f=1-(1-o.R2)*((o.nobs-1)/o.df_resid);return o.t=s,o.f=l,o.adjust_R2=f,o}return{ols:h}}(),n.extend({buildxmatrix:function(){for(var i=new Array(arguments.length),a=0;a1){for(u=[],c=0;c{if(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw D.NUM;return dn.besseli(t,e)},BESSELJ:(t,e)=>{if(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw D.NUM;return dn.besselj(t,e)},BESSELK:(t,e)=>{if(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw D.NUM;return dn.besselk(t,e)},BESSELY:(t,e)=>{if(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN),e=Math.trunc(e),e<0)throw D.NUM;return dn.bessely(t,e)},BIN2DEC:t=>{t=b.accept(t,H.NUMBER_NO_BOOLEAN);let e=t.toString();if(e.length>10)throw D.NUM;return e.length===10&&e.substring(0,1)==="1"?parseInt(e.substring(1),2)+vn:parseInt(e,2)},BIN2HEX:(t,e)=>{t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN,null);const n=t.toString();if(n.length>10)throw D.NUM;if(n.length===10&&n.substring(0,1)==="1")return(parseInt(n.substring(1),2)+0xfffffffe00).toString(16).toUpperCase();const r=parseInt(t,2).toString(16);if(e==null)return r.toUpperCase();if(e<0)throw D.NUM;if(e=Math.trunc(e),e>=r.length)return(Ke.REPT("0",e-r.length)+r).toUpperCase();throw D.NUM},BIN2OCT:(t,e)=>{t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER,null);let n=t.toString();if(n.length>10)throw D.NUM;if(n.length===10&&n.substr(0,1)==="1")return(parseInt(n.substr(1),2)+1073741312).toString(8);let r=parseInt(t,2).toString(8);if(e==null)return r.toUpperCase();if(e<0)throw D.NUM;if(e=Math.trunc(e),e>=r.length)return Ke.REPT("0",e-r.length)+r;throw D.NUM},BITAND:(t,e)=>{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER),t<0||e<0||Math.floor(t)!==t||Math.floor(e)!==e||t>0xffffffffffff||e>0xffffffffffff)throw D.NUM;return t&e},BITLSHIFT:(t,e)=>{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER),e=Math.trunc(e),Math.abs(e)>53||t<0||Math.floor(t)!==t||t>0xffffffffffff)throw D.NUM;const n=e>=0?t*2**e:Math.trunc(t/2**-e);if(n>0xffffffffffff)throw D.NUM;return n},BITOR:(t,e)=>{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER),t<0||e<0||Math.floor(t)!==t||Math.floor(e)!==e||t>0xffffffffffff||e>0xffffffffffff)throw D.NUM;return t|e},BITRSHIFT:(t,e)=>(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER),K.BITLSHIFT(t,-e)),BITXOR:(t,e)=>{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER),t<0||t>0xffffffffffff||Math.floor(t)!==t||e<0||e>0xffffffffffff||Math.floor(e)!==e)throw D.NUM;return t^e},COMPLEX:(t,e,n)=>{if(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN),n=b.accept(n,H.STRING,"i"),n!=="i"&&n!=="j")throw D.VALUE;if(t===0&&e===0)return 0;if(t===0)return e===1?n:e===-1?"-"+n:e.toString()+n;if(e===0)return t.toString();{let r=e>0?"+":"";return e===1?t.toString()+r+n:e===-1?t.toString()+r+"-"+n:t.toString()+r+e.toString()+n}},DEC2BIN:(t,e)=>{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER,null),tEr)throw D.NUM;if(t<0)return"1"+Ke.REPT("0",9-(512+t).toString(2).length)+(512+t).toString(2);let n=parseInt(t,10).toString(2);if(e==null)return n;if(e=Math.trunc(e),e<=0||e{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER,null),t<-549755813888||t>549755813888)throw D.NUM;if(t<0)return(1099511627776+t).toString(16).toUpperCase();let n=parseInt(t,10).toString(16);if(e==null)return n.toUpperCase();if(e=Math.trunc(e),e<=0||e{if(t=b.accept(t,H.NUMBER),e=b.accept(e,H.NUMBER,null),t<-536870912||t>536870912)throw D.NUM;if(t<0)return(t+1073741824).toString(8);let n=parseInt(t,10).toString(8);if(e==null)return n.toUpperCase();if(e=Math.trunc(e),e<=0||e(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN,0),t===e?1:0),ERF:(t,e)=>(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN,0),mi.erf(t)),ERFC:t=>(t=b.accept(t,H.NUMBER_NO_BOOLEAN),mi.erfc(t)),GESTEP:(t,e)=>(t=b.accept(t,H.NUMBER_NO_BOOLEAN),e=b.accept(e,H.NUMBER_NO_BOOLEAN,0),t>=e?1:0),HEX2BIN:(t,e)=>{if(t=b.accept(t,H.STRING),e=b.accept(e,H.NUMBER,null),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw D.NUM;let n=t.length===10&&t.substr(0,1).toLowerCase()==="f",r=n?parseInt(t,16)-1099511627776:parseInt(t,16);if(rEr)throw D.NUM;if(n)return"1"+Ke.REPT("0",9-(r+512).toString(2).length)+(r+512).toString(2);let i=r.toString(2);if(e==null)return i;if(e=Math.trunc(e),e<=0||e{if(t=b.accept(t,H.STRING),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw D.NUM;let e=parseInt(t,16);return e>=549755813888?e-1099511627776:e},HEX2OCT:(t,e)=>{if(t=b.accept(t,H.STRING),t.length>10||!/^[0-9a-fA-F]*$/.test(t))throw D.NUM;let n=K.HEX2DEC(t);if(n>Ga||n<$a)throw D.NUM;return K.DEC2OCT(n,e)},IMABS:t=>{const{real:e,im:n}=re(t);return Math.sqrt(Math.pow(e,2)+Math.pow(n,2))},IMAGINARY:t=>re(t).im,IMARGUMENT:t=>{const{real:e,im:n}=re(t);if(e===0&&n===0)throw D.DIV0;return e===0&&n>0?Math.PI/2:e===0&&n<0?-Math.PI/2:e<0&&n===0?Math.PI:e>0&&n===0?0:e>0?Math.atan(n/e):e<0&&n>0?Math.atan(n/e)+Math.PI:Math.atan(n/e)-Math.PI},IMCONJUGATE:t=>{const{real:e,im:n,unit:r}=re(t);return n!==0?K.COMPLEX(e,-n,r):""+e},IMCOS:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.cos(e)*(Math.exp(n)+Math.exp(-n))/2,a=-Math.sin(e)*(Math.exp(n)-Math.exp(-n))/2;return K.COMPLEX(i,a,r)},IMCOSH:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.cos(n)*(Math.exp(e)+Math.exp(-e))/2,a=-Math.sin(n)*(Math.exp(e)-Math.exp(-e))/2;return K.COMPLEX(i,-a,r)},IMCOT:t=>{t=b.accept(t);let e=K.IMCOS(t),n=K.IMSIN(t);return K.IMDIV(e,n)},IMCSC:t=>(t=b.accept(t),K.IMDIV("1",K.IMSIN(t))),IMCSCH:t=>(t=b.accept(t),K.IMDIV("1",K.IMSINH(t))),IMDIV:(t,e)=>{const n=re(t),r=n.real,i=n.im,a=n.unit,c=re(e),h=c.real,p=c.im,u=c.unit;if(h===0&&p===0||a!==u)throw D.NUM;let o=a,s=Math.pow(h,2)+Math.pow(p,2);return K.COMPLEX((r*h+i*p)/s,(i*h-r*p)/s,o)},IMEXP:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.exp(e);return K.COMPLEX(i*Math.cos(n),i*Math.sin(n),r)},IMLN:t=>{const{real:e,im:n,unit:r}=re(t);return K.COMPLEX(Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(n,2))),Math.atan(n/e),r)},IMLOG10:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(n,2)))/Math.log(10),a=Math.atan(n/e)/Math.log(10);return K.COMPLEX(i,a,r)},IMLOG2:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.log(Math.sqrt(Math.pow(e,2)+Math.pow(n,2)))/Math.log(2),a=Math.atan(n/e)/Math.log(2);return K.COMPLEX(i,a,r)},IMPOWER:(t,e)=>{let{unit:n}=re(t);e=b.accept(e,H.NUMBER_NO_BOOLEAN);let r=Math.pow(K.IMABS(t),e),i=K.IMARGUMENT(t),a=r*Math.cos(e*i),c=r*Math.sin(e*i);return K.COMPLEX(a,c,n)},IMPRODUCT:(...t)=>{let e,n=0;return b.flattenParams(t,null,!1,r=>{if(n===0)e=b.accept(r),re(e);else{const i=re(e),a=i.real,c=i.im,h=i.unit,p=re(r),u=p.real,o=p.im,s=p.unit;if(h!==s)throw D.VALUE;e=K.COMPLEX(a*u-c*o,a*o+c*u)}n++},1),e},IMREAL:t=>re(t).real,IMSEC:t=>K.IMDIV("1",K.IMCOS(t)),IMSECH:t=>K.IMDIV("1",K.IMCOSH(t)),IMSIN:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.sin(e)*(Math.exp(n)+Math.exp(-n))/2,a=Math.cos(e)*(Math.exp(n)-Math.exp(-n))/2;return K.COMPLEX(i,a,r)},IMSINH:t=>{const{real:e,im:n,unit:r}=re(t);let i=Math.cos(n)*(Math.exp(e)-Math.exp(-e))/2,a=Math.sin(n)*(Math.exp(e)+Math.exp(-e))/2;return K.COMPLEX(i,a,r)},IMSQRT:t=>{const{unit:e}=re(t);let n=Math.sqrt(K.IMABS(t)),r=K.IMARGUMENT(t);return K.COMPLEX(n*Math.cos(r/2),n*Math.sin(r/2),e)},IMSUB:(t,e)=>{const n=re(t),r=n.real,i=n.im,a=n.unit,c=re(e),h=c.real,p=c.im,u=c.unit;if(a!==u)throw D.VALUE;return K.COMPLEX(r-h,i-p,a)},IMSUM:(...t)=>{let e=0,n=0,r;return b.flattenParams(t,null,!1,i=>{const{real:a,im:c,unit:h}=re(i);if(r||(r=h),r!==h)throw D.VALUE;e+=a,n+=c}),K.COMPLEX(e,n,r)},IMTAN:t=>{const{unit:e}=re(t);return K.IMDIV(K.IMSIN(t),K.IMCOS(t),e)},OCT2BIN:(t,e)=>{if(t=b.accept(t,H.STRING),e=b.accept(e,H.NUMBER,null),t.length>10||e>10||e!==null&&e<0)throw D.NUM;e=Math.trunc(e);let n=t.length===10&&t.substring(0,1)==="7",r=K.OCT2DEC(t);if(rEr)return D.NUM;if(n)return"1"+Ke.REPT("0",9-(512+r).toString(2).length)+(512+r).toString(2);let i=r.toString(2);if(e===0)return i;if(e{if(t=b.accept(t,H.STRING),t.length>10)throw D.NUM;for(const n of t)if(n<"0"||n>"7")throw D.NUM;let e=parseInt(t,8);return e>=536870912?e-1073741824:e},OCT2HEX:(t,e)=>{if(t=b.accept(t,H.STRING),e=b.accept(e,H.NUMBER_NO_BOOLEAN,null),t.length>10)throw D.NUM;for(const i of t)if(i<"0"||i>"7")throw D.NUM;if(e=Math.trunc(e),e<0||e>10)throw D.NUM;let n=K.OCT2DEC(t),r=K.DEC2HEX(n);if(e===0)return r;if(e{if(t=X.accept(t,Oe.NUMBER),e=X.accept(e,Oe.NUMBER),n=X.accept(n,Oe.NUMBER,1),r=X.accept(r,Oe.BOOLEAN,!0),i=X.accept(i,Oe.STRING,""),t<1||e<1||n<1||n>4)throw te.VALUE;let a="";return i.length>0&&(/[^A-Za-z_.\d\u007F-\uFFFF]/.test(i)?a+=`'${i}'!`:a+=i+"!"),r?(a+=n===1||n===3?"$":"",a+=za.columnNumberToName(e),a+=n===1||n===2?"$":"",a+=t):(a+="R",a+=n===4||n===3?`[${t}]`:t,a+="C",a+=n===4||n===2?`[${e}]`:e),a},AREAS:t=>(t=X.accept(t),t instanceof Ri?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 te.VALUE;if(X.isCellRef(e))return e.ref.col;if(X.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 te.VALUE;if(X.isCellRef(e))return 1;if(X.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,n,r)=>{t=X.accept(t);try{e=X.accept(e,Oe.ARRAY,void 0,!1)}catch(a){throw a instanceof te?te.NA:a}if(n=X.accept(n,Oe.NUMBER),r=X.accept(r,Oe.BOOLEAN,!0),n<1)throw te.VALUE;if(e[n-1]===void 0)throw te.REF;const i=typeof t;if(r){let a=i===typeof e[0][0]?e[0][0]:null;for(let c=1;ct&&h>t)throw te.NA;if(h===t)return e[n-1][c];if(a!=null&&h>t&&a<=t)return e[n-1][c-1];a=h}}if(a==null)throw te.NA;return a}else{let a=-1;if(gn.isWildCard(t)?a=e[0].findIndex(c=>gn.toRegex(t,"i").test(c)):a=e[0].findIndex(c=>c===t),a===-1)throw te.NA;return e[n-1][a]}},INDEX:(t,e,n,r,i)=>{n=t.utils.extractRefValue(n),n={value:n.val,isArray:n.isArray},n=X.accept(n,Oe.NUMBER),n=Math.trunc(n),r==null?r=1:(r=t.utils.extractRefValue(r),r={value:r.val,isArray:r.isArray},r=X.accept(r,Oe.NUMBER,1),r=Math.trunc(r)),i==null?i=1:(i=t.utils.extractRefValue(i),i={value:i.val,isArray:i.isArray},i=X.accept(i,Oe.NUMBER,1),i=Math.trunc(i));let a=e;if(e instanceof Ri)a=e.refs[i-1];else if(i>1)throw te.REF;if(n===0&&r===0)return a;if(n===0){if(X.isRangeRef(a)){if(a.ref.to.col-a.ref.from.colc.push([h[r-1]])),c}}if(r===0){if(X.isRangeRef(a)){if(a.ref.to.row-a.ref.from.row1||r>1)throw te.REF;return{ref:{row:a.row+n-1,col:a.col+r-1}}}else if(Array.isArray(a)){if(a.length{},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 te.VALUE;if(X.isCellRef(e))return e.ref.row;if(X.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 te.VALUE;if(X.isCellRef(e))return 1;if(X.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=X.accept(t,Oe.ARRAY,void 0,!1);const e=[];for(let n=0;n{t=X.accept(t);try{e=X.accept(e,Oe.ARRAY,void 0,!1)}catch(a){throw a instanceof te?te.NA:a}if(n=X.accept(n,Oe.NUMBER),r=X.accept(r,Oe.BOOLEAN,!0),n<1)throw te.VALUE;if(e[0][n-1]===void 0)throw te.REF;const i=typeof t;if(r){let a=i===typeof e[0][0]?e[0][0]:null;for(let c=1;ct&&p>t)throw te.NA;if(p===t)return h[n-1];if(a!=null&&p>t&&a<=t)return e[c-1][n-1];a=p}}if(a==null)throw te.NA;return a}else{let a=-1;if(gn.isWildCard(t)?a=e.findIndex(c=>gn.toRegex(t,"i").test(c[0])):a=e.findIndex(c=>c[0]===t),a===-1)throw te.NA;return e[a][n-1]}}};var Qa=Xa;const lt=he(),{FormulaHelpers:Za,Types:Ja}=ge(),me=Za,ja={"#NULL!":1,"#DIV/0!":2,"#VALUE!":3,"#REF!":4,"#NAME?":5,"#NUM!":6,"#N/A":7},ec={CELL:(t,e)=>{},"ERROR.TYPE":t=>{if(t=me.accept(t),t instanceof lt)return ja[t.toString()];throw lt.NA},INFO:()=>{},ISBLANK:t=>t.ref?t.value==null||t.value==="":!1,ISERR:t=>(t=me.accept(t),t instanceof lt&&t.toString()!=="#N/A"),ISERROR:t=>(t=me.accept(t),t instanceof lt),ISEVEN:t=>(t=me.accept(t,Ja.NUMBER),t=Math.trunc(t),t%2===0),ISLOGICAL:t=>(t=me.accept(t),typeof t=="boolean"),ISNA:t=>(t=me.accept(t),t instanceof lt&&t.toString()==="#N/A"),ISNONTEXT:t=>(t=me.accept(t),typeof t!="string"),ISNUMBER:t=>(t=me.accept(t),typeof t=="number"),ISREF:t=>!t.ref||me.isCellRef(t)&&(t.ref.row>1048576||t.ref.col>16384)||me.isRangeRef(t)&&(t.ref.from.row>1048576||t.ref.from.col>16384||t.ref.to.row>1048576||t.ref.to.col>16384)?!1:(t=me.accept(t),!(t instanceof lt&&t.toString()==="#REF!")),ISTEXT:t=>(t=me.accept(t),typeof t=="string"),N:t=>{t=me.accept(t);const e=typeof t;if(e==="number")return t;if(e==="boolean")return Number(t);if(t instanceof lt)throw t;return 0},NA:()=>{throw lt.NA},TYPE:t=>{if(t.ref){if(me.isRangeRef(t))return 16;if(me.isCellRef(t)&&(t=me.accept(t),typeof t=="string"&&t.length===0))return 1}t=me.accept(t);const e=typeof t;if(e==="number")return 1;if(e==="string")return 2;if(e==="boolean")return 4;if(t instanceof lt)return 16;if(Array.isArray(t))return 64}};var tc=ec;const k=he(),{FormulaHelpers:nc,Types:I}=ge(),O=nc,B=zo,En=qo,rc=2.5066282746310002,Xo={"BETA.DIST":(t,e,n,r,i,a)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),i=O.accept(i,I.NUMBER,0),a=O.accept(a,I.NUMBER,1),e<=0||n<=0||ta||i===a)throw k.NUM;return t=(t-i)/(a-i),r?B.beta.cdf(t,e,n):B.beta.pdf(t,e,n)/(a-i)},"BETA.INV":(t,e,n,r,i)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.NUMBER,0),i=O.accept(i,I.NUMBER,1),e<=0||n<=0||t<=0||t>1)throw k.NUM;return B.beta.inv(t,e,n)*(i-r)+r},"BINOM.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),e<0||n<0||n>1||t<0||t>e)throw k.NUM;return r?B.binomial.cdf(t,e,n):B.binomial.pdf(t,e,n)},"BINOM.DIST.RANGE":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.NUMBER,n),t<0||e<0||e>1||n<0||n>t||rt)throw k.NUM;let i=0;for(let a=n;a<=r;a++)i+=En.COMBIN(t,a)*Math.pow(e,a)*Math.pow(1-e,t-a);return i},"BINOM.INV":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<0||e<0||e>1||n<0||n>1)throw k.NUM;let r=0;for(;r<=t;){if(B.binomial.cdf(r,t,e)>=n)return r;r++}},"CHISQ.DIST":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),e=Math.trunc(e),t<0||e<1||e>10**10)throw k.NUM;return n?B.chisquare.cdf(t,e):B.chisquare.pdf(t,e)},"CHISQ.DIST.RT":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),e=Math.trunc(e),t<0||e<1||e>10**10)throw k.NUM;return 1-B.chisquare.cdf(t,e)},"CHISQ.INV":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),e=Math.trunc(e),t<0||t>1||e<1||e>10**10)throw k.NUM;return B.chisquare.inv(t,e)},"CHISQ.INV.RT":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),e=Math.trunc(e),t<0||t>1||e<1||e>10**10)throw k.NUM;return B.chisquare.inv(1-t,e)},"CHISQ.TEST":(t,e)=>{const n=O.accept(t,I.ARRAY,void 0,!1,!1),r=O.accept(e,I.ARRAY,void 0,!1,!1);if(n.length!==r.length||n[0].length!==r[0].length||n.length===1&&n[0].length===1)throw k.NA;const i=n.length,a=n[0].length;let c=(i-1)*(a-1);i===1?c=a-1:c=i-1;let h=0;for(let l=0;l=2;)p=p*h/u,u=u-2;let o=p,s=c;for(;o>1e-15*p;)s=s+2,o=o*h/s,p=p+o;return 1-p},"CONFIDENCE.NORM":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),n=Math.trunc(n),t<=0||t>=1||e<=0||n<1)throw k.NUM;return B.normalci(1,t,e,n)[1]-1},"CONFIDENCE.T":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),n=Math.trunc(n),t<=0||t>=1||e<=0||n<1)throw k.NUM;if(n===1)throw k.DIV0;return B.tci(1,t,e,n)[1]-1},CORREL:(t,e)=>{if(t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0),t.length!==e.length)throw k.NA;const n=[],r=[];for(let i=0;i{if(t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0),t.length!==e.length)throw k.NA;const n=[],r=[];for(let h=0;h{if(t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0),t.length!==e.length)throw k.NA;const n=[],r=[];for(let i=0;i{let e=0,n=[];O.flattenParams(t,I.NUMBER,!0,(i,a)=>{typeof i=="number"&&(e+=i,n.push(i))});const r=e/n.length;e=0;for(let i=0;i{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.BOOLEAN),t<0||e<=0)throw k.NUM;return n?B.exponential.cdf(t,e):B.exponential.pdf(t,e)},"F.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),t<0||e<1||n<1)throw k.NUM;return e=Math.trunc(e),n=Math.trunc(n),r?B.centralF.cdf(t,e,n):B.centralF.pdf(t,e,n)},"F.DIST.RT":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<0||e<1||n<1)throw k.NUM;return e=Math.trunc(e),n=Math.trunc(n),1-B.centralF.cdf(t,e,n)},"F.INV":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<0||t>1||e<1||n<1)throw k.NUM;return e=Math.trunc(e),n=Math.trunc(n),B.centralF.inv(t,e,n)},"F.INV.RT":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<0||t>1||e<1||e>=Math.pow(10,10)||n<1||n>=Math.pow(10,10))throw k.NUM;return e=Math.trunc(e),n=Math.trunc(n),B.centralF.inv(1-t,e,n)},"F.TEST":(t,e)=>{t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0);const n=[],r=[];let i=0,a=0;for(let p=0;p{if(t=O.accept(t,I.NUMBER),t<=-1||t>=1)throw k.NUM;return Math.log((1+t)/(1-t))/2},FISHERINV:t=>{t=O.accept(t,I.NUMBER);let e=Math.exp(2*t);return(e-1)/(e+1)},FORECAST:(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.ARRAY,void 0,!0,!0),n=O.accept(n,I.ARRAY,void 0,!0,!0),n.length!==e.length)throw k.NA;const r=[],i=[];let a=!0;for(let l=0;l{},"FORECAST.ETS.CONFINT":()=>{},"FORECAST.ETS.SEASONALITY":()=>{},"FORECAST.ETS.STAT":()=>{},"FORECAST.LINEAR":(...t)=>Xo.FORECAST(...t),FREQUENCY:(t,e)=>{t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0);const n=[];for(let i=0;i{if(t=O.accept(t,I.NUMBER),t===0||t<0&&t===Math.trunc(t))throw k.NUM;return B.gammafn(t)},"GAMMA.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),t<0||e<=0||n<=0)throw k.NUM;return r?B.gamma.cdf(t,e,n,!0):B.gamma.pdf(t,e,n,!1)},"GAMMA.INV":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<0||t>1||e<=0||n<=0)throw k.NUM;return B.gamma.inv(t,e,n)},GAMMALN:t=>{if(t=O.accept(t,I.NUMBER),t<=0)throw k.NUM;return B.gammaln(t)},"GAMMALN.PRECISE":t=>{if(t=O.accept(t,I.NUMBER),t<=0)throw k.NUM;return B.gammaln(t)},GAUSS:t=>(t=O.accept(t,I.NUMBER),B.normal.cdf(t,0,1)-.5),GEOMEAN:(...t)=>{const e=[];return O.flattenParams(t,I.NUMBER,!0,(n,r)=>{typeof n=="number"&&e.push(n)}),B.geomean(e)},GROWTH:(t,e,n,r)=>{t=O.accept(t,I.ARRAY,void 0,!0,!0);for(let f=0;f{let e=0,n=0;return O.flattenParams(t,I.NUMBER,!0,(r,i)=>{typeof r=="number"&&(n+=1/r,e++)}),e/n},"HYPGEOM.DIST":(t,e,n,r,i)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.NUMBER),i=O.accept(i,I.BOOLEAN),t=Math.trunc(t),e=Math.trunc(e),n=Math.trunc(n),r=Math.trunc(r),r<=0||t<0||e<=0||n<=0||e>r||n>r||e{if(t=O.accept(t,I.ARRAY,void 0,!0,!0),e=O.accept(e,I.ARRAY,void 0,!0,!0),e.length!==t.length)throw k.NA;const n=[],r=[];for(let u=0;u{let e=0,n=[];O.flattenParams(t,I.NUMBER,!0,(a,c)=>{typeof a=="number"&&(e+=a,n.push(a))});const r=n.length;e/=r;let i=0;for(let a=0;a{},LOGEST:()=>{},"LOGNORM.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),t<=0||n<=0)throw k.NUM;return r?B.lognormal.cdf(t,e,n):B.lognormal.pdf(t,e,n)},"LOGNORM.INV":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<=0||t>=1||n<=0)throw k.NUM;return B.lognormal.inv(t,e,n)},"MODE.MULT":()=>{},"MODE.SNGL":()=>{},"NEGBINOM.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),t=Math.trunc(t),e=Math.trunc(e),n<0||n>1||t<0||e<1)throw k.NUM;return r?B.negbin.cdf(t,e,n):B.negbin.pdf(t,e,n)},"NORM.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),n<=0)throw k.NUM;return r?B.normal.cdf(t,e,n):B.normal.pdf(t,e,n)},"NORM.INV":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),t<=0||t>=1||n<=0)throw k.NUM;return B.normal.inv(t,e,n)},"NORM.S.DIST":(t,e)=>(t=O.accept(t,I.NUMBER),e=O.accept(e,I.BOOLEAN),e?B.normal.cdf(t,0,1):B.normal.pdf(t,0,1)),"NORM.S.INV":t=>{if(t=O.accept(t,I.NUMBER),t<=0||t>=1)throw k.NUM;return B.normal.inv(t,0,1)},PEARSON:()=>{},"PERCENTILE.EXC":()=>{},"PERCENTILE.INC":()=>{},"PERCENTRANK.EXC":()=>{},"PERCENTRANK.INC":()=>{},PERMUTATIONA:()=>{},PHI:t=>(t=O.accept(t,I.NUMBER),Math.exp(-.5*t*t)/rc),"POISSON.DIST":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.BOOLEAN),t<0||e<0)throw k.NUM;return t=Math.trunc(t),n?B.poisson.cdf(t,e):B.poisson.pdf(t,e)},PROB:()=>{},"QUARTILE.EXC":()=>{},"QUARTILE.INC":()=>{},"RANK.AVG":()=>{},"RANK.EQ":()=>{},RSQ:()=>{},SKEW:()=>{},"SKEW.P":()=>{},SLOPE:()=>{},STANDARDIZE:(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),n<=0)throw k.NUM;return(t-e)/n},"STDEV.P":()=>{},"STDEV.S":()=>{},STDEVA:()=>{},STDEVPA:()=>{},STEYX:()=>{},"T.DIST":(t,e,n)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.BOOLEAN),e<1)throw k.NUM;return n?B.studentt.cdf(t,e):B.studentt.pdf(t,e)},"T.DIST.2T":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),e<1||t<0)throw k.NUM;return(1-B.studentt.cdf(t,e))*2},"T.DIST.RT":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),e<1)throw k.NUM;return 1-B.studentt.cdf(t,e)},"T.INV":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),t<=0||t>1||e<1)throw k.NUM;return e=e%1===0?e:Math.trunc(e),B.studentt.inv(t,e)},"T.INV.2T":(t,e)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),t<=0||t>1||e<1)throw k.NUM;return e=e%1===0?e:Math.trunc(e),Math.abs(B.studentt.inv(t/2,e))},"T.TEST":()=>{},TREND:()=>{},TRIMMEAN:()=>{},"VAR.P":()=>{},"VAR.S":()=>{},VARA:()=>{},VARPA:()=>{},"WEIBULL.DIST":(t,e,n,r)=>{if(t=O.accept(t,I.NUMBER),e=O.accept(e,I.NUMBER),n=O.accept(n,I.NUMBER),r=O.accept(r,I.BOOLEAN),t<0||e<=0||n<=0)throw k.NUM;return r?1-Math.exp(-Math.pow(t/n,e)):Math.pow(t,e-1)*Math.exp(-Math.pow(t/n,e))*e/Math.pow(n,e)},"Z.TEST":()=>{}};var ic={DistributionFunctions:Xo};const oc=he(),{FormulaHelpers:sc,Types:mn,Criteria:Ni,Address:Vh}=ge(),{Infix:Ai}=Wr,ut=sc,{DistributionFunctions:ac}=ic,cc={AVEDEV:(...t)=>{let e=0;const n=[];ut.flattenParams(t,mn.NUMBER,!0,(i,a)=>{typeof i=="number"&&(e+=i,n.push(i))});const r=e/n.length;e=0;for(let i=0;i{let e=0,n=0;return ut.flattenParams(t,mn.NUMBER,!0,(r,i)=>{typeof r=="number"&&(e+=r,n++)}),e/n},AVERAGEA:(...t)=>{let e=0,n=0;return ut.flattenParams(t,mn.NUMBER,!0,(r,i)=>{const a=typeof r;a==="number"?(e+=r,n++):a==="string"&&n++}),e/n},AVERAGEIF:(t,e,n,r)=>{const i=ut.retrieveRanges(t,e,r);e=i[0],r=i[1],n=ut.retrieveArg(t,n);const a=n.isArray;n=Ni.parse(ut.accept(n));let c=0,h=0;if(e.forEach((p,u)=>{p.forEach((o,s)=>{const l=r[u][s];typeof l=="number"&&(n.op==="wc"?n.match===n.value.test(o)&&(c+=l,h++):Ai.compareOp(o,n.op,n.value,Array.isArray(o),a)&&(c+=l,h++))})}),h===0)throw oc.DIV0;return c/h},AVERAGEIFS:()=>{},COUNT:(...t)=>{let e=0;return ut.flattenParams(t,null,!0,(n,r)=>{(r.isLiteral&&!isNaN(n)||typeof n=="number")&&e++}),e},COUNTIF:(t,e)=>{t=ut.accept(t,mn.ARRAY,void 0,!1,!0);const n=e.isArray;e=ut.accept(e);let r=0;return e=Ni.parse(e),t.forEach(i=>{i.forEach(a=>{e.op==="wc"?e.match===e.value.test(a)&&r++:Ai.compareOp(a,e.op,e.value,Array.isArray(a),n)&&r++})}),r},LARGE:()=>{},MAX:()=>{},MAXA:()=>{},MAXIFS:()=>{},MEDIAN:()=>{},MIN:()=>{},MINA:()=>{},MINIFS:()=>{},PERMUT:()=>{},PERMUTATIONA:()=>{},SMALL:()=>{}};var lc=Object.assign(cc,ac);const De=he(),{FormulaHelpers:uc,Types:pe}=ge(),ae=uc,Rn=1e3*60*60*24,Lr=new Date(Date.UTC(1900,0,1)),fc=[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],hc=[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]],yi=[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]],pc=/^\s*(\d\d?)\s*(:\s*\d\d?)?\s*(:\s*\d\d?)?\s*(pm|am)?\s*$/i,dc=/^\s*((\d\d?)\s*([-\/])\s*(\d\d?))([\d:.apm\s]*)$/i,vc=/^\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,gc=/^\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 Ec(t){const e=t.match(dc),n=t.match(vc),r=t.match(gc);return e?t=e[1]+e[3]+new Date().getFullYear()+e[5]:n?t=n[1]+n[3]+new Date().getFullYear()+n[5]:r&&(t=r[1]+r[3]+new Date().getFullYear()+r[5]),new Date(Date.parse(`${t} UTC`))}function mc(t){const e=t.match(pc);if(!e)return;const n=e[2]?e[2]:":00",r=e[3]?e[3]:":00",i=e[4]?" "+e[4]:"",a=new Date(Date.parse(`1/1/1900 ${e[1]+n+r+i} UTC`));let 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(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()))}function Ot(t){const e=t>-22038912e5?2:1;return Math.floor((t-Lr)/864e5)+e}function Rc(t){if(t<0)throw De.VALUE;return t<=60?new Date(Lr.getTime()+(t-1)*864e5):new Date(Lr.getTime()+(t-2)*864e5)}function Qo(t){if(t instanceof Date)return{date:t};t=ae.accept(t);let e=!0,n;return isNaN(t)?(n=mc(t),n?e=!1:n=Ec(t)):(t=Number(t),n=Rc(t)),{date:n,isDateGiven:e}}function Z(t){return Qo(t).date}function mr(t,e){return t.getUTCFullYear()===e.getUTCFullYear()&&t.getUTCMonth()===e.getUTCMonth()&&t.getUTCDate()===e.getUTCDate()}function Nc(t){return t===1900?!0:new Date(t,1,29).getMonth()===1}const Mt={DATE:(t,e,n)=>{if(t=ae.accept(t,pe.NUMBER),e=ae.accept(e,pe.NUMBER),n=ae.accept(n,pe.NUMBER),t<0||t>=1e4)throw De.NUM;return t<1900&&(t+=1900),Ot(Date.UTC(t,e-1,n))},DATEDIF:(t,e,n)=>{if(t=Z(t),e=Z(e),n=ae.accept(n,pe.STRING).toLowerCase(),t>e)throw De.NUM;const r=e.getUTCFullYear()-t.getUTCFullYear(),i=e.getUTCMonth()-t.getUTCMonth(),a=e.getUTCDate()-t.getUTCDate();let c;switch(n){case"y":return c=i<0||i===0&&a<0?-1:0,c+r;case"m":return c=a<0?-1:0,r*12+i+c;case"d":return Math.floor(e-t)/Rn;case"md":return t.setUTCFullYear(e.getUTCFullYear()),a<0?t.setUTCMonth(e.getUTCMonth()-1):t.setUTCMonth(e.getUTCMonth()),Math.floor(e-t)/Rn;case"ym":return c=a<0?-1:0,(c+r*12+i)%12;case"yd":return i<0||i===0&&a<0?t.setUTCFullYear(e.getUTCFullYear()-1):t.setUTCFullYear(e.getUTCFullYear()),Math.floor(e-t)/Rn}},DATEVALUE:t=>{t=ae.accept(t,pe.STRING);const{date:e,isDateGiven:n}=Qo(t);if(!n)return 0;const r=Ot(e);if(r<0||r>2958465)throw De.VALUE;return r},DAY:t=>Z(t).getUTCDate(),DAYS:(t,e)=>{t=Z(t),e=Z(e);let n=0;return e<-22038912e5&&-22038912e5{t=Z(t),e=Z(e),n=ae.accept(n,pe.BOOLEAN,!1),t.getUTCDate()===31&&t.setUTCDate(30),!n&&t.getUTCDate()<30&&e.getUTCDate()>30?e.setUTCMonth(e.getUTCMonth()+1,1):e.getUTCDate()===31&&e.setUTCDate(30);const r=e.getUTCFullYear()-t.getUTCFullYear(),i=e.getUTCMonth()-t.getUTCMonth(),a=e.getUTCDate()-t.getUTCDate();return i*30+a+r*12*30},EDATE:(t,e)=>(t=Z(t),e=ae.accept(e,pe.NUMBER),t.setUTCMonth(t.getUTCMonth()+e),Ot(t)),EOMONTH:(t,e)=>(t=Z(t),e=ae.accept(e,pe.NUMBER),t.setUTCMonth(t.getUTCMonth()+e+1,0),Ot(t)),HOUR:t=>Z(t).getUTCHours(),ISOWEEKNUM:t=>{const e=Z(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())),r=n.getUTCDay();n.setUTCDate(n.getUTCDate()+4-r);const i=new Date(Date.UTC(n.getUTCFullYear(),0,1));return Math.ceil(((n-i)/864e5+1)/7)},MINUTE:t=>Z(t).getUTCMinutes(),MONTH:t=>Z(t).getUTCMonth()+1,NETWORKDAYS:(t,e,n)=>{t=Z(t),e=Z(e);let r=1;if(t>e){r=-1;const c=t;t=e,e=c}const i=[];n!=null&&ae.flattenParams([n],pe.NUMBER,!1,c=>{i.push(Z(c))});let a=0;for(;t<=e;){if(t.getUTCDay()!==0&&t.getUTCDay()!==6){let c=!1;for(let h=0;h{t=Z(t),e=Z(e);let i=1;if(t>e){i=-1;const h=t;t=e,e=h}if(n=ae.accept(n,null,1),n==="1111111")return 0;if(typeof n=="string"&&Number(n).toString()!==n){if(n.length!==7)throw De.VALUE;n=n.charAt(6)+n.slice(0,6);const h=[];for(let p=0;p{a.push(Z(h))});let c=0;for(;t<=e;){let h=!1;for(let p=0;p{const t=new Date;return Ot(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=>Z(t).getUTCSeconds(),TIME:(t,e,n)=>{if(t=ae.accept(t,pe.NUMBER),e=ae.accept(e,pe.NUMBER),n=ae.accept(n,pe.NUMBER),t<0||t>32767||e<0||e>32767||n<0||n>32767)throw De.NUM;return(3600*t+60*e+n)/86400},TIMEVALUE:t=>(t=Z(t),(3600*t.getUTCHours()+60*t.getUTCMinutes()+t.getUTCSeconds())/86400),TODAY:()=>{const t=new Date;return Ot(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()))},WEEKDAY:(t,e)=>{const n=Z(t);e=ae.accept(e,pe.NUMBER,1);const r=n.getUTCDay(),i=hc[e];if(!i)throw De.NUM;return i[r]},WEEKNUM:(t,e)=>{const n=Z(t);if(e=ae.accept(e,pe.NUMBER,1),e===21)return Mt.ISOWEEKNUM(t);const r=fc[e],i=new Date(Date.UTC(n.getUTCFullYear(),0,1)),a=i.getUTCDay()Mt["WORKDAY.INTL"](t,e,1,n),"WORKDAY.INTL":(t,e,n,r)=>{if(t=Z(t),e=ae.accept(e,pe.NUMBER),n=ae.accept(n,null,1),n==="1111111")throw De.VALUE;if(typeof n=="string"&&Number(n).toString()!==n){if(n.length!==7)throw De.VALUE;n=n.charAt(6)+n.slice(0,6);const c=[];for(let h=0;h{i.push(Z(c))}),t.setUTCDate(t.getUTCDate()+1);let a=0;for(;aZ(t).getUTCFullYear(),YEARFRAC:(t,e,n)=>{if(t=Z(t),e=Z(e),t>e){const u=t;t=e,e=u}if(n=ae.accept(n,pe.NUMBER,0),n=Math.trunc(n),n<0||n>4)throw De.VALUE;let r=t.getUTCDate();const i=t.getUTCMonth()+1,a=t.getUTCFullYear();let c=e.getUTCDate();const h=e.getUTCMonth()+1,p=e.getUTCFullYear();switch(n){case 0:return r===31&&c===31?(r=30,c=30):r===31?r=30:r===30&&c===31&&(c=30),Math.abs(c+h*30+p*360-(r+i*30+a*360))/360;case 1:if(p-a<2){const u=Nc(a)&&a!==1900?366:365;return Mt.DAYS(e,t)/u}else{const u=p-a+1,s=(new Date(p+1,0,1)-new Date(a,0,1))/1e3/60/60/24/u;return Mt.DAYS(e,t)/s}case 2:return Math.abs(Mt.DAYS(e,t)/360);case 3:return Math.abs(Mt.DAYS(e,t)/365);case 4:return Math.abs(c+h*30+p*360-(r+i*30+a*360))/360}}};var Ac=Mt;const yc=he(),{FormulaHelpers:Tc,Types:wc}=ge(),Cc=Tc,Ic={ENCODEURL:t=>encodeURIComponent(Cc.accept(t,wc.STRING)),FILTERXML:()=>{},WEBSERVICE:(t,e)=>{throw yc.ERROR("WEBSERVICE is not supported in sync mode.")}};var Oc=Ic,_r="7.1.2";function ee(t){return t&&t.length===0}function Ze(t){return t==null?[]:Object.keys(t)}function xe(t){for(var e=[],n=Object.keys(t),r=0;r=this.input.length)throw Error("Unexpected end of input");this.idx++},e.prototype.loc=function(d){return{begin:d,end:this.idx}};var n=/[0-9a-fA-F]/,r=/[0-9]/,i=/[1-9]/;function a(d){return d.charCodeAt(0)}function c(d,g){d.length!==void 0?d.forEach(function(E){g.push(E)}):g.push(d)}function h(d,g){if(d[g]===!0)throw"duplicate flag "+g;d[g]=!0}function p(d){if(d===void 0)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var o,s=[];for(o=a("0");o<=a("9");o++)s.push(o);var l=[a("_")].concat(s);for(o=a("a");o<=a("z");o++)l.push(o);for(o=a("A");o<=a("Z");o++)l.push(o);var f=[a(" "),a("\f"),a(` `),a("\r"),a(" "),a("\v"),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a(" "),a("\u2028"),a("\u2029"),a(" "),a(" "),a(" "),a("\uFEFF")];function v(){}return v.prototype.visitChildren=function(d){for(var g in d){var E=d[g];d.hasOwnProperty(g)&&(E.type!==void 0?this.visit(E):Array.isArray(E)&&E.forEach(function(A){this.visit(A)},this))}},v.prototype.visit=function(d){switch(d.type){case"Pattern":this.visitPattern(d);break;case"Flags":this.visitFlags(d);break;case"Disjunction":this.visitDisjunction(d);break;case"Alternative":this.visitAlternative(d);break;case"StartAnchor":this.visitStartAnchor(d);break;case"EndAnchor":this.visitEndAnchor(d);break;case"WordBoundary":this.visitWordBoundary(d);break;case"NonWordBoundary":this.visitNonWordBoundary(d);break;case"Lookahead":this.visitLookahead(d);break;case"NegativeLookahead":this.visitNegativeLookahead(d);break;case"Character":this.visitCharacter(d);break;case"Set":this.visitSet(d);break;case"Group":this.visitGroup(d);break;case"GroupBackReference":this.visitGroupBackReference(d);break;case"Quantifier":this.visitQuantifier(d);break}this.visitChildren(d)},v.prototype.visitPattern=function(d){},v.prototype.visitFlags=function(d){},v.prototype.visitDisjunction=function(d){},v.prototype.visitAlternative=function(d){},v.prototype.visitStartAnchor=function(d){},v.prototype.visitEndAnchor=function(d){},v.prototype.visitWordBoundary=function(d){},v.prototype.visitNonWordBoundary=function(d){},v.prototype.visitLookahead=function(d){},v.prototype.visitNegativeLookahead=function(d){},v.prototype.visitCharacter=function(d){},v.prototype.visitSet=function(d){},v.prototype.visitGroup=function(d){},v.prototype.visitGroupBackReference=function(d){},v.prototype.visitQuantifier=function(d){},{RegExpParser:e,BaseRegExpVisitor:v,VERSION:"0.5.0"}})})(ns);var an=ns.exports,In={},Sc=new an.RegExpParser;function Yn(t){var e=t.toString();if(In.hasOwnProperty(e))return In[e];var n=Sc.pattern(e);return In[e]=n,n}function Bc(){In={}}var Fc=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),rs="Complement Sets are not supported for first char optimization",Sn=`Unable to use "first char" lexer optimizations: `;function bc(t,e){e===void 0&&(e=!1);try{var n=Yn(t),r=kr(n.value,{},n.flags.ignoreCase);return r}catch(a){if(a.message===rs)e&&jo(""+Sn+(" Unable to optimize: < "+t.toString()+` > `)+` Complement Sets cannot be automatically optimized. This will disable the lexer's first char optimizations. See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var i="";e&&(i=` This will disable the lexer's first char optimizations. See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),Pr(Sn+` `+(" Failed parsing: < "+t.toString()+` > `)+(" Using the regexp-to-ast library version: "+an.VERSION+` `)+" Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+i)}}return[]}function kr(t,e,n){switch(t.type){case"Disjunction":for(var r=0;r=Jt)for(var l=o.from>=Jt?o.from:Jt,f=o.to,v=Tt(l),d=Tt(f),g=v;g<=d;g++)e[g]=g}}});break;case"Group":kr(c.value,e,n);break;default:throw Error("Non Exhaustive Match")}var h=c.quantifier!==void 0&&c.quantifier.atLeast===0;if(c.type==="Group"&&xr(c)===!1||c.type!=="Group"&&h===!1)break}break;default:throw Error("non exhaustive match!")}return xe(e)}function Nn(t,e,n){var r=Tt(t);e[r]=r,n===!0&&Dc(t,e)}function Dc(t,e){var n=String.fromCharCode(t),r=n.toUpperCase();if(r!==n){var i=Tt(r.charCodeAt(0));e[i]=i}else{var a=n.toLowerCase();if(a!==n){var i=Tt(a.charCodeAt(0));e[i]=i}}}function Ii(t,e){return Ht(t.value,function(n){if(typeof n=="number")return fe(e,n);var r=n;return Ht(e,function(i){return r.from<=i&&i<=r.to})!==void 0})}function xr(t){return t.quantifier&&t.quantifier.atLeast===0?!0:t.value?ot(t.value)?We(t.value,xr):xr(t.value):!1}var Vc=function(t){Fc(e,t);function e(n){var r=t.call(this)||this;return r.targetCharCodes=n,r.found=!1,r}return e.prototype.visitChildren=function(n){if(this.found!==!0){switch(n.type){case"Lookahead":this.visitLookahead(n);return;case"NegativeLookahead":this.visitNegativeLookahead(n);return}t.prototype.visitChildren.call(this,n)}},e.prototype.visitCharacter=function(n){fe(this.targetCharCodes,n.value)&&(this.found=!0)},e.prototype.visitSet=function(n){n.complement?Ii(n,this.targetCharCodes)===void 0&&(this.found=!0):Ii(n,this.targetCharCodes)!==void 0&&(this.found=!0)},e}(an.BaseRegExpVisitor);function zr(t,e){if(e instanceof RegExp){var n=Yn(e),r=new Vc(t);return r.visit(n),r.found}else return Ht(e,function(i){return fe(t,i.charCodeAt(0))})!==void 0}var is=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),at="PATTERN",Lt="defaultMode",An="modes",os=typeof new RegExp("(?:)").sticky=="boolean";function Gc(t,e){e=Kr(e,{useSticky:os,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",` `],tracer:function(A,m){return m()}});var n=e.tracer;n("initCharCodeToOptimizedIndexMap",function(){ul()});var r;n("Reject Lexer.NA",function(){r=Wt(t,function(A){return A[at]===Qe.NA})});var i=!1,a;n("Transform Patterns",function(){i=!1,a=x(r,function(A){var m=A[at];if(dt(m)){var N=m.source;return N.length===1&&N!=="^"&&N!=="$"&&N!=="."&&!m.ignoreCase?N:N.length===2&&N[0]==="\\"&&!fe(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],N[1])?N[1]:e.useSticky?Mi(m):Oi(m)}else{if(Ct(m))return i=!0,{exec:m};if($(m,"exec"))return i=!0,m;if(typeof m=="string"){if(m.length===1)return m;var y=m.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),R=new RegExp(y);return e.useSticky?Mi(R):Oi(R)}else throw Error("non exhaustive match")}})});var c,h,p,u,o;n("misc mapping",function(){c=x(r,function(A){return A.tokenTypeIdx}),h=x(r,function(A){var m=A.GROUP;if(m!==Qe.SKIPPED){if(st(m))return m;if(pt(m))return!1;throw Error("non exhaustive match")}}),p=x(r,function(A){var m=A.LONGER_ALT;if(m){var N=Lc(r,m);return N}}),u=x(r,function(A){return A.PUSH_MODE}),o=x(r,function(A){return $(A,"POP_MODE")})});var s;n("Line Terminator Handling",function(){var A=cs(e.lineTerminatorCharacters);s=x(r,function(m){return!1}),e.positionTracking!=="onlyOffset"&&(s=x(r,function(m){if($(m,"LINE_BREAKS"))return m.LINE_BREAKS;if(as(m,A)===!1)return zr(A,m.PATTERN)}))});var l,f,v,d;n("Misc Mapping #2",function(){l=x(r,ss),f=x(a,al),v=Ne(r,function(A,m){var N=m.GROUP;return st(N)&&N!==Qe.SKIPPED&&(A[N]=[]),A},{}),d=x(a,function(A,m){return{pattern:a[m],longerAlt:p[m],canLineTerminator:s[m],isCustom:l[m],short:f[m],group:h[m],push:u[m],pop:o[m],tokenTypeIdx:c[m],tokenType:r[m]}})});var g=!0,E=[];return e.safeMode||n("First Char Optimization",function(){E=Ne(r,function(A,m,N){if(typeof m.PATTERN=="string"){var y=m.PATTERN.charCodeAt(0),R=Tt(y);Rr(A,R,d[N])}else if(ot(m.START_CHARS_HINT)){var T;V(m.START_CHARS_HINT,function(C){var M=typeof C=="string"?C.charCodeAt(0):C,_=Tt(M);T!==_&&(T=_,Rr(A,_,d[N]))})}else if(dt(m.PATTERN))if(m.PATTERN.unicode)g=!1,e.ensureOptimizations&&Pr(""+Sn+(" Unable to analyze < "+m.PATTERN.toString()+` > pattern. `)+` The regexp unicode flag is not currently supported by the regexp-to-ast library. This will disable the lexer's first char optimizations. For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var w=bc(m.PATTERN,e.ensureOptimizations);ee(w)&&(g=!1),V(w,function(C){Rr(A,C,d[N])})}else e.ensureOptimizations&&Pr(""+Sn+(" TokenType: <"+m.name+`> is using a custom token pattern without providing parameter. `)+` This will disable the lexer's first char optimizations. For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),g=!1;return A},[])}),n("ArrayPacking",function(){E=kc(E)}),{emptyGroups:v,patternIdxToConfig:d,charCodeToPatternIdxToConfig:E,hasCustom:i,canBeOptimized:g}}function $c(t,e){var n=[],r=Wc(t);n=n.concat(r.errors);var i=qc(r.valid),a=i.valid;return n=n.concat(i.errors),n=n.concat(Hc(a)),n=n.concat(jc(a)),n=n.concat(el(a,e)),n=n.concat(tl(a)),n}function Hc(t){var e=[],n=je(t,function(r){return dt(r[at])});return e=e.concat(Kc(n)),e=e.concat(Qc(n)),e=e.concat(Zc(n)),e=e.concat(Jc(n)),e=e.concat(zc(n)),e}function Wc(t){var e=je(t,function(i){return!$(i,at)}),n=x(e,function(i){return{message:"Token Type: ->"+i.name+"<- missing static 'PATTERN' property",type:se.MISSING_PATTERN,tokenTypes:[i]}}),r=qn(t,e);return{errors:n,valid:r}}function qc(t){var e=je(t,function(i){var a=i[at];return!dt(a)&&!Ct(a)&&!$(a,"exec")&&!st(a)}),n=x(e,function(i){return{message:"Token Type: ->"+i.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:se.INVALID_PATTERN,tokenTypes:[i]}}),r=qn(t,e);return{errors:n,valid:r}}var Yc=/[^\\][\$]/;function Kc(t){var e=function(i){is(a,i);function a(){var c=i!==null&&i.apply(this,arguments)||this;return c.found=!1,c}return a.prototype.visitEndAnchor=function(c){this.found=!0},a}(an.BaseRegExpVisitor),n=je(t,function(i){var a=i[at];try{var c=Yn(a),h=new e;return h.visit(c),h.found}catch{return Yc.test(a.source)}}),r=x(n,function(i){return{message:`Unexpected RegExp Anchor Error: Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain end of input anchor '$' See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:se.EOI_ANCHOR_FOUND,tokenTypes:[i]}});return r}function zc(t){var e=je(t,function(r){var i=r[at];return i.test("")}),n=x(e,function(r){return{message:"Token Type: ->"+r.name+"<- static 'PATTERN' must not match an empty string",type:se.EMPTY_MATCH_PATTERN,tokenTypes:[r]}});return n}var Xc=/[^\\[][\^]|^\^/;function Qc(t){var e=function(i){is(a,i);function a(){var c=i!==null&&i.apply(this,arguments)||this;return c.found=!1,c}return a.prototype.visitStartAnchor=function(c){this.found=!0},a}(an.BaseRegExpVisitor),n=je(t,function(i){var a=i[at];try{var c=Yn(a),h=new e;return h.visit(c),h.found}catch{return Xc.test(a.source)}}),r=x(n,function(i){return{message:`Unexpected RegExp Anchor Error: Token Type: ->`+i.name+`<- static 'PATTERN' cannot contain start of input anchor '^' See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS for details.`,type:se.SOI_ANCHOR_FOUND,tokenTypes:[i]}});return r}function Zc(t){var e=je(t,function(r){var i=r[at];return i instanceof RegExp&&(i.multiline||i.global)}),n=x(e,function(r){return{message:"Token Type: ->"+r.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:se.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[r]}});return n}function Jc(t){var e=[],n=x(t,function(a){return Ne(t,function(c,h){return a.PATTERN.source===h.PATTERN.source&&!fe(e,h)&&h.PATTERN!==Qe.NA&&(e.push(h),c.push(h)),c},[])});n=sn(n);var r=je(n,function(a){return a.length>1}),i=x(r,function(a){var c=x(a,function(p){return p.name}),h=Je(a).PATTERN;return{message:"The same RegExp pattern ->"+h+"<-"+("has been used in all of the following Token Types: "+c.join(", ")+" <-"),type:se.DUPLICATE_PATTERNS_FOUND,tokenTypes:a}});return i}function jc(t){var e=je(t,function(r){if(!$(r,"GROUP"))return!1;var i=r.GROUP;return i!==Qe.SKIPPED&&i!==Qe.NA&&!st(i)}),n=x(e,function(r){return{message:"Token Type: ->"+r.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:se.INVALID_GROUP_TYPE_FOUND,tokenTypes:[r]}});return n}function el(t,e){var n=je(t,function(i){return i.PUSH_MODE!==void 0&&!fe(e,i.PUSH_MODE)}),r=x(n,function(i){var a="Token Type: ->"+i.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+i.PUSH_MODE+"<-which does not exist";return{message:a,type:se.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[i]}});return r}function tl(t){var e=[],n=Ne(t,function(r,i,a){var c=i.PATTERN;return c===Qe.NA||(st(c)?r.push({str:c,idx:a,tokenType:i}):dt(c)&&rl(c)&&r.push({str:c.source,idx:a,tokenType:i})),r},[]);return V(t,function(r,i){V(n,function(a){var c=a.str,h=a.idx,p=a.tokenType;if(i"+r.name+"<-")+`in the lexer's definition. See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;e.push({message:u,type:se.UNREACHABLE_PATTERN,tokenTypes:[r,p]})}})}),e}function nl(t,e){if(dt(e)){var n=e.exec(t);return n!==null&&n.index===0}else{if(Ct(e))return e(t,0,[],{});if($(e,"exec"))return e.exec(t,0,[],{});if(typeof e=="string")return e===t;throw Error("non exhaustive match")}}function rl(t){var e=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return Ht(e,function(n){return t.source.indexOf(n)!==-1})===void 0}function Oi(t){var e=t.ignoreCase?"i":"";return new RegExp("^(?:"+t.source+")",e)}function Mi(t){var e=t.ignoreCase?"iy":"y";return new RegExp(""+t.source,e)}function il(t,e,n){var r=[];return $(t,Lt)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+Lt+`> property in its definition `,type:se.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),$(t,An)||r.push({message:"A MultiMode Lexer cannot be initialized without a <"+An+`> property in its definition `,type:se.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),$(t,An)&&$(t,Lt)&&!$(t.modes,t.defaultMode)&&r.push({message:"A MultiMode Lexer cannot be initialized with a "+Lt+": <"+t.defaultMode+`>which does not exist `,type:se.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),$(t,An)&&V(t.modes,function(i,a){V(i,function(c,h){pt(c)&&r.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+a+"> at index: <"+h+`> `),type:se.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),r}function ol(t,e,n){var r=[],i=!1,a=sn(Ge(Mc(t.modes,function(p){return p}))),c=Wt(a,function(p){return p[at]===Qe.NA}),h=cs(n);return e&&V(c,function(p){var u=as(p,h);if(u!==!1){var o=ll(p,u),s={message:o,type:u.issue,tokenType:p};r.push(s)}else $(p,"LINE_BREAKS")?p.LINE_BREAKS===!0&&(i=!0):zr(h,p.PATTERN)&&(i=!0)}),e&&!i&&r.push({message:`Warning: No LINE_BREAKS Found. This Lexer has been defined to track line and column information, But none of the Token Types can be identified as matching a line terminator. See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS for details.`,type:se.NO_LINE_BREAKS_FLAGS}),r}function sl(t){var e={},n=Ze(t);return V(n,function(r){var i=t[r];if(ot(i))e[r]=[];else throw Error("non exhaustive match")}),e}function ss(t){var e=t.PATTERN;if(dt(e))return!1;if(Ct(e))return!0;if($(e,"exec"))return!0;if(st(e))return!1;throw Error("non exhaustive match")}function al(t){return st(t)&&t.length===1?t.charCodeAt(0):!1}var cl={test:function(t){for(var e=t.length,n=this.lastIndex;n Token Type `)+(" Root cause: "+e.errMsg+`. `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(e.issue===se.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the option. `+(" The problem is in the <"+t.name+`> Token Type `)+" For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}function cs(t){var e=x(t,function(n){return st(n)&&n.length>0?n.charCodeAt(0):n});return e}function Rr(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}var Jt=256;function Tt(t){return t255?255+~~(t/255):t}}function Kn(t,e){var n=t.tokenTypeIdx;return n===e.tokenTypeIdx?!0:e.isParent===!0&&e.categoryMatchesMap[n]===!0}function Bn(t,e){return t.tokenTypeIdx===e.tokenTypeIdx}var Ui=1,ls={};function cn(t){var e=fl(t);hl(e),dl(e),pl(e),V(e,function(n){n.isParent=n.categoryMatches.length>0})}function fl(t){for(var e=Se(t),n=t,r=!0;r;){n=sn(Ge(x(n,function(a){return a.CATEGORIES})));var i=qn(n,e);e=e.concat(i),ee(i)?r=!1:n=i}return e}function hl(t){V(t,function(e){fs(e)||(ls[Ui]=e,e.tokenTypeIdx=Ui++),Li(e)&&!ot(e.CATEGORIES)&&(e.CATEGORIES=[e.CATEGORIES]),Li(e)||(e.CATEGORIES=[]),vl(e)||(e.categoryMatches=[]),gl(e)||(e.categoryMatchesMap={})})}function pl(t){V(t,function(e){e.categoryMatches=[],V(e.categoryMatchesMap,function(n,r){e.categoryMatches.push(ls[r].tokenTypeIdx)})})}function dl(t){V(t,function(e){us([],e)})}function us(t,e){V(t,function(n){e.categoryMatchesMap[n.tokenTypeIdx]=!0}),V(e.CATEGORIES,function(n){var r=t.concat(e);fe(r,n)||us(r,n)})}function fs(t){return $(t,"tokenTypeIdx")}function Li(t){return $(t,"CATEGORIES")}function vl(t){return $(t,"categoryMatches")}function gl(t){return $(t,"categoryMatchesMap")}function El(t){return $(t,"tokenTypeIdx")}var hs={buildUnableToPopLexerModeMessage:function(t){return"Unable to pop Lexer Mode after encountering Token ->"+t.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(t,e,n,r,i){return"unexpected character: ->"+t.charAt(e)+"<- at offset: "+e+","+(" skipped "+n+" characters.")}},se;(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"})(se||(se={}));var jt={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[` `,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:hs,traceInitPerf:!1,skipValidations:!1};Object.freeze(jt);var Qe=function(){function t(e,n){var r=this;if(n===void 0&&(n=jt),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 n=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object. a boolean 2nd argument is no longer supported`);this.config=Ti(jt,n);var i=this.config.traceInitPerf;i===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof i=="number"&&(this.traceInitMaxIdent=i,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var a,c=!0;r.TRACE_INIT("Lexer Config handling",function(){if(r.config.lineTerminatorsPattern===jt.lineTerminatorsPattern)r.config.lineTerminatorsPattern=cl;else if(r.config.lineTerminatorCharacters===jt.lineTerminatorCharacters)throw Error(`Error: Missing property on the Lexer config. For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(n.safeMode&&n.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');r.trackStartLines=/full|onlyStart/i.test(r.config.positionTracking),r.trackEndLines=/full/i.test(r.config.positionTracking),ot(e)?(a={modes:{}},a.modes[Lt]=Se(e),a[Lt]=Lt):(c=!1,a=on(e))}),r.config.skipValidations===!1&&(r.TRACE_INIT("performRuntimeChecks",function(){r.lexerDefinitionErrors=r.lexerDefinitionErrors.concat(il(a,r.trackStartLines,r.config.lineTerminatorCharacters))}),r.TRACE_INIT("performWarningRuntimeChecks",function(){r.lexerDefinitionWarning=r.lexerDefinitionWarning.concat(ol(a,r.trackStartLines,r.config.lineTerminatorCharacters))})),a.modes=a.modes?a.modes:{},V(a.modes,function(o,s){a.modes[s]=Wt(o,function(l){return pt(l)})});var h=Ze(a.modes);if(V(a.modes,function(o,s){r.TRACE_INIT("Mode: <"+s+"> processing",function(){if(r.modes.push(s),r.config.skipValidations===!1&&r.TRACE_INIT("validatePatterns",function(){r.lexerDefinitionErrors=r.lexerDefinitionErrors.concat($c(o,h))}),ee(r.lexerDefinitionErrors)){cn(o);var l;r.TRACE_INIT("analyzeTokenTypes",function(){l=Gc(o,{lineTerminatorCharacters:r.config.lineTerminatorCharacters,positionTracking:n.positionTracking,ensureOptimizations:n.ensureOptimizations,safeMode:n.safeMode,tracer:r.TRACE_INIT.bind(r)})}),r.patternIdxToConfig[s]=l.patternIdxToConfig,r.charCodeToPatternIdxToConfig[s]=l.charCodeToPatternIdxToConfig,r.emptyGroups=Ti(r.emptyGroups,l.emptyGroups),r.hasCustom=l.hasCustom||r.hasCustom,r.canModeBeOptimized[s]=l.canBeOptimized}})}),r.defaultMode=a.defaultMode,!ee(r.lexerDefinitionErrors)&&!r.config.deferDefinitionErrorsHandling){var p=x(r.lexerDefinitionErrors,function(o){return o.message}),u=p.join(`----------------------- `);throw new Error(`Errors detected in definition of Lexer: `+u)}V(r.lexerDefinitionWarning,function(o){jo(o.message)}),r.TRACE_INIT("Choosing sub-methods implementations",function(){if(os?(r.chopInput=wi,r.match=r.matchWithTest):(r.updateLastIndex=de,r.match=r.matchWithExec),c&&(r.handleModes=de),r.trackStartLines===!1&&(r.computeNewColumn=wi),r.trackEndLines===!1&&(r.updateTokenEndLineColumnLocation=de),/full/i.test(r.config.positionTracking))r.createTokenInstance=r.createFullToken;else if(/onlyStart/i.test(r.config.positionTracking))r.createTokenInstance=r.createStartOnlyToken;else if(/onlyOffset/i.test(r.config.positionTracking))r.createTokenInstance=r.createOffsetOnlyToken;else throw Error('Invalid config option: "'+r.config.positionTracking+'"');r.hasCustom?(r.addToken=r.addTokenUsingPush,r.handlePayload=r.handlePayloadWithCustom):(r.addToken=r.addTokenUsingMemberAccess,r.handlePayload=r.handlePayloadNoCustom)}),r.TRACE_INIT("Failed Optimization Warnings",function(){var o=Ne(r.canModeBeOptimized,function(s,l,f){return l===!1&&s.push(f),s},[]);if(n.ensureOptimizations&&!ee(o))throw Error("Lexer Modes: < "+o.join(", ")+` > cannot be optimized. Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode. Or inspect the console log for details on how to resolve these issues.`)}),r.TRACE_INIT("clearRegExpParserCache",function(){Bc()}),r.TRACE_INIT("toFastProperties",function(){es(r)})})}return t.prototype.tokenize=function(e,n){if(n===void 0&&(n=this.defaultMode),!ee(this.lexerDefinitionErrors)){var r=x(this.lexerDefinitionErrors,function(c){return c.message}),i=r.join(`----------------------- `);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer: `+i)}var a=this.tokenizeInternal(e,n);return a},t.prototype.tokenizeInternal=function(e,n){var r=this,i,a,c,h,p,u,o,s,l,f,v,d,g,E,A=e,m=A.length,N=0,y=0,R=this.hasCustom?0:Math.floor(e.length/10),T=new Array(R),w=[],C=this.trackStartLines?1:void 0,M=this.trackStartLines?1:void 0,_=sl(this.emptyGroups),W=this.trackStartLines,F=this.config.lineTerminatorsPattern,S=0,G=[],J=[],le=[],nt=[];Object.freeze(nt);var Ae=void 0;function Be(){return G}function Fe(we){var Kt=Tt(we),Dt=J[Kt];return Dt===void 0?nt:Dt}var rt=function(we){if(le.length===1&&we.tokenType.PUSH_MODE===void 0){var Kt=r.config.errorMessageProvider.buildUnableToPopLexerModeMessage(we);w.push({offset:we.startOffset,line:we.startLine!==void 0?we.startLine:void 0,column:we.startColumn!==void 0?we.startColumn:void 0,length:we.image.length,message:Kt})}else{le.pop();var Dt=Zo(le);G=r.patternIdxToConfig[Dt],J=r.charCodeToPatternIdxToConfig[Dt],S=G.length;var Js=r.canModeBeOptimized[Dt]&&r.config.safeMode===!1;J&&Js?Ae=Fe:Ae=Be}};function Ee(we){le.push(we),J=this.charCodeToPatternIdxToConfig[we],G=this.patternIdxToConfig[we],S=G.length,S=G.length;var Kt=this.canModeBeOptimized[we]&&this.config.safeMode===!1;J&&Kt?Ae=Fe:Ae=Be}Ee.call(this,n);for(var ue;Np.length&&(p=c,u=o,ue=nr)}break}}if(p!==null){if(s=p.length,l=ue.group,l!==void 0&&(f=ue.tokenTypeIdx,v=this.createTokenInstance(p,N,f,ue.tokenType,C,M,s),this.handlePayload(v,u),l===!1?y=this.addToken(T,y,v):_[l].push(v)),e=this.chopInput(e,s),N=N+s,M=this.computeNewColumn(M,s),W===!0&&ue.canLineTerminator===!0){var fn=0,ir=void 0,or=void 0;F.lastIndex=0;do ir=F.test(p),ir===!0&&(or=F.lastIndex-1,fn++);while(ir===!0);fn!==0&&(C=C+fn,M=s-or,this.updateTokenEndLineColumnLocation(v,l,or,fn,C,M,s))}this.handleModes(ue,rt,Ee,v)}else{for(var sr=N,si=C,ai=M,Yt=!1;!Yt&&N <"+e+">");var i=ts(n),a=i.time,c=i.value,h=a>10?console.warn:console.log;return this.traceInitIndent time: "+a+"ms"),this.traceInitIndent--,c}else return n()},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}();function Pt(t){return ps(t)?t.LABEL:t.name}function ml(t){return t.name}function ps(t){return st(t.LABEL)&&t.LABEL!==""}var Rl="parent",_i="categories",Pi="label",ki="group",xi="push_mode",Si="pop_mode",Bi="longer_alt",Fi="line_breaks",bi="start_chars_hint";function Xr(t){return Nl(t)}function Nl(t){var e=t.pattern,n={};if(n.name=t.name,pt(e)||(n.PATTERN=e),$(t,Rl))throw`The parent property is no longer supported. See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return $(t,_i)&&(n.CATEGORIES=t[_i]),cn([n]),$(t,Pi)&&(n.LABEL=t[Pi]),$(t,ki)&&(n.GROUP=t[ki]),$(t,Si)&&(n.POP_MODE=t[Si]),$(t,xi)&&(n.PUSH_MODE=t[xi]),$(t,Bi)&&(n.LONGER_ALT=t[Bi]),$(t,Fi)&&(n.LINE_BREAKS=t[Fi]),$(t,bi)&&(n.START_CHARS_HINT=t[bi]),n}var wt=Xr({name:"EOF",pattern:Qe.NA});cn([wt]);function zn(t,e,n,r,i,a,c,h){return{image:e,startOffset:n,endOffset:r,startLine:i,endLine:a,startColumn:c,endColumn:h,tokenTypeIdx:t.tokenTypeIdx,tokenType:t}}function Al(t,e){return Kn(t,e)}var gt=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),ct=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),V(this.definition,function(n){n.accept(e)})},t}(),Ue=function(t){gt(e,t);function e(n){var r=t.call(this,[])||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return Object.defineProperty(e.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(n){},enumerable:!1,configurable:!0}),e.prototype.accept=function(n){n.visit(this)},e}(ct),xt=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.orgText="",tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),Te=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.ignoreAmbiguities=!1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),ye=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),qe=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),Ye=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),ce=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),$e=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,tt(r,et(n,function(i){return i!==void 0})),r}return e}(ct),He=function(t){gt(e,t);function e(n){var r=t.call(this,n.definition)||this;return r.idx=1,r.ignoreAmbiguities=!1,r.hasPredicates=!1,tt(r,et(n,function(i){return i!==void 0})),r}return Object.defineProperty(e.prototype,"definition",{get:function(){return this._definition},set:function(n){this._definition=n},enumerable:!1,configurable:!0}),e}(ct),ne=function(){function t(e){this.idx=1,tt(this,et(e,function(n){return n!==void 0}))}return t.prototype.accept=function(e){e.visit(this)},t}();function ds(t){return x(t,en)}function en(t){function e(i){return x(i,en)}if(t instanceof Ue)return{type:"NonTerminal",name:t.nonTerminalName,idx:t.idx};if(t instanceof Te)return{type:"Alternative",definition:e(t.definition)};if(t instanceof ye)return{type:"Option",idx:t.idx,definition:e(t.definition)};if(t instanceof qe)return{type:"RepetitionMandatory",idx:t.idx,definition:e(t.definition)};if(t instanceof Ye)return{type:"RepetitionMandatoryWithSeparator",idx:t.idx,separator:en(new ne({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof $e)return{type:"RepetitionWithSeparator",idx:t.idx,separator:en(new ne({terminalType:t.separator})),definition:e(t.definition)};if(t instanceof ce)return{type:"Repetition",idx:t.idx,definition:e(t.definition)};if(t instanceof He)return{type:"Alternation",idx:t.idx,definition:e(t.definition)};if(t instanceof ne){var n={type:"Terminal",name:t.terminalType.name,label:Pt(t.terminalType),idx:t.idx},r=t.terminalType.PATTERN;return t.terminalType.PATTERN&&(n.pattern=dt(r)?r.source:r),n}else{if(t instanceof xt)return{type:"Rule",name:t.name,orgText:t.orgText,definition:e(t.definition)};throw Error("non exhaustive match")}}var Xn=function(){function t(){}return t.prototype.walk=function(e,n){var r=this;n===void 0&&(n=[]),V(e.definition,function(i,a){var c=Re(e.definition,a+1);if(i instanceof Ue)r.walkProdRef(i,c,n);else if(i instanceof ne)r.walkTerminal(i,c,n);else if(i instanceof Te)r.walkFlat(i,c,n);else if(i instanceof ye)r.walkOption(i,c,n);else if(i instanceof qe)r.walkAtLeastOne(i,c,n);else if(i instanceof Ye)r.walkAtLeastOneSep(i,c,n);else if(i instanceof $e)r.walkManySep(i,c,n);else if(i instanceof ce)r.walkMany(i,c,n);else if(i instanceof He)r.walkOr(i,c,n);else throw Error("non exhaustive match")})},t.prototype.walkTerminal=function(e,n,r){},t.prototype.walkProdRef=function(e,n,r){},t.prototype.walkFlat=function(e,n,r){var i=n.concat(r);this.walk(e,i)},t.prototype.walkOption=function(e,n,r){var i=n.concat(r);this.walk(e,i)},t.prototype.walkAtLeastOne=function(e,n,r){var i=[new ye({definition:e.definition})].concat(n,r);this.walk(e,i)},t.prototype.walkAtLeastOneSep=function(e,n,r){var i=Di(e,n,r);this.walk(e,i)},t.prototype.walkMany=function(e,n,r){var i=[new ye({definition:e.definition})].concat(n,r);this.walk(e,i)},t.prototype.walkManySep=function(e,n,r){var i=Di(e,n,r);this.walk(e,i)},t.prototype.walkOr=function(e,n,r){var i=this,a=n.concat(r);V(e.definition,function(c){var h=new Te({definition:[c]});i.walk(h,a)})},t}();function Di(t,e,n){var r=[new ye({definition:[new ne({terminalType:t.separator})].concat(t.definition)})],i=r.concat(e,n);return i}var St=function(){function t(){}return t.prototype.visit=function(e){var n=e;switch(n.constructor){case Ue:return this.visitNonTerminal(n);case Te:return this.visitAlternative(n);case ye:return this.visitOption(n);case qe:return this.visitRepetitionMandatory(n);case Ye:return this.visitRepetitionMandatoryWithSeparator(n);case $e:return this.visitRepetitionWithSeparator(n);case ce:return this.visitRepetition(n);case He:return this.visitAlternation(n);case ne:return this.visitTerminal(n);case xt:return this.visitRule(n);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}(),yl=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();function Tl(t){return t instanceof Te||t instanceof ye||t instanceof ce||t instanceof qe||t instanceof Ye||t instanceof $e||t instanceof ne||t instanceof xt}function Fn(t,e){e===void 0&&(e=[]);var n=t instanceof ye||t instanceof ce||t instanceof $e;return n?!0:t instanceof He?Jo(t.definition,function(r){return Fn(r,e)}):t instanceof Ue&&fe(e,t)?!1:t instanceof ct?(t instanceof Ue&&e.push(t),We(t.definition,function(r){return Fn(r,e)})):!1}function wl(t){return t instanceof He}function it(t){if(t instanceof Ue)return"SUBRULE";if(t instanceof ye)return"OPTION";if(t instanceof He)return"OR";if(t instanceof qe)return"AT_LEAST_ONE";if(t instanceof Ye)return"AT_LEAST_ONE_SEP";if(t instanceof $e)return"MANY_SEP";if(t instanceof ce)return"MANY";if(t instanceof ne)return"CONSUME";throw Error("non exhaustive match")}var vs=function(t){yl(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.separator="-",n.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},n}return e.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},e.prototype.visitTerminal=function(n){var r=n.terminalType.name+this.separator+"Terminal";$(this.dslMethods,r)||(this.dslMethods[r]=[]),this.dslMethods[r].push(n)},e.prototype.visitNonTerminal=function(n){var r=n.nonTerminalName+this.separator+"Terminal";$(this.dslMethods,r)||(this.dslMethods[r]=[]),this.dslMethods[r].push(n)},e.prototype.visitOption=function(n){this.dslMethods.option.push(n)},e.prototype.visitRepetitionWithSeparator=function(n){this.dslMethods.repetitionWithSeparator.push(n)},e.prototype.visitRepetitionMandatory=function(n){this.dslMethods.repetitionMandatory.push(n)},e.prototype.visitRepetitionMandatoryWithSeparator=function(n){this.dslMethods.repetitionMandatoryWithSeparator.push(n)},e.prototype.visitRepetition=function(n){this.dslMethods.repetition.push(n)},e.prototype.visitAlternation=function(n){this.dslMethods.alternation.push(n)},e}(St),yn=new vs;function Cl(t){yn.reset(),t.accept(yn);var e=yn.dslMethods;return yn.reset(),e}function ln(t){if(t instanceof Ue)return ln(t.referencedRule);if(t instanceof ne)return Ml(t);if(Tl(t))return Il(t);if(wl(t))return Ol(t);throw Error("non exhaustive match")}function Il(t){for(var e=[],n=t.definition,r=0,i=n.length>r,a,c=!0;i&&c;)a=n[r],c=Fn(a),e=e.concat(ln(a)),r=r+1,i=n.length>r;return qr(e)}function Ol(t){var e=x(t.definition,function(n){return ln(n)});return qr(Ge(e))}function Ml(t){return[t.terminalType]}var gs="_~IN~_",Ul=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Ll=function(t){Ul(e,t);function e(n){var r=t.call(this)||this;return r.topProd=n,r.follows={},r}return e.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},e.prototype.walkTerminal=function(n,r,i){},e.prototype.walkProdRef=function(n,r,i){var a=Pl(n.referencedRule,n.idx)+this.topProd.name,c=r.concat(i),h=new Te({definition:c}),p=ln(h);this.follows[a]=p},e}(Xn);function _l(t){var e={};return V(t,function(n){var r=new Ll(n).startWalking();tt(e,r)}),e}function Pl(t,e){return t.name+e+gs}var Qr={buildMismatchTokenMessage:function(t){var e=t.expected,n=t.actual;t.previous,t.ruleName;var r=ps(e),i=r?"--> "+Pt(e)+" <--":"token of type --> "+e.name+" <--",a="Expecting "+i+" but found --> '"+n.image+"' <--";return a},buildNotAllInputParsedMessage:function(t){var e=t.firstRedundant;return t.ruleName,"Redundant input, expecting EOF but found: "+e.image},buildNoViableAltMessage:function(t){var e=t.expectedPathsPerAlt,n=t.actual;t.previous;var r=t.customUserDescription;t.ruleName;var i="Expecting: ",a=Je(n).image,c=` but found: '`+a+"'";if(r)return i+r+c;var h=Ne(e,function(s,l){return s.concat(l)},[]),p=x(h,function(s){return"["+x(s,function(l){return Pt(l)}).join(", ")+"]"}),u=x(p,function(s,l){return" "+(l+1)+". "+s}),o=`one of these possible Token sequences: `+u.join(` `);return i+o+c},buildEarlyExitMessage:function(t){var e=t.expectedIterationPaths,n=t.actual,r=t.customUserDescription;t.ruleName;var i="Expecting: ",a=Je(n).image,c=` but found: '`+a+"'";if(r)return i+r+c;var h=x(e,function(u){return"["+x(u,function(o){return Pt(o)}).join(",")+"]"}),p=`expecting at least one iteration which starts with one of these possible Token sequences:: `+("<"+h.join(" ,")+">");return i+p+c}};Object.freeze(Qr);var Es={buildRuleNotFoundError:function(t,e){var n="Invalid grammar, reference to a rule which is not defined: ->"+e.nonTerminalName+`<- inside top level rule: ->`+t.name+"<-";return n}},Qn={buildDuplicateFoundError:function(t,e){function n(o){return o instanceof ne?o.terminalType.name:o instanceof Ue?o.nonTerminalName:""}var r=t.name,i=Je(e),a=i.idx,c=it(i),h=n(i),p=a>0,u="->"+c+(p?a:"")+"<- "+(h?"with argument: ->"+h+"<-":"")+` appears more than once (`+e.length+" times) in the top level rule: ->"+r+`<-. For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES `;return u=u.replace(/[ \t]+/g," "),u=u.replace(/\s\s+/g,` `),u},buildNamespaceConflictError:function(t){var e=`Namespace conflict found in grammar. `+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+t.name+`>. `)+`To resolve this make sure each Terminal and Non-Terminal names are unique This is easy to accomplish by using the convention that Terminal names start with an uppercase letter and Non-Terminal names start with a lower case letter.`;return e},buildAlternationPrefixAmbiguityError:function(t){var e=x(t.prefixPath,function(i){return Pt(i)}).join(", "),n=t.alternation.idx===0?"":t.alternation.idx,r="Ambiguous alternatives: <"+t.ambiguityIndices.join(" ,")+`> due to common lookahead prefix `+("in inside <"+t.topLevelRule.name+`> Rule, `)+("<"+e+`> may appears as a prefix path in all these alternatives. `)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX For Further details.`;return r},buildAlternationAmbiguityError:function(t){var e=x(t.prefixPath,function(i){return Pt(i)}).join(", "),n=t.alternation.idx===0?"":t.alternation.idx,r="Ambiguous Alternatives Detected: <"+t.ambiguityIndices.join(" ,")+"> in "+(" inside <"+t.topLevelRule.name+`> Rule, `)+("<"+e+`> may appears as a prefix path in all these alternatives. `);return r=r+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES For Further details.`,r},buildEmptyRepetitionError:function(t){var e=it(t.repetition);t.repetition.idx!==0&&(e+=t.repetition.idx);var n="The repetition <"+e+"> within Rule <"+t.topLevelRule.name+`> can never consume any tokens. This could lead to an infinite loop.`;return n},buildTokenNameError:function(t){return"deprecated"},buildEmptyAlternationError:function(t){var e="Ambiguous empty alternative: <"+(t.emptyChoiceIdx+1)+">"+(" in inside <"+t.topLevelRule.name+`> Rule. `)+"Only the last alternative may be an empty alternative.";return e},buildTooManyAlternativesError:function(t){var e=`An Alternation cannot have more than 256 alternatives: `+(" inside <"+t.topLevelRule.name+`> Rule. has `+(t.alternation.definition.length+1)+" alternatives.");return e},buildLeftRecursionError:function(t){var e=t.topLevelRule.name,n=x(t.leftRecursionPath,function(a){return a.name}),r=e+" --> "+n.concat([e]).join(" --> "),i=`Left Recursion found in grammar. `+("rule: <"+e+`> can be invoked from itself (directly or indirectly) `)+(`without consuming any Tokens. The grammar path that causes this is: `+r+` `)+` To fix this refactor your grammar to remove the left recursion. see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return i},buildInvalidRuleNameError:function(t){return"deprecated"},buildDuplicateRuleNameError:function(t){var e;t.topLevelRule instanceof xt?e=t.topLevelRule.name:e=t.topLevelRule;var n="Duplicate definition, rule: ->"+e+"<- is already defined in the grammar: ->"+t.grammarName+"<-";return n}},kl=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();function xl(t,e){var n=new Sl(t,e);return n.resolveRefs(),n.errors}var Sl=function(t){kl(e,t);function e(n,r){var i=t.call(this)||this;return i.nameToTopRule=n,i.errMsgProvider=r,i.errors=[],i}return e.prototype.resolveRefs=function(){var n=this;V(xe(this.nameToTopRule),function(r){n.currTopLevel=r,r.accept(n)})},e.prototype.visitNonTerminal=function(n){var r=this.nameToTopRule[n.nonTerminalName];if(r)n.referencedRule=r;else{var i=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,n);this.errors.push({message:i,type:Le.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:n.nonTerminalName})}},e}(St),Bt=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Bl=function(t){Bt(e,t);function e(n,r){var i=t.call(this)||this;return i.topProd=n,i.path=r,i.possibleTokTypes=[],i.nextProductionName="",i.nextProductionOccurrence=0,i.found=!1,i.isAtEndOfPath=!1,i}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=Se(this.path.ruleStack).reverse(),this.occurrenceStack=Se(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},e.prototype.walk=function(n,r){r===void 0&&(r=[]),this.found||t.prototype.walk.call(this,n,r)},e.prototype.walkProdRef=function(n,r,i){if(n.referencedRule.name===this.nextProductionName&&n.idx===this.nextProductionOccurrence){var a=r.concat(i);this.updateExpectedNext(),this.walk(n.referencedRule,a)}},e.prototype.updateExpectedNext=function(){ee(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},e}(Xn),Fl=function(t){Bt(e,t);function e(n,r){var i=t.call(this,n,r)||this;return i.path=r,i.nextTerminalName="",i.nextTerminalOccurrence=0,i.nextTerminalName=i.path.lastTok.name,i.nextTerminalOccurrence=i.path.lastTokOccurrence,i}return e.prototype.walkTerminal=function(n,r,i){if(this.isAtEndOfPath&&n.terminalType.name===this.nextTerminalName&&n.idx===this.nextTerminalOccurrence&&!this.found){var a=r.concat(i),c=new Te({definition:a});this.possibleTokTypes=ln(c),this.found=!0}},e}(Bl),Zn=function(t){Bt(e,t);function e(n,r){var i=t.call(this)||this;return i.topRule=n,i.occurrence=r,i.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},i}return e.prototype.startWalking=function(){return this.walk(this.topRule),this.result},e}(Xn),bl=function(t){Bt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkMany=function(n,r,i){if(n.idx===this.occurrence){var a=Je(r.concat(i));this.result.isEndOfRule=a===void 0,a instanceof ne&&(this.result.token=a.terminalType,this.result.occurrence=a.idx)}else t.prototype.walkMany.call(this,n,r,i)},e}(Zn),Vi=function(t){Bt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkManySep=function(n,r,i){if(n.idx===this.occurrence){var a=Je(r.concat(i));this.result.isEndOfRule=a===void 0,a instanceof ne&&(this.result.token=a.terminalType,this.result.occurrence=a.idx)}else t.prototype.walkManySep.call(this,n,r,i)},e}(Zn),Dl=function(t){Bt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkAtLeastOne=function(n,r,i){if(n.idx===this.occurrence){var a=Je(r.concat(i));this.result.isEndOfRule=a===void 0,a instanceof ne&&(this.result.token=a.terminalType,this.result.occurrence=a.idx)}else t.prototype.walkAtLeastOne.call(this,n,r,i)},e}(Zn),Gi=function(t){Bt(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.walkAtLeastOneSep=function(n,r,i){if(n.idx===this.occurrence){var a=Je(r.concat(i));this.result.isEndOfRule=a===void 0,a instanceof ne&&(this.result.token=a.terminalType,this.result.occurrence=a.idx)}else t.prototype.walkAtLeastOneSep.call(this,n,r,i)},e}(Zn);function Sr(t,e,n){n===void 0&&(n=[]),n=Se(n);var r=[],i=0;function a(u){return u.concat(Re(t,i+1))}function c(u){var o=Sr(a(u),e,n);return r.concat(o)}for(;n.length=0;F--){var S=E.definition[F],G={idx:v,def:S.definition.concat(Re(f)),ruleStack:d,occurrenceStack:g};s.push(G),s.push(c)}else if(E instanceof Te)s.push({idx:v,def:E.definition.concat(Re(f)),ruleStack:d,occurrenceStack:g});else if(E instanceof xt)s.push(Vl(E,v,d,g));else throw Error("non exhaustive match")}}return o}function Vl(t,e,n,r){var i=Se(n);i.push(t.name);var a=Se(r);return a.push(1),{idx:e,def:t.definition,ruleStack:i,occurrenceStack:a}}var Rs=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),j;(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"})(j||(j={}));function Gl(t){if(t instanceof ye)return j.OPTION;if(t instanceof ce)return j.REPETITION;if(t instanceof qe)return j.REPETITION_MANDATORY;if(t instanceof Ye)return j.REPETITION_MANDATORY_WITH_SEPARATOR;if(t instanceof $e)return j.REPETITION_WITH_SEPARATOR;if(t instanceof He)return j.ALTERNATION;throw Error("non exhaustive match")}function $l(t,e,n,r,i,a){var c=Zr(t,e,n),h=ys(c)?Bn:Kn;return a(c,r,h,i)}function Hl(t,e,n,r,i,a){var c=Jr(t,e,i,n),h=ys(c)?Bn:Kn;return a(c[0],h,r)}function Wl(t,e,n,r){var i=t.length,a=We(t,function(p){return We(p,function(u){return u.length===1})});if(e)return function(p){for(var u=x(p,function(m){return m.GATE}),o=0;o1}),c=x(xe(a),function(h){var p=Je(h),u=e.buildDuplicateFoundError(t,h),o=it(p),s={message:u,type:Le.DUPLICATE_PRODUCTIONS,ruleName:t.name,dslName:o,occurrence:p.idx},l=Ts(p);return l&&(s.parameter=l),s});return c}function Zl(t){return it(t)+"_#_"+t.idx+"_#_"+Ts(t)}function Ts(t){return t instanceof ne?t.terminalType.name:t instanceof Ue?t.nonTerminalName:""}var Jl=function(t){jr(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.allProductions=[],n}return e.prototype.visitNonTerminal=function(n){this.allProductions.push(n)},e.prototype.visitOption=function(n){this.allProductions.push(n)},e.prototype.visitRepetitionWithSeparator=function(n){this.allProductions.push(n)},e.prototype.visitRepetitionMandatory=function(n){this.allProductions.push(n)},e.prototype.visitRepetitionMandatoryWithSeparator=function(n){this.allProductions.push(n)},e.prototype.visitRepetition=function(n){this.allProductions.push(n)},e.prototype.visitAlternation=function(n){this.allProductions.push(n)},e.prototype.visitTerminal=function(n){this.allProductions.push(n)},e}(St);function jl(t,e,n,r){var i=[],a=Ne(e,function(h,p){return p.name===t.name?h+1:h},0);if(a>1){var c=r.buildDuplicateRuleNameError({topLevelRule:t,grammarName:n});i.push({message:c,type:Le.DUPLICATE_RULE_NAME,ruleName:t.name})}return i}function eu(t,e,n){var r=[],i;return fe(e,t)||(i="Invalid rule override, rule: ->"+t+"<- cannot be overridden in the grammar: ->"+n+"<-as it is not defined in any of the super grammars ",r.push({message:i,type:Le.INVALID_RULE_OVERRIDE,ruleName:t})),r}function ws(t,e,n,r){r===void 0&&(r=[]);var i=[],a=Mn(e.definition);if(ee(a))return[];var c=t.name,h=fe(a,t);h&&i.push({message:n.buildLeftRecursionError({topLevelRule:t,leftRecursionPath:r}),type:Le.LEFT_RECURSION,ruleName:c});var p=qn(a,r.concat([t])),u=x(p,function(o){var s=Se(r);return s.push(o),ws(t,o,n,s)});return i.concat(Ge(u))}function Mn(t){var e=[];if(ee(t))return e;var n=Je(t);if(n instanceof Ue)e.push(n.referencedRule);else if(n instanceof Te||n instanceof ye||n instanceof qe||n instanceof Ye||n instanceof $e||n instanceof ce)e=e.concat(Mn(n.definition));else if(n instanceof He)e=Ge(x(n.definition,function(c){return Mn(c.definition)}));else if(!(n instanceof ne))throw Error("non exhaustive match");var r=Fn(n),i=t.length>1;if(r&&i){var a=Re(t);return e.concat(Mn(a))}else return e}var ei=function(t){jr(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.alternations=[],n}return e.prototype.visitAlternation=function(n){this.alternations.push(n)},e}(St);function tu(t,e){var n=new ei;t.accept(n);var r=n.alternations,i=Ne(r,function(a,c){var h=nn(c.definition),p=x(h,function(u,o){var s=ms([u],[],null,1);return ee(s)?{message:e.buildEmptyAlternationError({topLevelRule:t,alternation:c,emptyChoiceIdx:o}),type:Le.NONE_LAST_EMPTY_ALT,ruleName:t.name,occurrence:c.idx,alternative:o+1}:null});return a.concat(sn(p))},[]);return i}function nu(t,e,n){var r=new ei;t.accept(r);var i=r.alternations;i=Wt(i,function(c){return c.ignoreAmbiguities===!0});var a=Ne(i,function(c,h){var p=h.idx,u=h.maxLookahead||e,o=Zr(p,t,u,h),s=su(o,h,t,n),l=au(o,h,t,n);return c.concat(s,l)},[]);return a}var ru=function(t){jr(e,t);function e(){var n=t!==null&&t.apply(this,arguments)||this;return n.allProductions=[],n}return e.prototype.visitRepetitionWithSeparator=function(n){this.allProductions.push(n)},e.prototype.visitRepetitionMandatory=function(n){this.allProductions.push(n)},e.prototype.visitRepetitionMandatoryWithSeparator=function(n){this.allProductions.push(n)},e.prototype.visitRepetition=function(n){this.allProductions.push(n)},e}(St);function iu(t,e){var n=new ei;t.accept(n);var r=n.alternations,i=Ne(r,function(a,c){return c.definition.length>255&&a.push({message:e.buildTooManyAlternativesError({topLevelRule:t,alternation:c}),type:Le.TOO_MANY_ALTS,ruleName:t.name,occurrence:c.idx}),a},[]);return i}function ou(t,e,n){var r=[];return V(t,function(i){var a=new ru;i.accept(a);var c=a.allProductions;V(c,function(h){var p=Gl(h),u=h.maxLookahead||e,o=h.idx,s=Jr(o,i,p,u),l=s[0];if(ee(Ge(l))){var f=n.buildEmptyRepetitionError({topLevelRule:i,repetition:h});r.push({message:f,type:Le.NO_NON_EMPTY_LOOKAHEAD,ruleName:i.name})}})}),r}function su(t,e,n,r){var i=[],a=Ne(t,function(h,p,u){return e.definition[u].ignoreAmbiguities===!0||V(p,function(o){var s=[u];V(t,function(l,f){u!==f&&Br(l,o)&&e.definition[f].ignoreAmbiguities!==!0&&s.push(f)}),s.length>1&&!Br(i,o)&&(i.push(o),h.push({alts:s,path:o}))}),h},[]),c=x(a,function(h){var p=x(h.alts,function(o){return o+1}),u=r.buildAlternationAmbiguityError({topLevelRule:n,alternation:e,ambiguityIndices:p,prefixPath:h.path});return{message:u,type:Le.AMBIGUOUS_ALTS,ruleName:n.name,occurrence:e.idx,alternatives:[h.alts]}});return c}function au(t,e,n,r){var i=[],a=Ne(t,function(c,h,p){var u=x(h,function(o){return{idx:p,path:o}});return c.concat(u)},[]);return V(a,function(c){var h=e.definition[c.idx];if(h.ignoreAmbiguities!==!0){var p=c.idx,u=c.path,o=Uc(a,function(l){return e.definition[l.idx].ignoreAmbiguities!==!0&&l.idx: `+(""+a.join(` `).replace(/\n/g,` `)))}}};return n.prototype=r,n.prototype.constructor=n,n._RULE_NAMES=e,n}function Ru(t,e,n){var r=function(){};Ds(r,t+"BaseSemanticsWithDefaults");var i=Object.create(n.prototype);return V(e,function(a){i[a]=Eu}),r.prototype=i,r.prototype.constructor=r,r}var bn;(function(t){t[t.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",t[t.MISSING_METHOD=1]="MISSING_METHOD"})(bn||(bn={}));function Nu(t,e){var n=Au(t,e),r=Tu(t,e);return n.concat(r)}function Au(t,e){var n=x(e,function(r){if(!Ct(t[r]))return{msg:"Missing visitor method: <"+r+"> on "+jn(t.constructor)+" CST Visitor.",type:bn.MISSING_METHOD,methodName:r}});return sn(n)}var yu=["constructor","visit","validateVisitor"];function Tu(t,e){var n=[];for(var r in t)Ct(t[r])&&!fe(yu,r)&&!fe(e,r)&&n.push({msg:"Redundant visitor method: <"+r+"> on "+jn(t.constructor)+` CST Visitor There is no Grammar Rule corresponding to this method's name. `,type:bn.REDUNDANT_METHOD,methodName:r});return n}var wu=function(){function t(){}return t.prototype.initTreeBuilder=function(e){if(this.CST_STACK=[],this.outputCst=e.outputCst,this.nodeLocationTracking=$(e,"nodeLocationTracking")?e.nodeLocationTracking:vt.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=de,this.cstFinallyStateUpdate=de,this.cstPostTerminal=de,this.cstPostNonTerminal=de,this.cstPostRule=de;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Wi,this.setNodeLocationFromNode=Wi,this.cstPostRule=de,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=de,this.setNodeLocationFromNode=de,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=Hi,this.setNodeLocationFromNode=Hi,this.cstPostRule=de,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=de,this.setNodeLocationFromNode=de,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=de,this.setNodeLocationFromNode=de,this.cstPostRule=de,this.setInitialNodeLocation=de;else throw Error('Invalid 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 n=this.LA(1);e.location={startOffset:n.startOffset,startLine:n.startLine,startColumn:n.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},t.prototype.cstInvocationStateUpdate=function(e,n){var r={name:e,children:{}};this.setInitialNodeLocation(r),this.CST_STACK.push(r)},t.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},t.prototype.cstPostRuleFull=function(e){var n=this.LA(0),r=e.location;r.startOffset<=n.startOffset?(r.endOffset=n.endOffset,r.endLine=n.endLine,r.endColumn=n.endColumn):(r.startOffset=NaN,r.startLine=NaN,r.startColumn=NaN)},t.prototype.cstPostRuleOnlyOffset=function(e){var n=this.LA(0),r=e.location;r.startOffset<=n.startOffset?r.endOffset=n.endOffset:r.startOffset=NaN},t.prototype.cstPostTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];du(r,n,e),this.setNodeLocationFromToken(r.location,n)},t.prototype.cstPostNonTerminal=function(e,n){var r=this.CST_STACK[this.CST_STACK.length-1];vu(r,n,e),this.setNodeLocationFromNode(r.location,e.location)},t.prototype.getBaseCstVisitorConstructor=function(){if(pt(this.baseCstVisitorConstructor)){var e=mu(this.className,Ze(this.gastProductionsCache));return this.baseCstVisitorConstructor=e,e}return this.baseCstVisitorConstructor},t.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(pt(this.baseCstVisitorWithDefaultsConstructor)){var e=Ru(this.className,Ze(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}(),Cu=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 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)):Vn},t.prototype.LA=function(e){var n=this.currIdx+e;return n<0||this.tokVectorLength<=n?Vn:this.tokVector[n]},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}(),Iu=function(){function t(){}return t.prototype.ACTION=function(e){return e.call(this)},t.prototype.consume=function(e,n,r){return this.consumeInternal(n,e,r)},t.prototype.subrule=function(e,n,r){return this.subruleInternal(n,e,r)},t.prototype.option=function(e,n){return this.optionInternal(n,e)},t.prototype.or=function(e,n){return this.orInternal(n,e)},t.prototype.many=function(e,n){return this.manyInternal(e,n)},t.prototype.atLeastOne=function(e,n){return this.atLeastOneInternal(e,n)},t.prototype.CONSUME=function(e,n){return this.consumeInternal(e,0,n)},t.prototype.CONSUME1=function(e,n){return this.consumeInternal(e,1,n)},t.prototype.CONSUME2=function(e,n){return this.consumeInternal(e,2,n)},t.prototype.CONSUME3=function(e,n){return this.consumeInternal(e,3,n)},t.prototype.CONSUME4=function(e,n){return this.consumeInternal(e,4,n)},t.prototype.CONSUME5=function(e,n){return this.consumeInternal(e,5,n)},t.prototype.CONSUME6=function(e,n){return this.consumeInternal(e,6,n)},t.prototype.CONSUME7=function(e,n){return this.consumeInternal(e,7,n)},t.prototype.CONSUME8=function(e,n){return this.consumeInternal(e,8,n)},t.prototype.CONSUME9=function(e,n){return this.consumeInternal(e,9,n)},t.prototype.SUBRULE=function(e,n){return this.subruleInternal(e,0,n)},t.prototype.SUBRULE1=function(e,n){return this.subruleInternal(e,1,n)},t.prototype.SUBRULE2=function(e,n){return this.subruleInternal(e,2,n)},t.prototype.SUBRULE3=function(e,n){return this.subruleInternal(e,3,n)},t.prototype.SUBRULE4=function(e,n){return this.subruleInternal(e,4,n)},t.prototype.SUBRULE5=function(e,n){return this.subruleInternal(e,5,n)},t.prototype.SUBRULE6=function(e,n){return this.subruleInternal(e,6,n)},t.prototype.SUBRULE7=function(e,n){return this.subruleInternal(e,7,n)},t.prototype.SUBRULE8=function(e,n){return this.subruleInternal(e,8,n)},t.prototype.SUBRULE9=function(e,n){return this.subruleInternal(e,9,n)},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,n,r){if(r===void 0&&(r=Gn),fe(this.definedRulesNames,e)){var i=Qn.buildDuplicateRuleNameError({topLevelRule:e,grammarName:this.className}),a={message:i,type:Le.DUPLICATE_RULE_NAME,ruleName:e};this.definitionErrors.push(a)}this.definedRulesNames.push(e);var c=this.defineRule(e,n,r);return this[e]=c,c},t.prototype.OVERRIDE_RULE=function(e,n,r){r===void 0&&(r=Gn);var i=[];i=i.concat(eu(e,this.definedRulesNames,this.className)),this.definitionErrors.push.apply(this.definitionErrors,i);var a=this.defineRule(e,n,r);return this[e]=a,a},t.prototype.BACKTRACK=function(e,n){return function(){this.isBackTrackingStack.push(1);var r=this.saveRecogState();try{return e.apply(this,n),!0}catch(i){if(rn(i))return!1;throw i}finally{this.reloadRecogState(r),this.isBackTrackingStack.pop()}}},t.prototype.getGAstProductions=function(){return this.gastProductionsCache},t.prototype.getSerializedGastProductions=function(){return ds(xe(this.gastProductionsCache))},t}(),Ou=function(){function t(){}return t.prototype.initRecognizerEngine=function(e,n){if(this.className=gu(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=Bn,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},$(n,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a property. See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0 For Further details.`);if(ot(e)){if(ee(e))throw Error(`A Token Vocabulary cannot be empty. Note that the first argument for the parser constructor 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. See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0 For Further details.`)}if(ot(e))this.tokensMap=Ne(e,function(c,h){return c[h.name]=h,c},{});else if($(e,"modes")&&We(Ge(xe(e.modes)),El)){var r=Ge(xe(e.modes)),i=qr(r);this.tokensMap=Ne(i,function(c,h){return c[h.name]=h,c},{})}else if(Yr(e))this.tokensMap=on(e);else throw new Error(" argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=wt;var a=We(xe(e),function(c){return ee(c.categoryMatches)});this.tokenMatcher=a?Bn:Kn,cn(xe(this.tokensMap))},t.prototype.defineRule=function(e,n,r){if(this.selfAnalysisDone)throw Error("Grammar rule <"+e+`> may not be defined after the 'performSelfAnalysis' method has been called' Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var i=$(r,"resyncEnabled")?r.resyncEnabled:Gn.resyncEnabled,a=$(r,"recoveryValueFunc")?r.recoveryValueFunc:Gn.recoveryValueFunc,c=this.ruleShortNameIdx<n},t.prototype.orInternal=function(e,n){var r=this.getKeyForAutomaticLookahead(Fs,n),i=ot(e)?e:e.DEF,a=this.getLaFuncFromCache(r),c=a.call(this,i);if(c!==void 0){var h=i[c];return h.ALT.call(this)}this.raiseNoAltException(n,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),n=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:e,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new ks(n,e))}},t.prototype.subruleInternal=function(e,n,r){var i;try{var a=r!==void 0?r.ARGS:void 0;return i=e.call(this,n,a),this.cstPostNonTerminal(i,r!==void 0&&r.LABEL!==void 0?r.LABEL:e.ruleName),i}catch(c){this.subruleInternalError(c,r,e.ruleName)}},t.prototype.subruleInternalError=function(e,n,r){throw rn(e)&&e.partialCstResult!==void 0&&(this.cstPostNonTerminal(e.partialCstResult,n!==void 0&&n.LABEL!==void 0?n.LABEL:r),delete e.partialCstResult),e},t.prototype.consumeInternal=function(e,n,r){var i;try{var a=this.LA(1);this.tokenMatcher(a,e)===!0?(this.consumeToken(),i=a):this.consumeInternalError(e,a,r)}catch(c){i=this.consumeInternalRecovery(e,n,c)}return this.cstPostTerminal(r!==void 0&&r.LABEL!==void 0?r.LABEL:e.name,i),i},t.prototype.consumeInternalError=function(e,n,r){var i,a=this.LA(0);throw r!==void 0&&r.ERR_MSG?i=r.ERR_MSG:i=this.errorMessageProvider.buildMismatchTokenMessage({expected:e,actual:n,previous:a,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new ti(i,n,a))},t.prototype.consumeInternalRecovery=function(e,n,r){if(this.recoveryEnabled&&r.name==="MismatchedTokenException"&&!this.isBackTracking()){var i=this.getFollowsForInRuleRecovery(e,n);try{return this.tryInRuleRecovery(e,i)}catch(a){throw a.name===Ss?r:a}}else throw r},t.prototype.saveRecogState=function(){var e=this.errors,n=Se(this.RULE_STACK);return{errors:e,lexerState:this.exportLexerState(),RULE_STACK:n,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,n,r){this.RULE_OCCURRENCE_STACK.push(r),this.RULE_STACK.push(e),this.cstInvocationStateUpdate(n,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),wt)},t.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},t}(),Mu=function(){function t(){}return t.prototype.initErrorHandler=function(e){this._errors=[],this.errorMessageProvider=$(e,"errorMessageProvider")?e.errorMessageProvider:vt.errorMessageProvider},t.prototype.SAVE_ERROR=function(e){if(rn(e))return e.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:Se(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 Se(this._errors)},set:function(e){this._errors=e},enumerable:!1,configurable:!0}),t.prototype.raiseEarlyExitException=function(e,n,r){for(var i=this.getCurrRuleFullName(),a=this.getGAstProductions()[i],c=Jr(e,a,n,this.maxLookahead),h=c[0],p=[],u=1;u<=this.maxLookahead;u++)p.push(this.LA(u));var o=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:h,actual:p,previous:this.LA(0),customUserDescription:r,ruleName:i});throw this.SAVE_ERROR(new xs(o,this.LA(1),this.LA(0)))},t.prototype.raiseNoAltException=function(e,n){for(var r=this.getCurrRuleFullName(),i=this.getGAstProductions()[r],a=Zr(e,i,this.maxLookahead),c=[],h=1;h<=this.maxLookahead;h++)c.push(this.LA(h));var p=this.LA(0),u=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:a,actual:c,previous:p,customUserDescription:n,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new Ps(u,this.LA(1),p))},t}(),Uu=function(){function t(){}return t.prototype.initContentAssist=function(){},t.prototype.computeContentAssist=function(e,n){var r=this.gastProductionsCache[e];if(pt(r))throw Error("Rule ->"+e+"<- does not exist in this grammar.");return ms([r],n,this.tokenMatcher,this.maxLookahead)},t.prototype.getNextPossibleTokenTypes=function(e){var n=Je(e.ruleStack),r=this.getGAstProductions(),i=r[n],a=new Fl(i,e).startWalking();return a},t}(),er={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(er);var Yi=!0,Ki=Math.pow(2,It)-1,Vs=Xr({name:"RECORDING_PHASE_TOKEN",pattern:Qe.NA});cn([Vs]);var Gs=zn(Vs,`This IToken indicates the Parser is in Recording Phase See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(Gs);var Lu={name:`This CSTNode indicates the Parser is in Recording Phase See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},_u=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 n=function(i){var a=i>0?i:"";e["CONSUME"+a]=function(c,h){return this.consumeInternalRecord(c,i,h)},e["SUBRULE"+a]=function(c,h){return this.subruleInternalRecord(c,i,h)},e["OPTION"+a]=function(c){return this.optionInternalRecord(c,i)},e["OR"+a]=function(c){return this.orInternalRecord(c,i)},e["MANY"+a]=function(c){this.manyInternalRecord(i,c)},e["MANY_SEP"+a]=function(c){this.manySepFirstInternalRecord(i,c)},e["AT_LEAST_ONE"+a]=function(c){this.atLeastOneInternalRecord(i,c)},e["AT_LEAST_ONE_SEP"+a]=function(c){this.atLeastOneSepFirstInternalRecord(i,c)}},r=0;r<10;r++)n(r);e.consume=function(i,a,c){return this.consumeInternalRecord(a,i,c)},e.subrule=function(i,a,c){return this.subruleInternalRecord(a,i,c)},e.option=function(i,a){return this.optionInternalRecord(a,i)},e.or=function(i,a){return this.orInternalRecord(a,i)},e.many=function(i,a){this.manyInternalRecord(i,a)},e.atLeastOne=function(i,a){this.atLeastOneInternalRecord(i,a)},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 n=0;n<10;n++){var r=n>0?n:"";delete e["CONSUME"+r],delete e["SUBRULE"+r],delete e["OPTION"+r],delete e["OR"+r],delete e["MANY"+r],delete e["MANY_SEP"+r],delete e["AT_LEAST_ONE"+r],delete e["AT_LEAST_ONE_SEP"+r]}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,n){return function(){return!0}},t.prototype.LA_RECORD=function(e){return Vn},t.prototype.topLevelRuleRecord=function(e,n){try{var r=new xt({definition:[],name:e});return r.name=e,this.recordingProdStack.push(r),n.call(this),this.recordingProdStack.pop(),r}catch(i){if(i.KNOWN_RECORDER_ERROR!==!0)try{i.message=i.message+` This error was thrown during the "grammar recording phase" For more info see: https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw i}throw i}},t.prototype.optionInternalRecord=function(e,n){return zt.call(this,ye,e,n)},t.prototype.atLeastOneInternalRecord=function(e,n){zt.call(this,qe,n,e)},t.prototype.atLeastOneSepFirstInternalRecord=function(e,n){zt.call(this,Ye,n,e,Yi)},t.prototype.manyInternalRecord=function(e,n){zt.call(this,ce,n,e)},t.prototype.manySepFirstInternalRecord=function(e,n){zt.call(this,$e,n,e,Yi)},t.prototype.orInternalRecord=function(e,n){return Pu.call(this,e,n)},t.prototype.subruleInternalRecord=function(e,n,r){if(Dn(n),!e||$(e,"ruleName")===!1){var i=new Error(" argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(e)+">")+(` inside top level rule: <`+this.recordingProdStack[0].name+">"));throw i.KNOWN_RECORDER_ERROR=!0,i}var a=xn(this.recordingProdStack),c=e.ruleName,h=new Ue({idx:n,nonTerminalName:c,referencedRule:void 0});return a.definition.push(h),this.outputCst?Lu:er},t.prototype.consumeInternalRecord=function(e,n,r){if(Dn(n),!fs(e)){var i=new Error(" argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(e)+">")+(` inside top level rule: <`+this.recordingProdStack[0].name+">"));throw i.KNOWN_RECORDER_ERROR=!0,i}var a=xn(this.recordingProdStack),c=new ne({idx:n,terminalType:e});return a.definition.push(c),Gs},t}();function zt(t,e,n,r){r===void 0&&(r=!1),Dn(n);var i=xn(this.recordingProdStack),a=Ct(e)?e:e.DEF,c=new t({definition:[],idx:n});return r&&(c.separator=e.SEP),$(e,"MAX_LOOKAHEAD")&&(c.maxLookahead=e.MAX_LOOKAHEAD),this.recordingProdStack.push(c),a.call(this),i.definition.push(c),this.recordingProdStack.pop(),er}function Pu(t,e){var n=this;Dn(e);var r=xn(this.recordingProdStack),i=ot(t)===!1,a=i===!1?t:t.DEF,c=new He({definition:[],idx:e,ignoreAmbiguities:i&&t.IGNORE_AMBIGUITIES===!0});$(t,"MAX_LOOKAHEAD")&&(c.maxLookahead=t.MAX_LOOKAHEAD);var h=Jo(a,function(p){return Ct(p.GATE)});return c.hasPredicates=h,r.definition.push(c),V(a,function(p){var u=new Te({definition:[]});c.definition.push(u),$(p,"IGNORE_AMBIGUITIES")?u.ignoreAmbiguities=p.IGNORE_AMBIGUITIES:$(p,"GATE")&&(u.ignoreAmbiguities=!0),n.recordingProdStack.push(u),p.ALT.call(n),n.recordingProdStack.pop()}),er}function zi(t){return t===0?"":""+t}function Dn(t){if(t<0||t>Ki){var e=new Error("Invalid DSL Method idx value: <"+t+`> `+("Idx value must be a none negative value smaller than "+(Ki+1)));throw e.KNOWN_RECORDER_ERROR=!0,e}}var ku=function(){function t(){}return t.prototype.initPerformanceTracer=function(e){if($(e,"traceInitPerf")){var n=e.traceInitPerf,r=typeof n=="number";this.traceInitMaxIdent=r?n:1/0,this.traceInitPerf=r?n>0:n}else this.traceInitMaxIdent=0,this.traceInitPerf=vt.traceInitPerf;this.traceInitIndent=-1},t.prototype.TRACE_INIT=function(e,n){if(this.traceInitPerf===!0){this.traceInitIndent++;var r=new Array(this.traceInitIndent+1).join(" ");this.traceInitIndent <"+e+">");var i=ts(n),a=i.time,c=i.value,h=a>10?console.warn:console.log;return this.traceInitIndent time: "+a+"ms"),this.traceInitIndent--,c}else return n()},t}(),$s=globalThis&&globalThis.__extends||function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(r[a]=i[a])},t(e,n)};return function(e,n){t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}(),Vn=zn(wt,"",NaN,NaN,NaN,NaN,NaN,NaN);Object.freeze(Vn);var vt=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:Qr,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),Gn=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0}),Le;(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"})(Le||(Le={}));function xu(t){return t===void 0&&(t=void 0),function(){return t}}var ni=function(){function t(e,n){this.definitionErrors=[],this.selfAnalysisDone=!1;var r=this;if(r.initErrorHandler(n),r.initLexerAdapter(),r.initLooksAhead(n),r.initRecognizerEngine(e,n),r.initRecoverable(n),r.initTreeBuilder(n),r.initContentAssist(),r.initGastRecorder(n),r.initPerformanceTracer(n),$(n,"ignoredIssues"))throw new Error(`The IParserConfig property has been deprecated. Please use the flag on the relevant DSL method instead. See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES For further details.`);this.skipValidations=$(n,"skipValidations")?n.skipValidations:vt.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 n;e.selfAnalysisDone=!0;var r=e.className;e.TRACE_INIT("toFastProps",function(){es(e)}),e.TRACE_INIT("Grammar Recording",function(){try{e.enableRecording(),V(e.definedRulesNames,function(a){var c=e[a],h=c.originalGrammarAction,p=void 0;e.TRACE_INIT(a+" Rule",function(){p=e.topLevelRuleRecord(a,h)}),e.gastProductionsCache[a]=p})}finally{e.disableRecording()}});var i=[];if(e.TRACE_INIT("Grammar Resolving",function(){i=Cs({rules:xe(e.gastProductionsCache)}),e.definitionErrors.push.apply(e.definitionErrors,i)}),e.TRACE_INIT("Grammar Validations",function(){if(ee(i)&&e.skipValidations===!1){var a=Is({rules:xe(e.gastProductionsCache),maxLookahead:e.maxLookahead,tokenTypes:xe(e.tokensMap),errMsgProvider:Qn,grammarName:r});e.definitionErrors.push.apply(e.definitionErrors,a)}}),ee(e.definitionErrors)&&(e.recoveryEnabled&&e.TRACE_INIT("computeAllProdsFollows",function(){var a=_l(xe(e.gastProductionsCache));e.resyncFollows=a}),e.TRACE_INIT("ComputeLookaheadFunctions",function(){e.preComputeLookaheadFunctions(xe(e.gastProductionsCache))})),!t.DEFER_DEFINITION_ERRORS_HANDLING&&!ee(e.definitionErrors))throw n=x(e.definitionErrors,function(a){return a.message}),new Error(`Parser Definition Errors detected: `+n.join(` ------------------------------- `))})},t.DEFER_DEFINITION_ERRORS_HANDLING=!1,t}();xc(ni,[uu,pu,wu,Cu,Ou,Iu,Mu,Uu,_u,ku]);var Su=function(t){$s(e,t);function e(n,r){r===void 0&&(r=vt);var i=this,a=on(r);return a.outputCst=!0,i=t.call(this,n,a)||this,i}return e}(ni),Bu=function(t){$s(e,t);function e(n,r){r===void 0&&(r=vt);var i=this,a=on(r);return a.outputCst=!1,i=t.call(this,n,a)||this,i}return e}(ni);function Fu(t,e){var n=e===void 0?{}:e,r=n.resourceBase,i=r===void 0?"https://unpkg.com/chevrotain@"+_r+"/diagrams/":r,a=n.css,c=a===void 0?"https://unpkg.com/chevrotain@"+_r+"/diagrams/diagrams.css":a,h=` `,p=` `,u=`