index.js 681 KB

1234567
  1. "use strict";var Bu=Object.defineProperty;var Iu=(i,o,e)=>o in i?Bu(i,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[o]=e;var A=(i,o,e)=>Iu(i,typeof o!="symbol"?o+"":o,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@univerjs/core"),er=require("rxjs"),Fu=require("@univerjs/rpc");var Mt=(i=>(i.FALSE="FALSE",i.TRUE="TRUE",i))(Mt||{}),pt=(i=>(i[i.SUCCESS=0]="SUCCESS",i[i.ERROR=1]="ERROR",i))(pt||{}),Je=(i=>(i[i.FRONT=0]="FRONT",i[i.BACK=1]="BACK",i))(Je||{});function mi(i,o,e,t,r){for(let n=0,s=i.length;n<s;n++){const a=i[n];if(o!==a.unitId||e!==a.sheetId)continue;const{startRow:u,startColumn:c,endRow:l,endColumn:f}=a.range;if(t>=u&&t<=l&&r>=c&&r<=f)return!0}return!1}var h=(i=>(i.DIV_BY_ZERO="#DIV/0!",i.NAME="#NAME?",i.VALUE="#VALUE!",i.NUM="#NUM!",i.NA="#N/A",i.CYCLE="#CYCLE!",i.REF="#REF!",i.SPILL="#SPILL!",i.CALC="#CALC!",i.ERROR="#ERROR!",i.CONNECT="#GETTING_DATA",i.NULL="#NULL!",i))(h||{});const Kt=new Set(Object.values(h)),Ra=[...new Set(Object.values(h).map(i=>i.length))];var hi=(i=>(i[i.Financial=0]="Financial",i[i.Date=1]="Date",i[i.Math=2]="Math",i[i.Statistical=3]="Statistical",i[i.Lookup=4]="Lookup",i[i.Database=5]="Database",i[i.Text=6]="Text",i[i.Logical=7]="Logical",i[i.Information=8]="Information",i[i.Engineering=9]="Engineering",i[i.Cube=10]="Cube",i[i.Compatibility=11]="Compatibility",i[i.Web=12]="Web",i[i.Array=13]="Array",i[i.Univer=14]="Univer",i[i.User=15]="User",i[i.DefinedName=16]="DefinedName",i))(hi||{}),X=(i=>(i.PLUS="+",i.MINUS="-",i.MULTIPLY="*",i.DIVIDED="/",i.CONCATENATE="&",i.POWER="^",i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))(X||{}),Y=(i=>(i.EQUALS="=",i.NOT_EQUAL="<>",i.GREATER_THAN=">",i.GREATER_THAN_OR_EQUAL=">=",i.LESS_THAN="<",i.LESS_THAN_OR_EQUAL="<=",i))(Y||{});const Fr=new Map([["<>",4],["<",4],[">=",4],["=",4],[">",4],["<=",4],["&",3],["+",2],["-",2],["/",1],["*",1],["^",0]]),bt=new Set(Fr.keys()),ku=new Set(["=","<>",">",">=","<","<="]);var K=(i=>(i.OPEN_BRACKET="(",i.CLOSE_BRACKET=")",i.COMMA=",",i.SINGLE_QUOTATION="'",i.DOUBLE_QUOTATION='"',i.OPEN_BRACES="{",i.CLOSE_BRACES="}",i.COLON=":",i.OPEN_SQUARE_BRACKET="[",i.CLOSE_SQUARE_BRACKET="]",i))(K||{}),He=(i=>(i.PERCENTAGE="%",i.POUND="#",i))(He||{});const Wn=new Set(["%","#"]);var Ne=(i=>(i.AT="@",i.MINUS="-",i.PLUS="+",i))(Ne||{});const $u=" ",gi=[...Object.values(Y),...Object.values(X),...Object.values(K),...Object.values(He),...Object.values(Ne)];function hr(i){return gi.includes(i)}function di(i){for(const o of gi)if(i.indexOf(o)>-1)return!0;return!1}function Yu(i){return i[0]==="'"&&i[i.length-1]==="'"?i.substring(1,i.length-1):i}function Hu(i){return hr(i)&&i!==K.CLOSE_BRACES&&i!==K.CLOSE_BRACKET&&i!==K.SINGLE_QUOTATION&&i!==K.DOUBLE_QUOTATION||i===" "}const Gu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,K.OPEN_BRACKET,K.COMMA,K.COLON,K.OPEN_BRACES,K.OPEN_SQUARE_BRACKET]);function Wu(i){return Gu.has(i)}const Qu=new Set([X.PLUS,X.MINUS,X.MULTIPLY,X.DIVIDED,X.CONCATENATE,X.POWER,X.EQUALS,X.NOT_EQUAL,X.GREATER_THAN,X.GREATER_THAN_OR_EQUAL,X.LESS_THAN,X.LESS_THAN_OR_EQUAL,K.OPEN_BRACKET,K.COMMA,K.COLON,K.OPEN_BRACES,K.OPEN_SQUARE_BRACKET,He.PERCENTAGE,He.POUND]);function qu(i){return Qu.has(i)}function Ci(i){const o={};return Object.keys(i).forEach(e=>{const t=i[e];if(t==null)return!0;o[e]==null&&(o[e]={}),Object.keys(t).forEach(r=>{const n=t[r];o[e][r]=new S.ObjectMatrix(n)})}),o}function Ku(i){const o={};for(const e in i){const t=i[e];if(t!=null){o[e]==null&&(o[e]={});for(const r in t){const n=t[r],s={};n.forValue((a,u,c)=>{s[a]===void 0&&(s[a]={}),s[a][u]=c}),o[e][r]=s}}}return o}const _i='\\[([^\\[\\]\\/?:"<>|*\\\\]+)\\]',pa=new RegExp(_i),Xu="((?![\\[\\]\\/?*\\\\]).)*!",St="$",xs="\\s*?:\\s*?",qr="[A-Za-z]+",Kr="[1-9][0-9]*",cr=`'?(${_i})?(${Xu})?'?`,is=`\\${St}?${qr}\\${St}?${Kr}`,Zu=`^(${Ne.AT})?${cr}${is}${xs}${is}$`,Na=new RegExp(Zu),zu=`^${cr}\\s*?${is}(${He.POUND})?$`,Va=new RegExp(zu),Ju=`^${cr}\\${St}?${Kr}${xs}\\${St}?${Kr}$`,Oa=new RegExp(Ju),ec=`^${cr}\\${St}?${qr}${xs}\\${St}?${qr}$`,Ma=new RegExp(ec),tc=`^${cr}\\s*?\\${St}?${Kr}$`,Sa=new RegExp(tc),rc=`^${cr}\\s*?\\${St}?${qr}$`,Da=new RegExp(rc),nc="{.*?}",wa=new RegExp(nc,"g");function yr(i){return Va.lastIndex=0,Va.test(i)}function sc(i){return Na.lastIndex=0,Na.test(i)}function Ai(i){return Oa.lastIndex=0,Oa.test(i)}function Ei(i){return Ma.lastIndex=0,Ma.test(i)}function bi(i){return Sa.lastIndex=0,Sa.test(i)}function yi(i){return Da.lastIndex=0,Da.test(i)}function ac(i){return wa.lastIndex=0,wa.test(i)}function Ri(i){return yr(i)||sc(i)||Ai(i)||Ei(i)}const pi={id:"formula.mutation.register-function",type:S.CommandType.MUTATION,handler:()=>!0},Xr={id:"formula.mutation.set-array-formula-data",type:S.CommandType.MUTATION,handler:(i,o)=>!0},ic=/[^0-9]/g,oc=/[^A-Za-z]/g;function gr(i){let o=i[0]==="$";const e=i.substring(1);let t=e.indexOf("$")>-1;return S.Tools.isStringNumber(e)&&o&&!t&&(o=!1,t=!0),o&&t?S.AbsoluteRefType.ALL:o?S.AbsoluteRefType.COLUMN:t?S.AbsoluteRefType.ROW:S.AbsoluteRefType.NONE}function uc(i){const o=i.split("!");o.length>1&&(i=o[o.length-1]);const e=i.split(":");return e.length>1?{startAbsoluteRefType:gr(e[0]),endAbsoluteRefType:gr(e[1])}:{startAbsoluteRefType:gr(e[0])}}function Pa(i=S.AbsoluteRefType.NONE){let o="",e="";return i===S.AbsoluteRefType.ROW?o="$":i===S.AbsoluteRefType.COLUMN?e="$":i===S.AbsoluteRefType.ALL&&(o="$",e="$"),{rowAbsoluteString:o,columnAbsoluteString:e}}function Yt(i){const{startColumn:o,startRow:e,endColumn:t,endRow:r,startAbsoluteRefType:n,endAbsoluteRefType:s,rangeType:a=S.RANGE_TYPE.NORMAL}=i,u=Pa(n),c=Pa(s);if(a===S.RANGE_TYPE.ROW||a===S.RANGE_TYPE.ALL){const m=`${u.rowAbsoluteString}${e+1}`,d=`${c.rowAbsoluteString}${r+1}`;return`${m}:${d}`}if(a===S.RANGE_TYPE.COLUMN){const m=`${u.columnAbsoluteString}${S.Tools.chatAtABC(o)}`,d=`${c.columnAbsoluteString}${S.Tools.chatAtABC(t)}`;return`${m}:${d}`}const l=`${u.columnAbsoluteString}${S.Tools.chatAtABC(o)}${u.rowAbsoluteString}${e+1}`,f=`${c.columnAbsoluteString}${S.Tools.chatAtABC(t)}${c.rowAbsoluteString}${r+1}`;return l===f?l:`${l}:${f}`}function Ni(i,o){return`${Si(i)}!${Yt(o)}`}function Vi(i,o,e){return os(i)||os(o)?`'[${us(i)}]${us(o)}'!${Yt(e)}`:`[${i}]${o}!${Yt(e)}`}function Zr(i){const{unitId:o,sheetName:e,range:t}=i;return o!=null&&o.length>0&&e!=null&&e.length>0?Vi(o,e,t):e!=null&&e.length>0?Ni(e,t):Yt(t)}function kr(i){const o=Number.parseInt(i.replace(ic,""))-1,e=S.Tools.ABCatNum(i.replace(oc,"")),t=gr(i);return{row:o,column:e,absoluteRefType:t}}function _n(i){const o=pa.exec(i);let e="";o!=null&&(e=o[0].trim(),e=La(e.slice(1,e.length-1)),i=i.replace(pa,""));const t=i.indexOf("!");let r="",n="";return t>-1?(r=i.substring(0,t),r[0]==="'"&&r[r.length-1]==="'"&&(r=r.substring(1,r.length-1)),r=La(r),n=i.substring(t+1)):n=i,{refBody:n,sheetName:r,unitId:e}}function Cr(i){const{refBody:o,sheetName:e,unitId:t}=_n(i),r=o.indexOf(":");if(r===-1){const _=kr(o),C=_.row,E=_.column,b=_.absoluteRefType;return{unitId:t,sheetName:e,range:{startRow:C,startColumn:E,endRow:C,endColumn:E,startAbsoluteRefType:b,endAbsoluteRefType:b}}}const n=o.substring(0,r),s=o.substring(r+1),a=kr(n),u=kr(s),c=a.row>u.row?u.row:a.row,l=a.column>u.column?u.column:a.column,f=a.row>u.row?a.row:u.row,m=a.column>u.column?a.column:u.column;let d=S.RANGE_TYPE.NORMAL;return Number.isNaN(c)&&Number.isNaN(f)?d=S.RANGE_TYPE.COLUMN:Number.isNaN(l)&&Number.isNaN(m)&&(d=S.RANGE_TYPE.ROW),{unitId:t,sheetName:e,range:{startRow:c,startColumn:l,endRow:f,endColumn:m,startAbsoluteRefType:a.absoluteRefType,endAbsoluteRefType:u.absoluteRefType,rangeType:d}}}const cc=["LOG10"];function dr(i){const o=Oi(i);if(!Ri(o)||cc.includes(o.toUpperCase().trim()))return!1;const{range:e}=Cr(o);return!(e.endColumn>=16384)}function Oi(i){const o=[];let e=!1;for(let t=0,r=i.length;t<r;t++){const n=i[t];if(n===$u&&!e)o.push(n);else{if(!e&&(n===Ne.AT||n===Ne.MINUS||n===Ne.PLUS))continue;o.push(n),e=!0}}return o.join("")}function lc(i,o){const e=(i==null?void 0:i.split(","))||[];return i===""||e.length===0?[]:Mi(i)?e.map(n=>{const s=Cr(n);return{unitId:s.unitId,sheetId:o(s.sheetName),range:s.range,sheetName:s.sheetName}}):[]}function Mi(i){return((i==null?void 0:i.split(","))||[]).every(e=>dr(e.trim()))}function os(i){return i.length===0?!1:!!(di(i)||fc(i)||mc(i)||hc(i)||/[\s!$%^&*()+\-=\[\]{};':"\\|,.<>\/?()]/.test(i))}function Si(i){return os(i)?`'${us(i)}'`:i}function us(i){return i.replace(/'/g,"''")}function La(i){return i.replace(/''/g,"'")}function fc(i){const o=i.match(/[1-9][0-9]{0,6}/);return/^[A-Z]+[1-9][0-9]{0,6}$/.test(i)&&o!==null}function mc(i){return/^(R(-?[0-9]+)?C(-?[0-9]+)?|C(-?[0-9]+)?|R(-?[0-9]+)?)$/.test(i)}function hc(i){return!new RegExp("^\\p{Letter}","u").test(i.charAt(0))}var gc=Object.defineProperty,dc=Object.getOwnPropertyDescriptor,Cc=(i,o,e,t)=>{for(var r=t>1?void 0:t?dc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&gc(o,e,r),r},_c=(i,o)=>(e,t)=>o(e,t,i);exports.DefinedNamesService=class extends S.Disposable{constructor(e){super();A(this,"_definedNameMap",{});A(this,"_update$",new er.Subject);A(this,"update$",this._update$.asObservable());A(this,"_currentRange",{unitId:"",sheetId:"",range:{startRow:0,endRow:0,startColumn:0,endColumn:0}});A(this,"_currentRange$",new er.Subject);A(this,"currentRange$",this._currentRange$.asObservable());A(this,"_focusRange$",new er.Subject);A(this,"focusRange$",this._focusRange$.asObservable());this._univerInstanceService=e}dispose(){this._definedNameMap={}}getWorksheetByRef(e,t){var n;const{sheetName:r}=_n(t);return(n=this._univerInstanceService.getUnit(e))==null?void 0:n.getSheetBySheetName(r)}focusRange(e,t){const r=this.getValueById(e,t);r!=null&&this._focusRange$.next({...r,unitId:e})}setCurrentRange(e){this._currentRange=e,this._currentRange$.next(e)}getCurrentRange(){return this._currentRange}getCurrentRangeForString(){return Yt(this._currentRange.range)}registerDefinedNames(e,t){this._definedNameMap[e]=t,this._update()}registerDefinedName(e,t){this._definedNameMap[e]==null&&(this._definedNameMap[e]={}),this._definedNameMap[e][t.id]=t,this._update()}removeDefinedName(e,t){var r;(r=this._definedNameMap[e])==null||delete r[t],this._update()}removeUnitDefinedName(e){delete this._definedNameMap[e],this._update()}getDefinedNameMap(e){return this._definedNameMap[e]}getValueByName(e,t){var n;const r=this._definedNameMap[e];return r==null?null:(n=Array.from(Object.values(r)).filter(s=>s.name===t))==null?void 0:n[0]}getValueById(e,t){var r;return(r=this._definedNameMap[e])==null?void 0:r[t]}hasDefinedName(e){return this._definedNameMap[e]==null?!1:(Array.from(Object.values(this._definedNameMap[e])).length||0)!==0}_update(){this._update$.next(null)}};exports.DefinedNamesService=Cc([_c(0,S.IUniverInstanceService)],exports.DefinedNamesService);const Xt=S.createIdentifier("univer.formula.defined-names.service"),Ac=(i,o)=>{const{unitId:e,id:t}=o;return{...i.get(Xt).getValueById(e,t),unitId:e}},An={id:"formula.mutation.set-defined-name",type:S.CommandType.MUTATION,handler:(i,o)=>{if(o==null)return!1;const e=i.get(Xt),{id:t,unitId:r,name:n,formulaOrRefString:s,comment:a,hidden:u,localSheetId:c}=o;return e.registerDefinedName(r,{id:t,name:n.trim(),formulaOrRefString:s.trim(),comment:a==null?void 0:a.trim(),hidden:u,localSheetId:c}),!0}},js={id:"formula.mutation.remove-defined-name",type:S.CommandType.MUTATION,handler:(i,o)=>{if(o==null)return!1;const e=i.get(Xt),{unitId:t,id:r}=o;return e.removeDefinedName(t,r),!0}},En={id:"formula.mutation.set-feature-calculation",type:S.CommandType.MUTATION,handler:()=>!0},bn={id:"formula.mutation.remove-feature-calculation",type:S.CommandType.MUTATION,handler:()=>!0},Us={id:"formula.mutation.set-formula-calculation-start",type:S.CommandType.MUTATION,handler:()=>!0},Ts={id:"formula.mutation.set-formula-calculation-stop",type:S.CommandType.MUTATION,handler:()=>!0},zr={id:"formula.mutation.set-formula-calculation-notification",type:S.CommandType.MUTATION,handler:()=>!0},vs={id:"formula.mutation.set-formula-calculation-result",type:S.CommandType.MUTATION,handler:()=>!0},Bs={id:"formula.mutation.set-formula-data",type:S.CommandType.MUTATION,handler:(i,o)=>!0},yn={id:"formula.mutation.set-other-formula",type:S.CommandType.MUTATION,handler:()=>!0},Rn={id:"formula.mutation.remove-other-formula",type:S.CommandType.MUTATION,handler:()=>!0},Di={id:"formula.mutation.set-super-table",type:S.CommandType.MUTATION,handler:()=>!0},wi={id:"formula.mutation.remove-super-table",type:S.CommandType.MUTATION,handler:()=>!0},Is={id:"formula.mutation.set-super-table-option",type:S.CommandType.MUTATION,handler:()=>!0};class ht{constructor(o){A(this,"_cache");this._cache=new S.LRUMap(o)}set(o,e){const t=this._hash(o);this._cache.set(t,e)}get(o){const e=this._hash(o);return this._cache.get(e)}clear(){this._cache.clear()}_hash(o){return o.length<=64?o:S.hashAlgorithm(o).toString()}}const nt="P_1",Vt="R_1",nr="L_1",Rr="LR_1",Pi="LO_1",Ec="LET",_r="LAMBDA",bc="CUBE",yc=new Set(["RAND","RANDBETWEEN","NOW","TODAY"]),cs=new ht(1e5);function Ht(i){const o=cs.get(i);if(o)return o;const e=Cr(i);return cs.set(i,e),Cr(i)}function Rc(){cs.clear()}var Te=(i=>(i[i.NORMAL=0]="NORMAL",i[i.NUMBER=1]="NUMBER",i[i.STRING=2]="STRING",i[i.FUNCTION=3]="FUNCTION",i[i.REFERENCE=4]="REFERENCE",i[i.ARRAY=5]="ARRAY",i[i.DEFINED_NAME=6]="DEFINED_NAME",i))(Te||{});function ls(i){let o="";for(const e of i)typeof e=="string"?o+=e:o+=e.token;return o}class ae{constructor(){A(this,"_parent");A(this,"_token",Vt);A(this,"_children",[]);A(this,"_lambdaId");A(this,"_functionDefinitionPrivacyVar");A(this,"_lambdaParameter","");A(this,"_startIndex",-1);A(this,"_endIndex",-1);A(this,"_definedNames",[])}dispose(){var o;this._children.forEach(e=>{typeof e!="string"&&e.dispose()}),(o=this._functionDefinitionPrivacyVar)==null||o.clear(),this._functionDefinitionPrivacyVar=null,this._children=[],this._parent=null,this._definedNames=[]}getDefinedNames(){return this._definedNames}getStartIndex(){return this._startIndex}getLambdaId(){return this._lambdaId}setLambdaId(o){this._lambdaId=o}getFunctionDefinitionPrivacyVar(){return this._functionDefinitionPrivacyVar}setLambdaPrivacyVar(o){this._functionDefinitionPrivacyVar=o}getLambdaParameter(){return this._lambdaParameter}setLambdaParameter(o){this._lambdaParameter=o}getParent(){return this._parent}setParent(o){this._parent=o}getChildren(){return this._children}setChildren(o){this._children=o}addChildren(o){this._children.push(o)}addChildrenFirst(o){this._children.unshift(o)}getToken(){return this._token}setToken(o){this._token=o}setIndex(o,e){this._startIndex=o,this._endIndex=e}setDefinedNames(o){this._definedNames=o}hasDefinedNames(){return this._definedNames.length>0}replaceChild(o,e){const t=this._getIndexInParent(o);t!=null&&(this.getChildren().splice(t,1,e),e.setParent(this))}changeToParent(o){const e=this.getParent();e&&e.removeChild(this),this.setParent(o),o.getChildren().push(this)}removeChild(o){const e=this._getIndexInParent(o);e!=null&&this.getChildren().splice(e,1)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let n=0;n<r;n++){const s=e[n];s instanceof ae?t.push(s.serialize()):t.push(s)}return{token:o,st:this._startIndex,ed:this._endIndex,children:t}}_getIndexInParent(o){const e=this.getChildren(),t=e.length;for(let r=0;r<t;r++)if(e[r]===o)return r}}const Li=2e3,Qn=new ht(Li),qn=new ht(Li);class pn extends S.Disposable{constructor(){super(...arguments);A(this,"_currentLexerNode",new ae);A(this,"_upLevel",0);A(this,"_segment","");A(this,"_bracketState",[]);A(this,"_squareBracketState",0);A(this,"_bracesState",0);A(this,"_singleQuotationState",0);A(this,"_doubleQuotationState",0);A(this,"_lambdaState",!1);A(this,"_colonState",!1);A(this,"_formulaErrorCount",0);A(this,"_tableBracketState",!1)}dispose(){this._resetTemp(),this._currentLexerNode.dispose(),Qn.clear(),qn.clear()}getUpLevel(){return this._upLevel}isColonClose(){return this._colonState===!1}isColonOpen(){return this._colonState===!0}isDoubleQuotationClose(){return this._doubleQuotationState===0}isLambdaOpen(){return this._lambdaState===!0}isLambdaClose(){return this._lambdaState===!1}isSingleQuotationClose(){return this._singleQuotationState===0}isBracesClose(){return this._bracesState===0}isBracketClose(){return this._bracketState.length===0}isSquareBracketClose(){return this._squareBracketState===0}getCurrentLexerNode(){return this._currentLexerNode}getFunctionAndParameter(e,t){const r=this._getCurrentParamIndex(e,t);if(r==null||r===h.VALUE)return;const n=r[0];if(typeof n=="string")return;let s=n.getParent(),a=n;for(;s;){const u=s.getToken();if(u!==nt&&!hr(u)&&s.getStartIndex()!==-1){const c=s.getChildren().indexOf(a);return{functionName:u,paramIndex:c}}a=s,s=s.getParent()}}checkIfAddBracket(e){let t=0,r=e.length-1,n=e[r];for(;(n===K.CLOSE_BRACKET||n===" ")&&r>=0;)n===K.CLOSE_BRACKET&&t++,n=e[--r];const s=this._getCurrentParamIndex(e,e.length-2);if(s==null||s===h.VALUE)return 0;const a=s[0];if(typeof a=="string")return 0;let u=a.getParent(),c=0;for(s[1]===K.OPEN_BRACKET&&c++;u;){const l=u.getToken();l!==nt&&l!==K.COLON&&u.getStartIndex()!==-1&&l.toUpperCase()!==_r&&(t===0?c+=1:t--),u=u.getParent()}return c}sequenceNodesBuilder(e){const t=qn.get(e);if(t)return[...t];const r=this._getSequenceArray(e);if(r.length===0)return;const n=this.getSequenceNode(r);return qn.set(e,[...n]),n}convertRefersToAbsolute(e,t,r,n=""){const s=this.sequenceNodesBuilder(e);if(s==null)return e;let a="";e.substring(0,1)===X.EQUALS&&(a=X.EQUALS);for(let u=0,c=s.length;u<c;u++){const l=s[u];if(typeof l!="string"&&l.nodeType===Te.REFERENCE){const{token:f,endIndex:m}=l,d=Ht(f);if(d==null)continue;const{range:_,sheetName:C,unitId:E}=d,b={..._,startAbsoluteRefType:t,endAbsoluteRefType:r},R=Zr({range:b,unitId:E,sheetName:C||n}),p=R.length-f.length;s[u]={...l,token:R,endIndex:m+p};for(let V=u+1;V<c;V++){const M=s[V];typeof M!="string"&&(M.startIndex+=p,M.endIndex+=p)}}}return`${a}${ls(s)}`}moveFormulaRefOffset(e,t,r,n=!1){const s=this.sequenceNodesBuilder(e);if(s==null)return e;const a=[];for(let u=0,c=s.length;u<c;u++){const l=s[u];if(typeof l=="string"||l.nodeType!==Te.REFERENCE){a.push(l);continue}const{token:f}=l,m=Ht(f),{sheetName:d,unitId:_}=m;let C=m.range;if(!n&&C.startAbsoluteRefType===S.AbsoluteRefType.ALL&&C.endAbsoluteRefType===S.AbsoluteRefType.ALL){a.push(l);continue}else C=S.moveRangeByOffset(C,t,r,n);let E="";S.isValidRange(C)?E=Zr({range:C,unitId:_,sheetName:d}):E=h.REF,a.push({...l,token:E})}return`=${ls(a)}`}_formulaSpellCheck(){if(this._currentLexerNode.getChildren().length===0)return!0;const e=this._currentLexerNode.getChildren()[0];return!!(e instanceof ae||bt.has(e)||Wn.has(e)||e===Ne.AT||e===K.COMMA||e===K.COLON||e===K.OPEN_BRACKET)}getSequenceNode(e){const t=[];let r=!1;for(let n=0,s=e.length;n<s;n++){const a=e[n],u=e[n-1],{segment:c,currentString:l}=a;if(l===K.DOUBLE_QUOTATION&&(r=!0),(c!==""||n===0)&&n!==s-1){t.push(l);continue}let f=(u==null?void 0:u.segment)||"";const m=n-f.length;let d=n-1;const _=n-1;if(n===s-1&&this._isLastMergeString(l)&&(f+=l,d+=1),f===""||Fr.has(f)){t.push(l);continue}const C=f.trim(),E=Oi(C);r===!0&&C[C.length-1]===K.DOUBLE_QUOTATION&&C[0]!==K.OPEN_BRACES?(r=!1,this._processPushSequenceNode(t,Te.STRING,f,m,d,_)):yr(E)&&dr(E)?this._processPushSequenceNode(t,Te.REFERENCE,f,m,d,_):S.Tools.isStringNumber(C)?this._processPushSequenceNode(t,Te.NUMBER,f,m,d,_):C.length>0&&this._processPushSequenceNode(t,Te.FUNCTION,f,m,d,_),(n!==s-1||!this._isLastMergeString(l))&&t.push(l)}return this._mergeSequenceNodeReference(t)}_processPushSequenceNode(e,t,r,n,s,a){this._pushSequenceNode(e,{nodeType:t,token:r,startIndex:n,endIndex:s},a)}_getCurrentParamIndex(e,t){return this._nodeMaker(e,void 0,t)}_isLastMergeString(e){return e===K.DOUBLE_QUOTATION||S.Tools.isStringNumber(e)||!hr(e)}_mergeSequenceNodeReference(e){const t=[],r=e.length;let n=0;for(;n<r;){const s=e[n];if(typeof s=="string"){const a=e[n-1];if(s.trim()===K.CLOSE_BRACES&&a!=null&&typeof a!="string"&&a.nodeType===Te.FUNCTION&&a.token.trim().substring(0,1)===K.OPEN_BRACES){a.nodeType=Te.ARRAY,a.token+=s,a.endIndex+=s.length,n++;continue}t.push(s)}else{const a=e[n+1],u=e[n+2];a===K.COLON&&typeof s!="string"&&u!=null&&typeof u!="string"&&dr((s.token+a+u.token).trim())&&(s.nodeType=Te.REFERENCE,s.token+=a+u.token,s.endIndex=u.endIndex,n+=2),t.push(s)}n++}return this._minusSplitSequenceNode(t)}_minusSplitSequenceNode(e){const t=[];for(const r of e){if(typeof r!="string"){const s=r.token.match(/^(\s*([-@+]\s*)+)(.*)$/);if(s){const a=s[1],u=s[3];if(dr(u.trim())){const c=a.length,l=r.startIndex,f=r.startIndex+c-1,m={nodeType:Te.NORMAL,token:a,startIndex:l,endIndex:f},d={nodeType:Te.REFERENCE,token:u,startIndex:f+1,endIndex:r.endIndex};t.push(m),t.push(d);continue}}}t.push(r)}return t}_pushSequenceNode(e,t,r){const n=r-t.startIndex+1;e.splice(e.length-n,n,t)}nodeMakerTest(e){return this._nodeMaker(e)}treeBuilder(e,t=!0,r,n){if(t===!0){const m=Qn.get(e),d=n==null?void 0:n(e);if(m&&!d)return m}this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Vt);const s=[];let a=this._nodeMaker(e,s);if(a===h.VALUE||s.length===0)return a;let u=!1,c="",l=[];if(r){const{hasDefinedName:m,sequenceString:d,definedNames:_}=r(s);u=m,c=d,l=_}if(u&&(this._resetCurrentLexerNode(),this._currentLexerNode.setToken(Vt),a=this._nodeMaker(`=${c}`),a===h.VALUE))return a;const f=this._getTopNode(this._currentLexerNode);if(f&&(this._currentLexerNode=f),t){if(!this._suffixExpressionHandler(this._currentLexerNode))return h.VALUE;Qn.set(e,this._currentLexerNode)}return u&&this._currentLexerNode.setDefinedNames(l),this._currentLexerNode}_suffixExpressionHandler(e){var u;const t=e.getChildren();if(!t)return!1;const r=t.length,n=[],s=[];let a=!0;for(let c=0;c<r;c++){const l=t[c];if(l instanceof ae)a=this._suffixExpressionHandler(l),n.push(l);else{const f=l.trim();if(f==="")continue;if(bt.has(f)){if(f===X.PLUS&&this._deletePlusForPreNode(t[c-1]))continue;if(f!==X.PLUS&&f!==X.MINUS&&this._deletePlusForPreNode(t[c-1]))return!1;for(;s.length>0;){const m=(u=s[s.length-1])==null?void 0:u.trim();if(!m||m===K.OPEN_BRACKET)break;const d=Fr.get(m),_=Fr.get(f);if(!d||!_)break;if(_>=d)n.push(s.pop());else break}s.push(l)}else if(f===K.OPEN_BRACKET)s.push(l);else if(f===K.CLOSE_BRACKET)this._processSuffixExpressionCloseBracket(n,s,t,c);else{if(this._checkCloseBracket(t[c-1]))return!1;n.push(l)}}}return a?this._processSuffixExpressionRemain(n,s,e):!1}_processSuffixExpressionRemain(e,t,r){const n=e.length,s=e[n-1];for(;t.length>0;){const a=t.pop();if(!(s instanceof ae)&&(a===K.OPEN_BRACKET||a===K.CLOSE_BRACKET))return!1;e.push(a)}return r.setChildren(e),!0}_processSuffixExpressionCloseBracket(e,t,r,n){var s;if(this._checkOpenBracket(r[n-1])||this._checkOperator(r[n-1]))return!1;for(;t.length>0;){const a=(s=t[t.length-1])==null?void 0:s.trim();if(!a)break;if(a===K.OPEN_BRACKET){t.pop();break}e.push(t.pop())}}_checkCloseBracket(e){return e===K.CLOSE_BRACKET||e instanceof ae}_checkOpenBracket(e){return e===K.OPEN_BRACKET}_checkOperator(e){return e==null||e instanceof ae?!1:bt.has(e)}_deletePlusForPreNode(e){if(e==null)return!0;if(!(e instanceof ae)){const t=e.trim();if(bt.has(t)||t===K.OPEN_BRACKET)return!0}return!1}_resetCurrentLexerNode(){this._currentLexerNode=new ae}_resetSegment(){this._segment=""}_openBracket(e=0){this._bracketState.push(e)}_closeBracket(){this._bracketState.pop()}_openSquareBracket(){this._squareBracketState+=1}_closeSquareBracket(){this._squareBracketState-=1}_getCurrentBracket(){const e=this._bracketState;return e[e.length-1]}_changeCurrentBracket(e){const t=this._bracketState;t[t.length-1]=e}_openBraces(){this._bracesState+=1}_closeBraces(){this._bracesState-=1}_openSingleQuotation(){this._singleQuotationState+=1}_closeSingleQuotation(){this._singleQuotationState-=1}_openDoubleQuotation(){this._doubleQuotationState+=1}_closeDoubleQuotation(){this._doubleQuotationState-=1}_openLambda(){this._lambdaState=!0}_closeLambda(){this._lambdaState=!1}_openColon(e){this._upLevel=e,this._colonState=!0}_closeColon(){this._upLevel=0,this._colonState=!1}_isTableBracket(){return this._tableBracketState}_openTableBracket(){this._tableBracketState=!0}_closeTableBracket(){this._tableBracketState=!1}_formalErrorOccurred(){this._formulaErrorCount+=1}_hasFormalError(){return this._formulaErrorCount>0}_getLastChildCurrentLexerNode(){const e=this._currentLexerNode.getChildren();if(e&&e.length>0){const t=e[e.length-1];if(t instanceof ae)return t}return!1}_getLastChildCurrent(){const e=this._currentLexerNode.getChildren();return e&&e.length>0?e[e.length-1]:!1}_setParentCurrentLexerNode(){const e=this._currentLexerNode.getParent();return e?(this._currentLexerNode=e,!0):!1}_setAncestorCurrentLexerNode(){var r,n,s,a,u,c;const e=(r=this._currentLexerNode)==null?void 0:r.getParent();let t=!1;if(e&&e.getToken()===nr){if((n=e==null?void 0:e.getParent())!=null&&n.getParent()){const l=(a=(s=this._currentLexerNode.getParent())==null?void 0:s.getParent())==null?void 0:a.getParent();l&&(this._currentLexerNode=l),t=!0}}else if(e!=null&&e.getParent()){const l=(u=this._currentLexerNode.getParent())==null?void 0:u.getParent();l&&(this._currentLexerNode=l),t=!0}for(let l=0;l<this._upLevel;l++){const f=(c=this._currentLexerNode)==null?void 0:c.getParent();f&&(this._currentLexerNode=f),this._currentLexerNode?t=!0:t=!1}return t}_segmentCount(){return this._segment.trim().length}_pushSegment(e){this._segment+=e}_pushNodeToChildren(e,t=!1){let r=e;if(r!==""){const n=this._currentLexerNode.getChildren();if(!(r instanceof ae)&&this.isColonOpen()){const s=new ae;s.setToken(r),s.setParent(this._currentLexerNode),r=s}t?n.unshift(r):n.push(r)}this.isColonOpen()&&(this._setAncestorCurrentLexerNode(),this._closeColon())}_setCurrentLexerNode(e,t=!1){this._pushNodeToChildren(e,t),e.setParent(this._currentLexerNode),this._currentLexerNode=e}_newAndPushCurrentLexerNode(e,t,r=!1){const n=new ae;n.setToken(e),n.setIndex(t-e.length,t-1),this._setCurrentLexerNode(n,r)}_getTopNode(e){let t=e;for(;t!=null&&t.getParent();)t=t.getParent();return t}_removeLastChild(){this._currentLexerNode.getChildren().splice(-1)}_formulaErrorLastTokenCheck(e,t){const r=this._findPreviousToken(e,t)||"",n=e.length-1===t;if(!n&&this._isOperatorToken(r)||n&&Wu(r))return!0;if(Wn.has(r)){const s=this._findSecondLastNonSpaceToken(e,t);if(s==null||qu(s))return!0}return!1}_findPreviousToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r--}}_findSecondLastNonSpaceToken(e,t){let r=t,n=0;for(;r>=0;){const s=e[r];if(s!==" "&&(n++,n===2))return s;r--}return null}_findNextToken(e,t){let r=t;for(;r>=0;){const n=e[r];if(n!==" ")return n;r++}}_unexpectedEndingTokenExcludeOperator(e){return e===K.OPEN_BRACKET||e===K.COMMA||e===X.EQUALS||e===""}_unexpectedEndingToken(e){return!!(this._isOperatorToken(e)||this._unexpectedEndingTokenExcludeOperator(e))}_isOperatorToken(e){return!!bt.has(e)}_getSequenceArray(e){const t=[];return this._nodeMaker(e,t),t}_resetTemp(){this._currentLexerNode=new ae,this._upLevel=0,this._segment="",this._bracketState=[],this._bracesState=0,this._singleQuotationState=0,this._doubleQuotationState=0,this._lambdaState=!1,this._colonState=!1,this._formulaErrorCount=0}_checkErrorState(){return!!(this._bracketState.length>0||this._bracesState>0||this._singleQuotationState>0||this._doubleQuotationState>0||this._hasFormalError())}_checkSimilarErrorToken(e,t,r){let n=t;if(e!==He.POUND)return!0;let s=r[++n];for(;s===" ";)s=r[++n];return!!hr(s)}_checkIfErrorObject(e,t){return!!this._findErrorObject(e,t)}_findErrorObject(e,t){for(let r=0;r<Ra.length;r++){const n=Ra[r],s=t.slice(e,e+n).join("").toUpperCase();if(Kt.has(s))return s}}_nodeMaker(e,t,r){let n=e.replace(/\r\n$/,"").replace(/\r/g," ").replace(/\n/g," ");n.substring(0,1)===X.EQUALS&&(n=n.substring(1));const s=n.split(""),a=s.length;let u=0;for(this._resetTemp(),this._formulaErrorLastTokenCheck(s,a-1)&&this._formalErrorOccurred();u<a;){const c=s[u];if(r===u)return[this._currentLexerNode,c];if(c===He.POUND&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()&&this._checkIfErrorObject(u,s)){const l=this._findErrorObject(u,s);if(l==null)return h.VALUE;this._pushNodeToChildren(l);for(let f=0;f<l.length;f++){const m=s[u];this._pushSegment(m),this._addSequenceArray(t,m,u),u++}this._resetSegment();continue}else if(c===K.OPEN_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())if(this._segmentCount()>0||this.isLambdaOpen()){this.isLambdaClose()&&(this._newAndPushCurrentLexerNode(this._segment,u),this._resetSegment()),this._openBracket(1),this._closeLambda();const l=s[u+1];if(l&&l===K.CLOSE_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,l,u),u++,this._closeBracket();continue}else l&&this._newAndPushCurrentLexerNode(nt,u)}else this._pushNodeToChildren(c),this._openBracket(0),this._resetSegment();else if(c===K.CLOSE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred(),this._pushNodeToChildren(this._segment),this._resetSegment();const l=this._getCurrentBracket();if(l===0)this._pushNodeToChildren(c);else if(l===1){const f=s[u+1];if(f&&f===K.OPEN_BRACKET){if(!this._setParentCurrentLexerNode()&&u!==a-1)return h.VALUE;this._newAndPushCurrentLexerNode(nr,u,!0),this._openLambda()}else if(!this._setAncestorCurrentLexerNode()&&u!==a-1)return h.VALUE}else return h.VALUE;this._closeBracket()}else if(c===K.OPEN_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()){if(this._pushSegment(c),this._openBraces(),!this._formulaSpellCheck())return h.VALUE}else if(c===K.CLOSE_BRACES&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._pushSegment(c),this._pushNodeToChildren(this._segment),this._resetSegment(),this._closeBraces();else if(c===K.OPEN_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._segment.length>0&&this._openTableBracket(),this._pushSegment(c),this._openSquareBracket();else if(c===K.CLOSE_SQUARE_BRACKET&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose())this._closeSquareBracket(),this.isSquareBracketClose()?(this._pushSegment(c),this._isTableBracket()&&(this._pushNodeToChildren(this._segment),this._resetSegment()),this._closeTableBracket()):this._pushSegment(c);else if(c===K.DOUBLE_QUOTATION&&this.isSingleQuotationClose()&&this.isSquareBracketClose()){if(this.isDoubleQuotationClose())this._openDoubleQuotation();else{const l=s[u+1];l&&l===K.DOUBLE_QUOTATION?u++:this._closeDoubleQuotation()}this._pushSegment(c)}else if(c===K.SINGLE_QUOTATION&&this.isDoubleQuotationClose()){if(this.isSingleQuotationClose())this._openSingleQuotation(),this._segmentCount()===0&&this._resetSegment();else{const l=s[u+1];if(l&&l===K.SINGLE_QUOTATION){this._pushSegment(c),this._addSequenceArray(t,c,u),u++,this._pushSegment(l),this._addSequenceArray(t,l,u),u++;continue}else this._closeSingleQuotation()}this._pushSegment(c)}else if(c===K.COMMA&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){this._formulaErrorLastTokenCheck(s,u-1)&&this._formalErrorOccurred();const l=this._getCurrentBracket();if(l===1||l==null){if(this._pushNodeToChildren(this._segment),this._resetSegment(),!this._setParentCurrentLexerNode()&&u!==a-1&&l!=null)return h.VALUE;this._newAndPushCurrentLexerNode(nt,u)}else{const f=new ae;f.setToken(bc);const m=new ae;m.setToken(nt),m.changeToParent(f);const d=this._currentLexerNode.getParent();if(d&&d.getToken()===K.COLON){const _=d.getParent();if(!_)return h.VALUE;d.changeToParent(m),_.setChildren([]),f.changeToParent(_)}else return h.VALUE;this._changeCurrentBracket(1),this._pushNodeToChildren(this._segment),this._resetSegment(),this._currentLexerNode=f,this._newAndPushCurrentLexerNode(nt,u)}}else if(c===K.COLON&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isBracesClose()&&this.isSquareBracketClose()){const l=new ae;l.setToken(c);const f=new ae;f.setToken(nt),f.setParent(l);const m=new ae;m.setToken(nt),m.setParent(l),l.getChildren().push(f,m);let d=l,_=0;if(this._segmentCount()>0){let C,E,b=0;const R=this._segment.trim(),p=R[0],V=R[1];if(p===Ne.MINUS&&(C=new ae,C.setToken(Ne.MINUS),b++),(p===Ne.AT||V===Ne.AT)&&(E=new ae,E.setToken(Ne.AT),C&&(C.addChildren(E),E.setParent(C)),b++),b>0&&(this._segment=R.slice(b)),_=b,E)if(E.addChildren(l),l.setParent(E),E.getParent()){const D=E.getParent();D&&(d=D)}else d=E;else C&&(d=C,C.addChildren(l),l.setParent(C));const M=new ae;M.setToken(this._segment),M.setParent(f),f.getChildren().push(M),this._resetSegment()}else{const C=this._getLastChildCurrentLexerNode();C&&C.changeToParent(f)}this._setCurrentLexerNode(d),this._currentLexerNode=m,this._openColon(_)}else if(Wn.has(c)&&this._checkSimilarErrorToken(c,u,s)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){this._pushNodeToChildren(this._segment);const l=new ae;l.setToken(c);const f=this._getLastChildCurrent();f instanceof ae?f.changeToParent(l):f!==!1&&(l.getChildren().push(f),this._removeLastChild()),this._pushNodeToChildren(l),l.setParent(this._currentLexerNode),this._resetSegment()}else if(bt.has(c)&&this.isSingleQuotationClose()&&this.isDoubleQuotationClose()&&this.isSquareBracketClose()&&this.isBracesClose()){let l=this._segment.trim();if(c===X.MINUS&&l===""){const f=this._findPreviousToken(s,u-1)||"",m=this._findNextToken(s,u+1)||"";if(this._unexpectedEndingTokenExcludeOperator(f)&&this._isOperatorToken(m)){this._pushNodeToChildren("0"),this._pushNodeToChildren(X.MINUS),this._addSequenceArray(t,c,u),this._resetSegment(),u++;continue}else if(this._unexpectedEndingToken(f))if(m===X.PLUS){this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),this._addSequenceArray(t,X.PLUS,u+1),u+=2;continue}else{this._pushSegment(X.MINUS),this._addSequenceArray(t,c,u),u++;continue}}else if(this._segment.length>0&&this._isScientificNotation(s,u,c)){this._pushSegment(c),this._addSequenceArray(t,c,u),u++;continue}else this._segment.length>0&&l===""?l=this._segment:(this._pushNodeToChildren(this._segment),l="");if(c===X.LESS_THAN||c===X.GREATER_THAN){const f=s[u+1];if(f&&bt.has(c+f)){this._pushNodeToChildren(l+c+f),this._resetSegment(),this._addSequenceArray(t,c,u),u++,this._addSequenceArray(t,f,u),u++;continue}else this._pushNodeToChildren(l+c)}else this._pushNodeToChildren(l+c);this._resetSegment()}else this._pushSegment(c);this._addSequenceArray(t,c,u),u++}if(this._pushNodeToChildren(this._segment),this._checkErrorState())return h.VALUE}_isScientificNotation(e,t,r){const n=e[t-2];if(n&&Number.isNaN(Number(n))||!(r===X.MINUS||r===X.PLUS))return!1;const s=e[t+1];if(s&&Number.isNaN(Number(s)))return!1;const a=e[t-1];return a&&a.toUpperCase()==="E"}_addSequenceArray(e,t,r){e==null||e.push({segment:this._segment,currentString:t,cur:r,currentLexerNode:this._currentLexerNode})}}function pc(i,o,e,t,r,n,s){const a=(s==null?void 0:s.f)||"",u=(s==null?void 0:s.si)||"",c=S.isFormulaString(a),l=S.isFormulaId(u),f=i.getValue(r,n),m=(f==null?void 0:f.f)||"",d=(f==null?void 0:f.si)||"";function _(){var C;if(S.isFormulaString(m)&&S.isFormulaId(d)){const E=(C=e==null?void 0:e[d])==null?void 0:C.f;E?t.set(d,E):t.set(d,m)}}c&&l?(d!==u&&_(),i.setValue(r,n,{f:a,si:u}),e[u]={f:a,r,c:n},o.setValue(r,n,{f:a,si:u})):c&&!l?(m!==a&&_(),i.setValue(r,n,{f:a}),o.setValue(r,n,{f:a})):!c&&l?(d!==u&&_(),i.setValue(r,n,{f:"",si:u})):!c&&!l&&i.getValue(r,n)&&(_(),i.realDeleteValue(r,n),o.setValue(r,n,null))}function Nc(i,o,e,t){const r=i==null?void 0:i.getValue(e,t);if(r==null)return!0;const n=[];i.forValue((l,f,m)=>{l===e&&f===t||S.Rectangle.intersects(m,r)&&n.push(m)});const{startRow:s,startColumn:a,endRow:u,endColumn:c}=r;for(let l=s;l<=u;l++)for(let f=a;f<=c;f++){let m=!1;const d=S.cellToRange(l,f);n.some(_=>S.Rectangle.contains(_,d)?(m=!0,!0):!1),m||o.realDeleteValue(l,f)}}var Vc=Object.defineProperty,Oc=Object.getOwnPropertyDescriptor,Mc=(i,o,e,t)=>{for(var r=t>1?void 0:t?Oc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Vc(o,e,r),r},xa=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaDataModel=class extends S.Disposable{constructor(e,t){super();A(this,"_arrayFormulaRange",{});A(this,"_arrayFormulaCellData",{});this._univerInstanceService=e,this._lexerTreeBuilder=t}dispose(){super.dispose(),this._arrayFormulaRange={},this._arrayFormulaCellData={}}clearPreviousArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{var l,f,m,d;const s=r[n],a=(f=(l=this._arrayFormulaRange)==null?void 0:l[t])==null?void 0:f[n];if(a==null)return!0;const u=new S.ObjectMatrix(a);let c=new S.ObjectMatrix;((m=this._arrayFormulaCellData[t])==null?void 0:m[n])!=null&&(c=new S.ObjectMatrix((d=this._arrayFormulaCellData[t])==null?void 0:d[n])),s.forValue((_,C)=>{const E=u.getValue(_,C);if(E==null)return!0;const{startRow:b,startColumn:R,endRow:p,endColumn:V}=E;for(let M=b;M<=p;M++)for(let D=R;D<=V;D++)c.setValue(M,D,null);u.realDeleteValue(_,C)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=c.getData())})})}mergeArrayFormulaCellData(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]==null&&(this._arrayFormulaRange[t]={}),this._arrayFormulaCellData[t]==null&&(this._arrayFormulaCellData[t]={}),Object.keys(r).forEach(n=>{var c,l;const s=r[n],a=new S.ObjectMatrix((c=this._arrayFormulaRange[t])==null?void 0:c[n]),u=new S.ObjectMatrix((l=this._arrayFormulaCellData[t])==null?void 0:l[n]);s.forValue((f,m)=>{const d=a==null?void 0:a.getValue(f,m);if(d==null)return!0;const{startRow:_,startColumn:C,endRow:E,endColumn:b}=d;for(let R=_;R<=E;R++)for(let p=C;p<=b;p++)u.setValue(R,p,null)}),s.forValue((f,m,d)=>{u.setValue(f,m,d)}),this._arrayFormulaCellData[t]&&(this._arrayFormulaCellData[t][n]=u.getData())})})}getFormulaData(){const e={},t=this._univerInstanceService.getAllUnitsForType(S.UniverInstanceType.UNIVER_SHEET);return t.length===0||t.forEach(r=>{const n=r.getUnitId();e[n]={},r.getSheets().forEach(a=>{const u=a.getCellMatrix(),c=a.getSheetId();fs(e,n,c,u)})}),e}getSheetFormulaData(e,t){const r={},n=this._univerInstanceService.getUnit(e);if(n==null)return{};r[e]={};const s=n.getSheetBySheetId(t);if(s==null)return{};const a=s.getCellMatrix();return fs(r,e,t,a),r[e][t]}getArrayFormulaRange(){return this._arrayFormulaRange}setArrayFormulaRange(e){this._arrayFormulaRange=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}mergeArrayFormulaRange(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;this._arrayFormulaRange[t]||(this._arrayFormulaRange[t]={}),Object.keys(r).forEach(n=>{var u;const s=new S.ObjectMatrix(r[n]),a=new S.ObjectMatrix((u=this._arrayFormulaRange[t])==null?void 0:u[n]);s.forValue((c,l,f)=>{a.setValue(c,l,f)}),this._arrayFormulaRange[t]&&(this._arrayFormulaRange[t][n]=a.getData())})})}deleteArrayFormulaRange(e,t,r,n){var u;const s=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(s==null)return;const a=new S.ObjectMatrix(s);a.getValue(r,n)&&(a.realDeleteValue(r,n),this._arrayFormulaRange[e]&&(this._arrayFormulaRange[e][t]=a.getData()))}getCalculateData(){const e=this._univerInstanceService.getAllUnitsForType(S.UniverInstanceType.UNIVER_SHEET),t={},r={};for(const n of e){const s=n.getUnitId(),a=n.getSheets(),u={},c={};for(const l of a){const f=l.getSheetId(),m=l.getConfig();u[f]={cellData:new S.ObjectMatrix(m.cellData),rowCount:m.rowCount,columnCount:m.columnCount,rowData:m.rowData,columnData:m.columnData,defaultRowHeight:m.defaultRowHeight,defaultColumnWidth:m.defaultColumnWidth},c[l.getName()]=l.getSheetId()}t[s]=u,r[s]=c}return{allUnitData:t,unitSheetNameMap:r}}updateFormulaData(e,t,r){const n=new S.ObjectMatrix(r),s=this._getSheetFormulaIdMap(e,t),a=new Map,u=this.getFormulaData();u[e]==null&&(u[e]={});const c=u[e];c[t]==null&&(c[t]={});const l=new S.ObjectMatrix(c[t]||{}),f=new S.ObjectMatrix;return n.forValue((m,d,_)=>{pc(l,f,s,a,m,d,_)}),l.forValue((m,d,_)=>{const C=(_==null?void 0:_.f)||"",E=(_==null?void 0:_.si)||"";if(S.isFormulaId(E)){const b=s==null?void 0:s[E],R=a.get(E);if(b&&!S.isFormulaString(C)){const p=b.f,V=d-b.c,M=m-b.r;l.setValue(m,d,{f:p,si:E,x:V,y:M}),f.setValue(m,d,{f:p,si:E,x:V,y:M})}else if(typeof R=="string"){const p=(_==null?void 0:_.x)||0,V=(_==null?void 0:_.y)||0,M=this._lexerTreeBuilder.moveFormulaRefOffset(R,p,V);a.set(E,{r:m,c:d,f:M}),l.setValue(m,d,{f:M,si:E}),f.setValue(m,d,{f:M,si:E})}else if(typeof R=="object"){const p=d-R.c,V=m-R.r;l.setValue(m,d,{f:R.f,si:E,x:p,y:V}),f.setValue(m,d,{f:R.f,si:E,x:p,y:V})}}}),f.getMatrix()}updateArrayFormulaRange(e,t,r){var u;const n=(u=this._arrayFormulaRange[e])==null?void 0:u[t];if(!n)return;const s=new S.ObjectMatrix(n);new S.ObjectMatrix(r).forValue((c,l,f)=>{s.realDeleteValue(c,l)})}updateArrayFormulaCellData(e,t,r){var l,f;const n=(l=this._arrayFormulaRange[e])==null?void 0:l[t];if(!n)return;const s=new S.ObjectMatrix(n),a=(f=this._arrayFormulaCellData[e])==null?void 0:f[t];if(!a)return;const u=new S.ObjectMatrix(a);new S.ObjectMatrix(r).forValue((m,d,_)=>{Nc(s,u,m,d)})}getFormulaStringByCell(e,t,r,n){const s=this._univerInstanceService.getUnit(n);if(s==null)return null;const a=s.getSheetBySheetId(r);if(a==null)return null;const u=a.getCellMatrix(),c=u.getValue(e,t);if(c==null)return null;const{f:l,si:f}=c;if(S.isFormulaString(l))return l;if(S.isFormulaId(f)){let m=null;return u.forValue((d,_,C)=>{if(C==null)return!0;const{f:E,si:b}=C;if(S.isFormulaString(E)&&f===b)return m=this._lexerTreeBuilder.moveFormulaRefOffset(E,t-_,e-d),!1}),m}return null}getFormulaDirtyRanges(){const e=this.getFormulaData(),t=[];for(const r in e){const n=e[r];if(!n)continue;const s=this._univerInstanceService.getUnit(r);if(s)for(const a in n){const u=n[a];if(!u)continue;const c=s.getSheetBySheetId(a);if(!c)continue;const l={};for(const f of Object.keys(u)){const m=Number(f);for(const d in u[m]){const _=Number(d),C=c.getCellRaw(m,_),E=S.isFormulaString(C==null?void 0:C.f)||S.isFormulaId(C==null?void 0:C.si),b=(C==null?void 0:C.v)===void 0;if(!(E&&b))continue;l[_]||(l[_]=[]);const R=l[_].slice(-1)[0];R&&R.endRow===m-1?R.endRow=m:l[_].push({startRow:m,endRow:m})}}for(const f in l){const m=l[f];for(let d=0;d<m.length;d++){const _=m[d];t.push({unitId:r,sheetId:a,range:{rangeType:S.RANGE_TYPE.NORMAL,startRow:_.startRow,endRow:_.endRow,startColumn:Number(f),endColumn:Number(f)}})}}}}return t}_getSheetFormulaIdMap(e,t){const r={},n=this._univerInstanceService.getUnit(e);if(n==null)return r;const s=n.getSheetBySheetId(t);return s==null||s.getCellMatrix().forValue((u,c,l)=>{if(l==null)return!0;const{f,si:m}=l;S.isFormulaString(f)&&S.isFormulaId(m)&&(r[m]={f,r:u,c})}),r}};exports.FormulaDataModel=Mc([xa(0,S.IUniverInstanceService),xa(1,S.Inject(pn))],exports.FormulaDataModel);function fs(i,o,e,t){i[o]||(i[o]={}),i[o][e]||(i[o][e]={});const r=new Map,n=new S.ObjectMatrix(i[o][e]);t.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"",m=S.isFormulaString(l),d=S.isFormulaId(f);m&&d?(n.setValue(a,u,{f:l,si:f}),r.set(f,{f:l,r:a,c:u})):m&&!d?n.setValue(a,u,{f:l}):!m&&d&&n.setValue(a,u,{f:"",si:f})}),n.forValue((a,u,c)=>{const l=(c==null?void 0:c.f)||"",f=(c==null?void 0:c.si)||"";if(S.isFormulaId(f)&&!S.isFormulaString(l)){const m=r.get(f);if(m){const d=m.f,_=u-m.c,C=a-m.r;n.setValue(a,u,{f:d,si:f,x:_,y:C})}else n.realDeleteValue(a,u)}});const s=n.getMatrix();return{[o]:{[e]:s}}}const Sc=class ms{constructor(o,e){this.low=o,this.high=e}clone(){return new ms(this.low,this.high)}get max(){return this.clone()}less_than(o){return this.low<o.low||this.low===o.low&&this.high<o.high}equal_to(o){return this.low===o.low&&this.high===o.high}intersect(o){return!this.not_intersect(o)}not_intersect(o){return this.high<o.low||o.high<this.low}merge(o){return new ms(this.low===void 0?o.low:this.low<o.low?this.low:o.low,this.high===void 0?o.high:this.high>o.high?this.high:o.high)}output(){return[this.low,this.high]}static comparable_max(o,e){return o.merge(e)}static comparable_less_than(o,e){return o<e}},we=0,_e=1;class Lt{constructor(o=void 0,e=void 0,t=null,r=null,n=null,s=_e){if(this.left=t,this.right=r,this.parent=n,this.color=s,this.item={key:o,value:e},o&&o instanceof Array&&o.length===2&&!Number.isNaN(o[0])&&!Number.isNaN(o[1])){let[a,u]=o;a>u&&([a,u]=[u,a]),this.item.key=new Sc(a,u)}this.max=this.item.key?this.item.key.max:void 0}isNil(){return this.item.key===void 0&&this.item.value===void 0&&this.left===null&&this.right===null&&this.color===_e}_value_less_than(o){return this.item.value&&o.item.value&&this.item.value.less_than?this.item.value.less_than(o.item.value):this.item.value<o.item.value}less_than(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.less_than(o.item.key):this.item.key.less_than(o.item.key)||this.item.key.equal_to(o.item.key)&&this._value_less_than(o)}_value_equal(o){return this.item.value&&o.item.value&&this.item.value.equal_to?this.item.value.equal_to(o.item.value):this.item.value===o.item.value}equal_to(o){return this.item.value===this.item.key&&o.item.value===o.item.key?this.item.key.equal_to(o.item.key):this.item.key.equal_to(o.item.key)&&this._value_equal(o)}intersect(o){return this.item.key.intersect(o.item.key)}copy_data(o){this.item.key=o.item.key,this.item.value=o.item.value}update_max(){if(this.max=this.item.key?this.item.key.max:void 0,this.right&&this.right.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.right.max)}if(this.left&&this.left.max){const o=this.item.key.constructor.comparable_max;this.max=o(this.max,this.left.max)}}not_intersect_left_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.left.max.high!==void 0?this.left.max.high:this.left.max;return e(t,o.item.key.low)}not_intersect_right_subtree(o){const e=this.item.key.constructor.comparable_less_than;let t=this.right.max.low!==void 0?this.right.max.low:this.right.item.key.low;return e(o.item.key.high,t)}}class Fs{constructor(){this.root=null,this.nil_node=new Lt}get size(){let o=0;return this.tree_walk(this.root,()=>o++),o}get keys(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.key.output?e.item.key.output():e.item.key)),o}get values(){let o=[];return this.tree_walk(this.root,e=>o.push(e.item.value)),o}get items(){let o=[];return this.tree_walk(this.root,e=>o.push({key:e.item.key.output?e.item.key.output():e.item.key,value:e.item.value})),o}isEmpty(){return this.root==null||this.root===this.nil_node}clear(){this.root=null}insert(o,e=o){if(o===void 0)return;let t=new Lt(o,e,this.nil_node,this.nil_node,null,we);return this.tree_insert(t),this.recalc_max(t),t}exist(o,e=o){let t=new Lt(o,e);return!!this.tree_search(this.root,t)}remove(o,e=o){let t=new Lt(o,e),r=this.tree_search(this.root,t);return r&&this.tree_delete(r),r}search(o,e=(t,r)=>t===r?r.output():t){let t=new Lt(o),r=[];return this.tree_search_interval(this.root,t,r),r.map(n=>e(n.item.value,n.item.key))}intersect_any(o){let e=new Lt(o);return this.tree_find_any_interval(this.root,e)}forEach(o){this.tree_walk(this.root,e=>o(e.item.key,e.item.value))}map(o){const e=new Fs;return this.tree_walk(this.root,t=>e.insert(t.item.key,o(t.item.value,t.item.key))),e}*iterate(o,e=(t,r)=>t===r?r.output():t){let t;for(o?t=this.tree_search_nearest_forward(this.root,new Lt(o)):this.root&&(t=this.local_minimum(this.root));t;)yield e(t.item.value,t.item.key),t=this.tree_successor(t)}recalc_max(o){let e=o;for(;e.parent!=null;)e.parent.update_max(),e=e.parent}tree_insert(o){let e=this.root,t=null;if(this.root==null||this.root===this.nil_node)this.root=o;else{for(;e!==this.nil_node;)t=e,o.less_than(e)?e=e.left:e=e.right;o.parent=t,o.less_than(t)?t.left=o:t.right=o}this.insert_fixup(o)}insert_fixup(o){let e,t;for(e=o;e!==this.root&&e.parent.color===we;)e.parent===e.parent.parent.left?(t=e.parent.parent.right,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.right&&(e=e.parent,this.rotate_left(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_right(e.parent.parent))):(t=e.parent.parent.left,t.color===we?(e.parent.color=_e,t.color=_e,e.parent.parent.color=we,e=e.parent.parent):(e===e.parent.left&&(e=e.parent,this.rotate_right(e)),e.parent.color=_e,e.parent.parent.color=we,this.rotate_left(e.parent.parent)));this.root.color=_e}tree_delete(o){let e,t;o.left===this.nil_node||o.right===this.nil_node?e=o:e=this.tree_successor(o),e.left!==this.nil_node?t=e.left:t=e.right,t.parent=e.parent,e===this.root?this.root=t:(e===e.parent.left?e.parent.left=t:e.parent.right=t,e.parent.update_max()),this.recalc_max(t),e!==o&&(o.copy_data(e),o.update_max(),this.recalc_max(o)),e.color===_e&&this.delete_fixup(t)}delete_fixup(o){let e=o,t;for(;e!==this.root&&e.parent!=null&&e.color===_e;)e===e.parent.left?(t=e.parent.right,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_left(e.parent),t=e.parent.right),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.right.color===_e&&(t.color=we,t.left.color=_e,this.rotate_right(t),t=e.parent.right),t.color=e.parent.color,e.parent.color=_e,t.right.color=_e,this.rotate_left(e.parent),e=this.root)):(t=e.parent.left,t.color===we&&(t.color=_e,e.parent.color=we,this.rotate_right(e.parent),t=e.parent.left),t.left.color===_e&&t.right.color===_e?(t.color=we,e=e.parent):(t.left.color===_e&&(t.color=we,t.right.color=_e,this.rotate_left(t),t=e.parent.left),t.color=e.parent.color,e.parent.color=_e,t.left.color=_e,this.rotate_right(e.parent),e=this.root));e.color=_e}tree_search(o,e){if(!(o==null||o===this.nil_node))return e.equal_to(o)?o:e.less_than(o)?this.tree_search(o.left,e):this.tree_search(o.right,e)}tree_search_nearest_forward(o,e){let t,r=o;for(;r&&r!==this.nil_node;)r.less_than(e)?r.intersect(e)?(t=r,r=r.left):r=r.right:((!t||r.less_than(t))&&(t=r),r=r.left);return t||null}tree_search_interval(o,e,t){o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&this.tree_search_interval(o.left,e,t),o.intersect(e)&&t.push(o),o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&this.tree_search_interval(o.right,e,t))}tree_find_any_interval(o,e){let t=!1;return o!=null&&o!==this.nil_node&&(o.left!==this.nil_node&&!o.not_intersect_left_subtree(e)&&(t=this.tree_find_any_interval(o.left,e)),t||(t=o.intersect(e)),!t&&o.right!==this.nil_node&&!o.not_intersect_right_subtree(e)&&(t=this.tree_find_any_interval(o.right,e))),t}local_minimum(o){let e=o;for(;e.left!=null&&e.left!==this.nil_node;)e=e.left;return e}local_maximum(o){let e=o;for(;e.right!=null&&e.right!==this.nil_node;)e=e.right;return e}tree_successor(o){let e,t,r;if(o.right!==this.nil_node)e=this.local_minimum(o.right);else{for(t=o,r=o.parent;r!=null&&r.right===t;)t=r,r=r.parent;e=r}return e}rotate_left(o){let e=o.right;o.right=e.left,e.left!==this.nil_node&&(e.left.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.left=o,o.parent=e,o!=null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}rotate_right(o){let e=o.left;o.left=e.right,e.right!==this.nil_node&&(e.right.parent=o),e.parent=o.parent,o===this.root?this.root=e:o===o.parent.left?o.parent.left=e:o.parent.right=e,e.right=o,o.parent=e,o!==null&&o!==this.nil_node&&o.update_max(),e=o.parent,e!=null&&e!==this.nil_node&&e.update_max()}tree_walk(o,e){o!=null&&o!==this.nil_node&&(this.tree_walk(o.left,e),e(o),this.tree_walk(o.right,e))}testRedBlackProperty(){let o=!0;return this.tree_walk(this.root,function(e){e.color===we&&(e.left.color===_e&&e.right.color===_e||(o=!1))}),o}testBlackHeightProperty(o){let e=0,t=0,r=0;if(o.color===_e&&e++,o.left!==this.nil_node?t=this.testBlackHeightProperty(o.left):t=1,o.right!==this.nil_node?r=this.testBlackHeightProperty(o.right):r=1,t!==r)throw new Error("Red-black height property violated");return e+=t,e}}class Dc{constructor(){A(this,"_cache",new Map);A(this,"_continueBuildingCache",new Map)}set(o,e,t,r,n){if(!this.shouldContinueBuildingCache(o,e,t,n))return;let s=this._cache.get(o);s==null&&(s=new Map,this._cache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);u==null&&(u=new Map,a.set(t,u));let c=u.get(r);c==null&&(c=new Set,u.set(r,c)),c.add(n)}getCellValuePositions(o,e,t){var r,n;return(n=(r=this._cache.get(o))==null?void 0:r.get(e))==null?void 0:n.get(t)}getCellPositions(o,e,t,r,n){var a,u,c;const s=(c=(u=(a=this._cache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t))==null?void 0:c.get(r);return s&&[...s].filter(l=>n.some(([f,m])=>l>=f&&l<=m))}setContinueBuildingCache(o,e,t,r,n){if(t===-1||r===-1||n===-1)return;let s=this._continueBuildingCache.get(o);s==null&&(s=new Map,this._continueBuildingCache.set(o,s));let a=s.get(e);a==null&&(a=new Map,s.set(e,a));let u=a.get(t);if(u==null){u=new Fs,u.insert([r,n]),a.set(t,u);return}this._handleNewInterval(u,r,n)}shouldContinueBuildingCache(o,e,t,r){var a,u;if(t===-1||r===-1)return!1;const n=(u=(a=this._continueBuildingCache.get(o))==null?void 0:a.get(e))==null?void 0:u.get(t);return n?n.search([r,r]).length===0:!0}canUseCache(o,e,t,r,n){var f,m;const s=(m=(f=this._continueBuildingCache.get(o))==null?void 0:f.get(e))==null?void 0:m.get(t);if(t===-1||r===-1||n===-1||!s)return{rowsInCache:[],rowsNotInCache:[]};const a=s.search([r,n]);if(a.length===0)return{rowsInCache:[],rowsNotInCache:[]};a.sort((d,_)=>d[0]-_[0]);const u=[],c=[];let l=r;for(let d=0;d<a.length;d++){const[_,C]=a[d];if(l>=_){if(n<=C){u.push([l,n]);break}u.push([l,C]),l=C+1,d===a.length-1&&l<=n&&c.push([l,n])}else{if(n>C){u.push([_,C]),c.push([l,_-1]),l=C+1,d===a.length-1&&l<=n&&c.push([l,n]);continue}u.push([_,n]),c.push([l,_-1])}}return{rowsInCache:u,rowsNotInCache:c}}clear(){this._cache.clear(),this._continueBuildingCache.clear()}_handleNewInterval(o,e,t){let r=o.search([e,t]);if(r.length===0){const a=[e-1<0?0:e-1,t+1];if(r=o.search(a),r.length===0){o.insert([e,t]);return}}let n=e,s=t;for(const a of r)n=Math.min(n,a[0]),s=Math.max(s,a[1]),o.remove(a);o.insert([n,s])}}const yt=new Dc,Nn="engine-formula.config",xi=1,wc="CYCLE_REFERENCE_COUNT",ja={};var Pc=Object.defineProperty,Lc=Object.getOwnPropertyDescriptor,xc=(i,o,e,t)=>{for(var r=t>1?void 0:t?Lc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Pc(o,e,r),r},Ua=(i,o)=>(e,t)=>o(e,t,i);exports.FormulaCurrentConfigService=class extends S.Disposable{constructor(e,t){super();A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_arrayFormulaCellData",{});A(this,"_arrayFormulaRange",{});A(this,"_formulaData",{});A(this,"_sheetNameMap",{});A(this,"_forceCalculate",!1);A(this,"_clearDependencyTreeCache",{});A(this,"_dirtyRanges",[]);A(this,"_dirtyNameMap",{});A(this,"_dirtyDefinedNameMap",{});A(this,"_dirtyUnitFeatureMap",{});A(this,"_dirtyUnitOtherFormulaMap",{});A(this,"_excludedCell");A(this,"_sheetIdToNameMap",{});A(this,"_executeUnitId","");A(this,"_executeSubUnitId","");this._univerInstanceService=e,this._localeService=t}dispose(){this._unitData={},this._unitStylesData={},this._formulaData={},this._arrayFormulaCellData={},this._arrayFormulaRange={},this._sheetNameMap={},this._dirtyRanges=[],this._dirtyNameMap={},this._dirtyDefinedNameMap={},this._dirtyUnitFeatureMap={},this._excludedCell={},this._sheetIdToNameMap={},this._dirtyUnitOtherFormulaMap={}}getExecuteUnitId(){return this._executeUnitId}getExecuteSubUnitId(){return this._executeSubUnitId}setExecuteUnitId(e){this._executeUnitId=e}setExecuteSubUnitId(e){this._executeSubUnitId=e}getExcludedRange(){return this._excludedCell}getUnitData(){return this._unitData}getUnitStylesData(){return this._unitStylesData}getFormulaData(){return this._formulaData}getArrayFormulaCellData(){return this._arrayFormulaCellData}getArrayFormulaRange(){return this._arrayFormulaRange}getSheetNameMap(){return this._sheetNameMap}isForceCalculate(){return this._forceCalculate}getDirtyRanges(){return this._dirtyRanges}getDirtyNameMap(){return this._dirtyNameMap}getDirtyDefinedNameMap(){return this._dirtyDefinedNameMap}getDirtyUnitFeatureMap(){return this._dirtyUnitFeatureMap}getDirtyUnitOtherFormulaMap(){return this._dirtyUnitOtherFormulaMap}getSheetName(e,t){return this._sheetIdToNameMap[e]==null?"":this._sheetIdToNameMap[e][t]||""}getClearDependencyTreeCache(){return this._clearDependencyTreeCache}getLocale(){return this._localeService.getCurrentLocale()}getSheetsInfo(){const e=this._univerInstanceService.getCurrentUnitForType(S.UniverInstanceType.UNIVER_SHEET),{id:t,sheetOrder:r}=e.getSnapshot();return{sheetOrder:r,sheetNameMap:this._sheetIdToNameMap[t]}}getSheetRowColumnCount(e,t){const r=this._univerInstanceService.getUnit(e),n=r==null?void 0:r.getSheetBySheetId(t),s=n==null?void 0:n.getSnapshot();if(!s)return{rowCount:0,columnCount:0};const{rowCount:a,columnCount:u}=s;return{rowCount:a,columnCount:u}}load(e){if(e.allUnitData&&e.unitSheetNameMap&&e.unitStylesData)this._unitData=e.allUnitData,this._unitStylesData=e.unitStylesData,this._sheetNameMap=e.unitSheetNameMap;else{const{allUnitData:t,unitSheetNameMap:r,unitStylesData:n}=this._loadSheetData();this._unitData=t,this._unitStylesData=n,this._sheetNameMap=r}this._formulaData=e.formulaData,this._arrayFormulaCellData=Ci(e.arrayFormulaCellData),this._arrayFormulaRange=e.arrayFormulaRange,this._forceCalculate=e.forceCalculate,this._clearDependencyTreeCache=e.clearDependencyTreeCache||{},this._dirtyRanges=e.dirtyRanges,this._dirtyNameMap=e.dirtyNameMap,this._dirtyDefinedNameMap=e.dirtyDefinedNameMap,this._dirtyUnitFeatureMap=e.dirtyUnitFeatureMap,this._dirtyUnitOtherFormulaMap=e.dirtyUnitOtherFormulaMap,this._excludedCell=e.excludedCell,this._mergeNameMap(this._sheetNameMap,this._dirtyNameMap)}getDirtyData(){return{forceCalculation:this._forceCalculate,dirtyRanges:this._dirtyRanges,dirtyNameMap:this._dirtyNameMap,dirtyDefinedNameMap:this._dirtyDefinedNameMap,dirtyUnitFeatureMap:this._dirtyUnitFeatureMap,dirtyUnitOtherFormulaMap:this._dirtyUnitOtherFormulaMap,clearDependencyTreeCache:this._clearDependencyTreeCache}}loadDirtyRangesAndExcludedCell(e,t){this._dirtyRanges=e,this._excludedCell=t,this._dirtyNameMap={}}registerUnitData(e){this._unitData=e}registerFormulaData(e){this._formulaData=e}registerSheetNameMap(e){this._sheetNameMap=e}_mergeNameMap(e,t){Object.keys(t).forEach(r=>{t[r]&&Object.keys(t[r]).forEach(n=>{e[r]==null&&(e[r]={}),e[r][t[r][n]]=n})}),this._sheetIdToNameMap={},Object.keys(e).forEach(r=>{Object.keys(e[r]).forEach(n=>{this._sheetIdToNameMap[r]==null&&(this._sheetIdToNameMap[r]={}),this._sheetIdToNameMap[r][e[r][n]]=n})})}_loadSheetData(){const e=this._univerInstanceService.getAllUnitsForType(S.UniverInstanceType.UNIVER_SHEET),t=this._univerInstanceService.getCurrentUnitForType(S.UniverInstanceType.UNIVER_SHEET),r=t==null?void 0:t.getActiveSheet();this._executeUnitId=t==null?void 0:t.getUnitId(),this._executeSubUnitId=r==null?void 0:r.getSheetId();const n={},s={},a={};for(const u of e){const c=u.getUnitId(),l=u.getSheets(),f={},m={};for(const d of l){const _=d.getSheetId(),C=d.getConfig();f[_]={cellData:new S.ObjectMatrix(C.cellData),rowCount:C.rowCount,columnCount:C.columnCount,rowData:C.rowData,columnData:C.columnData,defaultRowHeight:C.defaultRowHeight,defaultColumnWidth:C.defaultColumnWidth},m[d.getName()]=d.getSheetId()}n[c]=f,s[c]=u.getStyles(),a[c]=m}return{allUnitData:n,unitStylesData:s,unitSheetNameMap:a}}};exports.FormulaCurrentConfigService=xc([Ua(0,S.IUniverInstanceService),Ua(1,S.Inject(S.LocaleService))],exports.FormulaCurrentConfigService);const gt=S.createIdentifier("univer.formula.current-data.service");var jc=Object.defineProperty,Uc=Object.getOwnPropertyDescriptor,Tc=(i,o,e,t)=>{for(var r=t>1?void 0:t?Uc(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&jc(o,e,r),r},Kn=(i,o)=>(e,t)=>o(e,t,i);exports.Lexer=class extends S.Disposable{constructor(o,e,t){super(),this._definedNamesService=o,this._lexerTreeBuilder=e,this._formulaCurrentConfigService=t}treeBuilder(o,e=!0){return this._lexerTreeBuilder.treeBuilder(o,e,this._injectDefinedName.bind(this),this._simpleCheckDefinedName.bind(this))}_simpleCheckDefinedName(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(o.indexOf(a)>-1)return!0}}return!1}_checkDefinedNameDirty(o){const e=this._formulaCurrentConfigService.getDirtyDefinedNameMap(),t=this._formulaCurrentConfigService.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++)if(r[n]===o)return!0}return!1}_injectDefinedName(o){const e=this._formulaCurrentConfigService.getExecuteUnitId();if(e==null)return{sequenceString:"",hasDefinedName:!1,definedNames:[]};const t=this._lexerTreeBuilder.getSequenceNode(o);let r="",n=!1;const s=[];for(let a=0,u=t.length;a<u;a++){const c=t[a];if(typeof c=="string"){r+=c;continue}const{nodeType:l,token:f}=c;if(l===Te.REFERENCE||l===Te.FUNCTION){const m=this._definedNamesService.getValueByName(e,f);if(m){let d=m.formulaOrRefString;d.substring(0,1)===X.EQUALS&&(d=d.substring(1)),r+=d,s.push(m.name),n=!0}else this._checkDefinedNameDirty(f)?(r+=h.NAME,n=!0,s.push(f)):r+=f}else r+=f}return{sequenceString:r,hasDefinedName:n,definedNames:s}}};exports.Lexer=Tc([Kn(0,Xt),Kn(1,S.Inject(pn)),Kn(2,gt)],exports.Lexer);function $r(i){if(i==null)return!0;const{v:o,f:e,si:t,p:r}=i;return!(!(o==null||typeof o=="string"&&o.length===0)||e!=null&&e.length>0||t!=null&&t.length>0||r!=null)}function ji(i,o,e,t,r){var s;const n=Object.keys(r);for(const a of n){const u=r[a],c=(s=u==null?void 0:u[t])==null?void 0:s[e];if(c==null)continue;const l=c.getValue(i,o);if(l!=null)return l}}const vc=["$","£","¥","¤","֏","؋","৳","฿","៛","₡","₦","₩","₪","₫","€","₭","₮","₱","₲","₴","₸","₹","₺","₼","₽","₾","₿"],Bc={currency:2,date:4,datetime:5,error:11,fraction:7,general:0,grouped:11,number:1,percent:6,scientific:8,text:9,time:5,unknown:11};function Ic(i,o,e){var u,c;if(i==null||o==null)return o;const t=(e==null?void 0:e.getStyleByCell(i))||i.s,r=(e==null?void 0:e.getStyleByCell(o))||o.s;if(t==null||r==null||typeof t!="object"||typeof r!="object")return o;const n=(u=t==null?void 0:t.n)==null?void 0:u.pattern,s=(c=r==null?void 0:r.n)==null?void 0:c.pattern;if(n==null||s==null)return o;const a=n||s;return r.n.pattern=a,o}const hs=new ht(1e5);function Ta(i){const o=hs.get(i);if(o!==void 0)return o;const e=kc(i);return hs.set(i,e),e}function Fc(){hs.clear()}function kc(i){if($c(i))return 3;const o=S.numfmt.getInfo(i).type||"unknown";return Bc[o]}function $c(i){return!!vc.find(o=>i.includes(o))&&i.startsWith("_(")}function jr(i,o,e){if(i==="")return o;if(o==="")return i;const t=Ta(i),r=Ta(o);return e===X.PLUS||e===X.MINUS?t===4&&r===4||t===11&&r===11?"":o:e===X.MULTIPLY||e===X.DIVIDED?t===6&&r===6||t===7&&r===7||t===8&&r===8||t===9&&r===9?o:"":i||o}const Yc=new Map([[S.LocaleType.EN_US,"$"],[S.LocaleType.RU_RU,"₽"],[S.LocaleType.VI_VN,"₫"],[S.LocaleType.ZH_CN,"¥"],[S.LocaleType.ZH_TW,"NT$"]]);function va(i){return Yc.get(i)||"$"}function Ye(i,o=2){let e=o;o>127&&(e=127);let t="";return e>0&&(t=`.${"0".repeat(e)}`),`"${va(i)}"#,##0${t}_);[Red]("${va(i)}"#,##0${t})`}function Hc(i,o,e=2){return S.numfmt.format(Ye(i,e),o)}const ks=new ht(1e5);function Gc(i){let o=i;o.startsWith('"')&&o.endsWith('"')&&(o=o.slice(1,-1));const e=ks.get(o);if(e)return{isNumberPattern:!0,value:e.value,pattern:e.pattern};const t=S.numfmt.parseNumber(o);if(t&&t.z)return Xn(o,t.v,t.z);const r=S.numfmt.parseDate(o);if(r&&r.z)return Xn(o,r.v,r.z);const n=S.numfmt.parseTime(o);return n&&n.z?Xn(o,n.v,n.z):{isNumberPattern:!1}}function Xn(i,o,e){return ks.set(i,{value:o,pattern:e}),{isNumberPattern:!0,value:o,pattern:e}}function Wc(){ks.clear()}class Vn{constructor(){A(this,"pattern","")}dispose(){}getPattern(){return this.pattern}setPattern(o){this.pattern=o}isError(){return!1}isAsyncObject(){return!1}isAsyncArrayObject(){return!1}isReferenceObject(){return!1}isArray(){return!1}isValueObject(){return!1}isEqualType(o){return!1}}class dt extends Vn{constructor(o){super(),this._rawValue=o}isValueObject(){return!0}toUnitRange(){return{range:{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1},sheetId:"",unitId:""}}getValue(){return 0}getArrayValue(){return[]}setValue(o){}setArrayValue(o){}isCube(){return!1}isString(){return!1}isNumber(){return!1}isBoolean(){return!1}isLambda(){return!1}isError(){return!1}isNull(){return!1}sum(){return g.create(h.VALUE)}max(){return g.create(h.VALUE)}min(){return g.create(h.VALUE)}count(){return g.create(h.VALUE)}countA(){return g.create(h.VALUE)}countBlank(){return g.create(h.VALUE)}getNegative(){return g.create(h.VALUE)}getReciprocal(){return g.create(h.VALUE)}plus(o){return g.create(h.VALUE)}minus(o){return g.create(h.VALUE)}multiply(o){return g.create(h.VALUE)}divided(o){return g.create(h.VALUE)}mod(o){return g.create(h.VALUE)}map(o){return g.create(h.NAME)}mapValue(o){return g.create(h.NAME)}compare(o,e,t=!1){return g.create(h.NAME)}isEqual(o){return this.compare(o,Y.EQUALS)}isNotEqual(o){return this.compare(o,Y.NOT_EQUAL)}isGreaterThanOrEqual(o){return this.compare(o,Y.GREATER_THAN_OR_EQUAL)}isLessThanOrEqual(o){return this.compare(o,Y.LESS_THAN_OR_EQUAL)}isLessThan(o){return this.compare(o,Y.LESS_THAN)}isGreaterThan(o){return this.compare(o,Y.GREATER_THAN)}concatenateFront(o){return g.create(h.NAME)}concatenateBack(o){return g.create(h.NAME)}plusBy(o){return g.create(h.VALUE)}minusBy(o){return g.create(h.VALUE)}multiplyBy(o){return g.create(h.VALUE)}dividedBy(o){return g.create(h.VALUE)}modInverse(o){return g.create(h.VALUE)}compareBy(o,e){return g.create(h.NAME)}concatenate(o,e=Je.FRONT){let t=this.getValue().toString();if(typeof o=="string")e===Je.FRONT?t=o+t:t+=o;else if(typeof o=="number")e===Je.FRONT?t=o.toString()+t:t+=o.toString();else if(typeof o=="boolean"){const r=o?"TRUE":"FALSE";e===Je.FRONT?t=r+t:t+=r}return t}pow(o){return g.create(h.VALUE)}powInverse(o){return g.create(h.VALUE)}sqrt(){return g.create(h.VALUE)}cbrt(){return g.create(h.VALUE)}cos(){return g.create(h.VALUE)}cosh(){return g.create(h.VALUE)}acos(){return g.create(h.VALUE)}acosh(){return g.create(h.VALUE)}sin(){return g.create(h.VALUE)}sinh(){return g.create(h.VALUE)}asin(){return g.create(h.VALUE)}asinh(){return g.create(h.VALUE)}tan(){return g.create(h.VALUE)}tanh(){return g.create(h.VALUE)}atan(){return g.create(h.VALUE)}atan2(o){return g.create(h.VALUE)}atan2Inverse(o){return g.create(h.VALUE)}atanh(){return g.create(h.VALUE)}mean(){return this}median(){return this}var(){return this}std(){return this}log(){return g.create(h.VALUE)}log10(){return g.create(h.VALUE)}exp(){return g.create(h.VALUE)}abs(){return g.create(h.VALUE)}round(o){return g.create(h.VALUE)}roundInverse(o){return g.create(h.VALUE)}floor(o){return g.create(h.VALUE)}floorInverse(o){return g.create(h.VALUE)}ceil(o){return g.create(h.VALUE)}ceilInverse(o){return g.create(h.VALUE)}convertToNumberObjectValue(){return g.create(h.VALUE)}convertToBooleanObjectValue(){return g.create(h.VALUE)}}const Qc=1e3,Ba=new ht(Qc);class g extends dt{constructor(o,e=""){super(o),this._errorType=o,this._errorContent=e}static create(o,e=""){const t=`${o}-${e}`,r=Ba.get(t);if(r)return r;const n=new g(o,e);return Ba.set(t,n),n}getValue(){return this._errorType}getErrorType(){return this._errorType}getErrorContent(){return this._errorContent}isEqualType(o){return o.getErrorType()===this.getErrorType()}isError(){return!0}}function qc(i){if(i===null)return 0;if(i!=null&&i.p){const o=i==null?void 0:i.p.body;if(o==null)return 0;const e=o.dataStream;return S.BuildTextUtils.transform.getPlainText(e)}return(i==null?void 0:i.v)||0}var Ut=(i=>(i[i.MIN=0]="MIN",i[i.MAX=1]="MAX",i))(Ut||{}),Me=(i=>(i[i.NORMAL=0]="NORMAL",i[i.MIN=1]="MIN",i[i.MAX=2]="MAX",i))(Me||{});function Jr(){return Intl&&Intl.Collator?new Intl.Collator(void 0,{numeric:!1}).compare:(i,o)=>i.localeCompare(o)}function Kc(i){return i.indexOf("*")>-1||i.indexOf("?")>-1}function Zn(i,o){const e=Zc(o).replace(/~?[*?]/g,r=>r.startsWith("~")?`\\${r.substring(1)}`:r==="*"?".*":r==="?"?".":r);return new RegExp(`^${e}$`).test(i)}function Ia(i){return i.replace(/~?[*?]/g,o=>o.startsWith("~")?o.substring(1):" ")}function Xc(i,o,e){let t=!1;switch(e){case Y.EQUALS:t=Zn(i,o);break;case Y.NOT_EQUAL:t=!Zn(i,o);break;case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:t=Zn(i,o)||i>Ia(o);break;case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:t=i<Ia(o);break}return t}function Zc(i){return i.replace(/[.+^${}()|[\]\\]/g,"\\$&")}function gs(i){switch(i){case 1:return 2;case 0:return 0;case-1:return 1;default:return 0}}function ds(i){return i===-2?1:0}function $s(i){let o;switch(i){case Y.EQUALS:o=Y.EQUALS;break;case Y.GREATER_THAN:o=Y.LESS_THAN;break;case Y.GREATER_THAN_OR_EQUAL:o=Y.LESS_THAN_OR_EQUAL;break;case Y.LESS_THAN:o=Y.GREATER_THAN;break;case Y.LESS_THAN_OR_EQUAL:o=Y.GREATER_THAN_OR_EQUAL;break;case Y.NOT_EQUAL:o=Y.NOT_EQUAL;break}return o}/*!
  2. * decimal.js v10.4.3
  3. * An arbitrary-precision Decimal type for JavaScript.
  4. * https://github.com/MikeMcl/decimal.js
  5. * Copyright (c) 2022 Michael Mclaughlin <M8ch88l@gmail.com>
  6. * MIT Licence
  7. */var Cs=9e15,Pt=1e9,_s="0123456789abcdef",en="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",tn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",As={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:Cs,crypto:!1},Ui,mt,ue=!0,On="[DecimalError] ",Dt=On+"Invalid argument: ",Ti=On+"Precision limit exceeded",vi=On+"crypto unavailable",Bi="[object Decimal]",xe=Math.floor,Se=Math.pow,zc=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Jc=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,el=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ii=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,tt=1e7,re=7,tl=9007199254740991,rl=en.length-1,Es=tn.length-1,I={toStringTag:Bi};I.absoluteValue=I.abs=function(){var i=new this.constructor(this);return i.s<0&&(i.s=1),ee(i)};I.ceil=function(){return ee(new this.constructor(this),this.e+1,2)};I.clampedTo=I.clamp=function(i,o){var e,t=this,r=t.constructor;if(i=new r(i),o=new r(o),!i.s||!o.s)return new r(NaN);if(i.gt(o))throw Error(Dt+o);return e=t.cmp(i),e<0?i:t.cmp(o)>0?o:new r(t)};I.comparedTo=I.cmp=function(i){var o,e,t,r,n=this,s=n.d,a=(i=new n.constructor(i)).d,u=n.s,c=i.s;if(!s||!a)return!u||!c?NaN:u!==c?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-c:0;if(u!==c)return u;if(n.e!==i.e)return n.e>i.e^u<0?1:-1;for(t=s.length,r=a.length,o=0,e=t<r?t:r;o<e;++o)if(s[o]!==a[o])return s[o]>a[o]^u<0?1:-1;return t===r?0:t>r^u<0?1:-1};I.cosine=I.cos=function(){var i,o,e=this,t=e.constructor;return e.d?e.d[0]?(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+re,t.rounding=1,e=nl(t,Hi(t,e)),t.precision=i,t.rounding=o,ee(mt==2||mt==3?e.neg():e,i,o,!0)):new t(1):new t(NaN)};I.cubeRoot=I.cbrt=function(){var i,o,e,t,r,n,s,a,u,c,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(ue=!1,n=l.s*Se(l.s*l,1/3),!n||Math.abs(n)==1/0?(e=Pe(l.d),i=l.e,(n=(i-e.length+1)%3)&&(e+=n==1||n==-2?"0":"00"),n=Se(e,1/3),i=xe((i+1)/3)-(i%3==(i<0?-1:2)),n==1/0?e="5e"+i:(e=n.toExponential(),e=e.slice(0,e.indexOf("e")+1)+i),t=new f(e),t.s=l.s):t=new f(n.toString()),s=(i=f.precision)+3;;)if(a=t,u=a.times(a).times(a),c=u.plus(l),t=Re(c.plus(l).times(a),c.plus(u),s+2,1),Pe(a.d).slice(0,s)===(e=Pe(t.d)).slice(0,s))if(e=e.slice(s-3,s+1),e=="9999"||!r&&e=="4999"){if(!r&&(ee(a,i+1,0),a.times(a).times(a).eq(l))){t=a;break}s+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(ee(t,i+1,1),o=!t.times(t).times(t).eq(l));break}return ue=!0,ee(t,i,f.rounding,o)};I.decimalPlaces=I.dp=function(){var i,o=this.d,e=NaN;if(o){if(i=o.length-1,e=(i-xe(this.e/re))*re,i=o[i],i)for(;i%10==0;i/=10)e--;e<0&&(e=0)}return e};I.dividedBy=I.div=function(i){return Re(this,new this.constructor(i))};I.dividedToIntegerBy=I.divToInt=function(i){var o=this,e=o.constructor;return ee(Re(o,new e(i),0,1,1),e.precision,e.rounding)};I.equals=I.eq=function(i){return this.cmp(i)===0};I.floor=function(){return ee(new this.constructor(this),this.e+1,3)};I.greaterThan=I.gt=function(i){return this.cmp(i)>0};I.greaterThanOrEqualTo=I.gte=function(i){var o=this.cmp(i);return o==1||o===0};I.hyperbolicCosine=I.cosh=function(){var i,o,e,t,r,n=this,s=n.constructor,a=new s(1);if(!n.isFinite())return new s(n.s?1/0:NaN);if(n.isZero())return a;e=s.precision,t=s.rounding,s.precision=e+Math.max(n.e,n.sd())+4,s.rounding=1,r=n.d.length,r<32?(i=Math.ceil(r/3),o=(1/Sn(4,i)).toString()):(i=16,o="2.3283064365386962890625e-10"),n=sr(s,1,n.times(o),new s(1),!0);for(var u,c=i,l=new s(8);c--;)u=n.times(n),n=a.minus(u.times(l.minus(u.times(l))));return ee(n,s.precision=e,s.rounding=t,!0)};I.hyperbolicSine=I.sinh=function(){var i,o,e,t,r=this,n=r.constructor;if(!r.isFinite()||r.isZero())return new n(r);if(o=n.precision,e=n.rounding,n.precision=o+Math.max(r.e,r.sd())+4,n.rounding=1,t=r.d.length,t<3)r=sr(n,2,r,r,!0);else{i=1.4*Math.sqrt(t),i=i>16?16:i|0,r=r.times(1/Sn(5,i)),r=sr(n,2,r,r,!0);for(var s,a=new n(5),u=new n(16),c=new n(20);i--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(c))))}return n.precision=o,n.rounding=e,ee(r,o,e,!0)};I.hyperbolicTangent=I.tanh=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+7,t.rounding=1,Re(e.sinh(),e.cosh(),t.precision=i,t.rounding=o)):new t(e.s)};I.inverseCosine=I.acos=function(){var i,o=this,e=o.constructor,t=o.abs().cmp(1),r=e.precision,n=e.rounding;return t!==-1?t===0?o.isNeg()?et(e,r,n):new e(0):new e(NaN):o.isZero()?et(e,r+4,n).times(.5):(e.precision=r+6,e.rounding=1,o=o.asin(),i=et(e,r+4,n).times(.5),e.precision=r,e.rounding=n,i.minus(o))};I.inverseHyperbolicCosine=I.acosh=function(){var i,o,e=this,t=e.constructor;return e.lte(1)?new t(e.eq(1)?0:NaN):e.isFinite()?(i=t.precision,o=t.rounding,t.precision=i+Math.max(Math.abs(e.e),e.sd())+4,t.rounding=1,ue=!1,e=e.times(e).minus(1).sqrt().plus(e),ue=!0,t.precision=i,t.rounding=o,e.ln()):new t(e)};I.inverseHyperbolicSine=I.asinh=function(){var i,o,e=this,t=e.constructor;return!e.isFinite()||e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+2*Math.max(Math.abs(e.e),e.sd())+6,t.rounding=1,ue=!1,e=e.times(e).plus(1).sqrt().plus(e),ue=!0,t.precision=i,t.rounding=o,e.ln())};I.inverseHyperbolicTangent=I.atanh=function(){var i,o,e,t,r=this,n=r.constructor;return r.isFinite()?r.e>=0?new n(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(i=n.precision,o=n.rounding,t=r.sd(),Math.max(t,i)<2*-r.e-1?ee(new n(r),i,o,!0):(n.precision=e=t-r.e,r=Re(r.plus(1),new n(1).minus(r),e+i,1),n.precision=i+4,n.rounding=1,r=r.ln(),n.precision=i,n.rounding=o,r.times(.5))):new n(NaN)};I.inverseSine=I.asin=function(){var i,o,e,t,r=this,n=r.constructor;return r.isZero()?new n(r):(o=r.abs().cmp(1),e=n.precision,t=n.rounding,o!==-1?o===0?(i=et(n,e+4,t).times(.5),i.s=r.s,i):new n(NaN):(n.precision=e+6,n.rounding=1,r=r.div(new n(1).minus(r.times(r)).sqrt().plus(1)).atan(),n.precision=e,n.rounding=t,r.times(2)))};I.inverseTangent=I.atan=function(){var i,o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding;if(c.isFinite()){if(c.isZero())return new l(c);if(c.abs().eq(1)&&f+4<=Es)return s=et(l,f+4,m).times(.25),s.s=c.s,s}else{if(!c.s)return new l(NaN);if(f+4<=Es)return s=et(l,f+4,m).times(.5),s.s=c.s,s}for(l.precision=a=f+10,l.rounding=1,e=Math.min(28,a/re+2|0),i=e;i;--i)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(ue=!1,o=Math.ceil(a/re),t=1,u=c.times(c),s=new l(c),r=c;i!==-1;)if(r=r.times(u),n=s.minus(r.div(t+=2)),r=r.times(u),s=n.plus(r.div(t+=2)),s.d[o]!==void 0)for(i=o;s.d[i]===n.d[i]&&i--;);return e&&(s=s.times(2<<e-1)),ue=!0,ee(s,l.precision=f,l.rounding=m,!0)};I.isFinite=function(){return!!this.d};I.isInteger=I.isInt=function(){return!!this.d&&xe(this.e/re)>this.d.length-2};I.isNaN=function(){return!this.s};I.isNegative=I.isNeg=function(){return this.s<0};I.isPositive=I.isPos=function(){return this.s>0};I.isZero=function(){return!!this.d&&this.d[0]===0};I.lessThan=I.lt=function(i){return this.cmp(i)<0};I.lessThanOrEqualTo=I.lte=function(i){return this.cmp(i)<1};I.logarithm=I.log=function(i){var o,e,t,r,n,s,a,u,c=this,l=c.constructor,f=l.precision,m=l.rounding,d=5;if(i==null)i=new l(10),o=!0;else{if(i=new l(i),e=i.d,i.s<0||!e||!e[0]||i.eq(1))return new l(NaN);o=i.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new l(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(o)if(e.length>1)n=!0;else{for(r=e[0];r%10===0;)r/=10;n=r!==1}if(ue=!1,a=f+d,s=Nt(c,a),t=o?rn(l,a+10):Nt(i,a),u=Re(s,t,a,1),Ar(u.d,r=f,m))do if(a+=10,s=Nt(c,a),t=o?rn(l,a+10):Nt(i,a),u=Re(s,t,a,1),!n){+Pe(u.d).slice(r+1,r+15)+1==1e14&&(u=ee(u,f+1,0));break}while(Ar(u.d,r+=10,m));return ue=!0,ee(u,f,m)};I.minus=I.sub=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,_=d.constructor;if(i=new _(i),!d.d||!i.d)return!d.s||!i.s?i=new _(NaN):d.d?i.s=-i.s:i=new _(i.d||d.s!==i.s?d:NaN),i;if(d.s!=i.s)return i.s=-i.s,d.plus(i);if(c=d.d,m=i.d,a=_.precision,u=_.rounding,!c[0]||!m[0]){if(m[0])i.s=-i.s;else if(c[0])i=new _(d);else return new _(u===3?-0:0);return ue?ee(i,a,u):i}if(e=xe(i.e/re),l=xe(d.e/re),c=c.slice(),n=l-e,n){for(f=n<0,f?(o=c,n=-n,s=m.length):(o=m,e=l,s=c.length),t=Math.max(Math.ceil(a/re),s)+2,n>t&&(n=t,o.length=1),o.reverse(),t=n;t--;)o.push(0);o.reverse()}else{for(t=c.length,s=m.length,f=t<s,f&&(s=t),t=0;t<s;t++)if(c[t]!=m[t]){f=c[t]<m[t];break}n=0}for(f&&(o=c,c=m,m=o,i.s=-i.s),s=c.length,t=m.length-s;t>0;--t)c[s++]=0;for(t=m.length;t>n;){if(c[--t]<m[t]){for(r=t;r&&c[--r]===0;)c[r]=tt-1;--c[r],c[t]+=tt}c[t]-=m[t]}for(;c[--s]===0;)c.pop();for(;c[0]===0;c.shift())--e;return c[0]?(i.d=c,i.e=Mn(c,e),ue?ee(i,a,u):i):new _(u===3?-0:0)};I.modulo=I.mod=function(i){var o,e=this,t=e.constructor;return i=new t(i),!e.d||!i.s||i.d&&!i.d[0]?new t(NaN):!i.d||e.d&&!e.d[0]?ee(new t(e),t.precision,t.rounding):(ue=!1,t.modulo==9?(o=Re(e,i.abs(),0,3,1),o.s*=i.s):o=Re(e,i,0,t.modulo,1),o=o.times(i),ue=!0,e.minus(o))};I.naturalExponential=I.exp=function(){return bs(this)};I.naturalLogarithm=I.ln=function(){return Nt(this)};I.negated=I.neg=function(){var i=new this.constructor(this);return i.s=-i.s,ee(i)};I.plus=I.add=function(i){var o,e,t,r,n,s,a,u,c,l,f=this,m=f.constructor;if(i=new m(i),!f.d||!i.d)return!f.s||!i.s?i=new m(NaN):f.d||(i=new m(i.d||f.s===i.s?f:NaN)),i;if(f.s!=i.s)return i.s=-i.s,f.minus(i);if(c=f.d,l=i.d,a=m.precision,u=m.rounding,!c[0]||!l[0])return l[0]||(i=new m(f)),ue?ee(i,a,u):i;if(n=xe(f.e/re),t=xe(i.e/re),c=c.slice(),r=n-t,r){for(r<0?(e=c,r=-r,s=l.length):(e=l,t=n,s=c.length),n=Math.ceil(a/re),s=n>s?n+1:s+1,r>s&&(r=s,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for(s=c.length,r=l.length,s-r<0&&(r=s,e=l,l=c,c=e),o=0;r;)o=(c[--r]=c[r]+l[r]+o)/tt|0,c[r]%=tt;for(o&&(c.unshift(o),++t),s=c.length;c[--s]==0;)c.pop();return i.d=c,i.e=Mn(c,t),ue?ee(i,a,u):i};I.precision=I.sd=function(i){var o,e=this;if(i!==void 0&&i!==!!i&&i!==1&&i!==0)throw Error(Dt+i);return e.d?(o=Fi(e.d),i&&e.e+1>o&&(o=e.e+1)):o=NaN,o};I.round=function(){var i=this,o=i.constructor;return ee(new o(i),i.e+1,o.rounding)};I.sine=I.sin=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+Math.max(e.e,e.sd())+re,t.rounding=1,e=al(t,Hi(t,e)),t.precision=i,t.rounding=o,ee(mt>2?e.neg():e,i,o,!0)):new t(NaN)};I.squareRoot=I.sqrt=function(){var i,o,e,t,r,n,s=this,a=s.d,u=s.e,c=s.s,l=s.constructor;if(c!==1||!a||!a[0])return new l(!c||c<0&&(!a||a[0])?NaN:a?s:1/0);for(ue=!1,c=Math.sqrt(+s),c==0||c==1/0?(o=Pe(a),(o.length+u)%2==0&&(o+="0"),c=Math.sqrt(o),u=xe((u+1)/2)-(u<0||u%2),c==1/0?o="5e"+u:(o=c.toExponential(),o=o.slice(0,o.indexOf("e")+1)+u),t=new l(o)):t=new l(c.toString()),e=(u=l.precision)+3;;)if(n=t,t=n.plus(Re(s,n,e+2,1)).times(.5),Pe(n.d).slice(0,e)===(o=Pe(t.d)).slice(0,e))if(o=o.slice(e-3,e+1),o=="9999"||!r&&o=="4999"){if(!r&&(ee(n,u+1,0),n.times(n).eq(s))){t=n;break}e+=4,r=1}else{(!+o||!+o.slice(1)&&o.charAt(0)=="5")&&(ee(t,u+1,1),i=!t.times(t).eq(s));break}return ue=!0,ee(t,u,l.rounding,i)};I.tangent=I.tan=function(){var i,o,e=this,t=e.constructor;return e.isFinite()?e.isZero()?new t(e):(i=t.precision,o=t.rounding,t.precision=i+10,t.rounding=1,e=e.sin(),e.s=1,e=Re(e,new t(1).minus(e.times(e)).sqrt(),i+10,0),t.precision=i,t.rounding=o,ee(mt==2||mt==4?e.neg():e,i,o,!0)):new t(NaN)};I.times=I.mul=function(i){var o,e,t,r,n,s,a,u,c,l=this,f=l.constructor,m=l.d,d=(i=new f(i)).d;if(i.s*=l.s,!m||!m[0]||!d||!d[0])return new f(!i.s||m&&!m[0]&&!d||d&&!d[0]&&!m?NaN:!m||!d?i.s/0:i.s*0);for(e=xe(l.e/re)+xe(i.e/re),u=m.length,c=d.length,u<c&&(n=m,m=d,d=n,s=u,u=c,c=s),n=[],s=u+c,t=s;t--;)n.push(0);for(t=c;--t>=0;){for(o=0,r=u+t;r>t;)a=n[r]+d[t]*m[r-t-1]+o,n[r--]=a%tt|0,o=a/tt|0;n[r]=(n[r]+o)%tt|0}for(;!n[--s];)n.pop();return o?++e:n.shift(),i.d=n,i.e=Mn(n,e),ue?ee(i,f.precision,f.rounding):i};I.toBinary=function(i,o){return Ys(this,2,i,o)};I.toDecimalPlaces=I.toDP=function(i,o){var e=this,t=e.constructor;return e=new t(e),i===void 0?e:(Ie(i,0,Pt),o===void 0?o=t.rounding:Ie(o,0,8),ee(e,i+e.e+1,o))};I.toExponential=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=it(t,!0):(Ie(i,0,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i+1,o),e=it(t,!0,i+1)),t.isNeg()&&!t.isZero()?"-"+e:e};I.toFixed=function(i,o){var e,t,r=this,n=r.constructor;return i===void 0?e=it(r):(Ie(i,0,Pt),o===void 0?o=n.rounding:Ie(o,0,8),t=ee(new n(r),i+r.e+1,o),e=it(t,!1,i+t.e+1)),r.isNeg()&&!r.isZero()?"-"+e:e};I.toFraction=function(i){var o,e,t,r,n,s,a,u,c,l,f,m,d=this,_=d.d,C=d.constructor;if(!_)return new C(d);if(c=e=new C(1),t=u=new C(0),o=new C(t),n=o.e=Fi(_)-d.e-1,s=n%re,o.d[0]=Se(10,s<0?re+s:s),i==null)i=n>0?o:c;else{if(a=new C(i),!a.isInt()||a.lt(c))throw Error(Dt+a);i=a.gt(o)?n>0?o:c:a}for(ue=!1,a=new C(Pe(_)),l=C.precision,C.precision=n=_.length*re*2;f=Re(a,o,0,1,1),r=e.plus(f.times(t)),r.cmp(i)!=1;)e=t,t=r,r=c,c=u.plus(f.times(r)),u=r,r=o,o=a.minus(f.times(r)),a=r;return r=Re(i.minus(e),t,0,1,1),u=u.plus(r.times(c)),e=e.plus(r.times(t)),u.s=c.s=d.s,m=Re(c,t,n,1).minus(d).abs().cmp(Re(u,e,n,1).minus(d).abs())<1?[c,t]:[u,e],C.precision=l,ue=!0,m};I.toHexadecimal=I.toHex=function(i,o){return Ys(this,16,i,o)};I.toNearest=function(i,o){var e=this,t=e.constructor;if(e=new t(e),i==null){if(!e.d)return e;i=new t(1),o=t.rounding}else{if(i=new t(i),o===void 0?o=t.rounding:Ie(o,0,8),!e.d)return i.s?e:i;if(!i.d)return i.s&&(i.s=e.s),i}return i.d[0]?(ue=!1,e=Re(e,i,0,o,1).times(i),ue=!0,ee(e)):(i.s=e.s,e=i),e};I.toNumber=function(){return+this};I.toOctal=function(i,o){return Ys(this,8,i,o)};I.toPower=I.pow=function(i){var o,e,t,r,n,s,a=this,u=a.constructor,c=+(i=new u(i));if(!a.d||!i.d||!a.d[0]||!i.d[0])return new u(Se(+a,c));if(a=new u(a),a.eq(1))return a;if(t=u.precision,n=u.rounding,i.eq(1))return ee(a,t,n);if(o=xe(i.e/re),o>=i.d.length-1&&(e=c<0?-c:c)<=tl)return r=ki(u,a,e,t),i.s<0?new u(1).div(r):ee(r,t,n);if(s=a.s,s<0){if(o<i.d.length-1)return new u(NaN);if(i.d[o]&1||(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return e=Se(+a,c),o=e==0||!isFinite(e)?xe(c*(Math.log("0."+Pe(a.d))/Math.LN10+a.e+1)):new u(e+"").e,o>u.maxE+1||o<u.minE-1?new u(o>0?s/0:0):(ue=!1,u.rounding=a.s=1,e=Math.min(12,(o+"").length),r=bs(i.times(Nt(a,t+e)),t),r.d&&(r=ee(r,t+5,1),Ar(r.d,t,n)&&(o=t+10,r=ee(bs(i.times(Nt(a,o+e)),o),o+5,1),+Pe(r.d).slice(t+1,t+15)+1==1e14&&(r=ee(r,t+1,0)))),r.s=s,ue=!0,u.rounding=n,ee(r,t,n))};I.toPrecision=function(i,o){var e,t=this,r=t.constructor;return i===void 0?e=it(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(Ie(i,1,Pt),o===void 0?o=r.rounding:Ie(o,0,8),t=ee(new r(t),i,o),e=it(t,i<=t.e||t.e<=r.toExpNeg,i)),t.isNeg()&&!t.isZero()?"-"+e:e};I.toSignificantDigits=I.toSD=function(i,o){var e=this,t=e.constructor;return i===void 0?(i=t.precision,o=t.rounding):(Ie(i,1,Pt),o===void 0?o=t.rounding:Ie(o,0,8)),ee(new t(e),i,o)};I.toString=function(){var i=this,o=i.constructor,e=it(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()&&!i.isZero()?"-"+e:e};I.truncated=I.trunc=function(){return ee(new this.constructor(this),this.e+1,1)};I.valueOf=I.toJSON=function(){var i=this,o=i.constructor,e=it(i,i.e<=o.toExpNeg||i.e>=o.toExpPos);return i.isNeg()?"-"+e:e};function Pe(i){var o,e,t,r=i.length-1,n="",s=i[0];if(r>0){for(n+=s,o=1;o<r;o++)t=i[o]+"",e=re-t.length,e&&(n+=Rt(e)),n+=t;s=i[o],t=s+"",e=re-t.length,e&&(n+=Rt(e))}else if(s===0)return"0";for(;s%10===0;)s/=10;return n+s}function Ie(i,o,e){if(i!==~~i||i<o||i>e)throw Error(Dt+i)}function Ar(i,o,e,t){var r,n,s,a;for(n=i[0];n>=10;n/=10)--o;return--o<0?(o+=re,r=0):(r=Math.ceil((o+1)/re),o%=re),n=Se(10,re-o),a=i[r]%n|0,t==null?o<3?(o==0?a=a/100|0:o==1&&(a=a/10|0),s=e<4&&a==99999||e>3&&a==49999||a==5e4||a==0):s=(e<4&&a+1==n||e>3&&a+1==n/2)&&(i[r+1]/n/100|0)==Se(10,o-2)-1||(a==n/2||a==0)&&(i[r+1]/n/100|0)==0:o<4?(o==0?a=a/1e3|0:o==1?a=a/100|0:o==2&&(a=a/10|0),s=(t||e<4)&&a==9999||!t&&e>3&&a==4999):s=((t||e<4)&&a+1==n||!t&&e>3&&a+1==n/2)&&(i[r+1]/n/1e3|0)==Se(10,o-3)-1,s}function Yr(i,o,e){for(var t,r=[0],n,s=0,a=i.length;s<a;){for(n=r.length;n--;)r[n]*=o;for(r[0]+=_s.indexOf(i.charAt(s++)),t=0;t<r.length;t++)r[t]>e-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/e|0,r[t]%=e)}return r.reverse()}function nl(i,o){var e,t,r;if(o.isZero())return o;t=o.d.length,t<32?(e=Math.ceil(t/3),r=(1/Sn(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),i.precision+=e,o=sr(i,1,o.times(r),new i(1));for(var n=e;n--;){var s=o.times(o);o=s.times(s).minus(s).times(8).plus(1)}return i.precision-=e,o}var Re=function(){function i(t,r,n){var s,a=0,u=t.length;for(t=t.slice();u--;)s=t[u]*r+a,t[u]=s%n|0,a=s/n|0;return a&&t.unshift(a),t}function o(t,r,n,s){var a,u;if(n!=s)u=n>s?1:-1;else for(a=u=0;a<n;a++)if(t[a]!=r[a]){u=t[a]>r[a]?1:-1;break}return u}function e(t,r,n,s){for(var a=0;n--;)t[n]-=a,a=t[n]<r[n]?1:0,t[n]=a*s+t[n]-r[n];for(;!t[0]&&t.length>1;)t.shift()}return function(t,r,n,s,a,u){var c,l,f,m,d,_,C,E,b,R,p,V,M,D,w,P,L,B,j,k,Q=t.constructor,te=t.s==r.s?1:-1,z=t.d,W=r.d;if(!z||!z[0]||!W||!W[0])return new Q(!t.s||!r.s||(z?W&&z[0]==W[0]:!W)?NaN:z&&z[0]==0||!W?te*0:te/0);for(u?(d=1,l=t.e-r.e):(u=tt,d=re,l=xe(t.e/d)-xe(r.e/d)),j=W.length,L=z.length,b=new Q(te),R=b.d=[],f=0;W[f]==(z[f]||0);f++);if(W[f]>(z[f]||0)&&l--,n==null?(D=n=Q.precision,s=Q.rounding):a?D=n+(t.e-r.e)+1:D=n,D<0)R.push(1),_=!0;else{if(D=D/d+2|0,f=0,j==1){for(m=0,W=W[0],D++;(f<L||m)&&D--;f++)w=m*u+(z[f]||0),R[f]=w/W|0,m=w%W|0;_=m||f<L}else{for(m=u/(W[0]+1)|0,m>1&&(W=i(W,m,u),z=i(z,m,u),j=W.length,L=z.length),P=j,p=z.slice(0,j),V=p.length;V<j;)p[V++]=0;k=W.slice(),k.unshift(0),B=W[0],W[1]>=u/2&&++B;do m=0,c=o(W,p,j,V),c<0?(M=p[0],j!=V&&(M=M*u+(p[1]||0)),m=M/B|0,m>1?(m>=u&&(m=u-1),C=i(W,m,u),E=C.length,V=p.length,c=o(C,p,E,V),c==1&&(m--,e(C,j<E?k:W,E,u))):(m==0&&(c=m=1),C=W.slice()),E=C.length,E<V&&C.unshift(0),e(p,C,V,u),c==-1&&(V=p.length,c=o(W,p,j,V),c<1&&(m++,e(p,j<V?k:W,V,u))),V=p.length):c===0&&(m++,p=[0]),R[f++]=m,c&&p[0]?p[V++]=z[P]||0:(p=[z[P]],V=1);while((P++<L||p[0]!==void 0)&&D--);_=p[0]!==void 0}R[0]||R.shift()}if(d==1)b.e=l,Ui=_;else{for(f=1,m=R[0];m>=10;m/=10)f++;b.e=f+l*d-1,ee(b,a?n+b.e+1:n,s,_)}return b}}();function ee(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor;e:if(o!=null){if(f=i.d,!f)return i;for(r=1,a=f[0];a>=10;a/=10)r++;if(n=o-r,n<0)n+=re,s=o,l=f[m=0],u=l/Se(10,r-s-1)%10|0;else if(m=Math.ceil((n+1)/re),a=f.length,m>=a)if(t){for(;a++<=m;)f.push(0);l=u=0,r=1,n%=re,s=n-re+1}else break e;else{for(l=a=f[m],r=1;a>=10;a/=10)r++;n%=re,s=n-re+r,u=s<0?0:l/Se(10,r-s-1)%10|0}if(t=t||o<0||f[m+1]!==void 0||(s<0?l:l%Se(10,r-s-1)),c=e<4?(u||t)&&(e==0||e==(i.s<0?3:2)):u>5||u==5&&(e==4||t||e==6&&(n>0?s>0?l/Se(10,r-s):0:f[m-1])%10&1||e==(i.s<0?8:7)),o<1||!f[0])return f.length=0,c?(o-=i.e+1,f[0]=Se(10,(re-o%re)%re),i.e=-o||0):f[0]=i.e=0,i;if(n==0?(f.length=m,a=1,m--):(f.length=m+1,a=Se(10,re-n),f[m]=s>0?(l/Se(10,r-s)%Se(10,s)|0)*a:0),c)for(;;)if(m==0){for(n=1,s=f[0];s>=10;s/=10)n++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;n!=a&&(i.e++,f[0]==tt&&(f[0]=1));break}else{if(f[m]+=a,f[m]!=tt)break;f[m--]=0,a=1}for(n=f.length;f[--n]===0;)f.pop()}return ue&&(i.e>d.maxE?(i.d=null,i.e=NaN):i.e<d.minE&&(i.e=0,i.d=[0])),i}function it(i,o,e){if(!i.isFinite())return Yi(i);var t,r=i.e,n=Pe(i.d),s=n.length;return o?(e&&(t=e-s)>0?n=n.charAt(0)+"."+n.slice(1)+Rt(t):s>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(i.e<0?"e":"e+")+i.e):r<0?(n="0."+Rt(-r-1)+n,e&&(t=e-s)>0&&(n+=Rt(t))):r>=s?(n+=Rt(r+1-s),e&&(t=e-r-1)>0&&(n=n+"."+Rt(t))):((t=r+1)<s&&(n=n.slice(0,t)+"."+n.slice(t)),e&&(t=e-s)>0&&(r+1===s&&(n+="."),n+=Rt(t))),n}function Mn(i,o){var e=i[0];for(o*=re;e>=10;e/=10)o++;return o}function rn(i,o,e){if(o>rl)throw ue=!0,e&&(i.precision=e),Error(Ti);return ee(new i(en),o,1,!0)}function et(i,o,e){if(o>Es)throw Error(Ti);return ee(new i(tn),o,e,!0)}function Fi(i){var o=i.length-1,e=o*re+1;if(o=i[o],o){for(;o%10==0;o/=10)e--;for(o=i[0];o>=10;o/=10)e++}return e}function Rt(i){for(var o="";i--;)o+="0";return o}function ki(i,o,e,t){var r,n=new i(1),s=Math.ceil(t/re+4);for(ue=!1;;){if(e%2&&(n=n.times(o),ka(n.d,s)&&(r=!0)),e=xe(e/2),e===0){e=n.d.length-1,r&&n.d[e]===0&&++n.d[e];break}o=o.times(o),ka(o.d,s)}return ue=!0,n}function Fa(i){return i.d[i.d.length-1]&1}function $i(i,o,e){for(var t,r=new i(o[0]),n=0;++n<o.length;)if(t=new i(o[n]),t.s)r[e](t)&&(r=t);else{r=t;break}return r}function bs(i,o){var e,t,r,n,s,a,u,c=0,l=0,f=0,m=i.constructor,d=m.rounding,_=m.precision;if(!i.d||!i.d[0]||i.e>17)return new m(i.d?i.d[0]?i.s<0?0:1/0:1:i.s?i.s<0?0:i:NaN);for(o==null?(ue=!1,u=_):u=o,a=new m(.03125);i.e>-2;)i=i.times(a),f+=5;for(t=Math.log(Se(2,f))/Math.LN10*2+5|0,u+=t,e=n=s=new m(1),m.precision=u;;){if(n=ee(n.times(i),u,1),e=e.times(++l),a=s.plus(Re(n,e,u,1)),Pe(a.d).slice(0,u)===Pe(s.d).slice(0,u)){for(r=f;r--;)s=ee(s.times(s),u,1);if(o==null)if(c<3&&Ar(s.d,u-t,d,c))m.precision=u+=10,e=n=a=new m(1),l=0,c++;else return ee(s,m.precision=_,d,ue=!0);else return m.precision=_,s}s=a}}function Nt(i,o){var e,t,r,n,s,a,u,c,l,f,m,d=1,_=10,C=i,E=C.d,b=C.constructor,R=b.rounding,p=b.precision;if(C.s<0||!E||!E[0]||!C.e&&E[0]==1&&E.length==1)return new b(E&&!E[0]?-1/0:C.s!=1?NaN:E?0:C);if(o==null?(ue=!1,l=p):l=o,b.precision=l+=_,e=Pe(E),t=e.charAt(0),Math.abs(n=C.e)<15e14){for(;t<7&&t!=1||t==1&&e.charAt(1)>3;)C=C.times(i),e=Pe(C.d),t=e.charAt(0),d++;n=C.e,t>1?(C=new b("0."+e),n++):C=new b(t+"."+e.slice(1))}else return c=rn(b,l+2,p).times(n+""),C=Nt(new b(t+"."+e.slice(1)),l-_).plus(c),b.precision=p,o==null?ee(C,p,R,ue=!0):C;for(f=C,u=s=C=Re(C.minus(1),C.plus(1),l,1),m=ee(C.times(C),l,1),r=3;;){if(s=ee(s.times(m),l,1),c=u.plus(Re(s,new b(r),l,1)),Pe(c.d).slice(0,l)===Pe(u.d).slice(0,l))if(u=u.times(2),n!==0&&(u=u.plus(rn(b,l+2,p).times(n+""))),u=Re(u,new b(d),l,1),o==null)if(Ar(u.d,l-_,R,a))b.precision=l+=_,c=s=C=Re(f.minus(1),f.plus(1),l,1),m=ee(C.times(C),l,1),r=a=1;else return ee(u,b.precision=p,R,ue=!0);else return b.precision=p,u;u=c,r+=2}}function Yi(i){return String(i.s*i.s/0)}function ys(i,o){var e,t,r;for((e=o.indexOf("."))>-1&&(o=o.replace(".","")),(t=o.search(/e/i))>0?(e<0&&(e=t),e+=+o.slice(t+1),o=o.substring(0,t)):e<0&&(e=o.length),t=0;o.charCodeAt(t)===48;t++);for(r=o.length;o.charCodeAt(r-1)===48;--r);if(o=o.slice(t,r),o){if(r-=t,i.e=e=e-t-1,i.d=[],t=(e+1)%re,e<0&&(t+=re),t<r){for(t&&i.d.push(+o.slice(0,t)),r-=re;t<r;)i.d.push(+o.slice(t,t+=re));o=o.slice(t),t=re-o.length}else t-=r;for(;t--;)o+="0";i.d.push(+o),ue&&(i.e>i.constructor.maxE?(i.d=null,i.e=NaN):i.e<i.constructor.minE&&(i.e=0,i.d=[0]))}else i.e=0,i.d=[0];return i}function sl(i,o){var e,t,r,n,s,a,u,c,l;if(o.indexOf("_")>-1){if(o=o.replace(/(\d)_(?=\d)/g,"$1"),Ii.test(o))return ys(i,o)}else if(o==="Infinity"||o==="NaN")return+o||(i.s=NaN),i.e=NaN,i.d=null,i;if(Jc.test(o))e=16,o=o.toLowerCase();else if(zc.test(o))e=2;else if(el.test(o))e=8;else throw Error(Dt+o);for(n=o.search(/p/i),n>0?(u=+o.slice(n+1),o=o.substring(2,n)):o=o.slice(2),n=o.indexOf("."),s=n>=0,t=i.constructor,s&&(o=o.replace(".",""),a=o.length,n=a-n,r=ki(t,new t(e),n,n*2)),c=Yr(o,e,tt),l=c.length-1,n=l;c[n]===0;--n)c.pop();return n<0?new t(i.s*0):(i.e=Mn(c,l),i.d=c,ue=!1,s&&(i=Re(i,r,a*4)),u&&(i=i.times(Math.abs(u)<54?Se(2,u):x.pow(2,u))),ue=!0,i)}function al(i,o){var e,t=o.d.length;if(t<3)return o.isZero()?o:sr(i,2,o,o);e=1.4*Math.sqrt(t),e=e>16?16:e|0,o=o.times(1/Sn(5,e)),o=sr(i,2,o,o);for(var r,n=new i(5),s=new i(16),a=new i(20);e--;)r=o.times(o),o=o.times(n.plus(r.times(s.times(r).minus(a))));return o}function sr(i,o,e,t,r){var n,s,a,u,c=i.precision,l=Math.ceil(c/re);for(ue=!1,u=e.times(e),a=new i(t);;){if(s=Re(a.times(u),new i(o++*o++),c,1),a=r?t.plus(s):t.minus(s),t=Re(s.times(u),new i(o++*o++),c,1),s=a.plus(t),s.d[l]!==void 0){for(n=l;s.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=t,t=s,s=n}return ue=!0,s.d.length=l+1,s}function Sn(i,o){for(var e=i;--o;)e*=i;return e}function Hi(i,o){var e,t=o.s<0,r=et(i,i.precision,1),n=r.times(.5);if(o=o.abs(),o.lte(n))return mt=t?4:1,o;if(e=o.divToInt(r),e.isZero())mt=t?3:2;else{if(o=o.minus(e.times(r)),o.lte(n))return mt=Fa(e)?t?2:3:t?4:1,o;mt=Fa(e)?t?1:4:t?3:2}return o.minus(r).abs()}function Ys(i,o,e,t){var r,n,s,a,u,c,l,f,m,d=i.constructor,_=e!==void 0;if(_?(Ie(e,1,Pt),t===void 0?t=d.rounding:Ie(t,0,8)):(e=d.precision,t=d.rounding),!i.isFinite())l=Yi(i);else{for(l=it(i),s=l.indexOf("."),_?(r=2,o==16?e=e*4-3:o==8&&(e=e*3-2)):r=o,s>=0&&(l=l.replace(".",""),m=new d(1),m.e=l.length-s,m.d=Yr(it(m),10,r),m.e=m.d.length),f=Yr(l,10,r),n=u=f.length;f[--u]==0;)f.pop();if(!f[0])l=_?"0p+0":"0";else{if(s<0?n--:(i=new d(i),i.d=f,i.e=n,i=Re(i,m,e,t,0,r),f=i.d,n=i.e,c=Ui),s=f[e],a=r/2,c=c||f[e+1]!==void 0,c=t<4?(s!==void 0||c)&&(t===0||t===(i.s<0?3:2)):s>a||s===a&&(t===4||c||t===6&&f[e-1]&1||t===(i.s<0?8:7)),f.length=e,c)for(;++f[--e]>r-1;)f[e]=0,e||(++n,f.unshift(1));for(u=f.length;!f[u-1];--u);for(s=0,l="";s<u;s++)l+=_s.charAt(f[s]);if(_){if(u>1)if(o==16||o==8){for(s=o==16?4:3,--u;u%s;u++)l+="0";for(f=Yr(l,r,o),u=f.length;!f[u-1];--u);for(s=1,l="1.";s<u;s++)l+=_s.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)l="0"+l;l="0."+l}else if(++n>u)for(n-=u;n--;)l+="0";else n<u&&(l=l.slice(0,n)+"."+l.slice(n))}l=(o==16?"0x":o==2?"0b":o==8?"0o":"")+l}return i.s<0?"-"+l:l}function ka(i,o){if(i.length>o)return i.length=o,!0}function il(i){return new this(i).abs()}function ol(i){return new this(i).acos()}function ul(i){return new this(i).acosh()}function cl(i,o){return new this(i).plus(o)}function ll(i){return new this(i).asin()}function fl(i){return new this(i).asinh()}function ml(i){return new this(i).atan()}function hl(i){return new this(i).atanh()}function gl(i,o){i=new this(i),o=new this(o);var e,t=this.precision,r=this.rounding,n=t+4;return!i.s||!o.s?e=new this(NaN):!i.d&&!o.d?(e=et(this,n,1).times(o.s>0?.25:.75),e.s=i.s):!o.d||i.isZero()?(e=o.s<0?et(this,t,r):new this(0),e.s=i.s):!i.d||o.isZero()?(e=et(this,n,1).times(.5),e.s=i.s):o.s<0?(this.precision=n,this.rounding=1,e=this.atan(Re(i,o,n,1)),o=et(this,n,1),this.precision=t,this.rounding=r,e=i.s<0?e.minus(o):e.plus(o)):e=this.atan(Re(i,o,n,1)),e}function dl(i){return new this(i).cbrt()}function Cl(i){return ee(i=new this(i),i.e+1,2)}function _l(i,o,e){return new this(i).clamp(o,e)}function Al(i){if(!i||typeof i!="object")throw Error(On+"Object expected");var o,e,t,r=i.defaults===!0,n=["precision",1,Pt,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,Cs,"maxE",0,Cs,"minE",-9e15,0,"modulo",0,9];for(o=0;o<n.length;o+=3)if(e=n[o],r&&(this[e]=As[e]),(t=i[e])!==void 0)if(xe(t)===t&&t>=n[o+1]&&t<=n[o+2])this[e]=t;else throw Error(Dt+e+": "+t);if(e="crypto",r&&(this[e]=As[e]),(t=i[e])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(vi);else this[e]=!1;else throw Error(Dt+e+": "+t);return this}function El(i){return new this(i).cos()}function bl(i){return new this(i).cosh()}function Gi(i){var o,e,t;function r(n){var s,a,u,c=this;if(!(c instanceof r))return new r(n);if(c.constructor=r,$a(n)){c.s=n.s,ue?!n.d||n.e>r.maxE?(c.e=NaN,c.d=null):n.e<r.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(u=typeof n,u==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(s=0,a=n;a>=10;a/=10)s++;ue?s>r.maxE?(c.e=NaN,c.d=null):s<r.minE?(c.e=0,c.d=[0]):(c.e=s,c.d=[n]):(c.e=s,c.d=[n]);return}else if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return ys(c,n.toString())}else if(u!=="string")throw Error(Dt+n);return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),Ii.test(n)?ys(c,n):sl(c,n)}if(r.prototype=I,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Al,r.clone=Gi,r.isDecimal=$a,r.abs=il,r.acos=ol,r.acosh=ul,r.add=cl,r.asin=ll,r.asinh=fl,r.atan=ml,r.atanh=hl,r.atan2=gl,r.cbrt=dl,r.ceil=Cl,r.clamp=_l,r.cos=El,r.cosh=bl,r.div=yl,r.exp=Rl,r.floor=pl,r.hypot=Nl,r.ln=Vl,r.log=Ol,r.log10=Sl,r.log2=Ml,r.max=Dl,r.min=wl,r.mod=Pl,r.mul=Ll,r.pow=xl,r.random=jl,r.round=Ul,r.sign=Tl,r.sin=vl,r.sinh=Bl,r.sqrt=Il,r.sub=Fl,r.sum=kl,r.tan=$l,r.tanh=Yl,r.trunc=Hl,i===void 0&&(i={}),i&&i.defaults!==!0)for(t=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],o=0;o<t.length;)i.hasOwnProperty(e=t[o++])||(i[e]=this[e]);return r.config(i),r}function yl(i,o){return new this(i).div(o)}function Rl(i){return new this(i).exp()}function pl(i){return ee(i=new this(i),i.e+1,3)}function Nl(){var i,o,e=new this(0);for(ue=!1,i=0;i<arguments.length;)if(o=new this(arguments[i++]),o.d)e.d&&(e=e.plus(o.times(o)));else{if(o.s)return ue=!0,new this(1/0);e=o}return ue=!0,e.sqrt()}function $a(i){return i instanceof x||i&&i.toStringTag===Bi||!1}function Vl(i){return new this(i).ln()}function Ol(i,o){return new this(i).log(o)}function Ml(i){return new this(i).log(2)}function Sl(i){return new this(i).log(10)}function Dl(){return $i(this,arguments,"lt")}function wl(){return $i(this,arguments,"gt")}function Pl(i,o){return new this(i).mod(o)}function Ll(i,o){return new this(i).mul(o)}function xl(i,o){return new this(i).pow(o)}function jl(i){var o,e,t,r,n=0,s=new this(1),a=[];if(i===void 0?i=this.precision:Ie(i,1,Pt),t=Math.ceil(i/re),this.crypto)if(crypto.getRandomValues)for(o=crypto.getRandomValues(new Uint32Array(t));n<t;)r=o[n],r>=429e7?o[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=r%1e7;else if(crypto.randomBytes){for(o=crypto.randomBytes(t*=4);n<t;)r=o[n]+(o[n+1]<<8)+(o[n+2]<<16)+((o[n+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(o,n):(a.push(r%1e7),n+=4);n=t/4}else throw Error(vi);else for(;n<t;)a[n++]=Math.random()*1e7|0;for(t=a[--n],i%=re,t&&i&&(r=Se(10,re-i),a[n]=(t/r|0)*r);a[n]===0;n--)a.pop();if(n<0)e=0,a=[0];else{for(e=-1;a[0]===0;e-=re)a.shift();for(t=1,r=a[0];r>=10;r/=10)t++;t<re&&(e-=re-t)}return s.e=e,s.d=a,s}function Ul(i){return ee(i=new this(i),i.e+1,this.rounding)}function Tl(i){return i=new this(i),i.d?i.d[0]?i.s:0*i.s:i.s||NaN}function vl(i){return new this(i).sin()}function Bl(i){return new this(i).sinh()}function Il(i){return new this(i).sqrt()}function Fl(i,o){return new this(i).sub(o)}function kl(){var i=0,o=arguments,e=new this(o[i]);for(ue=!1;e.s&&++i<o.length;)e=e.plus(o[i]);return ue=!0,ee(e,this.precision,this.rounding)}function $l(i){return new this(i).tan()}function Yl(i){return new this(i).tanh()}function Hl(i){return ee(i=new this(i),i.e+1,1)}I[Symbol.for("nodejs.util.inspect.custom")]=I.toString;I[Symbol.toStringTag]="Decimal";var x=I.constructor=Gi(As);en=new x(en);tn=new x(tn);function Gl(i,o){const e=i+o;return Number.isSafeInteger(e)?e:new x(i).add(o).toNumber()}function Wl(i,o){const e=i-o;return Number.isSafeInteger(e)?e:new x(i).sub(o).toNumber()}function lr(i,o){const e=i*o;return Number.isSafeInteger(e)?e:new x(i).mul(o).toNumber()}function Ql(i,o){const e=i/o;return Number.isSafeInteger(e)?e:new x(i).div(o).toNumber()}function Ot(i,o){const e=10**Math.trunc(o),t=Dn(i,e);return Math.round(lr(i,e)+t)/e}function ke(i,o){const e=10**Math.trunc(o),t=Dn(i,e);return Math.floor(lr(i,e)+t)/e}function Be(i,o){const e=10**Math.trunc(o),t=Dn(i,e);return Math.ceil(lr(i,e)-t)/e}function Dn(i,o){return Number.EPSILON*Math.max(1,Math.abs(lr(i,o)))}function Ya(i,o){return i-o*Math.floor(i/o)}function ql(i,o){return i**o}function Kl(i){return Math.sqrt(i)}function Ha(i,o){return i===o}function Xl(i,o){return i>o}function Zl(i,o){return i>=o}function zl(i,o){return i<o}function Jl(i,o){return i<=o}function Rs(i,o=15){return Number.parseFloat(i.toPrecision(o))}function ef(i,o,e=Number.EPSILON){return Math.abs(i-o)<e}function Wi(i,o=12,e=1e-10){const t=Rs(i,o);return ef(i,t,e)?t:Rs(i)}function tf(i){return i-Math.trunc(i)}const Cn=class Cn extends dt{static create(){return this._instance=this._instance||new Cn(0),this._instance}isNull(){return!0}plus(o){return y.create(0).plus(o)}minus(o){return y.create(0).minus(o)}multiply(o){return y.create(0).multiply(o)}divided(o){return y.create(0).divided(o)}mod(o){return y.create(0).mod(o)}compare(o,e){return o.isString()?U.create("").compare(o,e):o.isBoolean()?v.create(!1).compare(o,e):y.create(0).compare(o,e)}concatenateFront(o){return o.isArray()?o.concatenateBack(U.create("")):U.create(this.concatenate(o.getValue(),Je.FRONT))}concatenateBack(o){return o.isArray()?o.concatenateFront(U.create("")):U.create(this.concatenate(o.getValue(),Je.BACK))}plusBy(o){return y.create(0).plusBy(o)}minusBy(o){return y.create(0).minusBy(o)}multiplyBy(o){return y.create(0).multiplyBy(o)}dividedBy(o){return y.create(0).dividedBy(o)}compareBy(o,e){return typeof o=="string"?U.create("").compareBy(o,e):typeof o=="boolean"?v.create(!1).compareBy(o,e):y.create(0).compareBy(o,e)}pow(o){return y.create(0).pow(o)}sqrt(){return y.create(0).sqrt()}cbrt(){return y.create(0).cbrt()}cos(){return y.create(0).cos()}cosh(){return y.create(0).cosh()}acos(){return y.create(0).acos()}acosh(){return y.create(0).acosh()}sin(){return y.create(0).sin()}sinh(){return y.create(0).sinh()}asin(){return y.create(0).asin()}asinh(){return y.create(0).asinh()}tan(){return y.create(0).tan()}tanh(){return y.create(0).tanh()}atan(){return y.create(0).atan()}atan2(o){return y.create(0).atan2(o)}atanh(){return y.create(0).atanh()}log(){return g.create(h.NUM)}log10(){return g.create(h.NUM)}exp(){return y.create(0).exp()}abs(){return y.create(0).abs()}round(o){return y.create(0).round(o)}floor(o){return y.create(0).floor(o)}ceil(o){return y.create(0).ceil(o)}convertToNumberObjectValue(){return y.create(0)}convertToBooleanObjectValue(){return v.create(!1)}};A(Cn,"_instance");let ie=Cn;const vt=class vt extends dt{constructor(e){super(e);A(this,"_value",!1);this._value=e}static create(e){return e?(this._instanceTrue=this._instanceTrue||new vt(!0),this._instanceTrue):(this._instanceFalse=this._instanceFalse||new vt(!1),this._instanceFalse)}getValue(){return this._value}isBoolean(){return!0}getNegative(){const e=this.getValue();let t=0;return e&&(t=1),y.create(-t)}getReciprocal(){return this.getValue()?y.create(1):g.create(h.DIV_BY_ZERO)}plus(e){return this._convertToNumber().plus(e)}minus(e){return this._convertToNumber().minus(e)}multiply(e){return this._convertToNumber().multiply(e)}divided(e){return this._convertToNumber().divided(e)}mod(e){return this._convertToNumber().mod(e)}compare(e,t){return e.isArray()?e.compare(this,$s(t)):e.isNull()?this._convertToNumber().compare(e,t):this.compareBy(e.getValue(),t)}compareBy(e,t){let r=!1;if(typeof e=="string"||typeof e=="number")r=this._compareString(t);else if(typeof e=="boolean"){const n=y.create(e?1:0);return this._convertToNumber().compare(n,t)}return vt.create(r)}_compareString(e){switch(e){case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:return!0;case Y.EQUALS:case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:case Y.NOT_EQUAL:return!1}}concatenateFront(e){return this._convertToNumber().concatenateFront(e)}concatenateBack(e){return this._convertToNumber().concatenateBack(e)}_convertToNumber(){const e=this.getValue();let t=0;return e&&(t=1),y.create(t)}pow(e){return this._convertToNumber().pow(e)}sqrt(){return this._convertToNumber().sqrt()}cbrt(){return this._convertToNumber().cbrt()}cos(){return this._convertToNumber().cos()}cosh(){return this._convertToNumber().cosh()}acos(){return this._convertToNumber().acos()}acosh(){return this._convertToNumber().acosh()}sin(){return this._convertToNumber().sin()}sinh(){return this._convertToNumber().sinh()}asin(){return this._convertToNumber().asin()}asinh(){return this._convertToNumber().asinh()}tan(){return this._convertToNumber().tan()}tanh(){return this._convertToNumber().tanh()}atan(){return this._convertToNumber().atan()}atan2(e){return this._convertToNumber().atan2(e)}atanh(){return this._convertToNumber().atanh()}log(){return this._convertToNumber().log()}log10(){return this._convertToNumber().log10()}exp(){return this._convertToNumber().exp()}abs(){return this._convertToNumber().abs()}round(e){return this._convertToNumber().round(e)}floor(e){return this._convertToNumber().floor(e)}ceil(e){return this._convertToNumber().ceil(e)}convertToNumberObjectValue(){return Pn(this.getValue())}convertToBooleanObjectValue(){return this}};A(vt,"_instanceTrue"),A(vt,"_instanceFalse");let v=vt;class y extends dt{constructor(e){super(e);A(this,"_value",0);this._value=Number(e)}static create(e,t=""){const r=new y(e);return t&&r.setPattern(t),r}getValue(){return this._value}setValue(e){this._value=e}isNumber(){return!0}getNegative(){return y.create(0).minus(this)}getReciprocal(){return y.create(1).divided(this)}plus(e){if(e.isArray())return e.plus(this);let t=this.plusBy(e.getValue());if(t.isError())return t;const r=jr(this.getPattern(),e.getPattern(),X.PLUS);return t=y.create(Number(t.getValue()),r),t}equalZero(){return this._value===0}minus(e){if(e.isArray()){const n=e.getNegative();return n.isError()?n:n.plus(this)}let t=this.minusBy(e.getValue());if(t.isError())return t;const r=jr(this.getPattern(),e.getPattern(),X.MINUS);return t=y.create(Number(t.getValue()),r),t}multiply(e){if(e.isArray())return e.multiply(this);let t=this.multiplyBy(e.getValue());if(t.isError())return t;const r=jr(this.getPattern(),e.getPattern(),X.MULTIPLY);return t=y.create(Number(t.getValue()),r),t}divided(e){if(e.isArray()){const n=e.getReciprocal();return n.isError()?n:n.multiply(this)}let t=this.dividedBy(e.getValue());if(t.isError())return t;const r=jr(this.getPattern(),e.getPattern(),X.DIVIDED);return t=y.create(Number(t.getValue()),r),t}mod(e){if(e.isArray())return e.modInverse(this);const t=this.getValue(),r=e.getValue();if(e.isNull())return g.create(h.DIV_BY_ZERO);if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(r===0)return g.create(h.DIV_BY_ZERO);if(!Number.isFinite(t)||!Number.isFinite(r)||Math.abs(r)*11259e8<=Math.abs(t))return g.create(h.NUM);const n=Ya(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}if(typeof r=="boolean"){const n=r?1:0;return n===0?g.create(h.DIV_BY_ZERO):y.create(Ya(t,n))}return this}concatenateFront(e){return e.isArray()?e.concatenateBack(this):U.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):U.create(this.concatenate(e.getValue(),Je.BACK))}compare(e,t){return e.isArray()?e.compare(this,$s(t)):this.compareBy(e.getValue(),t)}plusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=Gl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}minusBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=Wl(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}multiplyBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=lr(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}dividedBy(e){const t=+this.getValue(),r=+e;if(Number.isNaN(t)||Number.isNaN(r))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(r===0)return g.create(h.DIV_BY_ZERO);const n=Ql(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}compareBy(e,t){const r=this.getValue();let n=!1;return typeof e=="string"?n=this._compareString(t):typeof e=="number"?n=this._compareNumber(r,e,t):typeof e=="boolean"&&(n=this._compareBoolean(t)),v.create(n)}_compareString(e){switch(e){case Y.EQUALS:case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:return!1;case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:case Y.NOT_EQUAL:return!0}}_compareNumber(e,t,r){return!Number.isFinite(e)||!Number.isFinite(t)?this._compareInfinity(e,t,r):this._compareFiniteNumber(e,t,r)}_compareFiniteNumber(e,t,r){switch(r){case Y.EQUALS:return Ha(e,t);case Y.GREATER_THAN:return Xl(e,t);case Y.GREATER_THAN_OR_EQUAL:return Zl(e,t);case Y.LESS_THAN:return zl(e,t);case Y.LESS_THAN_OR_EQUAL:return Jl(e,t);case Y.NOT_EQUAL:return!Ha(e,t)}}_compareBoolean(e){switch(e){case Y.EQUALS:case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:return!1;case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:case Y.NOT_EQUAL:return!0}}pow(e){if(e.isArray())return e.powInverse(this);if(this.isError())return this;const t=this.getValue();let r=e;if(e.isString()&&(r=e.convertToNumberObjectValue()),r.isError())return r;const n=+r.getValue();if(Number.isNaN(n))return g.create(h.VALUE);if(!Number.isFinite(t)||!Number.isFinite(n))return g.create(h.NUM);if(t===0)return n<0?g.create(h.DIV_BY_ZERO):n===0?g.create(h.NUM):y.create(0);const s=ql(t,n);return Number.isFinite(s)?y.create(s):g.create(h.NUM)}sqrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Kl(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cbrt(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cbrt(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cos(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}cosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.cosh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}acos(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acos(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}acosh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.acosh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}sin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sin(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}sinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.sinh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}asin(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asin(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}asinh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.asinh(e);return Number.isNaN(t)?g.create(h.NUM):y.create(t)}tan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}tanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.tanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atan(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}atan2(e){if(e.isArray())return e.atan2Inverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);if(t===0&&r===0)return g.create(h.DIV_BY_ZERO);const n=Math.atan2(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Math.atan2(t,r?1:0)):this}atanh(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.atanh(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}log10(){const e=this.getValue();if(typeof e=="number"&&e<=0||!Number.isFinite(e))return g.create(h.NUM);const t=Math.log10(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}exp(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.exp(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}abs(){const e=this.getValue();if(!Number.isFinite(e))return g.create(h.NUM);const t=Math.abs(e);return Number.isFinite(t)?y.create(t):g.create(h.NUM)}round(e){if(e.isArray())return e.roundInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Ot(Math.abs(t),r):Ot(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Ot(t,r?1:0)):this}floor(e){if(e.isArray())return e.floorInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-ke(Math.abs(t),r):ke(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(ke(t,r?1:0)):this}ceil(e){if(e.isArray())return e.ceilInverse(this);const t=this.getValue(),r=e.getValue();if(typeof r=="string")return g.create(h.VALUE);if(typeof r=="number"){if(!Number.isFinite(t)||!Number.isFinite(r))return g.create(h.NUM);const n=t<0?-Be(Math.abs(t),r):Be(t,r);return Number.isFinite(n)?y.create(n):g.create(h.NUM)}return typeof r=="boolean"?y.create(Be(t,r?1:0)):this}convertToNumberObjectValue(){return this}convertToBooleanObjectValue(){return wn(!0)}_compareInfinity(e,t,r){let n=!1;switch(r){case Y.EQUALS:n=e===t;break;case Y.GREATER_THAN:n=e>t;break;case Y.GREATER_THAN_OR_EQUAL:n=e>=t;break;case Y.LESS_THAN:n=e<t;break;case Y.LESS_THAN_OR_EQUAL:n=e<=t;break;case Y.NOT_EQUAL:n=e!==t;break}return n}}const rf=1e5,Ga=new ht(rf);class U extends dt{constructor(e){super(e);A(this,"_value");this._value=e}static create(e){const t=Ga.get(e);if(t)return t;const r=new U(e);return Ga.set(e,r),r}getValue(){return this._value}isString(){return!0}concatenateFront(e){return e.isArray()?e.concatenateBack(this):U.create(this.concatenate(e.getValue(),Je.FRONT))}concatenateBack(e){return e.isArray()?e.concatenateFront(this):U.create(this.concatenate(e.getValue(),Je.BACK))}plus(e){return this.convertToNumberObjectValue().plus(e)}minus(e){return this.convertToNumberObjectValue().minus(e)}multiply(e){return this.convertToNumberObjectValue().multiply(e)}divided(e){return this.convertToNumberObjectValue().divided(e)}compare(e,t,r){return e.isArray()?e.compare(this,$s(t),r):this.compareBy(e.getValue(),t,r)}compareBy(e,t,r=!1){let n=this.getValue(),s=!1;if(typeof e=="string"){let a=e;if(r||(n=n.toLocaleLowerCase(),a=a.toLocaleLowerCase()),Kc(a))return this._checkWildcard(a,t);s=this._compareString(n,a,t)}else typeof e=="number"?s=this._compareNumber(t):typeof e=="boolean"&&(s=this._compareBoolean(t));return v.create(s)}_compareString(e,t,r){switch(r){case Y.EQUALS:return e===t;case Y.GREATER_THAN:return e>t;case Y.GREATER_THAN_OR_EQUAL:return e>=t;case Y.LESS_THAN:return e<t;case Y.LESS_THAN_OR_EQUAL:return e<=t;case Y.NOT_EQUAL:return e!==t}}_compareNumber(e){switch(e){case Y.NOT_EQUAL:case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:return!0;case Y.EQUALS:case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:return!1}}_compareBoolean(e){switch(e){case Y.EQUALS:case Y.GREATER_THAN:case Y.GREATER_THAN_OR_EQUAL:return!1;case Y.LESS_THAN:case Y.LESS_THAN_OR_EQUAL:case Y.NOT_EQUAL:return!0}}convertToNumberObjectValue(){return Pn(this.getValue())}convertToBooleanObjectValue(){return v.create(!0)}_checkWildcard(e,t){const r=this.getValue().toLocaleLowerCase(),n=Xc(r,e,t);return v.create(n)}}function wn(i){if(typeof i=="boolean")return v.create(i);let o=!1;if(typeof i=="string"){const e=i.toLocaleUpperCase();e===Mt.TRUE?o=!0:e===Mt.FALSE&&(o=!1)}else i===1?o=!0:o=!1;return v.create(o)}function nf(i){let o=i.toString();return o.charAt(0)==='"'&&o.charAt(o.length-1)==='"'&&(o=o.slice(1,-1),o=o.replace(/""/g,'"')),U.create(o)}function Pn(i,o=""){if(typeof i=="boolean"){let e=0;return i&&(e=1),y.create(e,o)}else{if(typeof i=="number")return Number.isFinite(i)?y.create(i,o):g.create(h.NUM);if(S.isRealNum(i))return y.create(Number(i),o)}return g.create(h.VALUE)}function sf(i){return""}function Qi(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];o[e][r]=ot.create(n)}}return o}function af(i=[]){const o=[];for(let e=0;e<i.length;e++){const t=i[e];o[e]==null&&(o[e]=[]);for(let r=0;r<t.length;r++){const n=t[r];n==null?o[e][r]=null:n.isError()?o[e][r]=n.getErrorType():o[e][r]=n.getValue()}}return o}class q extends dt{constructor(e){super(typeof e=="string"?e:sf());A(this,"_values",[]);A(this,"_rowCount",-1);A(this,"_columnCount",-1);A(this,"_unitId","");A(this,"_sheetId","");A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_sliceCache",new Map);A(this,"_flattenCache");A(this,"_defaultValue",null);A(this,"_flattenPosition");this._values=this._formatValue(e)}static create(e){return new q(e)}static createByArray(e){const r={calculateValueList:Qi(e),rowCount:e.length,columnCount:e[0].length||0,unitId:"",sheetId:"",row:-1,column:-1};return new q(r)}dispose(){this._values=[],this._defaultValue=null,this._flattenPosition=null,this._clearCache()}clone(){return this.map(e=>e)}getRowCount(){return this._rowCount}setRowCount(e){this._rowCount=e}getColumnCount(){return this._columnCount}setColumnCount(e){this._columnCount=e}setCurrent(e,t){this._currentRow=e,this._currentColumn=t}setUnitId(e){this._unitId=e}getUnitId(){return this._unitId}setSheetId(e){this._sheetId=e}getSheetId(){return this._sheetId}getCurrentRow(){return this._currentRow}getCurrentColumn(){return this._currentColumn}getArrayValue(){return this._values}setArrayValue(e){this._clearCache(),this._values=e}isArray(){return!0}setDefaultValue(e){this._defaultValue=e}get(e,t){var r;return((r=this._values[e])==null?void 0:r[t])||this._defaultValue}getRealValue(e,t){const r=this._values[e];if(r==null)return null;const n=r[t];return n==null?null:n}getValueOrDefault(e,t){return this.get(e,t)||this._defaultValue}set(e,t,r){if(e>=this._rowCount||t>=this._columnCount)throw new Error("Exceeding array bounds.");this._clearCache(),this._values[e][t]=r}getRangePosition(){const t=this.getRowCount(),r=0,n=this.getColumnCount();return{startRow:0,endRow:t-1,startColumn:r,endColumn:n-1}}iterator(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=t;c<=r;c++)for(let l=n;l<=s;l++)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}iteratorReverse(e){var u;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=this.getArrayValue();for(let c=r;c>=t;c--)for(let l=s;l>=n;l--)if(e(((u=a[c])==null?void 0:u[l])||this._defaultValue,c,l)===!1)return}getLastTruePosition(){let e;return this.iteratorReverse((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstTruePosition(){let e;return this.iterator((t,r,n)=>{if(t!=null&&t.isBoolean()&&t.getValue()===!0)return e={row:r,column:n},!1}),e}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ie.create()}getLastCell(){const{endRow:e,endColumn:t}=this.getRangePosition();return this.get(e,t)||this._defaultValue||ie.create()}pick(e){const t=this.pickRaw(e);return this._createNewArray(t,1,t[0].length)}pickRaw(e){const t=e.getRowCount(),r=e.getColumnCount();if(t!==this._rowCount||r!==this._columnCount)return[[ie.create()]];const n=[];n[0]=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.get(s,a);if(!(u==null||u.isError())&&u.getValue()===!0){const c=this.get(s,a);n[0].push(c)}}return n}flatten(){if(this._flattenCache!=null)return this._flattenCache;const e=[];e[0]=[];for(let r=0;r<this._rowCount;r++)for(let n=0;n<this._columnCount;n++){const s=this.get(r,n);e[0].push(s)}const t=this._createNewArray(e,1,e[0].length);return t.setDefaultValue(this._defaultValue),this._flattenCache=t,t}flattenPosition(){if(this._flattenPosition!=null)return this._flattenPosition;const e=[],t=[],r=[],n=[];let s=0;for(let u=0;u<this._rowCount;u++)for(let c=0;c<this._columnCount;c++){const l=this.get(u,c);if(l==null||l.isError()||l.isNull()){s++;continue}l.isString()?(e.push(l),r.push(s++)):(t.push(l),n.push(s++))}const a={stringArray:e,numberArray:t,stringPosition:r,numberPosition:n};return this._flattenPosition=a,a}slice(e,t){let r=0,n=this._rowCount,s=1,a=0,u=this._columnCount,c=1;if(e!=null&&(r=e[0]||0,n=e[1]||this._rowCount,s=e[2]||1),t!=null&&(a=t[0]||0,u=t[1]||this._columnCount,c=t[2]||1),r>=this._rowCount||a>=this._columnCount)return;const l=`${r}_${n}_${s}_${a}_${u}_${c}`,f=this._sliceCache.get(l);if(f!=null)return f;const m=[],d=this._values;let _=0,C=0;for(let p=r;p<n;p+=s){C=0,m[_]==null&&(m[_]=[]);for(let V=a;V<u;V+=c){if(!d[p])return;let M=d[p][V]||this._defaultValue;M==null&&(M=ie.create()),m[_][C]=M,C++}_++}if(m.length===0||m[0].length===0)return;const E=s>1?-1:r+this._currentRow,b=c>1?-1:a+this._currentColumn,R=this._createNewArray(m,m.length,m[0].length,E,b);return R.setDefaultValue(this._defaultValue),this._sliceCache.set(l,R),R}sortByRow(e){const t=this._transposeArray(this._values);t.sort(this._sort(e)),this._clearCache(),this._values=this._transposeArray(t)}sortByColumn(e){this._clearCache(),this._values.sort(this._sort(e))}transpose(){const e=this._transposeArray(this._values),t=this._rowCount,r=this._columnCount,n=this._createNewArray(e,r,t);return n.setDefaultValue(this._defaultValue),n}orderSearch(e,t=Me.MIN,r=!1,n=!1){let s,a,u,c;const l=(f,m,d)=>{if(f==null)return!0;let _;if(n===!0?_=f.compare(e,Y.EQUALS):_=f.isEqual(e),(_==null?void 0:_.getValue())===!0)return s=f,u={row:m,column:d},!1;t===Me.MAX?f.isGreaterThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d}):t===Me.MIN&&f.isLessThan(e).getValue()===!0&&(a==null||f.minus(e).abs().isLessThanOrEqual(a.minus(e).abs()).getValue()===!0)&&(a=f,c={row:m,column:d})};if(r?this.iteratorReverse((f,m,d)=>l(f,m,d)):this.iterator((f,m,d)=>l(f,m,d)),s!=null)return u;if(a!=null)return c}binarySearch(e,t=Ut.MIN,r=Me.MIN){if(e.isError())return;const{stringArray:n,stringPosition:s,numberArray:a,numberPosition:u}=this.flattenPosition();return e.isString()?this._binarySearch(e,n,s,t,r):this._binarySearch(e,a,u,t,r)}_binarySearch(e,t,r,n=Ut.MIN,s=Me.MIN){const a=Jr(),u=Number(e.getValue()),c=!Number.isNaN(u);let l=0,f=t.length-1,m=-1,d=-1,_=-1;for(;l<=f;){const C=Math.floor((l+f)/2),E=t[C];let b;if(E.isNull())b=n===Ut.MIN?1:-1;else{const R=E.getValue();if(c){const p=Number(R);b=Number.isNaN(p)?1:Math.sign(p-u)}else b=a(R.toString().toLocaleLowerCase(),e.getValue().toString().toLocaleLowerCase())}if(n===Ut.MAX&&(b=-b),b===0){m=C;break}b<0?(d=C,l=C+1):(_=C,f=C-1)}if(s===Me.NORMAL)return m!==-1?r[m]:void 0;if(s===Me.MIN)return m!==-1?r[m]:n===Ut.MIN?r[d]:r[_];if(s===Me.MAX)return m!==-1?r[m]:n===Ut.MIN?r[_]:r[d]}sum(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isString()||t.isBoolean()||t.isNull())return!0;if(t.isError())return e=t,!1;e=e.plus(t)}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isLessThan(t).getValue()&&(e=t)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this.iterator(t=>{if(t==null)return!0;if(t.isError())return e=t,!1;if(t.isString()||t.isNull()||t.isBoolean())return!0;e.isGreaterThan(t).getValue()&&(e=t)}),e}count(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isError()||t.isString()||t.isNull()||t.isBoolean())return!0;e=e.plusBy(1)}),e}countA(){let e=y.create(0);return this.iterator(t=>{if(t==null||t.isNull())return!0;e=e.plusBy(1)}),e}countBlank(){let e=y.create(0);return this.iterator(t=>{(t==null||t.isNull()||t.getValue()==="")&&(e=e.plusBy(1))}),e}getNegative(){return q.create("{0}").minus(this)}getReciprocal(){return q.create("{1}").divided(this)}plus(e){return this._batchOperator(e,1)}minus(e){return this._batchOperator(e,0)}multiply(e){return this._batchOperator(e,2)}divided(e){return this._batchOperator(e,3)}mod(e){return this._batchOperator(e,4)}modInverse(e){return this.map(t=>t.isError()?t:e.mod(t))}compare(e,t,r){return this._batchOperator(e,5,t,r)}concatenateFront(e){return this._batchOperator(e,6)}concatenateBack(e){return this._batchOperator(e,7)}map(e){const t=(r,n,s)=>r==null?ie.create():r.isError()?r:e(r,n,s);return this.mapValue(t)}mapValue(e){var s;const t=this._rowCount,r=this._columnCount,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){const l=(s=this._values)==null?void 0:s[a];if(l==null)u[c]=g.create(h.VALUE);else{const f=l[c]||this._defaultValue;f?u[c]=e(f,a,c):u[c]=ie.create()}}n.push(u)}return this._createNewArray(n,t,r)}pow(e){return this._batchOperator(e,8)}powInverse(e){return this.map(t=>t.isError()?t:e.pow(t))}sqrt(){return this.map(e=>e.isError()?e:e.sqrt())}cbrt(){return this.map(e=>e.isError()?e:e.cbrt())}cos(){return this.map(e=>e.isError()?e:e.cos())}cosh(){return this.map(e=>e.isError()?e:e.cosh())}acos(){return this.map(e=>e.isError()?e:e.acos())}acosh(){return this.map(e=>e.isError()?e:e.acosh())}sin(){return this.map(e=>e.isError()?e:e.sin())}sinh(){return this.map(e=>e.isError()?e:e.sinh())}asin(){return this.map(e=>e.isError()?e:e.asin())}asinh(){return this.map(e=>e.isError()?e:e.asinh())}tan(){return this.map(e=>e.isError()?e:e.tan())}tanh(){return this.map(e=>e.isError()?e:e.tanh())}atan(){return this.map(e=>e.isError()?e:e.atan())}atanh(){return this.map(e=>e.isError()?e:e.atanh())}atan2(e){return this._batchOperator(e,12)}atan2Inverse(e){return this.map(t=>t.isError()?t:e.atan2(t))}mean(e=0){const t=this.sum(),r=this.count();return t.divided(e===0?r:r.minusBy(1))}median(){const e=this.flattenPosition().numberArray,t=this._createNewArray([e],1,e.length),r=t.getColumnCount();if(r<=1)return t.get(0,0)||ie.create();if(t.sortByRow(0),r%2===0){const n=t.get(0,r/2)||ie.create(),s=t.get(0,r/2-1)||ie.create();return n.plus(s).divided(y.create(2))}return t.get(0,(r-1)/2)||ie.create()}var(e=0){const t=this.mean(),r=[[]];this.iterator(l=>{if(l==null||l.isError()||l.isString()||l.isBoolean()||l.isNull())return;const f=l.minus(t).pow(y.create(2));f.isError()||r[0].push(f)});const{_unitId:n,_sheetId:s,_currentRow:a,_currentColumn:u}=this;return q.create({calculateValueList:r,rowCount:1,columnCount:r[0].length,unitId:n,sheetId:s,row:a,column:u}).mean(e)}std(e=0){const t=this.var(e);return t.isError()?t:t.sqrt()}log(){return this.map(e=>e.isError()?e:e.log())}log10(){return this.map(e=>e.isError()?e:e.log10())}exp(){return this.map(e=>e.isError()?e:e.exp())}abs(){return this.map(e=>e.isError()?e:e.abs())}round(e){return this._batchOperator(e,9)}roundInverse(e){return this.map(t=>t.isError()?t:e.round(t))}floor(e){return this._batchOperator(e,10)}floorInverse(e){return this.map(t=>t.isError()?t:e.floor(t))}ceil(e){return this._batchOperator(e,11)}ceilInverse(e){return this.map(t=>t.isError()?t:e.ceil(t))}toValue(){return af(this._values)}_clearCache(){this._flattenCache=null,this._sliceCache.clear()}_sort(e){const t=Jr();return(r,n)=>{const s=r[e],a=n[e];return s==null?1:a==null?-1:s.isError()&&s.isError()?0:s.isError()?1:a.isError()?-1:t(s.getValue(),a.getValue())}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_batchOperator(e,t,r,n){const s=[];let a=this._rowCount,u=this._columnCount;if(e.isArray()){const f=e.getRowCount(),m=e.getColumnCount();if(a=Math.max(f,a),u=Math.max(m,u),f===1&&m===1){const d=e.getFirstCell();for(let _=0;_<u;_++)s.push(d)}else if(f===1&&this._columnCount>1){const d=e.getArrayValue();for(let _=0;_<u;_++)s.push(d[0][_])}else return this._batchOperatorArray(e,t,r,n)}else for(let f=0;f<u;f++)s.push(e);const c=[];for(let f=0;f<u;f++){const m=s[f];this._batchOperatorValue(m,f,c,t,r,n)}const l=this._createNewArray(c,a,u);return l.setDefaultValue(v.create(!1)),l}_batchOperatorValue(e,t,r,n,s,a){const u=this._rowCount,c=this.getUnitId(),l=this.getSheetId(),f=this.getCurrentRow(),m=this.getCurrentColumn();if(n===5){const{rowsInCache:d,rowsNotInCache:_}=yt.canUseCache(c,l,t+m,f,f+u-1);if(d.length>0){if(s===Y.EQUALS){const C=yt.getCellPositions(c,l,t+m,e.getValue(),d);C!=null&&C.forEach(E=>{if(E<f||E>f+u-1)return;const b=E-f;r[b]==null&&(r[b]=[]),r[b][t]=v.create(!0)})}else{const C=yt.getCellValuePositions(c,l,t+m);C!=null&&C.forEach((E,b)=>{let R=ie.create();Kt.has(b)?R=g.create(b):typeof b=="string"?R=U.create(b):typeof b=="number"?R=y.create(b):typeof b=="boolean"&&(R=v.create(b));let p;R.isError()?p=R:e.isError()?p=e:p=R.compare(e,s,a),(p.isError()||p.getValue()===!0)&&E.forEach(V=>{V>=f&&V<=f+u-1&&(r[V-f]==null&&(r[V-f]=[]),r[V-f][t]=p)})})}if(_.length>0)for(const C of _){const[E,b]=C;for(let R=E;R<=b;R++)this.__batchOperatorRowValue(e,t,r,n,R-f,c,l,f,m,s,a);yt.setContinueBuildingCache(c,l,t+m,E,b)}return}}for(let d=0;d<u;d++)this.__batchOperatorRowValue(e,t,r,n,d,c,l,f,m,s,a);yt.setContinueBuildingCache(c,l,t+m,f,f+u-1)}__batchOperatorRowValue(e,t,r,n,s,a,u,c,l,f,m){const d=this.getValueOrDefault(s,t);if(r[s]==null&&(r[s]=[]),d&&e)if(d.isError())r[s][t]=d;else if(e.isError())r[s][t]=e;else switch(n){case 1:r[s][t]=d.plus(e);break;case 0:r[s][t]=d.minus(e);break;case 2:r[s][t]=d.multiply(e);break;case 3:r[s][t]=d.divided(e);break;case 4:r[s][t]=d.mod(e);break;case 5:f?r[s][t]=d.compare(e,f,m):r[s][t]=g.create(h.VALUE);break;case 6:r[s][t]=d.concatenateFront(e);break;case 7:r[s][t]=d.concatenateBack(e);break;case 8:r[s][t]=d.pow(e);break;case 9:r[s][t]=d.round(e);break;case 10:r[s][t]=d.floor(e);break;case 12:r[s][t]=d.atan2(e);break;case 11:r[s][t]=d.ceil(e);break}else r[s][t]=g.create(h.NA);d!=null&&(d.isError()?yt.set(a,u,t+l,d.getErrorType(),s+c):yt.set(a,u,t+l,d.getValue(),s+c))}_batchOperatorArray(e,t,r,n){let s=e.getRowCount(),a=e.getColumnCount();s<this._rowCount&&(s=this._rowCount),a<this._columnCount&&(a=this._columnCount);const u=[],c=this._checkArrayCalculateType(this),l=this._checkArrayCalculateType(e);for(let f=0;f<s;f++){const m=[];for(let d=0;d<a;d++){let _;c===3?_=this.getValueOrDefault(0,0):c===1?_=this.getValueOrDefault(0,d):c===2?_=this.getValueOrDefault(f,0):_=this.getValueOrDefault(f,d);let C;if(l===3?C=e.getValueOrDefault(0,0):l===1?C=e.getValueOrDefault(0,d):l===2?C=e.getValueOrDefault(f,0):C=e.getValueOrDefault(f,d),_&&C)if(_.isError())m[d]=_;else if(C.isError())m[d]=C;else switch(t){case 1:m[d]=_.plus(C);break;case 0:m[d]=_.minus(C);break;case 2:m[d]=_.multiply(C);break;case 3:m[d]=_.divided(C);break;case 4:m[d]=_.mod(C);break;case 5:r?m[d]=_.compare(C,r,n):m[d]=g.create(h.VALUE);break;case 6:m[d]=_.concatenateFront(C);break;case 7:m[d]=_.concatenateBack(C);break;case 8:m[d]=_.pow(C);break;case 9:m[d]=_.round(C);break;case 12:m[d]=_.atan2(C);break;case 10:m[d]=_.floor(C);break;case 11:m[d]=_.ceil(C);break}else m[d]=g.create(h.NA)}u.push(m)}return this._createNewArray(u,s,a)}_checkArrayCalculateType(e){return e.getRowCount()===1&&e.getColumnCount()===1?3:e.getRowCount()===1?1:e.getColumnCount()===1?2:0}_formatValue(e){if(typeof e!="string")return e=e,this._rowCount=e.rowCount,this._columnCount=e.columnCount,this._unitId=e.unitId,this._sheetId=e.sheetId,this._currentRow=e.row,this._currentColumn=e.column,e.calculateValueList;e=e.slice(1,-1);const t=e.split(";"),r=t.length,n=[];let s=0;for(let a=0;a<r;a++){const c=t[a].split(","),l=c.length;s<l&&(s=l);const f=[];for(let m=0;m<l;m++){const d=c[m].trim();f.push(ot.create(d))}n.push(f)}return this._rowCount=r,this._columnCount=s,n}_createNewArray(e,t,r,n=-1,s=-1){(this._currentColumn===-1||this._currentRow===-1)&&(n=-1,s=-1);const a={calculateValueList:e,rowCount:t,columnCount:r,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:n,column:s};return q.create(a)}}class ot{static create(o){if(o==null)return ie.create();if(typeof o=="boolean")return v.create(o);if(typeof o=="string"){const e=o.toLocaleUpperCase().trim();if(Kt.has(e))return g.create(e);if(e===Mt.TRUE||e===Mt.FALSE)return wn(o);if(S.isRealNum(o))return y.create(Number(o));const{isNumberPattern:t,value:r,pattern:n}=Gc(o);if(t)return y.create(r,n);const s=o.replace(/\n/g,"").replace(/\r/g,"");return!of(s)&&ac(s)?q.create(s):nf(o)}return typeof o=="number"?Pn(o):g.create(h.VALUE)}}function of(i){const o=i.trim();return o.startsWith('"')&&o.endsWith('"')}const uf=1e4,ps=new ht(uf);class pr extends Vn{constructor(e){super();A(this,"_forcedSheetId","");A(this,"_forcedSheetName","");A(this,"_defaultSheetId","");A(this,"_rangeData",{startColumn:-1,startRow:-1,endRow:-1,endColumn:-1});A(this,"_unitData",{});A(this,"_unitStylesData",{});A(this,"_defaultUnitId","");A(this,"_forcedUnitId","");A(this,"_runtimeData",{});A(this,"_arrayFormulaCellData",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeFeatureCellData",{});A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._token=e}dispose(){this._unitData={},this._unitStylesData={},this._runtimeData={}}getToken(){return this._token}setToken(e){this._token=e}isExceedRange(){const{startRow:e,endRow:t,startColumn:r,endColumn:n}=this.getRangePosition();return e<0||r<0||t>=this.getActiveSheetRowCount()||n>=this.getActiveSheetColumnCount()}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}getRangePosition(){let{startRow:e,startColumn:t,endRow:r,endColumn:n}=S.moveRangeByOffset(this._rangeData,this._refOffsetX,this._refOffsetY);return Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Number.isNaN(r)&&(r=this.getActiveSheetRowCount()-1),Number.isNaN(n)&&(n=this.getActiveSheetColumnCount()-1),{...this._rangeData,startRow:e,endRow:r,startColumn:t,endColumn:n}}isReferenceObject(){return!0}iterator(e){const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition();if(this._checkIfWorksheetMiss())return e(g.create(h.VALUE),t,n);const a=this._forcedUnitId||this._defaultUnitId,u=this._forcedSheetId||this._defaultSheetId;for(let c=t;c<=r;c++)for(let l=n;l<=s;l++){if(c<0||l<0)return e(g.create(h.REF),c,l);const f=this.getCellData(c,l);let m=!1;if($r(f)){m=e(null,c,l);continue}let d=this.getCellValueObject(f);if(c===t&&l===n){const _=this.getCellPattern(a,u,c,l);if(_&&d.isNumber()){const C=Number(d.getValue());d=y.create(C,_)}}if(m=e(d,c,l),m===!1)return}}getFirstCell(){const{startRow:e,startColumn:t}=this.getRangePosition(),r=this.getCellData(e,t);if(!r)return y.create(0);let n=this.getCellValueObject(r);const s=this._forcedUnitId||this._defaultUnitId,a=this._forcedSheetId||this._defaultSheetId,u=this.getCellPattern(s,a,e,t);if(u&&n.isNumber()){const c=Number(n.getValue());n=y.create(c,u)}return n}getRangeData(){return this._rangeData}setRangeData(e){this._rangeData=e}getUnitId(){return this._forcedUnitId&&this._forcedUnitId.length>0?this._forcedUnitId:this._defaultUnitId}getSheetId(){return this._forcedSheetId&&this._forcedSheetId.length>0?this._forcedSheetId:this._defaultSheetId}setForcedUnitIdDirect(e){e.length>0&&(this._forcedUnitId=e)}getForcedUnitId(){return this._forcedUnitId}setForcedSheetId(e){var t;this._forcedSheetId=(t=e[this.getUnitId()])==null?void 0:t[this._forcedSheetName]}setForcedSheetIdDirect(e){this._forcedSheetId=e}getForcedSheetId(){return this._forcedSheetId}setForcedSheetName(e){e.length>0&&(this._forcedSheetName=e)}getForcedSheetName(){return this._forcedSheetName}setDefaultSheetId(e){this._defaultSheetId=e}getDefaultSheetId(){return this._defaultSheetId}setDefaultUnitId(e){this._defaultUnitId=e}getDefaultUnitId(){return this._defaultUnitId}getUnitData(){return this._unitData}setUnitData(e){this._unitData=e}getUnitStylesData(){return this._unitStylesData}setUnitStylesData(e){this._unitStylesData=e}getRuntimeData(){return this._runtimeData}setRuntimeData(e){this._runtimeData=e}getArrayFormulaCellData(){return this._arrayFormulaCellData}setArrayFormulaCellData(e){this._arrayFormulaCellData=e}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}setRuntimeArrayFormulaCellData(e){this._runtimeArrayFormulaCellData=e}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e){this._runtimeFeatureCellData=e}getActiveSheetRowCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowCount)||0}getActiveSheetColumnCount(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnCount)||0}getRowCount(){return this._rangeData.endRow-this._rangeData.startRow+1}getColumnCount(){return this._rangeData.endColumn-this._rangeData.startColumn+1}getRowData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.rowData)||{}}getColumnData(){var e;return((e=this.getCurrentActiveSheetData())==null?void 0:e.columnData)||{}}isCell(){return!1}isColumn(){return!1}isRow(){return!1}isRange(){return!1}isTable(){return!1}unionBy(e){return g.create(h.REF)}unionRange(e,t){return{startRow:-1,startColumn:-1,endRow:-1,endColumn:-1}}getCellValueObject(e){const t=qc(e);if(Kt.has(t))return g.create(t);if(e.t===S.CellValueType.NUMBER){const r=this._getPatternByCell(e);return Pn(t,r)}return e.t===S.CellValueType.STRING||e.t===S.CellValueType.FORCE_STRING?U.create(t.toString()):e.t===S.CellValueType.BOOLEAN?wn(t):ot.create(t)}_getPatternByCell(e){var n;const t=this._unitStylesData[this.getUnitId()];if(!t)return"";const r=t.getStyleByCell(e);return((n=r==null?void 0:r.n)==null?void 0:n.pattern)||""}getCellByRow(e){return this.getCellByPosition(e)}getCellByColumn(e){return this.getCellByPosition(void 0,e)}getCurrentActiveSheetData(){var e;return(e=this._unitData[this.getUnitId()])==null?void 0:e[this.getSheetId()]}getCurrentStylesData(){return this._unitStylesData[this.getUnitId()]}getCurrentRuntimeSheetData(){var e,t;return(t=(e=this._runtimeData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentActiveArrayFormulaCellData(){var e,t;return(t=(e=this._arrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCurrentRuntimeActiveArrayFormulaCellData(){var e,t;return(t=(e=this._runtimeArrayFormulaCellData)==null?void 0:e[this.getUnitId()])==null?void 0:t[this.getSheetId()]}getCellData(e,t){const r=this.getCurrentActiveSheetData(),n=this.getCurrentRuntimeSheetData(),s=this.getCurrentActiveArrayFormulaCellData(),a=this.getCurrentRuntimeActiveArrayFormulaCellData();return(n==null?void 0:n.getValue(e,t))||(a==null?void 0:a.getValue(e,t))||this.getRuntimeFeatureCellValue(e,t)||(s==null?void 0:s.getValue(e,t))||(r==null?void 0:r.cellData.getValue(e,t))}getRuntimeFeatureCellValue(e,t){return ji(e,t,this.getSheetId(),this.getUnitId(),this._runtimeFeatureCellData)}getCellByPosition(e,t){let r=e,n=t;r||(r=this._rangeData.startRow),n||(n=this._rangeData.startColumn);const s=this.getCellData(r,n);return s?this.getCellValueObject(s):g.create(h.VALUE)}getCellPattern(e,t,r,n){var c,l,f,m;const s=this._unitStylesData[e];if(!s)return"";const a=(f=(l=(c=this._unitData[e])==null?void 0:c[t])==null?void 0:l.cellData)==null?void 0:f.getValue(r,n);if(!a)return"";const u=s.getStyleByCell(a);return((m=u==null?void 0:u.n)==null?void 0:m.pattern)||""}toArrayValueObject(e=!0){var _;const{startRow:t,endRow:r,startColumn:n,endColumn:s}=this.getRangePosition(),a=`${this.getUnitId()}_${this.getSheetId()}_${t}_${r}_${n}_${s}`,u=ps.get(a);if(u&&e)return u;const c=r-t+1,l=s-n+1;if(c<0||l<0)return this._getBlankArrayValueObject();const f=new Array(c);this.iterator((C,E,b)=>{const R=E-t,p=b-n;f[R]||(f[R]=new Array(l)),C==null&&(C=ie.create()),f[R][p]=C});const m={calculateValueList:f,rowCount:f.length,columnCount:((_=f[0])==null?void 0:_.length)||0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:t,column:n},d=q.create(m);return e&&ps.set(a,d),d}toUnitRange(){return{range:this.getRangePosition(),sheetId:this.getSheetId(),unitId:this.getUnitId()}}_checkIfWorksheetMiss(){return(this._forcedSheetId==null||this._forcedSheetId.length===0)&&this._forcedSheetName.length>0}_getBlankArrayValueObject(){const e={calculateValueList:[],rowCount:0,columnCount:0,unitId:this.getUnitId(),sheetId:this.getSheetId(),row:0,column:0};return q.create(e)}}class qi extends Vn{constructor(o){super(),this._promise=o}isAsyncObject(){return!0}async getValue(){return this._promise}}class Ki extends Vn{constructor(o){super(),this._promiseList=o}isAsyncArrayObject(){return!0}async getValue(){var t;const o=[];for(let r=0;r<this._promiseList.length;r++){const n=this._promiseList[r];o[r]==null&&(o[r]=[]);for(let s=0;s<n.length;s++){const a=n[s];a.isAsyncObject()?o[r][s]=await a.getValue():o[r][s]=a}}const e={calculateValueList:o,rowCount:o.length,columnCount:((t=o[0])==null?void 0:t.length)||0,unitId:"",sheetId:"",row:0,column:0};return q.create(e)}}class Er extends pr{constructor(o,e,t){super(""),this.setRangeData(o),e&&this.setForcedSheetIdDirect(e),t&&this.setForcedUnitIdDirect(t)}isRange(){return!0}}class Hs extends pr{constructor(o){super(o);const e=Ht(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName),this.setRangeData(e.range)}isCell(){return!0}unionBy(o){if(!o.isCell())return g.create(h.REF);const e=o,t=this.unionRange(this.getRangeData(),e.getRangeData());return this._createRange(t)}unionRange(o,e){const t=o.startRow,r=o.startColumn,n=e.startRow,s=e.startColumn,a={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1};return t>n?(a.startRow=n,a.endRow=t):(a.startRow=t,a.endRow=n),r>s?(a.startColumn=s,a.endColumn=r):(a.startColumn=r,a.endColumn=s),o.startAbsoluteRefType&&(a.startAbsoluteRefType=o.startAbsoluteRefType),e.startAbsoluteRefType&&(a.endAbsoluteRefType=e.startAbsoluteRefType),a}_createRange(o){const e=new Er(o,this.getForcedSheetId(),this.getForcedUnitId());e.setUnitData(this.getUnitData()),e.setDefaultSheetId(this.getDefaultSheetId()),e.setDefaultUnitId(this.getDefaultUnitId()),e.setRuntimeData(this.getRuntimeData()),e.setUnitStylesData(this.getUnitStylesData()),e.setArrayFormulaCellData(this.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(this.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this.getRuntimeFeatureCellData());const{x:t,y:r}=this.getRefOffset();e.setRefOffset(t,r);const n=this.getForcedSheetId();e.setForcedSheetName(this.getForcedSheetName()),n!=null&&e.setForcedSheetIdDirect(n);const s=this.getForcedUnitId();return s&&e.setForcedUnitIdDirect(s),e}}class Gs extends pr{constructor(o){super(o);const e=Ht(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:e.range.startColumn,startRow:Number.NaN,endColumn:e.range.endColumn,endRow:Number.NaN,rangeType:S.RANGE_TYPE.COLUMN};this.setRangeData(t)}isColumn(){return!0}unionBy(o){if(!o.isColumn())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startColumn;if(n>=t.startColumn&&n<=t.endColumn)return this;const s=t.startColumn;return n>s?t.endColumn=n:(t.startColumn=n,t.endColumn=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=S.RANGE_TYPE.COLUMN,this.setToken(`${this.getToken()}${K.COLON}${e.getToken()}`),this}}class Ws extends pr{constructor(o){super(o);const e=Ht(o);this.setForcedUnitIdDirect(e.unitId),this.setForcedSheetName(e.sheetName);const t={...e.range,startColumn:Number.NaN,startRow:e.range.startRow,endColumn:Number.NaN,endRow:e.range.endRow,rangeType:S.RANGE_TYPE.ROW};this.setRangeData(t)}isRow(){return!0}unionBy(o){if(!o.isRow())return g.create(h.REF);const e=o;if(e.getForcedSheetName()!==void 0&&e.getForcedSheetName()!=="")return g.create(h.REF);const t=this.getRangeData(),r=e.getRangeData(),n=r.startRow;if(n>=t.startRow&&n<=t.endRow)return this;const s=t.startRow;return n>s?t.endRow=n:(t.startRow=n,t.endRow=s),r.startAbsoluteRefType&&(t.endAbsoluteRefType=r.startAbsoluteRefType),t.rangeType=S.RANGE_TYPE.ROW,this.setToken(`${this.getToken()}${K.COLON}${e.getToken()}`),this}}function O(i,o,e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<i;a++){const u=[];for(let c=0;c<o;c++){if(r===1&&n===1){const f=e.isArray()?e.get(0,0):e;u.push(f);continue}if(r===1&&c<n){const f=e.get(0,c);u.push(f);continue}if(n===1&&a<r){const f=e.get(a,0);u.push(f);continue}if(a>=r||c>=n){u.push(t!=null?t:ie.create());continue}const l=e.get(a,c);u.push(l)}s.push(u)}return Gt(s,i,o)}function Gt(i,o,e,t="",r=""){const n={calculateValueList:i,rowCount:o,columnCount:e,unitId:t,sheetId:r,row:-1,column:-1};return q.create(n)}function Qs(i){const o=[Y.EQUALS,Y.NOT_EQUAL,Y.GREATER_THAN_OR_EQUAL,Y.GREATER_THAN,Y.LESS_THAN_OR_EQUAL,Y.LESS_THAN];for(const e of o)if(i.startsWith(e)){const t=i.substring(e.length);return[e,ot.create(t)]}return[Y.EQUALS,ot.create(i)]}function Ln(i,o,e,t){if(!e)if(o.isString()){const r=`${o.getValue()}`,[n,s]=Qs(r);e=n,o=s}else e=Y.EQUALS;return i.compare(o,e,t)}function cf(i,o){const e=Math.max(i.isArray()?i.getRowCount():1,o.isArray()?o.getRowCount():1),t=Math.max(i.isArray()?i.getColumnCount():1,o.isArray()?o.getColumnCount():1),r=O(e,t,i),n=O(e,t,o);return r.mapValue((s,a,u)=>{const c=n.get(a,u);return s!=null&&s.isError()?s:c!=null&&c.isError()?c:s!=null&&s.isBoolean()&&(c!=null&&c.isBoolean())?wn(s.getValue()&&c.getValue()):v.create(!1)})}function lf(i){const o=i.getValue();let e=0;return o&&(e=1),y.create(e)}function Wa(i){return i.isArray()&&i.getRowCount()===1&&i.getColumnCount()===1?!0:i.isReferenceObject()?!!(i.isCell()||i.getRowCount()===1&&i.getColumnCount()===1):(i=i,!!(i.isString()||i.isNumber()||i.isBoolean()||i.isError()||i.isNull()))}function xt(i){const o=i==null?void 0:i.getPattern();let e={};if(o&&(e={s:{n:{pattern:o}}}),i==null)return{v:null,...e};if(i.isError())return{v:i.getErrorType(),t:S.CellValueType.STRING,...e};if(i.isValueObject()){const t=i,r=t.getValue();return t.isNumber()?{v:r,t:S.CellValueType.NUMBER,...e}:t.isBoolean()?{v:r?1:0,t:S.CellValueType.BOOLEAN,...e}:t.isString()?{v:r,t:S.CellValueType.STRING,...e}:t.isNull()?{v:null,...e}:{v:r,t:S.CellValueType.STRING,...e}}}function fr(i){let o=0,e=0;return i.forEach((t,r)=>{if(r%2===1)if(t.isArray()){const n=t;o=Math.max(o,n.getRowCount()),e=Math.max(e,n.getColumnCount())}else o=Math.max(o,1),e=Math.max(e,1)}),{maxRowLength:o,maxColumnLength:e}}function Nr(i,o,e,t){const r=o.getRowCount(),n=o.getColumnCount();for(let s=0;s<i.length;s++){if(s%2===1)continue;const a=i[s],u=a.getRowCount(),c=a.getColumnCount();if(u!==r||c!==n)return O(e,t,g.create(h.VALUE))}return null}function Vr(i,o,e,t=!1){const r=[];for(let n=0;n<i.length;n++){if(n%2===1)continue;const s=i[n],a=i[n+1];O(o,e,a,g.create(h.NA)).iterator((c,l,f)=>{if(!c)return;let m=Ln(s,c);if(t&&(m=xn(m,s,c)),r[l]===void 0&&(r[l]=[]),r[l][f]===void 0){r[l][f]=m;return}r[l][f]=cf(r[l][f],m)})}return r}function xn(i,o,e){const[t,r]=Qs(`${e.getValue()}`);return i.mapValue((n,s,a)=>{const u=o.get(s,a);if(u&&ff(u,r))return n;if(u!=null&&u.isNumber()){if(r.isString()){const c=r.convertToNumberObjectValue();if(c.isNumber())return u.compare(c,t)}return v.create(!1)}else if(r.isNumber()){if(u!=null&&u.isString()){const c=u.convertToNumberObjectValue();if(c.isNumber())return c.compare(r,t)}return v.create(!1)}else return u!=null&&u.isError()&&r.isError()&&u.getValue()===r.getValue()?v.create(!0):v.create(!1)})}function ff(i,o){if(i.isNumber()&&o.isNumber()||i.isBoolean()&&o.isBoolean())return!0;const e=i.isString()&&i.getValue()==="",t=o.isString()&&o.getValue()==="";return!!((e||i.isNull())&&(t||o.isNull())||i.isString()&&!e&&o.isString()&&!t)}var Hr=(i=>(i[i.CELL=0]="CELL",i[i.COLUMN=1]="COLUMN",i[i.ROW=2]="ROW",i))(Hr||{});function mf(i,o){let e;switch(o){case 0:e=new Hs(i);break;case 1:e=new Gs(i);break;case 2:e=new Ws(i);break;default:throw new Error("Unknown reference object type")}return e}function hf(i,o){let e=g.create(h.NAME);return(i.isCell()&&o.isCell()||i.isRow()&&o.isRow()||i.isColumn()&&o.isColumn())&&(e=i.unionBy(o)),e}var gf=Object.defineProperty,df=Object.getOwnPropertyDescriptor,Cf=(i,o,e,t)=>{for(var r=t>1?void 0:t?df(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&gf(o,e,r),r},_f=(i,o)=>(e,t)=>o(e,t,i),ze=(i=>(i[i.IDLE=0]="IDLE",i[i.START=1]="START",i[i.START_DEPENDENCY=2]="START_DEPENDENCY",i[i.START_CALCULATION=3]="START_CALCULATION",i[i.CURRENTLY_CALCULATING=4]="CURRENTLY_CALCULATING",i[i.START_DEPENDENCY_ARRAY_FORMULA=5]="START_DEPENDENCY_ARRAY_FORMULA",i[i.START_CALCULATION_ARRAY_FORMULA=6]="START_CALCULATION_ARRAY_FORMULA",i[i.CURRENTLY_CALCULATING_ARRAY_FORMULA=7]="CURRENTLY_CALCULATING_ARRAY_FORMULA",i[i.CALCULATION_COMPLETED=8]="CALCULATION_COMPLETED",i))(ze||{}),Jt=(i=>(i[i.INITIAL=0]="INITIAL",i[i.STOP_EXECUTION=1]="STOP_EXECUTION",i[i.NOT_EXECUTED=2]="NOT_EXECUTED",i[i.SUCCESS=3]="SUCCESS",i))(Jt||{});exports.FormulaRuntimeService=class extends S.Disposable{constructor(e){super();A(this,"_formulaExecuteStage",0);A(this,"_stopState",!1);A(this,"_currentRow",-1);A(this,"_currentColumn",-1);A(this,"_currentRowCount",Number.NEGATIVE_INFINITY);A(this,"_currentColumnCount",Number.NEGATIVE_INFINITY);A(this,"_currentSubUnitId","");A(this,"_currentUnitId","");A(this,"_runtimeData",{});A(this,"_runtimeOtherData",{});A(this,"_unitArrayFormulaRange",{});A(this,"_runtimeArrayFormulaCellData",{});A(this,"_runtimeClearArrayFormulaCellData",{});A(this,"_runtimeFeatureRange",{});A(this,"_runtimeFeatureCellData",{});A(this,"_functionsExecutedState",0);A(this,"_functionDefinitionPrivacyVar",new Map);A(this,"_totalFormulasToCalculate",0);A(this,"_completedFormulasCount",0);A(this,"_totalArrayFormulasToCalculate",0);A(this,"_completedArrayFormulasCount",0);A(this,"_formulaCycleIndex",0);A(this,"_isCycleDependency",!1);this._currentConfigService=e}get currentRow(){return this._currentRow}get currentColumn(){return this._currentColumn}get currentRowCount(){return this._currentRowCount}get currentColumnCount(){return this._currentColumnCount}get currentSubUnitId(){return this._currentSubUnitId}get currentUnitId(){return this._currentUnitId}dispose(){this.reset(),this._runtimeFeatureCellData={},this._runtimeFeatureRange={},this.clearReferenceAndNumberformatCache()}enableCycleDependency(){this._isCycleDependency=!0}disableCycleDependency(){this._isCycleDependency=!1}isCycleDependency(){return this._isCycleDependency}setFormulaCycleIndex(e){this._formulaCycleIndex=e}getFormulaCycleIndex(){return this._formulaCycleIndex}setTotalArrayFormulasToCalculate(e){this._totalArrayFormulasToCalculate=e}getTotalArrayFormulasToCalculate(){return this._totalArrayFormulasToCalculate}setCompletedArrayFormulasCount(e){this._completedArrayFormulasCount=e}getCompletedArrayFormulasCount(){return this._completedArrayFormulasCount}setTotalFormulasToCalculate(e){this._totalFormulasToCalculate=e}getTotalFormulasToCalculate(){return this._totalFormulasToCalculate}setCompletedFormulasCount(e){this._completedFormulasCount=e}getCompletedFormulasCount(){return this._completedFormulasCount}markedAsSuccessfullyExecuted(){this._functionsExecutedState=3}markedAsNoFunctionsExecuted(){this._functionsExecutedState=2}markedAsStopFunctionsExecuted(){this._functionsExecutedState=1}markedAsInitialFunctionsExecuted(){this._functionsExecutedState=0}stopExecution(){this._stopState=!0,this.setFormulaExecuteStage(0)}isStopExecution(){return this._stopState}setFormulaExecuteStage(e){this._formulaExecuteStage=e}getFormulaExecuteStage(){return this._formulaExecuteStage}reset(){this._formulaExecuteStage=0,this._runtimeData={},this._runtimeOtherData={},this._unitArrayFormulaRange={},this._runtimeArrayFormulaCellData={},this._runtimeClearArrayFormulaCellData={},this._functionDefinitionPrivacyVar.clear(),this.markedAsInitialFunctionsExecuted(),this._stopState=!1,this._isCycleDependency=!1,this._totalFormulasToCalculate=0,this._completedFormulasCount=0,this.clearReferenceAndNumberformatCache()}clearReferenceAndNumberformatCache(){Fc(),Wc(),Rc()}setCurrent(e,t,r,n,s,a){this._currentRow=e,this._currentColumn=t,this._currentRowCount=r,this._currentColumnCount=n,this._currentSubUnitId=s,this._currentUnitId=a}clearFunctionDefinitionPrivacyVar(){this._functionDefinitionPrivacyVar.clear()}registerFunctionDefinitionPrivacyVar(e,t){this._functionDefinitionPrivacyVar.set(e,t)}getFunctionDefinitionPrivacyVar(e){return this._functionDefinitionPrivacyVar.get(e)}setRuntimeOtherData(e,t,r,n){const s=this._currentSubUnitId,a=this._currentUnitId;this._runtimeOtherData[a]===void 0&&(this._runtimeOtherData[a]={});const u=this._runtimeOtherData[a];(u[s]===void 0||u[s]===null)&&(u[s]={});const c=u[s];let l=[];if(n.isReferenceObject()||n.isValueObject()&&n.isArray()){const f=n,{startRow:m,startColumn:d}=f.getRangePosition();f.iterator((_,C,E)=>{const b=xt(_),R=C-m,p=E-d;l[R]==null&&(l[R]=[]),l[R][p]=b})}else l=[[xt(n)]];(c[e]===void 0||c[e]===null)&&(c[e]={}),(c[e][r]===void 0||c[e][r]===null)&&(c[e][r]={}),c[e][r][t]=l}setRuntimeData(e){const t=this._currentRow,r=this._currentColumn,n=this._currentRowCount,s=this.currentColumnCount,a=this._currentSubUnitId,u=this._currentUnitId;this._runtimeData[u]==null&&(this._runtimeData[u]={});const c=this._runtimeData[u];c[a]==null&&(c[a]=new S.ObjectMatrix),this._unitArrayFormulaRange[u]==null&&(this._unitArrayFormulaRange[u]={});const l=this._unitArrayFormulaRange[u];(l[a]===null||l[a]===void 0)&&(l[a]={});const f=new S.ObjectMatrix(l[a]);this._runtimeArrayFormulaCellData[u]===void 0&&(this._runtimeArrayFormulaCellData[u]={});const m=this._runtimeArrayFormulaCellData[u];m[a]==null&&(m[a]=new S.ObjectMatrix),this._runtimeClearArrayFormulaCellData[u]===void 0&&(this._runtimeClearArrayFormulaCellData[u]={});const d=this._runtimeClearArrayFormulaCellData[u];d[a]==null&&(d[a]=new S.ObjectMatrix);const _=c[a],C=m[a],E=d[a];if(e.isReferenceObject()||e.isValueObject()&&e.isArray()){const b=e,{startRow:R,startColumn:p,endRow:V,endColumn:M}=b.getRangePosition();if(R===V&&p===M){const w=b.getFirstCell(),P=xt(w);_.setValue(t,r,P),E.setValue(t,r,P);return}const D={startRow:t,startColumn:r,endRow:V-R+t,endColumn:M-p+r};if(f.setValue(t,r,D),this._checkIfArrayFormulaRangeHasData(u,a,t,r,D)||this._checkIfArrayFormulaExceeded(n,s,D)){const w=xt(g.create(h.SPILL));_.setValue(t,r,w),E.setValue(t,r,w);const P=this._currentConfigService.getUnitData();b.iterator((L,B,j)=>{var z,W;const k=B-R+t,Q=j-p+r,te=(W=(z=P[u])==null?void 0:z[a])==null?void 0:W.cellData.getValue(k,Q);if(B===R&&j===p)C.setValue(t,r,w);else if(te!=null)te.v==null&&(te.v=""),C.setValue(k,Q,te);else{if(this._isInOtherArrayFormulaRange(u,a,t,r,k,Q))return!0;C.setValue(k,Q,{v:""})}})}else{const w=g.create(h.SPILL);b.iterator((P,L,B)=>{const j=xt(P);if(L===R&&B===p){if(P!=null&&P.isError()&&P.isEqualType(w))return E.setValue(t,r,{}),_.setValue(t,r,{...xt(w)}),!1;_.setValue(t,r,{...j})}const k=L-R+t,Q=B-p+r;C.setValue(k,Q,j)})}}else{const b=xt(e);_.setValue(t,r,b),E.setValue(t,r,b)}}getUnitData(){return this._runtimeData}getUnitArrayFormula(){return this._unitArrayFormulaRange}getRuntimeOtherData(){return this._runtimeOtherData}getRuntimeArrayFormulaCellData(){return this._runtimeArrayFormulaCellData}getRuntimeClearArrayFormulaCellData(){return this._runtimeClearArrayFormulaCellData}getRuntimeFeatureRange(){return this._runtimeFeatureRange}setRuntimeFeatureRange(e,t){this._runtimeFeatureRange[e]=t}getRuntimeFeatureCellData(){return this._runtimeFeatureCellData}setRuntimeFeatureCellData(e,t){this._runtimeFeatureCellData[e]=t}getAllRuntimeData(){return{unitData:this.getUnitData(),arrayFormulaRange:this.getUnitArrayFormula(),unitOtherData:this.getRuntimeOtherData(),functionsExecutedState:this._functionsExecutedState,arrayFormulaCellData:this.getRuntimeArrayFormulaCellData(),clearArrayFormulaCellData:this.getRuntimeClearArrayFormulaCellData(),runtimeFeatureRange:this.getRuntimeFeatureRange(),runtimeFeatureCellData:this.getRuntimeFeatureCellData()}}getRuntimeState(){return{totalFormulasToCalculate:this.getTotalFormulasToCalculate(),completedFormulasCount:this.getCompletedFormulasCount(),totalArrayFormulasToCalculate:this.getTotalArrayFormulasToCalculate(),completedArrayFormulasCount:this.getCompletedArrayFormulasCount(),stage:this.getFormulaExecuteStage(),formulaCycleIndex:this.getFormulaCycleIndex()}}_checkIfArrayFormulaRangeHasData(e,t,r,n,s){var d,_,C,E,b,R,p,V,M,D,w;const{startRow:a,startColumn:u,endRow:c,endColumn:l}=s,f=this._currentConfigService.getUnitData(),m=this._currentConfigService.getArrayFormulaCellData();(C=(_=(d=this._unitArrayFormulaRange[e])==null?void 0:d[t])==null?void 0:_[r])==null||C[n];for(let P=a;P<=c;P++)for(let L=u;L<=l;L++){if(P===r&&n===L)continue;const B=(R=(b=(E=this._runtimeData)==null?void 0:E[e])==null?void 0:b[t])==null?void 0:R.getValue(P,L);(V=(p=m==null?void 0:m[e])==null?void 0:p[t])==null||V.getValue(P,L);const j=(w=(D=(M=f==null?void 0:f[e])==null?void 0:M[t])==null?void 0:D.cellData)==null?void 0:w.getValue(P,L),k=this._getRuntimeFeatureCellValue(P,L,t,e);if(!$r(B)||this._isInOtherArrayFormulaRange(e,t,r,n,P,L)||!$r(j)||!$r(k))return!0}return!1}_getRuntimeFeatureCellValue(e,t,r,n){return ji(e,t,r,n,this._runtimeFeatureCellData)}_arrayCellHasData(e){return e==null?!1:e.v!==void 0}_isInOtherArrayFormulaRange(e,t,r,n,s,a){var f;const u=(f=this._currentConfigService.getArrayFormulaRange()[e])==null?void 0:f[t];if(u==null)return!1;let c=!1;return new S.ObjectMatrix(u).forValue((m,d,_)=>{var b,R;if(m===r&&d===n)return;const C=this._isInArrayFormulaRange(_,s,a),E=(R=(b=this._runtimeData[e])==null?void 0:b[t])==null?void 0:R.getValue(m,d);C&&(E==null?void 0:E.v)!==h.SPILL&&(c=!0)}),c}_isInArrayFormulaRange(e,t,r){if(e==null)return!1;const{startRow:n,startColumn:s,endRow:a,endColumn:u}=e;return t>=n&&t<=a&&r>=s&&r<=u}_checkIfArrayFormulaExceeded(e,t,r){return r.endRow>=e||r.endColumn>=t}_isInDirtyRange(e,t,r,n){const s=this._currentConfigService.getDirtyRanges();return s.length===0?!0:mi(s,e,t,r,n)}};exports.FormulaRuntimeService=Cf([_f(0,gt)],exports.FormulaRuntimeService);const ut=S.createIdentifier("univer.formula.runtime.service");var oe=(i=>(i[i.REFERENCE=1]="REFERENCE",i[i.VALUE=2]="VALUE",i[i.OPERATOR=3]="OPERATOR",i[i.FUNCTION=4]="FUNCTION",i[i.LAMBDA=5]="LAMBDA",i[i.LAMBDA_PARAMETER=6]="LAMBDA_PARAMETER",i[i.ERROR=7]="ERROR",i[i.BASE=8]="BASE",i[i.ROOT=9]="ROOT",i[i.UNION=10]="UNION",i[i.PREFIX=11]="PREFIX",i[i.SUFFIX=12]="SUFFIX",i[i.NULL=13]="NULL",i))(oe||{});const ct=new Map([[1,7],[2,9],[3,8],[4,6],[5,1],[6,2],[9,10],[10,3],[11,4],[12,5]]);class Fe{constructor(o){A(this,"_children",[]);A(this,"_definedNames");A(this,"_parent");A(this,"_valueObject");A(this,"_calculateState",!1);A(this,"_async",!1);A(this,"_address",!1);A(this,"_isForcedCalculateFunction",!1);this._token=o}dispose(){var o;this._children.forEach(e=>{e.dispose()}),(o=this._valueObject)==null||o.dispose(),this._valueObject=null,this._children=[],this._definedNames=null,this._parent=null}get nodeType(){return oe.BASE}isAsync(){return this._async}isAddress(){return this._address}isForcedCalculateFunction(){return this._isForcedCalculateFunction}setAsync(){this._async=!0}setAddress(){this._address=!0}getParent(){return this._parent}setParent(o){this._parent=o,o.addChildren(this)}setForcedCalculateFunction(){this._isForcedCalculateFunction=!0}getChildren(){return this._children}addChildren(...o){this._children.push(...o)}getToken(){return this._token}setValue(o){this._valueObject=o}getValue(){return this._valueObject}isCalculated(){return this._calculateState}setCalculated(){this._calculateState=!0}execute(){}setNotEmpty(o=!0){}async executeAsync(){return Promise.resolve(pt.SUCCESS)}serialize(){const o=this.getToken(),e=this.getChildren(),t=[],r=e.length;for(let s=0;s<r;s++){const a=e[s];t.push(a.serialize())}const n={token:o,nodeType:this.nodeType};return r>0&&(n.children=t),n}hasDefinedName(o){var e;return((e=this._definedNames)==null?void 0:e.includes(o))||!1}setDefinedNames(o){this._definedNames=o}getDefinedNames(){return this._definedNames}}class De extends Fe{constructor(e){super(e);A(this,"_errorValueObject");this._errorValueObject=g.create(e)}get nodeType(){return oe.ERROR}static create(e){return new De(e)}getValue(){return this._errorValueObject}}const lt=100;class ft{get zIndex(){return 0}dispose(){}create(o,e,t){let r;return o instanceof ae?r=o.getToken():r=o,new Fe(r)}}class Ns extends Fe{get nodeType(){return oe.ROOT}execute(){const o=this.getChildren();if(o.length>1){this.setValue(g.create(h.VALUE));return}const e=o[0];e==null?this.setValue(g.create(h.VALUE)):this.setValue(e.getValue())}}class qs extends ft{get zIndex(){return ct.get(oe.ROOT)||lt}checkAndCreateNodeType(o){if(!(o instanceof ae))return;if(o.getToken()===Vt)return new Ns(Vt)}}const Ct=S.createIdentifier("univer.formula-function.service");class Xi extends S.Disposable{constructor(){super(...arguments);A(this,"_functionExecutors",new Map);A(this,"_functionDescriptions",new Map)}dispose(){this._functionExecutors.clear(),this._functionDescriptions.clear()}registerExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.set(r.name,r)}}getExecutors(){return this._functionExecutors}getExecutor(e){return this._functionExecutors.get(e)}hasExecutor(e){return this._functionExecutors.has(e)}unregisterExecutors(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionExecutors.delete(r)}}registerDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.set(r.functionName,r)}return S.toDisposable(()=>{for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r.functionName)}})}getDescriptions(){return this._functionDescriptions}getDescription(e){return this._functionDescriptions.get(e)}hasDescription(e){return this._functionDescriptions.has(e)}unregisterDescriptions(...e){for(let t=0;t<e.length;t++){const r=e[t];this._functionDescriptions.delete(r)}}}var Le=(i=>(i.COMPARE="COMPARE",i.DIVIDED="DIVIDED",i.MINUS="MINUS",i.MULTIPLY="MULTIPLY",i.PLUS="PLUS",i.UNION="UNION",i.CUBE="CUBE",i))(Le||{}),Af=Object.defineProperty,Ef=Object.getOwnPropertyDescriptor,bf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Ef(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Af(o,e,r),r},Qa=(i,o)=>(e,t)=>o(e,t,i);class nn extends Fe{constructor(o,e,t){super(e),this._runtimeService=o,this._operatorString=e,this._functionExecutor=t}get nodeType(){return oe.PREFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");this._operatorString===Ne.MINUS?(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(y.create(0),e)):this._operatorString===Ne.AT?t=this._handlerAT(e):t=g.create(h.VALUE),this.setValue(t)}_handlerAT(o){if(!o.isReferenceObject())return g.create(h.VALUE);const e=o;if(e.isCell())return g.create(h.VALUE);const t=this._runtimeService,r=t.currentRow||0,n=t.currentColumn||0,s=e.getRangePosition(),{startRow:a,startColumn:u,endRow:c,endColumn:l}=s;return l!==u&&c!==a||a===c&&u===l?g.create(h.VALUE):c===a&&n>=u&&n<=l?e.getCellByColumn(n):u===l&&r>=a&&r<=c?e.getCellByRow(r):e.isTable()?e.getCellByPosition(r):g.create(h.VALUE)}}exports.PrefixNodeFactory=class extends ft{constructor(o,e){super(),this._functionService=o,this._runtimeService=e}get zIndex(){return ct.get(oe.PREFIX)||lt}checkAndCreateNodeType(o){if(!(o instanceof ae))return;const e=o.getToken(),t=e.trim();if(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')return;let r="";if(t===Ne.MINUS)r=Le.MINUS;else return t===Ne.AT?new nn(this._runtimeService,t):void 0;const n=this._functionService.getExecutor(r);return n?new nn(this._runtimeService,t,n):(console.error(`No function ${e}`),De.create(h.NAME))}};exports.PrefixNodeFactory=bf([Qa(0,Ct),Qa(1,ut)],exports.PrefixNodeFactory);new RegExp(Ne.MINUS,"g");new RegExp(Ne.AT,"g");function Zi(i,o,e){let t,r,n=i;const s=n.slice(0,2);let a=0;if(s[0]===Ne.MINUS){const u=o.getExecutor(Le.MINUS);t=new nn(e,Ne.MINUS,u),a++}return s[0]===Ne.AT&&(r=new nn(e,Ne.AT),t&&r.setParent(t),a++),a>0&&(n=n.slice(a)),{tokenTrim:n,minusPrefixNode:t,atPrefixNode:r}}var yf=Object.defineProperty,Rf=Object.getOwnPropertyDescriptor,pf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Rf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&yf(o,e,r),r},zt=(i,o)=>(e,t)=>o(e,t,i);class Nf extends Fe{constructor(o,e,t,r,n,s){super(o),this._functionExecutor=e,this._currentConfigService=t,this._runtimeService=r,this._definedNamesService=n,this._formulaDataModel=s,this._functionExecutor.isAsync()&&this.setAsync(),this._functionExecutor.isAddress()&&this.setAddress(),this._functionExecutor.needsLocale&&this._setLocale(),this._functionExecutor.needsSheetsInfo&&this._setSheetsInfo(),this._functionExecutor.needsFormulaDataModel&&this._functionExecutor.setFormulaDataModel(this._formulaDataModel)}get nodeType(){return oe.FUNCTION}async executeAsync(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let s=0;s<t;s++){const u=e[s].getValue();u!=null&&(u.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(u.toArrayValueObject()):o.push(u))}const r=await this._calculateAsync(o);let n;return r.isAsyncObject()||r.isAsyncArrayObject()?n=await r.getValue():n=r,this._setRefData(n),this.setValue(n),Promise.resolve(pt.SUCCESS)}execute(){const o=[],e=this.getChildren(),t=e.length;this._compatibility();for(let n=0;n<t;n++){const a=e[n].getValue();a!=null&&(a.isReferenceObject()&&!this._functionExecutor.needsReferenceObject?o.push(a.toArrayValueObject()):o.push(a))}const r=this._calculate(o);this._setRefData(r),this.setValue(r)}_compatibility(){this._lookupCompatibility()}_lookupCompatibility(){const o=this.getChildren(),e=o.length;if(!this._functionExecutor.needsExpandParams||e!==3)return;const t=o[1].getValue(),r=o[2].getValue();if(!(t!=null&&t.isReferenceObject())&&!(r!=null&&r.isReferenceObject()))return;let n,s;if(t!=null&&t.isReferenceObject()){const _=t.getRangeData(),{startRow:C,startColumn:E,endRow:b,endColumn:R}=_;n=b-C+1,s=R-E+1}else n=t!=null&&t.isArray()?t.getRowCount():1,s=t!=null&&t.isArray()?t.getColumnCount():1;const a=r.getRangeData(),{startRow:u,startColumn:c,endRow:l,endColumn:f}=a,m=l-u+1,d=f-c+1;n!==m&&(a.endRow+=n-m),s!==d&&(a.endColumn+=s-d)}_handleCustomResult(o){var t;if(typeof o!="object"||o==null)return ot.create(o);const e=Qi(o);return q.create({calculateValueList:e,rowCount:e.length,columnCount:((t=e[0])==null?void 0:t.length)||0,unitId:"",sheetId:"",row:-1,column:-1})}_handleAddressFunction(){this._functionExecutor.isAddress()&&this._setDefinedNamesForFunction()}_mapVariantsToValues(o){return o.map(e=>e.isArray()?e.toValue():e.isLambda()?e:e.getValue())}_calculate(o){const{minParams:e,maxParams:t}=this._functionExecutor;if(e!==-1&&t!==-1&&(o.length<e||o.length>t))return g.create(h.NA);let r;if(this._setRefInfo(),this._functionExecutor.isCustom()){const n=this._functionExecutor.calculateCustom(...this._mapVariantsToValues(o));r=this._handleCustomResult(n)}else this._handleAddressFunction(),r=this._functionExecutor.calculate(...o);return r}async _calculateAsync(o){const{minParams:e,maxParams:t}=this._functionExecutor;if(e!==-1&&t!==-1&&(o.length<e||o.length>t))return g.create(h.NA);let r;if(this._setRefInfo(),this._functionExecutor.isCustom()){const n=await this._functionExecutor.calculateCustom(...this._mapVariantsToValues(o));r=this._handleCustomResult(n)}else this._handleAddressFunction(),r=this._functionExecutor.calculate(...o);return r}_setDefinedNamesForFunction(){const o=this._currentConfigService.getExecuteUnitId();if(o==null)return;const e=this._definedNamesService.getDefinedNameMap(o);e!=null&&this._functionExecutor.setDefinedNames(e)}_setRefInfo(){const{currentUnitId:o,currentSubUnitId:e,currentRow:t,currentColumn:r}=this._runtimeService;if(this._functionExecutor.setRefInfo(o,e,t,r),this._functionExecutor.needsSheetRowColumnCount){const{rowCount:n,columnCount:s}=this._currentConfigService.getSheetRowColumnCount(o,e);this._functionExecutor.setSheetRowColumnCount(n,s)}}_setRefData(o){if(!o.isReferenceObject())return;const e=o;e.setForcedSheetId(this._currentConfigService.getSheetNameMap()),e.setUnitData(this._currentConfigService.getUnitData()),e.setArrayFormulaCellData(this._currentConfigService.getArrayFormulaCellData()),e.setRuntimeData(this._runtimeService.getUnitData()),e.setRuntimeArrayFormulaCellData(this._runtimeService.getRuntimeArrayFormulaCellData()),e.setRuntimeFeatureCellData(this._runtimeService.getRuntimeFeatureCellData())}_setLocale(){this._functionExecutor.setLocale(this._currentConfigService.getLocale())}_setSheetsInfo(){this._functionExecutor.setSheetsInfo(this._currentConfigService.getSheetsInfo())}}class Vf extends Fe{constructor(o="Error"){super(o)}get nodeType(){return oe.FUNCTION}async executeAsync(){return this.setValue(g.create(h.NAME)),Promise.resolve(pt.SUCCESS)}execute(){this.setValue(g.create(h.NAME))}}exports.FunctionNodeFactory=class extends ft{constructor(o,e,t,r,n,s){super(),this._functionService=o,this._currentConfigService=e,this._runtimeService=t,this._definedNamesService=r,this._injector=n,this._formulaDataModel=s}get zIndex(){return ct.get(oe.FUNCTION)||lt}create(o){const e=this._functionService.getExecutor(o);return e?new Nf(o,e,this._currentConfigService,this._runtimeService,this._definedNamesService,this._formulaDataModel):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(typeof o=="string")return;const e=o.getToken(),{tokenTrim:t,minusPrefixNode:r,atPrefixNode:n}=Zi(e.trim(),this._functionService,this._runtimeService);if(!Number.isNaN(Number(t))&&!this._isParentUnionNode(o))return De.create(h.VALUE);const s=t.toUpperCase();if(this._functionService.hasExecutor(s)){const a=this.create(s);return n?a.setParent(n):r&&a.setParent(r),a}}_isParentUnionNode(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken())===K.COLON}};exports.FunctionNodeFactory=pf([zt(0,Ct),zt(1,gt),zt(2,ut),zt(3,Xt),zt(4,S.Inject(S.Injector)),zt(5,S.Inject(exports.FormulaDataModel))],exports.FunctionNodeFactory);var Of=Object.defineProperty,Mf=Object.getOwnPropertyDescriptor,Sf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Mf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Of(o,e,r),r},Df=(i,o)=>(e,t)=>o(e,t,i);exports.Interpreter=class extends S.Disposable{constructor(o){super(),this._runtimeService=o}async executeAsync(o){if(!o||!o.node)return Promise.resolve(g.create(h.VALUE));const e=o.node,t=o.refOffsetX,r=o.refOffsetY;await this._executeAsync(e,t,r);const n=e.getValue();return n==null?Promise.resolve(g.create(h.VALUE)):Promise.resolve(n)}execute(o){if(!o||!o.node)return g.create(h.VALUE);const e=o.node,t=o.refOffsetX,r=o.refOffsetY;this._execute(e,t,r);const n=e.getValue();return n==null?g.create(h.VALUE):n}executePreCalculateNode(o){return o.execute(),o.getValue()}checkAsyncNode(o){if(o==null)return!1;const e=[];this._checkAsyncNode(o,e);for(let t=0,r=e.length;t<r;t++)if(e[t]===!0)return!0;return!1}_checkAsyncNode(o,e){const t=o.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];e.push(s.isAsync()),this._checkAsyncNode(s,e)}}async _executeAsync(o,e=0,t=0){if(this._runtimeService.isStopExecution())return Promise.resolve(pt.ERROR);const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===_r&&a.isEmptyParamFunction()){a.execute();continue}await this._executeAsync(a,e,t)}return o.nodeType===oe.REFERENCE&&o.setRefOffset(e,t),o.nodeType===oe.FUNCTION&&o.isAsync()?await o.executeAsync():o.execute(),Promise.resolve(pt.SUCCESS)}_execute(o,e=0,t=0){if(this._runtimeService.isStopExecution())return pt.ERROR;const r=o.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.getToken().toUpperCase()===_r&&a.isEmptyParamFunction()){a.execute();continue}this._execute(a,e,t)}return o.nodeType===oe.REFERENCE&&o.setRefOffset(e,t),o.execute(),pt.SUCCESS}};exports.Interpreter=Sf([Df(0,ut)],exports.Interpreter);function zi(i){return i instanceof ae?i.getToken()===nr:!1}function wf(i){return i instanceof ae?i.getToken()===Pi:!1}function Ks(i,o,e){const t=i.getChildren(),r=t.length,n=t[0];for(let s=0;s<r;s++){const a=t[s];if(!(zi(n)&&s!==0))if(a instanceof ae)Ks(a,o,e);else{const u=a.trim();if(e.has(u)){const c=new ae;c.setToken(Rr),c.setLambdaId(o),c.setLambdaPrivacyVar(e),c.setLambdaParameter(u),t[s]=c}}}}function Pf(i){let o=i;for(;o!=null&&o.getParent();)o=o.getParent();return o}function qa(i,o=0,e=0){return{node:i,refOffsetX:o,refOffsetY:e}}function Ji(i){if(!i)return;if(i.getToken()!==Rr)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(!e)return;const r=e.get(t);return r==null&&i.getValue()?i:Ji(r)}class jn extends dt{constructor(e,t,r){super(0);A(this,"_lambdaPrivacyValueMap",new Map);this._lambdaNode=e,this._interpreter=t,this._lambdaPrivacyVarKeys=r,this._lambdaPrivacyValueMap.clear()}static create(e,t,r){return new jn(e,t,r)}dispose(){this._lambdaPrivacyValueMap.clear(),this._lambdaPrivacyValueMap=new Map,this._lambdaNode=null,this._interpreter=null,this._lambdaPrivacyVarKeys=[]}isLambda(){return!0}execute(...e){const t=this._lambdaPrivacyVarKeys.length;if(e.length!==t||!this._interpreter||!this._lambdaNode)return g.create(h.VALUE);this._setLambdaPrivacyValueMap(e),this._setLambdaNodeValue(this._lambdaNode),this._lambdaNode.setNotEmpty(!1);let r;if(this._interpreter.checkAsyncNode(this._lambdaNode))r=new qi(this._interpreter.executeAsync(qa(this._lambdaNode)));else{const n=this._interpreter.execute(qa(this._lambdaNode));n.isReferenceObject()?r=n.toArrayValueObject():r=n}return this._lambdaNode.setNotEmpty(!0),r}executeCustom(...e){const t=e.map(r=>ot.create(r));return this.execute(...t)}_setLambdaNodeValue(e){if(!e)return;const t=e.getChildren(),r=t.length;for(let n=0;n<r;n++){const s=t[n];if(s.getToken()===Rr){const u=s.getLambdaParameter(),c=this._lambdaPrivacyValueMap.get(u);if(c)s.setValue(c);else{const l=s.getCurrentLambdaPrivacyVar(),f=Ji(l.get(u));f!=null&&s.setValue(f.getValue())}continue}this._setLambdaNodeValue(s)}}_setLambdaPrivacyValueMap(e){for(let t=0;t<e.length;t++){const r=e[t],n=this._lambdaPrivacyVarKeys[t];this._lambdaPrivacyValueMap.set(n,r)}}getLambdaPrivacyVarKeys(){return this._lambdaPrivacyVarKeys}}var Lf=Object.defineProperty,xf=Object.getOwnPropertyDescriptor,jf=(i,o,e,t)=>{for(var r=t>1?void 0:t?xf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Lf(o,e,r),r},Ka=(i,o)=>(e,t)=>o(e,t,i);class Uf extends Fe{constructor(e,t,r,n){super(e);A(this,"_isNotEmpty",!0);this._lambdaId=t,this._interpreter=r,this._lambdaPrivacyVarKeys=n}get nodeType(){return oe.LAMBDA}setNotEmpty(e=!1){this._isNotEmpty=e}isEmptyParamFunction(){return this.getChildren().length<2&&this._isNotEmpty}isFunctionParameter(){return this._lambdaId===null}getLambdaId(){return this._lambdaId}execute(){if(this.isEmptyParamFunction())this.setValue(jn.create(this,this._interpreter,this._lambdaPrivacyVarKeys));else{const e=this.getChildren(),t=e.length;this.setValue(e[t-1].getValue())}}}exports.LambdaNodeFactory=class extends ft{constructor(o,e){super(),this._runtimeService=o,this._interpreter=e}get zIndex(){return ct.get(oe.LAMBDA)||lt}create(o){const e=o.getChildren(),t=e[0];let r=e.slice(1,-1);const n=e[e.length-1];if(!(t instanceof ae&&n instanceof ae))return De.create(h.NAME);if(t.getToken()===nr){const u=t.getChildren();if(r.length!==u.length)return De.create(h.VALUE)}else r=e.slice(0,-1);const s=S.Tools.generateRandomId(8),a=new Map;for(let u=0;u<r.length;u++){const c=r[u];if(c instanceof ae){const l=c.getChildren()[0];c.setToken(Pi),a.set(l.trim(),void 0)}else return De.create(h.VALUE)}return this._runtimeService.registerFunctionDefinitionPrivacyVar(s,a),this._updateLambdaStatement(n,s,a),new Uf(o.getToken(),s,this._interpreter,[...a.keys()])}checkAndCreateNodeType(o){if(!(!(o instanceof ae)||o.getToken().trim().toUpperCase()!==_r))return this.create(o)}_updateLambdaStatement(o,e,t){Ks(o,e,t)}};exports.LambdaNodeFactory=jf([Ka(0,ut),Ka(1,S.Inject(exports.Interpreter))],exports.LambdaNodeFactory);function eo(i){if(!i)return;if(i.getToken()!==Rr)return i;const o=i,e=o.getCurrentLambdaPrivacyVar(),t=o.getLambdaParameter();if(e)return eo(e.get(t))}class Tf extends Fe{constructor(o,e,t){super(o),this._lambdaParameter=e,this._currentLambdaPrivacyVar=t}getLambdaParameter(){return this._lambdaParameter}getCurrentLambdaPrivacyVar(){return this._currentLambdaPrivacyVar}get nodeType(){return oe.LAMBDA_PARAMETER}execute(){const o=eo(this._currentLambdaPrivacyVar.get(this._lambdaParameter));if(o)this.setValue(o.getValue());else{const e=this.getValue();(e==null||e.isError())&&this.setValue(g.create(h.NAME))}}}class Xs extends ft{get zIndex(){return ct.get(oe.LAMBDA_PARAMETER)||lt}create(o){const e=o.getFunctionDefinitionPrivacyVar(),t=o.getLambdaParameter();return e?new Tf(o.getToken(),t,e):new De(h.NAME)}checkAndCreateNodeType(o){if(!(!(o instanceof ae)||o.getToken().trim()!==Rr))return this.create(o)}}class vf extends Fe{constructor(o){super(o),this._operatorString=o}get nodeType(){return oe.NULL}execute(){this.setValue(ie.create())}}var H=(i=>(i.ABS="ABS",i.ACOS="ACOS",i.ACOSH="ACOSH",i.ACOT="ACOT",i.ACOTH="ACOTH",i.AGGREGATE="AGGREGATE",i.ARABIC="ARABIC",i.ASIN="ASIN",i.ASINH="ASINH",i.ATAN="ATAN",i.ATAN2="ATAN2",i.ATANH="ATANH",i.BASE="BASE",i.CEILING="CEILING",i.CEILING_MATH="CEILING.MATH",i.CEILING_PRECISE="CEILING.PRECISE",i.COMBIN="COMBIN",i.COMBINA="COMBINA",i.COS="COS",i.COSH="COSH",i.COT="COT",i.COTH="COTH",i.CSC="CSC",i.CSCH="CSCH",i.DECIMAL="DECIMAL",i.DEGREES="DEGREES",i.EVEN="EVEN",i.EXP="EXP",i.FACT="FACT",i.FACTDOUBLE="FACTDOUBLE",i.FLOOR="FLOOR",i.FLOOR_MATH="FLOOR.MATH",i.FLOOR_PRECISE="FLOOR.PRECISE",i.GCD="GCD",i.INT="INT",i.ISO_CEILING="ISO.CEILING",i.LCM="LCM",i.LET="LET",i.LN="LN",i.LOG="LOG",i.LOG10="LOG10",i.MDETERM="MDETERM",i.MINVERSE="MINVERSE",i.MMULT="MMULT",i.MOD="MOD",i.MROUND="MROUND",i.MULTINOMIAL="MULTINOMIAL",i.MUNIT="MUNIT",i.ODD="ODD",i.PI="PI",i.POWER="POWER",i.PRODUCT="PRODUCT",i.QUOTIENT="QUOTIENT",i.RADIANS="RADIANS",i.RAND="RAND",i.RANDARRAY="RANDARRAY",i.RANDBETWEEN="RANDBETWEEN",i.ROMAN="ROMAN",i.ROUND="ROUND",i.ROUNDBANK="ROUNDBANK",i.ROUNDDOWN="ROUNDDOWN",i.ROUNDUP="ROUNDUP",i.SEC="SEC",i.SECH="SECH",i.SERIESSUM="SERIESSUM",i.SEQUENCE="SEQUENCE",i.SIGN="SIGN",i.SIN="SIN",i.SINH="SINH",i.SQRT="SQRT",i.SQRTPI="SQRTPI",i.SUBTOTAL="SUBTOTAL",i.SUM="SUM",i.SUMIF="SUMIF",i.SUMIFS="SUMIFS",i.SUMPRODUCT="SUMPRODUCT",i.SUMSQ="SUMSQ",i.SUMX2MY2="SUMX2MY2",i.SUMX2PY2="SUMX2PY2",i.SUMXMY2="SUMXMY2",i.TAN="TAN",i.TANH="TANH",i.TRUNC="TRUNC",i))(H||{}),se=(i=>(i.ASC="ASC",i.ARRAYTOTEXT="ARRAYTOTEXT",i.BAHTTEXT="BAHTTEXT",i.CHAR="CHAR",i.CLEAN="CLEAN",i.CODE="CODE",i.CONCAT="CONCAT",i.CONCATENATE="CONCATENATE",i.DBCS="DBCS",i.DOLLAR="DOLLAR",i.EXACT="EXACT",i.FIND="FIND",i.FINDB="FINDB",i.FIXED="FIXED",i.LEFT="LEFT",i.LEFTB="LEFTB",i.LEN="LEN",i.LENB="LENB",i.LOWER="LOWER",i.MID="MID",i.MIDB="MIDB",i.NUMBERVALUE="NUMBERVALUE",i.PHONETIC="PHONETIC",i.PROPER="PROPER",i.REGEXEXTRACT="REGEXEXTRACT",i.REGEXMATCH="REGEXMATCH",i.REGEXREPLACE="REGEXREPLACE",i.REPLACE="REPLACE",i.REPLACEB="REPLACEB",i.REPT="REPT",i.RIGHT="RIGHT",i.RIGHTB="RIGHTB",i.SEARCH="SEARCH",i.SEARCHB="SEARCHB",i.SUBSTITUTE="SUBSTITUTE",i.T="T",i.TEXT="TEXT",i.TEXTAFTER="TEXTAFTER",i.TEXTBEFORE="TEXTBEFORE",i.TEXTJOIN="TEXTJOIN",i.TEXTSPLIT="TEXTSPLIT",i.TRIM="TRIM",i.UNICHAR="UNICHAR",i.UNICODE="UNICODE",i.UPPER="UPPER",i.VALUE="VALUE",i.VALUETOTEXT="VALUETOTEXT",i.CALL="CALL",i.EUROCONVERT="EUROCONVERT",i.REGISTER_ID="REGISTER.ID",i))(se||{}),Bf=Object.defineProperty,If=Object.getOwnPropertyDescriptor,Ff=(i,o,e,t)=>{for(var r=t>1?void 0:t?If(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Bf(o,e,r),r},kf=(i,o)=>(e,t)=>o(e,t,i);class $f extends Fe{constructor(o,e){super(o),this._functionExecutor=e}get nodeType(){return oe.OPERATOR}execute(){const o=this.getChildren();this._functionExecutor.name===Le.COMPARE&&this._functionExecutor.setCompareType(this.getToken());const e=o[0],t=o[1];let r=e==null?void 0:e.getValue(),n=t==null?void 0:t.getValue();const s=this.getToken();if((r==null||n==null)&&s!==X.MINUS&&s!==X.PLUS){this.setValue(g.create(h.VALUE));return}r==null&&(r=ie.create()),n==null&&(n=ie.create()),r.isReferenceObject()&&(r=r.toArrayValueObject()),n.isReferenceObject()&&(n=n.toArrayValueObject()),this.setValue(this._functionExecutor.calculate(r,n))}}exports.OperatorNodeFactory=class extends ft{constructor(o){super(),this._functionService=o}get zIndex(){return ct.get(oe.OPERATOR)||lt}create(o){let e="";const t=o;t===X.PLUS?e=Le.PLUS:t===X.MINUS?e=Le.MINUS:t===X.MULTIPLY?e=Le.MULTIPLY:t===X.DIVIDED?e=Le.DIVIDED:t===X.CONCATENATE?e=se.CONCATENATE:t===X.POWER?e=H.POWER:ku.has(t)&&(e=Le.COMPARE);const r=this._functionService.getExecutor(e);return r?new $f(t,r):(console.error(`No function ${o}`),De.create(h.NAME))}checkAndCreateNodeType(o){if(o instanceof ae)return;const e=o.trim();if(!(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')&&bt.has(e))return this.create(e)}};exports.OperatorNodeFactory=Ff([kf(0,Ct)],exports.OperatorNodeFactory);var Yf=Object.defineProperty,Hf=Object.getOwnPropertyDescriptor,Gf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Hf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Yf(o,e,r),r},zn=(i,o)=>(e,t)=>o(e,t,i);class Jn extends Fe{constructor(e,t,r,n,s=!1){super(r);A(this,"_refOffsetX",0);A(this,"_refOffsetY",0);this._currentConfigService=e,this._runtimeService=t,this._referenceObjectType=n,this._isPrepareMerge=s}get nodeType(){return oe.REFERENCE}execute(){const e=this._currentConfigService,t=this._runtimeService,r=mf(this.getToken(),this._referenceObjectType);r.setDefaultUnitId(t.currentUnitId),r.setDefaultSheetId(t.currentSubUnitId),r.setForcedSheetId(e.getSheetNameMap()),r.setUnitData(e.getUnitData()),r.setArrayFormulaCellData(e.getArrayFormulaCellData()),r.setRuntimeData(t.getUnitData()),r.setUnitStylesData(e.getUnitStylesData()),r.setRuntimeArrayFormulaCellData(t.getRuntimeArrayFormulaCellData()),r.setRuntimeFeatureCellData(t.getRuntimeFeatureCellData());const{x:n,y:s}=this.getRefOffset();r.setRefOffset(n,s),!this._isPrepareMerge&&r.isExceedRange()?this.setValue(g.create(h.NAME)):this.setValue(r)}setRefOffset(e=0,t=0){this._refOffsetX=e,this._refOffsetY=t}getRefOffset(){return{x:this._refOffsetX,y:this._refOffsetY}}}exports.ReferenceNodeFactory=class extends ft{constructor(o,e,t){super(),this._currentConfigService=o,this._formulaRuntimeService=e,this._functionService=t}get zIndex(){return ct.get(oe.REFERENCE)||lt}checkAndCreateNodeType(o){var f,m;let e=!1,t,r=!1;o instanceof ae?(e=!0,t=o.getToken().trim(),((m=(f=o.getParent())==null?void 0:f.getParent())==null?void 0:m.getToken().trim())===K.COLON&&(r=!0)):t=o.trim();const n=this._currentConfigService,s=this._formulaRuntimeService,{tokenTrim:a,minusPrefixNode:u,atPrefixNode:c}=Zi(t,this._functionService,s);if(!e&&a.charAt(0)==='"'&&a.charAt(a.length-1)==='"')return;let l;if(yr(a)?l=new Jn(n,s,a,Hr.CELL,r):e&&this._checkParentIsUnionOperator(o)&&(bi(a)?l=new Jn(n,s,a,Hr.ROW,r):yi(a)&&(l=new Jn(n,s,a,Hr.COLUMN,r))),l)return c?l.setParent(c):u&&l.setParent(u),l}_checkParentIsUnionOperator(o){var e,t;return((t=(e=o.getParent())==null?void 0:e.getParent())==null?void 0:t.getToken().trim())===K.COLON}};exports.ReferenceNodeFactory=Gf([zn(0,gt),zn(1,ut),zn(2,Ct)],exports.ReferenceNodeFactory);var Wf=Object.defineProperty,Qf=Object.getOwnPropertyDescriptor,qf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Qf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Wf(o,e,r),r},es=(i,o)=>(e,t)=>o(e,t,i);class Xa extends Fe{constructor(o,e,t,r){super(t),this._currentConfigService=o,this._lexer=e,this._operatorString=t,this._functionExecutor=r}get nodeType(){return oe.SUFFIX}execute(){let e=this.getChildren()[0].getValue(),t;if(e==null)throw new Error("object is null");if(this._operatorString===He.PERCENTAGE){if(e.isReferenceObject()&&(e=e.toArrayValueObject()),t=this._functionExecutor.calculate(e,y.create(100)),t.isNumber()){const r=Number(t.getValue());t=y.create(r,"0.00%")}}else this._operatorString===He.POUND?t=this._handlerPound(e):t=g.create(h.VALUE);this.setValue(t)}_handlerPound(o){var u,c,l,f;if(!o.isReferenceObject()||!o.isCell())return g.create(h.VALUE);const e=o,t=e.getRangePosition(),r=e.getUnitId(),n=e.getSheetId(),s=this._currentConfigService.getFormulaData(),a=(f=(l=(c=(u=s==null?void 0:s[r])==null?void 0:u[n])==null?void 0:c[t.startRow])==null?void 0:l[t.startColumn])==null?void 0:f.f;return a&&this._lexer.treeBuilder(a),g.create(h.VALUE)}}exports.SuffixNodeFactory=class extends ft{constructor(o,e,t){super(),this._functionService=o,this._lexer=e,this._currentConfigService=t}get zIndex(){return ct.get(oe.SUFFIX)||lt}checkAndCreateNodeType(o){if(!(o instanceof ae))return;const e=o.getToken().trim();if(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"')return;let t="";if(e===He.PERCENTAGE)t=Le.DIVIDED;else return e===He.POUND?new Xa(this._currentConfigService,this._lexer,e):void 0;const r=this._functionService.getExecutor(t);return r?new Xa(this._currentConfigService,this._lexer,e,r):(console.error(`No function ${o}`),De.create(h.NAME))}};exports.SuffixNodeFactory=qf([es(0,Ct),es(1,S.Inject(exports.Lexer)),es(2,gt)],exports.SuffixNodeFactory);var Kf=Object.defineProperty,Xf=Object.getOwnPropertyDescriptor,Zf=(i,o,e,t)=>{for(var r=t>1?void 0:t?Xf(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&Kf(o,e,r),r},zf=(i,o)=>(e,t)=>o(e,t,i);class Jf extends Fe{constructor(o){super(o)}get nodeType(){return oe.UNION}execute(){const o=this.getChildren(),e=o[0],t=o[1],r=e.getValue(),n=t.getValue();if(r==null||n==null)throw new Error("leftNode and rightNode");let s;this.getToken()===K.COLON?s=this._unionFunction(r,n):s=g.create(h.NAME),this.setValue(s)}_unionFunction(o,e){return o.isError()||e.isError()||!o.isReferenceObject()||!e.isReferenceObject()?g.create(h.REF):(o=o,e=e,hf(o,e))}}exports.UnionNodeFactory=class extends ft{constructor(o){super(),this._functionService=o}get zIndex(){return ct.get(oe.UNION)||lt}create(o){return new Jf(o)}checkAndCreateNodeType(o){if(!(o instanceof ae))return;const t=o.getToken().trim();if(!(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"')&&t===K.COLON)return this.create(t)}};exports.UnionNodeFactory=Zf([zf(0,Ct)],exports.UnionNodeFactory);class em extends Fe{constructor(o){super(o)}get nodeType(){return oe.VALUE}execute(){this.setValue(ot.create(this.getToken()))}}class Zs extends ft{get zIndex(){return ct.get(oe.VALUE)||lt}_checkValueNode(o){if(Number.isNaN(Number(o))){const e=o.trim(),t=e.charAt(0),r=e.charAt(e.length-1);if(Kt.has(e))return this.create(e);if(t==='"'&&r==='"')return this.create(e);if(t==="{"&&r==="}")return this.create(e);const n=e.toUpperCase();if(n===Mt.TRUE||n===Mt.FALSE)return this.create(n)}else return this.create(o)}create(o){return new em(o)}checkAndCreateNodeType(o){if(!(o instanceof ae))return this._checkValueNode(o)}}var tm=Object.defineProperty,rm=Object.getOwnPropertyDescriptor,nm=(i,o,e,t)=>{for(var r=t>1?void 0:t?rm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&tm(o,e,r),r},Ze=(i,o)=>(e,t)=>o(e,t,i);exports.AstTreeBuilder=class extends S.Disposable{constructor(e,t,r,n,s,a,u,c,l,f,m){super();A(this,"_astNodeFactoryList",[]);this._runtimeService=e,this._astRootNodeFactory=t,this._functionNodeFactory=r,this._lambdaNodeFactory=n,this._lambdaParameterNodeFactory=s,this._operatorNodeFactory=a,this._prefixNodeFactory=u,this._referenceNodeFactory=c,this._suffixNodeFactory=l,this._unionNodeFactory=f,this._valueNodeFactory=m,this._initializeAstNode()}dispose(){this._astNodeFactoryList.forEach(e=>{e.dispose()}),this._astNodeFactoryList=[]}parse(e){const t=new Ns(Vt),r=this._parse(e,t);return e.hasDefinedNames()&&(r==null||r.setDefinedNames(e.getDefinedNames())),r}_lambdaParameterHandler(e,t){if(t.getLambdaId==null)return De.create(h.VALUE);const r=t.getLambdaId(),n=new Ns(Vt),s=this._runtimeService.getFunctionDefinitionPrivacyVar(r);if(!s)return!1;const a=[...s.keys()],u=e.getChildren(),c=u.length;for(let l=0;l<c;l++){const f=u[l];if(f instanceof ae){Ks(f,r,s),this._parse(f,n);const d=n.getChildren()[l];d!=null&&s.set(a[l],d)}else return!1}return n.setParent(t),t}_changeLetToLambda(e){const t=e.getChildren(),r=t.length;if(r%2!==1||r===0)return;const n=new ae;n.setToken(_r);const s=new ae;s.setToken(nr);const a=[...t];for(let c=0;c<r;c++){const l=a[c];if(!(l instanceof ae))return;c%2===0?l.changeToParent(n):l.changeToParent(s)}n.addChildrenFirst(s),s.setParent(n);const u=e.getParent();return u==null||u.replaceChild(e,n),n}_parse(e,t){var f;const r=e.getChildren(),n=r.length,s=[];let a=null;const u=e.getToken().trim().toUpperCase();if(u===Ec){const m=this._changeLetToLambda(e);return m!=null?this._parse(m,t):De.create(h.ERROR)}if(u===nt){if(a=t,n===0)return new vf(Vt).setParent(t),a}else{if(u===nr){let m=this._lambdaParameterHandler(e,t);return m===!1&&(m=De.create(h.ERROR)),m}if(a=this._checkAstNode(e),a==null)return De.create(h.NAME)}const c=r[0];for(let m=0;m<n;m++){const d=r[m];if(zi(c)){if(m!==0&&m!==n-1)continue}else if(wf(d)&&m!==n-1)continue;let _=null;if(d instanceof ae){if(d.getToken()===nt&&d.getChildren().length===0){const C=(f=d.getParent())==null?void 0:f.getChildren();if(C&&C.length===1)return De.create(h.NAME)}if(_=this._parse(d,a),_===a)continue}else _=this._checkAstNode(d);if(_==null)return De.create(h.NAME);if(_=Pf(_),_==null||(_==null?void 0:_.nodeType)===oe.ERROR)return _;switch(_.nodeType){case oe.FUNCTION:{const C=_.getToken().trim().toUpperCase();yc.has(C)&&_.setForcedCalculateFunction(),s.push(_);break}case oe.LAMBDA:s.push(_);break;case oe.LAMBDA_PARAMETER:s.push(_);break;case oe.OPERATOR:{const C=s.pop(),E=s.pop();E&&E.setParent(_),C&&C.setParent(_),s.push(_);break}case oe.REFERENCE:s.push(_);break;case oe.ROOT:s.push(_);break;case oe.UNION:s.push(_);break;case oe.VALUE:s.push(_);break;case oe.PREFIX:s.push(_);break;case oe.SUFFIX:s.push(_);break}}const l=s.length;for(let m=0;m<l;m++)s[m].setParent(a);return a}_checkAstNode(e){let t=null;const r=this._astNodeFactoryList.length;for(let n=0;n<r&&(t=this._astNodeFactoryList[n].checkAndCreateNodeType(e),t==null);n++);return t==null?new Vf:t}_initializeAstNode(){this._astNodeFactoryList=[this._astRootNodeFactory,this._functionNodeFactory,this._lambdaNodeFactory,this._lambdaParameterNodeFactory,this._operatorNodeFactory,this._prefixNodeFactory,this._referenceNodeFactory,this._suffixNodeFactory,this._unionNodeFactory,this._valueNodeFactory].sort(S.sortRules)}};exports.AstTreeBuilder=nm([Ze(0,ut),Ze(1,S.Inject(qs)),Ze(2,S.Inject(exports.FunctionNodeFactory)),Ze(3,S.Inject(exports.LambdaNodeFactory)),Ze(4,S.Inject(Xs)),Ze(5,S.Inject(exports.OperatorNodeFactory)),Ze(6,S.Inject(exports.PrefixNodeFactory)),Ze(7,S.Inject(exports.ReferenceNodeFactory)),Ze(8,S.Inject(exports.SuffixNodeFactory)),Ze(9,S.Inject(exports.UnionNodeFactory)),Ze(10,S.Inject(Zs))],exports.AstTreeBuilder);class to extends S.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",new Map);A(this,"_featureFormulaData",new Map);A(this,"_formulaData",new Map);A(this,"_definedNameMap",new Map);A(this,"_otherFormulaDataMainData",new Set);A(this,"_dependencyRTreeCache",new S.RTree);A(this,"_dependencyTreeIdLast",0)}buildDependencyTree(e,t){throw new Error("Method not implemented.")}getTreeById(e){throw new Error("Method not implemented.")}getAllTree(){throw new Error("Method not implemented.")}reset(){throw new Error("Method not implemented.")}addOtherFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeOtherFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearOtherFormulaDependency(e,t){throw new Error("Method not implemented.")}addFeatureFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}removeFeatureFormulaDependency(e,t,r){throw new Error("Method not implemented.")}clearFeatureFormulaDependency(e,t){throw new Error("Method not implemented.")}addFormulaDependency(e,t,r,n,s){throw new Error("Method not implemented.")}removeFormulaDependency(e,t,r,n){throw new Error("Method not implemented.")}clearFormulaDependency(e,t){throw new Error("Method not implemented.")}removeFormulaDependencyByDefinedName(e,t){throw new Error("Method not implemented.")}searchDependency(e,t){return this._dependencyRTreeCache.bulkSearch(e,t)}_restDependencyTreeId(){this._dependencyTreeIdLast=0}getOtherFormulaDependency(e,t,r){var n,s;return(s=(n=this._otherFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}addOtherFormulaDependencyMainData(e){this._otherFormulaDataMainData.add(e)}hasOtherFormulaDataMainData(e){return this._otherFormulaDataMainData.has(e)}_removeDependencyRTreeCacheById(e,t){this._dependencyRTreeCache.removeById(e,t)}getFeatureFormulaDependency(e,t,r){var n,s;return(s=(n=this._featureFormulaData.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}getFormulaDependency(e,t,r,n){var s,a;return(a=(s=this._formulaData.get(e))==null?void 0:s.get(t))==null?void 0:a.getValue(r,n)}addDependencyRTreeCache(e){const t=[];for(let r=0;r<e.rangeList.length;r++){const n=e.rangeList[r],{unitId:s,sheetId:a,range:u}=n;t.push({unitId:s,sheetId:a,range:u,id:e.treeId})}this._dependencyRTreeCache.bulkInsert(t),this._addAllTreeMap(e)}getLastTreeId(){const e=this._dependencyTreeIdLast;return this._dependencyTreeIdLast++,e}_addAllTreeMap(e){throw new Error("Method not implemented.")}_addDefinedName(e,t,r){this._definedNameMap.has(e)||this._definedNameMap.set(e,new Map);const n=this._definedNameMap.get(e);n.has(t)||n.set(t,new Set),n.get(t).add(r)}addFormulaDependencyByDefinedName(e,t){const r=e.treeId,n=(t==null?void 0:t.getDefinedNames())||[];for(const s of n)this._addDefinedName(e.unitId,s,r)}}class ro extends to{constructor(){super(...arguments);A(this,"_allTreeMap",new Map)}dispose(){this.reset()}buildDependencyTree(e,t=[]){const r=this.getAllTree();return e.length===0?(this._buildReverseDependency(r,t),r):(this._buildDependencyTree(r,e),this._buildReverseDependency(r,e),r)}_buildDependencyTree(e,t){const r=new Map;for(let n=0;n<t.length;n++){const s=t[n];r.set(s.treeId,s)}for(let n=0;n<e.length;n++){const s=e[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}_buildReverseDependency(e,t){const r=new Map;for(let n=0;n<e.length;n++){const s=e[n];r.set(s.treeId,s)}for(let n=0;n<t.length;n++){const s=t[n],a=s.toRTreeItem(),u=this._dependencyRTreeCache.bulkSearch(a);for(const c of u){const l=r.get(c);l&&s!==l&&!l.hasChildren(s.treeId)&&l.pushChildren(s)}}r.clear()}getAllTree(){const e=[];return this._allTreeMap.forEach(t=>{t.resetState(),e.push(t)}),e}getTreeById(e){return this._allTreeMap.get(e)}reset(){this._otherFormulaData.clear(),this._featureFormulaData.clear(),this._formulaData.clear(),this._dependencyRTreeCache.clear(),this._allTreeMap.clear(),this._restDependencyTreeId(),this._otherFormulaDataMainData.clear()}addOtherFormulaDependency(e,t,r,n){this._otherFormulaData.has(e)||this._otherFormulaData.set(e,new Map);const s=this._otherFormulaData.get(e);s.has(t)||s.set(t,new Map);const a=s.get(t);a.has(r)||a.set(r,new S.ObjectMatrix),a.get(r).setValue(n.refOffsetX,n.refOffsetY,n.treeId),this._addAllTreeMap(n)}removeOtherFormulaDependency(e,t,r){const n=this._otherFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{this._removeDependencyRTreeCache(f),this.clearDependencyForTree(this._allTreeMap.get(f)),this._removeAllTreeMap(f)}),s.delete(a),this._otherFormulaDataMainData.delete(a))}),s.size===0&&n.delete(t),n.size===0&&this._otherFormulaData.delete(e)}}clearOtherFormulaDependency(e,t){const r=this._otherFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t);for(const s of n.keys()){const a=n.get(s);a!=null&&(a.forValue((u,c,l)=>{const f=this._allTreeMap.get(l);f&&(this.clearDependencyForTree(f),this._removeAllTreeMap(l))}),this._otherFormulaDataMainData.delete(s))}n.clear()}else if(r){for(const n of r.keys()){const s=r.get(n);this._removeDependencyRTreeCacheById(e,n);for(const a of s.keys()){const u=s.get(a);u!=null&&(u.forValue((c,l,f)=>{const m=this._allTreeMap.get(f);m&&(this.clearDependencyForTree(m),this._removeAllTreeMap(f))}),this._otherFormulaDataMainData.delete(a))}}this._otherFormulaData.delete(e)}}addFeatureFormulaDependency(e,t,r,n){this._featureFormulaData.has(e)||this._featureFormulaData.set(e,new Map);const s=this._featureFormulaData.get(e);s.has(t)||s.set(t,new Map),s.get(t).set(r,n.treeId),this._addAllTreeMap(n)}removeFeatureFormulaDependency(e,t,r){const n=this._featureFormulaData.get(e);if(n&&n.has(t)){const s=n.get(t);r.forEach(a=>{const u=s.get(a);u!=null&&(this._removeDependencyRTreeCache(u),s.delete(a),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u))})}}clearFeatureFormulaDependency(e,t){const r=this._featureFormulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forEach(s=>{s!=null&&(this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s))}),n.clear()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forEach(a=>{a!=null&&(this.clearDependencyForTree(this._allTreeMap.get(a)),this._removeAllTreeMap(a))})}),this._featureFormulaData.delete(e))}addFormulaDependency(e,t,r,n,s){this._formulaData.has(e)||this._formulaData.set(e,new Map);const a=this._formulaData.get(e);a.has(t)||a.set(t,new S.ObjectMatrix),a.get(t).setValue(r,n,s.treeId),this._addAllTreeMap(s)}removeFormulaDependency(e,t,r,n){const s=this._formulaData.get(e);if(s&&s.has(t)){const a=s.get(t),u=a.getValue(r,n);if(u==null)return;this._removeDependencyRTreeCache(u),a.realDeleteValue(r,n),this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}}clearFormulaDependency(e,t){const r=this._formulaData.get(e);if(t&&r&&r.has(t)){const n=r.get(t);this._removeDependencyRTreeCacheById(e,t),n.forValue((s,a,u)=>{if(u==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(u)),this._removeAllTreeMap(u)}),n.reset()}else r&&(r.forEach((n,s)=>{this._removeDependencyRTreeCacheById(e,s),n.forValue((a,u,c)=>{if(c==null)return!0;this.clearDependencyForTree(this._allTreeMap.get(c)),this._removeAllTreeMap(c)})}),this._formulaData.delete(e))}clearDependencyForTree(e){if(e==null)return;const t=e.parents,r=e.children,n=this._allTreeMap;for(const s of t){const a=n.get(s);a==null||a.children.delete(e.treeId)}for(const s of r){const a=n.get(s);a==null||a.parents.delete(e.treeId)}e.dispose()}_removeDependencyRTreeCache(e){if(e==null)return;const t=this._allTreeMap.get(e);if(t){const r=[];for(let n=0;n<t.rangeList.length;n++){const s=t.rangeList[n],{unitId:a,sheetId:u,range:c}=s;r.push({unitId:a,sheetId:u,range:c,id:e})}this._dependencyRTreeCache.bulkRemove(r)}}removeFormulaDependencyByDefinedName(e,t){const r=this._definedNameMap.get(e);if(r){const n=r.get(t);if(n){for(const s of n)this._removeDependencyRTreeCache(s),this.clearDependencyForTree(this._allTreeMap.get(s)),this._removeAllTreeMap(s);n.clear()}}}_removeAllTreeMap(e){e!=null&&this._allTreeMap.delete(e)}_addAllTreeMap(e){this._allTreeMap.set(e.treeId,e)}}const Or=S.createIdentifier("univer.formula.dependency-manager.service");class no extends S.Disposable{constructor(){super(...arguments);A(this,"_referenceExecutorMap",new Map);A(this,"_onChanged$",new er.Subject);A(this,"onChanged$",this._onChanged$.asObservable())}dispose(){this._referenceExecutorMap.clear()}remove(e,t,r){r.forEach(n=>{var s,a;(a=(s=this._referenceExecutorMap.get(e))==null?void 0:s.get(t))==null||a.delete(n)}),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:r})}get(e,t,r){var n,s;return(s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))==null?void 0:s.get(r)}has(e,t,r){var n,s;return!!((s=(n=this._referenceExecutorMap.get(e))==null?void 0:n.get(t))!=null&&s.has(r))}register(e,t,r,n){let s=this._referenceExecutorMap.get(e);s||(s=new Map,this._referenceExecutorMap.set(e,s));let a=s.get(t);a||(a=new Map,s.set(t,a)),this._onChanged$.next({unitId:e,subUnitId:t,featureIds:[r]}),a.set(r,n)}getReferenceExecutorMap(){return this._referenceExecutorMap}}const ar=S.createIdentifier("univer.formula.feature-calculation-manager.service");class so extends S.Disposable{constructor(){super(...arguments);A(this,"_otherFormulaData",{})}dispose(){this._otherFormulaData={}}remove(e){var s,a,u;const{unitId:t,subUnitId:r,formulaId:n}=e;(u=(a=(s=this._otherFormulaData)==null?void 0:s[t])==null?void 0:a[r])==null||delete u[n]}get(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return(a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n]}has(e){var s,a;const{unitId:t,subUnitId:r,formulaId:n}=e;return((a=(s=this._otherFormulaData[t])==null?void 0:s[r])==null?void 0:a[n])!=null}register(e){const{unitId:t,subUnitId:r,formulaId:n,item:s}=e;this._otherFormulaData[t]||(this._otherFormulaData[t]={}),this._otherFormulaData[t][r]||(this._otherFormulaData[t][r]={}),this._otherFormulaData[t][r][n]=s}batchRegister(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{const u=s[a];if(u==null)return!0;this.register({unitId:t,subUnitId:n,formulaId:a,item:u})})})})}batchRemove(e){Object.keys(e).forEach(t=>{const r=e[t];if(r==null)return!0;Object.keys(r).forEach(n=>{const s=r[n];if(s==null)return!0;Object.keys(s).forEach(a=>{this.remove({unitId:t,subUnitId:n,formulaId:a})})})})}getOtherFormulaData(){return this._otherFormulaData}}const Un=S.createIdentifier("univer.formula.other-formula-manager.service"),sm=5e3,Vs=new ht(sm);function Os(i,o,e,t,r){let n=Vs.get(`${i}${o}`);if(n&&!ao(n,r))return n;const s=e.treeBuilder(o);if(Kt.has(s))return De.create(s);if(n=t.parse(s),n==null)throw new Error("astNode is null");return Vs.set(`${i}${o}`,n),n}function ao(i,o){const e=o.getDirtyDefinedNameMap(),t=o.getExecuteUnitId();if(t!=null&&e[t]!=null){const r=Object.keys(e[t]);for(let n=0,s=r.length;n<s;n++){const a=r[n];if(i.hasDefinedName(a))return!0}}return!1}function am(i,o,e){return!!(o!=null&&ao(o,e))}var sn=(i=>(i[i.NORMAL_FORMULA=0]="NORMAL_FORMULA",i[i.OTHER_FORMULA=1]="OTHER_FORMULA",i[i.FEATURE_FORMULA=2]="FEATURE_FORMULA",i))(sn||{});class io{constructor(){A(this,"_state",0);A(this,"treeId");A(this,"children",new Set);A(this,"parents",new Set)}resetState(){this._state=0}setAdded(){this._state=1}isAdded(){return this._state===1}setSkip(){this._state=2}isSkip(){return this._state===2}pushChildren(o){this.children.add(o.treeId),o._pushParent(this)}hasChildren(o){return this.children.has(o)}_pushParent(o){this.parents.add(o.treeId)}}class Ms extends io{constructor(){super(...arguments);A(this,"refTree");A(this,"refOffsetX",-1);A(this,"refOffsetY",-1);A(this,"isCache",!1);A(this,"isDirty",!1);A(this,"addressFunctionNodes",[]);A(this,"getDirtyData");A(this,"featureId")}get isVirtual(){return!0}get row(){return this.refTree==null?-1:this.refTree.row+this.refOffsetY}get column(){return this.refTree==null?-1:this.refTree.column+this.refOffsetX}get rowCount(){return this.refTree==null?0:this.refTree.rowCount}get columnCount(){return this.refTree==null?0:this.refTree.columnCount}get unitId(){return this.refTree==null?"":this.refTree.unitId}get subUnitId(){return this.refTree==null?"":this.refTree.subUnitId}get formula(){var e,t;return(t=(e=this.refTree)==null?void 0:e.formula)!=null?t:""}get nodeData(){return{node:this.node,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}get node(){var e;return(e=this.refTree)==null?void 0:e.node}dispose(){this.refTree=null}get rangeList(){const e=[];if(this.refTree==null)return[];for(let t=0;t<this.refTree.rangeList.length;t++){const r=this.refTree.rangeList[t];e.push({unitId:r.unitId,sheetId:r.sheetId,range:S.moveRangeByOffset(r.range,this.refOffsetX,this.refOffsetY)})}return e}toRTreeItem(){const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){return this.refTree==null?!1:this.refTree.dependencySheetName(e)}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:_,endColumn:C}=l;Number.isNaN(m)&&(m=0),Number.isNaN(_)&&(_=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(C)&&(C=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=_&&R<=C)return E=!0,!1}),E)return!0}return!1}get formulaId(){return this.refTree==null?"":this.refTree.formulaId}}class Gr extends io{constructor(e){super();A(this,"isCache",!1);A(this,"featureId");A(this,"featureDirtyRanges",[]);A(this,"refOffsetX",0);A(this,"refOffsetY",0);A(this,"type",0);A(this,"formulaId");A(this,"subUnitId","");A(this,"unitId","");A(this,"rangeList",[]);A(this,"formula","");A(this,"row",-1);A(this,"column",-1);A(this,"rowCount",Number.NEGATIVE_INFINITY);A(this,"columnCount",Number.NEGATIVE_INFINITY);A(this,"isDirty",!1);A(this,"node");A(this,"addressFunctionNodes",[]);A(this,"getDirtyData");this.treeId=e}get isVirtual(){return!1}get nodeData(){return{node:this.node,refOffsetX:0,refOffsetY:0}}toJson(){return{formula:this.formula,refOffsetX:this.refOffsetX,refOffsetY:this.refOffsetY}}dispose(){this.featureDirtyRanges=[],this.rangeList=[],this.addressFunctionNodes=[],this.getDirtyData=null}inRangeData(e){const t=e.startRow,r=e.startColumn,n=e.endRow,s=e.endColumn,a=this.row,u=this.column;return!(a<t||a>n||u<r||u>s)}dependencySheetName(e){var r;const t=this.rangeList;if(t.length===0||e==null)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c}=a;if(((r=e[u])==null?void 0:r[c])!=null)return!0}return!1}isExcludeRange(e){var r;const t=this.rangeList;if(t.length===0)return!1;for(let n=0,s=t.length;n<s;n++){const a=t[n],{unitId:u,sheetId:c,range:l}=a,f=(r=e==null?void 0:e[u])==null?void 0:r[c];let{startRow:m,endRow:d,startColumn:_,endColumn:C}=l;Number.isNaN(m)&&(m=0),Number.isNaN(_)&&(_=0),Number.isNaN(d)&&(d=Number.POSITIVE_INFINITY),Number.isNaN(C)&&(C=Number.POSITIVE_INFINITY);let E=!1;if(f==null||f.forValue((b,R)=>{if(b>=m&&b<=d&&R>=_&&R<=C)return E=!0,!1}),E)return!0}return!1}pushRangeList(e){this.rangeList.push(...e)}shouldBePushRangeList(){return this.rangeList.length===0&&this.type!==2}toRTreeItem(){if(this.featureId!=null)return this.featureDirtyRanges;const e=this.row,t=this.column;return[{unitId:this.unitId,sheetId:this.subUnitId,range:{startRow:e,startColumn:t,endRow:e,endColumn:t}}]}}var im=Object.defineProperty,om=Object.getOwnPropertyDescriptor,um=(i,o,e,t)=>{for(var r=t>1?void 0:t?om(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&im(o,e,r),r},Et=(i,o)=>(e,t)=>o(e,t,i);function Tt(i){return i.getLastTreeId()||0}const an=S.createIdentifier("engine-formula.dependency-generator");exports.FormulaDependencyGenerator=class extends S.Disposable{constructor(e,t,r,n,s,a,u,c){super();A(this,"_updateRangeFlattenCache",new Map);A(this,"_dependencyRTreeCacheForAddressFunction",new S.RTree);A(this,"_executedAddressFunctionNodeIds",new Set);this._currentConfigService=e,this._runtimeService=t,this._otherFormulaManagerService=r,this._featureCalculationManagerService=n,this._interpreter=s,this._astTreeBuilder=a,this._lexer=u,this._dependencyManagerService=c}dispose(){this._updateRangeFlattenCache.clear(),this._dependencyRTreeCacheForAddressFunction.clear(),Vs.clear()}async generate(){this._updateRangeFlatten();const e=this._currentConfigService.getFormulaData(),t=this._otherFormulaManagerService.getOtherFormulaData(),r=this._currentConfigService.getClearDependencyTreeCache();r!=null&&Object.keys(r).forEach(f=>{f!=null&&Object.keys(r[f]).forEach(m=>{m!=null&&(this._dependencyManagerService.clearOtherFormulaDependency(f,m),this._dependencyManagerService.clearFeatureFormulaDependency(f,m),this._dependencyManagerService.clearFormulaDependency(f,m))})});const n=this._currentConfigService.getUnitData(),s=await this._generateTreeList(e,t,n),a=this._getUpdateTreeListAndMakeDependency(s);let u=this._calculateRunList(a);return this._dependencyFeatureCalculation(u)&&(u.forEach(f=>{f.resetState()}),u=this._calculateRunList(u)),this._checkIsCycleDependency(u)&&this._runtimeService.enableCycleDependency(),this._dependencyRTreeCacheForAddressFunction.clear(),Promise.resolve(u)}_dependencyFeatureCalculation(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();if(t.size===0)return;this._clearFeatureCalculationNode(e);let r=!1;return t.forEach((n,s)=>{n.forEach((a,u)=>{a.forEach((c,l)=>{const{unitId:f,subUnitId:m,getDirtyData:d}=c,_=d(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),C=this._convertDirtyRangesToUnitRange(_.dirtyRanges),E=this._intersectFeatureCalculation(C,e,{unitId:f,subUnitId:m,featureId:l});if(E.length>0){let b=this._getExistTreeList({unitId:f,subUnitId:m,featureId:l},e);b==null&&(b=this._getFeatureFormulaTree(l,Tt(this._dependencyManagerService),c),e.push(b)),b.parents=new Set,E.forEach(R=>{R.hasChildren(b.treeId)||R.pushChildren(b)}),r=!0}})})}),r}_clearFeatureCalculationNode(e){const t=this._featureCalculationManagerService.getReferenceExecutorMap();e.forEach(r=>{var a,u,c,l;const n=new Set;for(const f of r.children){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(u=(a=t.get(r.unitId))==null?void 0:a.get(r.subUnitId))!=null&&u.has(m.featureId)||n.add(f))}r.children=n;const s=new Set;for(const f of r.parents){const m=this._dependencyManagerService.getTreeById(f);m&&(m.featureId&&(l=(c=t.get(r.unitId))==null?void 0:c.get(r.subUnitId))!=null&&l.has(m.featureId)||s.add(f))}r.parents=s})}_convertDirtyRangesToUnitRange(e){const t=[];for(const r in e){const n=e[r];for(const s in n){const a=n[s];for(const u of a)t.push({unitId:r,sheetId:s,range:u})}}return t}_intersectFeatureCalculation(e,t,r){const n=[],s=this._dependencyManagerService.searchDependency(e);for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r.unitId&&c.subUnitId===r.subUnitId&&c.featureId===r.featureId)continue;s.has(c.treeId)&&n.push(c)}return n}_getExistTreeList(e,t){const{unitId:r,subUnitId:n,featureId:s}=e;for(let a=0,u=t.length;a<u;a++){const c=t[a];if(c.unitId===r&&c.subUnitId===n&&c.featureId===s)return c}}_isCyclicUtil(e,t,r){const n=this._dependencyManagerService.getTreeById(e);if(n==null)return!1;if(!t.has(n.treeId)){t.add(n.treeId),r.add(n.treeId);for(const s of n.children)if(!t.has(s)&&this._isCyclicUtil(s,t,r)||r.has(s))return!0}return r.delete(n.treeId),!1}_checkIsCycleDependency(e){const t=new Set,r=new Set;for(let n=0,s=e.length;n<s;n++){const a=e[n];if(this._isCyclicUtil(a.treeId,t,r)===!0)return!0}return!1}async _generateTreeList(e,t,r){const n=Object.keys(e),s=Object.keys(t),a=[];this._currentConfigService.isForceCalculate()&&this._dependencyManagerService.reset(),this._registerFormulas(n,e,r,a),this._registerOtherFormulas(t,s,a),this._registerFeatureFormulas(a);for(let c=0,l=a.length;c<l;c++){const f=a[c],m=this._getTreeNode(f);f.isDirty=this._includeTree(f,m);const d=this._getAddressFunctionNodeList(m);if(d.length>0&&(f.addressFunctionNodes=d),f.isVirtual)continue;this._runtimeService.setCurrent(f.row,f.column,f.rowCount,f.columnCount,f.subUnitId,f.unitId);const _=await this._getRangeListByNode({node:m,refOffsetX:f.refOffsetX,refOffsetY:f.refOffsetY});f.pushRangeList(_)}for(let c=0,l=a.length;c<l;c++){const f=a[c];f.isCache||this._dependencyManagerService.addDependencyRTreeCache(f)}return await this._calculateListByFunctionRefNode(a),a}_registerFeatureFormulas(e){this._featureCalculationManagerService.getReferenceExecutorMap().forEach((r,n)=>{r.forEach((s,a)=>{s.forEach((u,c)=>{const l=this._dependencyManagerService.getFeatureFormulaDependency(u.unitId,u.subUnitId,c);e.push(this._getFeatureFormulaTree(c,l,u))})})})}_getFeatureFormulaTree(e,t,r){const{unitId:n,subUnitId:s,dependencyRanges:a,getDirtyData:u}=r,c=t||Tt(this._dependencyManagerService),l=new Gr(c);l.unitId=n,l.subUnitId=s,l.rangeList=a,l.getDirtyData=u;const f=u(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData()),m=this._convertDirtyRangesToUnitRange(f.dirtyRanges);return l.featureDirtyRanges=m,l.featureId=e,l.type=sn.FEATURE_FORMULA,this._dependencyManagerService.addFeatureFormulaDependency(n,s,e,l),this._dependencyManagerService.getFeatureFormulaDependency(r.unitId,r.subUnitId,e)&&(l.isCache=!0),l}_registerOtherFormulas(e,t,r){for(const n of t){const s=e[n];if(s==null)continue;const a=Object.keys(s);for(const u of a){const c=s[u];if(c==null)continue;const l=Object.keys(c);for(const f of l){const m=this._dependencyManagerService.hasOtherFormulaDataMainData(f),d=c[f],{f:_,ranges:C}=d;let E=!1;m&&(E=!0);const b=Os(n,_,this._lexer,this._astTreeBuilder,this._currentConfigService),{firstRow:R,firstColumn:p}=this._getFirstCellOfRange(C),V=this._dependencyManagerService.getOtherFormulaDependency(n,u,f),M=(V==null?void 0:V.getValue(0,0))||Tt(this._dependencyManagerService),D=new Gr(M);for(let w=0;w<C.length;w++){const P=C[w],{startRow:L,startColumn:B,endRow:j,endColumn:k}=P;for(let Q=L;Q<=j;Q++)for(let te=B;te<=k;te++){const z=te-p,W=Q-R;if(z===0&&W===0){D.node=b,D.formula=_,D.unitId=n,D.subUnitId=u,D.formulaId=f,D.type=sn.OTHER_FORMULA,D.isCache=E,r.push(D),this._dependencyManagerService.addOtherFormulaDependency(n,u,f,D),this._dependencyManagerService.addFormulaDependencyByDefinedName(D);continue}const ce=new Ms;ce.treeId=(V==null?void 0:V.getValue(z,W))||Tt(this._dependencyManagerService),ce.refTree=D,ce.refOffsetX=z,ce.refOffsetY=W,ce.isCache=E,this._dependencyManagerService.addOtherFormulaDependency(n,u,f,ce),this._dependencyManagerService.addFormulaDependencyByDefinedName(ce),r.push(ce)}}this._dependencyManagerService.addOtherFormulaDependencyMainData(f)}}}}_getFirstCellOfRange(e){const t=e[0];return{firstRow:t.startRow,firstColumn:t.startColumn}}_registerFormulas(e,t,r,n){for(const s of e){const a=t[s];if(a==null)continue;const u=Object.keys(a);for(const c of u){const l=new S.ObjectMatrix(a[c]||{}),f=new Map;l.forValue((m,d,_)=>{if(_==null)return!0;const{x:C=0,y:E=0,si:b}=_;if(!(C===0&&E===0&&b!=null))return!0;const R=this._createFDtree(s,c,m,d,r,_),p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),f.set(b,R),n.push(R)}),l.forValue((m,d,_)=>{if(_==null)return!0;const{x:C=0,y:E=0,si:b}=_;if(C===0&&E===0&&b!=null)return!0;let R;if(b&&f.has(b)){const V=f.get(b);R=this._createVirtualFDtree(V,_)}else R=this._createFDtree(s,c,m,d,r,_);const p=this._dependencyManagerService.getFormulaDependency(s,c,m,d);p!=null?R.treeId=p:(this._dependencyManagerService.addFormulaDependency(s,c,m,d,R),this._dependencyManagerService.addFormulaDependencyByDefinedName(R)),n.push(R)}),f.clear()}}}_createFDtree(e,t,r,n,s,a){const{f:u,x:c=0,y:l=0}=a,f=new Gr(Tt(this._dependencyManagerService)),m=s[e][t],d=Os(e,u,this._lexer,this._astTreeBuilder,this._currentConfigService);return f.node=d,f.formula=u,f.unitId=e,f.subUnitId=t,f.row=r,f.column=n,f.rowCount=m.rowCount,f.columnCount=m.columnCount,f}_createVirtualFDtree(e,t){const{x:r=0,y:n=0}=t,s=new Ms;return s.treeId=Tt(this._dependencyManagerService),s.refTree=e,s.refOffsetX=r,s.refOffsetY=n,s}_updateRangeFlatten(){const e=this._currentConfigService.isForceCalculate(),t=this._currentConfigService.getDirtyRanges();if(!e){this._updateRangeFlattenCache.clear();for(let r=0;r<t.length;r++){const n=t[r],s=n.range,a=n.sheetId,u=n.unitId;this._addFlattenCache(u,a,s)}}}_addFlattenCache(e,t,r){let n=this._updateRangeFlattenCache.get(e);n==null&&(n=new Map,this._updateRangeFlattenCache.set(e,n));let s=n.get(t);s==null&&(s=[],n.set(t,s)),s.push(r)}_isPreCalculateNode(e){return e.nodeType===oe.UNION||e.nodeType===oe.PREFIX&&e.getToken()===Ne.AT||e.nodeType===oe.SUFFIX&&e.getToken()===He.POUND}_nodeTraversalRef(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(this._isPreCalculateNode(a)){if(t.push(a),a.nodeType===oe.UNION)for(const u of a.getChildren())u.nodeType===oe.FUNCTION&&u.isAddress()&&this._nodeTraversalRef(u,t);continue}else a.nodeType===oe.REFERENCE&&t.push(a);this._nodeTraversalRef(a,t)}}_nodeTraversalReferenceFunction(e,t){const r=e.getChildren(),n=r.length;for(let s=0;s<n;s++){const a=r[s];if(a.nodeType===oe.FUNCTION&&a.isAddress()){t.push(a);continue}this._nodeTraversalReferenceFunction(a,t)}}async _executeNode(e,t=0,r=0){let n;const s={node:e,refOffsetX:t,refOffsetY:r};return this._interpreter.checkAsyncNode(e)?n=await this._interpreter.executeAsync(s):n=this._interpreter.execute(s),n}async _getRangeListByNode(e){const t=[],r=e.refOffsetX,n=e.refOffsetY,s=e.node;if(s==null)return[];this._nodeTraversalRef(s,t);const a=[];for(let u=0,c=t.length;u<c;u++){const l=t[u],m=(await this._executeNode(l,r,n)).toUnitRange();a.push(m),l.setValue(null)}return a}_getAddressFunctionNodeList(e){const t=[];return e==null?[]:(this._nodeTraversalReferenceFunction(e,t),t)}_getTreeNode(e){return e.node}async _buildDirtyRangesByAddressFunction(e,t){const r=t.addressFunctionNodes;if(r.length===0)return;const n=t.refOffsetX,s=t.refOffsetY,a=await this._getRangeListByFunctionRefNode(r,n,s);t.addressFunctionNodes=[],this._addDependencyTreeByAddressFunction(t,a);const u=e.bulkSearch(a),c=this._buildTreeNodeById(u);c.length!==0&&await this._calculateAddressFunctionRuntimeData(e,c)}async _calculateListByFunctionRefNode(e){const t=new S.RTree;for(let r=0,n=e.length;r<n;r++){const s=e[r];t.insert({unitId:s.unitId,sheetId:s.subUnitId,range:{startRow:s.row,startColumn:s.column,endRow:s.row,endColumn:s.column},id:s.treeId})}this._executedAddressFunctionNodeIds.clear();for(let r=0,n=e.length;r<n;r++){const s=e[r];await this._calculateAddressFunction(t,s)}}async _calculateAddressFunction(e,t){const r=t.addressFunctionNodes;if(r.length===0)return;const n=t.refOffsetX,s=t.refOffsetY;this._runtimeService.setCurrent(t.row,t.column,t.rowCount,t.columnCount,t.subUnitId,t.unitId);const a=[];for(let l=0,f=r.length;l<f;l++){const m=await this._getRangeListByNode({node:r[l],refOffsetX:n,refOffsetY:s});a.push(...m)}const u=new Set;this._searchDependencyByAddressFunction(e,a,u);const c=this._buildTreeNodeById(u);if(c.length===0){await this._buildDirtyRangesByAddressFunction(e,t);return}await this._calculateAddressFunctionRuntimeData(e,c),await this._buildDirtyRangesByAddressFunction(e,t)}async _calculateAddressFunctionRuntimeData(e,t){for(;t.length>0;){const r=t.pop(),s={node:this._getTreeNode(r),refOffsetX:r.refOffsetX,refOffsetY:r.refOffsetY};await this._calculateAddressFunction(e,r),this._runtimeService.setCurrent(r.row,r.column,r.rowCount,r.columnCount,r.subUnitId,r.unitId);let a;this._interpreter.checkAsyncNode(s.node)?a=await this._interpreter.executeAsync(s):a=this._interpreter.execute(s),r.formulaId!=null?this._runtimeService.setRuntimeOtherData(r.formulaId,r.refOffsetX,r.refOffsetY,a):this._runtimeService.setRuntimeData(a)}}_buildTreeNodeById(e){const t=[];for(const r of e){const n=this._getTreeById(r);!n||this._executedAddressFunctionNodeIds.has(r)||(this._executedAddressFunctionNodeIds.add(r),t.push(n))}return t}_searchDependencyByAddressFunction(e,t,r){const n=e.bulkSearch(t),s=this._dependencyRTreeCacheForAddressFunction.bulkSearch(t);for(const u of s)r.has(u)||r.add(u);const a=[];for(const u of n){const c=this._getTreeById(u);c&&!r.has(u)&&(a.push(...c.rangeList),r.add(u))}return a.length>0&&this._searchDependencyByAddressFunction(e,a,r),r}_getTreeById(e){return this._dependencyManagerService.getTreeById(e)}_addDependencyTreeByAddressFunction(e,t){const r=[];for(let n=0;n<t.length;n++){const s=t[n],{unitId:a,sheetId:u,range:c}=s;r.push({unitId:a,sheetId:u,range:c,id:e.treeId})}this._dependencyRTreeCacheForAddressFunction.bulkInsert(r)}async _getRangeListByFunctionRefNode(e,t,r){const n=[];for(let s=0,a=e.length;s<a;s++){const u=e[s],l=(await this._executeNode(u,t,r)).toUnitRange();n.push(l),u.setValue(null)}return n}_getUpdateTreeListAndMakeDependency(e){const t=[],r=new Set,n=this._currentConfigService.isForceCalculate(),s=this._currentConfigService.getDirtyRanges(),a=this._dependencyManagerService.searchDependency(s),u=this._dependencyRTreeCacheForAddressFunction.bulkSearch(s);for(const l of u)a.add(l);const c=this._dependencyManagerService.buildDependencyTree(e);for(const l of c){const f=l.treeId;(n||l.isDirty||l.dependencySheetName(this._currentConfigService.getDirtyNameMap())||a.has(f)&&!l.isExcludeRange(this._currentConfigService.getExcludedRange()))&&!r.has(f)&&(t.push(l),r.add(f))}return t}_includeTreeFeature(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.featureId;if(n!=null){const u=this._currentConfigService.getDirtyUnitFeatureMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_includeOtherFormula(e){var s,a;const t=e.unitId,r=e.subUnitId,n=e.formulaId;if(n!=null){const u=this._currentConfigService.getDirtyUnitOtherFormulaMap();if(((a=(s=u==null?void 0:u[t])==null?void 0:s[r])==null?void 0:a[n])!=null)return!0}return!1}_detectForcedRecalculationNode(e,t){return t==null?!1:this._detectForcedRecalculationNodeRecursion(t)}_detectForcedRecalculationNodeRecursion(e){if(e.isForcedCalculateFunction())return!0;const t=e.getChildren();for(let r=0,n=t.length;r<n;r++){const s=t[r];if(this._detectForcedRecalculationNodeRecursion(s))return!0}return!1}_includeTree(e,t){var l,f,m;const r=e.unitId,n=e.subUnitId;if(this._detectForcedRecalculationNode(e,t)===!0||this._includeTreeFeature(e)===!0||this._includeOtherFormula(e)===!0||am(e,t,this._currentConfigService)===!0)return!0;const s=(f=(l=this._currentConfigService.getExcludedRange())==null?void 0:l[r])==null?void 0:f[n];if((s==null?void 0:s.getValue(e.row,e.column))!=null)return!1;if(((m=this._currentConfigService.getDirtyNameMap()[r])==null?void 0:m[n])!=null)return!0;if(!this._updateRangeFlattenCache.has(r))return!1;const u=this._updateRangeFlattenCache.get(r);if(!u.has(n))return!1;const c=u.get(n);for(const d of c)if(e.inRangeData(d))return!0;return!1}_calculateRunList(e){const t=e,r=[],n=[];for(;t.length>0;){const s=t.pop();if(s===void 0||s.isSkip())continue;if(s.isAdded()){r.push(s),s.setSkip();continue}n.length=0;for(const u of s.parents){const c=this._dependencyManagerService.getTreeById(u);if(!c)throw new Error("ParentDependencyTree object is null");c.isAdded()||s.isSkip()||n.push(c)}const a=this._dependencyRTreeCacheForAddressFunction.bulkSearch(s.toRTreeItem());for(const u of a){const c=this._dependencyManagerService.getTreeById(u);if(!c)throw new Error("ParentDependencyTree object is null");c.isAdded()||s.isSkip()||n.push(c)}n.length===0?(r.push(s),s.setSkip()):(s.setAdded(),t.push(s,...n))}return r}};exports.FormulaDependencyGenerator=um([Et(0,gt),Et(1,ut),Et(2,Un),Et(3,ar),Et(4,S.Inject(exports.Interpreter)),Et(5,S.Inject(exports.AstTreeBuilder)),Et(6,S.Inject(exports.Lexer)),Et(7,Or)],exports.FormulaDependencyGenerator);var cm=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,fm=(i,o,e,t)=>{for(var r=t>1?void 0:t?lm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&cm(o,e,r),r},jt=(i,o)=>(e,t)=>o(e,t,i);const oo=500,on=S.createIdentifier("engine-formula.calculate-formula.service");exports.CalculateFormulaService=class extends S.Disposable{constructor(e,t,r,n,s,a,u){super();A(this,"_executionInProgressListener$",new er.Subject);A(this,"executionInProgressListener$",this._executionInProgressListener$.asObservable());A(this,"_executionCompleteListener$",new er.Subject);A(this,"executionCompleteListener$",this._executionCompleteListener$.asObservable());this._configService=e,this._lexer=t,this._currentConfigService=r,this._runtimeService=n,this._formulaDependencyGenerator=s,this._interpreter=a,this._astTreeBuilder=u}stopFormulaExecution(){this._runtimeService.stopExecution()}setRuntimeFeatureCellData(e,t){this._runtimeService.setRuntimeFeatureCellData(e,t)}setRuntimeFeatureRange(e,t){this._runtimeService.setRuntimeFeatureRange(e,t)}async execute(e){this._runtimeService.setFormulaExecuteStage(ze.START),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._currentConfigService.load(e),this._runtimeService.reset();const t=e.maxIteration||xi;for(let r=0;r<t&&(this._runtimeService.setFormulaCycleIndex(r),await this._execute(),ps.clear(),!!this._runtimeService.isCycleDependency());r++);this._runtimeService.setFormulaExecuteStage(ze.CALCULATION_COMPLETED),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData()),yt.clear(),this._runtimeService.reset()}async _execute(){const e=await this._apply();if(e==null)return;const{arrayFormulaRange:t,runtimeFeatureRange:r}=e,{dirtyRanges:n,excludedCell:s}=this._getArrayFormulaDirtyRangeAndExcludedRange(t,r);return n==null||n.length===0||(this._currentConfigService.loadDirtyRangesAndExcludedCell(n,s),await this._apply(!0)),!0}_getArrayFormulaDirtyRangeAndExcludedRange(e,t){const r=[],n={};return Object.keys(e).forEach(s=>{const a=e[s];if(a==null)return!0;Object.keys(a).forEach(u=>{const c=new S.ObjectMatrix(a[u]);if(c==null)return!0;const l=new S.ObjectMatrix;c.forValue((f,m,d)=>{l.setValue(f,m,!0),r.push({unitId:s,sheetId:u,range:d})}),n[s]==null&&(n[s]={}),n[s][u]=l})}),Object.keys(t).forEach(s=>{const a=t[s];Object.keys(a).forEach(u=>{const c=a[u];if(c==null)return!0;Object.keys(c).forEach(l=>{const f=c[l];if(f==null)return!0;for(const m of f)r.push({unitId:u,sheetId:l,range:m})})})}),{dirtyRanges:r,excludedCell:n}}async _apply(e=!1){e?this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY_ARRAY_FORMULA):this._runtimeService.setFormulaExecuteStage(ze.START_DEPENDENCY),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());const t=(await this._formulaDependencyGenerator.generate()).reverse(),r=this._interpreter;e?(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION_ARRAY_FORMULA),this._runtimeService.setTotalArrayFormulasToCalculate(t.length)):(this._runtimeService.setFormulaExecuteStage(ze.START_CALCULATION),this._runtimeService.setTotalFormulasToCalculate(t.length)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState());let n=[];const s=this._configService.getConfig(Nn),a=(s==null?void 0:s.intervalCount)||oo,u=t.length;for(let c=0;c<u;c++){const l=t[c],f=l.nodeData,m=l.getDirtyData;if(c%a===0&&(await new Promise(_=>{const C=S.requestImmediateMacroTask(_);n.push(C)}),e?(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING_ARRAY_FORMULA),this._runtimeService.setCompletedArrayFormulasCount(c+1)):(this._runtimeService.setFormulaExecuteStage(ze.CURRENTLY_CALCULATING),this._runtimeService.setCompletedFormulasCount(c+1)),this._executionInProgressListener$.next(this._runtimeService.getRuntimeState()),this._runtimeService.isStopExecution()||f==null&&m==null)){this._runtimeService.setFormulaExecuteStage(ze.IDLE),this._runtimeService.markedAsStopFunctionsExecuted(),this._executionCompleteListener$.next(this._runtimeService.getAllRuntimeData());return}this._runtimeService.setCurrent(l.row,l.column,l.rowCount,l.columnCount,l.subUnitId,l.unitId);let d;if(m!=null&&l.featureId!=null){const{runtimeCellData:_,dirtyRanges:C}=m(this._currentConfigService.getDirtyData(),this._runtimeService.getAllRuntimeData());this._runtimeService.setRuntimeFeatureCellData(l.featureId,_),this._runtimeService.setRuntimeFeatureRange(l.featureId,C)}else f!=null&&(r.checkAsyncNode(f.node)?d=await r.executeAsync(f):d=r.execute(f),l.formulaId!=null?this._runtimeService.setRuntimeOtherData(l.formulaId,l.refOffsetX,l.refOffsetY,d):this._runtimeService.setRuntimeData(d))}return n.forEach(c=>c()),n=[],u>0?this._runtimeService.markedAsSuccessfullyExecuted():e||this._runtimeService.markedAsNoFunctionsExecuted(),this._runtimeService.getAllRuntimeData()}calculate(e,t=!0){const r=this._lexer.treeBuilder(e,t);if(Object.values(h).includes(r))return De.create(r);const n=this._astTreeBuilder.parse(r);n==null||n.serialize()}};exports.CalculateFormulaService=fm([jt(0,S.IConfigService),jt(1,S.Inject(exports.Lexer)),jt(2,gt),jt(3,ut),jt(4,an),jt(5,S.Inject(exports.Interpreter)),jt(6,S.Inject(exports.AstTreeBuilder))],exports.CalculateFormulaService);var mm=Object.defineProperty,hm=Object.getOwnPropertyDescriptor,gm=(i,o,e,t)=>{for(var r=t>1?void 0:t?hm(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&mm(o,e,r),r},ts=(i,o)=>(e,t)=>o(e,t,i);exports.CalculateController=class extends S.Disposable{constructor(o,e,t){super(),this._commandService=o,this._calculateFormulaService=e,this._formulaDataModel=t,this._initialize()}_initialize(){this._commandExecutedListener(),this._initialExecuteFormulaListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(o=>{if(o.id===Ts.id)this._calculateFormulaService.stopFormulaExecution();else if(o.id===Us.id){const e=o.params;this._calculate(e)}else if(o.id===Xr.id){const e=o.params;if(e==null)return;const{arrayFormulaRange:t,arrayFormulaCellData:r}=e;this._formulaDataModel.setArrayFormulaRange(t),this._formulaDataModel.setArrayFormulaCellData(r)}}))}async _calculate(o){const{forceCalculation:e=!1,dirtyRanges:t=[],dirtyNameMap:r={},dirtyDefinedNameMap:n={},dirtyUnitFeatureMap:s={},dirtyUnitOtherFormulaMap:a={},clearDependencyTreeCache:u={},maxIteration:c=xi}=o,l=this._formulaDataModel.getFormulaData(),f=this._formulaDataModel.getArrayFormulaCellData(),m=this._formulaDataModel.getArrayFormulaRange();this._calculateFormulaService.execute({formulaData:l,arrayFormulaCellData:f,arrayFormulaRange:m,forceCalculate:e,dirtyRanges:t,dirtyNameMap:r,dirtyDefinedNameMap:n,dirtyUnitFeatureMap:s,dirtyUnitOtherFormulaMap:a,clearDependencyTreeCache:u,maxIteration:c})}_initialExecuteFormulaListener(){this._calculateFormulaService.executionCompleteListener$.subscribe(o=>{const e=o.functionsExecutedState;switch(e){case Jt.NOT_EXECUTED:break;case Jt.STOP_EXECUTION:break;case Jt.SUCCESS:this._applyResult(o);break;case Jt.INITIAL:break}this._commandService.executeCommand(zr.id,{functionsExecutedState:e},{onlyLocal:!0})}),this._calculateFormulaService.executionInProgressListener$.subscribe(o=>{this._commandService.executeCommand(zr.id,{stageInfo:o},{onlyLocal:!0})})}async _applyResult(o){const{unitData:e,unitOtherData:t,arrayFormulaRange:r,arrayFormulaCellData:n,clearArrayFormulaCellData:s}=o;if(!e){console.error("No sheetData from Formula Engine!");return}r&&(this._formulaDataModel.clearPreviousArrayFormulaCellData(s),this._formulaDataModel.mergeArrayFormulaCellData(n),this._formulaDataModel.mergeArrayFormulaRange(r),this._commandService.executeCommand(Xr.id,{arrayFormulaRange:this._formulaDataModel.getArrayFormulaRange(),arrayFormulaCellData:this._formulaDataModel.getArrayFormulaCellData()},{onlyLocal:!0})),this._commandService.executeCommand(vs.id,{unitData:Ku(e),unitOtherData:t},{onlyLocal:!0})}};exports.CalculateController=gm([ts(0,S.ICommandService),ts(1,on),ts(2,S.Inject(exports.FormulaDataModel))],exports.CalculateController);const Za=/[\[\]]/g;function za(i,o){if(Za.test(i)){const e=Number(i.replace(Za,""));return o+e}return Number(i)-1}function rs(i,o=0,e=0){i=i.toLocaleUpperCase();const t=i.split(/[RC]/),r=t[1],n=t[2],s=za(r,o),a=za(n,e);return{row:s,column:a,absoluteRefType:S.AbsoluteRefType.NONE}}function uo(i,o=0,e=0){const{refBody:t,sheetName:r,unitId:n}=_n(i),s=t.indexOf(":");if(s===-1){const C=rs(t,o,e),E=C.row,b=C.column,R=C.absoluteRefType;return{unitId:n,sheetName:r,range:{startRow:E,startColumn:b,endRow:E,endColumn:b,startAbsoluteRefType:R,endAbsoluteRefType:R}}}const a=t.substring(0,s),u=t.substring(s+1),c=rs(a,o,e),l=rs(u,o,e),f=c.row,m=c.column,d=l.row,_=l.column;return{unitId:n,sheetName:r,range:{startRow:f,startColumn:m,endRow:d,endColumn:_,startAbsoluteRefType:c.absoluteRefType,endAbsoluteRefType:l.absoluteRefType}}}function dm(i){const o=Ur(i.startRow,i.startAbsoluteRefType,!0),e=Ur(i.startColumn,i.startAbsoluteRefType,!1),t=Ur(i.endRow,i.endAbsoluteRefType,!0),r=Ur(i.endColumn,i.endAbsoluteRefType,!1);return o===t&&e===r?`R${o}C${e}`:`R${o}C${e}:R${t}C${r}`}function Ur(i,o=S.AbsoluteRefType.ALL,e){switch(i+=1,o){case S.AbsoluteRefType.ALL:return`${i}`;case S.AbsoluteRefType.ROW:return e?`${i}`:`[${i}]`;case S.AbsoluteRefType.COLUMN:return e?`[${i}]`:`${i}`;case S.AbsoluteRefType.NONE:return`[${i}]`}}function It(i){let o=i;if(i.isArray()){const e=i.getRowCount(),t=i.getColumnCount();if(e>1||t>1)return g.create(h.VALUE);o=i.get(0,0)}return o.isError(),o}function Mr(...i){for(let o=0;o<i.length;o++){const e=It(i[o]);if(e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}function G(...i){for(let o=0;o<i.length;o++){const e=It(i[o]);if(e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function je(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isError())return{isError:!0,errorObject:e};if(e.isNull())return{isError:!0,errorObject:g.create(h.NA)};if(e=It(i[o]),e.isError())return{isError:!0,errorObject:e};if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE)};i[o]=e}return{isError:!1,variants:i}}function F(...i){for(let o=0;o<i.length;o++){let e=i[o];if(e.isString()&&(e=e.convertToNumberObjectValue()),e.isError())return{isError:!0,errorObject:e};i[o]=e}return{isError:!1,variants:i}}class N{constructor(o){A(this,"_unitId");A(this,"_subUnitId");A(this,"_row",-1);A(this,"_column",-1);A(this,"_definedNames");A(this,"_locale");A(this,"_sheetOrder");A(this,"_sheetNameMap");A(this,"_formulaDataModel");A(this,"_rowCount",-1);A(this,"_columnCount",-1);A(this,"needsExpandParams",!1);A(this,"needsReferenceObject",!1);A(this,"needsLocale",!1);A(this,"needsSheetsInfo",!1);A(this,"needsFormulaDataModel",!1);A(this,"needsSheetRowColumnCount",!1);A(this,"minParams",-1);A(this,"maxParams",-1);this._name=o}get name(){return this._name}get unitId(){return this._unitId}get subUnitId(){return this._subUnitId}get row(){return this._row}get column(){return this._column}dispose(){}getDefinedName(o){var t;const e=this._definedNames;return e==null?null:(t=Array.from(Object.values(e)).filter(r=>r.name===o))==null?void 0:t[0]}setDefinedNames(o){this._definedNames=o}getLocale(){return this._locale}setLocale(o){this._locale=o}getSheetsInfo(){return{sheetOrder:this._sheetOrder,sheetNameMap:this._sheetNameMap}}setSheetsInfo({sheetOrder:o,sheetNameMap:e}){this._sheetOrder=o,this._sheetNameMap=e}setFormulaDataModel(o){this._formulaDataModel=o}setSheetRowColumnCount(o,e){this._rowCount=o,this._columnCount=e}isAsync(){return!1}isAddress(){return!1}isCustom(){return!1}setRefInfo(o,e,t,r){this._unitId=o,this._subUnitId=e,this._row=t,this._column=r}calculateCustom(...o){return null}calculate(...o){return g.create(h.VALUE)}checkArrayType(o){return o.isReferenceObject()||o.isValueObject()&&o.isArray()}getIndexNumValue(o,e=1){let t=o;if(t.isArray()&&(t=t.getFirstCell()),t.isBoolean())return t.getValue()===!1?g.create(h.VALUE):e;if(t.isString()){const r=Number(t.getValue());return Number.isNaN(r)?g.create(h.REF):r}else if(t.isNumber())return t.getValue();return g.create(h.VALUE)}getZeroOrOneByOneDefault(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;o.isNumber()&&o.getValue()===0&&(e=0)}return e}getMatchTypeValue(o){if(o==null)return 1;let e=1;if(o.isArray()&&(o=o.getFirstCell()),o.isBoolean())o.getValue()===!1&&(e=0);else{if(o.isString())return;if(o.isNumber()){const t=o.getValue();t<=0&&(e=t)}}return e}binarySearch(o,e,t,r,n){const s=e.binarySearch(o,r,n);if(s==null)return g.create(h.NA);let a;return t.getRowCount()===1?a=t.get(0,s)||ie.create():a=t.get(s,0)||ie.create(),a.isNull()?y.create(0):a}_getOneFirstByRaw(o){return o.length===0?g.create(h.NA):o[0][0]||g.create(h.NA)}_getOneLastByRaw(o){return o.length===0?g.create(h.NA):o[o.length-1][o[0].length-1]||g.create(h.NA)}equalSearch(o,e,t,r=!0){const n=t.pickRaw(e.isEqual(o));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}fuzzySearch(o,e,t,r=!0){const n=t.pickRaw(e.compare(o,Y.EQUALS));return r?this._getOneFirstByRaw(n):this._getOneLastByRaw(n)}orderSearch(o,e,t,r=Me.MIN,n=!1){const s=e.orderSearch(o,r,n);if(s==null)return g.create(h.NA);const a=t.get(s.row,s.column)||ie.create();return a.isNull()?g.create(h.NA):a}binarySearchExpand(o,e,t,r=0,n,s){const a=e.binarySearch(o,n,s);return a==null?g.create(h.NA):r===0?t.slice([a,a+1]):t.slice(void 0,[a,a+1])}equalSearchExpand(o,e,t,r=!0,n=0){const s=e.isEqual(o);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}fuzzySearchExpand(o,e,t,r=!0,n=0){const s=e.compare(o,Y.EQUALS);let a;return r?a=s.getFirstTruePosition():a=s.getLastTruePosition(),a==null?g.create(h.NA):n===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}orderSearchExpand(o,e,t,r=Me.MIN,n=!1,s=0){const a=e.orderSearch(o,r,n);return a==null?g.create(h.NA):s===0?t.slice([a.row,a.row+1]):t.slice(void 0,[a.column,a.column+1])}flattenArray(o,e=!0){const t=[];t[0]=[];for(let r=0;r<o.length;r++){let n=o[r];if((n.isString()||n.isBoolean()||n.isNull())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()){let s;if(n.iterator(a=>{if(a==null||a.isNull()||e&&(a.isString()||a.isBoolean()))return!0;if(a=this._includingLogicalValuesAndText(a),a.isError())return s=a,!1;t[0].push(a)}),s!=null&&s.isError())return s}else t[0].push(n)}return Gt(t,1,t[0].length)}_includingLogicalValuesAndText(o){if(o.isBoolean()&&(o=lf(o)),o.isString()){const e=Number(o.getValue());o=y.create(Number.isNaN(e)?0:e)}return o}createReferenceObject(o,e){const t=o.getForcedUnitId(),r=o.getForcedSheetId()||"",n=o.getForcedSheetName(),a=Zr({unitId:t,sheetName:n,range:e});let u;return yr(a)?u=new Hs(a):bi(a)?u=new Ws(a):yi(a)?u=new Gs(a):u=new Er(e,r,t),this._setReferenceDefault(o,u)}_setReferenceDefault(o,e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e.setUnitData(o.getUnitData()),e.setRuntimeData(o.getRuntimeData()),e.setArrayFormulaCellData(o.getArrayFormulaCellData()),e.setRuntimeArrayFormulaCellData(o.getRuntimeArrayFormulaCellData()),e)}}class Cm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;const{isError:n,errorObject:s,variants:a}=Mr(t,r);if(n)return s;const{isError:u,errorObject:c,variants:l}=F(...a);if(u)return c;const[f,m]=l,d=Math.floor(+f.getValue()),_=Math.floor(+m.getValue());if(d<0||_<0)return g.create(h.NUM);if(d===0||_===0)return g.create(h.REF);const C=e.isArray()?e.getRowCount():1,E=e.isArray()?e.getColumnCount():1;if(C===1&&E===1)return e.isArray()?e.get(0,0):e;const b=d>C?C:d,R=_>E?E:_;return e.slice([0,b],[0,R])}}class _m extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r],s=n.isArray()?n.getRowCount():1,a=n.isArray()?n.getColumnCount():1;for(let u=0;u<s;u++)for(let c=0;c<a;c++){const l=n.isArray()?n.get(u,c):n;t.push([l])}}return q.create({calculateValueList:t,rowCount:t.length,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}var un=(i=>(i.ARRAY_CONSTRAIN="ARRAY_CONSTRAIN",i.FLATTEN="FLATTEN",i))(un||{});const co=[[Cm,un.ARRAY_CONSTRAIN],[_m,un.FLATTEN]];var ir;(i=>{const o=.636619772;function e(n,s){let a=0;for(let u=0;u<n.length;++u)a=s*a+n[u];return a}function t(n,s,a,u,c){if(s===0)return a;if(s===1)return u;const l=2/n;let f=a,m=u,d=u;for(let _=1;_<s;++_)d=m*_*l+c*f,f=m,m=d;return d}function r(n,s,a,u){return function(l,f){if(a){if(l===0)return a===1?-1/0:1/0;if(l<0)return Number.NaN}if(f===0)return n(l);if(f===1)return s(l);if(f<0)return Number.NaN;const m=f|0,d=n(l),_=s(l);return t(l,m,d,_,u)}}i.besselj=(()=>{const n=[-184.9052456,77392.33017,-1121442418e-2,6516196407e-1,-13362590354,57568490574],s=[1,267.8532712,59272.64853,9494680718e-3,1029532985,57568490411],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934935152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(C){let E=0,b=0,R=0,p=C*C;if(C<8)b=e(n,p),R=e(s,p),E=b/R;else{const V=C-.785398164;p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/C)*(Math.cos(V)*b-Math.sin(V)*R*8/C)}return E}const l=[-30.16036606,15704.4826,-2972611439e-3,2423968531e-1,-7895059235,72362614232],f=[1,376.9991397,99447.43394,1858330474e-2,2300535178,144725228442],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function _(C){let E=0,b=0,R=0,p=C*C;const V=Math.abs(C)-2.356194491;return Math.abs(C)<8?(b=C*e(l,p),R=e(f,p),E=b/R):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/Math.abs(C))*(Math.cos(V)*b-Math.sin(V)*R*8/Math.abs(C)),C<0&&(E=-E)),E}return function C(E,b){const R=Math.round(b);if(!Number.isFinite(E))return Number.isNaN(E)?E:0;if(R<0)return(R%2?-1:1)*C(E,-R);if(E<0)return(R%2?-1:1)*C(-E,R);if(R===0)return c(E);if(R===1)return _(E);if(E===0)return 0;let p=0;if(E>R)p=t(E,R,c(E),_(E),-1);else{const V=2*Math.floor((R+Math.floor(Math.sqrt(40*R)))/2);let M=!1,D=0,w=0,P=1,L=0;const B=2/E;for(let j=V;j>0;j--)if(L=j*B*P-D,D=P,P=L,Math.abs(P)>1e10&&(P*=1e-10,D*=1e-10,p*=1e-10,w*=1e-10),M&&(w+=P),M=!M,j===R&&(p=D),V-j>100&&p===0)return Number.NaN;w=2*w-P,p/=w}return p}})(),i.bessely=(()=>{const n=[228.4622733,-86327.92757,1087988129e-2,-5123598036e-1,7062834065,-2957821389],s=[1,226.1030244,47447.2647,7189466438e-3,7452499648e-1,40076544269],a=[2093887211e-16,-2073370639e-15,2734510407e-14,-.001098628627,1],u=[-934945152e-16,7621095161e-16,-6911147651e-15,.0001430488765,-.01562499995];function c(C){let E=0,b=0,R=0,p=C*C;const V=C-.785398164;return C<8?(b=e(n,p),R=e(s,p),E=b/R+o*(0,i.besselj)(C,0)*Math.log(C)):(p=64/p,b=e(a,p),R=e(u,p),E=Math.sqrt(o/C)*(Math.sin(V)*b+Math.cos(V)*R*8/C)),E}const l=[8511.937935,-4237922726e-3,7349264551e-1,-51534381390,127527439e4,-4900604943e3],f=[1,354.9632885,102042.605,2245904002e-2,3733650367,424441966400,249958057e5],m=[-240337019e-15,2457520174e-15,-3516396496e-14,.00183105,1],d=[105787412e-15,-88228987e-14,8449199096e-15,-.0002002690873,.04687499995];function _(C){let E=0,b=0,R=0,p=C*C;const V=C-2.356194491;return C<8?(b=C*e(l,p),R=e(f,p),E=b/R+o*((0,i.besselj)(C,1)*Math.log(C)-1/C)):(p=64/p,b=e(m,p),R=e(d,p),E=Math.sqrt(o/C)*(Math.sin(V)*b+Math.cos(V)*R*8/C)),E}return r(c,_,1,-1)})(),i.besseli=(()=>{const n=[.0045813,.0360768,.2659732,1.2067492,3.0899424,3.5156229,1],s=[.00392377,-.01647633,.02635537,-.02057706,.00916281,-.00157565,.00225319,.01328592,.39894228];function a(f){return f<=3.75?e(n,f*f/(3.75*3.75)):Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(s,3.75/Math.abs(f))}const u=[32411e-8,.00301532,.02658733,.15084934,.51498869,.87890594,.5],c=[-.00420059,.01787654,-.02895312,.02282967,-.01031555,.00163801,-.00362018,-.03988024,.39894228];function l(f){return f<3.75?f*e(u,f*f/(3.75*3.75)):(f<0?-1:1)*Math.exp(Math.abs(f))/Math.sqrt(Math.abs(f))*e(c,3.75/Math.abs(f))}return function f(m,d){const _=Math.round(d);if(_===0)return a(m);if(_===1)return l(m);if(_<0)return Number.NaN;if(Math.abs(m)===0)return 0;if(m===1/0)return 1/0;let C=0,E;const b=2/Math.abs(m);let R=0,p=1,V=0;const M=2*Math.round((_+Math.round(Math.sqrt(40*_)))/2);for(E=M;E>0;E--)if(V=E*b*p+R,R=p,p=V,Math.abs(p)>1e10&&(p*=1e-10,R*=1e-10,C*=1e-10),E===_&&(C=R),M-E>100&&C===0)return Number.NaN;return C*=f(m,0)/p,m<0&&_%2?-C:C}})(),i.besselk=(()=>{const n=[74e-7,1075e-7,.00262698,.0348859,.23069756,.4227842,-.57721566],s=[53208e-8,-.0025154,.00587872,-.01062446,.02189568,-.07832358,1.25331414];function a(f){return f<=2?-Math.log(f/2)*(0,i.besseli)(f,0)+e(n,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(s,2/f)}const u=[-4686e-8,-.00110404,-.01919402,-.18156897,-.67278579,.15443144,1],c=[-68245e-8,.00325614,-.00780353,.01504268,-.0365562,.23498619,1.25331414];function l(f){return f<=2?Math.log(f/2)*(0,i.besseli)(f,1)+1/f*e(u,f*f/4):Math.exp(-f)/Math.sqrt(f)*e(c,2/f)}return r(a,l,2,1)})()})(ir||(ir={}));function zs(i){return/^[01]{1,10}$/.test(i)}function Js(i){return/^[0-7]{1,10}$/.test(i)}function ea(i){return/^[0-9A-Fa-f]{1,10}$/.test(i)}function Ft(i){if(i===0)return 0;const o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18];let e=i,t=!1;e<0&&(e=-e,t=!0);const r=2/(2+e),n=4*r-2;let s=0,a=0,u;for(let l=o.length-1;l>0;l--)u=s,s=n*s-a+o[l],a=u;const c=r*Math.exp(-e*e+.5*(o[0]+n*s)-a);return t?c-1:1-c}function ta(i){return 1-Ft(i)}function Am(i){if(i>=2)return-100;if(i<=0)return 100;const o=i<1?i:2-i,e=Math.sqrt(-2*Math.log(o/2));let t=-.70711*((2.30753+e*.27061)/(1+e*(.99229+e*.04481))-e);for(let r=0;r<2;r++){const n=ta(t)-o;t+=n/(1.1283791670955126*Math.exp(-t*t)-t*n)}return i<1?t:-t}function tr(i,o=1){let e=Math.floor(i);if(i<0)return Number.NaN;let t=1;for(;e>1&&Number.isFinite(t);)t*=e,e-=o;return t}function kt(i,o){const e=Math.min(i-o,o);let t=1;for(let r=1;r<=e&&Number.isFinite(t);r++)t*=i-r+1,t/=r;return t}function Ss(i,o){let e=Math.floor(i),t=Math.floor(o);for(;t!==0;){const r=t;t=e%t,e=r}return e}function Ja(i,o){const e=Ss(i,o);return e===0?0:Math.abs(i*o)/e}function Tn(i){const o=i.length;if(o===1)return i[0][0];if(o===2)return i[0][0]*i[1][1]-i[0][1]*i[1][0];let e=0;for(let t=0;t<o;t++)e+=(t%2===0?1:-1)*i[0][t]*Tn(lo(i,0,t));return e}function Em(i){const o=Tn(i);return o===0?null:i.length===1?[[1/o]]:bm(i).map(r=>r.map(n=>n/o))}function lo(i,o,e){return i.filter((t,r)=>r!==o).map(t=>t.filter((r,n)=>n!==e))}function bm(i){const o=i.length,e=Array.from({length:o},()=>new Array(o).fill(0));for(let t=0;t<o;t++)for(let r=0;r<o;r++){const n=(t+r)%2===0?1:-1;e[r][t]=n*Tn(lo(i,t,r))}return e}function rr(i,o){return i.map(e=>o[0].map((t,r)=>e.reduce((n,s,a)=>n+s*o[a][r],0)))}function st(i){return i[0].map((o,e)=>i.map(t=>t[e]))}function ym(i){const{smallPivotDetected:o,luMatrix:e,permutation:t}=Rm(i);return o?null:pm(e,t)}function Rm(i){const o=st(i),e=o.length,t=o[0].length;let r=!0,n=!1;const s=Ds(e,t,0),a=new Array(t).fill(0).map((u,c)=>c);for(let u=0;u<t;u++){for(let m=0;m<u;m++){let d=o[m][u];for(let _=0;_<m;_++)d-=s[m][_]*s[_][u];s[m][u]=d}let c=-1/0,l=u;for(let m=u;m<e;m++){let d=o[m][u];for(let C=0;C<u;C++)d-=s[m][C]*s[C][u];s[m][u]=d;const _=Math.abs(d);_>c&&(c=_,l=m)}if(Math.abs(s[l][u])<1e-11){n=!0;break}l!==u&&([s[u],s[l]]=[s[l],s[u]],[o[u],o[l]]=[o[l],o[u]],[a[u],a[l]]=[a[l],a[u]],r=!r);const f=s[u][u];for(let m=u+1;m<e;m++)s[m][u]/=f}return{rowSwap:r,smallPivotDetected:n,luMatrix:s,permutation:a}}function pm(i,o){const e=o.length,t=Ds(e,e,0);for(let n=0;n<e;n++)t[n][n]=1;const r=Ds(e,e,0);for(let n=0;n<e;n++){const s=o[n];for(let a=0;a<e;a++)r[n][a]=t[s][a]}for(let n=0;n<e;n++){const s=r[n];for(let a=n+1;a<e;a++){const u=i[a][n];for(let c=0;c<e;c++)r[a][c]-=s[c]*u}}for(let n=e-1;n>=0;n--){const s=r[n],a=i[n][n];for(let u=0;u<e;u++)s[u]/=a;for(let u=0;u<n;u++){const c=i[u][n];for(let l=0;l<e;l++)r[u][l]-=s[l]*c}}return r}function Ds(i,o,e){const t=[];for(let r=0;r<i;r++){t[r]=[];for(let n=0;n<o;n++)t[r].push(e)}return t}function Nm(i){const o=Vm(i);if(!o)return null;const{matrixU:e,matrixS:t,matrixV:r}=o,n=st(e),s=Array.from({length:t.length},()=>new Array(i[0].length).fill(0)),a=Math.max(i.length,i[0].length)*Number.EPSILON*t[0];for(let u=0;u<t.length;u++)Math.abs(t[u])>a&&(s[u][u]=1/t[u]);return rr(r,rr(s,n))}function Vm(i){const o=st(i),e=o.length,t=o[0].length;if(e<t)return null;const r=new Array(t).fill(0),n=new Array(t).fill(0),s=Array.from({length:t},()=>new Array(t).fill(0));let a=Number.EPSILON,u=0,c=0,l=0;for(let C=0;C<t;C++){if(r[C]=u,c=ns(o,C,e,C,C),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[C][C]>=0&&(u=-u);const b=o[C][C]*u-c;o[C][C]-=u;for(let R=C+1;R<t;R++){c=ns(o,C,e,C,R);for(let p=C;p<e;p++)o[p][R]+=c/b*o[p][C]}}if(n[C]=u,c=ei(o,C+1,t,C,C),c<=1e-64/a)u=0;else{u=Math.sqrt(c),o[C][C+1]>=0&&(u=-u);const b=o[C][C+1]*u-c;o[C][C+1]-=u;for(let R=C+1;R<t;R++)r[R]=o[C][R]/b;for(let R=C+1;R<e;R++){c=ei(o,C+1,t,R,C);for(let p=C+1;p<t;p++)o[R][p]+=c*r[p]}}const E=Math.abs(n[C])+Math.abs(r[C]);E>l&&(l=E)}let f=0;for(let C=t-1;C>=0;C--){if(u!==0){for(let E=f;E<t;E++)s[E][C]=o[C][E]/(u*o[C][C+1]);for(let E=f;E<t;E++){c=0;for(let b=f;b<t;b++)c+=o[C][b]*s[b][E];for(let b=f;b<t;b++)s[b][E]+=c*s[b][C]}}for(let E=f;E<t;E++)s[C][E]=0,s[E][C]=0;s[C][C]=1,u=r[C],f=C}for(let C=t-1;C>=0;C--){u=n[C];for(let E=C+1;E<t;E++)o[C][E]=0;if(u!==0){for(let E=C+1;E<t;E++){c=ns(o,C+1,e,C,E);for(let b=C;b<e;b++)o[b][E]+=c/(o[C][C]*u)*o[b][C]}for(let E=C;E<e;E++)o[E][C]/=u}else for(let E=C;E<e;E++)o[E][C]=0;o[C][C]+=1}a*=l;let m=0,d=0,_=0;for(let C=t-1;C>=0;C--)for(let E=0;E<50;E++){let b=!1,R=C;for(;R>=0;R--){if(Math.abs(r[R])<=a){b=!0;break}if(Math.abs(n[R-1])<=a)break}if(!b){let D=0,w=1;for(let P=R;P<C+1&&(m=w*r[P],d=n[P],r[P]*=D,!(Math.abs(m)<=a));P++){_=Tr(m,d),n[P]=_,D=d/_,w=-m/_;for(let L=0;L<e;L++){const B=o[L][R-1],j=o[L][P];o[L][R-1]=B*D+j*w,o[L][P]=-B*w+j*D}}}if(R===C){if(n[C]<0){n[C]=-n[C];for(let D=0;D<t;D++)s[D][C]=-s[D][C]}break}if(E>=49)return null;let p=n[R];m=((n[C-1]-n[C])*(n[C-1]+n[C])+(r[C-1]-r[C])*(r[C-1]+r[C]))/(2*r[C]*n[C-1]),_=Tr(m,1),m<0?m=((p-n[C])*(p+n[C])+r[C]*(n[C-1]/(m-_)-r[C]))/p:m=((p-n[C])*(p+n[C])+r[C]*(n[C-1]/(m+_)-r[C]))/p;let V=1,M=1;for(let D=R+1;D<C+1;D++){let w=r[D],P=n[D];d=M*w,w*=V,_=Tr(m,d),r[D-1]=_,V=m/_,M=d/_,m=p*V+w*M,d=P*M,w=-p*M+w*V,P*=V;for(let L=0;L<t;L++){const B=s[L][D-1],j=s[L][D];s[L][D-1]=B*V+j*M,s[L][D]=-B*M+j*V}_=Tr(m,d),n[D-1]=_,V=m/_,M=d/_,m=V*w+M*P,p=-M*w+V*P;for(let L=0;L<e;L++){const B=o[L][D-1],j=o[L][D];o[L][D-1]=B*V+j*M,o[L][D]=-B*M+j*V}}r[R]=0,r[C]=m,n[C]=p}for(let C=0;C<n.length;C++)n[C]<a&&(n[C]=0);for(let C=0;C<t;C++)for(let E=C-1;E>=0;E--)if(n[E]<n[C]){const b=n[E];n[E]=n[C],n[C]=b;for(let R=0;R<o.length;R++){const p=o[R][C];o[R][C]=o[R][E],o[R][E]=p}for(let R=0;R<s.length;R++){const p=s[R][C];s[R][C]=s[R][E],s[R][E]=p}C=E}return{matrixU:o,matrixS:n,matrixV:s}}function Tr(i,o){let e=0;return Math.abs(i)>Math.abs(o)?(e=o/i,Math.abs(i)*Math.sqrt(1+e*e)):o!==0?(e=i/o,Math.abs(o)*Math.sqrt(1+e*e)):0}function ns(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[s][t]*i[s][r];return n}function ei(i,o,e,t,r){let n=0;for(let s=o;s<e;s++)n+=i[t][s]*i[r][s];return n}const vr=new Map([["I",1],["V",5],["X",10],["L",50],["C",100],["D",500],["M",1e3]]),Om=new Map([[1,"I"],[4,"IV"],[5,"V"],[9,"IX"],[10,"X"],[40,"XL"],[45,"VL"],[49,"IL"],[50,"L"],[90,"XC"],[95,"VC"],[99,"IC"],[100,"C"],[400,"CD"],[450,"LD"],[490,"XD"],[495,"VD"],[499,"ID"],[500,"D"],[900,"CM"],[950,"LM"],[990,"XM"],[995,"VM"],[999,"IM"],[1e3,"M"]]),Mm=[[1,4,5,9,10,40,50,90,100,400,500,900,1e3,4e3],[1,4,5,9,10,40,45,50,90,95,100,400,450,500,900,950,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,500,900,950,990,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,500,900,950,990,995,1e3,4e3],[1,4,5,9,10,40,45,49,50,90,95,99,100,400,450,490,495,499,500,900,950,990,995,999,1e3,4e3]];function fo(i,o,e){return i<=0?0:i>=1?1:vn(i,o,e)}function Sm(i,o,e){return i<=0||i>=1?0:o===1&&e===1?1:o<512&&e<512?i**(o-1)*(1-i)**(e-1)/na(o,e):Math.exp((o-1)*Math.log(i)+(e-1)*Math.log(1-i)-sa(o,e))}function ra(i,o,e){if(i<=0)return 0;if(i>=1)return 1;const t=1e-8;let r;if(o>=1&&e>=1){const c=i<.5?i:1-i,l=Math.sqrt(-2*Math.log(c));r=(2.30753+l*.27061)/(1+l*(.99229+l*.04481))-l,i<.5&&(r=-r);const f=(r*r-3)/6,m=2/(1/(2*o-1)+1/(2*e-1)),d=r*Math.sqrt(f+m)/m-(1/(2*e-1)-1/(2*o-1))*(f+5/6-2/(3*m));r=o/(o+e*Math.exp(2*d))}else{const c=Math.exp(o*Math.log(o/(o+e)))/o,l=Math.exp(e*Math.log(e/(o+e)))/e,f=c+l;i<c/f?r=(o*f*i)**(1/o):r=1-(e*f*(1-i))**(1/e)}const n=-sa(o,e);let s,a,u;for(let c=0;c<10;c++){if(r===0||r===1)return r;if(s=vn(r,o,e)-i,a=Math.exp((o-1)*Math.log(r)+(e-1)*Math.log(1-r)+n),u=s/a,r-=a=u/(1-.5*Math.min(1,u*((o-1)/r-(e-1)/(1-r)))),r<=0&&(r=.5*(r+a)),r>=1&&(r=.5*(r+a+1)),Math.abs(a)<t*r&&c>0)break}return r}function vn(i,o,e){const t=i===0||i===1?0:Math.exp(rt(o+e)-rt(o)-rt(e)+o*Math.log(i)+e*Math.log(1-i));return i<(o+1)/(o+e+2)?t*ti(i,o,e)/o:1-t*ti(1-i,e,o)/e}function ti(i,o,e){let n=1-(o+e)*i/(o+1);Math.abs(n)<1e-8&&(n=1e-8),n=1/n;let s=1,a=n;for(let u=1;u<=100;u++){let c=u*(e-u)*i/((o-1+u*2)*(o+u*2));if(n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,c=-(o+u)*(o+e+u)*i/((o+u*2)*(o+1+u*2)),n=1+c*n,Math.abs(n)<1e-8&&(n=1e-8),s=1+c/s,Math.abs(s)<1e-8&&(s=1e-8),n=1/n,a*=n*s,Math.abs(n*s-1)<1e-8)break}return a}function na(i,o){return i+o>170?Math.exp(sa(i,o)):Wr(i)*Wr(o)/Wr(i+o)}function sa(i,o){return rt(i)+rt(o)-rt(i+o)}function mo(i,o,e){if(i<0)return 0;if(i>=o)return 1;if(e<0||e>1||o<=0)return Number.NaN;let t=0;for(let r=0;r<=i;r++)t+=aa(r,o,e);return t}function aa(i,o,e){return e===0||e===1?o*e===i?1:0:kt(o,i)*e**i*(1-e)**(o-i)}function ia(i,o){return i<=0?0:ua(o/2,i/2)}function Dm(i,o){return i<0?0:i===0&&o===2?.5:Math.exp((o/2-1)*Math.log(i)-i/2-o/2*Math.log(2)-rt(o/2))}function ho(i,o){return i<=0?0:i>=1?1/0:2*_o(i,o/2)}function oa(i,o,e){return i<0?0:vn(o*i/(o*i+e),o/2,e/2)}function wm(i,o,e){if(i<0)return 0;if(i===0&&o<2)return 1/0;if(i===0&&o===2)return 1;let t=1/na(o/2,e/2);return t*=(o/e)**(o/2),t*=i**(o/2-1),t*=(1+o/e*i)**(-(o+e)/2),t}function go(i,o,e){return i<=0?0:i>=1?1/0:e/(o*(1/ra(i,o/2,e/2)-1))}function Pm(i,o){return i<0?0:1-Math.exp(-o*i)}function Lm(i,o){return i<0?0:o*Math.exp(-o*i)}function Co(i,o,e){const t=o.length;let r=0,n=0;for(let m=0;m<t;m++)r+=o[m],n+=e[m];const s=r/t,a=n/t;let u=0,c=0;for(let m=0;m<t;m++)u+=(o[m]-s)*(e[m]-a),c+=(e[m]-a)**2;if(c===0)return 1/0;const l=u/c;return s-l*a+l*i}function Wr(i){const o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],e=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535];let t=0,r=i;if(i>171.6243769536076)return 1/0;if(r<=0){const f=r%1+36e-17;if(f)t=(r&1?-1:1)*Math.PI/Math.sin(Math.PI*f),r=1-r;else return 1/0}const n=r;let s=0,a;r<1?a=r++:a=(r-=s=(r|0)-1)-1;let u=0,c=0;for(let f=0;f<8;++f)u=(u+o[f])*a,c=c*a+e[f];let l=u/c+1;if(n<r)l/=n;else if(n>r)for(let f=0;f<s;++f)l*=r,r++;return t&&(l=t/l),l}function xm(i,o,e){return i<=0?0:ua(o,i/e)}function jm(i,o,e){return i<0?0:i===0&&o===1?1/e:Math.exp((o-1)*Math.log(i)-i/e-rt(o)-o*Math.log(e))}function Um(i,o,e){return i<=0?0:i>=1?1/0:e*_o(i,o)}function rt(i){const o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];let e=i,t=i+5.5;t-=(i+.5)*Math.log(t);let r=1.000000000190015;for(let n=0;n<6;n++)r+=o[n]/++e;return-t+Math.log(2.5066282746310007*r/i)}function ua(i,o){if(o<0||i<=0)return Number.NaN;const e=1e-30,t=-~(Math.log(i>=1?i:1/i)*8.5+i*.4+17),r=rt(i),n=Math.exp(-o+i*Math.log(o)-r);let s=i,a=1/i,u=a;if(o<i+1){if(n===0)return 0;for(let d=1;d<=t&&(a+=u*=o/++s,!(Math.abs(u)<Math.abs(a)*e));d++);return a*n}if(n===0)return 1;let c=o+1-i,l=1/e,f=1/c,m=f;for(let d=1;d<=t;d++){const _=-d*(d-i);if(c+=2,f=_*f+c,Math.abs(f)<e&&(f=e),l=c+_/l,Math.abs(l)<e&&(l=e),f=1/f,m*=f*l,Math.abs(f*l-1)<e)break}return 1-m*n}function _o(i,o){if(i<=0)return 0;if(i>=1)return Math.max(100,o+100*Math.sqrt(o));let e;if(o>1){const a=i<.5?i:1-i,u=Math.sqrt(-2*Math.log(a));e=(2.30753+u*.27061)/(1+u*(.99229+u*.04481))-u,i<.5&&(e=-e),e=Math.max(.001,o*(1-1/(9*o)-e/(3*Math.sqrt(o)))**3)}else{const a=1-o*(.253+o*.12);i<a?e=(i/a)**(1/o):e=1-Math.log(1-(i-a)/(1-a))}const t=1e-8,r=rt(o);let n,s;for(let a=0;a<12;a++){if(e<=0)return 0;if(n=ua(o,e)-i,o>1?s=Math.exp((o-1)*(Math.log(o-1)-1)-r)*Math.exp(-(e-(o-1))+(o-1)*(Math.log(e)-Math.log(o-1))):s=Math.exp(-e+(o-1)*Math.log(e)-r),s!==0&&(s=n/s/(1-.5*Math.min(1,n/s*((o-1)/e-1)))),e-=s,e<=0&&(e=.5*(e+s)),Math.abs(s)<t*e)break}return e}function Tm(i,o,e,t){let r=0;for(let n=0;n<=i;n++)r+=ca(n,o,e,t);return r}function ca(i,o,e,t){return o-i>t-e?0:kt(e,i)*kt(t-e,o-i)/kt(t,o)}function Ao(i,o,e){return i<0?0:.5+.5*Ft((Math.log(i)-o)/Math.sqrt(2*e*e))}function vm(i,o,e){return i<=0?0:Math.exp(-Math.log(i)-.5*Math.log(2*Math.PI)-Math.log(e)-(Math.log(i)-o)**2/(2*e*e))}function Bm(i,o,e){return Math.exp(Bn(i,o,e))}function Im(i,o,e){if(i<0)return 0;let t=0;for(let r=0;r<=i;r++)t+=la(r,o,e);return t}function la(i,o,e){return i<0?0:kt(i+o-1,o-1)*e**o*(1-e)**i}function Sr(i,o,e){return .5*(1+Ft((i-o)/Math.sqrt(2*e*e)))}function Eo(i,o,e){return Math.exp(-.5*Math.log(2*Math.PI)-Math.log(e)-(i-o)**2/(2*e*e))}function Bn(i,o,e){return-1.4142135623730951*e*Am(2*i)+o}function Fm(i,o){let e=0;for(let t=0;t<=i;t++)e+=bo(t,o);return e}function bo(i,o){return Math.exp(-o)*o**i/tr(i)}function Dr(i,o){const e=.5*vn(o/(i**2+o),o/2,.5);return i<0?e:1-e}function km(i,o){const e=(1+i**2/o)**(-(o+1)/2);return 1/(Math.sqrt(o)*na(.5,o/2))*e}function In(i,o){let e=ra(2*Math.min(i,1-i),.5*o,.5);return e=Math.sqrt(o*(1-e)/e),i>.5?e:-e}function Ge(i,o,e,t,r){const n=[],s=[];let a=!0;for(let u=0;u<e;u++){const c=Math.floor(u/t),l=u%t,f=Math.floor(u/r),m=u%r,d=i.isArray()?i.get(c,l):i,_=o.isArray()?o.get(f,m):o;if(d.isError())return{isError:!0,errorObject:d,array1Values:n,array2Values:s,noCalculate:a};if(_.isError())return{isError:!0,errorObject:_,array1Values:n,array2Values:s,noCalculate:a};if(d.isNull()||_.isNull()||d.isBoolean()||_.isBoolean())continue;const C=d.getValue(),E=_.getValue();!S.isRealNum(C)||!S.isRealNum(E)||(n.push(+C),s.push(+E),a=!1)}return{isError:!1,errorObject:null,array1Values:n,array2Values:s,noCalculate:a}}function Fn(i,o,e){const t=i.isArray()?i.getRowCount():1,r=i.isArray()?i.getColumnCount():1;let n=t,s=r;if(o&&!o.isNull()&&(n=o.isArray()?o.getRowCount():1,s=o.isArray()?o.getColumnCount():1,t===1&&s!==r||r===1&&n!==t||t!==1&&r!==1&&(n!==t||s!==r)))return{isError:!0,errorObject:g.create(h.REF)};if(e&&!e.isNull()){const a=e.isArray()?e.getRowCount():1,u=e.isArray()?e.getColumnCount():1;if(t===1&&n>1&&a!==n||r===1&&s>1&&u!==s)return{isError:!0,errorObject:g.create(h.REF)}}return{isError:!1,errorObject:null}}function at(i){const o=i.isArray()?i.getRowCount():1,e=i.isArray()?i.getColumnCount():1,t=[];for(let r=0;r<o;r++){t[r]=[];for(let n=0;n<e;n++){const s=i.isArray()?i.get(r,n):i;if(s.isError()||s.isNull()||s.isBoolean()||s.isString())return g.create(h.VALUE);t[r].push(+s.getValue())}}return t}function kn(i,o){const e=[];let t=1;for(let r=0;r<i;r++){e[r]=[];for(let n=0;n<o;n++)e[r].push(t++)}return e}function $n(i,o,e,t){let r=o;t&&(r=o.map(a=>Math.log(a)));let n,s;return e?{slope:n,intercept:s}=$m(i,r):{slope:n,intercept:s}=Ym(i,r),t&&(n=Math.exp(n),s=Math.exp(s)),Number.isNaN(n)&&!e&&(n=0),{slope:n,intercept:s,Y:r}}function $m(i,o){const e=o.length;let t=0,r=0,n=0,s=0;for(let l=0;l<e;l++)t+=i[l],r+=o[l],n+=i[l]*i[l],s+=i[l]*o[l];const u=(e*s-t*r)/(e*n-t*t),c=1/e*r-u*(1/e)*t;return{slope:u,intercept:c}}function Ym(i,o){const e=[[...i]],t=[...o];let r=e.length,n=e[0].length,s=Math.min(r,n);const a=new Array(s).fill(0);for(let c=0;c<s;c++){const l=e[c];let f=0;for(let d=0;d<n;d++)f+=l[d]**2;const m=l[c]<0?Math.sqrt(f):-Math.sqrt(f);if(a[c]=m,m!==0){l[c]-=m;for(let d=c+1;d<r;d++){let _=0;for(let C=c;C<n;C++)_-=e[d][C]*l[C];_/=m*l[c];for(let C=c;C<n;C++)e[d][C]-=_*l[C]}}}r=e.length,n=e[0].length,s=Math.min(r,n);const u=new Array(r).fill(0);for(let c=0;c<s;c++){const l=e[c];let f=0;for(let m=0;m<n;m++)f+=t[m]*l[m];f/=a[c]*l[c];for(let m=0;m<n;m++)t[m]+=f*l[m]}for(let c=a.length-1;c>=0;c--){t[c]/=a[c];const l=t[c],f=e[c];u[c]=l;for(let m=0;m<c;m++)t[m]-=l*f[m]}return{slope:u[0],intercept:0}}function Yn(i,o,e,t,r){const n=i.length===1&&i[0].length>1;let s=i;r&&(s=i.map(C=>C.map(E=>Math.log(E))));let a=o,u=e;n&&(s=st(s),a=st(a),u=st(u)),t&&(a=a.map(C=>[...C,1]));const c=st(a),l=rr(c,a),f=rr(c,s);let m=ym(l);if(!m&&(m=Nm(l),!m))return g.create(h.NA);let d=rr(m,f);t||d.push([0]),d=st(d);const _=d[0].pop();if(d[0].reverse(),d[0].push(_),r)for(let C=0;C<d[0].length;C++)d[0][C]=Math.exp(d[0][C]);return{coefficients:d,Y:s,X:a,newX:u,XTXInverse:m}}class yo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p);return this._handleSignleObject(b,V,M,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=F(e,t,r,n,s);if(a)return u;const[l,f,m,d,_]=c,C=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+_.getValue();if(E<=0||b<=0||C<=0||C>=1||R>=p)return g.create(h.NUM);const V=ra(C,E,b)*(p-R)+R;return y.create(V)}}class Ro extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),_=Math.floor(+l.getValue()),C=+f.getValue(),E=+m.getValue();if(d<0||d>_||C<0||C>1)return g.create(h.NUM);let b;return E?b=mo(d,_,C):b=aa(d,_,C),y.create(b)}}class po extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0||m>=1||d<=0||d>=1)return g.create(h.NUM);let _=0;for(;_<=f&&!(mo(_,f,m)>=d);)_++;return y.create(_)}}class No extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=1-ia(c,l);return y.create(f)}}class Vo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=ho(1-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Oo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.NA);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d,r,n)}_getResult(e,t,r,n){let s=0;for(let c=0;c<e.length;c++){if(t[c]===0)return g.create(h.DIV_BY_ZERO);s+=(e[c]-t[c])**2/t[c]}let a=(r-1)*(n-1);r===1?a=n-1:n===1&&(a=r-1);const u=1-ia(s,a);return y.create(u)}}class Mo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);if(f.isError())return f;if(_.isError())return _;if(C.isError())return C;const{isError:E,errorObject:b,variants:R}=F(f,_,C);if(E)return b;const[p,V,M]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+M.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);const L=Math.abs(Bn(D/2,0,1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class So extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/r)}}class Do extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||m<=0)return g.create(h.NUM);let _;return d?_=Pm(f,m):_=Lm(f,m),y.create(_)}}class wo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const _=1-oa(f,m,d);return y.create(_)}}class Po extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const _=go(1-f,m,d);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}class Lo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variance:s,ns1:a}=this._getValues(e);if(r)return n;const{isError:u,errorObject:c,variance:l,ns1:f}=this._getValues(t);if(u)return c;let m=2*(1-oa(s/l,a,f));return m>1&&(m=2-m),y.create(m)}_getValues(e){let t=0,r=0;const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;if(n===1&&s===1){const f=e.isArray()?e.get(0,0):e;return f.isError()?{isError:!0,errorObject:f,variance:t,ns1:r}:f.isNull()?{isError:!0,errorObject:g.create(h.VALUE),variance:t,ns1:r}:{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}}const a=[];let u=0;for(let f=0;f<n;f++)for(let m=0;m<s;m++){const d=e.isArray()?e.get(f,m):e;if(d.isError())return{isError:!0,errorObject:d,variance:t,ns1:r};if(d.isNull()||d.isBoolean())continue;const _=d.getValue();S.isRealNum(_)&&(a.push(+_),u+=+_)}if(a.length<=1)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r};const c=u/a.length;let l=0;for(let f=0;f<a.length;f++)l+=(a[f]-c)**2;return r=a.length-1,t=l/r,t===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),variance:t,ns1:r}:{isError:!1,errorObject:null,variance:t,ns1:r}}}class xo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),_=+l.getValue(),C=+f.getValue(),E=+m.getValue();if(d<0||_<=0||C<=0)return g.create(h.NUM);let b;return E?b=xm(d,_,C):b=jm(d,_,C),y.create(b)}}class jo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<0||f>1||m<=0||d<=0)return g.create(h.NUM);const _=Um(f,m,d);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}class Uo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const _=Bm(f,m,d);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}class To extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();S.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return y.create(r[0])}}class vo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),_=+l.getValue(),C=+f.getValue(),E=+m.getValue();if(C<=0)return g.create(h.NUM);let b;return E?b=Sr(d,_,C):b=Eo(d,_,C),y.create(b)}}class Bo extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||f>=1||d<=0)return g.create(h.NUM);const _=Bn(f,m,d);return y.create(_)}}class Io extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0||a>=1)return g.create(h.NUM);const u=Bn(a,0,1);return y.create(u)}}class Fo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<0||u>1)return g.create(h.NUM);const l=u*(c-1),f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class ko extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,_)=>{const C=l.get(d,_);return m.isError()?m:C.isError()?C:this._handleSingleObject(n,m,C)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=F(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,_=!1,C=0;for(;!_&&C<m;)l===e[C]?(d=C/(m-1),_=!0):l>e[C]&&C+1<m&&l<e[C+1]&&(d=(C+(l-e[C])/(e[C+1]-e[C]))/(m-1),_=!0),C++;return _?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class $o extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=+c.getValue(),d=+l.getValue();if(f<0||m<0)return g.create(h.NUM);let _;return d?_=Fm(f,m):_=bo(f,m),y.create(_)}}class Yo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>4)return g.create(h.NUM);const c=u/4,l=e.length,f=c*(l-1),m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const _=e[m]+d*(e[m+1]-e[m]);return y.create(_)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class Ho extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std()}}class Go extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.std(1)}}class Wo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=Math.abs(In(c/2,l));return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Qo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,array1Values:u,array2Values:c}=this._handleArray1AndArray2(e,t),l=this._getArrayValues(e),f=this._getArrayValues(t),m=Math.max(r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),d=Math.max(r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),_=O(m,d,r,g.create(h.NA)),C=O(m,d,n,g.create(h.NA)),E=_.mapValue((b,R,p)=>{const V=C.get(R,p);if(e.isError())return e;if(t.isError())return t;if(b.isError())return b;if(V.isError())return V;const{isError:M,errorObject:D,variants:w}=F(b,V);if(M)return D;const[P,L]=w,B=Math.floor(+P.getValue()),j=Math.floor(+L.getValue());return![1,2].includes(B)||![1,2,3].includes(j)?g.create(h.NUM):j===1&&s?a:j!==1&&l instanceof g?l:j!==1&&f instanceof g?f:this._handleSignleObject(j===1?u:l,j===1?c:f,B,j)});return m===1&&d===1?E.get(0,0):E}_handleSignleObject(e,t,r,n){if(e.length<2||t.length<2)return g.create(h.DIV_BY_ZERO);const{isError:s,errorObject:a,x:u,degFreedom:c}=this._getTDistParamByArrayValues(e,t,n);if(s)return a;let l=Dr(-u,c);return r===2&&(l*=2),Number.isNaN(l)||!Number.isFinite(l)?g.create(h.NUM):y.create(l)}_getArrayValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()){if(t*r===1)return g.create(h.VALUE);continue}u.isBoolean()||u.isString()||n.push(+u.getValue())}return n}_handleArray1AndArray2(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,array1Values:[],array2Values:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,array1Values:[],array2Values:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),array1Values:[],array2Values:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),array1Values:[],array2Values:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,array1Values:[],array2Values:[]}:_||m.length<2?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),array1Values:[],array2Values:[]}:{isError:!1,errorObject:null,array1Values:m,array2Values:d}}_getTDistParamByArrayValues(e,t,r){return r===1?this._getTDistParamByType1(e,t):r===2?this._getTDistParamByType2(e,t):this._getTDistParamByType3(e,t)}_getTDistParamByType1(e,t){const r=e.length;let n=0,s=0,a=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m],a+=(e[m]-t[m])**2;const u=n-s,c=r*a-u**2,l=r-1;return c===0?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:l}:{isError:!1,errorObject:null,x:Math.abs(u)*Math.sqrt(l/c),degFreedom:l}}_getTDistParamByType2(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let E=0;E<r;E++)s+=e[E],a+=e[E]**2;let u=0,c=0;for(let E=0;E<n;E++)u+=t[E],c+=t[E]**2;const l=a-s**2/r,f=c-u**2/n,m=Math.sqrt(l+f);if(m===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const d=r-1+n-1,_=Math.sqrt(r*n*d/(r+n));return{isError:!1,errorObject:null,x:Math.abs(s/r-u/n)/m*_,degFreedom:d}}_getTDistParamByType3(e,t){const r=e.length,n=t.length;let s=0,a=0;for(let C=0;C<r;C++)s+=e[C],a+=e[C]**2;let u=0,c=0;for(let C=0;C<n;C++)u+=t[C],c+=t[C]**2;const l=(a-s**2/r)/(r*(r-1)),f=(c-u**2/n)/(n*(n-1));if(l+f===0)return{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),x:0,degFreedom:0};const m=l/(l+f),d=Math.abs(s/r-u/n)/Math.sqrt(l+f),_=1/(m**2/(r-1)+(1-m)**2/(n-1));return{isError:!1,errorObject:null,x:d,degFreedom:_}}}class qo extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var()}}class Ko extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e);return t.isError()?t:t.var(1)}}class Xo extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),_=+l.getValue(),C=+f.getValue(),E=+m.getValue();if(d<0||_<=0||C<=0)return g.create(h.NUM);const b=Math.exp(-((d/C)**_));let R;return E?R=1-b:R=_/C**_*d**(_-1)*b,Number.isNaN(R)||!Number.isFinite(R)?g.create(h.NUM):y.create(R)}}class Zo extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getArrayValues(e),s=Math.max(t.isArray()?t.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(t.isArray()?t.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,t,g.create(h.NA)),c=r?O(s,a,r,g.create(h.NA)):void 0,l=u.mapValue((f,m,d)=>{if(n instanceof g)return n;if(f.isError())return f;const _=r?c.get(m,d):void 0;return _!=null&&_.isError()?_:n.length===0?g.create(h.NA):n.length===1?g.create(h.DIV_BY_ZERO):this._handleSignleObject(n,f,_)});return s===1&&a===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.length;let f=0,m=0;for(let E=0;E<l;E++)f+=e[E],m+=e[E]**2;let d=0;if(r!==void 0){const{isError:E,errorObject:b,variants:R}=F(r);if(E)return b;const[p]=R;d=+p.getValue()}else{const E=f/l;d=Math.sqrt((m-2*E*f+l*E**2)/(l-1))}if(d<=0)return g.create(h.NUM);const _=(f/l-c)/(d/Math.sqrt(l)),C=1-Sr(_,0,1);return Number.isNaN(C)||!Number.isFinite(C)?g.create(h.NUM):y.create(C)}_getArrayValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();S.isRealNum(c)&&t.push(+c)}return t}}class Hm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=n!=null?n:y.create(0),u=s!=null?s:y.create(1);a.isNull()&&(a=y.create(0)),u.isNull()&&(u=y.create(1));const c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.mapValue((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p);return this._handleSignleObject(b,V,M,D,w)});return c===1&&l===1?E.get(0,0):E}_handleSignleObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;const{isError:a,errorObject:u,variants:c}=F(e,t,r,n,s);if(a)return u;const[l,f,m,d,_]=c,C=+l.getValue(),E=+f.getValue(),b=+m.getValue(),R=+d.getValue(),p=+_.getValue();if(E<=0||b<=0||C<R||C>p||R===p)return g.create(h.NUM);const V=fo((C-R)/(p-R),E,b);return y.create(V)}}var fe=(i=>(i.BETADIST="BETADIST",i.BETAINV="BETAINV",i.BINOMDIST="BINOMDIST",i.CHIDIST="CHIDIST",i.CHIINV="CHIINV",i.CHITEST="CHITEST",i.CONFIDENCE="CONFIDENCE",i.COVAR="COVAR",i.CRITBINOM="CRITBINOM",i.EXPONDIST="EXPONDIST",i.FDIST="FDIST",i.FINV="FINV",i.FTEST="FTEST",i.GAMMADIST="GAMMADIST",i.GAMMAINV="GAMMAINV",i.HYPGEOMDIST="HYPGEOMDIST",i.LOGINV="LOGINV",i.LOGNORMDIST="LOGNORMDIST",i.MODE="MODE",i.NEGBINOMDIST="NEGBINOMDIST",i.NORMDIST="NORMDIST",i.NORMINV="NORMINV",i.NORMSDIST="NORMSDIST",i.NORMSINV="NORMSINV",i.PERCENTILE="PERCENTILE",i.PERCENTRANK="PERCENTRANK",i.POISSON="POISSON",i.QUARTILE="QUARTILE",i.RANK="RANK",i.STDEV="STDEV",i.STDEVP="STDEVP",i.TDIST="TDIST",i.TINV="TINV",i.TTEST="TTEST",i.VAR="VAR",i.VARP="VARP",i.WEIBULL="WEIBULL",i.ZTEST="ZTEST",i))(fe||{});class Gm extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),_=Math.floor(+l.getValue()),C=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||d>_||d>C||d<_-E+C||_<=0||_>E||C<=0||C>E||E<=0)return g.create(h.NUM);let b=ca(d,_,C,E);return Number.isNaN(b)&&(b=0),y.create(b)}}class Wm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(f<=0||d<=0)return g.create(h.NUM);const _=Ao(f,m,d);return y.create(_)}}class Qm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||d<=0||d>=1)return g.create(h.NUM);const _=la(f,m,d);return y.create(_)}}class qm extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSignleObject(r));return e.getRowCount()===1&&e.getColumnCount()===1?t.get(0,0):t}return this._handleSignleObject(e)}_handleSignleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Sr(a,0,1);return y.create(u)}}class Km extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),_=m.map((C,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+C.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?_.get(0,0):_}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class Xm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||m<1||m>10**10||d<1||d>2)return g.create(h.NUM);let _=Dr(-f,m);return d===2&&(_*=2),Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}const zo=[[Hm,fe.BETADIST],[yo,fe.BETAINV],[Ro,fe.BINOMDIST],[No,fe.CHIDIST],[Vo,fe.CHIINV],[Oo,fe.CHITEST],[Mo,fe.CONFIDENCE],[So,fe.COVAR],[po,fe.CRITBINOM],[Do,fe.EXPONDIST],[wo,fe.FDIST],[Po,fe.FINV],[Lo,fe.FTEST],[xo,fe.GAMMADIST],[jo,fe.GAMMAINV],[Gm,fe.HYPGEOMDIST],[Wm,fe.LOGNORMDIST],[Uo,fe.LOGINV],[To,fe.MODE],[Qm,fe.NEGBINOMDIST],[vo,fe.NORMDIST],[Bo,fe.NORMINV],[qm,fe.NORMSDIST],[Io,fe.NORMSINV],[Fo,fe.PERCENTILE],[ko,fe.PERCENTRANK],[$o,fe.POISSON],[Yo,fe.QUARTILE],[Km,fe.RANK],[Go,fe.STDEV],[Ho,fe.STDEVP],[Xm,fe.TDIST],[Wo,fe.TINV],[Qo,fe.TTEST],[Ko,fe.VAR],[qo,fe.VARP],[Xo,fe.WEIBULL],[Zo,fe.ZTEST]],Jo=[];var eu=(i=>(i.CUBEKPIMEMBER="CUBEKPIMEMBER",i.CUBEMEMBER="CUBEMEMBER",i.CUBEMEMBERPROPERTY="CUBEMEMBERPROPERTY",i.CUBERANKEDMEMBER="CUBERANKEDMEMBER",i.CUBESET="CUBESET",i.CUBESETCOUNT="CUBESETCOUNT",i.CUBEVALUE="CUBEVALUE",i))(eu||{});class tu extends N{isCustom(){return!0}}class Zm extends tu{isAsync(){return!0}}function We(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,databaseValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),databaseValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}let u=`${a.getValue()}`;if(a.isBoolean()&&(u=u.toLocaleUpperCase()),a.isNumber()||S.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,databaseValues:o}}function Qe(i,o){let e=-1;if(i.isError())return{isError:!0,errorObject:i,fieldIndex:e};const t=i.isArray()?i.getRowCount():1,r=i.isArray()?i.getColumnCount():1;if(t>1||r>1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};const n=i.isArray()?i.get(0,0):i;let s=`${n.getValue()}`;if(n.isNull()?s=0:n.isBoolean()?s=n.getValue()?1:0:(n.isNumber()||S.isRealNum(s))&&(s=Math.floor(+s)),typeof s=="number"){if(s<1||s>o[0].length)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};e=s-1}else if(e=o[0].findIndex(a=>a===null?!1:`${a}`.toLocaleLowerCase()===s.toLocaleLowerCase()),e===-1)return{isError:!0,errorObject:g.create(h.VALUE),fieldIndex:e};return{isError:!1,errorObject:null,fieldIndex:e}}function qe(i){const o=[];if(i.isError())return{isError:!0,errorObject:i,criteriaValues:o};const e=i.isArray()?i.getRowCount():1,t=i.isArray()?i.getColumnCount():1;if(e<2)return{isError:!0,errorObject:g.create(h.VALUE),criteriaValues:o};for(let r=0;r<e;r++){const n=[];for(let s=0;s<t;s++){const a=i.get(r,s);if(a.isNull()){n.push(null);continue}const u=`${a.getValue()}`;if(a.isBoolean()){n.push(a.getValue()?1:0);continue}if(a.isNumber()||S.isRealNum(u)){n.push(+u);continue}n.push(u)}o.push(n)}return{isError:!1,errorObject:null,criteriaValues:o}}function Ke(i,o,e){const t=i.length,r=i[0].length,n={};let s=!1;for(let a=1;a<t;a++){let u=!0;for(let c=0;c<r;c++){const l=i[a][c];if(l===null)continue;let f=n[c];if(f===void 0){const m=i[0][c];f=o[0].findIndex(d=>d===null||m===null?!1:`${d}`.toLocaleLowerCase()===`${m}`.toLocaleLowerCase()),n[c]=f}if(f===-1&&(typeof l=="string"||l===0)){u=!1;break}else if(f>-1){const m=o[e][f];if(m===null){u=!1;break}const[d,_]=Qs(`${l}`);if(!ot.create(`${m}`).compare(_,d).getValue()){u=!1;break}}}if(u){s=!0;break}}return s}class zm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=0,C=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Ke(d,a,E)&&(_+=b,C++)}return C===0?g.create(h.DIV_BY_ZERO):y.create(_/C)}}class Jm extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=0;for(let C=1;C<a.length;C++)typeof a[C][l]=="number"&&Ke(d,a,C)&&_++;return y.create(_)}}class eh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=0;for(let C=1;C<a.length;C++){const E=a[C][l];E!=null&&Ke(d,a,C)&&_++}return y.create(_)}}class th extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=0,C=0;for(let E=1;E<a.length;E++){const b=a[E][l];b!=null&&Ke(d,a,E)&&(_++,C=E)}return _===0?g.create(h.VALUE):_>1?g.create(h.NUM):e.get(C,l)}}class rh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=-1/0,C=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Ke(d,a,E)&&(_=Math.max(_,b),C++)}return C===0?y.create(0):y.create(_)}}class nh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=1/0,C=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Ke(d,a,E)&&(_=Math.min(_,b),C++)}return C===0?y.create(0):y.create(_)}}class sh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=1,C=0;for(let E=1;E<a.length;E++){const b=a[E][l];typeof b=="number"&&Ke(d,a,E)&&(_*=b,C++)}return C===0?y.create(0):y.create(_)}}class ah extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const _=[];let C=0,E=0;for(let V=1;V<a.length;V++){const M=a[V][l];typeof M=="number"&&Ke(d,a,V)&&(_.push(M),C+=M,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=C/E;let R=0;for(let V=0;V<E;V++)R+=(_[V]-b)**2;const p=Math.sqrt(R/(E-1));return y.create(p)}}class ih extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const _=[];let C=0,E=0;for(let V=1;V<a.length;V++){const M=a[V][l];typeof M=="number"&&Ke(d,a,V)&&(_.push(M),C+=M,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=C/E;let R=0;for(let V=0;V<E;V++)R+=(_[V]-b)**2;const p=Math.sqrt(R/E);return y.create(p)}}class oh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;let _=0;for(let C=1;C<a.length;C++){const E=a[C][l];typeof E=="number"&&Ke(d,a,C)&&(_+=E)}return y.create(_)}}class uh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const _=[];let C=0,E=0;for(let V=1;V<a.length;V++){const M=a[V][l];typeof M=="number"&&Ke(d,a,V)&&(_.push(M),C+=M,E++)}if(E<=1)return g.create(h.DIV_BY_ZERO);const b=C/E;let R=0;for(let V=0;V<E;V++)R+=(_[V]-b)**2;const p=R/(E-1);return y.create(p)}}class ch extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,databaseValues:a}=We(e);if(n)return s;const{isError:u,errorObject:c,fieldIndex:l}=Qe(t,a);if(u)return c;const{isError:f,errorObject:m,criteriaValues:d}=qe(r);if(f)return m;const _=[];let C=0,E=0;for(let V=1;V<a.length;V++){const M=a[V][l];typeof M=="number"&&Ke(d,a,V)&&(_.push(M),C+=M,E++)}if(E===0)return g.create(h.DIV_BY_ZERO);const b=C/E;let R=0;for(let V=0;V<E;V++)R+=(_[V]-b)**2;const p=R/E;return y.create(p)}}var ve=(i=>(i.DAVERAGE="DAVERAGE",i.DCOUNT="DCOUNT",i.DCOUNTA="DCOUNTA",i.DGET="DGET",i.DMAX="DMAX",i.DMIN="DMIN",i.DPRODUCT="DPRODUCT",i.DSTDEV="DSTDEV",i.DSTDEVP="DSTDEVP",i.DSUM="DSUM",i.DVAR="DVAR",i.DVARP="DVARP",i))(ve||{});const ru=[[zm,ve.DAVERAGE],[Jm,ve.DCOUNT],[eh,ve.DCOUNTA],[th,ve.DGET],[rh,ve.DMAX],[nh,ve.DMIN],[sh,ve.DPRODUCT],[ah,ve.DSTDEV],[ih,ve.DSTDEVP],[oh,ve.DSUM],[uh,ve.DVAR],[ch,ve.DVARP]],fa="yyyy/mm/dd;@",lh="yyyy/mm/dd hh:mm",fh="h:mm A/P";function be(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28)),t=Date.UTC(i.getFullYear(),i.getMonth(),i.getDate());let r=(t-o.getTime())/(1e3*3600*24);return t>e.getTime()&&(r+=1),Math.floor(r)+1}function wr(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let r=(i.getTime()-o.getTime())/(1e3*3600*24);return i>e&&(r+=1),r+1}function ne(i){const o=new Date(Date.UTC(1900,0,1)),e=new Date(Date.UTC(1900,1,28));let t=Math.floor(i)-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),new Date(o.getTime()+t*(1e3*3600*24))}function ma(i){const o=new Date(Date.UTC(1900,0,1,0,0,0)),e=new Date(Date.UTC(1900,1,28,0,0,0));let t=i-1;return t>(e.getTime()-o.getTime())/(1e3*3600*24)&&(t-=1),t<0&&(t=i),new Date(o.getTime()+t*(1e3*3600*24))}function ha(i){if(!/^\d{4}[-/](0?[1-9]|1[012])[-/](0?[1-9]|[12][0-9]|3[01])$/.test(i))return!1;const e=i.replace(/-/g,"/").replace(/T.+/,""),t=new Date(`${e}`);if(Number.isNaN(t.getTime()))return!1;const r=t.getFullYear(),n=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=`${r}-${n}-${s}`;return i.replace(/\//g,"-").split("-").map(c=>c.padStart(2,"0")).join("-")===a}function ws(i){return S.numfmt.parseDate(i)}function nu(i){return S.numfmt.parseValue(i)}function Ps(i){return S.numfmt.parseTime(i)}function ga(i){return S.numfmt.isDate(i)}const su={1:[6,0],2:[0,1],3:[1,2],4:[2,3],5:[3,4],6:[4,5],7:[5,6],11:[0],12:[1],13:[2],14:[3],15:[4],16:[5],17:[6]};function br(i){return!!(typeof i=="string"&&/^[0|1]{7}/.test(i)||su[Number(i)])}function au(i){if(!br(i))return[];if(typeof i=="string"&&/^[0|1]{7}/.test(i)){const o=[];for(let e=1;e<=i.length;e++)`${i[e-1]}`=="1"&&(e===i.length?o.push(0):o.push(e));return o}return su[Number(i)]||[]}function cn(i,o,e=1,t){const r=au(e),n=Math.floor(i),s=Math.floor(o),a=s>n?n:s;let u=0;const c=Math.abs(Math.floor(o)-Math.floor(i))+1;for(let l=0;l<c;l++){const f=a+l;if(t&&t.length>0&&t.some(d=>Math.floor(d)===f))continue;const m=Wt(f);r.includes(m)||u++}return s>=n?u:-u}function ln(i,o,e=1,t){const r=au(e),n=Math.floor(i);let s=n,a=Math.abs(o);for(let u=1;u<=a;u++){const c=o<0?n-u:n+u;if(c<0)return g.create(h.NUM);if(t&&t.length>0&&t.some(f=>Math.floor(f)===c)){a++;continue}const l=Wt(c);if(r.includes(l)){a++;continue}s=c}return s}function $(i){if(i.isError())return i;const o=i.getValue();if(i.isString()){let e;if(ws(`${o}`))e=ws(`${o}`).v;else if(Ps(`${o}`))e=Ps(`${o}`).v;else if(S.isRealNum(o))e=+o;else return g.create(h.VALUE);return e instanceof Date&&(e=wr(e)),+e<0||+e>2958465?g.create(h.NUM):+e}else{const e=+i.getValue();return e<0||e>2958465?g.create(h.NUM):e}}function Wt(i){const o=Math.floor(i)===60;let e=ne(i);const t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getTime(),r=new Date(Date.UTC(1900,1,28)).getTime();return!o&&t<=r&&(e=new Date(t-24*3600*1e3)),new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())).getUTCDay()}function Ce(i,o,e){switch(e){case 0:return mh(i,o);case 1:return hh(i,o);case 2:return{days:Math.abs(o-i),yearDays:360};case 3:return{days:Math.abs(o-i),yearDays:365};case 4:return gh(i,o);default:return{days:Math.abs(o-i),yearDays:365}}}function mh(i,o){const e=ne(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0,s=ne(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1,c=o>0?s.getUTCDate():0;r===2?ne(i+1).getUTCMonth()+1===3&&(n=30):n===31&&(n=30),c===31&&(n<30?(s=ne(o+1),a=s.getUTCFullYear(),u=s.getUTCMonth()+1,c=s.getUTCDate()):c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function hh(i,o){const e=ne(i),t=i>0?e.getUTCFullYear():1900,r=ne(o),n=o>0?r.getUTCFullYear():1900,s=Math.abs(o-i),a=Math.abs(n-t)+1;let u,c;if(n<t){const l=new Date(Date.UTC(n,0,1)),f=new Date(Date.UTC(t,11,31));u=be(l),c=be(f),n===1900&&(u+=1)}else{const l=new Date(Date.UTC(t,0,1)),f=new Date(Date.UTC(n,11,31));u=be(l),c=be(f),t===1900&&(u+=1)}return{days:s,yearDays:(c-u+1)/a}}function gh(i,o){const e=ne(i),t=i>0?e.getUTCFullYear():1900,r=i>0?e.getUTCMonth()+1:1;let n=i>0?e.getUTCDate():0;const s=ne(o),a=o>0?s.getUTCFullYear():1900,u=o>0?s.getUTCMonth()+1:1;let c=o>0?s.getUTCDate():0;n===31&&(n=30),c===31&&(c=30);const l=(a-t)*360,f=o>=i?30-n:-n,m=o>=i?c:c-30,d=(o>=i?u-r-1:u-r+1)*30;return{days:Math.abs(l+f+m+d),yearDays:360}}function dh(i){return i%4===0&&i%100!==0||i%400===0}function Ch(i){return i%4===0&&i%100!==0||i%400===0||i===1900}const _h=[31,29,31,30,31,30,31,31,30,31,30,31],Ah=[31,28,31,30,31,30,31,31,30,31,30,31];function Pr(i,o){return dh(i)?_h[o]:Ah[o]}function Hn(i){return Ch(i)?366:365}function iu(i,o){switch(o){case 0:case 2:case 4:return 360;case 1:return Hn(ne(i).getUTCFullYear());case 3:return 365;default:return-1}}function or(i,o,e){return Pr(i,o)===e}function ur(i,o){let e=i.getUTCFullYear(),t=i.getUTCMonth();const r=i.getUTCDate();return or(e,t,r)?(i.setUTCDate(1),i.setUTCMonth(i.getUTCMonth()+o),e=i.getUTCFullYear(),t=i.getUTCMonth(),i.setUTCDate(Pr(e,t))):i.setUTCMonth(i.getUTCMonth()+o),i}class Eh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>{const d=u.get(f,m)||ie.create(),_=c.get(f,m)||ie.create();if(l.isError())return l;if(d.isError())return d;if(_.isError())return _;if(l.isString()||d.isString()||_.isString())return g.create(h.VALUE);let C=+l.getValue();const E=Math.floor(+d.getValue()),b=+_.getValue();if(C<0||C>9999)return g.create(h.NUM);C>=0&&C<1899&&(C+=1900);const R=new Date(C,E-1,b),p=be(R);return p<0?g.create(h.NUM):y.create(p,fa)})}}class bh extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t,a=r;if(n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),a.isArray()&&(a=a.get(0,0)),n.isError())return n;if(s.isError())return s;if(a.isError())return a;const u=$(n);if(typeof u!="number")return u;const c=$(s);return typeof c!="number"?c:c<u||!a.isString()?g.create(h.NUM):this._getResultByUnit(u,c,a)}_getResultByUnit(e,t,r){const n=ne(e),s=n.getUTCFullYear(),a=n.getUTCMonth()+1,u=n.getUTCDate(),c=ne(t),l=c.getUTCFullYear(),f=c.getUTCMonth()+1,m=c.getUTCDate(),d=`${r.getValue()}`.toLocaleUpperCase();let _=0,C;switch(d){case"Y":_=l-s,(f<a||f===a&&m<u)&&(_-=1);break;case"M":_=(l-s)*12+f-a,m<u&&(_-=1);break;case"D":_=Math.floor(t)-Math.floor(e);break;case"MD":_=m-u,m<u&&(C=new Date(Date.UTC(l,f-1,0)),_+=Pr(C.getUTCFullYear(),C.getUTCMonth()));break;case"YM":_=f-a,(f<a||f===a&&m<u)&&(_+=12),m<u&&(_-=1);break;case"YD":C=new Date(Date.UTC(s,f-1,m)),(f<a||f===a&&m<u)&&(C=new Date(Date.UTC(s+1,f-1,m))),_=Math.floor(be(C))-Math.floor(e);break;default:return g.create(h.NUM)}return y.create(_)}}class yh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=nu(t);if(r){let{v:n,z:s}=r;if(s&&ga(s))return n instanceof Date&&(n=wr(n)),y.create(Math.trunc(+n))}}return g.create(h.VALUE)}}class Rh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t;const r=e.getValue();if(e.isString()){if(!ha(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(0);t=ne(a)}const n=t.getDate();return y.create(n)}}class ph extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t),u=s.map((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const d=$(c);if(typeof d!="number")return d;const _=$(m);if(typeof _!="number")return _;const C=Math.floor(d)-Math.floor(_);return y.create(C)});return r===1&&n===1?u.get(0,0):u}}class Nh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:v.create(!1);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,_)=>{const C=c.get(d,_);let E=l.get(d,_);if(m.isError())return m;const b=$(m);if(typeof b!="number")return b;if(C.isError())return C;const R=$(C);if(typeof R!="number")return R;if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;const p=+E.getValue(),{days:V}=Ce(b,R,p?4:0),M=R>=b?V:-V;return y.create(M)});return s===1&&a===1?f.get(0,0):f}}class Vh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{const f=a.get(c,l)||ie.create();if(u.isError())return u;if(f.isError())return f;if(u.isString()||u.isBoolean()||f.isString()||f.isBoolean())return g.create(h.VALUE);const m=+u.getValue();if(m<0)return g.create(h.NUM);const d=Math.floor(+f.getValue()),_=ne(m),C=_.getUTCFullYear(),E=_.getUTCMonth()+d,b=_.getUTCDate(),R=new Date(Date.UTC(C,E,b)),p=be(R);return y.create(p,fa)})}}class Oh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;if(r.isArray()){const d=r.getRowCount(),_=r.getColumnCount();if(d>1||_>1)return g.create(h.VALUE);r=r.get(0,0)}if(n.isArray()){const d=n.getRowCount(),_=n.getColumnCount();if(d>1||_>1)return g.create(h.VALUE);n=n.get(0,0)}if(r.isError())return r;if(n.isError())return n;const s=$(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=ne(s),u=s>0?a.getUTCFullYear():1900,c=s>0?a.getUTCMonth():0,l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);const f=new Date(Date.UTC(u,c+l+1,0)),m=be(f);return y.create(m)}}class Mh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){const r=t!=null?t:y.create(1),{isError:n,errorObject:s,timestampIsReferenceObject:a,timestampObject:u,unitObject:c}=this._checkVariants(e,r);if(n)return s;if(u.isNull()||u.isBoolean()||u.isString()||!a&&u.isNumber()&&u.getPattern()!=="")return g.create(h.VALUE);let l=+u.getValue();const{isError:f,errorObject:m,variants:d}=F(c);if(f)return m;const[_]=d,C=Math.floor(+_.getValue());if(l<0||C<1||C>3)return g.create(h.NUM);C===1&&(l=l*1e3),C===3&&(l=l/1e3);const E=new Date(Date.UTC(1970,0,1,0,0,0,0)+l);if(Number.isNaN(E.getTime())){const b=25569+l/864e5;return y.create(b)}else{const b=wr(E);return y.create(b,"yyyy-MM-dd AM/PM hh:mm:ss")}}_checkVariants(e,t){const r=e.isReferenceObject(),n=t.isReferenceObject();let s=e;if(r&&(s=e.toArrayValueObject()),s.isArray()){const u=s.getRowCount(),c=s.getColumnCount();if(u>1||c>1)return{isError:!0,errorObject:g.create(h.VALUE)};s=s.get(0,0)}if(s.isError())return{isError:!0,errorObject:s};let a=t;if(n&&(a=t.toArrayValueObject()),a.isArray()){const u=a.getRowCount(),c=a.getColumnCount();if(u>1||c>1)return{isError:!0,errorObject:g.create(h.VALUE)};a=a.get(0,0)}return a.isError()?{isError:!0,errorObject:a}:{isError:!1,errorObject:null,timestampIsReferenceObject:r,timestampObject:s,unitIsReferenceObject:n,unitObject:a}}}var Ae=(i=>(i.DATE="DATE",i.DATEDIF="DATEDIF",i.DATEVALUE="DATEVALUE",i.DAY="DAY",i.DAYS="DAYS",i.DAYS360="DAYS360",i.EDATE="EDATE",i.EOMONTH="EOMONTH",i.EPOCHTODATE="EPOCHTODATE",i.HOUR="HOUR",i.ISOWEEKNUM="ISOWEEKNUM",i.MINUTE="MINUTE",i.MONTH="MONTH",i.NETWORKDAYS="NETWORKDAYS",i.NETWORKDAYS_INTL="NETWORKDAYS.INTL",i.NOW="NOW",i.SECOND="SECOND",i.TIME="TIME",i.TIMEVALUE="TIMEVALUE",i.TO_DATE="TO_DATE",i.TODAY="TODAY",i.WEEKDAY="WEEKDAY",i.WEEKNUM="WEEKNUM",i.WORKDAY="WORKDAY",i.WORKDAY_INTL="WORKDAY.INTL",i.YEAR="YEAR",i.YEARFRAC="YEARFRAC",i))(Ae||{});class Sh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=$(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ma(t).getUTCHours();return y.create(n)}}class Dh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=$(e);if(typeof t!="number")return t;const r=ne(t),n=t>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=be(s),u=Wt(a),c;u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),t<c&&(s=new Date(Date.UTC(n-1,0,1)),a=be(s),u=Wt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));const l=Math.ceil((t-c+1)/7);return y.create(l)}}class wh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=$(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ma(t).getUTCMinutes();return y.create(n)}}class Ph extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ha(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+e.getValue();if(a<0)return g.create(h.NUM);if(a===0)return y.create(1);t=ne(a)}const n=t.getUTCMonth()+1;return y.create(n)}}class Lh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=$(n);if(typeof a!="number")return a;const u=$(s);if(typeof u!="number")return u;if(r)return this._getResultByHolidays(a,u,r);const c=cn(a,u);return y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=$(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=$(r);if(typeof a!="number")return a;n.push(a)}const s=cn(e,t,1,n);return y.create(s)}}class xh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){let s=e,a=t;if(s.isArray()){const m=s.getRowCount(),d=s.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(a.isArray()){const m=a.getRowCount(),d=a.getColumnCount();if(m>1||d>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isError())return a;let u=1;if(r){if(u=r.getValue(),r.isBoolean()&&(u=+u),r.isString()&&!br(u))return g.create(h.VALUE);if(!br(u))return g.create(h.NUM)}if(s.isBoolean()||a.isBoolean())return g.create(h.VALUE);const c=$(s);if(typeof c!="number")return c;const l=$(a);if(typeof l!="number")return l;if(n)return this._getResultByHolidays(c,l,u,n);const f=cn(c,l,u);return y.create(f)}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=$(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=$(n);if(typeof u!="number")return u;s.push(u)}const a=cn(e,t,r,s);return y.create(a)}}class jh extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=new Date,t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())),r=wr(t);return y.create(r,lh)}}class Uh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>t.isError()?t:this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=$(e);if(typeof t!="number")return t;if(t===0)return y.create(0);const n=ma(t).getUTCSeconds();return y.create(n)}}class Th extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e),u=O(n,s,t),c=O(n,s,r);return a.map((l,f,m)=>this._calculateTime(l,u,c,f,m))}_calculateTime(e,t,r,n,s){let a=e,u=t.get(n,s)||ie.create(),c=r.get(n,s)||ie.create();if((a.isString()||a.isBoolean())&&(a=a.convertToNumberObjectValue()),(u.isString()||u.isBoolean())&&(u=u.convertToNumberObjectValue()),(c.isString()||c.isBoolean())&&(c=c.convertToNumberObjectValue()),a.isError())return a;if(u.isError())return u;if(c.isError())return c;let l=Math.floor(+a.getValue()),f=Math.floor(+u.getValue()),m=Math.floor(+c.getValue());if(l<0||f<0||m<0||l>32767||f>32767||m>32767)return g.create(h.NUM);f+=Math.floor(m/60),m%=60,l+=Math.floor(f/60),f%=60,l%=24;const _=(l*3600+f*60+m)/86400;return y.create(_,fh)}}class vh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isString()){const t=`${e.getValue()}`,r=nu(t);if(r){let{v:n,z:s}=r;if(s&&ga(s))return n instanceof Date&&(n=wr(n)),y.create(tf(+n))}}return g.create(h.VALUE)}}class Bh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){const t=e.isReferenceObject();let r=e;if(t&&(r=e.toArrayValueObject()),r.isArray()){const s=r.getRowCount(),a=r.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError()||r.isNull()||r.isBoolean()||r.isString()||!t&&r.isNumber()&&r.getPattern()!=="")return r;const n=+r.getValue();return y.create(n,"yyyy-MM-dd hh:mm:ss AM/PM")}}class Ih extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){const e=be(new Date);return y.create(e,fa)}}class Fh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:[1,2,3,4,5,6,7],2:[7,1,2,3,4,5,6],3:[6,0,1,2,3,4,5],11:[7,1,2,3,4,5,6],12:[6,7,1,2,3,4,5],13:[5,6,7,1,2,3,4],14:[4,5,6,7,1,2,3],15:[3,4,5,6,7,1,2],16:[2,3,4,5,6,7,1],17:[1,2,3,4,5,6,7]})}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{const d=u.get(f,m);return this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(r.isError())return r;const n=$(e);if(typeof n!="number")return n;if(r.isString()&&(r=r.convertToNumberObjectValue(),r.isError()))return r;const s=Math.floor(+r.getValue());if(!this._returnTypeMap[s])return g.create(h.NUM);const a=Wt(n),u=this._returnTypeMap[s][a];return y.create(u)}}class kh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"_returnTypeMap",{1:0,2:1,11:1,12:2,13:3,14:4,15:5,16:6,17:0,21:4})}calculate(e,t){let r=e,n=t!=null?t:y.create(1);if(r.isArray()){const u=r.getRowCount(),c=r.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;if(n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();if(u>1||c>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean())return g.create(h.VALUE);const s=$(r);if(typeof s!="number")return s;if(n.isBoolean())return g.create(h.VALUE);const a=Math.floor(+n.getValue());return Number.isNaN(a)?g.create(h.VALUE):a in this._returnTypeMap?this._getResult(s,a):g.create(h.NUM)}_getResult(e,t){const r=ne(e),n=e>0?r.getUTCFullYear():1900;let s=new Date(Date.UTC(n,0,1)),a=be(s),u=Wt(a),c;if(t===21)u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u),e<c&&(s=new Date(Date.UTC(n-1,0,1)),a=be(s),u=Wt(a),u<1?c=a+1:u<=4?c=a-(u-1):c=a+(11-u));else{const f=this._returnTypeMap[t];u<f?c=a-(u+7-f):c=a-(u-f)}const l=Math.ceil((e-c+1)/7);return y.create(l)}}class $h extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=e,s=t;if(n.isArray()){const l=n.getRowCount(),f=n.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(s.isArray()){const l=s.getRowCount(),f=s.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);s=s.get(0,0)}if(s.isError())return s;if(r!=null&&r.isError())return r;if(n.isBoolean()||s.isBoolean())return g.create(h.VALUE);const a=$(n);if(typeof a!="number")return a;const u=+s.getValue();if(Number.isNaN(u))return g.create(h.VALUE);if(r)return this._getResultByHolidays(a,u,r);const c=ln(a,u);return typeof c!="number"?c:y.create(c)}_getResultByHolidays(e,t,r){const n=[];if(r!=null&&r.isArray()){const a=r.getRowCount(),u=r.getColumnCount();for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=r.get(c,l);if(f.isBoolean())return g.create(h.VALUE);const m=$(f);if(typeof m!="number")return m;n.push(m)}}else{if(r.isBoolean())return g.create(h.VALUE);const a=$(r);if(typeof a!="number")return a;n.push(a)}const s=ln(e,t,1,n);return typeof s!="number"?s:y.create(s)}}class Yh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){return e.isError()?e:t.isError()?t:r!=null&&r.isError()?r:n!=null&&n.isError()?n:r!=null&&r.isArray()?r.map(s=>this._handleSingleObject(e,t,s,n)):this._handleSingleObject(e,t,r,n)}_handleSingleObject(e,t,r,n){const s=r!=null?r:y.create(1),a=this._checkArrayError(e);if(a.isError())return a;const u=this._checkArrayError(t);if(u.isError())return u;if(a.isBoolean()||u.isBoolean())return g.create(h.VALUE);const c=$(e);if(typeof c!="number")return c;const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);let f=s.getValue();if(s.isBoolean()&&(f=+f),s.isString()&&(!br(f)||f==="1111111"))return g.create(h.VALUE);if(!br(f))return g.create(h.NUM);if(n)return this._getResultByHolidays(c,l,f,n);const m=ln(c,l,f);return typeof m!="number"?m:y.create(m)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isError(),t}_getResultByHolidays(e,t,r,n){const s=[];if(n!=null&&n.isArray()){const u=n.getRowCount(),c=n.getColumnCount();for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=n.get(l,f);if(m.isBoolean())return g.create(h.VALUE);const d=$(m);if(typeof d!="number")return d;s.push(d)}}else{if(n.isBoolean())return g.create(h.VALUE);const u=$(n);if(typeof u!="number")return u;s.push(u)}const a=ln(e,t,r,s);return typeof a!="number"?a:y.create(a)}}class Hh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;let t;const r=e.getValue();if(e.isString()){if(!ha(`${r}`))return g.create(h.VALUE);t=new Date(`${r}`)}else{const a=+r;if(a<0)return g.create(h.NUM);if(a===0)return y.create(1900);t=ne(a)}const n=t.getUTCFullYear();return y.create(n)}}class Gh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:y.create(0);const s=It(e);if(s.isError())return s;const a=It(t);if(a.isError())return a;if(n=It(n),n.isError())return n;if(s.isBoolean()||a.isBoolean()||n.isBoolean())return g.create(h.VALUE);const u=$(s);if(typeof u!="number")return u;const c=$(a);if(typeof c!="number")return c;const l=Math.floor(+n.getValue());if(Number.isNaN(l))return g.create(h.VALUE);if(l<0||l>4)return g.create(h.NUM);const{days:f,yearDays:m}=Ce(u,c,l),d=f/m;return y.create(d)}}const ou=[[Eh,Ae.DATE],[bh,Ae.DATEDIF],[yh,Ae.DATEVALUE],[Rh,Ae.DAY],[ph,Ae.DAYS],[Nh,Ae.DAYS360],[Vh,Ae.EDATE],[Oh,Ae.EOMONTH],[Mh,Ae.EPOCHTODATE],[Sh,Ae.HOUR],[Dh,Ae.ISOWEEKNUM],[wh,Ae.MINUTE],[Ph,Ae.MONTH],[Lh,Ae.NETWORKDAYS],[xh,Ae.NETWORKDAYS_INTL],[jh,Ae.NOW],[Uh,Ae.SECOND],[Th,Ae.TIME],[vh,Ae.TIMEVALUE],[Bh,Ae.TO_DATE],[Ih,Ae.TODAY],[Fh,Ae.WEEKDAY],[kh,Ae.WEEKNUM],[$h,Ae.WORKDAY],[Yh,Ae.WORKDAY_INTL],[Hh,Ae.YEAR],[Gh,Ae.YEARFRAC]];class Wh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besseli(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Qh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselj(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class qh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.besselk(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Kh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);const f=ir.bessely(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class Xh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!zs(a))return g.create(h.NUM);let u;return a.length===10&&a.substring(0,1)==="1"?u=Number.parseInt(a.substring(1),2)-512:u=Number.parseInt(a,2),y.create(u)}}class Zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=G(t);if(f)return m;const[_]=d;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!zs(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(0xfffffffe00+Number.parseInt(c.substring(1),2)).toString(16);else if(l=Number.parseInt(c,2).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return U.create(l.toLocaleUpperCase())}}class zh extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=G(t);if(f)return m;const[_]=d;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!zs(c))return g.create(h.NUM);let l;if(c.length===10&&c.substring(0,1)==="1")l=(1073741312+Number.parseInt(c.substring(1),2)).toString(8);else if(l=Number.parseInt(c,2).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return U.create(l)}}class Jh extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue(),C=+d.getValue();if(_<0||C<0||Math.floor(_)!==_||Math.floor(C)!==C||_>0xffffffffffff||C>0xffffffffffff)return g.create(h.NUM);const E=_&C;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class eg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue();let C=+d.getValue();if(_<0||Math.floor(_)!==_||_>0xffffffffffff||Math.abs(C)>53)return g.create(h.NUM);C=Math.trunc(C);const E=Number(C>=0?BigInt(_)<<BigInt(C):BigInt(_)>>BigInt(-C));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class tg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue(),C=+d.getValue();if(_<0||C<0||Math.floor(_)!==_||Math.floor(C)!==C||_>0xffffffffffff||C>0xffffffffffff)return g.create(h.NUM);const E=Number(BigInt(_)|BigInt(C));return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class rg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue();let C=+d.getValue();if(_<0||Math.floor(_)!==_||_>0xffffffffffff||Math.abs(C)>53)return g.create(h.NUM);C=Math.trunc(C);const E=Number(C>=0?BigInt(_)>>BigInt(C):BigInt(_)<<BigInt(-C));return E>0xffffffffffff?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class ng extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;let d=a.get(l,f);if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue(),C=+d.getValue();if(_<0||C<0||Math.floor(_)!==_||Math.floor(C)!==C||_>0xffffffffffff||C>0xffffffffffff)return g.create(h.NUM);const E=_^C;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}x.prototype.cos=function(){const i=this.toNumber();return new x(Math.cos(i))};let he=class le{constructor(o){A(this,"_inumber","");A(this,"_realNum",0);A(this,"_iNum",0);A(this,"_suffix","");A(this,"_isError",!1);if(`${o}`.trim()===""){this._isError=!0;return}this._inumber=o,this._getImReal(),this._getImAginary(),this._getImSuffix()}static getComplex(o,e,t){const r=new x(o).toSignificantDigits(15).toNumber(),n=new x(e).toSignificantDigits(15).toNumber(),s=t===""?"i":t;let a;if(r===0&&n===0)a=0;else if(r===0)a=n===1?s:`${n}${s}`;else if(n===0)a=r;else{const u=n>0?"+":"",c=n===1?s:`${n}${s}`;a=`${r}${u}${c}`}return a}static createByComplexStr(o,e,t){const r=le.getComplex(o,e,t);return new le(r)}_getImReal(){if(this._inumber===0||this._inumber==="0"){this._realNum=0;return}const o=`${this._inumber}`;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(o)>=0){this._realNum=0;return}let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,e):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._realNum=+o.substring(0,t)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._realNum=0:Number.isNaN(+o)?this._isError=!0:this._realNum=+o}_getImAginary(){if(this._isError)return;if(this._inumber===0||this._inumber==="0"){this._iNum=0;return}let o=`${this._inumber}`;if(["i","j"].indexOf(o)>=0){this._iNum=1;return}o=o.replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j");let e=o.indexOf("+"),t=o.indexOf("-");e===0&&(e=o.indexOf("+",1)),t===0&&(t=o.indexOf("-",1));const r=o.substring(o.length-1,o.length),n=r==="i"||r==="j";if(e>=0||t>=0){if(!n){this._isError=!0;return}e>=0?Number.isNaN(+o.substring(0,e))||Number.isNaN(+o.substring(e+1,o.length-1))?this._isError=!0:this._iNum=+o.substring(e+1,o.length-1):Number.isNaN(+o.substring(0,t))||Number.isNaN(+o.substring(t+1,o.length-1))?this._isError=!0:this._iNum=-+o.substring(t+1,o.length-1)}else n?Number.isNaN(+o.substring(0,o.length-1))?this._isError=!0:this._iNum=+o.substring(0,o.length-1):Number.isNaN(+o)?this._isError=!0:this._iNum=0}_getImSuffix(){const o=`${this._inumber}`,e=o.substring(o.length-1);this._suffix=e==="i"||e==="j"?e:""}getRealNum(){return this._realNum}getINum(){return this._iNum}getSuffix(){return this._suffix}isError(){return this._isError}toString(){return le.getComplex(this._realNum,this._iNum,this._suffix)}isDifferentSuffixes(o){const e=o.getSuffix();return this._suffix===""||e===""?!1:this._suffix!==e}Abs(){return x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))).toSignificantDigits(16).toNumber()}Argument(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2)));let e=x.acos(new x(this._realNum).div(o)).toSignificantDigits(16).toNumber();return this._iNum<0&&(e=-e),e}Conjugate(){return le.getComplex(this._realNum,-this._iNum,this._suffix)}Cos(){if(this._iNum){const o=x.cos(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.sin(this._realNum).mul(x.sinh(this._iNum)).negated().toNumber();return le.getComplex(o,e,this._suffix)}else{const o=x.cos(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Cosh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.cosh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.sinh(this._realNum).mul(x.sin(this._iNum)).toNumber();return le.getComplex(o,e,this._suffix)}else{const o=x.cosh(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Cot(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).negated().toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.tan(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Coth(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.cosh(this._realNum*2).sub(x.cos(this._iNum*2)),e=x.sinh(this._realNum*2).div(o).toNumber(),t=x.sin(this._iNum*2).div(o).negated().toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.tanh(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Csc(){if(this._iNum){const o=x.cosh(this._iNum*2).sub(x.cos(this._realNum*2)),e=x.sin(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.cos(this._realNum).mul(x.sinh(this._iNum)).mul(-2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sin(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Csch(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return le.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).sub(x.cos(this._iNum*2)),e=x.sinh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.cosh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.sinh(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Div(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=r.mul(r).add(n.mul(n)),a=e.mul(r).add(t.mul(n)).div(s).toNumber(),u=t.mul(r).sub(e.mul(n)).div(s).toNumber(),c=this._suffix===""?o.getSuffix():this._suffix;return le.getComplex(a,u,c)}Exp(){if(!Number.isFinite(Math.exp(this._realNum)))return this._isError=!0,"";const o=x.exp(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.exp(this._realNum).mul(x.sin(this._iNum)).toNumber();return le.getComplex(o,e,this._suffix)}Ln(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.ln(o).toNumber(),t=x.acos(new x(this._realNum).div(o)).toNumber();return le.getComplex(e,t,this._suffix)}Log(o){const e=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),t=x.ln(e);let r=x.acos(new x(this._realNum).div(e));this._iNum<0&&(r=r.negated());const n=x.ln(o),s=new x(0),a=n.mul(n).add(s.mul(s));if(a.eq(0))return this._isError=!0,"";const u=t.mul(n).add(r.mul(s)).div(a).toNumber(),c=r.mul(n).sub(t.mul(s)).div(a).toNumber();return le.getComplex(u,c,this._suffix)}Power(o){if(this._realNum===0&&this._iNum===0)return o>0?le.getComplex(this._realNum,this._iNum,this._suffix):(this._isError=!0,"");let e=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),t=x.acos(new x(this._realNum).div(e));this._iNum<0&&(t=t.negated()),e=x.pow(e,o),t=t.mul(o);const r=x.cos(t).mul(e).toNumber(),n=x.sin(t).mul(e).toNumber();return!Number.isFinite(r)||!Number.isFinite(n)?(this._isError=!0,""):le.getComplex(r,n,this._suffix)}Product(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.mul(r).sub(t.mul(n)).toNumber(),a=e.mul(n).add(t.mul(r)).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return le.getComplex(s,a,u)}Sec(){if(this._iNum){const o=x.cosh(this._iNum*2).add(x.cos(this._realNum*2)),e=x.cos(this._realNum).mul(x.cosh(this._iNum)).mul(2).div(o).toNumber(),t=x.sin(this._realNum).mul(x.sinh(this._iNum)).mul(2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cos(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Sech(){if(!Number.isFinite(Math.sinh(this._realNum*2))||!Number.isFinite(Math.cosh(this._realNum*2)))return le.getComplex(0,0,this._suffix);if(this._iNum){const o=x.cosh(this._realNum*2).add(x.cos(this._iNum*2)),e=x.cosh(this._realNum).mul(x.cos(this._iNum)).mul(2).div(o).toNumber(),t=x.sinh(this._realNum).mul(x.sin(this._iNum)).mul(-2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=new x(1).div(x.cosh(this._realNum)).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Sin(){if(this._iNum){const o=x.sin(this._realNum).mul(x.cosh(this._iNum)).toNumber(),e=x.cos(this._realNum).mul(x.sinh(this._iNum)).toNumber();return le.getComplex(o,e,this._suffix)}else{const o=x.sin(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Sinh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.sinh(this._realNum).mul(x.cos(this._iNum)).toNumber(),e=x.cosh(this._realNum).mul(x.sin(this._iNum)).toNumber();return le.getComplex(o,e,this._suffix)}else{const o=x.sinh(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Sqrt(){const o=x.sqrt(x.pow(this._realNum,2).add(x.pow(this._iNum,2))),e=x.sqrt(o);let t=x.acos(new x(this._realNum).div(o));this._iNum<0&&(t=t.negated());const r=e.mul(x.cos(t.div(2).toNumber())).toNumber(),n=e.mul(x.sin(t.div(2))).toNumber();return le.getComplex(r,n,this._suffix)}Sub(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.sub(r).toNumber(),a=t.sub(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return le.getComplex(s,a,u)}Sum(o){const e=new x(this._realNum),t=new x(this._iNum),r=new x(o.getRealNum()),n=new x(o.getINum()),s=e.add(r).toNumber(),a=t.add(n).toNumber(),u=this._suffix===""?o.getSuffix():this._suffix;return le.getComplex(s,a,u)}Tan(){if(this._iNum){const o=x.cos(this._realNum*2).add(x.cosh(this._iNum*2)),e=x.sin(this._realNum*2).div(o).toNumber(),t=x.sinh(this._iNum*2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=x.tan(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}Tanh(){if(!Number.isFinite(Math.sinh(this._realNum))||!Number.isFinite(Math.cosh(this._realNum)))return this._isError=!0,"";if(this._iNum){const o=x.cosh(this._realNum*2).add(x.cos(this._iNum*2)),e=x.sinh(this._realNum*2).div(o).toNumber(),t=x.sin(this._iNum*2).div(o).toNumber();return le.getComplex(e,t,this._suffix)}else{const o=x.tanh(this._realNum).toNumber();return le.getComplex(o,this._iNum,this._suffix)}}};class sg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:U.create("i"),{isError:s,errorObject:a,variants:u}=G(e,t,n);if(s)return a;const[c,l,f]=u,m=+c.getValue(),d=+l.getValue(),_=`${f.getValue()}`;if(Number.isNaN(m)||Number.isNaN(d)||_!=="i"&&_!=="j")return g.create(h.VALUE);const C=he.getComplex(m,d,_);return typeof C=="number"?y.create(C):U.create(C)}}class ag extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"_units",[["a.u. of action","?",null,"action",!1,!1,105457168181818e-48],["a.u. of charge","e",null,"electric_charge",!1,!1,160217653141414e-33],["a.u. of energy","Eh",null,"energy",!1,!1,435974417757576e-32],["a.u. of length","a?",null,"length",!1,!1,529177210818182e-25],["a.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["a.u. of time","?/Eh",null,"time",!1,!1,241888432650516e-31],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,149597870691667e-25],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["centigrade","C",["cel"],"temperature",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,846786664623715e-61],["cubic metre","m3",["m^3"],"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,416818182544058e-5],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,758660370370369e-22],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,166053886282828e-41],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["fahrenheit","F",["fah"],"temperature",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519538e-3],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,105457168181818e-48],["n.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,128808866778687e-35],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["rankine","Rank",null,"temperature",!1,!0,1],["reaumur","Reau",null,"temperature",!1,!0,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,895054210748189e17],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988110336e-6],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]]);A(this,"_binaryPrefixes",{Yi:["yobi",80,12089258196146292e8,"Yi","yotta"],Zi:["zebi",70,11805916207174113e5,"Zi","zetta"],Ei:["exbi",60,1152921504606847e3,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]});A(this,"_unitPrefixes",{Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]})}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=G(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=`${c.getValue()}`,d=`${l.getValue()}`;if(Number.isNaN(f))return g.create(h.VALUE);let _,C=1,E,b=1;const{_from:R,_to:p}=this._lookupFromAndToUnits(m,d);if(_=R,E=p,_===null){const{_from:M,_fromMultiplier:D}=this._lookupFromPrefix(m);_=M,C=D}if(E===null){const{_to:M,_toMultiplier:D}=this._lookupToPrefix(d);E=M,b=D}if(_===null||E===null||_[3]!==E[3])return g.create(h.NA);let V;return _[3]==="temperature"?(V=this._getTemperatureConversion(f,_[1],E[1]),V=+V.toFixed(2)):V=f*_[6]*C/(E[6]*b),y.create(V)}_lookupFromAndToUnits(e,t){let r=null,n=null,s;for(let a=0;a<this._units.length;a++)s=this._units[a][2]===null?[]:this._units[a][2],(this._units[a][1]===e||s.indexOf(e)>=0)&&(r=this._units[a]),(this._units[a][1]===t||s.indexOf(t)>=0)&&(n=this._units[a]);return{_from:r,_to:n}}_lookupFromPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_from:t,_fromMultiplier:r}}_lookupToPrefix(e){let t=null,r=1,n=e,s;const a=this._binaryPrefixes[e.substring(0,2)];let u=this._unitPrefixes[e.substring(0,1)];e.substring(0,2)==="da"&&(u=["dekao",10,"da"]),a?(r=a[2],n=e.substring(2)):u&&(r=u[1],n=e.substring(u[2].length));for(let c=0;c<this._units.length;c++)s=this._units[c][2]===null?[]:this._units[c][2],(this._units[c][1]===n||s.indexOf(n)>=0)&&(t=this._units[c]);return{_to:t,_toMultiplier:r}}_getTemperatureConversion(e,t,r){switch(t){case"C":return this._centigradeConversion(e,r);case"F":return this._fahrenheitConversion(e,r);case"K":return this._kelvinConversion(e,r);case"Rank":return this._rankineConversion(e,r);case"Reau":return this._reaumurConversion(e,r);default:return e}}_centigradeConversion(e,t){switch(t){case"F":return e*9/5+32;case"K":return e+273.15;case"Rank":return(e+273.15)*9/5;case"Reau":return e*4/5;default:return e}}_fahrenheitConversion(e,t){switch(t){case"C":return(e-32)*5/9;case"K":return(e-32)*5/9+273.15;case"Rank":return e+459.67;case"Reau":return(e-32)*4/9;default:return e}}_kelvinConversion(e,t){switch(t){case"C":return e-273.15;case"F":return(e-273.15)*9/5+32;case"Rank":return e*9/5;case"Reau":return(e-273.15)*4/5;default:return e}}_rankineConversion(e,t){switch(t){case"C":return(e-491.67)*5/9;case"F":return e-459.67;case"K":return e*5/9;case"Reau":return(e-491.67)*4/9;default:return e}}_reaumurConversion(e,t){switch(t){case"C":return e*5/4;case"F":return e*9/4+32;case"K":return e*5/4+273.15;case"Rank":return e*9/4+491.67;default:return e}}}class ig extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=G(t);if(f)return m;const[_]=d;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,3}$/.test(`${c}`)||c<-512||c>511)return g.create(h.NUM);let l;if(c<0){const f=(512+c).toString(2);l=`1${"0".repeat(9-f.length)}${f}`}else if(l=Number.parseInt(`${c}`,10).toString(2),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return U.create(l)}}class og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=G(t);if(f)return m;const[_]=d;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,12}$/.test(`${c}`)||c<-549755813888||c>549755813887)return g.create(h.NUM);let l;if(c<0)l=(1099511627776+c).toString(16);else if(l=Number.parseInt(`${c}`,10).toString(16),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return U.create(l.toLocaleUpperCase())}}class ug extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:f,errorObject:m,variants:d}=G(t);if(f)return m;const[_]=d;if(r=Math.floor(+_.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=Math.trunc(+u.getValue());if(Number.isNaN(c))return g.create(h.VALUE);if(!/^-?[0-9]{1,9}$/.test(`${c}`)||c<-536870912||c>536870911)return g.create(h.NUM);let l;if(c<0)l=(1073741824+c).toString(8);else if(l=Number.parseInt(`${c}`,10).toString(8),t){if(r<l.length)return g.create(h.NUM);l="0".repeat(r-l.length)+l}return U.create(l)}}class cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=G(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l===f?1:0;return y.create(m)}}class lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r;if(t){const{isError:n,errorObject:s,variants:a}=G(e,t);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);r=Ft(f)-Ft(l)}else{const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);r=Ft(c)}return y.create(r)}}class fg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=Ft(a);return y.create(u)}}class mg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=ta(a);return y.create(u)}}class hg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=+s.getValue();if(Number.isNaN(a))return g.create(h.VALUE);const u=ta(a);return y.create(u)}}var Z=(i=>(i.BESSELI="BESSELI",i.BESSELJ="BESSELJ",i.BESSELK="BESSELK",i.BESSELY="BESSELY",i.BIN2DEC="BIN2DEC",i.BIN2HEX="BIN2HEX",i.BIN2OCT="BIN2OCT",i.BITAND="BITAND",i.BITLSHIFT="BITLSHIFT",i.BITOR="BITOR",i.BITRSHIFT="BITRSHIFT",i.BITXOR="BITXOR",i.COMPLEX="COMPLEX",i.CONVERT="CONVERT",i.DEC2BIN="DEC2BIN",i.DEC2HEX="DEC2HEX",i.DEC2OCT="DEC2OCT",i.DELTA="DELTA",i.ERF="ERF",i.ERF_PRECISE="ERF.PRECISE",i.ERFC="ERFC",i.ERFC_PRECISE="ERFC.PRECISE",i.GESTEP="GESTEP",i.HEX2BIN="HEX2BIN",i.HEX2DEC="HEX2DEC",i.HEX2OCT="HEX2OCT",i.IMABS="IMABS",i.IMAGINARY="IMAGINARY",i.IMARGUMENT="IMARGUMENT",i.IMCONJUGATE="IMCONJUGATE",i.IMCOS="IMCOS",i.IMCOSH="IMCOSH",i.IMCOT="IMCOT",i.IMCOTH="IMCOTH",i.IMCSC="IMCSC",i.IMCSCH="IMCSCH",i.IMDIV="IMDIV",i.IMEXP="IMEXP",i.IMLN="IMLN",i.IMLOG="IMLOG",i.IMLOG10="IMLOG10",i.IMLOG2="IMLOG2",i.IMPOWER="IMPOWER",i.IMPRODUCT="IMPRODUCT",i.IMREAL="IMREAL",i.IMSEC="IMSEC",i.IMSECH="IMSECH",i.IMSIN="IMSIN",i.IMSINH="IMSINH",i.IMSQRT="IMSQRT",i.IMSUB="IMSUB",i.IMSUM="IMSUM",i.IMTAN="IMTAN",i.IMTANH="IMTANH",i.OCT2BIN="OCT2BIN",i.OCT2DEC="OCT2DEC",i.OCT2HEX="OCT2HEX",i))(Z||{});class gg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);const r=t!=null?t:y.create(0),{isError:n,errorObject:s,variants:a}=G(e,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=+c.getValue();if(Number.isNaN(l)||Number.isNaN(f))return g.create(h.VALUE);const m=l>=f?1:0;return y.create(m)}}class dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:_,variants:C}=G(t);if(d)return _;const[E]=C;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ea(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1).toLocaleUpperCase()==="F",f=l?Number.parseInt(c,16)-1099511627776:Number.parseInt(c,16);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return U.create(m)}}class Cg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!ea(a))return g.create(h.NUM);let u=Number.parseInt(a,16);return u>=549755813888&&(u-=1099511627776),y.create(u)}}class _g extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:_}=G(t);if(m)return d;const[C]=_;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!ea(c))return g.create(h.NUM);const l=Number.parseInt(c,16);if(l>536870911&&l<0xffe0000000)return g.create(h.NUM);let f;if(l>=0xffe0000000)f=(l-0xffc0000000).toString(8);else if(f=l.toString(8),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return U.create(f)}}class Ag extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Abs();return y.create(c)}}class Eg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.getINum();return y.create(c)}}class bg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return g.create(h.DIV_BY_ZERO);const c=u.Argument();return y.create(c)}}class yg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Conjugate();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Rg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Cos();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Cosh();return u.isError()?g.create(h.NUM):typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Ng extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Cot();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Vg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Coth();return u.isError()?g.create(h.NUM):typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Og extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csc();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Mg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Csch();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Sg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new he(c),m=new he(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m)||m.getRealNum()===0&&m.getINum()===0)return g.create(h.NUM);const d=f.Div(m);return typeof d=="number"||S.isRealNum(d)?y.create(+d):U.create(d)}}class Dg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Exp();return u.isError()?g.create(h.NUM):typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class wg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Ln();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Pg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e);if(r)return n;const[a]=s;let u=t!=null?t:y.create(10);if(u.isArray()){const b=u.getRowCount(),R=u.getColumnCount();if(b>1||R>1)return g.create(h.VALUE);u=u.get(0,0)}const{isError:c,errorObject:l,variants:f}=F(u);if(c)return l;const[m]=f,d=`${a.getValue()}`,_=+m.getValue(),C=new he(d);if(C.isError()||C.getRealNum()===0&&C.getINum()===0||_<=0)return g.create(h.NUM);const E=C.Log(_);return C.isError()?g.create(h.NUM):typeof E=="number"||S.isRealNum(E)?y.create(+E):U.create(E)}}class Lg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log(2);return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class xg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError()||u.getRealNum()===0&&u.getINum()===0)return g.create(h.NUM);const c=u.Log(10);return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class jg extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=new he(c);if(l.isError())return g.create(h.NUM);const f=+u.getValue();if(Number.isNaN(f))return g.create(h.VALUE);const m=l.Power(f);return l.isError()?g.create(h.NUM):typeof m=="number"||S.isRealNum(m)?y.create(+m):U.create(m)}}class Ug extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||S.isRealNum(t)?y.create(+t):U.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new he(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new he(t),a=new he(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Product(a)}return r}}class Tg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.getRealNum();return y.create(c)}}class vg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Sec();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Bg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Sech();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Ig extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Sin();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Fg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Sinh();return u.isError()?g.create(h.NUM):typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class kg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);if(u.getRealNum()===0&&u.getINum()===0)return y.create(0);const c=u.Sqrt();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class $g extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=`${a.getValue()}`,l=`${u.getValue()}`,f=new he(c),m=new he(l);if(f.isError()||m.isError()||f.isDifferentSuffixes(m))return g.create(h.NUM);const d=f.Sub(m);return typeof d=="number"||S.isRealNum(d)?y.create(+d):U.create(d)}}class Yg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="";for(let r=0;r<e.length;r++){if(t instanceof g)return t;const n=e[r];if(n.isArray()){let s=!1,a;if(n.iterator(u=>{if(t=this._handleSingleObject(u,t),t instanceof g)return s=!0,a=t,!1}),s)return a}else t=this._handleSingleObject(n,t)}return t instanceof g?t:typeof t=="number"||S.isRealNum(t)?y.create(+t):U.create(t)}_handleSingleObject(e,t){let r=t;if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);const n=`${e.getValue()}`;if(typeof t!="number"&&!t){const s=new he(n);if(s.isError())return g.create(h.NUM);r=s.toString()}else{const s=new he(t),a=new he(n);if(s.isError()||a.isError())return g.create(h.NUM);if(s.isDifferentSuffixes(a))return g.create(h.VALUE);r=s.Sum(a)}return r}}class Hg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Tan();return typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Gg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`,u=new he(a);if(u.isError())return g.create(h.NUM);const c=u.Tanh();return u.isError()?g.create(h.NUM):typeof c=="number"||S.isRealNum(c)?y.create(+c):U.create(c)}}class Wg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:d,errorObject:_,variants:C}=G(t);if(d)return _;const[E]=C;if(r=Math.floor(+E.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Js(c))return g.create(h.NUM);const l=c.length===10&&c.substring(0,1)==="7",f=l?Number.parseInt(c,8)-1073741824:Number.parseInt(c,8);if(f<-512||f>511)return g.create(h.NUM);let m;if(l){const d=(512+f).toString(2);m=`1${"0".repeat(9-d.length)}${d}`}else if(m=f.toString(2),t){if(r<m.length)return g.create(h.NUM);m="0".repeat(r-m.length)+m}return U.create(m)}}class Qg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const{isError:t,errorObject:r,variants:n}=G(e);if(t)return r;const[s]=n,a=`${s.getValue()}`;if(!Js(a))return g.create(h.NUM);let u=Number.parseInt(a,8);return u>=536870912&&(u-=1073741824),y.create(u)}}class qg extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){if(e.isNull())return g.create(h.NA);let r=0;if(t){const{isError:m,errorObject:d,variants:_}=G(t);if(m)return d;const[C]=_;if(r=Math.floor(+C.getValue()),Number.isNaN(r))return g.create(h.VALUE);if(r<0||r>10)return g.create(h.NUM)}const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=`${u.getValue()}`;if(!Js(c))return g.create(h.NUM);const l=Number.parseInt(c,8);let f;if(l>=536870912)f=`ff${(l+3221225472).toString(16)}`;else if(f=l.toString(16),t){if(r<f.length)return g.create(h.NUM);f="0".repeat(r-f.length)+f}return U.create(f.toLocaleUpperCase())}}const uu=[[Wh,Z.BESSELI],[Qh,Z.BESSELJ],[qh,Z.BESSELK],[Kh,Z.BESSELY],[Xh,Z.BIN2DEC],[Zh,Z.BIN2HEX],[zh,Z.BIN2OCT],[Jh,Z.BITAND],[eg,Z.BITLSHIFT],[tg,Z.BITOR],[rg,Z.BITRSHIFT],[ng,Z.BITXOR],[sg,Z.COMPLEX],[ag,Z.CONVERT],[ig,Z.DEC2BIN],[og,Z.DEC2HEX],[ug,Z.DEC2OCT],[cg,Z.DELTA],[lg,Z.ERF],[fg,Z.ERF_PRECISE],[mg,Z.ERFC],[hg,Z.ERFC_PRECISE],[gg,Z.GESTEP],[dg,Z.HEX2BIN],[Cg,Z.HEX2DEC],[_g,Z.HEX2OCT],[Ag,Z.IMABS],[Eg,Z.IMAGINARY],[bg,Z.IMARGUMENT],[yg,Z.IMCONJUGATE],[Rg,Z.IMCOS],[pg,Z.IMCOSH],[Ng,Z.IMCOT],[Vg,Z.IMCOTH],[Og,Z.IMCSC],[Mg,Z.IMCSCH],[Sg,Z.IMDIV],[Dg,Z.IMEXP],[wg,Z.IMLN],[Pg,Z.IMLOG],[xg,Z.IMLOG10],[Lg,Z.IMLOG2],[jg,Z.IMPOWER],[Ug,Z.IMPRODUCT],[Tg,Z.IMREAL],[vg,Z.IMSEC],[Bg,Z.IMSECH],[Ig,Z.IMSIN],[Fg,Z.IMSINH],[kg,Z.IMSQRT],[$g,Z.IMSUB],[Yg,Z.IMSUM],[Hg,Z.IMTAN],[Gg,Z.IMTANH],[Wg,Z.OCT2BIN],[Qg,Z.OCT2DEC],[qg,Z.OCT2HEX]];var J=(i=>(i.ACCRINT="ACCRINT",i.ACCRINTM="ACCRINTM",i.AMORDEGRC="AMORDEGRC",i.AMORLINC="AMORLINC",i.COUPDAYBS="COUPDAYBS",i.COUPDAYS="COUPDAYS",i.COUPDAYSNC="COUPDAYSNC",i.COUPNCD="COUPNCD",i.COUPNUM="COUPNUM",i.COUPPCD="COUPPCD",i.CUMIPMT="CUMIPMT",i.CUMPRINC="CUMPRINC",i.DB="DB",i.DDB="DDB",i.DISC="DISC",i.DOLLARDE="DOLLARDE",i.DOLLARFR="DOLLARFR",i.DURATION="DURATION",i.EFFECT="EFFECT",i.FV="FV",i.FVSCHEDULE="FVSCHEDULE",i.INTRATE="INTRATE",i.IPMT="IPMT",i.IRR="IRR",i.ISPMT="ISPMT",i.MDURATION="MDURATION",i.MIRR="MIRR",i.NOMINAL="NOMINAL",i.NPER="NPER",i.NPV="NPV",i.ODDFPRICE="ODDFPRICE",i.ODDFYIELD="ODDFYIELD",i.ODDLPRICE="ODDLPRICE",i.ODDLYIELD="ODDLYIELD",i.PDURATION="PDURATION",i.PMT="PMT",i.PPMT="PPMT",i.PRICE="PRICE",i.PRICEDISC="PRICEDISC",i.PRICEMAT="PRICEMAT",i.PV="PV",i.RATE="RATE",i.RECEIVED="RECEIVED",i.RRI="RRI",i.SLN="SLN",i.SYD="SYD",i.TBILLEQ="TBILLEQ",i.TBILLPRICE="TBILLPRICE",i.TBILLYIELD="TBILLYIELD",i.VDB="VDB",i.XIRR="XIRR",i.XNPV="XNPV",i.YIELD="YIELD",i.YIELDDISC="YIELDDISC",i.YIELDMAT="YIELDMAT",i))(J||{});function Gn(i,o,e,t){const r=wt(i,o,e),{days:n}=Ce(r,i,t);return n}function $e(i,o,e,t){let r;if(t===1){const n=wt(i,o,e);let s=ne(n);s=ur(s,12/e);const a=be(s);n<0&&e===1?r=365:r=a-n}else t===3?r=365/e:r=360/e;return r}function cu(i,o,e){const t=ne(i);let r=ne(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return r=ur(r,12/e),be(r)}function Qt(i,o,e){let t=0;const r=ne(i);let n=ne(o);for(;n>r;)n=ur(n,-12/e),t++;return t}function wt(i,o,e){const t=ne(i);let r=ne(o);for(r.setUTCFullYear(t.getUTCFullYear()),r<t&&r.setUTCFullYear(r.getUTCFullYear()+1);r>t;)r=ur(r,-12/e);return be(r)}function lu(i,o,e,t,r,n){const s=Gn(i,o,r,n),a=$e(i,o,r,n),u=Qt(i,o,r),c=(a-s)/a-1,l=t/r+1,f=e*100/r;let m=0,d=0;for(let E=1;E<=u;E++){const b=E+c,R=f/l**b;m+=b*R,d+=R}const _=u+c,C=100/l**_;return m+=_*C,d+=C,m/d/r}function Lr(i,o,e,t,r){let n;if(i===0)n=(e+t)/o;else{const s=(1+i)**o;n=r===1?(t*i/(s-1)+e*i/(1-1/s))/(1+i):t*i/(s-1)+e*i/(1-1/s)}return-n}function qt(i,o,e,t,r){let n;if(i===0)n=t+e*o;else{if(i===-1&&o===0)return Number.NaN;const s=(1+i)**o;n=r===1?t*s+e*(1+i)*(s-1)/i:t*s+e*(s-1)/i}return-n}function fu(i,o,e,t,r,n){const s=Lr(i,e,t,r,n);return(o===1?n===1?0:-t:n===1?qt(i,o-2,s,t,1)-s:qt(i,o-1,s,t,0))*i}function mu(i,o){let e=0;for(let t=1;t<=o.length;t++)e+=o[t-1]/(1+i)**t;return e}function hu(i,o,e,t,r,n,s,a,u){const c=Bt(e,t,u),l=$e(i,t,a,u);return c<l?Kg(i,o,e,t,r,n,s,a,u,c,l):Xg(i,o,e,t,r,n,s,a,u,l)}function Kg(i,o,e,t,r,n,s,a,u,c,l){let f=0;const m=Qt(i,o,a),d=Bt(i,t,u);f+=s/(1+n/a)**(m-1+d/l),f+=100*r/a*c/l/(1+n/a)**(d/l);for(let C=2;C<=m;C++)f+=100*r/a/(1+n/a)**(C-1+d/l);const _=Bt(e,i,u);return f-=100*r/a*_/l,f}function Xg(i,o,e,t,r,n,s,a,u,c){let l=0;const f=Qt(t,o,a),m=Zg(t,i,12/a);let d;if(u===2||u===3){const R=cu(i,t,a);d=Bt(i,R,u)}else{const R=wt(i,t,a),{days:p}=Ce(R,i,u);d=c-p}l+=s/(1+n/a)**(f+m+d/c);const _=Qt(e,t,a);let C=t,E=0,b=0;for(let R=_;R>=1;R--){const p=$t(C,-12/a,!1),V=u===1?Bt(p,C,u):c,M=R>1?V:Bt(e,C,u);E+=M/V;const D=e>p?e:p,w=i<C?i:C,P=Bt(D,w,u);b+=P/V,C=p}l+=100*r/a*E/(1+n/a)**(m+d/c);for(let R=1;R<=f;R++)l+=100*r/a/(1+n/a)**(R+m+d/c);return l-=100*r/a*b,l}function Bt(i,o,e){const{days:t}=Ce(i,o,e);return i<o?t:0}function gu(i,o,e){const t=ne(i),r=t.getUTCFullYear(),n=t.getUTCMonth(),s=t.getUTCDate(),a=or(r,n,s),u=ne(o),c=u.getUTCFullYear(),l=u.getUTCMonth(),f=u.getUTCDate(),m=or(c,l,f);return!(s!==f&&!(a&&m)||Math.abs((c-r)*12+(l-n))%(12/e)!==0)}function mr(i,o,e){return wt(i,o,e)>=0}function $t(i,o,e){let t=ne(i);if(t=ur(t,o),e){const r=t.getUTCFullYear(),n=t.getUTCMonth(),s=Pr(r,n);t.setUTCDate(s)}return be(t)}function Zg(i,o,e,t){const r=ne(i),n=ne(o),s=r.getUTCFullYear(),a=r.getUTCMonth(),u=r.getUTCDate(),c=n.getUTCFullYear(),l=n.getUTCMonth(),f=n.getUTCDate(),m=or(s,a,u),d=!m&&a!==1&&u>28&&u<Pr(s,a)?or(c,l,f):m,_=$t(o,0,d);let C=1+ +(o<_),E=$t(_,e,d);for(;!(e>0?E>=o:E<=o);)E=$t(E,e,d),C++;return C}function da(i,o){let n=1,s=0,a=i,u;for(;n>1e-7&&s<500;){const c=(o(a+1e-7)-o(a-1e-7))/2e-7;u=a-o(a)/c,s++,n=Math.abs(u-a),a=u}return Number.isNaN(a)||Math.abs(a)===1/0||s===500?zg(i,o):a}function zg(i,o){const r=Number.MAX_VALUE,n=-1,s=1.6;let a=i-.01<=n?n+1e-7:i-.01,u=i+.01>=r?r-1e-7:i+.01,c,l,f=0;if(i<=n||i>=r)return g.create(h.NUM);for(let E=0;E<60;E++){c=a<=n?n+1e-7:a,l=u>=r?r-1e-7:u;const b=o(c),R=o(l);if(b*R<=0)break;if(b*R>0)a=c+s*(c-l),u=l+s*(l-c);else return g.create(h.NUM);if(E===59)return g.create(h.NUM)}c=c,l=l;let m=o(c);const d=o(l);let _,C;if(Math.abs(m)<1e-7||Math.abs(d)<1e-7)return g.create(h.NUM);do C=c+(l-c)/2,_=o(C),m*_<0?l=C:c=C,m=o(c),f++;while(Math.abs(_)>1e-7&&f<60);return C}function Qr(i,o,e,t,r,n,s){const a=Qt(i,o,n),u=$e(i,o,n,s),c=Gn(i,o,n,s);if(a===1){const m=u-c,d=100*e/n+r,_=t/n*m/u+1,C=100*e/n*c/u;return d/_-C}const l=u-c;let f=r/(1+t/n)**(a-1+l/u);for(let m=1;m<=a;m++)f+=100*e/n/(1+t/n)**(m-1+l/u);return f-=100*e/n*c/u,f}function Ls(i,o,e,t,r){let n=0,s=r/e;s>=1?(s=1,n=t===1?i:0):n=i*(1-s)**(t-1);const a=i*(1-s)**t;let u=0;return a<o?u=n-o:u=n-a,u<0&&(u=0),u}class Jg extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){const l=u!=null?u:y.create(0),f=c!=null?c:v.create(!0),{isError:m,errorObject:d,variants:_}=G(e,t,r,n,s,a,l);if(m)return d;const[C,E,b,R,p,V,M]=_,D=$(C);if(typeof D!="number")return D;const w=$(E);if(typeof w!="number")return w;const P=$(b);if(typeof P!="number")return P;const L=+R.getValue(),B=+p.getValue(),j=Math.floor(+V.getValue()),k=Math.floor(+M.getValue()),Q=+f.getValue();return Number.isNaN(L)||Number.isNaN(B)||Number.isNaN(j)||Number.isNaN(k)||Number.isNaN(Q)?g.create(h.VALUE):L<=0||B<=0||![1,2,4].includes(j)||k<0||k>4||Math.floor(D)>=Math.floor(P)?g.create(h.NUM):this._getResult(D,w,P,L,B,j,k,Q)}_getResult(e,t,r,n,s,a,u,c){let l=wt(e,t,a);if(l<=0)return y.create(0);l=wt(r,t,a);const f=12/a,m=ne(t),d=m.getUTCFullYear(),_=m.getUTCMonth(),C=m.getUTCDate(),E=or(d,_,C);let b=$t(t,-f,E);if(r>t&&c)for(b=t;b<r;)b=$t(b,f,E);let R=e>b?e:b,{days:p}=Ce(R,r,u);if(l>=e){const{days:L}=Ce(R,r,u?4:0);p=L}r<R&&(p=-p);let V=$e(b,t,a,u),M=p/V,D=b,w=e;for(;D>e;){w=D,D=$t(D,-f,E),R=e>D?e:D;const{days:L}=Ce(R,w,u);if(u===0)w>=R||e<=D?p=L:p=-L,V=$e(D,w,a,u);else if(p=w<R?-L:L,u===3)V=365/a;else{const{days:B}=Ce(D,w,u);V=w<D?-B:B}M+=e<=D?c?1:0:p/V}const P=s*n/a*M;return y.create(P)}}class e1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=G(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>Math.floor(b))return g.create(h.NUM);if(Math.floor(E)===Math.floor(b))return y.create(0);const{days:M,yearDays:D}=Ce(E,b,V),w=p*R*M/D;return y.create(w)}}class t1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){const c=u!=null?u:y.create(0),{isError:l,errorObject:f,variants:m}=G(e,t,r,n,s,a,c);if(l)return f;const[d,_,C,E,b,R,p]=m,V=$(_);if(typeof V!="number")return V;const M=$(C);if(typeof M!="number")return M;const D=+d.getValue(),w=+E.getValue();let P=+b.getValue();const L=+R.getValue(),B=Math.floor(+p.getValue());return Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(B)?g.create(h.VALUE):D<=0||w<0||D<w||Math.floor(V)>Math.floor(M)||P<0||L<=0||![0,1,3,4].includes(B)?g.create(h.NUM):(P>1?P=Math.floor(P):P=Math.ceil(P),this._getResult(D,V,M,w,P,L,B))}_getResult(e,t,r,n,s,a,u){const c=e-n,l=e*a,{days:f,yearDays:m}=Ce(t,r,u),d=f/m,_=Math.ceil(c/l-d);if(_<0)return y.create(0);let C=l;return s===0?C=l*d:s===_?C=c-l*(d+s-1):s>_&&(C=0),y.create(C)}}class r1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C))return g.create(h.NUM);const R=Gn(_,C,E,b);return y.create(R)}}class n1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C))return g.create(h.NUM);const R=$e(_,C,E,b);return y.create(R)}}class s1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C))return g.create(h.NUM);const R=ne(_),p=ne(C);for(p.setUTCFullYear(R.getUTCFullYear()),p<R&&p.setUTCFullYear(p.getUTCFullYear()+1);p>R;)p.setUTCMonth(p.getUTCMonth()-12/E);p.setUTCMonth(p.getUTCMonth()+12/E);const V=be(p),{days:M}=Ce(_,V,b);return y.create(M)}}class a1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C))return g.create(h.NUM);const R=cu(_,C,E);return y.create(R)}}class i1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C)||wt(_,C,E)<0)return g.create(h.NUM);const p=Qt(_,C,E);return y.create(p)}}class o1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=n!=null?n:y.create(0),{isError:a,errorObject:u,variants:c}=G(e,t,r,s);if(a)return u;const[l,f,m,d]=c,_=$(l);if(typeof _!="number")return _;const C=$(f);if(typeof C!="number")return C;const E=Math.floor(+m.getValue()),b=Math.floor(+d.getValue());if(Number.isNaN(E)||Number.isNaN(b))return g.create(h.VALUE);if(![1,2,4].includes(E)||b<0||b>4||Math.floor(_)>=Math.floor(C))return g.create(h.NUM);let R=wt(_,C,E);return R<0&&(R=0),y.create(R)}}class u1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=G(e,t,r,n,s,a);if(u)return c;const[f,m,d,_,C,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+_.getValue(),M=+C.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(M)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||M<1||V>M||V>R||M>R||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(M)!==M&&Math.trunc(V)===Math.trunc(M)?y.create(0):this._getResult(b,R,p,V,M,D)}_getResult(e,t,r,n,s,a){const u=Lr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(a===0&&(c=-r),l++);let f=!1;for(let m=l;m<=s;m++){const d=a===1?qt(e,m-2,u,r,1):qt(e,m-1,u,r,0);if(d===0){f=!0;break}c+=a===1?d-u:d}return c*=e,(c<u*(s-n+1)||f)&&(c=u*(s-n+1)),y.create(c)}}class c1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=G(e,t,r,n,s,a);if(u)return c;const[f,m,d,_,C,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+_.getValue(),M=+C.getValue(),D=+E.getValue();return Number.isNaN(b)||Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(M)||Number.isNaN(D)?g.create(h.VALUE):b<=0||R<=0||p<=0||V<1||M<1||V>M||![0,1].includes(D)?g.create(h.NUM):Math.trunc(V)!==V&&Math.trunc(M)!==M&&Math.trunc(V)===Math.trunc(M)?y.create(0):this._getResult(b,R,p,V,M,D)}_getResult(e,t,r,n,s,a){const u=Lr(e,t,r,0,a);let c=0,l=Math.ceil(n);l===1&&(c=a===0?u+r*e:u,l++);for(let f=l;f<=s;f++)c+=a===1?u-(qt(e,f-2,u,r,1)-u)*e:u-qt(e,f-1,u,r,0)*e;return y.create(c)}}class l1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(12);a.isNull()&&(a=y.create(12));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),_=O(u,c,a,g.create(h.NA)),C=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),M=d.get(b,R),D=_.get(b,R),{isError:w,errorObject:P,variants:L}=F(E,p,V,M,D);if(w)return P;const[B,j,k,Q,te]=L,z=+B.getValue(),W=+j.getValue(),ce=+k.getValue();let de=+Q.getValue();const Ee=Math.floor(+te.getValue());return z<0||W<0||ce<=0||de<=0||Math.floor(de)>Math.floor(ce)||Ee<1||Ee>12?g.create(h.NUM):(de<1&&(de=1),de=Math.floor(de),this._getResult(z,W,ce,de,Ee,b,R))});return u===1&&c===1?C.get(0,0):C}_getResult(e,t,r,n,s,a,u){const c=+(1-(t/e)**(1/r)).toFixed(3),l=e*c*s/12;let f=l,m=0;const d=n===r?r-1:n;for(let C=2;C<=d;C++)m=(e-f)*c,f+=m;let _;return n===1?_=l:n===r?_=(e-f)*c:_=m,Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):a===0&&u===0?y.create(_,Ye(this.getLocale())):y.create(_)}}class f1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(2);a.isNull()&&(a=y.create(2));const u=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,a.isArray()?a.getRowCount():1),c=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,a.isArray()?a.getColumnCount():1),l=O(u,c,e,g.create(h.NA)),f=O(u,c,t,g.create(h.NA)),m=O(u,c,r,g.create(h.NA)),d=O(u,c,n,g.create(h.NA)),_=O(u,c,a,g.create(h.NA)),C=l.map((E,b,R)=>{const p=f.get(b,R),V=m.get(b,R),M=d.get(b,R),D=_.get(b,R),{isError:w,errorObject:P,variants:L}=F(E,p,V,M,D);if(w)return P;const[B,j,k,Q,te]=L,z=+B.getValue(),W=+j.getValue(),ce=+k.getValue(),de=+Q.getValue(),Ee=+te.getValue();if(z<0||W<0||ce<=0||de<=0||de>ce||Ee<=0)return g.create(h.NUM);const ye=Ls(z,W,ce,de,Ee);return Number.isNaN(ye)||!Number.isFinite(ye)?g.create(h.NUM):b===0&&R===0?y.create(ye,Ye(this.getLocale())):y.create(ye)});return u===1&&c===1?C.get(0,0):C}}class m1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=G(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:M,yearDays:D}=Ce(E,b,V),w=(p-R)/p*(D/M);return y.create(w)}}class h1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);f+=c%1*10**Math.ceil(Math.log(l)/Math.LN10)/l;const m=10**(Math.ceil(Math.log(l)/Math.LN2)+1);return f=Math.round(f*m)/m,y.create(f)}}class g1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l<0)return g.create(h.NUM);if(l>=0&&l<1)return g.create(h.DIV_BY_ZERO);l=Number.parseInt(`${l}`,10);let f=Number.parseInt(`${c}`,10);return f+=c%1*10**-Math.ceil(Math.log(l)/Math.LN10)*l,y.create(f)}}class d1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,_,C,E,b]=f,R=$(m);if(typeof R!="number")return R;const p=$(d);if(typeof p!="number")return p;const V=+_.getValue(),M=+C.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(M)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||M<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p)||R<=0||p<=366)return g.create(h.NUM);const P=lu(R,p,V,M,D,w);return y.create(P)}}class C1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=(1+c/l)**l-1;return y.create(f)}}class _1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p),{isError:P,errorObject:L,variants:B}=F(b,V,M,D,w);if(P)return L;const[j,k,Q,te,z]=B,W=+j.getValue(),ce=+k.getValue(),de=+Q.getValue(),Ee=+te.getValue(),ye=+z.getValue(),ge=qt(W,ce,de,Ee,ye?1:0);return Number.isNaN(ge)||!Number.isFinite(ge)?g.create(h.NUM):R===0&&p===0?y.create(ge,Ye(this.getLocale())):y.create(ge)});return c===1&&l===1?E.get(0,0):E}}class A1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e);if(r)return n;const[a]=s,u=+a.getValue();if(Number.isNaN(u))return g.create(h.VALUE);let c=u;if(t.isArray()){const l=t.getArrayValue().flat();for(let f=0;f<l.length;f++){const m=l[f];if(m.isBoolean())return g.create(h.VALUE);const d=+m.getValue();if(Number.isNaN(d))return g.create(h.VALUE);c*=1+d}}else{if(t.isBoolean())return g.create(h.VALUE);const l=+t.getValue();if(Number.isNaN(l))return g.create(h.VALUE);c*=1+l}return y.create(c)}}class E1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=s!=null?s:y.create(0),{isError:u,errorObject:c,variants:l}=G(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||Math.floor(E)>=Math.floor(b))return g.create(h.NUM);const{days:M,yearDays:D}=Ce(E,b,V),w=(p-R)/R*(D/M);return y.create(w)}}class b1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),_=O(l,f,r,g.create(h.NA)),C=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,M)=>{const D=d.get(V,M),w=_.get(V,M),P=C.get(V,M),L=E.get(V,M),B=b.get(V,M),{isError:j,errorObject:k,variants:Q}=F(p,D,w,P,L,B);if(j)return k;const[te,z,W,ce,de,Ee]=Q,ye=+te.getValue(),ge=+z.getValue(),Ue=+W.getValue(),_t=+ce.getValue(),Zt=+de.getValue(),At=+Ee.getValue();if(ge<1||Math.floor(ge)>Math.ceil(Ue))return g.create(h.NUM);const Xe=fu(ye,ge,Ue,_t,Zt,At?1:0);return Number.isNaN(Xe)||!Number.isFinite(Xe)?g.create(h.NUM):V===0&&M===0?y.create(Xe,Ye(this.getLocale())):y.create(Xe)});return l===1&&f===1?R.get(0,0):R}}class y1 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(.1);return r.isNull()&&(r=y.create(.1)),r.isArray()?r.map((n,s,a)=>this._handleSingleObject(e,n,s,a)):this._handleSingleObject(e,r)}_handleSingleObject(e,t,r=0,n=0){if(e.isError())return e;if(t.isError())return t;if(e.isNull())return g.create(h.VALUE);if(!e.isArray())return g.create(h.NUM);const{_values:s,valuesHasError:a}=this._getValues(e);if(a)return g.create(h.VALUE);let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()))return u;const c=+u.getValue(),{positive:l,negative:f}=this._checkValues(s);if(!l||!f)return g.create(h.NUM);const m=da(c,d=>mu(d,s));return typeof m!="number"?m:r===0&&n===0?y.create(m,"0%"):y.create(m)}_getValues(e){const t=[];let r=!1;return e.iterator(n=>{const s=n;if(s.isError())return r=!0,!1;if(s.isNull()||s.isBoolean())return!0;const a=+s.getValue();if(Number.isNaN(a))return!0;t.push(a)}),{_values:t,valuesHasError:r}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}}class R1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C),{isError:p,errorObject:V,variants:M}=F(d,E,b,R);if(p)return V;const[D,w,P,L]=M,B=+D.getValue(),j=+w.getValue(),k=+P.getValue(),Q=+L.getValue();if(k===0)return g.create(h.DIV_BY_ZERO);const te=Q*B*(j/k-1);return y.create(te)});return s===1&&a===1?m.get(0,0):m}}class p1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,_,C,E,b]=f,R=$(m);if(typeof R!="number")return R;const p=$(d);if(typeof p!="number")return p;const V=+_.getValue(),M=+C.getValue(),D=Math.floor(+E.getValue()),w=Math.floor(+b.getValue());if(Number.isNaN(V)||Number.isNaN(M)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);if(V<0||M<0||![1,2,4].includes(D)||w<0||w>4||Math.floor(R)>=Math.floor(p))return g.create(h.NUM);let P=lu(R,p,V,M,D,w);return P/=1+M/D,y.create(P)}}class N1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{_values:n,numberValues:s,positive:a,negative:u}=this._getValues(e),c=Math.max(t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),l=Math.max(t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),f=O(c,l,t,g.create(h.NA)),m=O(c,l,r,g.create(h.NA)),d=f.map((_,C,E)=>{const b=m.get(C,E);if(e.isError())return e;if(b.isError())return b;if(n.isError())return n;if(!a||!u)return g.create(h.DIV_BY_ZERO);const R=+_.getValue(),p=+b.getValue();if(Number.isNaN(R)||Number.isNaN(p))return g.create(h.VALUE);if(p===-1)return g.create(h.DIV_BY_ZERO);const V=this._getResult(s,R,p);return C===0&&E===0?y.create(V,"0%"):y.create(V)});return c===1&&l===1?d.get(0,0):d}_getValues(e){let t=e,r=[],n=!1,s=!1;if(!e.isError())if(e.isNull())t=g.create(h.VALUE);else if(!e.isArray())t=g.create(h.DIV_BY_ZERO);else{const{numberValues:a,valuesHasError:u,errorObject:c,positive:l,negative:f}=this._checkValues(e);u&&(t=c),r=a,n=l,s=f}return{_values:t,numberValues:r,positive:n,negative:s}}_checkValues(e){const t=[];let r=!1,n=g.create(h.VALUE),s=!1,a=!1;return e.iterator(u=>{const c=u;if(c.isError())return r=!0,n=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;l>0&&(s=!0),l<0&&(a=!0),t.push(l)}),{numberValues:t,valuesHasError:r,errorObject:n,positive:s,negative:a}}_getResult(e,t,r){const n=e.length,s=[],a=[];for(let d=0;d<n;d++)e[d]>0?a.push(e[d]):e[d]<0&&s.push(e[d]);const u=this._npv(r,e,"positive"),c=this._npv(t,e,"negative"),l=-u*(1+r)**n,f=c*(1+t);return(l/f)**(1/(n-1))-1}_npv(e,t,r){let n=0;for(let s=1;s<=t.length;s++){const a=t[s-1];(r==="positive"&&a>0||r==="negative"&&a<0)&&(n+=a/(1+e)**s)}return n}}class V1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue();let l=Math.floor(+u.getValue());if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(c<=0||l<1)return g.create(h.NUM);l=Number.parseInt(`${l}`,10);const f=((c+1)**(1/l)-1)*l;return y.create(f)}}class O1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p),{isError:P,errorObject:L,variants:B}=F(b,V,M,D,w);if(P)return L;const[j,k,Q,te,z]=B,W=+j.getValue(),ce=+k.getValue(),de=+Q.getValue(),Ee=+te.getValue();let ye=+z.getValue();if(ye=ye?1:0,W===0&&ce===0)return g.create(h.DIV_BY_ZERO);let ge;if(W===0)ge=-(de+Ee)/ce;else{const Ue=ce*(1+W*ye)-Ee*W,_t=de*W+ce*(1+W*ye);ge=Math.log(Ue/_t)/Math.log(1+W)}return Number.isNaN(ge)||!Number.isFinite(ge)?g.create(h.NUM):y.create(ge)});return c===1&&l===1?E.get(0,0):E}}class M1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsLocale",!0)}calculate(e,...t){if(e.isError())return e;const{isError:r,errorObject:n,values:s}=this._getValues(t);return e.isArray()?e.map((a,u,c)=>this._handleSingleObject(a,r,n,s,u,c)):this._handleSingleObject(e,r,n,s)}_handleSingleObject(e,t,r,n,s=0,a=0){let u=e;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(t)return r;const c=+e.getValue(),l=mu(c,n);return Number.isNaN(l)||Math.abs(l)===1/0?g.create(h.DIV_BY_ZERO):s===0&&a===0?y.create(l,Ye(this.getLocale())):y.create(l)}_getValues(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return{isError:!0,errorObject:n};if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{const c=u;if(c.isError())return s=!0,a=c,!1;if(c.isNull()||c.isBoolean())return!0;const l=+c.getValue();if(Number.isNaN(l))return!0;t.push(l)}),s)return{isError:s,errorObject:a}}else{const s=+n.getValue();if(Number.isNaN(s))return{isError:!0,errorObject:g.create(h.VALUE)};t.push(s)}}return{isError:!1,values:t}}}class S1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:_}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[C,E,b,R,p,V,M,D,w]=_,P=$(C);if(typeof P!="number")return P;const L=$(E);if(typeof L!="number")return L;const B=$(b);if(typeof B!="number")return B;const j=$(R);if(typeof j!="number")return j;const k=+p.getValue(),Q=+V.getValue(),te=+M.getValue(),z=Math.floor(+D.getValue()),W=Math.floor(+w.getValue());if(Number.isNaN(k)||Number.isNaN(Q)||Number.isNaN(te)||Number.isNaN(z)||Number.isNaN(W))return g.create(h.VALUE);if(k<0||Q<0||te<=0||![1,2,4].includes(z)||W<0||W>4||!this._validDate(L,j,P,B,z))return g.create(h.NUM);const ce=hu(P,L,B,j,k,Q,te,z,W);return y.create(ce)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&gu(e,t,s)&&mr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}}class D1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c,l){let f=l!=null?l:y.create(0);f.isNull()&&(f=y.create(0));const{isError:m,errorObject:d,variants:_}=je(e,t,r,n,s,a,u,c,f);if(m)return d;const[C,E,b,R,p,V,M,D,w]=_,P=$(C);if(typeof P!="number")return P;const L=$(E);if(typeof L!="number")return L;const B=$(b);if(typeof B!="number")return B;const j=$(R);if(typeof j!="number")return j;const k=+p.getValue(),Q=+V.getValue(),te=+M.getValue(),z=Math.floor(+D.getValue()),W=Math.floor(+w.getValue());return Number.isNaN(k)||Number.isNaN(Q)||Number.isNaN(te)||Number.isNaN(z)||Number.isNaN(W)?g.create(h.VALUE):k<0||Q<=0||te<=0||![1,2,4].includes(z)||W<0||W>4||!this._validDate(L,j,P,B,z)?g.create(h.NUM):this._getResult(P,L,B,j,k,Q,te,z,W)}_validDate(e,t,r,n,s){return this._getDateCorrectOrder(e,t,r,n)&&gu(e,t,s)&&mr(n,e,s)}_getDateCorrectOrder(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&Math.floor(r)>Math.floor(n)}_getResult(e,t,r,n,s,a,u,c,l){const{days:f}=Ce(e,t,l),m=(s*f*100-(a-100))/((a-100)*.25*(1+2*f)+f*100);function d(C){return a-hu(e,t,r,n,s,C,u,c,l)}const _=da(m,C=>d(C));return typeof _!="number"?_:y.create(_)}}class w1 extends N{constructor(){super(...arguments);A(this,"minParams",7);A(this,"maxParams",8)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[_,C,E,b,R,p,V,M]=d,D=$(_);if(typeof D!="number")return D;const w=$(C);if(typeof w!="number")return w;const P=$(E);if(typeof P!="number")return P;const L=+b.getValue(),B=+R.getValue(),j=+p.getValue(),k=Math.floor(+V.getValue()),Q=Math.floor(+M.getValue());if(Number.isNaN(L)||Number.isNaN(B)||Number.isNaN(j)||Number.isNaN(k)||Number.isNaN(Q))return g.create(h.VALUE);if(L<0||B<0||j<=0||![1,2,4].includes(k)||Q<0||Q>4||!this._validDate(w,D,P,k))return g.create(h.NUM);const te=this._getResult(D,w,P,L,B,j,k,Q);return y.create(te)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&mr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(a*u+100*n*(m-f*(1+s*d/u)))/(s*d+u)}_getCoupDate(e,t,r){const n=ne(e),s=ne(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return be(s)}_getFrac(e,t,r,n,s){const a=ne(e),u=ne(t),c=ne(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=be(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=be(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let _=m/d;const C=ne(f),E=ne(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)C.setUTCMonth(C.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),_+=1;l=be(C),f=be(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return _+=b/R,_}}class P1 extends N{constructor(){super(...arguments);A(this,"minParams",8);A(this,"maxParams",9)}calculate(e,t,r,n,s,a,u,c){let l=c!=null?c:y.create(0);l.isNull()&&(l=y.create(0));const{isError:f,errorObject:m,variants:d}=je(e,t,r,n,s,a,u,l);if(f)return m;const[_,C,E,b,R,p,V,M]=d,D=$(_);if(typeof D!="number")return D;const w=$(C);if(typeof w!="number")return w;const P=$(E);if(typeof P!="number")return P;const L=+b.getValue(),B=+R.getValue(),j=+p.getValue(),k=Math.floor(+V.getValue()),Q=Math.floor(+M.getValue());if(Number.isNaN(L)||Number.isNaN(B)||Number.isNaN(j)||Number.isNaN(k)||Number.isNaN(Q))return g.create(h.VALUE);if(L<0||B<=0||j<=0||![1,2,4].includes(k)||Q<0||Q>4||!this._validDate(w,D,P,k))return g.create(h.NUM);const te=this._getResult(D,w,P,L,B,j,k,Q);return y.create(te)}_validDate(e,t,r,n){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)&&mr(r,e,n)}_getResult(e,t,r,n,s,a,u,c){const l=this._getCoupDate(t,r,u),f=this._getFrac(r,e,l,u,c),m=this._getFrac(r,t,l,u,c),d=this._getFrac(e,t,l,u,c);return(u*(a-s)+100*n*(m-f))/(d*s+100*n*f*d/u)}_getCoupDate(e,t,r){const n=ne(e),s=ne(t);for(s.setUTCFullYear(n.getUTCFullYear()),s>n&&s.setUTCFullYear(s.getUTCFullYear()-1);s<n;)s.setUTCMonth(s.getUTCMonth()+12/r);return be(s)}_getFrac(e,t,r,n,s){const a=ne(e),u=ne(t),c=ne(r);for(c.setUTCFullYear(a.getUTCFullYear()),c<a&&c.setUTCFullYear(c.getUTCFullYear()+1);c>a;)c.setUTCMonth(c.getUTCMonth()-12/n);let l=be(c);c.setUTCMonth(c.getUTCMonth()+12/n);let f=be(c);if(f>=t){const{days:p}=Ce(e,t,s),V=$e(l,f,n,s);return p/V}const{days:m}=Ce(e,f,s),d=$e(l,f,n,s);let _=m/d;const C=ne(f),E=ne(f);for(E.setUTCMonth(E.getUTCMonth()+12/n);E<u;)C.setUTCMonth(C.getUTCMonth()+12/n),E.setUTCMonth(E.getUTCMonth()+12/n),_+=1;l=be(C),f=be(E);const{days:b}=Ce(l,t,s),R=$e(l,f,n,s);return _+=b/R,_}}class L1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d),{isError:E,errorObject:b,variants:R}=F(f,_,C);if(E)return b;const[p,V,M]=R,D=+p.getValue(),w=+V.getValue(),P=+M.getValue();if(D<=-1)return g.create(h.NUM);const L=(Math.log(P)-Math.log(w))/Math.log(1+D);return Number.isNaN(L)||!Number.isFinite(L)?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class x1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p),{isError:P,errorObject:L,variants:B}=F(b,V,M,D,w);if(P)return L;const[j,k,Q,te,z]=B,W=+j.getValue(),ce=+k.getValue(),de=+Q.getValue(),Ee=+te.getValue(),ye=+z.getValue();if(W<=-1)return g.create(h.NUM);const ge=Lr(W,ce,de,Ee,ye?1:0);return Number.isNaN(ge)||!Number.isFinite(ge)?g.create(h.NUM):R===0&&p===0?y.create(ge,Ye(this.getLocale())):y.create(ge)});return c===1&&l===1?E.get(0,0):E}}class j1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a){const u=s!=null?s:y.create(0),c=a!=null?a:y.create(0),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),_=O(l,f,r,g.create(h.NA)),C=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.map((p,V,M)=>{const D=d.get(V,M),w=_.get(V,M),P=C.get(V,M),L=E.get(V,M),B=b.get(V,M),{isError:j,errorObject:k,variants:Q}=F(p,D,w,P,L,B);if(j)return k;const[te,z,W,ce,de,Ee]=Q,ye=+te.getValue(),ge=+z.getValue(),Ue=+W.getValue(),_t=+ce.getValue(),Zt=+de.getValue(),At=+Ee.getValue();if(ge<1||Math.floor(ge)>Math.ceil(Ue)||ge-Ue>=1)return g.create(h.NUM);const Xe=Lr(ye,Ue,_t,Zt,At?1:0)-fu(ye,ge,Ue,_t,Zt,At?1:0);return Number.isNaN(Xe)||!Number.isFinite(Xe)?g.create(h.NUM):V===0&&M===0?y.create(Xe,Ye(this.getLocale())):y.create(Xe)});return l===1&&f===1?R.get(0,0):R}}class U1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,_,C,E,b,R,p]=m,V=$(d);if(typeof V!="number")return V;const M=$(_);if(typeof M!="number")return M;const D=+C.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),B=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(B))return g.create(h.VALUE);if(D<0||w<0||P<=0||![1,2,4].includes(L)||B<0||B>4||V>=M||!mr(V,M,L))return g.create(h.NUM);const j=Qr(V,M,D,w,P,L,B);return y.create(j)}}class T1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:M,yearDays:D}=Ce(E,b,V),w=p-R*p*M/D;return y.create(w)}}class v1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,_,C,E,b]=f,R=$(m);if(typeof R!="number")return R;const p=$(d);if(typeof p!="number")return p;const V=$(_);if(typeof V!="number")return V;const M=+C.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(M)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(M<0||D<0||w<0||w>4||!P)return g.create(h.NUM);const L=iu(R,w),{days:B}=Ce(R,p,w),{days:j}=Ce(V,p,w),{days:k}=Ce(V,R,w),Q=(100+j/L*M*100)/(1+B/L*D)-k/L*M*100;return y.create(Q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}class B1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsLocale",!0)}calculate(e,t,r,n,s){const a=n!=null?n:y.create(0),u=s!=null?s:y.create(0),c=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,e,g.create(h.NA)),m=O(c,l,t,g.create(h.NA)),d=O(c,l,r,g.create(h.NA)),_=O(c,l,a,g.create(h.NA)),C=O(c,l,u,g.create(h.NA)),E=f.map((b,R,p)=>{const V=m.get(R,p),M=d.get(R,p),D=_.get(R,p),w=C.get(R,p),{isError:P,errorObject:L,variants:B}=F(b,V,M,D,w);if(P)return L;const[j,k,Q,te,z]=B,W=+j.getValue(),ce=+k.getValue(),de=+Q.getValue(),Ee=+te.getValue();let ye=+z.getValue();ye=ye?1:0;const ge=W===0?-de*ce-Ee:((1-(1+W)**ce)/W*de*(1+W*ye)-Ee)/(1+W)**ce;return Number.isNaN(ge)||!Number.isFinite(ge)?g.create(h.NUM):R===0&&p===0?y.create(ge,Ye(this.getLocale())):y.create(ge)});return c===1&&l===1?E.get(0,0):E}}class I1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){const u=n!=null?n:y.create(0),c=s!=null?s:y.create(0),l=a!=null?a:y.create(.1),f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),_=O(f,m,t,g.create(h.NA)),C=O(f,m,r,g.create(h.NA)),E=O(f,m,u,g.create(h.NA)),b=O(f,m,c,g.create(h.NA)),R=O(f,m,l,g.create(h.NA)),p=d.map((V,M,D)=>{const w=_.get(M,D),P=C.get(M,D),L=E.get(M,D),B=b.get(M,D),j=R.get(M,D),{isError:k,errorObject:Q,variants:te}=F(V,w,P,L,B,j);if(k)return Q;const[z,W,ce,de,Ee,ye]=te,ge=+z.getValue(),Ue=+W.getValue(),_t=+ce.getValue(),Zt=+de.getValue();let At=+Ee.getValue();const Xe=+ye.getValue();return At=At?1:0,ge<=0||Ue>=0?g.create(h.NUM):this._getResult(ge,Ue,_t,Zt,At,Xe,M,D)});return f===1&&m===1?p.get(0,0):p}_getResult(e,t,r,n,s,a,u,c){let m=a;for(let d=0;d<20;d++){if(m<=-1)return g.create(h.NUM);let _,C;if(Math.abs(m)<1e-10?_=r*(1+e*m)+t*(1+m*s)*e+n:(C=(1+m)**e,_=r*C+t*(1/m+s)*(C-1)+n),Math.abs(_)<1e-10)break;let E;if(Math.abs(m)<1e-10)E=r*e+t*s*e;else{C=(1+m)**e;const b=e*(1+m)**(e-1);E=r*b+t*(1/m+s)*b+t*(-1/(m*m))*(C-1)}m-=_/E}return u===0&&c===0?y.create(m,"0%"):y.create(m)}}class F1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:M,yearDays:D}=Ce(E,b,V),w=R/(1-p*M/D);return w<0?g.create(h.NUM):y.create(w)}}class k1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d),{isError:E,errorObject:b,variants:R}=F(f,_,C);if(E)return b;const[p,V,M]=R,D=+p.getValue(),w=+V.getValue(),P=+M.getValue();if(D<=0)return g.create(h.NUM);if(w===0&&P===0)return y.create(0);const L=(P/w)**(1/D)-1;return Number.isNaN(L)||!Number.isFinite(L)||P/w<0?g.create(h.NUM):y.create(L)});return n===1&&s===1?l.get(0,0):l}}class $1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.map((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);if(_.isError())return _;if(C.isError())return C;const E=+f.getValue(),b=+_.getValue(),R=+C.getValue();if(Number.isNaN(E)||Number.isNaN(b)||Number.isNaN(R))return g.create(h.VALUE);if(R===0)return g.create(h.DIV_BY_ZERO);const p=(E-b)/R;return m===0&&d===0?y.create(p,Ye(this.getLocale())):y.create(p)});return n===1&&s===1?l.get(0,0):l}}class Y1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4);A(this,"needsLocale",!0)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.map((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);if(E.isError())return E;if(b.isError())return b;if(R.isError())return R;const p=+d.getValue(),V=+E.getValue(),M=+b.getValue(),D=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V)||Number.isNaN(M)||Number.isNaN(D))return g.create(h.VALUE);if(V<0||M<=0||D>M)return g.create(h.NUM);const w=(p-V)*(M-D+1)*2/(M*(M+1));return _===0&&C===0?y.create(w,Ye(this.getLocale())):y.create(w)});return s===1&&a===1?m.get(0,0):m}}class H1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=$(u);if(typeof f!="number")return f;const m=$(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const _=Math.floor(m)-Math.floor(f),E=ne(f).getUTCFullYear(),b=Hn(E);if(_>b)return g.create(h.NUM);let R=365*d/(360-d*_);if(_>182){const p=100*(1-d*_/360),V=_/365;if(R=(-V+Math.sqrt(V*V-(V*2-1)*(1-100/p)))/(V-.5),Number.isNaN(R))return g.create(h.NUM)}return R<0?g.create(h.NUM):y.create(R)}}class G1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsLocale",!0)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=$(u);if(typeof f!="number")return f;const m=$(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const _=Math.floor(m)-Math.floor(f),E=ne(f).getUTCFullYear(),b=Hn(E);if(_>b)return g.create(h.NUM);const R=100*(1-d*_/360);return R<0?g.create(h.NUM):y.create(R,Ye(this.getLocale()))}}class W1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=je(e,t,r);if(n)return s;const[u,c,l]=a,f=$(u);if(typeof f!="number")return f;const m=$(c);if(typeof m!="number")return m;const d=+l.getValue();if(Number.isNaN(d))return g.create(h.VALUE);if(d<=0||f>=m)return g.create(h.NUM);const _=Math.floor(m)-Math.floor(f),E=ne(f).getUTCFullYear(),b=Hn(E);if(_>b)return g.create(h.NUM);const R=(100-d)/d*360/_;return y.create(R)}}class Q1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",7);A(this,"needsLocale",!0)}calculate(e,t,r,n,s,a,u){let c=a!=null?a:y.create(2);c.isNull()&&(c=y.create(2));let l=u!=null?u:v.create(!1);l.isNull()&&(l=v.create(!1));const f=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,e,g.create(h.NA)),_=O(f,m,t,g.create(h.NA)),C=O(f,m,r,g.create(h.NA)),E=O(f,m,n,g.create(h.NA)),b=O(f,m,s,g.create(h.NA)),R=O(f,m,c,g.create(h.NA)),p=O(f,m,l,g.create(h.NA));return this._getResultArray(d,_,C,E,b,R,p,f,m)}_getResultArray(e,t,r,n,s,a,u,c,l){const f=e.map((m,d,_)=>{const C=t.get(d,_),E=r.get(d,_),b=n.get(d,_),R=s.get(d,_),p=a.get(d,_),V=u.get(d,_),{isError:M,errorObject:D,variants:w}=F(m,C,E,b,R,p,V);if(M)return D;const[P,L,B,j,k,Q,te]=w,z=+P.getValue(),W=+L.getValue(),ce=+B.getValue(),de=+j.getValue(),Ee=+k.getValue(),ye=+Q.getValue(),ge=+te.getValue();if(z<0||W<0||ce<0||de<0||Ee<0||Ee>ce||de>Ee||ye<0)return g.create(h.NUM);if(ce===0&&de===0&&Ee===0)return g.create(h.DIV_BY_ZERO);const Ue=this._getResult(z,W,ce,de,Ee,ye,ge);return d===0&&_===0?y.create(Ue,Ye(this.getLocale())):y.create(Ue)});return c===1&&l===1?f.get(0,0):f}_getResult(e,t,r,n,s,a,u){const c=Math.floor(n),l=Math.ceil(s);let f=0;if(e<t){if(n>=1||u)return f;const m=Math.abs(e-t);return f=m*(s-n)>m?m:m*(s-n),-f}if(u)for(let m=c+1;m<=l;m++){let d=Ls(e,t,r,m,a);m===c+1?d*=Math.min(s,c+1)-n:m===l&&(d*=s+1-l),f+=d}else{const m=e-this._getVdb(e,t,r,r,n,a);f=this._getVdb(m,t,r,r-n,s-n,a)}return f}_getVdb(e,t,r,n,s,a){const u=Math.ceil(s);let c=0,l=e-t,f=0,m=0,d=!1;for(let _=1;_<=u;_++){if(d)m=f;else{const C=Ls(e,t,r,_,a);f=l/(n-(_-1)),f>C?(m=f,d=!0):(m=C,l-=C)}_===u&&(m*=s+1-u),c+=m}return c}}class q1 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull())return g.create(h.NA);const{isError:n,errorObejct:s,_values:a,_dates:u}=this._checkErrors(e,t);if(n)return s;let c=r!=null?r:y.create(.1);c.isNull()&&(c=y.create(.1));const{isError:l,errorObject:f,variants:m}=G(c);if(l)return f;const[d]=m,_=+d.getValue();if(Number.isNaN(_))return g.create(h.VALUE);const{positive:C,negative:E}=this._checkValues(a);if(!C||!E||(a==null?void 0:a.length)!==(u==null?void 0:u.length)||_<0)return g.create(h.NUM);const b=da(_,R=>this._iterF(a,u,R));return typeof b!="number"?b:y.create(b)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!S.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{if(s!=null&&s.isError())return r=!0,n=s,!1;if(s!=null&&s.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const a=+s.getValue();if(Number.isNaN(a))return r=!0,n=g.create(h.VALUE),!1;if(a<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(a))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isBoolean()||e.isString()&&!S.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkValues(e){let t=!1,r=!1;for(let n=0;n<e.length;n++)e[n]>0&&(t=!0),e[n]<0&&(r=!0);return{positive:t,negative:r}}_iterF(e,t,r){return e.reduce((n,s,a)=>n+s/(1+r)**((t[a]-t[0])/365),0)}}class K1 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){if(e.isNull()||t.isNull()||r.isNull())return g.create(h.NA);const{isError:n,errorObject:s,variants:a}=G(e);if(n)return s;const[u]=a,c=+u.getValue();if(Number.isNaN(c))return g.create(h.VALUE);let{isError:l,errorObejct:f,_values:m,_dates:d}=this._checkErrors(t,r);if(l)return f;if(m=m,d=d,c<0||m.length!==d.length)return g.create(h.NUM);let _=0;const C=d[0];for(let E=0;E<d.length;E++){const b=d[E],R=m[E];_+=R/(1+c)**((b-C)/365)}return y.create(_)}_checkErrors(e,t){if(e.isError())return{isError:!0,errorObejct:e};if(t.isError())return{isError:!0,errorObejct:t};const{isError:r,errorObejct:n,_values:s}=this._checkErrorValues(e);if(r)return{isError:r,errorObejct:n};const{isError:a,errorObejct:u,_dates:c}=this._checkErrorDates(t);return a?{isError:a,errorObejct:u}:{isError:!1,_values:s,_dates:c}}_checkErrorValues(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;t.push(u)}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_values:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!S.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:{isError:!0,errorObejct:g.create(h.NA)}}}_checkErrorDates(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);return e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;if(a.isNull()||a.isBoolean())return r=!0,n=g.create(h.VALUE),!1;const u=+a.getValue();if(Number.isNaN(u))return r=!0,n=g.create(h.VALUE),!1;if(u<0)return r=!0,n=g.create(h.NUM),!1;t.push(Math.floor(u))}),r?{isError:r,errorObejct:n}:t.length<=1?{isError:!0,errorObejct:g.create(h.NA)}:{isError:r,_dates:t}}else{const r=e.getValue();return e.isNull()||e.isBoolean()||e.isString()&&!S.isRealNum(r)?{isError:!0,errorObejct:g.create(h.VALUE)}:+r<0?{isError:!0,errorObejct:g.create(h.NUM)}:{isError:!0,errorObejct:g.create(h.NA)}}}}class X1 extends N{constructor(){super(...arguments);A(this,"minParams",6);A(this,"maxParams",7)}calculate(e,t,r,n,s,a,u){let c=u!=null?u:y.create(0);c.isNull()&&(c=y.create(0));const{isError:l,errorObject:f,variants:m}=je(e,t,r,n,s,a,c);if(l)return f;const[d,_,C,E,b,R,p]=m,V=$(d);if(typeof V!="number")return V;const M=$(_);if(typeof M!="number")return M;const D=+C.getValue(),w=+E.getValue(),P=+b.getValue(),L=Math.floor(+R.getValue()),B=Math.floor(+p.getValue());if(Number.isNaN(D)||Number.isNaN(w)||Number.isNaN(P)||Number.isNaN(L)||Number.isNaN(B))return g.create(h.VALUE);if(D<0||w<=0||P<=0||![1,2,4].includes(L)||B<0||B>4||V>=M||!mr(V,M,L))return g.create(h.NUM);const j=this._getResult(V,M,D,w,P,L,B);return y.create(j)}_getResult(e,t,r,n,s,a,u){if(Qt(e,t,a)>1){let E=r||.01,b=Qr(e,t,r,E,s,a,u),R=b-n;for(let p=0;p<100&&Math.abs(R)>1e-7;p++)b=Qr(e,t,r,1.01*E,s,a,u),E+=-R/(b-n-R)*E*.01,R=Qr(e,t,r,E,s,a,u)-n;return E}const l=Gn(e,t,a,u),f=$e(e,t,a,u),{days:m}=Ce(e,t,u),d=n/100+l/f*r/a;return(s/100+r/a-d)/d*a*f/m}}class Z1 extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",5)}calculate(e,t,r,n,s){let a=s!=null?s:y.create(0);a.isNull()&&(a=y.create(0));const{isError:u,errorObject:c,variants:l}=je(e,t,r,n,a);if(u)return c;const[f,m,d,_,C]=l,E=$(f);if(typeof E!="number")return E;const b=$(m);if(typeof b!="number")return b;const R=+d.getValue(),p=+_.getValue(),V=Math.floor(+C.getValue());if(Number.isNaN(R)||Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);if(R<=0||p<=0||V<0||V>4||E>=b)return g.create(h.NUM);const{days:M,yearDays:D}=Ce(E,b,V),w=(p/R-1)/(M/D);return y.create(w)}}class z1 extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=a!=null?a:y.create(0);u.isNull()&&(u=y.create(0));const{isError:c,errorObject:l,variants:f}=je(e,t,r,n,s,u);if(c)return l;const[m,d,_,C,E,b]=f,R=$(m);if(typeof R!="number")return R;const p=$(d);if(typeof p!="number")return p;const V=$(_);if(typeof V!="number")return V;const M=+C.getValue(),D=+E.getValue(),w=Math.floor(+b.getValue());if(Number.isNaN(M)||Number.isNaN(D)||Number.isNaN(w))return g.create(h.VALUE);const P=this._getDateCorrectOrder(p,R,V);if(M<0||D<=0||w<0||w>4||!P)return g.create(h.NUM);const L=iu(R,w),{days:B}=Ce(R,p,w),{days:j}=Ce(V,p,w),{days:k}=Ce(V,R,w),Q=((1+j/L*M)/(D/100+k/L*M)-1)/(B/L);return y.create(Q)}_getDateCorrectOrder(e,t,r){return Math.floor(e)>Math.floor(t)&&Math.floor(t)>Math.floor(r)}}const du=[[Jg,J.ACCRINT],[e1,J.ACCRINTM],[t1,J.AMORLINC],[r1,J.COUPDAYBS],[n1,J.COUPDAYS],[s1,J.COUPDAYSNC],[a1,J.COUPNCD],[i1,J.COUPNUM],[o1,J.COUPPCD],[u1,J.CUMIPMT],[c1,J.CUMPRINC],[l1,J.DB],[f1,J.DDB],[m1,J.DISC],[h1,J.DOLLARDE],[g1,J.DOLLARFR],[d1,J.DURATION],[C1,J.EFFECT],[_1,J.FV],[A1,J.FVSCHEDULE],[E1,J.INTRATE],[b1,J.IPMT],[y1,J.IRR],[R1,J.ISPMT],[p1,J.MDURATION],[N1,J.MIRR],[V1,J.NOMINAL],[O1,J.NPER],[M1,J.NPV],[S1,J.ODDFPRICE],[D1,J.ODDFYIELD],[w1,J.ODDLPRICE],[P1,J.ODDLYIELD],[L1,J.PDURATION],[x1,J.PMT],[j1,J.PPMT],[U1,J.PRICE],[T1,J.PRICEDISC],[v1,J.PRICEMAT],[B1,J.PV],[I1,J.RATE],[F1,J.RECEIVED],[k1,J.RRI],[$1,J.SLN],[Y1,J.SYD],[H1,J.TBILLEQ],[G1,J.TBILLPRICE],[W1,J.TBILLYIELD],[Q1,J.VDB],[q1,J.XIRR],[K1,J.XNPV],[X1,J.YIELD],[Z1,J.YIELDDISC],[z1,J.YIELDMAT]];class J1 extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),r.isArray()){const n=r.getRowCount(),s=r.getColumnCount();if(n===1&&s===1){const a=r.get(0,0);return this._handleSingleObject(a,t)}return r.map(a=>a.isError()?a:this._handleSingleObject(a,t,!0))}return this._handleSingleObject(r,t)}_handleSingleObject(e,t,r=!1){let n=t;if(n.isError())return n;if(!n.isReferenceObject())return g.create(h.NA);const s=n.getCurrentActiveSheetData(),{columnData:a,defaultColumnWidth:u}=s;n=n.toArrayValueObject();const c=n.getCurrentRow(),l=n.getCurrentColumn();n=n.getFirstCell();const f=`${e.getValue()}`;let m;switch(f.toLocaleLowerCase()){case"address":return U.create(`$${S.Tools.chatAtABC(l)}$${c+1}`);case"col":return y.create(l+1);case"color":return y.create(0);case"contents":return n;case"filename":return g.create(h.VALUE);case"format":return U.create("G");case"parentheses":return y.create(0);case"prefix":return U.create("");case"protect":return y.create(1);case"row":return y.create(c+1);case"type":return m="v",n.isNull()&&(m="b"),n.isString()&&(m="l"),U.create(m);case"width":return this._getWidthResult(a,u,l,r);default:return g.create(h.VALUE)}}_getWidthResult(e,t,r,n){var u;let s=(u=e[r])==null?void 0:u.w;if(!s&&s!==0&&(s=t),n)return y.create(s);const a=[[s,s===t]];return q.createByArray(a)}}class ed extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"_errorTypeValueMap",new Map([[h.NULL,1],[h.DIV_BY_ZERO,2],[h.VALUE,3],[h.REF,4],[h.NAME,5],[h.NUM,6],[h.NA,7],[h.CONNECT,8],[h.CALC,14]]))}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const t=e.getValue(),r=this._errorTypeValueMap.get(t);return r?y.create(r):g.create(h.NA)}}var pe=(i=>(i.CELL="CELL",i.ERROR_TYPE="ERROR.TYPE",i.INFO="INFO",i.ISBETWEEN="ISBETWEEN",i.ISBLANK="ISBLANK",i.ISDATE="ISDATE",i.ISEMAIL="ISEMAIL",i.ISERR="ISERR",i.ISERROR="ISERROR",i.ISEVEN="ISEVEN",i.ISFORMULA="ISFORMULA",i.ISLOGICAL="ISLOGICAL",i.ISNA="ISNA",i.ISNONTEXT="ISNONTEXT",i.ISNUMBER="ISNUMBER",i.ISODD="ISODD",i.ISOMITTED="ISOMITTED",i.ISREF="ISREF",i.ISTEXT="ISTEXT",i.ISURL="ISURL",i.N="N",i.NA="NA",i.SHEET="SHEET",i.SHEETS="SHEETS",i.TYPE="TYPE",i))(pe||{});class td extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=n!=null?n:v.create(!0),u=s!=null?s:v.create(!0),{isError:c,errorObject:l,variants:f}=Mr(e,t,r,a,u);if(c)return l;const[m,d,_,C,E]=f;if(C.isString()||E.isString())return g.create(h.VALUE);if(d.compare(_,">").getValue()===!0)return g.create(h.NUM);const R=+C.getValue(),p=+E.getValue(),V=R?">=":">",M=p?"<=":"<";return m.compare(d,V).getValue()===!1||m.compare(_,M).getValue()===!1?v.create(!1):v.create(!0)}}class rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNull()?v.create(!0):e.isArray()?e.mapValue(t=>t.isNull()?v.create(!0):v.create(!1)):v.create(!1)}}class nd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isError()?t:t.isNumber()&&t.getPattern()!==""?v.create(ga(t.getPattern())):t.isString()&&(ws(`${t.getValue()}`)||Ps(`${t.getValue()}`))?v.create(!0):v.create(!1)}}class sd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const a=t.getRowCount(),u=t.getColumnCount();if(a>1||u>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isNull()||t.isBoolean()||t.isNumber())return v.create(!1);const r=`${t.getValue()}`;if(r.length>254)return v.create(!1);const n=S.Tools.topLevelDomainCombiningString(),s=new RegExp(`^(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})$`,"i");return v.create(s.test(r))}}class ad extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?v.create(!1):e.isError()?v.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?v.create(!1):t.isError()?v.create(!0):v.create(!1)):v.create(!1)}}class id extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?v.create(!0):e.isArray()?e.mapValue(t=>t.isError()?v.create(!0):v.create(!1)):v.create(!1)}}class od extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2===0;return v.create(n)}}class ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){var u;if(e.isError())return e;if(!e.isReferenceObject())return g.create(h.NA);const t=(u=e.getCurrentActiveSheetData())==null?void 0:u.cellData.getMatrix(),{startRow:r,startColumn:n}=e.getRangePosition(),s=e.toArrayValueObject(),a=s.mapValue((c,l,f)=>{var d;const m=(d=t==null?void 0:t[r+l])==null?void 0:d[n+f];return m!=null&&m.f||m!=null&&m.si?v.create(!0):v.create(!1)});return s.getRowCount()===1&&s.getColumnCount()===1?a.get(0,0):a}}class cd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isBoolean()?v.create(!0):e.isArray()?e.mapValue(t=>t.isBoolean()?v.create(!0):v.create(!1)):v.create(!1)}}class ld extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.getValue()===h.NA?v.create(!0):e.isArray()?e.mapValue(t=>t.getValue()===h.NA?v.create(!0):v.create(!1)):v.create(!1)}}class fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return!e.isArray()&&!e.isString()?v.create(!0):e.isArray()?e.mapValue(t=>t.isString()?v.create(!1):v.create(!0)):v.create(!1)}}class md extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isNumber()?v.create(!0):e.isArray()?e.mapValue(t=>t.isNumber()?v.create(!0):v.create(!1)):v.create(!1)}}class hd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isBoolean())return g.create(h.VALUE);const r=Math.trunc(+t.getValue());if(Number.isNaN(r))return g.create(h.VALUE);const n=r%2!==0;return v.create(n)}}class gd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?v.create(!0):v.create(!1)}}class dd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isString()?v.create(!0):e.isArray()?e.mapValue(t=>t.isString()?v.create(!0):v.create(!1)):v.create(!1)}}class Cd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const a=t.getRowCount(),u=t.getColumnCount();if(a>1||u>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isError())return t;if(t.isNull()||t.isBoolean()||t.isNumber())return v.create(!1);const r=`${t.getValue()}`.replace(/^\s+|\s+$/g,"");if(r.length>1e3)return v.create(!1);const n=S.Tools.topLevelDomainCombiningString(),s=new RegExp(`^(?:(?:https?|s?ftp|ftps|nfs|ssh)://+[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})(?::[0-9]+)?(?:/(?:[A-Za-z0-9\\-._~!$&'()*+,;=:@]|%[A-Fa-f0-9]{2})*)*/?(?:[?#]\\S*)?|mailto:(?:[\\w+-]+\\.)*[\\w+-]+@[a-z0-9_-]+(?:\\.[a-z0-9_-]+)*\\.(?:${n})|(?:news|aim):[%a-z0-9$_\\.+!*(),;/?#:@&~=-]+)$`,"i");return v.create(s.test(r))}}class _d extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()&&(t=e.get(0,0)),t.isError())return t;if(t.isString())return y.create(0);const r=+t.getValue();return y.create(r)}}class Ad extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return g.create(h.NA)}}class Ed extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsSheetsInfo",!0)}calculate(e){var u;if(e!=null&&e.isError())return e;const{sheetOrder:t,sheetNameMap:r}=this.getSheetsInfo();if(!e){const c=t.findIndex(l=>l===this.subUnitId);return y.create(c+1)}if(e.isReferenceObject()){const c=e.getForcedSheetId(),l=e.getDefaultSheetId(),f=t.findIndex(m=>c?m===c:m===l);return y.create(f+1)}if(e.isArray())return g.create(h.NA);const n=`${e.getValue()}`.toLocaleLowerCase(),s=(u=Object.entries(r).find(([c,l])=>l.toLocaleLowerCase()===n))==null?void 0:u[0];if(!s)return g.create(h.NA);const a=t.findIndex(c=>c===s);return y.create(a+1)}}class bd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0);A(this,"needsSheetsInfo",!0)}calculate(){const{sheetOrder:e}=this.getSheetsInfo();return y.create(e.length)}}class yd extends N{constructor(){super(...arguments);A(this,"needsReferenceObject",!0);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isReferenceObject()){const t=e.getRowCount(),r=e.getColumnCount();if(t===1&&r===1){const n=e.getFirstCell();if(n.isError())return y.create(16);if(n.isBoolean())return y.create(4);if(n.isString())return y.create(2);if(n.isNumber()||n.isNull())return y.create(1)}else return y.create(64)}else{if(e.isArray())return y.create(64);if(e.isError())return y.create(16);if(e.isBoolean())return y.create(4);if(e.isString())return y.create(2);if(e.isNumber()||e.isNull())return y.create(1)}return y.create(128)}}const Cu=[[J1,pe.CELL],[ed,pe.ERROR_TYPE],[td,pe.ISBETWEEN],[rd,pe.ISBLANK],[nd,pe.ISDATE],[sd,pe.ISEMAIL],[ad,pe.ISERR],[id,pe.ISERROR],[od,pe.ISEVEN],[ud,pe.ISFORMULA],[cd,pe.ISLOGICAL],[ld,pe.ISNA],[fd,pe.ISNONTEXT],[md,pe.ISNUMBER],[hd,pe.ISODD],[gd,pe.ISREF],[dd,pe.ISTEXT],[Cd,pe.ISURL],[_d,pe.N],[Ad,pe.NA],[Ed,pe.SHEET],[bd,pe.SHEETS],[yd,pe.TYPE]];class Rd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t&&!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t&&!!s.getValue(),r=!1)}return r?g.create(h.VALUE):v.create(t)}}class pd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[[]];for(let l=0;l<u;l++){const f=[];for(let _=0;_<a;_++){const C=r.get(_,l);f.push([C])}let m=q.create({calculateValueList:f,rowCount:a,columnCount:1,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:_,startColumn:C}=n.getRangePosition(),E={startRow:_,startColumn:C+l,endRow:_+a-1,endColumn:C+l};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const _=d.getRowCount(),C=d.getColumnCount();if(_>1||C>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c[0].push(d)}return u===1?c[0][0]:q.create({calculateValueList:c,rowCount:1,columnCount:u,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Nd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"needsReferenceObject",!0)}calculate(e,t){let r=e,n=null;if(e.isReferenceObject()&&(r=e.toArrayValueObject(),n=e),r.isError())return r;if(t.isError())return t;if(!(t.isValueObject()&&t.isLambda()&&t.getLambdaPrivacyVarKeys().length===1))return g.create(h.VALUE);const s=t,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;r=O(a,u,r);const c=[];for(let l=0;l<a;l++){const f=[[]];for(let _=0;_<u;_++){const C=r.get(l,_);f[0].push(C)}let m=q.create({calculateValueList:f,rowCount:1,columnCount:u,unitId:"",sheetId:"",row:0,column:0});if(n){const{startRow:_,startColumn:C}=n.getRangePosition(),E={startRow:_+l,startColumn:C,endRow:_+l,endColumn:C+u-1};m=this.createReferenceObject(n,E)}let d=s.execute(m);if(d.isArray()){const _=d.getRowCount(),C=d.getColumnCount();if(_>1||C>1)return g.create(h.CALC);d=d.get(0,0)}d.isNull()&&(d=y.create(0)),c.push([d])}return a===1?c[0][0]:q.create({calculateValueList:c,rowCount:a,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Vd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return v.create(!1)}}var Ve=(i=>(i.AND="AND",i.BYCOL="BYCOL",i.BYROW="BYROW",i.FALSE="FALSE",i.IF="IF",i.IFERROR="IFERROR",i.IFNA="IFNA",i.IFS="IFS",i.LAMBDA="LAMBDA",i.LET="LET",i.MAKEARRAY="MAKEARRAY",i.MAP="MAP",i.NOT="NOT",i.OR="OR",i.REDUCE="REDUCE",i.SCAN="SCAN",i.SWITCH="SWITCH",i.TRUE="TRUE",i.XOR="XOR",i))(Ve||{});class Od extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r=v.create(!1)){const n=this._getSingleValueObject(e);if(n.isError())return n;if(!n.isArray())return n.getValue()?t:r;const s=Math.max(n.isArray()?n.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),a=Math.max(n.isArray()?n.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),u=O(s,a,n),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{if(f.isNull())return g.create(h.NA);{const _=c.get(m,d)||ie.create(),C=l.get(m,d)||ie.create();return this._calculateSingleCell(f,_,C)}})}_getSingleValueObject(e){return e.isArray()&&e.getRowCount()===1&&e.getColumnCount()===1?e.getFirstCell():e}_calculateSingleCell(e,t,r){return e.isNull()?g.create(h.NA):e.getValue()?t.isNull()?g.create(h.NA):t:r.isNull()?g.create(h.NA):r}}class Md extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(!e.isArray())return e.isError()?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&s.set(c,l,a.get(c,l))}),s}}class Sd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError()&&e.getErrorType()!==h.NA)return e;if(t.isError())return t;if(!e.isArray())return e.isError()&&e.getErrorType()===h.NA?t:e;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.iterator((u,c,l)=>{u!=null&&u.isError()&&u.getErrorType()===h.NA&&s.set(c,l,a.get(c,l))}),s}}class Dd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0)return g.create(h.NA);for(let a=0;a<e.length;a++)if(e[a].isError())return e[a];const t=Math.max(...e.map(a=>a.isArray()?a.getRowCount():1)),r=Math.max(...e.map(a=>a.isArray()?a.getColumnCount():1)),n=e.map(a=>O(t,r,a,g.create(h.NA))),s=n[0].map((a,u,c)=>{for(let l=0;l<n.length;l+=2){const f=n[l].get(u,c)||ie.create(),m=n[l+1].get(u,c)||ie.create();if(f.isNull())continue;if(f.isError())return f;const d=f.getValue();if(f.isString()){if(`${d}`.toLocaleUpperCase()==="TRUE")return m;if(`${d}`.toLocaleUpperCase()==="FALSE")continue;return g.create(h.VALUE)}if(+d)return m.isNull()?g.create(h.NA):m}return g.create(h.NA)});return t===1&&r===1?s.get(0,0):s}}class wd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class Pd extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(...e){return g.create(h.VALUE)}}class Ld extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(...e){const t=this.getIndexNumValue(e[0]);if(typeof t!="number")return t;const r=this.getIndexNumValue(e[1]);if(typeof r!="number")return r;if(!(e[2].isValueObject()&&e[2].isLambda()))return g.create(h.VALUE);const n=e[2],s=[];for(let a=0;a<t;a++){s[a]==null&&(s[a]=[]);for(let u=0;u<r;u++){let c=n.execute(y.create(a+1),y.create(u+1));c.isArray()&&(c=c.get(0,0)),s[a][u]=c}}return new Ki(s)}isAsync(){return!0}}let xd=class extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(...e){const t=[];let r=null,n=0,s=0;for(let u=0;u<e.length;u++){const c=e[u];let l=c;if(l.isReferenceObject()&&(l=c.toArrayValueObject()),l.isError())return l;if(u===e.length-1){if(!(c.isValueObject()&&c.isLambda()))return g.create(h.VALUE);r=c}else t.push(c),n=Math.max(n,l.isArray()?l.getRowCount():1),s=Math.max(s,l.isArray()?l.getColumnCount():1)}const a=this._getResultArray(t,r,n,s);return a instanceof g?a:n===1&&s===1?a[0][0]:q.create({calculateValueList:a,rowCount:n,columnCount:s,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArray(e,t,r,n){const s=[];for(let a=0;a<r;a++){const u=[];for(let c=0;c<n;c++){const l=[];let f=!1;for(let d=0;d<e.length;d++){let _=e[d],C=null;if(_.isReferenceObject()&&(C=_,_=_.toArrayValueObject()),!_.isArray())if(a===0&&c===0){l.push(C||_);continue}else{u.push(g.create(h.NA)),f=!0;break}let E=_.get(a,c);if(!E){u.push(g.create(h.NA)),f=!0;break}if(C){const{startRow:b,startColumn:R}=C.getRangePosition(),p={startRow:b+a,startColumn:R+c,endRow:b+a,endColumn:R+c};E=this.createReferenceObject(C,p)}l.push(E)}if(f||l.length===0)continue;let m=t.execute(...l);if(m.isArray()){const d=m.getRowCount(),_=m.getColumnCount();if(d>1||_>1)return g.create(h.CALC);m=m.get(0,0)}m.isNull()&&(m=y.create(0)),u.push(m)}s.push(u)}return s}};class jd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const t=+e.getValue();return Number.isNaN(t)?g.create(h.VALUE):v.create(!t)}}class Ud extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=!1,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(t=t||!!a.getValue(),r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(t=t||!!s.getValue(),r=!1)}return r?new g(h.VALUE):new v(t)}}class Td extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n,s;e.isReferenceObject()?(n=e.toArrayValueObject(),s=e):(n=e,s=null);let a,u;return t.isReferenceObject()?(a=t.toArrayValueObject(),u=t):(a=t,u=null),n.isArray()?n.mapValue(c=>this._handleSingleValueObject(c,a,r,s,u)):this._handleSingleValueObject(n,a,r,s,u)}_handleSingleValueObject(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);const a=r,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++)for(let m=0;m<c;m++){let d=t.isArray()?t.get(f,m):t;if(d.isError())return d;if(s){const{startRow:C,startColumn:E}=s.getRangePosition(),b={startRow:C+f,startColumn:E+m,endRow:C+f,endColumn:E+m};d=this.createReferenceObject(s,b)}let _=a.execute(l,d);if(_.isError())return _;_.isNull()&&(_=y.create(0)),l=_}return l.isReferenceObject()?l.toArrayValueObject():l}}class vd extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e,s=null;e.isReferenceObject()&&(n=e.toArrayValueObject(),s=e),n=n;let a=t,u=null;if(t.isReferenceObject()&&(a=t.toArrayValueObject(),u=t),a=a,n.isError())return n;if(a.isError())return a;if(r.isError())return r;if(!(r.isValueObject()&&r.isLambda()&&r.getLambdaPrivacyVarKeys().length===2))return g.create(h.VALUE);if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.CALC);n=n.get(0,0)}return this._getResult(n,a,r,s,u)}_getResult(e,t,r,n,s){const a=[],u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;let l=e;n&&(l=n);for(let f=0;f<u;f++){const m=[];for(let d=0;d<c;d++){if(l.isError()){m.push(l);continue}let _=t.isArray()?t.get(f,d):t;if(_.isError()){l=_,m.push(_);continue}if(s){const{startRow:E,startColumn:b}=s.getRangePosition(),R={startRow:E+f,startColumn:b+d,endRow:E+f,endColumn:b+d};_=this.createReferenceObject(s,R)}let C=r.execute(l,_);if(C.isArray()){const E=C.getRowCount(),b=C.getColumnCount();if(E>1||b>1)return g.create(h.CALC);C=C.get(0,0)}C.isNull()&&(C=y.create(0)),l=C,m.push(C)}a.push(m)}return u===1&&c===1?a[0][0]:q.create({calculateValueList:a,rowCount:u,columnCount:c,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Bd extends N{constructor(){super(...arguments);A(this,"minParams",3)}calculate(e,...t){if(e.isError())return e;const r=t.length%2!==0,n=r?t[t.length-1]:ie.create();return!e.isArray()&&!t.some(s=>s.isArray())?this._handleNonArrayInputs(e,t,n,r):this._handleArrayInputs(e,t,n,r)}_handleNonArrayInputs(e,t,r,n){for(let s=0;s<t.length-(n?1:0);s+=2){const a=t[s],u=t[s+1];if(!a.isNull()){if(a.isError())return a;if(`${e.getValue()}`.toLocaleLowerCase()===`${a.getValue()}`.toLocaleLowerCase())return u.isNull()?g.create(h.NA):u}}return r.isNull()?g.create(h.NA):r}_handleArrayInputs(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,...t.map(f=>f.isArray()?f.getRowCount():1),r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,...t.map(f=>f.isArray()?f.getColumnCount():1),r.isArray()?r.getColumnCount():1),u=O(s,a,e),c=t.map(f=>O(s,a,f,g.create(h.NA))),l=O(s,a,r,g.create(h.NA));return u.map((f,m,d)=>{for(let C=0;C<c.length-(n?1:0);C+=2){const E=c[C].get(m,d)||ie.create(),b=c[C+1].get(m,d)||ie.create();if(!E.isNull()){if(E.isError()||f.isError())return E.isError()?E:f;if(`${f.getValue()}`.toLocaleLowerCase()===`${E.getValue()}`.toLocaleLowerCase())return b.isNull()?g.create(h.NA):b}}const _=l.get(m,d)||ie.create();return _.isNull()?g.create(h.NA):_})}}class Id extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return v.create(!0)}}class Fd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=!0,n=null;for(const s of e){if(s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a!=null&&a.isError())return n=a,!1;(a!=null&&a.isBoolean()||a!=null&&a.isNumber())&&(a.getValue()&&t++,r=!1)}),n)return n}else(s.isBoolean()||s.isNumber())&&(s.getValue()&&t++,r=!1)}return r?g.create(h.VALUE):v.create(t%2===1)}}const _u=[[Rd,Ve.AND],[pd,Ve.BYCOL],[Nd,Ve.BYROW],[Vd,Ve.FALSE],[Od,Ve.IF],[Md,Ve.IFERROR],[Sd,Ve.IFNA],[Dd,Ve.IFS],[wd,Ve.LAMBDA],[Pd,Ve.LET],[Ld,Ve.MAKEARRAY],[xd,Ve.MAP],[jd,Ve.NOT],[Ud,Ve.OR],[Td,Ve.REDUCE],[vd,Ve.SCAN],[Bd,Ve.SWITCH],[Id,Ve.TRUE],[Fd,Ve.XOR]];class kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",5)}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=r!=null?r:y.create(1),u=n!=null?n:v.create(!0),c=s!=null?s:U.create(""),l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),_=O(l,f,a,g.create(h.NA)),C=O(l,f,u,g.create(h.NA)),E=O(l,f,c,g.create(h.NA));return m.map((b,R,p)=>{const V=d.get(R,p)||g.create(h.NA),M=_.get(R,p)||g.create(h.NA),D=C.get(R,p)||g.create(h.NA),w=E.get(R,p)||g.create(h.NA);return b.isError()?b:V.isError()?V:M.isError()?M:D.isError()?D:w.isError()?w:this._calculateSingleCell(b,V,M,D,w)})}_calculateSingleCell(e,t,r,n,s){const a=Number.parseInt(`${Number(e.getValue())-1}`),u=Number.parseInt(`${Number(t.getValue())-1}`),c=Number.parseInt(`${Number(r.getValue())}`);if(Number.isNaN(a)||Number.isNaN(u)||Number.isNaN(c)||c<1||c>4)return g.create(h.VALUE);const l=$d(c),f=this.getZeroOrOneByOneDefault(n),m=`${s.getValue()}`,d=Si(m),_={startRow:a,startColumn:u,endRow:a,endColumn:u,startAbsoluteRefType:l,endAbsoluteRefType:l},C=n&&!f?dm(_):Yt(_);return U.create(d!==""?`${d}!${C}`:C)}}function $d(i){switch(i){case 1:return S.AbsoluteRefType.ALL;case 2:return S.AbsoluteRefType.ROW;case 3:return S.AbsoluteRefType.COLUMN;case 4:return S.AbsoluteRefType.NONE;default:return S.AbsoluteRefType.ALL}}class Yd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0)}calculate(e){return e.isReferenceObject()?y.create(1):g.create(h.VALUE)}}class Hd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(e,...t){let r=e;if(r.isError())return r;if(r.isReferenceObject()&&(r=r.toArrayValueObject()),!r.isArray()){const c=r.convertToNumberObjectValue();return c.isError()?c:t[Math.trunc(+c.getValue())-1]||g.create(h.VALUE)}let n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;t.forEach((c,l)=>{if(c.isArray()){const f=c;n=Math.max(n,f.getRowCount()),s=Math.max(s,f.getColumnCount())}else n=Math.max(n,1),s=Math.max(s,1)});const a=O(n,s,r,g.create(h.NA)),u=t.map(c=>{let l=c;return l.isReferenceObject()&&(l=l.toArrayValueObject()),O(n,s,l,g.create(h.NA))});return a.map((c,l,f)=>{if(c.isError())return c;const m=c.convertToNumberObjectValue();if(m.isError())return m;const d=u[Math.trunc(+m.getValue())-1];let _=(d==null?void 0:d.get(l,f))||g.create(h.VALUE);return _!=null&&_.isNull()&&(_=y.create(0)),_})}}class Gd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=[];for(let a=0;a<t.length;a++){let u=t[a];if(u.isArray()){const f=u.getRowCount(),m=u.getColumnCount();if(f>1||m>1)return g.create(h.VALUE);u=u.get(0,0)}if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;const c=Math.trunc(+u.getValue());if(c===0||Math.abs(c)>n)return g.create(h.VALUE);let l=e;n>1&&(c<0?l=e.slice(void 0,[c+n,c+1+n]):l=e.slice(void 0,[c-1,c]));for(let f=0;f<r;f++)s[f]||(s[f]=[]),e.isArray()?s[f].push(l.get(f,0)):s[f].push(e)}return q.create({calculateValueList:s,rowCount:s.length,columnCount:s[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Wd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=e.isArray()?e.getRowCount():1,n=[];for(let s=0;s<t.length;s++){let a=t[s];if(a.isArray()){const l=a.getRowCount(),f=a.getColumnCount();if(l>1||f>1)return g.create(h.VALUE);a=a.get(0,0)}if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.trunc(+a.getValue());if(u===0||Math.abs(u)>r)return g.create(h.VALUE);let c=e;r>1&&(u<0?c=e.slice([u+r,u+1+r]):c=e.slice([u-1,u])),e.isArray()?n.push(c.getArrayValue()[0]):n.push([e])}return q.create({calculateValueList:n,rowCount:n.length,columnCount:n[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Qd extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.column+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentColumn(),r=e.getColumnCount(),n=[];for(let a=0;a<r;a++)n.push(y.create(t+a+1));const s={calculateValueList:[n],rowCount:1,columnCount:r,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(s)}}class qd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getColumnCount();return y.create(t)}}class Kd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0),s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA));if(u>1||c>1)return l.mapValue((R,p,V)=>{const M=f.get(p,V);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:D,errorObject:w}=this._checkRowsColumns(R,M,s,a);return D?w:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const m=t.isArray()?t.get(0,0):t,d=n.isArray()?n.get(0,0):n,{isError:_,errorObject:C,rowsValue:E,columnsValue:b}=this._checkRowsColumns(m,d,s,a);return _?C:this._getResultArray(e,E,b,s,a)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)>=r||Math.abs(a)>=n?{isError:!0,errorObject:g.create(h.CALC)}:{isError:!1,rowsValue:s,columnsValue:a}}_getResultArray(e,t,r,n,s){const a=t>=0?[t,n]:[0,n+t],u=r>=0?[r,s]:[0,s+r];let c;return t===0&&r===0?c=e:t===0?c=e.slice(void 0,u):r===0?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),n-t===1&&s-r===1?c.get(0,0):c}}class Xd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1;let u=t,c=r!=null?r:y.create(a);const l=n!=null?n:g.create(h.NA);t.isNull()&&(u=y.create(s)),c.isNull()&&(c=y.create(a));const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),d=O(f,m,u,g.create(h.NA)),_=O(f,m,c,g.create(h.NA));if(f>1||m>1)return d.mapValue((D,w,P)=>{const L=_.get(w,P);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:B,errorObject:j}=this._checkRowsColumnsPadWith(D,L,l,s,a);return B?j:e.isArray()?e.get(0,0):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const C=u.isArray()?u.get(0,0):u,E=c.isArray()?c.get(0,0):c,{isError:b,errorObject:R,rowsValue:p,columnsValue:V,padWithObject:M}=this._checkRowsColumnsPadWith(C,E,l,s,a);return b?R:this._getResultArray(e,p,V,M,s,a)}_checkRowsColumnsPadWith(e,t,r,n,s){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};const a=Math.trunc(+e.getValue()),u=Math.trunc(+t.getValue());if(Number.isNaN(a)||Number.isNaN(u))return{isError:!0,errorObject:g.create(h.VALUE)};if(Math.abs(a)<n||Math.abs(u)<s)return{isError:!0,errorObject:g.create(h.VALUE)};let c=r;if(r.isArray()){const l=r.getRowCount(),f=r.getColumnCount();if(l>1||f>1)return{isError:!0,errorObject:g.create(h.VALUE)};c=r.get(0,0)}return{isError:!1,rowsValue:a,columnsValue:u,padWithObject:c}}_getResultArray(e,t,r,n,s,a){let u=[];e.isArray()?u=e.map(f=>f.isNull()?y.create(0):f).getArrayValue():u=[[e]];const c=Math.max(0,t-s),l=Math.max(0,r-a);for(let f=0;f<c;f++)u.push(new Array(a).fill(n));for(let f=0;f<l;f++)u.forEach(m=>{m.push(n)});return t===1&&r===1?u[0][0]:q.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class Zd extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:g.create(h.CALC);if(e.isError())return e;if(t.isError())return t;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t.isArray()?t.getRowCount():1,c=t.isArray()?t.getColumnCount():1;return u>1&&c>1||u===1&&c!==a||c===1&&u!==s?g.create(h.VALUE):s===1&&a===1?this._getResultArrayByR1C1(e,t,n):u===1?c!==a?g.create(h.VALUE):this._getResultArrayByR1(s,a,e,t,n):c===1?u!==s?g.create(h.VALUE):this._getResultArrayByC1(s,a,e,t,n):n}_getResultArrayByR1C1(e,t,r){let n=e,s=t;return n.isArray()&&(n=n.get(0,0)),s.isArray()&&(s=s.get(0,0)),s.isString()&&(s=s.convertToNumberObjectValue()),s.isError()?s:+s.getValue()?n:r}_getResultArrayByR1(e,t,r,n,s){const a=[];for(let u=0;u<t;u++){let c=n.get(0,u);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(+c.getValue())for(let f=0;f<e;f++){a[f]||(a[f]=[]);const m=r.get(f,u);a[f].push(m)}}return a.length===0?s:q.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getResultArrayByC1(e,t,r,n,s){const a=[];for(let u=0;u<e;u++){let c=n.get(u,0);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;if(!+c.getValue())continue;const f=[];for(let m=0;m<t;m++){const d=r.get(u,m);f.push(d)}a.push(f)}return a.length===0?s:q.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class zd extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1);A(this,"needsReferenceObject",!0);A(this,"needsFormulaDataModel",!0)}calculate(e){var f,m;if(!e.isReferenceObject())return g.create(h.NA);const t=e.getUnitId(),r=e.getSheetId(),s=(m=(f=e.getUnitData()[t])==null?void 0:f[r])==null?void 0:m.cellData,{startRow:a,startColumn:u}=e.getRangePosition(),l=e.toArrayValueObject().mapValue((d,_,C)=>{const E=s.getValue(a+_,u+C);if(E!=null&&E.f||E!=null&&E.si){const b=this._formulaDataModel.getFormulaStringByCell(a+_,u+C,r,t);return U.create(b)}return g.create(h.NA)});return l.getRowCount()===1&&l.getColumnCount()===1?l.get(0,0):l}}var me=(i=>(i.ADDRESS="ADDRESS",i.AREAS="AREAS",i.CHOOSE="CHOOSE",i.CHOOSECOLS="CHOOSECOLS",i.CHOOSEROWS="CHOOSEROWS",i.COLUMN="COLUMN",i.COLUMNS="COLUMNS",i.DROP="DROP",i.EXPAND="EXPAND",i.FILTER="FILTER",i.FORMULATEXT="FORMULATEXT",i.GETPIVOTDATA="GETPIVOTDATA",i.HLOOKUP="HLOOKUP",i.HSTACK="HSTACK",i.HYPERLINK="HYPERLINK",i.IMAGE="IMAGE",i.INDEX="INDEX",i.INDIRECT="INDIRECT",i.LOOKUP="LOOKUP",i.MATCH="MATCH",i.OFFSET="OFFSET",i.ROW="ROW",i.ROWS="ROWS",i.RTD="RTD",i.SORT="SORT",i.SORTBY="SORTBY",i.TAKE="TAKE",i.TOCOL="TOCOL",i.TOROW="TOROW",i.TRANSPOSE="TRANSPOSE",i.UNIQUE="UNIQUE",i.VLOOKUP="VLOOKUP",i.VSTACK="VSTACK",i.WRAPCOLS="WRAPCOLS",i.WRAPROWS="WRAPROWS",i.XLOOKUP="XLOOKUP",i.XMATCH="XMATCH",i))(me||{});class Jd extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray()||r.isError()||n!=null&&n.isError())return g.create(h.NA);const s=this.getZeroOrOneByOneDefault(n);if(s==null)return g.create(h.VALUE);const a=this.getIndexNumValue(r);if(a instanceof g)return a;const u=t.slice([0,1]),c=t.slice([a-1,a]);return u==null||c==null?g.create(h.REF):e.isArray()?e.map(l=>this._handleSingleObject(l,u,c,s)):this._handleSingleObject(e,u,c,s)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class e0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getRowCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<t;c++){r[c]||(r[c]=[]);for(let l=0;l<u;l++){let f=s;s.isArray()&&(f=s.get(c,l)),c>a-1||!f?r[c].push(g.create(h.NA)):r[c].push(f)}}}return q.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class t0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4);A(this,"needsReferenceObject",!0)}calculate(e,t,r,n){if(e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;let s=0,a=0;if(e.isValueObject())s=1,a=1;else if(e.isReferenceObject()){const{startRow:d,endRow:_,startColumn:C,endColumn:E}=e.getRangePosition();s=_-d+1,a=E-C+1}else return g.create(h.VALUE);let u,c;s===1&&a>1&&r==null?(c=t!=null?t:y.create(0),u=y.create(0)):(u=t!=null?t:y.create(0),c=r!=null?r:y.create(0));let l=n!=null?n:y.create(1);u.isReferenceObject()&&(u=u.toArrayValueObject()),c.isReferenceObject()&&(c=c.toArrayValueObject()),l.isReferenceObject()&&(l=l.toArrayValueObject());const f=Math.max(u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1);if(u=u,c=c,l=l,f===1&&m===1)return this._calculateSingleCell(e,u,c,l);{const d=O(f,m,u,g.create(h.NA)),_=O(f,m,c,g.create(h.NA)),C=O(f,m,l,g.create(h.NA));return d.map((E,b,R)=>{const p=_.get(b,R)||ie.create(),V=C.get(b,R)||ie.create(),M=this._calculateSingleCell(e,E,p,V);return M.isReferenceObject()?M.toArrayValueObject().getFirstCell():M})}}_calculateSingleCell(e,t,r,n){if(t.isError())return t;const s=this._getNumberValue(t);if(s===void 0||s<0)return g.create(h.VALUE);if(r.isError())return r;const a=this._getNumberValue(r);if(a===void 0||a<0)return g.create(h.VALUE);if(n.isError())return n;const u=this._getAreaNumberValue(n);return u===void 0||u<1?g.create(h.VALUE):e.isReferenceObject()?this._getReferenceObject(e,s,a,u):e.isValueObject()&&s===1&&a===1?e:g.create(h.REF)}_getNumberValue(e){if(e==null)return 0;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getAreaNumberValue(e){if(e==null)return 1;let t=0;if(e.isBoolean())e.getValue()===!0&&(t=1);else{if(e.isString())return;e.isNumber()?t=Math.floor(e.getValue()):e.isNull()&&(t=0)}return t}_getReferenceObject(e,t,r,n){const{startRow:s,endRow:a,startColumn:u,endColumn:c}=e.getRangePosition();let l=0,f=0,m=0,d=0;if(t===0?(l=s,f=a):l=f=s+t-1,r===0?(m=u,d=c):m=d=u+r-1,l>a||m>c)return g.create(h.REF);const _={startRow:l,startColumn:m,endRow:f,endColumn:d};return this.createReferenceObject(e,_)}}class r0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}isAddress(){return!0}calculate(e,t){if(e.isError())return e;if(t!=null&&t.isError())return t;let r=this.getZeroOrOneByOneDefault(t);r==null&&(r=1);let n=e;if(e.isArray()){const s=e.getRowCount(),a=e.getColumnCount();if(s>1||a>1)return e.map(()=>g.create(h.VALUE));n=e.getFirstCell()}return this._handleSingleObject(n,r)}_handleSingleObject(e,t){const r=`${e.getValue()}`;if(r.trim()==="")return g.create(h.REF);const n=this._convertToDefinedName(r);if(t===0){const f=uo(n),{range:m,sheetName:d,unitId:_}=f,C=new Er(m);return C.setForcedUnitIdDirect(_),C.setForcedSheetName(d),this._setDefault(C)}if(yr(n))return this._setDefault(new Hs(n));if(Ai(n))return this._setDefault(new Ws(n));if(Ei(n))return this._setDefault(new Gs(n));const s=Ht(n),{range:a,sheetName:u,unitId:c}=s;if(Number.isNaN(a.startRow)||a.endRow+1>1048576||Number.isNaN(a.startColumn)||a.endColumn+1>16384)return g.create(h.REF);const l=new Er(a);return l.setForcedUnitIdDirect(c),l.setForcedSheetName(u),this._setDefault(l)}_setDefault(e){return this.unitId==null||this.subUnitId==null?g.create(h.REF):(e.setDefaultUnitId(this.unitId),e.setDefaultSheetId(this.subUnitId),e)}_convertToDefinedName(e){const t=this.getDefinedName(e);if(t==null)return e;const r=t.formulaOrRefString;return r==null?e:r.startsWith(X.EQUALS)?r.slice(1):r}}class n0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsExpandParams",!0)}calculate(e,t,r){return e.isError()?e:t.isError()?g.create(h.REF):t.isArray()?r!=null&&r.isError()?r:t.getColumnCount()===1||t.getRowCount()===1?r!=null&&!r.isArray()?g.create(h.REF):this._handleVector(e,t,r):this._handleArray(e,t):g.create(h.VALUE)}_handleVector(e,t,r){let n=r;if(n==null)n=t;else if(n.getRowCount()!==t.getRowCount()||n.getColumnCount()!==t.getColumnCount())return g.create(h.REF);return e.isArray()?e.map(s=>this.binarySearch(s,t,n)):this.binarySearch(e,t,n)}_handleArray(e,t){const r=t.getRowCount(),n=t.getColumnCount();let s,a;return n>r?(s=t.slice([0,1]),a=t.slice([r-1,r])):(s=t.slice(void 0,[0,1]),a=t.slice(void 0,[n-1,n])),s==null||a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this.binarySearch(u,s,a)):this.binarySearch(e,s,a)}}class s0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const n=t.getRowCount(),s=t.getColumnCount();if(n!==1&&s!==1||r!=null&&r.isError())return g.create(h.NA);const a=this.getMatchTypeValue(r);return a==null?g.create(h.VALUE):e.isArray()?e.map(u=>this._handleSingleObject(u,t,a)):this._handleSingleObject(e,t,a)}_handleSingleObject(e,t,r){const n=this._getSearchModeValue(r),s=t.orderSearch(e,n);if(s==null)return g.create(h.NA);if(s instanceof g)return s;const a=t.getRowCount()===1?s.column+1:s.row+1;return y.create(a)}_getSearchModeValue(e){switch(e){case 1:return Me.MIN;case 0:return Me.NORMAL;case-1:return Me.MAX}}}class a0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",5);A(this,"needsReferenceObject",!0)}isAddress(){return!0}calculate(e,t,r,n,s){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;if(!e.isReferenceObject())return g.create(h.VALUE);const a=e.getRowCount(),u=e.getColumnCount();let c=t;c.isReferenceObject()&&(c=c.toArrayValueObject());let l=r;l.isReferenceObject()&&(l=l.toArrayValueObject());let f=n!=null?n:y.create(a);f.isReferenceObject()&&(f=f.toArrayValueObject()),f.isNull()&&(f=y.create(a));let m=s!=null?s:y.create(u);m.isReferenceObject()&&(m=m.toArrayValueObject()),m.isNull()&&(m=y.create(u));const d=Math.max(c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1),_=Math.max(c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1);if(c=c,l=l,f=f,m=m,d===1&&_===1)return c=c.isArray()?c.get(0,0):c,l=l.isArray()?l.get(0,0):l,f=f.isArray()?f.get(0,0):f,m=m.isArray()?m.get(0,0):m,this._handleSingleObject(e,c,l,f,m);const C=O(d,_,c,g.create(h.NA)),E=O(d,_,l,g.create(h.NA)),b=O(d,_,f,g.create(h.NA)),R=O(d,_,m,g.create(h.NA));return C.mapValue((p,V,M)=>{const D=E.get(V,M),w=b.get(V,M),P=R.get(V,M);return p.isError()?p:D.isError()?D:w.isError()?w:P.isError()?P:this._handleSingleObject(e,p,D,w,P,!0)})}_handleSingleObject(e,t,r,n,s,a=!1){const{startRow:u,startColumn:c}=e.getRangePosition();let l=t;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;let f=r;if(f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+l.getValue(),d=+f.getValue();if(typeof m!="number"||typeof d!="number")return g.create(h.VALUE);const _=u+m,C=c+d;if(_<0||C<0)return g.create(h.REF);const E=this.getIndexNumValue(n),b=this.getIndexNumValue(s);if(typeof E!="number"||typeof b!="number")return g.create(h.VALUE);if(E===0||b===0)return g.create(h.REF);const R=E>0?_+E-1:_+E+1,p=b>0?C+b-1:C+b+1;if(R<0||p<0)return g.create(h.REF);if(a)return g.create(h.VALUE);const V=_<R?_:R,M=C<p?C:p,D=_>R?_:R,w=C>p?C:p,P={startRow:V,startColumn:M,endRow:D,endColumn:w};return this.createReferenceObject(e,P)}}class i0 extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",1)}calculate(e){if(e==null)return y.create(this.row+1);if(e.isError())return e;if(!e.isArray())return g.create(h.NA);const t=e.getCurrentRow(),r=e.getRowCount(),n=[];for(let a=0;a<r;a++)n.push([y.create(t+a+1)]);const s={calculateValueList:n,rowCount:r,columnCount:1,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(s)}}class o0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isString()||e.isNumber()||e.isBoolean())return y.create(1);if(!e.isArray())return g.create(h.NA);const t=e.getRowCount();return y.create(t)}}class u0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const s=t!=null?t:y.create(1),a=r!=null?r:y.create(1),u=n!=null?n:v.create(!1);if(u.isArray()){const c=u.getRowCount(),l=u.getColumnCount();if(c===1&&l===1){const f=u.get(0,0);return this._handleSingleObject(e,s,a,f)}return u.map(f=>{const m=this._handleSingleObject(e,s,a,f);return m.isArray()?m.get(0,0):m})}return this._handleSingleObject(e,s,a,u)}_handleSingleObject(e,t,r,n){if(e.isError())return e;const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=this._checkArrayError(t);if(u.isError())return u;const c=Math.floor(+u.getValue());if(c<1)return g.create(h.VALUE);const l=this._checkArrayError(r);if(l.isError())return l;const f=Math.floor(+l.getValue());if(f!==-1&&f!==1)return g.create(h.VALUE);let m=n;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(!e.isArray()||s===1&&a===1)return e;const d=+m.getValue();return this._getResult(e,c,f,d,s,a)}_checkArrayError(e){let t=e;if(t.isArray()){const r=t.getRowCount(),n=t.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=t.get(0,0)}return t.isString()&&(t=t.convertToNumberObjectValue()),t}_getResult(e,t,r,n,s,a){if(n){if(t>s)return g.create(h.VALUE);const u=e.transpose().getArrayValue();return u.sort(this._sort(t-1,r)),q.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}).transpose()}else{if(t>a)return g.create(h.VALUE);const u=e.getArrayValue();return u.sort(this._sort(t-1,r)),q.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}_sort(e,t=1){const r=Jr();return t===1?this._sortAsc(e,r):this._sortDesc(e,r)}_sortAsc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return 1;if(a.isError())return-1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?1:a.isBoolean()&&c===!0?-1:s.isBoolean()&&u===!1?1:a.isBoolean()&&c===!1?-1:s.isNumber()&&a.isNumber()?+u-+c:t(u,c)}}_sortDesc(e,t){return(r,n)=>{const s=r[e],a=n[e];if(s==null||s.isNull())return 1;if(a==null||a.isNull())return-1;if(s.isError()&&a.isError())return 0;if(s.isError())return-1;if(a.isError())return 1;const u=s.getValue(),c=a.getValue();return s.isBoolean()&&u===!0?-1:a.isBoolean()&&c===!0?1:s.isBoolean()&&u===!1?-1:a.isBoolean()&&c===!1?1:s.isNumber()&&a.isNumber()?+c-+u:t(c,u)}}}class c0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(e,...t){t.length===1&&t.push(y.create(1));const r=this._getVariantsError(e,...t),{maxRowLength:n,maxColumnLength:s}=fr(t);if(r.isError()){const c=O(n,s,r);return n===1&&s===1?c.get(0,0):c}const a=t.map((c,l)=>l%2===0?c:O(n,s,c,g.create(h.NA))),u=this._getResultArray(e,a,n,s);return n===1&&s===1?u[0][0]:q.create({calculateValueList:u,rowCount:u.length,columnCount:u[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}_getVariantsError(e,...t){if(e.isError())return e;for(let u=0;u<t.length;u++){const c=t[u];if(c.isError())return c}if(t.length<2||t.length%2!==0)return g.create(h.VALUE);const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t[0].isArray()?t[0].getRowCount():1,a=t[0].isArray()?t[0].getColumnCount():1;if((s>1||a>1)&&(s>1&&a>1||s===1&&a!==n||a===1&&s!==r))return g.create(h.VALUE);for(let u=2;u<t.length;u++){if(u%2===1)continue;const c=t[u].isArray()?t[u].getRowCount():1,l=t[u].isArray()?t[u].getColumnCount():1;if(c!==s||l!==a)return g.create(h.VALUE)}return v.create(!0)}_getResultArray(e,t,r,n){const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=t[0].isArray()?t[0].getRowCount():1,c=t[0].isArray()?t[0].getColumnCount():1,l=[];for(let f=0;f<r;f++){l[f]=[];for(let m=0;m<n;m++){const{isError:d,errorObject:_,byArrays:C,sortOrders:E}=this._getByArraysAndSortOrders(t,f,m,c);if(d){l[f].push(_);continue}if(!e.isArray()||s===1&&a===1){l[f].push(e);continue}let b=e.getArrayValue();u===1&&c===1||(u===1?(b=b.concat(C),b=this._transposeArray(b),b.sort(this._sort(s,E)),b=this._transposeArray(b).slice(0,s)):c===1&&(b=this._transposeArray(b),b=b.concat(C),b=this._transposeArray(b),b.sort(this._sort(a,E)),b=b.map(p=>p.slice(0,a))));const R=q.create({calculateValueList:b,rowCount:b.length,columnCount:b[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column});if(r>1||n>1){l[f].push(R.get(0,0));continue}l[f].push(R)}}return l}_getByArraysAndSortOrders(e,t,r,n){const s=[],a=[];let u=!1,c=null;for(let l=0;l<e.length;l++){if(l%2===1)continue;const f=e[l];let m=e[l+1].get(t,r);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError()){u=!0,c=m;break}const d=Math.floor(+m.getValue());if(d!==-1&&d!==1){u=!0,c=g.create(h.VALUE);break}if(a.push(d),f.isArray()){let _=f.getArrayValue();n===1&&(_=this._transposeArray(_)),s.push(_[0])}else s.push([f])}return{isError:u,errorObject:c,byArrays:s,sortOrders:a}}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}_sort(e,t){const r=Jr();return(n,s)=>{let a=n[e],u=s[e],c=this._compare(a,u,t[0],r);if(c===0&&t.length>1){for(let l=1;l<t.length;l++)if(a=n[e+l],u=s[e+l],c=this._compare(a,u,t[l],r),c!==0)return c}return c}}_compare(e,t,r,n){return r===1?this._asc(e,t,n):this._desc(e,t,n)}_asc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return 1;if(t.isError())return-1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?1:t.isBoolean()&&s===!0?-1:e.isBoolean()&&n===!1?1:t.isBoolean()&&s===!1?-1:e.isNumber()&&t.isNumber()?+n-+s:r(n,s)}_desc(e,t,r){if(e==null||e.isNull())return 1;if(t==null||t.isNull())return-1;if(e.isError()&&t.isError())return 0;if(e.isError())return-1;if(t.isError())return 1;const n=e.getValue(),s=t.getValue();return e.isBoolean()&&n===!0?-1:t.isBoolean()&&s===!0?1:e.isBoolean()&&n===!1?-1:t.isBoolean()&&s===!1?1:e.isNumber()&&t.isNumber()?+s-+n:r(s,n)}}class l0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=t,u=r!=null?r:y.create(s);t.isNull()&&(a=y.create(n)),u.isNull()&&(u=y.create(s));const c=Math.max(a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1),l=Math.max(a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1),f=O(c,l,a,g.create(h.NA)),m=O(c,l,u,g.create(h.NA));if(c>1||l>1)return f.mapValue((p,V,M)=>{const D=m.get(V,M);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const{isError:w,errorObject:P}=this._checkRowsColumns(p,D,n,s);return w?P:e.isArray()?g.create(h.VALUE):e});if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);const d=a.isArray()?a.get(0,0):a,_=u.isArray()?u.get(0,0):u,{isError:C,errorObject:E,rowsValue:b,columnsValue:R}=this._checkRowsColumns(d,_,n,s);return C?E:this._getResultArray(e,b,R,n,s)}_checkRowsColumns(e,t,r,n){if(e.isError())return{isError:!0,errorObject:e};if(t.isError())return{isError:!0,errorObject:t};let s=Math.trunc(+e.getValue()),a=Math.trunc(+t.getValue());return Number.isNaN(s)||Number.isNaN(a)?{isError:!0,errorObject:g.create(h.VALUE)}:Math.abs(s)===0||Math.abs(a)===0?{isError:!0,errorObject:g.create(h.CALC)}:(s>r&&(s=r),a>n&&(a=n),{isError:!1,rowsValue:s,columnsValue:a})}_getResultArray(e,t,r,n,s){if(!e.isArray())return e;const a=t>=0?[0,t]:[n+t,n],u=r>=0?[0,r]:[s+r,s];let c;return t===n&&r===s?c=e:t===n?c=e.slice(void 0,u):r===s?c=e.slice(a,void 0):c=e.slice(a,u),c=c.map(l=>l.isNull()?y.create(0):l),t===1&&r===1?c.get(0,0):c}}class f0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:v.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,_)=>{const C=l.get(d,_);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(m.isError())return m;if(C.isError())return C;const E=Math.trunc(+m.getValue()),b=+C.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b))return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:q.create({calculateValueList:R.map(p=>[p]),rowCount:R.length,columnCount:1,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class m0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(0),s=r!=null?r:v.create(!1),a=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,n,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,_)=>{const C=l.get(d,_);if(e.isError())return e;if(m.isError())return m;if(C.isError())return C;const E=Math.trunc(+m.getValue()),b=+C.getValue();if(Number.isNaN(E)||E<0||E>3||Number.isNaN(b)||e.isNull())return g.create(h.VALUE);if(!e.isArray())return e;let R=[];return b?R=this._getArrayValueByColumn(e,E):R=this._getArrayValueByRow(e,E),R.length===0?g.create(h.CALC):a>1||u>1||R.length===1?R[0]:q.create({calculateValueList:[R],rowCount:1,columnCount:R.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return a===1&&u===1?f.get(0,0):f}_getArrayValueByColumn(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<s;u++)for(let c=0;c<n;c++){const l=r.get(c,u);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_getArrayValueByRow(e,t){const r=e,n=r.getRowCount(),s=r.getColumnCount(),a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){const l=r.get(u,c);this._isIgnore(l,t)||a.push(l.isNull()?y.create(0):l)}return a}_isIgnore(e,t){switch(t){case 0:return!1;case 1:return e.isNull();case 2:return e.isError();case 3:return e.isNull()||e.isError();default:return!1}}}class h0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isError())return e;if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t===1&&r===1?e.get(0,0):e.transpose()}return e}}class g0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:v.create(!1),s=r!=null?r:v.create(!1),a=e.isArray()?e.getRowCount():1,u=e.isArray()?e.getColumnCount():1,c=Math.max(n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),l=Math.max(n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),f=O(c,l,n,g.create(h.NA)),m=O(c,l,s,g.create(h.NA)),d=f.map((_,C,E)=>{let b=_,R=m.get(C,E);if(e.isError())return e;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+b.getValue(),V=+R.getValue();let M;return!p&&a===1||p&&u===1?M=e:M=this._getResult(e,p,V),(c>1||l>1)&&(M!=null&&M.isArray())?M.get(0,0):M});return c===1&&l===1?d.get(0,0):d}_getResult(e,t,r){const n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;let a=e.getArrayValue(),u=n,c=s;t&&(a=this._transposeArray(a),u=s,c=n);const l=this._getRepeatRows(a,u,c);if(l.length>0){const f=[];l.forEach(m=>{m.forEach((d,_)=>{(_!==0||r)&&f.push(d)})}),a=a.filter((m,d)=>!f.includes(d))}return a.length===0?g.create(h.CALC):(t&&(a=this._transposeArray(a)),q.create({calculateValueList:a,rowCount:a.length,columnCount:a[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}))}_getRepeatRows(e,t,r){let n=[];for(let s=0;s<r;s++)if(s===0){const a=new Array(t).fill(null).map((u,c)=>({r:c,valueObject:e[c][s]}));n=this._getRepeatRowsByObjects(a)}else{if(n.length===0)break;let a=[];n.forEach(u=>{const c=u.map(f=>({r:f,valueObject:e[f][s]})),l=this._getRepeatRowsByObjects(c);a=a.concat(l)}),n=a}return n}_getRepeatRowsByObjects(e){const t=new Map;return e.forEach(r=>{const n=r.r,s=r.valueObject;let a=s.getValue();if(s.isNull()?a=null:s.isString()&&S.isRealNum(a)&&(a=+a),!t.has(a))t.set(a,[n]);else{const u=t.get(a);u.push(n),t.set(a,u)}}),Array.from(t.values()).filter(r=>r.length>1)}_transposeArray(e){const t=e.length,r=e[0].length,n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<t;a++)n[s][a]=e[a][s]}return n}}class d0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return t;if(!t.isArray())return g.create(h.VALUE);if(r.isError())return r;if(n!=null&&n.isError())return n;const s=n!=null?n:v.create(!0);return Wa(e)&&Wa(s)&&r.isArray()?this._handleArrayColIndexNum(e,t,r,s):this._handleNonArrayColIndexNum(e,t,r,s)}_handleArrayColIndexNum(e,t,r,n){const s=e.isArray()?e.getFirstCell():e,a=this.getZeroOrOneByOneDefault(n);if(a==null)return g.create(h.VALUE);let u;const c=[];return r.iterator((l,f,m)=>{if(l==null)return u=g.create(h.VALUE),!1;const d=this._handleTableArray(s,t,l,a);if(d.isError())return u=d,!1;c[f]===void 0&&(c[f]=[]),c[f][m]=d}),u||Gt(c,c.length,c[0].length,this.unitId||"",this.subUnitId||"")}_handleNonArrayColIndexNum(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e),c=O(s,a,n);return u.map((l,f,m)=>{if(l.isError())return l;const d=c.get(f,m);if(d==null)return g.create(h.VALUE);if(d.isError())return d;const _=this.getZeroOrOneByOneDefault(d);return _==null?g.create(h.VALUE):this._handleTableArray(l,t,r,_)})}_handleTableArray(e,t,r,n){let s=this.getIndexNumValue(r);if(s instanceof g)return s;if(s=Math.floor(s),s<1)return g.create(h.VALUE);const a=t.slice(void 0,[0,1]);if(a==null)return g.create(h.VALUE);const u=t.slice(void 0,[s-1,s]);return u==null?g.create(h.REF):this._handleSingleObject(e,a,u,n)}_handleSingleObject(e,t,r,n){return n===0?this.equalSearch(e,t,r):this.binarySearch(e,t,r)}}class C0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=Math.max(...e.map(n=>n.isArray()?n.getColumnCount():1)),r=[];for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++){const l=[];for(let f=0;f<t;f++){let m=s;s.isArray()&&(m=s.get(c,f)),f>u-1||!m?l.push(g.create(h.NA)):l.push(m)}r.push(l)}}return q.create({calculateValueList:r,rowCount:r.length,columnCount:r[0].length||0,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})}}class _0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,_,C)=>{const E=f.get(_,C);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:q.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++)for(let c=0;c<s;c++){a[c]||(a[c]=[]);const l=u*s+c;l<e.length?a[c].push(e[l].isNull()?y.create(0):e[l]):a[c].push(r)}return a}}class A0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){let n=r!=null?r:g.create(h.NA);n.isNull()&&(n=g.create(h.NA));const s=e.isArray()?e.getRowCount():1,a=e.isArray()?e.getColumnCount():1,u=Math.max(t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),c=Math.max(t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),l=O(u,c,t,g.create(h.NA)),f=O(u,c,n,g.create(h.NA)),m=l.mapValue((d,_,C)=>{const E=f.get(_,C);if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);if(d.isError())return d;const b=Math.trunc(+d.getValue());if(s>1&&a>1||Number.isNaN(b))return g.create(h.VALUE);if(b<1)return g.create(h.NUM);const R=e.isArray()?e.getArrayValue().flat():[e],p=this._getWrapArray(R,b,E);return u>1||c>1||p.length===1&&p[0].length===1?p[0][0]:q.create({calculateValueList:p,rowCount:p.length,columnCount:p[0].length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column})});return u===1&&c===1?m.get(0,0):m}_getWrapArray(e,t,r){const n=Math.ceil(e.length/t),s=n>1?t:e.length,a=[];for(let u=0;u<n;u++){const c=[];for(let l=0;l<s;l++){const f=u*s+l;f<e.length?c.push(e[f].isNull()?y.create(0):e[f]):c.push(r)}a.push(c)}return a}}class E0 extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=n!=null?n:g.create(h.NA);n!=null&&n.isNull()&&(u=g.create(h.NA));let c=s!=null?s:y.create(0);s!=null&&s.isNull()&&(c=y.create(0));let l=a!=null?a:y.create(1);if(a!=null&&a.isNull()&&(l=y.create(1)),e.isError())return e;if(t.isError()||r.isError())return g.create(h.REF);if(!t.isArray()||!r.isArray())return g.create(h.VALUE);const f=t.getRowCount(),m=t.getColumnCount(),d=r.getRowCount(),_=r.getColumnCount();if(f!==1&&m!==1||f===1&&m>1&&m!==_||m===1&&f>1&&f!==d)return g.create(h.VALUE);if(c.isError())return c;if(l.isError())return l;const C=this.getIndexNumValue(c);if(C instanceof g)return C;const E=this.getIndexNumValue(l);return E instanceof g?E:this._getResult(e,t,r,u,C,E,f,m,d,_)}_getResult(e,t,r,n,s,a,u,c,l,f){const m=e.isArray()?e.getRowCount():1,d=e.isArray()?e.getColumnCount():1;if(m>1||d>1){let b;return u===1?b=r.slice([0,1]):b=r.slice(void 0,[0,1]),b==null?g.create(h.NA):e.map(R=>{const p=this._checkErrorCombination(s,a);if(p)return p;const V=this._handleSingleObject(R,t,b,s,a);return V.isError()?n:V})}const _=e.isArray()?e.get(0,0):e;if(c===f&&u===l){const b=this._checkErrorCombination(s,a);if(b)return b;const R=this._handleSingleObject(_,t,r,s,a);return R.isError()?n:R}let C=0;c===f&&(C=1);const E=this._handleExpandObject(_,t,r,s,a,C);return E==null?g.create(h.NA):E}_handleExpandObject(e,t,r,n,s,a=0){if((s===2||s===-2)&&n!==2){const u=ds(s),c=gs(n);return this.binarySearchExpand(e,t,r,a,u,c)}return n===2?this.fuzzySearchExpand(e,t,r,s!==-1,a):n===-1||n===1?this.orderSearchExpand(e,t,r,n===1?Me.MAX:Me.MIN,s===-1,a):this.equalSearchExpand(e,t,r,s!==-1,a)}_handleSingleObject(e,t,r,n,s){if((s===2||s===-2)&&n!==2){const a=ds(s),u=gs(n);return this.binarySearch(e,t,r,a,u)}return n===2?this.fuzzySearch(e,t,r,s!==-1):n===-1||n===1?this.orderSearch(e,t,r,n===1?Me.MAX:Me.MIN,s===-1):this.equalSearch(e,t,r,s!==-1)}_checkErrorCombination(e,t){return e===2&&(t===-2||t===2)?g.create(h.VALUE):null}}class b0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isError())return e;if(t.isError())return g.create(h.REF);if(!t.isArray())return g.create(h.VALUE);const s=t.getRowCount(),a=t.getColumnCount();if(s!==1&&a!==1)return g.create(h.VALUE);if(r!=null&&r.isError()||n!=null&&n.isError())return g.create(h.NA);const u=this.getIndexNumValue(r||y.create(0));if(u instanceof g)return u;const c=this.getIndexNumValue(n||y.create(1));return c instanceof g?c:e.isArray()?e.map(l=>this._handleSingleObject(l,t,u,c)):this._handleSingleObject(e,t,u,c)}_handleSingleObject(e,t,r,n){let s;if((n===2||n===-2)&&r!==2){const a=ds(n),u=gs(r);s=t.binarySearch(e,a,u)}else if(r===2){const a=t.compare(e,Y.EQUALS);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}else if(r===-1||r===1){const a=t.orderSearch(e,r===1?Me.MAX:Me.MIN,n===-1);if(a==null)return g.create(h.NA);if(a instanceof g)return a;s=t.getRowCount()===1?a.column:a.row}else{const a=t.isEqual(e);let u;if(n!==-1?u=a.getFirstTruePosition():u=a.getLastTruePosition(),u==null)return g.create(h.NA);s=t.getRowCount()===1?u.column:u.row}return s==null?g.create(h.NA):y.create(s+1)}}const Au=[[kd,me.ADDRESS],[Yd,me.AREAS],[Hd,me.CHOOSE],[Gd,me.CHOOSECOLS],[Wd,me.CHOOSEROWS],[Qd,me.COLUMN],[qd,me.COLUMNS],[Kd,me.DROP],[Xd,me.EXPAND],[Zd,me.FILTER],[zd,me.FORMULATEXT],[Jd,me.HLOOKUP],[e0,me.HSTACK],[t0,me.INDEX],[r0,me.INDIRECT],[n0,me.LOOKUP],[s0,me.MATCH],[a0,me.OFFSET],[i0,me.ROW],[o0,me.ROWS],[u0,me.SORT],[c0,me.SORTBY],[l0,me.TAKE],[f0,me.TOCOL],[m0,me.TOROW],[h0,me.TRANSPOSE],[g0,me.UNIQUE],[d0,me.VLOOKUP],[C0,me.VSTACK],[_0,me.WRAPCOLS],[A0,me.WRAPROWS],[E0,me.XLOOKUP],[b0,me.XMATCH]];class y0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.abs()}}class R0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acos()}}class p0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.acosh()}}class N0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:ri(r)):ri(t)}}function ri(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);o=Number(o);let e=Math.atan(1/o);return o<0&&(e+=Math.PI),Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class V0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.isArray()?t.map(r=>r.isError()?r:ni(r)):ni(t)}}function ni(i){let o=i.getValue();if(i.isBoolean()&&(o=o?1:0),!Number.isFinite(o))return g.create(h.VALUE);if(o=Number(o),Math.abs(o)<=1)return g.create(h.NUM);const e=1/2*Math.log((o+1)/(o-1));return Number.isNaN(e)?g.create(h.VALUE):y.create(e)}class O0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return y.create(0);if(e.isBoolean()||e.isNumber())return g.create(h.VALUE);let t=e.getValue().toLocaleString().toLocaleUpperCase();if(t.length>255)return g.create(h.VALUE);const r=t.startsWith("-");r&&(t=t.slice(1));let n=0;for(let s=0;s<t.length;s++){const a=vr.get(t[s])||0,u=vr.get(t[s+1])||0,c=vr.get(t[s+2])||0,l=vr.get(t[s+3])||0;if(!a||c>=u&&c>a||a===u&&a===c&&a===l||a===u/2)return g.create(h.VALUE);a<u?n-=a:n+=a}return y.create(r?-n:n)}}class M0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asin()}}class S0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.asinh()}}class D0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atan()}}class w0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e,n=t;return r.isString()&&(r=r.convertToNumberObjectValue()),r.isError()?r:(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:n.atan2(r))}}class P0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.atanh()}}class L0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(0);if(e.isError())return e;if(t.isError())return t;if(n.isError())return n;const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.map((m,d,_)=>{const C=c.get(d,_),E=l.get(d,_);return this._handleSingleObject(m,C,E)});return f.getRowCount()===1&&f.getColumnCount()===1?f.getArrayValue()[0][0]:f}_handleSingleObject(e,t,r){let n=e;if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;let s=t;if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;let a=r;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return a;const u=Math.floor(+n.getValue()),c=Math.floor(+s.getValue()),l=Math.floor(+a.getValue());if(u<0||u>=2**53||c<2||c>36||l<0)return g.create(h.NUM);let f=u.toString(c);return f.length<l&&(f=new Array(l-f.length+1).join("0")+f),U.create(f.toLocaleUpperCase())}}class x0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const _=+m.getValue(),C=+d.getValue();if(_>0&&C<0)return g.create(h.NUM);if(_===0||C===0)return y.create(0);const E=Be(_/C,0)*C;return y.create(E)});return u.getRowCount()===1&&u.getColumnCount()===1?u.getArrayValue()[0][0]:u}}class j0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0);if(e.isError())return e;if(n.isError())return n;if(s.isError())return s;const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,_,C)=>{let E=d,b=l.get(_,C),R=f.get(_,C);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),M=+R.getValue();return p===0||V===0?y.create(0):this._getResult(p,V,M)});return a===1&&u===1?m.get(0,0):m}_getResult(e,t,r){let n;return e<0&&r!==0?n=(t<0?Be(Math.abs(e)/Math.abs(t),0):-Be(Math.abs(e)/t,0))*t:n=(t<0?-Be(e/Math.abs(t),0):Be(e/t,0))*t,y.create(n)}}class U0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),_=l;if(_.isString()&&(_=_.convertToNumberObjectValue()),_.isError())return _;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+_.getValue(),E=+d.getValue();if(C===0||E===0)return y.create(0);const b=(E<0?-Be(C/Math.abs(E),0):Be(C/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class T0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const _=Math.floor(+m.getValue()),C=Math.floor(+d.getValue());if(_<0||C<0||_<C)return g.create(h.NUM);const E=kt(_,C);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class v0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{let m=c,d=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),d.isString()&&(d=d.convertToNumberObjectValue()),m.isError())return m;if(d.isError())return d;const _=Math.floor(+m.getValue()),C=Math.floor(+d.getValue());if(_<0||C<0||_===0&&_<C)return g.create(h.NUM);const E=kt(_+C-1,_-1);return Number.isNaN(E)||!Number.isFinite(E)?g.create(h.NUM):y.create(E)});return r===1&&n===1?u.get(0,0):u}}class B0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cos()}}class I0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.cosh()}}class F0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.tan().getReciprocal()}}class k0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:+t.getValue()===0?g.create(h.DIV_BY_ZERO):t.tanh().getReciprocal()}}class $0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):r===0?g.create(h.DIV_BY_ZERO):t.sin().getReciprocal()}}class Y0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return r===0?g.create(h.DIV_BY_ZERO):!Number.isNaN(r)&&!Number.isFinite(Math.sinh(r))?y.create(0):t.sinh().getReciprocal()}}class H0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{if(c.isError())return c;let m=a.get(l,f);if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const d=`${c.getValue()}`,_=Math.floor(+m.getValue());if(S.isRealNum(d)&&(+d<0||+d>=2**53||!Number.isInteger(+d))||d.toLocaleLowerCase()==="true"||d.toLocaleLowerCase()==="false"||_<2||_>36)return g.create(h.NUM);if(d.replace(/\s/g,"")==="")return y.create(0);if(!this._isValidCharForRadix(d,_))return g.create(h.NUM);const C=Number.parseInt(d,_);return Number.isNaN(C)?g.create(h.NUM):y.create(C)});return r===1&&n===1?u.get(0,0):u}_isValidCharForRadix(e,t){for(const r of e){const n=r.toUpperCase().charCodeAt(0);if(t<=10&&!(n>=48&&n<48+t)||t>10&&!(n>=48&&n<58||n>=65&&n<65+t-10))return!1}return!0}}class G0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(180/Math.PI);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class W0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=(r<0?-Be(Math.abs(r)/2,0):Be(r/2,0))*2;return Number.isNaN(n)?g.create(h.VALUE):n===0?y.create(0):y.create(n)}}class Q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.exp()}}class q0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=tr(r);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class K0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(e.isArray()){const r=e.getRowCount(),n=e.getColumnCount();if(r>1||n>1)return g.create(h.VALUE);t=e.get(0,0)}return this._handleSingleObject(t)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue()),n=tr(r,2);return Number.isNaN(n)||!Number.isFinite(n)?g.create(h.NUM):y.create(n)}}class X0 extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f),d=c;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;if(m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const _=+d.getValue(),C=+m.getValue();if(_>0&&C<0)return g.create(h.NUM);if(_===0)return y.create(0);if(C===0)return g.create(h.DIV_BY_ZERO);const E=ke(_/C,0)*C;return y.create(E)});return r===1&&n===1?u.get(0,0):u}}class Z0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:y.create(1),s=r!=null?r:y.create(0),a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.map((d,_,C)=>{let E=d,b=l.get(_,C),R=f.get(_,C);if(E.isString()&&(E=E.convertToNumberObjectValue()),E.isError())return E;if(b.isString()&&(b=b.convertToNumberObjectValue()),b.isError())return b;if(R.isString()&&(R=R.convertToNumberObjectValue()),R.isError())return R;const p=+E.getValue(),V=+b.getValue(),M=+R.getValue();if(p===0||V===0)return y.create(0);let D;return p<0&&M!==0?D=(V<0?ke(Math.abs(p)/Math.abs(V),0):-ke(Math.abs(p)/V,0))*V:D=(V<0?-ke(p/Math.abs(V),0):ke(p/V,0))*V,y.create(D)});return a===1&&u===1?m.get(0,0):m}}class z0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),_=l;if(_.isString()&&(_=_.convertToNumberObjectValue()),_.isError())return _;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+_.getValue(),E=+d.getValue();if(C===0||E===0)return y.create(0);const b=(E<0?-ke(C/Math.abs(E),0):ke(C/E,0))*E;return y.create(b)});return n===1&&s===1?c.get(0,0):c}}class J0 extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];if(!n.isNull())if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isNull())return!0;const{isError:c,errorObject:l,number:f}=this._handleSingleObject(u);if(c)return s=!0,a=l,!1;t=Ss(t,f)}),s)return a}else{const{isError:s,errorObject:a,number:u}=this._handleSingleObject(n);if(s)return a;t=Ss(t,u)}}return y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0||r>=2**53?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class eC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());return y.create(r)}}class tC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=!0;for(let n=0;n<e.length;n++){const s=e[n];if(!s.isNull())if(s.isArray()){let a=!1,u=g.create(h.VALUE);if(s.iterator(c=>{if(c!=null&&c.isNull())return!0;const{isError:l,errorObject:f,number:m}=this._handleSingleObject(c);if(l)return a=!0,u=f,!1;t=Ja(t,m),r=!1}),a)return u}else{const{isError:a,errorObject:u,number:c}=this._handleSingleObject(s);if(a)return u;t=Ja(t,c),r=!1}}return r?y.create(0):Number.isNaN(t)||!Number.isFinite(t)||t>=2**53?g.create(h.VALUE):y.create(t)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class rC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log()}}class nC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(10);if(e.isError())return e;if(r.isError())return r;const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),_=l;if(_.isString()&&(_=_.convertToNumberObjectValue()),_.isError())return _;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+_.getValue(),E=+d.getValue();if(C<=0||E<=0)return g.create(h.NUM);const b=Math.log(E);if(b===0)return g.create(h.DIV_BY_ZERO);const R=Math.log(C)/b;return y.create(R)});return n===1&&s===1?c.get(0,0):c}}class sC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.log10()}}class aC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=Tn(n);return y.create(s)}}class iC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let a=0;a<t;a++){const u=[];for(let c=0;c<r;c++){let l=e.isArray()?e.get(a,c):e;if(l.isError())return l;if(l.isNull()||l.isBoolean())return g.create(h.VALUE);if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return l;const f=+l.getValue();u.push(f)}n.push(u)}if(t!==r)return g.create(h.VALUE);const s=Em(n);return s===null?g.create(h.NUM):q.createByArray(s)}}class oC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(n!==s)return g.create(h.VALUE);const u=this._getMatrix(e,r,n),c=this._getMatrix(t,s,a);if(u instanceof g)return u;if(c instanceof g)return c;const l=rr(u,c);return q.createByArray(l)}_getMatrix(e,t,r){const n=[];for(let s=0;s<t;s++){const a=[];for(let u=0;u<r;u++){let c=e.isArray()?e.get(s,u):e;if(c.isError())return c;if(c.isNull()||c.isBoolean())return g.create(h.VALUE);if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();a.push(l)}n.push(a)}return n}}class uC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.mod(n)}}class cC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(a===0)return y.create(0);if(s>0&&a<0||s<0&&a>0)return g.create(h.NUM);const u=Ot(s/a,0)*a;return y.create(u)}}class lC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=1;for(let s=0;s<e.length;s++){const a=e[s];if(!a.isNull())if(a.isArray()){let u=!1,c=g.create(h.VALUE);if(a.iterator(l=>{if(l!=null&&l.isNull())return!0;const{isError:f,errorObject:m,number:d}=this._handleSingleObject(l);if(f)return u=!0,c=m,!1;if(t+=d,t>170)return u=!0,c=g.create(h.NUM),!1;r*=tr(d)}),u)return c}else{const{isError:u,errorObject:c,number:l}=this._handleSingleObject(a);if(u)return c;if(t+=l,t>170)return g.create(h.NUM);r*=tr(l)}}const n=tr(t)/r;return y.create(n)}_handleSingleObject(e){if(e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),number:null};let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return{isError:!0,errorObject:t,number:null};const r=Math.floor(+t.getValue());return r<0?{isError:!0,errorObject:g.create(h.NUM),number:null}:{isError:!1,errorObject:null,number:r}}}class fC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount(),n=e.mapValue(s=>{const a=this._handleSingleObject(s);return a.isError()?a:t>1||r>1?a.get(0,0):a});return t===1&&r===1?n.get(0,0):n}return this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=Math.floor(+t.getValue());if(r<=0)return g.create(h.VALUE);const n=[];for(let s=0;s<r;s++){n[s]=[];for(let a=0;a<r;a++)n[s][a]=s===a?1:0}return q.createByArray(n)}}class mC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);let n=r<0?-Be(Math.abs(r),0):Be(r,0);return Number.isNaN(n)?g.create(h.VALUE):(Math.abs(n)%2===0&&(r<0?n--:n++),y.create(n))}}class hC extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.PI)}}class gC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.pow(n)}}class dC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(1),r=!0;for(let n=0;n<e.length;n++){let s=e[n];if(s.isError())return s;if(s.isArray()){let a=!1,u=null;if(s.iterator(c=>{if(c!=null&&c.isError())return a=!0,u=c,!1;if(!c||c.isNull()||c.isString()||c.isBoolean())return!0;t=t.multiply(c),r=!1}),a)return u}else{if(s.isNull())continue;if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;t=t.multiply(s),r=!1}if(t.isError())return t}return r?y.create(0):t}}class CC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=G(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();if(Number.isNaN(c)||Number.isNaN(l))return g.create(h.VALUE);if(l===0)return g.create(h.DIV_BY_ZERO);const f=Math.trunc(c/l);return y.create(f)}}class _C extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(!Number.isFinite(r))return g.create(h.VALUE);const n=r*(Math.PI/180);return Number.isNaN(n)?g.create(h.VALUE):y.create(n)}}class AC extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",0)}calculate(){return y.create(Math.random())}}class EC extends N{constructor(){super(...arguments);A(this,"minParams",0);A(this,"maxParams",5);A(this,"needsSheetRowColumnCount",!0)}calculate(e,t,r,n,s){if(e!=null&&e.isError())return e;if(t!=null&&t.isError())return t;if(r!=null&&r.isError())return r;if(n!=null&&n.isError())return n;if(s!=null&&s.isError())return s;const a=e!=null?e:y.create(1),u=t!=null?t:y.create(1),c=r!=null?r:y.create(0),l=n!=null?n:y.create(1),f=s!=null?s:y.create(0);return this._calculateResult(a,u,c,l,f)}_calculateResult(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1);if(a===1&&u===1)return this._calculateSingleCell(e,t,r,n,s);const c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA));return c.map((_,C,E)=>{const b=l.get(C,E),R=f.get(C,E),p=m.get(C,E),V=d.get(C,E),M=this._handleError(_,b,R,p,V);if(M.errorObject)return M.errorObject;let{minValue:D,maxValue:w,wholeNumberValue:P}=M,L;return P?(D=Math.ceil(D),w=Math.floor(w),L=Math.floor(Math.random()*(w-D+1))+D):L=Math.random()*(w-D)+D,L<D||L>w?g.create(h.VALUE):y.create(L)})}_calculateSingleCell(e,t,r,n,s){let a=e;a.isArray()&&(a=a.get(0,0));let u=t;u.isArray()&&(u=u.get(0,0));let c=r;c.isArray()&&(c=c.get(0,0));let l=n;l.isArray()&&(l=l.get(0,0));let f=s;f.isArray()&&(f=f.get(0,0));const m=this._handleError(a,u,c,l,f);if(m.errorObject)return m.errorObject;let{rowsValue:d,columnsValue:_,minValue:C,maxValue:E,wholeNumberValue:b}=m;if(b&&(C=Math.ceil(C),E=Math.floor(E),C>E))return g.create(h.VALUE);const R=[];for(let p=0;p<d;p++){const V=[];for(let M=0;M<_;M++)b?V.push(Math.floor(Math.random()*(E-C+1))+C):V.push(Math.random()*(E-C)+C);R.push(V)}return d===1&&_===1?y.create(R[0][0]):q.createByArray(R)}_handleError(e,t,r,n,s){let a=e;if(a.isString()&&(a=a.convertToNumberObjectValue()),a.isError())return{errorObject:a};let u=t;if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return{errorObject:u};let c=r;if(c.isString()&&(c=c.convertToNumberObjectValue()),c.isError())return{errorObject:c};let l=n;if(l.isString()&&(l=l.convertToNumberObjectValue()),l.isError())return{errorObject:l};let f=s;return f.isString()&&(f=f.convertToNumberObjectValue()),f.isError()?{errorObject:f}:this._getValue(a,u,c,l,f)}_getValue(e,t,r,n,s){const a=Math.floor(+e.getValue()),u=Math.floor(+t.getValue());if(a===0||u===0)return{errorObject:g.create(h.CALC)};const c=this._rowCount-this.row,l=this._columnCount-this.column;if(a<0||u<0||a*u>10**7)return{errorObject:g.create(h.VALUE)};if(a>c||u>l)return{errorObject:g.create(h.REF)};const f=+r.getValue(),m=+n.getValue(),d=+s.getValue();return f>m?{errorObject:g.create(h.VALUE)}:d&&(!Number.isInteger(f)||!Number.isInteger(m))?{errorObject:g.create(h.VALUE)}:{rowsValue:a,columnsValue:u,minValue:f,maxValue:m,wholeNumberValue:d}}}class bC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isArray()){const c=r.getRowCount(),l=r.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);r=r.get(0,0)}if(r.isError())return r;let n=t;if(n.isArray()){const c=n.getRowCount(),l=n.getColumnCount();if(c>1||l>1)return g.create(h.VALUE);n=n.get(0,0)}if(n.isError())return n;if(r.isBoolean()||n.isBoolean())return g.create(h.VALUE);let s=+r.getValue(),a=+n.getValue();if(Number.isNaN(s)||Number.isNaN(a))return g.create(h.VALUE);if(s>a)return g.create(h.NUM);s=Math.ceil(s),a=Math.floor(a);const u=Math.floor(Math.random()*(a-s+1))+s;return y.create(u)}}class yC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e);if(r)return n;const[a]=s;let u=Math.floor(+a.getValue()),c=t;if(c.isString()&&(c=c.convertToNumberObjectValue(),c.isError()))return c;let l=Math.floor(+c.getValue());if(c.isBoolean()&&(l=c.getValue()?0:4),u<0||u>3999||l<0||l>4)return g.create(h.VALUE);const f=Mm[l];let m=f.length-1,d="";for(;u>0;){m=this._binarySearch(u,0,m,f);const _=f[m];u-=_,d+=Om.get(_)}return U.create(d)}_binarySearch(e,t,r,n){let s=t,a=r;for(;a-s>1;){const u=Math.floor((s+a)/2),c=n[u];if(c===e)return u;c>e?a=u:s=u}return s!==a&&n[a]<=e?a:s}}class RC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.round(n)}}class pC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:_,variants:C}=F(c,m);if(d)return _;const[E,b]=C,R=+E.getValue(),p=Math.trunc(+b.getValue()),V=this._roundBank(R,p);return y.create(V)});return r===1&&n===1?u.get(0,0):u}_roundBank(e,t){if(t>16)return e;if(t<-16)return 0;const r=1e-8,n=10**t,s=+(e*n).toFixed(8),a=Math.floor(s),u=s-a;let c=Math.round(s);return u>.5-r&&u<.5+r&&(c=a%2===0?a:a+1),t?c/n:c}}class NC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.floor(n)}}class VC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){let r=e;if(r.isString()&&(r=r.convertToNumberObjectValue()),r.isError())return r;let n=t;return n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()?n:r.ceil(n)}}class OC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Math.abs(r)>=2**27?g.create(h.NUM):t.cos().getReciprocal()}}class MC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.map(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){let t=e;if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();return Number.isFinite(Math.cosh(r))?Math.abs(r)>=2**27?g.create(h.NUM):t.cosh().getReciprocal():y.create(0)}}class SC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4);A(this,"needsSheetRowColumnCount",!0)}calculate(e,t,r,n){let s=e,a=t!=null?t:y.create(1),u=r!=null?r:y.create(1),c=n!=null?n:y.create(1);s.isNull()&&(s=y.create(1)),a.isNull()&&(a=y.create(1)),u.isNull()&&(u=y.create(1)),c.isNull()&&(c=y.create(1));const l=Math.max(s.isArray()?s.getRowCount():1,a.isArray()?a.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(s.isArray()?s.getColumnCount():1,a.isArray()?a.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,s,g.create(h.NA)),d=O(l,f,a,g.create(h.NA)),_=O(l,f,u,g.create(h.NA)),C=O(l,f,c,g.create(h.NA)),E=m.mapValue((b,R,p)=>{const V=d.get(R,p),M=_.get(R,p),D=C.get(R,p);return b.isError()?b:V.isError()?V:M.isError()?M:D.isError()?D:this._getResult(b,V,M,D,l,f)});return l===1&&f===1?E.get(0,0):E}_getResult(e,t,r,n,s,a){const{isError:u,errorObject:c,variants:l}=F(e,t,r,n);if(u)return c;const[f,m,d,_]=l,C=Math.floor(+f.getValue()),E=Math.floor(+m.getValue()),b=+d.getValue(),R=+_.getValue();if(C<0||E<0||C*E>10**7)return g.create(h.VALUE);if(C===0||E===0)return g.create(h.CALC);const p=this._rowCount-this.row,V=this._columnCount-this.column;if(C>p||E>V)return g.create(h.REF);const M=[];for(let D=0;D<C;D++){M[D]=[];for(let w=0;w<E;w++)M[D][w]=b+(D*E+w)*R}return s>1||a>1?y.create(M[0][0]):q.createByArray(M)}}class DC extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){if(e.isNull()||t.isNull()||r.isNull()||n.isNull())return g.create(h.NA);const{isError:s,errorObject:a,variants:u}=G(e,t,r);if(s)return a;const{isError:c,errorObject:l,variants:f}=F(...u);if(c)return l;const[m,d,_]=f,C=+m.getValue(),E=+d.getValue(),b=+_.getValue(),R=[];if(n.isArray()){let V=!1,M=g.create(h.VALUE);if(n.iterator(D=>{const{isError:w,errorObject:P,coefficientsObject:L}=this._handleSingleObject(D);if(w)return V=!0,M=P,!1;const B=+L.getValue();R.push(B)}),V)return M}else{const{isError:V,errorObject:M,coefficientsObject:D}=this._handleSingleObject(n);if(V)return M;const w=+D.getValue();R.push(w)}let p=0;for(let V=0;V<R.length;V++)p+=R[V]*C**(E+V*b);return Number.isNaN(p)||!Number.isFinite(p)?g.create(h.NUM):y.create(p)}_handleSingleObject(e){if(e.isError())return{isError:!0,errorObject:e,coefficientsObject:null};if(e!=null&&e.isBoolean())return{isError:!0,errorObject:g.create(h.VALUE),coefficientsObject:null};let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?{isError:!0,errorObject:t,coefficientsObject:null}:{isError:!1,errorObject:null,coefficientsObject:t}}}class wC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue();return a>0?y.create(1):a<0?y.create(-1):y.create(0)}}class PC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sin()}}class LC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sinh()}}class xC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.sqrt()}}class jC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;if(t.isArray()){const s=t.getRowCount(),a=t.getColumnCount();if(s>1||a>1)return g.create(h.VALUE);t=t.get(0,0)}if(t.isString()&&(t=t.convertToNumberObjectValue()),t.isError())return t;const r=+t.getValue();if(r<0)return g.create(h.NUM);const n=Math.sqrt(r*Math.PI);return y.create(n)}}class UC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255);A(this,"needsReferenceObject",!0)}calculate(e,...t){if(e.isError())return e;if(e.isReferenceObject()){const r=[];return e.iterator((n,s,a)=>{r[s]==null&&(r[s]=[]),r[s][a]=this._handleSingleObject(n,...t)}),Gt(r,r.length,r[0].length)}return this._handleSingleObject(e,...t)}_handleSingleObject(e,...t){const r=this._getIndexNumValue(e);let n;if(r instanceof g)return r;switch(r){case 1:n=this._average(!1,...t);break;case 2:n=this._count(!1,...t);break;case 3:n=this._counta(!1,...t);break;case 4:n=this._max(!1,...t);break;case 5:n=this._min(!1,...t);break;case 6:n=this._product(!1,...t);break;case 7:n=this._stdev(!1,...t);break;case 8:n=this._stdevp(!1,...t);break;case 9:n=this._sum(!1,...t);break;case 10:n=this._var(!1,...t);break;case 11:n=this._varp(!1,...t);break;case 101:n=this._average(!0,...t);break;case 102:n=this._count(!0,...t);break;case 103:n=this._counta(!0,...t);break;case 104:n=this._max(!0,...t);break;case 105:n=this._min(!0,...t);break;case 106:n=this._product(!0,...t);break;case 107:n=this._stdev(!0,...t);break;case 108:n=this._stdevp(!0,...t);break;case 109:n=this._sum(!0,...t);break;case 110:n=this._var(!0,...t);break;case 111:n=this._varp(!0,...t);break;default:n=g.create(h.VALUE)}return n}_getIndexNumValue(e){const t=e?Number(e.getValue()):0;if(Number.isNaN(t))return g.create(h.VALUE);const r=Math.floor(t);return r>=1&&r<=11||r>=101&&r<=111?r:g.create(h.VALUE)}_average(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.mean()}_count(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c))return!0;u!=null&&u.isNumber()&&(r=r.plusBy(1))})}return r}_counta(e,...t){let r=y.create(0);for(let n=0;n<t.length;n++){const s=t[n];if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();s.iterator((u,c)=>{if(e&&this._isRowHidden(a,c)||u==null||u.isNull())return!0;r=r.plusBy(1)})}return r}_max(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.max()}_min(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?y.create(0):r.min()}_product(e,...t){const r=this._flattenRefArray(e,...t);if(r.isError())return r;if(this._isBlankArrayObject(r))return y.create(0);let n=y.create(1);return r.iterator(s=>{n=n.multiply(s)}),n}_stdev(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std(1)}_stdevp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.std()}_sum(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:r.sum()}_var(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var(1)}_varp(e,...t){const r=this._flattenRefArray(e,...t);return r.isError()?r:this._isBlankArrayObject(r)?g.create(h.DIV_BY_ZERO):r.var()}_flattenRefArray(e,...t){const r=[];r[0]=[];for(let n=0;n<t.length;n++){const s=t[n];if(s.isError())return s;if(!s.isReferenceObject())return g.create(h.VALUE);const a=s.getRowData();let u;if(s.iterator((c,l)=>{if(e&&this._isRowHidden(a,l)||c==null||c.isNull()||c.isString()||c.isBoolean())return!0;if(c.isError())return u=c,!1;r[0].push(c)}),u!=null&&u.isError())return u}return Gt(r,1,r[0].length)}_isRowHidden(e,t){const r=e[t];return r?r.hd===S.BooleanNumber.TRUE:!1}_isBlankArrayObject(e){return e.getArrayValue()[0].length===0}}class TC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError()||(n.isArray()&&(n=n.sum()),n.isError()))return n;if(t=t.plus(n),t.isError())return t}return t}}class vC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=t;if(t.isReferenceObject()&&(n=t.toArrayValueObject()),n.isArray()){const s=n.mapValue(a=>this._handleSingleObject(e,a,r));return s.getRowCount()===1&&s.getColumnCount()===1?s.get(0,0):s}return this._handleSingleObject(e,n,r)}_handleSingleObject(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;if(!e.isReferenceObject()||r&&!r.isReferenceObject())return g.create(h.VALUE);const n=e.toArrayValueObject();let s=Ln(n,t);s=xn(s,n,t);const a=n.getRowCount(),u=n.getColumnCount();let c=n;if(r){c=r.toArrayValueObject();const l=c.getRowCount(),f=c.getColumnCount();if(a!==l||u!==f){const m=r.getRangeData();m.endRow=m.startRow+a-1,m.endColumn=m.startColumn+u-1,r.setRangeData(m),c=r.toArrayValueObject()}}return c.pick(s).sum()}}class BC extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;if(!e.isArray()||t.length<2||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=fr(t),s=Nr(t,e,r,n);if(s)return s;const a=Vr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>e.pick(a).sum())),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(n)}}class IC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return e;const r=this._initArray1(e);if(t.length>0){const n=r.getRowCount(),s=r.getColumnCount();let a=this._getResultArrayByArray1(n,s,r);if(a instanceof g)return a;a=a;for(let c=0;c<t.length;c++){if(t[c].isError())return t[c];let l=1,f=1;if(t[c].isArray()&&(l=t[c].getRowCount(),f=t[c].getColumnCount()),l!==n||f!==s)return g.create(h.VALUE);for(let m=0;m<n;m++){const d=[];for(let _=0;_<s;_++){let C=t[c];if(t[c].isArray()&&(C=t[c].get(m,_)),C.isError())return C;const E=C.getValue();!E||!S.isRealNum(E)?d.push(0):d.push(+E*a[m][_])}a[m]=d}}const u=a.reduce((c,l)=>c.concat(l)).reduce((c,l)=>c+l,0);return y.create(u)}else return r.sum()}_initArray1(e){let t=e;return t.isArray()||(t=q.create({calculateValueList:[[t]],rowCount:1,columnCount:1,unitId:"",sheetId:"",row:0,column:0})),t}_getResultArrayByArray1(e,t,r){const n=[];for(let s=0;s<e;s++){const a=[];for(let u=0;u<t;u++){const c=r.get(s,u);if(c.isError())return c;const l=c.getValue();!l||!S.isRealNum(l)?a.push(0):a.push(+l)}n.push(a)}return n}}class FC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);const r=y.create(2);for(let n=0;n<e.length;n++){let s=e[n];if(s.isString()&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()?s.iterator(a=>{if(a==null||a.isString()||a.isBoolean()||a.isNull())return!0;if(a.isError())return t=a,!1;t=t.plus(a.pow(r))}):t=t.plus(s.pow(r)),t.isError())return t}return t}}class kC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ie.create();const d=[],_=[];let C=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),M=+p.getValue();d.push(V),_.push(M),C+=V**2-M**2}),m.isError()?m:d.length===0||_.length===0?g.create(h.DIV_BY_ZERO):y.create(C)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!S.isRealNum(s)||r.isBoolean()||n.isString()&&!S.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2-a**2;return y.create(u)}}class $C extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ie.create();const d=[],_=[];let C=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),M=+p.getValue();d.push(V),_.push(M),C+=V**2+M**2}),m.isError()?m:d.length===0||_.length===0?g.create(h.DIV_BY_ZERO):y.create(C)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!S.isRealNum(s)||r.isBoolean()||n.isString()&&!S.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=s**2+a**2;return y.create(u)}}class YC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=r*n,a=t.isArray()?t.getRowCount():1,u=t.isArray()?t.getColumnCount():1,c=a*u;if(s!==c)return g.create(h.NA);if(s===1)return this._calculateSingleCell(e,t);{const l=e.flatten(),f=t.flatten();let m=ie.create();const d=[],_=[];let C=0;return l.iterator((E,b,R)=>{const p=f.get(b,R);if(E==null||E.isString()||E.isBoolean()||E.isNull())return!0;if(E!=null&&E.isError())return m=E,!1;if(p==null||p.isString()||p.isBoolean()||p.isNull())return!0;if(p!=null&&p.isError())return m=p,!1;const V=+E.getValue(),M=+p.getValue();d.push(V),_.push(M),C+=(V-M)**2}),m.isError()?m:d.length===0||_.length===0?g.create(h.DIV_BY_ZERO):y.create(C)}}_calculateSingleCell(e,t){let r=e;if(r.isArray()&&(r=r.get(0,0)),r.isError())return r;let n=t;if(n.isArray()&&(n=n.get(0,0)),n.isError())return n;if(r.isNull()||n.isNull())return g.create(h.VALUE);const s=+r.getValue(),a=+n.getValue();if(r.isString()&&!S.isRealNum(s)||r.isBoolean()||n.isString()&&!S.isRealNum(a)||n.isBoolean())return g.create(h.DIV_BY_ZERO);const u=(s-a)**2;return y.create(u)}}class HC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tan()}}class GC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return t.isString()&&(t=t.convertToNumberObjectValue()),t.isError()?t:t.tanh()}}class WC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.map((l,f,m)=>{let d=u.get(f,m),_=l;if(_.isString()&&(_=_.convertToNumberObjectValue()),_.isError())return _;if(d.isString()&&(d=d.convertToNumberObjectValue()),d.isError())return d;const C=+_.getValue(),E=+d.getValue(),b=10**Math.trunc(E),R=Dn(C,b),p=Math.trunc(lr(C,b)+R)/b;return y.create(p)});return n===1&&s===1?c.get(0,0):c}}const Eu=[[y0,H.ABS],[R0,H.ACOS],[p0,H.ACOSH],[N0,H.ACOT],[V0,H.ACOTH],[O0,H.ARABIC],[M0,H.ASIN],[S0,H.ASINH],[D0,H.ATAN],[w0,H.ATAN2],[P0,H.ATANH],[L0,H.BASE],[x0,H.CEILING],[j0,H.CEILING_MATH],[U0,H.CEILING_PRECISE],[T0,H.COMBIN],[v0,H.COMBINA],[B0,H.COS],[I0,H.COSH],[F0,H.COT],[k0,H.COTH],[$0,H.CSC],[Y0,H.CSCH],[H0,H.DECIMAL],[G0,H.DEGREES],[W0,H.EVEN],[Q0,H.EXP],[q0,H.FACT],[K0,H.FACTDOUBLE],[X0,H.FLOOR],[Z0,H.FLOOR_MATH],[z0,H.FLOOR_PRECISE],[J0,H.GCD],[eC,H.INT],[tC,H.LCM],[rC,H.LN],[nC,H.LOG],[sC,H.LOG10],[aC,H.MDETERM],[iC,H.MINVERSE],[oC,H.MMULT],[uC,H.MOD],[cC,H.MROUND],[lC,H.MULTINOMIAL],[fC,H.MUNIT],[mC,H.ODD],[hC,H.PI],[gC,H.POWER],[dC,H.PRODUCT],[CC,H.QUOTIENT],[_C,H.RADIANS],[AC,H.RAND],[EC,H.RANDARRAY],[bC,H.RANDBETWEEN],[yC,H.ROMAN],[RC,H.ROUND],[pC,H.ROUNDBANK],[NC,H.ROUNDDOWN],[VC,H.ROUNDUP],[OC,H.SEC],[MC,H.SECH],[DC,H.SERIESSUM],[SC,H.SEQUENCE],[wC,H.SIGN],[PC,H.SIN],[LC,H.SINH],[xC,H.SQRT],[jC,H.SQRTPI],[UC,H.SUBTOTAL],[TC,H.SUM],[vC,H.SUMIF],[BC,H.SUMIFS],[IC,H.SUMPRODUCT],[FC,H.SUMSQ],[kC,H.SUMX2MY2],[$C,H.SUMX2PY2],[YC,H.SUMXMY2],[HC,H.TAN],[GC,H.TANH],[WC,H.TRUNC]];class QC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2);A(this,"_compareType",Y.EQUALS)}setCompareType(e){this._compareType=e}calculate(e,t){return e.isError()?e:t.isError()?t:e.compare(t,this._compareType)}}class Ca extends dt{constructor(e){super("");A(this,"_values",[]);this._values=e}static create(e){return new Ca(e)}isCube(){return!0}dispose(){this._values.forEach(e=>{e.dispose()}),this._values=[]}sum(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.sum())}),e}max(){let e=y.create(Number.NEGATIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isLessThan(r)&&(e=r)}),e}min(){let e=y.create(Number.POSITIVE_INFINITY);return this._values.forEach(t=>{const r=t.max();e.isGreaterThan(r)&&(e=r)}),e}count(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.count())}),e}countA(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countA())}),e}countBlank(){const e=y.create(0);return this._values.forEach(t=>{e.plus(t.countBlank())}),e}}class qC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isError())return n;if(!n.isArray())return g.create(h.VALUE);t.push(n)}return Ca.create(t)}}class KC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:!t.isArray()&&t.getValue()===0?g.create(h.DIV_BY_ZERO):e.divided(t)}}class XC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.minus(t)}}class ZC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.multiply(t)}}class zC extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()?e:t.isError()?t:e.plus(t)}}const bu=[[QC,Le.COMPARE],[KC,Le.DIVIDED],[XC,Le.MINUS],[ZC,Le.MULTIPLY],[zC,Le.PLUS],[qC,Le.CUBE]];class JC extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(u=e_(u),u.isError())return u;if(e[a]=u,t=t.plus(u.sum()),t.isError())return t;r=r.plus(u.count())}else u.isNull()||(t=t.plus(u),r=r.plus(y.create(1)))}if(r.getValue()===0)return g.create(h.NUM);const n=t.divided(r);if(n.isError())return n;let s=y.create(0);for(let a=0;a<e.length;a++){let u=e[a];if(u.isString()&&(u=u.convertToNumberObjectValue()),u.isError())return u;if(u.isArray()){if(s=s.plus(u.minus(n).abs().sum()),s.isError())return s}else u.isNull()||(s=s.plus(u.minus(n).abs()))}return s.divided(r)}}function e_(i){const o=[];o[0]=[];let e=null;return i.iterator((t,r,n)=>{if(t!=null&&t.isError())return e=t,!1;t!=null&&t.isNumber()&&o[0].push(t)}),e||Gt(o,1,o[0].length)}class t_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(t=t.plus(s.sum()),t.isError())return t;r=r.plus(s.count())}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class r_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",254)}calculate(...e){let t=!1,r;e.length%2!==0&&(t=!0,r=g.create(h.NA));const n=[],s=[];for(let a=0;a<e.length;a+=2){const u=e[a],c=u.isArray()?u.getRowCount():1,l=u.isArray()?u.getColumnCount():1;for(let _=0;_<c;_++)for(let C=0;C<l;C++){const E=u.isArray()?u.get(_,C):u;if(E.isError())return E;if(t)continue;const b=E.isNull()?"":E.getValue();n.push(b)}if(a+1>=e.length)continue;const f=e[a+1],m=f.isArray()?f.getRowCount():1,d=f.isArray()?f.getColumnCount():1;(m!==c||d!==l)&&(t=!0,r=g.create(h.VALUE));for(let _=0;_<m;_++)for(let C=0;C<d;C++){const E=f.isArray()?f.get(_,C):f;if(E.isError())return E;if(t)continue;const b=E.isNull()?"":E.getValue();s.push(b)}}return t?r:this._getResult(n,s)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let u=0;u<r;u++){const c=e[u],l=t[u];if(!(typeof c!="number"&&typeof l!="number")){if(typeof c!="number"||typeof l!="number"||l<0)return g.create(h.VALUE);n+=c*l,s+=l}}if(s===0)return g.create(h.DIV_BY_ZERO);const a=n/s;return y.create(a)}}class n_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0),r=y.create(0);for(let n=0;n<e.length;n++){let s=e[n];if((s.isString()||s.isBoolean())&&(s=s.convertToNumberObjectValue()),s.isError())return s;if(s.isArray()){if(s.iterator(a=>{if(a==null||a.isNull())return!0;let u=a;if(u.isString()&&(u=u.convertToNumberObjectValue(),u.isError()&&(u=y.create(0))),u.isBoolean()&&(u=u.convertToNumberObjectValue()),u.isError())return t=u,!1;t=t.plus(u),r=r.plus(y.create(1))}),t.isError())return t}else s.isNull()||(t=t.plus(s),r=r.plus(y.create(1)))}return t.divided(r)}}class s_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){if(e.isError())return e;if(t.isError())return t;if(r!=null&&r.isError())return r;let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject()),n.isArray()||(n=Gt([[n]],1,1));let s=t;return s.isReferenceObject()&&(s=s.toArrayValueObject()),r&&!(r!=null&&r.isReferenceObject())?g.create(h.NA):(s=s,s.isArray()?s.map(a=>this._handleSingleObject(n,a,r)):this._handleSingleObject(n,s,r))}_handleSingleObject(e,t,r){let n=Ln(e,t);n=xn(n,e,t);let s=r?this._createRangeReferenceObject(r,e):e;if(!s)return g.create(h.VALUE);if(s.isError())return s;s.isReferenceObject()&&(s=s.toArrayValueObject()),s=s;const a=s.pick(n),u=a.sum(),c=a.count();return u.divided(c)}_createRangeReferenceObject(e,t){const r=e.getRowCount(),n=e.getColumnCount(),s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;if(r===s&&n===a)return e;const{startRow:u,startColumn:c}=e.getRangePosition(),l={startRow:u,startColumn:c,endRow:u+s-1,endColumn:c+a-1};return this.createReferenceObject(e,l)}}class a_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=fr(t),s=Nr(t,e,r,n);if(s)return s;const a=Vr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a),c=u.sum(),l=u.count();return c.divided(l)})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(n)}}class i_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=s!=null?s:y.create(0),c=a!=null?a:y.create(1);u.isNull()&&(u=y.create(0)),c.isNull()&&(c=y.create(1));const l=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,u.isArray()?u.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,u.isArray()?u.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,e,g.create(h.NA)),d=O(l,f,t,g.create(h.NA)),_=O(l,f,r,g.create(h.NA)),C=O(l,f,n,g.create(h.NA)),E=O(l,f,u,g.create(h.NA)),b=O(l,f,c,g.create(h.NA)),R=m.mapValue((p,V,M)=>{const D=d.get(V,M),w=_.get(V,M),P=C.get(V,M),L=E.get(V,M),B=b.get(V,M);return this._handleSignleObject(p,D,w,P,L,B)});return l===1&&f===1?R.get(0,0):R}_handleSignleObject(e,t,r,n,s,a){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;if(n.isError())return n;if(s.isError())return s;if(a.isError())return a;const{isError:u,errorObject:c,variants:l}=F(e,t,r,n,s,a);if(u)return c;const[f,m,d,_,C,E]=l,b=+f.getValue(),R=+m.getValue(),p=+d.getValue(),V=+_.getValue(),M=+C.getValue(),D=+E.getValue();if(R<=0||p<=0||b<M||b>D||M===D)return g.create(h.NUM);let w;return V?w=fo((b-M)/(D-M),R,p):w=Sm((b-M)/(D-M),R,p)/(D-M),y.create(w)}}class o_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){let s=n!=null?n:r;s.isNull()&&(s=r);const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,s,g.create(h.NA)),d=c.mapValue((_,C,E)=>{const b=l.get(C,E),R=f.get(C,E),p=m.get(C,E);return _.isError()?_:b.isError()?b:R.isError()?R:p.isError()?p:this._handleSignleObject(_,b,R,p)});return a===1&&u===1?d.get(0,0):d}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),_=+l.getValue(),C=Math.floor(+f.getValue()),E=Math.floor(+m.getValue());if(d<0||_<0||_>1||C<0||C>d||E<0||E<C||E>d)return g.create(h.NUM);let b=0;for(let R=C;R<=E;R++)b+=aa(R,d,_);return y.create(b)}}class u_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(f<0||m<1||m>10**10)return g.create(h.NUM);let _;return d?_=ia(f,m):_=Dm(f,m),y.create(_)}}class c_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=ho(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class l_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);if(f.isError())return f;if(_.isError())return _;if(C.isError())return C;const{isError:E,errorObject:b,variants:R}=F(f,_,C);if(E)return b;const[p,V,M]=R,D=+p.getValue(),w=+V.getValue(),P=Math.floor(+M.getValue());if(D<=0||D>=1||w<=0||P<1)return g.create(h.NUM);if(P===1)return g.create(h.DIV_BY_ZERO);const L=Math.abs(In(D/2,P-1)*w/Math.sqrt(P));return y.create(L)});return n===1&&s===1?l.get(0,0):l}}class f_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++){const _=e[d]-a,C=t[d]-u;c+=_*C,l+=_**2,f+=C**2}const m=Math.sqrt(l*f);return m===0?g.create(h.DIV_BY_ZERO):y.create(c/m)}}class m_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){const n=e[r];n.isError()||(n.isArray()?t=t.plus(n.count()):n.isString()?n.convertToNumberObjectValue().isError()||(t=t.plus(y.create(1))):n.isNull()||(t=t.plus(y.create(1))))}return t}}class h_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(0);for(let r=0;r<e.length;r++){let n=e[r];if(n.isError()){t=t.plus(y.create(1));continue}n.isArray()?(n=n.countA(),t=t.plus(n)):n.isNull()||(t=t.plus(y.create(1)))}return t}}class g_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isError()?e:e.getValue()===""||e.isNull()?y.create(1):e.isArray()?e.countBlank():y.create(0)}}class d_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){return e.isError()||t.isError()?g.create(h.NA):e.isArray()?t.isArray()?t.mapValue(r=>this._handleSingleObject(e,r)):this._handleSingleObject(e,t):g.create(h.VALUE)}_handleSingleObject(e,t){let r=Ln(e,t);r=xn(r,e,t);const n=e.pick(r);return this._countA(n)}_countA(e){let t=y.create(0);return e.iterator(r=>{if(r==null)return!0;t=t.plusBy(1)}),t}}class C_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",255)}calculate(...e){if(e.length%2!==0||e.some((a,u)=>u%2===0&&!a.isArray()))return g.create(h.VALUE);const{maxRowLength:t,maxColumnLength:r}=fr(e),n=Nr(e,e[0],t,r);if(n)return n;const s=Vr(e,t,r,!0);return this._aggregateResults(s)}_aggregateResults(e){const t=e.map(n=>n.map(s=>__(s))),r={calculateValueList:t,rowCount:t.length,columnCount:t[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(r)}}function __(i){let o=0;return i.iterator(e=>{e!=null&&e.isBoolean()&&e.getValue()===!0&&o++}),y.create(o)}class A_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length<=1)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let l=0;l<r;l++)n+=e[l],s+=t[l];const a=n/r,u=s/r;let c=0;for(let l=0;l<r;l++){const f=e[l]-a,m=t[l]-u;c+=f*m}return y.create(c/(r-1))}}class E_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0,n=!0;for(let u=0;u<e.length;u++){const c=e[u];if(c.isArray()){let l=!1,f=g.create(h.VALUE);if(c.iterator(m=>{const d=this._handleSingleObject(m);if(d.isError())return l=!0,f=d,!1;if(d.isNull())return!0;const _=d.getValue();t.push(_),r+=_,n=!1}),l)return f}else{const l=this._handleSingleObject(c);if(l.isError())return l;if(l.isNull())continue;const f=l.getValue();t.push(f),r+=f,n=!1}}if(n)return g.create(h.NUM);const s=r/t.length;let a=0;for(let u=0;u<t.length;u++)a+=(t[u]-s)**2;return y.create(a)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull()||e.isBoolean())return ie.create();const t=e.getValue();return S.isRealNum(t)?y.create(+t):ie.create()}}class b_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),_=Math.floor(+l.getValue()),C=Math.floor(+f.getValue()),E=+m.getValue();if(d<0||_<1||_>10**10||C<1||C>10**10)return g.create(h.NUM);let b;return E?b=oa(d,_,C):b=wm(d,_,C),Number.isNaN(b)||!Number.isFinite(b)?g.create(h.NUM):y.create(b)}}class y_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=Math.floor(+l.getValue());if(f<0||f>1||m<1||m>10**10||d<1||d>10**10)return g.create(h.NUM);const _=go(f,m,d);return Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}class R_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=s.getValue();if(a<=-1||a>=1)return g.create(h.NUM);const u=Math.log((1+a)/(1-a))/2;return y.create(u)}}class p_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){return e.isArray()?e.mapValue(t=>this._handleSingleObject(t)):this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(2*a)-1,c=Math.exp(2*a)+1;return!Number.isFinite(u)&&u>0&&!Number.isFinite(c)&&c>0?y.create(1):y.create(u/c)}}class si extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=t.isArray()?t.getRowCount():1,s=t.isArray()?t.getColumnCount():1,a=r.isArray()?r.getRowCount():1,u=r.isArray()?r.getColumnCount():1;let c=t;t.isArray()&&n===1&&s===1&&(c=t.get(0,0));let l=r;return r.isArray()&&a===1&&u===1&&(l=r.get(0,0)),e.isArray()?e.mapValue(f=>this._handleSignleObject(f,c,l,n,s,a,u)):this._handleSignleObject(e,c,l,n,s,a,u)}_handleSignleObject(e,t,r,n,s,a,u){if(e.isError())return e;if(t.isError())return t;if(r.isError())return r;let c=e;if(e.isString()&&(c=e.convertToNumberObjectValue()),c.isError())return c;const l=+c.getValue();if((n*s===1||a*u===1)&&(t.isNull()||r.isNull()))return g.create(h.VALUE);if(n*s!==a*u)return g.create(h.NA);const{isError:f,errorObject:m,array1Values:d,array2Values:_,noCalculate:C}=Ge(t,r,n*s,s,u);if(f)return m;if(C)return g.create(h.DIV_BY_ZERO);const E=Co(l,d,_);return Number.isFinite(E)?y.create(E):g.create(h.DIV_BY_ZERO)}}class N_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,values:s}=this._getValues(e);if(r)return n;if(e.isNull()||t.isNull())return g.create(h.VALUE);let{values:a}=this._getValues(t,!0);a.length===0&&(a=[0]);const u=this._getNewBinsArrayValues(a),c=new Array(u.length).fill(0);for(let l=0;l<s.length;l++){const f=s[l],m=u.findIndex(d=>f>d.start&&f<=d.end);c[m]++}return q.createByArray(c.map(l=>[l]))}_getValues(e,t=!1){const r=[],n=e.isArray()?e.getRowCount():1,s=e.isArray()?e.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=e.isArray()?e.get(a,u):e;if(c.isError()){if(!t)return{isError:!0,errorObject:c,values:r};continue}if(c.isNull()||c.isBoolean())continue;const l=c.getValue();S.isRealNum(l)&&r.push(+l)}return{isError:!1,errorObject:null,values:r}}_getNewBinsArrayValues(e){const t=e.map((n,s)=>({value:n,index:s})).sort((n,s)=>n.value-s.value),r=[];for(let n=0;n<t.length;n++){const s=t[n].index;if(n===0){r[s]={start:-1/0,end:t[n].value};continue}r[s]={start:t[n-1].value,end:t[n].value}}return r.push({start:t[t.length-1].value,end:1/0}),r}}var T=(i=>(i.AVEDEV="AVEDEV",i.AVERAGE="AVERAGE",i.AVERAGE_WEIGHTED="AVERAGE.WEIGHTED",i.AVERAGEA="AVERAGEA",i.AVERAGEIF="AVERAGEIF",i.AVERAGEIFS="AVERAGEIFS",i.BETA_DIST="BETA.DIST",i.BETA_INV="BETA.INV",i.BINOM_DIST="BINOM.DIST",i.BINOM_DIST_RANGE="BINOM.DIST.RANGE",i.BINOM_INV="BINOM.INV",i.CHISQ_DIST="CHISQ.DIST",i.CHISQ_DIST_RT="CHISQ.DIST.RT",i.CHISQ_INV="CHISQ.INV",i.CHISQ_INV_RT="CHISQ.INV.RT",i.CHISQ_TEST="CHISQ.TEST",i.CONFIDENCE_NORM="CONFIDENCE.NORM",i.CONFIDENCE_T="CONFIDENCE.T",i.CORREL="CORREL",i.COUNT="COUNT",i.COUNTA="COUNTA",i.COUNTBLANK="COUNTBLANK",i.COUNTIF="COUNTIF",i.COUNTIFS="COUNTIFS",i.COVARIANCE_P="COVARIANCE.P",i.COVARIANCE_S="COVARIANCE.S",i.DEVSQ="DEVSQ",i.EXPON_DIST="EXPON.DIST",i.F_DIST="F.DIST",i.F_DIST_RT="F.DIST.RT",i.F_INV="F.INV",i.F_INV_RT="F.INV.RT",i.F_TEST="F.TEST",i.FISHER="FISHER",i.FISHERINV="FISHERINV",i.FORECAST="FORECAST",i.FORECAST_ETS="FORECAST.ETS",i.FORECAST_ETS_CONFINT="FORECAST.ETS.CONFINT",i.FORECAST_ETS_SEASONALITY="FORECAST.ETS.SEASONALITY",i.FORECAST_ETS_STAT="FORECAST.ETS.STAT",i.FORECAST_LINEAR="FORECAST.LINEAR",i.FREQUENCY="FREQUENCY",i.GAMMA="GAMMA",i.GAMMA_DIST="GAMMA.DIST",i.GAMMA_INV="GAMMA.INV",i.GAMMALN="GAMMALN",i.GAMMALN_PRECISE="GAMMALN.PRECISE",i.GAUSS="GAUSS",i.GEOMEAN="GEOMEAN",i.GROWTH="GROWTH",i.HARMEAN="HARMEAN",i.HYPGEOM_DIST="HYPGEOM.DIST",i.INTERCEPT="INTERCEPT",i.KURT="KURT",i.LARGE="LARGE",i.LINEST="LINEST",i.LOGEST="LOGEST",i.LOGNORM_DIST="LOGNORM.DIST",i.LOGNORM_INV="LOGNORM.INV",i.MARGINOFERROR="MARGINOFERROR",i.MAX="MAX",i.MAXA="MAXA",i.MAXIFS="MAXIFS",i.MEDIAN="MEDIAN",i.MIN="MIN",i.MINA="MINA",i.MINIFS="MINIFS",i.MODE_MULT="MODE.MULT",i.MODE_SNGL="MODE.SNGL",i.NEGBINOM_DIST="NEGBINOM.DIST",i.NORM_DIST="NORM.DIST",i.NORM_INV="NORM.INV",i.NORM_S_DIST="NORM.S.DIST",i.NORM_S_INV="NORM.S.INV",i.PEARSON="PEARSON",i.PERCENTILE_EXC="PERCENTILE.EXC",i.PERCENTILE_INC="PERCENTILE.INC",i.PERCENTRANK_EXC="PERCENTRANK.EXC",i.PERCENTRANK_INC="PERCENTRANK.INC",i.PERMUT="PERMUT",i.PERMUTATIONA="PERMUTATIONA",i.PHI="PHI",i.POISSON_DIST="POISSON.DIST",i.PROB="PROB",i.QUARTILE_EXC="QUARTILE.EXC",i.QUARTILE_INC="QUARTILE.INC",i.RANK_AVG="RANK.AVG",i.RANK_EQ="RANK.EQ",i.RSQ="RSQ",i.SKEW="SKEW",i.SKEW_P="SKEW.P",i.SLOPE="SLOPE",i.SMALL="SMALL",i.STANDARDIZE="STANDARDIZE",i.STDEV_P="STDEV.P",i.STDEV_S="STDEV.S",i.STDEVA="STDEVA",i.STDEVPA="STDEVPA",i.STEYX="STEYX",i.T_DIST="T.DIST",i.T_DIST_2T="T.DIST.2T",i.T_DIST_RT="T.DIST.RT",i.T_INV="T.INV",i.T_INV_2T="T.INV.2T",i.T_TEST="T.TEST",i.TREND="TREND",i.TRIMMEAN="TRIMMEAN",i.VAR_P="VAR.P",i.VAR_S="VAR.S",i.VARA="VARA",i.VARPA="VARPA",i.WEIBULL_DIST="WEIBULL.DIST",i.Z_TEST="Z.TEST",i))(T||{});class V_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue();if(a===0||a<0&&a%1===0)return g.create(h.NUM);const u=Wr(a);return Number.isNaN(u)||!Number.isFinite(u)?g.create(h.NUM):y.create(u)}}class ai extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue();if(a<=0)return g.create(h.NUM);const u=rt(a);return Math.abs(u)<1e-15?y.create(0):y.create(u)}}class O_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Sr(a,0,1)-.5;return y.create(u)}}class M_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=1,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!S.isRealNum(m))return!0;+m<=0&&(n=!0),t*=+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!S.isRealNum(c))continue;+c<=0&&(n=!0),t*=+c,r++}}if(r===0||n)return g.create(h.NUM);const s=t**(1/r);return y.create(s)}}class S_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a}=Fn(e,t,r);if(s)return a;const u=at(e);if(u instanceof g)return u;const c=this._getKnownXsValues(u,t);if(c instanceof g)return c;const l=this._getNewXsValues(c,r);if(l instanceof g)return l;let f=n!=null?n:v.create(!0);if(f.isArray()&&(f=f.get(0,0)),f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+f.getValue();return this._getResult(u,c,l,m)}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?e.length===1&&t.length>1&&(n?t.length+1:t.length)>e[0].length||e[0].length===1&&t[0].length>1&&(n?t[0].length+1:t[0].length)>e.length?g.create(h.NA):this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=e.length===1&&e[0].length>1,a=Yn(e,t,r,n,!0);if(a instanceof g)return a;const{coefficients:u,newX:c}=a,l=u[0].length,f=u[0][l-1];let m=[];for(let d=0;d<c.length;d++){m[d]=[];let _=f;for(let C=l-2;C>=0;C--)_*=u[0][l-2-C]**c[d][C];m[d].push(_)}return s&&(m=st(m)),q.createByArray(m)}_getResultBySimpleVariables(e,t,r,n){const s=e.flat(),a=t.flat(),{slope:u,intercept:c}=$n(a,s,n,!0),l=r.map(f=>f.map(m=>c*u**m));return q.createByArray(l)}_getKnownXsValues(e,t){return!t||t.isNull()?kn(e.length,e[0].length):at(t)}_getNewXsValues(e,t){return!t||t.isNull()?e:at(t)}}class D_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0,n=!1;for(let a=0;a<e.length;a++){const u=e[a];if(u.isArray()){let c=!1,l=g.create(h.VALUE);if(u.iterator(f=>{if(f!=null&&f.isError())return c=!0,l=f,!1;if(f!=null&&f.isNull()||f!=null&&f.isBoolean())return!0;const m=f.getValue();if(!S.isRealNum(m))return!0;+m<=0&&(n=!0),t+=1/+m,r++}),c)return l}else{if(u.isError())return u;if(u.isString()){const l=u.convertToNumberObjectValue();if(l.isError())return l}if(u.isNull()||u.isBoolean())continue;const c=u.getValue();if(!S.isRealNum(c))continue;+c<=0&&(n=!0),t+=1/+c,r++}}if(r===0)return g.create(h.NA);if(n)return g.create(h.NUM);const s=r/t;return y.create(s)}}class w_ extends N{constructor(){super(...arguments);A(this,"minParams",5);A(this,"maxParams",5)}calculate(e,t,r,n,s){const a=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,t,g.create(h.NA)),f=O(a,u,r,g.create(h.NA)),m=O(a,u,n,g.create(h.NA)),d=O(a,u,s,g.create(h.NA)),_=c.mapValue((C,E,b)=>{const R=l.get(E,b),p=f.get(E,b),V=m.get(E,b),M=d.get(E,b);return C.isError()?C:R.isError()?R:p.isError()?p:V.isError()?V:M.isError()?M:this._handleSignleObject(C,R,p,V,M)});return a===1&&u===1?_.get(0,0):_}_handleSignleObject(e,t,r,n,s){const{isError:a,errorObject:u,variants:c}=F(e,t,r,n,s);if(a)return u;const[l,f,m,d,_]=c,C=Math.floor(+l.getValue()),E=Math.floor(+f.getValue()),b=Math.floor(+m.getValue()),R=Math.floor(+d.getValue()),p=+_.getValue();if(C<0||C>E||C>b||C<E-R+b||E<=0||E>R||b<=0||b>R||R<=0)return g.create(h.NUM);let V;return p?V=Tm(C,E,b,R):V=ca(C,E,b,R),Number.isNaN(V)&&(V=0),y.create(V)}}class P_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=Co(0,e,t);return Number.isFinite(r)?y.create(r):g.create(h.DIV_BY_ZERO)}}class L_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();S.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=3?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**4;const c=r*(r+1)/((r-1)*(r-2)*(r-3))*u-3*(r-1)**2/((r-2)*(r-3));return y.create(c)}}class x_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.ceil(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>a-s)}}class j_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a}=Fn(e,t);if(s)return a;const u=at(e);if(u instanceof g)return u;const c=this._getKnownXsValues(u,t);if(c instanceof g)return c;let l=r!=null?r:v.create(!0);l.isArray()&&(l=l.get(0,0));let f=n!=null?n:v.create(!1);f.isArray()&&(f=f.get(0,0));const{isError:m,errorObject:d,variants:_}=F(l,f);if(m)return d;const[C,E]=_;return this._getResult(u,c,+C.getValue(),+E.getValue())}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?e.length===1&&t.length>1&&(r?t.length+1:t.length)>e[0].length||e[0].length===1&&t[0].length>1&&(r?t[0].length+1:t[0].length)>e.length?g.create(h.NA):this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=Yn(e,t,t,r,!1);if(s instanceof g)return s;const{coefficients:a,X:u,XTXInverse:c}=s;let l=[];if(n){const f=e.flat(),m=f.length,d=r?f.reduce((j,k)=>j+k,0)/m:0,_=c.length,C=m-_,E=a[0].length,b=new Array(E-2).fill(h.NA),R=a[0][E-1],p=[];for(let j=0;j<u.length;j++){let k=R;for(let Q=E-2;Q>=0;Q--)k+=a[0][E-2-Q]*u[j][Q];p.push(k)}let V=0,M=0;for(let j=0;j<m;j++)V+=(f[j]-d)**2,M+=(f[j]-p[j])**2;const D=V-M,w=V===0?0:D/V,P=[];for(let j=_-1;j>=0;j--){const k=C>0?Math.sqrt(M/C*c[j][j]):0;P.push(k)}if(r){const j=P.shift();P.push(j)}else P.push(h.NA);const L=C>0?Math.sqrt(M/C):0,B=C>0?D/(E-1)/(M/C):h.NUM;l=[a[0],[...P],[w,L,...b],[B,C,...b],[D,M,...b]]}else l=[a[0]];return q.createByArray(l)}_getResultBySimpleVariables(e,t,r,n){const s=e.flat(),a=t.flat(),{slope:u,intercept:c}=$n(a,s,r,!1);if(Number.isNaN(u))return g.create(h.NA);let l=[];if(n){const f=s.length;let m=0,d=0,_=f-1;if(r){let P=0,L=0;for(let B=0;B<f;B++)P+=s[B],L+=a[B];m=P/f,d=L/f,_=f-2}let C=0,E=0,b=0;for(let P=0;P<f;P++)C+=(s[P]-m)**2,E+=(s[P]-(u*a[P]+c))**2,b+=(a[P]-d)**2;const R=C-E,p=R===C?1:R/C;let V=0,M=0,D=0;_>0&&(b>0&&(V=Math.sqrt(E/_/b),M=Math.sqrt(E/_*(1/f+d**2/b))),D=Math.sqrt(E/_));const w=_>0?R/1/(E/_):h.NUM;r||(M=h.NA),l=[[u,c],[V,M],[p,D],[w,_],[R,E]]}else l=[[u,c]];return q.createByArray(l)}_getKnownXsValues(e,t){return!t||t.isNull()?kn(e.length,e[0].length):at(t)}}class U_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a}=Fn(e,t);if(s)return a;const u=at(e);if(u instanceof g)return u;const c=this._getKnownXsValues(u,t);if(c instanceof g)return c;let l=r!=null?r:v.create(!0);l.isArray()&&(l=l.get(0,0));let f=n!=null?n:v.create(!1);f.isArray()&&(f=f.get(0,0));const{isError:m,errorObject:d,variants:_}=F(l,f);if(m)return d;const[C,E]=_;return this._getResult(u,c,+C.getValue(),+E.getValue())}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?e.length===1&&t.length>1&&(r?t.length+1:t.length)>e[0].length||e[0].length===1&&t[0].length>1&&(r?t[0].length+1:t[0].length)>e.length?g.create(h.NA):this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=Yn(e,t,t,r,!0);if(s instanceof g)return s;const{coefficients:a,Y:u,X:c,XTXInverse:l}=s;let f=[];if(n){const m=u.flat(),d=m.length,_=r?m.reduce((k,Q)=>k+Q,0)/d:0,C=l.length,E=d-C,b=a[0].length,R=new Array(b-2).fill(h.NA),p=a[0][b-1],V=[];for(let k=0;k<c.length;k++){let Q=p;for(let te=b-2;te>=0;te--)Q*=a[0][b-2-te]**c[k][te];V.push(Math.log(Q))}let M=0,D=0;for(let k=0;k<d;k++)M+=(m[k]-_)**2,!(!r&&!Number.isFinite(V[k]))&&(D+=(m[k]-V[k])**2);Number.isFinite(D)||(D=0);const w=M-D,P=M===0?0:w/M,L=[];for(let k=C-1;k>=0;k--){const Q=E>0?Math.sqrt(D/E*l[k][k]):0;L.push(Q)}if(r){const k=L.shift();L.push(k)}else L.push(h.NA);const B=E>0?Math.sqrt(D/E):0,j=E>0?w/(b-1)/(D/E):h.NUM;f=[a[0],[...L],[P,B,...R],[j,E,...R],[w,D,...R]]}else f=[a[0]];return q.createByArray(f)}_getResultBySimpleVariables(e,t,r,n){const s=e.flat(),a=t.flat(),{slope:u,intercept:c,Y:l}=$n(a,s,r,!0);if(Number.isNaN(u))return g.create(h.NA);let f=[];if(n){const m=l.length;let d=0,_=0,C=m-1;if(r){let L=0,B=0;for(let j=0;j<m;j++)L+=l[j],B+=a[j];d=L/m,_=B/m,C=m-2}let E=0,b=0,R=0;for(let L=0;L<m;L++)E+=(l[L]-d)**2,b+=(l[L]-Math.log(c*u**a[L]))**2,R+=(a[L]-_)**2;const p=E-b,V=E===0?0:p/E;let M=0,D=0,w=0,P=0;C>0&&(R>0&&(M=Math.sqrt(b/C/R),D=Math.sqrt(b/C*(1/m+_**2/R))),w=Math.sqrt(b/C),P=p/1/(b/C)),r||(D=h.NA),f=[[u,c],[M,D],[V,w],[P,C],[p,b]]}else f=[[u,c]];return q.createByArray(f)}_getKnownXsValues(e,t){return!t||t.isNull()?kn(e.length,e[0].length):at(t)}}class T_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=+c.getValue(),_=+l.getValue(),C=+f.getValue(),E=+m.getValue();if(d<=0||C<=0)return g.create(h.NUM);let b;return E?b=Ao(d,_,C):b=vm(d,_,C),y.create(b)}}class v_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getRangeValues(e);if(r instanceof g)return r;const n=It(t);if(n.isError())return n;const{isError:s,errorObject:a,variants:u}=F(n);if(s)return a;const[c]=u,l=+c.getValue();if(l<=0||l>=1)return g.create(h.NUM);if(r.length<2)return g.create(h.DIV_BY_ZERO);const f=1-l,m=r.length,d=r.reduce((b,R)=>b+R,0)/m,_=r.reduce((b,R)=>b+(R-d)**2,0)/(m-1),C=Math.sqrt(_);if(C<=0)return g.create(h.NUM);const E=Math.abs(In(f/2,m-1)*C/Math.sqrt(m));return y.create(E)}_getRangeValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;u.isNull()||u.isBoolean()||u.isString()||t.push(+u.getValue())}return t}}class B_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.max()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class I_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.NEGATIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.NEGATIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isLessThan(t);let n=e;return r.getValue()&&(n=t),n}}class F_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=fr(t),s=Nr(t,e,r,n);if(s)return s;const a=Vr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?q.create("0"):u.max()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(n)}}class k_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(n.isArray()){let s=!1,a=g.create(h.VALUE);if(n.iterator(u=>{if(u!=null&&u.isError())return s=!0,a=u,!1;if(u!=null&&u.isNull()||u!=null&&u.isBoolean())return!0;const c=u.getValue();if(!S.isRealNum(c))return!0;t.push(+c)}),s)return a}else{if(n.isError())return n;if(n.isNull()||n.isBoolean())continue;if(n.isString()){const a=n.convertToNumberObjectValue();if(a.isError())return a}const s=n.getValue();if(!S.isRealNum(s))continue;t.push(+s)}}return t.length===0?g.create(h.NUM):this._getResult(t.sort((r,n)=>r-n))}_getResult(e){const t=e.length;let r;if(t%2===0){const n=t/2;r=(e[n-1]+e[n])/2}else r=e[Math.floor(t/2)];return y.create(r)}}class $_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isArray()&&(n=n.min()),n.isError())return n;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class Y_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=y.create(Number.POSITIVE_INFINITY);for(let r=0;r<e.length;r++){let n=e[r];if(!n.isNull()){if((n.isString()||n.isBoolean())&&(n=n.convertToNumberObjectValue()),n.isError())return n;if(n.isArray()&&n.iterator(s=>{let a=s;if((a==null||a.isNull()||a.isString())&&(a=y.create(0)),a.isBoolean()&&(a=a.convertToNumberObjectValue()),a.isError())return t=a,!1;t=this._validator(t,a)}),t.isError())return t;t=this._validator(t,n)}}return t.getValue()===Number.POSITIVE_INFINITY?y.create(0):t}_validator(e,t){const r=e.isGreaterThan(t);let n=e;return r.getValue()&&(n=t),n}}class H_ extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,...t){if(e.isError())return g.create(h.NA);if(!e.isArray()||t.length%2!==0||t.some((u,c)=>c%2===0&&!u.isArray()))return g.create(h.VALUE);const{maxRowLength:r,maxColumnLength:n}=fr(t),s=Nr(t,e,r,n);if(s)return s;const a=Vr(t,r,n,!0);return this._aggregateResults(e,a)}_aggregateResults(e,t){const r=t.map(s=>s.map(a=>{const u=e.pick(a);return u.getColumnCount()===0?q.create("0"):u.min()})),n={calculateValueList:r,rowCount:r.length,columnCount:r[0].length,unitId:this.unitId||"",sheetId:this.subUnitId||"",row:this.row,column:this.column};return q.create(n)}}class G_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t={};let r=0,n=1;for(let s=0;s<e.length;s++){const a=e[s];if(a.isError())return a;if(a.isString()){const l=a.convertToNumberObjectValue();if(l.isError())return l}const u=a.isArray()?a.getRowCount():1,c=a.isArray()?a.getColumnCount():1;for(let l=0;l<u;l++)for(let f=0;f<c;f++){const m=a.isArray()?a.get(l,f):a;if(m.isError())return m;if(m.isNull()||m.isBoolean()||m.isString())continue;const d=m.getValue();S.isRealNum(d)&&(t[+d]?(t[+d].count++,t[+d].count>n&&(n=t[+d].count)):t[+d]={count:1,order:r++})}}return r===0||n===1?new g(h.NA):this._getResult(t,n)}_getResult(e,t){const r=Object.entries(e).filter(([n,{count:s}])=>s===t).sort((n,s)=>n[1].order-s[1].order).map(([n])=>+n);return r.length===1?y.create(r[0]):q.createByArray(r.map(n=>[n]))}}class W_ extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSignleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(e,t,r,n);if(s)return a;const[c,l,f,m]=u,d=Math.floor(+c.getValue()),_=Math.floor(+l.getValue()),C=+f.getValue(),E=+m.getValue();if(d<0||_<1||C<=0||C>=1)return g.create(h.NUM);let b;return E?b=Im(d,_,C):b=la(d,_,C),y.create(b)}}class Q_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=+u.getValue();let f;return l?f=Sr(c,0,1):f=Eo(c,0,1),y.create(f)}}class q_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=c/Math.sqrt(l*f);return y.create(m)}}class K_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=+a.getValue(),c=e.length;if(u<1/(c+1)||u>1-1/(c+1))return g.create(h.NUM);const l=u*(c+1)-1,f=Math.floor(l),m=l-f;if(m===0)return y.create(e[f]);const d=e[f]+m*(e[f+1]-e[f]);return y.create(d)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class X_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=this._getValues(e);let s=r!=null?r:y.create(3);s.isNull()&&(s=y.create(3));const a=Math.max(t.isArray()?t.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(t.isArray()?t.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,t,g.create(h.NA)),l=O(a,u,s,g.create(h.NA)),f=c.mapValue((m,d,_)=>{const C=l.get(d,_);return m.isError()?m:C.isError()?C:this._handleSingleObject(n,m,C)});return a===1&&u===1?f.get(0,0):f}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=F(t,r);if(n)return s;const[u,c]=a,l=+u.getValue(),f=Math.floor(+c.getValue()),m=e.length;if(m===0||l<e[0]||l>e[m-1])return g.create(h.NA);if(m===1)return l===e[0]?y.create(1):g.create(h.NA);let d=0,_=!1,C=0;for(;!_&&C<m;)l===e[C]?(d=(C+1)/(m+1),_=!0):l>e[C]&&C+1<m&&l<e[C+1]&&(d=(C+1+(l-e[C])/(e[C+1]-e[C]))/(m+1),_=!0),C++;return _?f<1?g.create(h.NUM):(d=ke(d,f),y.create(d)):g.create(h.NA)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.sort((s,a)=>s-a)}}class Z_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:_,variants:C}=F(c,m);if(d)return _;const[E,b]=C,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0||R<p)return g.create(h.NUM);let V=1;for(let M=R-p+1;M<=R;M++)V*=M;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class z_ extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);if(c.isError())return c;if(m.isError())return m;const{isError:d,errorObject:_,variants:C}=F(c,m);if(d)return _;const[E,b]=C,R=Math.floor(+E.getValue()),p=Math.floor(+b.getValue());if(R<0||R>=2147483647||p<0)return g.create(h.NUM);if(R===0)return p===0?y.create(1):y.create(0);const V=R**p;return Number.isFinite(V)?y.create(V):g.create(h.NUM)});return r===1&&n===1?u.get(0,0):u}}class J_ extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.exp(-.5*a*a)/Math.sqrt(2*Math.PI);return y.create(u)}}class eA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a,xRangeValues:u,probRangeValues:c}=this._handleXRangeAndProbRange(e,t);let l=n!=null?n:r;n!=null&&n.isNull()&&(l=r);const f=Math.max(r.isArray()?r.getRowCount():1,l.isArray()?l.getRowCount():1),m=Math.max(r.isArray()?r.getColumnCount():1,l.isArray()?l.getColumnCount():1),d=O(f,m,r,g.create(h.NA)),_=O(f,m,l,g.create(h.NA)),C=d.mapValue((E,b,R)=>{const p=_.get(b,R);return e.isError()?e:t.isError()?t:E.isError()?E:p.isError()?p:s?a:this._handleSignleObject(u,c,E,p)});return f===1&&m===1?C.get(0,0):C}_handleSignleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(r,n);if(s)return a;const[c,l]=u,f=+c.getValue(),m=+l.getValue();if(t.reduce((_,C)=>_+C,0)!==1)return g.create(h.NUM);let d=0;for(let _=0;_<e.length;_++)e[_]>=f&&e[_]<=m&&(d+=t[_]);return y.create(d)}_handleXRangeAndProbRange(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return{isError:!0,errorObject:u,xRangeValues:[],probRangeValues:[]};let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return{isError:!0,errorObject:c,xRangeValues:[],probRangeValues:[]};if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return{isError:!0,errorObject:g.create(h.VALUE),xRangeValues:[],probRangeValues:[]};if(r*n!==s*a)return{isError:!0,errorObject:g.create(h.NA),xRangeValues:[],probRangeValues:[]};const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?{isError:!0,errorObject:f,xRangeValues:[],probRangeValues:[]}:_?{isError:!0,errorObject:g.create(h.DIV_BY_ZERO),xRangeValues:[],probRangeValues:[]}:{isError:!1,errorObject:null,xRangeValues:m,probRangeValues:d}}}class tA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<=0||u>=4)return g.create(h.NUM);const c=u/4,l=e.length;if(c<1/(l+1)||c>1-1/(l+1))return g.create(h.NUM);const f=c*(l+1)-1,m=Math.floor(f),d=f-m;if(d===0)return y.create(e[m]);const _=e[m]+d*(e[m+1]-e[m]);return y.create(_)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class rA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),_=m.map((C,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+C.getValue(),V=+R.getValue();return Number.isNaN(p)||Number.isNaN(V)?g.create(h.VALUE):this._getResult(p,V,u)});return l===1&&f===1?_.get(0,0):_}_getResult(e,t,r){const n=r.sort((c,l)=>t?c-l:l-c);let s=n.indexOf(e);const a=[];for(;s>=0;){const c=s+1;a.push(c),s=n.indexOf(e,c)}if(a.length===0)return g.create(h.NA);const u=a.reduce((c,l)=>c+l,0)/a.length;return y.create(u)}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class nA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3);A(this,"needsReferenceObject",!0)}calculate(e,t,r){let n=e;n.isReferenceObject()&&(n=n.toArrayValueObject());const{refHasError:s,refErrorObject:a,refNumbers:u}=this._checkRefReferenceObject(t);let c=r!=null?r:y.create(0);c.isReferenceObject()&&(c=c.toArrayValueObject());const l=Math.max(n.isArray()?n.getRowCount():1,c.isArray()?c.getRowCount():1),f=Math.max(n.isArray()?n.getColumnCount():1,c.isArray()?c.getColumnCount():1),m=O(l,f,n,g.create(h.NA)),d=O(l,f,c,g.create(h.NA)),_=m.map((C,E,b)=>{const R=d.get(E,b);if(!e.isReferenceObject()&&e.isNull())return g.create(h.NA);if(s)return a;if(R.isError())return R;const p=+C.getValue(),V=+R.getValue();if(Number.isNaN(p)||Number.isNaN(V))return g.create(h.VALUE);const D=u.sort((w,P)=>V?w-P:P-w).indexOf(p);return D===-1?g.create(h.NA):y.create(D+1)});return l===1&&f===1?_.get(0,0):_}_checkRefReferenceObject(e){let t=!1,r=g.create(h.NA);const n=[];return e.isReferenceObject()?(e.toArrayValueObject().iterator(a=>{const u=a;if(u.isError())return t=!0,r=u,!1;if(u.isNull()||u.isBoolean())return!0;const c=+u.getValue();if(Number.isNaN(c))return!0;n.push(c)}),{refHasError:t,refErrorObject:r,refNumbers:n}):{refHasError:!0,refErrorObject:r,refNumbers:n}}}class sA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){if(e.length===0)return g.create(h.DIV_BY_ZERO);const r=e.length;let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(l===0||f===0)return g.create(h.DIV_BY_ZERO);const m=(c/Math.sqrt(l*f))**2;return y.create(m)}}class aA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();S.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/(r-1));if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=r/((r-1)*(r-2))*u;return y.create(c)}}class iA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=[];let r=0;for(let n=0;n<e.length;n++){const s=e[n];if(s.isError())return s;if(s.isString()){const c=s.convertToNumberObjectValue();if(c.isError())return c}const a=s.isArray()?s.getRowCount():1,u=s.isArray()?s.getColumnCount():1;for(let c=0;c<a;c++)for(let l=0;l<u;l++){const f=s.isArray()?s.get(c,l):s;if(f.isError())return f;if(f.isNull()||f.isBoolean())continue;const m=f.getValue();S.isRealNum(m)&&(t.push(+m),r+=+m)}}return t.length<=2?g.create(h.DIV_BY_ZERO):this._getResult(t,r)}_getResult(e,t){const r=e.length,n=t/r;let s=0;for(let l=0;l<r;l++)s+=(e[l]-n)**2;const a=Math.sqrt(s/r);if(a===0)return g.create(h.DIV_BY_ZERO);let u=0;for(let l=0;l<r;l++)u+=((e[l]-n)/a)**3;const c=u/r;return y.create(c)}}class oA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if(r*n===1||s*a===1)return u.isNull()||c.isNull()?g.create(h.VALUE):g.create(h.DIV_BY_ZERO);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;let n=0,s=0;for(let m=0;m<r;m++)n+=e[m],s+=t[m];const a=n/r,u=s/r;let c=0,l=0;for(let m=0;m<r;m++)c+=(e[m]-a)*(t[m]-u),l+=(t[m]-u)**2;if(l===0)return g.create(h.DIV_BY_ZERO);const f=c/l;return y.create(f)}}class uA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s;let u=+a.getValue();return u<1||u>e.length?g.create(h.NUM):(u=Math.floor(u),y.create(e[u-1]))}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean()||u.isString())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class cA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=+c.getValue(),d=+l.getValue();if(d<=0)return g.create(h.NUM);const _=(f-m)/d;return y.create(_)}}class lA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std(1)}}class fA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.std()}}class mA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1,s=t.isArray()?t.getRowCount():1,a=t.isArray()?t.getColumnCount():1;let u=e;if(e.isArray()&&r===1&&n===1&&(u=e.get(0,0)),u.isError())return u;let c=t;if(t.isArray()&&s===1&&a===1&&(c=t.get(0,0)),c.isError())return c;if((r*n===1||s*a===1)&&(u.isNull()||c.isNull()))return g.create(h.VALUE);if(r*n!==s*a)return g.create(h.NA);const{isError:l,errorObject:f,array1Values:m,array2Values:d,noCalculate:_}=Ge(e,t,r*n,n,a);return l?f:_?g.create(h.DIV_BY_ZERO):this._getResult(m,d)}_getResult(e,t){const r=e.length;if(r<=2)return g.create(h.DIV_BY_ZERO);let n=0,s=0;for(let d=0;d<r;d++)n+=e[d],s+=t[d];const a=n/r,u=s/r;let c=0,l=0,f=0;for(let d=0;d<r;d++)c+=(e[d]-a)*(t[d]-u),l+=(e[d]-a)**2,f+=(t[d]-u)**2;if(f===0)return g.create(h.DIV_BY_ZERO);const m=Math.sqrt((l-c**2/f)/(r-2));return Number.isNaN(m)||!Number.isFinite(m)?g.create(h.NUM):y.create(m)}}class hA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSignleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSignleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a,f=+u.getValue(),m=Math.floor(+c.getValue()),d=+l.getValue();if(m<1)return g.create(h.NUM);let _;return d?_=Dr(f,m):_=km(f,m),Number.isNaN(_)||!Number.isFinite(_)?g.create(h.NUM):y.create(_)}}class gA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<0||l<1||l>10**10)return g.create(h.NUM);const f=Dr(-c,l)*2;return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class dA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(l<1||l>10**10)return g.create(h.NUM);const f=Dr(-c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class CA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSignleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSignleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s,c=+a.getValue(),l=Math.floor(+u.getValue());if(c<=0||c>1||l<1||l>10**10)return g.create(h.NUM);const f=In(c,l);return Number.isNaN(f)||!Number.isFinite(f)?g.create(h.NUM):y.create(f)}}class _A extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",4)}calculate(e,t,r,n){const{isError:s,errorObject:a}=Fn(e,t,r);if(s)return a;const u=at(e);if(u instanceof g)return u;const c=this._getKnownXsValues(u,t);if(c instanceof g)return c;const l=this._getNewXsValues(c,r);if(l instanceof g)return l;let f=n!=null?n:v.create(!0);if(f.isArray()&&(f=f.get(0,0)),f.isString()&&(f=f.convertToNumberObjectValue()),f.isError())return f;const m=+f.getValue();return this._getResult(u,c,l,m)}_getResult(e,t,r,n){return e.length===1&&t.length>1||e[0].length===1&&t[0].length>1?e.length===1&&t.length>1&&(n?t.length+1:t.length)>e[0].length||e[0].length===1&&t[0].length>1&&(n?t[0].length+1:t[0].length)>e.length?g.create(h.NA):this._getResultByMultipleVariables(e,t,r,n):this._getResultBySimpleVariables(e,t,r,n)}_getResultByMultipleVariables(e,t,r,n){const s=e.length===1&&e[0].length>1,a=Yn(e,t,r,n,!1);if(a instanceof g)return a;const{coefficients:u,newX:c}=a,l=u[0].length,f=u[0][l-1];let m=[];for(let d=0;d<c.length;d++){m[d]=[];let _=f;for(let C=l-2;C>=0;C--)_+=u[0][l-2-C]*c[d][C];m[d].push(_)}return s&&(m=st(m)),q.createByArray(m)}_getResultBySimpleVariables(e,t,r,n){const s=e.flat(),a=t.flat(),{slope:u,intercept:c}=$n(a,s,n,!1);if(Number.isNaN(u))return g.create(h.NA);const l=r.map(f=>f.map(m=>u*m+c));return q.createByArray(l)}_getKnownXsValues(e,t){return!t||t.isNull()?kn(e.length,e[0].length):at(t)}_getNewXsValues(e,t){return!t||t.isNull()?e:at(t)}}class AA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=this._getValues(e);if(t.isArray()){const n=t.mapValue(s=>this._handleSingleObject(r,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(r,t)}_handleSingleObject(e,t){if(e instanceof g)return e;const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=+a.getValue();if(u<0||u>=1)return g.create(h.NUM);const c=ke(e.length*u/2,0)*2,l=e.slice(c/2,e.length-c/2),f=l.reduce((m,d)=>m+d,0)/l.length;return y.create(f)}_getValues(e){const t=e.isArray()?e.getRowCount():1,r=e.isArray()?e.getColumnCount():1,n=[];for(let s=0;s<t;s++)for(let a=0;a<r;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;if(u.isNull()||u.isBoolean())continue;const c=u.getValue();S.isRealNum(c)&&n.push(+c)}return n.length===0?g.create(h.NUM):n.sort((s,a)=>s-a)}}class EA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var(1)}}class bA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){const t=this.flattenArray(e,!1);return t.isError()?t:t.var()}}const yu=[[JC,T.AVEDEV],[t_,T.AVERAGE],[r_,T.AVERAGE_WEIGHTED],[n_,T.AVERAGEA],[s_,T.AVERAGEIF],[a_,T.AVERAGEIFS],[i_,T.BETA_DIST],[yo,T.BETA_INV],[Ro,T.BINOM_DIST],[o_,T.BINOM_DIST_RANGE],[po,T.BINOM_INV],[u_,T.CHISQ_DIST],[No,T.CHISQ_DIST_RT],[c_,T.CHISQ_INV],[Vo,T.CHISQ_INV_RT],[Oo,T.CHISQ_TEST],[Mo,T.CONFIDENCE_NORM],[l_,T.CONFIDENCE_T],[f_,T.CORREL],[m_,T.COUNT],[h_,T.COUNTA],[g_,T.COUNTBLANK],[d_,T.COUNTIF],[C_,T.COUNTIFS],[So,T.COVARIANCE_P],[A_,T.COVARIANCE_S],[E_,T.DEVSQ],[Do,T.EXPON_DIST],[b_,T.F_DIST],[wo,T.F_DIST_RT],[y_,T.F_INV],[Po,T.F_INV_RT],[Lo,T.F_TEST],[R_,T.FISHER],[p_,T.FISHERINV],[si,T.FORECAST],[si,T.FORECAST_LINEAR],[N_,T.FREQUENCY],[V_,T.GAMMA],[xo,T.GAMMA_DIST],[jo,T.GAMMA_INV],[ai,T.GAMMALN],[ai,T.GAMMALN_PRECISE],[O_,T.GAUSS],[M_,T.GEOMEAN],[S_,T.GROWTH],[D_,T.HARMEAN],[w_,T.HYPGEOM_DIST],[P_,T.INTERCEPT],[L_,T.KURT],[x_,T.LARGE],[j_,T.LINEST],[U_,T.LOGEST],[T_,T.LOGNORM_DIST],[Uo,T.LOGNORM_INV],[v_,T.MARGINOFERROR],[B_,T.MAX],[I_,T.MAXA],[F_,T.MAXIFS],[k_,T.MEDIAN],[$_,T.MIN],[Y_,T.MINA],[H_,T.MINIFS],[G_,T.MODE_MULT],[To,T.MODE_SNGL],[W_,T.NEGBINOM_DIST],[vo,T.NORM_DIST],[Bo,T.NORM_INV],[Q_,T.NORM_S_DIST],[Io,T.NORM_S_INV],[q_,T.PEARSON],[K_,T.PERCENTILE_EXC],[Fo,T.PERCENTILE_INC],[X_,T.PERCENTRANK_EXC],[ko,T.PERCENTRANK_INC],[Z_,T.PERMUT],[z_,T.PERMUTATIONA],[J_,T.PHI],[$o,T.POISSON_DIST],[eA,T.PROB],[tA,T.QUARTILE_EXC],[Yo,T.QUARTILE_INC],[rA,T.RANK_AVG],[nA,T.RANK_EQ],[sA,T.RSQ],[aA,T.SKEW],[iA,T.SKEW_P],[oA,T.SLOPE],[uA,T.SMALL],[cA,T.STANDARDIZE],[Ho,T.STDEV_P],[Go,T.STDEV_S],[lA,T.STDEVA],[fA,T.STDEVPA],[mA,T.STEYX],[hA,T.T_DIST],[gA,T.T_DIST_2T],[dA,T.T_DIST_RT],[CA,T.T_INV],[Wo,T.T_INV_2T],[Qo,T.T_TEST],[_A,T.TREND],[AA,T.TRIMMEAN],[qo,T.VAR_P],[Ko,T.VAR_S],[EA,T.VARA],[bA,T.VARPA],[Xo,T.WEIBULL_DIST],[Zo,T.Z_TEST]];class yA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){let r=t!=null?t:y.create(0);if(t!=null&&t.isNull()&&(r=y.create(0)),r.isArray()){const n=r.mapValue(s=>this._handleSingleObject(e,s));return n.getRowCount()===1&&n.getColumnCount()===1?n.get(0,0):n}return this._handleSingleObject(e,r)}_handleSingleObject(e,t){const r=this._checkArray(e);if(r.isError())return r;const{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=+u.getValue(),l=e.isArray()?e.getRowCount():1,f=e.isArray()?e.getColumnCount():1;let m="";for(let d=0;d<l;d++)for(let _=0;_<f;_++){const C=e.isArray()?e.get(d,_):e;let E=`${C.getValue()}`;C.isNull()&&(E=""),C.isBoolean()&&(E=E.toLocaleUpperCase()),C.isString()&&c?m+=`"${E}"`:m+=E,d===l-1&&_===f-1||(c?_===f-1?m+=";":m+=",":m+=", ")}return c&&(m=`{${m}}`),m.length>32767?g.create(h.CALC):U.create(m)}_checkArray(e){if(e.isArray()){const t=e.getRowCount(),r=e.getColumnCount();return t>1||r>1?e:e.get(0,0)}return e}}class RA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const t=e.getValue().toLocaleString();let r="";for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);s===12288?s=32:s>=65281&&s<=65374&&(s-=65248),r+=String.fromCharCode(s)}return U.create(r)}}class pA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=+s.getValue(),u=Math.abs(Number.parseInt(a.toString(),10)),c=Number.parseFloat((Math.abs(a)-u).toFixed(2));let l="";return u===0?c!==0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(c*100)}สตางค์`:l="ศูนย์บาทถ้วน":c===0?l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาทถ้วน`:l=`${a<0?"ลบ":""}${this._convertNumberToThaiText(u)}บาท${this._convertNumberToThaiText(c*100)}สตางค์`,U.create(l)}_convertNumberToThaiText(e){const t=["ล้าน","สิบ","ร้อย","พัน","หมื่น","แสน",""],r=["ศูนย์","หนึ่ง","สอง","สาม","สี่","ห้า","หก","เจ็ด","แปด","เก้า"],n=["ลบ","บาท","ถ้วน","สตางค์","ยี่","เอ็ด",","," ","฿"],s=e.toString(),a=s.length;let u="";for(let c=a;c>0;c--){const l=Number.parseInt(s.charAt(a-c),10);let f=r[l];const m=c>1?(c-1)%6:6;if(m===1&&l===2&&(f=n[4]),l===1)switch(m){case 0:case 6:u+=c<a?n[5]:f;break;case 1:break;default:u+=f;break}else if(l===0){m===0&&(u+=t[m]);continue}else u+=f;u+=t[m]}return u}}const NA=Object.values(S.DataStreamTreeTokenType).filter(i=>[S.DataStreamTreeTokenType.TABLE_START,S.DataStreamTreeTokenType.TABLE_ROW_START,S.DataStreamTreeTokenType.TABLE_CELL_START,S.DataStreamTreeTokenType.TABLE_CELL_END,S.DataStreamTreeTokenType.TABLE_ROW_END,S.DataStreamTreeTokenType.TABLE_END,S.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class VA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<=0)return g.create(h.VALUE);let u=String.fromCharCode(a);return NA.some(c=>c===u)&&(u=""),U.create(u)}}class OA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isBoolean()||e.isNumber())return e;if(e.isNull())return U.create("");const r=`${e.getValue()}`.replace(/[\0-\x1F]/g,"");return U.create(r)}}class MA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();if(e.isBoolean()&&(t=t.toLocaleUpperCase()),t==="")return g.create(h.VALUE);const r=t.charCodeAt(0);return y.create(r)}}class SA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t="",r=null;for(const n of e)if(n.isArray()){if(n.iterator(s=>{if(s==null||s.isNull())return!0;if(s.isError())return r=s,!1;s.isBoolean()?t+=`${s.getValue()}`.toLocaleUpperCase():(s.isString()||s.isNumber())&&(t+=s.getValue())}),r)return r}else!n.isError()&&!n.isNull()&&(t+=n.getValue());return U.create(t)}}class DA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",255)}calculate(...e){let t=0,r=0;e.forEach(s=>{if(s.isArray()){const a=s;t=Math.max(t,a.getRowCount()),r=Math.max(r,a.getColumnCount())}else t=Math.max(t,1),r=Math.max(r,1)});let n=null;for(const s of e)n=O(t,r,s,g.create(h.NA)).mapValue((u,c,l)=>{const f=n&&n.get(c,l);if(f!=null&&f.isError())return f;if(u.isError())return u;let m=f==null?void 0:f.getValue(),d=u==null?void 0:u.getValue();f!=null&&f.isBoolean()&&(m=`${m}`.toLocaleUpperCase()),u!=null&&u.isBoolean()&&(d=`${d}`.toLocaleUpperCase());const _=f!=null&&f.isNull()?"":m!=null?m:"",C=u!=null&&u.isNull()?"":d!=null?d:"";return U.create(`${_}${C}`)});return n||g.create(h.VALUE)}}class wA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return U.create("");let t=`${e.getValue()}`;e.isBoolean()&&(t=t.toLocaleUpperCase());let r="";for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);s>=33&&s<=126?r+=String.fromCharCode(s+65248):s===32?r+=" ":r+=t.charAt(n)}return U.create(r)}}class PA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2);A(this,"needsLocale",!0)}calculate(e,t){let r=t!=null?t:y.create(2);r.isNull()&&(r=y.create(2));const n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(e,t);if(r)return n;const[a,u]=s;let c=+a.getValue(),l=Math.trunc(+u.getValue());if(l>127)return g.create(h.VALUE);l<0&&(`${c}`.length<Math.abs(l)?c=0:c=c<0?-Ot(Math.abs(c),l):Ot(c,l),l=0);const f=Hc(this.getLocale(),c,l);return U.create(f)}}class LA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,ie.create()),a=O(r,n,t,ie.create()),u=s.mapValue((c,l,f)=>{const m=a.get(l,f);return c.isError()?c:m.isError()?m:this._handleSingleObject(c,m)});return r===1&&n===1?u.get(0,0):u}_handleSingleObject(e,t){if(e.isNull()||t.isNull()){const a=e.isNull()&&t.isNull();return v.create(a)}let r=`${e.getValue()}`;e.isBoolean()&&(r=r.toLocaleUpperCase());let n=`${t.getValue()}`;t.isBoolean()&&(n=n.toLocaleUpperCase());const s=r===n;return v.create(s)}}const _a=(i,o)=>S.numfmt.format(i,o,{throws:!1}),Oe=i=>{let o=`${i.getValue()}`;return i.isNull()&&(o=""),i.isBoolean()&&(o=o.toLocaleUpperCase()),i.isNumber()&&(i.getPattern()!==""?o=_a(i.getPattern(),+i.getValue()):o=`${Wi(+i.getValue())}`),o};class xA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,_)=>{const C=c.get(d,_),E=l.get(d,_);return m.isError()?m:C.isError()?C:E.isError()?E:this._handleSingleObject(m,C,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Oe(e),s=Oe(t),{isError:a,errorObject:u,variants:c}=F(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}function Aa(i){let o=0;for(let e=0;e<i.length;e++)o+=xr(i,e);return o}function xr(i,o,e="ltr"){return jA(i,o,e)>255?2:1}function ii(i){return i>=55296&&i<=56319}function oi(i){return i>=56320&&i<=57343}function ui(i,o){const e=(i&1023)<<10,t=o&1023;return e+t+65536}function jA(i,o,e="ltr"){const t=i.charCodeAt(o);if(e==="ltr"&&ii(t)&&o+1<i.length){const r=i.charCodeAt(o+1);if(oi(r))return ui(t,r)}if(e==="rtl"&&oi(t)&&o-1>=0){const r=i.charCodeAt(o-1);if(ii(r))return ui(r,t)}return t}class UA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,_)=>{const C=c.get(d,_),E=l.get(d,_);return m.isError()?m:C.isError()?C:E.isError()?E:this._handleSingleObject(m,C,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Oe(e),s=Oe(t),{isError:a,errorObject:u,variants:c}=F(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=Aa(s.substring(0,m))+1;return y.create(d)}}class TA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){let n=t!=null?t:y.create(2);n.isNull()&&(n=y.create(2));let s=r!=null?r:v.create(!1);s.isNull()&&(s=v.create(!1));const a=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,s.isArray()?s.getRowCount():1),u=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,s.isArray()?s.getColumnCount():1),c=O(a,u,e,g.create(h.NA)),l=O(a,u,n,g.create(h.NA)),f=O(a,u,s,g.create(h.NA)),m=c.mapValue((d,_,C)=>{const E=l.get(_,C),b=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:this._handleSingleObject(d,E,b)});return a===1&&u===1?m.get(0,0):m}_handleSingleObject(e,t,r){const{isError:n,errorObject:s,variants:a}=F(e,t,r);if(n)return s;const[u,c,l]=a;let f=+u.getValue(),m=Math.trunc(+c.getValue());const d=+l.getValue();if(m>127)return g.create(h.VALUE);m<0&&(`${f}`.length<Math.abs(m)?f=0:f=f<0?-Ot(Math.abs(f),m):Ot(f,m),m=0);let _=d?"###0":"#,##0";m>0&&(_+=`.${"0".repeat(m)}`);const C=_a(_,f);return U.create(C)}}class vA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Oe(e),{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return U.create("");if(c>=r.length)return U.create(r);const l=r.substring(0,c);return U.create(l)}}class BA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,ie.create()),u=O(n,s,r,ie.create()),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Oe(e),{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return U.create("");let l=0,f=0,m="";for(;f<c&&l<r.length;)f+=xr(r,l),m+=r.charAt(l),l++;return U.create(m)}}class IA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Oe(e);return y.create(t.length)}}class FA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleText(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleText(e)}_handleSingleText(e){if(e.isError())return e;const t=Oe(e),r=Aa(t);return y.create(r)}}class kA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return U.create("");const t=`${e.getValue()}`.toLocaleLowerCase();return U.create(t)}}class $A extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSingleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){const n=Oe(e),{isError:s,errorObject:a,variants:u}=F(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return U.create("");const d=n.substring(f-1,f-1+m);return U.create(d)}}class YA extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const n=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,t,g.create(h.NA)),c=O(n,s,r,g.create(h.NA)),l=a.mapValue((f,m,d)=>{const _=u.get(m,d),C=c.get(m,d);return f.isError()?f:_.isError()?_:C.isError()?C:this._handleSingleObject(f,_,C)});return n===1&&s===1?l.get(0,0):l}_handleSingleObject(e,t,r){let n=Oe(e);const{isError:s,errorObject:a,variants:u}=F(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);if(e.isNull()||f>n.length||m===0)return U.create("");n=n.substring(f-1);let d=0,_=0,C="";for(;_<m&&d<n.length;)_+=xr(n,d),C+=n.charAt(d),d++;return U.create(C)}}class HA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",3)}calculate(e,t,r){const n=t!=null?t:U.create("."),s=Math.max(e.isArray()?e.getRowCount():1,n.isArray()?n.getRowCount():1,r!=null&&r.isArray()?r.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,n.isArray()?n.getColumnCount():1,r!=null&&r.isArray()?r.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,n,g.create(h.NA)),l=r?O(s,a,r,g.create(h.NA)):void 0,f=u.mapValue((m,d,_)=>{const C=c.get(d,_),E=r?l.get(d,_):void 0;return m.isError()?m:C.isError()?C:E!=null&&E.isError()?E:C.isNull()||E!=null&&E.isNull()?g.create(h.VALUE):m.isNull()?y.create(0):this._handleSingleObject(m,C,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){let n=`${e.getValue()}`;n=n.replace(/\s+/g,"");let s=`${t.getValue()}`;t.isBoolean()&&(s=s.toLocaleUpperCase()),s=s.charAt(0);let a;if(r&&(a=`${r.getValue()}`,r.isBoolean()&&(a=a.toLocaleUpperCase()),a=a.charAt(0),s===a))return g.create(h.VALUE);if(n.trim()==="")return y.create(0);if(!n.match(/^\s*[+-]?\s*(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][+-]?\d+)?[ \t]*/))return g.create(h.VALUE);const u=n.split(s);if(u.length>2)return g.create(h.VALUE);let c=u[0].replace(/,/g,"");r&&(c=c.split(a).join(""));let l=0;if(u.length===1){s===","&&(c=c.replace(/\./g,""));let f=0;for(;c.endsWith("%");)c=c.slice(0,-1),f++;f>0?l=+c/100**f:l=+c}else{if(!S.isRealNum(c))return g.create(h.VALUE);let f=u[1],m=0;for(;f.endsWith("%");)f=f.slice(0,-1),m++;const d=`${c}.${f}`;if(!S.isRealNum(d))return g.create(h.VALUE);m>0?l=+d/100**m:l=+d}return Number.isNaN(l)?g.create(h.VALUE):y.create(l)}}class GA extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError()||e.isNull()||e.isBoolean()||e.isNumber())return e;const r=e.getValue().toLocaleString().toLocaleLowerCase().replace(/(^|\b|\W|\d|_)[a-z]/g,n=>n.toLocaleUpperCase());return U.create(r)}}const Ru=()=>[{type:4,from:48,to:57}],pu=()=>[{type:7,value:95},{type:4,from:97,to:122},{type:4,from:65,to:90},{type:4,from:48,to:57}],Nu=()=>[{type:7,value:9},{type:7,value:10},{type:7,value:11},{type:7,value:12},{type:7,value:13},{type:7,value:32},{type:7,value:160},{type:7,value:5760},{type:4,from:8192,to:8202},{type:7,value:8232},{type:7,value:8233},{type:7,value:8239},{type:7,value:8287},{type:7,value:12288},{type:7,value:65279}],Vu=()=>({type:3,set:pu(),not:!1}),Ou=()=>({type:3,set:pu(),not:!0}),Mu=()=>({type:3,set:Ru(),not:!1}),Su=()=>({type:3,set:Ru(),not:!0}),Du=()=>({type:3,set:Nu(),not:!1}),wu=()=>({type:3,set:Nu(),not:!0}),WA=()=>({type:3,set:[{type:7,value:10},{type:7,value:13},{type:7,value:8232},{type:7,value:8233}],not:!0});function QA(i){const o={type:0,stack:[]};let e=o,t=o.stack;const r=[],n=[];let s=0;const a=f=>{throw new SyntaxError(`Invalid regular expression: /${i}/: Nothing to repeat at column ${f-1}`)},u=KA(i);let c=0,l;for(;c<u.length;)switch(l=u[c++],l){case"\\":if(c===u.length)throw new SyntaxError(`Invalid regular expression: /${i}/: \\ at end of pattern`);switch(l=u[c++],l){case"b":t.push({type:2,value:"b"});break;case"B":t.push({type:2,value:"B"});break;case"w":t.push(Vu());break;case"W":t.push(Ou());break;case"d":t.push(Mu());break;case"D":t.push(Su());break;case"s":t.push(Du());break;case"S":t.push(wu());break;default:if(/\d/.test(l)){for(;/\d/.test(u[c])&&c<u.length;)l+=u[c++];const f=Number.parseInt(l,10);t.push({type:6,value:f}),n.push({reference:{type:6,value:f},stack:t,index:t.length-1})}else t.push({type:7,value:l.charCodeAt(0)})}break;case"^":t.push({type:2,value:"^"});break;case"$":t.push({type:2,value:"$"});break;case"[":{const f=u[c]==="^";f&&c++;const m=qA(u.slice(c),i);c+=m[1],t.push({type:3,set:m[0],not:f});break}case".":t.push(WA());break;case"(":{const f={type:1,stack:[],remember:!0};if(u[c]==="?"){const m=u[c+1];if(c+=2,m==="=")f.followedBy=!0;else if(m==="!")f.notFollowedBy=!0;else if(m!==":")throw new SyntaxError(`Invalid regular expression: /${i}/: Invalid group, character '${m}' after '?' at column ${c-1}`);f.remember=!1}else s+=1;t.push(f),r.push(e),e=f,t=f.stack;break}case")":if(r.length===0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unmatched ) at column ${c-1}`);e=r.pop(),t=e.options?e.options[e.options.length-1]:e.stack;break;case"|":{e.options||(e.options=[e.stack],delete e.stack);const f=[];e.options.push(f),t=f;break}case"{":{const f=/^(\d+)(,(\d+)?)?\}/.exec(u.slice(c));if(f){t.length===0&&a(c);const m=Number.parseInt(f[1],10),d=f[2]?f[3]?Number.parseInt(f[3],10):1/0:m;c+=f[0].length,t.push({type:5,min:m,max:d,value:t.pop()})}else t.push({type:7,value:123});break}case"?":t.length===0&&a(c),t.push({type:5,min:0,max:1,value:t.pop()});break;case"+":t.length===0&&a(c),t.push({type:5,min:1,max:1/0,value:t.pop()});break;case"*":t.length===0&&a(c),t.push({type:5,min:0,max:1/0,value:t.pop()});break;default:t.push({type:7,value:l.charCodeAt(0)})}if(r.length>0)throw new SyntaxError(`Invalid regular expression: /${i}/: Unterminated group`);return XA(n,s),o}function qA(i,o){let e;const t=[],r=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;(e=r.exec(i))!==null;){let n=null;const[,s,a,u,c,l,f,m,d,_,C]=e;if(s||a||u||c||l||f?n=(()=>{let E={type:3,set:[],not:!1};return s?E=Vu():a?E=Mu():u?E=Du():c?E=Ou():l?E=Su():f&&(E=wu()),E})():m&&C?n={type:4,from:(d||_).charCodeAt(0),to:C.charCodeAt(C.length-1)}:e[16]&&(n={type:7,value:e[16].charCodeAt(0)}),!n)return[t,r.lastIndex];t.push(n)}throw new SyntaxError(`Invalid regular expression: /${o}/: Unterminated character class`)}function KA(i){return i.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(o,e,t,r,n,s,a)=>{if(t)return o;let u;e?u=8:r?u=Number.parseInt(r,16):n?u=Number.parseInt(n,16):s?u="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?".indexOf(s):u={0:0,t:9,n:10,v:11,f:12,r:13}[a];const c=String.fromCharCode(u);return/[[\]{}^$.|?*+()]/.test(c)?`\\${c}`:c})}function XA(i,o){for(const e of i.reverse()){const t=e.reference.value;if(o<t){e.reference.type=7;const r=t.toString();if(e.reference.value=Number.parseInt(r,8),!/^[0-7]+$/.test(r)){let n=0;for(;r[n]!=="8"&&r[n]!=="9"&&n<r.length;)n+=1;if(n===0?(e.reference.value=r.charCodeAt(0),n+=1):e.reference.value=Number.parseInt(r.slice(0,n),8),r.length>n){const s=e.stack.splice(e.index+1);for(const a of r.slice(n))e.stack.push({type:7,value:a.charCodeAt(0)});e.stack.push(...s)}}}}}function Ea(i,o){if(!ZA(i))return{isError:!0,regExp:null};try{const e=new RegExp(i,o?"ug":"u");return zA(e)?{isError:!1,regExp:e}:{isError:!0,regExp:null}}catch{return{isError:!0,regExp:null}}}function ZA(i){return!(/\(\?<=.*?\)/g.test(i)&&!/\[.*?(\?<=.*?)\]/g.test(i)||/\(\?<!.*?\)/g.test(i)&&!/\[.*?(\?<!.*?)\]/g.test(i))}function zA(i,o){let t;Object.prototype.toString.call(i)==="[object RegExp]"?t=i.source:i&&typeof i!="string"&&(t=`${i}`);let r;try{r=QA(t)}catch{return!1}let n=0;const s=(a,u)=>{let c=u;if(a.type===5&&(c++,n++,c>1||n>25))return!1;if(a.options){for(const f of a.options)if(!s({stack:f},c))return!1}const l=a.stack||a.value&&a.value.stack;if(!l)return!0;for(const f of l)if(!s(f,c))return!1;return!0};return s(r,0)}class JA extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Mr(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=Ea(l,!1);if(f)return g.create(h.REF);const d=c.match(m);if(d===null)return g.create(h.NA);if(d.length>1){const _=d.slice(1).map(C=>U.create(C));return _.length>1?q.create({calculateValueList:[_],rowCount:1,columnCount:_.length,unitId:this.unitId,sheetId:this.subUnitId,row:this.row,column:this.column}):_[0]}return U.create(d[0])}}class eE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){const{isError:r,errorObject:n,variants:s}=Mr(e,t);if(r)return n;const[a,u]=s;let c=a.getValue();a.isNull()&&(c=""),a.isBoolean()&&(c=c?"TRUE":"FALSE"),c=`${c}`;let l=u.getValue();u.isNull()&&(l=""),u.isBoolean()&&(l=l?"TRUE":"FALSE"),l=`${l}`;const{isError:f,regExp:m}=Ea(l,!1);return f?g.create(h.REF):c.match(m)===null?v.create(!1):v.create(!0)}}class tE extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",3)}calculate(e,t,r){const{isError:n,errorObject:s,variants:a}=Mr(e,t,r);if(n)return s;const[u,c,l]=a;let f=u.getValue();u.isNull()&&(f=""),u.isBoolean()&&(f=f?"TRUE":"FALSE"),f=`${f}`;let m=c.getValue();c.isNull()&&(m=""),c.isBoolean()&&(m=m?"TRUE":"FALSE"),m=`${m}`;let d=l.getValue();l.isNull()&&(d=""),l.isBoolean()&&(d=d?"TRUE":"FALSE"),d=`${d}`;const{isError:_,regExp:C}=Ea(m,!0);if(_)return g.create(h.REF);const E=f.replace(C,d);return U.create(E)}}class rE extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);const d=Oe(e),_=Oe(n),C=d.substring(0,f-1)+_+d.substring(f-1+m);return U.create(C)}}class nE extends N{constructor(){super(...arguments);A(this,"minParams",4);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=O(s,a,n,g.create(h.NA)),m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C),R=f.get(_,C);return d.isError()?d:E.isError()?E:b.isError()?b:R.isError()?R:this._handleSingleObject(d,E,b,R)});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const{isError:s,errorObject:a,variants:u}=F(t,r);if(s)return a;const[c,l]=u,f=Math.floor(+c.getValue()),m=Math.floor(+l.getValue());if(f<=0||m<0)return g.create(h.VALUE);let d=Oe(e);const _=Oe(n);let C=d.substring(0,f-1);d=d.substring(f-1);let E=0,b=0;for(;b<m&&E<d.length;)b+=xr(d,E),E++;return C+=_+d.substring(E),U.create(C)}}class sE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e,g.create(h.NA)),a=O(r,n,t,g.create(h.NA)),u=s.map((c,l,f)=>{let m=a.get(l,f);if(c.isError())return c;let d=c.getValue();if(c.isNull()&&(d=""),c.isBoolean()&&(d=d?"TRUE":"FALSE"),d+="",m.isString()&&(m=m.convertToNumberObjectValue()),m.isError())return m;const _=32767,C=Math.floor(+m.getValue());if(C<0||C>_/d.length)return g.create(h.VALUE);const E=d.repeat(C);return U.create(E)});return r===1&&n===1?u.get(0,0):u}}class aE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Oe(e),{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return U.create("");if(c>=r.length)return U.create(r);const l=r.substring(r.length-c);return U.create(l)}}class iE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(1),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const r=Oe(e),{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;const[u]=a,c=Math.floor(+u.getValue());if(c<0)return g.create(h.VALUE);if(e.isNull()||c===0)return U.create("");let l=r.length-1,f=0,m="";for(;f<c&&l>=0;)f+=xr(r,l,"rtl"),m=r.charAt(l)+m,l--;return U.create(m)}}class oE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,_)=>{const C=c.get(d,_),E=l.get(d,_);return m.isError()?m:C.isError()?C:E.isError()?E:this._handleSingleObject(m,C,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Oe(e).toLocaleUpperCase(),s=Oe(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=F(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);return m===-1?g.create(h.VALUE):y.create(m+1)}}class uE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",3)}calculate(e,t,r){const n=r!=null?r:y.create(1),s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,n,g.create(h.NA)),f=u.mapValue((m,d,_)=>{const C=c.get(d,_),E=l.get(d,_);return m.isError()?m:C.isError()?C:E.isError()?E:this._handleSingleObject(m,C,E)});return s===1&&a===1?f.get(0,0):f}_handleSingleObject(e,t,r){const n=Oe(e).toLocaleUpperCase(),s=Oe(t).toLocaleUpperCase(),{isError:a,errorObject:u,variants:c}=F(r);if(a)return u;const[l]=c,f=Math.floor(+l.getValue());if(t.isNull()||f<=0||f>s.length)return g.create(h.VALUE);if(e.isNull()||n.length===0)return y.create(f);const m=s.indexOf(n,f-1);if(m===-1)return g.create(h.VALUE);const d=Aa(s.substring(0,m))+1;return y.create(d)}}class cE extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",4)}calculate(e,t,r,n){const s=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1,r.isArray()?r.getRowCount():1,n!=null&&n.isArray()?n.getRowCount():1),a=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1,r.isArray()?r.getColumnCount():1,n!=null&&n.isArray()?n.getColumnCount():1),u=O(s,a,e,g.create(h.NA)),c=O(s,a,t,g.create(h.NA)),l=O(s,a,r,g.create(h.NA)),f=n?O(s,a,n,g.create(h.NA)):void 0,m=u.mapValue((d,_,C)=>{const E=c.get(_,C),b=l.get(_,C);let R=n?f.get(_,C):void 0;return d.isError()?d:E.isError()?E:b.isError()?b:R!=null&&R.isError()?R:R!=null&&R.isNull()||R!=null&&R.isBoolean()?g.create(h.VALUE):(R!=null&&R.isString()&&(R=R.convertToNumberObjectValue()),R!=null&&R.isError()?R:this._handleSingleObject(d,E,b,R))});return s===1&&a===1?m.get(0,0):m}_handleSingleObject(e,t,r,n){const s=this._getObjectString(e),a=this._getObjectString(t),u=this._getObjectString(r),c=n?Math.floor(+n.getValue()):void 0;if(n&&c<=0)return g.create(h.VALUE);if(a==="")return U.create(s);let l="",f=0;for(let m=0;m<s.length;m++){const d=s.substr(m,a.length);if(d===a||d.length===a.length&&d.trim()===a.trim()){if(f++,f===c){l=s.substr(0,m)+u+s.substr(m+a.length);break}c===void 0&&(l+=u),m+=a.length-1}else c===void 0&&(l+=s[m])}return c&&f<c&&(l=s),U.create(l)}_getObjectString(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}}class lE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){let t=e;return e.isArray()&&(t=e.get(0,0)),t.isError()?t:t.isNull()||t.isBoolean()||t.isNumber()?U.create(""):t}}class fE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",2)}calculate(e,t){if(e.isError())return e;if(t.isError())return t;const r=Math.max(e.isArray()?e.getRowCount():1,t.isArray()?t.getRowCount():1),n=Math.max(e.isArray()?e.getColumnCount():1,t.isArray()?t.getColumnCount():1),s=O(r,n,e),a=O(r,n,t);return s.map((u,c,l)=>{if(u.isError())return u;let f=a.get(c,l)||U.create(" ");if(f.isError())return f;if(f.isBoolean())return g.create(h.VALUE);if(u.isBoolean())return u;let m=u.getValue();if(u.isNull()&&(m=0),u.isString()){if(!S.isRealNum(m))return u;m=Number(m)}f.isNull()&&(f=U.create(" "));const d=`${f.getValue()}`,_=_a(d,m);return U.create(d===" "?_.trimEnd():_)})}}class mE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),_=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),C=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(_,C,e,g.create(h.NA)),b=O(_,C,c,g.create(h.NA)),R=O(_,C,f,g.create(h.NA)),p=O(_,C,m,g.create(h.NA)),V=O(_,C,d,g.create(h.NA)),M=this._getResultArray(E,t,b,R,p,V,u,l);return _===1&&C===1?M.get(0,0):M}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const _=r.get(m,d),C=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,_,C,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const M=this._getVariantsNumberFloorValue(_,C,E);if(M instanceof g)return M;const[D,w,P]=M;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?U.create(p):U.create(""):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return v.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(C=>C.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let C=0;C<Math.abs(r);C++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),d=E.length,m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?U.create(""):U.create(e):a;const _=e.substr(f+d);return U.create(_)}}class hE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=!1,c=r!=null?r:y.create(1);c.isNull()&&(u=!0,c=y.create(1));const l=!n,f=n!=null?n:y.create(0),m=s!=null?s:y.create(0),d=a!=null?a:g.create(h.NA),_=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,f.isArray()?f.getRowCount():1,m.isArray()?m.getRowCount():1,d.isArray()?d.getRowCount():1),C=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,f.isArray()?f.getColumnCount():1,m.isArray()?m.getColumnCount():1,d.isArray()?d.getColumnCount():1),E=O(_,C,e,g.create(h.NA)),b=O(_,C,c,g.create(h.NA)),R=O(_,C,f,g.create(h.NA)),p=O(_,C,m,g.create(h.NA)),V=O(_,C,d,g.create(h.NA)),M=this._getResultArray(E,t,b,R,p,V,u,l);return _===1&&C===1?M.get(0,0):M}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{const _=r.get(m,d),C=n.get(m,d),E=s.get(m,d),b=a.get(m,d),R=this._checkVariantsError(f,_,C,E);if(R.isError())return R;const p=this._getStringValue(f),V=this._getDelimiterValue(t);if(V instanceof g)return V;const M=this._getVariantsNumberFloorValue(_,C,E);if(M instanceof g)return M;const[D,w,P]=M;return D===0||w<0||w>1||P<0||P>1?g.create(h.VALUE):V.includes("")?D>0?U.create(""):U.create(p):!u&&Math.abs(D)>p.length?g.create(h.VALUE):V.every(L=>L.length>p.length)?g.create(h.NA):this._getResult(p,V,D,w,P,b,c)})}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return v.create(!0)}_getStringValue(e){let t=`${e.getValue()}`;return e.isNull()&&(t=""),e.isBoolean()&&(t=t.toLocaleUpperCase()),t}_getDelimiterValue(e){const t=[];if(e.isArray()){let r=!1,n=g.create(h.VALUE);if(e.iterator(s=>{const a=s;if(a.isError())return r=!0,n=a,!1;t.push(this._getStringValue(a))}),r)return n}else{if(e.isError())return e;t.push(this._getStringValue(e))}return t}_getVariantsNumberFloorValue(...e){const t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.isString()&&(n=n.convertToNumberObjectValue()),n.isError())return n;const s=Math.floor(+n.getValue());t.push(s)}return t}_getResult(e,t,r,n,s,a,u){let c=n?e.toLocaleLowerCase():e;const l=n?t.map(C=>C.toLocaleLowerCase()):t;let f=0,m=0,d=0;for(let C=0;C<Math.abs(r);C++)if(r<0){const E=l.map(b=>({index:c.lastIndexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>R.index-b.index)[0];if(!E)break;f=E.index,c=c.substr(0,E.index),m++}else{const E=l.map(b=>({index:c.indexOf(b),length:b.length})).filter(b=>b.index!==-1).sort((b,R)=>b.index-R.index)[0];if(!E)break;f+=E.index+d,c=c.substr(E.index+E.length),d=E.length,m++}if(m&&m<Math.abs(r)&&u)return g.create(h.NA);if(!m||m<Math.abs(r))return s?r>0?U.create(e):U.create(""):a;const _=e.substr(0,f);return U.create(_)}}class gE extends N{constructor(){super(...arguments);A(this,"minParams",3);A(this,"maxParams",255)}calculate(e,t,...r){const n=this._getDelimiterValues(e),s=this._getTextValues(r);if(t.isArray()){const u=t.mapValue(c=>this._handleSingleObject(n,c,s));return u.getRowCount()===1&&u.getColumnCount()===1?u.get(0,0):u}const a=t;if(a.isString()){const u=`${a.getValue()}`.toLocaleUpperCase();if(u==="TRUE")return this._handleSingleObject(n,v.create(!0),s);if(u==="FALSE")return this._handleSingleObject(n,v.create(!1),s)}return this._handleSingleObject(n,t,s)}_handleSingleObject(e,t,r){if(e instanceof g)return e;const{isError:n,errorObject:s,variants:a}=F(t);if(n)return s;if(r instanceof g)return r;const[u]=a,c=+u.getValue();let l=r;c&&(l=r.filter(m=>m!==null));let f="";for(let m=0;m<l.length;m++)l[m]!==null&&(f+=l[m]),m<l.length-1&&(f+=e[m%e.length]);return U.create(f)}_getDelimiterValues(e){const t=[],r=e.isArray()?e.getRowCount():1,n=e.isArray()?e.getColumnCount():1;for(let s=0;s<r;s++)for(let a=0;a<n;a++){const u=e.isArray()?e.get(s,a):e;if(u.isError())return u;let c=`${u.getValue()}`;u.isNull()&&(c=""),u.isBoolean()&&(c=c.toLocaleUpperCase()),t.push(c)}return t}_getTextValues(e){const t=[];for(const r of e){const n=r.isArray()?r.getRowCount():1,s=r.isArray()?r.getColumnCount():1;for(let a=0;a<n;a++)for(let u=0;u<s;u++){const c=r.isArray()?r.get(a,u):r;if(c.isError())return c;if(c.isNull()){t.push(null);continue}let l=`${c.getValue()}`;c.isBoolean()&&(l=l.toLocaleUpperCase()),t.push(l)}}return t}}class dE extends N{constructor(){super(...arguments);A(this,"minParams",2);A(this,"maxParams",6)}calculate(e,t,r,n,s,a){let u=r!=null?r:U.create("\\s");const c=n!=null?n:y.create(0),l=s!=null?s:y.create(0),f=a!=null?a:U.create(h.NA),{_variant:m,values:d}=this._getStringValues(t),{_variant:_,values:C}=this._getStringValues(u,!1);u=_;const E=Math.max(e.isArray()?e.getRowCount():1,c.isArray()?c.getRowCount():1,l.isArray()?l.getRowCount():1),b=Math.max(e.isArray()?e.getColumnCount():1,c.isArray()?c.getColumnCount():1,l.isArray()?l.getColumnCount():1),R=O(E,b,e,g.create(h.NA)),p=O(E,b,c,g.create(h.NA)),V=O(E,b,l,g.create(h.NA)),M=this._getResultArray(R,m,u,p,V,f,d,C);return E===1&&b===1?M.get(0,0):M.map(D=>D.get(0,0))}_getStringValues(e,t=!0){let r=e;const n=[];if(r.isArray())r.iterator(s=>{if(s!=null&&s.isError())return r=s,!1;if(s!=null&&s.isNull()&&t)return r=g.create(h.VALUE),!1;const a=this._getRegExpStringValue(s);if(a==="")return r=g.create(h.VALUE),!1;n.push(a)});else{r.isNull()&&t&&(r=g.create(h.VALUE));const s=this._getRegExpStringValue(r);s===""&&(r=g.create(h.VALUE)),n.push(s)}return{_variant:r,values:n}}_getResultArray(e,t,r,n,s,a,u,c){return e.map((f,m,d)=>{let _=n.get(m,d),C=s.get(m,d);const E=this._checkVariantsError(f,t,r,_,C);if(E.isError())return E;if(f.isNull())return g.create(h.VALUE);let b=a;if(b.isArray()){const D=b.getRowCount(),w=b.getColumnCount();if(D>1||w>1)return g.create(h.VALUE);b=b.get(0,0)}let R=`${f.getValue()}`;if(f.isBoolean()&&(R=R.toLocaleUpperCase()),_.isString()&&(_=_.convertToNumberObjectValue(),_.isError()))return _;const p=Math.floor(+_.getValue());if(C.isString()&&(C=C.convertToNumberObjectValue(),C.isError()))return C;const V=Math.floor(+C.getValue());if(V<0||V>1)return g.create(h.VALUE);let M=`${b.getValue()}`;return b.isBoolean()&&(M=M.toLocaleUpperCase()),this._getResult(R,u,c,p,V,M)})}_getResult(e,t,r,n,s,a){const u=new RegExp(r.join("|"),`g${s?"i":""}`),c=new RegExp(t.join("|"),`g${s?"i":""}`),l=e.split(u);let f=1,m=l.map(d=>{let _=d.split(c);return n&&(_=_.filter(C=>C!=="")),f=Math.max(f,_.length),_});return m=m.map(d=>{let _=d;return _.length<f&&(_=_.concat(new Array(f-_.length).fill(a))),_}),q.createByArray(m)}_checkVariantsError(...e){for(let t=0;t<e.length;t++){const r=e[t];if(r.isError())return r}return v.create(!0)}_getRegExpStringValue(e){let t=e.getValue();return e.isNull()&&(t="\\s"),e.isBoolean()&&(t=t?"TRUE":"FALSE"),t+="",this._escapeRegExp(t)}_escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}class CE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return U.create("");let t=`${e.getValue()}`;return e.isBoolean()&&(t=t.toLocaleUpperCase()),t=t.trim().replace(/\s+/g," "),U.create(t)}}const _E=Object.values(S.DataStreamTreeTokenType).filter(i=>[S.DataStreamTreeTokenType.TABLE_START,S.DataStreamTreeTokenType.TABLE_ROW_START,S.DataStreamTreeTokenType.TABLE_CELL_START,S.DataStreamTreeTokenType.TABLE_CELL_END,S.DataStreamTreeTokenType.TABLE_ROW_END,S.DataStreamTreeTokenType.TABLE_END,S.DataStreamTreeTokenType.CUSTOM_BLOCK].includes(i));class AE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){const{isError:t,errorObject:r,variants:n}=F(e);if(t)return r;const[s]=n,a=Math.floor(+s.getValue());if(a<1||a>1114111)return g.create(h.VALUE);if(a===1114111||a===1114110)return g.create(h.NA);let u=String.fromCharCode(a);return _E.some(c=>c===u)&&(u=""),U.create(u)}}class EE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return g.create(h.VALUE);let t=e.getValue().toLocaleString();e.isBoolean()&&(t=t.toLocaleUpperCase());const r=t.charCodeAt(0);return y.create(r)}}class bE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isNull())return U.create("");const t=`${e.getValue()}`.toLocaleUpperCase();return U.create(t)}}class yE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;if(e.isBoolean())return g.create(h.VALUE);let t=e;if(e.isString()&&(t=t.convertToNumberObjectValue(),t.isError()))return t;const r=+t.getValue();return y.create(r)}}class RE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",2)}calculate(e,t){const r=t!=null?t:y.create(0),n=Math.max(e.isArray()?e.getRowCount():1,r.isArray()?r.getRowCount():1),s=Math.max(e.isArray()?e.getColumnCount():1,r.isArray()?r.getColumnCount():1),a=O(n,s,e,g.create(h.NA)),u=O(n,s,r,g.create(h.NA)),c=a.mapValue((l,f,m)=>{const d=u.get(f,m);return l.isError()?l:d.isError()?d:this._handleSingleObject(l,d)});return n===1&&s===1?c.get(0,0):c}_handleSingleObject(e,t){const{isError:r,errorObject:n,variants:s}=F(t);if(r)return n;const[a]=s,u=Math.floor(+a.getValue());if(u<0||u>1)return g.create(h.VALUE);if(e.isNull())return U.create("");if(e.isBoolean())return e;if(e.isNumber())return y.create(e.getValue());const c=u?`"${e.getValue()}"`:`${e.getValue()}`;return U.create(c)}}const Pu=[[RA,se.ASC],[yA,se.ARRAYTOTEXT],[pA,se.BAHTTEXT],[VA,se.CHAR],[OA,se.CLEAN],[MA,se.CODE],[SA,se.CONCAT],[DA,se.CONCATENATE],[wA,se.DBCS],[PA,se.DOLLAR],[LA,se.EXACT],[xA,se.FIND],[UA,se.FINDB],[TA,se.FIXED],[vA,se.LEFT],[BA,se.LEFTB],[IA,se.LEN],[FA,se.LENB],[kA,se.LOWER],[$A,se.MID],[YA,se.MIDB],[HA,se.NUMBERVALUE],[JA,se.REGEXEXTRACT],[eE,se.REGEXMATCH],[tE,se.REGEXREPLACE],[GA,se.PROPER],[rE,se.REPLACE],[nE,se.REPLACEB],[sE,se.REPT],[aE,se.RIGHT],[iE,se.RIGHTB],[oE,se.SEARCH],[uE,se.SEARCHB],[cE,se.SUBSTITUTE],[lE,se.T],[fE,se.TEXT],[mE,se.TEXTAFTER],[hE,se.TEXTBEFORE],[gE,se.TEXTJOIN],[dE,se.TEXTSPLIT],[CE,se.TRIM],[AE,se.UNICHAR],[EE,se.UNICODE],[bE,se.UPPER],[yE,se.VALUE],[RE,se.VALUETOTEXT]],Lu=[];var xu=(i=>i)(xu||{});class pE extends N{constructor(){super(...arguments);A(this,"minParams",1);A(this,"maxParams",1)}calculate(e){if(e.isArray()){const t=e.mapValue(r=>this._handleSingleObject(r));return t.getRowCount()===1&&t.getColumnCount()===1?t.get(0,0):t}return this._handleSingleObject(e)}_handleSingleObject(e){if(e.isError())return e;const t=Oe(e),r=encodeURIComponent(t).replace(/[!~'()*]/g,n=>`%${n.charCodeAt(0).toString(16).toLocaleUpperCase()}`);return U.create(r)}}var ba=(i=>(i.ENCODEURL="ENCODEURL",i.FILTERXML="FILTERXML",i.WEBSERVICE="WEBSERVICE",i))(ba||{});const ju=[[pE,ba.ENCODEURL]];var NE=Object.defineProperty,VE=Object.getOwnPropertyDescriptor,OE=(i,o,e,t)=>{for(var r=t>1?void 0:t?VE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&NE(o,e,r),r},Br=(i,o)=>(e,t)=>o(e,t,i);let fn=class extends S.Disposable{constructor(i,o,e,t){super(),this._commandService=i,this._functionService=o,this._configService=e,this._dataSyncPrimaryController=t,this._initialize()}_initialize(){this._registerCommands(),this._registerFunctions()}_registerCommands(){[Bs,Xr,Us,Ts,zr,vs,An,js,En,bn,yn,Rn,Di,wi,Is,pi].forEach(i=>{var o;this._commandService.registerCommand(i),(o=this._dataSyncPrimaryController)==null||o.registerSyncingMutations(i)})}_registerFunctions(){var e;const i=this._configService.getConfig(Nn),o=[...co,...zo,...Jo,...ru,...ou,...uu,...du,...Cu,..._u,...Au,...Eu,...bu,...yu,...Pu,...Lu,...ju].concat((e=i==null?void 0:i.function)!=null?e:[]).map(t=>{const r=t[0],n=t[1];return new r(n)});this._functionService.registerExecutors(...o)}};fn=OE([Br(0,S.ICommandService),Br(1,Ct),Br(2,S.IConfigService),Br(3,S.Optional(Fu.DataSyncPrimaryController))],fn);var ME=Object.defineProperty,SE=Object.getOwnPropertyDescriptor,DE=(i,o,e,t)=>{for(var r=t>1?void 0:t?SE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&ME(o,e,r),r},Ir=(i,o)=>(e,t)=>o(e,t,i);let mn=class extends S.Disposable{constructor(i,o,e){super(),this._commandService=i,this._dependencyManagerService=o,this._featureCalculationManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener(),this._featureCalculationManagerServiceListener()}_featureCalculationManagerServiceListener(){this.disposeWithMe(this._featureCalculationManagerService.onChanged$.subscribe(i=>{const{unitId:o,subUnitId:e,featureIds:t}=i;this._dependencyManagerService.removeFeatureFormulaDependency(o,e,t)}))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._dependencyManagerService.removeFeatureFormulaDependency(t,r,e)}else if(i.id===En.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._dependencyManagerService.removeFeatureFormulaDependency(r,n,[e])}else if(i.id===Rn.id){const o=i.params;if(o==null)return;this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,o.formulaIdList)}else if(i.id===yn.id){const o=i.params;if(o==null)return;const e=o.formulaMap,t=[];Object.keys(e).forEach(r=>{t.push(r)}),this._dependencyManagerService.removeOtherFormulaDependency(o.unitId,o.subUnitId,t)}else if(i.id===Bs.id){const o=i.params.formulaData;Object.keys(o).forEach(e=>{const t=o[e];if(t!==void 0){if(t===null){this._dependencyManagerService.clearFormulaDependency(e);return}Object.keys(t).forEach(r=>{const n=t[r];if(n!==void 0){if(n===null)return this._dependencyManagerService.clearFormulaDependency(e,r),!0;new S.ObjectMatrix(n).forValue((s,a)=>{this._dependencyManagerService.removeFormulaDependency(e,r,s,a)})}})}})}else i.id===An.id&&this._handleSetDefinedName(i)}))}_handleSetDefinedName(i){const o=i.params;if(o==null)return;const{unitId:e,name:t}=o;this._dependencyManagerService.removeFormulaDependencyByDefinedName(e,t)}};mn=DE([Ir(0,S.ICommandService),Ir(1,ar),Ir(1,Or),Ir(2,ar)],mn);var wE=Object.defineProperty,PE=Object.getOwnPropertyDescriptor,LE=(i,o,e,t)=>{for(var r=t>1?void 0:t?PE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&wE(o,e,r),r},ci=(i,o)=>(e,t)=>o(e,t,i);let hn=class extends S.Disposable{constructor(i,o){super(),this._commandService=i,this._featureCalculationManagerService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===En.id){const o=i.params;if(o==null)return;const{featureId:e,calculationParam:t}=o,{unitId:r,subUnitId:n}=t;this._featureCalculationManagerService.register(r,n,e,t)}else if(i.id===bn.id){const o=i.params;if(o==null)return;const{featureIds:e,unitId:t,subUnitId:r}=o;this._featureCalculationManagerService.remove(t,r,e)}}))}};hn=LE([ci(0,S.ICommandService),ci(1,ar)],hn);var xE=Object.defineProperty,jE=Object.getOwnPropertyDescriptor,UE=(i,o,e,t)=>{for(var r=t>1?void 0:t?jE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&xE(o,e,r),r},ss=(i,o)=>(e,t)=>o(e,t,i);let gn=class extends S.Disposable{constructor(i,o,e){super(),this._commandService=i,this._otherFormulaManagerService=o,this._dependencyManagerService=e,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===yn.id){const o=i.params;if(o==null)return;const e={[o.unitId]:{[o.subUnitId]:o.formulaMap}};this._otherFormulaManagerService.batchRegister(e)}else if(i.id===Rn.id){const o=i.params;if(o==null)return;const e={};o.formulaIdList.forEach(r=>e[r]=!0);const t={[o.unitId]:{[o.subUnitId]:e}};this._otherFormulaManagerService.batchRemove(t)}}))}};gn=UE([ss(0,S.ICommandService),ss(1,Un),ss(2,Or)],gn);class Uu extends S.Disposable{constructor(){super(...arguments);A(this,"_tableMap",new Map);A(this,"_tableOptionMap",new Map)}dispose(){this._tableMap.clear(),this._tableOptionMap.clear()}remove(e,t){var r;(r=this._tableMap.get(e))==null||r.delete(t)}getTableMap(e){return this._tableMap.get(e)}getTableOptionMap(){return this._tableOptionMap}registerTable(e,t,r){var n;this._tableMap.get(e)==null&&this._tableMap.set(e,new Map),(n=this._tableMap.get(e))==null||n.set(t,r)}registerTableOptionMap(e,t){this._tableOptionMap.set(e,t)}}const ya=S.createIdentifier("univer.formula.super-table.service");var TE=Object.defineProperty,vE=Object.getOwnPropertyDescriptor,BE=(i,o,e,t)=>{for(var r=t>1?void 0:t?vE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&TE(o,e,r),r},li=(i,o)=>(e,t)=>o(e,t,i);let dn=class extends S.Disposable{constructor(i,o){super(),this._commandService=i,this._superTableService=o,this._initialize()}_initialize(){this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===An.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t,reference:r}=o;this._superTableService.registerTable(e,t,r)}else if(i.id===js.id){const o=i.params;if(o==null)return;const{unitId:e,tableName:t}=o;this._superTableService.remove(e,t)}else if(i.id===Is.id){const o=i.params;if(o==null)return;const{tableOption:e,tableOptionType:t}=o;this._superTableService.registerTableOptionMap(e,t)}}))}};dn=BE([li(0,S.ICommandService),li(1,ya)],dn);class Tu extends S.Disposable{constructor(){super(...arguments);A(this,"_dirtyConversionMap",new Map)}dispose(){this._dirtyConversionMap.clear()}remove(e){this._dirtyConversionMap.delete(e)}get(e){return this._dirtyConversionMap.get(e)}has(e){return this._dirtyConversionMap.has(e)}register(e,t){this._dirtyConversionMap.set(e,t)}getDirtyConversionMap(){return this._dirtyConversionMap}}const vu=S.createIdentifier("univer.formula.active-dirty-manager.service");var IE=Object.defineProperty,FE=Object.getOwnPropertyDescriptor,kE=(i,o,e,t)=>{for(var r=t>1?void 0:t?FE(o,e):o,n=i.length-1,s;n>=0;n--)(s=i[n])&&(r=(t?s(o,e,r):s(r))||r);return t&&r&&IE(o,e,r),r},fi=(i,o)=>(e,t)=>o(e,t,i);const $E="UNIVER_ENGINE_FORMULA_PLUGIN";var as;exports.UniverFormulaEnginePlugin=(as=class extends S.Plugin{constructor(o=ja,e,t){super(),this._config=o,this._injector=e,this._configService=t;const{...r}=S.merge({},ja,this._config);this._configService.setConfig(Nn,r)}onStarting(){this._initialize(),this._initializeWithOverride()}onReady(){var o;S.touchDependencies(this._injector,[[fn],[dn]]),(o=this._config)!=null&&o.notExecuteFormula||S.touchDependencies(this._injector,[[gn],[hn],[mn],[exports.CalculateController]])}onRendered(){var o;(o=this._config)!=null&&o.notExecuteFormula||S.touchDependencies(this._injector,[[on],[an]])}_initialize(){var e;const o=[[Ct,{useClass:Xi}],[Xt,{useClass:exports.DefinedNamesService}],[vu,{useClass:Tu}],[ya,{useClass:Uu}],[exports.FormulaDataModel],[pn],[fn],[dn]];(e=this._config)!=null&&e.notExecuteFormula||o.push([Un,{useClass:so}],[ut,{useClass:exports.FormulaRuntimeService}],[gt,{useClass:exports.FormulaCurrentConfigService}],[ar,{useClass:no}],[exports.CalculateController],[gn],[mn],[hn],[exports.Interpreter],[exports.AstTreeBuilder],[exports.Lexer],[qs],[exports.FunctionNodeFactory],[exports.LambdaNodeFactory],[Xs],[exports.OperatorNodeFactory],[exports.PrefixNodeFactory],[exports.ReferenceNodeFactory],[exports.SuffixNodeFactory],[exports.UnionNodeFactory],[Zs]),o.forEach(t=>this._injector.add(t))}_initializeWithOverride(){var o;(o=this._config)!=null&&o.notExecuteFormula||[[on,{useClass:exports.CalculateFormulaService}],[Or,{useClass:ro}],[an,{useClass:exports.FormulaDependencyGenerator}]].forEach(t=>this._injector.add(t))}},A(as,"pluginName",$E),as);exports.UniverFormulaEnginePlugin=kE([fi(1,S.Inject(S.Injector)),fi(2,S.IConfigService)],exports.UniverFormulaEnginePlugin);exports.ActiveDirtyManagerService=Tu;exports.ArrayValueObject=q;exports.AstRootNodeFactory=qs;exports.AsyncArrayObject=Ki;exports.AsyncCustomFunction=Zm;exports.AsyncObject=qi;exports.BaseFunction=N;exports.BaseReferenceObject=pr;exports.BaseValueObject=dt;exports.BooleanValue=Mt;exports.BooleanValueObject=v;exports.CustomFunction=tu;exports.DEFAULT_INTERVAL_COUNT=oo;exports.DependencyManagerBaseService=to;exports.DependencyManagerService=ro;exports.ENGINE_FORMULA_CYCLE_REFERENCE_COUNT=wc;exports.ENGINE_FORMULA_PLUGIN_CONFIG_KEY=Nn;exports.ERROR_TYPE_SET=Kt;exports.ErrorType=h;exports.ErrorValueObject=g;exports.FUNCTION_NAMES_ARRAY=un;exports.FUNCTION_NAMES_COMPATIBILITY=fe;exports.FUNCTION_NAMES_CUBE=eu;exports.FUNCTION_NAMES_DATABASE=ve;exports.FUNCTION_NAMES_DATE=Ae;exports.FUNCTION_NAMES_ENGINEERING=Z;exports.FUNCTION_NAMES_FINANCIAL=J;exports.FUNCTION_NAMES_INFORMATION=pe;exports.FUNCTION_NAMES_LOGICAL=Ve;exports.FUNCTION_NAMES_LOOKUP=me;exports.FUNCTION_NAMES_MATH=H;exports.FUNCTION_NAMES_STATISTICAL=T;exports.FUNCTION_NAMES_TEXT=se;exports.FUNCTION_NAMES_UNIVER=xu;exports.FUNCTION_NAMES_WEB=ba;exports.FeatureCalculationManagerService=no;exports.FormulaDependencyTree=Gr;exports.FormulaDependencyTreeType=sn;exports.FormulaDependencyTreeVirtual=Ms;exports.FormulaExecuteStageType=ze;exports.FormulaExecutedStateType=Jt;exports.FunctionService=Xi;exports.FunctionType=hi;exports.IActiveDirtyManagerService=vu;exports.ICalculateFormulaService=on;exports.IDefinedNamesService=Xt;exports.IDependencyManagerService=Or;exports.IFeatureCalculationManagerService=ar;exports.IFormulaCurrentConfigService=gt;exports.IFormulaDependencyGenerator=an;exports.IFormulaRuntimeService=ut;exports.IFunctionService=Ct;exports.IOtherFormulaManagerService=Un;exports.ISuperTableService=ya;exports.LambdaParameterNodeFactory=Xs;exports.LambdaValueObjectObject=jn;exports.LexerNode=ae;exports.LexerTreeBuilder=pn;exports.NullValueObject=ie;exports.NumberValueObject=y;exports.OtherFormulaManagerService=so;exports.RangeReferenceObject=Er;exports.RegisterFunctionMutation=pi;exports.RemoveDefinedNameMutation=js;exports.RemoveFeatureCalculationMutation=bn;exports.RemoveOtherFormulaMutation=Rn;exports.RemoveSuperTableMutation=wi;exports.SetArrayFormulaDataMutation=Xr;exports.SetDefinedNameMutation=An;exports.SetDefinedNameMutationFactory=Ac;exports.SetFeatureCalculationMutation=En;exports.SetFormulaCalculationNotificationMutation=zr;exports.SetFormulaCalculationResultMutation=vs;exports.SetFormulaCalculationStartMutation=Us;exports.SetFormulaCalculationStopMutation=Ts;exports.SetFormulaDataMutation=Bs;exports.SetOtherFormulaMutation=yn;exports.SetSuperTableMutation=Di;exports.SetSuperTableOptionMutation=Is;exports.StringValueObject=U;exports.SuperTableService=Uu;exports.ValueNodeFactory=Zs;exports.ValueObjectFactory=ot;exports.compareToken=Y;exports.convertUnitDataToRuntime=Ci;exports.deserializeRangeForR1C1=uo;exports.deserializeRangeWithSheet=Cr;exports.deserializeRangeWithSheetWithCache=Ht;exports.functionArray=co;exports.functionCompatibility=zo;exports.functionCube=Jo;exports.functionDatabase=ru;exports.functionDate=ou;exports.functionEngineering=uu;exports.functionFinancial=du;exports.functionInformation=Cu;exports.functionLogical=_u;exports.functionLookup=Au;exports.functionMath=Eu;exports.functionMeta=bu;exports.functionStatistical=yu;exports.functionText=Pu;exports.functionUniver=Lu;exports.functionWeb=ju;exports.generateAstNode=Os;exports.generateRandomDependencyTreeId=Tt;exports.generateStringWithSequence=ls;exports.getAbsoluteRefTypeWitString=uc;exports.getAbsoluteRefTypeWithSingleString=gr;exports.getRangeWithRefsString=lc;exports.handleNumfmtInCell=Ic;exports.handleRefStringInfo=_n;exports.includeFormulaLexerToken=di;exports.initSheetFormulaData=fs;exports.isFormulaLexerToken=hr;exports.isInDirtyRange=mi;exports.isReferenceString=Ri;exports.isReferenceStringWithEffectiveColumn=dr;exports.isReferenceStrings=Mi;exports.matchRefDrawToken=Hu;exports.matchToken=K;exports.normalizeSheetName=Yu;exports.operatorToken=X;exports.sequenceNodeType=Te;exports.serializeRange=Yt;exports.serializeRangeToRefString=Zr;exports.serializeRangeWithSheet=Ni;exports.serializeRangeWithSpreadsheet=Vi;exports.singleReferenceToGrid=kr;exports.strip=Rs;exports.stripErrorMargin=Wi;